Implemented subtasks type checks

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 7 years ago
parent 65f55220b2
commit dde7044e18
  1. 22
      BuildServer/lib/task-processor.ts
  2. 8
      BuildServer/lib/tasks/cleanupafterdotnetbuild.ts
  3. 5
      BuildServer/lib/tasks/conditional.ts
  4. 2
      BuildServer/lib/tasks/copy.ts
  5. 8
      BuildServer/lib/tasks/copyglob.ts
  6. 2
      BuildServer/lib/tasks/cssnano.ts
  7. 8
      BuildServer/lib/tasks/cssnanoall.ts
  8. 2
      BuildServer/lib/tasks/deletefromcode.ts
  9. 24
      BuildServer/lib/tasks/dotnetbuild.ts
  10. 28
      BuildServer/lib/tasks/dotnetbuildandtest.ts
  11. 2
      BuildServer/lib/tasks/dotnetbuilderwrapper.ts
  12. 53
      BuildServer/lib/tasks/dotnetbuildwithoutcleanup.ts
  13. 8
      BuildServer/lib/tasks/dotnetcheckstyle.ts
  14. 24
      BuildServer/lib/tasks/dotnetcompile.ts
  15. 14
      BuildServer/lib/tasks/dotnetnugetpack.ts
  16. 18
      BuildServer/lib/tasks/dotnetnugetprocess.ts
  17. 17
      BuildServer/lib/tasks/dotnetnugetprocessinternal.ts
  18. 14
      BuildServer/lib/tasks/dotnetnugetpush.ts
  19. 4
      BuildServer/lib/tasks/dotnetnugetpushonly.ts
  20. 4
      BuildServer/lib/tasks/dotnetnugetrestore.ts
  21. 4
      BuildServer/lib/tasks/dotnetnunit.ts
  22. 8
      BuildServer/lib/tasks/dotnetnunitall.ts
  23. 35
      BuildServer/lib/tasks/dotnetpackwebapp.ts
  24. 4
      BuildServer/lib/tasks/dotnetrewrite.ts
  25. 2
      BuildServer/lib/tasks/echo.ts
  26. 2
      BuildServer/lib/tasks/eslintbrowser.ts
  27. 8
      BuildServer/lib/tasks/eslintbrowserall.ts
  28. 2
      BuildServer/lib/tasks/noop.ts
  29. 35
      BuildServer/lib/tasks/packform.ts
  30. 2
      BuildServer/lib/tasks/parallel.ts
  31. 2
      BuildServer/lib/tasks/sequential.ts
  32. 2
      BuildServer/lib/tasks/uglifyjs.ts
  33. 8
      BuildServer/lib/tasks/uglifyjsall.ts
  34. 2
      BuildServer/lib/tasks/writefile.ts
  35. 2
      BuildServer/lib/tasks/zip.ts
  36. 2
      BuildServer/lib/types/dotnetbuilder-types.ts
  37. 6
      BuildServer/lib/types/task-processor-types.ts

@ -9,15 +9,20 @@ interface IFlags {
const isExternalTask = (task: TaskInfo): task is TaskInfoExternal => (task as TaskInfoExternal).type !== undefined; 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. // 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 createTaskProcessor = (task: TaskInfo, outerProcessor: TaskProcessorCore, callback: TaskProcessorCallback) => {
const taskId = tasksCount++;
const errors: string[] = []; const errors: string[] = [];
const name = task.name || (isExternalTask(task) ? task.type : null);
const nameWithId = String(name || "") + "#" + taskId;
const getOuterPrefix = (prefix?: string) => { const getOuterPrefix = (prefix?: string) => {
if (task.name && prefix) { if (!prefix) {
return `${task.name}/${prefix}`; return nameWithId;
} }
return String(task.name || "") + String(prefix || ""); return `${nameWithId}/${prefix}`;
}; };
const onError = (message: string, prefix?: string) => { const onError = (message: string, prefix?: string) => {
errors.push(message); 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 onWarn = (message: string, prefix?: string) => outerProcessor.onWarn(message, getOuterPrefix(prefix));
const onInfo = (message: string, prefix?: string) => outerProcessor.onInfo(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; let result: TaskProcessor;
result = { result = {
context: outerProcessor.context, context: outerProcessor.context,
done: () => callback(errors.join("\r\n")), done: () => {
onInfo(`Completed task ${nameWithId}`);
callback(errors.join("\r\n"));
},
onError, onError,
onWarn, onWarn,
onInfo, 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(), processTask: (innerTask, innerCallback) => createTaskProcessor(innerTask, result, innerCallback).process(),
settings: outerProcessor.settings, settings: outerProcessor.settings,
}; };

@ -3,9 +3,10 @@
import * as glob from "glob"; import * as glob from "glob";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import deletefromcode from "./deletefromcode";
import parallel from "./parallel"; 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, cwd: processor.context.exported,
dot: true, dot: true,
}, (err, files) => { }, (err, files) => {
@ -22,8 +23,7 @@ export default ((_params, processor) => () => glob("**/obj/{Debug,Release}/*.{dl
return parallel({ return parallel({
tasks: files.map((file) => ({ tasks: files.map((file) => ({
name: file, name: file,
params: { filename: file }, task: deletefromcode({ filename: file }),
type: "deletefromcode",
})), })),
}, processor)(); })(processor)();
})) as GenericTask<{}>; })) as GenericTask<{}>;

