ES6 variables; code style

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent 1a9dfc7263
commit d058d8f93e
  1. 23
      BuildServer/app.js
  2. 67
      BuildServer/lib/builder.js
  3. 49
      BuildServer/lib/commenter.js
  4. 23
      BuildServer/lib/git/copy.js
  5. 30
      BuildServer/lib/git/loader.js
  6. 7
      BuildServer/lib/mail-sender.js
  7. 29
      BuildServer/lib/status-processor.js
  8. 124
      BuildServer/lib/task-processor.js
  9. 5
      BuildServer/lib/tasks/cleanupafterdotnetbuild.js
  10. 4
      BuildServer/lib/tasks/conditional.js
  11. 6
      BuildServer/lib/tasks/copy.js
  12. 3
      BuildServer/lib/tasks/copyglob.js
  13. 2
      BuildServer/lib/tasks/deletefromcode.js
  14. 2
      BuildServer/lib/tasks/dotnetbuild.js
  15. 3
      BuildServer/lib/tasks/dotnetbuildandtest.js
  16. 34
      BuildServer/lib/tasks/dotnetbuilderwrapper.js
  17. 4
      BuildServer/lib/tasks/dotnetbuildwithoutcleanup.js
  18. 8
      BuildServer/lib/tasks/dotnetcheckstyle.js
  19. 8
      BuildServer/lib/tasks/dotnetcompile.js
  20. 7
      BuildServer/lib/tasks/dotnetnugetpack.js
  21. 42
      BuildServer/lib/tasks/dotnetnugetprocess.js
  22. 9
      BuildServer/lib/tasks/dotnetnugetpush.js
  23. 5
      BuildServer/lib/tasks/dotnetnugetpushonly.js
  24. 2
      BuildServer/lib/tasks/dotnetnugetrestore.js
  25. 2
      BuildServer/lib/tasks/dotnetnunit.js
  26. 5
      BuildServer/lib/tasks/dotnetnunitall.js
  27. 13
      BuildServer/lib/tasks/dotnetpackwebapp.js
  28. 27
      BuildServer/lib/tasks/dotnetrewrite.js
  29. 6
      BuildServer/lib/tasks/parallel.js
  30. 4
      BuildServer/lib/tasks/sequential.js
  31. 6
      BuildServer/lib/tasks/writefile.js
  32. 2
      BuildServer/routes/artifact.js
  33. 7
      BuildServer/routes/index.js
  34. 4
      BuildServer/routes/manual.js
  35. 104
      BuildServer/routes/postreceive.js
  36. 34
      BuildServer/routes/release.js
  37. 27
      BuildServer/routes/status.js

