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. 74
      BuildServer/lib/commenter.js
  4. 30
      BuildServer/lib/git/copy.js
  5. 22
      BuildServer/lib/git/loader.js
  6. 4
      BuildServer/lib/mail-sender.js
  7. 28
      BuildServer/lib/status-processor.js
  8. 40
      BuildServer/lib/task-processor.js
  9. 20
      BuildServer/lib/tasks/cleanupafterdotnetbuild.js
  10. 6
      BuildServer/lib/tasks/conditional.js
  11. 10
      BuildServer/lib/tasks/copy.js
  12. 20
      BuildServer/lib/tasks/copyglob.js
  13. 2
      BuildServer/lib/tasks/deletefromcode.js
  14. 6
      BuildServer/lib/tasks/dotnetbuild.js
  15. 6
      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. 6
      BuildServer/lib/tasks/dotnetnugetprocess.js
  22. 2
      BuildServer/lib/tasks/dotnetnugetpush.js
  23. 6
      BuildServer/lib/tasks/dotnetnugetpushonly.js
  24. 6
      BuildServer/lib/tasks/dotnetnugetrestore.js
  25. 6
      BuildServer/lib/tasks/dotnetnunit.js
  26. 16
      BuildServer/lib/tasks/dotnetnunitall.js
  27. 6
      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. 16
      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. 26
      BuildServer/routes/status.js

