dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 7 years ago
parent c54d004d72
commit bec09d8c9f
  1. 16
      BuildServer/app.ts
  2. 53
      BuildServer/lib/builder.ts
  3. 38
      BuildServer/lib/commenter.ts
  4. 26
      BuildServer/lib/git/copy.ts
  5. 7
      BuildServer/lib/git/loader.ts
  6. 68
      BuildServer/lib/report-processor.ts
  7. 17
      BuildServer/lib/status-processor.ts
  8. 54
      BuildServer/lib/task-processor.ts
  9. 26
      BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
  10. 6
      BuildServer/lib/tasks/conditional.ts
  11. 10
      BuildServer/lib/tasks/copy.ts
  12. 26
      BuildServer/lib/tasks/copyglob.ts
  13. 11
      BuildServer/lib/tasks/cssnano.ts
  14. 26
      BuildServer/lib/tasks/cssnanoall.ts
  15. 10
      BuildServer/lib/tasks/deletefromcode.ts
  16. 18
      BuildServer/lib/tasks/dotnetbuild.ts
  17. 22
      BuildServer/lib/tasks/dotnetbuildandtest.ts
  18. 11
      BuildServer/lib/tasks/dotnetbuilderwrapper.ts
  19. 26
      BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
  20. 18
      BuildServer/lib/tasks/dotnetcheckstyle.ts
  21. 18
      BuildServer/lib/tasks/dotnetcompile.ts
  22. 12
      BuildServer/lib/tasks/dotnetnugetpack.ts
  23. 46
      BuildServer/lib/tasks/dotnetnugetprocess.ts
  24. 24
      BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
  25. 12
      BuildServer/lib/tasks/dotnetnugetpush.ts
  26. 15
      BuildServer/lib/tasks/dotnetnugetpushonly.ts
  27. 20
      BuildServer/lib/tasks/dotnetnugetrestore.ts
  28. 8
      BuildServer/lib/tasks/dotnetnunit.ts
  29. 26
      BuildServer/lib/tasks/dotnetnunitall.ts
  30. 61
      BuildServer/lib/tasks/dotnetpackwebapp.ts
  31. 26
      BuildServer/lib/tasks/dotnetrewrite.ts
  32. 8
      BuildServer/lib/tasks/echo.ts
  33. 14
      BuildServer/lib/tasks/eslintbrowser.ts
  34. 26
      BuildServer/lib/tasks/eslintbrowserall.ts
  35. 9
      BuildServer/lib/tasks/index.ts
  36. 2
      BuildServer/lib/tasks/noop.ts
  37. 34
      BuildServer/lib/tasks/packform.ts
  38. 2
      BuildServer/lib/tasks/parallel.ts
  39. 2
      BuildServer/lib/tasks/sequential.ts
  40. 9
      BuildServer/lib/tasks/uglifyjs.ts
  41. 26
      BuildServer/lib/tasks/uglifyjsall.ts
  42. 8
      BuildServer/lib/tasks/writefile.ts
  43. 10
      BuildServer/lib/tasks/zip.ts
  44. 5
      BuildServer/package.json
  45. 12
      BuildServer/routes/artifact.ts
  46. 9
      BuildServer/routes/index.ts
  47. 8
      BuildServer/routes/manual.ts
  48. 55
      BuildServer/routes/postreceive.ts
  49. 12
      BuildServer/routes/release.ts
  50. 39
      BuildServer/routes/status.ts
  51. 2
      BuildServer/tsconfig.json
  52. 103
      BuildServer/tslint.json

