@expo/steps 1.0.136 → 1.0.138

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.
Files changed (40) hide show
  1. package/LICENSE +1 -1
  2. package/dist_commonjs/BuildStep.cjs +85 -75
  3. package/dist_commonjs/BuildStep.d.ts +7 -7
  4. package/dist_commonjs/BuildStep.js.map +1 -1
  5. package/dist_commonjs/BuildStepContext.cjs +19 -1
  6. package/dist_commonjs/BuildStepContext.d.ts +7 -4
  7. package/dist_commonjs/BuildStepContext.js.map +1 -1
  8. package/dist_commonjs/BuildTemporaryFiles.cjs +3 -13
  9. package/dist_commonjs/BuildTemporaryFiles.d.ts +2 -2
  10. package/dist_commonjs/BuildTemporaryFiles.js.map +1 -1
  11. package/dist_commonjs/BuildWorkflow.cjs +4 -7
  12. package/dist_commonjs/BuildWorkflow.js.map +1 -1
  13. package/dist_commonjs/cli/cli.d.ts +2 -2
  14. package/dist_commonjs/cli/cli.js.map +1 -1
  15. package/dist_commonjs/index.cjs +2 -0
  16. package/dist_commonjs/index.d.ts +2 -0
  17. package/dist_commonjs/index.js.map +1 -1
  18. package/dist_commonjs/interpolation.cjs +30 -0
  19. package/dist_commonjs/interpolation.d.ts +5 -0
  20. package/dist_commonjs/interpolation.js.map +1 -0
  21. package/dist_esm/BuildStep.d.ts +7 -7
  22. package/dist_esm/BuildStep.js +86 -76
  23. package/dist_esm/BuildStep.js.map +1 -1
  24. package/dist_esm/BuildStepContext.d.ts +7 -4
  25. package/dist_esm/BuildStepContext.js +19 -1
  26. package/dist_esm/BuildStepContext.js.map +1 -1
  27. package/dist_esm/BuildTemporaryFiles.d.ts +2 -2
  28. package/dist_esm/BuildTemporaryFiles.js +2 -12
  29. package/dist_esm/BuildTemporaryFiles.js.map +1 -1
  30. package/dist_esm/BuildWorkflow.js +4 -7
  31. package/dist_esm/BuildWorkflow.js.map +1 -1
  32. package/dist_esm/cli/cli.d.ts +2 -2
  33. package/dist_esm/cli/cli.js.map +1 -1
  34. package/dist_esm/index.d.ts +2 -0
  35. package/dist_esm/index.js +2 -0
  36. package/dist_esm/index.js.map +1 -1
  37. package/dist_esm/interpolation.d.ts +5 -0
  38. package/dist_esm/interpolation.js +26 -0
  39. package/dist_esm/interpolation.js.map +1 -0
  40. package/package.json +3 -3
package/LICENSE CHANGED
@@ -12,7 +12,7 @@ Additional Use Grant: You may make use of the Licensed Work, provided that you d
12
12
  to access the functionality of and directly benefit from the
13
13
  functionality of the Licensed Work.
14
14
 
15
- Change Date: 2027-07-01
15
+ Change Date: 2027-10-01
16
16
 
17
17
  Change License: MIT
18
18
 
@@ -17,6 +17,7 @@ const spawn_js_1 = require("./utils/shell/spawn.cjs");
17
17
  const template_js_1 = require("./utils/template.cjs");
18
18
  const errors_js_1 = require("./errors.cjs");
19
19
  const jsepEval_js_1 = require("./utils/jsepEval.cjs");
20
+ const interpolation_js_1 = require("./interpolation.cjs");
20
21
  var BuildStepStatus;
