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. 52
      BuildServer/lib/builder.js
  3. 66
      BuildServer/lib/commenter.js
  4. 28
      BuildServer/lib/git/copy.js
  5. 22
      BuildServer/lib/git/loader.js
  6. 4
      BuildServer/lib/mail-sender.js
  7. 26
      BuildServer/lib/status-processor.js
  8. 40
      BuildServer/lib/task-processor.js
  9. 18
      BuildServer/lib/tasks/cleanupafterdotnetbuild.js
  10. 6
      BuildServer/lib/tasks/conditional.js
  11. 10
      BuildServer/lib/tasks/copy.js
  12. 18
      BuildServer/lib/tasks/copyglob.js
  13. 2
      BuildServer/lib/tasks/deletefromcode.js
  14. 4
      BuildServer/lib/tasks/dotnetbuild.js
  15. 4
      BuildServer/lib/tasks/dotnetbuildandtest.js
  16. 20
      BuildServer/lib/tasks/dotnetbuilderwrapper.js
  17. 2
      BuildServer/lib/tasks/dotnetbuildwithoutcleanup.js
  18. 18
      BuildServer/lib/tasks/dotnetcheckstyle.js
  19. 2
      BuildServer/lib/tasks/dotnetcompile.js
  20. 2
      BuildServer/lib/tasks/dotnetnugetpack.js
  21. 4
      BuildServer/lib/tasks/dotnetnugetprocess.js
  22. 2
      BuildServer/lib/tasks/dotnetnugetpush.js
  23. 4
      BuildServer/lib/tasks/dotnetnugetpushonly.js
  24. 4
      BuildServer/lib/tasks/dotnetnugetrestore.js
  25. 4
      BuildServer/lib/tasks/dotnetnunit.js
  26. 16
      BuildServer/lib/tasks/dotnetnunitall.js
  27. 4
      BuildServer/lib/tasks/dotnetpackwebapp.js
  28. 32
      BuildServer/lib/tasks/dotnetrewrite.js
  29. 8
      BuildServer/lib/tasks/echo.js
  30. 10
      BuildServer/lib/tasks/noop.js
  31. 14
      BuildServer/lib/tasks/parallel.js
  32. 6
      BuildServer/lib/tasks/sequential.js
  33. 10
      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. 24
      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(function (callback) { statusQueue.push((callback) => notifyStatus({
notifyStatus({
state: "pending", state: "pending",
description: "Preparing to build...", description: "Preparing to build...",
owner: owner, owner: owner,
reponame: reponame, reponame: reponame,
hash: rev hash: rev
}, callback); }, callback));
});
fse.mkdirsSync(release); fse.mkdirsSync(release);
@ -62,25 +58,21 @@ 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) {
notifyStatus({
state: err ? "error" : "success", state: err ? "error" : "success",
description: errorMessage || warnMessage || infoMessage || "Success", description: errorMessage || warnMessage || infoMessage || "Success",
owner: owner, owner: owner,
reponame: reponame, reponame: reponame,
hash: rev hash: rev
}, callback); }, callback),
}, (callback) => mailSender.send({
function (callback) {
mailSender.send({
from: settings.smtp.sender, from: settings.smtp.sender,
to: settings.smtp.receiver, to: settings.smtp.receiver,
subject: (err ? "Build failed for " : "Successfully built ") + owner + "/" + reponame + "/" + branch, subject: (err ? "Build failed for " : "Successfully built ") + owner + "/" + reponame + "/" + branch,
@ -89,18 +81,16 @@ const build = function (options, callback) {
}, },
text: ("Build status URL: " + settings.siteRoot + "status/" + owner + "/" + reponame + "/" + rev + "\r\n\r\n") + text: ("Build status URL: " + settings.siteRoot + "status/" + owner + "/" + reponame + "/" + rev + "\r\n\r\n") +
(err ? ("Error message: " + err + "\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")) ((!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),
}, (callback) => {
function (callback) {
if (err) { if (err) {
return process.nextTick(callback); return process.nextTick(callback);
} }
return fse.remove(tmp, callback); return fse.remove(tmp, callback);
} }
], 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,24 +1,21 @@
"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);
} }
@ -30,14 +27,12 @@ const closePullRequest = function (options, message, callback) {
state: "closed" state: "closed"
}, callback); }, callback);
}); });
};
const checkHasIssue = function (options, issueNumber, callback) { const checkHasIssue = (options, issueNumber, callback) => options.github.issues.getRepoIssue({
return options.github.issues.getRepoIssue({
user: options.baseRepoOptions.owner, user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame, repo: options.baseRepoOptions.reponame,
number: issueNumber number: issueNumber
}, function (err, result) { }, (err, result) => {
if (err && err.code !== 404) { if (err && err.code !== 404) {
return callback(err); return callback(err);
} }
@ -52,23 +47,20 @@ const checkHasIssue = function (options, issueNumber, callback) {
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
}, function (err, result) { }, (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,14 +148,11 @@ 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);
} }
@ -178,9 +167,9 @@ const getStatusMessageFromRelease = function (app, options, callback) {
} }
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) {
@ -190,18 +179,15 @@ const getStatusMessageFromRelease = function (app, options, callback) {
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,10 +18,9 @@ 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(function (err, subTree) { entry.getTree((err, subTree) => {
if (err) { if (err) {
return callback(err); return callback(err);
} }
@ -35,8 +34,7 @@ const gitToFsCopier = new Copier({
} else { } else {
callback(); callback();
} }
}; }), (err) => {
}), function (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,13 +38,11 @@ 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) .catch(globalCallback)
.then(function (remote) { .then((remote) => remote.fetch([options.branch])
remote.fetch([options.branch])
.catch(globalCallback) .catch(globalCallback)
.then(function (number) { .then((number) => {
if (number) { if (number) {
return globalCallback("Failed to fetch commit: error number " + number); return globalCallback("Failed to fetch commit: error number " + number);
} }
@ -53,16 +51,14 @@ module.exports = function (options, globalCallback) {
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,13 +2,11 @@
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 () {
glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
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();
@ -21,18 +19,14 @@ module.exports = function (params, processor) {
return processor.processTask({ return processor.processTask({
type: "parallel", type: "parallel",
params: { params: {
tasks: files.map(function (file) { tasks: files.map((file) => ({
return {
name: file, name: file,
type: "deletefromcode", type: "deletefromcode",
params: { params: {
filename: file 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,15 +2,14 @@
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 {
@ -19,5 +18,4 @@ module.exports = function (params, processor) {
return processor.done(); return processor.done();
}); });
} }
}; });
};

@ -2,13 +2,11 @@
const glob = require('glob'); const glob = require('glob');
module.exports = function (params, processor) { module.exports = (params, processor) => ({
return { process: () => glob(params.mask, {
process: function () {
glob(params.mask, {
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();
@ -21,18 +19,14 @@ module.exports = function (params, processor) {
return processor.processTask({ return processor.processTask({
type: "parallel", type: "parallel",
params: { params: {
tasks: files.map(function (file) { tasks: files.map((file) => ({
return {
name: file, name: file,
type: "copy", type: "copy",
params: { params: {
filename: file 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,8 +2,7 @@
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",
@ -16,4 +15,3 @@ module.exports = function (params, processor) {
} }
] ]
}, processor); }, processor);
};

@ -2,8 +2,7 @@
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",
@ -21,4 +20,3 @@ module.exports = function (params, processor) {
} }
] ]
}, processor); }, processor);
};

@ -3,22 +3,17 @@
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', function (data) { builder.stdout.on('data', (data) => result += data);
result += data; builder.stderr.on('data', (data) => error += data);
}); builder.on('exit', (code) => {
builder.stderr.on('data', function (data) {
error += data;
});
builder.on('exit', function (code) {
if (code !== 0) { if (code !== 0) {
error = "Return code is " + code + "\r\n" + error; error = "Return code is " + code + "\r\n" + error;
processor.onError(error); processor.onError(error);
@ -27,7 +22,7 @@ module.exports = function (params, processor) {
const report = JSON.parse(result); const report = JSON.parse(result);
const messages = report.Messages; const messages = report.Messages;
messages.forEach(function (message) { messages.forEach((message) => {
if (!message) { if (!message) {
return processor.onError("Message is null"); return processor.onError("Message is null");
} }
@ -49,5 +44,4 @@ module.exports = function (params, processor) {
builder.stdin.write(JSON.stringify(params)); builder.stdin.write(JSON.stringify(params));
builder.stdin.end(); 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,16 +8,15 @@ 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(); return processor.done();
} }
processor.context.dotnetcheckerDone = true; processor.context.dotnetcheckerDone = true;
glob("**/*.cs", {cwd: processor.context.exported}, function (err, files) { glob("**/*.cs", {cwd: processor.context.exported}, (err, files) => {
if (err) { if (err) {
processor.onError(err); processor.onError(err);
return processor.done(); return processor.done();
@ -30,9 +29,7 @@ module.exports = function (params, processor) {
return processor.done(); return processor.done();
} }
return async.parallel(files.map(function (file) { return async.parallel(files.map((file) => (callback) => fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, (err, data) => {
return function (callback) {
return fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, function (err, data) {
if (err) { if (err) {
processor.onError("Unable to check file " + file + ": " + err); processor.onError("Unable to check file " + file + ": " + err);
return callback(err); return callback(err);
@ -59,10 +56,7 @@ module.exports = function (params, processor) {
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,8 +2,7 @@
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: {
@ -29,4 +28,3 @@ module.exports = function (params, processor) {
} }
} }
}, processor); }, 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,8 +2,7 @@
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",
@ -15,4 +14,3 @@ module.exports = function (params, processor) {
} }
] ]
}, 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,9 +2,8 @@
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");
} }
@ -14,7 +13,7 @@ module.exports = function (params, processor) {
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();
@ -28,18 +27,15 @@ module.exports = function (params, processor) {
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,8 +9,7 @@ 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",
@ -46,4 +45,3 @@ module.exports = function (params, processor) {
} }
] ]
}, processor); }, processor);
};

@ -5,13 +5,10 @@ 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();
} }
@ -27,14 +24,11 @@ module.exports = function (params, processor) {
"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,
function (match, p1) { (match, p1) => "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")"
return "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")";
}
); );
} }
@ -44,9 +38,8 @@ module.exports = function (params, processor) {
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();
@ -59,23 +52,18 @@ module.exports = function (params, processor) {
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) {
return async.waterfall([
fs.readFile.bind(null, processor.context.exported + "/" + file, { encoding: "utf8" }), fs.readFile.bind(null, processor.context.exported + "/" + file, { encoding: "utf8" }),
processAssemblyInfo(file.toLowerCase().indexOf("assemblyinfo.cs") >= 0), processAssemblyInfo(file.toLowerCase().indexOf("assemblyinfo.cs") >= 0),
fs.writeFile.bind(null, processor.context.exported + "/" + file) fs.writeFile.bind(null, processor.context.exported + "/" + file)
], function (err) { ], (err) => {
if (err) { if (err) {
processor.onError("Unable to rewrite file " + file + ": " + err); processor.onError("Unable to rewrite file " + file + ": " + err);
} else { } else {
processor.onInfo("Rewritten file " + file); processor.onInfo("Rewritten file " + file);
} }
callback(err); callback(err);
}); })), processor.done.bind(processor));
};
}), processor.done.bind(processor));
}); });
} }
}; });
};

@ -1,8 +1,7 @@
"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);
} }
@ -17,5 +16,4 @@ module.exports = function (params, processor) {
processor.done(); 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,13 +2,12 @@
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 {
@ -17,5 +16,4 @@ module.exports = function (params, processor) {
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