@ -5,22 +5,22 @@ import { gracefulify } from "graceful-fs";
gracefulify(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 express from "express";
import * as routes from "./routes";
import { createServer } from "http"; import { createServer } from "http";
import * as methodOverride from "method-override";
import * as morgan from "morgan";
import { join } from "path"; import { join } from "path";
import * as serveFavicon from "serve-favicon"; 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 serveStatic from "serve-static";
import * as errorhandler from "errorhandler";
import * as routes from "./routes";
import settings from "./settings"; import settings from "./settings";
const app = express(); 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("views", join(__dirname, "views"));
app.set("view engine", "jade"); app.set("view engine", "jade");
app.set("gitpath", settings.gitpath); app.set("gitpath", settings.gitpath);
@ -28,8 +28,8 @@ app.set("tmpcodepath", settings.tmpcodepath);
app.set("releasepath", settings.releasepath); app.set("releasepath", settings.releasepath);
app.use(serveFavicon(join(__dirname, "public/images/favicon.png"))); app.use(serveFavicon(join(__dirname, "public/images/favicon.png")));
app.use(morgan("dev")); app.use(morgan("dev"));
app.use(bodyJson({ "limit": "10mb" })); app.use(bodyJson({ limit: "10mb" }));
app.use(bodyUrlencoded({ "extended": false })); app.use(bodyUrlencoded({ extended: false }));
app.use(methodOverride()); app.use(methodOverride());
app.use(serveStatic(join(__dirname, "public"))); app.use(serveStatic(join(__dirname, "public")));

@ -1,15 +1,16 @@
"use strict"; "use strict";
import { join } from "path"; import { parallel, queue } from "async";
import { exists, readFile, writeFileSync } from "fs"; import { exists, readFile, writeFileSync } from "fs";
import { mkdirsSync, remove } from "fs-extra"; import { mkdirsSync, remove } from "fs-extra";
import { parallel, queue } from "async";
import * as JSONParse from "json-parse-safe"; import * as JSONParse from "json-parse-safe";
import { join } from "path";
import settings from "../settings";
import { gitLoader } from "./git/loader"; import { gitLoader } from "./git/loader";
import { processTask } from "./task-processor";
import { writeReport } from "./report-processor";
import { send as sendMail } from "./mail-sender"; import { send as sendMail } from "./mail-sender";
import settings from "../settings"; import { writeReport } from "./report-processor";
import { processTask } from "./task-processor";
const codePostfix = ""; const codePostfix = "";
const mailLazinessLevel = 1000; const mailLazinessLevel = 1000;
@ -35,12 +36,12 @@ const createBuildDoneMessage = (isSuccess, name) => {
const notifyStatus = (options, notifyStatusCallback) => { const notifyStatus = (options, notifyStatusCallback) => {
const status = { const status = {
"description": String(options.description || "").substr(0, maxDescriptionLength), description: String(options.description || "").substr(0, maxDescriptionLength),
"owner": options.owner, owner: options.owner,
"repo": options.reponame, repo: options.reponame,
"sha": options.hash, sha: options.hash,
"state": options.state, state: options.state,
"target_url": `${settings.siteRoot}status/${options.owner}/${options.reponame}/${options.hash}` target_url: `${settings.siteRoot}status/${options.owner}/${options.reponame}/${options.hash}`,
}; };
settings.createGithub(options.owner).repos.createStatus(status, (createStatusErr) => { 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}`; const versionInfo = `${version}; built from ${rev}; repository: ${owner}/${reponame}; branch: ${branch}`;
statusQueue.push((queueCallback) => notifyStatus({ statusQueue.push((queueCallback) => notifyStatus({
"description": "Preparing to build...", description: "Preparing to build...",
"hash": rev, hash: rev,
owner, owner,
reponame, reponame,
"state": "pending" state: "pending",
}, queueCallback)); }, queueCallback));
mkdirsSync(release); mkdirsSync(release);
@ -125,18 +126,18 @@ export const build = (options, buildCallback) => {
writeReport(release, doneErr, result, (writeErr) => { writeReport(release, doneErr, result, (writeErr) => {
statusQueue.push((queueCallback) => parallel([ statusQueue.push((queueCallback) => parallel([
(parallelCallback) => notifyStatus({ (parallelCallback) => notifyStatus({
"description": errorMessage || warnMessage || infoMessage || "Success", description: errorMessage || warnMessage || infoMessage || "Success",
"hash": rev, hash: rev,
owner, owner,
reponame, reponame,
"state": createFinalState(!doneErr) state: createFinalState(!doneErr),
}, parallelCallback), }, parallelCallback),
(parallelCallback) => sendMail({ (parallelCallback) => sendMail({
"from": settings.smtp.sender, from: settings.smtp.sender,
"headers": { "X-Laziness-level": mailLazinessLevel }, headers: { "X-Laziness-level": mailLazinessLevel },
"subject": createBuildDoneMessage(doneErr, `${owner}/${reponame}/${branch}`), subject: createBuildDoneMessage(doneErr, `${owner}/${reponame}/${branch}`),
"text": `Build status URL: ${settings.siteRoot}status/${owner}/${reponame}/${rev}\r\n\r\n${createErrorMessageForMail(doneErr)}${createResultMessageForMail(result)}`, text: `Build status URL: ${settings.siteRoot}status/${owner}/${reponame}/${rev}\r\n\r\n${createErrorMessageForMail(doneErr)}${createResultMessageForMail(result)}`,
"to": settings.smtp.receiver to: settings.smtp.receiver,
}, parallelCallback), }, parallelCallback),
(parallelCallback) => { (parallelCallback) => {
if (doneErr) { if (doneErr) {
@ -144,7 +145,7 @@ export const build = (options, buildCallback) => {
} }
return remove(tmp, parallelCallback); return remove(tmp, parallelCallback);
} },
], queueCallback)); ], queueCallback));
if (writeErr) { if (writeErr) {
@ -158,9 +159,9 @@ export const build = (options, buildCallback) => {
actualGitLoader({ actualGitLoader({
branch, branch,
exported, exported,
"hash": rev, hash: rev,
local, local,
"remote": `${url}.git` remote: `${url}.git`,
}, (gitLoaderErr) => { }, (gitLoaderErr) => {
if (gitLoaderErr) { if (gitLoaderErr) {
console.log(gitLoaderErr); console.log(gitLoaderErr);
@ -196,7 +197,7 @@ export const build = (options, buildCallback) => {
reponame, reponame,
rev, rev,
tmp, tmp,
versionInfo versionInfo,
}, (processErr, result) => { }, (processErr, result) => {
if (processErr) { if (processErr) {
return done(processErr, result); return done(processErr, result);

@ -1,8 +1,9 @@
"use strict"; "use strict";
import * as _ from "underscore"; import * as _ from "underscore";
import { getStatusMessageFromRelease } from "./report-processor";
import settings from "../settings"; import settings from "../settings";
import { getStatusMessageFromRelease } from "./report-processor";
const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/; const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/;
const versionNamePattern = /^v\d+(\.\d+)*$/; const versionNamePattern = /^v\d+(\.\d+)*$/;
@ -12,10 +13,10 @@ const httpNotFound = 404;
const maxCommentLength = 64000; const maxCommentLength = 64000;
const writeComment = (options, message, callback) => options.github.issues.createComment({ const writeComment = (options, message, callback) => options.github.issues.createComment({
"body": message, body: message,
"number": options.pullRequestNumber, number: options.pullRequestNumber,
"owner": options.baseRepoOptions.owner, owner: options.baseRepoOptions.owner,
"repo": options.baseRepoOptions.reponame repo: options.baseRepoOptions.reponame,
}, callback); }, callback);
const closePullRequest = (options, message, callback) => writeComment(options, message, (err) => { 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({ return options.github.issues.edit({
"number": options.pullRequestNumber, number: options.pullRequestNumber,
"owner": options.baseRepoOptions.owner, owner: options.baseRepoOptions.owner,
"repo": options.baseRepoOptions.reponame, repo: options.baseRepoOptions.reponame,
"state": "closed" state: "closed",
}, callback); }, callback);
}); });
const checkHasIssue = (options, issueNumber, callback) => options.github.issues.get({ const checkHasIssue = (options, issueNumber, callback) => options.github.issues.get({
"number": issueNumber, number: issueNumber,
"owner": options.baseRepoOptions.owner, owner: options.baseRepoOptions.owner,
"repo": options.baseRepoOptions.reponame repo: options.baseRepoOptions.reponame,
}, (getIssueErr, result) => { }, (getIssueErr, result) => {
if (getIssueErr && getIssueErr.code !== httpNotFound) { if (getIssueErr && getIssueErr.code !== httpNotFound) {
return callback(getIssueErr); return callback(getIssueErr);
@ -52,9 +53,9 @@ const checkHasIssue = (options, issueNumber, callback) => options.github.issues.
}); });
const checkHasReleases = (options, callback) => options.github.repos.getReleases({ const checkHasReleases = (options, callback) => options.github.repos.getReleases({
"owner": options.baseRepoOptions.owner, owner: options.baseRepoOptions.owner,
"per_page": 1, per_page: 1,
"repo": options.baseRepoOptions.reponame repo: options.baseRepoOptions.reponame,
}, (getReleasesErr, result) => { }, (getReleasesErr, result) => {
if (getReleasesErr) { if (getReleasesErr) {
return callback(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); 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) => { return checkHasIssue(options, issueNumber, (hasIssueErr, hasIssue, issueTitle) => {
if (hasIssueErr) { if (hasIssueErr) {
@ -137,8 +139,8 @@ const checkPullRequest = (options, callback) => {
}; };
export const commentOnPullRequest = (originalOptions, callback) => { export const commentOnPullRequest = (originalOptions, callback) => {
const optionsGithub = _.extend(originalOptions, { "github": settings.createGithub(originalOptions.baseRepoOptions.owner) }); 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...", _.noop) });
return checkPullRequest(options, () => getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => { return checkPullRequest(options, () => getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => {
const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength) const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength)

@ -1,9 +1,9 @@
"use strict"; "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 { parallel } from "async";
import { EventEmitter } from "events";
import { mkdir, writeFile } from "fs";
import { join } from "path";
import { Copier } from "recursive-tree-copy"; import { Copier } from "recursive-tree-copy";
const safeGetEntries = (tree, callback) => { const safeGetEntries = (tree, callback) => {
@ -15,8 +15,8 @@ const safeGetEntries = (tree, callback) => {
}; };
const gitToFsCopier = new Copier({ const gitToFsCopier = new Copier({
"concurrency": 4, concurrency: 4,
"copyLeaf": (entry, targetDir, callback) => { copyLeaf: (entry, targetDir, callback) => {
const targetPath = join(targetDir, entry.name()); const targetPath = join(targetDir, entry.name());
entry.getBlob((err, blob) => { entry.getBlob((err, blob) => {
@ -27,7 +27,7 @@ const gitToFsCopier = new Copier({
return writeFile(targetPath, blob.content(), callback); return writeFile(targetPath, blob.content(), callback);
}); });
}, },
"createTargetTree": (tree, targetDir, callback) => { createTargetTree: (tree, targetDir, callback) => {
const targetSubdir = join(targetDir, tree.name); const targetSubdir = join(targetDir, tree.name);
mkdir(targetSubdir, (err) => { mkdir(targetSubdir, (err) => {
@ -39,8 +39,8 @@ const gitToFsCopier = new Copier({
return callback(null, targetSubdir); return callback(null, targetSubdir);
}); });
}, },
"finalizeTargetTree": (targetSubdir, callback) => callback(), finalizeTargetTree: (targetSubdir, callback) => callback(),
"walkSourceTree": (tree) => { walkSourceTree: (tree) => {
const emitter = new EventEmitter(); const emitter = new EventEmitter();
process.nextTick(() => safeGetEntries(tree, (getEntriesErr, entries) => { process.nextTick(() => safeGetEntries(tree, (getEntriesErr, entries) => {
@ -56,8 +56,8 @@ const gitToFsCopier = new Copier({
} }
emitter.emit("tree", { emitter.emit("tree", {
"gitTree": subTree, gitTree: subTree,
"name": entry.name() name: entry.name(),
}); });
return callback(); return callback();
@ -81,7 +81,7 @@ const gitToFsCopier = new Copier({
})); }));
return emitter; return emitter;
} },
}); });
export const gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => { 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({ return gitToFsCopier.copy({
"gitTree": tree, gitTree: tree,
"name": "." name: ".",
}, exportDir, callback); }, exportDir, callback);
}); });

@ -1,7 +1,8 @@
"use strict"; "use strict";
import { Repository, Remote } from "nodegit";
import { mkdirsSync, removeSync } from "fs-extra"; import { mkdirsSync, removeSync } from "fs-extra";
import { Remote, Repository } from "nodegit";
import { gitToFs } from "./copy"; import { gitToFs } from "./copy";
const fixUrl = (url) => { const fixUrl = (url) => {
@ -27,8 +28,8 @@ export const gitLoader = (options, globalCallback) => {
const path = `${options.local}/${options.hash}`; const path = `${options.local}/${options.hash}`;
const exported = options.exported; const exported = options.exported;
removeSync(path); // eslint-disable-line no-sync removeSync(path);
mkdirsSync(path); // eslint-disable-line no-sync mkdirsSync(path);
console.log(`Cloning ${url} to ${path}`); console.log(`Cloning ${url} to ${path}`);

@ -1,46 +1,12 @@
"use strict"; "use strict";
import { join } from "path";
import { createReadStream, createWriteStream, exists } from "fs"; import { createReadStream, createWriteStream, exists } from "fs";
import { createGzip, createGunzip } from "zlib";
import * as glob from "glob"; import * as glob from "glob";
import * as JSONParse from "json-parse-safe";
import { join } from "path";
import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers"; import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers";
import * as _ from "underscore"; import * as _ from "underscore";
import * as JSONParse from "json-parse-safe"; import { createGunzip, createGzip } from "zlib";
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 reportFilename = "report.json.gz";
const maxAttemptsNumber = 100; const maxAttemptsNumber = 100;
@ -50,8 +16,8 @@ const directoryCheckTimeout = 2000;
const attemptsDebugFrequency = 10; const attemptsDebugFrequency = 10;
const readableStreamBufferOptions = { const readableStreamBufferOptions = {
"chunkSize": 262144, chunkSize: 262144,
"frequency": 1 frequency: 1,
}; };
const getAllErrors = (report: Report): Message[] => (report.result && report.result.errors && report.result.errors.$allMessages) || []; 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) => { export const writeReport = (releaseDir, err, result: ReportResult, callback) => {
const data = JSON.stringify({ const data = JSON.stringify({
"date": Date.now(), date: Date.now(),
err, err,
result result,
}); });
const readable = new ReadableStreamBuffer(readableStreamBufferOptions); 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); const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
glob("**", { glob("**", {
"cwd": releaseDir, cwd: releaseDir,
"mark": true mark: true,
}, (err, files) => { }, (err, files) => {
if (err) { if (err) {
return callback(err, options); return callback(err, options);
@ -135,7 +101,7 @@ export const loadReport = (app, options, callback) => {
return callback(null, _.extend(options, { return callback(null, _.extend(options, {
files, files,
report report,
})); }));
}); });
}); });
@ -143,7 +109,7 @@ export const loadReport = (app, options, callback) => {
}; };
export const getStatusMessageFromRelease = (app, originalOptions, 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 releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev);
const reportFile = join(releaseDir, reportFilename); const reportFile = join(releaseDir, reportFilename);
@ -181,19 +147,17 @@ export const getStatusMessageFromRelease = (app, originalOptions, callback) => {
const infos = getAllInfos(report); const infos = getAllInfos(report);
if (errors.length + warns.length) { if (errors.length + warns.length) {
return callback(_.map( const formattedErrors = _.map(errors, (message) => `ERR: ${message.message}`);
errors, (message) => `ERR: ${message.message}` const formattedWarns = _.map(warns, (message) => `WARN: ${message.message}`);
).concat(_.map(
warns, (message) => `WARN: ${message.message}` return callback(formattedErrors.concat(formattedWarns).join("\r\n"));
))
.join("\r\n"));
} }
if (!report.result || report.err) { if (!report.result || report.err) {
return callback(`CRITICAL ERROR: ${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); }), reportReadTimeout);
}); });
}; };