21
22
  (function (BuildStepStatus) {
22
23
  BuildStepStatus["NEW"] = "new";
@@ -40,6 +41,9 @@ class BuildStepOutputAccessor {
40
41
  this.executed = executed;
41
42
  this.outputById = outputById;
42
43
  }
44
+ get outputs() {
45
+ return Object.values(this.outputById);
46
+ }
43
47
  getOutputValueByName(name) {
44
48
  if (!this.executed) {
45
49
  throw new errors_js_1.BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
@@ -102,7 +106,6 @@ class BuildStep extends BuildStepOutputAccessor {
102
106
  this.displayName = displayName;
103
107
  this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;
104
108
  this.inputs = inputs;
105
- this.outputs = outputs;
106
109
  this.inputById = (0, BuildStepInput_js_1.makeBuildStepInputByIdMap)(inputs);
107
110
  this.outputById = outputById;
108
111
  this.fn = fn;
@@ -118,17 +121,23 @@ class BuildStep extends BuildStepOutputAccessor {
118
121
  });
119
122
  this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });
120
123
  this.stepEnvOverrides = env !== null && env !== void 0 ? env : {};
124
+ this.outputsDir = (0, BuildTemporaryFiles_js_1.getTemporaryOutputsDirPath)(ctx, this.id);
125
+ this.envsDir = (0, BuildTemporaryFiles_js_1.getTemporaryEnvsDirPath)(ctx, this.id);
121
126
  ctx.registerStep(this);
122
127
  }
123
128
  async executeAsync() {
124
129
  try {
125
130
  this.ctx.logger.info({ marker: BuildStepLogMarker.START_STEP }, `Executing build step "${this.displayName}"`);
126
131
  this.status = BuildStepStatus.IN_PROGRESS;
132
+ await promises_1.default.mkdir(this.outputsDir, { recursive: true });
133
+ this.ctx.logger.debug(`Created temporary directory for step outputs: ${this.outputsDir}`);
134
+ await promises_1.default.mkdir(this.envsDir, { recursive: true });
135
+ this.ctx.logger.debug(`Created temporary directory for step environment variables: ${this.envsDir}`);
127
136
  if (this.command !== undefined) {
128
137
  await this.executeCommandAsync();
129
138
  }
130
139
  else {
131
- await this.exectuteFnAsync();
140
+ await this.executeFnAsync();
132
141
  }
133
142
  this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS }, `Finished build step "${this.displayName}" successfully`);
134
143
  this.status = BuildStepStatus.SUCCESS;
@@ -141,39 +150,41 @@ class BuildStep extends BuildStepOutputAccessor {
141
150
  }
142
151
  finally {
143
152
  this.executed = true;
153
+ try {
154
+ await this.collectAndValidateOutputsAsync(this.outputsDir);
155
+ await this.collectAndUpdateEnvsAsync(this.envsDir);
156
+ this.ctx.logger.debug('Finished collecting output parameters');
157
+ }
158
+ catch (error) {
159
+ // If the step succeeded, we expect the outputs to be collected successfully.
160
+ if (this.status === BuildStepStatus.SUCCESS) {
161
+ throw error;
162
+ }
163
+ this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');
164
+ }
165
+ await (0, BuildTemporaryFiles_js_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx.global, this.id);
144
166
  }
145
167
  }
146
- hasOutputParameter(name) {
147
- return name in this.outputById;
148
- }
149
- getOutputValueByName(name) {
150
- if (!this.executed) {
151
- throw new errors_js_1.BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
152
- }
153
- if (!this.hasOutputParameter(name)) {
154
- throw new errors_js_1.BuildStepRuntimeError(`Step "${this.displayName}" does not have output "${name}".`);
155
- }
156
- return this.outputById[name].value;
157
- }
158
168
  canBeRunOnRuntimePlatform() {
159
169
  return (!this.supportedRuntimePlatforms ||
160
170
  this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform));
161
171
  }
