From bec09d8c9f0b94ae3bde2f0531340e37f2683689 Mon Sep 17 00:00:00 2001 From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Tue, 28 Feb 2017 16:12:43 +0300 Subject: [PATCH] Code style --- BuildServer/app.ts | 16 +-- BuildServer/lib/builder.ts | 53 ++++----- BuildServer/lib/commenter.ts | 38 ++++--- BuildServer/lib/git/copy.ts | 26 ++--- BuildServer/lib/git/loader.ts | 7 +- BuildServer/lib/report-processor.ts | 68 +++--------- BuildServer/lib/status-processor.ts | 17 +-- BuildServer/lib/task-processor.ts | 54 ++++----- .../lib/tasks/cleanupafterdotnetbuild.ts | 26 ++--- BuildServer/lib/tasks/conditional.ts | 6 +- BuildServer/lib/tasks/copy.ts | 10 +- BuildServer/lib/tasks/copyglob.ts | 26 ++--- BuildServer/lib/tasks/cssnano.ts | 11 +- BuildServer/lib/tasks/cssnanoall.ts | 26 ++--- BuildServer/lib/tasks/deletefromcode.ts | 10 +- BuildServer/lib/tasks/dotnetbuild.ts | 18 +-- BuildServer/lib/tasks/dotnetbuildandtest.ts | 22 ++-- BuildServer/lib/tasks/dotnetbuilderwrapper.ts | 11 +- .../lib/tasks/dotnetbuildwithoutcleanup.ts | 26 ++--- BuildServer/lib/tasks/dotnetcheckstyle.ts | 18 +-- BuildServer/lib/tasks/dotnetcompile.ts | 18 +-- BuildServer/lib/tasks/dotnetnugetpack.ts | 12 +- BuildServer/lib/tasks/dotnetnugetprocess.ts | 46 ++++---- .../lib/tasks/dotnetnugetprocessinternal.ts | 24 ++-- BuildServer/lib/tasks/dotnetnugetpush.ts | 12 +- BuildServer/lib/tasks/dotnetnugetpushonly.ts | 15 +-- BuildServer/lib/tasks/dotnetnugetrestore.ts | 20 ++-- BuildServer/lib/tasks/dotnetnunit.ts | 8 +- BuildServer/lib/tasks/dotnetnunitall.ts | 26 ++--- BuildServer/lib/tasks/dotnetpackwebapp.ts | 61 +++++------ BuildServer/lib/tasks/dotnetrewrite.ts | 26 ++--- BuildServer/lib/tasks/echo.ts | 8 +- BuildServer/lib/tasks/eslintbrowser.ts | 14 +-- BuildServer/lib/tasks/eslintbrowserall.ts | 26 ++--- BuildServer/lib/tasks/index.ts | 9 +- BuildServer/lib/tasks/noop.ts | 2 +- BuildServer/lib/tasks/packform.ts | 34 +++--- BuildServer/lib/tasks/parallel.ts | 2 +- BuildServer/lib/tasks/sequential.ts | 2 +- BuildServer/lib/tasks/uglifyjs.ts | 9 +- BuildServer/lib/tasks/uglifyjsall.ts | 26 ++--- BuildServer/lib/tasks/writefile.ts | 8 +- BuildServer/lib/tasks/zip.ts | 10 +- BuildServer/package.json | 5 +- BuildServer/routes/artifact.ts | 12 +- BuildServer/routes/index.ts | 9 +- BuildServer/routes/manual.ts | 8 +- BuildServer/routes/postreceive.ts | 55 +++++----- BuildServer/routes/release.ts | 12 +- BuildServer/routes/status.ts | 39 +++---- BuildServer/tsconfig.json | 2 + BuildServer/tslint.json | 103 +----------------- 52 files changed, 514 insertions(+), 638 deletions(-) diff --git a/BuildServer/app.ts b/BuildServer/app.ts index 5ca853e..8d60935 100644 --- a/BuildServer/app.ts +++ b/BuildServer/app.ts @@ -5,22 +5,22 @@ import { gracefulify } from "graceful-fs"; gracefulify(fs); +import { json as bodyJson, urlencoded as bodyUrlencoded } from "body-parser"; +import * as errorhandler from "errorhandler"; import * as express from "express"; -import * as routes from "./routes"; import { createServer } from "http"; +import * as methodOverride from "method-override"; +import * as morgan from "morgan"; import { join } from "path"; import * as serveFavicon from "serve-favicon"; -import * as morgan from "morgan"; -import { json as bodyJson, urlencoded as bodyUrlencoded } from "body-parser"; -import * as methodOverride from "method-override"; import * as serveStatic from "serve-static"; -import * as errorhandler from "errorhandler"; +import * as routes from "./routes"; import settings from "./settings"; const app = express(); -app.set("port", settings.port); // eslint-disable-line no-process-env +app.set("port", settings.port); app.set("views", join(__dirname, "views")); app.set("view engine", "jade"); app.set("gitpath", settings.gitpath); @@ -28,8 +28,8 @@ app.set("tmpcodepath", settings.tmpcodepath); app.set("releasepath", settings.releasepath); app.use(serveFavicon(join(__dirname, "public/images/favicon.png"))); app.use(morgan("dev")); -app.use(bodyJson({ "limit": "10mb" })); -app.use(bodyUrlencoded({ "extended": false })); +app.use(bodyJson({ limit: "10mb" })); +app.use(bodyUrlencoded({ extended: false })); app.use(methodOverride()); app.use(serveStatic(join(__dirname, "public"))); diff --git a/BuildServer/lib/builder.ts b/BuildServer/lib/builder.ts index bdb7c68..02d02c5 100644 --- a/BuildServer/lib/builder.ts +++ b/BuildServer/lib/builder.ts @@ -1,15 +1,16 @@ "use strict"; -import { join } from "path"; +import { parallel, queue } from "async"; import { exists, readFile, writeFileSync } from "fs"; import { mkdirsSync, remove } from "fs-extra"; -import { parallel, queue } from "async"; import * as JSONParse from "json-parse-safe"; +import { join } from "path"; + +import settings from "../settings"; import { gitLoader } from "./git/loader"; -import { processTask } from "./task-processor"; -import { writeReport } from "./report-processor"; import { send as sendMail } from "./mail-sender"; -import settings from "../settings"; +import { writeReport } from "./report-processor"; +import { processTask } from "./task-processor"; const codePostfix = ""; const mailLazinessLevel = 1000; @@ -35,12 +36,12 @@ const createBuildDoneMessage = (isSuccess, name) => { const notifyStatus = (options, notifyStatusCallback) => { const status = { - "description": String(options.description || "").substr(0, maxDescriptionLength), - "owner": options.owner, - "repo": options.reponame, - "sha": options.hash, - "state": options.state, - "target_url": `${settings.siteRoot}status/${options.owner}/${options.reponame}/${options.hash}` + description: String(options.description || "").substr(0, maxDescriptionLength), + owner: options.owner, + repo: options.reponame, + sha: options.hash, + state: options.state, + target_url: `${settings.siteRoot}status/${options.owner}/${options.reponame}/${options.hash}`, }; settings.createGithub(options.owner).repos.createStatus(status, (createStatusErr) => { @@ -85,11 +86,11 @@ export const build = (options, buildCallback) => { const versionInfo = `${version}; built from ${rev}; repository: ${owner}/${reponame}; branch: ${branch}`; statusQueue.push((queueCallback) => notifyStatus({ - "description": "Preparing to build...", - "hash": rev, + description: "Preparing to build...", + hash: rev, owner, reponame, - "state": "pending" + state: "pending", }, queueCallback)); mkdirsSync(release); @@ -125,18 +126,18 @@ export const build = (options, buildCallback) => { writeReport(release, doneErr, result, (writeErr) => { statusQueue.push((queueCallback) => parallel([ (parallelCallback) => notifyStatus({ - "description": errorMessage || warnMessage || infoMessage || "Success", - "hash": rev, + description: errorMessage || warnMessage || infoMessage || "Success", + hash: rev, owner, reponame, - "state": createFinalState(!doneErr) + state: createFinalState(!doneErr), }, parallelCallback), (parallelCallback) => sendMail({ - "from": settings.smtp.sender, - "headers": { "X-Laziness-level": mailLazinessLevel }, - "subject": createBuildDoneMessage(doneErr, `${owner}/${reponame}/${branch}`), - "text": `Build status URL: ${settings.siteRoot}status/${owner}/${reponame}/${rev}\r\n\r\n${createErrorMessageForMail(doneErr)}${createResultMessageForMail(result)}`, - "to": settings.smtp.receiver + from: settings.smtp.sender, + headers: { "X-Laziness-level": mailLazinessLevel }, + subject: createBuildDoneMessage(doneErr, `${owner}/${reponame}/${branch}`), + text: `Build status URL: ${settings.siteRoot}status/${owner}/${reponame}/${rev}\r\n\r\n${createErrorMessageForMail(doneErr)}${createResultMessageForMail(result)}`, + to: settings.smtp.receiver, }, parallelCallback), (parallelCallback) => { if (doneErr) { @@ -144,7 +145,7 @@ export const build = (options, buildCallback) => { } return remove(tmp, parallelCallback); - } + }, ], queueCallback)); if (writeErr) { @@ -158,9 +159,9 @@ export const build = (options, buildCallback) => { actualGitLoader({ branch, exported, - "hash": rev, + hash: rev, local, - "remote": `${url}.git` + remote: `${url}.git`, }, (gitLoaderErr) => { if (gitLoaderErr) { console.log(gitLoaderErr); @@ -196,7 +197,7 @@ export const build = (options, buildCallback) => { reponame, rev, tmp, - versionInfo + versionInfo, }, (processErr, result) => { if (processErr) { return done(processErr, result); diff --git a/BuildServer/lib/commenter.ts b/BuildServer/lib/commenter.ts index 0f3fc20..3698165 100644 --- a/BuildServer/lib/commenter.ts +++ b/BuildServer/lib/commenter.ts @@ -1,8 +1,9 @@ "use strict"; import * as _ from "underscore"; -import { getStatusMessageFromRelease } from "./report-processor"; + import settings from "../settings"; +import { getStatusMessageFromRelease } from "./report-processor"; const featureNamePattern = /^feature-(\d+)(?:-[a-zA-Z0-9]+)+$/; const versionNamePattern = /^v\d+(\.\d+)*$/; @@ -12,10 +13,10 @@ const httpNotFound = 404; const maxCommentLength = 64000; const writeComment = (options, message, callback) => options.github.issues.createComment({ - "body": message, - "number": options.pullRequestNumber, - "owner": options.baseRepoOptions.owner, - "repo": options.baseRepoOptions.reponame + body: message, + number: options.pullRequestNumber, + owner: options.baseRepoOptions.owner, + repo: options.baseRepoOptions.reponame, }, callback); const closePullRequest = (options, message, callback) => writeComment(options, message, (err) => { @@ -24,17 +25,17 @@ const closePullRequest = (options, message, callback) => writeComment(options, m } return options.github.issues.edit({ - "number": options.pullRequestNumber, - "owner": options.baseRepoOptions.owner, - "repo": options.baseRepoOptions.reponame, - "state": "closed" + number: options.pullRequestNumber, + owner: options.baseRepoOptions.owner, + repo: options.baseRepoOptions.reponame, + state: "closed", }, callback); }); const checkHasIssue = (options, issueNumber, callback) => options.github.issues.get({ - "number": issueNumber, - "owner": options.baseRepoOptions.owner, - "repo": options.baseRepoOptions.reponame + number: issueNumber, + owner: options.baseRepoOptions.owner, + repo: options.baseRepoOptions.reponame, }, (getIssueErr, result) => { if (getIssueErr && getIssueErr.code !== httpNotFound) { return callback(getIssueErr); @@ -52,9 +53,9 @@ const checkHasIssue = (options, issueNumber, callback) => options.github.issues. }); const checkHasReleases = (options, callback) => options.github.repos.getReleases({ - "owner": options.baseRepoOptions.owner, - "per_page": 1, - "repo": options.baseRepoOptions.reponame + owner: options.baseRepoOptions.owner, + per_page: 1, + repo: options.baseRepoOptions.reponame, }, (getReleasesErr, result) => { if (getReleasesErr) { return callback(getReleasesErr); @@ -101,7 +102,8 @@ const checkPullRequest = (options, callback) => { return closePullRequest(options, `Only merging to master or version branch is allowed; merging to '${base.branchname}' is not supported`, callback); } - const issueNumber = featureNamePattern.exec(head.branchname)[1]; + const execResult = featureNamePattern.exec(head.branchname); + const issueNumber = execResult && execResult[1]; return checkHasIssue(options, issueNumber, (hasIssueErr, hasIssue, issueTitle) => { if (hasIssueErr) { @@ -137,8 +139,8 @@ const checkPullRequest = (options, callback) => { }; export const commentOnPullRequest = (originalOptions, callback) => { - const optionsGithub = _.extend(originalOptions, { "github": settings.createGithub(originalOptions.baseRepoOptions.owner) }); - const options = _.extend(optionsGithub, { "onTenthAttempt": () => writeComment(optionsGithub, "Waiting for build to finish...", () => {}) }); + const optionsGithub = _.extend(originalOptions, { github: settings.createGithub(originalOptions.baseRepoOptions.owner) }); + const options = _.extend(optionsGithub, { onTenthAttempt: () => writeComment(optionsGithub, "Waiting for build to finish...", _.noop) }); return checkPullRequest(options, () => getStatusMessageFromRelease(options.app, options.headRepoOptions, (statusMessageErr, statusSuccessMessage) => { const escapedErr = String(statusMessageErr || "").substring(0, maxCommentLength) diff --git a/BuildServer/lib/git/copy.ts b/BuildServer/lib/git/copy.ts index 9fe1177..aca540c 100644 --- a/BuildServer/lib/git/copy.ts +++ b/BuildServer/lib/git/copy.ts @@ -1,9 +1,9 @@ "use strict"; -import { EventEmitter } from "events"; // eslint-disable-line fp/no-events -import { join } from "path"; -import { writeFile, mkdir } from "fs"; import { parallel } from "async"; +import { EventEmitter } from "events"; +import { mkdir, writeFile } from "fs"; +import { join } from "path"; import { Copier } from "recursive-tree-copy"; const safeGetEntries = (tree, callback) => { @@ -15,8 +15,8 @@ const safeGetEntries = (tree, callback) => { }; const gitToFsCopier = new Copier({ - "concurrency": 4, - "copyLeaf": (entry, targetDir, callback) => { + concurrency: 4, + copyLeaf: (entry, targetDir, callback) => { const targetPath = join(targetDir, entry.name()); entry.getBlob((err, blob) => { @@ -27,7 +27,7 @@ const gitToFsCopier = new Copier({ return writeFile(targetPath, blob.content(), callback); }); }, - "createTargetTree": (tree, targetDir, callback) => { + createTargetTree: (tree, targetDir, callback) => { const targetSubdir = join(targetDir, tree.name); mkdir(targetSubdir, (err) => { @@ -39,8 +39,8 @@ const gitToFsCopier = new Copier({ return callback(null, targetSubdir); }); }, - "finalizeTargetTree": (targetSubdir, callback) => callback(), - "walkSourceTree": (tree) => { + finalizeTargetTree: (targetSubdir, callback) => callback(), + walkSourceTree: (tree) => { const emitter = new EventEmitter(); process.nextTick(() => safeGetEntries(tree, (getEntriesErr, entries) => { @@ -56,8 +56,8 @@ const gitToFsCopier = new Copier({ } emitter.emit("tree", { - "gitTree": subTree, - "name": entry.name() + gitTree: subTree, + name: entry.name(), }); return callback(); @@ -81,7 +81,7 @@ const gitToFsCopier = new Copier({ })); return emitter; - } + }, }); export const gitToFs = (commit, exportDir, callback) => commit.getTree((err, tree) => { @@ -90,7 +90,7 @@ export const gitToFs = (commit, exportDir, callback) => commit.getTree((err, tre } return gitToFsCopier.copy({ - "gitTree": tree, - "name": "." + gitTree: tree, + name: ".", }, exportDir, callback); }); diff --git a/BuildServer/lib/git/loader.ts b/BuildServer/lib/git/loader.ts index a98d9ba..3d67360 100644 --- a/BuildServer/lib/git/loader.ts +++ b/BuildServer/lib/git/loader.ts @@ -1,7 +1,8 @@ "use strict"; -import { Repository, Remote } from "nodegit"; import { mkdirsSync, removeSync } from "fs-extra"; +import { Remote, Repository } from "nodegit"; + import { gitToFs } from "./copy"; const fixUrl = (url) => { @@ -27,8 +28,8 @@ export const gitLoader = (options, globalCallback) => { const path = `${options.local}/${options.hash}`; const exported = options.exported; - removeSync(path); // eslint-disable-line no-sync - mkdirsSync(path); // eslint-disable-line no-sync + removeSync(path); + mkdirsSync(path); console.log(`Cloning ${url} to ${path}`); diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts index e824786..1f232b3 100644 --- a/BuildServer/lib/report-processor.ts +++ b/BuildServer/lib/report-processor.ts @@ -1,46 +1,12 @@ "use strict"; -import { join } from "path"; import { createReadStream, createWriteStream, exists } from "fs"; -import { createGzip, createGunzip } from "zlib"; import * as glob from "glob"; +import * as JSONParse from "json-parse-safe"; +import { join } from "path"; import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers"; import * as _ from "underscore"; -import * as JSONParse from "json-parse-safe"; - -interface Message { - message: string; - prefix: string; -}; - -interface PartialMessagesLeaf { - $messages: string[]; -}; - -interface PartialMessagesRecursive { - [propName: string]: Messages; -}; - -interface PartialMessagesRoot { - $allMessages: Message[]; -}; - -type Messages = PartialMessagesLeaf & PartialMessagesRecursive; - -type MessagesRoot = PartialMessagesLeaf & PartialMessagesRecursive & PartialMessagesRoot; - -interface ReportResult { - errors: MessagesRoot; - warns: MessagesRoot; - infos: MessagesRoot; - messages: MessagesRoot; -}; - -interface Report { - date: number; - err?: string; - result?: ReportResult; -}; +import { createGunzip, createGzip } from "zlib"; const reportFilename = "report.json.gz"; const maxAttemptsNumber = 100; @@ -50,8 +16,8 @@ const directoryCheckTimeout = 2000; const attemptsDebugFrequency = 10; const readableStreamBufferOptions = { - "chunkSize": 262144, - "frequency": 1 + chunkSize: 262144, + frequency: 1, }; const getAllErrors = (report: Report): Message[] => (report.result && report.result.errors && report.result.errors.$allMessages) || []; @@ -60,9 +26,9 @@ const getAllInfos = (report: Report): Message[] => (report.result && report.resu export const writeReport = (releaseDir, err, result: ReportResult, callback) => { const data = JSON.stringify({ - "date": Date.now(), + date: Date.now(), err, - result + result, }); const readable = new ReadableStreamBuffer(readableStreamBufferOptions); @@ -114,8 +80,8 @@ export const loadReport = (app, options, callback) => { const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev); glob("**", { - "cwd": releaseDir, - "mark": true + cwd: releaseDir, + mark: true, }, (err, files) => { if (err) { return callback(err, options); @@ -135,7 +101,7 @@ export const loadReport = (app, options, callback) => { return callback(null, _.extend(options, { files, - report + report, })); }); }); @@ -143,7 +109,7 @@ export const loadReport = (app, options, callback) => { }; export const getStatusMessageFromRelease = (app, originalOptions, callback) => { - const options = _.extend(originalOptions, { "attemptsGetReport": (Number(originalOptions.attemptsGetReport) || Number()) + 1 }); + const options = _.extend(originalOptions, { attemptsGetReport: (Number(originalOptions.attemptsGetReport) || Number()) + 1 }); const releaseDir = join(app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev); const reportFile = join(releaseDir, reportFilename); @@ -181,19 +147,17 @@ export const getStatusMessageFromRelease = (app, originalOptions, callback) => { const infos = getAllInfos(report); if (errors.length + warns.length) { - return callback(_.map( - errors, (message) => `ERR: ${message.message}` - ).concat(_.map( - warns, (message) => `WARN: ${message.message}` - )) - .join("\r\n")); + const formattedErrors = _.map(errors, (message) => `ERR: ${message.message}`); + const formattedWarns = _.map(warns, (message) => `WARN: ${message.message}`); + + return callback(formattedErrors.concat(formattedWarns).join("\r\n")); } if (!report.result || report.err) { return callback(`CRITICAL ERROR: ${report.err}`); } - return callback(null, (infos[infos.length - 1] || { "message": "OK" }).message); + return callback(null, (infos[infos.length - 1] || { message: "OK" }).message); }), reportReadTimeout); }); }; diff --git a/BuildServer/lib/status-processor.ts b/BuildServer/lib/status-processor.ts index 41c7c5e..9c57f7a 100644 --- a/BuildServer/lib/status-processor.ts +++ b/BuildServer/lib/status-processor.ts @@ -1,8 +1,9 @@ "use strict"; -import { join } from "path"; import { exists, readFile } from "fs"; +import { join } from "path"; import * as _ from "underscore"; + import { loadReport } from "./report-processor"; const addBranchInfo = (app, options, callback) => { @@ -24,7 +25,7 @@ const addBranchInfo = (app, options, callback) => { return callback(null, _.extend(options, { branch, - branchName + branchName, })); }); }); @@ -56,23 +57,23 @@ const parseOptions = (app, options, callback) => { } const result = { - "owner": options.owner, - "reponame": options.reponame + owner: options.owner, + reponame: options.reponame, }; if (options.rev) { - return addBranchInfo(app, _.extend(result, { "rev": options.rev }), callback); + return addBranchInfo(app, _.extend(result, { rev: options.rev }), callback); } if (/^[\da-f]{40}$/i.test(options.branchName)) { - return addBranchInfo(app, _.extend(result, { "rev": options.branchName }), callback); + return addBranchInfo(app, _.extend(result, { rev: options.branchName }), callback); } const branchName = options.branchName || "master"; return addRevInfo(app, _.extend(result, { - "branch": `refs/heads/${branchName}`, - branchName + branch: `refs/heads/${branchName}`, + branchName, }), callback); }; diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts index fb6cac3..3df504a 100644 --- a/BuildServer/lib/task-processor.ts +++ b/BuildServer/lib/task-processor.ts @@ -4,10 +4,10 @@ import * as _ from "underscore"; import tasks from "./tasks"; // TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here. -const TaskProcessor = function (task, outerProcessor, callback) { - const that = this; - const createTaskWorker = () => tasks[task.type](task.params || {}, that); - const errors = []; +const createTaskProcessor = (task, outerProcessor: TaskProcessor, callback) => { + const result: TaskProcessor = {}; + const createTaskWorker = () => tasks[task.type](task.params || {}, result); + const errors: string[] = []; const process = () => createTaskWorker().process(); const getOuterPrefix = (prefix) => { if (task.name && prefix) { @@ -23,40 +23,42 @@ const TaskProcessor = function (task, outerProcessor, callback) { 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, that, innerCallback); + const innerProcessor = createTaskProcessor(innerTask, result, innerCallback); innerProcessor.process(); }; const done = () => callback(errors.join("\r\n")); - that.process = process; - that.onError = onError; - that.onWarn = onWarn; - that.onInfo = onInfo; - that.processTask = processTask; - that.done = done; - that.context = outerProcessor.context; + result.process = process; + result.onError = onError; + result.onWarn = onWarn; + result.onInfo = onInfo; + result.processTask = processTask; + result.done = done; + result.context = outerProcessor.context; + + return result; }; const pushMessage = (list, message, parts, index) => { if (!index) { - list.$allMessages = list.$allMessages || []; // eslint-disable-line fp/no-mutation - list.$allMessages.push({ // eslint-disable-line fp/no-mutating-methods + list.$allMessages = list.$allMessages || []; + list.$allMessages.push({ message, - "prefix": parts.join("/") + prefix: parts.join("/"), }); } - list.$messages = list.$messages || []; // eslint-disable-line fp/no-mutation + list.$messages = list.$messages || []; if (index === parts.length) { - return list.$messages.push(message); // eslint-disable-line fp/no-mutating-methods + return list.$messages.push(message); } return pushMessage(list, message, parts, index + 1); }; const addFlag = (flags) => (flagName) => { - flags[flagName] = true; // eslint-disable-line fp/no-mutation + flags[flagName] = true; }; const containsFlag = (flags) => (flagName) => flags[flagName]; @@ -73,19 +75,19 @@ export const processTask = (task, context, callback) => { pushMessage(messages, message, parts, 0); }; const flags = {}; - const processor = new TaskProcessor(task, { - "context": _.extend(context, { - "addFlag": addFlag(flags), - "containsFlag": containsFlag(flags) + const processor = createTaskProcessor(task, { + context: _.extend(context, { + addFlag: addFlag(flags), + containsFlag: containsFlag(flags), }), - "onError": messageProcessor(errors), - "onInfo": messageProcessor(infos), - "onWarn": messageProcessor(warns) + onError: messageProcessor(errors), + onInfo: messageProcessor(infos), + onWarn: messageProcessor(warns), }, (err) => callback(err, { errors, infos, messages, - warns + warns, })); processor.process(); diff --git a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts index f21a29e..23b96f3 100644 --- a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts +++ b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts @@ -2,10 +2,10 @@ import * as glob from "glob"; -export default (params, processor) => ({ - "process": () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", { - "cwd": processor.context.exported, - "dot": true +export default ((params, processor) => ({ + process: () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", { + cwd: processor.context.exported, + dot: true, }, (err, files) => { if (err) { processor.onError(err); @@ -18,14 +18,14 @@ export default (params, processor) => ({ } return processor.processTask({ - "params": { - "tasks": files.map((file) => ({ - "name": file, - "params": { "filename": file }, - "type": "deletefromcode" - })) + params: { + tasks: files.map((file) => ({ + name: file, + params: { filename: file }, + type: "deletefromcode", + })), }, - "type": "parallel" + type: "parallel", }, processor.done.bind(processor)); - }) -}); + }), +})) as Task; diff --git a/BuildServer/lib/tasks/conditional.ts b/BuildServer/lib/tasks/conditional.ts index ce8d2ff..7c8c13f 100644 --- a/BuildServer/lib/tasks/conditional.ts +++ b/BuildServer/lib/tasks/conditional.ts @@ -1,9 +1,9 @@ "use strict"; -export default (params, processor) => { +export default ((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": () => processor.processTask(task || { "type": "noop" }, processor.done.bind(processor)) }; -}; + return { process: () => processor.processTask(task || { type: "noop" }, processor.done.bind(processor)) }; +}) as Task; diff --git a/BuildServer/lib/tasks/copy.ts b/BuildServer/lib/tasks/copy.ts index f03e29a..e7f06a2 100644 --- a/BuildServer/lib/tasks/copy.ts +++ b/BuildServer/lib/tasks/copy.ts @@ -1,10 +1,10 @@ "use strict"; -import { join } from "path"; import { copy } from "fs-extra"; +import { join } from "path"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const sourceFilePath = join(processor.context.exported, params.filename); const targetFilePath = join(processor.context.release, params.filename); @@ -19,5 +19,5 @@ export default (params, processor) => ({ return processor.done(); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/copyglob.ts b/BuildServer/lib/tasks/copyglob.ts index 3f0d70d..522273f 100644 --- a/BuildServer/lib/tasks/copyglob.ts +++ b/BuildServer/lib/tasks/copyglob.ts @@ -2,10 +2,10 @@ import * as glob from "glob"; -export default (params, processor) => ({ - "process": () => glob(params.mask, { - "cwd": processor.context.exported, - "dot": true +export default ((params, processor) => ({ + process: () => glob(params.mask, { + cwd: processor.context.exported, + dot: true, }, (err, files) => { if (err) { processor.onError(err); @@ -18,14 +18,14 @@ export default (params, processor) => ({ } return processor.processTask({ - "params": { - "tasks": files.map((file) => ({ - "name": file, - "params": { "filename": file }, - "type": "copy" - })) + params: { + tasks: files.map((file) => ({ + name: file, + params: { filename: file }, + type: "copy", + })), }, - "type": "parallel" + type: "parallel", }, processor.done.bind(processor)); - }) -}); + }), +})) as Task; diff --git a/BuildServer/lib/tasks/cssnano.ts b/BuildServer/lib/tasks/cssnano.ts index 103fd52..1620342 100644 --- a/BuildServer/lib/tasks/cssnano.ts +++ b/BuildServer/lib/tasks/cssnano.ts @@ -1,11 +1,11 @@ "use strict"; +import { process as cssnanoProcess } from "cssnano"; import { readFile, writeFile } from "fs"; import { join } from "path"; -import { process as cssnanoProcess } from "cssnano"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const filePath = join(processor.context.exported, params.filename); readFile(filePath, (readErr, css) => { @@ -32,6 +32,5 @@ export default (params, processor) => ({ }); }); }); - } -}); - + }, +})) as Task; diff --git a/BuildServer/lib/tasks/cssnanoall.ts b/BuildServer/lib/tasks/cssnanoall.ts index 95c033f..882b9a8 100644 --- a/BuildServer/lib/tasks/cssnanoall.ts +++ b/BuildServer/lib/tasks/cssnanoall.ts @@ -3,8 +3,8 @@ import * as glob from "glob"; const flagDoneName = "cssnanoallDone"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { if (processor.context.containsFlag(flagDoneName)) { processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -12,8 +12,8 @@ export default (params, processor) => ({ processor.context.addFlag(flagDoneName); glob("**/*.css", { - "cwd": processor.context.exported, - "dot": true + cwd: processor.context.exported, + dot: true, }, (err, files) => { if (err) { processor.onError(err); @@ -22,15 +22,15 @@ export default (params, processor) => ({ } return processor.processTask({ - "params": { - "tasks": files.map((file) => ({ - "name": file, - "params": { "filename": file }, - "type": "cssnano" - })) + params: { + tasks: files.map((file) => ({ + name: file, + params: { filename: file }, + type: "cssnano", + })), }, - "type": (params.preventParallelTests && "sequential") || "parallel" + type: (params.preventParallelTests && "sequential") || "parallel", }, processor.done.bind(processor)); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/deletefromcode.ts b/BuildServer/lib/tasks/deletefromcode.ts index b5ae2b7..ff90878 100644 --- a/BuildServer/lib/tasks/deletefromcode.ts +++ b/BuildServer/lib/tasks/deletefromcode.ts @@ -1,10 +1,10 @@ "use strict"; -import { join } from "path"; import { remove } from "fs-extra"; +import { join } from "path"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const sourceFilePath = join(processor.context.exported, params.filename); processor.onInfo(`Deleting ${sourceFilePath}`); @@ -18,5 +18,5 @@ export default (params, processor) => ({ return processor.done(); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/dotnetbuild.ts b/BuildServer/lib/tasks/dotnetbuild.ts index 7b31af9..8b474cd 100644 --- a/BuildServer/lib/tasks/dotnetbuild.ts +++ b/BuildServer/lib/tasks/dotnetbuild.ts @@ -2,16 +2,16 @@ import sequential from "./sequential"; -export default (params, processor) => sequential({ - "tasks": [ +export default ((params, processor) => sequential({ + tasks: [ { - "name": "build", + name: "build", params, - "type": "dotnetbuildwithoutcleanup" + type: "dotnetbuildwithoutcleanup", }, { - "name": "cleanup", - "type": "cleanupafterdotnetbuild" - } - ] -}, processor); + name: "cleanup", + type: "cleanupafterdotnetbuild", + }, + ], +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetbuildandtest.ts b/BuildServer/lib/tasks/dotnetbuildandtest.ts index c4152cf..292dc58 100644 --- a/BuildServer/lib/tasks/dotnetbuildandtest.ts +++ b/BuildServer/lib/tasks/dotnetbuildandtest.ts @@ -2,21 +2,21 @@ import sequential from "./sequential"; -export default (params, processor) => sequential({ - "tasks": [ +export default ((params, processor) => sequential({ + tasks: [ { - "name": "build", + name: "build", params, - "type": "dotnetbuildwithoutcleanup" + type: "dotnetbuildwithoutcleanup", }, { - "name": "test", + name: "test", params, - "type": "dotnetnunitall" + type: "dotnetnunitall", }, { - "name": "cleanup", - "type": "cleanupafterdotnetbuild" - } - ] -}, processor); + name: "cleanup", + type: "cleanupafterdotnetbuild", + }, + ], +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts index dc9fa78..39af675 100644 --- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts +++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts @@ -1,8 +1,9 @@ "use strict"; import { spawn } from "child_process"; -import { WritableStreamBuffer } from "stream-buffers"; import * as JSONParse from "json-parse-safe"; +import { WritableStreamBuffer } from "stream-buffers"; + import settings from "../../settings"; const wrapBuilder = (builder, input, onExit) => { @@ -27,8 +28,8 @@ const wrapBuilder = (builder, input, onExit) => { builder.stdin.end(); }; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const input = JSON.stringify(params); const builder = spawn(settings.builderExecutable, [params.command]); @@ -71,5 +72,5 @@ export default (params, processor) => ({ return processor.done(); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts index 00cee5d..7742516 100644 --- a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts +++ b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts @@ -6,37 +6,37 @@ const createTasks = function *(params) { if (!params.skipMbsCheckStyle) { yield { params, - "type": "dotnetcheckstyle" + type: "dotnetcheckstyle", }; } yield { params, - "type": "dotnetrewrite" + type: "dotnetrewrite", }; if (!params.skipNugetRestore) { yield { params, - "type": "dotnetnugetrestore" + type: "dotnetnugetrestore", }; } yield { - "params": { - "configuration": params.configuration, - "forceCodeAnalysis": params.forceCodeAnalysis, - "ignoreCodeAnalysis": params.ignoreCodeAnalysis, - "skipCodeSigning": params.skipCodeSigning, - "solution": params.solution, - "target": "Rebuild" + params: { + configuration: params.configuration, + forceCodeAnalysis: params.forceCodeAnalysis, + ignoreCodeAnalysis: params.ignoreCodeAnalysis, + skipCodeSigning: params.skipCodeSigning, + solution: params.solution, + target: "Rebuild", }, - "type": "dotnetcompile" + type: "dotnetcompile", }; }; -export default (params, processor) => { +export default ((params, processor) => { const tasks = Array.from(createTasks(params)); return sequential({ tasks }, processor); -}; +}) as Task; diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.ts b/BuildServer/lib/tasks/dotnetcheckstyle.ts index 9d19dc0..0aa1222 100644 --- a/BuildServer/lib/tasks/dotnetcheckstyle.ts +++ b/BuildServer/lib/tasks/dotnetcheckstyle.ts @@ -1,9 +1,9 @@ "use strict"; -import { join } from "path"; -import { readFile } from "fs"; import { parallel } from "async"; +import { readFile } from "fs"; import * as glob from "glob"; +import { join } from "path"; const autoGeneratedMarker = "//------------------------------------------------------------------------------\n" @@ -11,15 +11,15 @@ const autoGeneratedMarker const flagDoneName = "dotnetcheckerDone"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { if (processor.context.containsFlag(flagDoneName)) { return processor.done(); } processor.context.addFlag(flagDoneName); - return glob("**/*.cs", { "cwd": processor.context.exported }, (globErr, files) => { + return glob("**/*.cs", { cwd: processor.context.exported }, (globErr, files) => { if (globErr) { processor.onError(globErr); @@ -58,7 +58,7 @@ export default (params, processor) => ({ return parallel(files.map((file) => (callback) => readFile( join(processor.context.exported, file), - { "encoding": "utf8" }, + { encoding: "utf8" }, (readErr, data) => { if (readErr) { processor.onError(`Unable to check file ${file}: ${readErr}`); @@ -69,8 +69,8 @@ export default (params, processor) => ({ processFile(data, file); return callback(); - } + }, )), processor.done.bind(processor)); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/dotnetcompile.ts b/BuildServer/lib/tasks/dotnetcompile.ts index 6402298..b77e236 100644 --- a/BuildServer/lib/tasks/dotnetcompile.ts +++ b/BuildServer/lib/tasks/dotnetcompile.ts @@ -5,7 +5,7 @@ import * as _ from "underscore"; import settings from "../../settings"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; -export default (params, processor) => { +export default ((params, processor) => { if (settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) { processor.onError("Code analysis is not supported"); @@ -17,7 +17,7 @@ export default (params, processor) => { return {}; } - return { "SigningKey": settings.codeSigningKeyFile }; + return { SigningKey: settings.codeSigningKeyFile }; }; const skipCodeAnalysis = settings.isCodeAnalysisUnsupported @@ -25,13 +25,13 @@ export default (params, processor) => { || (settings.ignoreCodeAnalysisByDefault && !params.forceCodeAnalysis); const compileParams = { - "Configuration": params.configuration, - "OutputDirectory": params.overrideOutputDirectory, - "SkipCodeAnalysis": skipCodeAnalysis, - "SolutionPath": join(processor.context.exported, params.solution), - "Target": params.target, - "command": "compile" + Configuration: params.configuration, + OutputDirectory: params.overrideOutputDirectory, + SkipCodeAnalysis: skipCodeAnalysis, + SolutionPath: join(processor.context.exported, params.solution), + Target: params.target, + command: "compile", }; return dotnetbuilderwrapper(_.extend(compileParams, getAdditionalSigningParameters()), processor); -}; +}) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetpack.ts b/BuildServer/lib/tasks/dotnetnugetpack.ts index 736c0af..1deec62 100644 --- a/BuildServer/lib/tasks/dotnetnugetpack.ts +++ b/BuildServer/lib/tasks/dotnetnugetpack.ts @@ -3,9 +3,9 @@ import * as _ from "underscore"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; -export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { - "getFinalTask": (nupkg) => ({ - "params": { "filename": nupkg }, - "type": "copy" - }) -}), processor); +export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { + getFinalTask: (nupkg) => ({ + params: { filename: nupkg }, + type: "copy", + }), +}), processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetprocess.ts b/BuildServer/lib/tasks/dotnetnugetprocess.ts index 5576fed..30c851e 100644 --- a/BuildServer/lib/tasks/dotnetnugetprocess.ts +++ b/BuildServer/lib/tasks/dotnetnugetprocess.ts @@ -2,29 +2,29 @@ import conditional from "./conditional"; -export default (params, processor) => conditional({ - "branch": "master", - "otherwise": { - "name": "nuget-pack", - "params": { - "major": params.major, - "name": params.nuspecName, - "nuspec": `${params.nuspecName}.nuspec`, - "version": params.version, - "withoutCommitSha": params.withoutCommitSha +export default ((params, processor) => conditional({ + branch: "master", + otherwise: { + name: "nuget-pack", + params: { + major: params.major, + name: params.nuspecName, + nuspec: `${params.nuspecName}.nuspec`, + version: params.version, + withoutCommitSha: params.withoutCommitSha, }, - "type": "dotnetnugetpack" + type: "dotnetnugetpack", }, - "owner": params.masterRepoOwner, - "task": { - "name": "nuget-push", - "params": { - "major": params.major, - "name": params.nuspecName, - "nuspec": `${params.nuspecName}.nuspec`, - "version": params.version, - "withoutCommitSha": params.withoutCommitSha + owner: params.masterRepoOwner, + task: { + name: "nuget-push", + params: { + major: params.major, + name: params.nuspecName, + nuspec: `${params.nuspecName}.nuspec`, + version: params.version, + withoutCommitSha: params.withoutCommitSha, }, - "type": "dotnetnugetpush" - } -}, processor); + type: "dotnetnugetpush", + }, +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts index 2d8f8d7..0a279af 100644 --- a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts +++ b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts @@ -15,7 +15,7 @@ const addPostfix = (version, params, processor) => { return `${version}-r${processor.context.rev.substr(0, postfixLength)}`; }; -export default (params, processor) => { +export default ((params, processor) => { const date = new Date(); const major = params.major || "0"; const minor = (date.getFullYear() * fourDigits) + ((date.getMonth() + 1) * twoDigits) + date.getDate(); @@ -24,18 +24,18 @@ export default (params, processor) => { const nupkg = `${params.name}.${version}.nupkg`; return sequential({ - "tasks": [ + tasks: [ { - "params": { - "BaseDirectory": processor.context.exported, - "OutputDirectory": processor.context.exported, - "SpecPath": join(processor.context.exported, params.nuspec), - "Version": version, - "command": "nugetpack" + params: { + BaseDirectory: processor.context.exported, + OutputDirectory: processor.context.exported, + SpecPath: join(processor.context.exported, params.nuspec), + Version: version, + command: "nugetpack", }, - "type": "dotnetbuilderwrapper" + type: "dotnetbuilderwrapper", }, - params.getFinalTask(nupkg) - ] + params.getFinalTask(nupkg), + ], }, processor); -}; +}) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetpush.ts b/BuildServer/lib/tasks/dotnetnugetpush.ts index e3a5aae..0b228ea 100644 --- a/BuildServer/lib/tasks/dotnetnugetpush.ts +++ b/BuildServer/lib/tasks/dotnetnugetpush.ts @@ -3,9 +3,9 @@ import * as _ from "underscore"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; -export default (params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { - "getFinalTask": (nupkg) => ({ - "params": { "Package": nupkg }, - "type": "dotnetnugetpushonly" - }) -}), processor); +export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { + getFinalTask: (nupkg) => ({ + params: { Package: nupkg }, + type: "dotnetnugetpushonly", + }), +}), processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetpushonly.ts b/BuildServer/lib/tasks/dotnetnugetpushonly.ts index b1d9134..3243647 100644 --- a/BuildServer/lib/tasks/dotnetnugetpushonly.ts +++ b/BuildServer/lib/tasks/dotnetnugetpushonly.ts @@ -1,12 +1,13 @@ "use strict"; import { join } from "path"; -import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; + import settings from "../../settings"; +import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; -export default (params, processor) => dotnetbuilderwrapper({ - "ApiKey": settings.nugetApiKey, - "NugetHost": settings.nugetHost, - "Package": join(processor.context.exported, params.Package), - "command": "nugetpush" -}, processor); +export default ((params, processor) => dotnetbuilderwrapper({ + ApiKey: settings.nugetApiKey, + NugetHost: settings.nugetHost, + Package: join(processor.context.exported, params.Package), + command: "nugetpush", +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetnugetrestore.ts b/BuildServer/lib/tasks/dotnetnugetrestore.ts index 4e50f32..3cf6dd5 100644 --- a/BuildServer/lib/tasks/dotnetnugetrestore.ts +++ b/BuildServer/lib/tasks/dotnetnugetrestore.ts @@ -3,15 +3,15 @@ import { join } from "path"; import sequential from "./sequential"; -export default (params, processor) => sequential({ - "tasks": [ +export default ((params, processor) => sequential({ + tasks: [ { - "params": { - "BaseDirectory": processor.context.exported, - "SolutionPath": join(processor.context.exported, params.solution), - "command": "nugetrestore" + params: { + BaseDirectory: processor.context.exported, + SolutionPath: join(processor.context.exported, params.solution), + command: "nugetrestore", }, - "type": "dotnetbuilderwrapper" - } - ] -}, processor); + type: "dotnetbuilderwrapper", + }, + ], +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetnunit.ts b/BuildServer/lib/tasks/dotnetnunit.ts index 018ec23..c085f73 100644 --- a/BuildServer/lib/tasks/dotnetnunit.ts +++ b/BuildServer/lib/tasks/dotnetnunit.ts @@ -3,7 +3,7 @@ import { join } from "path"; import dotNetBuilderWrapper from "./dotnetbuilderwrapper"; -export default (params, processor) => dotNetBuilderWrapper({ - "TestLibraryPath": join(processor.context.exported, params.assembly), - "command": "nunit" -}, processor); +export default ((params, processor) => dotNetBuilderWrapper({ + TestLibraryPath: join(processor.context.exported, params.assembly), + command: "nunit", +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetnunitall.ts b/BuildServer/lib/tasks/dotnetnunitall.ts index ee1b269..75307c7 100644 --- a/BuildServer/lib/tasks/dotnetnunitall.ts +++ b/BuildServer/lib/tasks/dotnetnunitall.ts @@ -3,8 +3,8 @@ import * as glob from "glob"; const flagDoneName = "dotnetnunitallDone"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { if (processor.context.containsFlag(flagDoneName)) { processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -12,8 +12,8 @@ export default (params, processor) => ({ processor.context.addFlag(flagDoneName); glob("**/{bin,build}/**/*.{Tests,Test,UnitTests}.dll", { - "cwd": processor.context.exported, - "dot": true + cwd: processor.context.exported, + dot: true, }, (err, files) => { if (err) { processor.onError(err); @@ -28,15 +28,15 @@ export default (params, processor) => ({ } return processor.processTask({ - "params": { - "tasks": files.map((file) => ({ - "name": file, - "params": { "assembly": file }, - "type": "dotnetnunit" - })) + params: { + tasks: files.map((file) => ({ + name: file, + params: { assembly: file }, + type: "dotnetnunit", + })), }, - "type": (params.preventParallelTests && "sequential") || "parallel" + type: (params.preventParallelTests && "sequential") || "parallel", }, processor.done.bind(processor)); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/dotnetpackwebapp.ts b/BuildServer/lib/tasks/dotnetpackwebapp.ts index 08d7dfe..f401329 100644 --- a/BuildServer/lib/tasks/dotnetpackwebapp.ts +++ b/BuildServer/lib/tasks/dotnetpackwebapp.ts @@ -1,50 +1,47 @@ "use strict"; -import { join } from "path"; import { readFileSync } from "fs"; import { render } from "mustache"; +import { join } from "path"; import sequential from "./sequential"; -// eslint-disable-next-line no-sync -const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { "encoding": "utf8" }); -// eslint-disable-next-line no-sync -const deployTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.bat"), { "encoding": "utf8" }); -// eslint-disable-next-line no-sync -const versionTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { "encoding": "utf8" }); +const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { encoding: "utf8" }); +const deployTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.bat"), { encoding: "utf8" }); +const versionTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { encoding: "utf8" }); -export default (params, processor) => sequential({ - "tasks": [ +export default ((params, processor) => sequential({ + tasks: [ { - "params": { - "data": render(msbuildTemplate, params), - "filename": "MakePackage.msbuild" + params: { + data: render(msbuildTemplate, params), + filename: "MakePackage.msbuild", }, - "type": "writefile" + type: "writefile", }, { - "params": { - "data": render(deployTemplate, params), - "filename": "Deploy.bat" + params: { + data: render(deployTemplate, params), + filename: "Deploy.bat", }, - "type": "writefile" + type: "writefile", }, { - "params": { - "data": render(versionTemplate, params), - "filename": "version.aspx" + params: { + data: render(versionTemplate, params), + filename: "version.aspx", }, - "type": "writefile" + type: "writefile", }, { - "params": { - "configuration": params.configuration, - "isCodeAnalysisUnsupported": params.isCodeAnalysisUnsupported, - "overrideOutputDirectory": processor.context.release, - "skipCodeSigning": params.skipCodeSigning, - "solution": "MakePackage.msbuild", - "target": "Package" + params: { + configuration: params.configuration, + isCodeAnalysisUnsupported: params.isCodeAnalysisUnsupported, + overrideOutputDirectory: processor.context.release, + skipCodeSigning: params.skipCodeSigning, + solution: "MakePackage.msbuild", + target: "Package", }, - "type": "dotnetcompile" - } - ] -}, processor); + type: "dotnetcompile", + }, + ], +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/dotnetrewrite.ts b/BuildServer/lib/tasks/dotnetrewrite.ts index 1fccb6c..d917bae 100644 --- a/BuildServer/lib/tasks/dotnetrewrite.ts +++ b/BuildServer/lib/tasks/dotnetrewrite.ts @@ -1,9 +1,9 @@ "use strict"; -import { join } from "path"; -import { readFile, writeFile } from "fs"; import { parallel, waterfall } from "async"; +import { readFile, writeFile } from "fs"; import * as glob from "glob"; +import { join } from "path"; import settings from "../../settings"; const flagDoneName = "dotnetrewriterDone"; @@ -14,10 +14,10 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => ( return content; } - return content.replace( - /InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g, - (match, p1) => `InternalsVisibleTo("${p1},PublicKey=${settings.codeSigningPublicKey}")` - ); + const pattern = /InternalsVisibleTo\s*\(\s*"([\w.]+)"\s*\)/g; + const replacer = (match, p1) => `InternalsVisibleTo("${p1},PublicKey=${settings.codeSigningPublicKey}")`; + + return content.replace(pattern, replacer); }; const processInformationalVersion = (content) => { @@ -31,15 +31,15 @@ const processAssemblyInfo = (params, processor, appendInformationalVersion) => ( return cb(null, processInformationalVersion(processInternalsVisible(originalContent))); }; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { if (processor.context.containsFlag(flagDoneName)) { return processor.done(); } processor.context.addFlag(flagDoneName); - return glob("**/{InternalsVisible,AssemblyInfo}*.cs", { "cwd": processor.context.exported }, (globErr, files) => { + return glob("**/{InternalsVisible,AssemblyInfo}*.cs", { cwd: processor.context.exported }, (globErr, files) => { if (globErr) { processor.onError(globErr); @@ -55,9 +55,9 @@ export default (params, processor) => ({ } return parallel(files.map((file) => (callback) => waterfall([ - readFile.bind(null, join(processor.context.exported, file), { "encoding": "utf8" }), + readFile.bind(null, join(processor.context.exported, file), { encoding: "utf8" }), processAssemblyInfo(params, processor, file.toLowerCase().includes("assemblyinfo.cs")), - writeFile.bind(null, join(processor.context.exported, file)) + writeFile.bind(null, join(processor.context.exported, file)), ], (err) => { if (err) { processor.onError(`Unable to rewrite file ${file}: ${err}`); @@ -67,5 +67,5 @@ export default (params, processor) => ({ callback(err); })), processor.done.bind(processor)); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/echo.ts b/BuildServer/lib/tasks/echo.ts index e06d52c..65690d0 100644 --- a/BuildServer/lib/tasks/echo.ts +++ b/BuildServer/lib/tasks/echo.ts @@ -1,7 +1,7 @@ "use strict"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { if (params.error) { processor.onError(params.error); } @@ -15,5 +15,5 @@ export default (params, processor) => ({ } processor.done(); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/eslintbrowser.ts b/BuildServer/lib/tasks/eslintbrowser.ts index 6f13cb2..86cde65 100644 --- a/BuildServer/lib/tasks/eslintbrowser.ts +++ b/BuildServer/lib/tasks/eslintbrowser.ts @@ -1,14 +1,15 @@ "use strict"; -import { join } from "path"; import { CLIEngine } from "eslint"; +import { join } from "path"; import settings from "../../settings"; -const cli = new CLIEngine({ "configFile": settings.eslintBrowserConfig }); + +const cli = new CLIEngine({ configFile: settings.eslintBrowserConfig }); const errorSeverity = 2; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const filePath = join(processor.context.exported, params.filename); const result = cli.executeOnFiles([filePath]); @@ -27,6 +28,5 @@ export default (params, processor) => ({ }); processor.done(); - } -}); - + }, +})) as Task; diff --git a/BuildServer/lib/tasks/eslintbrowserall.ts b/BuildServer/lib/tasks/eslintbrowserall.ts index f03bd4d..0c4c6e4 100644 --- a/BuildServer/lib/tasks/eslintbrowserall.ts +++ b/BuildServer/lib/tasks/eslintbrowserall.ts @@ -3,8 +3,8 @@ import * as glob from "glob"; const flagDoneName = "eslintbrowserallDone"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { if (processor.context.containsFlag(flagDoneName)) { processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -14,8 +14,8 @@ export default (params, processor) => ({ const excludeFiles = params.excludeFiles || []; glob("**/*.js", { - "cwd": processor.context.exported, - "dot": true + cwd: processor.context.exported, + dot: true, }, (err, files) => { if (err) { processor.onError(err); @@ -24,15 +24,15 @@ export default (params, processor) => ({ } return processor.processTask({ - "params": { - "tasks": files.filter((file) => !excludeFiles.includes(file)).map((file) => ({ - "name": file, - "params": { "filename": file }, - "type": "eslintbrowser" - })) + params: { + tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({ + name: file, + params: { filename: file }, + type: "eslintbrowser", + })), }, - "type": (params.preventParallelTests && "sequential") || "parallel" + type: (params.preventParallelTests && "sequential") || "parallel", }, processor.done.bind(processor)); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/index.ts b/BuildServer/lib/tasks/index.ts index c53c39c..8c660da 100644 --- a/BuildServer/lib/tasks/index.ts +++ b/BuildServer/lib/tasks/index.ts @@ -1,15 +1,14 @@ "use strict"; -let tasks = {}; +import { readdirSync } from "fs"; + +const tasks: Tasks = {}; // Code taken from http://stackoverflow.com/a/17204293 -// eslint-disable-next-line no-sync -require("fs").readdirSync(__dirname) +readdirSync(__dirname) .forEach((file) => { if (file.match(/\.ts$/) !== null && file !== "index.ts") { const name = file.replace(".ts", ""); - - // eslint-disable-next-line global-require tasks[name] = require(`./${file}`).default; } }); diff --git a/BuildServer/lib/tasks/noop.ts b/BuildServer/lib/tasks/noop.ts index a5bad82..5726067 100644 --- a/BuildServer/lib/tasks/noop.ts +++ b/BuildServer/lib/tasks/noop.ts @@ -1,3 +1,3 @@ "use strict"; -export default (params, processor) => ({ "process": () => processor.done() }); +export default ((params, processor) => ({ process: () => processor.done() })) as Task; diff --git a/BuildServer/lib/tasks/packform.ts b/BuildServer/lib/tasks/packform.ts index fa4568f..c693b7a 100644 --- a/BuildServer/lib/tasks/packform.ts +++ b/BuildServer/lib/tasks/packform.ts @@ -2,27 +2,27 @@ import sequential from "./sequential"; -export default (params, processor) => sequential({ - "tasks": [ +export default ((params, processor) => sequential({ + tasks: [ { - "params": { "excludeFiles": params.eslintExcludeFiles }, - "type": "eslintbrowserall" + params: { excludeFiles: params.eslintExcludeFiles }, + type: "eslintbrowserall", }, - { "type": "uglifyjsall" }, - { "type": "cssnanoall" }, + { type: "uglifyjsall" }, + { type: "cssnanoall" }, { - "params": { - "data": processor.context.versionInfo, - "filename": "version.txt" + params: { + data: processor.context.versionInfo, + filename: "version.txt", }, - "type": "writefile" + type: "writefile", }, { - "params": { - "archive": `${processor.context.reponame}.zip`, - "directory": "" + params: { + archive: `${processor.context.reponame}.zip`, + directory: "", }, - "type": "zip" - } - ] -}, processor); + type: "zip", + }, + ], +}, processor)) as Task; diff --git a/BuildServer/lib/tasks/parallel.ts b/BuildServer/lib/tasks/parallel.ts index 0bb5943..bd59e11 100644 --- a/BuildServer/lib/tasks/parallel.ts +++ b/BuildServer/lib/tasks/parallel.ts @@ -4,4 +4,4 @@ import { parallel } from "async"; const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback); -export default (params, processor) => ({ "process": () => parallel(params.tasks.map(mapper(processor)), () => processor.done()) }); +export default ((params, processor) => ({ process: () => parallel(params.tasks.map(mapper(processor)), () => processor.done()) })) as Task; diff --git a/BuildServer/lib/tasks/sequential.ts b/BuildServer/lib/tasks/sequential.ts index 53ffbf6..cfdfe20 100644 --- a/BuildServer/lib/tasks/sequential.ts +++ b/BuildServer/lib/tasks/sequential.ts @@ -4,4 +4,4 @@ import { series } from "async"; const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback); -export default (params, processor) => ({ "process": () => series(params.tasks.map(mapper(processor)), () => processor.done()) }); +export default ((params, processor) => ({ process: () => series(params.tasks.map(mapper(processor)), () => processor.done()) })) as Task; diff --git a/BuildServer/lib/tasks/uglifyjs.ts b/BuildServer/lib/tasks/uglifyjs.ts index 6926d40..6ea71e0 100644 --- a/BuildServer/lib/tasks/uglifyjs.ts +++ b/BuildServer/lib/tasks/uglifyjs.ts @@ -4,8 +4,8 @@ import { writeFile } from "fs"; import { join, normalize } from "path"; import { minify } from "uglify-js"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const filePath = normalize(join(processor.context.exported, params.filename)); const result = minify(filePath); @@ -18,6 +18,5 @@ export default (params, processor) => ({ processor.done(); }); - } -}); - + }, +})) as Task; diff --git a/BuildServer/lib/tasks/uglifyjsall.ts b/BuildServer/lib/tasks/uglifyjsall.ts index cf634ea..1e2d281 100644 --- a/BuildServer/lib/tasks/uglifyjsall.ts +++ b/BuildServer/lib/tasks/uglifyjsall.ts @@ -4,8 +4,8 @@ import * as glob from "glob"; const doneFlagName = "uglifyjsallDone"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { if (processor.context.containsFlag(doneFlagName)) { processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -13,8 +13,8 @@ export default (params, processor) => ({ processor.context.addFlag(doneFlagName); glob("**/*.js", { - "cwd": processor.context.exported, - "dot": true + cwd: processor.context.exported, + dot: true, }, (err, files) => { if (err) { processor.onError(err); @@ -23,15 +23,15 @@ export default (params, processor) => ({ } return processor.processTask({ - "params": { - "tasks": files.map((file) => ({ - "name": file, - "params": { "filename": file }, - "type": "uglifyjs" - })) + params: { + tasks: files.map((file) => ({ + name: file, + params: { filename: file }, + type: "uglifyjs", + })), }, - "type": (params.preventParallelTests && "sequential") || "parallel" + type: (params.preventParallelTests && "sequential") || "parallel", }, processor.done.bind(processor)); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/writefile.ts b/BuildServer/lib/tasks/writefile.ts index d20c696..46dda79 100644 --- a/BuildServer/lib/tasks/writefile.ts +++ b/BuildServer/lib/tasks/writefile.ts @@ -3,8 +3,8 @@ import { writeFile } from "fs"; import { join } from "path"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const filePath = join(processor.context.exported, params.filename); processor.onInfo(`Writing to ${filePath}`); @@ -18,5 +18,5 @@ export default (params, processor) => ({ return processor.done(); }); - } -}); + }, +})) as Task; diff --git a/BuildServer/lib/tasks/zip.ts b/BuildServer/lib/tasks/zip.ts index 5c2a476..20b1ccb 100644 --- a/BuildServer/lib/tasks/zip.ts +++ b/BuildServer/lib/tasks/zip.ts @@ -1,11 +1,11 @@ "use strict"; +import { create as createArchiver } from "archiver"; import { createWriteStream } from "fs"; import { join, normalize } from "path"; -import { create as createArchiver } from "archiver"; -export default (params, processor) => ({ - "process": () => { +export default ((params, processor) => ({ + process: () => { const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || ""))); const targetArchivePath = normalize(join(processor.context.release, params.archive)); @@ -20,5 +20,5 @@ export default (params, processor) => ({ archive.pipe(output); archive.directory(sourceDirectoryPath, false); archive.finalize(); - } -}); + }, +})) as Task; diff --git a/BuildServer/package.json b/BuildServer/package.json index a3087d6..8dd25bc 100644 --- a/BuildServer/package.json +++ b/BuildServer/package.json @@ -4,9 +4,9 @@ "private": true, "scripts": { "start": "forever -c node app.js", - "build": "./node_modules/.bin/tsc -p .", + "build": "./node_modules/.bin/tsc -p . --noEmitOnError", "pretest": "./node_modules/.bin/tsc -p . --noEmit", - "test": "./node_modules/.bin/tslint --project tsconfig.json --type-check" + "test": "./node_modules/.bin/tslint --config tslint.json --project tsconfig.json --type-check" }, "dependencies": { "archiver": "^1.3.0", @@ -52,6 +52,7 @@ "@types/uglify-js": "^2.6.28", "@types/underscore": "^1.7.36", "tslint": "^4.4.2", + "tslint-eslint-rules": "^3.4.0", "typescript": "^2.2.1" } } diff --git a/BuildServer/routes/artifact.ts b/BuildServer/routes/artifact.ts index d32e6b2..b1546fb 100644 --- a/BuildServer/routes/artifact.ts +++ b/BuildServer/routes/artifact.ts @@ -2,12 +2,12 @@ export default (req, res) => { const options = { - "branch": `/refs/heads/${req.params.branch}`, - "branchName": req.params.branch, - "file": req.params[0], - "owner": req.params.owner, - "reponame": req.params.reponame, - "rev": req.params.rev + branch: `/refs/heads/${req.params.branch}`, + branchName: req.params.branch, + file: req.params[0], + owner: req.params.owner, + reponame: req.params.reponame, + rev: req.params.rev, }; const pathParts = [req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev, options.file]; diff --git a/BuildServer/routes/index.ts b/BuildServer/routes/index.ts index ce1c912..125109f 100644 --- a/BuildServer/routes/index.ts +++ b/BuildServer/routes/index.ts @@ -1,12 +1,11 @@ "use strict"; -import postreceive from "./postreceive"; -import * as manual from "./manual"; -import * as status from "./status"; import artifact from "./artifact"; +import * as manual from "./manual"; +import postreceive from "./postreceive"; import release from "./release"; +import * as status from "./status"; -const index = (req, res) => res.render("index", { "title": `Express
\r\n${req}` }); +const index = (req, res) => res.render("index", { title: `Express
\r\n${req}` }); export { index, postreceive, manual, status, artifact, release }; - diff --git a/BuildServer/routes/manual.ts b/BuildServer/routes/manual.ts index ae4c86d..c9f7cc2 100644 --- a/BuildServer/routes/manual.ts +++ b/BuildServer/routes/manual.ts @@ -7,8 +7,8 @@ export const get = (req, res) => res.render("manual"); export const post = (req, res) => { const options = _.extend(req.body, { - "app": req.app, - "url": `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}` + app: req.app, + url: `https://pos-github.payonline.ru/${req.body.owner}/${req.body.reponame}`, }); build(options, (err, result) => { @@ -16,7 +16,7 @@ export const post = (req, res) => { console.log(`Error: ${err}`); res.render("manual-done", { err, - result + result, }); }); -}; \ No newline at end of file +}; diff --git a/BuildServer/routes/postreceive.ts b/BuildServer/routes/postreceive.ts index 504516d..92a3546 100644 --- a/BuildServer/routes/postreceive.ts +++ b/BuildServer/routes/postreceive.ts @@ -9,12 +9,12 @@ const getBranchDescription = (options) => `${options.owner}/${options.reponame}: const processPush = (req, res, payload) => { const repository = payload.repository; const options = { - "app": req.app, - "branch": payload.ref, - "owner": repository.owner.name, - "reponame": repository.name, - "rev": payload.after, - "url": repository.url + app: req.app, + branch: payload.ref, + owner: repository.owner.name, + reponame: repository.name, + rev: payload.after, + url: repository.url, }; console.log(`Got push event for ${getBranchDescription(options)}`); @@ -33,33 +33,33 @@ const processPullRequest = (req, res, payload) => { const head = pullRequest.head; const headRepo = head.repo; const headRepoOptions = { - "branch": `refs/heads/${head.ref}`, - "branchname": head.ref, - "owner": headRepo.owner.name || headRepo.owner.login, - "reponame": headRepo.name, - "rev": head.sha, - "url": headRepo.url + branch: `refs/heads/${head.ref}`, + branchname: head.ref, + owner: headRepo.owner.name || headRepo.owner.login, + reponame: headRepo.name, + rev: head.sha, + url: headRepo.url, }; const base = pullRequest.base; const baseRepo = base.repo; const baseRepoOptions = { - "branchname": base.ref, - "owner": baseRepo.owner.name || baseRepo.owner.login, - "reponame": baseRepo.name + branchname: base.ref, + owner: baseRepo.owner.name || baseRepo.owner.login, + reponame: baseRepo.name, }; const options = { action, - "app": req.app, + app: req.app, baseRepoOptions, headRepoOptions, - pullRequestNumber + pullRequestNumber, }; const masterOptions = { action, - "app": req.app, + app: req.app, baseRepoOptions, - "headRepoOptions": baseRepoOptions, - pullRequestNumber + headRepoOptions: baseRepoOptions, + pullRequestNumber, }; console.log(`Got pull request ${action} event, ` @@ -79,16 +79,13 @@ const processPullRequest = (req, res, payload) => { return res.send(""); } - return commentOnPullRequest( - (action === "closed" && masterOptions) || options, - (err, data) => { - if (err) { - console.log(`Unable to post comment: ${err}`); - } - - res.send(err || data); + return commentOnPullRequest((action === "closed" && masterOptions) || options, (err, data) => { + if (err) { + console.log(`Unable to post comment: ${err}`); } - ); + + res.send(err || data); + }); }; const getPayload = (body) => { diff --git a/BuildServer/routes/release.ts b/BuildServer/routes/release.ts index c4d5f0c..467c2b9 100644 --- a/BuildServer/routes/release.ts +++ b/BuildServer/routes/release.ts @@ -1,7 +1,7 @@ "use strict"; -import { join } from "path"; import { create as createArchiver } from "archiver"; +import { join } from "path"; import { readReport } from "../lib/report-processor"; @@ -25,11 +25,11 @@ const getDatePart = (report) => { export default (req, res, next) => { const options = { - "branch": `/refs/heads/${req.params.branch}`, - "branchName": req.params.branch, - "owner": req.params.owner, - "reponame": req.params.reponame, - "rev": req.params.rev + branch: `/refs/heads/${req.params.branch}`, + branchName: req.params.branch, + owner: req.params.owner, + reponame: req.params.reponame, + rev: req.params.rev, }; const releasePath = join(req.app.get("releasepath"), options.owner, options.reponame, options.branch, options.rev); diff --git a/BuildServer/routes/status.ts b/BuildServer/routes/status.ts index bea269f..11bd3a6 100644 --- a/BuildServer/routes/status.ts +++ b/BuildServer/routes/status.ts @@ -1,7 +1,8 @@ "use strict"; -import { parse } from "url"; import * as _ from "underscore"; +import { parse } from "url"; + import { getReport } from "../lib/status-processor"; const parseOptionsFromReferer = (path, callback) => { @@ -19,7 +20,7 @@ const parseOptionsFromReferer = (path, callback) => { branchName, owner, reponame, - rev + rev, }); } @@ -29,7 +30,7 @@ const parseOptionsFromReferer = (path, callback) => { branchName, owner, reponame, - rev + rev, }); }; @@ -42,24 +43,24 @@ const createShowReport = (res) => (err, inputOptions) => { export const image = (req, res) => { const getAdditionalOptions = (err, options) => { if (err === "ReportFileNotFound") { - return { "status": "Building" }; + return { status: "Building" }; } if (err) { return { - "message": err, - "status": "StatusError" + message: err, + status: "StatusError", }; } if (options.report.result === "MBSNotFound") { - return { "status": "MBSNotUsed" }; + return { status: "MBSNotUsed" }; } if (options.report.err) { return { - "message": options.report.err, - "status": "Error" + message: options.report.err, + status: "Error", }; } @@ -67,8 +68,8 @@ export const image = (req, res) => { const [firstWarn] = options.report.result.warns.$allMessages; return { - "message": firstWarn.message, - "status": "Warning" + message: firstWarn.message, + status: "Warning", }; } @@ -76,12 +77,12 @@ export const image = (req, res) => { if (allInfos.length) { return { - "message": allInfos[allInfos.length - 1].message, - "status": "OK" + message: allInfos[allInfos.length - 1].message, + status: "OK", }; } - return { "status": "OK" }; + return { status: "OK" }; }; const handle = (err, options) => { @@ -100,11 +101,11 @@ export const image = (req, res) => { export const page = (req, res) => { const options = { - "branch": `/refs/heads/${req.params.branch}`, - "branchName": req.params.branch, - "owner": req.params.owner, - "reponame": req.params.reponame, - "rev": req.params.rev + branch: `/refs/heads/${req.params.branch}`, + branchName: req.params.branch, + owner: req.params.owner, + reponame: req.params.reponame, + rev: req.params.rev, }; getReport(req.app, options, createShowReport(res)); diff --git a/BuildServer/tsconfig.json b/BuildServer/tsconfig.json index 4ce9f95..c99c2ba 100644 --- a/BuildServer/tsconfig.json +++ b/BuildServer/tsconfig.json @@ -3,12 +3,14 @@ "module": "commonjs", "target": "es6", "sourceMap": false, + "strictNullChecks": true, "typeRoots": [ "node_modules/@types" ] }, "include": [ "app.ts", + "global.d.ts", "settings.ts", "lib/**/*.ts", "routes/**/*.ts" diff --git a/BuildServer/tslint.json b/BuildServer/tslint.json index 1a58f91..0af5928 100644 --- a/BuildServer/tslint.json +++ b/BuildServer/tslint.json @@ -1,101 +1,10 @@ { - "jsRules": { - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "indent": [ - true, - "spaces" - ], - "no-duplicate-variable": true, - "no-eval": true, - "no-trailing-whitespace": true, - "no-unsafe-finally": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "double" - ], - "semicolon": [ - true, - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "variable-name": [ - true, - "ban-keywords" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - }, + "extends": [ + "tslint:latest", + "tslint-eslint-rules" + ], "rules": { - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "indent": [ - true, - "spaces" - ], - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-unsafe-finally": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "double" - ], - "semicolon": [ - true, - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": [ - true, - "ban-keywords" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] + "no-console": false, + "max-line-length": false } } \ No newline at end of file