ES6 arrow functions

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent 4f15a974a5
commit c569ab6132
  1. 8
      BuildServer/app.js
  2. 98
      BuildServer/lib/builder.js
  3. 188
      BuildServer/lib/commenter.js
  4. 62
      BuildServer/lib/git/copy.js
  5. 46
      BuildServer/lib/git/loader.js
  6. 4
      BuildServer/lib/mail-sender.js
  7. 36
      BuildServer/lib/status-processor.js
  8. 48
      BuildServer/lib/task-processor.js
  9. 54
      BuildServer/lib/tasks/cleanupafterdotnetbuild.js
  10. 6
      BuildServer/lib/tasks/conditional.js
  11. 32
      BuildServer/lib/tasks/copy.js
  12. 54
      BuildServer/lib/tasks/copyglob.js
  13. 2
      BuildServer/lib/tasks/deletefromcode.js
  14. 28
      BuildServer/lib/tasks/dotnetbuild.js
  15. 38
      BuildServer/lib/tasks/dotnetbuildandtest.js
  16. 80
      BuildServer/lib/tasks/dotnetbuilderwrapper.js
  17. 2
      BuildServer/lib/tasks/dotnetbuildwithoutcleanup.js
  18. 90
      BuildServer/lib/tasks/dotnetcheckstyle.js
  19. 2
      BuildServer/lib/tasks/dotnetcompile.js
  20. 2
      BuildServer/lib/tasks/dotnetnugetpack.js
  21. 52
      BuildServer/lib/tasks/dotnetnugetprocess.js
  22. 2
      BuildServer/lib/tasks/dotnetnugetpush.js
  23. 14
      BuildServer/lib/tasks/dotnetnugetpushonly.js
  24. 24
      BuildServer/lib/tasks/dotnetnugetrestore.js
  25. 12
      BuildServer/lib/tasks/dotnetnunit.js
  26. 70
      BuildServer/lib/tasks/dotnetnunitall.js
  27. 72
      BuildServer/lib/tasks/dotnetpackwebapp.js
  28. 116
      BuildServer/lib/tasks/dotnetrewrite.js
  29. 30
      BuildServer/lib/tasks/echo.js
  30. 10
      BuildServer/lib/tasks/noop.js
  31. 16
      BuildServer/lib/tasks/parallel.js
  32. 6
      BuildServer/lib/tasks/sequential.js
  33. 30
      BuildServer/lib/tasks/writefile.js
  34. 2
      BuildServer/routes/artifact.js
  35. 4
      BuildServer/routes/index.js
  36. 10
      BuildServer/routes/manual.js
  37. 10
      BuildServer/routes/postreceive.js
  38. 22
      BuildServer/routes/release.js
  39. 40
      BuildServer/routes/status.js