@ -1,6 +1,7 @@
"use strict"; "use strict";
import { GenericTask, TaskInfo } from "../types"; import { GenericTask, TaskInfo } from "../types";
import noop from "./noop";
interface IParameters { interface IParameters {
readonly owner?: string; readonly owner?: string;
@ -9,10 +10,10 @@ interface IParameters {
readonly otherwise?: TaskInfo; readonly otherwise?: TaskInfo;
} }
export default ((params, processor) => { export default ((params) => (processor) => {
const condition = (!params.owner || params.owner === processor.context.owner) const condition = (!params.owner || params.owner === processor.context.owner)
&& (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch); && (!params.branch || params.branch === processor.context.branch || `refs/heads/${params.branch}` === processor.context.branch);
const task = (condition && params.task) || params.otherwise; 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<IParameters>; }) as GenericTask<IParameters>;

@ -5,7 +5,7 @@ import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
const sourceFilePath = join(processor.context.exported, params.filename); const sourceFilePath = join(processor.context.exported, params.filename);
const targetFilePath = join(processor.context.release, params.filename); const targetFilePath = join(processor.context.release, params.filename);

@ -3,9 +3,10 @@
import * as glob from "glob"; import * as glob from "glob";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import copy from "./copy";
import parallel from "./parallel"; import parallel from "./parallel";
export default ((params, processor) => () => glob(params.mask, { export default ((params) => (processor) => () => glob(params.mask, {
cwd: processor.context.exported, cwd: processor.context.exported,
dot: true, dot: true,
}, (err, files) => { }, (err, files) => {
@ -22,8 +23,7 @@ export default ((params, processor) => () => glob(params.mask, {
return parallel({ return parallel({
tasks: files.map((file) => ({ tasks: files.map((file) => ({
name: file, name: file,
params: { filename: file }, task: copy({ filename: file }),
type: "copy",
})), })),
}, processor)(); })(processor)();
})) as GenericTask<{ readonly mask: string }>; })) as GenericTask<{ readonly mask: string }>;

@ -6,7 +6,7 @@ import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
const filePath = join(processor.context.exported, params.filename); const filePath = join(processor.context.exported, params.filename);
readFile(filePath, "utf8", (readErr, css) => { readFile(filePath, "utf8", (readErr, css) => {

@ -3,11 +3,12 @@
import * as glob from "glob"; import * as glob from "glob";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import cssnano from "./cssnano";
import parallel from "./parallel"; import parallel from "./parallel";
const flagDoneName = "cssnanoallDone"; const flagDoneName = "cssnanoallDone";
export default ((_params, processor) => () => { export default ((_params) => (processor) => () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("cssnanoall task is executed more than once; this is probably a bug in your mbs.json"); 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({ return parallel({
tasks: files.map((file) => ({ tasks: files.map((file) => ({
name: file, name: file,
params: { filename: file }, task: cssnano({ filename: file }),
type: "cssnano",
})), })),
}, processor)(); })(processor)();
}); });
}) as GenericTask<{}>; }) as GenericTask<{}>;

@ -5,7 +5,7 @@ import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
const sourceFilePath = join(processor.context.exported, params.filename); const sourceFilePath = join(processor.context.exported, params.filename);
processor.onInfo(`Deleting ${sourceFilePath}`); processor.onInfo(`Deleting ${sourceFilePath}`);

@ -1,19 +1,31 @@
"use strict"; "use strict";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import cleanupafterdotnetbuild from "./cleanupafterdotnetbuild";
import dotnetbuildwithoutcleanup from "./dotnetbuildwithoutcleanup";
import sequential from "./sequential"; 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: [ tasks: [
{ {
name: "build", name: "build",
params, task: dotnetbuildwithoutcleanup(params),
type: "dotnetbuildwithoutcleanup",
}, },
{ {
name: "cleanup", name: "cleanup",
params: {}, task: cleanupafterdotnetbuild({}),
type: "cleanupafterdotnetbuild",
}, },
], ],
}, processor)) as GenericTask<{}>; })(processor)) as GenericTask<IDotNetBuildParameters>;