@ -1,8 +1,9 @@
"use strict"; "use strict";
import { join } from "path";
import { exists, readFile } from "fs"; import { exists, readFile } from "fs";
import { join } from "path";
import * as _ from "underscore"; import * as _ from "underscore";
import { loadReport } from "./report-processor"; import { loadReport } from "./report-processor";
const addBranchInfo = (app, options, callback) => { const addBranchInfo = (app, options, callback) => {
@ -24,7 +25,7 @@ const addBranchInfo = (app, options, callback) => {
return callback(null, _.extend(options, { return callback(null, _.extend(options, {
branch, branch,
branchName branchName,
})); }));
}); });
}); });
@ -56,23 +57,23 @@ const parseOptions = (app, options, callback) => {
} }
const result = { const result = {
"owner": options.owner, owner: options.owner,
"reponame": options.reponame reponame: options.reponame,
}; };
if (options.rev) { 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)) { 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"; const branchName = options.branchName || "master";
return addRevInfo(app, _.extend(result, { return addRevInfo(app, _.extend(result, {
"branch": `refs/heads/${branchName}`, branch: `refs/heads/${branchName}`,
branchName branchName,
}), callback); }), callback);
}; };

@ -4,10 +4,10 @@ import * as _ from "underscore";
import tasks from "./tasks"; import tasks from "./tasks";
// TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here. // TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here.
const TaskProcessor = function (task, outerProcessor, callback) { const createTaskProcessor = (task, outerProcessor: TaskProcessor, callback) => {
const that = this; const result: TaskProcessor = {};
const createTaskWorker = () => tasks[task.type](task.params || {}, that); const createTaskWorker = () => tasks[task.type](task.params || {}, result);
const errors = []; const errors: string[] = [];
const process = () => createTaskWorker().process(); const process = () => createTaskWorker().process();
const getOuterPrefix = (prefix) => { const getOuterPrefix = (prefix) => {
if (task.name && 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 onWarn = (message, prefix) => outerProcessor.onWarn(message, getOuterPrefix(prefix));
const onInfo = (message, prefix) => outerProcessor.onInfo(message, getOuterPrefix(prefix)); const onInfo = (message, prefix) => outerProcessor.onInfo(message, getOuterPrefix(prefix));
const processTask = (innerTask, innerCallback) => { const processTask = (innerTask, innerCallback) => {
const innerProcessor = new TaskProcessor(innerTask, that, innerCallback); const innerProcessor = createTaskProcessor(innerTask, result, innerCallback);
innerProcessor.process(); innerProcessor.process();
}; };
const done = () => callback(errors.join("\r\n")); const done = () => callback(errors.join("\r\n"));
that.process = process; result.process = process;
that.onError = onError; result.onError = onError;
that.onWarn = onWarn; result.onWarn = onWarn;
that.onInfo = onInfo; result.onInfo = onInfo;
that.processTask = processTask; result.processTask = processTask;
that.done = done; result.done = done;
that.context = outerProcessor.context; result.context = outerProcessor.context;
return result;
}; };
const pushMessage = (list, message, parts, index) => { const pushMessage = (list, message, parts, index) => {
if (!index) { if (!index) {
list.$allMessages = list.$allMessages || []; // eslint-disable-line fp/no-mutation list.$allMessages = list.$allMessages || [];
list.$allMessages.push({ // eslint-disable-line fp/no-mutating-methods list.$allMessages.push({
message, 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) { 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); return pushMessage(list, message, parts, index + 1);
}; };
const addFlag = (flags) => (flagName) => { const addFlag = (flags) => (flagName) => {
flags[flagName] = true; // eslint-disable-line fp/no-mutation flags[flagName] = true;
}; };
const containsFlag = (flags) => (flagName) => flags[flagName]; const containsFlag = (flags) => (flagName) => flags[flagName];
@ -73,19 +75,19 @@ export const processTask = (task, context, callback) => {
pushMessage(messages, message, parts, 0); pushMessage(messages, message, parts, 0);
}; };
const flags = {}; const flags = {};
const processor = new TaskProcessor(task, { const processor = createTaskProcessor(task, {
"context": _.extend(context, { context: _.extend(context, {
"addFlag": addFlag(flags), addFlag: addFlag(flags),
"containsFlag": containsFlag(flags) containsFlag: containsFlag(flags),
}), }),
"onError": messageProcessor(errors), onError: messageProcessor(errors),
"onInfo": messageProcessor(infos), onInfo: messageProcessor(infos),
"onWarn": messageProcessor(warns) onWarn: messageProcessor(warns),
}, (err) => callback(err, { }, (err) => callback(err, {
errors, errors,
infos, infos,
messages, messages,
warns warns,
})); }));
processor.process(); processor.process();

@ -2,10 +2,10 @@
import * as glob from "glob"; import * as glob from "glob";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", { process: () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
"cwd": processor.context.exported, cwd: processor.context.exported,
"dot": true dot: true,
}, (err, files) => { }, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
@ -18,14 +18,14 @@ export default (params, processor) => ({
} }
return processor.processTask({ return processor.processTask({
"params": { params: {
"tasks": files.map((file) => ({ tasks: files.map((file) => ({
"name": file, name: file,
"params": { "filename": file }, params: { filename: file },
"type": "deletefromcode" type: "deletefromcode",
})) })),
}, },
"type": "parallel" type: "parallel",
}, processor.done.bind(processor)); }, processor.done.bind(processor));
}) }),
}); })) as Task;

