@expo/steps 1.0.263 → 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 +4 -3
- package/{dist_commonjs/BuildConfig.cjs → dist/BuildConfig.js} +24 -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} +33 -32
- package/dist/BuildConfigParser.js.map +1 -0
- package/{dist_esm → dist}/BuildFunction.d.ts +9 -7
- package/{dist_commonjs/BuildFunction.cjs → dist/BuildFunction.js} +9 -7
- 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 +8 -6
- package/{dist_commonjs/BuildStep.cjs → dist/BuildStep.js} +31 -30
- package/dist/BuildStep.js.map +1 -0
- package/{dist_commonjs → dist}/BuildStepContext.d.ts +7 -3
- package/{dist_commonjs/BuildStepContext.cjs → dist/BuildStepContext.js} +17 -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 +4 -3
- package/{dist_commonjs/BuildWorkflow.cjs → dist/BuildWorkflow.js} +17 -0
- 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/StepMetrics.d.ts +10 -0
- package/dist/StepMetrics.js +3 -0
- package/dist/StepMetrics.js.map +1 -0
- package/{dist_commonjs → dist}/StepsConfigParser.d.ts +5 -5
- package/{dist_commonjs/StepsConfigParser.cjs → dist/StepsConfigParser.js} +14 -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 +12 -24
- 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 -43
- package/dist_commonjs/BuildFunction.js.map +0 -1
- package/dist_commonjs/BuildFunctionGroup.js.map +0 -1
- package/dist_commonjs/BuildStep.d.ts +0 -98
- 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 -18
- 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 -79
- package/dist_esm/BuildConfig.js +0 -279
- package/dist_esm/BuildConfig.js.map +0 -1
- package/dist_esm/BuildConfigParser.js +0 -232
- package/dist_esm/BuildConfigParser.js.map +0 -1
- package/dist_esm/BuildFunction.js +0 -60
- 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 -353
- package/dist_esm/BuildStep.js.map +0 -1
- package/dist_esm/BuildStepContext.d.ts +0 -82
- package/dist_esm/BuildStepContext.js +0 -200
- 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 -13
- package/dist_esm/BuildWorkflow.js +0 -38
- 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/StepsConfigParser.d.ts +0 -24
- package/dist_esm/StepsConfigParser.js +0 -132
- 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 -18
- 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 → 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
package/dist_esm/BuildStep.js
DELETED
|
@@ -1,353 +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, }) {
|
|
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.status = BuildStepStatus.NEW;
|
|
111
|
-
this.internalId = uuidv4();
|
|
112
|
-
const logger = ctx.baseLogger.child({
|
|
113
|
-
buildStepInternalId: this.internalId,
|
|
114
|
-
buildStepId: this.id,
|
|
115
|
-
buildStepDisplayName: this.displayName,
|
|
116
|
-
});
|
|
117
|
-
this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });
|
|
118
|
-
this.stepEnvOverrides = env !== null && env !== void 0 ? env : {};
|
|
119
|
-
this.outputsDir = getTemporaryOutputsDirPath(ctx, this.id);
|
|
120
|
-
this.envsDir = getTemporaryEnvsDirPath(ctx, this.id);
|
|
121
|
-
ctx.registerStep(this);
|
|
122
|
-
}
|
|
123
|
-
async executeAsync() {
|
|
124
|
-
try {
|
|
125
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.START_STEP }, `Executing build step "${this.displayName}"`);
|
|
126
|
-
this.status = BuildStepStatus.IN_PROGRESS;
|
|
127
|
-
await fs.mkdir(this.outputsDir, { recursive: true });
|
|
128
|
-
this.ctx.logger.debug(`Created temporary directory for step outputs: ${this.outputsDir}`);
|
|
129
|
-
await fs.mkdir(this.envsDir, { recursive: true });
|
|
130
|
-
this.ctx.logger.debug(`Created temporary directory for step environment variables: ${this.envsDir}`);
|
|
131
|
-
if (this.timeoutMs !== undefined) {
|
|
132
|
-
const abortController = new AbortController();
|
|
133
|
-
let timeoutId;
|
|
134
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
135
|
-
timeoutId = setTimeout(() => {
|
|
136
|
-
// Reject with timeout error FIRST, before killing the process
|
|
137
|
-
// This ensures the timeout error wins the race
|
|
138
|
-
reject(new BuildStepRuntimeError(`Build step "${this.displayName}" timed out after ${this.timeoutMs}ms`));
|
|
139
|
-
abortController.abort();
|
|
140
|
-
}, this.timeoutMs);
|
|
141
|
-
});
|
|
142
|
-
try {
|
|
143
|
-
await Promise.race([
|
|
144
|
-
this.command !== undefined
|
|
145
|
-
? this.executeCommandAsync({ signal: abortController.signal })
|
|
146
|
-
: this.executeFnAsync({ signal: abortController.signal }),
|
|
147
|
-
timeoutPromise,
|
|
148
|
-
]);
|
|
149
|
-
}
|
|
150
|
-
finally {
|
|
151
|
-
if (timeoutId) {
|
|
152
|
-
clearTimeout(timeoutId);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
const executionPromise = this.command !== undefined
|
|
158
|
-
? this.executeCommandAsync({ signal: null })
|
|
159
|
-
: this.executeFnAsync({ signal: null });
|
|
160
|
-
await executionPromise;
|
|
161
|
-
}
|
|
162
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS }, `Finished build step "${this.displayName}" successfully`);
|
|
163
|
-
this.status = BuildStepStatus.SUCCESS;
|
|
164
|
-
}
|
|
165
|
-
catch (err) {
|
|
166
|
-
this.ctx.logger.error({ err });
|
|
167
|
-
this.ctx.logger.error({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL }, `Build step "${this.displayName}" failed`);
|
|
168
|
-
this.status = BuildStepStatus.FAIL;
|
|
169
|
-
throw err;
|
|
170
|
-
}
|
|
171
|
-
finally {
|
|
172
|
-
this.executed = true;
|
|
173
|
-
try {
|
|
174
|
-
await this.collectAndValidateOutputsAsync(this.outputsDir);
|
|
175
|
-
await this.collectAndUpdateEnvsAsync(this.envsDir);
|
|
176
|
-
this.ctx.logger.debug('Finished collecting output parameters');
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
// If the step succeeded, we expect the outputs to be collected successfully.
|
|
180
|
-
if (this.status === BuildStepStatus.SUCCESS) {
|
|
181
|
-
throw error;
|
|
182
|
-
}
|
|
183
|
-
this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');
|
|
184
|
-
}
|
|
185
|
-
await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
canBeRunOnRuntimePlatform() {
|
|
189
|
-
return (!this.supportedRuntimePlatforms ||
|
|
190
|
-
this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform));
|
|
191
|
-
}
|
|
192
|
-
shouldExecuteStep() {
|
|
193
|
-
var _a, _b;
|
|
194
|
-
const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;
|
|
195
|
-
if (!this.ifCondition) {
|
|
196
|
-
return !hasAnyPreviousStepFailed;
|
|
197
|
-
}
|
|
198
|
-
let ifCondition = this.ifCondition;
|
|
199
|
-
if (ifCondition.startsWith('${{') && ifCondition.endsWith('}}')) {
|
|
200
|
-
ifCondition = ifCondition.slice(3, -2);
|
|
201
|
-
}
|
|
202
|
-
else if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {
|
|
203
|
-
ifCondition = ifCondition.slice(2, -1);
|
|
204
|
-
}
|
|
205
|
-
return Boolean(jsepEval(ifCondition, {
|
|
206
|
-
inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
|
|
207
|
-
acc[input.id] = input.getValue({
|
|
208
|
-
interpolationContext: this.getInterpolationContext(),
|
|
209
|
-
});
|
|
210
|
-
return acc;
|
|
211
|
-
}, {})) !== null && _b !== void 0 ? _b : {},
|
|
212
|
-
eas: {
|
|
213
|
-
runtimePlatform: this.ctx.global.runtimePlatform,
|
|
214
|
-
...this.ctx.global.staticContext,
|
|
215
|
-
env: this.getScriptEnv(),
|
|
216
|
-
},
|
|
217
|
-
...this.getInterpolationContext(),
|
|
218
|
-
}));
|
|
219
|
-
}
|
|
220
|
-
skip() {
|
|
221
|
-
this.status = BuildStepStatus.SKIPPED;
|
|
222
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.START_STEP }, 'Executing build step "${this.displayName}"');
|
|
223
|
-
this.ctx.logger.info(`Skipped build step "${this.displayName}"`);
|
|
224
|
-
this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED }, `Skipped build step "${this.displayName}"`);
|
|
225
|
-
}
|
|
226
|
-
getInterpolationContext() {
|
|
227
|
-
return {
|
|
228
|
-
...this.ctx.global.getInterpolationContext(),
|
|
229
|
-
env: this.getScriptEnv(),
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
async executeCommandAsync({ signal }) {
|
|
233
|
-
assert(this.command, 'Command must be defined.');
|
|
234
|
-
const interpolatedCommand = interpolateJobContext({
|
|
235
|
-
target: this.command,
|
|
236
|
-
context: this.getInterpolationContext(),
|
|
237
|
-
});
|
|
238
|
-
const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(`${interpolatedCommand}`, this.inputs);
|
|
239
|
-
this.ctx.logger.debug(`Interpolated inputs in the command template`);
|
|
240
|
-
const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);
|
|
241
|
-
this.ctx.logger.debug(`Saved script to ${scriptPath}`);
|
|
242
|
-
const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);
|
|
243
|
-
this.ctx.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
|
|
244
|
-
try {
|
|
245
|
-
const workingDirectoryStat = await fs.stat(this.ctx.workingDirectory);
|
|
246
|
-
if (!workingDirectoryStat.isDirectory()) {
|
|
247
|
-
this.ctx.logger.error(`Working directory "${this.ctx.workingDirectory}" exists, but is not a directory`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
catch (err) {
|
|
251
|
-
if ((err === null || err === void 0 ? void 0 : err.code) === 'ENOENT') {
|
|
252
|
-
this.ctx.logger.error({ err }, `Working directory "${this.ctx.workingDirectory}" does not exist`);
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
this.ctx.logger.error({ err }, `Cannot access working directory "${this.ctx.workingDirectory}"`);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
await spawnAsync(shellCommand, args !== null && args !== void 0 ? args : [], {
|
|
259
|
-
cwd: this.ctx.workingDirectory,
|
|
260
|
-
logger: this.ctx.logger,
|
|
261
|
-
env: this.getScriptEnv(),
|
|
262
|
-
// stdin is /dev/null, std{out,err} are piped into logger.
|
|
263
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
264
|
-
signal: signal !== null && signal !== void 0 ? signal : undefined,
|
|
265
|
-
});
|
|
266
|
-
this.ctx.logger.debug(`Script completed successfully`);
|
|
267
|
-
}
|
|
268
|
-
async executeFnAsync({ signal }) {
|
|
269
|
-
assert(this.fn, 'Function (fn) must be defined');
|
|
270
|
-
await this.fn(this.ctx, {
|
|
271
|
-
inputs: Object.fromEntries(Object.entries(this.inputById).map(([key, input]) => [
|
|
272
|
-
key,
|
|
273
|
-
{ value: input.getValue({ interpolationContext: this.getInterpolationContext() }) },
|
|
274
|
-
])),
|
|
275
|
-
outputs: this.outputById,
|
|
276
|
-
env: this.getScriptEnv(),
|
|
277
|
-
signal: signal !== null && signal !== void 0 ? signal : undefined,
|
|
278
|
-
});
|
|
279
|
-
this.ctx.logger.debug(`Script completed successfully`);
|
|
280
|
-
}
|
|
281
|
-
interpolateInputsOutputsAndGlobalContextInTemplate(template, inputs) {
|
|
282
|
-
if (!inputs) {
|
|
283
|
-
return interpolateWithOutputs(this.ctx.global.interpolate(template), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
284
|
-
}
|
|
285
|
-
const vars = inputs.reduce((acc, input) => {
|
|
286
|
-
var _a;
|
|
287
|
-
const value = input.getValue({ interpolationContext: this.getInterpolationContext() });
|
|
288
|
-
acc[input.id] = typeof value === 'object' ? JSON.stringify(value) : (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '';
|
|
289
|
-
return acc;
|
|
290
|
-
}, {});
|
|
291
|
-
return interpolateWithOutputs(interpolateWithInputs(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
292
|
-
}
|
|
293
|
-
async collectAndValidateOutputsAsync(outputsDir) {
|
|
294
|
-
const files = await fs.readdir(outputsDir);
|
|
295
|
-
for (const outputId of files) {
|
|
296
|
-
if (!(outputId in this.outputById)) {
|
|
297
|
-
const newOutput = new BuildStepOutput(this.ctx.global, {
|
|
298
|
-
id: outputId,
|
|
299
|
-
stepDisplayName: this.displayName,
|
|
300
|
-
required: false,
|
|
301
|
-
});
|
|
302
|
-
this.outputById[outputId] = newOutput;
|
|
303
|
-
}
|
|
304
|
-
const file = path.join(outputsDir, outputId);
|
|
305
|
-
const rawContents = await fs.readFile(file, 'utf-8');
|
|
306
|
-
const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');
|
|
307
|
-
this.outputById[outputId].set(decodedContents);
|
|
308
|
-
}
|
|
309
|
-
const nonSetRequiredOutputIds = [];
|
|
310
|
-
for (const output of Object.values(this.outputById)) {
|
|
311
|
-
try {
|
|
312
|
-
const value = output.value;
|
|
313
|
-
this.ctx.logger.debug(`Output parameter "${output.id}" is set to "${value}"`);
|
|
314
|
-
}
|
|
315
|
-
catch (err) {
|
|
316
|
-
this.ctx.logger.debug({ err }, `Getting value for output parameter "${output.id}" failed.`);
|
|
317
|
-
nonSetRequiredOutputIds.push(output.id);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
if (nonSetRequiredOutputIds.length > 0) {
|
|
321
|
-
const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
|
|
322
|
-
throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {
|
|
323
|
-
metadata: { ids: nonSetRequiredOutputIds },
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
async collectAndUpdateEnvsAsync(envsDir) {
|
|
328
|
-
const filenames = await fs.readdir(envsDir);
|
|
329
|
-
const entries = await Promise.all(filenames.map(async (basename) => {
|
|
330
|
-
const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');
|
|
331
|
-
const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');
|
|
332
|
-
return [basename, decodedContents];
|
|
333
|
-
}));
|
|
334
|
-
this.ctx.global.updateEnv({
|
|
335
|
-
...this.ctx.global.env,
|
|
336
|
-
...Object.fromEntries(entries),
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
getScriptEnv() {
|
|
340
|
-
var _a;
|
|
341
|
-
const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };
|
|
342
|
-
const currentPath = (_a = effectiveEnv.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
|
|
343
|
-
const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;
|
|
344
|
-
return {
|
|
345
|
-
...effectiveEnv,
|
|
346
|
-
__EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,
|
|
347
|
-
__EXPO_STEPS_ENVS_DIR: this.envsDir,
|
|
348
|
-
__EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,
|
|
349
|
-
PATH: newPath,
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
//# 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,EAA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AI,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 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 }: {\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 }\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.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,82 +0,0 @@
|
|
|
1
|
-
import { JobInterpolationContext, StaticJobInterpolationContext } from '@expo/eas-build-job';
|
|
2
|
-
import { bunyan } from '@expo/logger';
|
|
3
|
-
import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep.js';
|
|
4
|
-
import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
5
|
-
import { BuildStepEnv } from './BuildStepEnv.js';
|
|
6
|
-
interface SerializedExternalBuildContextProvider {
|
|
7
|
-
projectSourceDirectory: string;
|
|
8
|
-
projectTargetDirectory: string;
|
|
9
|
-
defaultWorkingDirectory: string;
|
|
10
|
-
buildLogsDirectory: string;
|
|
11
|
-
runtimePlatform: BuildRuntimePlatform;
|
|
12
|
-
staticContext: Omit<StaticJobInterpolationContext, 'steps'>;
|
|
13
|
-
env: BuildStepEnv;
|
|
14
|
-
}
|
|
15
|
-
export interface ExternalBuildContextProvider {
|
|
16
|
-
readonly projectSourceDirectory: string;
|
|
17
|
-
readonly projectTargetDirectory: string;
|
|
18
|
-
readonly defaultWorkingDirectory: string;
|
|
19
|
-
readonly buildLogsDirectory: string;
|
|
20
|
-
readonly runtimePlatform: BuildRuntimePlatform;
|
|
21
|
-
readonly logger: bunyan;
|
|
22
|
-
readonly staticContext: () => Omit<StaticJobInterpolationContext, 'steps'>;
|
|
23
|
-
readonly env: BuildStepEnv;
|
|
24
|
-
updateEnv(env: BuildStepEnv): void;
|
|
25
|
-
}
|
|
26
|
-
export interface SerializedBuildStepGlobalContext {
|
|
27
|
-
stepsInternalBuildDirectory: string;
|
|
28
|
-
stepById: Record<string, SerializedBuildStepOutputAccessor>;
|
|
29
|
-
provider: SerializedExternalBuildContextProvider;
|
|
30
|
-
skipCleanup: boolean;
|
|
31
|
-
}
|
|
32
|
-
export declare class BuildStepGlobalContext {
|
|
33
|
-
private readonly provider;
|
|
34
|
-
readonly skipCleanup: boolean;
|
|
35
|
-
stepsInternalBuildDirectory: string;
|
|
36
|
-
readonly runtimePlatform: BuildRuntimePlatform;
|
|
37
|
-
readonly baseLogger: bunyan;
|
|
38
|
-
private didCheckOut;
|
|
39
|
-
private _hasAnyPreviousStepFailed;
|
|
40
|
-
private stepById;
|
|
41
|
-
constructor(provider: ExternalBuildContextProvider, skipCleanup: boolean);
|
|
42
|
-
get projectSourceDirectory(): string;
|
|
43
|
-
get projectTargetDirectory(): string;
|
|
44
|
-
get defaultWorkingDirectory(): string;
|
|
45
|
-
get buildLogsDirectory(): string;
|
|
46
|
-
get env(): BuildStepEnv;
|
|
47
|
-
get staticContext(): StaticJobInterpolationContext;
|
|
48
|
-
updateEnv(updatedEnv: BuildStepEnv): void;
|
|
49
|
-
registerStep(step: BuildStep): void;
|
|
50
|
-
getStepOutputValue(path: string): string | undefined;
|
|
51
|
-
getInterpolationContext(): JobInterpolationContext;
|
|
52
|
-
interpolate<InterpolableType extends string | object>(value: InterpolableType): InterpolableType;
|
|
53
|
-
stepCtx(options: {
|
|
54
|
-
logger: bunyan;
|
|
55
|
-
relativeWorkingDirectory?: string;
|
|
56
|
-
}): BuildStepContext;
|
|
57
|
-
markAsCheckedOut(logger: bunyan): void;
|
|
58
|
-
get hasAnyPreviousStepFailed(): boolean;
|
|
59
|
-
markAsFailed(): void;
|
|
60
|
-
wasCheckedOut(): boolean;
|
|
61
|
-
hashFiles(...patterns: string[]): string;
|
|
62
|
-
serialize(): SerializedBuildStepGlobalContext;
|
|
63
|
-
static deserialize(serialized: SerializedBuildStepGlobalContext, logger: bunyan): BuildStepGlobalContext;
|
|
64
|
-
}
|
|
65
|
-
export interface SerializedBuildStepContext {
|
|
66
|
-
relativeWorkingDirectory?: string;
|
|
67
|
-
global: SerializedBuildStepGlobalContext;
|
|
68
|
-
}
|
|
69
|
-
export declare class BuildStepContext {
|
|
70
|
-
private readonly ctx;
|
|
71
|
-
readonly logger: bunyan;
|
|
72
|
-
readonly relativeWorkingDirectory?: string;
|
|
73
|
-
constructor(ctx: BuildStepGlobalContext, { logger, relativeWorkingDirectory, }: {
|
|
74
|
-
logger: bunyan;
|
|
75
|
-
relativeWorkingDirectory?: string;
|
|
76
|
-
});
|
|
77
|
-
get global(): BuildStepGlobalContext;
|
|
78
|
-
get workingDirectory(): string;
|
|
79
|
-
serialize(): SerializedBuildStepContext;
|
|
80
|
-
static deserialize(serialized: SerializedBuildStepContext, logger: bunyan): BuildStepContext;
|
|
81
|
-
}
|
|
82
|
-
export {};
|