@ -34,9 +34,7 @@ if ('development' === app.get('env')) {
app.get('/', routes.index); app.get('/', routes.index);
app.post('/github/postreceive', routes.postreceive); app.post('/github/postreceive', routes.postreceive);
app.get('/github/postreceive', function (req, res) { app.get('/github/postreceive', (req, res) => res.send("Only automated POST requests are allowed for postreceive route"));
res.send("Only automated POST requests are allowed for postreceive route");
});
app.get('/manual', routes.manual.get); app.get('/manual', routes.manual.get);
app.post('/manual', routes.manual.post); app.post('/manual', routes.manual.post);
app.get('/status/:owner/:reponame/:branch/:rev?', routes.status.page); app.get('/status/:owner/:reponame/:branch/:rev?', routes.status.page);
@ -45,6 +43,4 @@ app.get('/status.svg', routes.status.image);
app.get('/release/:owner/:reponame/:branch/:rev', routes.release); app.get('/release/:owner/:reponame/:branch/:rev', routes.release);
app.get('/artifact/:owner/:reponame/:branch/:rev/*', routes.artifact); app.get('/artifact/:owner/:reponame/:branch/:rev/*', routes.artifact);
http.createServer(app).listen(app.get('port'), function(){ http.createServer(app).listen(app.get('port'), () => console.log('Express server listening on port ' + app.get('port')));
console.log('Express server listening on port ' + app.get('port'));
});

@ -11,7 +11,7 @@ const settings = require('../settings');
//const codePostfix = "/code"; //const codePostfix = "/code";
const codePostfix = ""; const codePostfix = "";
const notifyStatus = function (options, callback) { const notifyStatus = (options, callback) => {
const status = { const status = {
user: options.owner, user: options.owner,
repo: options.reponame, repo: options.reponame,
@ -20,7 +20,7 @@ const notifyStatus = function (options, callback) {
target_url: settings.siteRoot + "status/" + options.owner + "/" + options.reponame + "/" + options.hash, target_url: settings.siteRoot + "status/" + options.owner + "/" + options.reponame + "/" + options.hash,
description: ((options.description || "") + "").substr(0, 140) description: ((options.description || "") + "").substr(0, 140)
}; };
settings.createGithub(options.owner).statuses.create(status, function (err, result) { settings.createGithub(options.owner).statuses.create(status, (err, result) => {
if (err) { if (err) {
console.log("Error while creating status: " + err); console.log("Error while creating status: " + err);
console.log(status); console.log(status);
@ -30,7 +30,7 @@ const notifyStatus = function (options, callback) {
}); });
}; };
const build = function (options, callback) { const build = (options, callback) => {
const url = options.url; const url = options.url;
const owner = options.owner; const owner = options.owner;
const reponame = options.reponame; const reponame = options.reponame;
@ -41,20 +41,16 @@ const build = function (options, callback) {
const tmp = options.app.get('tmpcodepath') + "/" + rev.substr(0, 15); const tmp = options.app.get('tmpcodepath') + "/" + rev.substr(0, 15);
const exported = tmp + codePostfix; const exported = tmp + codePostfix;
const release = options.app.get('releasepath') + "/" + owner + "/" + reponame + "/" + branch + "/" + rev; const release = options.app.get('releasepath') + "/" + owner + "/" + reponame + "/" + branch + "/" + rev;
const statusQueue = async.queue(function (task, callback) { const statusQueue = async.queue((task, callback) => task(callback), 1);
task(callback); const actualGitLoader = skipGitLoader ? (options, callback) => process.nextTick(callback) : gitLoader;
}, 1);
const actualGitLoader = skipGitLoader ? function(options, callback) { process.nextTick(callback); } : gitLoader; statusQueue.push((callback) => notifyStatus({
state: "pending",
statusQueue.push(function (callback) { description: "Preparing to build...",
notifyStatus({ owner: owner,
state: "pending", reponame: reponame,
description: "Preparing to build...", hash: rev
owner: owner, }, callback));
reponame: reponame,
hash: rev
}, callback);
});
fse.mkdirsSync(release); fse.mkdirsSync(release);
@ -62,45 +58,39 @@ const build = function (options, callback) {
fse.mkdirsSync(options.app.get('releasepath') + "/" + owner + "/" + reponame + "/$revs"); fse.mkdirsSync(options.app.get('releasepath') + "/" + owner + "/" + reponame + "/$revs");
fs.writeFileSync(options.app.get('releasepath') + "/" + owner + "/" + reponame + "/$revs/" + rev + ".branch", branch); fs.writeFileSync(options.app.get('releasepath') + "/" + owner + "/" + reponame + "/$revs/" + rev + ".branch", branch);
const done = function (err, result) { const done = (err, result) => {
const errorMessage = result && result.errors ? ((result.errors.$allMessages || [])[0] || {}).message : err; const errorMessage = result && result.errors ? ((result.errors.$allMessages || [])[0] || {}).message : err;
const warnMessage = result && result.warns ? ((result.warns.$allMessages || [])[0] || {}).message : err; const warnMessage = result && result.warns ? ((result.warns.$allMessages || [])[0] || {}).message : err;
const infoMessage = result && result.infos ? ((result.infos.$allMessages || []).slice(-1)[0] || {}).message : err; const infoMessage = result && result.infos ? ((result.infos.$allMessages || []).slice(-1)[0] || {}).message : err;
fs.writeFile(release + "/report.json", JSON.stringify({date: Date.now(), err: err, result: result}), function (writeErr) { fs.writeFile(release + "/report.json", JSON.stringify({date: Date.now(), err: err, result: result}), (writeErr) => {
statusQueue.push(function (callback) { statusQueue.push((callback) => async.parallel([
async.parallel([ (callback) => notifyStatus({
function (callback) { state: err ? "error" : "success",
notifyStatus({ description: errorMessage || warnMessage || infoMessage || "Success",
state: err ? "error" : "success", owner: owner,
description: errorMessage || warnMessage || infoMessage || "Success", reponame: reponame,
owner: owner, hash: rev
reponame: reponame, }, callback),
hash: rev (callback) => mailSender.send({
}, callback); from: settings.smtp.sender,
}, to: settings.smtp.receiver,
function (callback) { subject: (err ? "Build failed for " : "Successfully built ") + owner + "/" + reponame + "/" + branch,
mailSender.send({ headers: {
from: settings.smtp.sender, 'X-Laziness-level': 1000
to: settings.smtp.receiver,
subject: (err ? "Build failed for " : "Successfully built ") + owner + "/" + reponame + "/" + branch,
headers: {
'X-Laziness-level': 1000
},
text: ("Build status URL: " + settings.siteRoot + "status/" + owner + "/" + reponame + "/" + rev + "\r\n\r\n") +
(err ? ("Error message: " + err + "\r\n\r\n") : "") +
((!result || !result.messages || !result.messages.$allMessages) ? JSON.stringify(result, null, 4) : result.messages.$allMessages.map(function (msg) { return msg.prefix + "\t" + msg.message; }).join("\r\n"))
}, callback);
}, },
function (callback) { text: ("Build status URL: " + settings.siteRoot + "status/" + owner + "/" + reponame + "/" + rev + "\r\n\r\n") +
if (err) { (err ? ("Error message: " + err + "\r\n\r\n") : "") +
return process.nextTick(callback); ((!result || !result.messages || !result.messages.$allMessages) ? JSON.stringify(result, null, 4) : result.messages.$allMessages.map(msg => msg.prefix + "\t" + msg.message).join("\r\n"))
} }, callback),
(callback) => {
return fse.remove(tmp, callback); if (err) {
return process.nextTick(callback);
} }
], callback);
}); return fse.remove(tmp, callback);
}
], callback));
if (writeErr) { if (writeErr) {
return callback(writeErr); return callback(writeErr);
@ -115,17 +105,17 @@ const build = function (options, callback) {
branch: branch, branch: branch,
hash: rev, hash: rev,
exported: tmp + codePostfix exported: tmp + codePostfix
}, function(err) { }, (err) => {
if (err) { if (err) {
console.log(err); console.log(err);
return done("Git fetch error: " + err); return done("Git fetch error: " + err);
} }
console.log("Done loading from git"); console.log("Done loading from git");
fs.exists(exported + "/mbs.json", function (exists) { fs.exists(exported + "/mbs.json", (exists) => {
if (!exists) { if (!exists) {
return done(null, "MBSNotFound"); return done(null, "MBSNotFound");
} }
fs.readFile(exported + "/mbs.json", function (err, data) { fs.readFile(exported + "/mbs.json", (err, data) => {
if (err) { if (err) {
return done(err, "MBSUnableToRead"); return done(err, "MBSUnableToRead");
} }
@ -146,7 +136,7 @@ const build = function (options, callback) {
tmp: tmp, tmp: tmp,
exported: exported, exported: exported,
release: release release: release
}, function (err, result) { }, (err, result) => {
if (err) { if (err) {
return done(err, result); return done(err, result);
} }

@ -1,74 +1,66 @@
"use strict"; "use strict";
const fs = require('fs'); const fs = require("fs");
const _ = require('underscore'); const _ = require("underscore");
const settings = require('../settings'); const settings = require("../settings");
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+)*$/;
const masterNamePattern = /^master$/; const masterNamePattern = /^master$/;
const writeComment = function (options, message, callback) { const writeComment = (options, message, callback) => options.github.issues.createComment({
return options.github.issues.createComment({ user: options.baseRepoOptions.owner,
user: options.baseRepoOptions.owner, repo: options.baseRepoOptions.reponame,
repo: options.baseRepoOptions.reponame, number: options.number,
number: options.number, body: message
body: message }, callback);
}, callback);
};
const closePullRequest = function (options, message, callback) { const closePullRequest = (options, message, callback) => writeComment(options, message, (err) => {
return writeComment(options, message, function (err) { if (err) {
if (err) { return callback(err);
return callback(err); }
}
return options.github.issues.edit({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: options.number,
state: "closed"
}, callback);
});
};
const checkHasIssue = function (options, issueNumber, callback) { return options.github.issues.edit({
return options.github.issues.getRepoIssue({
user: options.baseRepoOptions.owner, user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame, repo: options.baseRepoOptions.reponame,
number: issueNumber number: options.number,
}, function (err, result) { state: "closed"
if (err && err.code !== 404) { }, callback);
return callback(err); });
}
const checkHasIssue = (options, issueNumber, callback) => options.github.issues.getRepoIssue({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: issueNumber
}, (err, result) => {
if (err && err.code !== 404) {
return callback(err);
}
if (err || result.number.toString() !== issueNumber) { if (err || result.number.toString() !== issueNumber) {
return callback(undefined, false); return callback(undefined, false);
} }
if (result.pull_request && result.pull_request.url) { if (result.pull_request && result.pull_request.url) {
return callback(undefined, false); return callback(undefined, false);
} }
return callback(undefined, true, result.title); return callback(undefined, true, result.title);
}); });
};
const checkHasReleases = function (options, callback) { const checkHasReleases = (options, callback) => options.github.releases.listReleases({
return options.github.releases.listReleases({ owner: options.baseRepoOptions.owner,
owner: options.baseRepoOptions.owner, repo: options.baseRepoOptions.reponame,
repo: options.baseRepoOptions.reponame, per_page: 1
per_page: 1 }, (err, result) => {
}, function (err, result) { if (err) {
if (err) { return callback(err);
return callback(err); }
}
return callback(undefined, result && result.length); return callback(undefined, result && result.length);
}); });
};
const checkPullRequest = function (options, callback) { const checkPullRequest = (options, callback) => {
const head = options.headRepoOptions; const head = options.headRepoOptions;
const base = options.baseRepoOptions; const base = options.baseRepoOptions;
@ -81,7 +73,7 @@ const checkPullRequest = function (options, callback) {
return closePullRequest(options, "Only merging from version to master is allowed", callback); return closePullRequest(options, "Only merging from version to master is allowed", callback);
} }
return checkHasReleases(options, function (err, hasReleases) { return checkHasReleases(options, (err, hasReleases) => {
if (err) { if (err) {
return writeComment(options, "Unable to check for releases", callback); return writeComment(options, "Unable to check for releases", callback);
} }
@ -107,7 +99,7 @@ const checkPullRequest = function (options, callback) {
} }
const issueNumber = featureNamePattern.exec(head.branchname)[1]; const issueNumber = featureNamePattern.exec(head.branchname)[1];
return checkHasIssue(options, issueNumber, function (err, hasIssue, issueTitle) { return checkHasIssue(options, issueNumber, (err, hasIssue, issueTitle) => {
if (err) { if (err) {
return writeComment(options, "Unable to check for issue:\r\n\r\n" + err.message, callback); return writeComment(options, "Unable to check for issue:\r\n\r\n" + err.message, callback);
} }
@ -117,7 +109,7 @@ const checkPullRequest = function (options, callback) {
} }
const shouldHaveReleases = versionNamePattern.test(base.branchname); const shouldHaveReleases = versionNamePattern.test(base.branchname);
return checkHasReleases(options, function (err, hasReleases) { return checkHasReleases(options, (err, hasReleases) => {
if (err) { if (err) {
return writeComment(options, "Unable to check for releases", callback); return writeComment(options, "Unable to check for releases", callback);
} }
@ -139,15 +131,15 @@ const checkPullRequest = function (options, callback) {
}); });
}; };
const getStatusMessageFromRelease = function (app, options, callback) { const getStatusMessageFromRelease = (app, options, callback) => {
const releaseDir = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev; const releaseDir = app.get("releasepath") + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev;
const reportFile = releaseDir + "/report.json"; const reportFile = releaseDir + "/report.json";
options.attemptsGetReport = (options.attemptsGetReport || 0) + 1; options.attemptsGetReport = (options.attemptsGetReport || 0) + 1;
fs.exists(reportFile, function (exists) { fs.exists(reportFile, (exists) => {
if (!exists) { if (!exists) {
return fs.exists(releaseDir, function (dirExists) { return fs.exists(releaseDir, (dirExists) => {
if (!dirExists) { if (!dirExists) {
return callback("Release directory not found. Probably repository hooks are not configured"); return callback("Release directory not found. Probably repository hooks are not configured");
} }
@ -156,52 +148,46 @@ const getStatusMessageFromRelease = function (app, options, callback) {
} }
//maybe it is building right now //maybe it is building right now
return setTimeout(function () { return setTimeout(() => getStatusMessageFromRelease(app, options, callback), 10000);
getStatusMessageFromRelease(app, options, callback);
}, 10000);
}); });
} }
return setTimeout(function () { return setTimeout(() => fs.readFile(reportFile, (err, dataBuffer) => {
return fs.readFile(reportFile, function (err, dataBuffer) { if (err) {
if (err) { return callback(err);
return callback(err); }
} const data = dataBuffer.toString();
const data = dataBuffer.toString(); if (!data) {
if (!data) { return callback("Report file not found");
return callback("Report file not found"); }
} const report = JSON.parse(data);
const report = JSON.parse(data);
if (report.result === "MBSNotFound") { if (report.result === "MBSNotFound") {
return callback("mbs.json is not found"); return callback("mbs.json is not found");
} }
if (report.result && ((report.result.errors || {}).$allMessages || []).length + ((report.result.warns || {}).$allMessages || []).length > 0) { if (report.result && ((report.result.errors || {}).$allMessages || []).length + ((report.result.warns || {}).$allMessages || []).length > 0) {
return callback(_.map( return callback(_.map(
(report.result.errors || {}).$allMessages || [], function(message) { return "ERR: " + message.message; } (report.result.errors || {}).$allMessages || [], (message) => "ERR: " + message.message
).concat(_.map( ).concat(_.map(
(report.result.warns || {}).$allMessages || [], function(message) { return "WARN: " + message.message; } (report.result.warns || {}).$allMessages || [], (message) => "WARN: " + message.message
)).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);
} }
if ((report.result.infos.$allMessages || []).length > 0) { if ((report.result.infos.$allMessages || []).length > 0) {
return callback(undefined, report.result.infos.$allMessages[report.result.infos.$allMessages.length-1].message); return callback(undefined, report.result.infos.$allMessages[report.result.infos.$allMessages.length-1].message);
} }
return callback(undefined, "OK"); return callback(undefined, "OK");
}); }), 1000);
}, 1000);
}); });
}; };
exports.commentOnPullRequest = function (options, callback) { exports.commentOnPullRequest = (options, callback) => {
options.github = settings.createGithub(options.baseRepoOptions.owner); options.github = settings.createGithub(options.baseRepoOptions.owner);
return checkPullRequest(options, function (err, successMessage) { return checkPullRequest(options, (err, successMessage) => getStatusMessageFromRelease(options.app, options.headRepoOptions, (err, successMessage) => {
getStatusMessageFromRelease(options.app, options.headRepoOptions, function (err, successMessage) { const message = err ? ("Was not built:\r\n\r\n```\r\n" + err.replace(/```/g, "` ` `") + "\r\n```\r\n\r\nDO NOT MERGE!") : ("Build OK\r\n\r\n" + successMessage);
const message = err ? ("Was not built:\r\n\r\n```\r\n" + err.replace(/```/g, '` ` `') + "\r\n```\r\n\r\nDO NOT MERGE!") : ("Build OK\r\n\r\n" + successMessage); const statusUrlMessage = "Build status URL: " + settings.siteRoot + "status/" + options.headRepoOptions.owner + "/" + options.headRepoOptions.reponame + "/" + options.headRepoOptions.rev + "\r\n\r\n";
const statusUrlMessage = "Build status URL: " + settings.siteRoot + "status/" + options.headRepoOptions.owner + "/" + options.headRepoOptions.reponame + "/" + options.headRepoOptions.rev + "\r\n\r\n"; return writeComment(options, message + "\r\n\r\n" + statusUrlMessage, callback);
return writeComment(options, message + "\r\n\r\n" + statusUrlMessage, callback); }));
});
});
}; };

@ -8,9 +8,9 @@ const Copier = require('recursive-tree-copy').Copier;
const gitToFsCopier = new Copier({ const gitToFsCopier = new Copier({
concurrency: 4, concurrency: 4,
walkSourceTree: function (tree) { walkSourceTree: (tree) => {
const emitter = new EventEmitter(); const emitter = new EventEmitter();
process.nextTick(function () { process.nextTick(() => {
let entries; let entries;
try { try {
entries = tree.gitTree.entries(); entries = tree.gitTree.entries();
@ -18,25 +18,23 @@ const gitToFsCopier = new Copier({
return emitter.emit('error', err); return emitter.emit('error', err);
} }
async.parallel(entries.map(function (entry) { async.parallel(entries.map((entry) => (callback) => {
return function (callback) { if (entry.isTree()) {
if (entry.isTree()) { entry.getTree((err, subTree) => {
entry.getTree(function (err, subTree) { if (err) {
if (err) { return callback(err);
return callback(err); }
}
emitter.emit('tree', { gitTree: subTree, name: entry.name() }); emitter.emit('tree', { gitTree: subTree, name: entry.name() });
callback();
});
} else if (entry.isFile()) {
emitter.emit('leaf', entry);
callback(); callback();
} else { });
callback(); } else if (entry.isFile()) {
} emitter.emit('leaf', entry);
}; callback();
}), function (err) { } else {
callback();
}
}), (err) => {
if (err) { if (err) {
return emitter.emit('error', err); return emitter.emit('error', err);
} }
@ -46,9 +44,9 @@ const gitToFsCopier = new Copier({
}); });
return emitter; return emitter;
}, },
createTargetTree: function (tree, targetDir, callback) { createTargetTree: (tree, targetDir, callback) => {
const targetSubdir = path.join(targetDir, tree.name); const targetSubdir = path.join(targetDir, tree.name);
fs.mkdir(targetSubdir, function (err) { fs.mkdir(targetSubdir, (err) => {
if (err && err.code !== 'EEXIST' /* workaround for broken trees */) { if (err && err.code !== 'EEXIST' /* workaround for broken trees */) {
return callback(err); return callback(err);
} }
@ -56,12 +54,10 @@ const gitToFsCopier = new Copier({
callback(undefined, targetSubdir); callback(undefined, targetSubdir);
}); });
}, },
finalizeTargetTree: function (targetSubdir, callback) { finalizeTargetTree: (targetSubdir, callback) => callback(),
callback(); copyLeaf: (entry, targetDir, callback) => {
},
copyLeaf: function (entry, targetDir, callback) {
const targetPath = path.join(targetDir, entry.name()); const targetPath = path.join(targetDir, entry.name());
entry.getBlob(function (err, blob) { entry.getBlob((err, blob) => {
if (err) { if (err) {
return callback(err); return callback(err);
} }
@ -71,12 +67,10 @@ const gitToFsCopier = new Copier({
} }
}); });
exports.gitToFs = function (commit, exportDir, callback) { exports.gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => {
commit.getTree(function (err, tree) { if (err) {
if (err) { return callback(err);
return callback(err); }
}
gitToFsCopier.copy({ gitTree: tree, name: "." }, exportDir, callback); gitToFsCopier.copy({ gitTree: tree, name: "." }, exportDir, callback);
}); });
};

@ -3,11 +3,11 @@
const nodegit = require('nodegit'); const nodegit = require('nodegit');
const fse = require('fs-extra'); const fse = require('fs-extra');
const gitToFs = require('./copy').gitToFs; const gitToFs = require('./copy').gitToFs;
const mkdirs = function (path) { const mkdirs = (path) => {
/*jslint stupid: true */ /*jslint stupid: true */
fse.mkdirsSync(path); fse.mkdirsSync(path);
}; };
const removedirs = function (path) { const removedirs = (path) => {
/*jslint stupid: true */ /*jslint stupid: true */
fse.removeSync(path); fse.removeSync(path);
}; };
@ -22,7 +22,7 @@ options = {
} }
*/ */
module.exports = function (options, globalCallback) { module.exports = (options, globalCallback) => {
let url = options.remote; let url = options.remote;
const path = options.local + "/" + options.hash; const path = options.local + "/" + options.hash;
const exported = options.exported; const exported = options.exported;
@ -38,31 +38,27 @@ module.exports = function (options, globalCallback) {
nodegit.Repository.init(path, 1) nodegit.Repository.init(path, 1)
.catch(globalCallback) .catch(globalCallback)
.then(function (repo) { .then((repo) => nodegit.Remote.create(repo, "origin", url)
nodegit.Remote.create(repo, "origin", url) .catch(globalCallback)
.then((remote) => remote.fetch([options.branch])
.catch(globalCallback) .catch(globalCallback)
.then(function (remote) { .then((number) => {
remote.fetch([options.branch]) if (number) {
.catch(globalCallback) return globalCallback("Failed to fetch commit: error number " + number);
.then(function (number) { }
if (number) {
return globalCallback("Failed to fetch commit: error number " + number);
}
console.log("Cloned %s to %s", url, path); console.log("Cloned %s to %s", url, path);
repo.getCommit(options.hash) repo.getCommit(options.hash)
.catch(globalCallback) .catch(globalCallback)
.then(function (commit) { .then((commit) => {
removedirs(exported); removedirs(exported);
mkdirs(exported); mkdirs(exported);
gitToFs(commit, exported, function (err, result) { gitToFs(commit, exported, (err, result) => {
repo.free(); repo.free();
return globalCallback(err, result); return globalCallback(err, result);
}); });
});
}); });
}); })));
});
}; };

@ -3,11 +3,11 @@
const nodemailer = require('nodemailer'); const nodemailer = require('nodemailer');
const settings = require('../settings'); const settings = require('../settings');
exports.send = function (message, callback) { exports.send = (message, callback) => {
return process.nextTick(callback); return process.nextTick(callback);
/* /*
var transport = nodemailer.createTransport("SMTP", settings.smtp); var transport = nodemailer.createTransport("SMTP", settings.smtp);
transport.sendMail(message, function(err, result) { transport.sendMail(message, (err, result) => {
transport.close(); transport.close();
callback(err, result); callback(err, result);
}); });

@ -3,13 +3,13 @@
const fs = require('fs'); const fs = require('fs');
const glob = require('glob'); const glob = require('glob');
const addBranchInfo = function (app, options, callback) { const addBranchInfo = (app, options, callback) => {
const branchFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/$revs/" + options.rev + ".branch"; const branchFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/$revs/" + options.rev + ".branch";
fs.exists(branchFile, function (exists) { fs.exists(branchFile, (exists) => {
if (!exists) { if (!exists) {
return callback("BranchFileNotFound", options); return callback("BranchFileNotFound", options);
} }
fs.readFile(branchFile, function (err, data) { fs.readFile(branchFile, (err, data) => {
if (err) { if (err) {
return callback(err, options); return callback(err, options);
} }
@ -20,13 +20,13 @@ const addBranchInfo = function (app, options, callback) {
}); });
}; };
const addRevInfo = function (app, options, callback) { const addRevInfo = (app, options, callback) => {
const revFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/latest.id"; const revFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/latest.id";
fs.exists(revFile, function (exists) { fs.exists(revFile, (exists) => {
if (!exists) { if (!exists) {
return callback("RevFileNotFound", options); return callback("RevFileNotFound", options);
} }
fs.readFile(revFile, function (err, data) { fs.readFile(revFile, (err, data) => {
if (err) { if (err) {
return callback(err, options); return callback(err, options);
} }
@ -36,7 +36,7 @@ const addRevInfo = function (app, options, callback) {
}); });
}; };
const parseOptions = function (app, options, callback) { const parseOptions = (app, options, callback) => {
const result = {}; const result = {};
result.owner = options.owner; result.owner = options.owner;
@ -59,22 +59,22 @@ const parseOptions = function (app, options, callback) {
} }
}; };
const loadReport = function (app, options, callback) { const loadReport = (app, options, callback) => {
const releaseDir = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev; const releaseDir = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev;
glob("**", {cwd: releaseDir, mark: true}, function (err, files) { glob("**", {cwd: releaseDir, mark: true}, (err, files) => {
if (err) { if (err) {
return callback(err, options); return callback(err, options);
} }
const reportFile = releaseDir + "/report.json"; const reportFile = releaseDir + "/report.json";
options.files = files; options.files = files;
fs.exists(reportFile, function (exists) { fs.exists(reportFile, (exists) => {
if (!exists) { if (!exists) {
return callback("ReportFileNotFound", options); return callback("ReportFileNotFound", options);
} }
fs.readFile(reportFile, function (err, dataBuffer) { fs.readFile(reportFile, (err, dataBuffer) => {
if (err) { if (err) {
return callback(err, options); return callback(err, options);
} }
@ -89,12 +89,10 @@ const loadReport = function (app, options, callback) {
}); });
}; };
exports.getReport = function (app, options, callback) { exports.getReport = (app, options, callback) => parseOptions(app, options, (err, result) => {
parseOptions(app, options, function (err, result) { if (err) {
if (err) { return callback(err, {});
return callback(err, {}); }
}
return loadReport(app, result, callback); return loadReport(app, result, callback);
}); });
};

@ -9,29 +9,19 @@ const TaskProcessor = function (task, outerProcessor, callback) {
const self = this; const self = this;
let taskWorker = undefined; let taskWorker = undefined;
const errors = []; const errors = [];
const process = function () { const process = () => taskWorker.process();
taskWorker.process(); const getOuterPrefix = (prefix) => (task.name && prefix) ? (task.name + "/" + prefix) : (task.name || "") + (prefix || "");
}; const onError = (message, prefix) => {
const getOuterPrefix = function (prefix) {
return (task.name && prefix) ? (task.name + "/" + prefix) : (task.name || "") + (prefix || "");
};
const onError = function (message, prefix) {
errors.push(message); errors.push(message);
outerProcessor.onError(message, getOuterPrefix(prefix)); outerProcessor.onError(message, getOuterPrefix(prefix));
}; };
const onWarn = function (message, prefix) { const onWarn = (message, prefix) => outerProcessor.onWarn(message, getOuterPrefix(prefix));
outerProcessor.onWarn(message, getOuterPrefix(prefix)); const onInfo = (message, prefix) => outerProcessor.onInfo(message, getOuterPrefix(prefix));
}; const processTask = (innerTask, innerCallback) => {
const onInfo = function (message, prefix) {
outerProcessor.onInfo(message, getOuterPrefix(prefix));
};
const processTask = function (innerTask, innerCallback) {
const innerProcessor = new TaskProcessor(innerTask, self, innerCallback); const innerProcessor = new TaskProcessor(innerTask, self, innerCallback);
innerProcessor.process(); innerProcessor.process();
}; };
const done = function () { const done = () => callback(errors.join("\r\n"));
callback(errors.join("\r\n"));
};
self.process = process; self.process = process;
self.onError = onError; self.onError = onError;
@ -45,17 +35,17 @@ const TaskProcessor = function (task, outerProcessor, callback) {
taskWorker = taskImpl(task.params || {}, self); taskWorker = taskImpl(task.params || {}, self);
}; };
exports.processTask = function (task, context, callback) { exports.processTask = (task, context, callback) => {
const errors = {}; const errors = {};
const warns = {}; const warns = {};
const infos = {}; const infos = {};
const messages = {}; const messages = {};
const messageProcessor = function (list) { const messageProcessor = (list) => {
const f = function (list, message, prefix) { const f = (list, message, prefix) => {
const parts = prefix.split("/"); const parts = prefix.split("/");
let innerList = list; let innerList = list;
parts.forEach(function (part) { parts.forEach((part) => {
innerList = (innerList[part] = innerList[part] || {}); innerList = (innerList[part] = innerList[part] || {});
}); });
@ -66,7 +56,7 @@ exports.processTask = function (task, context, callback) {
list.$allMessages.push({ prefix: prefix, message: message }); list.$allMessages.push({ prefix: prefix, message: message });
}; };
return function (message, prefix) { return (message, prefix) => {
f(list, message, prefix); f(list, message, prefix);
f(messages, message, prefix); f(messages, message, prefix);
}; };
@ -76,14 +66,12 @@ exports.processTask = function (task, context, callback) {
onWarn: messageProcessor(warns), onWarn: messageProcessor(warns),
onInfo: messageProcessor(infos), onInfo: messageProcessor(infos),
context: context context: context
}, function (err) { }, (err) => callback(err, {
callback(err, { errors: errors,
errors: errors, warns: warns,
warns: warns, infos: infos,
infos: infos, messages: messages
messages: messages }));
});
});
processor.process(); processor.process();
}; };

@ -2,37 +2,31 @@
const glob = require('glob'); const glob = require('glob');
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
process: function () { dot: true,
glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", { cwd: processor.context.exported
dot: true, }, (err, files) => {
cwd: processor.context.exported if (err) {
}, function (err, files) { processor.onError(err);
if (err) { return processor.done();
processor.onError(err); }
return processor.done();
}
if (!files || !files.length) { if (!files || !files.length) {
return processor.done(); return processor.done();
} }
return processor.processTask({ return processor.processTask({
type: "parallel", type: "parallel",
params: {
tasks: files.map((file) => ({
name: file,
type: "deletefromcode",
params: { params: {
tasks: files.map(function (file) { filename: file
return {
name: file,
type: "deletefromcode",
params: {
filename: file
}
};
})
} }
}, processor.done.bind(processor)); }))
}); }
} }, processor.done.bind(processor));
}; })
}; });

@ -1,12 +1,10 @@
"use strict"; "use strict";
module.exports = function (params, processor) { module.exports = (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 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; const task = condition ? params.task : params.otherwise;
return { return {
process: function () { process: () => processor.processTask(task || {type: "noop"}, processor.done.bind(processor))
return processor.processTask(task || {type: "noop"}, processor.done.bind(processor));
}
}; };
}; };

@ -2,22 +2,20 @@
const fse = require('fs-extra'); const fse = require('fs-extra');
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => {
process: function () { const sourceFilePath = processor.context.exported + "/" + params.filename;
const sourceFilePath = processor.context.exported + "/" + params.filename; const targetFilePath = processor.context.release + "/" + params.filename;
const targetFilePath = processor.context.release + "/" + params.filename;
processor.onInfo("Copying " + sourceFilePath + " to " + targetFilePath); processor.onInfo("Copying " + sourceFilePath + " to " + targetFilePath);
fse.copy(sourceFilePath, targetFilePath, function(err) { fse.copy(sourceFilePath, targetFilePath, (err) => {
if (err) { if (err) {
processor.onError("Unable to copy file: " + err); processor.onError("Unable to copy file: " + err);
} else { } else {
processor.onInfo("Copied file"); processor.onInfo("Copied file");
} }
return processor.done(); return processor.done();
}); });
} }
}; });
};

@ -2,37 +2,31 @@
const glob = require('glob'); const glob = require('glob');
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => glob(params.mask, {
process: function () { dot: true,
glob(params.mask, { cwd: processor.context.exported
dot: true, }, (err, files) => {
cwd: processor.context.exported if (err) {
}, function (err, files) { processor.onError(err);
if (err) { return processor.done();
processor.onError(err); }
return processor.done();
}
if (!files || !files.length) { if (!files || !files.length) {
return processor.done(); return processor.done();
} }
return processor.processTask({ return processor.processTask({
type: "parallel", type: "parallel",
params: {
tasks: files.map((file) => ({
name: file,
type: "copy",
params: { params: {
tasks: files.map(function (file) { filename: file
return {
name: file,
type: "copy",
params: {
filename: file
}
};
})
} }
}, processor.done.bind(processor)); }))
}); }
} }, processor.done.bind(processor));
}; })
}; });

@ -4,7 +4,7 @@ const fse = require('fs-extra');
module.exports = function (params, processor) { module.exports = function (params, processor) {
return { return {
process: function () { process: () => {
var sourceFilePath = processor.context.exported + "/" + params.filename; var sourceFilePath = processor.context.exported + "/" + params.filename;
processor.onInfo("Deleting " + sourceFilePath); processor.onInfo("Deleting " + sourceFilePath);

@ -2,18 +2,16 @@
const sequential = require('./sequential'); const sequential = require('./sequential');
module.exports = function (params, processor) { module.exports = (params, processor) => sequential({
return sequential({ tasks: [
tasks: [ {
{ type: "dotnetbuildwithoutcleanup",
type: "dotnetbuildwithoutcleanup", name: "build",
name: "build", params: params
params: params },
}, {
{ type: "cleanupafterdotnetbuild",
type: "cleanupafterdotnetbuild", name: "cleanup"
name: "cleanup" }
} ]
] }, processor);
}, processor);
};

@ -2,23 +2,21 @@
const sequential = require("./sequential"); const sequential = require("./sequential");
module.exports = function (params, processor) { module.exports = (params, processor) => sequential({
return sequential({ tasks: [
tasks: [ {
{ type: "dotnetbuildwithoutcleanup",
type: "dotnetbuildwithoutcleanup", name: "build",
name: "build", params: params
params: params },
}, {
{ type: "dotnetnunitall",
type: "dotnetnunitall", name: "test",
name: "test", params: params
params: params },
}, {
{ type: "cleanupafterdotnetbuild",
type: "cleanupafterdotnetbuild", name: "cleanup"
name: "cleanup" }
} ]
] }, processor);
}, processor);
};

@ -3,51 +3,45 @@
const spawn = require('child_process').spawn; const spawn = require('child_process').spawn;
const settings = require("../../settings"); const settings = require("../../settings");
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => {
process: function () { let result = "";
let result = ""; let error = "";
let error = ""; const builder = spawn(settings.builderExecutable, [params.command]);
const builder = spawn(settings.builderExecutable, [params.command]);
processor.onInfo("DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + "): " + JSON.stringify(params, null, 4));
processor.onInfo("DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + "): " + JSON.stringify(params, null, 4));
builder.stdout.on('data', (data) => result += data);
builder.stderr.on('data', (data) => error += data);
builder.on('exit', (code) => {
if (code !== 0) {
error = "Return code is " + code + "\r\n" + error;
processor.onError(error);
return processor.done();
}
builder.stdout.on('data', function (data) { const report = JSON.parse(result);
result += data; const messages = report.Messages;
}); messages.forEach((message) => {
builder.stderr.on('data', function (data) { if (!message) {
error += data; return processor.onError("Message is null");
});
builder.on('exit', function (code) {
if (code !== 0) {
error = "Return code is " + code + "\r\n" + error;
processor.onError(error);
return processor.done();
} }
const report = JSON.parse(result); switch(message.Type) {
const messages = report.Messages; case "info":
messages.forEach(function (message) { return processor.onInfo(message.Body);
if (!message) { case "warn":
return processor.onError("Message is null"); 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()) + ")");
return processor.done();
}); });
builder.stdin.write(JSON.stringify(params)); processor.onInfo("Done DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + ")");
builder.stdin.end(); return processor.done();
} });
};
}; builder.stdin.write(JSON.stringify(params));
builder.stdin.end();
}
});

@ -2,7 +2,7 @@
const sequential = require('./sequential'); const sequential = require('./sequential');
module.exports = function (params, processor) { module.exports = (params, processor) => {
let tasks = []; let tasks = [];
if (!params.skipMbsCheckStyle) { if (!params.skipMbsCheckStyle) {

@ -8,61 +8,55 @@ const autoGeneratedMarker =
"//------------------------------------------------------------------------------" + "\n" + "//------------------------------------------------------------------------------" + "\n" +
"// <auto-generated>"; "// <auto-generated>";
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => {
process: function () { if (processor.context.dotnetcheckerDone) {
if (processor.context.dotnetcheckerDone) { return processor.done();
}
processor.context.dotnetcheckerDone = true;
glob("**/*.cs", {cwd: processor.context.exported}, (err, files) => {
if (err) {
processor.onError(err);
return processor.done(); return processor.done();
} }
processor.context.dotnetcheckerDone = true; processor.onInfo("Found " + files.length + " .cs files");
glob("**/*.cs", {cwd: processor.context.exported}, function (err, files) { if (!files || !files.length) {
processor.onWarn("No .cs files found");
return processor.done();
}
return async.parallel(files.map((file) => (callback) => fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, (err, data) => {
if (err) { if (err) {
processor.onError(err); processor.onError("Unable to check file " + file + ": " + err);
return processor.done(); return callback(err);
} }
if (data.indexOf("\r\n") >= 0) {
processor.onInfo("Found " + files.length + " .cs files"); processor.onError("Windows-style EOL (0D0A) found in file " + file);
return callback();
if (!files || !files.length) { }
processor.onWarn("No .cs files found"); if (params.ignoreCodeStyle) {
return processor.done(); return callback();
}
if (data.substr(1, autoGeneratedMarker.length) === autoGeneratedMarker || data.substr(0, autoGeneratedMarker.length) === autoGeneratedMarker) {
processor.onInfo("Skipping auto-generated file " + file);
return callback();
} }
return async.parallel(files.map(function (file) { if (data.indexOf("\t") >= 0 && data.indexOf(" ") >= 0) {
return function (callback) { processor.onError("Both tabs and spaces found in file " + file);
return fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, function (err, data) { }
if (err) {
processor.onError("Unable to check file " + file + ": " + err);
return callback(err);
}
if (data.indexOf("\r\n") >= 0) {
processor.onError("Windows-style EOL (0D0A) found in file " + file);
return callback();
}
if (params.ignoreCodeStyle) {
return callback();
}
if (data.substr(1, autoGeneratedMarker.length) === autoGeneratedMarker || data.substr(0, autoGeneratedMarker.length) === autoGeneratedMarker) {
processor.onInfo("Skipping auto-generated file " + file);
return callback();
}
if (data.indexOf("\t") >= 0 && data.indexOf(" ") >= 0) {
processor.onError("Both tabs and spaces found in file " + file);
}
if (data.indexOf("\t") >= 0) { if (data.indexOf("\t") >= 0) {
processor.onError("Tabs found in file " + file); processor.onError("Tabs found in file " + file);
} }
processor.onInfo("Checked file " + file); processor.onInfo("Checked file " + file);
callback(); callback();
}); })), processor.done.bind(processor));
}; });
}), processor.done.bind(processor)); }
}); });
}
};
};

@ -3,7 +3,7 @@
const settings = require('../../settings'); const settings = require('../../settings');
const dotnetbuilderwrapper = require('./dotnetbuilderwrapper'); const dotnetbuilderwrapper = require('./dotnetbuilderwrapper');
module.exports = function (params, processor) { module.exports = (params, processor) => {
const compileParams = { const compileParams = {
command: "compile", command: "compile",
SolutionPath: processor.context.exported + "/" + params.solution, SolutionPath: processor.context.exported + "/" + params.solution,

@ -2,7 +2,7 @@
const sequential = require('./sequential'); const sequential = require('./sequential');
module.exports = function (params, processor) { module.exports = (params, processor) => {
const date = new Date(); const date = new Date();
const version = (params.version || ((params.major || "0") + "." + (date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate()) + "." + ((date.getHours() * 100 + date.getMinutes()) * 100 + date.getSeconds()))) + (params.withoutCommitSha ? "" : ("-r" + processor.context.rev.substr(0, 16))); const version = (params.version || ((params.major || "0") + "." + (date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate()) + "." + ((date.getHours() * 100 + date.getMinutes()) * 100 + date.getSeconds()))) + (params.withoutCommitSha ? "" : ("-r" + processor.context.rev.substr(0, 16)));

@ -2,31 +2,29 @@
const conditional = require('./conditional'); const conditional = require('./conditional');
module.exports = function (params, processor) { module.exports = (params, processor) => conditional({
return conditional({ owner: params.masterRepoOwner,
owner: params.masterRepoOwner, branch: "master",
branch: "master", task: {
task: { name: "nuget-push",
name: "nuget-push", type: "dotnetnugetpush",
type: "dotnetnugetpush", params: {
params: { nuspec: params.nuspecName + ".nuspec",
nuspec: params.nuspecName + ".nuspec", name: params.nuspecName,
name: params.nuspecName, withoutCommitSha: params.withoutCommitSha,
withoutCommitSha: params.withoutCommitSha, version: params.version,
version: params.version, major: params.major
major: params.major
}
},
otherwise: {
name: "nuget-pack",
type: "dotnetnugetpack",
params: {
nuspec: params.nuspecName + ".nuspec",
name: params.nuspecName,
withoutCommitSha: params.withoutCommitSha,
version: params.version,
major: params.major
}
} }
}, processor); },
}; otherwise: {
name: "nuget-pack",
type: "dotnetnugetpack",
params: {
nuspec: params.nuspecName + ".nuspec",
name: params.nuspecName,
withoutCommitSha: params.withoutCommitSha,
version: params.version,
major: params.major
}
}
}, processor);

@ -2,7 +2,7 @@
const sequential = require("./sequential"); const sequential = require("./sequential");
module.exports = function (params, processor) { module.exports = (params, processor) => {
const date = new Date(); const date = new Date();
const version = (params.version || ((params.major || "0") + "." + (date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate()) + "." + ((date.getHours() * 100 + date.getMinutes()) * 100 + date.getSeconds()))) + (params.withoutCommitSha ? "" : ("-r" + processor.context.rev.substr(0, 16))); const version = (params.version || ((params.major || "0") + "." + (date.getFullYear() * 10000 + (date.getMonth() + 1) * 100 + date.getDate()) + "." + ((date.getHours() * 100 + date.getMinutes()) * 100 + date.getSeconds()))) + (params.withoutCommitSha ? "" : ("-r" + processor.context.rev.substr(0, 16)));
const nupkg = params.name + "." + version + ".nupkg"; const nupkg = params.name + "." + version + ".nupkg";

@ -3,11 +3,9 @@
const dotnetbuilderwrapper = require('./dotnetbuilderwrapper'); const dotnetbuilderwrapper = require('./dotnetbuilderwrapper');
const settings = require("../../settings"); const settings = require("../../settings");
module.exports = function (params, processor) { module.exports = (params, processor) => dotnetbuilderwrapper({
return dotnetbuilderwrapper({ command: "nugetpush",
command: "nugetpush", Package: processor.context.exported + "/" + params.Package,
Package: processor.context.exported + "/" + params.Package, NugetHost: settings.nugetHost,
NugetHost: settings.nugetHost, ApiKey: settings.nugetApiKey
ApiKey: settings.nugetApiKey }, processor);
}, processor);
};

@ -2,17 +2,15 @@
const sequential = require('./sequential'); const sequential = require('./sequential');
module.exports = function (params, processor) { module.exports = (params, processor) => sequential({
return sequential({ tasks: [
tasks: [ {
{ type: "dotnetbuilderwrapper",
type: "dotnetbuilderwrapper", params: {
params: { command: "nugetrestore",
command: "nugetrestore", BaseDirectory: processor.context.exported,
BaseDirectory: processor.context.exported, SolutionPath: processor.context.exported + "/" + params.solution
SolutionPath: processor.context.exported + "/" + params.solution
}
} }
] }
}, processor); ]
}; }, processor);

@ -2,10 +2,8 @@
const dotNetBuilderWrapper = require('./dotnetbuilderwrapper'); const dotNetBuilderWrapper = require('./dotnetbuilderwrapper');
module.exports = function (params, processor) { module.exports = (params, processor) => dotNetBuilderWrapper({
return dotNetBuilderWrapper({ command: "nunit",
command: "nunit", TestLibraryPath: processor.context.exported + "/" + params.assembly//,
TestLibraryPath: processor.context.exported + "/" + params.assembly//, // OutputPath: processor.context.release + "/" + params.solution + "/"
// OutputPath: processor.context.release + "/" + params.solution + "/" }, processor);
}, processor);
};

@ -2,44 +2,40 @@
const glob = require('glob'); const glob = require('glob');
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => {
process: function () { if (processor.context.dotnetnunitallDone) {
if (processor.context.dotnetnunitallDone) { 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"); }
}
processor.context.dotnetnunitallDone = true; processor.context.dotnetnunitallDone = true;
glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", { glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", {
dot: true, dot: true,
cwd: processor.context.exported cwd: processor.context.exported
}, function (err, files) { }, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
return processor.done(); return processor.done();
} }
if (!files || !files.length) { if (!files || !files.length) {
processor.onError("No test assemblies found in " + processor.context.exported); processor.onError("No test assemblies found in " + processor.context.exported);
return processor.done(); return processor.done();
} }
return processor.processTask({ return processor.processTask({
type: params.preventParallelTests ? "sequential" : "parallel", type: params.preventParallelTests ? "sequential" : "parallel",
params: { params: {
tasks: files.map(function (file) { tasks: files.map((file) => ({
return { name: file,
name: file, type: "dotnetnunit",
type: "dotnetnunit", params: {
params: { assembly: file
assembly: file }
} }))
}; }
}) }, processor.done.bind(processor));
} });
}, processor.done.bind(processor)); }
}); });
}
};
};

@ -9,41 +9,39 @@ const msbuildTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.
const deployTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.bat", {encoding: "utf8"}); const deployTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.bat", {encoding: "utf8"});
const versionTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.version.aspx", {encoding: "utf8"}); const versionTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.version.aspx", {encoding: "utf8"});
module.exports = function (params, processor) { module.exports = (params, processor) => sequential({
return sequential({ tasks: [
tasks: [ {
{ type: "writefile",
type: "writefile", params: {
params: { filename: "MakePackage.msbuild",
filename: "MakePackage.msbuild", data: Mustache.render(msbuildTemplate, params)
data: Mustache.render(msbuildTemplate, params)
}
},
{
type: "writefile",
params: {
filename: "Deploy.bat",
data: Mustache.render(deployTemplate, params)
}
},
{
type: "writefile",
params: {
filename: "version.aspx",
data: Mustache.render(versionTemplate, params)
}
},
{
type: "dotnetcompile",
params: {
solution: "MakePackage.msbuild",
skipCodeSigning: params.skipCodeSigning,
isCodeAnalysisUnsupported: params.isCodeAnalysisUnsupported,
configuration: params.configuration,
target: "Package",
overrideOutputDirectory: processor.context.release
}
} }
] },
}, processor); {
}; type: "writefile",
params: {
filename: "Deploy.bat",
data: Mustache.render(deployTemplate, params)
}
},
{
type: "writefile",
params: {
filename: "version.aspx",
data: Mustache.render(versionTemplate, params)
}
},
{
type: "dotnetcompile",
params: {
solution: "MakePackage.msbuild",
skipCodeSigning: params.skipCodeSigning,
isCodeAnalysisUnsupported: params.isCodeAnalysisUnsupported,
configuration: params.configuration,
target: "Package",
overrideOutputDirectory: processor.context.release
}
}
]
}, processor);

@ -5,77 +5,65 @@ const async = require('async');
const glob = require('glob'); const glob = require('glob');
const settings = require('../../settings'); const settings = require('../../settings');
const addAssemblyAttribute = function (content, attribute) { const addAssemblyAttribute = (content, attribute) => content + "\n" + attribute + "\n";
return content + "\n" + attribute + "\n";
};
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => {
process: function () { if (processor.context.dotnetrewriterDone) {
if (processor.context.dotnetrewriterDone) { return processor.done();
return processor.done(); }
}
processor.context.dotnetrewriterDone = true; processor.context.dotnetrewriterDone = true;
const date = new Date(); const date = new Date();
const version = date.getFullYear() + "." + const version = date.getFullYear() + "." +
(date.getMonth() + 1) + "." + (date.getMonth() + 1) + "." +
date.getDate() + "." + date.getDate() + "." +
(date.getHours() * 100 + date.getMinutes()) + "; " + (date.getHours() * 100 + date.getMinutes()) + "; " +
"built from " + processor.context.rev + "; " + "built from " + processor.context.rev + "; " +
"repository: " + processor.context.owner + "/" + processor.context.reponame + "; " + "repository: " + processor.context.owner + "/" + processor.context.reponame + "; " +
"branch: " + processor.context.branch; "branch: " + processor.context.branch;
const processAssemblyInfo = function (appendInformationalVersion) { const processAssemblyInfo = (appendInformationalVersion) => (content, cb) => {
return function (content, cb) { if (!params.skipCodeSigning && !settings.skipCodeSigning) {
if (!params.skipCodeSigning && !settings.skipCodeSigning) { content = content.replace(
content = content.replace( /InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g,
/InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g, (match, p1) => "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")"
function (match, p1) { );
return "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")"; }
}
);
}
if (appendInformationalVersion) { if (appendInformationalVersion) {
content = addAssemblyAttribute(content, "[assembly: System.Reflection.AssemblyInformationalVersion(\"" + version + "\")]"); content = addAssemblyAttribute(content, "[assembly: System.Reflection.AssemblyInformationalVersion(\"" + version + "\")]");
} }
return cb(null, content); return cb(null, content);
}; };
};
glob("**/{InternalsVisible,AssemblyInfo}*.cs", {cwd: processor.context.exported}, function (err, files) { glob("**/{InternalsVisible,AssemblyInfo}*.cs", {cwd: processor.context.exported}, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
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) { if (!files || !files.length) {
processor.onWarn("No AssemblyInfo.cs found"); processor.onWarn("No AssemblyInfo.cs found");
return processor.done(); return processor.done();
} }
return async.parallel(files.map(function (file) { return async.parallel(files.map((file) => (callback) => async.waterfall([
return function (callback) { fs.readFile.bind(null, processor.context.exported + "/" + file, { encoding: "utf8" }),
return async.waterfall([ processAssemblyInfo(file.toLowerCase().indexOf("assemblyinfo.cs") >= 0),
fs.readFile.bind(null, processor.context.exported + "/" + file, { encoding: "utf8" }), fs.writeFile.bind(null, processor.context.exported + "/" + file)
processAssemblyInfo(file.toLowerCase().indexOf("assemblyinfo.cs") >= 0), ], (err) => {
fs.writeFile.bind(null, processor.context.exported + "/" + file) if (err) {
], function (err) { processor.onError("Unable to rewrite file " + file + ": " + err);
if (err) { } else {
processor.onError("Unable to rewrite file " + file + ": " + err); processor.onInfo("Rewritten file " + file);
} else { }
processor.onInfo("Rewritten file " + file); callback(err);
} })), processor.done.bind(processor));
callback(err); });
}); }
}; });
}), processor.done.bind(processor));
});
}
};
};

@ -1,21 +1,19 @@
"use strict"; "use strict";
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => {
process: function () { if (params.error) {
if (params.error) { processor.onError(params.error);
processor.onError(params.error); }
}
if (params.warn) {
processor.onWarn(params.warn);
}
if (params.info) { if (params.warn) {
processor.onInfo(params.info); processor.onWarn(params.warn);
} }
processor.done(); if (params.info) {
processor.onInfo(params.info);
} }
};
}; processor.done();
}
});

@ -1,9 +1,5 @@
"use strict"; "use strict";
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => processor.done()
process: function () { });
processor.done();
}
};
};

@ -2,16 +2,6 @@
const async = require("async"); const async = require("async");
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => async.parallel(params.tasks.map((task) => (callback) => processor.processTask(task, (err) => callback())), processor.done.bind(processor))
process: function () { });
async.parallel(params.tasks.map(function (task) {
return function (callback) {
return processor.processTask(task, function (err) {
return callback();
});
};
}), processor.done.bind(processor));
}
};
};

@ -2,11 +2,9 @@
const async = require("async"); const async = require("async");
module.exports = function (params, processor) { module.exports = (params, processor) => {
const mapper = Function.bind.bind(processor.processTask, processor); const mapper = Function.bind.bind(processor.processTask, processor);
return { return {
process: function () { process: () => async.series(params.tasks.map((element) => mapper(element)), processor.done.bind(processor))
async.series(params.tasks.map(function (element) { return mapper(element); }), processor.done.bind(processor));
}
}; };
}; };

@ -2,20 +2,18 @@
const fs = require('fs'); const fs = require('fs');
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => {
process: function () { const filePath = processor.context.exported + "/" + params.filename;
const filePath = processor.context.exported + "/" + params.filename; processor.onInfo("Writing to " + filePath);
processor.onInfo("Writing to " + filePath);
fs.writeFile(filePath, params.data, function(err) { fs.writeFile(filePath, params.data, (err) => {
if (err) { if (err) {
processor.onError("Unable to write file: " + err); processor.onError("Unable to write file: " + err);
} else { } else {
processor.onInfo("Written file"); processor.onInfo("Written file");
} }
return processor.done(); return processor.done();
}); });
} }
}; });
};

@ -1,6 +1,6 @@
"use strict"; "use strict";
module.exports = function(req, res) { module.exports = (req, res) => {
const options = { const options = {
owner: req.params.owner, owner: req.params.owner,
reponame: req.params.reponame, reponame: req.params.reponame,

@ -1,8 +1,6 @@
"use strict"; "use strict";
exports.index = function(req, res){ exports.index = (req, res) => res.render('index', { title: 'Express' + req + "qq" });
res.render('index', { title: 'Express' + req + "qq" });
};
exports.postreceive = require('./postreceive'); exports.postreceive = require('./postreceive');
exports.manual = require('./manual'); exports.manual = require('./manual');

@ -2,16 +2,14 @@
const builder = require('../lib/builder'); const builder = require('../lib/builder');
exports.get = function (req, res) { exports.get = (req, res) => res.render('manual');
res.render('manual');
};
exports.post = function (req, res) { exports.post = (req, res) => {
var options = req.body; const options = req.body;
options.url = "https://pos-github.payonline.ru/" + options.owner + "/" + options.reponame; options.url = "https://pos-github.payonline.ru/" + options.owner + "/" + options.reponame;
options.app = req.app; options.app = req.app;
builder.build(options, function (err, result) { builder.build(options, (err, result) => {
console.log("Done processing manual request"); console.log("Done processing manual request");
console.log("Error: " + err); console.log("Error: " + err);
//console.log("Result:"); //console.log("Result:");

@ -3,7 +3,7 @@
const builder = require('../lib/builder'); const builder = require('../lib/builder');
const commenter = require('../lib/commenter'); const commenter = require('../lib/commenter');
const processPush = function (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,
@ -16,7 +16,7 @@ const processPush = function (req, res, payload) {
console.log("Got push event for " + options.owner + "/" + options.reponame + ":" + options.branch); console.log("Got push event for " + options.owner + "/" + options.reponame + ":" + options.branch);
builder.build(options, function (err, result) { builder.build(options, (err, result) => {
console.log("Done processing request from GitHub"); console.log("Done processing request from GitHub");
console.log("Error: " + err); console.log("Error: " + err);
//console.log("Result:"); //console.log("Result:");
@ -25,7 +25,7 @@ const processPush = function (req, res, payload) {
}); });
}; };
const processPullRequest = function (req, res, payload) { const processPullRequest = (req, res, payload) => {
const action = payload.action; const action = payload.action;
const number = payload.number; const number = payload.number;
const pullRequest = payload.pull_request; const pullRequest = payload.pull_request;
@ -80,7 +80,7 @@ const processPullRequest = function (req, res, payload) {
commenter.commentOnPullRequest( commenter.commentOnPullRequest(
action === "closed" ? masterOptions : options, action === "closed" ? masterOptions : options,
function (err, data) { (err, data) => {
if (err) { if (err) {
console.log("Unable to post comment: " + err); console.log("Unable to post comment: " + err);
} }
@ -90,7 +90,7 @@ const processPullRequest = function (req, res, payload) {
); );
}; };
module.exports = function (req, res) { module.exports = (req, res) => {
if (!req.body || (!req.body.payload && !req.body.repository)) { if (!req.body || (!req.body.payload && !req.body.repository)) {
return res.end(); return res.end();
} }

@ -4,15 +4,15 @@ const path = require('path');
const fs = require('fs'); const fs = require('fs');
const Zip = require('adm-zip'); const Zip = require('adm-zip');
const getReport = function(releasePath, callback) { const getReport = (releasePath, callback) => {
const reportFile = releasePath + "report.json"; const reportFile = releasePath + "report.json";
fs.exists(reportFile, function (exists) { fs.exists(reportFile, (exists) => {
if (!exists) { if (!exists) {
return callback("ReportFileNotFound: " + reportFile); return callback("ReportFileNotFound: " + reportFile);
} }
return fs.readFile(reportFile, function (err, dataBuffer) { return fs.readFile(reportFile, (err, dataBuffer) => {
if (err) { if (err) {
return callback(err, reportFile); return callback(err, reportFile);
} }
@ -26,15 +26,13 @@ const getReport = function(releasePath, callback) {
}); });
}; };
const getDatePart = function (report) { const getDatePart = (report) => {
if (!report.date) { if (!report.date) {
return "unknowndate"; return "unknowndate";
} }
const date = new Date(report.date); const date = new Date(report.date);
const paddingLeft = function (str, paddingValue) { const paddingLeft = (str, paddingValue) => String(paddingValue + str).slice(-paddingValue.length);
return String(paddingValue + str).slice(-paddingValue.length);
};
return date.getFullYear() + "." + return date.getFullYear() + "." +
paddingLeft(date.getMonth() + 1, "00") + "." + paddingLeft(date.getMonth() + 1, "00") + "." +
@ -44,7 +42,7 @@ const getDatePart = function (report) {
paddingLeft(date.getSeconds(), "00"); paddingLeft(date.getSeconds(), "00");
}; };
module.exports = function(req, res, next) { module.exports = (req, res, next) => {
const options = { const options = {
owner: req.params.owner, owner: req.params.owner,
reponame: req.params.reponame, reponame: req.params.reponame,
@ -56,17 +54,15 @@ module.exports = function(req, res, next) {
const zip = new Zip(); const zip = new Zip();
const releasePath = path.normalize(req.app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev + "/"); const releasePath = path.normalize(req.app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev + "/");
getReport(releasePath, function (err, report) { getReport(releasePath, (err, report) => {
if (err) { if (err) {
return next(err); return next(err);
} }
zip.addLocalFolder(releasePath); zip.addLocalFolder(releasePath);
zip.toBuffer(function (buffer) { zip.toBuffer((buffer) => {
res.attachment(options.reponame + '.' + getDatePart(report) + '.' + options.rev + '.zip', '.'); res.attachment(options.reponame + '.' + getDatePart(report) + '.' + options.rev + '.zip', '.');
res.send(buffer); res.send(buffer);
}, function (error) { }, (error) => next(error), () => { }, () => { });
next(error);
}, function () { }, function () { });
}); });
}; };

@ -3,8 +3,8 @@
const url = require('url'); const url = require('url');
const statusProcessor = require('../lib/status-processor'); const statusProcessor = require('../lib/status-processor');
const parseOptionsFromReferer = function (path, callback) { const parseOptionsFromReferer = (path, callback) => {
const pathParts = path.split("/").filter(function (value) { return value; }); const pathParts = path.split("/").filter((value) => value);
const result = {}; const result = {};
if (pathParts.length < 2) { if (pathParts.length < 2) {
@ -22,16 +22,14 @@ const parseOptionsFromReferer = function (path, callback) {
return callback(null, result); return callback(null, result);
}; };
const createShowReport = function (res) { const createShowReport = (res) => (err, options) => {
return function (err, options) { options = options || {};
options = options || {}; options.err = err;
options.err = err; res.render('status', options);
res.render('status', options);
};
}; };
exports.image = function(req, res) { exports.image = (req, res) => {
const handle = function (err, options) { const handle = (err, options) => {
if (err === "ReportFileNotFound") { if (err === "ReportFileNotFound") {
options.status = "Building"; options.status = "Building";
} else if (err) { } else if (err) {
@ -55,18 +53,16 @@ exports.image = function(req, res) {
res.render('status-image', options); res.render('status-image', options);
}; };
parseOptionsFromReferer(url.parse(req.headers.referer || "").pathname || "", function (err, options) { parseOptionsFromReferer(url.parse(req.headers.referer || "").pathname || "", (err, options) => {
if (err) { if (err) {
return handle(err, options); return handle(err, options);
} }
statusProcessor.getReport(req.app, options, function (err, options) { statusProcessor.getReport(req.app, options, (err, options) => handle(err, options));
handle(err, options);
});
}); });
}; };
exports.page = function(req, res) { exports.page = (req, res) => {
const options = { const options = {
owner: req.params.owner, owner: req.params.owner,
reponame: req.params.reponame, reponame: req.params.reponame,
@ -78,12 +74,10 @@ exports.page = function(req, res) {
statusProcessor.getReport(req.app, options, createShowReport(res)); statusProcessor.getReport(req.app, options, createShowReport(res));
}; };
exports.pageFromGithub = function (req, res) { exports.pageFromGithub = (req, res) => parseOptionsFromReferer(req.params[0], (err, options) => {
parseOptionsFromReferer(req.params[0], function (err, options) { if (err) {
if (err) { return createShowReport(err, options);
return createShowReport(err, options); }
}
return statusProcessor.getReport(req.app, options, createShowReport(res)); return statusProcessor.getReport(req.app, options, createShowReport(res));
}); });
};

Loading…
Cancel
Save