@ -34,9 +34,7 @@ if ('development' === app.get('env')) {
app.get('/', routes.index);
app.post('/github/postreceive', routes.postreceive);
app.get('/github/postreceive', function (req, res) {
res.send("Only automated POST requests are allowed for postreceive route");
});
app.get('/github/postreceive', (req, res) => res.send("Only automated POST requests are allowed for postreceive route"));
app.get('/manual', routes.manual.get);
app.post('/manual', routes.manual.post);
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('/artifact/:owner/:reponame/:branch/:rev/*', routes.artifact);
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
http.createServer(app).listen(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 = "";
const notifyStatus = function (options, callback) {
const notifyStatus = (options, callback) => {
const status = {
user: options.owner,
repo: options.reponame,
@ -20,7 +20,7 @@ const notifyStatus = function (options, callback) {
target_url: settings.siteRoot + "status/" + options.owner + "/" + options.reponame + "/" + options.hash,
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) {
console.log("Error while creating status: " + err);
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 owner = options.owner;
const reponame = options.reponame;
@ -41,20 +41,16 @@ const build = function (options, callback) {
const tmp = options.app.get('tmpcodepath') + "/" + rev.substr(0, 15);
const exported = tmp + codePostfix;
const release = options.app.get('releasepath') + "/" + owner + "/" + reponame + "/" + branch + "/" + rev;
const statusQueue = async.queue(function (task, callback) {
task(callback);
}, 1);
const actualGitLoader = skipGitLoader ? function(options, callback) { process.nextTick(callback); } : gitLoader;
const statusQueue = async.queue((task, callback) => task(callback), 1);
const actualGitLoader = skipGitLoader ? (options, callback) => process.nextTick(callback) : gitLoader;
statusQueue.push(function (callback) {
notifyStatus({
statusQueue.push((callback) => notifyStatus({
state: "pending",
description: "Preparing to build...",
owner: owner,
reponame: reponame,
hash: rev
}, callback);
});
}, callback));
fse.mkdirsSync(release);
@ -62,25 +58,21 @@ const build = function (options, callback) {
fse.mkdirsSync(options.app.get('releasepath') + "/" + owner + "/" + reponame + "/$revs");
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 warnMessage = result && result.warns ? ((result.warns.$allMessages || [])[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) {
statusQueue.push(function (callback) {
async.parallel([
function (callback) {
notifyStatus({
fs.writeFile(release + "/report.json", JSON.stringify({date: Date.now(), err: err, result: result}), (writeErr) => {
statusQueue.push((callback) => async.parallel([
(callback) => notifyStatus({
state: err ? "error" : "success",
description: errorMessage || warnMessage || infoMessage || "Success",
owner: owner,
reponame: reponame,
hash: rev
}, callback);
},
function (callback) {
mailSender.send({
}, callback),
(callback) => mailSender.send({
from: settings.smtp.sender,
to: settings.smtp.receiver,
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") +
(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) {
((!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) => {
if (err) {
return process.nextTick(callback);
}
return fse.remove(tmp, callback);
}
], callback);
});
], callback));
if (writeErr) {
return callback(writeErr);
@ -115,17 +105,17 @@ const build = function (options, callback) {
branch: branch,
hash: rev,
exported: tmp + codePostfix
}, function(err) {
}, (err) => {
if (err) {
console.log(err);
return done("Git fetch error: " + err);
}
console.log("Done loading from git");
fs.exists(exported + "/mbs.json", function (exists) {
fs.exists(exported + "/mbs.json", (exists) => {
if (!exists) {
return done(null, "MBSNotFound");
}
fs.readFile(exported + "/mbs.json", function (err, data) {
fs.readFile(exported + "/mbs.json", (err, data) => {
if (err) {
return done(err, "MBSUnableToRead");
}
@ -146,7 +136,7 @@ const build = function (options, callback) {
tmp: tmp,
exported: exported,
release: release
}, function (err, result) {
}, (err, result) => {
if (err) {
return done(err, result);
}

@ -1,24 +1,21 @@
"use strict";
const fs = require('fs');
const _ = require('underscore');
const settings = require('../settings');
const fs = require("fs");
const _ = require("underscore");
const settings = require("../settings");
const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/;
const versionNamePattern = /^v\d+(\.\d+)*$/;
const masterNamePattern = /^master$/;
const writeComment = function (options, message, callback) {
return options.github.issues.createComment({
const writeComment = (options, message, callback) => options.github.issues.createComment({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: options.number,
body: message
}, callback);
};
}, callback);
const closePullRequest = function (options, message, callback) {
return writeComment(options, message, function (err) {
const closePullRequest = (options, message, callback) => writeComment(options, message, (err) => {
if (err) {
return callback(err);
}
@ -29,15 +26,13 @@ const closePullRequest = function (options, message, callback) {
number: options.number,
state: "closed"
}, callback);
});
};
});
const checkHasIssue = function (options, issueNumber, callback) {
return options.github.issues.getRepoIssue({
const checkHasIssue = (options, issueNumber, callback) => options.github.issues.getRepoIssue({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: issueNumber
}, function (err, result) {
}, (err, result) => {
if (err && err.code !== 404) {
return callback(err);
}
@ -51,24 +46,21 @@ const checkHasIssue = function (options, issueNumber, callback) {
}
return callback(undefined, true, result.title);
});
};
});
const checkHasReleases = function (options, callback) {
return options.github.releases.listReleases({
const checkHasReleases = (options, callback) => options.github.releases.listReleases({
owner: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
per_page: 1
}, function (err, result) {
}, (err, result) => {
if (err) {
return callback(err);
}
return callback(undefined, result && result.length);
});
};
});
const checkPullRequest = function (options, callback) {
const checkPullRequest = (options, callback) => {
const head = options.headRepoOptions;
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 checkHasReleases(options, function (err, hasReleases) {
return checkHasReleases(options, (err, hasReleases) => {
if (err) {
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];
return checkHasIssue(options, issueNumber, function (err, hasIssue, issueTitle) {
return checkHasIssue(options, issueNumber, (err, hasIssue, issueTitle) => {
if (err) {
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);
return checkHasReleases(options, function (err, hasReleases) {
return checkHasReleases(options, (err, hasReleases) => {
if (err) {
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 releaseDir = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev;
const getStatusMessageFromRelease = (app, options, callback) => {
const releaseDir = app.get("releasepath") + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev;
const reportFile = releaseDir + "/report.json";
options.attemptsGetReport = (options.attemptsGetReport || 0) + 1;
fs.exists(reportFile, function (exists) {
fs.exists(reportFile, (exists) => {
if (!exists) {
return fs.exists(releaseDir, function (dirExists) {
return fs.exists(releaseDir, (dirExists) => {
if (!dirExists) {
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
return setTimeout(function () {
getStatusMessageFromRelease(app, options, callback);
}, 10000);
return setTimeout(() => getStatusMessageFromRelease(app, options, callback), 10000);
});
}
return setTimeout(function () {
return fs.readFile(reportFile, function (err, dataBuffer) {
return setTimeout(() => fs.readFile(reportFile, (err, dataBuffer) => {
if (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) {
return callback(_.map(
(report.result.errors || {}).$allMessages || [], function(message) { return "ERR: " + message.message; }
(report.result.errors || {}).$allMessages || [], (message) => "ERR: " + message.message
).concat(_.map(
(report.result.warns || {}).$allMessages || [], function(message) { return "WARN: " + message.message; }
(report.result.warns || {}).$allMessages || [], (message) => "WARN: " + message.message
)).join("\r\n"));
}
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, "OK");
});
}, 1000);
}), 1000);
});
};
exports.commentOnPullRequest = function (options, callback) {
exports.commentOnPullRequest = (options, callback) => {
options.github = settings.createGithub(options.baseRepoOptions.owner);
return checkPullRequest(options, function (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);
return checkPullRequest(options, (err, successMessage) => getStatusMessageFromRelease(options.app, options.headRepoOptions, (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 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);
});
});
}));
};

@ -8,9 +8,9 @@ const Copier = require('recursive-tree-copy').Copier;
const gitToFsCopier = new Copier({
concurrency: 4,
walkSourceTree: function (tree) {
walkSourceTree: (tree) => {
const emitter = new EventEmitter();
process.nextTick(function () {
process.nextTick(() => {
let entries;
try {
entries = tree.gitTree.entries();
@ -18,10 +18,9 @@ const gitToFsCopier = new Copier({
return emitter.emit('error', err);
}
async.parallel(entries.map(function (entry) {
return function (callback) {
async.parallel(entries.map((entry) => (callback) => {
if (entry.isTree()) {
entry.getTree(function (err, subTree) {
entry.getTree((err, subTree) => {
if (err) {
return callback(err);
}
@ -35,8 +34,7 @@ const gitToFsCopier = new Copier({
} else {
callback();
}
};
}), function (err) {
}), (err) => {
if (err) {
return emitter.emit('error', err);
}
@ -46,9 +44,9 @@ const gitToFsCopier = new Copier({
});
return emitter;
},
createTargetTree: function (tree, targetDir, callback) {
createTargetTree: (tree, targetDir, callback) => {
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 */) {
return callback(err);
}
@ -56,12 +54,10 @@ const gitToFsCopier = new Copier({
callback(undefined, targetSubdir);
});
},
finalizeTargetTree: function (targetSubdir, callback) {
callback();
},
copyLeaf: function (entry, targetDir, callback) {
finalizeTargetTree: (targetSubdir, callback) => callback(),
copyLeaf: (entry, targetDir, callback) => {
const targetPath = path.join(targetDir, entry.name());
entry.getBlob(function (err, blob) {
entry.getBlob((err, blob) => {
if (err) {
return callback(err);
}
@ -71,12 +67,10 @@ const gitToFsCopier = new Copier({
}
});
exports.gitToFs = function (commit, exportDir, callback) {
commit.getTree(function (err, tree) {
exports.gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => {
if (err) {
return callback(err);
}
gitToFsCopier.copy({ gitTree: tree, name: "." }, exportDir, callback);
});
};
});

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

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

@ -3,13 +3,13 @@
const fs = require('fs');
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";
fs.exists(branchFile, function (exists) {
fs.exists(branchFile, (exists) => {
if (!exists) {
return callback("BranchFileNotFound", options);
}
fs.readFile(branchFile, function (err, data) {
fs.readFile(branchFile, (err, data) => {
if (err) {
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";
fs.exists(revFile, function (exists) {
fs.exists(revFile, (exists) => {
if (!exists) {
return callback("RevFileNotFound", options);
}
fs.readFile(revFile, function (err, data) {
fs.readFile(revFile, (err, data) => {
if (err) {
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 = {};
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;
glob("**", {cwd: releaseDir, mark: true}, function (err, files) {
glob("**", {cwd: releaseDir, mark: true}, (err, files) => {
if (err) {
return callback(err, options);
}
const reportFile = releaseDir + "/report.json";
options.files = files;
fs.exists(reportFile, function (exists) {
fs.exists(reportFile, (exists) => {
if (!exists) {
return callback("ReportFileNotFound", options);
}
fs.readFile(reportFile, function (err, dataBuffer) {
fs.readFile(reportFile, (err, dataBuffer) => {
if (err) {
return callback(err, options);
}
@ -89,12 +89,10 @@ const loadReport = function (app, options, callback) {
});
};
exports.getReport = function (app, options, callback) {
parseOptions(app, options, function (err, result) {
exports.getReport = (app, options, callback) => parseOptions(app, options, (err, result) => {
if (err) {
return callback(err, {});
}
return loadReport(app, result, callback);
});
};
});

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

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

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

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

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

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

@ -2,8 +2,7 @@
const sequential = require('./sequential');
module.exports = function (params, processor) {
return sequential({
module.exports = (params, processor) => sequential({
tasks: [
{
type: "dotnetbuildwithoutcleanup",
@ -15,5 +14,4 @@ module.exports = function (params, processor) {
name: "cleanup"
}
]
}, processor);
};
}, processor);

@ -2,8 +2,7 @@
const sequential = require("./sequential");
module.exports = function (params, processor) {
return sequential({
module.exports = (params, processor) => sequential({
tasks: [
{
type: "dotnetbuildwithoutcleanup",
@ -20,5 +19,4 @@ module.exports = function (params, processor) {
name: "cleanup"
}
]
}, processor);
};
}, processor);

@ -3,22 +3,17 @@
const spawn = require('child_process').spawn;
const settings = require("../../settings");
module.exports = function (params, processor) {
return {
process: function () {
module.exports = (params, processor) => ({
process: () => {
let result = "";
let error = "";
const builder = spawn(settings.builderExecutable, [params.command]);
processor.onInfo("DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + "): " + JSON.stringify(params, null, 4));
builder.stdout.on('data', function (data) {
result += data;
});
builder.stderr.on('data', function (data) {
error += data;
});
builder.on('exit', function (code) {
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);
@ -27,7 +22,7 @@ module.exports = function (params, processor) {
const report = JSON.parse(result);
const messages = report.Messages;
messages.forEach(function (message) {
messages.forEach((message) => {
if (!message) {
return processor.onError("Message is null");
}
@ -49,5 +44,4 @@ module.exports = function (params, processor) {
builder.stdin.write(JSON.stringify(params));
builder.stdin.end();
}
};
};
});

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

@ -8,16 +8,15 @@ const autoGeneratedMarker =
"//------------------------------------------------------------------------------" + "\n" +
"// <auto-generated>";
module.exports = function (params, processor) {
return {
process: function () {
module.exports = (params, processor) => ({
process: () => {
if (processor.context.dotnetcheckerDone) {
return processor.done();
}
processor.context.dotnetcheckerDone = true;
glob("**/*.cs", {cwd: processor.context.exported}, function (err, files) {
glob("**/*.cs", {cwd: processor.context.exported}, (err, files) => {
if (err) {
processor.onError(err);
return processor.done();
@ -30,9 +29,7 @@ module.exports = function (params, processor) {
return processor.done();
}
return async.parallel(files.map(function (file) {
return function (callback) {
return fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, function (err, data) {
return async.parallel(files.map((file) => (callback) => fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, (err, data) => {
if (err) {
processor.onError("Unable to check file " + file + ": " + err);
return callback(err);
@ -59,10 +56,7 @@ module.exports = function (params, processor) {
processor.onInfo("Checked file " + file);
callback();
});
};
}), processor.done.bind(processor));
})), processor.done.bind(processor));
});
}
};
};
});

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

@ -2,7 +2,7 @@
const sequential = require('./sequential');
module.exports = function (params, processor) {
module.exports = (params, processor) => {
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)));

@ -2,8 +2,7 @@
const conditional = require('./conditional');
module.exports = function (params, processor) {
return conditional({
module.exports = (params, processor) => conditional({
owner: params.masterRepoOwner,
branch: "master",
task: {
@ -28,5 +27,4 @@ module.exports = function (params, processor) {
major: params.major
}
}
}, processor);
};
}, processor);

@ -2,7 +2,7 @@
const sequential = require("./sequential");
module.exports = function (params, processor) {
module.exports = (params, processor) => {
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 nupkg = params.name + "." + version + ".nupkg";

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

@ -2,8 +2,7 @@
const sequential = require('./sequential');
module.exports = function (params, processor) {
return sequential({
module.exports = (params, processor) => sequential({
tasks: [
{
type: "dotnetbuilderwrapper",
@ -14,5 +13,4 @@ module.exports = function (params, processor) {
}
}
]
}, processor);
};
}, processor);

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

@ -2,9 +2,8 @@
const glob = require('glob');
module.exports = function (params, processor) {
return {
process: function () {
module.exports = (params, processor) => ({
process: () => {
if (processor.context.dotnetnunitallDone) {
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", {
dot: true,
cwd: processor.context.exported
}, function (err, files) {
}, (err, files) => {
if (err) {
processor.onError(err);
return processor.done();
@ -28,18 +27,15 @@ module.exports = function (params, processor) {
return processor.processTask({
type: params.preventParallelTests ? "sequential" : "parallel",
params: {
tasks: files.map(function (file) {
return {
tasks: files.map((file) => ({
name: file,
type: "dotnetnunit",
params: {
assembly: file
}
};
})
}))
}
}, 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 versionTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.version.aspx", {encoding: "utf8"});
module.exports = function (params, processor) {
return sequential({
module.exports = (params, processor) => sequential({
tasks: [
{
type: "writefile",
@ -45,5 +44,4 @@ module.exports = function (params, processor) {
}
}
]
}, processor);
};
}, processor);

@ -5,13 +5,10 @@ const async = require('async');
const glob = require('glob');
const settings = require('../../settings');
const addAssemblyAttribute = function (content, attribute) {
return content + "\n" + attribute + "\n";
};
const addAssemblyAttribute = (content, attribute) => content + "\n" + attribute + "\n";
module.exports = function (params, processor) {
return {
process: function () {
module.exports = (params, processor) => ({
process: () => {
if (processor.context.dotnetrewriterDone) {
return processor.done();
}
@ -27,14 +24,11 @@ module.exports = function (params, processor) {
"repository: " + processor.context.owner + "/" + processor.context.reponame + "; " +
"branch: " + processor.context.branch;
const processAssemblyInfo = function (appendInformationalVersion) {
return function (content, cb) {
const processAssemblyInfo = (appendInformationalVersion) => (content, cb) => {
if (!params.skipCodeSigning && !settings.skipCodeSigning) {
content = content.replace(
/InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g,
function (match, p1) {
return "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")";
}
(match, p1) => "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")"
);
}
@ -44,9 +38,8 @@ module.exports = function (params, processor) {
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) {
processor.onError(err);
return processor.done();
@ -59,23 +52,18 @@ module.exports = function (params, processor) {
return processor.done();
}
return async.parallel(files.map(function (file) {
return function (callback) {
return async.waterfall([
return async.parallel(files.map((file) => (callback) => async.waterfall([
fs.readFile.bind(null, processor.context.exported + "/" + file, { encoding: "utf8" }),
processAssemblyInfo(file.toLowerCase().indexOf("assemblyinfo.cs") >= 0),
fs.writeFile.bind(null, processor.context.exported + "/" + file)
], function (err) {
], (err) => {
if (err) {
processor.onError("Unable to rewrite file " + file + ": " + err);
} else {
processor.onInfo("Rewritten file " + file);
}
callback(err);
});
};
}), processor.done.bind(processor));
})), processor.done.bind(processor));
});
}
};
};
});

@ -1,8 +1,7 @@
"use strict";
module.exports = function (params, processor) {
return {
process: function () {
module.exports = (params, processor) => ({
process: () => {
if (params.error) {
processor.onError(params.error);
}
@ -17,5 +16,4 @@ module.exports = function (params, processor) {
processor.done();
}
};
};
});

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

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

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

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

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

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

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

@ -3,7 +3,7 @@
const builder = require('../lib/builder');
const commenter = require('../lib/commenter');
const processPush = function (req, res, payload) {
const processPush = (req, res, payload) => {
const repository = payload.repository;
const options = {
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);
builder.build(options, function (err, result) {
builder.build(options, (err, result) => {
console.log("Done processing request from GitHub");
console.log("Error: " + err);
//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 number = payload.number;
const pullRequest = payload.pull_request;
@ -80,7 +80,7 @@ const processPullRequest = function (req, res, payload) {
commenter.commentOnPullRequest(
action === "closed" ? masterOptions : options,
function (err, data) {
(err, data) => {
if (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)) {
return res.end();
}

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

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

Loading…
Cancel
Save