@expo/steps 1.0.23 → 1.0.25
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/bin/set-env +23 -0
- package/dist_commonjs/BuildConfig.cjs +21 -5
- package/dist_commonjs/BuildConfig.d.ts +2 -0
- package/dist_commonjs/BuildConfig.js.map +1 -1
- package/dist_commonjs/BuildConfigParser.cjs +6 -2
- package/dist_commonjs/BuildConfigParser.d.ts +2 -2
- package/dist_commonjs/BuildConfigParser.js.map +1 -1
- package/dist_commonjs/BuildFunction.cjs +2 -1
- package/dist_commonjs/BuildFunction.d.ts +4 -2
- package/dist_commonjs/BuildFunction.js.map +1 -1
- package/dist_commonjs/BuildStep.cjs +49 -22
- package/dist_commonjs/BuildStep.d.ts +7 -4
- package/dist_commonjs/BuildStep.js.map +1 -1
- package/dist_commonjs/BuildStepContext.cjs +50 -13
- package/dist_commonjs/BuildStepContext.d.ts +35 -10
- package/dist_commonjs/BuildStepContext.js.map +1 -1
- package/dist_commonjs/BuildStepInput.cjs +59 -5
- package/dist_commonjs/BuildStepInput.d.ts +11 -5
- package/dist_commonjs/BuildStepInput.js.map +1 -1
- package/dist_commonjs/BuildStepOutput.d.ts +3 -3
- package/dist_commonjs/BuildStepOutput.js.map +1 -1
- package/dist_commonjs/BuildTemporaryFiles.cjs +11 -2
- package/dist_commonjs/BuildTemporaryFiles.d.ts +5 -4
- package/dist_commonjs/BuildTemporaryFiles.js.map +1 -1
- package/dist_commonjs/BuildWorkflow.cjs +2 -2
- package/dist_commonjs/BuildWorkflow.d.ts +3 -4
- package/dist_commonjs/BuildWorkflow.js.map +1 -1
- package/dist_commonjs/BuildWorkflowValidator.cjs +10 -3
- package/dist_commonjs/BuildWorkflowValidator.js.map +1 -1
- package/dist_commonjs/cli/cli.cjs +22 -3
- package/dist_commonjs/cli/cli.d.ts +16 -1
- package/dist_commonjs/cli/cli.js.map +1 -1
- package/dist_commonjs/index.cjs +2 -2
- package/dist_commonjs/index.d.ts +2 -1
- package/dist_commonjs/index.js.map +1 -1
- package/dist_commonjs/utils/template.cjs +40 -8
- package/dist_commonjs/utils/template.d.ts +5 -1
- package/dist_commonjs/utils/template.js.map +1 -1
- package/dist_esm/BuildConfig.d.ts +2 -0
- package/dist_esm/BuildConfig.js +21 -5
- package/dist_esm/BuildConfig.js.map +1 -1
- package/dist_esm/BuildConfigParser.d.ts +2 -2
- package/dist_esm/BuildConfigParser.js +7 -3
- package/dist_esm/BuildConfigParser.js.map +1 -1
- package/dist_esm/BuildFunction.d.ts +4 -2
- package/dist_esm/BuildFunction.js +2 -1
- package/dist_esm/BuildFunction.js.map +1 -1
- package/dist_esm/BuildStep.d.ts +7 -4
- package/dist_esm/BuildStep.js +50 -23
- package/dist_esm/BuildStep.js.map +1 -1
- package/dist_esm/BuildStepContext.d.ts +35 -10
- package/dist_esm/BuildStepContext.js +49 -13
- package/dist_esm/BuildStepContext.js.map +1 -1
- package/dist_esm/BuildStepInput.d.ts +11 -5
- package/dist_esm/BuildStepInput.js +60 -6
- package/dist_esm/BuildStepInput.js.map +1 -1
- package/dist_esm/BuildStepOutput.d.ts +3 -3
- package/dist_esm/BuildStepOutput.js.map +1 -1
- package/dist_esm/BuildTemporaryFiles.d.ts +5 -4
- package/dist_esm/BuildTemporaryFiles.js +9 -1
- package/dist_esm/BuildTemporaryFiles.js.map +1 -1
- package/dist_esm/BuildWorkflow.d.ts +3 -4
- package/dist_esm/BuildWorkflow.js +2 -2
- package/dist_esm/BuildWorkflow.js.map +1 -1
- package/dist_esm/BuildWorkflowValidator.js +10 -3
- package/dist_esm/BuildWorkflowValidator.js.map +1 -1
- package/dist_esm/cli/cli.d.ts +16 -1
- package/dist_esm/cli/cli.js +21 -4
- package/dist_esm/cli/cli.js.map +1 -1
- package/dist_esm/index.d.ts +2 -1
- package/dist_esm/index.js +1 -1
- package/dist_esm/index.js.map +1 -1
- package/dist_esm/utils/template.d.ts +5 -1
- package/dist_esm/utils/template.js +35 -8
- package/dist_esm/utils/template.js.map +1 -1
- package/package.json +4 -2
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
2
2
|
export declare enum BuildStepInputValueTypeName {
|
|
3
3
|
STRING = "string",
|
|
4
4
|
BOOLEAN = "boolean",
|
|
5
|
-
NUMBER = "number"
|
|
5
|
+
NUMBER = "number",
|
|
6
|
+
JSON = "json"
|
|
6
7
|
}
|
|
7
|
-
export type BuildStepInputValueType = string | boolean | number
|
|
8
|
+
export type BuildStepInputValueType = string | boolean | number | Record<string, any>;
|
|
8
9
|
export type BuildStepInputById = Record<string, BuildStepInput>;
|
|
9
|
-
export type BuildStepInputProvider = (ctx:
|
|
10
|
+
export type BuildStepInputProvider = (ctx: BuildStepGlobalContext, stepId: string) => BuildStepInput;
|
|
10
11
|
interface BuildStepInputProviderParams {
|
|
11
12
|
id: string;
|
|
12
13
|
allowedValues?: BuildStepInputValueType[];
|
|
@@ -27,11 +28,16 @@ export declare class BuildStepInput {
|
|
|
27
28
|
readonly required: boolean;
|
|
28
29
|
private _value?;
|
|
29
30
|
static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider;
|
|
30
|
-
constructor(ctx:
|
|
31
|
+
constructor(ctx: BuildStepGlobalContext, { id, stepDisplayName, allowedValues, defaultValue, required, allowedValueTypeName, }: BuildStepInputParams);
|
|
31
32
|
get value(): BuildStepInputValueType | undefined;
|
|
32
33
|
get rawValue(): BuildStepInputValueType | undefined;
|
|
33
34
|
set(value: BuildStepInputValueType | undefined): BuildStepInput;
|
|
34
35
|
isValueOneOfAllowedValues(): boolean;
|
|
36
|
+
isRawValueStepOrContextReference(): boolean;
|
|
37
|
+
private parseInputValueToAllowedType;
|
|
38
|
+
private parseInputValueToNumber;
|
|
39
|
+
private parseInputValueToBoolean;
|
|
40
|
+
private parseInputValueToObject;
|
|
35
41
|
}
|
|
36
42
|
export declare function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById;
|
|
37
43
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { BuildStepRuntimeError } from './errors.js';
|
|
2
|
-
import { interpolateWithOutputs } from './utils/template.js';
|
|
2
|
+
import { BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX, interpolateWithOutputs, } from './utils/template.js';
|
|
3
3
|
export var BuildStepInputValueTypeName;
|
|
4
4
|
(function (BuildStepInputValueTypeName) {
|
|
5
5
|
BuildStepInputValueTypeName["STRING"] = "string";
|
|
6
6
|
BuildStepInputValueTypeName["BOOLEAN"] = "boolean";
|
|
7
7
|
BuildStepInputValueTypeName["NUMBER"] = "number";
|
|
8
|
+
BuildStepInputValueTypeName["JSON"] = "json";
|
|
8
9
|
})(BuildStepInputValueTypeName || (BuildStepInputValueTypeName = {}));
|
|
9
10
|
export class BuildStepInput {
|
|
10
11
|
static createProvider(params) {
|
|
@@ -25,14 +26,21 @@ export class BuildStepInput {
|
|
|
25
26
|
if (this.required && rawValue === undefined) {
|
|
26
27
|
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const valueDoesNotRequireInterpolation = rawValue === undefined ||
|
|
30
|
+
typeof rawValue === 'boolean' ||
|
|
31
|
+
typeof rawValue === 'number' ||
|
|
32
|
+
typeof rawValue === 'object';
|
|
33
|
+
if (valueDoesNotRequireInterpolation) {
|
|
34
|
+
const currentTypeName = typeof rawValue === 'object' ? BuildStepInputValueTypeName.JSON : typeof rawValue;
|
|
35
|
+
if (currentTypeName !== this.allowedValueTypeName && rawValue !== undefined) {
|
|
36
|
+
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
37
|
+
}
|
|
32
38
|
return rawValue;
|
|
33
39
|
}
|
|
34
40
|
else {
|
|
35
|
-
|
|
41
|
+
const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);
|
|
42
|
+
const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(valueInterpolatedWithGlobalContext, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
43
|
+
return this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
get rawValue() {
|
|
@@ -54,6 +62,52 @@ export class BuildStepInput {
|
|
|
54
62
|
}
|
|
55
63
|
return this.allowedValues.includes(value);
|
|
56
64
|
}
|
|
65
|
+
isRawValueStepOrContextReference() {
|
|
66
|
+
return (typeof this.rawValue === 'string' &&
|
|
67
|
+
!!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue));
|
|
68
|
+
}
|
|
69
|
+
parseInputValueToAllowedType(value) {
|
|
70
|
+
if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {
|
|
74
|
+
return this.parseInputValueToNumber(value);
|
|
75
|
+
}
|
|
76
|
+
else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {
|
|
77
|
+
return this.parseInputValueToBoolean(value);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return this.parseInputValueToObject(value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
parseInputValueToNumber(value) {
|
|
84
|
+
const numberValue = Number(value);
|
|
85
|
+
if (Number.isNaN(numberValue)) {
|
|
86
|
+
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
87
|
+
}
|
|
88
|
+
return numberValue;
|
|
89
|
+
}
|
|
90
|
+
parseInputValueToBoolean(value) {
|
|
91
|
+
if (value === 'true') {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
else if (value === 'false') {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
parseInputValueToObject(value) {
|
|
102
|
+
try {
|
|
103
|
+
return JSON.parse(value);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`, {
|
|
107
|
+
cause: e,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
57
111
|
}
|
|
58
112
|
export function makeBuildStepInputByIdMap(inputs) {
|
|
59
113
|
if (inputs === undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,CAAN,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,gDAAiB,CAAA;IACjB,kDAAmB,CAAA;IACnB,gDAAiB,CAAA;AACnB,CAAC,EAJW,2BAA2B,KAA3B,2BAA2B,QAItC;AAkBD,MAAM,OAAO,cAAc;IAUlB,MAAM,CAAC,cAAc,CAAC,MAAoC;QAC/D,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,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AO,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC,YAAY,CAAC;IAC1C,CAAC;IAEM,GAAG,CAAC,KAA0C;QACnD,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,gBAAgB,CAC/E,CAAC;SACH;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,yBAAyB;;QAC9B,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC,YAAY,CAAC;QAC/C,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE;YAC3D,OAAO,IAAI,CAAC;SACb;QACD,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;CACF;AAED,MAAM,UAAU,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","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { interpolateWithOutputs } from './utils/template.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n}\nexport type BuildStepInputValueType = string | boolean | number;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (ctx: BuildStepContext, stepId: string) => BuildStepInput;\n\ninterface BuildStepInputProviderParams {\n id: string;\n allowedValues?: BuildStepInputValueType[];\n defaultValue?: BuildStepInputValueType;\n required?: boolean;\n allowedValueTypeName?: BuildStepInputValueTypeName;\n}\n\ninterface BuildStepInputParams extends BuildStepInputProviderParams {\n stepDisplayName: string;\n}\n\nexport class BuildStepInput {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: BuildStepInputValueType;\n public readonly allowedValues?: BuildStepInputValueType[];\n public readonly allowedValueTypeName: BuildStepInputValueTypeName;\n public readonly required: boolean;\n\n private _value?: BuildStepInputValueType;\n\n public static createProvider(params: BuildStepInputProviderParams): 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 allowedValues,\n defaultValue,\n required = true,\n allowedValueTypeName = BuildStepInputValueTypeName.STRING,\n }: BuildStepInputParams\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public get value(): BuildStepInputValueType | 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 if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n\n if (rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number') {\n return rawValue;\n } else {\n return interpolateWithOutputs(rawValue, (path) => this.ctx.getStepOutputValue(path) ?? '');\n }\n }\n\n public get rawValue(): BuildStepInputValueType | undefined {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: BuildStepInputValueType | 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\n this._value = value;\n return this;\n }\n\n public isValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\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
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,kDAAkD,EAClD,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,CAAN,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,gDAAiB,CAAA;IACjB,kDAAmB,CAAA;IACnB,gDAAiB,CAAA;IACjB,4CAAa,CAAA;AACf,CAAC,EALW,2BAA2B,KAA3B,2BAA2B,QAKtC;AAqBD,MAAM,OAAO,cAAc;IAUlB,MAAM,CAAC,cAAc,CAAC,MAAoC;QAC/D,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,GAA2B,EAC5C,EACE,EAAE,EACF,eAAe,EACf,aAAa,EACb,YAAY,EACZ,QAAQ,GAAG,IAAI,EACf,oBAAoB,GAAG,2BAA2B,CAAC,MAAM,GACpC;QARN,QAAG,GAAH,GAAG,CAAwB;QAU5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI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AAE,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","sourcesContent":["import { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport {\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n interpolateWithOutputs,\n} from './utils/template.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n JSON = 'json',\n}\nexport type BuildStepInputValueType = string | boolean | number | Record<string, any>;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams {\n id: string;\n allowedValues?: BuildStepInputValueType[];\n defaultValue?: BuildStepInputValueType;\n required?: boolean;\n allowedValueTypeName?: BuildStepInputValueTypeName;\n}\n\ninterface BuildStepInputParams extends BuildStepInputProviderParams {\n stepDisplayName: string;\n}\n\nexport class BuildStepInput {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: BuildStepInputValueType;\n public readonly allowedValues?: BuildStepInputValueType[];\n public readonly allowedValueTypeName: BuildStepInputValueTypeName;\n public readonly required: boolean;\n\n private _value?: BuildStepInputValueType;\n\n public static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n id,\n stepDisplayName,\n allowedValues,\n defaultValue,\n required = true,\n allowedValueTypeName = BuildStepInputValueTypeName.STRING,\n }: BuildStepInputParams\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public get value(): BuildStepInputValueType | 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 const valueDoesNotRequireInterpolation =\n rawValue === undefined ||\n typeof rawValue === 'boolean' ||\n typeof rawValue === 'number' ||\n typeof rawValue === 'object';\n if (valueDoesNotRequireInterpolation) {\n const currentTypeName =\n typeof rawValue === 'object' ? BuildStepInputValueTypeName.JSON : typeof rawValue;\n if (currentTypeName !== this.allowedValueTypeName && rawValue !== undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return rawValue;\n } else {\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n return this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n }\n\n public get rawValue(): BuildStepInputValueType | undefined {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: BuildStepInputValueType | 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\n this._value = value;\n return this;\n }\n\n public isValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\n }\n\n public isRawValueStepOrContextReference(): boolean {\n return (\n typeof this.rawValue === 'string' &&\n !!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue)\n );\n }\n\n private parseInputValueToAllowedType(value: string): BuildStepInputValueType {\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return value;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value);\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value);\n } else {\n return this.parseInputValueToObject(value);\n }\n }\n\n private parseInputValueToNumber(value: string): number {\n const numberValue = Number(value);\n if (Number.isNaN(numberValue)) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return numberValue;\n }\n\n private parseInputValueToBoolean(value: string): boolean {\n if (value === 'true') {\n return true;\n } else if (value === 'false') {\n return false;\n } else {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n }\n\n private parseInputValueToObject(value: string): Record<string, any> {\n try {\n return JSON.parse(value);\n } catch (e: any) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`,\n {\n cause: e,\n }\n );\n }\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,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
2
2
|
export type BuildStepOutputById = Record<string, BuildStepOutput>;
|
|
3
|
-
export type BuildStepOutputProvider = (ctx:
|
|
3
|
+
export type BuildStepOutputProvider = (ctx: BuildStepGlobalContext, stepDisplayName: string) => BuildStepOutput;
|
|
4
4
|
interface BuildStepOutputProviderParams {
|
|
5
5
|
id: string;
|
|
6
6
|
required?: boolean;
|
|
@@ -15,7 +15,7 @@ export declare class BuildStepOutput {
|
|
|
15
15
|
readonly required: boolean;
|
|
16
16
|
private _value?;
|
|
17
17
|
static createProvider(params: BuildStepOutputProviderParams): BuildStepOutputProvider;
|
|
18
|
-
constructor(ctx:
|
|
18
|
+
constructor(ctx: BuildStepGlobalContext, { id, stepDisplayName, required }: BuildStepOutputParams);
|
|
19
19
|
get value(): string | undefined;
|
|
20
20
|
set(value: string | undefined): BuildStepOutput;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAiBpD,MAAM,OAAO,eAAe;IAOnB,MAAM,CAAC,cAAc,CAAC,MAAqC;QAChE,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,
|
|
1
|
+
{"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAiBpD,MAAM,OAAO,eAAe;IAOnB,MAAM,CAAC,cAAc,CAAC,MAAqC;QAChE,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,GAA2B,EAC5C,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,GAAG,IAAI,EAAyB;QAD9C,QAAG,GAAH,GAAG,CAAwB;QAG5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAW,KAAK;QACd,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9C,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,mCAAmC,CACnG,CAAC;SACH;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,GAAG,CAAC,KAAyB;QAClC,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,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;AAED,MAAM,UAAU,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","sourcesContent":["import { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\n\nexport type BuildStepOutputById = Record<string, BuildStepOutput>;\nexport type BuildStepOutputProvider = (\n ctx: BuildStepGlobalContext,\n stepDisplayName: string\n) => BuildStepOutput;\n\ninterface BuildStepOutputProviderParams {\n id: string;\n required?: boolean;\n}\n\ninterface BuildStepOutputParams extends BuildStepOutputProviderParams {\n stepDisplayName: string;\n}\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: BuildStepOutputProviderParams): 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: BuildStepGlobalContext,\n { id, stepDisplayName, required = true }: BuildStepOutputParams\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.required = required;\n }\n\n public 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 public 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,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function saveScriptToTemporaryFileAsync(ctx:
|
|
3
|
-
export declare function createTemporaryOutputsDirectoryAsync(ctx:
|
|
4
|
-
export declare function
|
|
1
|
+
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
2
|
+
export declare function saveScriptToTemporaryFileAsync(ctx: BuildStepGlobalContext, stepId: string, scriptContents: string): Promise<string>;
|
|
3
|
+
export declare function createTemporaryOutputsDirectoryAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<string>;
|
|
4
|
+
export declare function createTemporaryEnvsDirectoryAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<string>;
|
|
5
|
+
export declare function cleanUpStepTemporaryDirectoriesAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<void>;
|
|
@@ -13,13 +13,18 @@ export async function createTemporaryOutputsDirectoryAsync(ctx, stepId) {
|
|
|
13
13
|
await fs.mkdir(directory, { recursive: true });
|
|
14
14
|
return directory;
|
|
15
15
|
}
|
|
16
|
+
export async function createTemporaryEnvsDirectoryAsync(ctx, stepId) {
|
|
17
|
+
const directory = getTemporaryEnvsDirPath(ctx, stepId);
|
|
18
|
+
await fs.mkdir(directory, { recursive: true });
|
|
19
|
+
return directory;
|
|
20
|
+
}
|
|
16
21
|
export async function cleanUpStepTemporaryDirectoriesAsync(ctx, stepId) {
|
|
17
22
|
if (ctx.skipCleanup) {
|
|
18
23
|
return;
|
|
19
24
|
}
|
|
20
25
|
const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);
|
|
21
26
|
await fs.rm(stepTemporaryDirectory, { recursive: true, force: true });
|
|
22
|
-
ctx.
|
|
27
|
+
ctx.baseLogger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');
|
|
23
28
|
}
|
|
24
29
|
function getTemporaryStepDirPath(ctx, stepId) {
|
|
25
30
|
return path.join(ctx.stepsInternalBuildDirectory, 'steps', stepId);
|
|
@@ -30,4 +35,7 @@ function getTemporaryScriptsDirPath(ctx, stepId) {
|
|
|
30
35
|
function getTemporaryOutputsDirPath(ctx, stepId) {
|
|
31
36
|
return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');
|
|
32
37
|
}
|
|
38
|
+
function getTemporaryEnvsDirPath(ctx, stepId) {
|
|
39
|
+
return path.join(getTemporaryStepDirPath(ctx, stepId), 'envs');
|
|
40
|
+
}
|
|
33
41
|
//# sourceMappingURL=BuildTemporaryFiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildTemporaryFiles.js","sourceRoot":"","sources":["../src/BuildTemporaryFiles.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,OAAO,EAAE,EAAE,I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CAAC;IAC/C,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oCAAoC,CACxD,GAA2B,EAC3B,MAAc;IAEd,IAAI,GAAG,CAAC,WAAW,EAAE;QACnB,OAAO;KACR;IACD,MAAM,sBAAsB,GAAG,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpE,MAAM,EAAE,CAAC,EAAE,CAAC,sBAAsB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,sBAAsB,EAAE,EAAE,kCAAkC,CAAC,CAAC;AACvF,CAAC;AAED,SAAS,uBAAuB,CAAC,GAA2B,EAAE,MAAc;IAC1E,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,2BAA2B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,0BAA0B,CAAC,GAA2B,EAAE,MAAc;IAC7E,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,0BAA0B,CAAC,GAA2B,EAAE,MAAc;IAC7E,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,uBAAuB,CAAC,GAA2B,EAAE,MAAc;IAC1E,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import path from 'path';\nimport fs from 'fs/promises';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\n\nexport async function saveScriptToTemporaryFileAsync(\n ctx: BuildStepGlobalContext,\n stepId: string,\n scriptContents: string\n): Promise<string> {\n const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);\n await fs.mkdir(scriptsDir, { recursive: true });\n const temporaryScriptPath = path.join(scriptsDir, `${uuidv4()}.sh`);\n await fs.writeFile(temporaryScriptPath, scriptContents);\n return temporaryScriptPath;\n}\n\nexport async function createTemporaryOutputsDirectoryAsync(\n ctx: BuildStepGlobalContext,\n stepId: string\n): Promise<string> {\n const directory = getTemporaryOutputsDirPath(ctx, stepId);\n await fs.mkdir(directory, { recursive: true });\n return directory;\n}\n\nexport async function createTemporaryEnvsDirectoryAsync(\n ctx: BuildStepGlobalContext,\n stepId: string\n): Promise<string> {\n const directory = getTemporaryEnvsDirPath(ctx, stepId);\n await fs.mkdir(directory, { recursive: true });\n return directory;\n}\n\nexport async function cleanUpStepTemporaryDirectoriesAsync(\n ctx: BuildStepGlobalContext,\n stepId: string\n): Promise<void> {\n if (ctx.skipCleanup) {\n return;\n }\n const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);\n await fs.rm(stepTemporaryDirectory, { recursive: true, force: true });\n ctx.baseLogger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');\n}\n\nfunction getTemporaryStepDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(ctx.stepsInternalBuildDirectory, 'steps', stepId);\n}\n\nfunction getTemporaryScriptsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');\n}\n\nfunction getTemporaryOutputsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');\n}\n\nfunction getTemporaryEnvsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'envs');\n}\n"]}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { BuildFunctionById } from './BuildFunction.js';
|
|
2
2
|
import { BuildStep } from './BuildStep.js';
|
|
3
|
-
import {
|
|
4
|
-
import { BuildStepEnv } from './BuildStepEnv.js';
|
|
3
|
+
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
5
4
|
export declare class BuildWorkflow {
|
|
6
5
|
private readonly ctx;
|
|
7
6
|
readonly buildSteps: BuildStep[];
|
|
8
7
|
readonly buildFunctions: BuildFunctionById;
|
|
9
|
-
constructor(ctx:
|
|
8
|
+
constructor(ctx: BuildStepGlobalContext, { buildSteps, buildFunctions }: {
|
|
10
9
|
buildSteps: BuildStep[];
|
|
11
10
|
buildFunctions: BuildFunctionById;
|
|
12
11
|
});
|
|
13
|
-
executeAsync(
|
|
12
|
+
executeAsync(): Promise<void>;
|
|
14
13
|
}
|
|
@@ -6,9 +6,9 @@ export class BuildWorkflow {
|
|
|
6
6
|
this.buildSteps = buildSteps;
|
|
7
7
|
this.buildFunctions = buildFunctions;
|
|
8
8
|
}
|
|
9
|
-
async executeAsync(
|
|
9
|
+
async executeAsync() {
|
|
10
10
|
for (const step of this.buildSteps) {
|
|
11
|
-
await step.executeAsync(
|
|
11
|
+
await step.executeAsync();
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,aAAa;IAIxB;IACE,wFAAwF;IACvE,GAA2B,EAC5C,EAAE,UAAU,EAAE,cAAc,EAAkE;QAD7E,QAAG,GAAH,GAAG,CAAwB;QAG5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YAClC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;SAC3B;IACH,CAAC;CACF","sourcesContent":["import { BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\n\nexport class BuildWorkflow {\n public readonly buildSteps: BuildStep[];\n public readonly buildFunctions: BuildFunctionById;\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: BuildStepGlobalContext,\n { buildSteps, buildFunctions }: { buildSteps: BuildStep[]; buildFunctions: BuildFunctionById }\n ) {\n this.buildSteps = buildSteps;\n this.buildFunctions = buildFunctions;\n }\n\n public async executeAsync(): Promise<void> {\n for (const step of this.buildSteps) {\n await step.executeAsync();\n }\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
1
2
|
import { BuildConfigError, BuildWorkflowError } from './errors.js';
|
|
2
3
|
import { duplicates } from './utils/expodash/duplicates.js';
|
|
3
4
|
import { nullthrows } from './utils/nullthrows.js';
|
|
@@ -37,9 +38,15 @@ export class BuildWorkflowValidator {
|
|
|
37
38
|
const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is required but it was not set.`);
|
|
38
39
|
errors.push(error);
|
|
39
40
|
}
|
|
41
|
+
const currentType = typeof currentStepInput.rawValue === 'object'
|
|
42
|
+
? BuildStepInputValueTypeName.JSON
|
|
43
|
+
: typeof currentStepInput.rawValue;
|
|
40
44
|
if (currentStepInput.rawValue !== undefined &&
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
!currentStepInput.isRawValueStepOrContextReference() &&
|
|
46
|
+
currentType !== currentStepInput.allowedValueTypeName) {
|
|
47
|
+
const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${typeof currentStepInput.rawValue === 'object'
|
|
48
|
+
? JSON.stringify(currentStepInput.rawValue)
|
|
49
|
+
: currentStepInput.rawValue}" which is not of type "${currentStepInput.allowedValueTypeName}" or is not step or context reference.`);
|
|
43
50
|
errors.push(error);
|
|
44
51
|
}
|
|
45
52
|
if (currentStepInput.defaultValue === undefined) {
|
|
@@ -81,7 +88,7 @@ export class BuildWorkflowValidator {
|
|
|
81
88
|
const errors = [];
|
|
82
89
|
for (const step of this.workflow.buildSteps) {
|
|
83
90
|
if (!step.canBeRunOnRuntimePlatform()) {
|
|
84
|
-
const error = new BuildConfigError(`Step "${step.displayName}" is not allowed on platform "${step.ctx.runtimePlatform}". Allowed platforms for this step are: ${nullthrows(step.supportedRuntimePlatforms, `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`)
|
|
91
|
+
const error = new BuildConfigError(`Step "${step.displayName}" is not allowed on platform "${step.ctx.global.runtimePlatform}". Allowed platforms for this step are: ${nullthrows(step.supportedRuntimePlatforms, `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`)
|
|
85
92
|
.map((p) => `"${p}"`)
|
|
86
93
|
.join(', ')}.`);
|
|
87
94
|
errors.push(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,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,CAA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W,iCACvB,IAAI,CAAC,GAAG,CAAC,eACX,2CAA2C,UAAU,CACnD,IAAI,CAAC,yBAAyB,EAC9B,uFAAuF,CACxF;qBACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;qBACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","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 { nullthrows } from './utils/nullthrows.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 errors.push(...this.validateAllowedPlatforms());\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.required && currentStepInput.rawValue === undefined) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is required but it was not set.`\n );\n errors.push(error);\n }\n\n if (\n currentStepInput.rawValue !== undefined &&\n typeof currentStepInput.rawValue !== currentStepInput.allowedValueTypeName\n ) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is set to \"${currentStepInput.rawValue}\" which is not of type \"${currentStepInput.allowedValueTypeName}\".`\n );\n errors.push(error);\n }\n\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n if (!currentStepInput.isValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n currentStepInput.value\n }\" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)\n .map((i) => `\"${i}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n const paths =\n typeof currentStepInput.defaultValue === 'string'\n ? findOutputPaths(currentStepInput.defaultValue)\n : [];\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 private validateAllowedPlatforms(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n for (const step of this.workflow.buildSteps) {\n if (!step.canBeRunOnRuntimePlatform()) {\n const error = new BuildConfigError(\n `Step \"${step.displayName}\" is not allowed on platform \"${\n step.ctx.runtimePlatform\n }\". Allowed platforms for this step are: ${nullthrows(\n step.supportedRuntimePlatforms,\n `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`\n )\n .map((p) => `\"${p}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,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,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,kBAAkB,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;SACpE;IACH,CAAC;IAEO,qBAAqB;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC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U,CACnD,IAAI,CAAC,yBAAyB,EAC9B,uFAAuF,CACxF;qBACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;qBACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BuildStep } from './BuildStep.js';\nimport { BuildStepInputValueTypeName } from './BuildStepInput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { nullthrows } from './utils/nullthrows.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 errors.push(...this.validateAllowedPlatforms());\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.required && currentStepInput.rawValue === undefined) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is required but it was not set.`\n );\n errors.push(error);\n }\n\n const currentType =\n typeof currentStepInput.rawValue === 'object'\n ? BuildStepInputValueTypeName.JSON\n : typeof currentStepInput.rawValue;\n if (\n currentStepInput.rawValue !== undefined &&\n !currentStepInput.isRawValueStepOrContextReference() &&\n currentType !== currentStepInput.allowedValueTypeName\n ) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n typeof currentStepInput.rawValue === 'object'\n ? JSON.stringify(currentStepInput.rawValue)\n : currentStepInput.rawValue\n }\" which is not of type \"${\n currentStepInput.allowedValueTypeName\n }\" or is not step or context reference.`\n );\n errors.push(error);\n }\n\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n if (!currentStepInput.isValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n currentStepInput.value\n }\" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)\n .map((i) => `\"${i}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n const paths =\n typeof currentStepInput.defaultValue === 'string'\n ? findOutputPaths(currentStepInput.defaultValue)\n : [];\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 private validateAllowedPlatforms(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n for (const step of this.workflow.buildSteps) {\n if (!step.canBeRunOnRuntimePlatform()) {\n const error = new BuildConfigError(\n `Step \"${step.displayName}\" is not allowed on platform \"${\n step.ctx.global.runtimePlatform\n }\". Allowed platforms for this step are: ${nullthrows(\n step.supportedRuntimePlatforms,\n `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`\n )\n .map((p) => `\"${p}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n}\n"]}
|
package/dist_esm/cli/cli.d.ts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { bunyan } from '@expo/logger';
|
|
2
|
+
import { ExternalBuildContextProvider } from '../BuildStepContext.js';
|
|
3
|
+
import { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';
|
|
4
|
+
import { BuildStepEnv } from '../BuildStepEnv.js';
|
|
5
|
+
export declare class CliContextProvider implements ExternalBuildContextProvider {
|
|
6
|
+
readonly logger: bunyan;
|
|
7
|
+
readonly runtimePlatform: BuildRuntimePlatform;
|
|
8
|
+
readonly projectSourceDirectory: string;
|
|
9
|
+
readonly projectTargetDirectory: string;
|
|
10
|
+
readonly defaultWorkingDirectory: string;
|
|
11
|
+
private _env;
|
|
12
|
+
constructor(logger: bunyan, runtimePlatform: BuildRuntimePlatform, projectSourceDirectory: string, projectTargetDirectory: string, defaultWorkingDirectory: string);
|
|
13
|
+
get env(): BuildStepEnv;
|
|
14
|
+
staticContext(): any;
|
|
15
|
+
updateEnv(env: BuildStepEnv): void;
|
|
16
|
+
}
|
package/dist_esm/cli/cli.js
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { createLogger } from '@expo/logger';
|
|
4
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
5
4
|
import { BuildConfigParser } from '../BuildConfigParser.js';
|
|
6
|
-
import {
|
|
5
|
+
import { BuildStepGlobalContext } from '../BuildStepContext.js';
|
|
7
6
|
import { BuildWorkflowError } from '../errors.js';
|
|
8
7
|
const logger = createLogger({
|
|
9
8
|
name: 'steps-cli',
|
|
10
9
|
level: 'info',
|
|
11
10
|
});
|
|
11
|
+
export class CliContextProvider {
|
|
12
|
+
constructor(logger, runtimePlatform, projectSourceDirectory, projectTargetDirectory, defaultWorkingDirectory) {
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
this.runtimePlatform = runtimePlatform;
|
|
15
|
+
this.projectSourceDirectory = projectSourceDirectory;
|
|
16
|
+
this.projectTargetDirectory = projectTargetDirectory;
|
|
17
|
+
this.defaultWorkingDirectory = defaultWorkingDirectory;
|
|
18
|
+
this._env = {};
|
|
19
|
+
}
|
|
20
|
+
get env() {
|
|
21
|
+
return this._env;
|
|
22
|
+
}
|
|
23
|
+
staticContext() {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
updateEnv(env) {
|
|
27
|
+
this._env = env;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
12
30
|
async function runAsync(configPath, relativeProjectDirectory, runtimePlatform) {
|
|
13
|
-
const
|
|
14
|
-
const ctx = new BuildStepContext(fakeBuildId, logger, false, runtimePlatform, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory);
|
|
31
|
+
const ctx = new BuildStepGlobalContext(new CliContextProvider(logger, runtimePlatform, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory), false);
|
|
15
32
|
const parser = new BuildConfigParser(ctx, { configPath });
|
|
16
33
|
const workflow = await parser.parseAsync();
|
|
17
34
|
await workflow.executeAsync();
|
package/dist_esm/cli/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli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AAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { bunyan, createLogger } from '@expo/logger';\n\nimport { BuildConfigParser } from '../BuildConfigParser.js';\nimport { ExternalBuildContextProvider, BuildStepGlobalContext } from '../BuildStepContext.js';\nimport { BuildWorkflowError } from '../errors.js';\nimport { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';\nimport { BuildStepEnv } from '../BuildStepEnv.js';\n\nconst logger = createLogger({\n name: 'steps-cli',\n level: 'info',\n});\n\nexport class CliContextProvider implements ExternalBuildContextProvider {\n private _env: BuildStepEnv = {};\n\n constructor(\n public readonly logger: bunyan,\n public readonly runtimePlatform: BuildRuntimePlatform,\n public readonly projectSourceDirectory: string,\n public readonly projectTargetDirectory: string,\n public readonly defaultWorkingDirectory: string\n ) {}\n public get env(): BuildStepEnv {\n return this._env;\n }\n public staticContext(): any {\n return {};\n }\n public updateEnv(env: BuildStepEnv): void {\n this._env = env;\n }\n}\n\nasync function runAsync(\n configPath: string,\n relativeProjectDirectory: string,\n runtimePlatform: BuildRuntimePlatform\n): Promise<void> {\n const ctx = new BuildStepGlobalContext(\n new CliContextProvider(\n logger,\n runtimePlatform,\n relativeProjectDirectory,\n relativeProjectDirectory,\n relativeProjectDirectory\n ),\n false\n );\n const parser = new BuildConfigParser(ctx, { configPath });\n const workflow = await parser.parseAsync();\n await workflow.executeAsync();\n}\n\nconst relativeConfigPath = process.argv[2];\nconst relativeProjectDirectoryPath = process.argv[3];\nconst platform: BuildRuntimePlatform = (process.argv[4] ??\n process.platform) as BuildRuntimePlatform;\n\nif (!relativeConfigPath || !relativeProjectDirectoryPath) {\n console.error('Usage: yarn cli config.yml path/to/project/directory [darwin|linux]');\n process.exit(1);\n}\n\nconst configPath = path.resolve(process.cwd(), relativeConfigPath);\nconst workingDirectory = path.resolve(process.cwd(), relativeProjectDirectoryPath);\n\nrunAsync(configPath, workingDirectory, platform).catch((err) => {\n logger.error({ err }, 'Build failed');\n if (err instanceof BuildWorkflowError) {\n logger.error('Failed to parse the custom build config file.');\n for (const detailedErr of err.errors) {\n logger.error({ err: detailedErr });\n }\n }\n});\n"]}
|
package/dist_esm/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { BuildFunction } from './BuildFunction.js';
|
|
|
4
4
|
export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
5
5
|
export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
6
6
|
export { BuildStepOutput } from './BuildStepOutput.js';
|
|
7
|
-
export {
|
|
7
|
+
export { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';
|
|
8
8
|
export { BuildWorkflow } from './BuildWorkflow.js';
|
|
9
|
+
export { BuildStepEnv } from './BuildStepEnv.js';
|
|
9
10
|
export * as errors from './errors.js';
|
package/dist_esm/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { BuildFunction } from './BuildFunction.js';
|
|
|
4
4
|
export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
5
5
|
export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
6
6
|
export { BuildStepOutput } from './BuildStepOutput.js';
|
|
7
|
-
export {
|
|
7
|
+
export { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
8
8
|
export { BuildWorkflow } from './BuildWorkflow.js';
|
|
9
9
|
export * as errors from './errors.js';
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
package/dist_esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAgC,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC","sourcesContent":["export { readAndValidateBuildConfigAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport { BuildStepEnv } from './BuildStepEnv.js';\nexport * as errors from './errors.js';\n"]}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export declare const BUILD_STEP_INPUT_EXPRESSION_REGEXP: RegExp;
|
|
2
2
|
export declare const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP: RegExp;
|
|
3
|
+
export declare const BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP: RegExp;
|
|
4
|
+
export declare const BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX: RegExp;
|
|
3
5
|
export declare function interpolateWithInputs(templateString: string, inputs: Record<string, string>): string;
|
|
4
6
|
export declare function interpolateWithOutputs(templateString: string, fn: (path: string) => string): string;
|
|
7
|
+
export declare function getObjectValueForInterpolation(path: string, obj: Record<string, any>): string | number | boolean | null;
|
|
8
|
+
export declare function interpolateWithGlobalContext(templateString: string, fn: (path: string) => string): string;
|
|
5
9
|
interface BuildOutputPath {
|
|
6
10
|
stepId: string;
|
|
7
11
|
outputId: string;
|
|
8
12
|
}
|
|
9
13
|
export declare function findOutputPaths(templateString: string): BuildOutputPath[];
|
|
10
|
-
export declare function parseOutputPath(
|
|
14
|
+
export declare function parseOutputPath(outputPathWithObjectName: string): BuildOutputPath;
|
|
11
15
|
export {};
|
|
@@ -1,13 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import get from 'lodash.get';
|
|
2
|
+
import { BuildStepInputValueTypeName } from '../BuildStepInput.js';
|
|
3
|
+
import { BuildConfigError, BuildStepRuntimeError } from '../errors.js';
|
|
2
4
|
import { nullthrows } from './nullthrows.js';
|
|
3
|
-
export const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*inputs\.
|
|
4
|
-
export const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*steps\.
|
|
5
|
+
export const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*(inputs\.[\S]+)\s*}/;
|
|
6
|
+
export const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*(steps\.[\S]+)\s*}/;
|
|
7
|
+
export const BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = /\${\s*(eas\.[\S]+)\s*}/;
|
|
8
|
+
export const BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = /\${\s*((steps|eas)\.[\S]+)\s*}/;
|
|
5
9
|
export function interpolateWithInputs(templateString, inputs) {
|
|
6
10
|
return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);
|
|
7
11
|
}
|
|
8
12
|
export function interpolateWithOutputs(templateString, fn) {
|
|
9
13
|
return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);
|
|
10
14
|
}
|
|
15
|
+
export function getObjectValueForInterpolation(path, obj) {
|
|
16
|
+
const value = get(obj, path);
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
throw new BuildStepRuntimeError(`Object field "${path}" does not exist. Ensure you are using the correct field name.`);
|
|
19
|
+
}
|
|
20
|
+
if (!isAllowedValueTypeForObjectInterpolation(value)) {
|
|
21
|
+
throw new BuildStepRuntimeError(`EAS context field "${path}" is not of type ${Object.values(BuildStepInputValueTypeName).join(', ')}, or undefined. It is of type "${typeof value}". We currently only support accessing string or undefined values from the EAS context.`);
|
|
22
|
+
}
|
|
23
|
+
if (value !== null && typeof value === 'object') {
|
|
24
|
+
return JSON.stringify(value);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
export function interpolateWithGlobalContext(templateString, fn) {
|
|
29
|
+
return interpolate(templateString, BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP, fn);
|
|
30
|
+
}
|
|
11
31
|
function interpolate(templateString, regex, varsOrFn) {
|
|
12
32
|
const matched = templateString.match(new RegExp(regex, 'g'));
|
|
13
33
|
if (!matched) {
|
|
@@ -15,12 +35,19 @@ function interpolate(templateString, regex, varsOrFn) {
|
|
|
15
35
|
}
|
|
16
36
|
let result = templateString;
|
|
17
37
|
for (const match of matched) {
|
|
18
|
-
const [,
|
|
19
|
-
const value = typeof varsOrFn === 'function' ? varsOrFn(
|
|
38
|
+
const [, path] = nullthrows(match.match(regex));
|
|
39
|
+
const value = typeof varsOrFn === 'function' ? varsOrFn(path) : varsOrFn[path.split('.')[1]];
|
|
20
40
|
result = result.replace(match, value);
|
|
21
41
|
}
|
|
22
42
|
return result;
|
|
23
43
|
}
|
|
44
|
+
function isAllowedValueTypeForObjectInterpolation(value) {
|
|
45
|
+
return (typeof value === 'string' ||
|
|
46
|
+
typeof value === 'number' ||
|
|
47
|
+
typeof value === 'boolean' ||
|
|
48
|
+
typeof value === 'object' ||
|
|
49
|
+
value === null);
|
|
50
|
+
}
|
|
24
51
|
export function findOutputPaths(templateString) {
|
|
25
52
|
const result = [];
|
|
26
53
|
const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));
|
|
@@ -29,10 +56,10 @@ export function findOutputPaths(templateString) {
|
|
|
29
56
|
}
|
|
30
57
|
return result;
|
|
31
58
|
}
|
|
32
|
-
export function parseOutputPath(
|
|
33
|
-
const splits =
|
|
59
|
+
export function parseOutputPath(outputPathWithObjectName) {
|
|
60
|
+
const splits = outputPathWithObjectName.split('.').slice(1);
|
|
34
61
|
if (splits.length !== 2) {
|
|
35
|
-
throw new 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: "${
|
|
62
|
+
throw new 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: "${outputPathWithObjectName}"`);
|
|
36
63
|
}
|
|
37
64
|
const [stepId, outputId] = splits;
|
|
38
65
|
return { stepId, outputId };
|