@ -1,24 +1,36 @@
"use strict"; "use strict";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import cleanupafterdotnetbuild from "./cleanupafterdotnetbuild";
import dotnetbuildwithoutcleanup from "./dotnetbuildwithoutcleanup";
import dotnetnunitall from "./dotnetnunitall";
import sequential from "./sequential"; 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: [ tasks: [
{ {
name: "build", name: "build",
params, task: dotnetbuildwithoutcleanup(params),
type: "dotnetbuildwithoutcleanup",
}, },
{ {
name: "test", name: "test",
params, task: dotnetnunitall(params),
type: "dotnetnunitall",
}, },
{ {
name: "cleanup", name: "cleanup",
params: {}, task: cleanupafterdotnetbuild({}),
type: "cleanupafterdotnetbuild",
}, },
], ],
}, processor)) as GenericTask<{}>; })(processor)) as GenericTask<IDotNetBuildAndTestParameters>;

@ -52,7 +52,7 @@ const wrapBuilder = (builder: ChildProcess, input: string, onExit: (code: number
}).catch((err) => onExit(0, "", err)); }).catch((err) => onExit(0, "", err));
}; };
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
const input = JSON.stringify(params); const input = JSON.stringify(params);
const builder = spawn(processor.settings.builderExecutable, [params.command]); const builder = spawn(processor.settings.builderExecutable, [params.command]);

@ -1,53 +1,54 @@
"use strict"; "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"; import sequential from "./sequential";
interface IParameters { interface IDotNetBuilderWithoutCleanupParameters {
readonly skipMbsCheckStyle?: boolean; readonly skipMbsCheckStyle?: boolean;
readonly forceCodeAnalysis?: boolean; readonly forceCodeAnalysis?: boolean;
readonly ignoreCodeAnalysis?: boolean; readonly ignoreCodeAnalysis?: boolean;
readonly skipCodeAnalysis: boolean;
readonly skipCodeSigning?: boolean; readonly skipCodeSigning?: boolean;
readonly skipNugetRestore?: boolean; readonly skipNugetRestore?: boolean;
readonly configuration: string; readonly configuration: string;
readonly solution: string; readonly solution: string;
readonly ignoreCodeStyle: boolean;
} }
const createTasks = function *(params: IParameters) { const createTasks = function *(params: IDotNetBuilderWithoutCleanupParameters) {
if (!params.skipMbsCheckStyle) { if (!params.skipMbsCheckStyle) {
yield { yield {
params, name: "dotnetcheckstyle",
type: "dotnetcheckstyle", task: dotnetcheckstyle(params),
}; } as TaskInfo;
} }
yield { yield {
params, name: "dotnetrewrite",
type: "dotnetrewrite", task: dotnetrewrite(params),
}; } as TaskInfo;
if (!params.skipNugetRestore) { if (!params.skipNugetRestore) {
yield { yield {
params, name: "dotnetnugetrestore",
type: "dotnetnugetrestore", task: dotnetnugetrestore(params),
}; } as TaskInfo;
} }
yield { yield {
params: { name: "dotnetcompile",
configuration: params.configuration, task: dotnetcompile({
forceCodeAnalysis: params.forceCodeAnalysis, ...params,
ignoreCodeAnalysis: params.ignoreCodeAnalysis,
skipCodeSigning: params.skipCodeSigning,
solution: params.solution,
target: "Rebuild", target: "Rebuild",
}, }),
type: "dotnetcompile", } as TaskInfo;
};
}; };
export default ((params, processor) => { export default ((params) => (processor) => {
const tasks = Array.from(createTasks(params)); const tasks = Array.from(createTasks(params)) as TaskInfo[];
return sequential({ tasks })(processor);
return sequential({ tasks }, processor); }) as GenericTask<IDotNetBuilderWithoutCleanupParameters>;
}) as GenericTask<IParameters>;