@ -1,19 +1,16 @@
"use strict";
/**
* Module dependencies.
*/
var https = require('https');
var realFs = require('fs');
var fs = require('graceful-fs');
//const https = require('https');
const realFs = require('fs');
const fs = require('graceful-fs');
fs.gracefulify(realFs);
var express = require('express');
var routes = require('./routes');
var http = require('http');
var path = require('path');
const express = require('express');
const routes = require('./routes');
const http = require('http');
const path = require('path');
var app = express();
const app = express();
// all environments
app.set('port', process.env.PORT || 3000);
@ -31,7 +28,7 @@ app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
// development only
if ('development' == app.get('env')) {
if ('development' === app.get('env')) {
app.use(express.errorHandler());
}

@ -1,18 +1,18 @@
"use strict";
var fs = require('fs');
var fse = require('fs-extra');
var async = require('async');
var gitLoader = require('./git/loader');
var processor = require('./task-processor');
var mailSender = require('./mail-sender');
var settings = require('../settings');
//var codePostfix = "/code";
var codePostfix = "";
var notifyStatus = function (options, callback) {
var status = {
const fs = require('fs');
const fse = require('fs-extra');
const async = require('async');
const gitLoader = require('./git/loader');
const processor = require('./task-processor');
const mailSender = require('./mail-sender');
const settings = require('../settings');
//const codePostfix = "/code";
const codePostfix = "";
const notifyStatus = function (options, callback) {
const status = {
user: options.owner,
repo: options.reponame,
sha: options.hash,
@ -30,21 +30,21 @@ var notifyStatus = function (options, callback) {
});
};
var build = function (options, callback) {
var url = options.url,
owner = options.owner,
reponame = options.reponame,
rev = options.rev,
branch = options.branch,
skipGitLoader = options.skipGitLoader,
local = options.app.get('gitpath') + "/r/",
tmp = options.app.get('tmpcodepath') + "/" + rev.substr(0, 15),
exported = tmp + codePostfix,
release = options.app.get('releasepath') + "/" + owner + "/" + reponame + "/" + branch + "/" + rev,
statusQueue = async.queue(function (task, callback) {
task(callback);
}, 1),
actualGitLoader = skipGitLoader ? function(options, callback) { process.nextTick(callback); } : gitLoader;
const build = function (options, callback) {
const url = options.url;
const owner = options.owner;
const reponame = options.reponame;
const rev = options.rev;
const branch = options.branch;
const skipGitLoader = options.skipGitLoader;
const local = options.app.get('gitpath') + "/r/";
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({
@ -62,10 +62,10 @@ var 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);
var done = function (err, result) {
var errorMessage = result && result.errors ? ((result.errors.$allMessages || [])[0] || {}).message : err,
warnMessage = result && result.warns ? ((result.warns.$allMessages || [])[0] || {}).message : err,
infoMessage = result && result.infos ? ((result.infos.$allMessages || []).slice(-1)[0] || {}).message : err;
const done = function (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) {
@ -80,7 +80,6 @@ var build = function (options, callback) {
}, callback);
},
function (callback) {
return process.nextTick(callback);
mailSender.send({
from: settings.smtp.sender,
to: settings.smtp.receiver,
@ -131,7 +130,7 @@ var build = function (options, callback) {
return done(err, "MBSUnableToRead");
}
var task;
let task;
try {
task = JSON.parse(data);
} catch(ex) {

@ -1,15 +1,14 @@
"use strict";
var fs = require('fs'),
_ = require('underscore'),
builder = require('../lib/builder'),
settings = require('../settings');
const fs = require('fs');
const _ = require('underscore');
const settings = require('../settings');
var featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/;
var versionNamePattern = /^v\d+(\.\d+)*$/;
var masterNamePattern = /^master$/;
const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/;
const versionNamePattern = /^v\d+(\.\d+)*$/;
const masterNamePattern = /^master$/;
var writeComment = function (options, message, callback) {
const writeComment = function (options, message, callback) {
return options.github.issues.createComment({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
@ -18,7 +17,7 @@ var writeComment = function (options, message, callback) {
}, callback);
};
var closePullRequest = function (options, message, callback) {
const closePullRequest = function (options, message, callback) {
return writeComment(options, message, function (err) {
if (err) {
return callback(err);
@ -33,7 +32,7 @@ var closePullRequest = function (options, message, callback) {
});
};
var checkHasIssue = function (options, issueNumber, callback) {
const checkHasIssue = function (options, issueNumber, callback) {
return options.github.issues.getRepoIssue({
user: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
@ -55,7 +54,7 @@ var checkHasIssue = function (options, issueNumber, callback) {
});
};
var checkHasReleases = function (options, callback) {
const checkHasReleases = function (options, callback) {
return options.github.releases.listReleases({
owner: options.baseRepoOptions.owner,
repo: options.baseRepoOptions.reponame,
@ -69,9 +68,9 @@ var checkHasReleases = function (options, callback) {
});
};
var checkPullRequest = function (options, callback) {
var head = options.headRepoOptions,
base = options.baseRepoOptions;
const checkPullRequest = function (options, callback) {
const head = options.headRepoOptions;
const base = options.baseRepoOptions;
if (head.reponame !== base.reponame) {
return closePullRequest(options, "Base and head repository names should match", callback);
@ -107,7 +106,7 @@ var checkPullRequest = function (options, callback) {
return closePullRequest(options, "Only merging to master or version branch is allowed; merging to '" + base.branchname + "' is not supported", callback);
}
var issueNumber = featureNamePattern.exec(head.branchname)[1];
const issueNumber = featureNamePattern.exec(head.branchname)[1];
return checkHasIssue(options, issueNumber, function (err, hasIssue, issueTitle) {
if (err) {
return writeComment(options, "Unable to check for issue:\r\n\r\n" + err.message, callback);
@ -117,7 +116,7 @@ var checkPullRequest = function (options, callback) {
return closePullRequest(options, "Unable to find issue #" + issueNumber, callback);
}
var shouldHaveReleases = versionNamePattern.test(base.branchname);
const shouldHaveReleases = versionNamePattern.test(base.branchname);
return checkHasReleases(options, function (err, hasReleases) {
if (err) {
return writeComment(options, "Unable to check for releases", callback);
@ -140,9 +139,9 @@ var checkPullRequest = function (options, callback) {
});
};
var getStatusMessageFromRelease = function (app, options, callback) {
var releaseDir = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev,
reportFile = releaseDir + "/report.json";
const getStatusMessageFromRelease = function (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;
@ -168,20 +167,20 @@ var getStatusMessageFromRelease = function (app, options, callback) {
if (err) {
return callback(err);
}
var data = dataBuffer.toString();
const data = dataBuffer.toString();
if (!data) {
return callback("Report file not found");
}
var report = JSON.parse(data);
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 }
(report.result.errors || {}).$allMessages || [], function(message) { return "ERR: " + message.message; }
).concat(_.map(
(report.result.warns || {}).$allMessages || [], function(message) { return "WARN: " + message.message }
(report.result.warns || {}).$allMessages || [], function(message) { return "WARN: " + message.message; }
)).join("\r\n"));
}
if (!report.result || report.err) {
@ -200,8 +199,8 @@ exports.commentOnPullRequest = function (options, callback) {
options.github = settings.createGithub(options.baseRepoOptions.owner);
return checkPullRequest(options, function (err, successMessage) {
getStatusMessageFromRelease(options.app, options.headRepoOptions, function (err, successMessage) {
var 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),
statusUrlMessage = "Build status URL: " + settings.siteRoot + "status/" + options.headRepoOptions.owner + "/" + options.headRepoOptions.reponame + "/" + options.headRepoOptions.rev + "\r\n\r\n";
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);
});
});

@ -1,18 +1,17 @@
"use strict";
var EventEmitter = require('events').EventEmitter,
path = require('path'),
fs = require('fs'),
nodegit = require('nodegit'),
async = require('async'),
Copier = require('recursive-tree-copy').Copier;
const EventEmitter = require('events').EventEmitter;
const path = require('path');
const fs = require('fs');
const async = require('async');
const Copier = require('recursive-tree-copy').Copier;
var gitToFsCopier = new Copier({
const gitToFsCopier = new Copier({
concurrency: 4,
walkSourceTree: function (tree) {
var emitter = new EventEmitter();
const emitter = new EventEmitter();
process.nextTick(function () {
var entries;
let entries;
try {
entries = tree.gitTree.entries();
} catch(err) {
@ -48,9 +47,9 @@ var gitToFsCopier = new Copier({
return emitter;
},
createTargetTree: function (tree, targetDir, callback) {
var targetSubdir = path.join(targetDir, tree.name);
const targetSubdir = path.join(targetDir, tree.name);
fs.mkdir(targetSubdir, function (err) {
if (err && err.code != 'EEXIST' /* workaround for broken trees */) {
if (err && err.code !== 'EEXIST' /* workaround for broken trees */) {
return callback(err);
}
@ -61,7 +60,7 @@ var gitToFsCopier = new Copier({
callback();
},
copyLeaf: function (entry, targetDir, callback) {
var targetPath = path.join(targetDir, entry.name());
const targetPath = path.join(targetDir, entry.name());
entry.getBlob(function (err, blob) {
if (err) {
return callback(err);

@ -1,16 +1,16 @@
"use strict";
var nodegit = require('nodegit'),
fse = require('fs-extra'),
gitToFs = require('./copy').gitToFs,
mkdirs = function (path) {
/*jslint stupid: true */
fse.mkdirsSync(path);
},
removedirs = function (path) {
/*jslint stupid: true */
fse.removeSync(path);
};
const nodegit = require('nodegit');
const fse = require('fs-extra');
const gitToFs = require('./copy').gitToFs;
const mkdirs = function (path) {
/*jslint stupid: true */
fse.mkdirsSync(path);
};
const removedirs = function (path) {
/*jslint stupid: true */
fse.removeSync(path);
};
/*
options = {
@ -23,14 +23,14 @@ options = {
*/
module.exports = function (options, globalCallback) {
var url = options.remote,
path = options.local + "/" + options.hash,
exported = options.exported;
let url = options.remote;
const path = options.local + "/" + options.hash;
const exported = options.exported;
removedirs(path);
mkdirs(path);
if (url.substr(0, 8) == "https://") {
if (url.substr(0, 8) === "https://") {
url = "git://" + url.substr(8);
}

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

@ -1,11 +1,10 @@
"use strict";
var fs = require('fs'),
url = require('url'),
glob = require('glob');
const fs = require('fs');
const glob = require('glob');
var addBranchInfo = function (app, options, callback) {
var branchFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/$revs/" + options.rev + ".branch";
const addBranchInfo = function (app, options, callback) {
const branchFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/$revs/" + options.rev + ".branch";
fs.exists(branchFile, function (exists) {
if (!exists) {
return callback("BranchFileNotFound", options);
@ -21,8 +20,8 @@ var addBranchInfo = function (app, options, callback) {
});
};
var addRevInfo = function (app, options, callback) {
var revFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/latest.id";
const addRevInfo = function (app, options, callback) {
const revFile = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/latest.id";
fs.exists(revFile, function (exists) {
if (!exists) {
return callback("RevFileNotFound", options);
@ -37,13 +36,13 @@ var addRevInfo = function (app, options, callback) {
});
};
var parseOptions = function (app, options, callback) {
var result = {};
const parseOptions = function (app, options, callback) {
const result = {};
result.owner = options.owner;
result.reponame = options.reponame;
if (options.rev && !/^[\da-f]{40}$/i.test(options.rev)) {
if (options.rev && !(/^[\da-f]{40}$/i).test(options.rev)) {
return callback("Wrong rev format: " + options.rev, options);
}
@ -60,15 +59,15 @@ var parseOptions = function (app, options, callback) {
}
};
var loadReport = function (app, options, callback) {
var releaseDir = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev;
const loadReport = function (app, options, callback) {
const releaseDir = app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev;
glob("**", {cwd: releaseDir, mark: true}, function (err, files) {
if (err) {
return callback(err, options);
}
var reportFile = releaseDir + "/report.json";
const reportFile = releaseDir + "/report.json";
options.files = files;
fs.exists(reportFile, function (exists) {
if (!exists) {
@ -79,7 +78,7 @@ var loadReport = function (app, options, callback) {
if (err) {
return callback(err, options);
}
var data = dataBuffer.toString();
const data = dataBuffer.toString();
if (!data) {
return callback("ReportFileNotFound", options);
}
@ -98,4 +97,4 @@ exports.getReport = function (app, options, callback) {
return loadReport(app, result, callback);
});
}
};

@ -1,38 +1,37 @@
"use strict";
//TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here.
var TaskProcessor = function (task, outerProcessor, callback) {
const TaskProcessor = function (task, outerProcessor, callback) {
if (!this) {
return new TaskProcessor(task);
}
var self = this,
taskImpl,
taskWorker,
errors = [],
process = function () {
taskWorker.process();
},
getOuterPrefix = function (prefix) {
return (task.name && prefix) ? (task.name + "/" + prefix) : (task.name || "") + (prefix || "");
},
onError = function (message, prefix) {
errors.push(message);
outerProcessor.onError(message, getOuterPrefix(prefix));
},
onWarn = function (message, prefix) {
outerProcessor.onWarn(message, getOuterPrefix(prefix));
},
onInfo = function (message, prefix) {
outerProcessor.onInfo(message, getOuterPrefix(prefix));
},
processTask = function (innerTask, innerCallback) {
var innerProcessor = new TaskProcessor(innerTask, self, innerCallback);
innerProcessor.process();
},
done = function () {
callback(errors.join("\r\n"));
};
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) {
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 innerProcessor = new TaskProcessor(innerTask, self, innerCallback);
innerProcessor.process();
};
const done = function () {
callback(errors.join("\r\n"));
};
self.process = process;
self.onError = onError;
@ -42,50 +41,49 @@ var TaskProcessor = function (task, outerProcessor, callback) {
self.done = done;
self.context = outerProcessor.context;
taskImpl = require('./tasks/' + task.type.match(/[\w\-]/g).join(""));
const taskImpl = require('./tasks/' + task.type.match(/[\w\-]/g).join(""));
taskWorker = taskImpl(task.params || {}, self);
};
exports.processTask = function (task, context, callback) {
var errors = {},
warns = {},
infos = {},
messages = {},
messageProcessor = function (list) {
var f = function (list, message, prefix) {
var i,
parts = prefix.split("/"),
innerList = list;
const errors = {};
const warns = {};
const infos = {};
const messages = {};
const messageProcessor = function (list) {
const f = function (list, message, prefix) {
const parts = prefix.split("/");
let innerList = list;
for (i = 0; i < parts.length; i += 1) {
innerList = (innerList[parts[i]] = innerList[parts[i]] || {});
}
parts.forEach(function (part) {
innerList = (innerList[part] = innerList[part] || {});
});
innerList.$messages = innerList.$messages || [];
innerList.$messages.push(message);
innerList.$messages = innerList.$messages || [];
innerList.$messages.push(message);
list.$allMessages = list.$allMessages || [];
list.$allMessages.push({ prefix: prefix, message: message });
};
list.$allMessages = list.$allMessages || [];
list.$allMessages.push({ prefix: prefix, message: message });
};
return function (message, prefix) {
f(list, message, prefix);
f(messages, message, prefix);
};
},
processor = new TaskProcessor(task, {
onError: messageProcessor(errors),
onWarn: messageProcessor(warns),
onInfo: messageProcessor(infos),
context: context
}, function (err) {
callback(err, {
errors: errors,
warns: warns,
infos: infos,
messages: messages
});
return function (message, prefix) {
f(list, message, prefix);
f(messages, message, prefix);
};
};
const processor = new TaskProcessor(task, {
onError: messageProcessor(errors),
onWarn: messageProcessor(warns),
onInfo: messageProcessor(infos),
context: context
}, function (err) {
callback(err, {
errors: errors,
warns: warns,
infos: infos,
messages: messages
});
});
processor.process();
};

@ -1,7 +1,6 @@
"use strict";
var glob = require('glob');
var deleteFromCode = require('./deletefromcode');
const glob = require('glob');
module.exports = function (params, processor) {
return {
@ -33,7 +32,7 @@ module.exports = function (params, processor) {
})
}
}, processor.done.bind(processor));
})
});
}
};
};

@ -1,8 +1,8 @@
"use strict";
module.exports = function (params, processor) {
var condition = (!params.owner || params.owner === processor.context.owner) && (!params.branch || params.branch === processor.context.branch || "refs/heads/" + params.branch === processor.context.branch),
task = condition ? params.task : params.otherwise;
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 () {

@ -1,12 +1,12 @@
"use strict";
var fse = require('fs-extra');
const fse = require('fs-extra');
module.exports = function (params, processor) {
return {
process: function () {
var sourceFilePath = processor.context.exported + "/" + params.filename,
targetFilePath = processor.context.release + "/" + params.filename;
const sourceFilePath = processor.context.exported + "/" + params.filename;
const targetFilePath = processor.context.release + "/" + params.filename;
processor.onInfo("Copying " + sourceFilePath + " to " + targetFilePath);

@ -1,7 +1,6 @@
"use strict";
var fse = require('fs-extra');
var glob = require('glob');
const glob = require('glob');
module.exports = function (params, processor) {
return {

@ -1,6 +1,6 @@
"use strict";
var fse = require('fs-extra');
const fse = require('fs-extra');
module.exports = function (params, processor) {
return {

@ -1,6 +1,6 @@
"use strict";
var sequential = require('./sequential');
const sequential = require('./sequential');
module.exports = function (params, processor) {
return sequential({

@ -1,7 +1,6 @@
"use strict";
var sequential = require("./sequential");
var settings = require("../../settings");
const sequential = require("./sequential");
module.exports = function (params, processor) {
return sequential({

@ -1,14 +1,14 @@
"use strict";
var spawn = require('child_process').spawn;
var settings = require("../../settings");
const spawn = require('child_process').spawn;
const settings = require("../../settings");
module.exports = function (params, processor) {
return {
process: function () {
var result = "",
error = "",
builder = spawn(settings.builderExecutable, [params.command]);
let result = "";
let error = "";
const builder = spawn(settings.builderExecutable, [params.command]);
processor.onInfo("DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + "): " + JSON.stringify(params, null, 4));
@ -25,26 +25,22 @@ module.exports = function (params, processor) {
return processor.done();
}
var report = JSON.parse(result);
var messages = report.Messages;
for (var i = 0; i < messages.length; i++) {
if (!messages[i]) {
processor.onError("Message is null");
continue;
const report = JSON.parse(result);
const messages = report.Messages;
messages.forEach(function (message) {
if (!message) {
return processor.onError("Message is null");
}
switch(messages[i].Type) {
switch(message.Type) {
case "info":
processor.onInfo(messages[i].Body);
break;
return processor.onInfo(message.Body);
case "warn":
processor.onWarn(messages[i].Body);
break;
return processor.onWarn(message.Body);
default:
processor.onError(messages[i].Body);
break;
return processor.onError(message.Body);
}
}
});
processor.onInfo("Done DotNetBuilderWrapper processing (at " + (new Date().toISOString()) + ")");
return processor.done();

@ -1,9 +1,9 @@
"use strict";
var sequential = require('./sequential');
const sequential = require('./sequential');
module.exports = function (params, processor) {
var tasks = [];
let tasks = [];
if (!params.skipMbsCheckStyle) {
tasks.push({

@ -1,10 +1,10 @@
"use strict";
var fs = require('fs');
var async = require('async');
var glob = require('glob');
const fs = require('fs');
const async = require('async');
const glob = require('glob');
var autoGeneratedMarker =
const autoGeneratedMarker =
"//------------------------------------------------------------------------------" + "\n" +
"// <auto-generated>";

@ -1,10 +1,10 @@
"use strict";
var settings = require('../../settings');
var dotnetbuilderwrapper = require('./dotnetbuilderwrapper');
const settings = require('../../settings');
const dotnetbuilderwrapper = require('./dotnetbuilderwrapper');
module.exports = function (params, processor) {
var compileParams = {
const compileParams = {
command: "compile",
SolutionPath: processor.context.exported + "/" + params.solution,
Configuration: params.configuration,
@ -30,4 +30,4 @@ module.exports = function (params, processor) {
}
}
return dotnetbuilderwrapper(compileParams, processor);
}
};

@ -1,11 +1,10 @@
"use strict";
var sequential = require('./sequential');
const sequential = require('./sequential');
module.exports = function (params, processor) {
var date = new Date(),
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))),
nupkg = processor.context.exported + "/" + params.name + "." + version + ".nupkg";
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)));
return sequential({
tasks: [

@ -1,31 +1,31 @@
"use strict";
var conditional = require('./conditional');
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
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
otherwise: {
name: "nuget-pack",
type: "dotnetnugetpack",
params: {
nuspec: params.nuspecName + ".nuspec",
name: params.nuspecName,
withoutCommitSha: params.withoutCommitSha,
version: params.version,
major: params.major
}
}
}, processor);

@ -1,12 +1,11 @@
"use strict";
var sequential = require("./sequential");
var settings = require("../../settings");
const sequential = require("./sequential");
module.exports = function (params, processor) {
var date = new Date(),
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))),
nupkg = params.name + "." + version + ".nupkg";
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";
return sequential({
tasks: [

@ -1,8 +1,7 @@
"use strict";
var sequential = require("./sequential");
var dotnetbuilderwrapper = require('./dotnetbuilderwrapper');
var settings = require("../../settings");
const dotnetbuilderwrapper = require('./dotnetbuilderwrapper');
const settings = require("../../settings");
module.exports = function (params, processor) {
return dotnetbuilderwrapper({

@ -1,6 +1,6 @@
"use strict";
var sequential = require('./sequential');
const sequential = require('./sequential');
module.exports = function (params, processor) {
return sequential({

@ -1,6 +1,6 @@
"use strict";
var dotNetBuilderWrapper = require('./dotnetbuilderwrapper');
const dotNetBuilderWrapper = require('./dotnetbuilderwrapper');
module.exports = function (params, processor) {
return dotNetBuilderWrapper({

@ -1,7 +1,6 @@
"use strict";
var glob = require('glob');
var dotNetBuilderWrapper = require('./dotnetbuilderwrapper');
const glob = require('glob');
module.exports = function (params, processor) {
return {
@ -40,7 +39,7 @@ module.exports = function (params, processor) {
})
}
}, processor.done.bind(processor));
})
});
}
};
};

@ -1,16 +1,15 @@
"use strict";
var fs = require('fs'),
Mustache = require('mustache');
const fs = require('fs');
const Mustache = require('mustache');
var sequential = require('./sequential');
const sequential = require('./sequential');
var msbuildTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.msbuild", {encoding: "utf8"});
var deployTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.bat", {encoding: "utf8"});
var versionTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.version.aspx", {encoding: "utf8"});
const msbuildTemplate = fs.readFileSync(__dirname + "/dotnetpackwebapp.template.msbuild", {encoding: "utf8"});
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: [
{

@ -1,13 +1,13 @@
"use strict";
var fs = require('fs');
var async = require('async');
var glob = require('glob');
var settings = require('../../settings');
const fs = require('fs');
const async = require('async');
const glob = require('glob');
const settings = require('../../settings');
var addAssemblyAttribute = function (content, attribute) {
const addAssemblyAttribute = function (content, attribute) {
return content + "\n" + attribute + "\n";
}
};
module.exports = function (params, processor) {
return {
@ -18,19 +18,20 @@ module.exports = function (params, processor) {
processor.context.dotnetrewriterDone = true;
var date = new Date(),
version = date.getFullYear() + "." +
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,
processAssemblyInfo = function (appendInformationalVersion) {
"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,
/InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g,
function (match, p1) {
return "InternalsVisibleTo(\"" + p1 + ",PublicKey=" + settings.codeSigningPublicKey + "\")";
}
@ -72,9 +73,9 @@ module.exports = function (params, processor) {
}
callback(err);
});
}
};
}), processor.done.bind(processor));
})
});
}
};
};

@ -1,6 +1,6 @@
"use strict";
var async = require("async");
const async = require("async");
module.exports = function (params, processor) {
return {
@ -9,8 +9,8 @@ module.exports = function (params, processor) {
return function (callback) {
return processor.processTask(task, function (err) {
return callback();
})
}
});
};
}), processor.done.bind(processor));
}
};

@ -1,9 +1,9 @@
"use strict";
var async = require("async");
const async = require("async");
module.exports = function (params, processor) {
var mapper = Function.bind.bind(processor.processTask, 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));

@ -1,13 +1,11 @@
"use strict";
var fs = require('fs');
var async = require('async');
var glob = require('glob');
const fs = require('fs');
module.exports = function (params, processor) {
return {
process: function () {
var filePath = processor.context.exported + "/" + params.filename;
const filePath = processor.context.exported + "/" + params.filename;
processor.onInfo("Writing to " + filePath);
fs.writeFile(filePath, params.data, function(err) {

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

@ -1,10 +1,7 @@
/*
* GET home page.
*/
"use strict";
exports.index = function(req, res){
res.render('index', { title: 'Express' + req + "qq" });
res.render('index', { title: 'Express' + req + "qq" });
};
exports.postreceive = require('./postreceive');

@ -1,4 +1,6 @@
var builder = require('../lib/builder');
"use strict";
const builder = require('../lib/builder');
exports.get = function (req, res) {
res.render('manual');

@ -1,22 +1,18 @@
"use strict";
var builder = require('../lib/builder'),
commenter = require('../lib/commenter');
/*
* POST from github
*/
var processPush = function (req, res, payload) {
var repository = payload.repository,
options = {
app: req.app,
url: repository.url,
owner: repository.owner.name,
reponame: repository.name,
rev: payload.after,
branch: payload.ref
};
const builder = require('../lib/builder');
const commenter = require('../lib/commenter');
const processPush = function (req, res, payload) {
const repository = payload.repository;
const options = {
app: req.app,
url: repository.url,
owner: repository.owner.name,
reponame: repository.name,
rev: payload.after,
branch: payload.ref
};
console.log("Got push event for " + options.owner + "/" + options.reponame + ":" + options.branch);
@ -29,41 +25,41 @@ var processPush = function (req, res, payload) {
});
};
var processPullRequest = function (req, res, payload) {
var action = payload.action,
number = payload.number,
pullRequest = payload.pull_request,
head = pullRequest.head,
headRepo = head.repo,
headRepoOptions = {
url: headRepo.url,
owner: headRepo.owner.name || headRepo.owner.login,
reponame: headRepo.name,
rev: head.sha,
branchname: head.ref,
branch: "refs/heads/" + head.ref
},
base = pullRequest.base,
baseRepo = base.repo,
baseRepoOptions = {
owner: baseRepo.owner.name || baseRepo.owner.login,
reponame: baseRepo.name,
branchname: base.ref
},
options = {
app: req.app,
action: action,
number: number,
headRepoOptions: headRepoOptions,
baseRepoOptions: baseRepoOptions
},
masterOptions = {
app: req.app,
action: action,
number: number,
headRepoOptions: baseRepoOptions,
baseRepoOptions: baseRepoOptions
};
const processPullRequest = function (req, res, payload) {
const action = payload.action;
const number = payload.number;
const pullRequest = payload.pull_request;
const head = pullRequest.head;
const headRepo = head.repo;
const headRepoOptions = {
url: headRepo.url,
owner: headRepo.owner.name || headRepo.owner.login,
reponame: headRepo.name,
rev: head.sha,
branchname: head.ref,
branch: "refs/heads/" + head.ref
};
const base = pullRequest.base;
const baseRepo = base.repo;
const baseRepoOptions = {
owner: baseRepo.owner.name || baseRepo.owner.login,
reponame: baseRepo.name,
branchname: base.ref
};
const options = {
app: req.app,
action: action,
number: number,
headRepoOptions: headRepoOptions,
baseRepoOptions: baseRepoOptions
};
const masterOptions = {
app: req.app,
action: action,
number: number,
headRepoOptions: baseRepoOptions,
baseRepoOptions: baseRepoOptions
};
console.log("Got pull request " + action + " event, from " + headRepoOptions.owner + "/" + headRepoOptions.reponame + ":" + headRepoOptions.branchname + " (" + headRepoOptions.rev + ") to " + baseRepoOptions.owner + "/" + baseRepoOptions.reponame + ":" + baseRepoOptions.branchname);
@ -99,8 +95,8 @@ module.exports = function (req, res) {
return res.end();
}
var eventType = req.header("x-github-event"),
payload = req.body.payload ? JSON.parse(req.body.payload || "{}") : req.body;
const eventType = req.header("x-github-event");
const payload = req.body.payload ? JSON.parse(req.body.payload || "{}") : req.body;
if (eventType === "push") {
return processPush(req, res, payload);

@ -1,11 +1,11 @@
"use strict";
var path = require('path'),
fs = require('fs'),
Zip = require('adm-zip');
const path = require('path');
const fs = require('fs');
const Zip = require('adm-zip');
var getReport = function(releasePath, callback) {
var reportFile = releasePath + "report.json";
const getReport = function(releasePath, callback) {
const reportFile = releasePath + "report.json";
fs.exists(reportFile, function (exists) {
if (!exists) {
@ -14,27 +14,27 @@ var getReport = function(releasePath, callback) {
return fs.readFile(reportFile, function (err, dataBuffer) {
if (err) {
return callback(err, options);
return callback(err, reportFile);
}
var data = dataBuffer.toString();
const data = dataBuffer.toString();
if (!data) {
return callback("ReportFileNotFound", options);
return callback("ReportFileNotFound", reportFile);
}
var report = JSON.parse(data);
const report = JSON.parse(data);
return callback(null, report);
});
});
};
var getDatePart = function (report) {
const getDatePart = function (report) {
if (!report.date) {
return "unknowndate";
}
var date = new Date(report.date),
paddingLeft = function (str, paddingValue) {
return String(paddingValue + str).slice(-paddingValue.length);
};
const date = new Date(report.date);
const paddingLeft = function (str, paddingValue) {
return String(paddingValue + str).slice(-paddingValue.length);
};
return date.getFullYear() + "." +
paddingLeft(date.getMonth() + 1, "00") + "." +
@ -45,7 +45,7 @@ var getDatePart = function (report) {
};
module.exports = function(req, res, next) {
var options = {
const options = {
owner: req.params.owner,
reponame: req.params.reponame,
branchName: req.params.branch,
@ -53,8 +53,8 @@ module.exports = function(req, res, next) {
rev: req.params.rev
};
var zip = new Zip(),
releasePath = path.normalize(req.app.get('releasepath') + "/" + options.owner + "/" + options.reponame + "/" + options.branch + "/" + options.rev + "/");
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) {
if (err) {

@ -1,19 +1,17 @@
"use strict";
var fs = require('fs'),
url = require('url'),
glob = require('glob'),
statusProcessor = require('../lib/status-processor');
const url = require('url');
const statusProcessor = require('../lib/status-processor');
var parseOptionsFromReferer = function (path, callback) {
var pathParts = path.split("/").filter(function (value) { return value; });
var result = {};
const parseOptionsFromReferer = function (path, callback) {
const pathParts = path.split("/").filter(function (value) { return value; });
const result = {};
if (pathParts.length < 2) {
return callback("BadRequest", result);
}
if (pathParts[2] == "tree") {
if (pathParts[2] === "tree") {
pathParts.splice(2, 1);
}
@ -24,16 +22,16 @@ var parseOptionsFromReferer = function (path, callback) {
return callback(null, result);
};
var createShowReport = function (res) {
const createShowReport = function (res) {
return function (err, options) {
options = options || {};
options.err = err;
res.render('status', options);
}
}
};
};
exports.image = function(req, res) {
var handle = function (err, options) {
const handle = function (err, options) {
if (err === "ReportFileNotFound") {
options.status = "Building";
} else if (err) {
@ -69,7 +67,7 @@ exports.image = function(req, res) {
};
exports.page = function(req, res) {
var options = {
const options = {
owner: req.params.owner,
reponame: req.params.reponame,
branchName: req.params.branch,
@ -88,5 +86,4 @@ exports.pageFromGithub = function (req, res) {
return statusProcessor.getReport(req.app, options, createShowReport(res));
});
}
};

Loading…
Cancel
Save