@ -1,9 +1,9 @@
"use strict"; "use strict";
export default (params, processor) => { export default ((params, processor) => {
const condition = (!params.owner || params.owner === processor.context.owner) const condition = (!params.owner || params.owner === processor.context.owner)
&& (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch); && (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch);
const task = (condition && params.task) || params.otherwise; 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;

@ -1,10 +1,10 @@
"use strict"; "use strict";
import { join } from "path";
import { copy } from "fs-extra"; import { copy } from "fs-extra";
import { join } from "path";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const sourceFilePath = join(processor.context.exported, params.filename); const sourceFilePath = join(processor.context.exported, params.filename);
const targetFilePath = join(processor.context.release, params.filename); const targetFilePath = join(processor.context.release, params.filename);
@ -19,5 +19,5 @@ export default (params, processor) => ({
return processor.done(); return processor.done();
}); });
} },
}); })) as Task;

@ -2,10 +2,10 @@
import * as glob from "glob"; import * as glob from "glob";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => glob(params.mask, { process: () => glob(params.mask, {
"cwd": processor.context.exported, cwd: processor.context.exported,
"dot": true dot: true,
}, (err, files) => { }, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
@ -18,14 +18,14 @@ export default (params, processor) => ({
} }
return processor.processTask({ return processor.processTask({
"params": { params: {
"tasks": files.map((file) => ({ tasks: files.map((file) => ({
"name": file, name: file,
"params": { "filename": file }, params: { filename: file },
"type": "copy" type: "copy",
})) })),
}, },
"type": "parallel" type: "parallel",
}, processor.done.bind(processor)); }, processor.done.bind(processor));
}) }),
}); })) as Task;

@ -1,11 +1,11 @@
"use strict"; "use strict";
import { process as cssnanoProcess } from "cssnano";
import { readFile, writeFile } from "fs"; import { readFile, writeFile } from "fs";
import { join } from "path"; import { join } from "path";
import { process as cssnanoProcess } from "cssnano";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const filePath = join(processor.context.exported, params.filename); const filePath = join(processor.context.exported, params.filename);
readFile(filePath, (readErr, css) => { readFile(filePath, (readErr, css) => {
@ -32,6 +32,5 @@ export default (params, processor) => ({
}); });
}); });
}); });
} },
}); })) as Task;

@ -3,8 +3,8 @@
import * as glob from "glob"; import * as glob from "glob";
const flagDoneName = "cssnanoallDone"; const flagDoneName = "cssnanoallDone";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json"); 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); processor.context.addFlag(flagDoneName);
glob("**/*.css", { glob("**/*.css", {
"cwd": processor.context.exported, cwd: processor.context.exported,
"dot": true dot: true,
}, (err, files) => { }, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
@ -22,15 +22,15 @@ export default (params, processor) => ({
} }
return processor.processTask({ return processor.processTask({
"params": { params: {
"tasks": files.map((file) => ({ tasks: files.map((file) => ({
"name": file, name: file,
"params": { "filename": file }, params: { filename: file },
"type": "cssnano" type: "cssnano",
})) })),
}, },
"type": (params.preventParallelTests && "sequential") || "parallel" type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor)); }, processor.done.bind(processor));
}); });
} },
}); })) as Task;

@ -1,10 +1,10 @@
"use strict"; "use strict";
import { join } from "path";
import { remove } from "fs-extra"; import { remove } from "fs-extra";
import { join } from "path";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const sourceFilePath = join(processor.context.exported, params.filename); const sourceFilePath = join(processor.context.exported, params.filename);
processor.onInfo(`Deleting ${sourceFilePath}`); processor.onInfo(`Deleting ${sourceFilePath}`);
@ -18,5 +18,5 @@ export default (params, processor) => ({
return processor.done(); return processor.done();
}); });
} },
}); })) as Task;

@ -2,16 +2,16 @@
import sequential from "./sequential"; import sequential from "./sequential";
export default (params, processor) => sequential({ export default ((params, processor) => sequential({
"tasks": [ tasks: [
{ {
"name": "build", name: "build",
params, params,
"type": "dotnetbuildwithoutcleanup" type: "dotnetbuildwithoutcleanup",
}, },
{ {
"name": "cleanup", name: "cleanup",
"type": "cleanupafterdotnetbuild" type: "cleanupafterdotnetbuild",
} },
] ],
}, processor); }, processor)) as Task;

@ -2,21 +2,21 @@
import sequential from "./sequential"; import sequential from "./sequential";
export default (params, processor) => sequential({ export default ((params, processor) => sequential({
"tasks": [ tasks: [
{ {
"name": "build", name: "build",
params, params,
"type": "dotnetbuildwithoutcleanup" type: "dotnetbuildwithoutcleanup",
}, },
{ {
"name": "test", name: "test",
params, params,
"type": "dotnetnunitall" type: "dotnetnunitall",
}, },
{ {
"name": "cleanup", name: "cleanup",
"type": "cleanupafterdotnetbuild" type: "cleanupafterdotnetbuild",
} },
] ],
}, processor); }, processor)) as Task;

@ -1,8 +1,9 @@
"use strict"; "use strict";
import { spawn } from "child_process"; import { spawn } from "child_process";
import { WritableStreamBuffer } from "stream-buffers";
import * as JSONParse from "json-parse-safe"; import * as JSONParse from "json-parse-safe";
import { WritableStreamBuffer } from "stream-buffers";
import settings from "../../settings"; import settings from "../../settings";
const wrapBuilder = (builder, input, onExit) => { const wrapBuilder = (builder, input, onExit) => {
@ -27,8 +28,8 @@ const wrapBuilder = (builder, input, onExit) => {
builder.stdin.end(); builder.stdin.end();
}; };
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const input = JSON.stringify(params); const input = JSON.stringify(params);
const builder = spawn(settings.builderExecutable, [params.command]); const builder = spawn(settings.builderExecutable, [params.command]);
@ -71,5 +72,5 @@ export default (params, processor) => ({
return processor.done(); return processor.done();
}); });
} },
}); })) as Task;

