@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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuildFunctionGroup = void 0;
|
|
4
4
|
exports.createBuildFunctionGroupByIdMapping = createBuildFunctionGroupByIdMapping;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const BuildStepInput_1 = require("./BuildStepInput");
|
|
6
|
+
const errors_1 = require("./errors");
|
|
7
7
|
class BuildFunctionGroup {
|
|
8
8
|
constructor({ namespace, id, inputProviders, createBuildStepsFromFunctionGroupCall, }) {
|
|
9
9
|
this.namespace = namespace;
|
|
@@ -19,7 +19,7 @@ class BuildFunctionGroup {
|
|
|
19
19
|
return input;
|
|
20
20
|
});
|
|
21
21
|
return createBuildStepsFromFunctionGroupCall(ctx, {
|
|
22
|
-
inputs: (0,
|
|
22
|
+
inputs: (0, BuildStepInput_1.makeBuildStepInputByIdMap)(inputs),
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
}
|
|
@@ -32,7 +32,7 @@ function createBuildFunctionGroupByIdMapping(buildFunctionGroups) {
|
|
|
32
32
|
const buildFunctionGroupById = {};
|
|
33
33
|
for (const buildFunctionGroup of buildFunctionGroups) {
|
|
34
34
|
if (buildFunctionGroupById[buildFunctionGroup.getFullId()] !== undefined) {
|
|
35
|
-
throw new
|
|
35
|
+
throw new errors_1.BuildConfigError(`Build function group with id ${buildFunctionGroup.getFullId()} is already defined.`);
|
|
36
36
|
}
|
|
37
37
|
buildFunctionGroupById[buildFunctionGroup.getFullId()] = buildFunctionGroup;
|
|
38
38
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildFunctionGroup.js","sourceRoot":"","sources":["../src/BuildFunctionGroup.ts"],"names":[],"mappings":";;;AAgEA,kFAaC;AA1ED,qDAI0B;AAC1B,qCAA4C;AAI5C,MAAa,kBAAkB;IAW7B,YAAY,EACV,SAAS,EACT,EAAE,EACF,cAAc,EACd,qCAAqC,GAatC;QACC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,qCAAqC,GAAG,CAAC,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;;YAC7E,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,cAAc,0CAAE,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE;gBACxD,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBACrC,IAAI,KAAK,CAAC,EAAE,IAAI,UAAU,EAAE,CAAC;oBAC3B,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;YACH,OAAO,qCAAqC,CAAC,GAAG,EAAE;gBAChD,MAAM,EAAE,IAAA,0CAAyB,EAAC,MAAM,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;IACjF,CAAC;CACF;AAlDD,gDAkDC;AAED,SAAgB,mCAAmC,CACjD,mBAAyC;IAEzC,MAAM,sBAAsB,GAA2B,EAAE,CAAC;IAC1D,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,IAAI,sBAAsB,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;YACzE,MAAM,IAAI,yBAAgB,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';\nimport { BuildStep } from './BuildStep';\nimport { BuildStepGlobalContext } from './BuildStepContext';\nimport {\n BuildStepInputById,\n BuildStepInputProvider,\n makeBuildStepInputByIdMap,\n} from './BuildStepInput';\nimport { BuildConfigError } from './errors';\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,8 +1,8 @@
|
|
|
1
|
-
import { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext
|
|
2
|
-
import { BuildStepInput } from './BuildStepInput
|
|
3
|
-
import { BuildStepOutput, BuildStepOutputById, SerializedBuildStepOutput } from './BuildStepOutput
|
|
4
|
-
import { BuildStepEnv } from './BuildStepEnv
|
|
5
|
-
import { BuildRuntimePlatform } from './BuildRuntimePlatform
|
|
1
|
+
import { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext';
|
|
2
|
+
import { BuildStepInput } from './BuildStepInput';
|
|
3
|
+
import { BuildStepOutput, BuildStepOutputById, SerializedBuildStepOutput } from './BuildStepOutput';
|
|
4
|
+
import { BuildStepEnv } from './BuildStepEnv';
|
|
5
|
+
import { BuildRuntimePlatform } from './BuildRuntimePlatform';
|
|
6
6
|
export declare enum BuildStepStatus {
|
|
7
7
|
NEW = "new",
|
|
8
8
|
IN_PROGRESS = "in-progress",
|
|
@@ -9,16 +9,16 @@ const promises_1 = __importDefault(require("fs/promises"));
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const buffer_1 = require("buffer");
|
|
11
11
|
const uuid_1 = require("uuid");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
12
|
+
const BuildStepInput_1 = require("./BuildStepInput");
|
|
13
|
+
const BuildStepOutput_1 = require("./BuildStepOutput");
|
|
14
|
+
const bin_1 = require("./utils/shell/bin");
|
|
15
|
+
const command_1 = require("./utils/shell/command");
|
|
16
|
+
const BuildTemporaryFiles_1 = require("./BuildTemporaryFiles");
|
|
17
|
+
const spawn_1 = require("./utils/shell/spawn");
|
|
18
|
+
const template_1 = require("./utils/template");
|
|
19
|
+
const errors_1 = require("./errors");
|
|
20
|
+
const jsepEval_1 = require("./utils/jsepEval");
|
|
21
|
+
const interpolation_1 = require("./interpolation");
|
|
22
22
|
var BuildStepStatus;
|
|
23
23
|
(function (BuildStepStatus) {
|
|
24
24
|
BuildStepStatus["NEW"] = "new";
|
|
@@ -47,10 +47,10 @@ class BuildStepOutputAccessor {
|
|
|
47
47
|
}
|
|
48
48
|
getOutputValueByName(name) {
|
|
49
49
|
if (!this.executed) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new errors_1.BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
|
|
51
51
|
}
|
|
52
52
|
if (!this.hasOutputParameter(name)) {
|
|
53
|
-
throw new
|
|
53
|
+
throw new errors_1.BuildStepRuntimeError(`Step "${this.displayName}" does not have output "${name}".`);
|
|
54
54
|
}
|
|
55
55
|
return this.outputById[name].value;
|
|
56
56
|
}
|
|
@@ -68,7 +68,7 @@ class BuildStepOutputAccessor {
|
|
|
68
68
|
static deserialize(serialized) {
|
|
69
69
|
const outputById = Object.fromEntries(Object.entries(serialized.outputById).map(([key, value]) => [
|
|
70
70
|
key,
|
|
71
|
-
|
|
71
|
+
BuildStepOutput_1.BuildStepOutput.deserialize(value),
|
|
72
72
|
]));
|
|
73
73
|
return new BuildStepOutputAccessor(serialized.id, serialized.displayName, serialized.executed, outputById);
|
|
74
74
|
}
|
|
@@ -99,7 +99,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
99
99
|
constructor(ctx, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }) {
|
|
100
100
|
(0, assert_1.default)(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');
|
|
101
101
|
(0, assert_1.default)(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');
|
|
102
|
-
const outputById = (0,
|
|
102
|
+
const outputById = (0, BuildStepOutput_1.makeBuildStepOutputByIdMap)(outputs);
|
|
103
103
|
super(id, displayName, false, outputById);
|
|
104
104
|
this.executed = false;
|
|
105
105
|
this.id = id;
|
|
@@ -107,7 +107,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
107
107
|
this.displayName = displayName;
|
|
108
108
|
this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;
|
|
109
109
|
this.inputs = inputs;
|
|
110
|
-
this.inputById = (0,
|
|
110
|
+
this.inputById = (0, BuildStepInput_1.makeBuildStepInputByIdMap)(inputs);
|
|
111
111
|
this.outputById = outputById;
|
|
112
112
|
this.fn = fn;
|
|
113
113
|
this.command = command;
|
|
@@ -124,8 +124,8 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
124
124
|
});
|
|
125
125
|
this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });
|
|
126
126
|
this.stepEnvOverrides = env !== null && env !== void 0 ? env : {};
|
|
127
|
-
this.outputsDir = (0,
|
|
128
|
-
this.envsDir = (0,
|
|
127
|
+
this.outputsDir = (0, BuildTemporaryFiles_1.getTemporaryOutputsDirPath)(ctx, this.id);
|
|
128
|
+
this.envsDir = (0, BuildTemporaryFiles_1.getTemporaryEnvsDirPath)(ctx, this.id);
|
|
129
129
|
ctx.registerStep(this);
|
|
130
130
|
}
|
|
131
131
|
async executeAsync() {
|
|
@@ -143,7 +143,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
143
143
|
timeoutId = setTimeout(() => {
|
|
144
144
|
// Reject with timeout error FIRST, before killing the process
|
|
145
145
|
// This ensures the timeout error wins the race
|
|
146
|
-
reject(new
|
|
146
|
+
reject(new errors_1.BuildStepRuntimeError(`Build step "${this.displayName}" timed out after ${this.timeoutMs}ms`));
|
|
147
147
|
abortController.abort();
|
|
148
148
|
}, this.timeoutMs);
|
|
149
149
|
});
|
|
@@ -190,7 +190,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
190
190
|
}
|
|
191
191
|
this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');
|
|
192
192
|
}
|
|
193
|
-
await (0,
|
|
193
|
+
await (0, BuildTemporaryFiles_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx.global, this.id);
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
canBeRunOnRuntimePlatform() {
|
|
@@ -210,7 +210,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
210
210
|
else if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {
|
|
211
211
|
ifCondition = ifCondition.slice(2, -1);
|
|
212
212
|
}
|
|
213
|
-
return Boolean((0,
|
|
213
|
+
return Boolean((0, jsepEval_1.jsepEval)(ifCondition, {
|
|
214
214
|
inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
|
|
215
215
|
acc[input.id] = input.getValue({
|
|
216
216
|
interpolationContext: this.getInterpolationContext(),
|
|
@@ -239,15 +239,15 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
239
239
|
}
|
|
240
240
|
async executeCommandAsync({ signal }) {
|
|
241
241
|
(0, assert_1.default)(this.command, 'Command must be defined.');
|
|
242
|
-
const interpolatedCommand = (0,
|
|
242
|
+
const interpolatedCommand = (0, interpolation_1.interpolateJobContext)({
|
|
243
243
|
target: this.command,
|
|
244
244
|
context: this.getInterpolationContext(),
|
|
245
245
|
});
|
|
246
246
|
const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(`${interpolatedCommand}`, this.inputs);
|
|
247
247
|
this.ctx.logger.debug(`Interpolated inputs in the command template`);
|
|
248
|
-
const scriptPath = await (0,
|
|
248
|
+
const scriptPath = await (0, BuildTemporaryFiles_1.saveScriptToTemporaryFileAsync)(this.ctx.global, this.id, command);
|
|
249
249
|
this.ctx.logger.debug(`Saved script to ${scriptPath}`);
|
|
250
|
-
const { command: shellCommand, args } = (0,
|
|
250
|
+
const { command: shellCommand, args } = (0, command_1.getShellCommandAndArgs)(this.shell, scriptPath);
|
|
251
251
|
this.ctx.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
|
|
252
252
|
try {
|
|
253
253
|
const workingDirectoryStat = await promises_1.default.stat(this.ctx.workingDirectory);
|
|
@@ -263,7 +263,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
263
263
|
this.ctx.logger.error({ err }, `Cannot access working directory "${this.ctx.workingDirectory}"`);
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
await (0,
|
|
266
|
+
await (0, spawn_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
|
|
267
267
|
cwd: this.ctx.workingDirectory,
|
|
268
268
|
logger: this.ctx.logger,
|
|
269
269
|
env: this.getScriptEnv(),
|
|
@@ -288,7 +288,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
288
288
|
}
|
|
289
289
|
interpolateInputsOutputsAndGlobalContextInTemplate(template, inputs) {
|
|
290
290
|
if (!inputs) {
|
|
291
|
-
return (0,
|
|
291
|
+
return (0, template_1.interpolateWithOutputs)(this.ctx.global.interpolate(template), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
292
292
|
}
|
|
293
293
|
const vars = inputs.reduce((acc, input) => {
|
|
294
294
|
var _a;
|
|
@@ -296,13 +296,13 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
296
296
|
acc[input.id] = typeof value === 'object' ? JSON.stringify(value) : (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '';
|
|
297
297
|
return acc;
|
|
298
298
|
}, {});
|
|
299
|
-
return (0,
|
|
299
|
+
return (0, template_1.interpolateWithOutputs)((0, template_1.interpolateWithInputs)(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
300
300
|
}
|
|
301
301
|
async collectAndValidateOutputsAsync(outputsDir) {
|
|
302
302
|
const files = await promises_1.default.readdir(outputsDir);
|
|
303
303
|
for (const outputId of files) {
|
|
304
304
|
if (!(outputId in this.outputById)) {
|
|
305
|
-
const newOutput = new
|
|
305
|
+
const newOutput = new BuildStepOutput_1.BuildStepOutput(this.ctx.global, {
|
|
306
306
|
id: outputId,
|
|
307
307
|
stepDisplayName: this.displayName,
|
|
308
308
|
required: false,
|
|
@@ -327,7 +327,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
327
327
|
}
|
|
328
328
|
if (nonSetRequiredOutputIds.length > 0) {
|
|
329
329
|
const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
|
|
330
|
-
throw new
|
|
330
|
+
throw new errors_1.BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {
|
|
331
331
|
metadata: { ids: nonSetRequiredOutputIds },
|
|
332
332
|
});
|
|
333
333
|
}
|
|
@@ -348,7 +348,7 @@ class BuildStep extends BuildStepOutputAccessor {
|
|
|
348
348
|
var _a;
|
|
349
349
|
const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };
|
|
350
350
|
const currentPath = (_a = effectiveEnv.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
|
|
351
|
-
const newPath = currentPath ? `${
|
|
351
|
+
const newPath = currentPath ? `${bin_1.BIN_PATH}:${currentPath}` : bin_1.BIN_PATH;
|
|
352
352
|
return {
|
|
353
353
|
...effectiveEnv,
|
|
354
354
|
__EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AACxB,mCAAgC;AAEhC,+BAAoC;AAIpC,qDAAiG;AACjG,uDAK2B;AAC3B,2CAA6C;AAC7C,mDAA+D;AAC/D,+DAK+B;AAC/B,+CAAiD;AACjD,+CAAiF;AACjF,qCAAiD;AAGjD,+CAA4C;AAC5C,mDAAwD;AAExD,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAgBD,0CAA0C;AAC1C,MAAM,UAAU,GACd,uFAAuF,CAAC;AAS1F,MAAa,uBAAuB;IAClC,YACkB,EAAU,EACV,WAAmB,EAChB,QAAiB,EACjB,UAA+B;QAHlC,OAAE,GAAF,EAAE,CAAQ;QACV,gBAAW,GAAX,WAAW,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAS;QACjB,eAAU,GAAV,UAAU,CAAqB;IACjD,CAAC;IAEJ,IAAW,OAAO;QAChB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAEM,oBAAoB,CAAC,IAAY;QACtC,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AE,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,cAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,cAAQ,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;AApbD,8BAobC","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';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput';\nimport { BIN_PATH } from './utils/shell/bin';\nimport { getShellCommandAndArgs } from './utils/shell/command';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n getTemporaryEnvsDirPath,\n getTemporaryOutputsDirPath,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles';\nimport { spawnAsync } from './utils/shell/spawn';\nimport { interpolateWithInputs, interpolateWithOutputs } from './utils/template';\nimport { BuildStepRuntimeError } from './errors';\nimport { BuildStepEnv } from './BuildStepEnv';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform';\nimport { jsepEval } from './utils/jsepEval';\nimport { interpolateJobContext } from './interpolation';\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"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { JobInterpolationContext, StaticJobInterpolationContext } from '@expo/eas-build-job';
|
|
2
2
|
import { bunyan } from '@expo/logger';
|
|
3
|
-
import { StepMetricInput, StepMetricsCollection } from './StepMetrics
|
|
4
|
-
import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep
|
|
5
|
-
import { BuildRuntimePlatform } from './BuildRuntimePlatform
|
|
6
|
-
import { BuildStepEnv } from './BuildStepEnv
|
|
3
|
+
import { StepMetricInput, StepMetricsCollection } from './StepMetrics';
|
|
4
|
+
import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep';
|
|
5
|
+
import { BuildRuntimePlatform } from './BuildRuntimePlatform';
|
|
6
|
+
import { BuildStepEnv } from './BuildStepEnv';
|
|
7
7
|
interface SerializedExternalBuildContextProvider {
|
|
8
8
|
projectSourceDirectory: string;
|
|
9
9
|
projectTargetDirectory: string;
|
|
@@ -8,10 +8,10 @@ const os_1 = __importDefault(require("os"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
10
10
|
const uuid_1 = require("uuid");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
11
|
+
const hashFiles_1 = require("./utils/hashFiles");
|
|
12
|
+
const BuildStep_1 = require("./BuildStep");
|
|
13
|
+
const template_1 = require("./utils/template");
|
|
14
|
+
const errors_1 = require("./errors");
|
|
15
15
|
class BuildStepGlobalContext {
|
|
16
16
|
constructor(provider, skipCleanup) {
|
|
17
17
|
this.provider = provider;
|
|
@@ -60,9 +60,9 @@ class BuildStepGlobalContext {
|
|
|
60
60
|
this.stepById[step.id] = step;
|
|
61
61
|
}
|
|
62
62
|
getStepOutputValue(path) {
|
|
63
|
-
const { stepId, outputId } = (0,
|
|
63
|
+
const { stepId, outputId } = (0, template_1.parseOutputPath)(path);
|
|
64
64
|
if (!(stepId in this.stepById)) {
|
|
65
|
-
throw new
|
|
65
|
+
throw new errors_1.BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
|
|
66
66
|
}
|
|
67
67
|
return this.stepById[stepId].getOutputValueByName(outputId);
|
|
68
68
|
}
|
|
@@ -91,9 +91,9 @@ class BuildStepGlobalContext {
|
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
interpolate(value) {
|
|
94
|
-
return (0,
|
|
94
|
+
return (0, template_1.interpolateWithGlobalContext)(value, (path) => {
|
|
95
95
|
var _a, _b;
|
|
96
|
-
return ((_b = (_a = (0,
|
|
96
|
+
return ((_b = (_a = (0, template_1.getObjectValueForInterpolation)(path, {
|
|
97
97
|
eas: {
|
|
98
98
|
runtimePlatform: this.runtimePlatform,
|
|
99
99
|
...this.staticContext,
|
|
@@ -140,7 +140,7 @@ class BuildStepGlobalContext {
|
|
|
140
140
|
if (validFilePaths.length === 0) {
|
|
141
141
|
return '';
|
|
142
142
|
}
|
|
143
|
-
return (0,
|
|
143
|
+
return (0, hashFiles_1.hashFiles)(validFilePaths);
|
|
144
144
|
}
|
|
145
145
|
serialize() {
|
|
146
146
|
return {
|
|
@@ -172,7 +172,7 @@ class BuildStepGlobalContext {
|
|
|
172
172
|
};
|
|
173
173
|
const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);
|
|
174
174
|
for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {
|
|
175
|
-
ctx.stepById[id] =
|
|
175
|
+
ctx.stepById[id] = BuildStep_1.BuildStepOutputAccessor.deserialize(stepOutputAccessor);
|
|
176
176
|
}
|
|
177
177
|
ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;
|
|
178
178
|
return ctx;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,0DAA2B;AAG3B,+BAAoC;AAGpC,iDAA8C;AAC9C,2CAAoG;AACpG,+CAI0B;AAC1B,qCAAiD;AAoCjD,MAAa,sBAAsB;IASjC,YACmB,QAAsC,EACvC,WAAoB;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QACvC,gBAA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GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACnF,CAAC;QAED,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACpF,CAAC;IAEM,SAAS;QACd,OAAO;YACL,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;YACvD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;SAC7B,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,WAAW,CACvB,UAAsC,EACtC,MAAc;QAEd,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzF,OAAO,IAAI,gBAAgB,CAAC,kBAAkB,EAAE;YAC9C,MAAM;YACN,wBAAwB,EAAE,UAAU,CAAC,wBAAwB;SAC9D,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,4CAmDC","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport fg from 'fast-glob';\nimport { Env, JobInterpolationContext, StaticJobInterpolationContext } from '@expo/eas-build-job';\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { StepMetricInput, StepMetricsCollection } from './StepMetrics';\nimport { hashFiles } from './utils/hashFiles';\nimport { BuildStep, BuildStepOutputAccessor, SerializedBuildStepOutputAccessor } from './BuildStep';\nimport {\n getObjectValueForInterpolation,\n interpolateWithGlobalContext,\n parseOutputPath,\n} from './utils/template';\nimport { BuildStepRuntimeError } from './errors';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform';\nimport { BuildStepEnv } from './BuildStepEnv';\n\ninterface SerializedExternalBuildContextProvider {\n projectSourceDirectory: string;\n projectTargetDirectory: string;\n defaultWorkingDirectory: string;\n buildLogsDirectory: string;\n runtimePlatform: BuildRuntimePlatform;\n // We omit steps, because they should be calculated live based on global context.\n staticContext: Omit<StaticJobInterpolationContext, 'steps'>;\n env: BuildStepEnv;\n}\n\nexport interface ExternalBuildContextProvider {\n readonly projectSourceDirectory: string;\n readonly projectTargetDirectory: string;\n readonly defaultWorkingDirectory: string;\n readonly buildLogsDirectory: string;\n readonly runtimePlatform: BuildRuntimePlatform;\n readonly logger: bunyan;\n\n readonly staticContext: () => Omit<StaticJobInterpolationContext, 'steps'>;\n\n readonly env: BuildStepEnv;\n updateEnv(env: BuildStepEnv): void;\n}\n\nexport interface SerializedBuildStepGlobalContext {\n stepsInternalBuildDirectory: string;\n stepById: Record<string, SerializedBuildStepOutputAccessor>;\n provider: SerializedExternalBuildContextProvider;\n skipCleanup: boolean;\n}\n\nexport class BuildStepGlobalContext {\n public stepsInternalBuildDirectory: string;\n public readonly runtimePlatform: BuildRuntimePlatform;\n public readonly baseLogger: bunyan;\n private didCheckOut = false;\n private _hasAnyPreviousStepFailed = false;\n private stepById: Record<string, BuildStepOutputAccessor> = {};\n private readonly _stepMetrics: StepMetricsCollection = [];\n\n constructor(\n private readonly provider: ExternalBuildContextProvider,\n public readonly skipCleanup: boolean\n ) {\n this.stepsInternalBuildDirectory = path.join(os.tmpdir(), 'eas-build', uuidv4());\n this.runtimePlatform = provider.runtimePlatform;\n this.baseLogger = provider.logger;\n this._hasAnyPreviousStepFailed = false;\n }\n\n public get projectSourceDirectory(): string {\n return this.provider.projectSourceDirectory;\n }\n\n public get projectTargetDirectory(): string {\n return this.provider.projectTargetDirectory;\n }\n\n public get defaultWorkingDirectory(): string {\n return this.didCheckOut ? this.provider.defaultWorkingDirectory : this.projectTargetDirectory;\n }\n\n public get buildLogsDirectory(): string {\n return this.provider.buildLogsDirectory;\n }\n\n public get env(): BuildStepEnv {\n return this.provider.env;\n }\n\n public get staticContext(): StaticJobInterpolationContext {\n return {\n ...this.provider.staticContext(),\n steps: Object.fromEntries(\n Object.values(this.stepById).map((step) => [\n step.id,\n {\n outputs: Object.fromEntries(\n step.outputs.map((output) => {\n return [output.id, output.rawValue];\n })\n ),\n },\n ])\n ),\n };\n }\n\n public updateEnv(updatedEnv: BuildStepEnv): void {\n this.provider.updateEnv(updatedEnv);\n }\n\n public registerStep(step: BuildStep): void {\n this.stepById[step.id] = step;\n }\n\n public getStepOutputValue(path: string): string | undefined {\n const { stepId, outputId } = parseOutputPath(path);\n if (!(stepId in this.stepById)) {\n throw new BuildStepRuntimeError(`Step \"${stepId}\" does not exist.`);\n }\n return this.stepById[stepId].getOutputValueByName(outputId);\n }\n\n public getInterpolationContext(): JobInterpolationContext {\n const hasAnyPreviousStepFailed = this.hasAnyPreviousStepFailed;\n\n return {\n ...this.staticContext,\n always: () => true,\n never: () => false,\n success: () => !hasAnyPreviousStepFailed,\n failure: () => hasAnyPreviousStepFailed,\n env: this.env as Env,\n fromJSON: (json: string) => JSON.parse(json),\n toJSON: (value: unknown) => JSON.stringify(value),\n contains: (value, substring) => value.includes(substring),\n startsWith: (value, prefix) => value.startsWith(prefix),\n endsWith: (value, suffix) => value.endsWith(suffix),\n hashFiles: (...patterns: string[]) => this.hashFiles(...patterns),\n replaceAll: (input: string, stringToReplace: string, replacementString: string) => {\n while (input.includes(stringToReplace)) {\n input = input.replace(stringToReplace, replacementString);\n }\n return input;\n },\n substring: (input: string, start: number, end?: number) => input.substring(start, end),\n };\n }\n\n public interpolate<InterpolableType extends string | object>(\n value: InterpolableType\n ): InterpolableType {\n return interpolateWithGlobalContext(value, (path) => {\n return (\n getObjectValueForInterpolation(path, {\n eas: {\n runtimePlatform: this.runtimePlatform,\n ...this.staticContext,\n env: this.env,\n },\n })?.toString() ?? ''\n );\n });\n }\n\n public stepCtx(options: { logger: bunyan; relativeWorkingDirectory?: string }): BuildStepContext {\n return new BuildStepContext(this, options);\n }\n\n public markAsCheckedOut(logger: bunyan): void {\n this.didCheckOut = true;\n logger.info(\n `Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`\n );\n }\n\n public get hasAnyPreviousStepFailed(): boolean {\n return this._hasAnyPreviousStepFailed;\n }\n\n public markAsFailed(): void {\n this._hasAnyPreviousStepFailed = true;\n }\n\n public get stepMetrics(): StepMetricsCollection {\n return this._stepMetrics;\n }\n\n public addStepMetric(metric: StepMetricInput): void {\n this._stepMetrics.push({ ...metric, platform: this.runtimePlatform });\n }\n\n public wasCheckedOut(): boolean {\n return this.didCheckOut;\n }\n\n public hashFiles(...patterns: string[]): string {\n const cwd = this.defaultWorkingDirectory;\n const workspacePath = path.resolve(cwd);\n\n // Use glob to find matching files across all patterns\n const filePaths = fg.sync(patterns, {\n cwd,\n absolute: true,\n onlyFiles: true,\n });\n\n if (filePaths.length === 0) {\n return '';\n }\n\n const validFilePaths = filePaths.filter((file) =>\n file.startsWith(`${workspacePath}${path.sep}`)\n );\n\n if (validFilePaths.length === 0) {\n return '';\n }\n\n return hashFiles(validFilePaths);\n }\n\n public serialize(): SerializedBuildStepGlobalContext {\n return {\n stepsInternalBuildDirectory: this.stepsInternalBuildDirectory,\n stepById: Object.fromEntries(\n Object.entries(this.stepById).map(([id, step]) => [id, step.serialize()])\n ),\n provider: {\n projectSourceDirectory: this.provider.projectSourceDirectory,\n projectTargetDirectory: this.provider.projectTargetDirectory,\n defaultWorkingDirectory: this.provider.defaultWorkingDirectory,\n buildLogsDirectory: this.provider.buildLogsDirectory,\n runtimePlatform: this.provider.runtimePlatform,\n staticContext: this.provider.staticContext(),\n env: this.provider.env,\n },\n skipCleanup: this.skipCleanup,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepGlobalContext,\n logger: bunyan\n ): BuildStepGlobalContext {\n const deserializedProvider: ExternalBuildContextProvider = {\n projectSourceDirectory: serialized.provider.projectSourceDirectory,\n projectTargetDirectory: serialized.provider.projectTargetDirectory,\n defaultWorkingDirectory: serialized.provider.defaultWorkingDirectory,\n buildLogsDirectory: serialized.provider.buildLogsDirectory,\n runtimePlatform: serialized.provider.runtimePlatform,\n logger,\n staticContext: () => serialized.provider.staticContext,\n env: serialized.provider.env,\n updateEnv: () => {},\n };\n const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);\n for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {\n ctx.stepById[id] = BuildStepOutputAccessor.deserialize(stepOutputAccessor);\n }\n ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;\n\n return ctx;\n }\n}\n\nexport interface SerializedBuildStepContext {\n relativeWorkingDirectory?: string;\n global: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepContext {\n public readonly logger: bunyan;\n public readonly relativeWorkingDirectory?: string;\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n logger,\n relativeWorkingDirectory,\n }: {\n logger: bunyan;\n relativeWorkingDirectory?: string;\n }\n ) {\n this.logger = logger ?? ctx.baseLogger;\n this.relativeWorkingDirectory = relativeWorkingDirectory;\n }\n\n public get global(): BuildStepGlobalContext {\n return this.ctx;\n }\n\n public get workingDirectory(): string {\n if (!this.relativeWorkingDirectory) {\n return this.ctx.defaultWorkingDirectory;\n }\n\n if (path.isAbsolute(this.relativeWorkingDirectory)) {\n return path.join(this.ctx.projectTargetDirectory, this.relativeWorkingDirectory);\n }\n\n return path.join(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory);\n }\n\n public serialize(): SerializedBuildStepContext {\n return {\n relativeWorkingDirectory: this.relativeWorkingDirectory,\n global: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepContext,\n logger: bunyan\n ): BuildStepContext {\n const deserializedGlobal = BuildStepGlobalContext.deserialize(serialized.global, logger);\n return new BuildStepContext(deserializedGlobal, {\n logger,\n relativeWorkingDirectory: serialized.relativeWorkingDirectory,\n });\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JobInterpolationContext } from '@expo/eas-build-job';
|
|
2
|
-
import { BuildStepGlobalContext } from './BuildStepContext
|
|
2
|
+
import { BuildStepGlobalContext } from './BuildStepContext';
|
|
3
3
|
export declare enum BuildStepInputValueTypeName {
|
|
4
4
|
STRING = "string",
|
|
5
5
|
BOOLEAN = "boolean",
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.BuildStepInput = exports.BuildStepInputValueTypeName = void 0;
|
|
7
7
|
exports.makeBuildStepInputByIdMap = makeBuildStepInputByIdMap;
|
|
8
8
|
const assert_1 = __importDefault(require("assert"));
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const errors_1 = require("./errors");
|
|
10
|
+
const template_1 = require("./utils/template");
|
|
11
|
+
const interpolation_1 = require("./interpolation");
|
|
12
12
|
var BuildStepInputValueTypeName;
|
|
13
13
|
(function (BuildStepInputValueTypeName) {
|
|
14
14
|
BuildStepInputValueTypeName["STRING"] = "string";
|
|
@@ -33,9 +33,9 @@ class BuildStepInput {
|
|
|
33
33
|
var _a;
|
|
34
34
|
const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
|
|
35
35
|
if (this.required && rawValue === undefined) {
|
|
36
|
-
throw new
|
|
36
|
+
throw new errors_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
37
37
|
}
|
|
38
|
-
const interpolatedValue = (0,
|
|
38
|
+
const interpolatedValue = (0, interpolation_1.interpolateJobContext)({
|
|
39
39
|
target: rawValue,
|
|
40
40
|
context: interpolationContext,
|
|
41
41
|
});
|
|
@@ -47,7 +47,7 @@ class BuildStepInput {
|
|
|
47
47
|
if (valueDoesNotRequireInterpolation) {
|
|
48
48
|
if (typeof interpolatedValue !== this.allowedValueTypeName &&
|
|
49
49
|
interpolatedValue !== undefined) {
|
|
50
|
-
throw new
|
|
50
|
+
throw new errors_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
51
51
|
}
|
|
52
52
|
returnValue = interpolatedValue;
|
|
53
53
|
}
|
|
@@ -56,7 +56,7 @@ class BuildStepInput {
|
|
|
56
56
|
// so this will never be true.
|
|
57
57
|
(0, assert_1.default)(interpolatedValue !== undefined);
|
|
58
58
|
const valueInterpolatedWithGlobalContext = this.ctx.interpolate(interpolatedValue);
|
|
59
|
-
const valueInterpolatedWithOutputsAndGlobalContext = (0,
|
|
59
|
+
const valueInterpolatedWithOutputsAndGlobalContext = (0, template_1.interpolateWithOutputs)(valueInterpolatedWithGlobalContext, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
60
60
|
returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);
|
|
61
61
|
}
|
|
62
62
|
return returnValue;
|
|
@@ -67,7 +67,7 @@ class BuildStepInput {
|
|
|
67
67
|
}
|
|
68
68
|
set(value) {
|
|
69
69
|
if (this.required && value === undefined) {
|
|
70
|
-
throw new
|
|
70
|
+
throw new errors_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
|
|
71
71
|
}
|
|
72
72
|
this._value = value;
|
|
73
73
|
return this;
|
|
@@ -82,7 +82,7 @@ class BuildStepInput {
|
|
|
82
82
|
}
|
|
83
83
|
isRawValueStepOrContextReference() {
|
|
84
84
|
return (typeof this.rawValue === 'string' &&
|
|
85
|
-
(!!
|
|
85
|
+
(!!template_1.BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue) ||
|
|
86
86
|
// If value is an interpolation reference we're going to render whatever it evaluates to.
|
|
87
87
|
// See `interpolateJobContext`.
|
|
88
88
|
(this.rawValue.startsWith('${{') && this.rawValue.endsWith('}}'))));
|
|
@@ -119,7 +119,7 @@ class BuildStepInput {
|
|
|
119
119
|
parseInputValueToNumber(value) {
|
|
120
120
|
const numberValue = Number(value);
|
|
121
121
|
if (Number.isNaN(numberValue)) {
|
|
122
|
-
throw new
|
|
122
|
+
throw new errors_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
123
123
|
}
|
|
124
124
|
return numberValue;
|
|
125
125
|
}
|
|
@@ -131,7 +131,7 @@ class BuildStepInput {
|
|
|
131
131
|
return false;
|
|
132
132
|
}
|
|
133
133
|
else {
|
|
134
|
-
throw new
|
|
134
|
+
throw new errors_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
parseInputValueToObject(value) {
|
|
@@ -139,7 +139,7 @@ class BuildStepInput {
|
|
|
139
139
|
return JSON.parse(value);
|
|
140
140
|
}
|
|
141
141
|
catch (e) {
|
|
142
|
-
throw new
|
|
142
|
+
throw new errors_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`, {
|
|
143
143
|
cause: e,
|
|
144
144
|
});
|
|
145
145
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":";;;;;;AAwOA,8DAQC;AAhPD,oDAA4B;AAK5B,qCAAiD;AACjD,+CAG0B;AAC1B,mDAAwD;AAExD,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,gDAAiB,CAAA;IACjB,kDAAmB,CAAA;IACnB,gDAAiB,CAAA;IACjB,4CAAa,CAAA;AACf,CAAC,EALW,2BAA2B,2CAA3B,2BAA2B,QAKtC;AAkCD,MAAa,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,EAC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AM,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';\nimport { BuildStepRuntimeError } from './errors';\nimport {\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n interpolateWithOutputs,\n} from './utils/template';\nimport { interpolateJobContext } from './interpolation';\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildStepGlobalContext } from './BuildStepContext
|
|
1
|
+
import { BuildStepGlobalContext } from './BuildStepContext';
|
|
2
2
|
export type BuildStepOutputById = Record<string, BuildStepOutput>;
|
|
3
3
|
export type BuildStepOutputProvider = (ctx: BuildStepGlobalContext, stepDisplayName: string) => BuildStepOutput;
|
|
4
4
|
interface BuildStepOutputProviderParams<R extends boolean = boolean> {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuildStepOutput = void 0;
|
|
4
4
|
exports.makeBuildStepOutputByIdMap = makeBuildStepOutputByIdMap;
|
|
5
|
-
const
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
6
|
class BuildStepOutput {
|
|
7
7
|
static createProvider(params) {
|
|
8
8
|
return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });
|
|
@@ -20,13 +20,13 @@ class BuildStepOutput {
|
|
|
20
20
|
}
|
|
21
21
|
get value() {
|
|
22
22
|
if (this.required && this._value === undefined) {
|
|
23
|
-
throw new
|
|
23
|
+
throw new errors_1.BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
24
24
|
}
|
|
25
25
|
return this._value;
|
|
26
26
|
}
|
|
27
27
|
set(value) {
|
|
28
28
|
if (this.required && value === undefined) {
|
|
29
|
-
throw new
|
|
29
|
+
throw new errors_1.BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
|
|
30
30
|
}
|
|
31
31
|
this._value = value;
|
|
32
32
|
return this;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":";;;AA8FA,gEAQC;AArGD,qCAAiD;AA6BjD,MAAa,eAAe;IAOnB,MAAM,CAAC,cAAc,CAAC,MAAqC;QAChE,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;IACE,wFAAwF;IACvE,GAAuC,EACxD,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,EAA4B;QAD1C,QAAG,GAAH,GAAG,CAAoC;QAGxD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAW,KAAK;QACd,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC/C,MAAM,IAAI,8BAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,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BuildStepGlobalContext } from './BuildStepContext';\nimport { BuildStepRuntimeError } from './errors';\n\nexport type BuildStepOutputById = Record<string, BuildStepOutput>;\nexport type BuildStepOutputProvider = (\n ctx: BuildStepGlobalContext,\n stepDisplayName: string\n) => BuildStepOutput;\n\ninterface BuildStepOutputProviderParams<R extends boolean = boolean> {\n id: string;\n required: R;\n}\n\ninterface BuildStepOutputParams<R extends boolean = boolean>\n extends BuildStepOutputProviderParams<R> {\n stepDisplayName: string;\n}\n\ntype BuildStepOutputValueType<R extends boolean = boolean> = R extends true\n ? string\n : string | undefined;\n\nexport interface SerializedBuildStepOutput<R extends boolean = boolean> {\n id: string;\n stepDisplayName: string;\n required: R;\n value?: string;\n}\n\nexport class BuildStepOutput<R extends boolean = boolean> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly required: R;\n\n private _value?: string;\n\n public static createProvider(params: BuildStepOutputProviderParams): BuildStepOutputProvider {\n return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n // @ts-expect-error ctx is not used in this class but let's keep it here for consistency\n private readonly ctx: BuildStepGlobalContext | undefined,\n { id, stepDisplayName, required }: BuildStepOutputParams<R>\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.required = required;\n }\n\n public get rawValue(): string | undefined {\n return this._value;\n }\n\n public get value(): BuildStepOutputValueType<R> {\n if (this.required && this._value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n return this._value as BuildStepOutputValueType<R>;\n }\n\n public set(value: BuildStepOutputValueType<R>): BuildStepOutput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n\n public serialize(): SerializedBuildStepOutput {\n return {\n id: this.id,\n stepDisplayName: this.stepDisplayName,\n required: this.required,\n value: this._value,\n };\n }\n\n public static deserialize(serialized: SerializedBuildStepOutput): BuildStepOutput {\n const deserialized = new BuildStepOutput(undefined, {\n id: serialized.id,\n stepDisplayName: serialized.stepDisplayName,\n required: serialized.required,\n });\n deserialized._value = serialized.value;\n return deserialized;\n }\n}\n\nexport function makeBuildStepOutputByIdMap(outputs?: BuildStepOutput[]): BuildStepOutputById {\n if (outputs === undefined) {\n return {};\n }\n return outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as BuildStepOutputById);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildStepGlobalContext } from './BuildStepContext
|
|
1
|
+
import { BuildStepGlobalContext } from './BuildStepContext';
|
|
2
2
|
export declare function saveScriptToTemporaryFileAsync(ctx: BuildStepGlobalContext, stepId: string, scriptContents: string): Promise<string>;
|
|
3
3
|
export declare function cleanUpStepTemporaryDirectoriesAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<void>;
|
|
4
4
|
export declare function getTemporaryOutputsDirPath(ctx: BuildStepGlobalContext, stepId: string): string;
|