From d63cdf06c58be21be888e5279ab4712a22e86947 Mon Sep 17 00:00:00 2001 From: Inga Lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Wed, 1 Mar 2017 17:33:16 +0300 Subject: [PATCH] Refactored type declarations --- BuildServer/lib/builder.ts | 1 + BuildServer/lib/report-processor.ts | 2 ++ BuildServer/lib/task-processor.ts | 2 ++ BuildServer/lib/tasks/cleanupafterdotnetbuild.ts | 2 ++ BuildServer/lib/tasks/conditional.ts | 2 ++ BuildServer/lib/tasks/copy.ts | 2 ++ BuildServer/lib/tasks/copyglob.ts | 2 ++ BuildServer/lib/tasks/cssnano.ts | 2 ++ BuildServer/lib/tasks/cssnanoall.ts | 3 +++ BuildServer/lib/tasks/deletefromcode.ts | 2 ++ BuildServer/lib/tasks/dotnetbuild.ts | 1 + BuildServer/lib/tasks/dotnetbuildandtest.ts | 1 + BuildServer/lib/tasks/dotnetbuilderwrapper.ts | 1 + BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts | 1 + BuildServer/lib/tasks/dotnetcheckstyle.ts | 2 ++ BuildServer/lib/tasks/dotnetcompile.ts | 2 ++ BuildServer/lib/tasks/dotnetnugetpack.ts | 2 ++ BuildServer/lib/tasks/dotnetnugetprocess.ts | 1 + BuildServer/lib/tasks/dotnetnugetprocessinternal.ts | 2 ++ BuildServer/lib/tasks/dotnetnugetpush.ts | 2 ++ BuildServer/lib/tasks/dotnetnugetpushonly.ts | 1 + BuildServer/lib/tasks/dotnetnugetrestore.ts | 2 ++ BuildServer/lib/tasks/dotnetnunit.ts | 2 ++ BuildServer/lib/tasks/dotnetnunitall.ts | 3 +++ BuildServer/lib/tasks/dotnetpackwebapp.ts | 2 ++ BuildServer/lib/tasks/dotnetrewrite.ts | 2 ++ BuildServer/lib/tasks/echo.ts | 2 ++ BuildServer/lib/tasks/eslintbrowser.ts | 2 ++ BuildServer/lib/tasks/eslintbrowserall.ts | 3 +++ BuildServer/lib/tasks/index.ts | 2 ++ BuildServer/lib/tasks/noop.ts | 2 ++ BuildServer/lib/tasks/packform.ts | 1 + BuildServer/lib/tasks/parallel.ts | 2 ++ BuildServer/lib/tasks/sequential.ts | 2 ++ BuildServer/lib/tasks/uglifyjs.ts | 2 ++ BuildServer/lib/tasks/uglifyjsall.ts | 2 ++ BuildServer/lib/tasks/writefile.ts | 2 ++ BuildServer/lib/tasks/zip.ts | 2 ++ BuildServer/{global.d.ts => types.d.ts} | 13 +++++++++++++ 39 files changed, 84 insertions(+) rename BuildServer/{global.d.ts => types.d.ts} (90%) diff --git a/BuildServer/lib/builder.ts b/BuildServer/lib/builder.ts index 75bb213..2df82aa 100644 --- a/BuildServer/lib/builder.ts +++ b/BuildServer/lib/builder.ts @@ -7,6 +7,7 @@ import * as JSONParse from "json-parse-safe"; import { join } from "path"; import settings from "../settings"; +import { ReportResult } from "../types"; import { gitLoader } from "./git/loader"; import { send as sendMail } from "./mail-sender"; import { writeReport } from "./report-processor"; diff --git a/BuildServer/lib/report-processor.ts b/BuildServer/lib/report-processor.ts index 1bc5b92..52520b8 100644 --- a/BuildServer/lib/report-processor.ts +++ b/BuildServer/lib/report-processor.ts @@ -8,6 +8,8 @@ import { ReadableStreamBuffer, WritableStreamBuffer } from "stream-buffers"; import * as _ from "underscore"; import { createGunzip, createGzip } from "zlib"; +import { Message, Report, ReportResult } from "../types"; + const reportFilename = "report.json.gz"; const maxAttemptsNumber = 100; const attemptsTimeout = 30000; diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts index 5a60450..f08f2c1 100644 --- a/BuildServer/lib/task-processor.ts +++ b/BuildServer/lib/task-processor.ts @@ -1,6 +1,8 @@ "use strict"; import * as _ from "underscore"; + +import { MessagesRoot, TaskInfo, TaskProcessor, TaskProcessorCallback, TaskProcessorCore } from "../types"; import tasks from "./tasks"; // TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here. diff --git a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts index 0c576b3..3ce6a4f 100644 --- a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts +++ b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts @@ -2,6 +2,8 @@ import * as glob from "glob"; +import { Task } from "../../types"; + export default ((params, processor) => () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", { cwd: processor.context.exported, dot: true, diff --git a/BuildServer/lib/tasks/conditional.ts b/BuildServer/lib/tasks/conditional.ts index 4bf70d8..428bec3 100644 --- a/BuildServer/lib/tasks/conditional.ts +++ b/BuildServer/lib/tasks/conditional.ts @@ -1,5 +1,7 @@ "use strict"; +import { Task } from "../../types"; + 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); diff --git a/BuildServer/lib/tasks/copy.ts b/BuildServer/lib/tasks/copy.ts index 589c67b..017eb3f 100644 --- a/BuildServer/lib/tasks/copy.ts +++ b/BuildServer/lib/tasks/copy.ts @@ -3,6 +3,8 @@ import { copy } from "fs-extra"; import { join } from "path"; +import { Task } from "../../types"; + export default ((params, processor) => () => { const sourceFilePath = join(processor.context.exported, params.filename); const targetFilePath = join(processor.context.release, params.filename); diff --git a/BuildServer/lib/tasks/copyglob.ts b/BuildServer/lib/tasks/copyglob.ts index b284971..d717abe 100644 --- a/BuildServer/lib/tasks/copyglob.ts +++ b/BuildServer/lib/tasks/copyglob.ts @@ -2,6 +2,8 @@ import * as glob from "glob"; +import { Task } from "../../types"; + export default ((params, processor) => () => glob(params.mask, { cwd: processor.context.exported, dot: true, diff --git a/BuildServer/lib/tasks/cssnano.ts b/BuildServer/lib/tasks/cssnano.ts index 7c4497c..6e616a1 100644 --- a/BuildServer/lib/tasks/cssnano.ts +++ b/BuildServer/lib/tasks/cssnano.ts @@ -4,6 +4,8 @@ import { process as cssnanoProcess } from "cssnano"; import { readFile, writeFile } from "fs"; import { join } from "path"; +import { Task } from "../../types"; + export default ((params, processor) => () => { const filePath = join(processor.context.exported, params.filename); diff --git a/BuildServer/lib/tasks/cssnanoall.ts b/BuildServer/lib/tasks/cssnanoall.ts index 30a229f..72e683f 100644 --- a/BuildServer/lib/tasks/cssnanoall.ts +++ b/BuildServer/lib/tasks/cssnanoall.ts @@ -1,6 +1,9 @@ "use strict"; import * as glob from "glob"; + +import { Task } from "../../types"; + const flagDoneName = "cssnanoallDone"; export default ((params, processor) => () => { diff --git a/BuildServer/lib/tasks/deletefromcode.ts b/BuildServer/lib/tasks/deletefromcode.ts index be12fe3..848dc81 100644 --- a/BuildServer/lib/tasks/deletefromcode.ts +++ b/BuildServer/lib/tasks/deletefromcode.ts @@ -3,6 +3,8 @@ import { remove } from "fs-extra"; import { join } from "path"; +import { Task } from "../../types"; + export default ((params, processor) => () => { const sourceFilePath = join(processor.context.exported, params.filename); diff --git a/BuildServer/lib/tasks/dotnetbuild.ts b/BuildServer/lib/tasks/dotnetbuild.ts index 8b474cd..90c38cf 100644 --- a/BuildServer/lib/tasks/dotnetbuild.ts +++ b/BuildServer/lib/tasks/dotnetbuild.ts @@ -1,5 +1,6 @@ "use strict"; +import { Task } from "../../types"; import sequential from "./sequential"; export default ((params, processor) => sequential({ diff --git a/BuildServer/lib/tasks/dotnetbuildandtest.ts b/BuildServer/lib/tasks/dotnetbuildandtest.ts index 292dc58..247beb4 100644 --- a/BuildServer/lib/tasks/dotnetbuildandtest.ts +++ b/BuildServer/lib/tasks/dotnetbuildandtest.ts @@ -1,5 +1,6 @@ "use strict"; +import { Task } from "../../types"; import sequential from "./sequential"; export default ((params, processor) => sequential({ diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts index d3a970d..b65a477 100644 --- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts +++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts @@ -5,6 +5,7 @@ import * as JSONParse from "json-parse-safe"; import { WritableStreamBuffer } from "stream-buffers"; import settings from "../../settings"; +import { Task } from "../../types"; const wrapBuilder = (builder, input, onExit) => { const stdoutPromise = new Promise((resolve, reject) => { diff --git a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts index 7742516..88b2657 100644 --- a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts +++ b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts @@ -1,5 +1,6 @@ "use strict"; +import { Task } from "../../types"; import sequential from "./sequential"; const createTasks = function *(params) { diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.ts b/BuildServer/lib/tasks/dotnetcheckstyle.ts index 0ab841e..473f009 100644 --- a/BuildServer/lib/tasks/dotnetcheckstyle.ts +++ b/BuildServer/lib/tasks/dotnetcheckstyle.ts @@ -5,6 +5,8 @@ import { readFile } from "fs"; import * as glob from "glob"; import { join } from "path"; +import { Task } from "../../types"; + const autoGeneratedMarker = "//------------------------------------------------------------------------------\n" + "// "; diff --git a/BuildServer/lib/tasks/dotnetcompile.ts b/BuildServer/lib/tasks/dotnetcompile.ts index b77e236..ecdc2ff 100644 --- a/BuildServer/lib/tasks/dotnetcompile.ts +++ b/BuildServer/lib/tasks/dotnetcompile.ts @@ -2,7 +2,9 @@ import { join } from "path"; import * as _ from "underscore"; + import settings from "../../settings"; +import { Task } from "../../types"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; export default ((params, processor) => { diff --git a/BuildServer/lib/tasks/dotnetnugetpack.ts b/BuildServer/lib/tasks/dotnetnugetpack.ts index 1deec62..776361a 100644 --- a/BuildServer/lib/tasks/dotnetnugetpack.ts +++ b/BuildServer/lib/tasks/dotnetnugetpack.ts @@ -1,6 +1,8 @@ "use strict"; import * as _ from "underscore"; + +import { Task } from "../../types"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { diff --git a/BuildServer/lib/tasks/dotnetnugetprocess.ts b/BuildServer/lib/tasks/dotnetnugetprocess.ts index 30c851e..1b5042d 100644 --- a/BuildServer/lib/tasks/dotnetnugetprocess.ts +++ b/BuildServer/lib/tasks/dotnetnugetprocess.ts @@ -1,5 +1,6 @@ "use strict"; +import { Task } from "../../types"; import conditional from "./conditional"; export default ((params, processor) => conditional({ diff --git a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts index 0a279af..1b80e79 100644 --- a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts +++ b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts @@ -1,6 +1,8 @@ "use strict"; import { join } from "path"; + +import { Task } from "../../types"; import sequential from "./sequential"; const postfixLength = 16; diff --git a/BuildServer/lib/tasks/dotnetnugetpush.ts b/BuildServer/lib/tasks/dotnetnugetpush.ts index 0b228ea..377c9f2 100644 --- a/BuildServer/lib/tasks/dotnetnugetpush.ts +++ b/BuildServer/lib/tasks/dotnetnugetpush.ts @@ -1,6 +1,8 @@ "use strict"; import * as _ from "underscore"; + +import { Task } from "../../types"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; export default ((params, processor) => dotnetnugetprocessinternal(_.extendOwn(params, { diff --git a/BuildServer/lib/tasks/dotnetnugetpushonly.ts b/BuildServer/lib/tasks/dotnetnugetpushonly.ts index 3243647..a18684f 100644 --- a/BuildServer/lib/tasks/dotnetnugetpushonly.ts +++ b/BuildServer/lib/tasks/dotnetnugetpushonly.ts @@ -3,6 +3,7 @@ import { join } from "path"; import settings from "../../settings"; +import { Task } from "../../types"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; export default ((params, processor) => dotnetbuilderwrapper({ diff --git a/BuildServer/lib/tasks/dotnetnugetrestore.ts b/BuildServer/lib/tasks/dotnetnugetrestore.ts index 3cf6dd5..27b8e3a 100644 --- a/BuildServer/lib/tasks/dotnetnugetrestore.ts +++ b/BuildServer/lib/tasks/dotnetnugetrestore.ts @@ -1,6 +1,8 @@ "use strict"; import { join } from "path"; + +import { Task } from "../../types"; import sequential from "./sequential"; export default ((params, processor) => sequential({ diff --git a/BuildServer/lib/tasks/dotnetnunit.ts b/BuildServer/lib/tasks/dotnetnunit.ts index c085f73..e1733f4 100644 --- a/BuildServer/lib/tasks/dotnetnunit.ts +++ b/BuildServer/lib/tasks/dotnetnunit.ts @@ -1,6 +1,8 @@ "use strict"; import { join } from "path"; + +import { Task } from "../../types"; import dotNetBuilderWrapper from "./dotnetbuilderwrapper"; export default ((params, processor) => dotNetBuilderWrapper({ diff --git a/BuildServer/lib/tasks/dotnetnunitall.ts b/BuildServer/lib/tasks/dotnetnunitall.ts index bc3ddf7..17e743d 100644 --- a/BuildServer/lib/tasks/dotnetnunitall.ts +++ b/BuildServer/lib/tasks/dotnetnunitall.ts @@ -1,6 +1,9 @@ "use strict"; import * as glob from "glob"; + +import { Task } from "../../types"; + const flagDoneName = "dotnetnunitallDone"; export default ((params, processor) => () => { diff --git a/BuildServer/lib/tasks/dotnetpackwebapp.ts b/BuildServer/lib/tasks/dotnetpackwebapp.ts index f401329..0d1fb6a 100644 --- a/BuildServer/lib/tasks/dotnetpackwebapp.ts +++ b/BuildServer/lib/tasks/dotnetpackwebapp.ts @@ -3,6 +3,8 @@ import { readFileSync } from "fs"; import { render } from "mustache"; import { join } from "path"; + +import { Task } from "../../types"; import sequential from "./sequential"; const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.msbuild"), { encoding: "utf8" }); diff --git a/BuildServer/lib/tasks/dotnetrewrite.ts b/BuildServer/lib/tasks/dotnetrewrite.ts index ec8ebdf..31cb5be 100644 --- a/BuildServer/lib/tasks/dotnetrewrite.ts +++ b/BuildServer/lib/tasks/dotnetrewrite.ts @@ -4,7 +4,9 @@ import { parallel, waterfall } from "async"; import { readFile, writeFile } from "fs"; import * as glob from "glob"; import { join } from "path"; + import settings from "../../settings"; +import { Task } from "../../types"; const flagDoneName = "dotnetrewriterDone"; diff --git a/BuildServer/lib/tasks/echo.ts b/BuildServer/lib/tasks/echo.ts index a5b3e2e..4317b0c 100644 --- a/BuildServer/lib/tasks/echo.ts +++ b/BuildServer/lib/tasks/echo.ts @@ -1,5 +1,7 @@ "use strict"; +import { Task } from "../../types"; + export default ((params, processor) => () => { if (params.error) { processor.onError(params.error); diff --git a/BuildServer/lib/tasks/eslintbrowser.ts b/BuildServer/lib/tasks/eslintbrowser.ts index 229d70b..2885842 100644 --- a/BuildServer/lib/tasks/eslintbrowser.ts +++ b/BuildServer/lib/tasks/eslintbrowser.ts @@ -2,7 +2,9 @@ import { CLIEngine } from "eslint"; import { join } from "path"; + import settings from "../../settings"; +import { Task } from "../../types"; const cli = new CLIEngine({ configFile: settings.eslintBrowserConfig }); diff --git a/BuildServer/lib/tasks/eslintbrowserall.ts b/BuildServer/lib/tasks/eslintbrowserall.ts index 253bb79..8f6aa08 100644 --- a/BuildServer/lib/tasks/eslintbrowserall.ts +++ b/BuildServer/lib/tasks/eslintbrowserall.ts @@ -1,6 +1,9 @@ "use strict"; import * as glob from "glob"; + +import { Task } from "../../types"; + const flagDoneName = "eslintbrowserallDone"; export default ((params, processor) => () => { diff --git a/BuildServer/lib/tasks/index.ts b/BuildServer/lib/tasks/index.ts index e182886..d154c17 100644 --- a/BuildServer/lib/tasks/index.ts +++ b/BuildServer/lib/tasks/index.ts @@ -3,6 +3,8 @@ import { readdirSync } from "fs"; import * as _ from "underscore"; +import { Tasks } from "../../types"; + const taskNames = _.unique(readdirSync(__dirname).map((file) => { if (file.match(/\.ts$/) !== null) { return file.substr(0, file.length - 3); diff --git a/BuildServer/lib/tasks/noop.ts b/BuildServer/lib/tasks/noop.ts index 88ab43c..c81d511 100644 --- a/BuildServer/lib/tasks/noop.ts +++ b/BuildServer/lib/tasks/noop.ts @@ -1,3 +1,5 @@ "use strict"; +import { Task } from "../../types"; + export default ((params, processor) => processor.done()) as Task; diff --git a/BuildServer/lib/tasks/packform.ts b/BuildServer/lib/tasks/packform.ts index c693b7a..efb57a1 100644 --- a/BuildServer/lib/tasks/packform.ts +++ b/BuildServer/lib/tasks/packform.ts @@ -1,5 +1,6 @@ "use strict"; +import { Task } from "../../types"; import sequential from "./sequential"; export default ((params, processor) => sequential({ diff --git a/BuildServer/lib/tasks/parallel.ts b/BuildServer/lib/tasks/parallel.ts index f195df4..f7a0ee9 100644 --- a/BuildServer/lib/tasks/parallel.ts +++ b/BuildServer/lib/tasks/parallel.ts @@ -2,6 +2,8 @@ import { parallel } from "async"; +import { Task } from "../../types"; + const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback); export default ((params, processor) => () => 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 6536bd5..0f21987 100644 --- a/BuildServer/lib/tasks/sequential.ts +++ b/BuildServer/lib/tasks/sequential.ts @@ -2,6 +2,8 @@ import { series } from "async"; +import { Task } from "../../types"; + const mapper = (processor) => (task) => (callback) => processor.processTask(task, callback); export default ((params, processor) => () => 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 d7857a9..19ca352 100644 --- a/BuildServer/lib/tasks/uglifyjs.ts +++ b/BuildServer/lib/tasks/uglifyjs.ts @@ -4,6 +4,8 @@ import { writeFile } from "fs"; import { join, normalize } from "path"; import { minify } from "uglify-js"; +import { Task } from "../../types"; + export default ((params, processor) => () => { const filePath = normalize(join(processor.context.exported, params.filename)); const result = minify(filePath); diff --git a/BuildServer/lib/tasks/uglifyjsall.ts b/BuildServer/lib/tasks/uglifyjsall.ts index 195cd55..859f5b6 100644 --- a/BuildServer/lib/tasks/uglifyjsall.ts +++ b/BuildServer/lib/tasks/uglifyjsall.ts @@ -2,6 +2,8 @@ import * as glob from "glob"; +import { Task } from "../../types"; + const doneFlagName = "uglifyjsallDone"; export default ((params, processor) => () => { diff --git a/BuildServer/lib/tasks/writefile.ts b/BuildServer/lib/tasks/writefile.ts index cc0b8ac..60d7c1b 100644 --- a/BuildServer/lib/tasks/writefile.ts +++ b/BuildServer/lib/tasks/writefile.ts @@ -3,6 +3,8 @@ import { writeFile } from "fs"; import { join } from "path"; +import { Task } from "../../types"; + export default ((params, processor) => () => { const filePath = join(processor.context.exported, params.filename); diff --git a/BuildServer/lib/tasks/zip.ts b/BuildServer/lib/tasks/zip.ts index 4ffd10a..2aceaff 100644 --- a/BuildServer/lib/tasks/zip.ts +++ b/BuildServer/lib/tasks/zip.ts @@ -4,6 +4,8 @@ import { create as createArchiver } from "archiver"; import { createWriteStream } from "fs"; import { join, normalize } from "path"; +import { Task } from "../../types"; + export default ((params, processor) => () => { const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || ""))); const targetArchivePath = normalize(join(processor.context.release, params.archive)); diff --git a/BuildServer/global.d.ts b/BuildServer/types.d.ts similarity index 90% rename from BuildServer/global.d.ts rename to BuildServer/types.d.ts index 7c05f6a..3a4ae52 100644 --- a/BuildServer/global.d.ts +++ b/BuildServer/types.d.ts @@ -62,3 +62,16 @@ interface Task { interface Tasks { readonly [taskName: string]: Task; } + +export { + Message, + MessagesRoot, + Report, + ReportResult, + Task, + TaskInfo, + TaskProcessor, + TaskProcessorCore, + TaskProcessorCallback, + Tasks +}