@expo/steps 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_commonjs/BuildConfig.cjs +3 -3
- package/dist_commonjs/BuildConfig.js.map +1 -1
- package/dist_commonjs/BuildConfigParser.cjs +55 -42
- package/dist_commonjs/BuildConfigParser.d.ts +5 -1
- package/dist_commonjs/BuildConfigParser.js.map +1 -1
- package/dist_commonjs/BuildFunction.cjs +9 -3
- package/dist_commonjs/BuildFunction.js.map +1 -1
- package/dist_commonjs/BuildStep.cjs +32 -24
- package/dist_commonjs/BuildStep.d.ts +9 -3
- package/dist_commonjs/BuildStep.js.map +1 -1
- package/dist_commonjs/BuildStepContext.cjs +2 -2
- package/dist_commonjs/BuildStepContext.js.map +1 -1
- package/dist_commonjs/BuildStepInput.cjs +6 -6
- package/dist_commonjs/BuildStepInput.d.ts +3 -3
- package/dist_commonjs/BuildStepInput.js.map +1 -1
- package/dist_commonjs/BuildStepOutput.cjs +6 -6
- package/dist_commonjs/BuildStepOutput.d.ts +4 -4
- package/dist_commonjs/BuildStepOutput.js.map +1 -1
- package/dist_commonjs/BuildWorkflowValidator.cjs +16 -17
- package/dist_commonjs/BuildWorkflowValidator.js.map +1 -1
- package/dist_commonjs/errors.cjs +30 -0
- package/dist_commonjs/errors.d.ts +24 -0
- package/dist_commonjs/errors.js.map +1 -0
- package/dist_commonjs/index.cjs +27 -1
- package/dist_commonjs/index.d.ts +2 -0
- package/dist_commonjs/index.js.map +1 -1
- package/dist_commonjs/utils/template.cjs +2 -2
- package/dist_commonjs/utils/template.js.map +1 -1
- package/dist_esm/BuildConfig.js +1 -1
- package/dist_esm/BuildConfig.js.map +1 -1
- package/dist_esm/BuildConfigParser.d.ts +5 -1
- package/dist_esm/BuildConfigParser.js +54 -41
- package/dist_esm/BuildConfigParser.js.map +1 -1
- package/dist_esm/BuildFunction.js +9 -3
- package/dist_esm/BuildFunction.js.map +1 -1
- package/dist_esm/BuildStep.d.ts +9 -3
- package/dist_esm/BuildStep.js +31 -23
- package/dist_esm/BuildStep.js.map +1 -1
- package/dist_esm/BuildStepContext.js +1 -1
- package/dist_esm/BuildStepContext.js.map +1 -1
- package/dist_esm/BuildStepInput.d.ts +3 -3
- package/dist_esm/BuildStepInput.js +6 -6
- package/dist_esm/BuildStepInput.js.map +1 -1
- package/dist_esm/BuildStepOutput.d.ts +4 -4
- package/dist_esm/BuildStepOutput.js +6 -6
- package/dist_esm/BuildStepOutput.js.map +1 -1
- package/dist_esm/BuildWorkflowValidator.js +15 -16
- package/dist_esm/BuildWorkflowValidator.js.map +1 -1
- package/dist_esm/errors.d.ts +24 -0
- package/dist_esm/errors.js +23 -0
- package/dist_esm/errors.js.map +1 -0
- package/dist_esm/index.d.ts +2 -0
- package/dist_esm/index.js +2 -0
- package/dist_esm/index.js.map +1 -1
- package/dist_esm/utils/template.js +1 -1
- package/dist_esm/utils/template.js.map +1 -1
- package/package.json +1 -1
- package/dist_commonjs/errors/BuildConfigError.cjs +0 -8
- package/dist_commonjs/errors/BuildConfigError.d.ts +0 -3
- package/dist_commonjs/errors/BuildConfigError.js.map +0 -1
- package/dist_commonjs/errors/BuildInternalError.cjs +0 -7
- package/dist_commonjs/errors/BuildInternalError.d.ts +0 -2
- package/dist_commonjs/errors/BuildInternalError.js.map +0 -1
- package/dist_commonjs/errors/BuildStepRuntimeError.cjs +0 -8
- package/dist_commonjs/errors/BuildStepRuntimeError.d.ts +0 -3
- package/dist_commonjs/errors/BuildStepRuntimeError.js.map +0 -1
- package/dist_commonjs/errors/BuildWorkflowError.cjs +0 -13
- package/dist_commonjs/errors/BuildWorkflowError.d.ts +0 -10
- package/dist_commonjs/errors/BuildWorkflowError.js.map +0 -1
- package/dist_commonjs/errors/UserError.cjs +0 -14
- package/dist_commonjs/errors/UserError.d.ts +0 -9
- package/dist_commonjs/errors/UserError.js.map +0 -1
- package/dist_esm/errors/BuildConfigError.d.ts +0 -3
- package/dist_esm/errors/BuildConfigError.js +0 -4
- package/dist_esm/errors/BuildConfigError.js.map +0 -1
- package/dist_esm/errors/BuildInternalError.d.ts +0 -2
- package/dist_esm/errors/BuildInternalError.js +0 -3
- package/dist_esm/errors/BuildInternalError.js.map +0 -1
- package/dist_esm/errors/BuildStepRuntimeError.d.ts +0 -3
- package/dist_esm/errors/BuildStepRuntimeError.js +0 -4
- package/dist_esm/errors/BuildStepRuntimeError.js.map +0 -1
- package/dist_esm/errors/BuildWorkflowError.d.ts +0 -10
- package/dist_esm/errors/BuildWorkflowError.js +0 -9
- package/dist_esm/errors/BuildWorkflowError.js.map +0 -1
- package/dist_esm/errors/UserError.d.ts +0 -9
- package/dist_esm/errors/UserError.js +0 -10
- package/dist_esm/errors/UserError.js.map +0 -1
|
@@ -7,7 +7,7 @@ exports.BuildStepContext = void 0;
|
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const template_js_1 = require("./utils/template.cjs");
|
|
10
|
-
const
|
|
10
|
+
const errors_js_1 = require("./errors.cjs");
|
|
11
11
|
class BuildStepContext {
|
|
12
12
|
constructor(buildId, logger, skipCleanup, workingDirectory) {
|
|
13
13
|
this.buildId = buildId;
|
|
@@ -23,7 +23,7 @@ class BuildStepContext {
|
|
|
23
23
|
getStepOutputValue(path) {
|
|
24
24
|
const { stepId, outputId } = (0, template_js_1.parseOutputPath)(path);
|
|
25
25
|
if (!(stepId in this.stepById)) {
|
|
26
|
-
throw new
|
|
26
|
+
throw new errors_js_1.BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
|
|
27
27
|
}
|
|
28
28
|
return this.stepById[stepId].getOutputValueByName(outputId);
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAKxB,qDAAsD;AACtD,
|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GAAI,IAAI,CAAC,MAAM,EACrB,IAAI,CAAC,WAAW,EAChB,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,IAAI,CAAC,gBAAgB,CAC1C,CAAC;IACJ,CAAC;CACF;AA1CD,4CA0CC","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStep } from './BuildStep.js';\nimport { parseOutputPath } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\n\nexport class BuildStepContext {\n public readonly baseWorkingDirectory: string;\n public readonly workingDirectory: string;\n\n private stepById: Record<string, BuildStep> = {};\n\n constructor(\n public readonly buildId: string,\n public readonly logger: bunyan,\n public readonly skipCleanup: boolean,\n workingDirectory?: string\n ) {\n this.baseWorkingDirectory = path.join(os.tmpdir(), 'eas-build', buildId);\n this.workingDirectory = workingDirectory ?? path.join(this.baseWorkingDirectory, 'project');\n }\n\n public registerStep(step: BuildStep): void {\n this.stepById[step.id] = step;\n }\n\n public getStepOutputValue(path: string): string | undefined {\n const { stepId, outputId } = parseOutputPath(path);\n if (!(stepId in this.stepById)) {\n throw new BuildStepRuntimeError(`Step \"${stepId}\" does not exist.`);\n }\n return this.stepById[stepId].getOutputValueByName(outputId);\n }\n\n public child({\n logger,\n workingDirectory,\n }: {\n logger?: bunyan;\n workingDirectory?: string;\n } = {}): BuildStepContext {\n return new BuildStepContext(\n this.buildId,\n logger ?? this.logger,\n this.skipCleanup,\n workingDirectory ?? this.workingDirectory\n );\n }\n}\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeBuildStepInputByIdMap = exports.BuildStepInput = void 0;
|
|
4
|
-
const
|
|
4
|
+
const errors_js_1 = require("./errors.cjs");
|
|
5
5
|
const template_js_1 = require("./utils/template.cjs");
|
|
6
6
|
class BuildStepInput {
|
|
7
7
|
static createProvider(params) {
|
|
8
|
-
return (ctx,
|
|
8
|
+
return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });
|
|
9
9
|
}
|
|
10
|
-
constructor(ctx, { id,
|
|
10
|
+
constructor(ctx, { id, stepDisplayName, defaultValue, required = true, }) {
|
|
11
11
|
this.ctx = ctx;
|
|
12
12
|
this.id = id;
|
|
13
|
-
this.
|
|
13
|
+
this.stepDisplayName = stepDisplayName;
|
|
14
14
|
this.defaultValue = defaultValue;
|
|
15
15
|
this.required = required;
|
|
16
16
|
}
|
|
@@ -18,7 +18,7 @@ class BuildStepInput {
|
|
|
18
18
|
var _a;
|
|
19
19
|
const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
|
|
20
20
|
if (this.required && rawValue === undefined) {
|
|
21
|
-
throw new
|
|
21
|
+
throw new errors_js_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
22
22
|
}
|
|
23
23
|
if (rawValue === undefined) {
|
|
24
24
|
return rawValue;
|
|
@@ -29,7 +29,7 @@ class BuildStepInput {
|
|
|
29
29
|
}
|
|
30
30
|
set(value) {
|
|
31
31
|
if (this.required && value === undefined) {
|
|
32
|
-
throw new
|
|
32
|
+
throw new errors_js_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
|
|
33
33
|
}
|
|
34
34
|
this._value = value;
|
|
35
35
|
return this;
|
|
@@ -4,7 +4,7 @@ export type BuildStepInputProvider = (ctx: BuildStepContext, stepId: string) =>
|
|
|
4
4
|
export declare class BuildStepInput {
|
|
5
5
|
private readonly ctx;
|
|
6
6
|
readonly id: string;
|
|
7
|
-
readonly
|
|
7
|
+
readonly stepDisplayName: string;
|
|
8
8
|
readonly defaultValue?: string;
|
|
9
9
|
readonly required: boolean;
|
|
10
10
|
private _value?;
|
|
@@ -13,9 +13,9 @@ export declare class BuildStepInput {
|
|
|
13
13
|
defaultValue?: string;
|
|
14
14
|
required?: boolean;
|
|
15
15
|
}): BuildStepInputProvider;
|
|
16
|
-
constructor(ctx: BuildStepContext, { id,
|
|
16
|
+
constructor(ctx: BuildStepContext, { id, stepDisplayName, defaultValue, required, }: {
|
|
17
17
|
id: string;
|
|
18
|
-
|
|
18
|
+
stepDisplayName: string;
|
|
19
19
|
defaultValue?: string;
|
|
20
20
|
required?: boolean;
|
|
21
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":";;;AACA,2CAAoD;AACpD,qDAA6D;AAK7D,MAAa,cAAc;IAQlB,MAAM,CAAC,cAAc,CAAC,MAI5B;QACC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,YACmB,GAAqB,EACtC,EACE,EAAE,EACF,eAAe,EACf,YAAY,EACZ,QAAQ,GAAG,IAAI,GAMhB;QAXgB,QAAG,GAAH,GAAG,CAAkB;QAatC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;;QACP,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,iCAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,mCAAmC,CAClG,CAAC;SACH;QAED,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,OAAO,QAAQ,CAAC;SACjB;aAAM;YACL,OAAO,IAAA,oCAAsB,EAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAA,EAAA,CAAC,CAAC;SAC5F;IACH,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,iCAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,gBAAgB,CAC/E,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA5DD,wCA4DC;AAED,SAAgB,yBAAyB,CAAC,MAAyB;IACjE,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,OAAO,EAAE,CAAC;KACX;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAClC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAwB,CAAC,CAAC;AAC/B,CAAC;AARD,8DAQC","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { interpolateWithOutputs } from './utils/template.js';\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (ctx: BuildStepContext, stepId: string) => BuildStepInput;\n\nexport class BuildStepInput {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: string;\n public readonly required: boolean;\n\n private _value?: string;\n\n public static createProvider(params: {\n id: string;\n defaultValue?: string;\n required?: boolean;\n }): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n stepDisplayName,\n defaultValue,\n required = true,\n }: {\n id: string;\n stepDisplayName: string;\n defaultValue?: string;\n required?: boolean;\n }\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.defaultValue = defaultValue;\n this.required = required;\n }\n\n get value(): string | undefined {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n\n if (rawValue === undefined) {\n return rawValue;\n } else {\n return interpolateWithOutputs(rawValue, (path) => this.ctx.getStepOutputValue(path) ?? '');\n }\n }\n\n set(value: string | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n\nexport function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById {\n if (inputs === undefined) {\n return {};\n }\n return inputs.reduce((acc, input) => {\n acc[input.id] = input;\n return acc;\n }, {} as BuildStepInputById);\n}\n"]}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeBuildStepOutputByIdMap = exports.BuildStepOutput = void 0;
|
|
4
|
-
const
|
|
4
|
+
const errors_js_1 = require("./errors.cjs");
|
|
5
5
|
class BuildStepOutput {
|
|
6
6
|
static createProvider(params) {
|
|
7
|
-
return (ctx,
|
|
7
|
+
return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });
|
|
8
8
|
}
|
|
9
9
|
constructor(
|
|
10
10
|
// @ts-expect-error ctx is not used in this class but let's keep it here for consistency
|
|
11
|
-
ctx, { id,
|
|
11
|
+
ctx, { id, stepDisplayName, required = true, }) {
|
|
12
12
|
this.ctx = ctx;
|
|
13
13
|
this.id = id;
|
|
14
|
-
this.
|
|
14
|
+
this.stepDisplayName = stepDisplayName;
|
|
15
15
|
this.required = required;
|
|
16
16
|
}
|
|
17
17
|
get value() {
|
|
18
18
|
if (this.required && this._value === undefined) {
|
|
19
|
-
throw new
|
|
19
|
+
throw new errors_js_1.BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
20
20
|
}
|
|
21
21
|
return this._value;
|
|
22
22
|
}
|
|
23
23
|
set(value) {
|
|
24
24
|
if (this.required && value === undefined) {
|
|
25
|
-
throw new
|
|
25
|
+
throw new errors_js_1.BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
|
|
26
26
|
}
|
|
27
27
|
this._value = value;
|
|
28
28
|
return this;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { BuildStepContext } from './BuildStepContext.js';
|
|
2
2
|
export type BuildStepOutputById = Record<string, BuildStepOutput>;
|
|
3
|
-
export type BuildStepOutputProvider = (ctx: BuildStepContext,
|
|
3
|
+
export type BuildStepOutputProvider = (ctx: BuildStepContext, stepDisplayName: string) => BuildStepOutput;
|
|
4
4
|
export declare class BuildStepOutput {
|
|
5
5
|
private readonly ctx;
|
|
6
6
|
readonly id: string;
|
|
7
|
-
readonly
|
|
7
|
+
readonly stepDisplayName: string;
|
|
8
8
|
readonly required: boolean;
|
|
9
9
|
private _value?;
|
|
10
10
|
static createProvider(params: {
|
|
11
11
|
id: string;
|
|
12
12
|
required?: boolean;
|
|
13
13
|
}): BuildStepOutputProvider;
|
|
14
|
-
constructor(ctx: BuildStepContext, { id,
|
|
14
|
+
constructor(ctx: BuildStepContext, { id, stepDisplayName, required, }: {
|
|
15
15
|
id: string;
|
|
16
|
-
|
|
16
|
+
stepDisplayName: string;
|
|
17
17
|
required?: boolean;
|
|
18
18
|
});
|
|
19
19
|
get value(): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":";;;AACA,2CAAoD;AAQpD,MAAa,eAAe;IAOnB,MAAM,CAAC,cAAc,CAAC,MAG5B;QACC,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;IACE,wFAAwF;IACvE,GAAqB,EACtC,EACE,EAAE,EACF,eAAe,EACf,QAAQ,GAAG,IAAI,GAC6C;QAL7C,QAAG,GAAH,GAAG,CAAkB;QAOtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9C,MAAM,IAAI,iCAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,mCAAmC,CACnG,CAAC;SACH;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,iCAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,gBAAgB,CAChF,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9CD,0CA8CC;AAED,SAAgB,0BAA0B,CAAC,OAA2B;IACpE,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,EAAE,CAAC;KACX;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACpC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACxB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAyB,CAAC,CAAC;AAChC,CAAC;AARD,gEAQC","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\n\nexport type BuildStepOutputById = Record<string, BuildStepOutput>;\nexport type BuildStepOutputProvider = (\n ctx: BuildStepContext,\n stepDisplayName: string\n) => BuildStepOutput;\n\nexport class BuildStepOutput {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly required: boolean;\n\n private _value?: string;\n\n public static createProvider(params: {\n id: string;\n required?: boolean;\n }): BuildStepOutputProvider {\n return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n // @ts-expect-error ctx is not used in this class but let's keep it here for consistency\n private readonly ctx: BuildStepContext,\n {\n id,\n stepDisplayName,\n required = true,\n }: { id: string; stepDisplayName: string; required?: boolean }\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.required = required;\n }\n\n get value(): string | undefined {\n if (this.required && this._value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n return this._value;\n }\n\n set(value: string | undefined): BuildStepOutput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n\nexport function makeBuildStepOutputByIdMap(outputs?: BuildStepOutput[]): BuildStepOutputById {\n if (outputs === undefined) {\n return {};\n }\n return outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as BuildStepOutputById);\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuildWorkflowValidator = void 0;
|
|
4
|
-
const
|
|
5
|
-
const BuildWorkflowError_js_1 = require("./errors/BuildWorkflowError.cjs");
|
|
4
|
+
const errors_js_1 = require("./errors.cjs");
|
|
6
5
|
const duplicates_js_1 = require("./utils/expodash/duplicates.cjs");
|
|
7
6
|
const template_js_1 = require("./utils/template.cjs");
|
|
8
7
|
class BuildWorkflowValidator {
|
|
@@ -14,7 +13,7 @@ class BuildWorkflowValidator {
|
|
|
14
13
|
errors.push(...this.validateUniqueStepIds());
|
|
15
14
|
errors.push(...this.validateInputs());
|
|
16
15
|
if (errors.length !== 0) {
|
|
17
|
-
throw new
|
|
16
|
+
throw new errors_js_1.BuildWorkflowError('Build workflow is invalid.', errors);
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
validateUniqueStepIds() {
|
|
@@ -24,7 +23,7 @@ class BuildWorkflowValidator {
|
|
|
24
23
|
return [];
|
|
25
24
|
}
|
|
26
25
|
else {
|
|
27
|
-
const error = new
|
|
26
|
+
const error = new errors_js_1.BuildConfigError(`Duplicated step IDs: ${duplicatedStepIds.map((i) => `"${i}"`).join(', ')}`);
|
|
28
27
|
return [error];
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -32,33 +31,33 @@ class BuildWorkflowValidator {
|
|
|
32
31
|
var _a;
|
|
33
32
|
const errors = [];
|
|
34
33
|
const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));
|
|
35
|
-
const
|
|
36
|
-
for (const
|
|
37
|
-
for (const
|
|
38
|
-
if (
|
|
34
|
+
const visitedStepByStepId = {};
|
|
35
|
+
for (const currentStep of this.workflow.buildSteps) {
|
|
36
|
+
for (const currentStepInput of (_a = currentStep.inputs) !== null && _a !== void 0 ? _a : []) {
|
|
37
|
+
if (currentStepInput.defaultValue === undefined) {
|
|
39
38
|
continue;
|
|
40
39
|
}
|
|
41
|
-
const paths = (0, template_js_1.findOutputPaths)(
|
|
42
|
-
for (const { stepId, outputId } of paths) {
|
|
43
|
-
if (!(
|
|
44
|
-
if (allStepIds.has(
|
|
45
|
-
const error = new
|
|
40
|
+
const paths = (0, template_js_1.findOutputPaths)(currentStepInput.defaultValue);
|
|
41
|
+
for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {
|
|
42
|
+
if (!(referencedStepId in visitedStepByStepId)) {
|
|
43
|
+
if (allStepIds.has(referencedStepId)) {
|
|
44
|
+
const error = new errors_js_1.BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an output parameter from the future step "${referencedStepId}".`);
|
|
46
45
|
errors.push(error);
|
|
47
46
|
}
|
|
48
47
|
else {
|
|
49
|
-
const error = new
|
|
48
|
+
const error = new errors_js_1.BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an output parameter from a non-existent step "${referencedStepId}".`);
|
|
50
49
|
errors.push(error);
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
else {
|
|
54
|
-
if (!
|
|
55
|
-
const error = new
|
|
53
|
+
if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {
|
|
54
|
+
const error = new errors_js_1.BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an undefined output parameter "${referencedStepOutputId}" from step "${referencedStepId}".`);
|
|
56
55
|
errors.push(error);
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
|
|
60
|
+
visitedStepByStepId[currentStep.id] = currentStep;
|
|
62
61
|
}
|
|
63
62
|
return errors;
|
|
64
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":";;;AAEA,2CAAmE;AACnE,kEAA4D;AAC5D,qDAAsD;AAEtD,MAAa,sBAAsB;IACjC,YAA6B,QAAuB;QAAvB,aAAQ,GAAR,QAAQ,CAAe;IAAG,CAAC;IAEjD,QAAQ;QACb,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,8BAAkB,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;SACpE;IACH,CAAC;IAEO,qBAAqB;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7D,MAAM,iBAAiB,GAAG,IAAA,0BAAU,EAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,OAAO,EAAE,CAAC;SACX;aAAM;YACL,MAAM,KAAK,GAAG,IAAI,4BAAgB,CAChC,wBAAwB,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC5E,CAAC;YACF,OAAO,CAAC,KAAK,CAAC,CAAC;SAChB;IACH,CAAC;IAEO,cAAc;;QACpB,MAAM,MAAM,GAAuB,EAAE,CAAC;QAEtC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,IAAI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CAAC,WAAW,uEAAuE,sBAAsB,gBAAgB,gBAAgB,IAAI,CAC/M,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;qBACF;iBACF;aACF;YACD,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;SACnD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAhED,wDAgEC","sourcesContent":["import { BuildStep } from './BuildStep.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { findOutputPaths } from './utils/template.js';\n\nexport class BuildWorkflowValidator {\n constructor(private readonly workflow: BuildWorkflow) {}\n\n public validate(): void {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n if (errors.length !== 0) {\n throw new BuildWorkflowError('Build workflow is invalid.', errors);\n }\n }\n\n private validateUniqueStepIds(): BuildConfigError[] {\n const stepIds = this.workflow.buildSteps.map(({ id }) => id);\n const duplicatedStepIds = duplicates(stepIds);\n if (duplicatedStepIds.length === 0) {\n return [];\n } else {\n const error = new BuildConfigError(\n `Duplicated step IDs: ${duplicatedStepIds.map((i) => `\"${i}\"`).join(', ')}`\n );\n return [error];\n }\n }\n\n private validateInputs(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n\n const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));\n const visitedStepByStepId: Record<string, BuildStep> = {};\n for (const currentStep of this.workflow.buildSteps) {\n for (const currentStepInput of currentStep.inputs ?? []) {\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n const paths = findOutputPaths(currentStepInput.defaultValue);\n for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {\n if (!(referencedStepId in visitedStepByStepId)) {\n if (allStepIds.has(referencedStepId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from the future step \"${referencedStepId}\".`\n );\n errors.push(error);\n } else {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from a non-existent step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n } else {\n if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an undefined output parameter \"${referencedStepOutputId}\" from step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n }\n }\n }\n visitedStepByStepId[currentStep.id] = currentStep;\n }\n\n return errors;\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildWorkflowError = exports.BuildStepRuntimeError = exports.BuildInternalError = exports.BuildConfigError = void 0;
|
|
4
|
+
class UserError extends Error {
|
|
5
|
+
constructor(message, extra) {
|
|
6
|
+
var _a;
|
|
7
|
+
super(message);
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.metadata = (_a = extra === null || extra === void 0 ? void 0 : extra.cause) !== null && _a !== void 0 ? _a : {};
|
|
10
|
+
this.cause = extra === null || extra === void 0 ? void 0 : extra.cause;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class BuildConfigError extends UserError {
|
|
14
|
+
}
|
|
15
|
+
exports.BuildConfigError = BuildConfigError;
|
|
16
|
+
class BuildInternalError extends Error {
|
|
17
|
+
}
|
|
18
|
+
exports.BuildInternalError = BuildInternalError;
|
|
19
|
+
class BuildStepRuntimeError extends UserError {
|
|
20
|
+
}
|
|
21
|
+
exports.BuildStepRuntimeError = BuildStepRuntimeError;
|
|
22
|
+
class BuildWorkflowError extends UserError {
|
|
23
|
+
constructor(message, errors, extra) {
|
|
24
|
+
super(message, extra);
|
|
25
|
+
this.message = message;
|
|
26
|
+
this.errors = errors;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.BuildWorkflowError = BuildWorkflowError;
|
|
30
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare abstract class UserError extends Error {
|
|
2
|
+
readonly message: string;
|
|
3
|
+
readonly cause?: Error;
|
|
4
|
+
readonly metadata: object;
|
|
5
|
+
constructor(message: string, extra?: {
|
|
6
|
+
metadata?: object;
|
|
7
|
+
cause?: Error;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export declare class BuildConfigError extends UserError {
|
|
11
|
+
}
|
|
12
|
+
export declare class BuildInternalError extends Error {
|
|
13
|
+
}
|
|
14
|
+
export declare class BuildStepRuntimeError extends UserError {
|
|
15
|
+
}
|
|
16
|
+
export declare class BuildWorkflowError extends UserError {
|
|
17
|
+
readonly message: string;
|
|
18
|
+
readonly errors: BuildConfigError[];
|
|
19
|
+
constructor(message: string, errors: BuildConfigError[], extra?: {
|
|
20
|
+
metadata?: object;
|
|
21
|
+
cause?: Error;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAe,SAAU,SAAQ,KAAK;IAIpC,YAC2B,OAAe,EACxC,KAGC;;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QANU,YAAO,GAAP,OAAO,CAAQ;QAOxC,IAAI,CAAC,QAAQ,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;IAC5B,CAAC;CACF;AAED,MAAa,gBAAiB,SAAQ,SAAS;CAAG;AAAlD,4CAAkD;AAElD,MAAa,kBAAmB,SAAQ,KAAK;CAAG;AAAhD,gDAAgD;AAEhD,MAAa,qBAAsB,SAAQ,SAAS;CAAG;AAAvD,sDAAuD;AAEvD,MAAa,kBAAmB,SAAQ,SAAS;IAC/C,YAC2B,OAAe,EACxB,MAA0B,EAC1C,KAGC;QAED,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAPG,YAAO,GAAP,OAAO,CAAQ;QACxB,WAAM,GAAN,MAAM,CAAoB;IAO5C,CAAC;CACF;AAXD,gDAWC","sourcesContent":["abstract class UserError extends Error {\n public readonly cause?: Error;\n public readonly metadata: object;\n\n constructor(\n public override readonly message: string,\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message);\n this.metadata = extra?.cause ?? {};\n this.cause = extra?.cause;\n }\n}\n\nexport class BuildConfigError extends UserError {}\n\nexport class BuildInternalError extends Error {}\n\nexport class BuildStepRuntimeError extends UserError {}\n\nexport class BuildWorkflowError extends UserError {\n constructor(\n public override readonly message: string,\n public readonly errors: BuildConfigError[],\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message, extra);\n }\n}\n"]}
|
package/dist_commonjs/index.cjs
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BuildStepContext = exports.BuildStepOutput = exports.BuildStepInput = exports.BuildFunction = exports.BuildConfigParser = void 0;
|
|
26
|
+
exports.errors = exports.BuildWorkflow = exports.BuildStepContext = exports.BuildStepOutput = exports.BuildStepInput = exports.BuildFunction = exports.BuildConfigParser = void 0;
|
|
4
27
|
var BuildConfigParser_js_1 = require("./BuildConfigParser.cjs");
|
|
5
28
|
Object.defineProperty(exports, "BuildConfigParser", { enumerable: true, get: function () { return BuildConfigParser_js_1.BuildConfigParser; } });
|
|
6
29
|
var BuildFunction_js_1 = require("./BuildFunction.cjs");
|
|
@@ -11,4 +34,7 @@ var BuildStepOutput_js_1 = require("./BuildStepOutput.cjs");
|
|
|
11
34
|
Object.defineProperty(exports, "BuildStepOutput", { enumerable: true, get: function () { return BuildStepOutput_js_1.BuildStepOutput; } });
|
|
12
35
|
var BuildStepContext_js_1 = require("./BuildStepContext.cjs");
|
|
13
36
|
Object.defineProperty(exports, "BuildStepContext", { enumerable: true, get: function () { return BuildStepContext_js_1.BuildStepContext; } });
|
|
37
|
+
var BuildWorkflow_js_1 = require("./BuildWorkflow.cjs");
|
|
38
|
+
Object.defineProperty(exports, "BuildWorkflow", { enumerable: true, get: function () { return BuildWorkflow_js_1.BuildWorkflow; } });
|
|
39
|
+
exports.errors = __importStar(require("./errors.cjs"));
|
|
14
40
|
//# sourceMappingURL=index.js.map
|
package/dist_commonjs/index.d.ts
CHANGED
|
@@ -3,3 +3,5 @@ export { BuildFunction } from './BuildFunction.js';
|
|
|
3
3
|
export { BuildStepInput } from './BuildStepInput.js';
|
|
4
4
|
export { BuildStepOutput } from './BuildStepOutput.js';
|
|
5
5
|
export { BuildStepContext } from './BuildStepContext.js';
|
|
6
|
+
export { BuildWorkflow } from './BuildWorkflow.js';
|
|
7
|
+
export * as errors from './errors.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,yDAAqD;AAA5C,mHAAA,cAAc,OAAA;AACvB,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,sDAAsC","sourcesContent":["export { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildStepInput } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepContext } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport * as errors from './errors.js';\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseOutputPath = exports.findOutputPaths = exports.interpolateWithOutputs = exports.interpolateWithInputs = exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = void 0;
|
|
4
|
-
const
|
|
4
|
+
const errors_js_1 = require("../errors.cjs");
|
|
5
5
|
const nullthrows_js_1 = require("./nullthrows.cjs");
|
|
6
6
|
exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*inputs\.([\S]+)\s*}/;
|
|
7
7
|
exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*steps\.([\S]+)\s*}/;
|
|
@@ -38,7 +38,7 @@ exports.findOutputPaths = findOutputPaths;
|
|
|
38
38
|
function parseOutputPath(outputPath) {
|
|
39
39
|
const splits = outputPath.split('.');
|
|
40
40
|
if (splits.length !== 2) {
|
|
41
|
-
throw new
|
|
41
|
+
throw new errors_js_1.BuildConfigError(`Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. "step3.output1". Passed: "${outputPath}"`);
|
|
42
42
|
}
|
|
43
43
|
const [stepId, outputId] = splits;
|
|
44
44
|
return { stepId, outputId };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,mDAA6C;AAEhC,QAAA,kCAAkC,GAAG,2BAA2B,CAAC;AACjE,QAAA,mCAAmC,GAAG,0BAA0B,CAAC;AAE9E,SAAgB,qBAAqB,CACnC,cAAsB,EACtB,MAA8B;IAE9B,OAAO,WAAW,CAAC,cAAc,EAAE,0CAAkC,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AALD,sDAKC;AAED,SAAgB,sBAAsB,CACpC,cAAsB,EACtB,EAA4B;IAE5B,OAAO,WAAW,CAAC,cAAc,EAAE,2CAAmC,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AALD,wDAKC;AAED,SAAS,WAAW,CAClB,cAAsB,EACtB,KAAa,EACb,QAA4D;IAE5D,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,MAAM,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C;AAC9B,CAAC;AATD,0CASC","sourcesContent":["import { BuildConfigError } from '../errors.js';\n\nimport { nullthrows } from './nullthrows.js';\n\nexport const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\\${\\s*inputs\\.([\\S]+)\\s*}/;\nexport const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\\${\\s*steps\\.([\\S]+)\\s*}/;\n\nexport function interpolateWithInputs(\n templateString: string,\n inputs: Record<string, string>\n): string {\n return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);\n}\n\nexport function interpolateWithOutputs(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);\n}\n\nfunction interpolate(\n templateString: string,\n regex: RegExp,\n varsOrFn: Record<string, string> | ((key: string) => string)\n): string {\n const matched = templateString.match(new RegExp(regex, 'g'));\n if (!matched) {\n return templateString;\n }\n let result = templateString;\n for (const match of matched) {\n const [, key] = nullthrows(match.match(regex));\n const value = typeof varsOrFn === 'function' ? varsOrFn(key) : varsOrFn[key];\n result = result.replace(match, value);\n }\n return result;\n}\n\ninterface BuildOutputPath {\n stepId: string;\n outputId: string;\n}\n\nexport function findOutputPaths(templateString: string): BuildOutputPath[] {\n const result: BuildOutputPath[] = [];\n const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));\n for (const match of matches) {\n result.push(parseOutputPath(match[1]));\n }\n return result;\n}\n\nexport function parseOutputPath(outputPath: string): BuildOutputPath {\n const splits = outputPath.split('.');\n if (splits.length !== 2) {\n throw new BuildConfigError(\n `Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. \"step3.output1\". Passed: \"${outputPath}\"`\n );\n }\n const [stepId, outputId] = splits;\n return { stepId, outputId };\n}\n"]}
|
package/dist_esm/BuildConfig.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
2
|
import Joi from 'joi';
|
|
3
|
-
import { BuildConfigError } from './errors
|
|
3
|
+
import { BuildConfigError } from './errors.js';
|
|
4
4
|
import { BuildPlatform } from './BuildPlatform.js';
|
|
5
5
|
const BuildInputOutputParametersSchema = Joi.array().items(Joi.alternatives().try(Joi.string().required(), Joi.object({
|
|
6
6
|
name: Joi.string().required(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA2DnD,MAAM,gCAAgC,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACxD,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,CACpB,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EACvB,GAAG,CAAC,MAAM,CAAC;IACT,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE;CACxB,CAAC,CAAC,QAAQ,EAAE,CACd,CACF,CAAC;AAEF,MAAM,uBAAuB,GAAG,GAAG,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IACxD,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;IAClB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;IAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,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B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,CACJ,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,wEAAwE,CACzE,CAAC;YACF,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACjC;KACF;IACD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACvD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE;;QACrE,OAAO,CACL,CAAC,CAAC,cAAc,IAAI,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC,CAC7F,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;QACnC,MAAM,IAAI,gBAAgB,CACxB,mCAAmC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3F,CAAC;KACH;AACH,CAAC","sourcesContent":["import assert from 'assert';\n\nimport Joi from 'joi';\n\nimport { BuildConfigError } from './errors/BuildConfigError.js';\nimport { BuildPlatform } from './BuildPlatform.js';\n\nexport interface BuildConfig {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n functions?: Record<string, BuildFunctionConfig>;\n}\n\nexport type BuildStepConfig =\n | BuildStepCommandRun\n | BuildStepBareCommandRun\n | BuildStepFunctionCall\n | BuildStepBareFunctionCall;\n\nexport type BuildStepCommandRun = {\n run: BuildFunctionCallConfig & {\n outputs?: BuildStepOutputs;\n command: string;\n };\n};\nexport type BuildStepBareCommandRun = { run: string };\nexport type BuildStepFunctionCall = {\n [functionId: string]: BuildFunctionCallConfig;\n};\nexport type BuildStepBareFunctionCall = string;\n\nexport type BuildFunctionCallConfig = {\n id?: string;\n inputs?: BuildStepInputs;\n name?: string;\n workingDirectory?: string;\n shell?: string;\n};\n\nexport type BuildStepInputs = Record<string, string>;\nexport type BuildStepOutputs = BuildInputOutputParameters;\n\nexport interface BuildFunctionConfig {\n inputs?: BuildFunctionInputs;\n outputs?: BuildFunctionOutputs;\n name?: string;\n platforms?: BuildPlatform[];\n shell?: string;\n command: string;\n}\n\nexport type BuildFunctionInputs = BuildInputOutputParameters;\nexport type BuildFunctionOutputs = BuildInputOutputParameters;\n\nexport type BuildInputOutputParameters = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nconst BuildInputOutputParametersSchema = Joi.array().items(\n Joi.alternatives().try(\n Joi.string().required(),\n Joi.object({\n name: Joi.string().required(),\n required: Joi.boolean(),\n }).required()\n )\n);\n\nconst BuildFunctionCallSchema = Joi.object({\n id: Joi.string(),\n inputs: Joi.object().pattern(Joi.string(), Joi.string()),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\n .when(\n Joi.object().pattern(\n Joi.string().disallow('run').required(),\n Joi.object().unknown().required()\n ),\n {\n then: Joi.object().pattern(\n Joi.string().disallow('run').min(1).required(),\n BuildFunctionCallSchema.required(),\n { matches: Joi.array().length(1) }\n ),\n }\n )\n .when(Joi.object({ run: Joi.object().unknown().required() }), {\n then: Joi.object({\n run: BuildFunctionCallSchema.keys({\n outputs: BuildInputOutputParametersSchema,\n command: Joi.string().required(),\n }),\n }),\n })\n .when(Joi.object({ run: Joi.string().required() }), {\n then: Joi.object({\n run: Joi.string().min(1).required(),\n }),\n })\n .when(Joi.string(), {\n then: Joi.string().min(1),\n });\n\nconst BuildFunctionConfigSchema = Joi.object({\n name: Joi.string(),\n platforms: Joi.string().allow(...Object.values(BuildPlatform)),\n inputs: BuildInputOutputParametersSchema,\n outputs: BuildInputOutputParametersSchema,\n command: Joi.string().required(),\n shell: Joi.string(),\n});\n\nexport const BuildConfigSchema = Joi.object<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array().items(BuildStepConfigSchema.required()).required(),\n }).required(),\n functions: Joi.object().pattern(\n Joi.string()\n .pattern(/^[\\w-]+$/, 'function names')\n .min(1)\n .required()\n .disallow('run'),\n BuildFunctionConfigSchema.required()\n ),\n}).required();\n\nexport function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun {\n return typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return typeof step === 'object' && !('run' in step);\n}\n\nexport function isBuildStepBareFunctionCall(\n step: BuildStepConfig\n): step is BuildStepBareFunctionCall {\n return typeof step === 'string';\n}\n\nexport function validateBuildConfig(rawConfig: object, externalFunctionIds: string[]): BuildConfig {\n const { error, value: buildConfig } = BuildConfigSchema.validate(rawConfig, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, { cause: error });\n }\n validateAllFunctionsExist(buildConfig, externalFunctionIds);\n return buildConfig;\n}\n\nfunction validateAllFunctionsExist(config: BuildConfig, externalFunctionIds: string[]): void {\n const calledFunctionsSet = new Set<string>();\n for (const step of config.build.steps) {\n if (typeof step === 'string') {\n calledFunctionsSet.add(step);\n } else if (!('run' in step)) {\n const keys = Object.keys(step);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n calledFunctionsSet.add(keys[0]);\n }\n }\n const calledFunctions = Array.from(calledFunctionsSet);\n const externalFunctionIdsSet = new Set(externalFunctionIds);\n const nonExistentFunctions = calledFunctions.filter((calledFunction) => {\n return (\n !(calledFunction in (config.functions ?? {})) && !externalFunctionIdsSet.has(calledFunction)\n );\n });\n if (nonExistentFunctions.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctions.map((f) => `\"${f}\"`).join(', ')}.`\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA2DnD,MAAM,gCAAgC,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACxD,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,CACpB,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EACvB,GAAG,CAAC,MAAM,CAAC;IACT,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE;CACxB,CAAC,CAAC,QAAQ,EAAE,CACd,CACF,CAAC;AAEF,MAAM,uBAAuB,GAAG,GAAG,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;IACxD,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;IAClB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;IAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;AAEn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AG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,CACJ,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,wEAAwE,CACzE,CAAC;YACF,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACjC;KACF;IACD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACvD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE;;QACrE,OAAO,CACL,CAAC,CAAC,cAAc,IAAI,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC,CAC7F,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;QACnC,MAAM,IAAI,gBAAgB,CACxB,mCAAmC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3F,CAAC;KACH;AACH,CAAC","sourcesContent":["import assert from 'assert';\n\nimport Joi from 'joi';\n\nimport { BuildConfigError } from './errors.js';\nimport { BuildPlatform } from './BuildPlatform.js';\n\nexport interface BuildConfig {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n functions?: Record<string, BuildFunctionConfig>;\n}\n\nexport type BuildStepConfig =\n | BuildStepCommandRun\n | BuildStepBareCommandRun\n | BuildStepFunctionCall\n | BuildStepBareFunctionCall;\n\nexport type BuildStepCommandRun = {\n run: BuildFunctionCallConfig & {\n outputs?: BuildStepOutputs;\n command: string;\n };\n};\nexport type BuildStepBareCommandRun = { run: string };\nexport type BuildStepFunctionCall = {\n [functionId: string]: BuildFunctionCallConfig;\n};\nexport type BuildStepBareFunctionCall = string;\n\nexport type BuildFunctionCallConfig = {\n id?: string;\n inputs?: BuildStepInputs;\n name?: string;\n workingDirectory?: string;\n shell?: string;\n};\n\nexport type BuildStepInputs = Record<string, string>;\nexport type BuildStepOutputs = BuildInputOutputParameters;\n\nexport interface BuildFunctionConfig {\n inputs?: BuildFunctionInputs;\n outputs?: BuildFunctionOutputs;\n name?: string;\n platforms?: BuildPlatform[];\n shell?: string;\n command: string;\n}\n\nexport type BuildFunctionInputs = BuildInputOutputParameters;\nexport type BuildFunctionOutputs = BuildInputOutputParameters;\n\nexport type BuildInputOutputParameters = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nconst BuildInputOutputParametersSchema = Joi.array().items(\n Joi.alternatives().try(\n Joi.string().required(),\n Joi.object({\n name: Joi.string().required(),\n required: Joi.boolean(),\n }).required()\n )\n);\n\nconst BuildFunctionCallSchema = Joi.object({\n id: Joi.string(),\n inputs: Joi.object().pattern(Joi.string(), Joi.string()),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\n .when(\n Joi.object().pattern(\n Joi.string().disallow('run').required(),\n Joi.object().unknown().required()\n ),\n {\n then: Joi.object().pattern(\n Joi.string().disallow('run').min(1).required(),\n BuildFunctionCallSchema.required(),\n { matches: Joi.array().length(1) }\n ),\n }\n )\n .when(Joi.object({ run: Joi.object().unknown().required() }), {\n then: Joi.object({\n run: BuildFunctionCallSchema.keys({\n outputs: BuildInputOutputParametersSchema,\n command: Joi.string().required(),\n }),\n }),\n })\n .when(Joi.object({ run: Joi.string().required() }), {\n then: Joi.object({\n run: Joi.string().min(1).required(),\n }),\n })\n .when(Joi.string(), {\n then: Joi.string().min(1),\n });\n\nconst BuildFunctionConfigSchema = Joi.object({\n name: Joi.string(),\n platforms: Joi.string().allow(...Object.values(BuildPlatform)),\n inputs: BuildInputOutputParametersSchema,\n outputs: BuildInputOutputParametersSchema,\n command: Joi.string().required(),\n shell: Joi.string(),\n});\n\nexport const BuildConfigSchema = Joi.object<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array().items(BuildStepConfigSchema.required()).required(),\n }).required(),\n functions: Joi.object().pattern(\n Joi.string()\n .pattern(/^[\\w-]+$/, 'function names')\n .min(1)\n .required()\n .disallow('run'),\n BuildFunctionConfigSchema.required()\n ),\n}).required();\n\nexport function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun {\n return typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return typeof step === 'object' && !('run' in step);\n}\n\nexport function isBuildStepBareFunctionCall(\n step: BuildStepConfig\n): step is BuildStepBareFunctionCall {\n return typeof step === 'string';\n}\n\nexport function validateBuildConfig(rawConfig: object, externalFunctionIds: string[]): BuildConfig {\n const { error, value: buildConfig } = BuildConfigSchema.validate(rawConfig, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, { cause: error });\n }\n validateAllFunctionsExist(buildConfig, externalFunctionIds);\n return buildConfig;\n}\n\nfunction validateAllFunctionsExist(config: BuildConfig, externalFunctionIds: string[]): void {\n const calledFunctionsSet = new Set<string>();\n for (const step of config.build.steps) {\n if (typeof step === 'string') {\n calledFunctionsSet.add(step);\n } else if (!('run' in step)) {\n const keys = Object.keys(step);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n calledFunctionsSet.add(keys[0]);\n }\n }\n const calledFunctions = Array.from(calledFunctionsSet);\n const externalFunctionIdsSet = new Set(externalFunctionIds);\n const nonExistentFunctions = calledFunctions.filter((calledFunction) => {\n return (\n !(calledFunction in (config.functions ?? {})) && !externalFunctionIdsSet.has(calledFunction)\n );\n });\n if (nonExistentFunctions.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctions.map((f) => `\"${f}\"`).join(', ')}.`\n );\n }\n}\n"]}
|
|
@@ -12,9 +12,13 @@ export declare class BuildConfigParser {
|
|
|
12
12
|
parseAsync(): Promise<BuildWorkflow>;
|
|
13
13
|
private readRawConfigAsync;
|
|
14
14
|
private createBuildStepFromConfig;
|
|
15
|
+
private createBuildStepFromBuildStepCommandRun;
|
|
16
|
+
private createBuildStepFromBuildStepBareCommandRun;
|
|
17
|
+
private createBuildStepFromBuildStepBareFunctionCall;
|
|
18
|
+
private createBuildStepFromBuildStepFunctionCall;
|
|
15
19
|
private createBuildFunctionsFromConfig;
|
|
16
20
|
private createBuildFunctionFromConfig;
|
|
17
|
-
private
|
|
21
|
+
private createBuildStepInputsFromDefinition;
|
|
18
22
|
private createBuildStepInputProvidersFromBuildFunctionInputs;
|
|
19
23
|
private createBuildStepOutputsFromDefinition;
|
|
20
24
|
private createBuildStepOutputProvidersFromBuildFunctionOutputs;
|