ES6 arrow functions

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

@ -34,9 +34,7 @@ if ('development' === app.get('env')) {
app.get('/', routes.index);
app.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;
statusQueue.push(function (callback) {
notifyStatus({
state: "pending",
description: "Preparing to build...",
owner: owner,
reponame: reponame,
hash: rev
}, callback);
});
const statusQueue = async.queue((task, callback) => task(callback), 1);
const actualGitLoader = skipGitLoader ? (options, callback) => process.nextTick(callback) : gitLoader;
statusQueue.push((callback) => notifyStatus({
state: "pending",
description: "Preparing to build...",
owner: owner,
reponame: reponame,
hash: rev
}, callback));
fse.mkdirsSync(release);
@ -62,45 +58,39 @@ 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({
state: err ? "error" : "success",
description: errorMessage || warnMessage || infoMessage || "Success",
owner: owner,
reponame: reponame,
hash: rev
}, callback);
},
function (callback) {
mailSender.send({
from: settings.smtp.sender,
to: settings.smtp.receiver,
subject: (err ? "Build failed for " : "Successfully built ") + owner + "/" + reponame + "/" + branch,
headers: {
'X-Laziness-level': 1000
},
text: ("Build status URL: " + settings.siteRoot + "status/" + owner + "/" + reponame + "/" + rev + "\r\n\r\n") +
(err ? ("Error message: " + err + "\r\n\r\n") : "") +
((!result || !result.messages || !result.messages.$allMessages) ? JSON.stringify(result, null, 4) : result.messages.$allMessages.map(function (msg) { return msg.prefix + "\t" + msg.message; }).join("\r\n"))
}, callback);
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),
(callback) => mailSender.send({
from: settings.smtp.sender,
to: settings.smtp.receiver,
subject: (err ? "Build failed for " : "Successfully built ") + owner + "/" + reponame + "/" + branch,
headers: {
'X-Laziness-level': 1000
},
function (callback) {
if (err) {
return process.nextTick(callback);
}
return fse.remove(tmp, 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(msg => msg.prefix + "\t" + msg.message).join("\r\n"))
}, callback),
(callback) => {
if (err) {
return process.nextTick(callback);
}
], callback);
});
return fse.remove(tmp, 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,74 +1,66 @@
"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({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: options.number,
body: message
}, callback);
};
const writeComment = (options, message, callback) => options.github.issues.createComment({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: options.number,
body: message
}, callback);
const closePullRequest = function (options, message, callback) {
return writeComment(options, message, function (err) {
if (err) {
return callback(err);
}
return options.github.issues.edit({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: options.number,
state: "closed"
}, callback);
});
};
const closePullRequest = (options, message, callback) => writeComment(options, message, (err) => {
if (err) {
return callback(err);
}
const checkHasIssue = function (options, issueNumber, callback) {
return options.github.issues.getRepoIssue({
return options.github.issues.edit({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: issueNumber
}, function (err, result) {
if (err && err.code !== 404) {
return callback(err);
}
number: options.number,
state: "closed"
}, callback);
});
const checkHasIssue = (options, issueNumber, callback) => options.github.issues.getRepoIssue({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
number: issueNumber
}, (err, result) => {
if (err && err.code !== 404) {
return callback(err);
}
if (err || result.number.toString() !== issueNumber) {
return callback(undefined, false);
}
if (err || result.number.toString() !== issueNumber) {
return callback(undefined, false);
}
if (result.pull_request && result.pull_request.url) {
return callback(undefined, false);
}
if (result.pull_request && result.pull_request.url) {
return callback(undefined, false);
}
return callback(undefined, true, result.title);
});
};
return callback(undefined, true, result.title);
});
const checkHasReleases = function (options, callback) {
return options.github.releases.listReleases({
owner: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
per_page: 1
}, function (err, result) {
if (err) {
return callback(err);
}
const checkHasReleases = (options, callback) => options.github.releases.listReleases({
owner: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
per_page: 1
}, (err, result) => {
if (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 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,52 +148,46 @@ 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) {
if (err) {
return callback(err);
}
const data = dataBuffer.toString();
if (!data) {
return callback("Report file not found");
}
const report = JSON.parse(data);
return setTimeout(() => fs.readFile(reportFile, (err, dataBuffer) => {
if (err) {
return callback(err);
}
const data = dataBuffer.toString();
if (!data) {
return callback("Report file not found");
}
const report = JSON.parse(data);
if (report.result === "MBSNotFound") {
return callback("mbs.json is not found");
}
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; }
).concat(_.map(
(report.result.warns || {}).$allMessages || [], function(message) { return "WARN: " + message.message; }
)).join("\r\n"));
}
if (!report.result || report.err) {
return callback("CRITICAL ERROR: " + report.err);
}
if ((report.result.infos.$allMessages || []).length > 0) {
return callback(undefined, report.result.infos.$allMessages[report.result.infos.$allMessages.length-1].message);
}
return callback(undefined, "OK");
});
}, 1000);
if (report.result === "MBSNotFound") {
return callback("mbs.json is not found");
}
if (report.result && ((report.result.errors || {}).$allMessages || []).length + ((report.result.warns || {}).$allMessages || []).length > 0) {
return callback(_.map(
(report.result.errors || {}).$allMessages || [], (message) => "ERR: " + message.message
).concat(_.map(
(report.result.warns || {}).$allMessages || [], (message) => "WARN: " + message.message
)).join("\r\n"));
}
if (!report.result || report.err) {
return callback("CRITICAL ERROR: " + report.err);
}
if ((report.result.infos.$allMessages || []).length > 0) {
return callback(undefined, report.result.infos.$allMessages[report.result.infos.$allMessages.length-1].message);
}
return callback(undefined, "OK");
}), 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);
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 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,25 +18,23 @@ const gitToFsCopier = new Copier({
return emitter.emit('error', err);
}
async.parallel(entries.map(function (entry) {
return function (callback) {
if (entry.isTree()) {
entry.getTree(function (err, subTree) {
if (err) {
return callback(err);
}
async.parallel(entries.map((entry) => (callback) => {
if (entry.isTree()) {
entry.getTree((err, subTree) => {
if (err) {
return callback(err);
}
emitter.emit('tree', { gitTree: subTree, name: entry.name() });
callback();
});
} else if (entry.isFile()) {
emitter.emit('leaf', entry);
emitter.emit('tree', { gitTree: subTree, name: entry.name() });
callback();
} else {
callback();
}
};
}), function (err) {
});
} else if (entry.isFile()) {
emitter.emit('leaf', entry);
callback();
} else {
callback();
}
}), (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) {
if (err) {
return callback(err);
}
exports.gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => {
if (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 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,31 +38,27 @@ 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((remote) => remote.fetch([options.branch])
.catch(globalCallback)
.then(function (remote) {
remote.fetch([options.branch])
.catch(globalCallback)
.then(function (number) {
if (number) {
return globalCallback("Failed to fetch commit: error number " + number);
}
.then((number) => {
if (number) {
return globalCallback("Failed to fetch commit: error number " + number);
}
console.log("Cloned %s to %s", url, path);
console.log("Cloned %s to %s", url, path);
repo.getCommit(options.hash)
.catch(globalCallback)
.then(function (commit) {
removedirs(exported);
mkdirs(exported);
repo.getCommit(options.hash)
.catch(globalCallback)
.then((commit) => {
removedirs(exported);
mkdirs(exported);
gitToFs(commit, exported, function (err, result) {
repo.free();
return globalCallback(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) {
if (err) {
return callback(err, {});
}
exports.getReport = (app, options, callback) => parseOptions(app, options, (err, result) => {
if (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;
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, {
errors: errors,
warns: warns,
infos: infos,
messages: messages
});
});
}, (err) => callback(err, {
errors: errors,
warns: warns,
infos: infos,
messages: messages
}));
processor.process();
};

@ -2,37 +2,31 @@
const glob = require('glob');
module.exports = function (params, processor) {
return {
process: function () {
glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
dot: true,
cwd: processor.context.exported
}, function (err, files) {
if (err) {
processor.onError(err);
return processor.done();
}
module.exports = (params, processor) => ({
process: () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", {
dot: true,
cwd: processor.context.exported
}, (err, files) => {
if (err) {
processor.onError(err);
return processor.done();
}
if (!files || !files.length) {
return processor.done();
}
if (!files || !files.length) {
return processor.done();
}
return processor.processTask({
type: "parallel",
return processor.processTask({
type: "parallel",
params: {
tasks: files.map((file) => ({
name: file,
type: "deletefromcode",
params: {
tasks: files.map(function (file) {
return {
name: file,
type: "deletefromcode",
params: {
filename: file
}
};
})
filename: file
}
}, processor.done.bind(processor));
});
}
};
};
}))
}
}, 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,22 +2,20 @@
const fse = require('fs-extra');
module.exports = function (params, processor) {
return {
process: function () {
const sourceFilePath = processor.context.exported + "/" + params.filename;
const targetFilePath = processor.context.release + "/" + params.filename;
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);
processor.onInfo("Copying " + sourceFilePath + " to " + targetFilePath);
fse.copy(sourceFilePath, targetFilePath, function(err) {
if (err) {
processor.onError("Unable to copy file: " + err);
} else {
processor.onInfo("Copied file");
}
return processor.done();
});
}
};
};
fse.copy(sourceFilePath, targetFilePath, (err) => {
if (err) {
processor.onError("Unable to copy file: " + err);
} else {
processor.onInfo("Copied file");
}
return processor.done();
});
}
});

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

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

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

@ -3,51 +3,45 @@
const spawn = require('child_process').spawn;
const settings = require("../../settings");
module.exports = function (params, processor) {
return {
process: function () {
let result = "";
let error = "";
const builder = spawn(settings.builderExecutable, [params.command]);
processor.onInfo("DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + "): " + JSON.stringify(params, null, 4));
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', (data) => result += data);
builder.stderr.on('data', (data) => error += data);
builder.on('exit', (code) => {
if (code !== 0) {
error = "Return code is " + code + "\r\n" + error;
processor.onError(error);
return processor.done();
}
builder.stdout.on('data', function (data) {
result += data;
});
builder.stderr.on('data', function (data) {
error += data;
});
builder.on('exit', function (code) {
if (code !== 0) {
error = "Return code is " + code + "\r\n" + error;
processor.onError(error);
return processor.done();
const report = JSON.parse(result);
const messages = report.Messages;
messages.forEach((message) => {
if (!message) {
return processor.onError("Message is null");
}
const report = JSON.parse(result);
const messages = report.Messages;
messages.forEach(function (message) {
if (!message) {
return processor.onError("Message is null");
}
switch(message.Type) {
case "info":
return processor.onInfo(message.Body);
case "warn":
return processor.onWarn(message.Body);
default:
return processor.onError(message.Body);
}
});
processor.onInfo("Done DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + ")");
return processor.done();
switch(message.Type) {
case "info":
return processor.onInfo(message.Body);
case "warn":
return processor.onWarn(message.Body);
default:
return processor.onError(message.Body);
}
});
builder.stdin.write(JSON.stringify(params));
builder.stdin.end();
}
};
};
processor.onInfo("Done DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + ")");
return processor.done();
});
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,61 +8,55 @@ const autoGeneratedMarker =
"//------------------------------------------------------------------------------" + "\n" +
"// <auto-generated>";
module.exports = function (params, processor) {
return {
process: function () {
if (processor.context.dotnetcheckerDone) {
module.exports = (params, processor) => ({
process: () => {
if (processor.context.dotnetcheckerDone) {
return processor.done();
}
processor.context.dotnetcheckerDone = true;
glob("**/*.cs", {cwd: processor.context.exported}, (err, files) => {
if (err) {
processor.onError(err);
return processor.done();
}
processor.context.dotnetcheckerDone = true;
processor.onInfo("Found " + files.length + " .cs files");
glob("**/*.cs", {cwd: processor.context.exported}, function (err, files) {
if (!files || !files.length) {
processor.onWarn("No .cs files found");
return processor.done();
}
return async.parallel(files.map((file) => (callback) => fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, (err, data) => {
if (err) {
processor.onError(err);
return processor.done();
processor.onError("Unable to check file " + file + ": " + err);
return callback(err);
}
processor.onInfo("Found " + files.length + " .cs files");
if (!files || !files.length) {
processor.onWarn("No .cs files found");
return processor.done();
if (data.indexOf("\r\n") >= 0) {
processor.onError("Windows-style EOL (0D0A) found in file " + file);
return callback();
}
if (params.ignoreCodeStyle) {
return callback();
}
if (data.substr(1, autoGeneratedMarker.length) === autoGeneratedMarker || data.substr(0, autoGeneratedMarker.length) === autoGeneratedMarker) {
processor.onInfo("Skipping auto-generated file " + file);
return callback();
}
return async.parallel(files.map(function (file) {
return function (callback) {
return fs.readFile(processor.context.exported + "/" + file, { encoding: "utf8" }, function (err, data) {
if (err) {
processor.onError("Unable to check file " + file + ": " + err);
return callback(err);
}
if (data.indexOf("\r\n") >= 0) {
processor.onError("Windows-style EOL (0D0A) found in file " + file);
return callback();
}
if (params.ignoreCodeStyle) {
return callback();
}
if (data.substr(1, autoGeneratedMarker.length) === autoGeneratedMarker || data.substr(0, autoGeneratedMarker.length) === autoGeneratedMarker) {
processor.onInfo("Skipping auto-generated file " + file);
return callback();
}
if (data.indexOf("\t") >= 0 && data.indexOf(" ") >= 0) {
processor.onError("Both tabs and spaces found in file " + file);
}
if (data.indexOf("\t") >= 0 && data.indexOf(" ") >= 0) {
processor.onError("Both tabs and spaces found in file " + file);
}
if (data.indexOf("\t") >= 0) {
processor.onError("Tabs found in file " + file);
}
if (data.indexOf("\t") >= 0) {
processor.onError("Tabs found in file " + file);
}
processor.onInfo("Checked file " + file);
callback();
});
};
}), processor.done.bind(processor));
});
}
};
};
processor.onInfo("Checked file " + file);
callback();
})), 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,31 +2,29 @@
const conditional = require('./conditional');
module.exports = function (params, processor) {
return conditional({
owner: params.masterRepoOwner,
branch: "master",
task: {
name: "nuget-push",
type: "dotnetnugetpush",
params: {
nuspec: params.nuspecName + ".nuspec",
name: params.nuspecName,
withoutCommitSha: params.withoutCommitSha,
version: params.version,
major: params.major
}
},
otherwise: {
name: "nuget-pack",
type: "dotnetnugetpack",
params: {
nuspec: params.nuspecName + ".nuspec",
name: params.nuspecName,
withoutCommitSha: params.withoutCommitSha,
version: params.version,
major: params.major
}
module.exports = (params, processor) => conditional({
owner: params.masterRepoOwner,
branch: "master",
task: {
name: "nuget-push",
type: "dotnetnugetpush",
params: {
nuspec: params.nuspecName + ".nuspec",
name: params.nuspecName,
withoutCommitSha: params.withoutCommitSha,
version: params.version,
major: params.major
}
}, processor);
};
},
otherwise: {
name: "nuget-pack",
type: "dotnetnugetpack",
params: {
nuspec: params.nuspecName + ".nuspec",
name: params.nuspecName,
withoutCommitSha: params.withoutCommitSha,
version: params.version,
major: params.major
}
}
}, processor);

@ -2,7 +2,7 @@
const sequential = require("./sequential");
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({
command: "nugetpush",
Package: processor.context.exported + "/" + params.Package,
NugetHost: settings.nugetHost,
ApiKey: settings.nugetApiKey
}, processor);
};
module.exports = (params, processor) => dotnetbuilderwrapper({
command: "nugetpush",
Package: processor.context.exported + "/" + params.Package,
NugetHost: settings.nugetHost,
ApiKey: settings.nugetApiKey
}, processor);

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

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

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

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

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

@ -1,21 +1,19 @@
"use strict";
module.exports = function (params, processor) {
return {
process: function () {
if (params.error) {
processor.onError(params.error);
}
if (params.warn) {
processor.onWarn(params.warn);
}
module.exports = (params, processor) => ({
process: () => {
if (params.error) {
processor.onError(params.error);
}
if (params.info) {
processor.onInfo(params.info);
}
if (params.warn) {
processor.onWarn(params.warn);
}
processor.done();
if (params.info) {
processor.onInfo(params.info);
}
};
};
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,20 +2,18 @@
const fs = require('fs');
module.exports = function (params, processor) {
return {
process: function () {
const filePath = processor.context.exported + "/" + params.filename;
processor.onInfo("Writing to " + filePath);
module.exports = (params, processor) => ({
process: () => {
const filePath = processor.context.exported + "/" + params.filename;
processor.onInfo("Writing to " + filePath);
fs.writeFile(filePath, params.data, function(err) {
if (err) {
processor.onError("Unable to write file: " + err);
} else {
processor.onInfo("Written file");
}
return processor.done();
});
}
};
};
fs.writeFile(filePath, params.data, (err) => {
if (err) {
processor.onError("Unable to write file: " + err);
} else {
processor.onInfo("Written file");
}
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) {
options = options || {};
options.err = err;
res.render('status', 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) {
if (err) {
return createShowReport(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));
});
};
return statusProcessor.getReport(req.app, options, createShowReport(res));
});

Loading…
Cancel
Save