@ -6,37 +6,37 @@ const createTasks = function *(params) {
if (!params.skipMbsCheckStyle) { if (!params.skipMbsCheckStyle) {
yield { yield {
params, params,
"type": "dotnetcheckstyle" type: "dotnetcheckstyle",
}; };
} }
yield { yield {
params, params,
"type": "dotnetrewrite" type: "dotnetrewrite",
}; };
if (!params.skipNugetRestore) { if (!params.skipNugetRestore) {
yield { yield {
params, params,
"type": "dotnetnugetrestore" type: "dotnetnugetrestore",
}; };
} }
yield { yield {
"params": { params: {
"configuration": params.configuration, configuration: params.configuration,
"forceCodeAnalysis": params.forceCodeAnalysis, forceCodeAnalysis: params.forceCodeAnalysis,
"ignoreCodeAnalysis": params.ignoreCodeAnalysis, ignoreCodeAnalysis: params.ignoreCodeAnalysis,
"skipCodeSigning": params.skipCodeSigning, skipCodeSigning: params.skipCodeSigning,
"solution": params.solution, solution: params.solution,
"target": "Rebuild" target: "Rebuild",
}, },
"type": "dotnetcompile" type: "dotnetcompile",
}; };
}; };
export default (params, processor) => { export default ((params, processor) => {
const tasks = Array.from(createTasks(params)); const tasks = Array.from(createTasks(params));
return sequential({ tasks }, processor); return sequential({ tasks }, processor);
}; }) as Task;

@ -1,9 +1,9 @@
"use strict"; "use strict";
import { join } from "path";
import { readFile } from "fs";
import { parallel } from "async"; import { parallel } from "async";
import { readFile } from "fs";
import * as glob from "glob"; import * as glob from "glob";
import { join } from "path";
const autoGeneratedMarker const autoGeneratedMarker
= "//------------------------------------------------------------------------------\n" = "//------------------------------------------------------------------------------\n"
@ -11,15 +11,15 @@ const autoGeneratedMarker
const flagDoneName = "dotnetcheckerDone"; const flagDoneName = "dotnetcheckerDone";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
return processor.done(); return processor.done();
} }
processor.context.addFlag(flagDoneName); processor.context.addFlag(flagDoneName);
return glob("**/*.cs", { "cwd": processor.context.exported }, (globErr, files) => { return glob("**/*.cs", { cwd: processor.context.exported }, (globErr, files) => {
if (globErr) { if (globErr) {
processor.onError(globErr); processor.onError(globErr);
@ -58,7 +58,7 @@ export default (params, processor) => ({
return parallel(files.map((file) => (callback) => readFile( return parallel(files.map((file) => (callback) => readFile(
join(processor.context.exported, file), join(processor.context.exported, file),
{ "encoding": "utf8" }, { encoding: "utf8" },
(readErr, data) => { (readErr, data) => {
if (readErr) { if (readErr) {
processor.onError(`Unable to check file ${file}: ${readErr}`); processor.onError(`Unable to check file ${file}: ${readErr}`);
@ -69,8 +69,8 @@ export default (params, processor) => ({
processFile(data, file); processFile(data, file);
return callback(); return callback();
} },
)), processor.done.bind(processor)); )), processor.done.bind(processor));
}); });
} },
}); })) as Task;

@ -5,7 +5,7 @@ import * as _ from "underscore";
import settings from "../../settings"; import settings from "../../settings";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
export default (params, processor) => { export default ((params, processor) => {
if (settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) { if (settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) {
processor.onError("Code analysis is not supported"); processor.onError("Code analysis is not supported");
@ -17,7 +17,7 @@ export default (params, processor) => {
return {}; return {};
} }
return { "SigningKey": settings.codeSigningKeyFile }; return { SigningKey: settings.codeSigningKeyFile };
}; };
const skipCodeAnalysis = settings.isCodeAnalysisUnsupported const skipCodeAnalysis = settings.isCodeAnalysisUnsupported
@ -25,13 +25,13 @@ export default (params, processor) => {
|| (settings.ignoreCodeAnalysisByDefault && !params.forceCodeAnalysis); || (settings.ignoreCodeAnalysisByDefault && !params.forceCodeAnalysis);
const compileParams = { const compileParams = {
"Configuration": params.configuration, Configuration: params.configuration,
"OutputDirectory": params.overrideOutputDirectory, OutputDirectory: params.overrideOutputDirectory,
"SkipCodeAnalysis": skipCodeAnalysis, SkipCodeAnalysis: skipCodeAnalysis,
"SolutionPath": join(processor.context.exported, params.solution), SolutionPath: join(processor.context.exported, params.solution),
"Target": params.target, Target: params.target,
"command": "compile" command: "compile",
}; };
return dotnetbuilderwrapper(_.extend(compileParams, getAdditionalSigningParameters()), processor); return dotnetbuilderwrapper(_.extend(compileParams, getAdditionalSigningParameters()), processor);
}; }) as Task;

@ -3,9 +3,9 @@
import * as _ from "underscore"; import * as _ from "underscore";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
"getFinalTask": (nupkg) => ({ getFinalTask: (nupkg) => ({
"params": { "filename": nupkg }, params: { filename: nupkg },
"type": "copy" type: "copy",
}) }),
}), processor); }), processor)) as Task;

@ -2,29 +2,29 @@
import conditional from "./conditional"; import conditional from "./conditional";
export default (params, processor) => conditional({ export default ((params, processor) => conditional({
"branch": "master", branch: "master",
"otherwise": { otherwise: {
"name": "nuget-pack", name: "nuget-pack",
"params": { params: {
"major": params.major, major: params.major,
"name": params.nuspecName, name: params.nuspecName,
"nuspec": `${params.nuspecName}.nuspec`, nuspec: `${params.nuspecName}.nuspec`,
"version": params.version, version: params.version,
"withoutCommitSha": params.withoutCommitSha withoutCommitSha: params.withoutCommitSha,
}, },
"type": "dotnetnugetpack" type: "dotnetnugetpack",
}, },
"owner": params.masterRepoOwner, owner: params.masterRepoOwner,
"task": { task: {
"name": "nuget-push", name: "nuget-push",
"params": { params: {
"major": params.major, major: params.major,
"name": params.nuspecName, name: params.nuspecName,
"nuspec": `${params.nuspecName}.nuspec`, nuspec: `${params.nuspecName}.nuspec`,
"version": params.version, version: params.version,
"withoutCommitSha": params.withoutCommitSha withoutCommitSha: params.withoutCommitSha,
}, },
"type": "dotnetnugetpush" type: "dotnetnugetpush",
} },
}, processor); }, processor)) as Task;