@ -7,8 +7,8 @@ import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
interface IParameters { interface IDotNetCheckStyleParameters {
ignoreCodeStyle: boolean; readonly ignoreCodeStyle: boolean;
} }
const autoGeneratedMarker const autoGeneratedMarker
@ -17,7 +17,7 @@ const autoGeneratedMarker
const flagDoneName = "dotnetcheckerDone"; const flagDoneName = "dotnetcheckerDone";
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
return processor.done(); return processor.done();
} }
@ -77,4 +77,4 @@ export default ((params, processor) => () => {
}, },
)), processor.done); )), processor.done);
}); });
}) as GenericTask<IParameters>; }) as GenericTask<IDotNetCheckStyleParameters>;

@ -5,18 +5,18 @@ import { join } from "path";
import { BuilderCompileRequest, GenericTask } from "../types"; import { BuilderCompileRequest, GenericTask } from "../types";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
interface IParameters { interface IDotNetCompileParameters {
configuration: string; readonly configuration: string;
overrideOutputDirectory: string; readonly overrideOutputDirectory?: string;
skipCodeAnalysis: boolean; readonly skipCodeAnalysis: boolean;
solution: string; readonly solution: string;
target: string; readonly target: string;
forceCodeAnalysis?: boolean; readonly forceCodeAnalysis?: boolean;
skipCodeSigning?: boolean; readonly skipCodeSigning?: boolean;
ignoreCodeAnalysis: boolean; readonly ignoreCodeAnalysis?: boolean;
} }
export default ((params, processor) => { export default ((params) => (processor) => {
if (processor.settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) { if (processor.settings.isCodeAnalysisUnsupported && params.forceCodeAnalysis) {
processor.onError("Code analysis is not supported"); processor.onError("Code analysis is not supported");
@ -45,5 +45,5 @@ export default ((params, processor) => {
...getAdditionalSigningParameters(), ...getAdditionalSigningParameters(),
}; };
return dotnetbuilderwrapper(compileParams, processor); return dotnetbuilderwrapper(compileParams)(processor);
}) as GenericTask<IParameters>; }) as GenericTask<IDotNetCompileParameters>;

@ -1,17 +1,21 @@
"use strict"; "use strict";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import copy from "./copy";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal";
interface IParameters { interface IDotNetNuGetPackParameters {
readonly withoutCommitSha?: boolean;
readonly major?: string;
readonly version?: string;
readonly name: string; readonly name: string;
readonly nuspec: string; readonly nuspec: string;
} }
export default ((params, processor) => dotnetnugetprocessinternal({ export default ((params) => (processor) => dotnetnugetprocessinternal({
...params, ...params,
getFinalTask: (nupkg) => ({ getFinalTask: (nupkg) => ({
params: { filename: nupkg }, name: "copynupkg",
type: "copy", task: copy({ filename: nupkg }),
}), }),
}, processor)) as GenericTask<IParameters>; })(processor)) as GenericTask<IDotNetNuGetPackParameters>;

@ -2,8 +2,10 @@
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import conditional from "./conditional"; import conditional from "./conditional";
import dotnetnugetpack from "./dotnetnugetpack";
import dotnetnugetpush from "./dotnetnugetpush";
interface IParameters { interface IDotNetNuGetPushParameters {
readonly major: string; readonly major: string;
readonly nuspecName: string; readonly nuspecName: string;
readonly version: string; readonly version: string;
@ -11,29 +13,27 @@ interface IParameters {
readonly masterRepoOwner: string; readonly masterRepoOwner: string;
} }
export default ((params, processor) => conditional({ export default ((params) => (processor) => conditional({
branch: "master", branch: "master",
otherwise: { otherwise: {
name: "nuget-pack", name: "nuget-pack",
params: { task: dotnetnugetpack({
major: params.major, major: params.major,
name: params.nuspecName, name: params.nuspecName,
nuspec: `${params.nuspecName}.nuspec`, nuspec: `${params.nuspecName}.nuspec`,
version: params.version, version: params.version,
withoutCommitSha: params.withoutCommitSha, withoutCommitSha: params.withoutCommitSha,
}, }),
type: "dotnetnugetpack",
}, },
owner: params.masterRepoOwner, owner: params.masterRepoOwner,
task: { task: {
name: "nuget-push", name: "nuget-push",
params: { task: dotnetnugetpush({
major: params.major, major: params.major,
name: params.nuspecName, name: params.nuspecName,
nuspec: `${params.nuspecName}.nuspec`, nuspec: `${params.nuspecName}.nuspec`,
version: params.version, version: params.version,
withoutCommitSha: params.withoutCommitSha, withoutCommitSha: params.withoutCommitSha,
}, }),
type: "dotnetnugetpush",
}, },
}, processor)) as GenericTask<IParameters>; })(processor)) as GenericTask<IDotNetNuGetPushParameters>;

@ -3,9 +3,10 @@
import { join } from "path"; import { join } from "path";
import { GenericTask, TaskInfo, TaskProcessor } from "../types"; import { GenericTask, TaskInfo, TaskProcessor } from "../types";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
import sequential from "./sequential"; import sequential from "./sequential";
interface IParameters { interface IDotNetNuGetProcessInternalParameters {
readonly withoutCommitSha?: boolean; readonly withoutCommitSha?: boolean;
readonly major?: string; readonly major?: string;
readonly version?: string; readonly version?: string;
@ -18,7 +19,7 @@ const postfixLength = 16;
const fourDigits = 10000; const fourDigits = 10000;
const twoDigits = 100; const twoDigits = 100;
const addPostfix = (version: string, params: IParameters, processor: TaskProcessor) => { const addPostfix = (version: string, params: IDotNetNuGetProcessInternalParameters, processor: TaskProcessor) => {
if (params.withoutCommitSha) { if (params.withoutCommitSha) {
return version; return version;
} }
@ -26,7 +27,7 @@ const addPostfix = (version: string, params: IParameters, processor: TaskProcess
return `${version}-r${processor.context.rev.substr(0, postfixLength)}`; return `${version}-r${processor.context.rev.substr(0, postfixLength)}`;
}; };
export default ((params, processor) => { export default ((params) => (processor) => {
const date = new Date(); const date = new Date();
const major = params.major || "0"; const major = params.major || "0";
const minor = (date.getFullYear() * fourDigits) + ((date.getMonth() + 1) * twoDigits) + date.getDate(); const minor = (date.getFullYear() * fourDigits) + ((date.getMonth() + 1) * twoDigits) + date.getDate();
@ -37,16 +38,16 @@ export default ((params, processor) => {
return sequential({ return sequential({
tasks: [ tasks: [
{ {
params: { name: "pack",
task: dotnetbuilderwrapper({
BaseDirectory: processor.context.exported, BaseDirectory: processor.context.exported,
OutputDirectory: processor.context.exported, OutputDirectory: processor.context.exported,
SpecPath: join(processor.context.exported, params.nuspec), SpecPath: join(processor.context.exported, params.nuspec),
Version: version, Version: version,
command: "nugetpack", command: "nugetpack",
}, }),
type: "dotnetbuilderwrapper",
}, },
params.getFinalTask(nupkg), params.getFinalTask(nupkg),
], ],
}, processor); })(processor);
}) as GenericTask<IParameters>; }) as GenericTask<IDotNetNuGetProcessInternalParameters>;

@ -2,16 +2,20 @@
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import dotnetnugetprocessinternal from "./dotnetnugetprocessinternal"; 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 name: string;
readonly nuspec: string; readonly nuspec: string;
} }
export default ((params, processor) => dotnetnugetprocessinternal({ export default ((params) => (processor) => dotnetnugetprocessinternal({
...params, ...params,
getFinalTask: (nupkg) => ({ getFinalTask: (nupkg) => ({
params: { Package: nupkg }, name: "pushonly",
type: "dotnetnugetpushonly", task: dotnetnugetpushonly({ Package: nupkg }),
}), }),
}, processor)) as GenericTask<IParameters>; })(processor)) as GenericTask<IDotNetNuGetPushParameters>;

@ -5,9 +5,9 @@ import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
export default ((params, processor) => dotnetbuilderwrapper({ export default ((params) => (processor) => dotnetbuilderwrapper({
ApiKey: processor.settings.nugetApiKey, ApiKey: processor.settings.nugetApiKey,
NugetHost: processor.settings.nugetHost, NugetHost: processor.settings.nugetHost,
Package: join(processor.context.exported, params.Package), Package: join(processor.context.exported, params.Package),
command: "nugetpush", command: "nugetpush",
}, processor)) as GenericTask<{ readonly Package: string }>; })(processor)) as GenericTask<{ readonly Package: string }>;

@ -5,8 +5,8 @@ import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import dotnetbuilderwrapper from "./dotnetbuilderwrapper"; import dotnetbuilderwrapper from "./dotnetbuilderwrapper";
export default ((params, processor) => dotnetbuilderwrapper({ export default ((params) => (processor) => dotnetbuilderwrapper({
BaseDirectory: processor.context.exported, BaseDirectory: processor.context.exported,
SolutionPath: join(processor.context.exported, params.solution), SolutionPath: join(processor.context.exported, params.solution),
command: "nugetrestore", command: "nugetrestore",
}, processor)) as GenericTask<{ readonly solution: string }>; })(processor)) as GenericTask<{ readonly solution: string }>;

@ -5,7 +5,7 @@ import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import dotNetBuilderWrapper from "./dotnetbuilderwrapper"; import dotNetBuilderWrapper from "./dotnetbuilderwrapper";
export default ((params, processor) => dotNetBuilderWrapper({ export default ((params) => (processor) => dotNetBuilderWrapper({
TestLibraryPath: join(processor.context.exported, params.assembly), TestLibraryPath: join(processor.context.exported, params.assembly),
command: "nunit", command: "nunit",
}, processor)) as GenericTask<{ readonly assembly: string }>; })(processor)) as GenericTask<{ readonly assembly: string }>;

@ -3,12 +3,13 @@
import * as glob from "glob"; import * as glob from "glob";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import dotnetnunit from "./dotnetnunit";
import parallel from "./parallel"; import parallel from "./parallel";
import sequential from "./sequential"; import sequential from "./sequential";
const flagDoneName = "dotnetnunitallDone"; const flagDoneName = "dotnetnunitallDone";
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); 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({ return task({
tasks: files.map((file) => ({ tasks: files.map((file) => ({
name: file, name: file,
params: { assembly: file }, task: dotnetnunit({ assembly: file }),
type: "dotnetnunit",
})), })),
}, processor)(); })(processor)();
}); });
}) as GenericTask<{ readonly preventParallelTests?: boolean }>; }) as GenericTask<{ readonly preventParallelTests?: boolean }>;