162
- shouldExecuteStep(hasAnyPreviousStepsFailed) {
172
+ shouldExecuteStep() {
163
173
  var _a, _b;
174
+ const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;
164
175
  if (!this.ifCondition) {
165
- return !hasAnyPreviousStepsFailed;
176
+ return !hasAnyPreviousStepFailed;
166
177
  }
167
178
  let ifCondition = this.ifCondition;
168
179
  if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {
169
180
  ifCondition = ifCondition.slice(2, -1);
170
181
  }
171
182
  return Boolean((0, jsepEval_js_1.jsepEval)(ifCondition, {
172
- success: () => !hasAnyPreviousStepsFailed,
173
- failure: () => hasAnyPreviousStepsFailed,
183
+ success: () => !hasAnyPreviousStepFailed,
184
+ failure: () => hasAnyPreviousStepFailed,
174
185
  always: () => true,
175
186
  never: () => false,
176
- env: this.effectiveEnv,
187
+ env: this.getScriptEnv(),
177
188
  inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
178
189
  acc[input.id] = input.value;
179
190
  return acc;
@@ -190,55 +201,48 @@ class BuildStep extends BuildStepOutputAccessor {
190
201
  this.ctx.logger.info(`Skipped build step "${this.displayName}"`);
191
202
  this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED }, `Skipped build step "${this.displayName}"`);
192
203
  }
204
+ getInterpolationContext() {
205
+ const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;
206
+ return {
207
+ ...this.ctx.global.staticContext,
208
+ always: () => true,
209
+ never: () => false,
210
+ success: () => !hasAnyPreviousStepFailed,
211
+ failure: () => hasAnyPreviousStepFailed,
212
+ env: this.getScriptEnv(),
213
+ fromJSON: (json) => JSON.parse(json),
214
+ toJSON: (value) => JSON.stringify(value),
215
+ };
216
+ }
193
217
  async executeCommandAsync() {
194
218
  (0, assert_1.default)(this.command, 'Command must be defined.');
195
- try {
196
- const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(this.command, this.inputs);
197
- this.ctx.logger.debug(`Interpolated inputs in the command template`);
198
- const outputsDir = await (0, BuildTemporaryFiles_js_1.createTemporaryOutputsDirectoryAsync)(this.ctx.global, this.id);
199
- this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);
200
- const envsDir = await (0, BuildTemporaryFiles_js_1.createTemporaryEnvsDirectoryAsync)(this.ctx.global, this.id);
201
- this.ctx.logger.debug(`Created temporary directory for step environment variables: ${outputsDir}`);
202
- const scriptPath = await (0, BuildTemporaryFiles_js_1.saveScriptToTemporaryFileAsync)(this.ctx.global, this.id, command);
203
- this.ctx.logger.debug(`Saved script to ${scriptPath}`);
204
- const { command: shellCommand, args } = (0, command_js_1.getShellCommandAndArgs)(this.shell, scriptPath);
205
- this.ctx.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
206
- await (0, spawn_js_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
207
- cwd: this.ctx.workingDirectory,
208
- logger: this.ctx.logger,
209
- env: this.getScriptEnv({ outputsDir, envsDir }),
210
- // stdin is /dev/null, std{out,err} are piped into logger.
211
- stdio: ['ignore', 'pipe', 'pipe'],
212
- });
213
- this.ctx.logger.debug(`Script completed successfully`);
214
- await this.collectAndValidateOutputsAsync(outputsDir);
215
- await this.collectAndUpdateEnvsAsync(envsDir);
216
- this.ctx.logger.debug('Finished collecting output paramters');
217
- }
218
- finally {
219
- await (0, BuildTemporaryFiles_js_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx.global, this.id);
220
- }
219
+ const interpolatedCommand = (0, interpolation_js_1.interpolateJobContext)({
220
+ target: this.command,
221
+ context: this.getInterpolationContext(),
222
+ });
223
+ const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(`${interpolatedCommand}`, this.inputs);
224
+ this.ctx.logger.debug(`Interpolated inputs in the command template`);
225
+ const scriptPath = await (0, BuildTemporaryFiles_js_1.saveScriptToTemporaryFileAsync)(this.ctx.global, this.id, command);
226
+ this.ctx.logger.debug(`Saved script to ${scriptPath}`);
227
+ const { command: shellCommand, args } = (0, command_js_1.getShellCommandAndArgs)(this.shell, scriptPath);
228
+ this.ctx.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
229
+ await (0, spawn_js_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
230
+ cwd: this.ctx.workingDirectory,
231
+ logger: this.ctx.logger,
232
+ env: this.getScriptEnv(),
233
+ // stdin is /dev/null, std{out,err} are piped into logger.
234
+ stdio: ['ignore', 'pipe', 'pipe'],
235
+ });
236
+ this.ctx.logger.debug(`Script completed successfully`);
221
237
  }
