@expo/steps 1.0.265 → 1.0.271
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 → dist}/AbstractConfigParser.d.ts +5 -5
- package/{dist_commonjs/AbstractConfigParser.cjs → dist/AbstractConfigParser.js} +13 -13
- package/dist/AbstractConfigParser.js.map +1 -0
- package/{dist_commonjs → dist}/BuildConfig.d.ts +3 -3
- package/{dist_commonjs/BuildConfig.cjs → dist/BuildConfig.js} +22 -22
- package/dist/BuildConfig.js.map +1 -0
- package/{dist_esm → dist}/BuildConfigParser.d.ts +5 -5
- package/{dist_commonjs/BuildConfigParser.cjs → dist/BuildConfigParser.js} +31 -31
- package/dist/BuildConfigParser.js.map +1 -0
- package/{dist_esm → dist}/BuildFunction.d.ts +6 -6
- package/{dist_commonjs/BuildFunction.cjs → dist/BuildFunction.js} +6 -6
- package/dist/BuildFunction.js.map +1 -0
- package/{dist_commonjs → dist}/BuildFunctionGroup.d.ts +4 -4
- package/{dist_commonjs/BuildFunctionGroup.cjs → dist/BuildFunctionGroup.js} +4 -4
- package/dist/BuildFunctionGroup.js.map +1 -0
- package/{dist_esm → dist}/BuildStep.d.ts +5 -5
- package/{dist_commonjs/BuildStep.cjs → dist/BuildStep.js} +29 -29
- package/dist/BuildStep.js.map +1 -0
- package/{dist_commonjs → dist}/BuildStepContext.d.ts +4 -4
- package/{dist_commonjs/BuildStepContext.cjs → dist/BuildStepContext.js} +10 -10
- package/dist/BuildStepContext.js.map +1 -0
- package/{dist_esm → dist}/BuildStepInput.d.ts +1 -1
- package/{dist_commonjs/BuildStepInput.cjs → dist/BuildStepInput.js} +12 -12
- package/dist/BuildStepInput.js.map +1 -0
- package/{dist_commonjs → dist}/BuildStepOutput.d.ts +1 -1
- package/{dist_commonjs/BuildStepOutput.cjs → dist/BuildStepOutput.js} +3 -3
- package/dist/BuildStepOutput.js.map +1 -0
- package/{dist_commonjs → dist}/BuildTemporaryFiles.d.ts +1 -1
- package/{dist_commonjs → dist}/BuildTemporaryFiles.js.map +1 -1
- package/{dist_commonjs → dist}/BuildWorkflow.d.ts +3 -3
- package/dist/BuildWorkflow.js.map +1 -0
- package/{dist_commonjs → dist}/BuildWorkflowValidator.d.ts +1 -1
- package/{dist_commonjs/BuildWorkflowValidator.cjs → dist/BuildWorkflowValidator.js} +19 -19
- package/dist/BuildWorkflowValidator.js.map +1 -0
- package/{dist_commonjs → dist}/StepsConfigParser.d.ts +5 -5
- package/{dist_commonjs/StepsConfigParser.cjs → dist/StepsConfigParser.js} +13 -13
- package/dist/StepsConfigParser.js.map +1 -0
- package/{dist_esm → dist}/cli/cli.d.ts +3 -3
- package/{dist_commonjs/cli/cli.cjs → dist/cli/cli.js} +6 -6
- package/dist/cli/cli.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/{dist_commonjs/index.cjs → dist/index.js} +30 -30
- package/dist/index.js.map +1 -0
- package/{dist_commonjs/interpolation.cjs → dist/interpolation.js} +3 -3
- package/dist/interpolation.js.map +1 -0
- package/{dist_commonjs/scripts/runCustomFunction.cjs → dist/scripts/runCustomFunction.js} +9 -9
- package/dist/scripts/runCustomFunction.js.map +1 -0
- package/{dist_commonjs → dist}/utils/customFunction.d.ts +4 -4
- package/{dist_commonjs/utils/customFunction.cjs → dist/utils/customFunction.js} +4 -6
- package/dist/utils/customFunction.js.map +1 -0
- package/{dist_commonjs/utils/shell/bin.cjs → dist/utils/shell/bin.js} +1 -3
- package/dist/utils/shell/bin.js.map +1 -0
- package/{dist_commonjs/utils/template.cjs → dist/utils/template.js} +7 -7
- package/dist/utils/template.js.map +1 -0
- package/package.json +11 -23
- package/dist_commonjs/AbstractConfigParser.js.map +0 -1
- package/dist_commonjs/BuildConfig.js.map +0 -1
- package/dist_commonjs/BuildConfigParser.d.ts +0 -33
- package/dist_commonjs/BuildConfigParser.js.map +0 -1
- package/dist_commonjs/BuildFunction.d.ts +0 -45
- package/dist_commonjs/BuildFunction.js.map +0 -1
- package/dist_commonjs/BuildFunctionGroup.js.map +0 -1
- package/dist_commonjs/BuildStep.d.ts +0 -100
- package/dist_commonjs/BuildStep.js.map +0 -1
- package/dist_commonjs/BuildStepContext.js.map +0 -1
- package/dist_commonjs/BuildStepInput.d.ts +0 -47
- package/dist_commonjs/BuildStepInput.js.map +0 -1
- package/dist_commonjs/BuildStepOutput.js.map +0 -1
- package/dist_commonjs/BuildWorkflow.js.map +0 -1
- package/dist_commonjs/BuildWorkflowValidator.js.map +0 -1
- package/dist_commonjs/StepsConfigParser.js.map +0 -1
- package/dist_commonjs/cli/cli.d.ts +0 -18
- package/dist_commonjs/cli/cli.js.map +0 -1
- package/dist_commonjs/index.d.ts +0 -19
- package/dist_commonjs/index.js.map +0 -1
- package/dist_commonjs/interpolation.js.map +0 -1
- package/dist_commonjs/scripts/runCustomFunction.js.map +0 -1
- package/dist_commonjs/utils/customFunction.js.map +0 -1
- package/dist_commonjs/utils/shell/bin.js.map +0 -1
- package/dist_commonjs/utils/template.js.map +0 -1
- package/dist_esm/AbstractConfigParser.d.ts +0 -23
- package/dist_esm/AbstractConfigParser.js +0 -61
- package/dist_esm/AbstractConfigParser.js.map +0 -1
- package/dist_esm/BuildConfig.d.ts +0 -80
- package/dist_esm/BuildConfig.js +0 -281
- package/dist_esm/BuildConfig.js.map +0 -1
- package/dist_esm/BuildConfigParser.js +0 -233
- package/dist_esm/BuildConfigParser.js.map +0 -1
- package/dist_esm/BuildFunction.js +0 -62
- package/dist_esm/BuildFunction.js.map +0 -1
- package/dist_esm/BuildFunctionGroup.d.ts +0 -23
- package/dist_esm/BuildFunctionGroup.js +0 -36
- package/dist_esm/BuildFunctionGroup.js.map +0 -1
- package/dist_esm/BuildRuntimePlatform.d.ts +0 -4
- package/dist_esm/BuildRuntimePlatform.js +0 -6
- package/dist_esm/BuildRuntimePlatform.js.map +0 -1
- package/dist_esm/BuildStep.js +0 -354
- package/dist_esm/BuildStep.js.map +0 -1
- package/dist_esm/BuildStepContext.d.ts +0 -86
- package/dist_esm/BuildStepContext.js +0 -207
- package/dist_esm/BuildStepContext.js.map +0 -1
- package/dist_esm/BuildStepEnv.d.ts +0 -1
- package/dist_esm/BuildStepEnv.js +0 -2
- package/dist_esm/BuildStepEnv.js.map +0 -1
- package/dist_esm/BuildStepInput.js +0 -150
- package/dist_esm/BuildStepInput.js.map +0 -1
- package/dist_esm/BuildStepOutput.d.ts +0 -33
- package/dist_esm/BuildStepOutput.js +0 -57
- package/dist_esm/BuildStepOutput.js.map +0 -1
- package/dist_esm/BuildTemporaryFiles.d.ts +0 -5
- package/dist_esm/BuildTemporaryFiles.js +0 -31
- package/dist_esm/BuildTemporaryFiles.js.map +0 -1
- package/dist_esm/BuildWorkflow.d.ts +0 -14
- package/dist_esm/BuildWorkflow.js +0 -55
- package/dist_esm/BuildWorkflow.js.map +0 -1
- package/dist_esm/BuildWorkflowValidator.d.ts +0 -10
- package/dist_esm/BuildWorkflowValidator.js +0 -121
- package/dist_esm/BuildWorkflowValidator.js.map +0 -1
- package/dist_esm/StepMetrics.d.ts +0 -10
- package/dist_esm/StepMetrics.js +0 -2
- package/dist_esm/StepMetrics.js.map +0 -1
- package/dist_esm/StepsConfigParser.d.ts +0 -24
- package/dist_esm/StepsConfigParser.js +0 -133
- package/dist_esm/StepsConfigParser.js.map +0 -1
- package/dist_esm/cli/cli.js +0 -61
- package/dist_esm/cli/cli.js.map +0 -1
- package/dist_esm/errors.d.ts +0 -24
- package/dist_esm/errors.js +0 -24
- package/dist_esm/errors.js.map +0 -1
- package/dist_esm/index.d.ts +0 -19
- package/dist_esm/index.js +0 -18
- package/dist_esm/index.js.map +0 -1
- package/dist_esm/interpolation.d.ts +0 -5
- package/dist_esm/interpolation.js +0 -26
- package/dist_esm/interpolation.js.map +0 -1
- package/dist_esm/scripts/runCustomFunction.d.ts +0 -1
- package/dist_esm/scripts/runCustomFunction.js +0 -100
- package/dist_esm/scripts/runCustomFunction.js.map +0 -1
- package/dist_esm/utils/customFunction.d.ts +0 -18
- package/dist_esm/utils/customFunction.js +0 -49
- package/dist_esm/utils/customFunction.js.map +0 -1
- package/dist_esm/utils/expodash/duplicates.d.ts +0 -1
- package/dist_esm/utils/expodash/duplicates.js +0 -14
- package/dist_esm/utils/expodash/duplicates.js.map +0 -1
- package/dist_esm/utils/expodash/uniq.d.ts +0 -1
- package/dist_esm/utils/expodash/uniq.js +0 -5
- package/dist_esm/utils/expodash/uniq.js.map +0 -1
- package/dist_esm/utils/hashFiles.d.ts +0 -6
- package/dist_esm/utils/hashFiles.js +0 -31
- package/dist_esm/utils/hashFiles.js.map +0 -1
- package/dist_esm/utils/jsepEval.d.ts +0 -1
- package/dist_esm/utils/jsepEval.js +0 -169
- package/dist_esm/utils/jsepEval.js.map +0 -1
- package/dist_esm/utils/nullthrows.d.ts +0 -1
- package/dist_esm/utils/nullthrows.js +0 -7
- package/dist_esm/utils/nullthrows.js.map +0 -1
- package/dist_esm/utils/shell/bin.d.ts +0 -1
- package/dist_esm/utils/shell/bin.js +0 -5
- package/dist_esm/utils/shell/bin.js.map +0 -1
- package/dist_esm/utils/shell/command.d.ts +0 -4
- package/dist_esm/utils/shell/command.js +0 -13
- package/dist_esm/utils/shell/command.js.map +0 -1
- package/dist_esm/utils/shell/spawn.d.ts +0 -15
- package/dist_esm/utils/shell/spawn.js +0 -16
- package/dist_esm/utils/shell/spawn.js.map +0 -1
- package/dist_esm/utils/template.d.ts +0 -19
- package/dist_esm/utils/template.js +0 -106
- package/dist_esm/utils/template.js.map +0 -1
- /package/{dist_commonjs → dist}/BuildRuntimePlatform.d.ts +0 -0
- /package/{dist_commonjs/BuildRuntimePlatform.cjs → dist/BuildRuntimePlatform.js} +0 -0
- /package/{dist_commonjs → dist}/BuildRuntimePlatform.js.map +0 -0
- /package/{dist_commonjs → dist}/BuildStepEnv.d.ts +0 -0
- /package/{dist_commonjs/BuildStepEnv.cjs → dist/BuildStepEnv.js} +0 -0
- /package/{dist_commonjs → dist}/BuildStepEnv.js.map +0 -0
- /package/{dist_commonjs/BuildTemporaryFiles.cjs → dist/BuildTemporaryFiles.js} +0 -0
- /package/{dist_commonjs/BuildWorkflow.cjs → dist/BuildWorkflow.js} +0 -0
- /package/{dist_commonjs → dist}/StepMetrics.d.ts +0 -0
- /package/{dist_commonjs/StepMetrics.cjs → dist/StepMetrics.js} +0 -0
- /package/{dist_commonjs → dist}/StepMetrics.js.map +0 -0
- /package/{dist_commonjs → dist}/errors.d.ts +0 -0
- /package/{dist_commonjs/errors.cjs → dist/errors.js} +0 -0
- /package/{dist_commonjs → dist}/errors.js.map +0 -0
- /package/{dist_commonjs → dist}/interpolation.d.ts +0 -0
- /package/{dist_commonjs → dist}/scripts/runCustomFunction.d.ts +0 -0
- /package/{dist_commonjs → dist}/utils/expodash/duplicates.d.ts +0 -0
- /package/{dist_commonjs/utils/expodash/duplicates.cjs → dist/utils/expodash/duplicates.js} +0 -0
- /package/{dist_commonjs → dist}/utils/expodash/duplicates.js.map +0 -0
- /package/{dist_commonjs → dist}/utils/expodash/uniq.d.ts +0 -0
- /package/{dist_commonjs/utils/expodash/uniq.cjs → dist/utils/expodash/uniq.js} +0 -0
- /package/{dist_commonjs → dist}/utils/expodash/uniq.js.map +0 -0
- /package/{dist_commonjs → dist}/utils/hashFiles.d.ts +0 -0
- /package/{dist_commonjs/utils/hashFiles.cjs → dist/utils/hashFiles.js} +0 -0
- /package/{dist_commonjs → dist}/utils/hashFiles.js.map +0 -0
- /package/{dist_commonjs → dist}/utils/jsepEval.d.ts +0 -0
- /package/{dist_commonjs/utils/jsepEval.cjs → dist/utils/jsepEval.js} +0 -0
- /package/{dist_commonjs → dist}/utils/jsepEval.js.map +0 -0
- /package/{dist_commonjs → dist}/utils/nullthrows.d.ts +0 -0
- /package/{dist_commonjs/utils/nullthrows.cjs → dist/utils/nullthrows.js} +0 -0
- /package/{dist_commonjs → dist}/utils/nullthrows.js.map +0 -0
- /package/{dist_commonjs → dist}/utils/shell/bin.d.ts +0 -0
- /package/{dist_commonjs → dist}/utils/shell/command.d.ts +0 -0
- /package/{dist_commonjs/utils/shell/command.cjs → dist/utils/shell/command.js} +0 -0
- /package/{dist_commonjs → dist}/utils/shell/command.js.map +0 -0
- /package/{dist_commonjs → dist}/utils/shell/spawn.d.ts +0 -0
- /package/{dist_commonjs/utils/shell/spawn.cjs → dist/utils/shell/spawn.js} +0 -0
- /package/{dist_commonjs → dist}/utils/shell/spawn.js.map +0 -0
- /package/{dist_commonjs → dist}/utils/template.d.ts +0 -0
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import { BuildStep } from './BuildStep.js';
|
|
3
|
-
import { createCustomFunctionCall } from './utils/customFunction.js';
|
|
4
|
-
export class BuildFunction {
|
|
5
|
-
constructor({ namespace, id, name, supportedRuntimePlatforms, inputProviders, outputProviders, command, fn, customFunctionModulePath, shell, __metricsId, }) {
|
|
6
|
-
assert(command !== undefined || fn !== undefined || customFunctionModulePath !== undefined, 'Either command, fn or path must be defined.');
|
|
7
|
-
assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');
|
|
8
|
-
assert(!(command !== undefined && customFunctionModulePath !== undefined), 'Command and path cannot be both set.');
|
|
9
|
-
assert(!(fn !== undefined && customFunctionModulePath !== undefined), 'Fn and path cannot be both set.');
|
|
10
|
-
this.namespace = namespace;
|
|
11
|
-
this.id = id;
|
|
12
|
-
this.name = name;
|
|
13
|
-
this.supportedRuntimePlatforms = supportedRuntimePlatforms;
|
|
14
|
-
this.inputProviders = inputProviders;
|
|
15
|
-
this.outputProviders = outputProviders;
|
|
16
|
-
this.command = command;
|
|
17
|
-
this.fn = fn;
|
|
18
|
-
this.shell = shell;
|
|
19
|
-
this.customFunctionModulePath = customFunctionModulePath;
|
|
20
|
-
this.__metricsId = __metricsId;
|
|
21
|
-
}
|
|
22
|
-
getFullId() {
|
|
23
|
-
return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;
|
|
24
|
-
}
|
|
25
|
-
createBuildStepFromFunctionCall(ctx, { id, name, callInputs = {}, workingDirectory, shell, env, ifCondition, timeoutMs, } = {}) {
|
|
26
|
-
var _a, _b, _c;
|
|
27
|
-
const buildStepId = BuildStep.getNewId(id);
|
|
28
|
-
const buildStepName = name !== null && name !== void 0 ? name : this.name;
|
|
29
|
-
const buildStepDisplayName = BuildStep.getDisplayName({
|
|
30
|
-
id: buildStepId,
|
|
31
|
-
command: this.command,
|
|
32
|
-
name: buildStepName,
|
|
33
|
-
});
|
|
34
|
-
const inputs = (_a = this.inputProviders) === null || _a === void 0 ? void 0 : _a.map((inputProvider) => {
|
|
35
|
-
const input = inputProvider(ctx, buildStepId);
|
|
36
|
-
if (input.id in callInputs) {
|
|
37
|
-
input.set(callInputs[input.id]);
|
|
38
|
-
}
|
|
39
|
-
return input;
|
|
40
|
-
});
|
|
41
|
-
const outputs = (_b = this.outputProviders) === null || _b === void 0 ? void 0 : _b.map((outputProvider) => outputProvider(ctx, buildStepId));
|
|
42
|
-
return new BuildStep(ctx, {
|
|
43
|
-
id: buildStepId,
|
|
44
|
-
name: buildStepName,
|
|
45
|
-
displayName: buildStepDisplayName,
|
|
46
|
-
command: this.command,
|
|
47
|
-
fn: (_c = this.fn) !== null && _c !== void 0 ? _c : (this.customFunctionModulePath
|
|
48
|
-
? createCustomFunctionCall(this.customFunctionModulePath)
|
|
49
|
-
: undefined),
|
|
50
|
-
workingDirectory,
|
|
51
|
-
inputs,
|
|
52
|
-
outputs,
|
|
53
|
-
shell,
|
|
54
|
-
supportedRuntimePlatforms: this.supportedRuntimePlatforms,
|
|
55
|
-
env,
|
|
56
|
-
ifCondition,
|
|
57
|
-
timeoutMs,
|
|
58
|
-
__metricsId: this.__metricsId,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=BuildFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildFunction.js","sourceRoot":"","sources":["../src/BuildFunction.ts"],"names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aAAa;YACnB,WAAW,EAAE,oBAAoB;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,EAAE,EACA,MAAA,IAAI,CAAC,EAAE,mCACP,CAAC,IAAI,CAAC,wBAAwB;gBAC5B,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,wBAAwB,CAAC;gBACzD,CAAC,CAAC,SAAS,CAAC;YAChB,gBAAgB;YAChB,MAAM;YACN,OAAO;YACP,KAAK;YACL,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;YACzD,GAAG;YACH,WAAW;YACX,SAAS;YACT,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import assert from 'assert';\n\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildStep, BuildStepFunction } from './BuildStep.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepInputProvider } from './BuildStepInput.js';\nimport { BuildStepOutputProvider } from './BuildStepOutput.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { createCustomFunctionCall } from './utils/customFunction.js';\n\nexport type BuildFunctionById = Record<string, BuildFunction>;\nexport type BuildFunctionCallInputs = Record<string, unknown>;\n\nexport class BuildFunction {\n public readonly namespace?: string;\n public readonly id: string;\n public readonly name?: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputProviders?: BuildStepInputProvider[];\n public readonly outputProviders?: BuildStepOutputProvider[];\n public readonly command?: string;\n public readonly customFunctionModulePath?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell?: string;\n public readonly __metricsId?: string;\n\n constructor({\n namespace,\n id,\n name,\n supportedRuntimePlatforms,\n inputProviders,\n outputProviders,\n command,\n fn,\n customFunctionModulePath,\n shell,\n __metricsId,\n }: {\n namespace?: string;\n id: string;\n name?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n inputProviders?: BuildStepInputProvider[];\n outputProviders?: BuildStepOutputProvider[];\n command?: string;\n customFunctionModulePath?: string;\n fn?: BuildStepFunction;\n shell?: string;\n __metricsId?: string;\n }) {\n assert(\n command !== undefined || fn !== undefined || customFunctionModulePath !== undefined,\n 'Either command, fn or path must be defined.'\n );\n\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n assert(\n !(command !== undefined && customFunctionModulePath !== undefined),\n 'Command and path cannot be both set.'\n );\n assert(\n !(fn !== undefined && customFunctionModulePath !== undefined),\n 'Fn and path cannot be both set.'\n );\n\n this.namespace = namespace;\n this.id = id;\n this.name = name;\n this.supportedRuntimePlatforms = supportedRuntimePlatforms;\n this.inputProviders = inputProviders;\n this.outputProviders = outputProviders;\n this.command = command;\n this.fn = fn;\n this.shell = shell;\n this.customFunctionModulePath = customFunctionModulePath;\n this.__metricsId = __metricsId;\n }\n\n public getFullId(): string {\n return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;\n }\n\n public createBuildStepFromFunctionCall(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n callInputs = {},\n workingDirectory,\n shell,\n env,\n ifCondition,\n timeoutMs,\n }: {\n id?: string;\n name?: string;\n callInputs?: BuildFunctionCallInputs;\n workingDirectory?: string;\n shell?: string;\n env?: BuildStepEnv;\n ifCondition?: string;\n timeoutMs?: number;\n } = {}\n ): BuildStep {\n const buildStepId = BuildStep.getNewId(id);\n const buildStepName = name ?? this.name;\n const buildStepDisplayName = BuildStep.getDisplayName({\n id: buildStepId,\n command: this.command,\n name: buildStepName,\n });\n\n const inputs = this.inputProviders?.map((inputProvider) => {\n const input = inputProvider(ctx, buildStepId);\n if (input.id in callInputs) {\n input.set(callInputs[input.id]);\n }\n return input;\n });\n const outputs = this.outputProviders?.map((outputProvider) => outputProvider(ctx, buildStepId));\n\n return new BuildStep(ctx, {\n id: buildStepId,\n name: buildStepName,\n displayName: buildStepDisplayName,\n command: this.command,\n fn:\n this.fn ??\n (this.customFunctionModulePath\n ? createCustomFunctionCall(this.customFunctionModulePath)\n : undefined),\n workingDirectory,\n inputs,\n outputs,\n shell,\n supportedRuntimePlatforms: this.supportedRuntimePlatforms,\n env,\n ifCondition,\n timeoutMs,\n __metricsId: this.__metricsId,\n });\n }\n}\n"]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BuildFunctionCallInputs } from './BuildFunction.js';
|
|
2
|
-
import { BuildStep } from './BuildStep.js';
|
|
3
|
-
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
4
|
-
import { BuildStepInputById, BuildStepInputProvider } from './BuildStepInput.js';
|
|
5
|
-
export type BuildFunctionGroupById = Record<string, BuildFunctionGroup | undefined>;
|
|
6
|
-
export declare class BuildFunctionGroup {
|
|
7
|
-
readonly namespace: string;
|
|
8
|
-
readonly id: string;
|
|
9
|
-
readonly inputProviders?: BuildStepInputProvider[];
|
|
10
|
-
readonly createBuildStepsFromFunctionGroupCall: (globalCtx: BuildStepGlobalContext, options?: {
|
|
11
|
-
callInputs?: BuildFunctionCallInputs;
|
|
12
|
-
}) => BuildStep[];
|
|
13
|
-
constructor({ namespace, id, inputProviders, createBuildStepsFromFunctionGroupCall, }: {
|
|
14
|
-
namespace: string;
|
|
15
|
-
id: string;
|
|
16
|
-
inputProviders?: BuildStepInputProvider[];
|
|
17
|
-
createBuildStepsFromFunctionGroupCall: (globalCtx: BuildStepGlobalContext, { inputs, }: {
|
|
18
|
-
inputs: BuildStepInputById;
|
|
19
|
-
}) => BuildStep[];
|
|
20
|
-
});
|
|
21
|
-
getFullId(): string;
|
|
22
|
-
}
|
|
23
|
-
export declare function createBuildFunctionGroupByIdMapping(buildFunctionGroups: BuildFunctionGroup[]): BuildFunctionGroupById;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { makeBuildStepInputByIdMap, } from './BuildStepInput.js';
|
|
2
|
-
import { BuildConfigError } from './errors.js';
|
|
3
|
-
export class BuildFunctionGroup {
|
|
4
|
-
constructor({ namespace, id, inputProviders, createBuildStepsFromFunctionGroupCall, }) {
|
|
5
|
-
this.namespace = namespace;
|
|
6
|
-
this.id = id;
|
|
7
|
-
this.inputProviders = inputProviders;
|
|
8
|
-
this.createBuildStepsFromFunctionGroupCall = (ctx, { callInputs = {} } = {}) => {
|
|
9
|
-
var _a;
|
|
10
|
-
const inputs = (_a = this.inputProviders) === null || _a === void 0 ? void 0 : _a.map((inputProvider) => {
|
|
11
|
-
const input = inputProvider(ctx, id);
|
|
12
|
-
if (input.id in callInputs) {
|
|
13
|
-
input.set(callInputs[input.id]);
|
|
14
|
-
}
|
|
15
|
-
return input;
|
|
16
|
-
});
|
|
17
|
-
return createBuildStepsFromFunctionGroupCall(ctx, {
|
|
18
|
-
inputs: makeBuildStepInputByIdMap(inputs),
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
getFullId() {
|
|
23
|
-
return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export function createBuildFunctionGroupByIdMapping(buildFunctionGroups) {
|
|
27
|
-
const buildFunctionGroupById = {};
|
|
28
|
-
for (const buildFunctionGroup of buildFunctionGroups) {
|
|
29
|
-
if (buildFunctionGroupById[buildFunctionGroup.getFullId()] !== undefined) {
|
|
30
|
-
throw new BuildConfigError(`Build function group with id ${buildFunctionGroup.getFullId()} is already defined.`);
|
|
31
|
-
}
|
|
32
|
-
buildFunctionGroupById[buildFunctionGroup.getFullId()] = buildFunctionGroup;
|
|
33
|
-
}
|
|
34
|
-
return buildFunctionGroupById;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=BuildFunctionGroup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildFunctionGroup.js","sourceRoot":"","sources":["../src/BuildFunctionGroup.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;A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AAgB,CACxB,gCAAgC,kBAAkB,CAAC,SAAS,EAAE,sBAAsB,CACrF,CAAC;QACJ,CAAC;QACD,sBAAsB,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9E,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { BuildFunctionCallInputs } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\nimport {\n BuildStepInputById,\n BuildStepInputProvider,\n makeBuildStepInputByIdMap,\n} from './BuildStepInput.js';\nimport { BuildConfigError } from './errors.js';\n\nexport type BuildFunctionGroupById = Record<string, BuildFunctionGroup | undefined>;\n\nexport class BuildFunctionGroup {\n public readonly namespace: string;\n public readonly id: string;\n public readonly inputProviders?: BuildStepInputProvider[];\n public readonly createBuildStepsFromFunctionGroupCall: (\n globalCtx: BuildStepGlobalContext,\n options?: {\n callInputs?: BuildFunctionCallInputs;\n }\n ) => BuildStep[];\n\n constructor({\n namespace,\n id,\n inputProviders,\n createBuildStepsFromFunctionGroupCall,\n }: {\n namespace: string;\n id: string;\n inputProviders?: BuildStepInputProvider[];\n createBuildStepsFromFunctionGroupCall: (\n globalCtx: BuildStepGlobalContext,\n {\n inputs,\n }: {\n inputs: BuildStepInputById;\n }\n ) => BuildStep[];\n }) {\n this.namespace = namespace;\n this.id = id;\n this.inputProviders = inputProviders;\n\n this.createBuildStepsFromFunctionGroupCall = (ctx, { callInputs = {} } = {}) => {\n const inputs = this.inputProviders?.map((inputProvider) => {\n const input = inputProvider(ctx, id);\n if (input.id in callInputs) {\n input.set(callInputs[input.id]);\n }\n return input;\n });\n return createBuildStepsFromFunctionGroupCall(ctx, {\n inputs: makeBuildStepInputByIdMap(inputs),\n });\n };\n }\n\n public getFullId(): string {\n return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;\n }\n}\n\nexport function createBuildFunctionGroupByIdMapping(\n buildFunctionGroups: BuildFunctionGroup[]\n): BuildFunctionGroupById {\n const buildFunctionGroupById: BuildFunctionGroupById = {};\n for (const buildFunctionGroup of buildFunctionGroups) {\n if (buildFunctionGroupById[buildFunctionGroup.getFullId()] !== undefined) {\n throw new BuildConfigError(\n `Build function group with id ${buildFunctionGroup.getFullId()} is already defined.`\n );\n }\n buildFunctionGroupById[buildFunctionGroup.getFullId()] = buildFunctionGroup;\n }\n return buildFunctionGroupById;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildRuntimePlatform.js","sourceRoot":"","sources":["../src/BuildRuntimePlatform.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,yCAAiB,CAAA;IACjB,uCAAe,CAAA;AACjB,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","sourcesContent":["export enum BuildRuntimePlatform {\n DARWIN = 'darwin',\n LINUX = 'linux',\n}\n"]}
|
package/dist_esm/BuildStep.js
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import fs from 'fs/promises';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { Buffer } from 'buffer';
|
|
5
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
-
import { makeBuildStepInputByIdMap } from './BuildStepInput.js';
|
|
7
|
-
import { BuildStepOutput, makeBuildStepOutputByIdMap, } from './BuildStepOutput.js';
|
|
8
|
-
import { BIN_PATH } from './utils/shell/bin.js';
|
|
9
|
-
import { getShellCommandAndArgs } from './utils/shell/command.js';
|
|
10
|
-
import { cleanUpStepTemporaryDirectoriesAsync, getTemporaryEnvsDirPath, getTemporaryOutputsDirPath, saveScriptToTemporaryFileAsync, } from './BuildTemporaryFiles.js';
|
|
11
|
-
import { spawnAsync } from './utils/shell/spawn.js';
|
|
12
|
-
import { interpolateWithInputs, interpolateWithOutputs } from './utils/template.js';
|
|
13
|
-
import { BuildStepRuntimeError } from './errors.js';
|
|
14
|
-
import { jsepEval } from './utils/jsepEval.js';
|
|
15
|
-
import { interpolateJobContext } from './interpolation.js';
|
|
16
|
-
export var BuildStepStatus;
|
|
17
|
-
(function (BuildStepStatus) {
|
|
18
|
-
BuildStepStatus["NEW"] = "new";
|
|
19
|
-
BuildStepStatus["IN_PROGRESS"] = "in-progress";
|
|
20
|
-
BuildStepStatus["SKIPPED"] = "skipped";
|
|
21
|
-
BuildStepStatus["FAIL"] = "fail";
|
|
22
|
-
BuildStepStatus["WARNING"] = "warning";
|
|
23
|
-
BuildStepStatus["SUCCESS"] = "success";
|
|
24
|
-
})(BuildStepStatus || (BuildStepStatus = {}));
|
|
25
|
-
export var BuildStepLogMarker;
|
|
26
|
-
(function (BuildStepLogMarker) {
|
|
27
|
-
BuildStepLogMarker["START_STEP"] = "start-step";
|
|
28
|
-
BuildStepLogMarker["END_STEP"] = "end-step";
|
|
29
|
-
})(BuildStepLogMarker || (BuildStepLogMarker = {}));
|
|
30
|
-
// TODO: move to a place common with tests
|
|
31
|
-
const UUID_REGEX = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/;
|
|
32
|
-
export class BuildStepOutputAccessor {
|
|
33
|
-
constructor(id, displayName, executed, outputById) {
|
|
34
|
-
this.id = id;
|
|
35
|
-
this.displayName = displayName;
|
|
36
|
-
this.executed = executed;
|
|
37
|
-
this.outputById = outputById;
|
|
38
|
-
}
|
|
39
|
-
get outputs() {
|
|
40
|
-
return Object.values(this.outputById);
|
|
41
|
-
}
|
|
42
|
-
getOutputValueByName(name) {
|
|
43
|
-
if (!this.executed) {
|
|
44
|
-
throw new BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
|
|
45
|
-
}
|
|
46
|
-
if (!this.hasOutputParameter(name)) {
|
|
47
|
-
throw new BuildStepRuntimeError(`Step "${this.displayName}" does not have output "${name}".`);
|
|
48
|
-
}
|
|
49
|
-
return this.outputById[name].value;
|
|
50
|
-
}
|
|
51
|
-
hasOutputParameter(name) {
|
|
52
|
-
return name in this.outputById;
|
|
53
|
-
}
|
|
54
|
-
serialize() {
|
|
55
|
-
return {
|
|
56
|
-
id: this.id,
|
|
57
|
-
executed: this.executed,
|
|
58
|
-
outputById: Object.fromEntries(Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])),
|
|
59
|
-
displayName: this.displayName,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
static deserialize(serialized) {
|
|
63
|
-
const outputById = Object.fromEntries(Object.entries(serialized.outputById).map(([key, value]) => [
|
|
64
|
-
key,
|
|
65
|
-
BuildStepOutput.deserialize(value),
|
|
66
|
-
]));
|
|
67
|
-
return new BuildStepOutputAccessor(serialized.id, serialized.displayName, serialized.executed, outputById);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
export class BuildStep extends BuildStepOutputAccessor {
|
|
71
|
-
static getNewId(userDefinedId) {
|
|
72
|
-
return userDefinedId !== null && userDefinedId !== void 0 ? userDefinedId : uuidv4();
|
|
73
|
-
}
|
|
74
|
-
static getDisplayName({ id, name, command, }) {
|
|
75
|
-
if (name) {
|
|
76
|
-
return name;
|
|
77
|
-
}
|
|
78
|
-
if (!id.match(UUID_REGEX)) {
|
|
79
|
-
return id;
|
|
80
|
-
}
|
|
81
|
-
if (command) {
|
|
82
|
-
const splits = command.trim().split('\n');
|
|
83
|
-
for (const split of splits) {
|
|
84
|
-
const trimmed = split.trim();
|
|
85
|
-
if (trimmed && !trimmed.startsWith('#')) {
|
|
86
|
-
return trimmed;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return id;
|
|
91
|
-
}
|
|
92
|
-
constructor(ctx, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }) {
|
|
93
|
-
assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');
|
|
94
|
-
assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');
|
|
95
|
-
const outputById = makeBuildStepOutputByIdMap(outputs);
|
|
96
|
-
super(id, displayName, false, outputById);
|
|
97
|
-
this.executed = false;
|
|
98
|
-
this.id = id;
|
|
99
|
-
this.name = name;
|
|
100
|
-
this.displayName = displayName;
|
|
101
|
-
this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;
|
|
102
|
-
this.inputs = inputs;
|
|
103
|
-
this.inputById = makeBuildStepInputByIdMap(inputs);
|
|
104
|
-
this.outputById = outputById;
|
|
105
|
-
this.fn = fn;
|
|
106
|
-
this.command = command;
|
|
107
|
-
this.shell = shell !== null && shell !== void 0 ? shell : '/bin/bash -eo pipefail';
|
|
108
|
-
this.ifCondition = ifCondition;
|
|
109
|
-
this.timeoutMs = timeoutMs;
|
|
110
|
-
this.__metricsId = __metricsId;
|
|
111
|
-
this.status = BuildStepStatus.NEW;
|
|
112
|
-
this.internalId = uuidv4();
|
|
113
|
-
const logger = ctx.baseLogger.child({
|
|
114
|
-
buildStepInternalId: this.internalId,
|
|
115
|
-
buildStepId: this.id,
|
|
116
|
-
buildStepDisplayName: this.displayName,
|
|
117
|
-
});
|
|
118
|
-
this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });
|
|
119
|
-
this.stepEnvOverrides = env !== null && env !== void 0 ? env : {};
|
|
120
|
-
this.outputsDir = getTemporaryOutputsDirPath(ctx, this.id);
|
|
121
|
-
this.envsDir = getTemporaryEnvsDirPath(ctx, this.id);
|
|
122
|
-
ctx.registerStep(this);
|
|
123
|
-
}
|
|
124
|
-
async executeAsync() {
|
|
125
|
-
try {
|
|
126
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.START_STEP }, `Executing build step "${this.displayName}"`);
|
|
127
|
-
this.status = BuildStepStatus.IN_PROGRESS;
|
|
128
|
-
await fs.mkdir(this.outputsDir, { recursive: true });
|
|
129
|
-
this.ctx.logger.debug(`Created temporary directory for step outputs: ${this.outputsDir}`);
|
|
130
|
-
await fs.mkdir(this.envsDir, { recursive: true });
|
|
131
|
-
this.ctx.logger.debug(`Created temporary directory for step environment variables: ${this.envsDir}`);
|
|
132
|
-
if (this.timeoutMs !== undefined) {
|
|
133
|
-
const abortController = new AbortController();
|
|
134
|
-
let timeoutId;
|
|
135
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
136
|
-
timeoutId = setTimeout(() => {
|
|
137
|
-
// Reject with timeout error FIRST, before killing the process
|
|
138
|
-
// This ensures the timeout error wins the race
|
|
139
|
-
reject(new BuildStepRuntimeError(`Build step "${this.displayName}" timed out after ${this.timeoutMs}ms`));
|
|
140
|
-
abortController.abort();
|
|
141
|
-
}, this.timeoutMs);
|
|
142
|
-
});
|
|
143
|
-
try {
|
|
144
|
-
await Promise.race([
|
|
145
|
-
this.command !== undefined
|
|
146
|
-
? this.executeCommandAsync({ signal: abortController.signal })
|
|
147
|
-
: this.executeFnAsync({ signal: abortController.signal }),
|
|
148
|
-
timeoutPromise,
|
|
149
|
-
]);
|
|
150
|
-
}
|
|
151
|
-
finally {
|
|
152
|
-
if (timeoutId) {
|
|
153
|
-
clearTimeout(timeoutId);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
const executionPromise = this.command !== undefined
|
|
159
|
-
? this.executeCommandAsync({ signal: null })
|
|
160
|
-
: this.executeFnAsync({ signal: null });
|
|
161
|
-
await executionPromise;
|
|
162
|
-
}
|
|
163
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS }, `Finished build step "${this.displayName}" successfully`);
|
|
164
|
-
this.status = BuildStepStatus.SUCCESS;
|
|
165
|
-
}
|
|
166
|
-
catch (err) {
|
|
167
|
-
this.ctx.logger.error({ err });
|
|
168
|
-
this.ctx.logger.error({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL }, `Build step "${this.displayName}" failed`);
|
|
169
|
-
this.status = BuildStepStatus.FAIL;
|
|
170
|
-
throw err;
|
|
171
|
-
}
|
|
172
|
-
finally {
|
|
173
|
-
this.executed = true;
|
|
174
|
-
try {
|
|
175
|
-
await this.collectAndValidateOutputsAsync(this.outputsDir);
|
|
176
|
-
await this.collectAndUpdateEnvsAsync(this.envsDir);
|
|
177
|
-
this.ctx.logger.debug('Finished collecting output parameters');
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
// If the step succeeded, we expect the outputs to be collected successfully.
|
|
181
|
-
if (this.status === BuildStepStatus.SUCCESS) {
|
|
182
|
-
throw error;
|
|
183
|
-
}
|
|
184
|
-
this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');
|
|
185
|
-
}
|
|
186
|
-
await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
canBeRunOnRuntimePlatform() {
|
|
190
|
-
return (!this.supportedRuntimePlatforms ||
|
|
191
|
-
this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform));
|
|
192
|
-
}
|
|
193
|
-
shouldExecuteStep() {
|
|
194
|
-
var _a, _b;
|
|
195
|
-
const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;
|
|
196
|
-
if (!this.ifCondition) {
|
|
197
|
-
return !hasAnyPreviousStepFailed;
|
|
198
|
-
}
|
|
199
|
-
let ifCondition = this.ifCondition;
|
|
200
|
-
if (ifCondition.startsWith('${{') && ifCondition.endsWith('}}')) {
|
|
201
|
-
ifCondition = ifCondition.slice(3, -2);
|
|
202
|
-
}
|
|
203
|
-
else if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {
|
|
204
|
-
ifCondition = ifCondition.slice(2, -1);
|
|
205
|
-
}
|
|
206
|
-
return Boolean(jsepEval(ifCondition, {
|
|
207
|
-
inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
|
|
208
|
-
acc[input.id] = input.getValue({
|
|
209
|
-
interpolationContext: this.getInterpolationContext(),
|
|
210
|
-
});
|
|
211
|
-
return acc;
|
|
212
|
-
}, {})) !== null && _b !== void 0 ? _b : {},
|
|
213
|
-
eas: {
|
|
214
|
-
runtimePlatform: this.ctx.global.runtimePlatform,
|
|
215
|
-
...this.ctx.global.staticContext,
|
|
216
|
-
env: this.getScriptEnv(),
|
|
217
|
-
},
|
|
218
|
-
...this.getInterpolationContext(),
|
|
219
|
-
}));
|
|
220
|
-
}
|
|
221
|
-
skip() {
|
|
222
|
-
this.status = BuildStepStatus.SKIPPED;
|
|
223
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.START_STEP }, 'Executing build step "${this.displayName}"');
|
|
224
|
-
this.ctx.logger.info(`Skipped build step "${this.displayName}"`);
|
|
225
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED }, `Skipped build step "${this.displayName}"`);
|
|
226
|
-
}
|
|
227
|
-
getInterpolationContext() {
|
|
228
|
-
return {
|
|
229
|
-
...this.ctx.global.getInterpolationContext(),
|
|
230
|
-
env: this.getScriptEnv(),
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
async executeCommandAsync({ signal }) {
|
|
234
|
-
assert(this.command, 'Command must be defined.');
|
|
235
|
-
const interpolatedCommand = interpolateJobContext({
|
|
236
|
-
target: this.command,
|
|
237
|
-
context: this.getInterpolationContext(),
|
|
238
|
-
});
|
|
239
|
-
const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(`${interpolatedCommand}`, this.inputs);
|
|
240
|
-
this.ctx.logger.debug(`Interpolated inputs in the command template`);
|
|
241
|
-
const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);
|
|
242
|
-
this.ctx.logger.debug(`Saved script to ${scriptPath}`);
|
|
243
|
-
const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);
|
|
244
|
-
this.ctx.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
|
|
245
|
-
try {
|
|
246
|
-
const workingDirectoryStat = await fs.stat(this.ctx.workingDirectory);
|
|
247
|
-
if (!workingDirectoryStat.isDirectory()) {
|
|
248
|
-
this.ctx.logger.error(`Working directory "${this.ctx.workingDirectory}" exists, but is not a directory`);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
catch (err) {
|
|
252
|
-
if ((err === null || err === void 0 ? void 0 : err.code) === 'ENOENT') {
|
|
253
|
-
this.ctx.logger.error({ err }, `Working directory "${this.ctx.workingDirectory}" does not exist`);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
this.ctx.logger.error({ err }, `Cannot access working directory "${this.ctx.workingDirectory}"`);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
await spawnAsync(shellCommand, args !== null && args !== void 0 ? args : [], {
|
|
260
|
-
cwd: this.ctx.workingDirectory,
|
|
261
|
-
logger: this.ctx.logger,
|
|
262
|
-
env: this.getScriptEnv(),
|
|
263
|
-
// stdin is /dev/null, std{out,err} are piped into logger.
|
|
264
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
265
|
-
signal: signal !== null && signal !== void 0 ? signal : undefined,
|
|
266
|
-
});
|
|
267
|
-
this.ctx.logger.debug(`Script completed successfully`);
|
|
268
|
-
}
|
|
269
|
-
async executeFnAsync({ signal }) {
|
|
270
|
-
assert(this.fn, 'Function (fn) must be defined');
|
|
271
|
-
await this.fn(this.ctx, {
|
|
272
|
-
inputs: Object.fromEntries(Object.entries(this.inputById).map(([key, input]) => [
|
|
273
|
-
key,
|
|
274
|
-
{ value: input.getValue({ interpolationContext: this.getInterpolationContext() }) },
|
|
275
|
-
])),
|
|
276
|
-
outputs: this.outputById,
|
|
277
|
-
env: this.getScriptEnv(),
|
|
278
|
-
signal: signal !== null && signal !== void 0 ? signal : undefined,
|
|
279
|
-
});
|
|
280
|
-
this.ctx.logger.debug(`Script completed successfully`);
|
|
281
|
-
}
|
|
282
|
-
interpolateInputsOutputsAndGlobalContextInTemplate(template, inputs) {
|
|
283
|
-
if (!inputs) {
|
|
284
|
-
return interpolateWithOutputs(this.ctx.global.interpolate(template), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
285
|
-
}
|
|
286
|
-
const vars = inputs.reduce((acc, input) => {
|
|
287
|
-
var _a;
|
|
288
|
-
const value = input.getValue({ interpolationContext: this.getInterpolationContext() });
|
|
289
|
-
acc[input.id] = typeof value === 'object' ? JSON.stringify(value) : (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '';
|
|
290
|
-
return acc;
|
|
291
|
-
}, {});
|
|
292
|
-
return interpolateWithOutputs(interpolateWithInputs(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
293
|
-
}
|
|
294
|
-
async collectAndValidateOutputsAsync(outputsDir) {
|
|
295
|
-
const files = await fs.readdir(outputsDir);
|
|
296
|
-
for (const outputId of files) {
|
|
297
|
-
if (!(outputId in this.outputById)) {
|
|
298
|
-
const newOutput = new BuildStepOutput(this.ctx.global, {
|
|
299
|
-
id: outputId,
|
|
300
|
-
stepDisplayName: this.displayName,
|
|
301
|
-
required: false,
|
|
302
|
-
});
|
|
303
|
-
this.outputById[outputId] = newOutput;
|
|
304
|
-
}
|
|
305
|
-
const file = path.join(outputsDir, outputId);
|
|
306
|
-
const rawContents = await fs.readFile(file, 'utf-8');
|
|
307
|
-
const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');
|
|
308
|
-
this.outputById[outputId].set(decodedContents);
|
|
309
|
-
}
|
|
310
|
-
const nonSetRequiredOutputIds = [];
|
|
311
|
-
for (const output of Object.values(this.outputById)) {
|
|
312
|
-
try {
|
|
313
|
-
const value = output.value;
|
|
314
|
-
this.ctx.logger.debug(`Output parameter "${output.id}" is set to "${value}"`);
|
|
315
|
-
}
|
|
316
|
-
catch (err) {
|
|
317
|
-
this.ctx.logger.debug({ err }, `Getting value for output parameter "${output.id}" failed.`);
|
|
318
|
-
nonSetRequiredOutputIds.push(output.id);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
if (nonSetRequiredOutputIds.length > 0) {
|
|
322
|
-
const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
|
|
323
|
-
throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {
|
|
324
|
-
metadata: { ids: nonSetRequiredOutputIds },
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
async collectAndUpdateEnvsAsync(envsDir) {
|
|
329
|
-
const filenames = await fs.readdir(envsDir);
|
|
330
|
-
const entries = await Promise.all(filenames.map(async (basename) => {
|
|
331
|
-
const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');
|
|
332
|
-
const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');
|
|
333
|
-
return [basename, decodedContents];
|
|
334
|
-
}));
|
|
335
|
-
this.ctx.global.updateEnv({
|
|
336
|
-
...this.ctx.global.env,
|
|
337
|
-
...Object.fromEntries(entries),
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
getScriptEnv() {
|
|
341
|
-
var _a;
|
|
342
|
-
const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };
|
|
343
|
-
const currentPath = (_a = effectiveEnv.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
|
|
344
|
-
const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;
|
|
345
|
-
return {
|
|
346
|
-
...effectiveEnv,
|
|
347
|
-
__EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,
|
|
348
|
-
__EXPO_STEPS_ENVS_DIR: this.envsDir,
|
|
349
|
-
__EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,
|
|
350
|
-
PATH: newPath,
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
//# sourceMappingURL=BuildStep.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAIpC,OAAO,EAAsC,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EACL,eAAe,EAGf,0BAA0B,GAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,0BAA0B,EAC1B,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CA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Ae,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC7E,OAAO,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACrC,CAAC,CAAC,CACH,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;YACxB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG;YACtB,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAEO,YAAY;;QAClB,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1E,MAAM,WAAW,GAAG,MAAA,YAAY,CAAC,IAAI,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QAC1D,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QACtE,OAAO;YACL,GAAG,YAAY;YACf,wBAAwB,EAAE,IAAI,CAAC,UAAU;YACzC,qBAAqB,EAAE,IAAI,CAAC,OAAO;YACnC,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\nimport { Buffer } from 'buffer';\n\nimport { v4 as uuidv4 } from 'uuid';\nimport { JobInterpolationContext } from '@expo/eas-build-job';\n\nimport { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput.js';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n getTemporaryEnvsDirPath,\n getTemporaryOutputsDirPath,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport { interpolateWithInputs, interpolateWithOutputs } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { jsepEval } from './utils/jsepEval.js';\nimport { interpolateJobContext } from './interpolation.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n SKIPPED = 'skipped',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport type BuildStepFunction = (\n ctx: BuildStepContext,\n {\n inputs,\n outputs,\n env,\n }: {\n inputs: { [key: string]: { value: unknown } };\n outputs: BuildStepOutputById;\n env: BuildStepEnv;\n signal?: AbortSignal;\n }\n) => unknown;\n\n// TODO: move to a place common with tests\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/;\n\nexport interface SerializedBuildStepOutputAccessor {\n id: string;\n executed: boolean;\n outputById: Record<string, SerializedBuildStepOutput>;\n displayName: string;\n}\n\nexport class BuildStepOutputAccessor {\n constructor(\n public readonly id: string,\n public readonly displayName: string,\n protected readonly executed: boolean,\n protected readonly outputById: BuildStepOutputById\n ) {}\n\n public get outputs(): BuildStepOutput[] {\n return Object.values(this.outputById);\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public serialize(): SerializedBuildStepOutputAccessor {\n return {\n id: this.id,\n executed: this.executed,\n outputById: Object.fromEntries(\n Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])\n ),\n displayName: this.displayName,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepOutputAccessor\n ): BuildStepOutputAccessor {\n const outputById = Object.fromEntries(\n Object.entries(serialized.outputById).map(([key, value]) => [\n key,\n BuildStepOutput.deserialize(value),\n ])\n );\n return new BuildStepOutputAccessor(\n serialized.id,\n serialized.displayName,\n serialized.executed,\n outputById\n );\n }\n}\n\nexport class BuildStep extends BuildStepOutputAccessor {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputs?: BuildStepInput[];\n public readonly outputById: BuildStepOutputById;\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell: string;\n public readonly ctx: BuildStepContext;\n public readonly stepEnvOverrides: BuildStepEnv;\n public readonly ifCondition?: string;\n public readonly timeoutMs?: number;\n public readonly __metricsId?: string;\n public status: BuildStepStatus;\n private readonly outputsDir: string;\n private readonly envsDir: string;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected executed = false;\n\n public static getNewId(userDefinedId?: string): string {\n return userDefinedId ?? uuidv4();\n }\n\n public static getDisplayName({\n id,\n name,\n command,\n }: {\n id: string;\n name?: string;\n command?: string;\n }): string {\n if (name) {\n return name;\n }\n if (!id.match(UUID_REGEX)) {\n return id;\n }\n if (command) {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return id;\n }\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n displayName,\n inputs,\n outputs,\n command,\n fn,\n workingDirectory: maybeWorkingDirectory,\n shell,\n supportedRuntimePlatforms: maybeSupportedRuntimePlatforms,\n env,\n ifCondition,\n timeoutMs,\n __metricsId,\n }: {\n id: string;\n name?: string;\n displayName: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command?: string;\n fn?: BuildStepFunction;\n workingDirectory?: string;\n shell?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n env?: BuildStepEnv;\n ifCondition?: string;\n timeoutMs?: number;\n __metricsId?: string;\n }\n ) {\n assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n const outputById = makeBuildStepOutputByIdMap(outputs);\n super(id, displayName, false, outputById);\n\n this.id = id;\n this.name = name;\n this.displayName = displayName;\n this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;\n this.inputs = inputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? '/bin/bash -eo pipefail';\n this.ifCondition = ifCondition;\n this.timeoutMs = timeoutMs;\n this.__metricsId = __metricsId;\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n\n const logger = ctx.baseLogger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });\n this.stepEnvOverrides = env ?? {};\n\n this.outputsDir = getTemporaryOutputsDirPath(ctx, this.id);\n this.envsDir = getTemporaryEnvsDirPath(ctx, this.id);\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.displayName}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n await fs.mkdir(this.outputsDir, { recursive: true });\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${this.outputsDir}`);\n\n await fs.mkdir(this.envsDir, { recursive: true });\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${this.envsDir}`\n );\n\n if (this.timeoutMs !== undefined) {\n const abortController = new AbortController();\n\n let timeoutId: NodeJS.Timeout | undefined;\n const timeoutPromise = new Promise<void>((_, reject) => {\n timeoutId = setTimeout(() => {\n // Reject with timeout error FIRST, before killing the process\n // This ensures the timeout error wins the race\n reject(\n new BuildStepRuntimeError(\n `Build step \"${this.displayName}\" timed out after ${this.timeoutMs}ms`\n )\n );\n\n abortController.abort();\n }, this.timeoutMs);\n });\n\n try {\n await Promise.race([\n this.command !== undefined\n ? this.executeCommandAsync({ signal: abortController.signal })\n : this.executeFnAsync({ signal: abortController.signal }),\n timeoutPromise,\n ]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n } else {\n const executionPromise =\n this.command !== undefined\n ? this.executeCommandAsync({ signal: null })\n : this.executeFnAsync({ signal: null });\n await executionPromise;\n }\n\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.displayName}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.ctx.logger.error({ err });\n this.ctx.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.displayName}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n\n try {\n await this.collectAndValidateOutputsAsync(this.outputsDir);\n await this.collectAndUpdateEnvsAsync(this.envsDir);\n this.ctx.logger.debug('Finished collecting output parameters');\n } catch (error) {\n // If the step succeeded, we expect the outputs to be collected successfully.\n if (this.status === BuildStepStatus.SUCCESS) {\n throw error;\n }\n\n this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');\n }\n\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n public canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(): boolean {\n const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;\n\n if (!this.ifCondition) {\n return !hasAnyPreviousStepFailed;\n }\n\n let ifCondition = this.ifCondition;\n\n if (ifCondition.startsWith('${{') && ifCondition.endsWith('}}')) {\n ifCondition = ifCondition.slice(3, -2);\n } else if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {\n ifCondition = ifCondition.slice(2, -1);\n }\n\n return Boolean(\n jsepEval(ifCondition, {\n inputs:\n this.inputs?.reduce(\n (acc, input) => {\n acc[input.id] = input.getValue({\n interpolationContext: this.getInterpolationContext(),\n });\n return acc;\n },\n {} as Record<string, unknown>\n ) ?? {},\n eas: {\n runtimePlatform: this.ctx.global.runtimePlatform,\n ...this.ctx.global.staticContext,\n env: this.getScriptEnv(),\n },\n ...this.getInterpolationContext(),\n })\n );\n }\n\n public skip(): void {\n this.status = BuildStepStatus.SKIPPED;\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n 'Executing build step \"${this.displayName}\"'\n );\n this.ctx.logger.info(`Skipped build step \"${this.displayName}\"`);\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED },\n `Skipped build step \"${this.displayName}\"`\n );\n }\n\n private getInterpolationContext(): JobInterpolationContext {\n return {\n ...this.ctx.global.getInterpolationContext(),\n env: this.getScriptEnv(),\n };\n }\n\n private async executeCommandAsync({ signal }: { signal: AbortSignal | null }): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n const interpolatedCommand = interpolateJobContext({\n target: this.command,\n context: this.getInterpolationContext(),\n });\n\n const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(\n `${interpolatedCommand}`,\n this.inputs\n );\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);\n this.ctx.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.ctx.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n\n try {\n const workingDirectoryStat = await fs.stat(this.ctx.workingDirectory);\n if (!workingDirectoryStat.isDirectory()) {\n this.ctx.logger.error(\n `Working directory \"${this.ctx.workingDirectory}\" exists, but is not a directory`\n );\n }\n } catch (err: any) {\n if (err?.code === 'ENOENT') {\n this.ctx.logger.error(\n { err },\n `Working directory \"${this.ctx.workingDirectory}\" does not exist`\n );\n } else {\n this.ctx.logger.error(\n { err },\n `Cannot access working directory \"${this.ctx.workingDirectory}\"`\n );\n }\n }\n\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv(),\n // stdin is /dev/null, std{out,err} are piped into logger.\n stdio: ['ignore', 'pipe', 'pipe'],\n signal: signal ?? undefined,\n });\n this.ctx.logger.debug(`Script completed successfully`);\n }\n\n private async executeFnAsync({ signal }: { signal: AbortSignal | null }): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n await this.fn(this.ctx, {\n inputs: Object.fromEntries(\n Object.entries(this.inputById).map(([key, input]) => [\n key,\n { value: input.getValue({ interpolationContext: this.getInterpolationContext() }) },\n ])\n ),\n outputs: this.outputById,\n env: this.getScriptEnv(),\n signal: signal ?? undefined,\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n }\n\n private interpolateInputsOutputsAndGlobalContextInTemplate(\n template: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return interpolateWithOutputs(\n this.ctx.global.interpolate(template),\n (path) => this.ctx.global.getStepOutputValue(path) ?? ''\n );\n }\n const vars = inputs.reduce(\n (acc, input) => {\n const value = input.getValue({ interpolationContext: this.getInterpolationContext() });\n acc[input.id] = typeof value === 'object' ? JSON.stringify(value) : value?.toString() ?? '';\n return acc;\n },\n {} as Record<string, string>\n );\n return interpolateWithOutputs(\n interpolateWithInputs(this.ctx.global.interpolate(template), vars),\n (path) => this.ctx.global.getStepOutputValue(path) ?? ''\n );\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n const newOutput = new BuildStepOutput(this.ctx.global, {\n id: outputId,\n stepDisplayName: this.displayName,\n required: false,\n });\n this.outputById[outputId] = newOutput;\n }\n\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');\n this.outputById[outputId].set(decodedContents);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of Object.values(this.outputById)) {\n try {\n const value = output.value;\n this.ctx.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.ctx.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {\n metadata: { ids: nonSetRequiredOutputIds },\n });\n }\n }\n\n private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> {\n const filenames = await fs.readdir(envsDir);\n\n const entries = await Promise.all(\n filenames.map(async (basename) => {\n const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');\n const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');\n return [basename, decodedContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private getScriptEnv(): Record<string, string> {\n const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };\n const currentPath = effectiveEnv.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...effectiveEnv,\n __EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,\n __EXPO_STEPS_ENVS_DIR: this.envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
|