@expo/steps 1.0.181 → 1.0.185
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/BuildStep.cjs +12 -18
- package/dist_commonjs/BuildStep.d.ts +6 -2
- package/dist_commonjs/BuildStep.js.map +1 -1
- package/dist_commonjs/BuildStepContext.cjs +17 -0
- package/dist_commonjs/BuildStepContext.d.ts +2 -1
- package/dist_commonjs/BuildStepContext.js.map +1 -1
- package/dist_commonjs/BuildStepInput.cjs +22 -39
- package/dist_commonjs/BuildStepInput.d.ts +6 -16
- package/dist_commonjs/BuildStepInput.js.map +1 -1
- package/dist_commonjs/BuildWorkflowValidator.cjs +2 -2
- package/dist_commonjs/BuildWorkflowValidator.js.map +1 -1
- package/dist_commonjs/cli/cli.cjs +0 -1
- package/dist_commonjs/cli/cli.js.map +1 -1
- package/dist_commonjs/scripts/runCustomFunction.cjs +2 -5
- package/dist_commonjs/scripts/runCustomFunction.js.map +1 -1
- package/dist_commonjs/utils/customFunction.cjs +16 -2
- package/dist_commonjs/utils/customFunction.d.ts +6 -1
- package/dist_commonjs/utils/customFunction.js.map +1 -1
- package/dist_esm/BuildStep.d.ts +6 -2
- package/dist_esm/BuildStep.js +12 -18
- package/dist_esm/BuildStep.js.map +1 -1
- package/dist_esm/BuildStepContext.d.ts +2 -1
- package/dist_esm/BuildStepContext.js +17 -0
- package/dist_esm/BuildStepContext.js.map +1 -1
- package/dist_esm/BuildStepInput.d.ts +6 -16
- package/dist_esm/BuildStepInput.js +22 -39
- package/dist_esm/BuildStepInput.js.map +1 -1
- package/dist_esm/BuildWorkflowValidator.js +2 -2
- package/dist_esm/BuildWorkflowValidator.js.map +1 -1
- package/dist_esm/cli/cli.js +0 -1
- package/dist_esm/cli/cli.js.map +1 -1
- package/dist_esm/scripts/runCustomFunction.js +2 -5
- package/dist_esm/scripts/runCustomFunction.js.map +1 -1
- package/dist_esm/utils/customFunction.d.ts +6 -1
- package/dist_esm/utils/customFunction.js +13 -1
- package/dist_esm/utils/customFunction.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BuildStepGlobalContext
|
|
1
|
+
import { JobInterpolationContext } from '@expo/eas-build-job';
|
|
2
|
+
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
3
3
|
export declare enum BuildStepInputValueTypeName {
|
|
4
4
|
STRING = "string",
|
|
5
5
|
BOOLEAN = "boolean",
|
|
@@ -19,16 +19,6 @@ interface BuildStepInputProviderParams<T extends BuildStepInputValueTypeName = B
|
|
|
19
19
|
interface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean> extends BuildStepInputProviderParams<T, R> {
|
|
20
20
|
stepDisplayName: string;
|
|
21
21
|
}
|
|
22
|
-
export interface SerializedBuildStepInput {
|
|
23
|
-
id: string;
|
|
24
|
-
stepDisplayName: string;
|
|
25
|
-
defaultValue?: unknown;
|
|
26
|
-
allowedValues?: unknown[];
|
|
27
|
-
allowedValueTypeName: BuildStepInputValueTypeName;
|
|
28
|
-
required: boolean;
|
|
29
|
-
value?: unknown;
|
|
30
|
-
ctx: SerializedBuildStepGlobalContext;
|
|
31
|
-
}
|
|
32
22
|
export declare class BuildStepInput<T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName, R extends boolean = boolean> {
|
|
33
23
|
private readonly ctx;
|
|
34
24
|
readonly id: string;
|
|
@@ -40,13 +30,13 @@ export declare class BuildStepInput<T extends BuildStepInputValueTypeName = Buil
|
|
|
40
30
|
private _value?;
|
|
41
31
|
static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider;
|
|
42
32
|
constructor(ctx: BuildStepGlobalContext, { id, stepDisplayName, allowedValues, defaultValue, required, allowedValueTypeName, }: BuildStepInputParams<T, R>);
|
|
43
|
-
|
|
33
|
+
getValue({ interpolationContext, }: {
|
|
34
|
+
interpolationContext: JobInterpolationContext;
|
|
35
|
+
}): R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | undefined;
|
|
44
36
|
get rawValue(): unknown;
|
|
45
37
|
set(value: unknown): BuildStepInput;
|
|
46
|
-
|
|
38
|
+
isRawValueOneOfAllowedValues(): boolean;
|
|
47
39
|
isRawValueStepOrContextReference(): boolean;
|
|
48
|
-
serialize(): SerializedBuildStepInput;
|
|
49
|
-
static deserialize(serializedInput: SerializedBuildStepInput, logger: bunyan): BuildStepInput;
|
|
50
40
|
private parseInputValueToAllowedType;
|
|
51
41
|
private parseInputValueToString;
|
|
52
42
|
private parseInputValueToNumber;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from 'assert';
|
|
2
|
-
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
3
2
|
import { BuildStepRuntimeError } from './errors.js';
|
|
4
3
|
import { BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX, interpolateWithOutputs, } from './utils/template.js';
|
|
4
|
+
import { interpolateJobContext } from './interpolation.js';
|
|
5
5
|
export var BuildStepInputValueTypeName;
|
|
6
6
|
(function (BuildStepInputValueTypeName) {
|
|
7
7
|
BuildStepInputValueTypeName["STRING"] = "string";
|
|
@@ -22,28 +22,33 @@ export class BuildStepInput {
|
|
|
22
22
|
this.required = required;
|
|
23
23
|
this.allowedValueTypeName = allowedValueTypeName;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
getValue({ interpolationContext, }) {
|
|
26
26
|
var _a;
|
|
27
27
|
const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
|
|
28
28
|
if (this.required && rawValue === undefined) {
|
|
29
29
|
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
rawValue
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const interpolatedValue = interpolateJobContext({
|
|
32
|
+
target: rawValue,
|
|
33
|
+
context: interpolationContext,
|
|
34
|
+
});
|
|
35
|
+
const valueDoesNotRequireInterpolation = interpolatedValue === undefined ||
|
|
36
|
+
interpolatedValue === null ||
|
|
37
|
+
typeof interpolatedValue === 'boolean' ||
|
|
38
|
+
typeof interpolatedValue === 'number';
|
|
35
39
|
let returnValue;
|
|
36
40
|
if (valueDoesNotRequireInterpolation) {
|
|
37
|
-
if (typeof
|
|
41
|
+
if (typeof interpolatedValue !== this.allowedValueTypeName &&
|
|
42
|
+
interpolatedValue !== undefined) {
|
|
38
43
|
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
39
44
|
}
|
|
40
|
-
returnValue =
|
|
45
|
+
returnValue = interpolatedValue;
|
|
41
46
|
}
|
|
42
47
|
else {
|
|
43
48
|
// `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined
|
|
44
49
|
// so this will never be true.
|
|
45
|
-
assert(
|
|
46
|
-
const valueInterpolatedWithGlobalContext = this.ctx.interpolate(
|
|
50
|
+
assert(interpolatedValue !== undefined);
|
|
51
|
+
const valueInterpolatedWithGlobalContext = this.ctx.interpolate(interpolatedValue);
|
|
47
52
|
const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(valueInterpolatedWithGlobalContext, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
48
53
|
returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);
|
|
49
54
|
}
|
|
@@ -60,7 +65,7 @@ export class BuildStepInput {
|
|
|
60
65
|
this._value = value;
|
|
61
66
|
return this;
|
|
62
67
|
}
|
|
63
|
-
|
|
68
|
+
isRawValueOneOfAllowedValues() {
|
|
64
69
|
var _a;
|
|
65
70
|
const value = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
|
|
66
71
|
if (this.allowedValues === undefined || value === undefined) {
|
|
@@ -70,32 +75,10 @@ export class BuildStepInput {
|
|
|
70
75
|
}
|
|
71
76
|
isRawValueStepOrContextReference() {
|
|
72
77
|
return (typeof this.rawValue === 'string' &&
|
|
73
|
-
!!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
id: this.id,
|
|
78
|
-
stepDisplayName: this.stepDisplayName,
|
|
79
|
-
defaultValue: this.defaultValue,
|
|
80
|
-
allowedValues: this.allowedValues,
|
|
81
|
-
allowedValueTypeName: this.allowedValueTypeName,
|
|
82
|
-
required: this.required,
|
|
83
|
-
value: this._value,
|
|
84
|
-
ctx: this.ctx.serialize(),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
static deserialize(serializedInput, logger) {
|
|
88
|
-
const deserializedContext = BuildStepGlobalContext.deserialize(serializedInput.ctx, logger);
|
|
89
|
-
const input = new BuildStepInput(deserializedContext, {
|
|
90
|
-
id: serializedInput.id,
|
|
91
|
-
stepDisplayName: serializedInput.stepDisplayName,
|
|
92
|
-
defaultValue: serializedInput.defaultValue,
|
|
93
|
-
allowedValues: serializedInput.allowedValues,
|
|
94
|
-
allowedValueTypeName: serializedInput.allowedValueTypeName,
|
|
95
|
-
required: serializedInput.required,
|
|
96
|
-
});
|
|
97
|
-
input._value = serializedInput.value;
|
|
98
|
-
return input;
|
|
78
|
+
(!!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue) ||
|
|
79
|
+
// If value is an interpolation reference we're going to render whatever it evaluates to.
|
|
80
|
+
// See `interpolateJobContext`.
|
|
81
|
+
(this.rawValue.startsWith('${{') && this.rawValue.endsWith('}}'))));
|
|
99
82
|
}
|
|
100
83
|
parseInputValueToAllowedType(value) {
|
|
101
84
|
if (typeof value === 'object') {
|
|
@@ -134,10 +117,10 @@ export class BuildStepInput {
|
|
|
134
117
|
return numberValue;
|
|
135
118
|
}
|
|
136
119
|
parseInputValueToBoolean(value) {
|
|
137
|
-
if (value === 'true') {
|
|
120
|
+
if (value === 'true' || value === true) {
|
|
138
121
|
return true;
|
|
139
122
|
}
|
|
140
|
-
else if (value === 'false') {
|
|
123
|
+
else if (value === 'false' || value === false) {
|
|
141
124
|
return false;
|
|
142
125
|
}
|
|
143
126
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,sBAAsB,EAAoC,MAAM,uBAAuB,CAAC;AACjG,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;AA6CD,MAAM,OAAO,cAAc;IAalB,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,EACR,oBAAoB,GACO;QARZ,QAAG,GAAH,GAAG,CAAwB;QAU5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACz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EACjH;gBACE,KAAK,EAAE,CAAC;aACT,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAyB;IACjE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;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 assert from 'assert';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStepGlobalContext, SerializedBuildStepGlobalContext } 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}\n\nexport type BuildStepInputValueType<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n> = T extends BuildStepInputValueTypeName.STRING\n ? string\n : T extends BuildStepInputValueTypeName.BOOLEAN\n ? boolean\n : T extends BuildStepInputValueTypeName.NUMBER\n ? number\n : Record<string, unknown>;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n allowedValues?: unknown[];\n defaultValue?: unknown;\n required: R;\n allowedValueTypeName: T;\n}\n\ninterface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean>\n extends BuildStepInputProviderParams<T, R> {\n stepDisplayName: string;\n}\n\nexport interface SerializedBuildStepInput {\n id: string;\n stepDisplayName: string;\n defaultValue?: unknown;\n allowedValues?: unknown[];\n allowedValueTypeName: BuildStepInputValueTypeName;\n required: boolean;\n value?: unknown;\n ctx: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: unknown;\n public readonly allowedValues?: unknown[];\n public readonly allowedValueTypeName: T;\n public readonly required: R;\n\n private _value?: unknown;\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,\n allowedValueTypeName,\n }: BuildStepInputParams<T, R>\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(): R extends true\n ? BuildStepInputValueType<T>\n : BuildStepInputValueType<T> | 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 rawValue === null ||\n typeof rawValue === 'boolean' ||\n typeof rawValue === 'number';\n let returnValue;\n if (valueDoesNotRequireInterpolation) {\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 returnValue = rawValue as BuildStepInputValueType<T>;\n } else {\n // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined\n // so this will never be true.\n assert(rawValue !== undefined);\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n return returnValue;\n }\n\n public get rawValue(): unknown {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: unknown): 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 public serialize(): SerializedBuildStepInput {\n return {\n id: this.id,\n stepDisplayName: this.stepDisplayName,\n defaultValue: this.defaultValue,\n allowedValues: this.allowedValues,\n allowedValueTypeName: this.allowedValueTypeName,\n required: this.required,\n value: this._value,\n ctx: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serializedInput: SerializedBuildStepInput,\n logger: bunyan\n ): BuildStepInput {\n const deserializedContext = BuildStepGlobalContext.deserialize(serializedInput.ctx, logger);\n const input = new BuildStepInput(deserializedContext, {\n id: serializedInput.id,\n stepDisplayName: serializedInput.stepDisplayName,\n defaultValue: serializedInput.defaultValue,\n allowedValues: serializedInput.allowedValues,\n allowedValueTypeName: serializedInput.allowedValueTypeName,\n required: serializedInput.required,\n });\n input._value = serializedInput.value;\n return input;\n }\n\n private parseInputValueToAllowedType(value: string | object): BuildStepInputValueType<T> {\n if (typeof value === 'object') {\n return value as BuildStepInputValueType<T>;\n }\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return this.parseInputValueToString(value) as BuildStepInputValueType<T>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value) as BuildStepInputValueType<T>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value) as BuildStepInputValueType<T>;\n } else {\n return this.parseInputValueToObject(value) as BuildStepInputValueType<T>;\n }\n }\n\n private parseInputValueToString(value: string): string {\n let parsedValue = value;\n try {\n parsedValue = JSON.parse(`\"${value}\"`);\n } catch (err) {\n if (!(err instanceof SyntaxError)) {\n throw err;\n }\n }\n return parsedValue;\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
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings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;YACN,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,sBAAsB,IAAI,CAAC,oBAAoB,IAAI,CAClH,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,uBAAuB,CAAC,KAAgC;QAC9D,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,sBAAsB,IAAI,CAAC,oBAAoB,IAAI,EACjH;gBACE,KAAK,EAAE,CAAC;aACT,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAyB;IACjE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;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 assert from 'assert';\n\nimport { JobInterpolationContext } from '@expo/eas-build-job';\n\nimport { 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';\nimport { interpolateJobContext } from './interpolation.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n JSON = 'json',\n}\n\nexport type BuildStepInputValueType<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n> = T extends BuildStepInputValueTypeName.STRING\n ? string\n : T extends BuildStepInputValueTypeName.BOOLEAN\n ? boolean\n : T extends BuildStepInputValueTypeName.NUMBER\n ? number\n : Record<string, unknown>;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n allowedValues?: unknown[];\n defaultValue?: unknown;\n required: R;\n allowedValueTypeName: T;\n}\n\ninterface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean>\n extends BuildStepInputProviderParams<T, R> {\n stepDisplayName: string;\n}\n\nexport class BuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: unknown;\n public readonly allowedValues?: unknown[];\n public readonly allowedValueTypeName: T;\n public readonly required: R;\n\n private _value?: unknown;\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,\n allowedValueTypeName,\n }: BuildStepInputParams<T, R>\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 getValue({\n interpolationContext,\n }: {\n interpolationContext: JobInterpolationContext;\n }): R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | 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 interpolatedValue = interpolateJobContext({\n target: rawValue,\n context: interpolationContext,\n });\n\n const valueDoesNotRequireInterpolation =\n interpolatedValue === undefined ||\n interpolatedValue === null ||\n typeof interpolatedValue === 'boolean' ||\n typeof interpolatedValue === 'number';\n let returnValue;\n if (valueDoesNotRequireInterpolation) {\n if (\n typeof interpolatedValue !== this.allowedValueTypeName &&\n interpolatedValue !== undefined\n ) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n returnValue = interpolatedValue as BuildStepInputValueType<T>;\n } else {\n // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined\n // so this will never be true.\n assert(interpolatedValue !== undefined);\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(interpolatedValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n return returnValue;\n }\n\n public get rawValue(): unknown {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: unknown): 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 isRawValueOneOfAllowedValues(): 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 // If value is an interpolation reference we're going to render whatever it evaluates to.\n // See `interpolateJobContext`.\n (this.rawValue.startsWith('${{') && this.rawValue.endsWith('}}')))\n );\n }\n\n private parseInputValueToAllowedType(\n value: string | object | boolean | number\n ): BuildStepInputValueType<T> {\n if (typeof value === 'object') {\n return value as BuildStepInputValueType<T>;\n }\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return this.parseInputValueToString(value) as BuildStepInputValueType<T>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value) as BuildStepInputValueType<T>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value) as BuildStepInputValueType<T>;\n } else {\n return this.parseInputValueToObject(value) as BuildStepInputValueType<T>;\n }\n }\n\n private parseInputValueToString(value: string | boolean | number): string {\n let parsedValue = value;\n try {\n parsedValue = JSON.parse(`\"${value}\"`);\n } catch (err) {\n if (!(err instanceof SyntaxError)) {\n throw err;\n }\n }\n return parsedValue as string;\n }\n\n private parseInputValueToNumber(value: string | boolean | number): 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 | number): boolean {\n if (value === 'true' || value === true) {\n return true;\n } else if (value === 'false' || 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 | boolean | number): Record<string, any> {\n try {\n return JSON.parse(value as string);\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"]}
|
|
@@ -55,8 +55,8 @@ export class BuildWorkflowValidator {
|
|
|
55
55
|
if (currentStepInput.defaultValue === undefined) {
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
if (!currentStepInput.
|
|
59
|
-
const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${currentStepInput.
|
|
58
|
+
if (!currentStepInput.isRawValueOneOfAllowedValues()) {
|
|
59
|
+
const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${currentStepInput.rawValue}" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)
|
|
60
60
|
.map((i) => `"${i}"`)
|
|
61
61
|
.join(', ')}.`);
|
|
62
62
|
errors.push(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1B,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,KAAK,CAAC,aAAa;QACxB,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,CAA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gBAAgB,CAChC,gCAAgC,aAAa,CAAC,wBAAwB,mBAAmB,aAAa,CAAC,EAAE,mBAAmB,CAC7H,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YAED,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1F,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,gCAAgC,aAAa,CAAC,wBAAwB,mBAAmB,aAAa,CAAC,EAAE,yCAAyC,CACnJ,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import path from 'path';\n\nimport fs from 'fs-extra';\n\nimport { 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 async validateAsync(): Promise<void> {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n errors.push(...this.validateAllowedPlatforms());\n errors.push(...(await this.validateCustomFunctionModulesAsync()));\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 private async validateCustomFunctionModulesAsync(): Promise<BuildConfigError[]> {\n const errors: BuildConfigError[] = [];\n for (const buildFunction of Object.values(this.workflow.buildFunctions)) {\n if (!buildFunction.customFunctionModulePath) {\n continue;\n }\n\n if (!(await fs.exists(buildFunction.customFunctionModulePath))) {\n const error = new BuildConfigError(\n `Custom function module path \"${buildFunction.customFunctionModulePath}\" for function \"${buildFunction.id}\" does not exist.`\n );\n errors.push(error);\n continue;\n }\n\n if (!(await fs.exists(path.join(buildFunction.customFunctionModulePath, 'package.json')))) {\n const error = new BuildConfigError(\n `Custom function module path \"${buildFunction.customFunctionModulePath}\" for function \"${buildFunction.id}\" does not contain a package.json file.`\n );\n errors.push(error);\n }\n }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C,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import path from 'path';\n\nimport fs from 'fs-extra';\n\nimport { 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 async validateAsync(): Promise<void> {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n errors.push(...this.validateAllowedPlatforms());\n errors.push(...(await this.validateCustomFunctionModulesAsync()));\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.isRawValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${currentStepInput.rawValue}\" which is not one of the allowed values: ${nullthrows(\n currentStepInput.allowedValues\n )\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 private async validateCustomFunctionModulesAsync(): Promise<BuildConfigError[]> {\n const errors: BuildConfigError[] = [];\n for (const buildFunction of Object.values(this.workflow.buildFunctions)) {\n if (!buildFunction.customFunctionModulePath) {\n continue;\n }\n\n if (!(await fs.exists(buildFunction.customFunctionModulePath))) {\n const error = new BuildConfigError(\n `Custom function module path \"${buildFunction.customFunctionModulePath}\" for function \"${buildFunction.id}\" does not exist.`\n );\n errors.push(error);\n continue;\n }\n\n if (!(await fs.exists(path.join(buildFunction.customFunctionModulePath, 'package.json')))) {\n const error = new BuildConfigError(\n `Custom function module path \"${buildFunction.customFunctionModulePath}\" for function \"${buildFunction.id}\" does not contain a package.json file.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n}\n"]}
|
package/dist_esm/cli/cli.js
CHANGED
package/dist_esm/cli/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAU,YAAY,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAgC,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIlD,MAAM,MAAM,GAAG,YAAY,CAAC;IA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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACnE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,4BAA4B,CAAC,CAAC;AAEnF,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7D,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACtC,IAAI,GAAG,YAAY,kBAAkB,EAAE,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC9D,KAAK,MAAM,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { Job, Metadata, StaticJobInterpolationContext } from '@expo/eas-build-job';\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 public readonly buildLogsDirectory: string\n ) {}\n public get env(): BuildStepEnv {\n return this._env;\n }\n public staticContext(): Omit<StaticJobInterpolationContext, 'steps'> {\n return {\n job: {} as Job,\n metadata: {} as Metadata,\n expoApiServerURL: 'http://api.expo.test',\n };\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 relativeProjectDirectory\n ),\n false\n );\n const parser = new BuildConfigParser(ctx, {\n configPath,\n });\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"]}
|
|
@@ -2,7 +2,7 @@ import assert from 'assert';
|
|
|
2
2
|
import { createLogger } from '@expo/logger';
|
|
3
3
|
import cloneDeep from 'lodash.clonedeep';
|
|
4
4
|
import { BuildStepOutput } from '../BuildStepOutput.js';
|
|
5
|
-
import {
|
|
5
|
+
import { deserializeInputs, } from '../utils/customFunction.js';
|
|
6
6
|
import { BuildStepContext } from '../BuildStepContext.js';
|
|
7
7
|
import { spawnAsync } from '../utils/shell/spawn.js';
|
|
8
8
|
async function runCustomJsFunctionAsync() {
|
|
@@ -58,10 +58,7 @@ async function runCustomJsFunctionAsync() {
|
|
|
58
58
|
],
|
|
59
59
|
});
|
|
60
60
|
const ctx = BuildStepContext.deserialize(serializedFunctionArguments.ctx, logger);
|
|
61
|
-
const inputs =
|
|
62
|
-
id,
|
|
63
|
-
BuildStepInput.deserialize(input, logger),
|
|
64
|
-
]));
|
|
61
|
+
const inputs = deserializeInputs(serializedFunctionArguments.inputs);
|
|
65
62
|
const outputs = Object.fromEntries(Object.entries(serializedFunctionArguments.outputs).map(([id, output]) => [
|
|
66
63
|
id,
|
|
67
64
|
BuildStepOutput.deserialize(output),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCustomFunction.js","sourceRoot":"","sources":["../../src/scripts/runCustomFunction.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"runCustomFunction.js","sourceRoot":"","sources":["../../src/scripts/runCustomFunction.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAEL,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,KAAK,UAAU,wBAAwB;IACrC,MAAM,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CA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C,QAAQ,EAAE,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC;YACjD,QAAQ,CAAC,IAAI,CACX,UAAU,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;gBAClD,GAAG;gBACH,KAAK,EAAE,MAAM;aACd,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,QAAQ,KAAK,SAAS,CAAC,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;YAChD,QAAQ,CAAC,IAAI,CACX,UAAU,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;gBACzC,GAAG;gBACH,KAAK,EAAE,MAAM;aACd,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,KAAK,wBAAwB,EAAE,CAAC","sourcesContent":["import assert from 'assert';\n\nimport { createLogger } from '@expo/logger';\nimport { SpawnPromise, SpawnResult } from '@expo/spawn-async';\nimport cloneDeep from 'lodash.clonedeep';\n\nimport { BuildStepOutput } from '../BuildStepOutput.js';\nimport {\n SerializedCustomBuildFunctionArguments,\n deserializeInputs,\n} from '../utils/customFunction.js';\nimport { BuildStepContext } from '../BuildStepContext.js';\nimport { BuildStepFunction } from '../BuildStep.js';\nimport { spawnAsync } from '../utils/shell/spawn.js';\n\nasync function runCustomJsFunctionAsync(): Promise<void> {\n const customJavascriptFunctionModulePath = process.argv[2];\n const functionArgs = process.argv[3];\n\n assert(customJavascriptFunctionModulePath, 'customJavascriptFunctionModulePath is required');\n assert(functionArgs, 'serializedFunctionParams is required');\n\n let serializedFunctionArguments: SerializedCustomBuildFunctionArguments;\n try {\n serializedFunctionArguments = JSON.parse(functionArgs);\n } catch (e) {\n console.error('Failed to parse serializedFunctionParams');\n throw e;\n }\n\n const logger = createLogger({\n name: 'customFunctionLogger',\n streams: [\n {\n type: 'raw',\n stream: {\n write: (rec: any) => {\n if (rec) {\n switch (rec.level) {\n case 20: // Debug level\n if (rec.msg) {\n console.debug(rec.msg);\n }\n break;\n case 30: // Info level\n if (rec.msg) {\n console.log(rec.msg);\n }\n break;\n case 40: // Warn level\n if (rec.msg) {\n console.warn(rec.msg);\n }\n break;\n case 50: // Error level\n case 60: // Fatal level\n if (rec.msg) {\n console.error(rec.msg);\n }\n break;\n default:\n break;\n }\n }\n },\n },\n },\n ],\n });\n\n const ctx = BuildStepContext.deserialize(serializedFunctionArguments.ctx, logger);\n const inputs = deserializeInputs(serializedFunctionArguments.inputs);\n const outputs = Object.fromEntries(\n Object.entries(serializedFunctionArguments.outputs).map(([id, output]) => [\n id,\n BuildStepOutput.deserialize(output),\n ])\n );\n const env = serializedFunctionArguments.env;\n const envBefore = cloneDeep(serializedFunctionArguments.env);\n\n let customModule: { default: BuildStepFunction };\n try {\n customModule = await require(customJavascriptFunctionModulePath);\n } catch (e) {\n console.error('Failed to load custom function module');\n throw e;\n }\n\n const customJavascriptFunction = customModule.default;\n\n await customJavascriptFunction(ctx, { inputs, outputs, env });\n\n const promises: SpawnPromise<SpawnResult>[] = [];\n for (const output of Object.values(outputs)) {\n if (output.rawValue) {\n assert(output.value, 'output.value is required');\n promises.push(\n spawnAsync('set-output', [output.id, output.value], {\n env,\n stdio: 'pipe',\n })\n );\n }\n }\n for (const envName of Object.keys(env)) {\n const envValue = env[envName];\n if (envValue !== envBefore[envName] && envValue) {\n promises.push(\n spawnAsync('set-env', [envName, envValue], {\n env,\n stdio: 'pipe',\n })\n );\n }\n }\n await Promise.all(promises);\n}\n\nvoid runCustomJsFunctionAsync();\n"]}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { BuildStepFunction } from '../BuildStep.js';
|
|
2
2
|
import { BuildStepEnv } from '../BuildStepEnv.js';
|
|
3
|
-
import { SerializedBuildStepInput } from '../BuildStepInput.js';
|
|
4
3
|
import { SerializedBuildStepOutput } from '../BuildStepOutput.js';
|
|
5
4
|
import { SerializedBuildStepContext } from '../BuildStepContext.js';
|
|
6
5
|
export declare const SCRIPTS_PATH: string;
|
|
6
|
+
type SerializedBuildStepInput = {
|
|
7
|
+
serializedValue: string | undefined;
|
|
8
|
+
};
|
|
7
9
|
export interface SerializedCustomBuildFunctionArguments {
|
|
8
10
|
env: BuildStepEnv;
|
|
9
11
|
inputs: Record<string, SerializedBuildStepInput>;
|
|
10
12
|
outputs: Record<string, SerializedBuildStepOutput>;
|
|
11
13
|
ctx: SerializedBuildStepContext;
|
|
12
14
|
}
|
|
15
|
+
export declare function serializeInputs(inputs: Parameters<BuildStepFunction>[1]['inputs']): SerializedCustomBuildFunctionArguments['inputs'];
|
|
16
|
+
export declare function deserializeInputs(inputs: SerializedCustomBuildFunctionArguments['inputs']): Parameters<BuildStepFunction>[1]['inputs'];
|
|
13
17
|
export declare function createCustomFunctionCall(rawCustomFunctionModulePath: string): BuildStepFunction;
|
|
18
|
+
export {};
|
|
@@ -4,6 +4,18 @@ import fs from 'fs-extra';
|
|
|
4
4
|
import { spawnAsync } from './shell/spawn.js';
|
|
5
5
|
const thisFileCtx = createContext();
|
|
6
6
|
export const SCRIPTS_PATH = path.join(thisFileCtx.dirname, '../../dist_commonjs/scripts');
|
|
7
|
+
export function serializeInputs(inputs) {
|
|
8
|
+
return Object.fromEntries(Object.entries(inputs).map(([id, input]) => [
|
|
9
|
+
id,
|
|
10
|
+
{ serializedValue: input === undefined ? undefined : JSON.stringify(input.value) },
|
|
11
|
+
]));
|
|
12
|
+
}
|
|
13
|
+
export function deserializeInputs(inputs) {
|
|
14
|
+
return Object.fromEntries(Object.entries(inputs).map(([id, { serializedValue }]) => [
|
|
15
|
+
id,
|
|
16
|
+
{ value: serializedValue === undefined ? undefined : JSON.parse(serializedValue) },
|
|
17
|
+
]));
|
|
18
|
+
}
|
|
7
19
|
export function createCustomFunctionCall(rawCustomFunctionModulePath) {
|
|
8
20
|
return async (ctx, { env, inputs, outputs }) => {
|
|
9
21
|
let customFunctionModulePath = rawCustomFunctionModulePath;
|
|
@@ -13,7 +25,7 @@ export function createCustomFunctionCall(rawCustomFunctionModulePath) {
|
|
|
13
25
|
}
|
|
14
26
|
const serializedArguments = {
|
|
15
27
|
env,
|
|
16
|
-
inputs:
|
|
28
|
+
inputs: serializeInputs(inputs),
|
|
17
29
|
outputs: Object.fromEntries(Object.entries(outputs).map(([id, output]) => [id, output.serialize()])),
|
|
18
30
|
ctx: ctx.serialize(),
|
|
19
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customFunction.js","sourceRoot":"","sources":["../../src/utils/customFunction.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"customFunction.js","sourceRoot":"","sources":["../../src/utils/customFunction.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,UAAU,CAAC;AAO1B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;AAW1F,MAAM,UAAU,eAAe,CAC7B,MAAkD;IAElD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GA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MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;YAC/B,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CACxE;YACD,GAAG,EAAE,GAAG,CAAC,SAAS,EAAE;SACrB,CAAC;QACF,IAAI,CAAC;YACH,MAAM,UAAU,CACd,MAAM,EACN;gBACE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,uBAAuB,CAAC;gBAChD,wBAAwB;gBACxB,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;aACpC,EACD;gBACE,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,GAAG,EAAE,GAAG,CAAC,gBAAgB;gBACzB,GAAG;gBACH,KAAK,EAAE,MAAM;aACd,CACF,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\n\nimport { createContext } from 'this-file';\nimport fs from 'fs-extra';\n\nimport { BuildStepFunction } from '../BuildStep.js';\nimport { BuildStepEnv } from '../BuildStepEnv.js';\nimport { SerializedBuildStepOutput } from '../BuildStepOutput.js';\nimport { SerializedBuildStepContext } from '../BuildStepContext.js';\n\nimport { spawnAsync } from './shell/spawn.js';\n\nconst thisFileCtx = createContext();\n\nexport const SCRIPTS_PATH = path.join(thisFileCtx.dirname, '../../dist_commonjs/scripts');\n\ntype SerializedBuildStepInput = { serializedValue: string | undefined };\n\nexport interface SerializedCustomBuildFunctionArguments {\n env: BuildStepEnv;\n inputs: Record<string, SerializedBuildStepInput>;\n outputs: Record<string, SerializedBuildStepOutput>;\n ctx: SerializedBuildStepContext;\n}\n\nexport function serializeInputs(\n inputs: Parameters<BuildStepFunction>[1]['inputs']\n): SerializedCustomBuildFunctionArguments['inputs'] {\n return Object.fromEntries(\n Object.entries(inputs).map(([id, input]) => [\n id,\n { serializedValue: input === undefined ? undefined : JSON.stringify(input.value) },\n ])\n );\n}\n\nexport function deserializeInputs(\n inputs: SerializedCustomBuildFunctionArguments['inputs']\n): Parameters<BuildStepFunction>[1]['inputs'] {\n return Object.fromEntries(\n Object.entries(inputs).map(([id, { serializedValue }]) => [\n id,\n { value: serializedValue === undefined ? undefined : JSON.parse(serializedValue) },\n ])\n );\n}\n\nexport function createCustomFunctionCall(rawCustomFunctionModulePath: string): BuildStepFunction {\n return async (ctx, { env, inputs, outputs }) => {\n let customFunctionModulePath = rawCustomFunctionModulePath;\n if (!(await fs.exists(ctx.global.projectSourceDirectory))) {\n const relative = path.relative(\n path.resolve(ctx.global.projectSourceDirectory),\n customFunctionModulePath\n );\n customFunctionModulePath = path.resolve(\n path.join(ctx.global.projectTargetDirectory, relative)\n );\n }\n const serializedArguments: SerializedCustomBuildFunctionArguments = {\n env,\n inputs: serializeInputs(inputs),\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([id, output]) => [id, output.serialize()])\n ),\n ctx: ctx.serialize(),\n };\n try {\n await spawnAsync(\n 'node',\n [\n path.join(SCRIPTS_PATH, 'runCustomFunction.cjs'),\n customFunctionModulePath,\n JSON.stringify(serializedArguments),\n ],\n {\n logger: ctx.logger,\n cwd: ctx.workingDirectory,\n env,\n stdio: 'pipe',\n }\n );\n } catch {\n throw new Error(`Custom function exited with non-zero exit code.`);\n }\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/steps",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.185",
|
|
5
5
|
"main": "./dist_commonjs/index.cjs",
|
|
6
6
|
"types": "./dist_esm/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"node": ">=18"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@expo/eas-build-job": "1.0.
|
|
51
|
+
"@expo/eas-build-job": "1.0.185",
|
|
52
52
|
"@expo/logger": "1.0.117",
|
|
53
53
|
"@expo/spawn-async": "^1.7.2",
|
|
54
54
|
"arg": "^5.0.2",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"node": "20.14.0",
|
|
66
66
|
"yarn": "1.22.21"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "ca087e7a6cfced26bc64fc601a24b3d7f8100e16"
|
|
69
69
|
}
|