222
- async exectuteFnAsync() {
238
+ async executeFnAsync() {
223
239
  (0, assert_1.default)(this.fn, 'Function (fn) must be defined');
224
- try {
225
- const outputsDir = await (0, BuildTemporaryFiles_js_1.createTemporaryOutputsDirectoryAsync)(this.ctx.global, this.id);
226
- this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);
227
- const envsDir = await (0, BuildTemporaryFiles_js_1.createTemporaryEnvsDirectoryAsync)(this.ctx.global, this.id);
228
- this.ctx.logger.debug(`Created temporary directory for step environment variables: ${outputsDir}`);
229
- await this.fn(this.ctx, {
230
- inputs: this.inputById,
231
- outputs: this.outputById,
232
- env: this.getScriptEnv({ outputsDir, envsDir }),
233
- });
234
- this.ctx.logger.debug(`Script completed successfully`);
235
- await this.collectAndValidateOutputsAsync(outputsDir);
236
- await this.collectAndUpdateEnvsAsync(envsDir);
237
- this.ctx.logger.debug('Finished collecting output paramters');
238
- }
239
- finally {
240
- await (0, BuildTemporaryFiles_js_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx.global, this.id);
241
- }
240
+ await this.fn(this.ctx, {
241
+ inputs: this.inputById,
242
+ outputs: this.outputById,
243
+ env: this.getScriptEnv(),
244
+ });
245
+ this.ctx.logger.debug(`Script completed successfully`);
242
246
  }