@ -5,11 +5,14 @@ import { render } from "mustache";
import { join } from "path"; import { join } from "path";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import dotnetcompile from "./dotnetcompile";
import sequential from "./sequential"; import sequential from "./sequential";
import writefile from "./writefile";
interface IParameters { interface IParameters {
readonly configuration: string; readonly configuration: string;
readonly isCodeAnalysisUnsupported: boolean; readonly isCodeAnalysisUnsupported: boolean;
readonly skipCodeAnalysis: boolean;
readonly skipCodeSigning: 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 deployTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.bat"), { encoding: "utf8" });
const versionTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { encoding: "utf8" }); const versionTemplate = readFileSync(join(__dirname, "/dotnetpackwebapp.template.version.aspx"), { encoding: "utf8" });
export default ((params, processor) => sequential({ export default ((params) => (processor) => sequential({
tasks: [ tasks: [
{ {
params: { name: "writemakepackage",
task: writefile({
data: render(msbuildTemplate, params), data: render(msbuildTemplate, params),
filename: "MakePackage.msbuild", filename: "MakePackage.msbuild",
}, }),
type: "writefile",
}, },
{ {
params: { name: "writedeploy",
task: writefile({
data: render(deployTemplate, params), data: render(deployTemplate, params),
filename: "Deploy.bat", filename: "Deploy.bat",
}, }),
type: "writefile",
}, },
{ {
params: { name: "writeversion",
task: writefile({
data: render(versionTemplate, params), data: render(versionTemplate, params),
filename: "version.aspx", filename: "version.aspx",
}, }),
type: "writefile",
}, },
{ {
params: { name: "compile",
configuration: params.configuration, task: dotnetcompile({
isCodeAnalysisUnsupported: params.isCodeAnalysisUnsupported, ...params,
overrideOutputDirectory: processor.context.release, overrideOutputDirectory: processor.context.release,
skipCodeSigning: params.skipCodeSigning,
solution: "MakePackage.msbuild", solution: "MakePackage.msbuild",
target: "Package", target: "Package",
}, }),
type: "dotnetcompile",
}, },
], ],
}, processor)) as GenericTask<IParameters>; })(processor)) as GenericTask<IParameters>;

@ -8,7 +8,7 @@ import { join } from "path";
import { GenericTask, TaskProcessor } from "../types"; import { GenericTask, TaskProcessor } from "../types";
interface IParameters { interface IParameters {
readonly skipCodeSigning: boolean; readonly skipCodeSigning?: boolean;
} }
type Callback = (err?: any, result?: string) => void; type Callback = (err?: any, result?: string) => void;
@ -38,7 +38,7 @@ const processAssemblyInfo = (params: IParameters, processor: TaskProcessor, appe
return cb(null, processInformationalVersion(processInternalsVisible(originalContent))); return cb(null, processInformationalVersion(processInternalsVisible(originalContent)));
}; };
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
return processor.done(); return processor.done();
} }

