diff --git a/BuildServer/lib/task-processor.ts b/BuildServer/lib/task-processor.ts index 8623e9c..5106001 100644 --- a/BuildServer/lib/task-processor.ts +++ b/BuildServer/lib/task-processor.ts @@ -9,15 +9,20 @@ interface IFlags { const isExternalTask = (task: TaskInfo): task is TaskInfoExternal => (task as TaskInfoExternal).type !== undefined; +let tasksCount = 0; + // TaskProcessor does not look like EventEmitter, so no need to extend EventEmitter and use `emit' here. const createTaskProcessor = (task: TaskInfo, outerProcessor: TaskProcessorCore, callback: TaskProcessorCallback) => { + const taskId = tasksCount++; const errors: string[] = []; + const name = task.name || (isExternalTask(task) ? task.type : null); + const nameWithId = String(name || "") + "#" + taskId; const getOuterPrefix = (prefix?: string) => { - if (task.name && prefix) { - return `${task.name}/${prefix}`; + if (!prefix) { + return nameWithId; } - return String(task.name || "") + String(prefix || ""); + return `${nameWithId}/${prefix}`; }; const onError = (message: string, prefix?: string) => { errors.push(message); @@ -25,15 +30,22 @@ const createTaskProcessor = (task: TaskInfo, outerProcessor: TaskProcessorCore, }; const onWarn = (message: string, prefix?: string) => outerProcessor.onWarn(message, getOuterPrefix(prefix)); const onInfo = (message: string, prefix?: string) => outerProcessor.onInfo(message, getOuterPrefix(prefix)); + const taskWithParameters = isExternalTask(task) ? tasks[task.type](task.params || {}) : task.task; let result: TaskProcessor; result = { context: outerProcessor.context, - done: () => callback(errors.join("\r\n")), + done: () => { + onInfo(`Completed task ${nameWithId}`); + callback(errors.join("\r\n")); + }, onError, onWarn, onInfo, - process: () => (isExternalTask(task) ? tasks[task.type](task.params || {}, result) : task.task)(), + process: () => { + onInfo(`Starting task ${nameWithId}`); + taskWithParameters(result)(); + }, processTask: (innerTask, innerCallback) => createTaskProcessor(innerTask, result, innerCallback).process(), settings: outerProcessor.settings, }; diff --git a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts index e2d3713..5369623 100644 --- a/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts +++ b/BuildServer/lib/tasks/cleanupafterdotnetbuild.ts @@ -3,9 +3,10 @@ import * as glob from "glob"; import { GenericTask } from "../types"; +import deletefromcode from "./deletefromcode"; import parallel from "./parallel"; -export default ((_params, processor) => () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", { +export default ((_params) => (processor) => () => glob("**/obj/{Debug,Release}/*.{dll,pdb,xml}", { cwd: processor.context.exported, dot: true, }, (err, files) => { @@ -22,8 +23,7 @@ export default ((_params, processor) => () => glob("**/obj/{Debug,Release}/*.{dl return parallel({ tasks: files.map((file) => ({ name: file, - params: { filename: file }, - type: "deletefromcode", + task: deletefromcode({ filename: file }), })), - }, processor)(); + })(processor)(); })) as GenericTask<{}>; diff --git a/BuildServer/lib/tasks/conditional.ts b/BuildServer/lib/tasks/conditional.ts index 568a3a0..24faade 100644 --- a/BuildServer/lib/tasks/conditional.ts +++ b/BuildServer/lib/tasks/conditional.ts @@ -1,6 +1,7 @@ "use strict"; import { GenericTask, TaskInfo } from "../types"; +import noop from "./noop"; interface IParameters { readonly owner?: string; @@ -9,10 +10,10 @@ interface IParameters { readonly otherwise?: TaskInfo; } -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 () => processor.processTask(task || { type: "noop", params: {} }, processor.done); + return () => processor.processTask(task || { task: noop({}) }, processor.done); }) as GenericTask; diff --git a/BuildServer/lib/tasks/copy.ts b/BuildServer/lib/tasks/copy.ts index b77690c..e3359ad 100644 --- a/BuildServer/lib/tasks/copy.ts +++ b/BuildServer/lib/tasks/copy.ts @@ -5,7 +5,7 @@ import { join } from "path"; import { GenericTask } from "../types"; -export default ((params, processor) => () => { +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 7efe654..49ed003 100644 --- a/BuildServer/lib/tasks/copyglob.ts +++ b/BuildServer/lib/tasks/copyglob.ts @@ -3,9 +3,10 @@ import * as glob from "glob"; import { GenericTask } from "../types"; +import copy from "./copy"; import parallel from "./parallel"; -export default ((params, processor) => () => glob(params.mask, { +export default ((params) => (processor) => () => glob(params.mask, { cwd: processor.context.exported, dot: true, }, (err, files) => { @@ -22,8 +23,7 @@ export default ((params, processor) => () => glob(params.mask, { return parallel({ tasks: files.map((file) => ({ name: file, - params: { filename: file }, - type: "copy", + task: copy({ filename: file }), })), - }, processor)(); + })(processor)(); })) as GenericTask<{ readonly mask: string }>; diff --git a/BuildServer/lib/tasks/cssnano.ts b/BuildServer/lib/tasks/cssnano.ts index dccd06f..25a6351 100644 --- a/BuildServer/lib/tasks/cssnano.ts +++ b/BuildServer/lib/tasks/cssnano.ts @@ -6,7 +6,7 @@ import { join } from "path"; import { GenericTask } from "../types"; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { const filePath = join(processor.context.exported, params.filename); readFile(filePath, "utf8", (readErr, css) => { diff --git a/BuildServer/lib/tasks/cssnanoall.ts b/BuildServer/lib/tasks/cssnanoall.ts index d4ba5f3..14ef892 100644 --- a/BuildServer/lib/tasks/cssnanoall.ts +++ b/BuildServer/lib/tasks/cssnanoall.ts @@ -3,11 +3,12 @@ import * as glob from "glob"; import { GenericTask } from "../types"; +import cssnano from "./cssnano"; import parallel from "./parallel"; const flagDoneName = "cssnanoallDone"; -export default ((_params, processor) => () => { +export default ((_params) => (processor) => () => { if (processor.context.containsFlag(flagDoneName)) { processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -27,9 +28,8 @@ export default ((_params, processor) => () => { return parallel({ tasks: files.map((file) => ({ name: file, - params: { filename: file }, - type: "cssnano", + task: cssnano({ filename: file }), })), - }, processor)(); + })(processor)(); }); }) as GenericTask<{}>; diff --git a/BuildServer/lib/tasks/deletefromcode.ts b/BuildServer/lib/tasks/deletefromcode.ts index b0b5e83..ae0712c 100644 --- a/BuildServer/lib/tasks/deletefromcode.ts +++ b/BuildServer/lib/tasks/deletefromcode.ts @@ -5,7 +5,7 @@ import { join } from "path"; import { GenericTask } from "../types"; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { const sourceFilePath = join(processor.context.exported, params.filename); processor.onInfo(`Deleting ${sourceFilePath}`); diff --git a/BuildServer/lib/tasks/dotnetbuild.ts b/BuildServer/lib/tasks/dotnetbuild.ts index 76e8790..882358c 100644 --- a/BuildServer/lib/tasks/dotnetbuild.ts +++ b/BuildServer/lib/tasks/dotnetbuild.ts @@ -1,19 +1,31 @@ "use strict"; import { GenericTask } from "../types"; +import cleanupafterdotnetbuild from "./cleanupafterdotnetbuild"; +import dotnetbuildwithoutcleanup from "./dotnetbuildwithoutcleanup"; import sequential from "./sequential"; -export default ((params, processor) => sequential({ +interface IDotNetBuildParameters { + readonly skipMbsCheckStyle?: boolean; + readonly forceCodeAnalysis?: boolean; + readonly ignoreCodeAnalysis?: boolean; + readonly skipCodeAnalysis: boolean; + readonly skipCodeSigning?: boolean; + readonly skipNugetRestore?: boolean; + readonly configuration: string; + readonly solution: string; + readonly ignoreCodeStyle: boolean; +} + +export default ((params) => (processor) => sequential({ tasks: [ { name: "build", - params, - type: "dotnetbuildwithoutcleanup", + task: dotnetbuildwithoutcleanup(params), }, { name: "cleanup", - params: {}, - type: "cleanupafterdotnetbuild", + task: cleanupafterdotnetbuild({}), }, ], -}, processor)) as GenericTask<{}>; +})(processor)) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetbuildandtest.ts b/BuildServer/lib/tasks/dotnetbuildandtest.ts index a8043ee..e4ee77c 100644 --- a/BuildServer/lib/tasks/dotnetbuildandtest.ts +++ b/BuildServer/lib/tasks/dotnetbuildandtest.ts @@ -1,24 +1,36 @@ "use strict"; import { GenericTask } from "../types"; +import cleanupafterdotnetbuild from "./cleanupafterdotnetbuild"; +import dotnetbuildwithoutcleanup from "./dotnetbuildwithoutcleanup"; +import dotnetnunitall from "./dotnetnunitall"; import sequential from "./sequential"; -export default ((params, processor) => sequential({ +interface IDotNetBuildAndTestParameters { + readonly skipMbsCheckStyle?: boolean; + readonly forceCodeAnalysis?: boolean; + readonly ignoreCodeAnalysis?: boolean; + readonly skipCodeAnalysis: boolean; + readonly skipCodeSigning?: boolean; + readonly skipNugetRestore?: boolean; + readonly configuration: string; + readonly solution: string; + readonly ignoreCodeStyle: boolean; +} + +export default ((params) => (processor) => sequential({ tasks: [ { name: "build", - params, - type: "dotnetbuildwithoutcleanup", + task: dotnetbuildwithoutcleanup(params), }, { name: "test", - params, - type: "dotnetnunitall", + task: dotnetnunitall(params), }, { name: "cleanup", - params: {}, - type: "cleanupafterdotnetbuild", + task: cleanupafterdotnetbuild({}), }, ], -}, processor)) as GenericTask<{}>; +})(processor)) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts index eef2134..045c45b 100644 --- a/BuildServer/lib/tasks/dotnetbuilderwrapper.ts +++ b/BuildServer/lib/tasks/dotnetbuilderwrapper.ts @@ -52,7 +52,7 @@ const wrapBuilder = (builder: ChildProcess, input: string, onExit: (code: number }).catch((err) => onExit(0, "", err)); }; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { const input = JSON.stringify(params); const builder = spawn(processor.settings.builderExecutable, [params.command]); diff --git a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts index ccc8df7..8c5c017 100644 --- a/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts +++ b/BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts @@ -1,53 +1,54 @@ "use strict"; -import { GenericTask } from "../types"; +import { GenericTask, TaskInfo } from "../types"; +import dotnetcheckstyle from "./dotnetcheckstyle"; +import dotnetcompile from "./dotnetcompile"; +import dotnetnugetrestore from "./dotnetnugetrestore"; +import dotnetrewrite from "./dotnetrewrite"; import sequential from "./sequential"; -interface IParameters { +interface IDotNetBuilderWithoutCleanupParameters { readonly skipMbsCheckStyle?: boolean; readonly forceCodeAnalysis?: boolean; readonly ignoreCodeAnalysis?: boolean; + readonly skipCodeAnalysis: boolean; readonly skipCodeSigning?: boolean; readonly skipNugetRestore?: boolean; readonly configuration: string; readonly solution: string; + readonly ignoreCodeStyle: boolean; } -const createTasks = function *(params: IParameters) { +const createTasks = function *(params: IDotNetBuilderWithoutCleanupParameters) { if (!params.skipMbsCheckStyle) { yield { - params, - type: "dotnetcheckstyle", - }; + name: "dotnetcheckstyle", + task: dotnetcheckstyle(params), + } as TaskInfo; } yield { - params, - type: "dotnetrewrite", - }; + name: "dotnetrewrite", + task: dotnetrewrite(params), + } as TaskInfo; if (!params.skipNugetRestore) { yield { - params, - type: "dotnetnugetrestore", - }; + name: "dotnetnugetrestore", + task: dotnetnugetrestore(params), + } as TaskInfo; } yield { - params: { - configuration: params.configuration, - forceCodeAnalysis: params.forceCodeAnalysis, - ignoreCodeAnalysis: params.ignoreCodeAnalysis, - skipCodeSigning: params.skipCodeSigning, - solution: params.solution, + name: "dotnetcompile", + task: dotnetcompile({ + ...params, target: "Rebuild", - }, - type: "dotnetcompile", - }; + }), + } as TaskInfo; }; -export default ((params, processor) => { - const tasks = Array.from(createTasks(params)); - - return sequential({ tasks }, processor); -}) as GenericTask; +export default ((params) => (processor) => { + const tasks = Array.from(createTasks(params)) as TaskInfo[]; + return sequential({ tasks })(processor); +}) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetcheckstyle.ts b/BuildServer/lib/tasks/dotnetcheckstyle.ts index 46c17d6..d84b349 100644 --- a/BuildServer/lib/tasks/dotnetcheckstyle.ts +++ b/BuildServer/lib/tasks/dotnetcheckstyle.ts @@ -7,8 +7,8 @@ import { join } from "path"; import { GenericTask } from "../types"; -interface IParameters { - ignoreCodeStyle: boolean; +interface IDotNetCheckStyleParameters { + readonly ignoreCodeStyle: boolean; } const autoGeneratedMarker @@ -17,7 +17,7 @@ const autoGeneratedMarker const flagDoneName = "dotnetcheckerDone"; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { if (processor.context.containsFlag(flagDoneName)) { return processor.done(); } @@ -77,4 +77,4 @@ export default ((params, processor) => () => { }, )), processor.done); }); -}) as GenericTask; +}) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetcompile.ts b/BuildServer/lib/tasks/dotnetcompile.ts index c07d9d0..5729f93 100644 --- a/BuildServer/lib/tasks/dotnetcompile.ts +++ b/BuildServer/lib/tasks/dotnetcompile.ts @@ -5,18 +5,18 @@ import { join } from "path"; import { BuilderCompileRequest, GenericTask } from "../types"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; -interface IParameters { - configuration: string; - overrideOutputDirectory: string; - skipCodeAnalysis: boolean; - solution: string; - target: string; - forceCodeAnalysis?: boolean; - skipCodeSigning?: boolean; - ignoreCodeAnalysis: boolean; +interface IDotNetCompileParameters { + readonly configuration: string; + readonly overrideOutputDirectory?: string; + readonly skipCodeAnalysis: boolean; + readonly solution: string; + readonly target: string; + readonly forceCodeAnalysis?: boolean; + readonly skipCodeSigning?: boolean; + readonly ignoreCodeAnalysis?: boolean; } -export default ((params, processor) => { +export default ((params) => (processor) => { if (processor.settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) { processor.onError("Code analysis is not supported"); @@ -45,5 +45,5 @@ export default ((params, processor) => { ...getAdditionalSigningParameters(), }; - return dotnetbuilderwrapper(compileParams, processor); -}) as GenericTask; + return dotnetbuilderwrapper(compileParams)(processor); +}) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetnugetpack.ts b/BuildServer/lib/tasks/dotnetnugetpack.ts index ab2844a..4f28565 100644 --- a/BuildServer/lib/tasks/dotnetnugetpack.ts +++ b/BuildServer/lib/tasks/dotnetnugetpack.ts @@ -1,17 +1,21 @@ "use strict"; import { GenericTask } from "../types"; +import copy from "./copy"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; -interface IParameters { +interface IDotNetNuGetPackParameters { + readonly withoutCommitSha?: boolean; + readonly major?: string; + readonly version?: string; readonly name: string; readonly nuspec: string; } -export default ((params, processor) => dotnetnugetprocessinternal({ +export default ((params) => (processor) => dotnetnugetprocessinternal({ ...params, getFinalTask: (nupkg) => ({ - params: { filename: nupkg }, - type: "copy", + name: "copynupkg", + task: copy({ filename: nupkg }), }), -}, processor)) as GenericTask; +})(processor)) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetnugetprocess.ts b/BuildServer/lib/tasks/dotnetnugetprocess.ts index afde11c..f2b7aeb 100644 --- a/BuildServer/lib/tasks/dotnetnugetprocess.ts +++ b/BuildServer/lib/tasks/dotnetnugetprocess.ts @@ -2,8 +2,10 @@ import { GenericTask } from "../types"; import conditional from "./conditional"; +import dotnetnugetpack from "./dotnetnugetpack"; +import dotnetnugetpush from "./dotnetnugetpush"; -interface IParameters { +interface IDotNetNuGetPushParameters { readonly major: string; readonly nuspecName: string; readonly version: string; @@ -11,29 +13,27 @@ interface IParameters { readonly masterRepoOwner: string; } -export default ((params, processor) => conditional({ +export default ((params) => (processor) => conditional({ branch: "master", otherwise: { name: "nuget-pack", - params: { + task: dotnetnugetpack({ major: params.major, name: params.nuspecName, nuspec: `${params.nuspecName}.nuspec`, version: params.version, withoutCommitSha: params.withoutCommitSha, - }, - type: "dotnetnugetpack", + }), }, owner: params.masterRepoOwner, task: { name: "nuget-push", - params: { + task: dotnetnugetpush({ major: params.major, name: params.nuspecName, nuspec: `${params.nuspecName}.nuspec`, version: params.version, withoutCommitSha: params.withoutCommitSha, - }, - type: "dotnetnugetpush", + }), }, -}, processor)) as GenericTask; +})(processor)) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts index aaa998d..a5fec2a 100644 --- a/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts +++ b/BuildServer/lib/tasks/dotnetnugetprocessinternal.ts @@ -3,9 +3,10 @@ import { join } from "path"; import { GenericTask, TaskInfo, TaskProcessor } from "../types"; +import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; import sequential from "./sequential"; -interface IParameters { +interface IDotNetNuGetProcessInternalParameters { readonly withoutCommitSha?: boolean; readonly major?: string; readonly version?: string; @@ -18,7 +19,7 @@ const postfixLength = 16; const fourDigits = 10000; const twoDigits = 100; -const addPostfix = (version: string, params: IParameters, processor: TaskProcessor) => { +const addPostfix = (version: string, params: IDotNetNuGetProcessInternalParameters, processor: TaskProcessor) => { if (params.withoutCommitSha) { return version; } @@ -26,7 +27,7 @@ const addPostfix = (version: string, params: IParameters, processor: TaskProcess 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(); @@ -37,16 +38,16 @@ export default ((params, processor) => { return sequential({ tasks: [ { - params: { + name: "pack", + task: dotnetbuilderwrapper({ BaseDirectory: processor.context.exported, OutputDirectory: processor.context.exported, SpecPath: join(processor.context.exported, params.nuspec), Version: version, command: "nugetpack", - }, - type: "dotnetbuilderwrapper", + }), }, params.getFinalTask(nupkg), ], - }, processor); -}) as GenericTask; + })(processor); +}) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetnugetpush.ts b/BuildServer/lib/tasks/dotnetnugetpush.ts index bd1533d..b6cb927 100644 --- a/BuildServer/lib/tasks/dotnetnugetpush.ts +++ b/BuildServer/lib/tasks/dotnetnugetpush.ts @@ -2,16 +2,20 @@ import { GenericTask } from "../types"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; +import dotnetnugetpushonly from "./dotnetnugetpushonly"; -interface IParameters { +interface IDotNetNuGetPushParameters { + readonly withoutCommitSha?: boolean; + readonly major?: string; + readonly version?: string; readonly name: string; readonly nuspec: string; } -export default ((params, processor) => dotnetnugetprocessinternal({ +export default ((params) => (processor) => dotnetnugetprocessinternal({ ...params, getFinalTask: (nupkg) => ({ - params: { Package: nupkg }, - type: "dotnetnugetpushonly", + name: "pushonly", + task: dotnetnugetpushonly({ Package: nupkg }), }), -}, processor)) as GenericTask; +})(processor)) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetnugetpushonly.ts b/BuildServer/lib/tasks/dotnetnugetpushonly.ts index d8cab8b..1c6ff1e 100644 --- a/BuildServer/lib/tasks/dotnetnugetpushonly.ts +++ b/BuildServer/lib/tasks/dotnetnugetpushonly.ts @@ -5,9 +5,9 @@ import { join } from "path"; import { GenericTask } from "../types"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; -export default ((params, processor) => dotnetbuilderwrapper({ +export default ((params) => (processor) => dotnetbuilderwrapper({ ApiKey: processor.settings.nugetApiKey, NugetHost: processor.settings.nugetHost, Package: join(processor.context.exported, params.Package), command: "nugetpush", -}, processor)) as GenericTask<{ readonly Package: string }>; +})(processor)) as GenericTask<{ readonly Package: string }>; diff --git a/BuildServer/lib/tasks/dotnetnugetrestore.ts b/BuildServer/lib/tasks/dotnetnugetrestore.ts index c3d4501..7b105c4 100644 --- a/BuildServer/lib/tasks/dotnetnugetrestore.ts +++ b/BuildServer/lib/tasks/dotnetnugetrestore.ts @@ -5,8 +5,8 @@ import { join } from "path"; import { GenericTask } from "../types"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; -export default ((params, processor) => dotnetbuilderwrapper({ +export default ((params) => (processor) => dotnetbuilderwrapper({ BaseDirectory: processor.context.exported, SolutionPath: join(processor.context.exported, params.solution), command: "nugetrestore", -}, processor)) as GenericTask<{ readonly solution: string }>; +})(processor)) as GenericTask<{ readonly solution: string }>; diff --git a/BuildServer/lib/tasks/dotnetnunit.ts b/BuildServer/lib/tasks/dotnetnunit.ts index 8eebb33..9fec149 100644 --- a/BuildServer/lib/tasks/dotnetnunit.ts +++ b/BuildServer/lib/tasks/dotnetnunit.ts @@ -5,7 +5,7 @@ import { join } from "path"; import { GenericTask } from "../types"; import dotNetBuilderWrapper from "./dotnetbuilderwrapper"; -export default ((params, processor) => dotNetBuilderWrapper({ +export default ((params) => (processor) => dotNetBuilderWrapper({ TestLibraryPath: join(processor.context.exported, params.assembly), command: "nunit", -}, processor)) as GenericTask<{ readonly assembly: string }>; +})(processor)) as GenericTask<{ readonly assembly: string }>; diff --git a/BuildServer/lib/tasks/dotnetnunitall.ts b/BuildServer/lib/tasks/dotnetnunitall.ts index 3f611a3..1d2389c 100644 --- a/BuildServer/lib/tasks/dotnetnunitall.ts +++ b/BuildServer/lib/tasks/dotnetnunitall.ts @@ -3,12 +3,13 @@ import * as glob from "glob"; import { GenericTask } from "../types"; +import dotnetnunit from "./dotnetnunit"; import parallel from "./parallel"; import sequential from "./sequential"; const flagDoneName = "dotnetnunitallDone"; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { if (processor.context.containsFlag(flagDoneName)) { processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -36,9 +37,8 @@ export default ((params, processor) => () => { return task({ tasks: files.map((file) => ({ name: file, - params: { assembly: file }, - type: "dotnetnunit", + task: dotnetnunit({ assembly: file }), })), - }, processor)(); + })(processor)(); }); }) as GenericTask<{ readonly preventParallelTests?: boolean }>; diff --git a/BuildServer/lib/tasks/dotnetpackwebapp.ts b/BuildServer/lib/tasks/dotnetpackwebapp.ts index a6f4672..3516d94 100644 --- a/BuildServer/lib/tasks/dotnetpackwebapp.ts +++ b/BuildServer/lib/tasks/dotnetpackwebapp.ts @@ -5,11 +5,14 @@ import { render } from "mustache"; import { join } from "path"; import { GenericTask } from "../types"; +import dotnetcompile from "./dotnetcompile"; import sequential from "./sequential"; +import writefile from "./writefile"; interface IParameters { readonly configuration: string; readonly isCodeAnalysisUnsupported: boolean; + readonly skipCodeAnalysis: boolean; readonly skipCodeSigning: boolean; } @@ -17,39 +20,37 @@ const msbuildTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template 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({ +export default ((params) => (processor) => sequential({ tasks: [ { - params: { + name: "writemakepackage", + task: writefile({ data: render(msbuildTemplate, params), filename: "MakePackage.msbuild", - }, - type: "writefile", + }), }, { - params: { + name: "writedeploy", + task: writefile({ data: render(deployTemplate, params), filename: "Deploy.bat", - }, - type: "writefile", + }), }, { - params: { + name: "writeversion", + task: writefile({ data: render(versionTemplate, params), filename: "version.aspx", - }, - type: "writefile", + }), }, { - params: { - configuration: params.configuration, - isCodeAnalysisUnsupported: params.isCodeAnalysisUnsupported, + name: "compile", + task: dotnetcompile({ + ...params, overrideOutputDirectory: processor.context.release, - skipCodeSigning: params.skipCodeSigning, solution: "MakePackage.msbuild", target: "Package", - }, - type: "dotnetcompile", + }), }, ], -}, processor)) as GenericTask; +})(processor)) as GenericTask; diff --git a/BuildServer/lib/tasks/dotnetrewrite.ts b/BuildServer/lib/tasks/dotnetrewrite.ts index 97d3d57..6f271f1 100644 --- a/BuildServer/lib/tasks/dotnetrewrite.ts +++ b/BuildServer/lib/tasks/dotnetrewrite.ts @@ -8,7 +8,7 @@ import { join } from "path"; import { GenericTask, TaskProcessor } from "../types"; interface IParameters { - readonly skipCodeSigning: boolean; + readonly skipCodeSigning?: boolean; } type Callback = (err?: any, result?: string) => void; @@ -38,7 +38,7 @@ const processAssemblyInfo = (params: IParameters, processor: TaskProcessor, appe return cb(null, processInformationalVersion(processInternalsVisible(originalContent))); }; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { if (processor.context.containsFlag(flagDoneName)) { return processor.done(); } diff --git a/BuildServer/lib/tasks/echo.ts b/BuildServer/lib/tasks/echo.ts index d30a170..185485f 100644 --- a/BuildServer/lib/tasks/echo.ts +++ b/BuildServer/lib/tasks/echo.ts @@ -8,7 +8,7 @@ interface IParameters { readonly info: string; } -export default ((params, processor) => () => { +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 1adf3ee..4b24b87 100644 --- a/BuildServer/lib/tasks/eslintbrowser.ts +++ b/BuildServer/lib/tasks/eslintbrowser.ts @@ -7,7 +7,7 @@ import { GenericTask } from "../types"; const errorSeverity = 2; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { if (processor.settings.isCodeAnalysisUnsupported) { return; } diff --git a/BuildServer/lib/tasks/eslintbrowserall.ts b/BuildServer/lib/tasks/eslintbrowserall.ts index e3e3751..8882faf 100644 --- a/BuildServer/lib/tasks/eslintbrowserall.ts +++ b/BuildServer/lib/tasks/eslintbrowserall.ts @@ -3,11 +3,12 @@ import * as glob from "glob"; import { GenericTask } from "../types"; +import eslintbrowser from "./eslintbrowser"; import parallel from "./parallel"; const flagDoneName = "eslintbrowserallDone"; -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { if (processor.context.containsFlag(flagDoneName)) { processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -29,9 +30,8 @@ export default ((params, processor) => () => { return parallel({ tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({ name: file, - params: { filename: file }, - type: "eslintbrowser", + task: eslintbrowser({ filename: file }), })), - }, processor)(); + })(processor)(); }); }) as GenericTask<{ readonly excludeFiles?: string[] }>; diff --git a/BuildServer/lib/tasks/noop.ts b/BuildServer/lib/tasks/noop.ts index 64b24ee..b5120d6 100644 --- a/BuildServer/lib/tasks/noop.ts +++ b/BuildServer/lib/tasks/noop.ts @@ -2,4 +2,4 @@ import { GenericTask } from "../types"; -export default ((_params, processor) => processor.done) as GenericTask<{}>; +export default ((_params) => (processor) => processor.done) as GenericTask<{}>; diff --git a/BuildServer/lib/tasks/packform.ts b/BuildServer/lib/tasks/packform.ts index 78186a6..8ad6ae1 100644 --- a/BuildServer/lib/tasks/packform.ts +++ b/BuildServer/lib/tasks/packform.ts @@ -1,39 +1,44 @@ "use strict"; import { GenericTask } from "../types"; +import cssnanoall from "./cssnanoall"; +import eslintbrowserall from "./eslintbrowserall"; import sequential from "./sequential"; +import uglifyjsall from "./uglifyjsall"; +import writefile from "./writefile"; +import zip from "./zip"; interface IParameters { - readonly eslintExcludeFiles: boolean; + readonly eslintExcludeFiles?: string[]; } -export default ((params, processor) => sequential({ +export default ((params) => (processor) => sequential({ tasks: [ { - params: { excludeFiles: params.eslintExcludeFiles }, - type: "eslintbrowserall", + name: "eslint", + task: eslintbrowserall({ excludeFiles: params.eslintExcludeFiles }), }, { - params: { }, - type: "uglifyjsall", + name: "uglifyjs", + task: uglifyjsall({}), }, { - params: { }, - type: "cssnanoall", + name: "cssnano", + task: cssnanoall({}), }, { - params: { + name: "writeversion", + task: writefile({ data: processor.context.versionInfo, filename: "version.txt", - }, - type: "writefile", + }), }, { - params: { + name: "zip", + task: zip({ archive: `${processor.context.reponame}.zip`, directory: "", - }, - type: "zip", + }), }, ], -}, processor)) as GenericTask; +})(processor)) as GenericTask; diff --git a/BuildServer/lib/tasks/parallel.ts b/BuildServer/lib/tasks/parallel.ts index f80ba16..0ae66ad 100644 --- a/BuildServer/lib/tasks/parallel.ts +++ b/BuildServer/lib/tasks/parallel.ts @@ -10,4 +10,4 @@ interface IParameters { const mapper = (processor: TaskProcessor) => (task: TaskInfo) => (callback: TaskProcessorCallback) => processor.processTask(task, callback); -export default ((params, processor) => () => parallel(params.tasks.map(mapper(processor)), processor.done)) as GenericTask; +export default ((params) => (processor) => () => parallel(params.tasks.map(mapper(processor)), processor.done)) as GenericTask; diff --git a/BuildServer/lib/tasks/sequential.ts b/BuildServer/lib/tasks/sequential.ts index 03ca165..55b552a 100644 --- a/BuildServer/lib/tasks/sequential.ts +++ b/BuildServer/lib/tasks/sequential.ts @@ -10,4 +10,4 @@ interface IParameters { const mapper = (processor: TaskProcessor) => (task: TaskInfo) => (callback: TaskProcessorCallback) => processor.processTask(task, callback); -export default ((params, processor) => () => series(params.tasks.map(mapper(processor)), processor.done)) as GenericTask; +export default ((params) => (processor) => () => series(params.tasks.map(mapper(processor)), processor.done)) as GenericTask; diff --git a/BuildServer/lib/tasks/uglifyjs.ts b/BuildServer/lib/tasks/uglifyjs.ts index 54891df..7291523 100644 --- a/BuildServer/lib/tasks/uglifyjs.ts +++ b/BuildServer/lib/tasks/uglifyjs.ts @@ -6,7 +6,7 @@ import { minify } from "uglify-js"; import { GenericTask } from "../types"; -export default ((params, processor) => () => { +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 c7fb27b..f510340 100644 --- a/BuildServer/lib/tasks/uglifyjsall.ts +++ b/BuildServer/lib/tasks/uglifyjsall.ts @@ -4,10 +4,11 @@ import * as glob from "glob"; import { GenericTask } from "../types"; import parallel from "./parallel"; +import uglifyjs from "./uglifyjs"; const doneFlagName = "uglifyjsallDone"; -export default ((_params, processor) => () => { +export default ((_params) => (processor) => () => { if (processor.context.containsFlag(doneFlagName)) { processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); } @@ -27,9 +28,8 @@ export default ((_params, processor) => () => { return parallel({ tasks: files.map((file) => ({ name: file, - params: { filename: file }, - type: "uglifyjs", + task: uglifyjs({ filename: file }), })), - }, processor)(); + })(processor)(); }); }) as GenericTask<{}>; diff --git a/BuildServer/lib/tasks/writefile.ts b/BuildServer/lib/tasks/writefile.ts index 4cd2782..44cc8b6 100644 --- a/BuildServer/lib/tasks/writefile.ts +++ b/BuildServer/lib/tasks/writefile.ts @@ -10,7 +10,7 @@ interface IParameters { readonly filename: string; } -export default ((params, processor) => () => { +export default ((params) => (processor) => () => { const filePath = join(processor.context.exported, params.filename); processor.onInfo(`Writing to ${filePath}`); diff --git a/BuildServer/lib/tasks/zip.ts b/BuildServer/lib/tasks/zip.ts index 334acf5..9680e60 100644 --- a/BuildServer/lib/tasks/zip.ts +++ b/BuildServer/lib/tasks/zip.ts @@ -11,7 +11,7 @@ interface IParameters { readonly archive: string; } -export default ((params, processor) => () => { +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/lib/types/dotnetbuilder-types.ts b/BuildServer/lib/types/dotnetbuilder-types.ts index c6c45a5..a79cbdb 100644 --- a/BuildServer/lib/types/dotnetbuilder-types.ts +++ b/BuildServer/lib/types/dotnetbuilder-types.ts @@ -3,7 +3,7 @@ export interface ICompileRequest { readonly SolutionPath: string; readonly Target: string; readonly Configuration: string; - readonly OutputDirectory: string; + readonly OutputDirectory?: string; readonly SigningKey?: string; readonly SkipCodeAnalysis: boolean; } diff --git a/BuildServer/lib/types/task-processor-types.ts b/BuildServer/lib/types/task-processor-types.ts index b1edc2d..13791de 100644 --- a/BuildServer/lib/types/task-processor-types.ts +++ b/BuildServer/lib/types/task-processor-types.ts @@ -35,9 +35,9 @@ interface ITaskParameters { readonly [paramName: string]: any; } -type TaskWithParameters = () => void; +type TaskWithParameters = (processor: ITaskProcessor) => () => void; -export type GenericTask = (params: TParams, processor: ITaskProcessor) => TaskWithParameters; +export type GenericTask = (params: TParams) => TaskWithParameters; export type Task = GenericTask; @@ -52,7 +52,7 @@ export interface ITaskInfoExternal { } export interface ITaskInfoInternal { - readonly name: string; + readonly name?: string; readonly task: TaskWithParameters; }