243
247
  interpolateInputsOutputsAndGlobalContextInTemplate(template, inputs) {
244
248
  if (!inputs) {
@@ -255,12 +259,21 @@ class BuildStep extends BuildStepOutputAccessor {
255
259
  return (0, template_js_1.interpolateWithOutputs)((0, template_js_1.interpolateWithInputs)(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
256
260
  }
257
261
  async collectAndValidateOutputsAsync(outputsDir) {
258
- var _a;
259
262
  const files = await promises_1.default.readdir(outputsDir);
260
263
  const nonDefinedOutputIds = [];
261
264
  for (const outputId of files) {
262
265
  if (!(outputId in this.outputById)) {
263
266
  nonDefinedOutputIds.push(outputId);
267
+ const newOutput = new BuildStepOutput_js_1.BuildStepOutput(this.ctx.global, {
268
+ id: outputId,
269
+ stepDisplayName: this.displayName,
270
+ required: false,
271
+ });
272
+ const file = path_1.default.join(outputsDir, outputId);
273
+ const rawContents = await promises_1.default.readFile(file, 'utf-8');
274
+ const value = rawContents.trim();
275
+ newOutput.set(value);
276
+ this.outputById[outputId] = newOutput;
264
277
  }
265
278
  else {
266
279
  const file = path_1.default.join(outputsDir, outputId);
@@ -274,7 +287,7 @@ class BuildStep extends BuildStepOutputAccessor {
274
287
  this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`);
275
288
  }
276
289
  const nonSetRequiredOutputIds = [];
277
- for (const output of (_a = this.outputs) !== null && _a !== void 0 ? _a : []) {
290
+ for (const output of Object.values(this.outputById)) {
278
291
  try {
279
292
  const value = output.value;
280
293
  this.ctx.logger.debug(`Output parameter "${output.id}" is set to "${value}"`);
@@ -302,18 +315,15 @@ class BuildStep extends BuildStepOutputAccessor {
302
315
  ...Object.fromEntries(entries),
303
316
  });
304
317
  }
305
- get effectiveEnv() {
306
- return { ...this.ctx.global.env, ...this.stepEnvOverrides };
307
- }
308
- getScriptEnv({ envsDir, outputsDir, }) {
318
+ getScriptEnv() {
309
319
  var _a;
310
- const env = this.effectiveEnv;
311
- const currentPath = (_a = env.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
320
+ const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };
321
+ const currentPath = (_a = effectiveEnv.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
312
322
  const newPath = currentPath ? `${bin_js_1.BIN_PATH}:${currentPath}` : bin_js_1.BIN_PATH;
313
323
  return {
314
- ...env,
315
- __EXPO_STEPS_OUTPUTS_DIR: outputsDir,
316
- __EXPO_STEPS_ENVS_DIR: envsDir,
324
+ ...effectiveEnv,
325
+ __EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,
326
+ __EXPO_STEPS_ENVS_DIR: this.envsDir,
317
327
  __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,
318
328
  PATH: newPath,
319
329
  };
@@ -32,6 +32,7 @@ export declare class BuildStepOutputAccessor {
32
32
  protected readonly executed: boolean;
33
33
  protected readonly outputById: BuildStepOutputById;
34
34
  constructor(id: string, displayName: string, executed: boolean, outputById: BuildStepOutputById);
35
+ get outputs(): BuildStepOutput[];
35
36
  getOutputValueByName(name: string): string | undefined;
36
37
  hasOutputParameter(name: string): boolean;
37
38
  serialize(): SerializedBuildStepOutputAccessor;
@@ -43,7 +44,7 @@ export declare class BuildStep extends BuildStepOutputAccessor {
43
44
  readonly displayName: string;
44
45
  readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];
45
46
  readonly inputs?: BuildStepInput[];
46
- readonly outputs?: BuildStepOutput[];
47
+ readonly outputById: BuildStepOutputById;
47
48
  readonly command?: string;
48
49
  readonly fn?: BuildStepFunction;
49
50
  readonly shell: string;
@@ -51,9 +52,10 @@ export declare class BuildStep extends BuildStepOutputAccessor {
51
52
  readonly stepEnvOverrides: BuildStepEnv;
52
53
  readonly ifCondition?: string;
53
54
  status: BuildStepStatus;
55
+ private readonly outputsDir;
56
+ private readonly envsDir;
54
57
  private readonly internalId;
55
58
  private readonly inputById;
56
- protected readonly outputById: BuildStepOutputById;
57
59
  protected executed: boolean;
58
60
  static getNewId(userDefinedId?: string): string;
59
61
  static getDisplayName({ id, name, command, }: {
@@ -76,16 +78,14 @@ export declare class BuildStep extends BuildStepOutputAccessor {
76
78
  ifCondition?: string;
77
79
  });
78
80
  executeAsync(): Promise<void>;
79
- hasOutputParameter(name: string): boolean;
80
- getOutputValueByName(name: string): string | undefined;
81
81
  canBeRunOnRuntimePlatform(): boolean;
82
- shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean;
82
+ shouldExecuteStep(): boolean;
83
83
  skip(): void;
84
+ private getInterpolationContext;
84
85
  private executeCommandAsync;
85
- private exectuteFnAsync;
86
+ private executeFnAsync;
86
87
  private interpolateInputsOutputsAndGlobalContextInTemplate;
87
88
  private collectAndValidateOutputsAsync;
88
89
  private collectAndUpdateEnvsAsync;
89
- private get effectiveEnv();
90
90
  private getScriptEnv;
91
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AAExB,+BAAoC;AAGpC,2DAAoG;AACpG,6DAK8B;AAC9B,iDAAgD;AAChD,yDAAmF;AACnF,qEAKkC;AAClC,qDAAoD;AACpD,qDAAoF;AACpF,2CAAoD;AAGpD,qDAA+C;AAE/C,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;I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,IAAI,CAAC;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,iBAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC;QACtE,OAAO;YACL,GAAG,GAAG;YACN,wBAAwB,EAAE,UAAU;YACpC,qBAAqB,EAAE,OAAO;YAC9B,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF;AAlYD,8BAkYC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\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 { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryEnvsDirectoryAsync,\n createTemporaryOutputsDirectoryAsync,\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';\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 }: { inputs: BuildStepInputById; outputs: BuildStepOutputById; env: BuildStepEnv }\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 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 outputs?: BuildStepOutput[];\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 status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected readonly outputById: BuildStepOutputById;\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 }: {\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 }\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.outputs = outputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? getDefaultShell();\n this.ifCondition = ifCondition;\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 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 if (this.command !== undefined) {\n await this.executeCommandAsync();\n } else {\n await this.exectuteFnAsync();\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 }\n\n public hasOutputParameter(name: string): boolean {\n return name in 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 canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean {\n if (!this.ifCondition) {\n return !hasAnyPreviousStepsFailed;\n }\n\n let ifCondition = this.ifCondition;\n\n if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {\n ifCondition = ifCondition.slice(2, -1);\n }\n\n return Boolean(\n jsepEval(ifCondition, {\n success: () => !hasAnyPreviousStepsFailed,\n failure: () => hasAnyPreviousStepsFailed,\n always: () => true,\n never: () => false,\n env: this.effectiveEnv,\n inputs:\n this.inputs?.reduce(\n (acc, input) => {\n acc[input.id] = input.value;\n return acc;\n },\n {} as Record<string, unknown>\n ) ?? {},\n eas: {\n runtimePlatform: this.ctx.global.runtimePlatform,\n ...this.ctx.global.staticContext,\n },\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 async executeCommandAsync(): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n try {\n const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(\n this.command,\n this.inputs\n );\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\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 await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n // stdin is /dev/null, std{out,err} are piped into logger.\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private async exectuteFnAsync(): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n try {\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n await this.fn(this.ctx, {\n inputs: this.inputById,\n outputs: this.outputById,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\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 acc[input.id] =\n typeof input.value === 'object'\n ? JSON.stringify(input.value)\n : input.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 const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of this.outputs ?? []) {\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 return [basename, rawContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private get effectiveEnv(): Record<string, unknown> {\n return { ...this.ctx.global.env, ...this.stepEnvOverrides };\n }\n\n private getScriptEnv({\n envsDir,\n outputsDir,\n }: {\n envsDir: string;\n outputsDir: string;\n }): Record<string, string> {\n const env = this.effectiveEnv;\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_ENVS_DIR: envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
1
+ {"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AAExB,+BAAoC;AAIpC,2DAAoG;AACpG,6DAK8B;AAC9B,iDAAgD;AAChD,yDAAmF;AACnF,qEAKkC;AAClC,qDAAoD;AACpD,qDAAoF;AACpF,2CAAoD;AAGpD,qDAA+C;AAC/C,yDAA2D;AAE3D,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;AAWD,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,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,iCAAqB,CAC7B,0BAA0B,IAAI,gBAAgB,IAAI,CAAC,WAAW,wCAAwC,CACvG,CAAC;QACJ,CAAC;QACD,IAA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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 { getDefaultShell, 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 }: { inputs: BuildStepInputById; outputs: BuildStepOutputById; env: BuildStepEnv }\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 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 }: {\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 }\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 ?? getDefaultShell();\n this.ifCondition = ifCondition;\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.command !== undefined) {\n await this.executeCommandAsync();\n } else {\n await this.executeFnAsync();\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(2, -1);\n }\n\n return Boolean(\n jsepEval(ifCondition, {\n success: () => !hasAnyPreviousStepFailed,\n failure: () => hasAnyPreviousStepFailed,\n always: () => true,\n never: () => false,\n env: this.getScriptEnv(),\n inputs:\n this.inputs?.reduce(\n (acc, input) => {\n acc[input.id] = input.value;\n return acc;\n },\n {} as Record<string, unknown>\n ) ?? {},\n eas: {\n runtimePlatform: this.ctx.global.runtimePlatform,\n ...this.ctx.global.staticContext,\n },\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 const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;\n\n return {\n ...this.ctx.global.staticContext,\n always: () => true,\n never: () => false,\n success: () => !hasAnyPreviousStepFailed,\n failure: () => hasAnyPreviousStepFailed,\n env: this.getScriptEnv(),\n fromJSON: (json: string) => JSON.parse(json),\n toJSON: (value: unknown) => JSON.stringify(value),\n };\n }\n private async executeCommandAsync(): 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 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 });\n this.ctx.logger.debug(`Script completed successfully`);\n }\n\n private async executeFnAsync(): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n await this.fn(this.ctx, {\n inputs: this.inputById,\n outputs: this.outputById,\n env: this.getScriptEnv(),\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 acc[input.id] =\n typeof input.value === 'object'\n ? JSON.stringify(input.value)\n : input.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 const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n const newOutput = new BuildStepOutput(this.ctx.global, {\n id: outputId,\n stepDisplayName: this.displayName,\n required: false,\n });\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n newOutput.set(value);\n this.outputById[outputId] = newOutput;\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\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 return [basename, rawContents];\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"]}
@@ -15,10 +15,12 @@ class BuildStepGlobalContext {
15
15
  this.provider = provider;
16
16
  this.skipCleanup = skipCleanup;
17
17
  this.didCheckOut = false;
18
+ this._hasAnyPreviousStepFailed = false;
18
19
  this.stepById = {};
19
20
  this.stepsInternalBuildDirectory = path_1.default.join(os_1.default.tmpdir(), 'eas-build', (0, uuid_1.v4)());
20
21
  this.runtimePlatform = provider.runtimePlatform;
21
22
  this.baseLogger = provider.logger;
23
+ this._hasAnyPreviousStepFailed = false;
22
24
  }
23
25
  get projectSourceDirectory() {
24
26
  return this.provider.projectSourceDirectory;
@@ -36,7 +38,17 @@ class BuildStepGlobalContext {
36
38
  return this.provider.env;
37
39
  }
38
40
  get staticContext() {
39
- return this.provider.staticContext();
41
+ return {
42
+ ...this.provider.staticContext(),
43
+ steps: Object.fromEntries(Object.values(this.stepById).map((step) => [
44
+ step.id,
45
+ {
46
+ outputs: Object.fromEntries(step.outputs.map((output) => {
47
+ return [output.id, output.rawValue];
48
+ })),
49
+ },
50
+ ])),
51
+ };
40
52
  }
41
53
  updateEnv(updatedEnv) {
42
54
  this.provider.updateEnv(updatedEnv);
@@ -69,6 +81,12 @@ class BuildStepGlobalContext {
69
81
  this.didCheckOut = true;
70
82
  logger.info(`Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`);
71
83
  }
84
+ get hasAnyPreviousStepFailed() {
85
+ return this._hasAnyPreviousStepFailed;
86
+ }
87
+ markAsFailed() {
88
+ this._hasAnyPreviousStepFailed = true;
89
+ }
72
90
  wasCheckedOut() {
73
91
  return this.didCheckOut;
74
92
  }
@@ -1,4 +1,4 @@
1
- import { BuildStaticContext } from '@expo/eas-build-job';
1
+ import { StaticJobInterpolationContext } from '@expo/eas-build-job';
2
2
  import { bunyan } from '@expo/logger';
3
3
  import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep.js';
4
4
  import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
@@ -9,7 +9,7 @@ interface SerializedExternalBuildContextProvider {
9
9
  defaultWorkingDirectory: string;
10
10
  buildLogsDirectory: string;
11
11
  runtimePlatform: BuildRuntimePlatform;
12
- staticContext: BuildStaticContext;
12
+ staticContext: Omit<StaticJobInterpolationContext, 'steps'>;
13
13
  env: BuildStepEnv;
14
14
  }
15
15
  export interface ExternalBuildContextProvider {
@@ -19,7 +19,7 @@ export interface ExternalBuildContextProvider {
19
19
  readonly buildLogsDirectory: string;
20
20
  readonly runtimePlatform: BuildRuntimePlatform;
21
21
  readonly logger: bunyan;
22
- readonly staticContext: () => BuildStaticContext;
22
+ readonly staticContext: () => Omit<StaticJobInterpolationContext, 'steps'>;
23
23
  readonly env: BuildStepEnv;
24
24
  updateEnv(env: BuildStepEnv): void;
25
25
  }
@@ -36,6 +36,7 @@ export declare class BuildStepGlobalContext {
36
36
  readonly runtimePlatform: BuildRuntimePlatform;
37
37
  readonly baseLogger: bunyan;
38
38
  private didCheckOut;
39
+ private _hasAnyPreviousStepFailed;
39
40
  private stepById;
40
41
  constructor(provider: ExternalBuildContextProvider, skipCleanup: boolean);
41
42
  get projectSourceDirectory(): string;
@@ -43,7 +44,7 @@ export declare class BuildStepGlobalContext {
43
44
  get defaultWorkingDirectory(): string;
44
45
  get buildLogsDirectory(): string;
45
46
  get env(): BuildStepEnv;
46
- get staticContext(): BuildStaticContext;
47
+ get staticContext(): StaticJobInterpolationContext;
47
48
  updateEnv(updatedEnv: BuildStepEnv): void;
48
49
  registerStep(step: BuildStep): void;
49
50
  getStepOutputValue(path: string): string | undefined;
@@ -53,6 +54,8 @@ export declare class BuildStepGlobalContext {
53
54
  relativeWorkingDirectory?: string;
54
55
  }): BuildStepContext;
55
56
  markAsCheckedOut(logger: bunyan): void;
57
+ get hasAnyPreviousStepFailed(): boolean;
58
+ markAsFailed(): void;
56
59
  wasCheckedOut(): boolean;
57
60
  serialize(): SerializedBuildStepGlobalContext;
58
61
  static deserialize(serialized: SerializedBuildStepGlobalContext, logger: bunyan): BuildStepGlobalContext;
@@ -1 +1 @@
1
- {"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAIxB,+BAAoC;AAEpC,iDAIwB;AACxB,qDAI6B;AAC7B,2CAAoD;AAmCpD,MAAa,sBAAsB;IAQjC,YACmB,QAAsC,EACvC,WAAoB;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QACvC,g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nimport { BuildStaticContext } from '@expo/eas-build-job';\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n BuildStep,\n BuildStepOutputAccessor,\n SerializedBuildStepOutputAccessor,\n} from './BuildStep.js';\nimport {\n getObjectValueForInterpolation,\n interpolateWithGlobalContext,\n parseOutputPath,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\n\ninterface SerializedExternalBuildContextProvider {\n projectSourceDirectory: string;\n projectTargetDirectory: string;\n defaultWorkingDirectory: string;\n buildLogsDirectory: string;\n runtimePlatform: BuildRuntimePlatform;\n staticContext: BuildStaticContext;\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: () => BuildStaticContext;\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\n private stepById: Record<string, BuildStepOutputAccessor> = {};\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 }\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(): BuildStaticContext {\n return this.provider.staticContext();\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 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 },\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 wasCheckedOut(): boolean {\n return this.didCheckOut;\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 return this.relativeWorkingDirectory\n ? path.resolve(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory)\n : this.ctx.defaultWorkingDirectory;\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
+ {"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAIxB,+BAAoC;AAEpC,iDAIwB;AACxB,qDAI6B;AAC7B,2CAAoD;AAoCpD,MAAa,sBAAsB;IAQjC,YACmB,QAAsC,EACvC,WAAoB;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QACvC,gBAAW,GAAX,WAAW,CAAS;QAN9B,gBAAW,GAAG,KAAK,CAAC;QACpB,8BAAyB,GAAG,KAAK,CAAC;QAClC,aAAQ,GAA4C,EAAE,CAAC;QAM7D,IAAI,CAAC,2BAA2B,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAA,SAAM,GAAE,CAAC,CAAC;QACjF,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;QAClC,IAAI,CAAC,yBAAyB,GAAG,KAAK,CAAC;IACzC,CAAC;IAED,IAAW,sBAAsB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAC9C,CAAC;IAED,IAAW,sBAAsB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAC9C,CAAC;IAED,IAAW,uBAAuB;QAChC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAChG,CAAC;IAED,IAAW,kBAAkB;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IAC1C,CAAC;IAED,I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AAa,gBAAgB;IAI3B,YACmB,GAA2B,EAC5C,EACE,MAAM,EACN,wBAAwB,GAIzB;QAPgB,QAAG,GAAH,GAAG,CAAwB;QAS5C,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,GAAG,CAAC,UAAU,CAAC;QACvC,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;IAC3D,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,wBAAwB;YAClC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,wBAAwB,CAAC;YAC/E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC;IACvC,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;AA7CD,4CA6CC","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport { StaticJobInterpolationContext } from '@expo/eas-build-job';\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n BuildStep,\n BuildStepOutputAccessor,\n SerializedBuildStepOutputAccessor,\n} from './BuildStep.js';\nimport {\n getObjectValueForInterpolation,\n interpolateWithGlobalContext,\n parseOutputPath,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\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\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 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 },\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 wasCheckedOut(): boolean {\n return this.didCheckOut;\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 return this.relativeWorkingDirectory\n ? path.resolve(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory)\n : this.ctx.defaultWorkingDirectory;\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"]}