@ -8,7 +8,7 @@ interface IParameters {
readonly info: string; readonly info: string;
} }
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
if (params.error) { if (params.error) {
processor.onError(params.error); processor.onError(params.error);
} }

@ -7,7 +7,7 @@ import { GenericTask } from "../types";
const errorSeverity = 2; const errorSeverity = 2;
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
if (processor.settings.isCodeAnalysisUnsupported) { if (processor.settings.isCodeAnalysisUnsupported) {
return; return;
} }

@ -3,11 +3,12 @@
import * as glob from "glob"; import * as glob from "glob";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import eslintbrowser from "./eslintbrowser";
import parallel from "./parallel"; import parallel from "./parallel";
const flagDoneName = "eslintbrowserallDone"; const flagDoneName = "eslintbrowserallDone";
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
if (processor.context.containsFlag(flagDoneName)) { if (processor.context.containsFlag(flagDoneName)) {
processor.onWarn("eslintbrowserall task is executed more than once; this is probably a bug in your mbs.json"); 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({ return parallel({
tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({ tasks: files.filter((file) => !excludeFiles.includes(file)).map((file) => ({
name: file, name: file,
params: { filename: file }, task: eslintbrowser({ filename: file }),
type: "eslintbrowser",
})), })),
}, processor)(); })(processor)();
}); });
}) as GenericTask<{ readonly excludeFiles?: string[] }>; }) as GenericTask<{ readonly excludeFiles?: string[] }>;