@ -15,7 +15,7 @@ const addPostfix = (version, params, processor) => {
return `${version}-r${processor.context.rev.substr(0, postfixLength)}`; return `${version}-r${processor.context.rev.substr(0, postfixLength)}`;
}; };
export default (params, processor) => { export default ((params, processor) => {
const date = new Date(); const date = new Date();
const major = params.major || "0"; const major = params.major || "0";
const minor = (date.getFullYear() * fourDigits) + ((date.getMonth() + 1) * twoDigits) + date.getDate(); 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`; const nupkg = `${params.name}.${version}.nupkg`;
return sequential({ return sequential({
"tasks": [ tasks: [
{ {
"params": { params: {
"BaseDirectory": processor.context.exported, BaseDirectory: processor.context.exported,
"OutputDirectory": processor.context.exported, OutputDirectory: processor.context.exported,
"SpecPath": join(processor.context.exported, params.nuspec), SpecPath: join(processor.context.exported, params.nuspec),
"Version": version, Version: version,
"command": "nugetpack" command: "nugetpack",
}, },
"type": "dotnetbuilderwrapper" type: "dotnetbuilderwrapper",
}, },
params.getFinalTask(nupkg) params.getFinalTask(nupkg),
] ],
}, processor); }, processor);
}; }) as Task;

@ -3,9 +3,9 @@
import * as _ from "underscore"; import * as _ from "underscore";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, {
"getFinalTask": (nupkg) => ({ getFinalTask: (nupkg) => ({
"params": { "Package": nupkg }, params: { Package: nupkg },
"type": "dotnetnugetpushonly" type: "dotnetnugetpushonly",
}) }),
}), processor); }), processor)) as Task;

@ -1,12 +1,13 @@
"use strict"; "use strict";
import { join } from "path"; import { join } from "path";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
import settings from "../../settings"; import settings from "../../settings";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
export default (params, processor) => dotnetbuilderwrapper({ export default ((params, processor) => dotnetbuilderwrapper({
"ApiKey": settings.nugetApiKey, ApiKey: settings.nugetApiKey,
"NugetHost": settings.nugetHost, NugetHost: settings.nugetHost,
"Package": join(processor.context.exported, params.Package), Package: join(processor.context.exported, params.Package),
"command": "nugetpush" command: "nugetpush",
}, processor); }, processor)) as Task;

@ -3,15 +3,15 @@
import { join } from "path"; import { join } from "path";
import sequential from "./sequential"; import sequential from "./sequential";
export default (params, processor) => sequential({ export default ((params, processor) => sequential({
"tasks": [ tasks: [
{ {
"params": { params: {
"BaseDirectory": processor.context.exported, BaseDirectory: processor.context.exported,
"SolutionPath": join(processor.context.exported, params.solution), SolutionPath: join(processor.context.exported, params.solution),
"command": "nugetrestore" command: "nugetrestore",
}, },
"type": "dotnetbuilderwrapper" type: "dotnetbuilderwrapper",
} },
] ],
}, processor); }, processor)) as Task;

@ -3,7 +3,7 @@
import { join } from "path"; import { join } from "path";
import dotNetBuilderWrapper from "./dotnetbuilderwrapper"; import dotNetBuilderWrapper from "./dotnetbuilderwrapper";
export default (params, processor) => dotNetBuilderWrapper({ export default ((params, processor) => dotNetBuilderWrapper({
"TestLibraryPath": join(processor.context.exported, params.assembly), TestLibraryPath: join(processor.context.exported, params.assembly),
"command": "nunit" command: "nunit",
}, processor); }, processor)) as Task;

@ -3,8 +3,8 @@
import * as glob from "glob"; import * as glob from "glob";
const flagDoneName = "dotnetnunitallDone"; const flagDoneName = "dotnetnunitallDone";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); 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); processor.context.addFlag(flagDoneName);
glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", { glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", {
"cwd": processor.context.exported, cwd: processor.context.exported,
"dot": true dot: true,
}, (err, files) => { }, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
@ -28,15 +28,15 @@ export default (params, processor) => ({
} }
return processor.processTask({ return processor.processTask({
"params": { params: {
"tasks": files.map((file) => ({ tasks: files.map((file) => ({
"name": file, name: file,
"params": { "assembly": file }, params: { assembly: file },
"type": "dotnetnunit" type: "dotnetnunit",
})) })),
}, },
"type": (params.preventParallelTests && "sequential") || "parallel" type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor)); }, processor.done.bind(processor));
}); });
} },
}); })) as Task;

@ -1,50 +1,47 @@
"use strict"; "use strict";
import { join } from "path";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import { render } from "mustache"; import { render } from "mustache";
import { join } from "path";
import sequential from "./sequential"; import sequential from "./sequential";
// eslint-disable-next-line no-sync const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { encoding: "utf8" });
const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { "encoding": "utf8" }); 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 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" });
export default (params, processor) => sequential({ export default ((params, processor) => sequential({
"tasks": [ tasks: [
{ {
"params": { params: {
"data": render(msbuildTemplate, params), data: render(msbuildTemplate, params),
"filename": "MakePackage.msbuild" filename: "MakePackage.msbuild",
}, },
"type": "writefile" type: "writefile",
}, },
{ {
"params": { params: {
"data": render(deployTemplate, params), data: render(deployTemplate, params),
"filename": "Deploy.bat" filename: "Deploy.bat",
}, },
"type": "writefile" type: "writefile",
}, },
{ {
"params": { params: {
"data": render(versionTemplate, params), data: render(versionTemplate, params),
"filename": "version.aspx" filename: "version.aspx",
}, },
"type": "writefile" type: "writefile",
}, },
{ {
"params": { params: {
"configuration": params.configuration, configuration: params.configuration,
"isCodeAnalysisUnsupported": params.isCodeAnalysisUnsupported, isCodeAnalysisUnsupported: params.isCodeAnalysisUnsupported,
"overrideOutputDirectory": processor.context.release, overrideOutputDirectory: processor.context.release,
"skipCodeSigning": params.skipCodeSigning, skipCodeSigning: params.skipCodeSigning,
"solution": "MakePackage.msbuild", solution: "MakePackage.msbuild",
"target": "Package" target: "Package",
}, },
"type": "dotnetcompile" type: "dotnetcompile",
} },
] ],
}, processor); }, processor)) as Task;

@ -1,9 +1,9 @@
"use strict"; "use strict";
import { join } from "path";
import { readFile, writeFile } from "fs";
import { parallel, waterfall } from "async"; import { parallel, waterfall } from "async";
import { readFile, writeFile } from "fs";
import * as glob from "glob"; import * as glob from "glob";
import { join } from "path";
import settings from "../../settings"; import settings from "../../settings";
const flagDoneName = "dotnetrewriterDone"; const flagDoneName = "dotnetrewriterDone";
@ -14,10 +14,10 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => (
return content; return content;
} }
return content.replace( const pattern = /InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g;
/InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g, const replacer = (match, p1) => `InternalsVisibleTo("${p1},PublicKey=${settings.codeSigningPublicKey}")`;
(match, p1) => `InternalsVisibleTo("${p1},PublicKey=${settings.codeSigningPublicKey}")`
); return content.replace(pattern, replacer);
}; };
const processInformationalVersion = (content) => { const processInformationalVersion = (content) => {
@ -31,15 +31,15 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => (
return cb(null, processInformationalVersion(processInternalsVisible(originalContent))); return cb(null, processInformationalVersion(processInternalsVisible(originalContent)));
}; };
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
return processor.done(); return processor.done();
} }
processor.context.addFlag(flagDoneName); 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) { if (globErr) {
processor.onError(globErr); processor.onError(globErr);
@ -55,9 +55,9 @@ export default (params, processor) => ({
} }
return parallel(files.map((file) => (callback) => waterfall([ 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")), 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) => { ], (err) => {
if (err) { if (err) {
processor.onError(`Unable to rewrite file ${file}: ${err}`); processor.onError(`Unable to rewrite file ${file}: ${err}`);
@ -67,5 +67,5 @@ export default (params, processor) => ({
callback(err); callback(err);
})), processor.done.bind(processor)); })), processor.done.bind(processor));
}); });
} },
}); })) as Task;

@ -1,7 +1,7 @@
"use strict"; "use strict";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
if (params.error) { if (params.error) {
processor.onError(params.error); processor.onError(params.error);
} }
@ -15,5 +15,5 @@ export default (params, processor) => ({
} }
processor.done(); processor.done();
} },
}); })) as Task;

@ -1,14 +1,15 @@
"use strict"; "use strict";
import { join } from "path";
import { CLIEngine } from "eslint"; import { CLIEngine } from "eslint";
import { join } from "path";
import settings from "../../settings"; import settings from "../../settings";
const cli = new CLIEngine({ "configFile": settings.eslintBrowserConfig });
const cli = new CLIEngine({ configFile: settings.eslintBrowserConfig });
const errorSeverity = 2; const errorSeverity = 2;
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const filePath = join(processor.context.exported, params.filename); const filePath = join(processor.context.exported, params.filename);
const result = cli.executeOnFiles([filePath]); const result = cli.executeOnFiles([filePath]);
@ -27,6 +28,5 @@ export default (params, processor) => ({
}); });
processor.done(); processor.done();
} },
}); })) as Task;

@ -3,8 +3,8 @@
import * as glob from "glob"; import * as glob from "glob";
const flagDoneName = "eslintbrowserallDone"; const flagDoneName = "eslintbrowserallDone";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json"); 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 || []; const excludeFiles = params.excludeFiles || [];
glob("**/*.js", { glob("**/*.js", {
"cwd": processor.context.exported, cwd: processor.context.exported,
"dot": true dot: true,
}, (err, files) => { }, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
@ -24,15 +24,15 @@ export default (params, processor) => ({
} }
return processor.processTask({ return processor.processTask({
"params": { params: {
"tasks": files.filter((file) => !excludeFiles.includes(file)).map((file) => ({ tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({
"name": file, name: file,
"params": { "filename": file }, params: { filename: file },
"type": "eslintbrowser" type: "eslintbrowser",
})) })),
}, },
"type": (params.preventParallelTests && "sequential") || "parallel" type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor)); }, processor.done.bind(processor));
}); });
} },
}); })) as Task;

@ -1,15 +1,14 @@
"use strict"; "use strict";
let tasks = {}; import { readdirSync } from "fs";
const tasks: Tasks = {};
// Code taken from http://stackoverflow.com/a/17204293 // Code taken from http://stackoverflow.com/a/17204293
// eslint-disable-next-line no-sync readdirSync(__dirname)
require("fs").readdirSync(__dirname)
.forEach((file) => { .forEach((file) => {
if (file.match(/\.ts$/) !== null && file !== "index.ts") { if (file.match(/\.ts$/) !== null && file !== "index.ts") {
const name = file.replace(".ts", ""); const name = file.replace(".ts", "");
// eslint-disable-next-line global-require
tasks[name] = require(`./${file}`).default; tasks[name] = require(`./${file}`).default;
} }
}); });

@ -1,3 +1,3 @@
"use strict"; "use strict";
export default (params, processor) => ({ "process": () => processor.done() }); export default ((params, processor) => ({ process: () => processor.done() })) as Task;

@ -2,27 +2,27 @@
import sequential from "./sequential"; import sequential from "./sequential";
export default (params, processor) => sequential({ export default ((params, processor) => sequential({
"tasks": [ tasks: [
{ {
"params": { "excludeFiles": params.eslintExcludeFiles }, params: { excludeFiles: params.eslintExcludeFiles },
"type": "eslintbrowserall" type: "eslintbrowserall",
}, },
{ "type": "uglifyjsall" }, { type: "uglifyjsall" },
{ "type": "cssnanoall" }, { type: "cssnanoall" },
{ {
"params": { params: {
"data": processor.context.versionInfo, data: processor.context.versionInfo,
"filename": "version.txt" filename: "version.txt",
}, },
"type": "writefile" type: "writefile",
}, },
{ {
"params": { params: {
"archive": `${processor.context.reponame}.zip`, archive: `${processor.context.reponame}.zip`,
"directory": "" directory: "",
}, },
"type": "zip" type: "zip",
} },
] ],
}, processor); }, processor)) as Task;

@ -4,4 +4,4 @@ import { parallel } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback); 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;

@ -4,4 +4,4 @@ import { series } from "async";
const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback); 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;

@ -4,8 +4,8 @@ import { writeFile } from "fs";
import { join, normalize } from "path"; import { join, normalize } from "path";
import { minify } from "uglify-js"; import { minify } from "uglify-js";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const filePath = normalize(join(processor.context.exported, params.filename)); const filePath = normalize(join(processor.context.exported, params.filename));
const result = minify(filePath); const result = minify(filePath);
@ -18,6 +18,5 @@ export default (params, processor) => ({
processor.done(); processor.done();
}); });
} },
}); })) as Task;

@ -4,8 +4,8 @@ import * as glob from "glob";
const doneFlagName = "uglifyjsallDone"; const doneFlagName = "uglifyjsallDone";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
if (processor.context.containsFlag(doneFlagName)) { if (processor.context.containsFlag(doneFlagName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); 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); processor.context.addFlag(doneFlagName);
glob("**/*.js", { glob("**/*.js", {
"cwd": processor.context.exported, cwd: processor.context.exported,
"dot": true dot: true,
}, (err, files) => { }, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
@ -23,15 +23,15 @@ export default (params, processor) => ({
} }
return processor.processTask({ return processor.processTask({
"params": { params: {
"tasks": files.map((file) => ({ tasks: files.map((file) => ({
"name": file, name: file,
"params": { "filename": file }, params: { filename: file },
"type": "uglifyjs" type: "uglifyjs",
})) })),
}, },
"type": (params.preventParallelTests && "sequential") || "parallel" type: (params.preventParallelTests && "sequential") || "parallel",
}, processor.done.bind(processor)); }, processor.done.bind(processor));
}); });
} },
}); })) as Task;

@ -3,8 +3,8 @@
import { writeFile } from "fs"; import { writeFile } from "fs";
import { join } from "path"; import { join } from "path";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const filePath = join(processor.context.exported, params.filename); const filePath = join(processor.context.exported, params.filename);
processor.onInfo(`Writing to ${filePath}`); processor.onInfo(`Writing to ${filePath}`);
@ -18,5 +18,5 @@ export default (params, processor) => ({
return processor.done(); return processor.done();
}); });
} },
}); })) as Task;

@ -1,11 +1,11 @@
"use strict"; "use strict";
import { create as createArchiver } from "archiver";
import { createWriteStream } from "fs"; import { createWriteStream } from "fs";
import { join, normalize } from "path"; import { join, normalize } from "path";
import { create as createArchiver } from "archiver";
export default (params, processor) => ({ export default ((params, processor) => ({
"process": () => { process: () => {
const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || ""))); const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || "")));
const targetArchivePath = normalize(join(processor.context.release, params.archive)); const targetArchivePath = normalize(join(processor.context.release, params.archive));
@ -20,5 +20,5 @@ export default (params, processor) => ({
archive.pipe(output); archive.pipe(output);
archive.directory(sourceDirectoryPath, false); archive.directory(sourceDirectoryPath, false);
archive.finalize(); archive.finalize();
} },
}); })) as Task;

@ -4,9 +4,9 @@
"private": true, "private": true,
"scripts": { "scripts": {
"start": "forever -c node app.js", "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", "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": { "dependencies": {
"archiver": "^1.3.0", "archiver": "^1.3.0",
@ -52,6 +52,7 @@
"@types/uglify-js": "^2.6.28", "@types/uglify-js": "^2.6.28",
"@types/underscore": "^1.7.36", "@types/underscore": "^1.7.36",
"tslint": "^4.4.2", "tslint": "^4.4.2",
"tslint-eslint-rules": "^3.4.0",
"typescript": "^2.2.1" "typescript": "^2.2.1"
} }
} }

@ -2,12 +2,12 @@
export default (req, res) => { export default (req, res) => {
const options = { const options = {
"branch": `/refs/heads/${req.params.branch}`, branch: `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch, branchName: req.params.branch,
"file": req.params[0], file: req.params[0],
"owner": req.params.owner, owner: req.params.owner,
"reponame": req.params.reponame, reponame: req.params.reponame,
"rev": req.params.rev rev: req.params.rev,
}; };
const pathParts = [req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev, options.file]; const pathParts = [req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev, options.file];

@ -1,12 +1,11 @@
"use strict"; "use strict";
import postreceive from "./postreceive";
import * as manual from "./manual";
import * as status from "./status";
import artifact from "./artifact"; import artifact from "./artifact";
import * as manual from "./manual";
import postreceive from "./postreceive";
import release from "./release"; import release from "./release";
import * as status from "./status";
const index = (req, res) => res.render("index", { "title": `Express<br/>\r\n${req}` }); const index = (req, res) => res.render("index", { title: `Express<br/>\r\n${req}` });
export { index, postreceive, manual, status, artifact, release }; export { index, postreceive, manual, status, artifact, release };

@ -7,8 +7,8 @@ export const get = (req, res) => res.render("manual");
export const post = (req, res) => { export const post = (req, res) => {
const options = _.extend(req.body, { const options = _.extend(req.body, {
"app": req.app, app: req.app,
"url": `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}` url: `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`,
}); });
build(options, (err, result) => { build(options, (err, result) => {
@ -16,7 +16,7 @@ export const post = (req, res) => {
console.log(`Error: ${err}`); console.log(`Error: ${err}`);
res.render("manual-done", { res.render("manual-done", {
err, err,
result result,
}); });
}); });
}; };

@ -9,12 +9,12 @@ const getBranchDescription = (options) => `${options.owner}/${options.reponame}:
const processPush = (req, res, payload) => { const processPush = (req, res, payload) => {
const repository = payload.repository; const repository = payload.repository;
const options = { const options = {
"app": req.app, app: req.app,
"branch": payload.ref, branch: payload.ref,
"owner": repository.owner.name, owner: repository.owner.name,
"reponame": repository.name, reponame: repository.name,
"rev": payload.after, rev: payload.after,
"url": repository.url url: repository.url,
}; };
console.log(`Got push event for ${getBranchDescription(options)}`); console.log(`Got push event for ${getBranchDescription(options)}`);
@ -33,33 +33,33 @@ const processPullRequest = (req, res, payload) => {
const head = pullRequest.head; const head = pullRequest.head;
const headRepo = head.repo; const headRepo = head.repo;
const headRepoOptions = { const headRepoOptions = {
"branch": `refs/heads/${head.ref}`, branch: `refs/heads/${head.ref}`,
"branchname": head.ref, branchname: head.ref,
"owner": headRepo.owner.name || headRepo.owner.login, owner: headRepo.owner.name || headRepo.owner.login,
"reponame": headRepo.name, reponame: headRepo.name,
"rev": head.sha, rev: head.sha,
"url": headRepo.url url: headRepo.url,
}; };
const base = pullRequest.base; const base = pullRequest.base;
const baseRepo = base.repo; const baseRepo = base.repo;
const baseRepoOptions = { const baseRepoOptions = {
"branchname": base.ref, branchname: base.ref,
"owner": baseRepo.owner.name || baseRepo.owner.login, owner: baseRepo.owner.name || baseRepo.owner.login,
"reponame": baseRepo.name reponame: baseRepo.name,
}; };
const options = { const options = {
action, action,
"app": req.app, app: req.app,
baseRepoOptions, baseRepoOptions,
headRepoOptions, headRepoOptions,
pullRequestNumber pullRequestNumber,
}; };
const masterOptions = { const masterOptions = {
action, action,
"app": req.app, app: req.app,
baseRepoOptions, baseRepoOptions,
"headRepoOptions": baseRepoOptions, headRepoOptions: baseRepoOptions,
pullRequestNumber pullRequestNumber,
}; };
console.log(`Got pull request ${action} event, ` console.log(`Got pull request ${action} event, `
@ -79,16 +79,13 @@ const processPullRequest = (req, res, payload) => {
return res.send(""); return res.send("");
} }
return commentOnPullRequest( return commentOnPullRequest((action === "closed" && masterOptions) || options, (err, data) => {
(action === "closed" && masterOptions) || options, if (err) {
(err, data) => { console.log(`Unable to post comment: ${err}`);
if (err) {
console.log(`Unable to post comment: ${err}`);
}
res.send(err || data);
} }
);
res.send(err || data);
});
}; };
const getPayload = (body) => { const getPayload = (body) => {

@ -1,7 +1,7 @@
"use strict"; "use strict";
import { join } from "path";
import { create as createArchiver } from "archiver"; import { create as createArchiver } from "archiver";
import { join } from "path";
import { readReport } from "../lib/report-processor"; import { readReport } from "../lib/report-processor";
@ -25,11 +25,11 @@ const getDatePart = (report) => {
export default (req, res, next) => { export default (req, res, next) => {
const options = { const options = {
"branch": `/refs/heads/${req.params.branch}`, branch: `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch, branchName: req.params.branch,
"owner": req.params.owner, owner: req.params.owner,
"reponame": req.params.reponame, reponame: req.params.reponame,
"rev": req.params.rev rev: req.params.rev,
}; };
const releasePath = 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);

