From c9dfd2b5b9ed9440353df7f273cb357acc4f0285 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 22 Feb 2017 13:17:11 +0300
Subject: [PATCH 01/13] Initial working version
---
BuildServer/.gitignore | 1 +
BuildServer/{app.js => app.ts} | 28 +++++++++----------
...old-reports.js => compress-old-reports.ts} | 0
BuildServer/lib/{builder.js => builder.ts} | 26 ++++++++---------
.../lib/{commenter.js => commenter.ts} | 10 +++----
BuildServer/lib/git/{copy.js => copy.ts} | 14 +++++-----
BuildServer/lib/git/{loader.js => loader.ts} | 8 +++---
BuildServer/lib/mail-sender.js | 3 --
BuildServer/lib/mail-sender.ts | 3 ++
...eport-processor.js => report-processor.ts} | 24 +++++++---------
...tatus-processor.js => status-processor.ts} | 10 +++----
.../{task-processor.js => task-processor.ts} | 10 ++-----
...netbuild.js => cleanupafterdotnetbuild.ts} | 4 +--
.../tasks/{conditional.js => conditional.ts} | 2 +-
BuildServer/lib/tasks/{copy.js => copy.ts} | 6 ++--
.../lib/tasks/{copyglob.js => copyglob.ts} | 4 +--
.../lib/tasks/{cssnano.js => cssnano.ts} | 8 +++---
.../tasks/{cssnanoall.js => cssnanoall.ts} | 4 +--
.../{deletefromcode.js => deletefromcode.ts} | 6 ++--
.../tasks/{dotnetbuild.js => dotnetbuild.ts} | 4 +--
...tbuildandtest.js => dotnetbuildandtest.ts} | 4 +--
...lderwrapper.js => dotnetbuilderwrapper.ts} | 10 +++----
...leanup.js => dotnetbuildwithoutcleanup.ts} | 4 +--
...otnetcheckstyle.js => dotnetcheckstyle.ts} | 10 +++----
.../{dotnetcompile.js => dotnetcompile.ts} | 10 +++----
BuildServer/lib/tasks/dotnetnugetpack.js | 11 --------
BuildServer/lib/tasks/dotnetnugetpack.ts | 11 ++++++++
...tnugetprocess.js => dotnetnugetprocess.ts} | 4 +--
...ernal.js => dotnetnugetprocessinternal.ts} | 6 ++--
BuildServer/lib/tasks/dotnetnugetpush.js | 11 --------
BuildServer/lib/tasks/dotnetnugetpush.ts | 11 ++++++++
...ugetpushonly.js => dotnetnugetpushonly.ts} | 8 +++---
...tnugetrestore.js => dotnetnugetrestore.ts} | 6 ++--
BuildServer/lib/tasks/dotnetnunit.js | 9 ------
BuildServer/lib/tasks/dotnetnunit.ts | 9 ++++++
.../{dotnetnunitall.js => dotnetnunitall.ts} | 4 +--
...otnetpackwebapp.js => dotnetpackwebapp.ts} | 11 ++++----
.../{dotnetrewrite.js => dotnetrewrite.ts} | 12 ++++----
BuildServer/lib/tasks/{echo.js => echo.ts} | 2 +-
.../{eslintbrowser.js => eslintbrowser.ts} | 8 +++---
...slintbrowserall.js => eslintbrowserall.ts} | 4 +--
BuildServer/lib/tasks/{index.js => index.ts} | 10 +++++--
BuildServer/lib/tasks/noop.js | 3 --
BuildServer/lib/tasks/noop.ts | 3 ++
.../lib/tasks/{packform.js => packform.ts} | 4 +--
BuildServer/lib/tasks/parallel.js | 7 -----
BuildServer/lib/tasks/parallel.ts | 7 +++++
BuildServer/lib/tasks/sequential.js | 7 -----
BuildServer/lib/tasks/sequential.ts | 7 +++++
.../lib/tasks/{uglifyjs.js => uglifyjs.ts} | 8 +++---
.../tasks/{uglifyjsall.js => uglifyjsall.ts} | 4 +--
.../lib/tasks/{writefile.js => writefile.ts} | 6 ++--
BuildServer/lib/tasks/{zip.js => zip.ts} | 8 +++---
BuildServer/package.json | 9 +++---
.../routes/{artifact.js => artifact.ts} | 2 +-
BuildServer/routes/index.js | 9 ------
BuildServer/routes/index.ts | 12 ++++++++
BuildServer/routes/{manual.js => manual.ts} | 10 +++----
.../routes/{postreceive.js => postreceive.ts} | 6 ++--
BuildServer/routes/{release.js => release.ts} | 8 +++---
BuildServer/routes/{status.js => status.ts} | 14 +++++-----
...ettings.js.example => settings.ts.example} | 5 +++-
BuildServer/tsconfig.json | 8 ++++++
63 files changed, 253 insertions(+), 244 deletions(-)
rename BuildServer/{app.js => app.ts} (70%)
rename BuildServer/{compress-old-reports.js => compress-old-reports.ts} (100%)
rename BuildServer/lib/{builder.js => builder.ts} (93%)
rename BuildServer/lib/{commenter.js => commenter.ts} (96%)
rename BuildServer/lib/git/{copy.js => copy.ts} (87%)
rename BuildServer/lib/git/{loader.js => loader.ts} (92%)
delete mode 100644 BuildServer/lib/mail-sender.js
create mode 100644 BuildServer/lib/mail-sender.ts
rename BuildServer/lib/{report-processor.js => report-processor.ts} (90%)
rename BuildServer/lib/{status-processor.js => status-processor.ts} (89%)
rename BuildServer/lib/{task-processor.js => task-processor.ts} (94%)
rename BuildServer/lib/tasks/{cleanupafterdotnetbuild.js => cleanupafterdotnetbuild.ts} (90%)
rename BuildServer/lib/tasks/{conditional.js => conditional.ts} (90%)
rename BuildServer/lib/tasks/{copy.js => copy.ts} (84%)
rename BuildServer/lib/tasks/{copyglob.js => copyglob.ts} (90%)
rename BuildServer/lib/tasks/{cssnano.js => cssnano.ts} (89%)
rename BuildServer/lib/tasks/{cssnanoall.js => cssnanoall.ts} (93%)
rename BuildServer/lib/tasks/{deletefromcode.js => deletefromcode.ts} (81%)
rename BuildServer/lib/tasks/{dotnetbuild.js => dotnetbuild.ts} (73%)
rename BuildServer/lib/tasks/{dotnetbuildandtest.js => dotnetbuildandtest.ts} (79%)
rename BuildServer/lib/tasks/{dotnetbuilderwrapper.js => dotnetbuilderwrapper.ts} (91%)
rename BuildServer/lib/tasks/{dotnetbuildwithoutcleanup.js => dotnetbuildwithoutcleanup.ts} (91%)
rename BuildServer/lib/tasks/{dotnetcheckstyle.js => dotnetcheckstyle.ts} (93%)
rename BuildServer/lib/tasks/{dotnetcompile.js => dotnetcompile.ts} (82%)
delete mode 100644 BuildServer/lib/tasks/dotnetnugetpack.js
create mode 100644 BuildServer/lib/tasks/dotnetnugetpack.ts
rename BuildServer/lib/tasks/{dotnetnugetprocess.js => dotnetnugetprocess.ts} (88%)
rename BuildServer/lib/tasks/{dotnetnugetprocessinternal.js => dotnetnugetprocessinternal.ts} (91%)
delete mode 100644 BuildServer/lib/tasks/dotnetnugetpush.js
create mode 100644 BuildServer/lib/tasks/dotnetnugetpush.ts
rename BuildServer/lib/tasks/{dotnetnugetpushonly.js => dotnetnugetpushonly.ts} (50%)
rename BuildServer/lib/tasks/{dotnetnugetrestore.js => dotnetnugetrestore.ts} (73%)
delete mode 100644 BuildServer/lib/tasks/dotnetnunit.js
create mode 100644 BuildServer/lib/tasks/dotnetnunit.ts
rename BuildServer/lib/tasks/{dotnetnunitall.js => dotnetnunitall.ts} (94%)
rename BuildServer/lib/tasks/{dotnetpackwebapp.js => dotnetpackwebapp.ts} (89%)
rename BuildServer/lib/tasks/{dotnetrewrite.js => dotnetrewrite.ts} (91%)
rename BuildServer/lib/tasks/{echo.js => echo.ts} (88%)
rename BuildServer/lib/tasks/{eslintbrowser.js => eslintbrowser.ts} (83%)
rename BuildServer/lib/tasks/{eslintbrowserall.js => eslintbrowserall.ts} (93%)
rename BuildServer/lib/tasks/{index.js => index.ts} (54%)
delete mode 100644 BuildServer/lib/tasks/noop.js
create mode 100644 BuildServer/lib/tasks/noop.ts
rename BuildServer/lib/tasks/{packform.js => packform.ts} (86%)
delete mode 100644 BuildServer/lib/tasks/parallel.js
create mode 100644 BuildServer/lib/tasks/parallel.ts
delete mode 100644 BuildServer/lib/tasks/sequential.js
create mode 100644 BuildServer/lib/tasks/sequential.ts
rename BuildServer/lib/tasks/{uglifyjs.js => uglifyjs.ts} (80%)
rename BuildServer/lib/tasks/{uglifyjsall.js => uglifyjsall.ts} (93%)
rename BuildServer/lib/tasks/{writefile.js => writefile.ts} (82%)
rename BuildServer/lib/tasks/{zip.js => zip.ts} (84%)
rename BuildServer/routes/{artifact.js => artifact.ts} (93%)
delete mode 100644 BuildServer/routes/index.js
create mode 100644 BuildServer/routes/index.ts
rename BuildServer/routes/{manual.js => manual.ts} (70%)
rename BuildServer/routes/{postreceive.js => postreceive.ts} (96%)
rename BuildServer/routes/{release.js => release.ts} (89%)
rename BuildServer/routes/{status.js => status.ts} (88%)
rename BuildServer/{settings.js.example => settings.ts.example} (92%)
create mode 100644 BuildServer/tsconfig.json
diff --git a/BuildServer/.gitignore b/BuildServer/.gitignore
index 51f33d8..285b65b 100644
--- a/BuildServer/.gitignore
+++ b/BuildServer/.gitignore
@@ -17,5 +17,6 @@ node_modules
data
*.crt
settings.js
+settings.ts
iisnode
diff --git a/BuildServer/app.js b/BuildServer/app.ts
similarity index 70%
rename from BuildServer/app.js
rename to BuildServer/app.ts
index cc65956..b6eb90d 100644
--- a/BuildServer/app.js
+++ b/BuildServer/app.ts
@@ -1,26 +1,26 @@
"use strict";
-const realFs = require("fs");
-const fs = require("graceful-fs");
+import realFs = require("fs");
+import fs = require("graceful-fs");
fs.gracefulify(realFs);
-const express = require("express");
-const routes = require("./routes");
-const http = require("http");
-const path = require("path");
-const serveFavicon = require("serve-favicon");
-const morgan = require("morgan");
-const bodyParser = require("body-parser");
-const methodOverride = require("method-override");
-const serveStatic = require("serve-static");
-const errorhandler = require("errorhandler");
+import express = require("express");
+import routes = require("./routes");
+import http = require("http");
+import path = require("path");
+import serveFavicon = require("serve-favicon");
+import morgan = require("morgan");
+import bodyParser = require("body-parser");
+import methodOverride = require("method-override");
+import serveStatic = require("serve-static");
+import errorhandler = require("errorhandler");
-const settings = require("./settings");
+import settings = require("./settings");
const app = express();
-app.set("port", process.env.PORT || settings.port); // eslint-disable-line no-process-env
+app.set("port", settings.port); // eslint-disable-line no-process-env
app.set("views", path.join(__dirname, "views"));
app.set("view engine", "jade");
app.set("gitpath", settings.gitpath);
diff --git a/BuildServer/compress-old-reports.js b/BuildServer/compress-old-reports.ts
similarity index 100%
rename from BuildServer/compress-old-reports.js
rename to BuildServer/compress-old-reports.ts
diff --git a/BuildServer/lib/builder.js b/BuildServer/lib/builder.ts
similarity index 93%
rename from BuildServer/lib/builder.js
rename to BuildServer/lib/builder.ts
index 120bd78..e1cdcf4 100644
--- a/BuildServer/lib/builder.js
+++ b/BuildServer/lib/builder.ts
@@ -1,14 +1,14 @@
"use strict";
-const path = require("path");
-const fs = require("fs");
-const fse = require("fs-extra");
-const async = require("async");
-const gitLoader = require("./git/loader");
-const processor = require("./task-processor");
-const reportProcessor = require("./report-processor");
-const mailSender = require("./mail-sender");
-const settings = require("../settings");
+import path = require("path");
+import fs = require("fs");
+import fse = require("fs-extra");
+import async = require("async");
+import gitLoader = require("./git/loader");
+import processor = require("./task-processor");
+import reportProcessor = require("./report-processor");
+import mailSender = require("./mail-sender");
+import settings = require("../settings");
const codePostfix = "";
const mailLazinessLevel = 1000;
@@ -62,7 +62,7 @@ const wrapGitLoader = (skipGitLoader) => {
return (gitLoaderOptions, gitLoaderCallback) => process.nextTick(gitLoaderCallback);
};
-const safeParseJson = (data) => {
+const safeParseJson = (data):any => {
try {
return { "parsed": JSON.parse(data) };
} catch (err) {
@@ -70,7 +70,7 @@ const safeParseJson = (data) => {
}
};
-const build = (options, buildCallback) => {
+export const build = (options, buildCallback) => {
const url = options.url;
const owner = options.owner;
const reponame = options.reponame;
@@ -121,7 +121,7 @@ const build = (options, buildCallback) => {
return result.messages.$allMessages.map((msg) => `${msg.prefix}\t${msg.message}`).join("\r\n");
};
- const done = (doneErr, result) => {
+ const done = (doneErr, result?) => {
const allErrors = ((result || {}).errors || {}).$allMessages || [];
const allWarns = ((result || {}).warns || {}).$allMessages || [];
const allInfos = ((result || {}).infos || {}).$allMessages || [];
@@ -215,5 +215,3 @@ const build = (options, buildCallback) => {
});
});
};
-
-exports.build = build;
diff --git a/BuildServer/lib/commenter.js b/BuildServer/lib/commenter.ts
similarity index 96%
rename from BuildServer/lib/commenter.js
rename to BuildServer/lib/commenter.ts
index 90a9483..6b7385a 100644
--- a/BuildServer/lib/commenter.js
+++ b/BuildServer/lib/commenter.ts
@@ -1,8 +1,8 @@
"use strict";
-const _ = require("underscore");
-const reportProcessor = require("./report-processor");
-const settings = require("../settings");
+import _ = require("underscore");
+import reportProcessor = require("./report-processor");
+import settings = require("../settings");
const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/;
const versionNamePattern = /^v\d+(\.\d+)*$/;
@@ -136,9 +136,9 @@ const checkPullRequest = (options, callback) => {
});
};
-exports.commentOnPullRequest = (originalOptions, callback) => {
+export const commentOnPullRequest = (originalOptions, callback) => {
const optionsGithub = _.extend(originalOptions, { "github": settings.createGithub(originalOptions.baseRepoOptions.owner) });
- const options = _.extend(optionsGithub, { "onTenthAttempt": () => writeComment(optionsGithub, "Waiting for build to finish...") });
+ const options = _.extend(optionsGithub, { "onTenthAttempt": () => writeComment(optionsGithub, "Waiting for build to finish...", () => {}) });
return checkPullRequest(options, () => reportProcessor.getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => {
const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength)
diff --git a/BuildServer/lib/git/copy.js b/BuildServer/lib/git/copy.ts
similarity index 87%
rename from BuildServer/lib/git/copy.js
rename to BuildServer/lib/git/copy.ts
index 27fafe3..fd1d0fa 100644
--- a/BuildServer/lib/git/copy.js
+++ b/BuildServer/lib/git/copy.ts
@@ -1,12 +1,12 @@
"use strict";
-const EventEmitter = require("events").EventEmitter; // eslint-disable-line fp/no-events
-const path = require("path");
-const fs = require("fs");
-const async = require("async");
-const Copier = require("recursive-tree-copy").Copier;
+import { EventEmitter } from "events"; // eslint-disable-line fp/no-events
+import path = require("path");
+import fs = require("fs");
+import async = require("async");
+import { Copier } from "recursive-tree-copy";
-const safeGetEntries = (tree) => {
+const safeGetEntries = (tree):any => {
try {
return { "entries": tree.gitTree.entries() };
} catch (err) {
@@ -86,7 +86,7 @@ const gitToFsCopier = new Copier({
}
});
-exports.gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => {
+export const gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => {
if (err) {
return callback(err);
}
diff --git a/BuildServer/lib/git/loader.js b/BuildServer/lib/git/loader.ts
similarity index 92%
rename from BuildServer/lib/git/loader.js
rename to BuildServer/lib/git/loader.ts
index 1cdea6a..68dc97a 100644
--- a/BuildServer/lib/git/loader.js
+++ b/BuildServer/lib/git/loader.ts
@@ -1,8 +1,8 @@
"use strict";
-const nodegit = require("nodegit");
-const fse = require("fs-extra");
-const gitToFs = require("./copy").gitToFs;
+import nodegit = require("nodegit");
+import fse = require("fs-extra");
+import { gitToFs } from "./copy";
const mkdirs = (path) => {
fse.mkdirsSync(path); // eslint-disable-line no-sync
@@ -30,7 +30,7 @@ options = {
}
*/
-module.exports = (options, globalCallback) => {
+export = (options, globalCallback) => {
const url = fixUrl(options.remote);
const path = `${options.local}/${options.hash}`;
const exported = options.exported;
diff --git a/BuildServer/lib/mail-sender.js b/BuildServer/lib/mail-sender.js
deleted file mode 100644
index 7b46146..0000000
--- a/BuildServer/lib/mail-sender.js
+++ /dev/null
@@ -1,3 +0,0 @@
-"use strict";
-
-exports.send = (message, callback) => process.nextTick(callback);
diff --git a/BuildServer/lib/mail-sender.ts b/BuildServer/lib/mail-sender.ts
new file mode 100644
index 0000000..2249d0d
--- /dev/null
+++ b/BuildServer/lib/mail-sender.ts
@@ -0,0 +1,3 @@
+"use strict";
+
+export const send = (message, callback) => process.nextTick(callback);
diff --git a/BuildServer/lib/report-processor.js b/BuildServer/lib/report-processor.ts
similarity index 90%
rename from BuildServer/lib/report-processor.js
rename to BuildServer/lib/report-processor.ts
index 5152713..07691db 100644
--- a/BuildServer/lib/report-processor.js
+++ b/BuildServer/lib/report-processor.ts
@@ -1,11 +1,11 @@
"use strict";
-const path = require("path");
-const fs = require("fs");
-const zlib = require("zlib");
-const glob = require("glob");
-const streamBuffers = require("stream-buffers");
-const _ = require("underscore");
+import path = require("path");
+import fs = require("fs");
+import zlib = require("zlib");
+import glob = require("glob");
+import streamBuffers = require("stream-buffers");
+import _ = require("underscore");
const reportFilename = "report.json.gz";
const maxAttemptsNumber = 100;
@@ -23,7 +23,7 @@ const getAllErrors = (report) => ((report.result || {}).errors || {}).$allMessag
const getAllWarns = (report) => ((report.result || {}).warns || {}).$allMessages || [];
const getAllInfos = (report) => ((report.result || {}).infos || {}).$allMessages || [];
-const writeReport = (releaseDir, err, result, callback) => {
+export const writeReport = (releaseDir, err, result, callback) => {
const data = JSON.stringify({
"date": Date.now(),
err,
@@ -48,7 +48,7 @@ const writeReport = (releaseDir, err, result, callback) => {
readable.stop();
};
-const readReport = (releaseDir, callback) => {
+export const readReport = (releaseDir, callback) => {
const readStream = fs.createReadStream(path.join(releaseDir, reportFilename));
const writable = new streamBuffers.WritableStreamBuffer();
@@ -71,11 +71,7 @@ const readReport = (releaseDir, callback) => {
});
};
-exports.readReport = readReport;
-
-exports.writeReport = writeReport;
-
-exports.loadReport = (app, options, callback) => {
+export const loadReport = (app, options, callback) => {
const releaseDir = path.join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
glob("**", {
@@ -107,7 +103,7 @@ exports.loadReport = (app, options, callback) => {
});
};
-exports.getStatusMessageFromRelease = (app, originalOptions, callback) => {
+export const getStatusMessageFromRelease = (app, originalOptions, callback) => {
const options = _.extend(originalOptions, { "attemptsGetReport": (Number(originalOptions.attemptsGetReport) || Number()) + 1 });
const releaseDir = path.join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
const reportFile = path.join(releaseDir, reportFilename);
diff --git a/BuildServer/lib/status-processor.js b/BuildServer/lib/status-processor.ts
similarity index 89%
rename from BuildServer/lib/status-processor.js
rename to BuildServer/lib/status-processor.ts
index f9ce9f5..a5f6a9e 100644
--- a/BuildServer/lib/status-processor.js
+++ b/BuildServer/lib/status-processor.ts
@@ -1,9 +1,9 @@
"use strict";
-const path = require("path");
-const fs = require("fs");
-const _ = require("underscore");
-const reportProcessor = require("./report-processor");
+import path = require("path");
+import fs = require("fs");
+import _ = require("underscore");
+import reportProcessor = require("./report-processor");
const addBranchInfo = (app, options, callback) => {
const branchFile = path.join(app.get("releasepath"), options.owner, options.reponame, "$revs", `${options.rev}.branch`);
@@ -76,7 +76,7 @@ const parseOptions = (app, options, callback) => {
}), callback);
};
-exports.getReport = (app, options, callback) => parseOptions(app, options, (err, result) => {
+export const getReport = (app, options, callback) => parseOptions(app, options, (err, result) => {
if (err) {
return callback(err, {});
}
diff --git a/BuildServer/lib/task-processor.js b/BuildServer/lib/task-processor.ts
similarity index 94%
rename from BuildServer/lib/task-processor.js
rename to BuildServer/lib/task-processor.ts
index fd92a9d..97b9a6b 100644
--- a/BuildServer/lib/task-processor.js
+++ b/BuildServer/lib/task-processor.ts
@@ -1,14 +1,10 @@
"use strict";
-const _ = require("underscore");
-const tasks = require("./tasks");
+import _ = require("underscore");
+import tasks from "./tasks";
// TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here.
const TaskProcessor = function (task, outerProcessor, callback) {
- if (!this) {
- return new TaskProcessor(task);
- }
-
const that = this;
const createTaskWorker = () => tasks[task.type](task.params || {}, that);
const errors = [];
@@ -65,7 +61,7 @@ const addFlag = (flags) => (flagName) => {
const containsFlag = (flags) => (flagName) => flags[flagName];
-exports.processTask = (task, context, callback) => {
+export const processTask = (task, context, callback) => {
const errors = {};
const warns = {};
const infos = {};
diff --git a/BuildServer/lib/tasks/cleanupafterdotnetbuild.js b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
similarity index 90%
rename from BuildServer/lib/tasks/cleanupafterdotnetbuild.js
rename to BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
index b02f255..56642b8 100644
--- a/BuildServer/lib/tasks/cleanupafterdotnetbuild.js
+++ b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
@@ -1,8 +1,8 @@
"use strict";
-const glob = require("glob");
+import glob = require("glob");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
"cwd": processor.context.exported,
"dot": true
diff --git a/BuildServer/lib/tasks/conditional.js b/BuildServer/lib/tasks/conditional.ts
similarity index 90%
rename from BuildServer/lib/tasks/conditional.js
rename to BuildServer/lib/tasks/conditional.ts
index d184581..9905e6f 100644
--- a/BuildServer/lib/tasks/conditional.js
+++ b/BuildServer/lib/tasks/conditional.ts
@@ -1,6 +1,6 @@
"use strict";
-module.exports = (params, processor) => {
+export = (params, processor) => {
const condition = (!params.owner || params.owner === processor.context.owner)
&& (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch);
const task = (condition && params.task) || params.otherwise;
diff --git a/BuildServer/lib/tasks/copy.js b/BuildServer/lib/tasks/copy.ts
similarity index 84%
rename from BuildServer/lib/tasks/copy.js
rename to BuildServer/lib/tasks/copy.ts
index cc0f59c..1783508 100644
--- a/BuildServer/lib/tasks/copy.js
+++ b/BuildServer/lib/tasks/copy.ts
@@ -1,9 +1,9 @@
"use strict";
-const path = require("path");
-const fse = require("fs-extra");
+import path = require("path");
+import fse = require("fs-extra");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const sourceFilePath = path.join(processor.context.exported, params.filename);
const targetFilePath = path.join(processor.context.release, params.filename);
diff --git a/BuildServer/lib/tasks/copyglob.js b/BuildServer/lib/tasks/copyglob.ts
similarity index 90%
rename from BuildServer/lib/tasks/copyglob.js
rename to BuildServer/lib/tasks/copyglob.ts
index a1a7aab..63920f5 100644
--- a/BuildServer/lib/tasks/copyglob.js
+++ b/BuildServer/lib/tasks/copyglob.ts
@@ -1,8 +1,8 @@
"use strict";
-const glob = require("glob");
+import glob = require("glob");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => glob(params.mask, {
"cwd": processor.context.exported,
"dot": true
diff --git a/BuildServer/lib/tasks/cssnano.js b/BuildServer/lib/tasks/cssnano.ts
similarity index 89%
rename from BuildServer/lib/tasks/cssnano.js
rename to BuildServer/lib/tasks/cssnano.ts
index cd7fac2..d7cc248 100644
--- a/BuildServer/lib/tasks/cssnano.js
+++ b/BuildServer/lib/tasks/cssnano.ts
@@ -1,10 +1,10 @@
"use strict";
-const fs = require("fs");
-const path = require("path");
-const cssnano = require("cssnano");
+import fs = require("fs");
+import path = require("path");
+import cssnano = require("cssnano");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const filePath = path.join(processor.context.exported, params.filename);
diff --git a/BuildServer/lib/tasks/cssnanoall.js b/BuildServer/lib/tasks/cssnanoall.ts
similarity index 93%
rename from BuildServer/lib/tasks/cssnanoall.js
rename to BuildServer/lib/tasks/cssnanoall.ts
index 92a8437..2e9d4ea 100644
--- a/BuildServer/lib/tasks/cssnanoall.js
+++ b/BuildServer/lib/tasks/cssnanoall.ts
@@ -1,9 +1,9 @@
"use strict";
-const glob = require("glob");
+import glob = require("glob");
const flagDoneName = "cssnanoallDone";
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/deletefromcode.js b/BuildServer/lib/tasks/deletefromcode.ts
similarity index 81%
rename from BuildServer/lib/tasks/deletefromcode.js
rename to BuildServer/lib/tasks/deletefromcode.ts
index f74e3dd..d710e5e 100644
--- a/BuildServer/lib/tasks/deletefromcode.js
+++ b/BuildServer/lib/tasks/deletefromcode.ts
@@ -1,9 +1,9 @@
"use strict";
-const path = require("path");
-const fse = require("fs-extra");
+import path = require("path");
+import fse = require("fs-extra");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const sourceFilePath = path.join(processor.context.exported, params.filename);
diff --git a/BuildServer/lib/tasks/dotnetbuild.js b/BuildServer/lib/tasks/dotnetbuild.ts
similarity index 73%
rename from BuildServer/lib/tasks/dotnetbuild.js
rename to BuildServer/lib/tasks/dotnetbuild.ts
index de55745..d1b5029 100644
--- a/BuildServer/lib/tasks/dotnetbuild.js
+++ b/BuildServer/lib/tasks/dotnetbuild.ts
@@ -1,8 +1,8 @@
"use strict";
-const sequential = require("./sequential");
+import sequential = require("./sequential");
-module.exports = (params, processor) => sequential({
+export = (params, processor) => sequential({
"tasks": [
{
"name": "build",
diff --git a/BuildServer/lib/tasks/dotnetbuildandtest.js b/BuildServer/lib/tasks/dotnetbuildandtest.ts
similarity index 79%
rename from BuildServer/lib/tasks/dotnetbuildandtest.js
rename to BuildServer/lib/tasks/dotnetbuildandtest.ts
index de27456..9ab71ca 100644
--- a/BuildServer/lib/tasks/dotnetbuildandtest.js
+++ b/BuildServer/lib/tasks/dotnetbuildandtest.ts
@@ -1,8 +1,8 @@
"use strict";
-const sequential = require("./sequential");
+import sequential = require("./sequential");
-module.exports = (params, processor) => sequential({
+export = (params, processor) => sequential({
"tasks": [
{
"name": "build",
diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.js b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
similarity index 91%
rename from BuildServer/lib/tasks/dotnetbuilderwrapper.js
rename to BuildServer/lib/tasks/dotnetbuilderwrapper.ts
index cf97e14..f087282 100644
--- a/BuildServer/lib/tasks/dotnetbuilderwrapper.js
+++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
@@ -1,8 +1,8 @@
"use strict";
-const spawn = require("child_process").spawn;
-const streamBuffers = require("stream-buffers");
-const settings = require("../../settings");
+import { spawn } from "child_process";
+import streamBuffers = require("stream-buffers");
+import settings = require("../../settings");
const wrapBuilder = (builder, input, onExit) => {
const resultBuffer = new streamBuffers.WritableStreamBuffer();
@@ -26,7 +26,7 @@ const wrapBuilder = (builder, input, onExit) => {
builder.stdin.end();
};
-const safeParseJson = (data) => {
+const safeParseJson = (data):any => {
try {
return { "parsed": JSON.parse(data) };
} catch (err) {
@@ -34,7 +34,7 @@ const safeParseJson = (data) => {
}
};
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const input = JSON.stringify(params);
const builder = spawn(settings.builderExecutable, [params.command]);
diff --git a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.js b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
similarity index 91%
rename from BuildServer/lib/tasks/dotnetbuildwithoutcleanup.js
rename to BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
index b5ed97e..efd9d38 100644
--- a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.js
+++ b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
@@ -1,6 +1,6 @@
"use strict";
-const sequential = require("./sequential");
+import sequential = require("./sequential");
const createTasks = function *(params) {
if (!params.skipMbsCheckStyle) {
@@ -35,7 +35,7 @@ const createTasks = function *(params) {
};
};
-module.exports = (params, processor) => {
+export = (params, processor) => {
const tasks = Array.from(createTasks(params));
return sequential({ tasks }, processor);
diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.js b/BuildServer/lib/tasks/dotnetcheckstyle.ts
similarity index 93%
rename from BuildServer/lib/tasks/dotnetcheckstyle.js
rename to BuildServer/lib/tasks/dotnetcheckstyle.ts
index 502787a..78340e8 100644
--- a/BuildServer/lib/tasks/dotnetcheckstyle.js
+++ b/BuildServer/lib/tasks/dotnetcheckstyle.ts
@@ -1,9 +1,9 @@
"use strict";
-const path = require("path");
-const fs = require("fs");
-const async = require("async");
-const glob = require("glob");
+import path = require("path");
+import fs = require("fs");
+import async = require("async");
+import glob = require("glob");
const autoGeneratedMarker
= "//------------------------------------------------------------------------------\n"
@@ -11,7 +11,7 @@ const autoGeneratedMarker
const flagDoneName = "dotnetcheckerDone";
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
return processor.done();
diff --git a/BuildServer/lib/tasks/dotnetcompile.js b/BuildServer/lib/tasks/dotnetcompile.ts
similarity index 82%
rename from BuildServer/lib/tasks/dotnetcompile.js
rename to BuildServer/lib/tasks/dotnetcompile.ts
index bbf360f..6242593 100644
--- a/BuildServer/lib/tasks/dotnetcompile.js
+++ b/BuildServer/lib/tasks/dotnetcompile.ts
@@ -1,11 +1,11 @@
"use strict";
-const path = require("path");
-const _ = require("underscore");
-const settings = require("../../settings");
-const dotnetbuilderwrapper = require("./dotnetbuilderwrapper");
+import path = require("path");
+import _ = require("underscore");
+import settings = require("../../settings");
+import dotnetbuilderwrapper = require("./dotnetbuilderwrapper");
-module.exports = (params, processor) => {
+export = (params, processor) => {
if (settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) {
processor.onError("Code analysis is not supported");
diff --git a/BuildServer/lib/tasks/dotnetnugetpack.js b/BuildServer/lib/tasks/dotnetnugetpack.js
deleted file mode 100644
index caae541..0000000
--- a/BuildServer/lib/tasks/dotnetnugetpack.js
+++ /dev/null
@@ -1,11 +0,0 @@
-"use strict";
-
-const _ = require("underscore");
-const dotnetnugetprocessinternal = require("./dotnetnugetprocessinternal");
-
-module.exports = (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
- "getFinalTask": (nupkg) => ({
- "params": { "filename": nupkg },
- "type": "copy"
- })
-}), processor);
diff --git a/BuildServer/lib/tasks/dotnetnugetpack.ts b/BuildServer/lib/tasks/dotnetnugetpack.ts
new file mode 100644
index 0000000..2c1e9c6
--- /dev/null
+++ b/BuildServer/lib/tasks/dotnetnugetpack.ts
@@ -0,0 +1,11 @@
+"use strict";
+
+import _ = require("underscore");
+import dotnetnugetprocessinternal = require("./dotnetnugetprocessinternal");
+
+export = (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
+ "getFinalTask": (nupkg) => ({
+ "params": { "filename": nupkg },
+ "type": "copy"
+ })
+}), processor);
diff --git a/BuildServer/lib/tasks/dotnetnugetprocess.js b/BuildServer/lib/tasks/dotnetnugetprocess.ts
similarity index 88%
rename from BuildServer/lib/tasks/dotnetnugetprocess.js
rename to BuildServer/lib/tasks/dotnetnugetprocess.ts
index c2110d6..59ef522 100644
--- a/BuildServer/lib/tasks/dotnetnugetprocess.js
+++ b/BuildServer/lib/tasks/dotnetnugetprocess.ts
@@ -1,8 +1,8 @@
"use strict";
-const conditional = require("./conditional");
+import conditional = require("./conditional");
-module.exports = (params, processor) => conditional({
+export = (params, processor) => conditional({
"branch": "master",
"otherwise": {
"name": "nuget-pack",
diff --git a/BuildServer/lib/tasks/dotnetnugetprocessinternal.js b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
similarity index 91%
rename from BuildServer/lib/tasks/dotnetnugetprocessinternal.js
rename to BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
index 5f77a1e..3db3aa7 100644
--- a/BuildServer/lib/tasks/dotnetnugetprocessinternal.js
+++ b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
@@ -1,7 +1,7 @@
"use strict";
-const path = require("path");
-const sequential = require("./sequential");
+import path = require("path");
+import sequential = require("./sequential");
const postfixLength = 16;
const fourDigits = 10000;
@@ -15,7 +15,7 @@ const addPostfix = (version, params, processor) => {
return `${version}-r${processor.context.rev.substr(0, postfixLength)}`;
};
-module.exports = (params, processor) => {
+export = (params, processor) => {
const date = new Date();
const major = params.major || "0";
const minor = (date.getFullYear() * fourDigits) + ((date.getMonth() + 1) * twoDigits) + date.getDate();
diff --git a/BuildServer/lib/tasks/dotnetnugetpush.js b/BuildServer/lib/tasks/dotnetnugetpush.js
deleted file mode 100644
index eef7074..0000000
--- a/BuildServer/lib/tasks/dotnetnugetpush.js
+++ /dev/null
@@ -1,11 +0,0 @@
-"use strict";
-
-const _ = require("underscore");
-const dotnetnugetprocessinternal = require("./dotnetnugetprocessinternal");
-
-module.exports = (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
- "getFinalTask": (nupkg) => ({
- "params": { "Package": nupkg },
- "type": "dotnetnugetpushonly"
- })
-}), processor);
diff --git a/BuildServer/lib/tasks/dotnetnugetpush.ts b/BuildServer/lib/tasks/dotnetnugetpush.ts
new file mode 100644
index 0000000..4cf8ca3
--- /dev/null
+++ b/BuildServer/lib/tasks/dotnetnugetpush.ts
@@ -0,0 +1,11 @@
+"use strict";
+
+import _ = require("underscore");
+import dotnetnugetprocessinternal = require("./dotnetnugetprocessinternal");
+
+export = (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
+ "getFinalTask": (nupkg) => ({
+ "params": { "Package": nupkg },
+ "type": "dotnetnugetpushonly"
+ })
+}), processor);
diff --git a/BuildServer/lib/tasks/dotnetnugetpushonly.js b/BuildServer/lib/tasks/dotnetnugetpushonly.ts
similarity index 50%
rename from BuildServer/lib/tasks/dotnetnugetpushonly.js
rename to BuildServer/lib/tasks/dotnetnugetpushonly.ts
index a7c0ffa..b551343 100644
--- a/BuildServer/lib/tasks/dotnetnugetpushonly.js
+++ b/BuildServer/lib/tasks/dotnetnugetpushonly.ts
@@ -1,10 +1,10 @@
"use strict";
-const path = require("path");
-const dotnetbuilderwrapper = require("./dotnetbuilderwrapper");
-const settings = require("../../settings");
+import path = require("path");
+import dotnetbuilderwrapper = require("./dotnetbuilderwrapper");
+import settings = require("../../settings");
-module.exports = (params, processor) => dotnetbuilderwrapper({
+export = (params, processor) => dotnetbuilderwrapper({
"ApiKey": settings.nugetApiKey,
"NugetHost": settings.nugetHost,
"Package": path.join(processor.context.exported, params.Package),
diff --git a/BuildServer/lib/tasks/dotnetnugetrestore.js b/BuildServer/lib/tasks/dotnetnugetrestore.ts
similarity index 73%
rename from BuildServer/lib/tasks/dotnetnugetrestore.js
rename to BuildServer/lib/tasks/dotnetnugetrestore.ts
index e8134c8..f62baa3 100644
--- a/BuildServer/lib/tasks/dotnetnugetrestore.js
+++ b/BuildServer/lib/tasks/dotnetnugetrestore.ts
@@ -1,9 +1,9 @@
"use strict";
-const path = require("path");
-const sequential = require("./sequential");
+import path = require("path");
+import sequential = require("./sequential");
-module.exports = (params, processor) => sequential({
+export = (params, processor) => sequential({
"tasks": [
{
"params": {
diff --git a/BuildServer/lib/tasks/dotnetnunit.js b/BuildServer/lib/tasks/dotnetnunit.js
deleted file mode 100644
index d5564d4..0000000
--- a/BuildServer/lib/tasks/dotnetnunit.js
+++ /dev/null
@@ -1,9 +0,0 @@
-"use strict";
-
-const path = require("path");
-const dotNetBuilderWrapper = require("./dotnetbuilderwrapper");
-
-module.exports = (params, processor) => dotNetBuilderWrapper({
- "TestLibraryPath": path.join(processor.context.exported, params.assembly),
- "command": "nunit"
-}, processor);
diff --git a/BuildServer/lib/tasks/dotnetnunit.ts b/BuildServer/lib/tasks/dotnetnunit.ts
new file mode 100644
index 0000000..5f8ba6a
--- /dev/null
+++ b/BuildServer/lib/tasks/dotnetnunit.ts
@@ -0,0 +1,9 @@
+"use strict";
+
+import path = require("path");
+import dotNetBuilderWrapper = require("./dotnetbuilderwrapper");
+
+export = (params, processor) => dotNetBuilderWrapper({
+ "TestLibraryPath": path.join(processor.context.exported, params.assembly),
+ "command": "nunit"
+}, processor);
diff --git a/BuildServer/lib/tasks/dotnetnunitall.js b/BuildServer/lib/tasks/dotnetnunitall.ts
similarity index 94%
rename from BuildServer/lib/tasks/dotnetnunitall.js
rename to BuildServer/lib/tasks/dotnetnunitall.ts
index f4340c3..4ee6445 100644
--- a/BuildServer/lib/tasks/dotnetnunitall.js
+++ b/BuildServer/lib/tasks/dotnetnunitall.ts
@@ -1,9 +1,9 @@
"use strict";
-const glob = require("glob");
+import glob = require("glob");
const flagDoneName = "dotnetnunitallDone";
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/dotnetpackwebapp.js b/BuildServer/lib/tasks/dotnetpackwebapp.ts
similarity index 89%
rename from BuildServer/lib/tasks/dotnetpackwebapp.js
rename to BuildServer/lib/tasks/dotnetpackwebapp.ts
index fd2f7d1..070f167 100644
--- a/BuildServer/lib/tasks/dotnetpackwebapp.js
+++ b/BuildServer/lib/tasks/dotnetpackwebapp.ts
@@ -1,10 +1,9 @@
"use strict";
-const path = require("path");
-const fs = require("fs");
-const Mustache = require("mustache");
-
-const sequential = require("./sequential");
+import path = require("path");
+import fs = require("fs");
+import Mustache = require("mustache");
+import sequential = require("./sequential");
// eslint-disable-next-line no-sync
const msbuildTemplate = fs.readFileSync(path.join(__dirname, "/dotnetpackwebapp.template.msbuild"), { "encoding": "utf8" });
@@ -13,7 +12,7 @@ const deployTemplate = fs.readFileSync(path.join(__dirname, "/dotnetpackwebapp.t
// eslint-disable-next-line no-sync
const versionTemplate = fs.readFileSync(path.join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { "encoding": "utf8" });
-module.exports = (params, processor) => sequential({
+export = (params, processor) => sequential({
"tasks": [
{
"params": {
diff --git a/BuildServer/lib/tasks/dotnetrewrite.js b/BuildServer/lib/tasks/dotnetrewrite.ts
similarity index 91%
rename from BuildServer/lib/tasks/dotnetrewrite.js
rename to BuildServer/lib/tasks/dotnetrewrite.ts
index c6db85c..a91fbc9 100644
--- a/BuildServer/lib/tasks/dotnetrewrite.js
+++ b/BuildServer/lib/tasks/dotnetrewrite.ts
@@ -1,10 +1,10 @@
"use strict";
-const path = require("path");
-const fs = require("fs");
-const async = require("async");
-const glob = require("glob");
-const settings = require("../../settings");
+import path = require("path");
+import fs = require("fs");
+import async = require("async");
+import glob = require("glob");
+import settings = require("../../settings");
const flagDoneName = "dotnetrewriterDone";
@@ -31,7 +31,7 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => (
return cb(null, processInformationalVersion(processInternalsVisible(originalContent)));
};
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
return processor.done();
diff --git a/BuildServer/lib/tasks/echo.js b/BuildServer/lib/tasks/echo.ts
similarity index 88%
rename from BuildServer/lib/tasks/echo.js
rename to BuildServer/lib/tasks/echo.ts
index dd5560b..d7079e5 100644
--- a/BuildServer/lib/tasks/echo.js
+++ b/BuildServer/lib/tasks/echo.ts
@@ -1,6 +1,6 @@
"use strict";
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
if (params.error) {
processor.onError(params.error);
diff --git a/BuildServer/lib/tasks/eslintbrowser.js b/BuildServer/lib/tasks/eslintbrowser.ts
similarity index 83%
rename from BuildServer/lib/tasks/eslintbrowser.js
rename to BuildServer/lib/tasks/eslintbrowser.ts
index e1d8b57..9a60085 100644
--- a/BuildServer/lib/tasks/eslintbrowser.js
+++ b/BuildServer/lib/tasks/eslintbrowser.ts
@@ -1,13 +1,13 @@
"use strict";
-const path = require("path");
-const CLIEngine = require("eslint").CLIEngine;
-const settings = require("../../settings");
+import path = require("path");
+import { CLIEngine } from "eslint";
+import settings = require("../../settings");
const cli = new CLIEngine({ "configFile": settings.eslintBrowserConfig });
const errorSeverity = 2;
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const filePath = path.join(processor.context.exported, params.filename);
const result = cli.executeOnFiles([filePath]);
diff --git a/BuildServer/lib/tasks/eslintbrowserall.js b/BuildServer/lib/tasks/eslintbrowserall.ts
similarity index 93%
rename from BuildServer/lib/tasks/eslintbrowserall.js
rename to BuildServer/lib/tasks/eslintbrowserall.ts
index 82d253c..8c3836a 100644
--- a/BuildServer/lib/tasks/eslintbrowserall.js
+++ b/BuildServer/lib/tasks/eslintbrowserall.ts
@@ -1,9 +1,9 @@
"use strict";
-const glob = require("glob");
+import glob = require("glob");
const flagDoneName = "eslintbrowserallDone";
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/index.js b/BuildServer/lib/tasks/index.ts
similarity index 54%
rename from BuildServer/lib/tasks/index.js
rename to BuildServer/lib/tasks/index.ts
index ec631b6..4f0fc02 100644
--- a/BuildServer/lib/tasks/index.js
+++ b/BuildServer/lib/tasks/index.ts
@@ -1,13 +1,17 @@
"use strict";
+var tasks = {};
+
// Code taken from http://stackoverflow.com/a/17204293
// eslint-disable-next-line no-sync
require("fs").readdirSync(__dirname)
.forEach((file) => {
- if (file.match(/\.js$/) !== null && file !== "index.js") {
- const name = file.replace(".js", "");
+ if (file.match(/\.ts$/) !== null && file !== "index.ts") {
+ const name = file.replace(".ts", "");
// eslint-disable-next-line global-require
- exports[name] = require(`./${file}`);
+ tasks[name] = require(`./${file}`);
}
});
+
+export default tasks;
diff --git a/BuildServer/lib/tasks/noop.js b/BuildServer/lib/tasks/noop.js
deleted file mode 100644
index 5e82011..0000000
--- a/BuildServer/lib/tasks/noop.js
+++ /dev/null
@@ -1,3 +0,0 @@
-"use strict";
-
-module.exports = (params, processor) => ({ "process": () => processor.done() });
diff --git a/BuildServer/lib/tasks/noop.ts b/BuildServer/lib/tasks/noop.ts
new file mode 100644
index 0000000..e51c990
--- /dev/null
+++ b/BuildServer/lib/tasks/noop.ts
@@ -0,0 +1,3 @@
+"use strict";
+
+export = (params, processor) => ({ "process": () => processor.done() });
diff --git a/BuildServer/lib/tasks/packform.js b/BuildServer/lib/tasks/packform.ts
similarity index 86%
rename from BuildServer/lib/tasks/packform.js
rename to BuildServer/lib/tasks/packform.ts
index 38c4b3b..6588cf3 100644
--- a/BuildServer/lib/tasks/packform.js
+++ b/BuildServer/lib/tasks/packform.ts
@@ -1,8 +1,8 @@
"use strict";
-const sequential = require("./sequential");
+import sequential = require("./sequential");
-module.exports = (params, processor) => sequential({
+export = (params, processor) => sequential({
"tasks": [
{
"params": { "excludeFiles": params.eslintExcludeFiles },
diff --git a/BuildServer/lib/tasks/parallel.js b/BuildServer/lib/tasks/parallel.js
deleted file mode 100644
index 6e4525e..0000000
--- a/BuildServer/lib/tasks/parallel.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-const async = require("async");
-
-const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-
-module.exports = (params, processor) => ({ "process": () => async.parallel(params.tasks.map(mapper(processor)), () => processor.done()) });
diff --git a/BuildServer/lib/tasks/parallel.ts b/BuildServer/lib/tasks/parallel.ts
new file mode 100644
index 0000000..c81415e
--- /dev/null
+++ b/BuildServer/lib/tasks/parallel.ts
@@ -0,0 +1,7 @@
+"use strict";
+
+import async = require("async");
+
+const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
+
+export = (params, processor) => ({ "process": () => async.parallel(params.tasks.map(mapper(processor)), () => processor.done()) });
diff --git a/BuildServer/lib/tasks/sequential.js b/BuildServer/lib/tasks/sequential.js
deleted file mode 100644
index 818813d..0000000
--- a/BuildServer/lib/tasks/sequential.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-const async = require("async");
-
-const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-
-module.exports = (params, processor) => ({ "process": () => async.series(params.tasks.map(mapper(processor)), () => processor.done()) });
diff --git a/BuildServer/lib/tasks/sequential.ts b/BuildServer/lib/tasks/sequential.ts
new file mode 100644
index 0000000..35b5abb
--- /dev/null
+++ b/BuildServer/lib/tasks/sequential.ts
@@ -0,0 +1,7 @@
+"use strict";
+
+import async = require("async");
+
+const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
+
+export = (params, processor) => ({ "process": () => async.series(params.tasks.map(mapper(processor)), () => processor.done()) });
diff --git a/BuildServer/lib/tasks/uglifyjs.js b/BuildServer/lib/tasks/uglifyjs.ts
similarity index 80%
rename from BuildServer/lib/tasks/uglifyjs.js
rename to BuildServer/lib/tasks/uglifyjs.ts
index cea7827..094a2a3 100644
--- a/BuildServer/lib/tasks/uglifyjs.js
+++ b/BuildServer/lib/tasks/uglifyjs.ts
@@ -1,10 +1,10 @@
"use strict";
-const fs = require("fs");
-const path = require("path");
-const UglifyJS = require("uglify-js");
+import fs = require("fs");
+import path = require("path");
+import UglifyJS = require("uglify-js");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const filePath = path.normalize(path.join(processor.context.exported, params.filename));
const result = UglifyJS.minify(filePath);
diff --git a/BuildServer/lib/tasks/uglifyjsall.js b/BuildServer/lib/tasks/uglifyjsall.ts
similarity index 93%
rename from BuildServer/lib/tasks/uglifyjsall.js
rename to BuildServer/lib/tasks/uglifyjsall.ts
index 0af6ef1..94bd135 100644
--- a/BuildServer/lib/tasks/uglifyjsall.js
+++ b/BuildServer/lib/tasks/uglifyjsall.ts
@@ -1,10 +1,10 @@
"use strict";
-const glob = require("glob");
+import glob = require("glob");
const doneFlagName = "uglifyjsallDone";
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(doneFlagName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/writefile.js b/BuildServer/lib/tasks/writefile.ts
similarity index 82%
rename from BuildServer/lib/tasks/writefile.js
rename to BuildServer/lib/tasks/writefile.ts
index 30b02d5..340ff48 100644
--- a/BuildServer/lib/tasks/writefile.js
+++ b/BuildServer/lib/tasks/writefile.ts
@@ -1,9 +1,9 @@
"use strict";
-const fs = require("fs");
-const path = require("path");
+import fs = require("fs");
+import path = require("path");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const filePath = path.join(processor.context.exported, params.filename);
diff --git a/BuildServer/lib/tasks/zip.js b/BuildServer/lib/tasks/zip.ts
similarity index 84%
rename from BuildServer/lib/tasks/zip.js
rename to BuildServer/lib/tasks/zip.ts
index 64c6c9e..fac39db 100644
--- a/BuildServer/lib/tasks/zip.js
+++ b/BuildServer/lib/tasks/zip.ts
@@ -1,10 +1,10 @@
"use strict";
-const fs = require("fs");
-const path = require("path");
-const Archiver = require("archiver");
+import fs = require("fs");
+import path = require("path");
+import Archiver = require("archiver");
-module.exports = (params, processor) => ({
+export = (params, processor) => ({
"process": () => {
const sourceDirectoryPath = path.normalize(path.join(processor.context.exported, String(params.directory || "")));
const targetArchivePath = path.normalize(path.join(processor.context.release, params.archive));
diff --git a/BuildServer/package.json b/BuildServer/package.json
index 8327619..ccdda39 100644
--- a/BuildServer/package.json
+++ b/BuildServer/package.json
@@ -42,8 +42,8 @@
"fp"
],
"extends": [
- "eslint:all",
- "plugin:fp/recommended"
+ "eslint:all",
+ "plugin:fp/recommended"
],
"rules": {
"fp/no-unused-expression": "off",
@@ -130,7 +130,8 @@
}
},
"devDependencies": {
- "eslint": "^3.15.0",
- "eslint-plugin-fp": "^2.3.0"
+ "@types/node": "^7.0.5",
+ "tslint": "^4.4.2",
+ "typescript": "^2.1.6"
}
}
diff --git a/BuildServer/routes/artifact.js b/BuildServer/routes/artifact.ts
similarity index 93%
rename from BuildServer/routes/artifact.js
rename to BuildServer/routes/artifact.ts
index 57b3dee..c317233 100644
--- a/BuildServer/routes/artifact.js
+++ b/BuildServer/routes/artifact.ts
@@ -1,6 +1,6 @@
"use strict";
-module.exports = (req, res) => {
+export = (req, res) => {
const options = {
"branch": `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch,
diff --git a/BuildServer/routes/index.js b/BuildServer/routes/index.js
deleted file mode 100644
index 985145b..0000000
--- a/BuildServer/routes/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-"use strict";
-
-exports.index = (req, res) => res.render("index", { "title": `Express
\r\n${req}` });
-
-exports.postreceive = require("./postreceive");
-exports.manual = require("./manual");
-exports.status = require("./status");
-exports.artifact = require("./artifact");
-exports.release = require("./release");
diff --git a/BuildServer/routes/index.ts b/BuildServer/routes/index.ts
new file mode 100644
index 0000000..15363c0
--- /dev/null
+++ b/BuildServer/routes/index.ts
@@ -0,0 +1,12 @@
+"use strict";
+
+import postreceive = require("./postreceive");
+import manual = require("./manual");
+import status = require("./status");
+import artifact = require("./artifact");
+import release = require("./release");
+
+const index = (req, res) => res.render("index", { "title": `Express
\r\n${req}` });
+
+export { index, postreceive, manual, status, artifact, release };
+
diff --git a/BuildServer/routes/manual.js b/BuildServer/routes/manual.ts
similarity index 70%
rename from BuildServer/routes/manual.js
rename to BuildServer/routes/manual.ts
index b14dd9f..337855e 100644
--- a/BuildServer/routes/manual.js
+++ b/BuildServer/routes/manual.ts
@@ -1,11 +1,11 @@
"use strict";
-const _ = require("underscore");
-const builder = require("../lib/builder");
+import _ = require("underscore");
+import builder = require("../lib/builder");
-exports.get = (req, res) => res.render("manual");
+export const get = (req, res) => res.render("manual");
-exports.post = (req, res) => {
+export const post = (req, res) => {
const options = _.extend(req.body, {
"app": req.app,
"url": `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`
@@ -19,4 +19,4 @@ exports.post = (req, res) => {
result
});
});
-};
+};
\ No newline at end of file
diff --git a/BuildServer/routes/postreceive.js b/BuildServer/routes/postreceive.ts
similarity index 96%
rename from BuildServer/routes/postreceive.js
rename to BuildServer/routes/postreceive.ts
index de7eff2..9507f16 100644
--- a/BuildServer/routes/postreceive.js
+++ b/BuildServer/routes/postreceive.ts
@@ -1,7 +1,7 @@
"use strict";
-const builder = require("../lib/builder");
-const commenter = require("../lib/commenter");
+import builder = require("../lib/builder");
+import commenter = require("../lib/commenter");
const getBranchDescription = (options) => `${options.owner}/${options.reponame}:${options.branchname || options.branch}`;
@@ -90,7 +90,7 @@ const processPullRequest = (req, res, payload) => {
);
};
-module.exports = (req, res) => {
+export = (req, res) => {
if (!req.body || (!req.body.payload && !req.body.repository)) {
return res.end();
}
diff --git a/BuildServer/routes/release.js b/BuildServer/routes/release.ts
similarity index 89%
rename from BuildServer/routes/release.js
rename to BuildServer/routes/release.ts
index ba9b4fe..8ad054a 100644
--- a/BuildServer/routes/release.js
+++ b/BuildServer/routes/release.ts
@@ -1,9 +1,9 @@
"use strict";
-const path = require("path");
-const Archiver = require("archiver");
+import path = require("path");
+import Archiver = require("archiver");
-const reportProcessor = require("../lib/report-processor");
+import reportProcessor = require("../lib/report-processor");
const getDatePart = (report) => {
if (!report.date) {
@@ -23,7 +23,7 @@ const getDatePart = (report) => {
return `${year}.${month}.${day}.${hours}.${minutes}.${seconds}`;
};
-module.exports = (req, res, next) => {
+export = (req, res, next) => {
const options = {
"branch": `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch,
diff --git a/BuildServer/routes/status.js b/BuildServer/routes/status.ts
similarity index 88%
rename from BuildServer/routes/status.js
rename to BuildServer/routes/status.ts
index 4aa859e..dbb75c4 100644
--- a/BuildServer/routes/status.js
+++ b/BuildServer/routes/status.ts
@@ -1,8 +1,8 @@
"use strict";
-const url = require("url");
-const _ = require("underscore");
-const statusProcessor = require("../lib/status-processor");
+import url = require("url");
+import _ = require("underscore");
+import statusProcessor = require("../lib/status-processor");
const parseOptionsFromReferer = (path, callback) => {
const pathParts = path.split("/").filter((value) => value);
@@ -39,7 +39,7 @@ const createShowReport = (res) => (err, inputOptions) => {
res.render("status", options);
};
-exports.image = (req, res) => {
+export const image = (req, res) => {
const getAdditionalOptions = (err, options) => {
if (err === "ReportFileNotFound") {
return { "status": "Building" };
@@ -98,7 +98,7 @@ exports.image = (req, res) => {
});
};
-exports.page = (req, res) => {
+export const page = (req, res) => {
const options = {
"branch": `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch,
@@ -110,9 +110,9 @@ exports.page = (req, res) => {
statusProcessor.getReport(req.app, options, createShowReport(res));
};
-exports.pageFromGithub = (req, res) => parseOptionsFromReferer(req.params[0], (err, options) => {
+export const pageFromGithub = (req, res) => parseOptionsFromReferer(req.params[0], (err, options) => {
if (err) {
- return createShowReport(err, options);
+ return createShowReport(res)(err, options);
}
return statusProcessor.getReport(req.app, options, createShowReport(res));
diff --git a/BuildServer/settings.js.example b/BuildServer/settings.ts.example
similarity index 92%
rename from BuildServer/settings.js.example
rename to BuildServer/settings.ts.example
index 4ab41be..77d7fc3 100644
--- a/BuildServer/settings.js.example
+++ b/BuildServer/settings.ts.example
@@ -12,8 +12,10 @@ const createGithub = () => new GitHubApi({
"version": "3.0.0"
});
-module.exports = {
+export = {
"builderExecutable": "../DotNetBuilder/bin/Debug/MicroBuildServer.DotNetBuilder.exe",
+ "codeSigningKeyFile": null,
+ "codeSigningPublicKey": null,
"createGithub": (repoOwner) => {
const github = createGithub();
@@ -36,6 +38,7 @@ module.exports = {
"eslintBrowserConfig": "settings-eslint-browser.json",
"gitpath": "M:/g",
"ignoreCodeAnalysisByDefault": true,
+ "isCodeAnalysisUnsupported": false,
"nugetApiKey": "*** NUGET API KEY ***",
"nugetHost": "https://*** NUGET HOST ***/",
"port": 3000,
diff --git a/BuildServer/tsconfig.json b/BuildServer/tsconfig.json
new file mode 100644
index 0000000..fe3b5ae
--- /dev/null
+++ b/BuildServer/tsconfig.json
@@ -0,0 +1,8 @@
+{
+ "compilerOptions": {
+ "target": "es6",
+ "typeRoots": [
+ "node_modules/@types"
+ ]
+ }
+}
From 48de21871cd13a6926dcb5f79b469e5f29c86363 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 22 Feb 2017 17:13:22 +0300
Subject: [PATCH 02/13] Switch to ES6 modules
---
BuildServer/app.ts | 38 +++++++--------
BuildServer/lib/builder.ts | 48 +++++++++----------
BuildServer/lib/commenter.ts | 8 ++--
BuildServer/lib/git/copy.ts | 16 +++----
BuildServer/lib/git/loader.ts | 26 ++++------
BuildServer/lib/report-processor.ts | 42 ++++++++--------
BuildServer/lib/status-processor.ts | 22 ++++-----
BuildServer/lib/task-processor.ts | 2 +-
.../lib/tasks/cleanupafterdotnetbuild.ts | 4 +-
BuildServer/lib/tasks/conditional.ts | 2 +-
BuildServer/lib/tasks/copy.ts | 12 ++---
BuildServer/lib/tasks/copyglob.ts | 4 +-
BuildServer/lib/tasks/cssnano.ts | 16 +++----
BuildServer/lib/tasks/cssnanoall.ts | 4 +-
BuildServer/lib/tasks/deletefromcode.ts | 10 ++--
BuildServer/lib/tasks/dotnetbuild.ts | 4 +-
BuildServer/lib/tasks/dotnetbuildandtest.ts | 4 +-
BuildServer/lib/tasks/dotnetbuilderwrapper.ts | 10 ++--
.../lib/tasks/dotnetbuildwithoutcleanup.ts | 4 +-
BuildServer/lib/tasks/dotnetcheckstyle.ts | 14 +++---
BuildServer/lib/tasks/dotnetcompile.ts | 12 ++---
BuildServer/lib/tasks/dotnetnugetpack.ts | 6 +--
BuildServer/lib/tasks/dotnetnugetprocess.ts | 4 +-
.../lib/tasks/dotnetnugetprocessinternal.ts | 8 ++--
BuildServer/lib/tasks/dotnetnugetpush.ts | 6 +--
BuildServer/lib/tasks/dotnetnugetpushonly.ts | 10 ++--
BuildServer/lib/tasks/dotnetnugetrestore.ts | 8 ++--
BuildServer/lib/tasks/dotnetnunit.ts | 8 ++--
BuildServer/lib/tasks/dotnetnunitall.ts | 4 +-
BuildServer/lib/tasks/dotnetpackwebapp.ts | 22 ++++-----
BuildServer/lib/tasks/dotnetrewrite.ts | 18 +++----
BuildServer/lib/tasks/echo.ts | 2 +-
BuildServer/lib/tasks/eslintbrowser.ts | 8 ++--
BuildServer/lib/tasks/eslintbrowserall.ts | 4 +-
BuildServer/lib/tasks/index.ts | 2 +-
BuildServer/lib/tasks/noop.ts | 2 +-
BuildServer/lib/tasks/packform.ts | 4 +-
BuildServer/lib/tasks/parallel.ts | 4 +-
BuildServer/lib/tasks/sequential.ts | 4 +-
BuildServer/lib/tasks/uglifyjs.ts | 14 +++---
BuildServer/lib/tasks/uglifyjsall.ts | 4 +-
BuildServer/lib/tasks/writefile.ts | 10 ++--
BuildServer/lib/tasks/zip.ts | 14 +++---
BuildServer/routes/artifact.ts | 2 +-
BuildServer/routes/index.ts | 10 ++--
BuildServer/routes/manual.ts | 6 +--
BuildServer/routes/postreceive.ts | 10 ++--
BuildServer/routes/release.ts | 12 ++---
BuildServer/routes/status.ts | 14 +++---
BuildServer/settings.ts.example | 7 ++-
50 files changed, 260 insertions(+), 269 deletions(-)
diff --git a/BuildServer/app.ts b/BuildServer/app.ts
index b6eb90d..bf4b741 100644
--- a/BuildServer/app.ts
+++ b/BuildServer/app.ts
@@ -1,37 +1,37 @@
"use strict";
-import realFs = require("fs");
-import fs = require("graceful-fs");
+import * as realFs from "fs";
+import * as fs from "graceful-fs";
fs.gracefulify(realFs);
-import express = require("express");
-import routes = require("./routes");
-import http = require("http");
-import path = require("path");
-import serveFavicon = require("serve-favicon");
-import morgan = require("morgan");
-import bodyParser = require("body-parser");
-import methodOverride = require("method-override");
-import serveStatic = require("serve-static");
-import errorhandler = require("errorhandler");
+import * as express from "express";
+import * as routes from "./routes";
+import { createServer } from "http";
+import { join } from "path";
+import * as serveFavicon from "serve-favicon";
+import * as morgan from "morgan";
+import { json as bodyJson, urlencoded as bodyUrlencoded } from "body-parser";
+import * as methodOverride from "method-override";
+import * as serveStatic from "serve-static";
+import * as errorhandler from "errorhandler";
-import settings = require("./settings");
+import settings from "./settings";
const app = express();
app.set("port", settings.port); // eslint-disable-line no-process-env
-app.set("views", path.join(__dirname, "views"));
+app.set("views", join(__dirname, "views"));
app.set("view engine", "jade");
app.set("gitpath", settings.gitpath);
app.set("tmpcodepath", settings.tmpcodepath);
app.set("releasepath", settings.releasepath);
-app.use(serveFavicon(path.join(__dirname, "public/images/favicon.png")));
+app.use(serveFavicon(join(__dirname, "public/images/favicon.png")));
app.use(morgan("dev"));
-app.use(bodyParser.json({ "limit": "10mb" }));
-app.use(bodyParser.urlencoded({ "extended": false }));
+app.use(bodyJson({ "limit": "10mb" }));
+app.use(bodyUrlencoded({ "extended": false }));
app.use(methodOverride());
-app.use(serveStatic(path.join(__dirname, "public")));
+app.use(serveStatic(join(__dirname, "public")));
if (app.get("env") === "development") {
app.use(errorhandler());
@@ -52,4 +52,4 @@ app.route("/status.svg").get(routes.status.image);
app.route("/release/:owner/:reponame/:branch/:rev").get(routes.release);
app.route("/artifact/:owner/:reponame/:branch/:rev/*").get(routes.artifact);
-http.createServer(app).listen(app.get("port"), () => console.log(`Express server listening on port ${app.get("port")}`));
+createServer(app).listen(app.get("port"), () => console.log(`Express server listening on port ${app.get("port")}`));
diff --git a/BuildServer/lib/builder.ts b/BuildServer/lib/builder.ts
index e1cdcf4..09181a5 100644
--- a/BuildServer/lib/builder.ts
+++ b/BuildServer/lib/builder.ts
@@ -1,14 +1,14 @@
"use strict";
-import path = require("path");
-import fs = require("fs");
-import fse = require("fs-extra");
-import async = require("async");
-import gitLoader = require("./git/loader");
-import processor = require("./task-processor");
-import reportProcessor = require("./report-processor");
-import mailSender = require("./mail-sender");
-import settings = require("../settings");
+import { join } from "path";
+import { exists, readFile, writeFileSync } from "fs";
+import { mkdirsSync, remove } from "fs-extra";
+import { parallel, queue } from "async";
+import { gitLoader } from "./git/loader";
+import { processTask } from "./task-processor";
+import { writeReport } from "./report-processor";
+import { send as sendMail } from "./mail-sender";
+import settings from "../settings";
const codePostfix = "";
const mailLazinessLevel = 1000;
@@ -77,11 +77,11 @@ export const build = (options, buildCallback) => {
const rev = options.rev;
const branch = options.branch;
const skipGitLoader = options.skipGitLoader;
- const local = path.join(options.app.get("gitpath"), "r");
- const tmp = path.join(options.app.get("tmpcodepath"), rev.substr(0, maxTmpcodepathLength));
+ const local = join(options.app.get("gitpath"), "r");
+ const tmp = join(options.app.get("tmpcodepath"), rev.substr(0, maxTmpcodepathLength));
const exported = tmp + codePostfix;
- const release = path.join(options.app.get("releasepath"), owner, reponame, branch, rev);
- const statusQueue = async.queue((task, queueCallback) => task(queueCallback), 1);
+ const release = join(options.app.get("releasepath"), owner, reponame, branch, rev);
+ const statusQueue = queue((task, queueCallback) => task(queueCallback), 1);
const actualGitLoader = wrapGitLoader(skipGitLoader);
const date = new Date();
const versionMajor = date.getFullYear();
@@ -99,11 +99,11 @@ export const build = (options, buildCallback) => {
"state": "pending"
}, queueCallback));
- fse.mkdirsSync(release);
+ mkdirsSync(release);
- fs.writeFileSync(path.join(options.app.get("releasepath"), owner, reponame, branch, "latest.id"), rev);
- fse.mkdirsSync(path.join(options.app.get("releasepath"), owner, reponame, "$revs"));
- fs.writeFileSync(path.join(options.app.get("releasepath"), owner, reponame, "$revs", `${rev}.branch`), branch);
+ writeFileSync(join(options.app.get("releasepath"), owner, reponame, branch, "latest.id"), rev);
+ mkdirsSync(join(options.app.get("releasepath"), owner, reponame, "$revs"));
+ writeFileSync(join(options.app.get("releasepath"), owner, reponame, "$revs", `${rev}.branch`), branch);
const createErrorMessageForMail = (doneErr) => {
if (!doneErr) {
@@ -129,8 +129,8 @@ export const build = (options, buildCallback) => {
const warnMessage = (allWarns[0] || {}).message;
const infoMessage = (allInfos[allInfos.length - 1] || {}).message;
- reportProcessor.writeReport(release, doneErr, result, (writeErr) => {
- statusQueue.push((queueCallback) => async.parallel([
+ writeReport(release, doneErr, result, (writeErr) => {
+ statusQueue.push((queueCallback) => parallel([
(parallelCallback) => notifyStatus({
"description": errorMessage || warnMessage || infoMessage || "Success",
"hash": rev,
@@ -138,7 +138,7 @@ export const build = (options, buildCallback) => {
reponame,
"state": createFinalState(!doneErr)
}, parallelCallback),
- (parallelCallback) => mailSender.send({
+ (parallelCallback) => sendMail({
"from": settings.smtp.sender,
"headers": { "X-Laziness-level": mailLazinessLevel },
"subject": createBuildDoneMessage(doneErr, `${owner}/${reponame}/${branch}`),
@@ -150,7 +150,7 @@ export const build = (options, buildCallback) => {
return process.nextTick(parallelCallback);
}
- return fse.remove(tmp, parallelCallback);
+ return remove(tmp, parallelCallback);
}
], queueCallback));
@@ -177,12 +177,12 @@ export const build = (options, buildCallback) => {
console.log("Done loading from git");
- return fs.exists(path.join(exported, "mbs.json"), (exists) => {
+ return exists(join(exported, "mbs.json"), (exists) => {
if (!exists) {
return done(null, "MBSNotFound");
}
- return fs.readFile(path.join(exported, "mbs.json"), (readErr, data) => {
+ return readFile(join(exported, "mbs.json"), (readErr, data) => {
if (readErr) {
return done(readErr, "MBSUnableToRead");
}
@@ -195,7 +195,7 @@ export const build = (options, buildCallback) => {
return done(err, "MBSMalformed");
}
- return processor.processTask(parsed, {
+ return processTask(parsed, {
branch,
exported,
owner,
diff --git a/BuildServer/lib/commenter.ts b/BuildServer/lib/commenter.ts
index 6b7385a..1504347 100644
--- a/BuildServer/lib/commenter.ts
+++ b/BuildServer/lib/commenter.ts
@@ -1,8 +1,8 @@
"use strict";
-import _ = require("underscore");
-import reportProcessor = require("./report-processor");
-import settings = require("../settings");
+import * as _ from "underscore";
+import { getStatusMessageFromRelease } from "./report-processor";
+import settings from "../settings";
const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/;
const versionNamePattern = /^v\d+(\.\d+)*$/;
@@ -140,7 +140,7 @@ export const commentOnPullRequest = (originalOptions, callback) => {
const optionsGithub = _.extend(originalOptions, { "github": settings.createGithub(originalOptions.baseRepoOptions.owner) });
const options = _.extend(optionsGithub, { "onTenthAttempt": () => writeComment(optionsGithub, "Waiting for build to finish...", () => {}) });
- return checkPullRequest(options, () => reportProcessor.getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => {
+ return checkPullRequest(options, () => getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => {
const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength)
.replace(/`/g, "` ");
const message = statusMessageErr
diff --git a/BuildServer/lib/git/copy.ts b/BuildServer/lib/git/copy.ts
index fd1d0fa..c345a0e 100644
--- a/BuildServer/lib/git/copy.ts
+++ b/BuildServer/lib/git/copy.ts
@@ -1,9 +1,9 @@
"use strict";
import { EventEmitter } from "events"; // eslint-disable-line fp/no-events
-import path = require("path");
-import fs = require("fs");
-import async = require("async");
+import { join } from "path";
+import { writeFile, mkdir } from "fs";
+import { parallel } from "async";
import { Copier } from "recursive-tree-copy";
const safeGetEntries = (tree):any => {
@@ -17,20 +17,20 @@ const safeGetEntries = (tree):any => {
const gitToFsCopier = new Copier({
"concurrency": 4,
"copyLeaf": (entry, targetDir, callback) => {
- const targetPath = path.join(targetDir, entry.name());
+ const targetPath = join(targetDir, entry.name());
entry.getBlob((err, blob) => {
if (err) {
return callback(err);
}
- return fs.writeFile(targetPath, blob.content(), callback);
+ return writeFile(targetPath, blob.content(), callback);
});
},
"createTargetTree": (tree, targetDir, callback) => {
- const targetSubdir = path.join(targetDir, tree.name);
+ const targetSubdir = join(targetDir, tree.name);
- fs.mkdir(targetSubdir, (err) => {
+ mkdir(targetSubdir, (err) => {
// Workaround for broken trees
if (err && err.code !== "EEXIST") {
return callback(err);
@@ -50,7 +50,7 @@ const gitToFsCopier = new Copier({
return emitter.emit("error", err);
}
- return async.parallel(entries.map((entry) => (callback) => {
+ return parallel(entries.map((entry) => (callback) => {
if (entry.isTree()) {
return entry.getTree((getTreeErr, subTree) => {
if (getTreeErr) {
diff --git a/BuildServer/lib/git/loader.ts b/BuildServer/lib/git/loader.ts
index 68dc97a..751604e 100644
--- a/BuildServer/lib/git/loader.ts
+++ b/BuildServer/lib/git/loader.ts
@@ -1,17 +1,9 @@
"use strict";
-import nodegit = require("nodegit");
-import fse = require("fs-extra");
+import { Repository, Remote } from "nodegit";
+import { mkdirsSync, removeSync } from "fs-extra";
import { gitToFs } from "./copy";
-const mkdirs = (path) => {
- fse.mkdirsSync(path); // eslint-disable-line no-sync
-};
-
-const removedirs = (path) => {
- fse.removeSync(path); // eslint-disable-line no-sync
-};
-
const fixUrl = (url) => {
if (!url.startsWith("https://")) {
return url;
@@ -30,19 +22,19 @@ options = {
}
*/
-export = (options, globalCallback) => {
+export const gitLoader = (options, globalCallback) => {
const url = fixUrl(options.remote);
const path = `${options.local}/${options.hash}`;
const exported = options.exported;
- removedirs(path);
- mkdirs(path);
+ removeSync(path); // eslint-disable-line no-sync
+ mkdirsSync(path); // eslint-disable-line no-sync
console.log(`Cloning ${url} to ${path}`);
- nodegit.Repository.init(path, 1)
+ Repository.init(path, 1)
.catch(globalCallback)
- .then((repo) => nodegit.Remote.create(repo, "origin", url)
+ .then((repo) => Remote.create(repo, "origin", url)
.catch(globalCallback)
.then((remote) => remote.fetch([options.branch])
.catch(globalCallback)
@@ -56,8 +48,8 @@ export = (options, globalCallback) => {
return repo.getCommit(options.hash)
.catch(globalCallback)
.then((commit) => {
- removedirs(exported);
- mkdirs(exported);
+ removeSync(exported);
+ mkdirsSync(exported);
gitToFs(commit, exported, (err, result) => {
repo.free();
diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts
index 07691db..7216e9d 100644
--- a/BuildServer/lib/report-processor.ts
+++ b/BuildServer/lib/report-processor.ts
@@ -1,11 +1,11 @@
"use strict";
-import path = require("path");
-import fs = require("fs");
-import zlib = require("zlib");
-import glob = require("glob");
-import streamBuffers = require("stream-buffers");
-import _ = require("underscore");
+import { join } from "path";
+import { createReadStream, createWriteStream, exists } from "fs";
+import { createGzip, createGunzip } from "zlib";
+import * as glob from "glob";
+import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers";
+import * as _ from "underscore";
const reportFilename = "report.json.gz";
const maxAttemptsNumber = 100;
@@ -30,12 +30,12 @@ export const writeReport = (releaseDir, err, result, callback) => {
result
});
- const readable = new streamBuffers.ReadableStreamBuffer(readableStreamBufferOptions);
- const writeStream = fs.createWriteStream(path.join(releaseDir, reportFilename));
+ const readable = new ReadableStreamBuffer(readableStreamBufferOptions);
+ const writeStream = createWriteStream(join(releaseDir, reportFilename));
readable
.on("error", callback)
- .pipe(zlib.createGzip())
+ .pipe(createGzip())
.on("error", callback)
.pipe(writeStream)
.on("error", callback)
@@ -49,12 +49,12 @@ export const writeReport = (releaseDir, err, result, callback) => {
};
export const readReport = (releaseDir, callback) => {
- const readStream = fs.createReadStream(path.join(releaseDir, reportFilename));
- const writable = new streamBuffers.WritableStreamBuffer();
+ const readStream = createReadStream(join(releaseDir, reportFilename));
+ const writable = new WritableStreamBuffer();
readStream
.on("error", callback)
- .pipe(zlib.createGunzip())
+ .pipe(createGunzip())
.on("error", callback)
.pipe(writable)
.on("error", callback)
@@ -72,7 +72,7 @@ export const readReport = (releaseDir, callback) => {
};
export const loadReport = (app, options, callback) => {
- const releaseDir = path.join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
+ const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
glob("**", {
"cwd": releaseDir,
@@ -82,10 +82,10 @@ export const loadReport = (app, options, callback) => {
return callback(err, options);
}
- const reportFile = path.join(releaseDir, reportFilename);
+ const reportFile = join(releaseDir, reportFilename);
- return fs.exists(reportFile, (exists) => {
- if (!exists) {
+ return exists(reportFile, (reportFileExists) => {
+ if (!reportFileExists) {
return callback("ReportFileNotFound", options);
}
@@ -105,12 +105,12 @@ export const loadReport = (app, options, callback) => {
export const getStatusMessageFromRelease = (app, originalOptions, callback) => {
const options = _.extend(originalOptions, { "attemptsGetReport": (Number(originalOptions.attemptsGetReport) || Number()) + 1 });
- const releaseDir = path.join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
- const reportFile = path.join(releaseDir, reportFilename);
+ const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
+ const reportFile = join(releaseDir, reportFilename);
- fs.exists(reportFile, (exists) => {
- if (!exists) {
- return setTimeout(() => fs.exists(releaseDir, (dirExists) => {
+ exists(reportFile, (reportFileExists) => {
+ if (!reportFileExists) {
+ return setTimeout(() => exists(releaseDir, (dirExists) => {
if (!dirExists) {
return callback("Release directory not found. Probably repository hooks are not configured");
}
diff --git a/BuildServer/lib/status-processor.ts b/BuildServer/lib/status-processor.ts
index a5f6a9e..41c7c5e 100644
--- a/BuildServer/lib/status-processor.ts
+++ b/BuildServer/lib/status-processor.ts
@@ -1,19 +1,19 @@
"use strict";
-import path = require("path");
-import fs = require("fs");
-import _ = require("underscore");
-import reportProcessor = require("./report-processor");
+import { join } from "path";
+import { exists, readFile } from "fs";
+import * as _ from "underscore";
+import { loadReport } from "./report-processor";
const addBranchInfo = (app, options, callback) => {
- const branchFile = path.join(app.get("releasepath"), options.owner, options.reponame, "$revs", `${options.rev}.branch`);
+ const branchFile = join(app.get("releasepath"), options.owner, options.reponame, "$revs", `${options.rev}.branch`);
- fs.exists(branchFile, (exists) => {
+ exists(branchFile, (exists) => {
if (!exists) {
return callback("BranchFileNotFound", options);
}
- return fs.readFile(branchFile, (err, data) => {
+ return readFile(branchFile, (err, data) => {
if (err) {
return callback(err, options);
}
@@ -31,14 +31,14 @@ const addBranchInfo = (app, options, callback) => {
};
const addRevInfo = (app, options, callback) => {
- const revFile = path.join(app.get("releasepath"), options.owner, options.reponame, options.branch, "latest.id");
+ const revFile = join(app.get("releasepath"), options.owner, options.reponame, options.branch, "latest.id");
- fs.exists(revFile, (exists) => {
+ exists(revFile, (exists) => {
if (!exists) {
return callback("RevFileNotFound", options);
}
- return fs.readFile(revFile, (err, data) => {
+ return readFile(revFile, (err, data) => {
if (err) {
return callback(err, options);
}
@@ -81,5 +81,5 @@ export const getReport = (app, options, callback) => parseOptions(app, options,
return callback(err, {});
}
- return reportProcessor.loadReport(app, result, callback);
+ return loadReport(app, result, callback);
});
diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts
index 97b9a6b..fb6cac3 100644
--- a/BuildServer/lib/task-processor.ts
+++ b/BuildServer/lib/task-processor.ts
@@ -1,6 +1,6 @@
"use strict";
-import _ = require("underscore");
+import * as _ from "underscore";
import tasks from "./tasks";
// TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here.
diff --git a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
index 56642b8..f21a29e 100644
--- a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
+++ b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
@@ -1,8 +1,8 @@
"use strict";
-import glob = require("glob");
+import * as glob from "glob";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
"cwd": processor.context.exported,
"dot": true
diff --git a/BuildServer/lib/tasks/conditional.ts b/BuildServer/lib/tasks/conditional.ts
index 9905e6f..ce8d2ff 100644
--- a/BuildServer/lib/tasks/conditional.ts
+++ b/BuildServer/lib/tasks/conditional.ts
@@ -1,6 +1,6 @@
"use strict";
-export = (params, processor) => {
+export default (params, processor) => {
const condition = (!params.owner || params.owner === processor.context.owner)
&& (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch);
const task = (condition && params.task) || params.otherwise;
diff --git a/BuildServer/lib/tasks/copy.ts b/BuildServer/lib/tasks/copy.ts
index 1783508..f03e29a 100644
--- a/BuildServer/lib/tasks/copy.ts
+++ b/BuildServer/lib/tasks/copy.ts
@@ -1,16 +1,16 @@
"use strict";
-import path = require("path");
-import fse = require("fs-extra");
+import { join } from "path";
+import { copy } from "fs-extra";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
- const sourceFilePath = path.join(processor.context.exported, params.filename);
- const targetFilePath = path.join(processor.context.release, params.filename);
+ const sourceFilePath = join(processor.context.exported, params.filename);
+ const targetFilePath = join(processor.context.release, params.filename);
processor.onInfo(`Copying ${sourceFilePath} to ${targetFilePath}`);
- fse.copy(sourceFilePath, targetFilePath, (err) => {
+ copy(sourceFilePath, targetFilePath, (err) => {
if (err) {
processor.onError(`Unable to copy file: ${err}`);
} else {
diff --git a/BuildServer/lib/tasks/copyglob.ts b/BuildServer/lib/tasks/copyglob.ts
index 63920f5..3f0d70d 100644
--- a/BuildServer/lib/tasks/copyglob.ts
+++ b/BuildServer/lib/tasks/copyglob.ts
@@ -1,8 +1,8 @@
"use strict";
-import glob = require("glob");
+import * as glob from "glob";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => glob(params.mask, {
"cwd": processor.context.exported,
"dot": true
diff --git a/BuildServer/lib/tasks/cssnano.ts b/BuildServer/lib/tasks/cssnano.ts
index d7cc248..103fd52 100644
--- a/BuildServer/lib/tasks/cssnano.ts
+++ b/BuildServer/lib/tasks/cssnano.ts
@@ -1,27 +1,27 @@
"use strict";
-import fs = require("fs");
-import path = require("path");
-import cssnano = require("cssnano");
+import { readFile, writeFile } from "fs";
+import { join } from "path";
+import { process as cssnanoProcess } from "cssnano";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
- const filePath = path.join(processor.context.exported, params.filename);
+ const filePath = join(processor.context.exported, params.filename);
- fs.readFile(filePath, (readErr, css) => {
+ readFile(filePath, (readErr, css) => {
if (readErr) {
processor.onError(`Unable to read stylesheet ${params.filename}: ${readErr}`);
return processor.done();
}
- return cssnano.process(css)
+ return cssnanoProcess(css)
.catch((cssErr) => {
processor.onError(`Unable to uglify stylesheet: ${cssErr}`);
processor.done();
})
.then((result) => {
- fs.writeFile(filePath, result.css, (writeErr) => {
+ writeFile(filePath, result.css, (writeErr) => {
if (writeErr) {
processor.onError(`Unable to write uglified stylesheet for ${params.filename}: ${writeErr}`);
} else {
diff --git a/BuildServer/lib/tasks/cssnanoall.ts b/BuildServer/lib/tasks/cssnanoall.ts
index 2e9d4ea..95c033f 100644
--- a/BuildServer/lib/tasks/cssnanoall.ts
+++ b/BuildServer/lib/tasks/cssnanoall.ts
@@ -1,9 +1,9 @@
"use strict";
-import glob = require("glob");
+import * as glob from "glob";
const flagDoneName = "cssnanoallDone";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/deletefromcode.ts b/BuildServer/lib/tasks/deletefromcode.ts
index d710e5e..b5ae2b7 100644
--- a/BuildServer/lib/tasks/deletefromcode.ts
+++ b/BuildServer/lib/tasks/deletefromcode.ts
@@ -1,15 +1,15 @@
"use strict";
-import path = require("path");
-import fse = require("fs-extra");
+import { join } from "path";
+import { remove } from "fs-extra";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
- const sourceFilePath = path.join(processor.context.exported, params.filename);
+ const sourceFilePath = join(processor.context.exported, params.filename);
processor.onInfo(`Deleting ${sourceFilePath}`);
- fse.remove(sourceFilePath, (err) => {
+ remove(sourceFilePath, (err) => {
if (err) {
processor.onError(`Unable to delete file: ${err}`);
} else {
diff --git a/BuildServer/lib/tasks/dotnetbuild.ts b/BuildServer/lib/tasks/dotnetbuild.ts
index d1b5029..7b31af9 100644
--- a/BuildServer/lib/tasks/dotnetbuild.ts
+++ b/BuildServer/lib/tasks/dotnetbuild.ts
@@ -1,8 +1,8 @@
"use strict";
-import sequential = require("./sequential");
+import sequential from "./sequential";
-export = (params, processor) => sequential({
+export default (params, processor) => sequential({
"tasks": [
{
"name": "build",
diff --git a/BuildServer/lib/tasks/dotnetbuildandtest.ts b/BuildServer/lib/tasks/dotnetbuildandtest.ts
index 9ab71ca..c4152cf 100644
--- a/BuildServer/lib/tasks/dotnetbuildandtest.ts
+++ b/BuildServer/lib/tasks/dotnetbuildandtest.ts
@@ -1,8 +1,8 @@
"use strict";
-import sequential = require("./sequential");
+import sequential from "./sequential";
-export = (params, processor) => sequential({
+export default (params, processor) => sequential({
"tasks": [
{
"name": "build",
diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
index f087282..144a46d 100644
--- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
+++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
@@ -1,12 +1,12 @@
"use strict";
import { spawn } from "child_process";
-import streamBuffers = require("stream-buffers");
-import settings = require("../../settings");
+import { WritableStreamBuffer } from "stream-buffers";
+import settings from "../../settings";
const wrapBuilder = (builder, input, onExit) => {
- const resultBuffer = new streamBuffers.WritableStreamBuffer();
- const errorBuffer = new streamBuffers.WritableStreamBuffer();
+ const resultBuffer = new WritableStreamBuffer();
+ const errorBuffer = new WritableStreamBuffer();
builder.stdout.on("data", (data) => {
resultBuffer.write(data);
@@ -34,7 +34,7 @@ const safeParseJson = (data):any => {
}
};
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
const input = JSON.stringify(params);
const builder = spawn(settings.builderExecutable, [params.command]);
diff --git a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
index efd9d38..00cee5d 100644
--- a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
+++ b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
@@ -1,6 +1,6 @@
"use strict";
-import sequential = require("./sequential");
+import sequential from "./sequential";
const createTasks = function *(params) {
if (!params.skipMbsCheckStyle) {
@@ -35,7 +35,7 @@ const createTasks = function *(params) {
};
};
-export = (params, processor) => {
+export default (params, processor) => {
const tasks = Array.from(createTasks(params));
return sequential({ tasks }, processor);
diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.ts b/BuildServer/lib/tasks/dotnetcheckstyle.ts
index 78340e8..9d19dc0 100644
--- a/BuildServer/lib/tasks/dotnetcheckstyle.ts
+++ b/BuildServer/lib/tasks/dotnetcheckstyle.ts
@@ -1,9 +1,9 @@
"use strict";
-import path = require("path");
-import fs = require("fs");
-import async = require("async");
-import glob = require("glob");
+import { join } from "path";
+import { readFile } from "fs";
+import { parallel } from "async";
+import * as glob from "glob";
const autoGeneratedMarker
= "//------------------------------------------------------------------------------\n"
@@ -11,7 +11,7 @@ const autoGeneratedMarker
const flagDoneName = "dotnetcheckerDone";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
return processor.done();
@@ -56,8 +56,8 @@ export = (params, processor) => ({
return processor.onInfo(`Checked file ${file}`);
};
- return async.parallel(files.map((file) => (callback) => fs.readFile(
- path.join(processor.context.exported, file),
+ return parallel(files.map((file) => (callback) => readFile(
+ join(processor.context.exported, file),
{ "encoding": "utf8" },
(readErr, data) => {
if (readErr) {
diff --git a/BuildServer/lib/tasks/dotnetcompile.ts b/BuildServer/lib/tasks/dotnetcompile.ts
index 6242593..6402298 100644
--- a/BuildServer/lib/tasks/dotnetcompile.ts
+++ b/BuildServer/lib/tasks/dotnetcompile.ts
@@ -1,11 +1,11 @@
"use strict";
-import path = require("path");
-import _ = require("underscore");
-import settings = require("../../settings");
-import dotnetbuilderwrapper = require("./dotnetbuilderwrapper");
+import { join } from "path";
+import * as _ from "underscore";
+import settings from "../../settings";
+import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
-export = (params, processor) => {
+export default (params, processor) => {
if (settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) {
processor.onError("Code analysis is not supported");
@@ -28,7 +28,7 @@ export = (params, processor) => {
"Configuration": params.configuration,
"OutputDirectory": params.overrideOutputDirectory,
"SkipCodeAnalysis": skipCodeAnalysis,
- "SolutionPath": path.join(processor.context.exported, params.solution),
+ "SolutionPath": join(processor.context.exported, params.solution),
"Target": params.target,
"command": "compile"
};
diff --git a/BuildServer/lib/tasks/dotnetnugetpack.ts b/BuildServer/lib/tasks/dotnetnugetpack.ts
index 2c1e9c6..736c0af 100644
--- a/BuildServer/lib/tasks/dotnetnugetpack.ts
+++ b/BuildServer/lib/tasks/dotnetnugetpack.ts
@@ -1,9 +1,9 @@
"use strict";
-import _ = require("underscore");
-import dotnetnugetprocessinternal = require("./dotnetnugetprocessinternal");
+import * as _ from "underscore";
+import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
-export = (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
+export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
"getFinalTask": (nupkg) => ({
"params": { "filename": nupkg },
"type": "copy"
diff --git a/BuildServer/lib/tasks/dotnetnugetprocess.ts b/BuildServer/lib/tasks/dotnetnugetprocess.ts
index 59ef522..5576fed 100644
--- a/BuildServer/lib/tasks/dotnetnugetprocess.ts
+++ b/BuildServer/lib/tasks/dotnetnugetprocess.ts
@@ -1,8 +1,8 @@
"use strict";
-import conditional = require("./conditional");
+import conditional from "./conditional";
-export = (params, processor) => conditional({
+export default (params, processor) => conditional({
"branch": "master",
"otherwise": {
"name": "nuget-pack",
diff --git a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
index 3db3aa7..2d8f8d7 100644
--- a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
+++ b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
@@ -1,7 +1,7 @@
"use strict";
-import path = require("path");
-import sequential = require("./sequential");
+import { join } from "path";
+import sequential from "./sequential";
const postfixLength = 16;
const fourDigits = 10000;
@@ -15,7 +15,7 @@ const addPostfix = (version, params, processor) => {
return `${version}-r${processor.context.rev.substr(0, postfixLength)}`;
};
-export = (params, processor) => {
+export default (params, processor) => {
const date = new Date();
const major = params.major || "0";
const minor = (date.getFullYear() * fourDigits) + ((date.getMonth() + 1) * twoDigits) + date.getDate();
@@ -29,7 +29,7 @@ export = (params, processor) => {
"params": {
"BaseDirectory": processor.context.exported,
"OutputDirectory": processor.context.exported,
- "SpecPath": path.join(processor.context.exported, params.nuspec),
+ "SpecPath": join(processor.context.exported, params.nuspec),
"Version": version,
"command": "nugetpack"
},
diff --git a/BuildServer/lib/tasks/dotnetnugetpush.ts b/BuildServer/lib/tasks/dotnetnugetpush.ts
index 4cf8ca3..e3a5aae 100644
--- a/BuildServer/lib/tasks/dotnetnugetpush.ts
+++ b/BuildServer/lib/tasks/dotnetnugetpush.ts
@@ -1,9 +1,9 @@
"use strict";
-import _ = require("underscore");
-import dotnetnugetprocessinternal = require("./dotnetnugetprocessinternal");
+import * as _ from "underscore";
+import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
-export = (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
+export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
"getFinalTask": (nupkg) => ({
"params": { "Package": nupkg },
"type": "dotnetnugetpushonly"
diff --git a/BuildServer/lib/tasks/dotnetnugetpushonly.ts b/BuildServer/lib/tasks/dotnetnugetpushonly.ts
index b551343..b1d9134 100644
--- a/BuildServer/lib/tasks/dotnetnugetpushonly.ts
+++ b/BuildServer/lib/tasks/dotnetnugetpushonly.ts
@@ -1,12 +1,12 @@
"use strict";
-import path = require("path");
-import dotnetbuilderwrapper = require("./dotnetbuilderwrapper");
-import settings = require("../../settings");
+import { join } from "path";
+import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
+import settings from "../../settings";
-export = (params, processor) => dotnetbuilderwrapper({
+export default (params, processor) => dotnetbuilderwrapper({
"ApiKey": settings.nugetApiKey,
"NugetHost": settings.nugetHost,
- "Package": path.join(processor.context.exported, params.Package),
+ "Package": join(processor.context.exported, params.Package),
"command": "nugetpush"
}, processor);
diff --git a/BuildServer/lib/tasks/dotnetnugetrestore.ts b/BuildServer/lib/tasks/dotnetnugetrestore.ts
index f62baa3..4e50f32 100644
--- a/BuildServer/lib/tasks/dotnetnugetrestore.ts
+++ b/BuildServer/lib/tasks/dotnetnugetrestore.ts
@@ -1,14 +1,14 @@
"use strict";
-import path = require("path");
-import sequential = require("./sequential");
+import { join } from "path";
+import sequential from "./sequential";
-export = (params, processor) => sequential({
+export default (params, processor) => sequential({
"tasks": [
{
"params": {
"BaseDirectory": processor.context.exported,
- "SolutionPath": path.join(processor.context.exported, params.solution),
+ "SolutionPath": join(processor.context.exported, params.solution),
"command": "nugetrestore"
},
"type": "dotnetbuilderwrapper"
diff --git a/BuildServer/lib/tasks/dotnetnunit.ts b/BuildServer/lib/tasks/dotnetnunit.ts
index 5f8ba6a..018ec23 100644
--- a/BuildServer/lib/tasks/dotnetnunit.ts
+++ b/BuildServer/lib/tasks/dotnetnunit.ts
@@ -1,9 +1,9 @@
"use strict";
-import path = require("path");
-import dotNetBuilderWrapper = require("./dotnetbuilderwrapper");
+import { join } from "path";
+import dotNetBuilderWrapper from "./dotnetbuilderwrapper";
-export = (params, processor) => dotNetBuilderWrapper({
- "TestLibraryPath": path.join(processor.context.exported, params.assembly),
+export default (params, processor) => dotNetBuilderWrapper({
+ "TestLibraryPath": join(processor.context.exported, params.assembly),
"command": "nunit"
}, processor);
diff --git a/BuildServer/lib/tasks/dotnetnunitall.ts b/BuildServer/lib/tasks/dotnetnunitall.ts
index 4ee6445..ee1b269 100644
--- a/BuildServer/lib/tasks/dotnetnunitall.ts
+++ b/BuildServer/lib/tasks/dotnetnunitall.ts
@@ -1,9 +1,9 @@
"use strict";
-import glob = require("glob");
+import * as glob from "glob";
const flagDoneName = "dotnetnunitallDone";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/dotnetpackwebapp.ts b/BuildServer/lib/tasks/dotnetpackwebapp.ts
index 070f167..08d7dfe 100644
--- a/BuildServer/lib/tasks/dotnetpackwebapp.ts
+++ b/BuildServer/lib/tasks/dotnetpackwebapp.ts
@@ -1,36 +1,36 @@
"use strict";
-import path = require("path");
-import fs = require("fs");
-import Mustache = require("mustache");
-import sequential = require("./sequential");
+import { join } from "path";
+import { readFileSync } from "fs";
+import { render } from "mustache";
+import sequential from "./sequential";
// eslint-disable-next-line no-sync
-const msbuildTemplate = fs.readFileSync(path.join(__dirname, "/dotnetpackwebapp.template.msbuild"), { "encoding": "utf8" });
+const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { "encoding": "utf8" });
// eslint-disable-next-line no-sync
-const deployTemplate = fs.readFileSync(path.join(__dirname, "/dotnetpackwebapp.template.bat"), { "encoding": "utf8" });
+const deployTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.bat"), { "encoding": "utf8" });
// eslint-disable-next-line no-sync
-const versionTemplate = fs.readFileSync(path.join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { "encoding": "utf8" });
+const versionTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { "encoding": "utf8" });
-export = (params, processor) => sequential({
+export default (params, processor) => sequential({
"tasks": [
{
"params": {
- "data": Mustache.render(msbuildTemplate, params),
+ "data": render(msbuildTemplate, params),
"filename": "MakePackage.msbuild"
},
"type": "writefile"
},
{
"params": {
- "data": Mustache.render(deployTemplate, params),
+ "data": render(deployTemplate, params),
"filename": "Deploy.bat"
},
"type": "writefile"
},
{
"params": {
- "data": Mustache.render(versionTemplate, params),
+ "data": render(versionTemplate, params),
"filename": "version.aspx"
},
"type": "writefile"
diff --git a/BuildServer/lib/tasks/dotnetrewrite.ts b/BuildServer/lib/tasks/dotnetrewrite.ts
index a91fbc9..1fccb6c 100644
--- a/BuildServer/lib/tasks/dotnetrewrite.ts
+++ b/BuildServer/lib/tasks/dotnetrewrite.ts
@@ -1,10 +1,10 @@
"use strict";
-import path = require("path");
-import fs = require("fs");
-import async = require("async");
-import glob = require("glob");
-import settings = require("../../settings");
+import { join } from "path";
+import { readFile, writeFile } from "fs";
+import { parallel, waterfall } from "async";
+import * as glob from "glob";
+import settings from "../../settings";
const flagDoneName = "dotnetrewriterDone";
@@ -31,7 +31,7 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => (
return cb(null, processInformationalVersion(processInternalsVisible(originalContent)));
};
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
return processor.done();
@@ -54,10 +54,10 @@ export = (params, processor) => ({
return processor.done();
}
- return async.parallel(files.map((file) => (callback) => async.waterfall([
- fs.readFile.bind(null, path.join(processor.context.exported, file), { "encoding": "utf8" }),
+ return parallel(files.map((file) => (callback) => waterfall([
+ readFile.bind(null, join(processor.context.exported, file), { "encoding": "utf8" }),
processAssemblyInfo(params, processor, file.toLowerCase().includes("assemblyinfo.cs")),
- fs.writeFile.bind(null, path.join(processor.context.exported, file))
+ writeFile.bind(null, join(processor.context.exported, file))
], (err) => {
if (err) {
processor.onError(`Unable to rewrite file ${file}: ${err}`);
diff --git a/BuildServer/lib/tasks/echo.ts b/BuildServer/lib/tasks/echo.ts
index d7079e5..e06d52c 100644
--- a/BuildServer/lib/tasks/echo.ts
+++ b/BuildServer/lib/tasks/echo.ts
@@ -1,6 +1,6 @@
"use strict";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
if (params.error) {
processor.onError(params.error);
diff --git a/BuildServer/lib/tasks/eslintbrowser.ts b/BuildServer/lib/tasks/eslintbrowser.ts
index 9a60085..6f13cb2 100644
--- a/BuildServer/lib/tasks/eslintbrowser.ts
+++ b/BuildServer/lib/tasks/eslintbrowser.ts
@@ -1,15 +1,15 @@
"use strict";
-import path = require("path");
+import { join } from "path";
import { CLIEngine } from "eslint";
-import settings = require("../../settings");
+import settings from "../../settings";
const cli = new CLIEngine({ "configFile": settings.eslintBrowserConfig });
const errorSeverity = 2;
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
- const filePath = path.join(processor.context.exported, params.filename);
+ const filePath = join(processor.context.exported, params.filename);
const result = cli.executeOnFiles([filePath]);
processor.onInfo(`ESLinted ${params.filename}`);
diff --git a/BuildServer/lib/tasks/eslintbrowserall.ts b/BuildServer/lib/tasks/eslintbrowserall.ts
index 8c3836a..f03bd4d 100644
--- a/BuildServer/lib/tasks/eslintbrowserall.ts
+++ b/BuildServer/lib/tasks/eslintbrowserall.ts
@@ -1,9 +1,9 @@
"use strict";
-import glob = require("glob");
+import * as glob from "glob";
const flagDoneName = "eslintbrowserallDone";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/index.ts b/BuildServer/lib/tasks/index.ts
index 4f0fc02..2f97c8e 100644
--- a/BuildServer/lib/tasks/index.ts
+++ b/BuildServer/lib/tasks/index.ts
@@ -10,7 +10,7 @@ require("fs").readdirSync(__dirname)
const name = file.replace(".ts", "");
// eslint-disable-next-line global-require
- tasks[name] = require(`./${file}`);
+ tasks[name] = require(`./${file}`).default;
}
});
diff --git a/BuildServer/lib/tasks/noop.ts b/BuildServer/lib/tasks/noop.ts
index e51c990..a5bad82 100644
--- a/BuildServer/lib/tasks/noop.ts
+++ b/BuildServer/lib/tasks/noop.ts
@@ -1,3 +1,3 @@
"use strict";
-export = (params, processor) => ({ "process": () => processor.done() });
+export default (params, processor) => ({ "process": () => processor.done() });
diff --git a/BuildServer/lib/tasks/packform.ts b/BuildServer/lib/tasks/packform.ts
index 6588cf3..fa4568f 100644
--- a/BuildServer/lib/tasks/packform.ts
+++ b/BuildServer/lib/tasks/packform.ts
@@ -1,8 +1,8 @@
"use strict";
-import sequential = require("./sequential");
+import sequential from "./sequential";
-export = (params, processor) => sequential({
+export default (params, processor) => sequential({
"tasks": [
{
"params": { "excludeFiles": params.eslintExcludeFiles },
diff --git a/BuildServer/lib/tasks/parallel.ts b/BuildServer/lib/tasks/parallel.ts
index c81415e..0bb5943 100644
--- a/BuildServer/lib/tasks/parallel.ts
+++ b/BuildServer/lib/tasks/parallel.ts
@@ -1,7 +1,7 @@
"use strict";
-import async = require("async");
+import { parallel } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-export = (params, processor) => ({ "process": () => async.parallel(params.tasks.map(mapper(processor)), () => processor.done()) });
+export default (params, processor) => ({ "process": () => parallel(params.tasks.map(mapper(processor)), () => processor.done()) });
diff --git a/BuildServer/lib/tasks/sequential.ts b/BuildServer/lib/tasks/sequential.ts
index 35b5abb..53ffbf6 100644
--- a/BuildServer/lib/tasks/sequential.ts
+++ b/BuildServer/lib/tasks/sequential.ts
@@ -1,7 +1,7 @@
"use strict";
-import async = require("async");
+import { series } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-export = (params, processor) => ({ "process": () => async.series(params.tasks.map(mapper(processor)), () => processor.done()) });
+export default (params, processor) => ({ "process": () => series(params.tasks.map(mapper(processor)), () => processor.done()) });
diff --git a/BuildServer/lib/tasks/uglifyjs.ts b/BuildServer/lib/tasks/uglifyjs.ts
index 094a2a3..6926d40 100644
--- a/BuildServer/lib/tasks/uglifyjs.ts
+++ b/BuildServer/lib/tasks/uglifyjs.ts
@@ -1,15 +1,15 @@
"use strict";
-import fs = require("fs");
-import path = require("path");
-import UglifyJS = require("uglify-js");
+import { writeFile } from "fs";
+import { join, normalize } from "path";
+import { minify } from "uglify-js";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
- const filePath = path.normalize(path.join(processor.context.exported, params.filename));
- const result = UglifyJS.minify(filePath);
+ const filePath = normalize(join(processor.context.exported, params.filename));
+ const result = minify(filePath);
- fs.writeFile(filePath, result.code, (err) => {
+ writeFile(filePath, result.code, (err) => {
if (err) {
processor.onError(`Unable to write uglified script for ${params.filename}: ${err}`);
} else {
diff --git a/BuildServer/lib/tasks/uglifyjsall.ts b/BuildServer/lib/tasks/uglifyjsall.ts
index 94bd135..cf634ea 100644
--- a/BuildServer/lib/tasks/uglifyjsall.ts
+++ b/BuildServer/lib/tasks/uglifyjsall.ts
@@ -1,10 +1,10 @@
"use strict";
-import glob = require("glob");
+import * as glob from "glob";
const doneFlagName = "uglifyjsallDone";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
if (processor.context.containsFlag(doneFlagName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
diff --git a/BuildServer/lib/tasks/writefile.ts b/BuildServer/lib/tasks/writefile.ts
index 340ff48..d20c696 100644
--- a/BuildServer/lib/tasks/writefile.ts
+++ b/BuildServer/lib/tasks/writefile.ts
@@ -1,15 +1,15 @@
"use strict";
-import fs = require("fs");
-import path = require("path");
+import { writeFile } from "fs";
+import { join } from "path";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
- const filePath = path.join(processor.context.exported, params.filename);
+ const filePath = join(processor.context.exported, params.filename);
processor.onInfo(`Writing to ${filePath}`);
- fs.writeFile(filePath, params.data, (err) => {
+ writeFile(filePath, params.data, (err) => {
if (err) {
processor.onError(`Unable to write file: ${err}`);
} else {
diff --git a/BuildServer/lib/tasks/zip.ts b/BuildServer/lib/tasks/zip.ts
index fac39db..b368d62 100644
--- a/BuildServer/lib/tasks/zip.ts
+++ b/BuildServer/lib/tasks/zip.ts
@@ -1,17 +1,17 @@
"use strict";
-import fs = require("fs");
-import path = require("path");
-import Archiver = require("archiver");
+import { createWriteStream } from "fs";
+import { join, normalize } from "path";
+import * as Archiver from "archiver";
-export = (params, processor) => ({
+export default (params, processor) => ({
"process": () => {
- const sourceDirectoryPath = path.normalize(path.join(processor.context.exported, String(params.directory || "")));
- const targetArchivePath = path.normalize(path.join(processor.context.release, params.archive));
+ const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || "")));
+ const targetArchivePath = normalize(join(processor.context.release, params.archive));
processor.onInfo(`Compressing "${params.directory}" to "${params.archive}"`);
- const output = fs.createWriteStream(targetArchivePath);
+ const output = createWriteStream(targetArchivePath);
const archive = new Archiver("zip");
output.on("close", () => processor.done());
diff --git a/BuildServer/routes/artifact.ts b/BuildServer/routes/artifact.ts
index c317233..d32e6b2 100644
--- a/BuildServer/routes/artifact.ts
+++ b/BuildServer/routes/artifact.ts
@@ -1,6 +1,6 @@
"use strict";
-export = (req, res) => {
+export default (req, res) => {
const options = {
"branch": `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch,
diff --git a/BuildServer/routes/index.ts b/BuildServer/routes/index.ts
index 15363c0..ce1c912 100644
--- a/BuildServer/routes/index.ts
+++ b/BuildServer/routes/index.ts
@@ -1,10 +1,10 @@
"use strict";
-import postreceive = require("./postreceive");
-import manual = require("./manual");
-import status = require("./status");
-import artifact = require("./artifact");
-import release = require("./release");
+import postreceive from "./postreceive";
+import * as manual from "./manual";
+import * as status from "./status";
+import artifact from "./artifact";
+import release from "./release";
const index = (req, res) => res.render("index", { "title": `Express
\r\n${req}` });
diff --git a/BuildServer/routes/manual.ts b/BuildServer/routes/manual.ts
index 337855e..ae4c86d 100644
--- a/BuildServer/routes/manual.ts
+++ b/BuildServer/routes/manual.ts
@@ -1,7 +1,7 @@
"use strict";
-import _ = require("underscore");
-import builder = require("../lib/builder");
+import * as _ from "underscore";
+import { build } from "../lib/builder";
export const get = (req, res) => res.render("manual");
@@ -11,7 +11,7 @@ export const post = (req, res) => {
"url": `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`
});
- builder.build(options, (err, result) => {
+ build(options, (err, result) => {
console.log("Done processing manual request");
console.log(`Error: ${err}`);
res.render("manual-done", {
diff --git a/BuildServer/routes/postreceive.ts b/BuildServer/routes/postreceive.ts
index 9507f16..591d19f 100644
--- a/BuildServer/routes/postreceive.ts
+++ b/BuildServer/routes/postreceive.ts
@@ -1,7 +1,7 @@
"use strict";
-import builder = require("../lib/builder");
-import commenter = require("../lib/commenter");
+import { build } from "../lib/builder";
+import { commentOnPullRequest } from "../lib/commenter";
const getBranchDescription = (options) => `${options.owner}/${options.reponame}:${options.branchname || options.branch}`;
@@ -18,7 +18,7 @@ const processPush = (req, res, payload) => {
console.log(`Got push event for ${getBranchDescription(options)}`);
- builder.build(options, (err, result) => {
+ build(options, (err, result) => {
console.log("Done processing request from GitHub");
console.log(`Error: ${err}`);
res.send(`Done processing request from GitHub\r\nError: ${err}\r\nResult: ${result}`);
@@ -78,7 +78,7 @@ const processPullRequest = (req, res, payload) => {
return res.send("");
}
- return commenter.commentOnPullRequest(
+ return commentOnPullRequest(
(action === "closed" && masterOptions) || options,
(err, data) => {
if (err) {
@@ -90,7 +90,7 @@ const processPullRequest = (req, res, payload) => {
);
};
-export = (req, res) => {
+export default (req, res) => {
if (!req.body || (!req.body.payload && !req.body.repository)) {
return res.end();
}
diff --git a/BuildServer/routes/release.ts b/BuildServer/routes/release.ts
index 8ad054a..c82fd9a 100644
--- a/BuildServer/routes/release.ts
+++ b/BuildServer/routes/release.ts
@@ -1,9 +1,9 @@
"use strict";
-import path = require("path");
-import Archiver = require("archiver");
+import { join } from "path";
+import * as Archiver from "archiver";
-import reportProcessor = require("../lib/report-processor");
+import { readReport } from "../lib/report-processor";
const getDatePart = (report) => {
if (!report.date) {
@@ -23,7 +23,7 @@ const getDatePart = (report) => {
return `${year}.${month}.${day}.${hours}.${minutes}.${seconds}`;
};
-export = (req, res, next) => {
+export default (req, res, next) => {
const options = {
"branch": `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch,
@@ -32,9 +32,9 @@ export = (req, res, next) => {
"rev": req.params.rev
};
- const releasePath = path.join(req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
+ const releasePath = join(req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
- reportProcessor.readReport(releasePath, (err, report) => {
+ readReport(releasePath, (err, report) => {
if (err) {
return next(err);
}
diff --git a/BuildServer/routes/status.ts b/BuildServer/routes/status.ts
index dbb75c4..bea269f 100644
--- a/BuildServer/routes/status.ts
+++ b/BuildServer/routes/status.ts
@@ -1,8 +1,8 @@
"use strict";
-import url = require("url");
-import _ = require("underscore");
-import statusProcessor = require("../lib/status-processor");
+import { parse } from "url";
+import * as _ from "underscore";
+import { getReport } from "../lib/status-processor";
const parseOptionsFromReferer = (path, callback) => {
const pathParts = path.split("/").filter((value) => value);
@@ -89,12 +89,12 @@ export const image = (req, res) => {
res.render("status-image", _.extend(options, getAdditionalOptions(err, options)));
};
- parseOptionsFromReferer(url.parse(req.headers.referer || "").pathname || "", (err, options) => {
+ parseOptionsFromReferer(parse(req.headers.referer || "").pathname || "", (err, options) => {
if (err) {
return handle(err, options);
}
- return statusProcessor.getReport(req.app, options, handle);
+ return getReport(req.app, options, handle);
});
};
@@ -107,7 +107,7 @@ export const page = (req, res) => {
"rev": req.params.rev
};
- statusProcessor.getReport(req.app, options, createShowReport(res));
+ getReport(req.app, options, createShowReport(res));
};
export const pageFromGithub = (req, res) => parseOptionsFromReferer(req.params[0], (err, options) => {
@@ -115,5 +115,5 @@ export const pageFromGithub = (req, res) => parseOptionsFromReferer(req.params[0
return createShowReport(res)(err, options);
}
- return statusProcessor.getReport(req.app, options, createShowReport(res));
+ return getReport(req.app, options, createShowReport(res));
});
diff --git a/BuildServer/settings.ts.example b/BuildServer/settings.ts.example
index 77d7fc3..55b6396 100644
--- a/BuildServer/settings.ts.example
+++ b/BuildServer/settings.ts.example
@@ -1,6 +1,6 @@
"use strict";
-const GitHubApi = require("github");
+import GitHubApi = require("github");
const createGithub = () => new GitHubApi({
"debug": false,
@@ -8,11 +8,10 @@ const createGithub = () => new GitHubApi({
"host": "pos-github.payonline.ru",
"pathPrefix": "/api/v3",
"protocol": "https",
- "timeout": 5000,
- "version": "3.0.0"
+ "timeout": 5000
});
-export = {
+export default {
"builderExecutable": "../DotNetBuilder/bin/Debug/MicroBuildServer.DotNetBuilder.exe",
"codeSigningKeyFile": null,
"codeSigningPublicKey": null,
From fa07bbd6350c953db63467a52bf5b796215aa151 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 22 Feb 2017 17:28:40 +0300
Subject: [PATCH 03/13] json-parse-safe package used instead of JSON.parse
---
BuildServer/lib/builder.ts | 17 +++++------------
BuildServer/lib/report-processor.ts | 9 +++++++--
BuildServer/lib/tasks/dotnetbuilderwrapper.ts | 17 +++++------------
BuildServer/package.json | 1 +
BuildServer/routes/postreceive.ts | 11 ++++++++++-
5 files changed, 28 insertions(+), 27 deletions(-)
diff --git a/BuildServer/lib/builder.ts b/BuildServer/lib/builder.ts
index 09181a5..422e3c8 100644
--- a/BuildServer/lib/builder.ts
+++ b/BuildServer/lib/builder.ts
@@ -4,6 +4,7 @@ import { join } from "path";
import { exists, readFile, writeFileSync } from "fs";
import { mkdirsSync, remove } from "fs-extra";
import { parallel, queue } from "async";
+import * as JSONParse from "json-parse-safe";
import { gitLoader } from "./git/loader";
import { processTask } from "./task-processor";
import { writeReport } from "./report-processor";
@@ -62,14 +63,6 @@ const wrapGitLoader = (skipGitLoader) => {
return (gitLoaderOptions, gitLoaderCallback) => process.nextTick(gitLoaderCallback);
};
-const safeParseJson = (data):any => {
- try {
- return { "parsed": JSON.parse(data) };
- } catch (err) {
- return { err };
- }
-};
-
export const build = (options, buildCallback) => {
const url = options.url;
const owner = options.owner;
@@ -187,15 +180,15 @@ export const build = (options, buildCallback) => {
return done(readErr, "MBSUnableToRead");
}
- const { parsed, err } = safeParseJson(data);
+ const { value, error } = JSONParse(data);
- if (err) {
+ if (error) {
console.log(`Malformed data: ${data}`);
- return done(err, "MBSMalformed");
+ return done(error, "MBSMalformed");
}
- return processTask(parsed, {
+ return processTask(value, {
branch,
exported,
owner,
diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts
index 7216e9d..b11014b 100644
--- a/BuildServer/lib/report-processor.ts
+++ b/BuildServer/lib/report-processor.ts
@@ -6,6 +6,7 @@ import { createGzip, createGunzip } from "zlib";
import * as glob from "glob";
import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers";
import * as _ from "underscore";
+import * as JSONParse from "json-parse-safe";
const reportFilename = "report.json.gz";
const maxAttemptsNumber = 100;
@@ -62,12 +63,16 @@ export const readReport = (releaseDir, callback) => {
readStream.destroy();
const data = writable.getContentsAsString();
-
if (!data) {
return callback("ReportFileNotFound");
}
- return callback(null, JSON.parse(data));
+ const { error, value } = JSONParse(data);
+ if (error) {
+ return callback("ReportFileMalformed");
+ }
+
+ return callback(null, value);
});
};
diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
index 144a46d..dc9fa78 100644
--- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
+++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
@@ -2,6 +2,7 @@
import { spawn } from "child_process";
import { WritableStreamBuffer } from "stream-buffers";
+import * as JSONParse from "json-parse-safe";
import settings from "../../settings";
const wrapBuilder = (builder, input, onExit) => {
@@ -26,14 +27,6 @@ const wrapBuilder = (builder, input, onExit) => {
builder.stdin.end();
};
-const safeParseJson = (data):any => {
- try {
- return { "parsed": JSON.parse(data) };
- } catch (err) {
- return { err };
- }
-};
-
export default (params, processor) => ({
"process": () => {
const input = JSON.stringify(params);
@@ -48,16 +41,16 @@ export default (params, processor) => ({
return processor.done();
}
- const { parsed, err } = safeParseJson(result);
+ const { value, error } = JSONParse(result);
- if (err || !parsed || !parsed.Messages) {
- processor.onError(`Malformed JSON: ${err}`);
+ if (error || !value || !value.Messages) {
+ processor.onError(`Malformed JSON: ${error}`);
processor.onInfo(result);
return processor.done();
}
- const messages = parsed.Messages;
+ const messages = value.Messages;
messages.forEach((message) => {
if (!message) {
diff --git a/BuildServer/package.json b/BuildServer/package.json
index ccdda39..ae07877 100644
--- a/BuildServer/package.json
+++ b/BuildServer/package.json
@@ -19,6 +19,7 @@
"glob": "~7.1.1",
"graceful-fs": "^4.1.11",
"jade": "*",
+ "json-parse-safe": "^1.0.3",
"method-override": "^2.3.7",
"morgan": "^1.7.0",
"mustache": "~2.3.0",
diff --git a/BuildServer/routes/postreceive.ts b/BuildServer/routes/postreceive.ts
index 591d19f..ab68958 100644
--- a/BuildServer/routes/postreceive.ts
+++ b/BuildServer/routes/postreceive.ts
@@ -1,5 +1,6 @@
"use strict";
+import * as JSONParse from "json-parse-safe";
import { build } from "../lib/builder";
import { commentOnPullRequest } from "../lib/commenter";
@@ -90,13 +91,21 @@ const processPullRequest = (req, res, payload) => {
);
};
+const getPayload = (body) => {
+ if (!body.payload) {
+ return body;
+ }
+
+ return JSONParse(body.payload).value;
+}
+
export default (req, res) => {
if (!req.body || (!req.body.payload && !req.body.repository)) {
return res.end();
}
const eventType = req.header("x-github-event");
- const payload = (req.body.payload && JSON.parse(req.body.payload)) || req.body;
+ const payload = getPayload(req.body);
if (eventType === "push") {
return processPush(req, res, payload);
From 80a7b9f4204482e8045f8b0a5190e28d0bedb0a8 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 22 Feb 2017 17:46:19 +0300
Subject: [PATCH 04/13] safeGetEntries typing improved
---
BuildServer/lib/git/copy.ts | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/BuildServer/lib/git/copy.ts b/BuildServer/lib/git/copy.ts
index c345a0e..9fe1177 100644
--- a/BuildServer/lib/git/copy.ts
+++ b/BuildServer/lib/git/copy.ts
@@ -6,11 +6,11 @@ import { writeFile, mkdir } from "fs";
import { parallel } from "async";
import { Copier } from "recursive-tree-copy";
-const safeGetEntries = (tree):any => {
+const safeGetEntries = (tree, callback) => {
try {
- return { "entries": tree.gitTree.entries() };
+ return callback(null, tree.gitTree.entries());
} catch (err) {
- return { err };
+ return callback(err);
}
};
@@ -43,11 +43,9 @@ const gitToFsCopier = new Copier({
"walkSourceTree": (tree) => {
const emitter = new EventEmitter();
- process.nextTick(() => {
- const { entries, err } = safeGetEntries(tree);
-
- if (err) {
- return emitter.emit("error", err);
+ process.nextTick(() => safeGetEntries(tree, (getEntriesErr, entries) => {
+ if (getEntriesErr) {
+ return emitter.emit("error", getEntriesErr);
}
return parallel(entries.map((entry) => (callback) => {
@@ -80,7 +78,7 @@ const gitToFsCopier = new Copier({
return emitter.emit("done");
});
- });
+ }));
return emitter;
}
From 58c26534511af7534f2d2f2eaf67d545e052b5d9 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Mon, 27 Feb 2017 16:31:50 +0300
Subject: [PATCH 05/13] TSLint installed
---
BuildServer/.gitignore | 1 +
BuildServer/package.json | 5 +-
BuildServer/tsconfig.json | 9 +++-
BuildServer/tslint.json | 101 ++++++++++++++++++++++++++++++++++++++
BuildServer/typings.json | 5 ++
5 files changed, 118 insertions(+), 3 deletions(-)
create mode 100644 BuildServer/tslint.json
create mode 100644 BuildServer/typings.json
diff --git a/BuildServer/.gitignore b/BuildServer/.gitignore
index 285b65b..86f6aa2 100644
--- a/BuildServer/.gitignore
+++ b/BuildServer/.gitignore
@@ -18,5 +18,6 @@ data
*.crt
settings.js
settings.ts
+*.d.ts
iisnode
diff --git a/BuildServer/package.json b/BuildServer/package.json
index ae07877..dcaca7b 100644
--- a/BuildServer/package.json
+++ b/BuildServer/package.json
@@ -4,7 +4,8 @@
"private": true,
"scripts": {
"start": "forever -c node app.js",
- "test": "./node_modules/.bin/eslint ."
+ "test": "./node_modules/.bin/eslint .",
+ "tslint": "./node_modules/.bin/tslint --project tsconfig.json --type-check --force"
},
"dependencies": {
"archiver": "^1.3.0",
@@ -133,6 +134,6 @@
"devDependencies": {
"@types/node": "^7.0.5",
"tslint": "^4.4.2",
- "typescript": "^2.1.6"
+ "typescript": "^2.2.1"
}
}
diff --git a/BuildServer/tsconfig.json b/BuildServer/tsconfig.json
index fe3b5ae..be0fb57 100644
--- a/BuildServer/tsconfig.json
+++ b/BuildServer/tsconfig.json
@@ -1,8 +1,15 @@
{
"compilerOptions": {
+ "module": "commonjs",
"target": "es6",
"typeRoots": [
"node_modules/@types"
]
- }
+ },
+ "include": [
+ "app.ts",
+ "settings.ts",
+ "lib/**/*.ts",
+ "routes/**/*.ts"
+ ]
}
diff --git a/BuildServer/tslint.json b/BuildServer/tslint.json
new file mode 100644
index 0000000..1a58f91
--- /dev/null
+++ b/BuildServer/tslint.json
@@ -0,0 +1,101 @@
+{
+ "jsRules": {
+ "class-name": true,
+ "comment-format": [
+ true,
+ "check-space"
+ ],
+ "indent": [
+ true,
+ "spaces"
+ ],
+ "no-duplicate-variable": true,
+ "no-eval": true,
+ "no-trailing-whitespace": true,
+ "no-unsafe-finally": true,
+ "one-line": [
+ true,
+ "check-open-brace",
+ "check-whitespace"
+ ],
+ "quotemark": [
+ true,
+ "double"
+ ],
+ "semicolon": [
+ true,
+ "always"
+ ],
+ "triple-equals": [
+ true,
+ "allow-null-check"
+ ],
+ "variable-name": [
+ true,
+ "ban-keywords"
+ ],
+ "whitespace": [
+ true,
+ "check-branch",
+ "check-decl",
+ "check-operator",
+ "check-separator",
+ "check-type"
+ ]
+ },
+ "rules": {
+ "class-name": true,
+ "comment-format": [
+ true,
+ "check-space"
+ ],
+ "indent": [
+ true,
+ "spaces"
+ ],
+ "no-eval": true,
+ "no-internal-module": true,
+ "no-trailing-whitespace": true,
+ "no-unsafe-finally": true,
+ "no-var-keyword": true,
+ "one-line": [
+ true,
+ "check-open-brace",
+ "check-whitespace"
+ ],
+ "quotemark": [
+ true,
+ "double"
+ ],
+ "semicolon": [
+ true,
+ "always"
+ ],
+ "triple-equals": [
+ true,
+ "allow-null-check"
+ ],
+ "typedef-whitespace": [
+ true,
+ {
+ "call-signature": "nospace",
+ "index-signature": "nospace",
+ "parameter": "nospace",
+ "property-declaration": "nospace",
+ "variable-declaration": "nospace"
+ }
+ ],
+ "variable-name": [
+ true,
+ "ban-keywords"
+ ],
+ "whitespace": [
+ true,
+ "check-branch",
+ "check-decl",
+ "check-operator",
+ "check-separator",
+ "check-type"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/BuildServer/typings.json b/BuildServer/typings.json
new file mode 100644
index 0000000..7b7ef5e
--- /dev/null
+++ b/BuildServer/typings.json
@@ -0,0 +1,5 @@
+{
+ "dependencies": {
+ "debug": "registry:npm/debug#2.0.0+20160723033700"
+ }
+}
From 9376803f407e735c39941061c6e0aedb8bc90321 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Mon, 27 Feb 2017 16:36:33 +0300
Subject: [PATCH 06/13] Code style fixes
---
BuildServer/lib/commenter.ts | 4 ++--
BuildServer/lib/git/loader.ts | 6 +++---
BuildServer/lib/tasks/index.ts | 2 +-
BuildServer/routes/postreceive.ts | 8 ++++----
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/BuildServer/lib/commenter.ts b/BuildServer/lib/commenter.ts
index 1504347..0f3fc20 100644
--- a/BuildServer/lib/commenter.ts
+++ b/BuildServer/lib/commenter.ts
@@ -13,7 +13,7 @@ const maxCommentLength = 64000;
const writeComment = (options, message, callback) => options.github.issues.createComment({
"body": message,
- "number": options.number,
+ "number": options.pullRequestNumber,
"owner": options.baseRepoOptions.owner,
"repo": options.baseRepoOptions.reponame
}, callback);
@@ -24,7 +24,7 @@ const closePullRequest = (options, message, callback) => writeComment(options, m
}
return options.github.issues.edit({
- "number": options.number,
+ "number": options.pullRequestNumber,
"owner": options.baseRepoOptions.owner,
"repo": options.baseRepoOptions.reponame,
"state": "closed"
diff --git a/BuildServer/lib/git/loader.ts b/BuildServer/lib/git/loader.ts
index 751604e..a98d9ba 100644
--- a/BuildServer/lib/git/loader.ts
+++ b/BuildServer/lib/git/loader.ts
@@ -38,9 +38,9 @@ export const gitLoader = (options, globalCallback) => {
.catch(globalCallback)
.then((remote) => remote.fetch([options.branch])
.catch(globalCallback)
- .then((number) => {
- if (number) {
- return globalCallback(`Failed to fetch commit: error number ${number}`);
+ .then((errorNumber) => {
+ if (errorNumber) {
+ return globalCallback(`Failed to fetch commit: error number ${errorNumber}`);
}
console.log(`Cloned ${url} to ${path}`);
diff --git a/BuildServer/lib/tasks/index.ts b/BuildServer/lib/tasks/index.ts
index 2f97c8e..c53c39c 100644
--- a/BuildServer/lib/tasks/index.ts
+++ b/BuildServer/lib/tasks/index.ts
@@ -1,6 +1,6 @@
"use strict";
-var tasks = {};
+let tasks = {};
// Code taken from http://stackoverflow.com/a/17204293
// eslint-disable-next-line no-sync
diff --git a/BuildServer/routes/postreceive.ts b/BuildServer/routes/postreceive.ts
index ab68958..504516d 100644
--- a/BuildServer/routes/postreceive.ts
+++ b/BuildServer/routes/postreceive.ts
@@ -28,7 +28,7 @@ const processPush = (req, res, payload) => {
const processPullRequest = (req, res, payload) => {
const action = payload.action;
- const number = payload.number;
+ const pullRequestNumber = payload.number;
const pullRequest = payload.pull_request;
const head = pullRequest.head;
const headRepo = head.repo;
@@ -52,14 +52,14 @@ const processPullRequest = (req, res, payload) => {
"app": req.app,
baseRepoOptions,
headRepoOptions,
- number
+ pullRequestNumber
};
const masterOptions = {
action,
"app": req.app,
baseRepoOptions,
"headRepoOptions": baseRepoOptions,
- number
+ pullRequestNumber
};
console.log(`Got pull request ${action} event, `
@@ -97,7 +97,7 @@ const getPayload = (body) => {
}
return JSONParse(body.payload).value;
-}
+};
export default (req, res) => {
if (!req.body || (!req.body.payload && !req.body.repository)) {
From c54d004d72baccb7e9b671e87cacd7d54986299a Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Tue, 28 Feb 2017 11:04:41 +0300
Subject: [PATCH 07/13] Typings added; code style improved
---
BuildServer/app.ts | 6 +-
BuildServer/lib/builder.ts | 2 +-
BuildServer/lib/report-processor.ts | 44 ++++++++--
BuildServer/lib/tasks/zip.ts | 4 +-
BuildServer/package.json | 122 +++++-----------------------
BuildServer/routes/release.ts | 4 +-
BuildServer/tsconfig.json | 4 +
7 files changed, 71 insertions(+), 115 deletions(-)
diff --git a/BuildServer/app.ts b/BuildServer/app.ts
index bf4b741..5ca853e 100644
--- a/BuildServer/app.ts
+++ b/BuildServer/app.ts
@@ -1,9 +1,9 @@
"use strict";
-import * as realFs from "fs";
-import * as fs from "graceful-fs";
+import * as fs from "fs";
+import { gracefulify } from "graceful-fs";
-fs.gracefulify(realFs);
+gracefulify(fs);
import * as express from "express";
import * as routes from "./routes";
diff --git a/BuildServer/lib/builder.ts b/BuildServer/lib/builder.ts
index 422e3c8..bdb7c68 100644
--- a/BuildServer/lib/builder.ts
+++ b/BuildServer/lib/builder.ts
@@ -74,7 +74,7 @@ export const build = (options, buildCallback) => {
const tmp = join(options.app.get("tmpcodepath"), rev.substr(0, maxTmpcodepathLength));
const exported = tmp + codePostfix;
const release = join(options.app.get("releasepath"), owner, reponame, branch, rev);
- const statusQueue = queue((task, queueCallback) => task(queueCallback), 1);
+ const statusQueue = queue((task: (callback: any) => void, queueCallback) => task(queueCallback), 1);
const actualGitLoader = wrapGitLoader(skipGitLoader);
const date = new Date();
const versionMajor = date.getFullYear();
diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts
index b11014b..e824786 100644
--- a/BuildServer/lib/report-processor.ts
+++ b/BuildServer/lib/report-processor.ts
@@ -8,6 +8,40 @@ import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers";
import * as _ from "underscore";
import * as JSONParse from "json-parse-safe";
+interface Message {
+ message: string;
+ prefix: string;
+};
+
+interface PartialMessagesLeaf {
+ $messages: string[];
+};
+
+interface PartialMessagesRecursive {
+ [propName: string]: Messages;
+};
+
+interface PartialMessagesRoot {
+ $allMessages: Message[];
+};
+
+type Messages = PartialMessagesLeaf & PartialMessagesRecursive;
+
+type MessagesRoot = PartialMessagesLeaf & PartialMessagesRecursive & PartialMessagesRoot;
+
+interface ReportResult {
+ errors: MessagesRoot;
+ warns: MessagesRoot;
+ infos: MessagesRoot;
+ messages: MessagesRoot;
+};
+
+interface Report {
+ date: number;
+ err?: string;
+ result?: ReportResult;
+};
+
const reportFilename = "report.json.gz";
const maxAttemptsNumber = 100;
const attemptsTimeout = 30000;
@@ -20,11 +54,11 @@ const readableStreamBufferOptions = {
"frequency": 1
};
-const getAllErrors = (report) => ((report.result || {}).errors || {}).$allMessages || [];
-const getAllWarns = (report) => ((report.result || {}).warns || {}).$allMessages || [];
-const getAllInfos = (report) => ((report.result || {}).infos || {}).$allMessages || [];
+const getAllErrors = (report: Report): Message[] => (report.result && report.result.errors && report.result.errors.$allMessages) || [];
+const getAllWarns = (report: Report): Message[] => (report.result && report.result.warns && report.result.errors.$allMessages) || [];
+const getAllInfos = (report: Report): Message[] => (report.result && report.result.infos && report.result.errors.$allMessages) || [];
-export const writeReport = (releaseDir, err, result, callback) => {
+export const writeReport = (releaseDir, err, result: ReportResult, callback) => {
const data = JSON.stringify({
"date": Date.now(),
err,
@@ -67,7 +101,7 @@ export const readReport = (releaseDir, callback) => {
return callback("ReportFileNotFound");
}
- const { error, value } = JSONParse(data);
+ const { error, value }: { error: any, value?: Report } = JSONParse(data);
if (error) {
return callback("ReportFileMalformed");
}
diff --git a/BuildServer/lib/tasks/zip.ts b/BuildServer/lib/tasks/zip.ts
index b368d62..5c2a476 100644
--- a/BuildServer/lib/tasks/zip.ts
+++ b/BuildServer/lib/tasks/zip.ts
@@ -2,7 +2,7 @@
import { createWriteStream } from "fs";
import { join, normalize } from "path";
-import * as Archiver from "archiver";
+import { create as createArchiver } from "archiver";
export default (params, processor) => ({
"process": () => {
@@ -12,7 +12,7 @@ export default (params, processor) => ({
processor.onInfo(`Compressing "${params.directory}" to "${params.archive}"`);
const output = createWriteStream(targetArchivePath);
- const archive = new Archiver("zip");
+ const archive = createArchiver("zip");
output.on("close", () => processor.done());
diff --git a/BuildServer/package.json b/BuildServer/package.json
index dcaca7b..a3087d6 100644
--- a/BuildServer/package.json
+++ b/BuildServer/package.json
@@ -4,8 +4,9 @@
"private": true,
"scripts": {
"start": "forever -c node app.js",
- "test": "./node_modules/.bin/eslint .",
- "tslint": "./node_modules/.bin/tslint --project tsconfig.json --type-check --force"
+ "build": "./node_modules/.bin/tsc -p .",
+ "pretest": "./node_modules/.bin/tsc -p . --noEmit",
+ "test": "./node_modules/.bin/tslint --project tsconfig.json --type-check"
},
"dependencies": {
"archiver": "^1.3.0",
@@ -16,7 +17,7 @@
"eslint": "^3.12.2",
"express": "4.14.0",
"fs-extra": "^1.0.0",
- "github": "~7.1.0",
+ "github": "~9.0.0",
"glob": "~7.1.1",
"graceful-fs": "^4.1.11",
"jade": "*",
@@ -25,7 +26,6 @@
"morgan": "^1.7.0",
"mustache": "~2.3.0",
"nodegit": "~0.16.0",
- "nodemailer": "~2.7.0",
"recursive-tree-copy": "0.0.1",
"serve-favicon": "^2.3.2",
"serve-static": "^1.11.1",
@@ -33,106 +33,24 @@
"uglify-js": "^2.7.5",
"underscore": "^1.8.3"
},
- "eslintConfig": {
- "env": {
- "node": true
- },
- "parserOptions": {
- "ecmaVersion": 6
- },
- "plugins": [
- "fp"
- ],
- "extends": [
- "eslint:all",
- "plugin:fp/recommended"
- ],
- "rules": {
- "fp/no-unused-expression": "off",
- "fp/no-nil": "off",
- "fp/no-mutation": [
- "error",
- {
- "commonjs": true
- }
- ],
- "prefer-destructuring": "off",
- "quotes": [
- "warn",
- "double"
- ],
- "require-jsdoc": "off",
- "func-names": [
- "warn",
- "never"
- ],
- "max-len": [
- "warn",
- {
- "code": 140
- }
- ],
- "operator-linebreak": [
- "warn",
- "before"
- ],
- "padded-blocks": [
- "warn",
- "never"
- ],
- "dot-notation": [
- "warn",
- {
- "allowPattern": "^[a-z]+(_[a-z]+)+$"
- }
- ],
- "linebreak-style": [
- "warn",
- "windows"
- ],
- "no-console": "off",
- "dot-location": [
- "warn",
- "property"
- ],
- "object-curly-spacing": [
- "warn",
- "always"
- ],
- "one-var": [
- "warn",
- {
- "initialized": "never"
- }
- ],
- "no-magic-numbers": [
- "warn",
- {
- "ignore": [
- 0,
- 1
- ]
- }
- ],
- "id-length": [
- "warn",
- {
- "exceptions": [
- "_"
- ]
- }
- ],
- "no-extra-parens": [
- "warn",
- "all",
- {
- "nestedBinaryExpressions": false
- }
- ]
- }
- },
"devDependencies": {
+ "@types/archiver": "^0.15.37",
+ "@types/async": "^2.0.38",
+ "@types/body-parser": "0.0.34",
+ "@types/errorhandler": "0.0.30",
+ "@types/express": "^4.0.35",
+ "@types/fs-extra": "0.0.37",
+ "@types/github": "0.0.0",
+ "@types/glob": "^5.0.30",
+ "@types/jade": "0.0.30",
+ "@types/method-override": "0.0.29",
+ "@types/morgan": "^1.7.32",
+ "@types/mustache": "^0.8.29",
"@types/node": "^7.0.5",
+ "@types/serve-favicon": "^2.2.28",
+ "@types/serve-static": "^1.7.31",
+ "@types/uglify-js": "^2.6.28",
+ "@types/underscore": "^1.7.36",
"tslint": "^4.4.2",
"typescript": "^2.2.1"
}
diff --git a/BuildServer/routes/release.ts b/BuildServer/routes/release.ts
index c82fd9a..c4d5f0c 100644
--- a/BuildServer/routes/release.ts
+++ b/BuildServer/routes/release.ts
@@ -1,7 +1,7 @@
"use strict";
import { join } from "path";
-import * as Archiver from "archiver";
+import { create as createArchiver } from "archiver";
import { readReport } from "../lib/report-processor";
@@ -39,7 +39,7 @@ export default (req, res, next) => {
return next(err);
}
- const archive = new Archiver("zip");
+ const archive = createArchiver("zip");
archive.on("error", next);
res.attachment(`${options.reponame}.${getDatePart(report)}.${options.rev}.zip`, ".");
diff --git a/BuildServer/tsconfig.json b/BuildServer/tsconfig.json
index be0fb57..4ce9f95 100644
--- a/BuildServer/tsconfig.json
+++ b/BuildServer/tsconfig.json
@@ -2,6 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"target": "es6",
+ "sourceMap": false,
"typeRoots": [
"node_modules/@types"
]
@@ -11,5 +12,8 @@
"settings.ts",
"lib/**/*.ts",
"routes/**/*.ts"
+ ],
+ "exclude": [
+ "node_modules/**/*.ts"
]
}
From bec09d8c9f0b94ae3bde2f0531340e37f2683689 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Tue, 28 Feb 2017 16:12:43 +0300
Subject: [PATCH 08/13] Code style
---
BuildServer/app.ts | 16 +--
BuildServer/lib/builder.ts | 53 ++++-----
BuildServer/lib/commenter.ts | 38 ++++---
BuildServer/lib/git/copy.ts | 26 ++---
BuildServer/lib/git/loader.ts | 7 +-
BuildServer/lib/report-processor.ts | 68 +++---------
BuildServer/lib/status-processor.ts | 17 +--
BuildServer/lib/task-processor.ts | 54 ++++-----
.../lib/tasks/cleanupafterdotnetbuild.ts | 26 ++---
BuildServer/lib/tasks/conditional.ts | 6 +-
BuildServer/lib/tasks/copy.ts | 10 +-
BuildServer/lib/tasks/copyglob.ts | 26 ++---
BuildServer/lib/tasks/cssnano.ts | 11 +-
BuildServer/lib/tasks/cssnanoall.ts | 26 ++---
BuildServer/lib/tasks/deletefromcode.ts | 10 +-
BuildServer/lib/tasks/dotnetbuild.ts | 18 +--
BuildServer/lib/tasks/dotnetbuildandtest.ts | 22 ++--
BuildServer/lib/tasks/dotnetbuilderwrapper.ts | 11 +-
.../lib/tasks/dotnetbuildwithoutcleanup.ts | 26 ++---
BuildServer/lib/tasks/dotnetcheckstyle.ts | 18 +--
BuildServer/lib/tasks/dotnetcompile.ts | 18 +--
BuildServer/lib/tasks/dotnetnugetpack.ts | 12 +-
BuildServer/lib/tasks/dotnetnugetprocess.ts | 46 ++++----
.../lib/tasks/dotnetnugetprocessinternal.ts | 24 ++--
BuildServer/lib/tasks/dotnetnugetpush.ts | 12 +-
BuildServer/lib/tasks/dotnetnugetpushonly.ts | 15 +--
BuildServer/lib/tasks/dotnetnugetrestore.ts | 20 ++--
BuildServer/lib/tasks/dotnetnunit.ts | 8 +-
BuildServer/lib/tasks/dotnetnunitall.ts | 26 ++---
BuildServer/lib/tasks/dotnetpackwebapp.ts | 61 +++++------
BuildServer/lib/tasks/dotnetrewrite.ts | 26 ++---
BuildServer/lib/tasks/echo.ts | 8 +-
BuildServer/lib/tasks/eslintbrowser.ts | 14 +--
BuildServer/lib/tasks/eslintbrowserall.ts | 26 ++---
BuildServer/lib/tasks/index.ts | 9 +-
BuildServer/lib/tasks/noop.ts | 2 +-
BuildServer/lib/tasks/packform.ts | 34 +++---
BuildServer/lib/tasks/parallel.ts | 2 +-
BuildServer/lib/tasks/sequential.ts | 2 +-
BuildServer/lib/tasks/uglifyjs.ts | 9 +-
BuildServer/lib/tasks/uglifyjsall.ts | 26 ++---
BuildServer/lib/tasks/writefile.ts | 8 +-
BuildServer/lib/tasks/zip.ts | 10 +-
BuildServer/package.json | 5 +-
BuildServer/routes/artifact.ts | 12 +-
BuildServer/routes/index.ts | 9 +-
BuildServer/routes/manual.ts | 8 +-
BuildServer/routes/postreceive.ts | 55 +++++-----
BuildServer/routes/release.ts | 12 +-
BuildServer/routes/status.ts | 39 +++----
BuildServer/tsconfig.json | 2 +
BuildServer/tslint.json | 103 +-----------------
52 files changed, 514 insertions(+), 638 deletions(-)
diff --git a/BuildServer/app.ts b/BuildServer/app.ts
index 5ca853e..8d60935 100644
--- a/BuildServer/app.ts
+++ b/BuildServer/app.ts
@@ -5,22 +5,22 @@ import { gracefulify } from "graceful-fs";
gracefulify(fs);
+import { json as bodyJson, urlencoded as bodyUrlencoded } from "body-parser";
+import * as errorhandler from "errorhandler";
import * as express from "express";
-import * as routes from "./routes";
import { createServer } from "http";
+import * as methodOverride from "method-override";
+import * as morgan from "morgan";
import { join } from "path";
import * as serveFavicon from "serve-favicon";
-import * as morgan from "morgan";
-import { json as bodyJson, urlencoded as bodyUrlencoded } from "body-parser";
-import * as methodOverride from "method-override";
import * as serveStatic from "serve-static";
-import * as errorhandler from "errorhandler";
+import * as routes from "./routes";
import settings from "./settings";
const app = express();
-app.set("port", settings.port); // eslint-disable-line no-process-env
+app.set("port", settings.port);
app.set("views", join(__dirname, "views"));
app.set("view engine", "jade");
app.set("gitpath", settings.gitpath);
@@ -28,8 +28,8 @@ app.set("tmpcodepath", settings.tmpcodepath);
app.set("releasepath", settings.releasepath);
app.use(serveFavicon(join(__dirname, "public/images/favicon.png")));
app.use(morgan("dev"));
-app.use(bodyJson({ "limit": "10mb" }));
-app.use(bodyUrlencoded({ "extended": false }));
+app.use(bodyJson({ limit: "10mb" }));
+app.use(bodyUrlencoded({ extended: false }));
app.use(methodOverride());
app.use(serveStatic(join(__dirname, "public")));
diff --git a/BuildServer/lib/builder.ts b/BuildServer/lib/builder.ts
index bdb7c68..02d02c5 100644
--- a/BuildServer/lib/builder.ts
+++ b/BuildServer/lib/builder.ts
@@ -1,15 +1,16 @@
"use strict";
-import { join } from "path";
+import { parallel, queue } from "async";
import { exists, readFile, writeFileSync } from "fs";
import { mkdirsSync, remove } from "fs-extra";
-import { parallel, queue } from "async";
import * as JSONParse from "json-parse-safe";
+import { join } from "path";
+
+import settings from "../settings";
import { gitLoader } from "./git/loader";
-import { processTask } from "./task-processor";
-import { writeReport } from "./report-processor";
import { send as sendMail } from "./mail-sender";
-import settings from "../settings";
+import { writeReport } from "./report-processor";
+import { processTask } from "./task-processor";
const codePostfix = "";
const mailLazinessLevel = 1000;
@@ -35,12 +36,12 @@ const createBuildDoneMessage = (isSuccess, name) => {
const notifyStatus = (options, notifyStatusCallback) => {
const status = {
- "description": String(options.description || "").substr(0, maxDescriptionLength),
- "owner": options.owner,
- "repo": options.reponame,
- "sha": options.hash,
- "state": options.state,
- "target_url": `${settings.siteRoot}status/${options.owner}/${options.reponame}/${options.hash}`
+ description: String(options.description || "").substr(0, maxDescriptionLength),
+ owner: options.owner,
+ repo: options.reponame,
+ sha: options.hash,
+ state: options.state,
+ target_url: `${settings.siteRoot}status/${options.owner}/${options.reponame}/${options.hash}`,
};
settings.createGithub(options.owner).repos.createStatus(status, (createStatusErr) => {
@@ -85,11 +86,11 @@ export const build = (options, buildCallback) => {
const versionInfo = `${version}; built from ${rev}; repository: ${owner}/${reponame}; branch: ${branch}`;
statusQueue.push((queueCallback) => notifyStatus({
- "description": "Preparing to build...",
- "hash": rev,
+ description: "Preparing to build...",
+ hash: rev,
owner,
reponame,
- "state": "pending"
+ state: "pending",
}, queueCallback));
mkdirsSync(release);
@@ -125,18 +126,18 @@ export const build = (options, buildCallback) => {
writeReport(release, doneErr, result, (writeErr) => {
statusQueue.push((queueCallback) => parallel([
(parallelCallback) => notifyStatus({
- "description": errorMessage || warnMessage || infoMessage || "Success",
- "hash": rev,
+ description: errorMessage || warnMessage || infoMessage || "Success",
+ hash: rev,
owner,
reponame,
- "state": createFinalState(!doneErr)
+ state: createFinalState(!doneErr),
}, parallelCallback),
(parallelCallback) => sendMail({
- "from": settings.smtp.sender,
- "headers": { "X-Laziness-level": mailLazinessLevel },
- "subject": createBuildDoneMessage(doneErr, `${owner}/${reponame}/${branch}`),
- "text": `Build status URL: ${settings.siteRoot}status/${owner}/${reponame}/${rev}\r\n\r\n${createErrorMessageForMail(doneErr)}${createResultMessageForMail(result)}`,
- "to": settings.smtp.receiver
+ from: settings.smtp.sender,
+ headers: { "X-Laziness-level": mailLazinessLevel },
+ subject: createBuildDoneMessage(doneErr, `${owner}/${reponame}/${branch}`),
+ text: `Build status URL: ${settings.siteRoot}status/${owner}/${reponame}/${rev}\r\n\r\n${createErrorMessageForMail(doneErr)}${createResultMessageForMail(result)}`,
+ to: settings.smtp.receiver,
}, parallelCallback),
(parallelCallback) => {
if (doneErr) {
@@ -144,7 +145,7 @@ export const build = (options, buildCallback) => {
}
return remove(tmp, parallelCallback);
- }
+ },
], queueCallback));
if (writeErr) {
@@ -158,9 +159,9 @@ export const build = (options, buildCallback) => {
actualGitLoader({
branch,
exported,
- "hash": rev,
+ hash: rev,
local,
- "remote": `${url}.git`
+ remote: `${url}.git`,
}, (gitLoaderErr) => {
if (gitLoaderErr) {
console.log(gitLoaderErr);
@@ -196,7 +197,7 @@ export const build = (options, buildCallback) => {
reponame,
rev,
tmp,
- versionInfo
+ versionInfo,
}, (processErr, result) => {
if (processErr) {
return done(processErr, result);
diff --git a/BuildServer/lib/commenter.ts b/BuildServer/lib/commenter.ts
index 0f3fc20..3698165 100644
--- a/BuildServer/lib/commenter.ts
+++ b/BuildServer/lib/commenter.ts
@@ -1,8 +1,9 @@
"use strict";
import * as _ from "underscore";
-import { getStatusMessageFromRelease } from "./report-processor";
+
import settings from "../settings";
+import { getStatusMessageFromRelease } from "./report-processor";
const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/;
const versionNamePattern = /^v\d+(\.\d+)*$/;
@@ -12,10 +13,10 @@ const httpNotFound = 404;
const maxCommentLength = 64000;
const writeComment = (options, message, callback) => options.github.issues.createComment({
- "body": message,
- "number": options.pullRequestNumber,
- "owner": options.baseRepoOptions.owner,
- "repo": options.baseRepoOptions.reponame
+ body: message,
+ number: options.pullRequestNumber,
+ owner: options.baseRepoOptions.owner,
+ repo: options.baseRepoOptions.reponame,
}, callback);
const closePullRequest = (options, message, callback) => writeComment(options, message, (err) => {
@@ -24,17 +25,17 @@ const closePullRequest = (options, message, callback) => writeComment(options, m
}
return options.github.issues.edit({
- "number": options.pullRequestNumber,
- "owner": options.baseRepoOptions.owner,
- "repo": options.baseRepoOptions.reponame,
- "state": "closed"
+ number: options.pullRequestNumber,
+ owner: options.baseRepoOptions.owner,
+ repo: options.baseRepoOptions.reponame,
+ state: "closed",
}, callback);
});
const checkHasIssue = (options, issueNumber, callback) => options.github.issues.get({
- "number": issueNumber,
- "owner": options.baseRepoOptions.owner,
- "repo": options.baseRepoOptions.reponame
+ number: issueNumber,
+ owner: options.baseRepoOptions.owner,
+ repo: options.baseRepoOptions.reponame,
}, (getIssueErr, result) => {
if (getIssueErr && getIssueErr.code !== httpNotFound) {
return callback(getIssueErr);
@@ -52,9 +53,9 @@ const checkHasIssue = (options, issueNumber, callback) => options.github.issues.
});
const checkHasReleases = (options, callback) => options.github.repos.getReleases({
- "owner": options.baseRepoOptions.owner,
- "per_page": 1,
- "repo": options.baseRepoOptions.reponame
+ owner: options.baseRepoOptions.owner,
+ per_page: 1,
+ repo: options.baseRepoOptions.reponame,
}, (getReleasesErr, result) => {
if (getReleasesErr) {
return callback(getReleasesErr);
@@ -101,7 +102,8 @@ const checkPullRequest = (options, callback) => {
return closePullRequest(options, `Only merging to master or version branch is allowed; merging to '${base.branchname}' is not supported`, callback);
}
- const issueNumber = featureNamePattern.exec(head.branchname)[1];
+ const execResult = featureNamePattern.exec(head.branchname);
+ const issueNumber = execResult && execResult[1];
return checkHasIssue(options, issueNumber, (hasIssueErr, hasIssue, issueTitle) => {
if (hasIssueErr) {
@@ -137,8 +139,8 @@ const checkPullRequest = (options, callback) => {
};
export const commentOnPullRequest = (originalOptions, callback) => {
- const optionsGithub = _.extend(originalOptions, { "github": settings.createGithub(originalOptions.baseRepoOptions.owner) });
- const options = _.extend(optionsGithub, { "onTenthAttempt": () => writeComment(optionsGithub, "Waiting for build to finish...", () => {}) });
+ const optionsGithub = _.extend(originalOptions, { github: settings.createGithub(originalOptions.baseRepoOptions.owner) });
+ const options = _.extend(optionsGithub, { onTenthAttempt: () => writeComment(optionsGithub, "Waiting for build to finish...", _.noop) });
return checkPullRequest(options, () => getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => {
const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength)
diff --git a/BuildServer/lib/git/copy.ts b/BuildServer/lib/git/copy.ts
index 9fe1177..aca540c 100644
--- a/BuildServer/lib/git/copy.ts
+++ b/BuildServer/lib/git/copy.ts
@@ -1,9 +1,9 @@
"use strict";
-import { EventEmitter } from "events"; // eslint-disable-line fp/no-events
-import { join } from "path";
-import { writeFile, mkdir } from "fs";
import { parallel } from "async";
+import { EventEmitter } from "events";
+import { mkdir, writeFile } from "fs";
+import { join } from "path";
import { Copier } from "recursive-tree-copy";
const safeGetEntries = (tree, callback) => {
@@ -15,8 +15,8 @@ const safeGetEntries = (tree, callback) => {
};
const gitToFsCopier = new Copier({
- "concurrency": 4,
- "copyLeaf": (entry, targetDir, callback) => {
+ concurrency: 4,
+ copyLeaf: (entry, targetDir, callback) => {
const targetPath = join(targetDir, entry.name());
entry.getBlob((err, blob) => {
@@ -27,7 +27,7 @@ const gitToFsCopier = new Copier({
return writeFile(targetPath, blob.content(), callback);
});
},
- "createTargetTree": (tree, targetDir, callback) => {
+ createTargetTree: (tree, targetDir, callback) => {
const targetSubdir = join(targetDir, tree.name);
mkdir(targetSubdir, (err) => {
@@ -39,8 +39,8 @@ const gitToFsCopier = new Copier({
return callback(null, targetSubdir);
});
},
- "finalizeTargetTree": (targetSubdir, callback) => callback(),
- "walkSourceTree": (tree) => {
+ finalizeTargetTree: (targetSubdir, callback) => callback(),
+ walkSourceTree: (tree) => {
const emitter = new EventEmitter();
process.nextTick(() => safeGetEntries(tree, (getEntriesErr, entries) => {
@@ -56,8 +56,8 @@ const gitToFsCopier = new Copier({
}
emitter.emit("tree", {
- "gitTree": subTree,
- "name": entry.name()
+ gitTree: subTree,
+ name: entry.name(),
});
return callback();
@@ -81,7 +81,7 @@ const gitToFsCopier = new Copier({
}));
return emitter;
- }
+ },
});
export const gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => {
@@ -90,7 +90,7 @@ export const gitToFs = (commit, exportDir, callback) => commit.getTree((err, tre
}
return gitToFsCopier.copy({
- "gitTree": tree,
- "name": "."
+ gitTree: tree,
+ name: ".",
}, exportDir, callback);
});
diff --git a/BuildServer/lib/git/loader.ts b/BuildServer/lib/git/loader.ts
index a98d9ba..3d67360 100644
--- a/BuildServer/lib/git/loader.ts
+++ b/BuildServer/lib/git/loader.ts
@@ -1,7 +1,8 @@
"use strict";
-import { Repository, Remote } from "nodegit";
import { mkdirsSync, removeSync } from "fs-extra";
+import { Remote, Repository } from "nodegit";
+
import { gitToFs } from "./copy";
const fixUrl = (url) => {
@@ -27,8 +28,8 @@ export const gitLoader = (options, globalCallback) => {
const path = `${options.local}/${options.hash}`;
const exported = options.exported;
- removeSync(path); // eslint-disable-line no-sync
- mkdirsSync(path); // eslint-disable-line no-sync
+ removeSync(path);
+ mkdirsSync(path);
console.log(`Cloning ${url} to ${path}`);
diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts
index e824786..1f232b3 100644
--- a/BuildServer/lib/report-processor.ts
+++ b/BuildServer/lib/report-processor.ts
@@ -1,46 +1,12 @@
"use strict";
-import { join } from "path";
import { createReadStream, createWriteStream, exists } from "fs";
-import { createGzip, createGunzip } from "zlib";
import * as glob from "glob";
+import * as JSONParse from "json-parse-safe";
+import { join } from "path";
import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers";
import * as _ from "underscore";
-import * as JSONParse from "json-parse-safe";
-
-interface Message {
- message: string;
- prefix: string;
-};
-
-interface PartialMessagesLeaf {
- $messages: string[];
-};
-
-interface PartialMessagesRecursive {
- [propName: string]: Messages;
-};
-
-interface PartialMessagesRoot {
- $allMessages: Message[];
-};
-
-type Messages = PartialMessagesLeaf & PartialMessagesRecursive;
-
-type MessagesRoot = PartialMessagesLeaf & PartialMessagesRecursive & PartialMessagesRoot;
-
-interface ReportResult {
- errors: MessagesRoot;
- warns: MessagesRoot;
- infos: MessagesRoot;
- messages: MessagesRoot;
-};
-
-interface Report {
- date: number;
- err?: string;
- result?: ReportResult;
-};
+import { createGunzip, createGzip } from "zlib";
const reportFilename = "report.json.gz";
const maxAttemptsNumber = 100;
@@ -50,8 +16,8 @@ const directoryCheckTimeout = 2000;
const attemptsDebugFrequency = 10;
const readableStreamBufferOptions = {
- "chunkSize": 262144,
- "frequency": 1
+ chunkSize: 262144,
+ frequency: 1,
};
const getAllErrors = (report: Report): Message[] => (report.result && report.result.errors && report.result.errors.$allMessages) || [];
@@ -60,9 +26,9 @@ const getAllInfos = (report: Report): Message[] => (report.result && report.resu
export const writeReport = (releaseDir, err, result: ReportResult, callback) => {
const data = JSON.stringify({
- "date": Date.now(),
+ date: Date.now(),
err,
- result
+ result,
});
const readable = new ReadableStreamBuffer(readableStreamBufferOptions);
@@ -114,8 +80,8 @@ export const loadReport = (app, options, callback) => {
const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
glob("**", {
- "cwd": releaseDir,
- "mark": true
+ cwd: releaseDir,
+ mark: true,
}, (err, files) => {
if (err) {
return callback(err, options);
@@ -135,7 +101,7 @@ export const loadReport = (app, options, callback) => {
return callback(null, _.extend(options, {
files,
- report
+ report,
}));
});
});
@@ -143,7 +109,7 @@ export const loadReport = (app, options, callback) => {
};
export const getStatusMessageFromRelease = (app, originalOptions, callback) => {
- const options = _.extend(originalOptions, { "attemptsGetReport": (Number(originalOptions.attemptsGetReport) || Number()) + 1 });
+ const options = _.extend(originalOptions, { attemptsGetReport: (Number(originalOptions.attemptsGetReport) || Number()) + 1 });
const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
const reportFile = join(releaseDir, reportFilename);
@@ -181,19 +147,17 @@ export const getStatusMessageFromRelease = (app, originalOptions, callback) => {
const infos = getAllInfos(report);
if (errors.length + warns.length) {
- return callback(_.map(
- errors, (message) => `ERR: ${message.message}`
- ).concat(_.map(
- warns, (message) => `WARN: ${message.message}`
- ))
- .join("\r\n"));
+ const formattedErrors = _.map(errors, (message) => `ERR: ${message.message}`);
+ const formattedWarns = _.map(warns, (message) => `WARN: ${message.message}`);
+
+ return callback(formattedErrors.concat(formattedWarns).join("\r\n"));
}
if (!report.result || report.err) {
return callback(`CRITICAL ERROR: ${report.err}`);
}
- return callback(null, (infos[infos.length - 1] || { "message": "OK" }).message);
+ return callback(null, (infos[infos.length - 1] || { message: "OK" }).message);
}), reportReadTimeout);
});
};
diff --git a/BuildServer/lib/status-processor.ts b/BuildServer/lib/status-processor.ts
index 41c7c5e..9c57f7a 100644
--- a/BuildServer/lib/status-processor.ts
+++ b/BuildServer/lib/status-processor.ts
@@ -1,8 +1,9 @@
"use strict";
-import { join } from "path";
import { exists, readFile } from "fs";
+import { join } from "path";
import * as _ from "underscore";
+
import { loadReport } from "./report-processor";
const addBranchInfo = (app, options, callback) => {
@@ -24,7 +25,7 @@ const addBranchInfo = (app, options, callback) => {
return callback(null, _.extend(options, {
branch,
- branchName
+ branchName,
}));
});
});
@@ -56,23 +57,23 @@ const parseOptions = (app, options, callback) => {
}
const result = {
- "owner": options.owner,
- "reponame": options.reponame
+ owner: options.owner,
+ reponame: options.reponame,
};
if (options.rev) {
- return addBranchInfo(app, _.extend(result, { "rev": options.rev }), callback);
+ return addBranchInfo(app, _.extend(result, { rev: options.rev }), callback);
}
if (/^[\da-f]{40}$/i.test(options.branchName)) {
- return addBranchInfo(app, _.extend(result, { "rev": options.branchName }), callback);
+ return addBranchInfo(app, _.extend(result, { rev: options.branchName }), callback);
}
const branchName = options.branchName || "master";
return addRevInfo(app, _.extend(result, {
- "branch": `refs/heads/${branchName}`,
- branchName
+ branch: `refs/heads/${branchName}`,
+ branchName,
}), callback);
};
diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts
index fb6cac3..3df504a 100644
--- a/BuildServer/lib/task-processor.ts
+++ b/BuildServer/lib/task-processor.ts
@@ -4,10 +4,10 @@ import * as _ from "underscore";
import tasks from "./tasks";
// TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here.
-const TaskProcessor = function (task, outerProcessor, callback) {
- const that = this;
- const createTaskWorker = () => tasks[task.type](task.params || {}, that);
- const errors = [];
+const createTaskProcessor = (task, outerProcessor: TaskProcessor, callback) => {
+ const result: TaskProcessor = {};
+ const createTaskWorker = () => tasks[task.type](task.params || {}, result);
+ const errors: string[] = [];
const process = () => createTaskWorker().process();
const getOuterPrefix = (prefix) => {
if (task.name && prefix) {
@@ -23,40 +23,42 @@ const TaskProcessor = function (task, outerProcessor, callback) {
const onWarn = (message, prefix) => outerProcessor.onWarn(message, getOuterPrefix(prefix));
const onInfo = (message, prefix) => outerProcessor.onInfo(message, getOuterPrefix(prefix));
const processTask = (innerTask, innerCallback) => {
- const innerProcessor = new TaskProcessor(innerTask, that, innerCallback);
+ const innerProcessor = createTaskProcessor(innerTask, result, innerCallback);
innerProcessor.process();
};
const done = () => callback(errors.join("\r\n"));
- that.process = process;
- that.onError = onError;
- that.onWarn = onWarn;
- that.onInfo = onInfo;
- that.processTask = processTask;
- that.done = done;
- that.context = outerProcessor.context;
+ result.process = process;
+ result.onError = onError;
+ result.onWarn = onWarn;
+ result.onInfo = onInfo;
+ result.processTask = processTask;
+ result.done = done;
+ result.context = outerProcessor.context;
+
+ return result;
};
const pushMessage = (list, message, parts, index) => {
if (!index) {
- list.$allMessages = list.$allMessages || []; // eslint-disable-line fp/no-mutation
- list.$allMessages.push({ // eslint-disable-line fp/no-mutating-methods
+ list.$allMessages = list.$allMessages || [];
+ list.$allMessages.push({
message,
- "prefix": parts.join("/")
+ prefix: parts.join("/"),
});
}
- list.$messages = list.$messages || []; // eslint-disable-line fp/no-mutation
+ list.$messages = list.$messages || [];
if (index === parts.length) {
- return list.$messages.push(message); // eslint-disable-line fp/no-mutating-methods
+ return list.$messages.push(message);
}
return pushMessage(list, message, parts, index + 1);
};
const addFlag = (flags) => (flagName) => {
- flags[flagName] = true; // eslint-disable-line fp/no-mutation
+ flags[flagName] = true;
};
const containsFlag = (flags) => (flagName) => flags[flagName];
@@ -73,19 +75,19 @@ export const processTask = (task, context, callback) => {
pushMessage(messages, message, parts, 0);
};
const flags = {};
- const processor = new TaskProcessor(task, {
- "context": _.extend(context, {
- "addFlag": addFlag(flags),
- "containsFlag": containsFlag(flags)
+ const processor = createTaskProcessor(task, {
+ context: _.extend(context, {
+ addFlag: addFlag(flags),
+ containsFlag: containsFlag(flags),
}),
- "onError": messageProcessor(errors),
- "onInfo": messageProcessor(infos),
- "onWarn": messageProcessor(warns)
+ onError: messageProcessor(errors),
+ onInfo: messageProcessor(infos),
+ onWarn: messageProcessor(warns),
}, (err) => callback(err, {
errors,
infos,
messages,
- warns
+ warns,
}));
processor.process();
diff --git a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
index f21a29e..23b96f3 100644
--- a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
+++ b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
@@ -2,10 +2,10 @@
import * as glob from "glob";
-export default (params, processor) => ({
- "process": () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
- "cwd": processor.context.exported,
- "dot": true
+export default ((params, processor) => ({
+ process: () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
+ cwd: processor.context.exported,
+ dot: true,
}, (err, files) => {
if (err) {
processor.onError(err);
@@ -18,14 +18,14 @@ export default (params, processor) => ({
}
return processor.processTask({
- "params": {
- "tasks": files.map((file) => ({
- "name": file,
- "params": { "filename": file },
- "type": "deletefromcode"
- }))
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "deletefromcode",
+ })),
},
- "type": "parallel"
+ type: "parallel",
}, processor.done.bind(processor));
- })
-});
+ }),
+})) as Task;
diff --git a/BuildServer/lib/tasks/conditional.ts b/BuildServer/lib/tasks/conditional.ts
index ce8d2ff..7c8c13f 100644
--- a/BuildServer/lib/tasks/conditional.ts
+++ b/BuildServer/lib/tasks/conditional.ts
@@ -1,9 +1,9 @@
"use strict";
-export default (params, processor) => {
+export default ((params, processor) => {
const condition = (!params.owner || params.owner === processor.context.owner)
&& (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch);
const task = (condition && params.task) || params.otherwise;
- return { "process": () => processor.processTask(task || { "type": "noop" }, processor.done.bind(processor)) };
-};
+ return { process: () => processor.processTask(task || { type: "noop" }, processor.done.bind(processor)) };
+}) as Task;
diff --git a/BuildServer/lib/tasks/copy.ts b/BuildServer/lib/tasks/copy.ts
index f03e29a..e7f06a2 100644
--- a/BuildServer/lib/tasks/copy.ts
+++ b/BuildServer/lib/tasks/copy.ts
@@ -1,10 +1,10 @@
"use strict";
-import { join } from "path";
import { copy } from "fs-extra";
+import { join } from "path";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const sourceFilePath = join(processor.context.exported, params.filename);
const targetFilePath = join(processor.context.release, params.filename);
@@ -19,5 +19,5 @@ export default (params, processor) => ({
return processor.done();
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/copyglob.ts b/BuildServer/lib/tasks/copyglob.ts
index 3f0d70d..522273f 100644
--- a/BuildServer/lib/tasks/copyglob.ts
+++ b/BuildServer/lib/tasks/copyglob.ts
@@ -2,10 +2,10 @@
import * as glob from "glob";
-export default (params, processor) => ({
- "process": () => glob(params.mask, {
- "cwd": processor.context.exported,
- "dot": true
+export default ((params, processor) => ({
+ process: () => glob(params.mask, {
+ cwd: processor.context.exported,
+ dot: true,
}, (err, files) => {
if (err) {
processor.onError(err);
@@ -18,14 +18,14 @@ export default (params, processor) => ({
}
return processor.processTask({
- "params": {
- "tasks": files.map((file) => ({
- "name": file,
- "params": { "filename": file },
- "type": "copy"
- }))
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "copy",
+ })),
},
- "type": "parallel"
+ type: "parallel",
}, processor.done.bind(processor));
- })
-});
+ }),
+})) as Task;
diff --git a/BuildServer/lib/tasks/cssnano.ts b/BuildServer/lib/tasks/cssnano.ts
index 103fd52..1620342 100644
--- a/BuildServer/lib/tasks/cssnano.ts
+++ b/BuildServer/lib/tasks/cssnano.ts
@@ -1,11 +1,11 @@
"use strict";
+import { process as cssnanoProcess } from "cssnano";
import { readFile, writeFile } from "fs";
import { join } from "path";
-import { process as cssnanoProcess } from "cssnano";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const filePath = join(processor.context.exported, params.filename);
readFile(filePath, (readErr, css) => {
@@ -32,6 +32,5 @@ export default (params, processor) => ({
});
});
});
- }
-});
-
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/cssnanoall.ts b/BuildServer/lib/tasks/cssnanoall.ts
index 95c033f..882b9a8 100644
--- a/BuildServer/lib/tasks/cssnanoall.ts
+++ b/BuildServer/lib/tasks/cssnanoall.ts
@@ -3,8 +3,8 @@
import * as glob from "glob";
const flagDoneName = "cssnanoallDone";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json");
}
@@ -12,8 +12,8 @@ export default (params, processor) => ({
processor.context.addFlag(flagDoneName);
glob("**/*.css", {
- "cwd": processor.context.exported,
- "dot": true
+ cwd: processor.context.exported,
+ dot: true,
}, (err, files) => {
if (err) {
processor.onError(err);
@@ -22,15 +22,15 @@ export default (params, processor) => ({
}
return processor.processTask({
- "params": {
- "tasks": files.map((file) => ({
- "name": file,
- "params": { "filename": file },
- "type": "cssnano"
- }))
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "cssnano",
+ })),
},
- "type": (params.preventParallelTests && "sequential") || "parallel"
+ type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor));
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/deletefromcode.ts b/BuildServer/lib/tasks/deletefromcode.ts
index b5ae2b7..ff90878 100644
--- a/BuildServer/lib/tasks/deletefromcode.ts
+++ b/BuildServer/lib/tasks/deletefromcode.ts
@@ -1,10 +1,10 @@
"use strict";
-import { join } from "path";
import { remove } from "fs-extra";
+import { join } from "path";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const sourceFilePath = join(processor.context.exported, params.filename);
processor.onInfo(`Deleting ${sourceFilePath}`);
@@ -18,5 +18,5 @@ export default (params, processor) => ({
return processor.done();
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/dotnetbuild.ts b/BuildServer/lib/tasks/dotnetbuild.ts
index 7b31af9..8b474cd 100644
--- a/BuildServer/lib/tasks/dotnetbuild.ts
+++ b/BuildServer/lib/tasks/dotnetbuild.ts
@@ -2,16 +2,16 @@
import sequential from "./sequential";
-export default (params, processor) => sequential({
- "tasks": [
+export default ((params, processor) => sequential({
+ tasks: [
{
- "name": "build",
+ name: "build",
params,
- "type": "dotnetbuildwithoutcleanup"
+ type: "dotnetbuildwithoutcleanup",
},
{
- "name": "cleanup",
- "type": "cleanupafterdotnetbuild"
- }
- ]
-}, processor);
+ name: "cleanup",
+ type: "cleanupafterdotnetbuild",
+ },
+ ],
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetbuildandtest.ts b/BuildServer/lib/tasks/dotnetbuildandtest.ts
index c4152cf..292dc58 100644
--- a/BuildServer/lib/tasks/dotnetbuildandtest.ts
+++ b/BuildServer/lib/tasks/dotnetbuildandtest.ts
@@ -2,21 +2,21 @@
import sequential from "./sequential";
-export default (params, processor) => sequential({
- "tasks": [
+export default ((params, processor) => sequential({
+ tasks: [
{
- "name": "build",
+ name: "build",
params,
- "type": "dotnetbuildwithoutcleanup"
+ type: "dotnetbuildwithoutcleanup",
},
{
- "name": "test",
+ name: "test",
params,
- "type": "dotnetnunitall"
+ type: "dotnetnunitall",
},
{
- "name": "cleanup",
- "type": "cleanupafterdotnetbuild"
- }
- ]
-}, processor);
+ name: "cleanup",
+ type: "cleanupafterdotnetbuild",
+ },
+ ],
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
index dc9fa78..39af675 100644
--- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
+++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
@@ -1,8 +1,9 @@
"use strict";
import { spawn } from "child_process";
-import { WritableStreamBuffer } from "stream-buffers";
import * as JSONParse from "json-parse-safe";
+import { WritableStreamBuffer } from "stream-buffers";
+
import settings from "../../settings";
const wrapBuilder = (builder, input, onExit) => {
@@ -27,8 +28,8 @@ const wrapBuilder = (builder, input, onExit) => {
builder.stdin.end();
};
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const input = JSON.stringify(params);
const builder = spawn(settings.builderExecutable, [params.command]);
@@ -71,5 +72,5 @@ export default (params, processor) => ({
return processor.done();
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
index 00cee5d..7742516 100644
--- a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
+++ b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
@@ -6,37 +6,37 @@ const createTasks = function *(params) {
if (!params.skipMbsCheckStyle) {
yield {
params,
- "type": "dotnetcheckstyle"
+ type: "dotnetcheckstyle",
};
}
yield {
params,
- "type": "dotnetrewrite"
+ type: "dotnetrewrite",
};
if (!params.skipNugetRestore) {
yield {
params,
- "type": "dotnetnugetrestore"
+ type: "dotnetnugetrestore",
};
}
yield {
- "params": {
- "configuration": params.configuration,
- "forceCodeAnalysis": params.forceCodeAnalysis,
- "ignoreCodeAnalysis": params.ignoreCodeAnalysis,
- "skipCodeSigning": params.skipCodeSigning,
- "solution": params.solution,
- "target": "Rebuild"
+ params: {
+ configuration: params.configuration,
+ forceCodeAnalysis: params.forceCodeAnalysis,
+ ignoreCodeAnalysis: params.ignoreCodeAnalysis,
+ skipCodeSigning: params.skipCodeSigning,
+ solution: params.solution,
+ target: "Rebuild",
},
- "type": "dotnetcompile"
+ type: "dotnetcompile",
};
};
-export default (params, processor) => {
+export default ((params, processor) => {
const tasks = Array.from(createTasks(params));
return sequential({ tasks }, processor);
-};
+}) as Task;
diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.ts b/BuildServer/lib/tasks/dotnetcheckstyle.ts
index 9d19dc0..0aa1222 100644
--- a/BuildServer/lib/tasks/dotnetcheckstyle.ts
+++ b/BuildServer/lib/tasks/dotnetcheckstyle.ts
@@ -1,9 +1,9 @@
"use strict";
-import { join } from "path";
-import { readFile } from "fs";
import { parallel } from "async";
+import { readFile } from "fs";
import * as glob from "glob";
+import { join } from "path";
const autoGeneratedMarker
= "//------------------------------------------------------------------------------\n"
@@ -11,15 +11,15 @@ const autoGeneratedMarker
const flagDoneName = "dotnetcheckerDone";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
if (processor.context.containsFlag(flagDoneName)) {
return processor.done();
}
processor.context.addFlag(flagDoneName);
- return glob("**/*.cs", { "cwd": processor.context.exported }, (globErr, files) => {
+ return glob("**/*.cs", { cwd: processor.context.exported }, (globErr, files) => {
if (globErr) {
processor.onError(globErr);
@@ -58,7 +58,7 @@ export default (params, processor) => ({
return parallel(files.map((file) => (callback) => readFile(
join(processor.context.exported, file),
- { "encoding": "utf8" },
+ { encoding: "utf8" },
(readErr, data) => {
if (readErr) {
processor.onError(`Unable to check file ${file}: ${readErr}`);
@@ -69,8 +69,8 @@ export default (params, processor) => ({
processFile(data, file);
return callback();
- }
+ },
)), processor.done.bind(processor));
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/dotnetcompile.ts b/BuildServer/lib/tasks/dotnetcompile.ts
index 6402298..b77e236 100644
--- a/BuildServer/lib/tasks/dotnetcompile.ts
+++ b/BuildServer/lib/tasks/dotnetcompile.ts
@@ -5,7 +5,7 @@ import * as _ from "underscore";
import settings from "../../settings";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
-export default (params, processor) => {
+export default ((params, processor) => {
if (settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) {
processor.onError("Code analysis is not supported");
@@ -17,7 +17,7 @@ export default (params, processor) => {
return {};
}
- return { "SigningKey": settings.codeSigningKeyFile };
+ return { SigningKey: settings.codeSigningKeyFile };
};
const skipCodeAnalysis = settings.isCodeAnalysisUnsupported
@@ -25,13 +25,13 @@ export default (params, processor) => {
|| (settings.ignoreCodeAnalysisByDefault && !params.forceCodeAnalysis);
const compileParams = {
- "Configuration": params.configuration,
- "OutputDirectory": params.overrideOutputDirectory,
- "SkipCodeAnalysis": skipCodeAnalysis,
- "SolutionPath": join(processor.context.exported, params.solution),
- "Target": params.target,
- "command": "compile"
+ Configuration: params.configuration,
+ OutputDirectory: params.overrideOutputDirectory,
+ SkipCodeAnalysis: skipCodeAnalysis,
+ SolutionPath: join(processor.context.exported, params.solution),
+ Target: params.target,
+ command: "compile",
};
return dotnetbuilderwrapper(_.extend(compileParams, getAdditionalSigningParameters()), processor);
-};
+}) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnugetpack.ts b/BuildServer/lib/tasks/dotnetnugetpack.ts
index 736c0af..1deec62 100644
--- a/BuildServer/lib/tasks/dotnetnugetpack.ts
+++ b/BuildServer/lib/tasks/dotnetnugetpack.ts
@@ -3,9 +3,9 @@
import * as _ from "underscore";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
-export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
- "getFinalTask": (nupkg) => ({
- "params": { "filename": nupkg },
- "type": "copy"
- })
-}), processor);
+export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
+ getFinalTask: (nupkg) => ({
+ params: { filename: nupkg },
+ type: "copy",
+ }),
+}), processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnugetprocess.ts b/BuildServer/lib/tasks/dotnetnugetprocess.ts
index 5576fed..30c851e 100644
--- a/BuildServer/lib/tasks/dotnetnugetprocess.ts
+++ b/BuildServer/lib/tasks/dotnetnugetprocess.ts
@@ -2,29 +2,29 @@
import conditional from "./conditional";
-export default (params, processor) => conditional({
- "branch": "master",
- "otherwise": {
- "name": "nuget-pack",
- "params": {
- "major": params.major,
- "name": params.nuspecName,
- "nuspec": `${params.nuspecName}.nuspec`,
- "version": params.version,
- "withoutCommitSha": params.withoutCommitSha
+export default ((params, processor) => conditional({
+ branch: "master",
+ otherwise: {
+ name: "nuget-pack",
+ params: {
+ major: params.major,
+ name: params.nuspecName,
+ nuspec: `${params.nuspecName}.nuspec`,
+ version: params.version,
+ withoutCommitSha: params.withoutCommitSha,
},
- "type": "dotnetnugetpack"
+ type: "dotnetnugetpack",
},
- "owner": params.masterRepoOwner,
- "task": {
- "name": "nuget-push",
- "params": {
- "major": params.major,
- "name": params.nuspecName,
- "nuspec": `${params.nuspecName}.nuspec`,
- "version": params.version,
- "withoutCommitSha": params.withoutCommitSha
+ owner: params.masterRepoOwner,
+ task: {
+ name: "nuget-push",
+ params: {
+ major: params.major,
+ name: params.nuspecName,
+ nuspec: `${params.nuspecName}.nuspec`,
+ version: params.version,
+ withoutCommitSha: params.withoutCommitSha,
},
- "type": "dotnetnugetpush"
- }
-}, processor);
+ type: "dotnetnugetpush",
+ },
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
index 2d8f8d7..0a279af 100644
--- a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
+++ b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
@@ -15,7 +15,7 @@ const addPostfix = (version, params, processor) => {
return `${version}-r${processor.context.rev.substr(0, postfixLength)}`;
};
-export default (params, processor) => {
+export default ((params, processor) => {
const date = new Date();
const major = params.major || "0";
const minor = (date.getFullYear() * fourDigits) + ((date.getMonth() + 1) * twoDigits) + date.getDate();
@@ -24,18 +24,18 @@ export default (params, processor) => {
const nupkg = `${params.name}.${version}.nupkg`;
return sequential({
- "tasks": [
+ tasks: [
{
- "params": {
- "BaseDirectory": processor.context.exported,
- "OutputDirectory": processor.context.exported,
- "SpecPath": join(processor.context.exported, params.nuspec),
- "Version": version,
- "command": "nugetpack"
+ params: {
+ BaseDirectory: processor.context.exported,
+ OutputDirectory: processor.context.exported,
+ SpecPath: join(processor.context.exported, params.nuspec),
+ Version: version,
+ command: "nugetpack",
},
- "type": "dotnetbuilderwrapper"
+ type: "dotnetbuilderwrapper",
},
- params.getFinalTask(nupkg)
- ]
+ params.getFinalTask(nupkg),
+ ],
}, processor);
-};
+}) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnugetpush.ts b/BuildServer/lib/tasks/dotnetnugetpush.ts
index e3a5aae..0b228ea 100644
--- a/BuildServer/lib/tasks/dotnetnugetpush.ts
+++ b/BuildServer/lib/tasks/dotnetnugetpush.ts
@@ -3,9 +3,9 @@
import * as _ from "underscore";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
-export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
- "getFinalTask": (nupkg) => ({
- "params": { "Package": nupkg },
- "type": "dotnetnugetpushonly"
- })
-}), processor);
+export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
+ getFinalTask: (nupkg) => ({
+ params: { Package: nupkg },
+ type: "dotnetnugetpushonly",
+ }),
+}), processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnugetpushonly.ts b/BuildServer/lib/tasks/dotnetnugetpushonly.ts
index b1d9134..3243647 100644
--- a/BuildServer/lib/tasks/dotnetnugetpushonly.ts
+++ b/BuildServer/lib/tasks/dotnetnugetpushonly.ts
@@ -1,12 +1,13 @@
"use strict";
import { join } from "path";
-import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
+
import settings from "../../settings";
+import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
-export default (params, processor) => dotnetbuilderwrapper({
- "ApiKey": settings.nugetApiKey,
- "NugetHost": settings.nugetHost,
- "Package": join(processor.context.exported, params.Package),
- "command": "nugetpush"
-}, processor);
+export default ((params, processor) => dotnetbuilderwrapper({
+ ApiKey: settings.nugetApiKey,
+ NugetHost: settings.nugetHost,
+ Package: join(processor.context.exported, params.Package),
+ command: "nugetpush",
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnugetrestore.ts b/BuildServer/lib/tasks/dotnetnugetrestore.ts
index 4e50f32..3cf6dd5 100644
--- a/BuildServer/lib/tasks/dotnetnugetrestore.ts
+++ b/BuildServer/lib/tasks/dotnetnugetrestore.ts
@@ -3,15 +3,15 @@
import { join } from "path";
import sequential from "./sequential";
-export default (params, processor) => sequential({
- "tasks": [
+export default ((params, processor) => sequential({
+ tasks: [
{
- "params": {
- "BaseDirectory": processor.context.exported,
- "SolutionPath": join(processor.context.exported, params.solution),
- "command": "nugetrestore"
+ params: {
+ BaseDirectory: processor.context.exported,
+ SolutionPath: join(processor.context.exported, params.solution),
+ command: "nugetrestore",
},
- "type": "dotnetbuilderwrapper"
- }
- ]
-}, processor);
+ type: "dotnetbuilderwrapper",
+ },
+ ],
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnunit.ts b/BuildServer/lib/tasks/dotnetnunit.ts
index 018ec23..c085f73 100644
--- a/BuildServer/lib/tasks/dotnetnunit.ts
+++ b/BuildServer/lib/tasks/dotnetnunit.ts
@@ -3,7 +3,7 @@
import { join } from "path";
import dotNetBuilderWrapper from "./dotnetbuilderwrapper";
-export default (params, processor) => dotNetBuilderWrapper({
- "TestLibraryPath": join(processor.context.exported, params.assembly),
- "command": "nunit"
-}, processor);
+export default ((params, processor) => dotNetBuilderWrapper({
+ TestLibraryPath: join(processor.context.exported, params.assembly),
+ command: "nunit",
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnunitall.ts b/BuildServer/lib/tasks/dotnetnunitall.ts
index ee1b269..75307c7 100644
--- a/BuildServer/lib/tasks/dotnetnunitall.ts
+++ b/BuildServer/lib/tasks/dotnetnunitall.ts
@@ -3,8 +3,8 @@
import * as glob from "glob";
const flagDoneName = "dotnetnunitallDone";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
}
@@ -12,8 +12,8 @@ export default (params, processor) => ({
processor.context.addFlag(flagDoneName);
glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", {
- "cwd": processor.context.exported,
- "dot": true
+ cwd: processor.context.exported,
+ dot: true,
}, (err, files) => {
if (err) {
processor.onError(err);
@@ -28,15 +28,15 @@ export default (params, processor) => ({
}
return processor.processTask({
- "params": {
- "tasks": files.map((file) => ({
- "name": file,
- "params": { "assembly": file },
- "type": "dotnetnunit"
- }))
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { assembly: file },
+ type: "dotnetnunit",
+ })),
},
- "type": (params.preventParallelTests && "sequential") || "parallel"
+ type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor));
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/dotnetpackwebapp.ts b/BuildServer/lib/tasks/dotnetpackwebapp.ts
index 08d7dfe..f401329 100644
--- a/BuildServer/lib/tasks/dotnetpackwebapp.ts
+++ b/BuildServer/lib/tasks/dotnetpackwebapp.ts
@@ -1,50 +1,47 @@
"use strict";
-import { join } from "path";
import { readFileSync } from "fs";
import { render } from "mustache";
+import { join } from "path";
import sequential from "./sequential";
-// eslint-disable-next-line no-sync
-const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { "encoding": "utf8" });
-// eslint-disable-next-line no-sync
-const deployTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.bat"), { "encoding": "utf8" });
-// eslint-disable-next-line no-sync
-const versionTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { "encoding": "utf8" });
+const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { encoding: "utf8" });
+const deployTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.bat"), { encoding: "utf8" });
+const versionTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { encoding: "utf8" });
-export default (params, processor) => sequential({
- "tasks": [
+export default ((params, processor) => sequential({
+ tasks: [
{
- "params": {
- "data": render(msbuildTemplate, params),
- "filename": "MakePackage.msbuild"
+ params: {
+ data: render(msbuildTemplate, params),
+ filename: "MakePackage.msbuild",
},
- "type": "writefile"
+ type: "writefile",
},
{
- "params": {
- "data": render(deployTemplate, params),
- "filename": "Deploy.bat"
+ params: {
+ data: render(deployTemplate, params),
+ filename: "Deploy.bat",
},
- "type": "writefile"
+ type: "writefile",
},
{
- "params": {
- "data": render(versionTemplate, params),
- "filename": "version.aspx"
+ params: {
+ data: render(versionTemplate, params),
+ filename: "version.aspx",
},
- "type": "writefile"
+ type: "writefile",
},
{
- "params": {
- "configuration": params.configuration,
- "isCodeAnalysisUnsupported": params.isCodeAnalysisUnsupported,
- "overrideOutputDirectory": processor.context.release,
- "skipCodeSigning": params.skipCodeSigning,
- "solution": "MakePackage.msbuild",
- "target": "Package"
+ params: {
+ configuration: params.configuration,
+ isCodeAnalysisUnsupported: params.isCodeAnalysisUnsupported,
+ overrideOutputDirectory: processor.context.release,
+ skipCodeSigning: params.skipCodeSigning,
+ solution: "MakePackage.msbuild",
+ target: "Package",
},
- "type": "dotnetcompile"
- }
- ]
-}, processor);
+ type: "dotnetcompile",
+ },
+ ],
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/dotnetrewrite.ts b/BuildServer/lib/tasks/dotnetrewrite.ts
index 1fccb6c..d917bae 100644
--- a/BuildServer/lib/tasks/dotnetrewrite.ts
+++ b/BuildServer/lib/tasks/dotnetrewrite.ts
@@ -1,9 +1,9 @@
"use strict";
-import { join } from "path";
-import { readFile, writeFile } from "fs";
import { parallel, waterfall } from "async";
+import { readFile, writeFile } from "fs";
import * as glob from "glob";
+import { join } from "path";
import settings from "../../settings";
const flagDoneName = "dotnetrewriterDone";
@@ -14,10 +14,10 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => (
return content;
}
- return content.replace(
- /InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g,
- (match, p1) => `InternalsVisibleTo("${p1},PublicKey=${settings.codeSigningPublicKey}")`
- );
+ const pattern = /InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g;
+ const replacer = (match, p1) => `InternalsVisibleTo("${p1},PublicKey=${settings.codeSigningPublicKey}")`;
+
+ return content.replace(pattern, replacer);
};
const processInformationalVersion = (content) => {
@@ -31,15 +31,15 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => (
return cb(null, processInformationalVersion(processInternalsVisible(originalContent)));
};
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
if (processor.context.containsFlag(flagDoneName)) {
return processor.done();
}
processor.context.addFlag(flagDoneName);
- return glob("**/{InternalsVisible,AssemblyInfo}*.cs", { "cwd": processor.context.exported }, (globErr, files) => {
+ return glob("**/{InternalsVisible,AssemblyInfo}*.cs", { cwd: processor.context.exported }, (globErr, files) => {
if (globErr) {
processor.onError(globErr);
@@ -55,9 +55,9 @@ export default (params, processor) => ({
}
return parallel(files.map((file) => (callback) => waterfall([
- readFile.bind(null, join(processor.context.exported, file), { "encoding": "utf8" }),
+ readFile.bind(null, join(processor.context.exported, file), { encoding: "utf8" }),
processAssemblyInfo(params, processor, file.toLowerCase().includes("assemblyinfo.cs")),
- writeFile.bind(null, join(processor.context.exported, file))
+ writeFile.bind(null, join(processor.context.exported, file)),
], (err) => {
if (err) {
processor.onError(`Unable to rewrite file ${file}: ${err}`);
@@ -67,5 +67,5 @@ export default (params, processor) => ({
callback(err);
})), processor.done.bind(processor));
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/echo.ts b/BuildServer/lib/tasks/echo.ts
index e06d52c..65690d0 100644
--- a/BuildServer/lib/tasks/echo.ts
+++ b/BuildServer/lib/tasks/echo.ts
@@ -1,7 +1,7 @@
"use strict";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
if (params.error) {
processor.onError(params.error);
}
@@ -15,5 +15,5 @@ export default (params, processor) => ({
}
processor.done();
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/eslintbrowser.ts b/BuildServer/lib/tasks/eslintbrowser.ts
index 6f13cb2..86cde65 100644
--- a/BuildServer/lib/tasks/eslintbrowser.ts
+++ b/BuildServer/lib/tasks/eslintbrowser.ts
@@ -1,14 +1,15 @@
"use strict";
-import { join } from "path";
import { CLIEngine } from "eslint";
+import { join } from "path";
import settings from "../../settings";
-const cli = new CLIEngine({ "configFile": settings.eslintBrowserConfig });
+
+const cli = new CLIEngine({ configFile: settings.eslintBrowserConfig });
const errorSeverity = 2;
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const filePath = join(processor.context.exported, params.filename);
const result = cli.executeOnFiles([filePath]);
@@ -27,6 +28,5 @@ export default (params, processor) => ({
});
processor.done();
- }
-});
-
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/eslintbrowserall.ts b/BuildServer/lib/tasks/eslintbrowserall.ts
index f03bd4d..0c4c6e4 100644
--- a/BuildServer/lib/tasks/eslintbrowserall.ts
+++ b/BuildServer/lib/tasks/eslintbrowserall.ts
@@ -3,8 +3,8 @@
import * as glob from "glob";
const flagDoneName = "eslintbrowserallDone";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json");
}
@@ -14,8 +14,8 @@ export default (params, processor) => ({
const excludeFiles = params.excludeFiles || [];
glob("**/*.js", {
- "cwd": processor.context.exported,
- "dot": true
+ cwd: processor.context.exported,
+ dot: true,
}, (err, files) => {
if (err) {
processor.onError(err);
@@ -24,15 +24,15 @@ export default (params, processor) => ({
}
return processor.processTask({
- "params": {
- "tasks": files.filter((file) => !excludeFiles.includes(file)).map((file) => ({
- "name": file,
- "params": { "filename": file },
- "type": "eslintbrowser"
- }))
+ params: {
+ tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "eslintbrowser",
+ })),
},
- "type": (params.preventParallelTests && "sequential") || "parallel"
+ type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor));
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/index.ts b/BuildServer/lib/tasks/index.ts
index c53c39c..8c660da 100644
--- a/BuildServer/lib/tasks/index.ts
+++ b/BuildServer/lib/tasks/index.ts
@@ -1,15 +1,14 @@
"use strict";
-let tasks = {};
+import { readdirSync } from "fs";
+
+const tasks: Tasks = {};
// Code taken from http://stackoverflow.com/a/17204293
-// eslint-disable-next-line no-sync
-require("fs").readdirSync(__dirname)
+readdirSync(__dirname)
.forEach((file) => {
if (file.match(/\.ts$/) !== null && file !== "index.ts") {
const name = file.replace(".ts", "");
-
- // eslint-disable-next-line global-require
tasks[name] = require(`./${file}`).default;
}
});
diff --git a/BuildServer/lib/tasks/noop.ts b/BuildServer/lib/tasks/noop.ts
index a5bad82..5726067 100644
--- a/BuildServer/lib/tasks/noop.ts
+++ b/BuildServer/lib/tasks/noop.ts
@@ -1,3 +1,3 @@
"use strict";
-export default (params, processor) => ({ "process": () => processor.done() });
+export default ((params, processor) => ({ process: () => processor.done() })) as Task;
diff --git a/BuildServer/lib/tasks/packform.ts b/BuildServer/lib/tasks/packform.ts
index fa4568f..c693b7a 100644
--- a/BuildServer/lib/tasks/packform.ts
+++ b/BuildServer/lib/tasks/packform.ts
@@ -2,27 +2,27 @@
import sequential from "./sequential";
-export default (params, processor) => sequential({
- "tasks": [
+export default ((params, processor) => sequential({
+ tasks: [
{
- "params": { "excludeFiles": params.eslintExcludeFiles },
- "type": "eslintbrowserall"
+ params: { excludeFiles: params.eslintExcludeFiles },
+ type: "eslintbrowserall",
},
- { "type": "uglifyjsall" },
- { "type": "cssnanoall" },
+ { type: "uglifyjsall" },
+ { type: "cssnanoall" },
{
- "params": {
- "data": processor.context.versionInfo,
- "filename": "version.txt"
+ params: {
+ data: processor.context.versionInfo,
+ filename: "version.txt",
},
- "type": "writefile"
+ type: "writefile",
},
{
- "params": {
- "archive": `${processor.context.reponame}.zip`,
- "directory": ""
+ params: {
+ archive: `${processor.context.reponame}.zip`,
+ directory: "",
},
- "type": "zip"
- }
- ]
-}, processor);
+ type: "zip",
+ },
+ ],
+}, processor)) as Task;
diff --git a/BuildServer/lib/tasks/parallel.ts b/BuildServer/lib/tasks/parallel.ts
index 0bb5943..bd59e11 100644
--- a/BuildServer/lib/tasks/parallel.ts
+++ b/BuildServer/lib/tasks/parallel.ts
@@ -4,4 +4,4 @@ import { parallel } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-export default (params, processor) => ({ "process": () => parallel(params.tasks.map(mapper(processor)), () => processor.done()) });
+export default ((params, processor) => ({ process: () => parallel(params.tasks.map(mapper(processor)), () => processor.done()) })) as Task;
diff --git a/BuildServer/lib/tasks/sequential.ts b/BuildServer/lib/tasks/sequential.ts
index 53ffbf6..cfdfe20 100644
--- a/BuildServer/lib/tasks/sequential.ts
+++ b/BuildServer/lib/tasks/sequential.ts
@@ -4,4 +4,4 @@ import { series } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-export default (params, processor) => ({ "process": () => series(params.tasks.map(mapper(processor)), () => processor.done()) });
+export default ((params, processor) => ({ process: () => series(params.tasks.map(mapper(processor)), () => processor.done()) })) as Task;
diff --git a/BuildServer/lib/tasks/uglifyjs.ts b/BuildServer/lib/tasks/uglifyjs.ts
index 6926d40..6ea71e0 100644
--- a/BuildServer/lib/tasks/uglifyjs.ts
+++ b/BuildServer/lib/tasks/uglifyjs.ts
@@ -4,8 +4,8 @@ import { writeFile } from "fs";
import { join, normalize } from "path";
import { minify } from "uglify-js";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const filePath = normalize(join(processor.context.exported, params.filename));
const result = minify(filePath);
@@ -18,6 +18,5 @@ export default (params, processor) => ({
processor.done();
});
- }
-});
-
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/uglifyjsall.ts b/BuildServer/lib/tasks/uglifyjsall.ts
index cf634ea..1e2d281 100644
--- a/BuildServer/lib/tasks/uglifyjsall.ts
+++ b/BuildServer/lib/tasks/uglifyjsall.ts
@@ -4,8 +4,8 @@ import * as glob from "glob";
const doneFlagName = "uglifyjsallDone";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
if (processor.context.containsFlag(doneFlagName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
}
@@ -13,8 +13,8 @@ export default (params, processor) => ({
processor.context.addFlag(doneFlagName);
glob("**/*.js", {
- "cwd": processor.context.exported,
- "dot": true
+ cwd: processor.context.exported,
+ dot: true,
}, (err, files) => {
if (err) {
processor.onError(err);
@@ -23,15 +23,15 @@ export default (params, processor) => ({
}
return processor.processTask({
- "params": {
- "tasks": files.map((file) => ({
- "name": file,
- "params": { "filename": file },
- "type": "uglifyjs"
- }))
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "uglifyjs",
+ })),
},
- "type": (params.preventParallelTests && "sequential") || "parallel"
+ type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor));
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/writefile.ts b/BuildServer/lib/tasks/writefile.ts
index d20c696..46dda79 100644
--- a/BuildServer/lib/tasks/writefile.ts
+++ b/BuildServer/lib/tasks/writefile.ts
@@ -3,8 +3,8 @@
import { writeFile } from "fs";
import { join } from "path";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const filePath = join(processor.context.exported, params.filename);
processor.onInfo(`Writing to ${filePath}`);
@@ -18,5 +18,5 @@ export default (params, processor) => ({
return processor.done();
});
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/lib/tasks/zip.ts b/BuildServer/lib/tasks/zip.ts
index 5c2a476..20b1ccb 100644
--- a/BuildServer/lib/tasks/zip.ts
+++ b/BuildServer/lib/tasks/zip.ts
@@ -1,11 +1,11 @@
"use strict";
+import { create as createArchiver } from "archiver";
import { createWriteStream } from "fs";
import { join, normalize } from "path";
-import { create as createArchiver } from "archiver";
-export default (params, processor) => ({
- "process": () => {
+export default ((params, processor) => ({
+ process: () => {
const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || "")));
const targetArchivePath = normalize(join(processor.context.release, params.archive));
@@ -20,5 +20,5 @@ export default (params, processor) => ({
archive.pipe(output);
archive.directory(sourceDirectoryPath, false);
archive.finalize();
- }
-});
+ },
+})) as Task;
diff --git a/BuildServer/package.json b/BuildServer/package.json
index a3087d6..8dd25bc 100644
--- a/BuildServer/package.json
+++ b/BuildServer/package.json
@@ -4,9 +4,9 @@
"private": true,
"scripts": {
"start": "forever -c node app.js",
- "build": "./node_modules/.bin/tsc -p .",
+ "build": "./node_modules/.bin/tsc -p . --noEmitOnError",
"pretest": "./node_modules/.bin/tsc -p . --noEmit",
- "test": "./node_modules/.bin/tslint --project tsconfig.json --type-check"
+ "test": "./node_modules/.bin/tslint --config tslint.json --project tsconfig.json --type-check"
},
"dependencies": {
"archiver": "^1.3.0",
@@ -52,6 +52,7 @@
"@types/uglify-js": "^2.6.28",
"@types/underscore": "^1.7.36",
"tslint": "^4.4.2",
+ "tslint-eslint-rules": "^3.4.0",
"typescript": "^2.2.1"
}
}
diff --git a/BuildServer/routes/artifact.ts b/BuildServer/routes/artifact.ts
index d32e6b2..b1546fb 100644
--- a/BuildServer/routes/artifact.ts
+++ b/BuildServer/routes/artifact.ts
@@ -2,12 +2,12 @@
export default (req, res) => {
const options = {
- "branch": `/refs/heads/${req.params.branch}`,
- "branchName": req.params.branch,
- "file": req.params[0],
- "owner": req.params.owner,
- "reponame": req.params.reponame,
- "rev": req.params.rev
+ branch: `/refs/heads/${req.params.branch}`,
+ branchName: req.params.branch,
+ file: req.params[0],
+ owner: req.params.owner,
+ reponame: req.params.reponame,
+ rev: req.params.rev,
};
const pathParts = [req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev, options.file];
diff --git a/BuildServer/routes/index.ts b/BuildServer/routes/index.ts
index ce1c912..125109f 100644
--- a/BuildServer/routes/index.ts
+++ b/BuildServer/routes/index.ts
@@ -1,12 +1,11 @@
"use strict";
-import postreceive from "./postreceive";
-import * as manual from "./manual";
-import * as status from "./status";
import artifact from "./artifact";
+import * as manual from "./manual";
+import postreceive from "./postreceive";
import release from "./release";
+import * as status from "./status";
-const index = (req, res) => res.render("index", { "title": `Express
\r\n${req}` });
+const index = (req, res) => res.render("index", { title: `Express
\r\n${req}` });
export { index, postreceive, manual, status, artifact, release };
-
diff --git a/BuildServer/routes/manual.ts b/BuildServer/routes/manual.ts
index ae4c86d..c9f7cc2 100644
--- a/BuildServer/routes/manual.ts
+++ b/BuildServer/routes/manual.ts
@@ -7,8 +7,8 @@ export const get = (req, res) => res.render("manual");
export const post = (req, res) => {
const options = _.extend(req.body, {
- "app": req.app,
- "url": `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`
+ app: req.app,
+ url: `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`,
});
build(options, (err, result) => {
@@ -16,7 +16,7 @@ export const post = (req, res) => {
console.log(`Error: ${err}`);
res.render("manual-done", {
err,
- result
+ result,
});
});
-};
\ No newline at end of file
+};
diff --git a/BuildServer/routes/postreceive.ts b/BuildServer/routes/postreceive.ts
index 504516d..92a3546 100644
--- a/BuildServer/routes/postreceive.ts
+++ b/BuildServer/routes/postreceive.ts
@@ -9,12 +9,12 @@ const getBranchDescription = (options) => `${options.owner}/${options.reponame}:
const processPush = (req, res, payload) => {
const repository = payload.repository;
const options = {
- "app": req.app,
- "branch": payload.ref,
- "owner": repository.owner.name,
- "reponame": repository.name,
- "rev": payload.after,
- "url": repository.url
+ app: req.app,
+ branch: payload.ref,
+ owner: repository.owner.name,
+ reponame: repository.name,
+ rev: payload.after,
+ url: repository.url,
};
console.log(`Got push event for ${getBranchDescription(options)}`);
@@ -33,33 +33,33 @@ const processPullRequest = (req, res, payload) => {
const head = pullRequest.head;
const headRepo = head.repo;
const headRepoOptions = {
- "branch": `refs/heads/${head.ref}`,
- "branchname": head.ref,
- "owner": headRepo.owner.name || headRepo.owner.login,
- "reponame": headRepo.name,
- "rev": head.sha,
- "url": headRepo.url
+ branch: `refs/heads/${head.ref}`,
+ branchname: head.ref,
+ owner: headRepo.owner.name || headRepo.owner.login,
+ reponame: headRepo.name,
+ rev: head.sha,
+ url: headRepo.url,
};
const base = pullRequest.base;
const baseRepo = base.repo;
const baseRepoOptions = {
- "branchname": base.ref,
- "owner": baseRepo.owner.name || baseRepo.owner.login,
- "reponame": baseRepo.name
+ branchname: base.ref,
+ owner: baseRepo.owner.name || baseRepo.owner.login,
+ reponame: baseRepo.name,
};
const options = {
action,
- "app": req.app,
+ app: req.app,
baseRepoOptions,
headRepoOptions,
- pullRequestNumber
+ pullRequestNumber,
};
const masterOptions = {
action,
- "app": req.app,
+ app: req.app,
baseRepoOptions,
- "headRepoOptions": baseRepoOptions,
- pullRequestNumber
+ headRepoOptions: baseRepoOptions,
+ pullRequestNumber,
};
console.log(`Got pull request ${action} event, `
@@ -79,16 +79,13 @@ const processPullRequest = (req, res, payload) => {
return res.send("");
}
- return commentOnPullRequest(
- (action === "closed" && masterOptions) || options,
- (err, data) => {
- if (err) {
- console.log(`Unable to post comment: ${err}`);
- }
-
- res.send(err || data);
+ return commentOnPullRequest((action === "closed" && masterOptions) || options, (err, data) => {
+ if (err) {
+ console.log(`Unable to post comment: ${err}`);
}
- );
+
+ res.send(err || data);
+ });
};
const getPayload = (body) => {
diff --git a/BuildServer/routes/release.ts b/BuildServer/routes/release.ts
index c4d5f0c..467c2b9 100644
--- a/BuildServer/routes/release.ts
+++ b/BuildServer/routes/release.ts
@@ -1,7 +1,7 @@
"use strict";
-import { join } from "path";
import { create as createArchiver } from "archiver";
+import { join } from "path";
import { readReport } from "../lib/report-processor";
@@ -25,11 +25,11 @@ const getDatePart = (report) => {
export default (req, res, next) => {
const options = {
- "branch": `/refs/heads/${req.params.branch}`,
- "branchName": req.params.branch,
- "owner": req.params.owner,
- "reponame": req.params.reponame,
- "rev": req.params.rev
+ branch: `/refs/heads/${req.params.branch}`,
+ branchName: req.params.branch,
+ owner: req.params.owner,
+ reponame: req.params.reponame,
+ rev: req.params.rev,
};
const releasePath = join(req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
diff --git a/BuildServer/routes/status.ts b/BuildServer/routes/status.ts
index bea269f..11bd3a6 100644
--- a/BuildServer/routes/status.ts
+++ b/BuildServer/routes/status.ts
@@ -1,7 +1,8 @@
"use strict";
-import { parse } from "url";
import * as _ from "underscore";
+import { parse } from "url";
+
import { getReport } from "../lib/status-processor";
const parseOptionsFromReferer = (path, callback) => {
@@ -19,7 +20,7 @@ const parseOptionsFromReferer = (path, callback) => {
branchName,
owner,
reponame,
- rev
+ rev,
});
}
@@ -29,7 +30,7 @@ const parseOptionsFromReferer = (path, callback) => {
branchName,
owner,
reponame,
- rev
+ rev,
});
};
@@ -42,24 +43,24 @@ const createShowReport = (res) => (err, inputOptions) => {
export const image = (req, res) => {
const getAdditionalOptions = (err, options) => {
if (err === "ReportFileNotFound") {
- return { "status": "Building" };
+ return { status: "Building" };
}
if (err) {
return {
- "message": err,
- "status": "StatusError"
+ message: err,
+ status: "StatusError",
};
}
if (options.report.result === "MBSNotFound") {
- return { "status": "MBSNotUsed" };
+ return { status: "MBSNotUsed" };
}
if (options.report.err) {
return {
- "message": options.report.err,
- "status": "Error"
+ message: options.report.err,
+ status: "Error",
};
}
@@ -67,8 +68,8 @@ export const image = (req, res) => {
const [firstWarn] = options.report.result.warns.$allMessages;
return {
- "message": firstWarn.message,
- "status": "Warning"
+ message: firstWarn.message,
+ status: "Warning",
};
}
@@ -76,12 +77,12 @@ export const image = (req, res) => {
if (allInfos.length) {
return {
- "message": allInfos[allInfos.length - 1].message,
- "status": "OK"
+ message: allInfos[allInfos.length - 1].message,
+ status: "OK",
};
}
- return { "status": "OK" };
+ return { status: "OK" };
};
const handle = (err, options) => {
@@ -100,11 +101,11 @@ export const image = (req, res) => {
export const page = (req, res) => {
const options = {
- "branch": `/refs/heads/${req.params.branch}`,
- "branchName": req.params.branch,
- "owner": req.params.owner,
- "reponame": req.params.reponame,
- "rev": req.params.rev
+ branch: `/refs/heads/${req.params.branch}`,
+ branchName: req.params.branch,
+ owner: req.params.owner,
+ reponame: req.params.reponame,
+ rev: req.params.rev,
};
getReport(req.app, options, createShowReport(res));
diff --git a/BuildServer/tsconfig.json b/BuildServer/tsconfig.json
index 4ce9f95..c99c2ba 100644
--- a/BuildServer/tsconfig.json
+++ b/BuildServer/tsconfig.json
@@ -3,12 +3,14 @@
"module": "commonjs",
"target": "es6",
"sourceMap": false,
+ "strictNullChecks": true,
"typeRoots": [
"node_modules/@types"
]
},
"include": [
"app.ts",
+ "global.d.ts",
"settings.ts",
"lib/**/*.ts",
"routes/**/*.ts"
diff --git a/BuildServer/tslint.json b/BuildServer/tslint.json
index 1a58f91..0af5928 100644
--- a/BuildServer/tslint.json
+++ b/BuildServer/tslint.json
@@ -1,101 +1,10 @@
{
- "jsRules": {
- "class-name": true,
- "comment-format": [
- true,
- "check-space"
- ],
- "indent": [
- true,
- "spaces"
- ],
- "no-duplicate-variable": true,
- "no-eval": true,
- "no-trailing-whitespace": true,
- "no-unsafe-finally": true,
- "one-line": [
- true,
- "check-open-brace",
- "check-whitespace"
- ],
- "quotemark": [
- true,
- "double"
- ],
- "semicolon": [
- true,
- "always"
- ],
- "triple-equals": [
- true,
- "allow-null-check"
- ],
- "variable-name": [
- true,
- "ban-keywords"
- ],
- "whitespace": [
- true,
- "check-branch",
- "check-decl",
- "check-operator",
- "check-separator",
- "check-type"
- ]
- },
+ "extends": [
+ "tslint:latest",
+ "tslint-eslint-rules"
+ ],
"rules": {
- "class-name": true,
- "comment-format": [
- true,
- "check-space"
- ],
- "indent": [
- true,
- "spaces"
- ],
- "no-eval": true,
- "no-internal-module": true,
- "no-trailing-whitespace": true,
- "no-unsafe-finally": true,
- "no-var-keyword": true,
- "one-line": [
- true,
- "check-open-brace",
- "check-whitespace"
- ],
- "quotemark": [
- true,
- "double"
- ],
- "semicolon": [
- true,
- "always"
- ],
- "triple-equals": [
- true,
- "allow-null-check"
- ],
- "typedef-whitespace": [
- true,
- {
- "call-signature": "nospace",
- "index-signature": "nospace",
- "parameter": "nospace",
- "property-declaration": "nospace",
- "variable-declaration": "nospace"
- }
- ],
- "variable-name": [
- true,
- "ban-keywords"
- ],
- "whitespace": [
- true,
- "check-branch",
- "check-decl",
- "check-operator",
- "check-separator",
- "check-type"
- ]
+ "no-console": false,
+ "max-line-length": false
}
}
\ No newline at end of file
From 11f9cdba9bed01cd49101b2630f36c3fc293d32a Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Tue, 28 Feb 2017 17:31:53 +0300
Subject: [PATCH 09/13] Refactoring; typing in tasks
---
BuildServer/lib/task-processor.ts | 26 +++---
.../lib/tasks/cleanupafterdotnetbuild.ts | 44 +++++----
BuildServer/lib/tasks/conditional.ts | 2 +-
BuildServer/lib/tasks/copy.ts | 28 +++---
BuildServer/lib/tasks/copyglob.ts | 44 +++++----
BuildServer/lib/tasks/cssnano.ts | 48 +++++-----
BuildServer/lib/tasks/cssnanoall.ts | 52 ++++++-----
BuildServer/lib/tasks/deletefromcode.ts | 26 +++---
BuildServer/lib/tasks/dotnetbuilderwrapper.ts | 68 +++++++-------
BuildServer/lib/tasks/dotnetcheckstyle.ts | 90 +++++++++----------
BuildServer/lib/tasks/dotnetnunitall.ts | 68 +++++++-------
BuildServer/lib/tasks/dotnetrewrite.ts | 60 ++++++-------
BuildServer/lib/tasks/echo.ts | 26 +++---
BuildServer/lib/tasks/eslintbrowser.ts | 38 ++++----
BuildServer/lib/tasks/eslintbrowserall.ts | 54 ++++++-----
BuildServer/lib/tasks/index.ts | 4 +-
BuildServer/lib/tasks/noop.ts | 2 +-
BuildServer/lib/tasks/parallel.ts | 2 +-
BuildServer/lib/tasks/sequential.ts | 2 +-
BuildServer/lib/tasks/uglifyjs.ts | 26 +++---
BuildServer/lib/tasks/uglifyjsall.ts | 52 ++++++-----
BuildServer/lib/tasks/writefile.ts | 26 +++---
BuildServer/lib/tasks/zip.ts | 26 +++---
23 files changed, 387 insertions(+), 427 deletions(-)
diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts
index 3df504a..08ed4b1 100644
--- a/BuildServer/lib/task-processor.ts
+++ b/BuildServer/lib/task-processor.ts
@@ -4,11 +4,8 @@ import * as _ from "underscore";
import tasks from "./tasks";
// TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here.
-const createTaskProcessor = (task, outerProcessor: TaskProcessor, callback) => {
- const result: TaskProcessor = {};
- const createTaskWorker = () => tasks[task.type](task.params || {}, result);
+const createTaskProcessor = (task: TaskInfo, outerProcessor: TaskProcessorCore, callback: TaskProcessorCallback) => {
const errors: string[] = [];
- const process = () => createTaskWorker().process();
const getOuterPrefix = (prefix) => {
if (task.name && prefix) {
return `${task.name}/${prefix}`;
@@ -22,20 +19,17 @@ const createTaskProcessor = (task, outerProcessor: TaskProcessor, callback) => {
};
const onWarn = (message, prefix) => outerProcessor.onWarn(message, getOuterPrefix(prefix));
const onInfo = (message, prefix) => outerProcessor.onInfo(message, getOuterPrefix(prefix));
- const processTask = (innerTask, innerCallback) => {
- const innerProcessor = createTaskProcessor(innerTask, result, innerCallback);
- innerProcessor.process();
+ let result: TaskProcessor;
+ result = {
+ context: outerProcessor.context,
+ done: () => callback(errors.join("\r\n")),
+ onError,
+ onWarn,
+ onInfo,
+ process: () => tasks[task.type](task.params || {}, result)(),
+ processTask: (innerTask, innerCallback) => createTaskProcessor(innerTask, result, innerCallback).process(),
};
- const done = () => callback(errors.join("\r\n"));
-
- result.process = process;
- result.onError = onError;
- result.onWarn = onWarn;
- result.onInfo = onInfo;
- result.processTask = processTask;
- result.done = done;
- result.context = outerProcessor.context;
return result;
};
diff --git a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
index 23b96f3..0c576b3 100644
--- a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
+++ b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
@@ -2,30 +2,28 @@
import * as glob from "glob";
-export default ((params, processor) => ({
- process: () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
- cwd: processor.context.exported,
- dot: true,
- }, (err, files) => {
- if (err) {
- processor.onError(err);
+export default ((params, processor) => () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
+ cwd: processor.context.exported,
+ dot: true,
+}, (err, files) => {
+ if (err) {
+ processor.onError(err);
- return processor.done();
- }
+ return processor.done();
+ }
- if (!files || !files.length) {
- return processor.done();
- }
+ if (!files || !files.length) {
+ return processor.done();
+ }
- return processor.processTask({
- params: {
- tasks: files.map((file) => ({
- name: file,
- params: { filename: file },
- type: "deletefromcode",
- })),
- },
- type: "parallel",
- }, processor.done.bind(processor));
- }),
+ return processor.processTask({
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "deletefromcode",
+ })),
+ },
+ type: "parallel",
+ }, processor.done);
})) as Task;
diff --git a/BuildServer/lib/tasks/conditional.ts b/BuildServer/lib/tasks/conditional.ts
index 7c8c13f..4bf70d8 100644
--- a/BuildServer/lib/tasks/conditional.ts
+++ b/BuildServer/lib/tasks/conditional.ts
@@ -5,5 +5,5 @@ export default ((params, processor) => {
&& (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch);
const task = (condition && params.task) || params.otherwise;
- return { process: () => processor.processTask(task || { type: "noop" }, processor.done.bind(processor)) };
+ return () => processor.processTask(task || { type: "noop" }, processor.done);
}) as Task;
diff --git a/BuildServer/lib/tasks/copy.ts b/BuildServer/lib/tasks/copy.ts
index e7f06a2..589c67b 100644
--- a/BuildServer/lib/tasks/copy.ts
+++ b/BuildServer/lib/tasks/copy.ts
@@ -3,21 +3,19 @@
import { copy } from "fs-extra";
import { join } from "path";
-export default ((params, processor) => ({
- process: () => {
- const sourceFilePath = join(processor.context.exported, params.filename);
- const targetFilePath = join(processor.context.release, params.filename);
+export default ((params, processor) => () => {
+ const sourceFilePath = join(processor.context.exported, params.filename);
+ const targetFilePath = join(processor.context.release, params.filename);
- processor.onInfo(`Copying ${sourceFilePath} to ${targetFilePath}`);
+ processor.onInfo(`Copying ${sourceFilePath} to ${targetFilePath}`);
- copy(sourceFilePath, targetFilePath, (err) => {
- if (err) {
- processor.onError(`Unable to copy file: ${err}`);
- } else {
- processor.onInfo("Copied file");
- }
+ copy(sourceFilePath, targetFilePath, (err) => {
+ if (err) {
+ processor.onError(`Unable to copy file: ${err}`);
+ } else {
+ processor.onInfo("Copied file");
+ }
- return processor.done();
- });
- },
-})) as Task;
+ return processor.done();
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/copyglob.ts b/BuildServer/lib/tasks/copyglob.ts
index 522273f..b284971 100644
--- a/BuildServer/lib/tasks/copyglob.ts
+++ b/BuildServer/lib/tasks/copyglob.ts
@@ -2,30 +2,28 @@
import * as glob from "glob";
-export default ((params, processor) => ({
- process: () => glob(params.mask, {
- cwd: processor.context.exported,
- dot: true,
- }, (err, files) => {
- if (err) {
- processor.onError(err);
+export default ((params, processor) => () => glob(params.mask, {
+ cwd: processor.context.exported,
+ dot: true,
+}, (err, files) => {
+ if (err) {
+ processor.onError(err);
- return processor.done();
- }
+ return processor.done();
+ }
- if (!files || !files.length) {
- return processor.done();
- }
+ if (!files || !files.length) {
+ return processor.done();
+ }
- return processor.processTask({
- params: {
- tasks: files.map((file) => ({
- name: file,
- params: { filename: file },
- type: "copy",
- })),
- },
- type: "parallel",
- }, processor.done.bind(processor));
- }),
+ return processor.processTask({
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "copy",
+ })),
+ },
+ type: "parallel",
+ }, processor.done);
})) as Task;
diff --git a/BuildServer/lib/tasks/cssnano.ts b/BuildServer/lib/tasks/cssnano.ts
index 1620342..7c4497c 100644
--- a/BuildServer/lib/tasks/cssnano.ts
+++ b/BuildServer/lib/tasks/cssnano.ts
@@ -4,33 +4,31 @@ import { process as cssnanoProcess } from "cssnano";
import { readFile, writeFile } from "fs";
import { join } from "path";
-export default ((params, processor) => ({
- process: () => {
- const filePath = join(processor.context.exported, params.filename);
+export default ((params, processor) => () => {
+ const filePath = join(processor.context.exported, params.filename);
- readFile(filePath, (readErr, css) => {
- if (readErr) {
- processor.onError(`Unable to read stylesheet ${params.filename}: ${readErr}`);
+ readFile(filePath, (readErr, css) => {
+ if (readErr) {
+ processor.onError(`Unable to read stylesheet ${params.filename}: ${readErr}`);
- return processor.done();
- }
+ return processor.done();
+ }
- return cssnanoProcess(css)
- .catch((cssErr) => {
- processor.onError(`Unable to uglify stylesheet: ${cssErr}`);
- processor.done();
- })
- .then((result) => {
- writeFile(filePath, result.css, (writeErr) => {
- if (writeErr) {
- processor.onError(`Unable to write uglified stylesheet for ${params.filename}: ${writeErr}`);
- } else {
- processor.onInfo(`Saved uglified stylesheet for ${params.filename}; uglified length: ${result.css.length}`);
- }
+ return cssnanoProcess(css)
+ .catch((cssErr) => {
+ processor.onError(`Unable to uglify stylesheet: ${cssErr}`);
+ processor.done();
+ })
+ .then((result) => {
+ writeFile(filePath, result.css, (writeErr) => {
+ if (writeErr) {
+ processor.onError(`Unable to write uglified stylesheet for ${params.filename}: ${writeErr}`);
+ } else {
+ processor.onInfo(`Saved uglified stylesheet for ${params.filename}; uglified length: ${result.css.length}`);
+ }
- processor.done();
- });
+ processor.done();
});
- });
- },
-})) as Task;
+ });
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/cssnanoall.ts b/BuildServer/lib/tasks/cssnanoall.ts
index 882b9a8..30a229f 100644
--- a/BuildServer/lib/tasks/cssnanoall.ts
+++ b/BuildServer/lib/tasks/cssnanoall.ts
@@ -3,34 +3,32 @@
import * as glob from "glob";
const flagDoneName = "cssnanoallDone";
-export default ((params, processor) => ({
- process: () => {
- if (processor.context.containsFlag(flagDoneName)) {
- processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json");
- }
+export default ((params, processor) => () => {
+ if (processor.context.containsFlag(flagDoneName)) {
+ processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json");
+ }
- processor.context.addFlag(flagDoneName);
+ processor.context.addFlag(flagDoneName);
- glob("**/*.css", {
- cwd: processor.context.exported,
- dot: true,
- }, (err, files) => {
- if (err) {
- processor.onError(err);
+ glob("**/*.css", {
+ cwd: processor.context.exported,
+ dot: true,
+ }, (err, files) => {
+ if (err) {
+ processor.onError(err);
- return processor.done();
- }
+ return processor.done();
+ }
- return processor.processTask({
- params: {
- tasks: files.map((file) => ({
- name: file,
- params: { filename: file },
- type: "cssnano",
- })),
- },
- type: (params.preventParallelTests && "sequential") || "parallel",
- }, processor.done.bind(processor));
- });
- },
-})) as Task;
+ return processor.processTask({
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "cssnano",
+ })),
+ },
+ type: (params.preventParallelTests && "sequential") || "parallel",
+ }, processor.done);
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/deletefromcode.ts b/BuildServer/lib/tasks/deletefromcode.ts
index ff90878..be12fe3 100644
--- a/BuildServer/lib/tasks/deletefromcode.ts
+++ b/BuildServer/lib/tasks/deletefromcode.ts
@@ -3,20 +3,18 @@
import { remove } from "fs-extra";
import { join } from "path";
-export default ((params, processor) => ({
- process: () => {
- const sourceFilePath = join(processor.context.exported, params.filename);
+export default ((params, processor) => () => {
+ const sourceFilePath = join(processor.context.exported, params.filename);
- processor.onInfo(`Deleting ${sourceFilePath}`);
+ processor.onInfo(`Deleting ${sourceFilePath}`);
- remove(sourceFilePath, (err) => {
- if (err) {
- processor.onError(`Unable to delete file: ${err}`);
- } else {
- processor.onInfo("Deleted file");
- }
+ remove(sourceFilePath, (err) => {
+ if (err) {
+ processor.onError(`Unable to delete file: ${err}`);
+ } else {
+ processor.onInfo("Deleted file");
+ }
- return processor.done();
- });
- },
-})) as Task;
+ return processor.done();
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
index 39af675..4c5eda1 100644
--- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
+++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
@@ -28,49 +28,47 @@ const wrapBuilder = (builder, input, onExit) => {
builder.stdin.end();
};
-export default ((params, processor) => ({
- process: () => {
- const input = JSON.stringify(params);
- const builder = spawn(settings.builderExecutable, [params.command]);
+export default ((params, processor) => () => {
+ const input = JSON.stringify(params);
+ const builder = spawn(settings.builderExecutable, [params.command]);
- processor.onInfo(`DotNetBuilderWrapper processing (at ${new Date().toISOString()}): ${input}`);
+ processor.onInfo(`DotNetBuilderWrapper processing (at ${new Date().toISOString()}): ${input}`);
- wrapBuilder(builder, input, (code, result, builderError) => {
- if (code || builderError) {
- processor.onError(`Return code is ${code}\r\n${builderError}`);
+ wrapBuilder(builder, input, (code, result, builderError) => {
+ if (code || builderError) {
+ processor.onError(`Return code is ${code}\r\n${builderError}`);
- return processor.done();
- }
+ return processor.done();
+ }
- const { value, error } = JSONParse(result);
+ const { value, error } = JSONParse(result);
- if (error || !value || !value.Messages) {
- processor.onError(`Malformed JSON: ${error}`);
- processor.onInfo(result);
+ if (error || !value || !value.Messages) {
+ processor.onError(`Malformed JSON: ${error}`);
+ processor.onInfo(result);
- return processor.done();
- }
+ return processor.done();
+ }
- const messages = value.Messages;
+ const messages = value.Messages;
- messages.forEach((message) => {
- if (!message) {
- return processor.onError("Message is null");
- }
+ messages.forEach((message) => {
+ if (!message) {
+ return processor.onError("Message is null");
+ }
- switch (message.Type) {
- case "info":
- return processor.onInfo(message.Body);
- case "warn":
- return processor.onWarn(message.Body);
- default:
- return processor.onError(message.Body);
- }
- });
+ switch (message.Type) {
+ case "info":
+ return processor.onInfo(message.Body);
+ case "warn":
+ return processor.onWarn(message.Body);
+ default:
+ return processor.onError(message.Body);
+ }
+ });
- processor.onInfo(`Done DotNetBuilderWrapper processing (at ${new Date().toISOString()})`);
+ processor.onInfo(`Done DotNetBuilderWrapper processing (at ${new Date().toISOString()})`);
- return processor.done();
- });
- },
-})) as Task;
+ return processor.done();
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.ts b/BuildServer/lib/tasks/dotnetcheckstyle.ts
index 0aa1222..0ab841e 100644
--- a/BuildServer/lib/tasks/dotnetcheckstyle.ts
+++ b/BuildServer/lib/tasks/dotnetcheckstyle.ts
@@ -11,66 +11,64 @@ const autoGeneratedMarker
const flagDoneName = "dotnetcheckerDone";
-export default ((params, processor) => ({
- process: () => {
- if (processor.context.containsFlag(flagDoneName)) {
- return processor.done();
- }
+export default ((params, processor) => () => {
+ if (processor.context.containsFlag(flagDoneName)) {
+ return processor.done();
+ }
- processor.context.addFlag(flagDoneName);
+ processor.context.addFlag(flagDoneName);
- return glob("**/*.cs", { cwd: processor.context.exported }, (globErr, files) => {
- if (globErr) {
- processor.onError(globErr);
+ return glob("**/*.cs", { cwd: processor.context.exported }, (globErr, files) => {
+ if (globErr) {
+ processor.onError(globErr);
- return processor.done();
- }
+ return processor.done();
+ }
+
+ processor.onInfo(`Found ${files.length} .cs files`);
- processor.onInfo(`Found ${files.length} .cs files`);
+ if (!files || !files.length) {
+ processor.onWarn("No .cs files found");
- if (!files || !files.length) {
- processor.onWarn("No .cs files found");
+ return processor.done();
+ }
- return processor.done();
+ const processFile = (data, file) => {
+ if (data.includes("\r\n")) {
+ return processor.onError(`Windows-style EOL (0D0A) found in file ${file}`);
}
- const processFile = (data, file) => {
- if (data.includes("\r\n")) {
- return processor.onError(`Windows-style EOL (0D0A) found in file ${file}`);
+ if (!params.ignoreCodeStyle) {
+ if (data.substr(1, autoGeneratedMarker.length) === autoGeneratedMarker || data.startsWith(autoGeneratedMarker)) {
+ return processor.onInfo(`Skipping auto-generated file ${file}`);
}
- if (!params.ignoreCodeStyle) {
- if (data.substr(1, autoGeneratedMarker.length) === autoGeneratedMarker || data.startsWith(autoGeneratedMarker)) {
- return processor.onInfo(`Skipping auto-generated file ${file}`);
- }
-
- if (data.includes("\t") && data.includes(" ")) {
- processor.onError(`Both tabs and spaces found in file ${file}`);
- }
+ if (data.includes("\t") && data.includes(" ")) {
+ processor.onError(`Both tabs and spaces found in file ${file}`);
+ }
- if (data.includes("\t")) {
- processor.onError(`Tabs found in file ${file}`);
- }
+ if (data.includes("\t")) {
+ processor.onError(`Tabs found in file ${file}`);
}
+ }
- return processor.onInfo(`Checked file ${file}`);
- };
+ return processor.onInfo(`Checked file ${file}`);
+ };
- return parallel(files.map((file) => (callback) => readFile(
- join(processor.context.exported, file),
- { encoding: "utf8" },
- (readErr, data) => {
- if (readErr) {
- processor.onError(`Unable to check file ${file}: ${readErr}`);
+ return parallel(files.map((file) => (callback) => readFile(
+ join(processor.context.exported, file),
+ { encoding: "utf8" },
+ (readErr, data) => {
+ if (readErr) {
+ processor.onError(`Unable to check file ${file}: ${readErr}`);
- return callback(readErr);
- }
+ return callback(readErr);
+ }
- processFile(data, file);
+ processFile(data, file);
- return callback();
- },
- )), processor.done.bind(processor));
- });
- },
-})) as Task;
+ return callback();
+ },
+ )), processor.done);
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/dotnetnunitall.ts b/BuildServer/lib/tasks/dotnetnunitall.ts
index 75307c7..bc3ddf7 100644
--- a/BuildServer/lib/tasks/dotnetnunitall.ts
+++ b/BuildServer/lib/tasks/dotnetnunitall.ts
@@ -3,40 +3,38 @@
import * as glob from "glob";
const flagDoneName = "dotnetnunitallDone";
-export default ((params, processor) => ({
- process: () => {
- if (processor.context.containsFlag(flagDoneName)) {
- processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
+export default ((params, processor) => () => {
+ if (processor.context.containsFlag(flagDoneName)) {
+ processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
+ }
+
+ processor.context.addFlag(flagDoneName);
+
+ glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", {
+ cwd: processor.context.exported,
+ dot: true,
+ }, (err, files) => {
+ if (err) {
+ processor.onError(err);
+
+ return processor.done();
+ }
+
+ if (!files || !files.length) {
+ processor.onError(`No test assemblies found in ${processor.context.exported}`);
+
+ return processor.done();
}
- processor.context.addFlag(flagDoneName);
-
- glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", {
- cwd: processor.context.exported,
- dot: true,
- }, (err, files) => {
- if (err) {
- processor.onError(err);
-
- return processor.done();
- }
-
- if (!files || !files.length) {
- processor.onError(`No test assemblies found in ${processor.context.exported}`);
-
- return processor.done();
- }
-
- return processor.processTask({
- params: {
- tasks: files.map((file) => ({
- name: file,
- params: { assembly: file },
- type: "dotnetnunit",
- })),
- },
- type: (params.preventParallelTests && "sequential") || "parallel",
- }, processor.done.bind(processor));
- });
- },
-})) as Task;
+ return processor.processTask({
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { assembly: file },
+ type: "dotnetnunit",
+ })),
+ },
+ type: (params.preventParallelTests && "sequential") || "parallel",
+ }, processor.done);
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/dotnetrewrite.ts b/BuildServer/lib/tasks/dotnetrewrite.ts
index d917bae..ec8ebdf 100644
--- a/BuildServer/lib/tasks/dotnetrewrite.ts
+++ b/BuildServer/lib/tasks/dotnetrewrite.ts
@@ -31,41 +31,39 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => (
return cb(null, processInformationalVersion(processInternalsVisible(originalContent)));
};
-export default ((params, processor) => ({
- process: () => {
- if (processor.context.containsFlag(flagDoneName)) {
- return processor.done();
- }
+export default ((params, processor) => () => {
+ if (processor.context.containsFlag(flagDoneName)) {
+ return processor.done();
+ }
- processor.context.addFlag(flagDoneName);
+ processor.context.addFlag(flagDoneName);
- return glob("**/{InternalsVisible,AssemblyInfo}*.cs", { cwd: processor.context.exported }, (globErr, files) => {
- if (globErr) {
- processor.onError(globErr);
+ return glob("**/{InternalsVisible,AssemblyInfo}*.cs", { cwd: processor.context.exported }, (globErr, files) => {
+ if (globErr) {
+ processor.onError(globErr);
- return processor.done();
- }
+ return processor.done();
+ }
- processor.onInfo(`Found ${files.length} AssemblyInfo.cs files`);
+ processor.onInfo(`Found ${files.length} AssemblyInfo.cs files`);
- if (!files || !files.length) {
- processor.onWarn("No AssemblyInfo.cs found");
+ if (!files || !files.length) {
+ processor.onWarn("No AssemblyInfo.cs found");
- return processor.done();
- }
+ return processor.done();
+ }
- return parallel(files.map((file) => (callback) => waterfall([
- readFile.bind(null, join(processor.context.exported, file), { encoding: "utf8" }),
- processAssemblyInfo(params, processor, file.toLowerCase().includes("assemblyinfo.cs")),
- writeFile.bind(null, join(processor.context.exported, file)),
- ], (err) => {
- if (err) {
- processor.onError(`Unable to rewrite file ${file}: ${err}`);
- } else {
- processor.onInfo(`Rewritten file ${file}`);
- }
- callback(err);
- })), processor.done.bind(processor));
- });
- },
-})) as Task;
+ return parallel(files.map((file) => (callback) => waterfall([
+ readFile.bind(null, join(processor.context.exported, file), { encoding: "utf8" }),
+ processAssemblyInfo(params, processor, file.toLowerCase().includes("assemblyinfo.cs")),
+ writeFile.bind(null, join(processor.context.exported, file)),
+ ], (err) => {
+ if (err) {
+ processor.onError(`Unable to rewrite file ${file}: ${err}`);
+ } else {
+ processor.onInfo(`Rewritten file ${file}`);
+ }
+ callback(err);
+ })), processor.done);
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/echo.ts b/BuildServer/lib/tasks/echo.ts
index 65690d0..a5b3e2e 100644
--- a/BuildServer/lib/tasks/echo.ts
+++ b/BuildServer/lib/tasks/echo.ts
@@ -1,19 +1,17 @@
"use strict";
-export default ((params, processor) => ({
- process: () => {
- if (params.error) {
- processor.onError(params.error);
- }
+export default ((params, processor) => () => {
+ if (params.error) {
+ processor.onError(params.error);
+ }
- if (params.warn) {
- processor.onWarn(params.warn);
- }
+ if (params.warn) {
+ processor.onWarn(params.warn);
+ }
- if (params.info) {
- processor.onInfo(params.info);
- }
+ if (params.info) {
+ processor.onInfo(params.info);
+ }
- processor.done();
- },
-})) as Task;
+ processor.done();
+}) as Task;
diff --git a/BuildServer/lib/tasks/eslintbrowser.ts b/BuildServer/lib/tasks/eslintbrowser.ts
index 86cde65..229d70b 100644
--- a/BuildServer/lib/tasks/eslintbrowser.ts
+++ b/BuildServer/lib/tasks/eslintbrowser.ts
@@ -8,25 +8,23 @@ const cli = new CLIEngine({ configFile: settings.eslintBrowserConfig });
const errorSeverity = 2;
-export default ((params, processor) => ({
- process: () => {
- const filePath = join(processor.context.exported, params.filename);
- const result = cli.executeOnFiles([filePath]);
-
- processor.onInfo(`ESLinted ${params.filename}`);
-
- result.results.forEach((subresult) => {
- subresult.messages.forEach((message) => {
- const messageText = `${params.filename}:${message.line},${message.column} (${message.ruleId}) ${message.message}`;
-
- if (message.fatal || message.severity === errorSeverity) {
- processor.onError(messageText);
- } else {
- processor.onWarn(messageText);
- }
- });
+export default ((params, processor) => () => {
+ const filePath = join(processor.context.exported, params.filename);
+ const result = cli.executeOnFiles([filePath]);
+
+ processor.onInfo(`ESLinted ${params.filename}`);
+
+ result.results.forEach((subresult) => {
+ subresult.messages.forEach((message) => {
+ const messageText = `${params.filename}:${message.line},${message.column} (${message.ruleId}) ${message.message}`;
+
+ if (message.fatal || message.severity === errorSeverity) {
+ processor.onError(messageText);
+ } else {
+ processor.onWarn(messageText);
+ }
});
+ });
- processor.done();
- },
-})) as Task;
+ processor.done();
+}) as Task;
diff --git a/BuildServer/lib/tasks/eslintbrowserall.ts b/BuildServer/lib/tasks/eslintbrowserall.ts
index 0c4c6e4..253bb79 100644
--- a/BuildServer/lib/tasks/eslintbrowserall.ts
+++ b/BuildServer/lib/tasks/eslintbrowserall.ts
@@ -3,36 +3,34 @@
import * as glob from "glob";
const flagDoneName = "eslintbrowserallDone";
-export default ((params, processor) => ({
- process: () => {
- if (processor.context.containsFlag(flagDoneName)) {
- processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json");
- }
+export default ((params, processor) => () => {
+ if (processor.context.containsFlag(flagDoneName)) {
+ processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json");
+ }
- processor.context.addFlag(flagDoneName);
+ processor.context.addFlag(flagDoneName);
- const excludeFiles = params.excludeFiles || [];
+ const excludeFiles = params.excludeFiles || [];
- glob("**/*.js", {
- cwd: processor.context.exported,
- dot: true,
- }, (err, files) => {
- if (err) {
- processor.onError(err);
+ glob("**/*.js", {
+ cwd: processor.context.exported,
+ dot: true,
+ }, (err, files) => {
+ if (err) {
+ processor.onError(err);
- return processor.done();
- }
+ return processor.done();
+ }
- return processor.processTask({
- params: {
- tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({
- name: file,
- params: { filename: file },
- type: "eslintbrowser",
- })),
- },
- type: (params.preventParallelTests && "sequential") || "parallel",
- }, processor.done.bind(processor));
- });
- },
-})) as Task;
+ return processor.processTask({
+ params: {
+ tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "eslintbrowser",
+ })),
+ },
+ type: (params.preventParallelTests && "sequential") || "parallel",
+ }, processor.done);
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/index.ts b/BuildServer/lib/tasks/index.ts
index 8c660da..3bc4051 100644
--- a/BuildServer/lib/tasks/index.ts
+++ b/BuildServer/lib/tasks/index.ts
@@ -2,7 +2,7 @@
import { readdirSync } from "fs";
-const tasks: Tasks = {};
+const tasks = {};
// Code taken from http://stackoverflow.com/a/17204293
readdirSync(__dirname)
@@ -13,4 +13,4 @@ readdirSync(__dirname)
}
});
-export default tasks;
+export default tasks as Tasks;
diff --git a/BuildServer/lib/tasks/noop.ts b/BuildServer/lib/tasks/noop.ts
index 5726067..88ab43c 100644
--- a/BuildServer/lib/tasks/noop.ts
+++ b/BuildServer/lib/tasks/noop.ts
@@ -1,3 +1,3 @@
"use strict";
-export default ((params, processor) => ({ process: () => processor.done() })) as Task;
+export default ((params, processor) => processor.done()) as Task;
diff --git a/BuildServer/lib/tasks/parallel.ts b/BuildServer/lib/tasks/parallel.ts
index bd59e11..f195df4 100644
--- a/BuildServer/lib/tasks/parallel.ts
+++ b/BuildServer/lib/tasks/parallel.ts
@@ -4,4 +4,4 @@ import { parallel } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-export default ((params, processor) => ({ process: () => parallel(params.tasks.map(mapper(processor)), () => processor.done()) })) as Task;
+export default ((params, processor) => () => parallel(params.tasks.map(mapper(processor)), processor.done)) as Task;
diff --git a/BuildServer/lib/tasks/sequential.ts b/BuildServer/lib/tasks/sequential.ts
index cfdfe20..6536bd5 100644
--- a/BuildServer/lib/tasks/sequential.ts
+++ b/BuildServer/lib/tasks/sequential.ts
@@ -4,4 +4,4 @@ import { series } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback);
-export default ((params, processor) => ({ process: () => series(params.tasks.map(mapper(processor)), () => processor.done()) })) as Task;
+export default ((params, processor) => () => series(params.tasks.map(mapper(processor)), processor.done)) as Task;
diff --git a/BuildServer/lib/tasks/uglifyjs.ts b/BuildServer/lib/tasks/uglifyjs.ts
index 6ea71e0..d7857a9 100644
--- a/BuildServer/lib/tasks/uglifyjs.ts
+++ b/BuildServer/lib/tasks/uglifyjs.ts
@@ -4,19 +4,17 @@ import { writeFile } from "fs";
import { join, normalize } from "path";
import { minify } from "uglify-js";
-export default ((params, processor) => ({
- process: () => {
- const filePath = normalize(join(processor.context.exported, params.filename));
- const result = minify(filePath);
+export default ((params, processor) => () => {
+ const filePath = normalize(join(processor.context.exported, params.filename));
+ const result = minify(filePath);
- writeFile(filePath, result.code, (err) => {
- if (err) {
- processor.onError(`Unable to write uglified script for ${params.filename}: ${err}`);
- } else {
- processor.onInfo(`Saved uglified script for ${params.filename}; uglified length: ${result.code.length}`);
- }
+ writeFile(filePath, result.code, (err) => {
+ if (err) {
+ processor.onError(`Unable to write uglified script for ${params.filename}: ${err}`);
+ } else {
+ processor.onInfo(`Saved uglified script for ${params.filename}; uglified length: ${result.code.length}`);
+ }
- processor.done();
- });
- },
-})) as Task;
+ processor.done();
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/uglifyjsall.ts b/BuildServer/lib/tasks/uglifyjsall.ts
index 1e2d281..195cd55 100644
--- a/BuildServer/lib/tasks/uglifyjsall.ts
+++ b/BuildServer/lib/tasks/uglifyjsall.ts
@@ -4,34 +4,32 @@ import * as glob from "glob";
const doneFlagName = "uglifyjsallDone";
-export default ((params, processor) => ({
- process: () => {
- if (processor.context.containsFlag(doneFlagName)) {
- processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
- }
+export default ((params, processor) => () => {
+ if (processor.context.containsFlag(doneFlagName)) {
+ processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json");
+ }
- processor.context.addFlag(doneFlagName);
+ processor.context.addFlag(doneFlagName);
- glob("**/*.js", {
- cwd: processor.context.exported,
- dot: true,
- }, (err, files) => {
- if (err) {
- processor.onError(err);
+ glob("**/*.js", {
+ cwd: processor.context.exported,
+ dot: true,
+ }, (err, files) => {
+ if (err) {
+ processor.onError(err);
- return processor.done();
- }
+ return processor.done();
+ }
- return processor.processTask({
- params: {
- tasks: files.map((file) => ({
- name: file,
- params: { filename: file },
- type: "uglifyjs",
- })),
- },
- type: (params.preventParallelTests && "sequential") || "parallel",
- }, processor.done.bind(processor));
- });
- },
-})) as Task;
+ return processor.processTask({
+ params: {
+ tasks: files.map((file) => ({
+ name: file,
+ params: { filename: file },
+ type: "uglifyjs",
+ })),
+ },
+ type: (params.preventParallelTests && "sequential") || "parallel",
+ }, processor.done);
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/writefile.ts b/BuildServer/lib/tasks/writefile.ts
index 46dda79..cc0b8ac 100644
--- a/BuildServer/lib/tasks/writefile.ts
+++ b/BuildServer/lib/tasks/writefile.ts
@@ -3,20 +3,18 @@
import { writeFile } from "fs";
import { join } from "path";
-export default ((params, processor) => ({
- process: () => {
- const filePath = join(processor.context.exported, params.filename);
+export default ((params, processor) => () => {
+ const filePath = join(processor.context.exported, params.filename);
- processor.onInfo(`Writing to ${filePath}`);
+ processor.onInfo(`Writing to ${filePath}`);
- writeFile(filePath, params.data, (err) => {
- if (err) {
- processor.onError(`Unable to write file: ${err}`);
- } else {
- processor.onInfo("Written file");
- }
+ writeFile(filePath, params.data, (err) => {
+ if (err) {
+ processor.onError(`Unable to write file: ${err}`);
+ } else {
+ processor.onInfo("Written file");
+ }
- return processor.done();
- });
- },
-})) as Task;
+ return processor.done();
+ });
+}) as Task;
diff --git a/BuildServer/lib/tasks/zip.ts b/BuildServer/lib/tasks/zip.ts
index 20b1ccb..4ffd10a 100644
--- a/BuildServer/lib/tasks/zip.ts
+++ b/BuildServer/lib/tasks/zip.ts
@@ -4,21 +4,19 @@ import { create as createArchiver } from "archiver";
import { createWriteStream } from "fs";
import { join, normalize } from "path";
-export default ((params, processor) => ({
- process: () => {
- const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || "")));
- const targetArchivePath = normalize(join(processor.context.release, params.archive));
+export default ((params, processor) => () => {
+ const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || "")));
+ const targetArchivePath = normalize(join(processor.context.release, params.archive));
- processor.onInfo(`Compressing "${params.directory}" to "${params.archive}"`);
+ processor.onInfo(`Compressing "${params.directory}" to "${params.archive}"`);
- const output = createWriteStream(targetArchivePath);
- const archive = createArchiver("zip");
+ const output = createWriteStream(targetArchivePath);
+ const archive = createArchiver("zip");
- output.on("close", () => processor.done());
+ output.on("close", processor.done);
- archive.on("error", (err) => processor.onError(`Error while compressing: ${err}`));
- archive.pipe(output);
- archive.directory(sourceDirectoryPath, false);
- archive.finalize();
- },
-})) as Task;
+ archive.on("error", (err) => processor.onError(`Error while compressing: ${err}`));
+ archive.pipe(output);
+ archive.directory(sourceDirectoryPath, false);
+ archive.finalize();
+}) as Task;
From 7bbefd15557035be758266d613d5723130b0b0dd Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 1 Mar 2017 10:32:52 +0300
Subject: [PATCH 10/13] Fixed messages prefixes processing; more type
annotations
---
BuildServer/lib/builder.ts | 20 ++++++++++----------
BuildServer/lib/report-processor.ts | 4 ++--
BuildServer/lib/task-processor.ts | 24 +++++++++++++++---------
3 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/BuildServer/lib/builder.ts b/BuildServer/lib/builder.ts
index 02d02c5..75bb213 100644
--- a/BuildServer/lib/builder.ts
+++ b/BuildServer/lib/builder.ts
@@ -115,13 +115,13 @@ export const build = (options, buildCallback) => {
return result.messages.$allMessages.map((msg) => `${msg.prefix}\t${msg.message}`).join("\r\n");
};
- const done = (doneErr, result?) => {
- const allErrors = ((result || {}).errors || {}).$allMessages || [];
- const allWarns = ((result || {}).warns || {}).$allMessages || [];
- const allInfos = ((result || {}).infos || {}).$allMessages || [];
- const errorMessage = (allErrors[0] || {}).message || doneErr;
- const warnMessage = (allWarns[0] || {}).message;
- const infoMessage = (allInfos[allInfos.length - 1] || {}).message;
+ const done = (doneErr, result?: ReportResult) => {
+ const allErrors = (result && result.errors && result.errors.$allMessages) || [];
+ const allWarns = (result && result.warns && result.errors.$allMessages) || [];
+ const allInfos = (result && result.infos && result.errors.$allMessages) || [];
+ const errorMessage = (allErrors[0] && allErrors[0].message) || doneErr;
+ const warnMessage = allWarns[0] && allWarns[0].message;
+ const infoMessage = allInfos[allInfos.length - 1] && allInfos[allInfos.length - 1].message;
writeReport(release, doneErr, result, (writeErr) => {
statusQueue.push((queueCallback) => parallel([
@@ -173,12 +173,12 @@ export const build = (options, buildCallback) => {
return exists(join(exported, "mbs.json"), (exists) => {
if (!exists) {
- return done(null, "MBSNotFound");
+ return done("MBSNotFound");
}
return readFile(join(exported, "mbs.json"), (readErr, data) => {
if (readErr) {
- return done(readErr, "MBSUnableToRead");
+ return done(`MBSUnableToRead: ${readErr}`);
}
const { value, error } = JSONParse(data);
@@ -186,7 +186,7 @@ export const build = (options, buildCallback) => {
if (error) {
console.log(`Malformed data: ${data}`);
- return done(error, "MBSMalformed");
+ return done("MBSMalformed");
}
return processTask(value, {
diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts
index 1f232b3..1bc5b92 100644
--- a/BuildServer/lib/report-processor.ts
+++ b/BuildServer/lib/report-processor.ts
@@ -24,12 +24,12 @@ const getAllErrors = (report: Report): Message[] => (report.result && report.res
const getAllWarns = (report: Report): Message[] => (report.result && report.result.warns && report.result.errors.$allMessages) || [];
const getAllInfos = (report: Report): Message[] => (report.result && report.result.infos && report.result.errors.$allMessages) || [];
-export const writeReport = (releaseDir, err, result: ReportResult, callback) => {
+export const writeReport = (releaseDir, err, result: ReportResult | undefined, callback) => {
const data = JSON.stringify({
date: Date.now(),
err,
result,
- });
+ } as Report);
const readable = new ReadableStreamBuffer(readableStreamBufferOptions);
const writeStream = createWriteStream(join(releaseDir, reportFilename));
diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts
index 08ed4b1..5a60450 100644
--- a/BuildServer/lib/task-processor.ts
+++ b/BuildServer/lib/task-processor.ts
@@ -36,19 +36,25 @@ const createTaskProcessor = (task: TaskInfo, outerProcessor: TaskProcessorCore,
const pushMessage = (list, message, parts, index) => {
if (!index) {
- list.$allMessages = list.$allMessages || [];
list.$allMessages.push({
message,
prefix: parts.join("/"),
});
}
- list.$messages = list.$messages || [];
- if (index === parts.length) {
- return list.$messages.push(message);
+ if (index < parts.length) {
+ if (!list[parts[index]]) {
+ list[parts[index]] = {};
+ }
+
+ return pushMessage(list[parts[index]], message, parts, index + 1);
+ }
+
+ if (!list.$messages) {
+ list.$messages = [];
}
- return pushMessage(list, message, parts, index + 1);
+ return list.$messages.push(message);
};
const addFlag = (flags) => (flagName) => {
@@ -58,10 +64,10 @@ const addFlag = (flags) => (flagName) => {
const containsFlag = (flags) => (flagName) => flags[flagName];
export const processTask = (task, context, callback) => {
- const errors = {};
- const warns = {};
- const infos = {};
- const messages = {};
+ const errors: MessagesRoot = { $allMessages: [] };
+ const warns: MessagesRoot = { $allMessages: [] };
+ const infos: MessagesRoot = { $allMessages: [] };
+ const messages: MessagesRoot = { $allMessages: [] };
const messageProcessor = (list) => (message, prefix) => {
const parts = prefix.split("/");
From f3930a78941b6636b66e9893089698c072a2247c Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 1 Mar 2017 10:34:36 +0300
Subject: [PATCH 11/13] Type annotations added to git
---
BuildServer/.gitignore | 1 -
BuildServer/global.d.ts | 64 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 1 deletion(-)
create mode 100644 BuildServer/global.d.ts
diff --git a/BuildServer/.gitignore b/BuildServer/.gitignore
index 86f6aa2..285b65b 100644
--- a/BuildServer/.gitignore
+++ b/BuildServer/.gitignore
@@ -18,6 +18,5 @@ data
*.crt
settings.js
settings.ts
-*.d.ts
iisnode
diff --git a/BuildServer/global.d.ts b/BuildServer/global.d.ts
new file mode 100644
index 0000000..7c05f6a
--- /dev/null
+++ b/BuildServer/global.d.ts
@@ -0,0 +1,64 @@
+interface Message {
+ readonly message: string;
+ readonly prefix: string;
+}
+
+interface PartialMessagesLeaf {
+ readonly $messages?: string[];
+}
+
+interface PartialMessagesRecursive {
+ readonly [propName: string]: Messages | string[] | Message[]; // workaround for compatibility with PartialMessagesLeaf and PartialMessagesRoot
+}
+
+interface PartialMessagesRoot {
+ readonly $allMessages: Message[];
+}
+
+type Messages = PartialMessagesLeaf & PartialMessagesRecursive;
+
+type MessagesRoot = PartialMessagesLeaf & PartialMessagesRecursive & PartialMessagesRoot;
+
+interface ReportResult {
+ readonly errors: MessagesRoot;
+ readonly warns: MessagesRoot;
+ readonly infos: MessagesRoot;
+ readonly messages: MessagesRoot;
+}
+
+interface Report {
+ readonly date: number;
+ readonly err?: string;
+ readonly result?: ReportResult;
+}
+
+interface TaskProcessorCallback {
+ (err: string): void;
+}
+
+interface TaskProcessorCore {
+ readonly onError: (message: string | Error, prefix?: string) => void;
+ readonly onWarn: (message: string, prefix?: string) => void;
+ readonly onInfo: (message: string, prefix?: string) => void;
+ readonly context?: any;
+}
+
+interface TaskProcessor extends TaskProcessorCore {
+ readonly process: () => void;
+ readonly processTask: (task: TaskInfo, innerCallback: TaskProcessorCallback) => void;
+ readonly done: () => void;
+}
+
+interface TaskInfo {
+ name?: string;
+ type: string;
+ params: any;
+}
+
+interface Task {
+ (params: any, processor: TaskProcessor): () => void;
+}
+
+interface Tasks {
+ readonly [taskName: string]: Task;
+}
From b1340eab1f38d6340087cd56c8b865ae00d9409d Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 1 Mar 2017 10:36:36 +0300
Subject: [PATCH 12/13] Removed legacy script; tsconfig cleanup
---
BuildServer/compress-old-reports.ts | 36 -----------------------------
BuildServer/tsconfig.json | 4 +---
2 files changed, 1 insertion(+), 39 deletions(-)
delete mode 100644 BuildServer/compress-old-reports.ts
diff --git a/BuildServer/compress-old-reports.ts b/BuildServer/compress-old-reports.ts
deleted file mode 100644
index 1d7b811..0000000
--- a/BuildServer/compress-old-reports.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-"use strict";
-
-const fs = require("fs");
-const path = require("path");
-const zlib = require("zlib");
-const glob = require("glob");
-const async = require("async");
-const settings = require("./settings");
-
-const streamsNumber = 100;
-
-glob("**\\report.json", { "cwd": settings.releasepath }, (globErr, files) => {
- if (globErr) {
- return console.log(globErr);
- }
-
- return async.parallelLimit(files.map((file) => (callback) => {
- const originalPath = path.join(settings.releasepath, file);
- const newPath = `${originalPath}.gz`;
-
- console.log(file);
- fs.createReadStream(originalPath)
- .pipe(zlib.createGzip())
- .pipe(fs.createWriteStream(newPath))
- .on("error", callback)
- .on("finish", () => {
- fs.unlink(originalPath, callback);
- });
- }), streamsNumber, (err) => {
- if (err) {
- console.log(err);
- }
-
- console.log("Done");
- });
-});
diff --git a/BuildServer/tsconfig.json b/BuildServer/tsconfig.json
index c99c2ba..b8f33ad 100644
--- a/BuildServer/tsconfig.json
+++ b/BuildServer/tsconfig.json
@@ -9,9 +9,7 @@
]
},
"include": [
- "app.ts",
- "global.d.ts",
- "settings.ts",
+ "*.ts",
"lib/**/*.ts",
"routes/**/*.ts"
],
From 78ed651184ec7e1f74d7a71b594618725450d8f6 Mon Sep 17 00:00:00 2001
From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com>
Date: Wed, 1 Mar 2017 10:59:41 +0300
Subject: [PATCH 13/13] Refactored dotnetbuilderwrapper to use promises; fixed
a bug causing incomplete data from wrapper
---
BuildServer/lib/tasks/dotnetbuilderwrapper.ts | 41 +++++++++++++------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
index 4c5eda1..d3a970d 100644
--- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
+++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts
@@ -7,25 +7,40 @@ import { WritableStreamBuffer } from "stream-buffers";
import settings from "../../settings";
const wrapBuilder = (builder, input, onExit) => {
- const resultBuffer = new WritableStreamBuffer();
- const errorBuffer = new WritableStreamBuffer();
-
- builder.stdout.on("data", (data) => {
- resultBuffer.write(data);
+ const stdoutPromise = new Promise((resolve, reject) => {
+ const streamBuffer = new WritableStreamBuffer();
+ builder.stdout
+ .on("error", reject)
+ .pipe(streamBuffer)
+ .on("error", reject)
+ .on("finish", () => {
+ streamBuffer.end();
+ resolve(streamBuffer.getContentsAsString());
+ });
});
- builder.stderr.on("data", (data) => {
- errorBuffer.write(data);
+ const stderrPromise = new Promise((resolve, reject) => {
+ const streamBuffer = new WritableStreamBuffer();
+ builder.stderr
+ .on("error", reject)
+ .pipe(streamBuffer)
+ .on("error", reject)
+ .on("finish", () => {
+ streamBuffer.end();
+ resolve(streamBuffer.getContentsAsString());
+ });
});
- builder.on("exit", (code) => {
- resultBuffer.end();
- errorBuffer.end();
- onExit(code, resultBuffer.getContentsAsString(), errorBuffer.getContentsAsString());
+ const builderPromise = new Promise((resolve, reject) => {
+ builder.stdin.write(input);
+ builder.stdin.end();
+ builder.on("exit", resolve);
});
- builder.stdin.write(input);
- builder.stdin.end();
+ Promise.all([stdoutPromise, stderrPromise, builderPromise]).then((values) => {
+ const [result, builderError, code] = values;
+ onExit(code, result, builderError);
+ }).catch((err) => onExit(0, undefined, err));
};
export default ((params, processor) => () => {