@ -2,4 +2,4 @@
import { GenericTask } from "../types"; import { GenericTask } from "../types";
export default ((_params, processor) => processor.done) as GenericTask<{}>; export default ((_params) => (processor) => processor.done) as GenericTask<{}>;

@ -1,39 +1,44 @@
"use strict"; "use strict";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import cssnanoall from "./cssnanoall";
import eslintbrowserall from "./eslintbrowserall";
import sequential from "./sequential"; import sequential from "./sequential";
import uglifyjsall from "./uglifyjsall";
import writefile from "./writefile";
import zip from "./zip";
interface IParameters { interface IParameters {
readonly eslintExcludeFiles: boolean; readonly eslintExcludeFiles?: string[];
} }
export default ((params, processor) => sequential({ export default ((params) => (processor) => sequential({
tasks: [ tasks: [
{ {
params: { excludeFiles: params.eslintExcludeFiles }, name: "eslint",
type: "eslintbrowserall", task: eslintbrowserall({ excludeFiles: params.eslintExcludeFiles }),
}, },
{ {
params: { }, name: "uglifyjs",
type: "uglifyjsall", task: uglifyjsall({}),
}, },
{ {
params: { }, name: "cssnano",
type: "cssnanoall", task: cssnanoall({}),
}, },
{ {
params: { name: "writeversion",
task: writefile({
data: processor.context.versionInfo, data: processor.context.versionInfo,
filename: "version.txt", filename: "version.txt",
}, }),
type: "writefile",
}, },
{ {
params: { name: "zip",
task: zip({
archive: `${processor.context.reponame}.zip`, archive: `${processor.context.reponame}.zip`,
directory: "", directory: "",
}, }),
type: "zip",
}, },
], ],
}, processor)) as GenericTask<IParameters>; })(processor)) as GenericTask<IParameters>;