@ -1,7 +1,8 @@
"use strict"; "use strict";
import { parse } from "url";
import * as _ from "underscore"; import * as _ from "underscore";
import { parse } from "url";
import { getReport } from "../lib/status-processor"; import { getReport } from "../lib/status-processor";
const parseOptionsFromReferer = (path, callback) => { const parseOptionsFromReferer = (path, callback) => {
@ -19,7 +20,7 @@ const parseOptionsFromReferer = (path, callback) => {
branchName, branchName,
owner, owner,
reponame, reponame,
rev rev,
}); });
} }
@ -29,7 +30,7 @@ const parseOptionsFromReferer = (path, callback) => {
branchName, branchName,
owner, owner,
reponame, reponame,
rev rev,
}); });
}; };
@ -42,24 +43,24 @@ const createShowReport = (res) => (err, inputOptions) => {
export const image = (req, res) => { export const image = (req, res) => {
const getAdditionalOptions = (err, options) => { const getAdditionalOptions = (err, options) => {
if (err === "ReportFileNotFound") { if (err === "ReportFileNotFound") {
return { "status": "Building" }; return { status: "Building" };
} }
if (err) { if (err) {
return { return {
"message": err, message: err,
"status": "StatusError" status: "StatusError",
}; };
} }
if (options.report.result === "MBSNotFound") { if (options.report.result === "MBSNotFound") {
return { "status": "MBSNotUsed" }; return { status: "MBSNotUsed" };
} }
if (options.report.err) { if (options.report.err) {
return { return {
"message": options.report.err, message: options.report.err,
"status": "Error" status: "Error",
}; };
} }
@ -67,8 +68,8 @@ export const image = (req, res) => {
const [firstWarn] = options.report.result.warns.$allMessages; const [firstWarn] = options.report.result.warns.$allMessages;
return { return {
"message": firstWarn.message, message: firstWarn.message,
"status": "Warning" status: "Warning",
}; };
} }
@ -76,12 +77,12 @@ export const image = (req, res) => {
if (allInfos.length) { if (allInfos.length) {
return { return {
"message": allInfos[allInfos.length - 1].message, message: allInfos[allInfos.length - 1].message,
"status": "OK" status: "OK",
}; };
} }
return { "status": "OK" }; return { status: "OK" };
}; };
const handle = (err, options) => { const handle = (err, options) => {
@ -100,11 +101,11 @@ export const image = (req, res) => {
export const page = (req, res) => { export const page = (req, res) => {
const options = { const options = {
"branch": `/refs/heads/${req.params.branch}`, branch: `/refs/heads/${req.params.branch}`,
"branchName": req.params.branch, branchName: req.params.branch,
"owner": req.params.owner, owner: req.params.owner,
"reponame": req.params.reponame, reponame: req.params.reponame,
"rev": req.params.rev rev: req.params.rev,
}; };
getReport(req.app, options, createShowReport(res)); getReport(req.app, options, createShowReport(res));

@ -3,12 +3,14 @@
"module": "commonjs", "module": "commonjs",
"target": "es6", "target": "es6",
"sourceMap": false, "sourceMap": false,
"strictNullChecks": true,
"typeRoots": [ "typeRoots": [
"node_modules/@types" "node_modules/@types"
] ]
}, },
"include": [ "include": [
"app.ts", "app.ts",
"global.d.ts",
"settings.ts", "settings.ts",
"lib/**/*.ts", "lib/**/*.ts",
"routes/**/*.ts" "routes/**/*.ts"

@ -1,101 +1,10 @@
{ {
"jsRules": { "extends": [
"class-name": true, "tslint:latest",
"comment-format": [ "tslint-eslint-rules"
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": { "rules": {
"class-name": true, "no-console": false,
"comment-format": [ "max-line-length": false
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"
]
} }
} }
Loading…
Cancel
Save