@ -10,4 +10,4 @@ interface IParameters {
const mapper = (processor: TaskProcessor) => (task: TaskInfo) => (callback: TaskProcessorCallback) => processor.processTask(task, callback); 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<IParameters>; export default ((params) => (processor) => () => parallel(params.tasks.map(mapper(processor)), processor.done)) as GenericTask<IParameters>;

@ -10,4 +10,4 @@ interface IParameters {
const mapper = (processor: TaskProcessor) => (task: TaskInfo) => (callback: TaskProcessorCallback) => processor.processTask(task, callback); 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<IParameters>; export default ((params) => (processor) => () => series(params.tasks.map(mapper(processor)), processor.done)) as GenericTask<IParameters>;

@ -6,7 +6,7 @@ import { minify } from "uglify-js";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
const filePath = normalize(join(processor.context.exported, params.filename)); const filePath = normalize(join(processor.context.exported, params.filename));
const result = minify(filePath); const result = minify(filePath);

@ -4,10 +4,11 @@ import * as glob from "glob";
import { GenericTask } from "../types"; import { GenericTask } from "../types";
import parallel from "./parallel"; import parallel from "./parallel";
import uglifyjs from "./uglifyjs";
const doneFlagName = "uglifyjsallDone"; const doneFlagName = "uglifyjsallDone";
export default ((_params, processor) => () => { export default ((_params) => (processor) => () => {
if (processor.context.containsFlag(doneFlagName)) { if (processor.context.containsFlag(doneFlagName)) {
processor.onWarn("dotnetnunitall task is executed more than once; this is probably a bug in your mbs.json"); 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({ return parallel({
tasks: files.map((file) => ({ tasks: files.map((file) => ({
name: file, name: file,
params: { filename: file }, task: uglifyjs({ filename: file }),
type: "uglifyjs",
})), })),
}, processor)(); })(processor)();
}); });
}) as GenericTask<{}>; }) as GenericTask<{}>;

@ -10,7 +10,7 @@ interface IParameters {
readonly filename: string; readonly filename: string;
} }
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
const filePath = join(processor.context.exported, params.filename); const filePath = join(processor.context.exported, params.filename);
processor.onInfo(`Writing to ${filePath}`); processor.onInfo(`Writing to ${filePath}`);

@ -11,7 +11,7 @@ interface IParameters {
readonly archive: string; readonly archive: string;
} }
export default ((params, processor) => () => { export default ((params) => (processor) => () => {
const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || ""))); const sourceDirectoryPath = normalize(join(processor.context.exported, String(params.directory || "")));
const targetArchivePath = normalize(join(processor.context.release, params.archive)); const targetArchivePath = normalize(join(processor.context.release, params.archive));

@ -3,7 +3,7 @@ export interface ICompileRequest {
readonly SolutionPath: string; readonly SolutionPath: string;
readonly Target: string; readonly Target: string;
readonly Configuration: string; readonly Configuration: string;
readonly OutputDirectory: string; readonly OutputDirectory?: string;
readonly SigningKey?: string; readonly SigningKey?: string;
readonly SkipCodeAnalysis: boolean; readonly SkipCodeAnalysis: boolean;
} }

@ -35,9 +35,9 @@ interface ITaskParameters {
readonly [paramName: string]: any; readonly [paramName: string]: any;
} }
type TaskWithParameters = () => void; type TaskWithParameters = (processor: ITaskProcessor) => () => void;
export type GenericTask<TParams> = (params: TParams, processor: ITaskProcessor) => TaskWithParameters; export type GenericTask<TParams> = (params: TParams) => TaskWithParameters;
export type Task = GenericTask<ITaskParameters>; export type Task = GenericTask<ITaskParameters>;
@ -52,7 +52,7 @@ export interface ITaskInfoExternal {
} }
export interface ITaskInfoInternal { export interface ITaskInfoInternal {
readonly name: string; readonly name?: string;
readonly task: TaskWithParameters; readonly task: TaskWithParameters;
} }

Loading…
Cancel
Save