@expo/steps 1.0.271 → 18.0.1

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 (74) hide show
  1. package/LICENSE +21 -100
  2. package/README.md +1 -1
  3. package/dist/AbstractConfigParser.js +9 -7
  4. package/dist/BuildConfig.d.ts +1 -1
  5. package/dist/BuildConfig.js +8 -11
  6. package/dist/BuildConfigParser.d.ts +2 -2
  7. package/dist/BuildConfigParser.js +16 -24
  8. package/dist/BuildFunction.d.ts +1 -1
  9. package/dist/BuildFunction.js +18 -8
  10. package/dist/BuildFunctionGroup.js +5 -3
  11. package/dist/BuildRuntimePlatform.js +0 -1
  12. package/dist/BuildStep.d.ts +2 -2
  13. package/dist/BuildStep.js +44 -24
  14. package/dist/BuildStepContext.d.ts +2 -2
  15. package/dist/BuildStepContext.js +22 -16
  16. package/dist/BuildStepEnv.js +0 -1
  17. package/dist/BuildStepInput.js +13 -9
  18. package/dist/BuildStepOutput.js +6 -4
  19. package/dist/BuildTemporaryFiles.js +1 -2
  20. package/dist/BuildWorkflow.js +5 -3
  21. package/dist/BuildWorkflowValidator.js +7 -8
  22. package/dist/StepMetrics.js +0 -1
  23. package/dist/StepsConfigParser.d.ts +2 -2
  24. package/dist/StepsConfigParser.js +12 -16
  25. package/dist/cli/cli.d.ts +1 -1
  26. package/dist/cli/cli.js +11 -6
  27. package/dist/errors.js +7 -4
  28. package/dist/index.js +17 -8
  29. package/dist/interpolation.js +1 -2
  30. package/dist/scripts/runCustomFunction.js +2 -3
  31. package/dist/utils/customFunction.d.ts +1 -1
  32. package/dist/utils/customFunction.js +1 -2
  33. package/dist/utils/expodash/duplicates.js +0 -1
  34. package/dist/utils/expodash/uniq.js +0 -1
  35. package/dist/utils/hashFiles.js +1 -2
  36. package/dist/utils/jsepEval.js +4 -5
  37. package/dist/utils/nullthrows.js +1 -2
  38. package/dist/utils/shell/bin.js +0 -1
  39. package/dist/utils/shell/command.js +0 -1
  40. package/dist/utils/shell/spawn.d.ts +2 -2
  41. package/dist/utils/shell/spawn.js +0 -1
  42. package/dist/utils/template.js +4 -5
  43. package/package.json +26 -29
  44. package/dist/AbstractConfigParser.js.map +0 -1
  45. package/dist/BuildConfig.js.map +0 -1
  46. package/dist/BuildConfigParser.js.map +0 -1
  47. package/dist/BuildFunction.js.map +0 -1
  48. package/dist/BuildFunctionGroup.js.map +0 -1
  49. package/dist/BuildRuntimePlatform.js.map +0 -1
  50. package/dist/BuildStep.js.map +0 -1
  51. package/dist/BuildStepContext.js.map +0 -1
  52. package/dist/BuildStepEnv.js.map +0 -1
  53. package/dist/BuildStepInput.js.map +0 -1
  54. package/dist/BuildStepOutput.js.map +0 -1
  55. package/dist/BuildTemporaryFiles.js.map +0 -1
  56. package/dist/BuildWorkflow.js.map +0 -1
  57. package/dist/BuildWorkflowValidator.js.map +0 -1
  58. package/dist/StepMetrics.js.map +0 -1
  59. package/dist/StepsConfigParser.js.map +0 -1
  60. package/dist/cli/cli.js.map +0 -1
  61. package/dist/errors.js.map +0 -1
  62. package/dist/index.js.map +0 -1
  63. package/dist/interpolation.js.map +0 -1
  64. package/dist/scripts/runCustomFunction.js.map +0 -1
  65. package/dist/utils/customFunction.js.map +0 -1
  66. package/dist/utils/expodash/duplicates.js.map +0 -1
  67. package/dist/utils/expodash/uniq.js.map +0 -1
  68. package/dist/utils/hashFiles.js.map +0 -1
  69. package/dist/utils/jsepEval.js.map +0 -1
  70. package/dist/utils/nullthrows.js.map +0 -1
  71. package/dist/utils/shell/bin.js.map +0 -1
  72. package/dist/utils/shell/command.js.map +0 -1
  73. package/dist/utils/shell/spawn.js.map +0 -1
  74. package/dist/utils/template.js.map +0 -1
package/dist/BuildStep.js CHANGED
@@ -5,20 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BuildStep = exports.BuildStepOutputAccessor = exports.BuildStepLogMarker = exports.BuildStepStatus = void 0;
7
7
  const assert_1 = __importDefault(require("assert"));
8
+ const buffer_1 = require("buffer");
8
9
  const promises_1 = __importDefault(require("fs/promises"));
9
10
  const path_1 = __importDefault(require("path"));
10
- const buffer_1 = require("buffer");
11
11
  const uuid_1 = require("uuid");
12
12
  const BuildStepInput_1 = require("./BuildStepInput");
13
13
  const BuildStepOutput_1 = require("./BuildStepOutput");
14
+ const BuildTemporaryFiles_1 = require("./BuildTemporaryFiles");
15
+ const errors_1 = require("./errors");
16
+ const interpolation_1 = require("./interpolation");
17
+ const jsepEval_1 = require("./utils/jsepEval");
14
18
  const bin_1 = require("./utils/shell/bin");
15
19
  const command_1 = require("./utils/shell/command");
16
- const BuildTemporaryFiles_1 = require("./BuildTemporaryFiles");
17
20
  const spawn_1 = require("./utils/shell/spawn");
18
21
  const template_1 = require("./utils/template");
19
- const errors_1 = require("./errors");
20
- const jsepEval_1 = require("./utils/jsepEval");
21
- const interpolation_1 = require("./interpolation");
22
22
  var BuildStepStatus;
23
23
  (function (BuildStepStatus) {
24
24
  BuildStepStatus["NEW"] = "new";
@@ -36,6 +36,10 @@ var BuildStepLogMarker;
36
36
  // TODO: move to a place common with tests
37
37
  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}$/;
38
38
  class BuildStepOutputAccessor {
39
+ id;
40
+ displayName;
41
+ executed;
42
+ outputById;
39
43
  constructor(id, displayName, executed, outputById) {
40
44
  this.id = id;
41
45
  this.displayName = displayName;
@@ -75,8 +79,28 @@ class BuildStepOutputAccessor {
75
79
  }
76
80
  exports.BuildStepOutputAccessor = BuildStepOutputAccessor;
77
81
  class BuildStep extends BuildStepOutputAccessor {
82
+ id;
83
+ name;
84
+ displayName;
85
+ supportedRuntimePlatforms;
86
+ inputs;
87
+ outputById;
88
+ command;
89
+ fn;
90
+ shell;
91
+ ctx;
92
+ stepEnvOverrides;
93
+ ifCondition;
94
+ timeoutMs;
95
+ __metricsId;
96
+ status;
97
+ outputsDir;
98
+ envsDir;
99
+ internalId;
100
+ inputById;
101
+ executed = false;
78
102
  static getNewId(userDefinedId) {
79
- return userDefinedId !== null && userDefinedId !== void 0 ? userDefinedId : (0, uuid_1.v4)();
103
+ return userDefinedId ?? (0, uuid_1.v4)();
80
104
  }
81
105
  static getDisplayName({ id, name, command, }) {
82
106
  if (name) {
@@ -101,7 +125,6 @@ class BuildStep extends BuildStepOutputAccessor {
101
125
  (0, assert_1.default)(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');
102
126
  const outputById = (0, BuildStepOutput_1.makeBuildStepOutputByIdMap)(outputs);
103
127
  super(id, displayName, false, outputById);
104
- this.executed = false;
105
128
  this.id = id;
106
129
  this.name = name;
107
130
  this.displayName = displayName;
@@ -111,7 +134,7 @@ class BuildStep extends BuildStepOutputAccessor {
111
134
  this.outputById = outputById;
112
135
  this.fn = fn;
113
136
  this.command = command;
114
- this.shell = shell !== null && shell !== void 0 ? shell : '/bin/bash -eo pipefail';
137
+ this.shell = shell ?? '/bin/bash -eo pipefail';
115
138
  this.ifCondition = ifCondition;
116
139
  this.timeoutMs = timeoutMs;
117
140
  this.__metricsId = __metricsId;
@@ -123,7 +146,7 @@ class BuildStep extends BuildStepOutputAccessor {
123
146
  buildStepDisplayName: this.displayName,
124
147
  });
125
148
  this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });
126
- this.stepEnvOverrides = env !== null && env !== void 0 ? env : {};
149
+ this.stepEnvOverrides = env ?? {};
127
150
  this.outputsDir = (0, BuildTemporaryFiles_1.getTemporaryOutputsDirPath)(ctx, this.id);
128
151
  this.envsDir = (0, BuildTemporaryFiles_1.getTemporaryEnvsDirPath)(ctx, this.id);
129
152
  ctx.registerStep(this);
@@ -198,7 +221,6 @@ class BuildStep extends BuildStepOutputAccessor {
198
221
  this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform));
199
222
  }
200
223
  shouldExecuteStep() {
201
- var _a, _b;
202
224
  const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;
203
225
  if (!this.ifCondition) {
204
226
  return !hasAnyPreviousStepFailed;
@@ -211,12 +233,12 @@ class BuildStep extends BuildStepOutputAccessor {
211
233
  ifCondition = ifCondition.slice(2, -1);
212
234
  }
213
235
  return Boolean((0, jsepEval_1.jsepEval)(ifCondition, {
214
- inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
236
+ inputs: this.inputs?.reduce((acc, input) => {
215
237
  acc[input.id] = input.getValue({
216
238
  interpolationContext: this.getInterpolationContext(),
217
239
  });
218
240
  return acc;
219
- }, {})) !== null && _b !== void 0 ? _b : {},
241
+ }, {}) ?? {},
220
242
  eas: {
221
243
  runtimePlatform: this.ctx.global.runtimePlatform,
222
244
  ...this.ctx.global.staticContext,
@@ -256,20 +278,20 @@ class BuildStep extends BuildStepOutputAccessor {
256
278
  }
257
279
  }
258
280
  catch (err) {
259
- if ((err === null || err === void 0 ? void 0 : err.code) === 'ENOENT') {
281
+ if (err?.code === 'ENOENT') {
260
282
  this.ctx.logger.error({ err }, `Working directory "${this.ctx.workingDirectory}" does not exist`);
261
283
  }
262
284
  else {
263
285
  this.ctx.logger.error({ err }, `Cannot access working directory "${this.ctx.workingDirectory}"`);
264
286
  }
265
287
  }
266
- await (0, spawn_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
288
+ await (0, spawn_1.spawnAsync)(shellCommand, args ?? [], {
267
289
  cwd: this.ctx.workingDirectory,
268
290
  logger: this.ctx.logger,
269
291
  env: this.getScriptEnv(),
270
292
  // stdin is /dev/null, std{out,err} are piped into logger.
271
293
  stdio: ['ignore', 'pipe', 'pipe'],
272
- signal: signal !== null && signal !== void 0 ? signal : undefined,
294
+ signal: signal ?? undefined,
273
295
  });
274
296
  this.ctx.logger.debug(`Script completed successfully`);
275
297
  }
@@ -282,21 +304,21 @@ class BuildStep extends BuildStepOutputAccessor {
282
304
  ])),
283
305
  outputs: this.outputById,
284
306
  env: this.getScriptEnv(),
285
- signal: signal !== null && signal !== void 0 ? signal : undefined,
307
+ signal: signal ?? undefined,
286
308
  });
287
309
  this.ctx.logger.debug(`Script completed successfully`);
288
310
  }
289
311
  interpolateInputsOutputsAndGlobalContextInTemplate(template, inputs) {
290
312
  if (!inputs) {
291
- return (0, template_1.interpolateWithOutputs)(this.ctx.global.interpolate(template), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
313
+ return (0, template_1.interpolateWithOutputs)(this.ctx.global.interpolate(template), path => this.ctx.global.getStepOutputValue(path) ?? '');
292
314
  }
293
315
  const vars = inputs.reduce((acc, input) => {
294
- var _a;
295
316
  const value = input.getValue({ interpolationContext: this.getInterpolationContext() });
296
- acc[input.id] = typeof value === 'object' ? JSON.stringify(value) : (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '';
317
+ acc[input.id] =
318
+ typeof value === 'object' ? JSON.stringify(value) : (value?.toString() ?? '');
297
319
  return acc;
298
320
  }, {});
299
- return (0, template_1.interpolateWithOutputs)((0, template_1.interpolateWithInputs)(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
321
+ return (0, template_1.interpolateWithOutputs)((0, template_1.interpolateWithInputs)(this.ctx.global.interpolate(template), vars), path => this.ctx.global.getStepOutputValue(path) ?? '');
300
322
  }
301
323
  async collectAndValidateOutputsAsync(outputsDir) {
302
324
  const files = await promises_1.default.readdir(outputsDir);
@@ -326,7 +348,7 @@ class BuildStep extends BuildStepOutputAccessor {
326
348
  }
327
349
  }
328
350
  if (nonSetRequiredOutputIds.length > 0) {
329
- const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
351
+ const idsString = nonSetRequiredOutputIds.map(i => `"${i}"`).join(', ');
330
352
  throw new errors_1.BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {
331
353
  metadata: { ids: nonSetRequiredOutputIds },
332
354
  });
@@ -345,9 +367,8 @@ class BuildStep extends BuildStepOutputAccessor {
345
367
  });
346
368
  }
347
369
  getScriptEnv() {
348
- var _a;
349
370
  const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };
350
- const currentPath = (_a = effectiveEnv.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
371
+ const currentPath = effectiveEnv.PATH ?? process.env.PATH;
351
372
  const newPath = currentPath ? `${bin_1.BIN_PATH}:${currentPath}` : bin_1.BIN_PATH;
352
373
  return {
353
374
  ...effectiveEnv,
@@ -359,4 +380,3 @@ class BuildStep extends BuildStepOutputAccessor {
359
380
  }
360
381
  }
361
382
  exports.BuildStep = BuildStep;
362
- //# sourceMappingURL=BuildStep.js.map
@@ -1,9 +1,9 @@
1
1
  import { JobInterpolationContext, StaticJobInterpolationContext } from '@expo/eas-build-job';
2
2
  import { bunyan } from '@expo/logger';
3
- import { StepMetricInput, StepMetricsCollection } from './StepMetrics';
4
- import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep';
5
3
  import { BuildRuntimePlatform } from './BuildRuntimePlatform';
4
+ import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep';
6
5
  import { BuildStepEnv } from './BuildStepEnv';
6
+ import { StepMetricInput, StepMetricsCollection } from './StepMetrics';
7
7
  interface SerializedExternalBuildContextProvider {
8
8
  projectSourceDirectory: string;
9
9
  projectTargetDirectory: string;
@@ -4,22 +4,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BuildStepContext = exports.BuildStepGlobalContext = void 0;
7
+ const fast_glob_1 = __importDefault(require("fast-glob"));
7
8
  const os_1 = __importDefault(require("os"));
8
9
  const path_1 = __importDefault(require("path"));
9
- const fast_glob_1 = __importDefault(require("fast-glob"));
10
10
  const uuid_1 = require("uuid");
11
- const hashFiles_1 = require("./utils/hashFiles");
12
11
  const BuildStep_1 = require("./BuildStep");
13
- const template_1 = require("./utils/template");
14
12
  const errors_1 = require("./errors");
13
+ const hashFiles_1 = require("./utils/hashFiles");
14
+ const template_1 = require("./utils/template");
15
15
  class BuildStepGlobalContext {
16
+ provider;
17
+ skipCleanup;
18
+ stepsInternalBuildDirectory;
19
+ runtimePlatform;
20
+ baseLogger;
21
+ didCheckOut = false;
22
+ _hasAnyPreviousStepFailed = false;
23
+ stepById = {};
24
+ _stepMetrics = [];
16
25
  constructor(provider, skipCleanup) {
17
26
  this.provider = provider;
18
27
  this.skipCleanup = skipCleanup;
19
- this.didCheckOut = false;
20
- this._hasAnyPreviousStepFailed = false;
21
- this.stepById = {};
22
- this._stepMetrics = [];
23
28
  this.stepsInternalBuildDirectory = path_1.default.join(os_1.default.tmpdir(), 'eas-build', (0, uuid_1.v4)());
24
29
  this.runtimePlatform = provider.runtimePlatform;
25
30
  this.baseLogger = provider.logger;
@@ -43,10 +48,10 @@ class BuildStepGlobalContext {
43
48
  get staticContext() {
44
49
  return {
45
50
  ...this.provider.staticContext(),
46
- steps: Object.fromEntries(Object.values(this.stepById).map((step) => [
51
+ steps: Object.fromEntries(Object.values(this.stepById).map(step => [
47
52
  step.id,
48
53
  {
49
- outputs: Object.fromEntries(step.outputs.map((output) => {
54
+ outputs: Object.fromEntries(step.outputs.map(output => {
50
55
  return [output.id, output.rawValue];
51
56
  })),
52
57
  },
@@ -91,15 +96,14 @@ class BuildStepGlobalContext {
91
96
  };
92
97
  }
93
98
  interpolate(value) {
94
- return (0, template_1.interpolateWithGlobalContext)(value, (path) => {
95
- var _a, _b;
96
- return ((_b = (_a = (0, template_1.getObjectValueForInterpolation)(path, {
99
+ return (0, template_1.interpolateWithGlobalContext)(value, path => {
100
+ return ((0, template_1.getObjectValueForInterpolation)(path, {
97
101
  eas: {
98
102
  runtimePlatform: this.runtimePlatform,
99
103
  ...this.staticContext,
100
104
  env: this.env,
101
105
  },
102
- })) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '');
106
+ })?.toString() ?? '');
103
107
  });
104
108
  }
105
109
  stepCtx(options) {
@@ -136,7 +140,7 @@ class BuildStepGlobalContext {
136
140
  if (filePaths.length === 0) {
137
141
  return '';
138
142
  }
139
- const validFilePaths = filePaths.filter((file) => file.startsWith(`${workspacePath}${path_1.default.sep}`));
143
+ const validFilePaths = filePaths.filter(file => file.startsWith(`${workspacePath}${path_1.default.sep}`));
140
144
  if (validFilePaths.length === 0) {
141
145
  return '';
142
146
  }
@@ -180,9 +184,12 @@ class BuildStepGlobalContext {
180
184
  }
181
185
  exports.BuildStepGlobalContext = BuildStepGlobalContext;
182
186
  class BuildStepContext {
187
+ ctx;
188
+ logger;
189
+ relativeWorkingDirectory;
183
190
  constructor(ctx, { logger, relativeWorkingDirectory, }) {
184
191
  this.ctx = ctx;
185
- this.logger = logger !== null && logger !== void 0 ? logger : ctx.baseLogger;
192
+ this.logger = logger ?? ctx.baseLogger;
186
193
  this.relativeWorkingDirectory = relativeWorkingDirectory;
187
194
  }
188
195
  get global() {
@@ -212,4 +219,3 @@ class BuildStepContext {
212
219
  }
213
220
  }
214
221
  exports.BuildStepContext = BuildStepContext;
215
- //# sourceMappingURL=BuildStepContext.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=BuildStepEnv.js.map
@@ -7,8 +7,8 @@ exports.BuildStepInput = exports.BuildStepInputValueTypeName = void 0;
7
7
  exports.makeBuildStepInputByIdMap = makeBuildStepInputByIdMap;
8
8
  const assert_1 = __importDefault(require("assert"));
9
9
  const errors_1 = require("./errors");
10
- const template_1 = require("./utils/template");
11
10
  const interpolation_1 = require("./interpolation");
11
+ const template_1 = require("./utils/template");
12
12
  var BuildStepInputValueTypeName;
13
13
  (function (BuildStepInputValueTypeName) {
14
14
  BuildStepInputValueTypeName["STRING"] = "string";
@@ -17,6 +17,14 @@ var BuildStepInputValueTypeName;
17
17
  BuildStepInputValueTypeName["JSON"] = "json";
18
18
  })(BuildStepInputValueTypeName || (exports.BuildStepInputValueTypeName = BuildStepInputValueTypeName = {}));
19
19
  class BuildStepInput {
20
+ ctx;
21
+ id;
22
+ stepDisplayName;
23
+ defaultValue;
24
+ allowedValues;
25
+ allowedValueTypeName;
26
+ required;
27
+ _value;
20
28
  static createProvider(params) {
21
29
  return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });
22
30
  }
@@ -30,8 +38,7 @@ class BuildStepInput {
30
38
  this.allowedValueTypeName = allowedValueTypeName;
31
39
  }
32
40
  getValue({ interpolationContext, }) {
33
- var _a;
34
- const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
41
+ const rawValue = this._value ?? this.defaultValue;
35
42
  if (this.required && rawValue === undefined) {
36
43
  throw new errors_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
37
44
  }
@@ -56,14 +63,13 @@ class BuildStepInput {
56
63
  // so this will never be true.
57
64
  (0, assert_1.default)(interpolatedValue !== undefined);
58
65
  const valueInterpolatedWithGlobalContext = this.ctx.interpolate(interpolatedValue);
59
- const valueInterpolatedWithOutputsAndGlobalContext = (0, template_1.interpolateWithOutputs)(valueInterpolatedWithGlobalContext, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
66
+ const valueInterpolatedWithOutputsAndGlobalContext = (0, template_1.interpolateWithOutputs)(valueInterpolatedWithGlobalContext, path => this.ctx.getStepOutputValue(path) ?? '');
60
67
  returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);
61
68
  }
62
69
  return returnValue;
63
70
  }
64
71
  get rawValue() {
65
- var _a;
66
- return (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
72
+ return this._value ?? this.defaultValue;
67
73
  }
68
74
  set(value) {
69
75
  if (this.required && value === undefined) {
@@ -73,8 +79,7 @@ class BuildStepInput {
73
79
  return this;
74
80
  }
75
81
  isRawValueOneOfAllowedValues() {
76
- var _a;
77
- const value = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
82
+ const value = this._value ?? this.defaultValue;
78
83
  if (this.allowedValues === undefined || value === undefined) {
79
84
  return true;
80
85
  }
@@ -155,4 +160,3 @@ function makeBuildStepInputByIdMap(inputs) {
155
160
  return acc;
156
161
  }, {});
157
162
  }
158
- //# sourceMappingURL=BuildStepInput.js.map
@@ -4,12 +4,15 @@ exports.BuildStepOutput = void 0;
4
4
  exports.makeBuildStepOutputByIdMap = makeBuildStepOutputByIdMap;
5
5
  const errors_1 = require("./errors");
6
6
  class BuildStepOutput {
7
+ ctx;
8
+ id;
9
+ stepDisplayName;
10
+ required;
11
+ _value;
7
12
  static createProvider(params) {
8
13
  return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });
9
14
  }
10
- constructor(
11
- // @ts-expect-error ctx is not used in this class but let's keep it here for consistency
12
- ctx, { id, stepDisplayName, required }) {
15
+ constructor(ctx, { id, stepDisplayName, required }) {
13
16
  this.ctx = ctx;
14
17
  this.id = id;
15
18
  this.stepDisplayName = stepDisplayName;
@@ -59,4 +62,3 @@ function makeBuildStepOutputByIdMap(outputs) {
59
62
  return acc;
60
63
  }, {});
61
64
  }
62
- //# sourceMappingURL=BuildStepOutput.js.map
@@ -7,8 +7,8 @@ exports.saveScriptToTemporaryFileAsync = saveScriptToTemporaryFileAsync;
7
7
  exports.cleanUpStepTemporaryDirectoriesAsync = cleanUpStepTemporaryDirectoriesAsync;
8
8
  exports.getTemporaryOutputsDirPath = getTemporaryOutputsDirPath;
9
9
  exports.getTemporaryEnvsDirPath = getTemporaryEnvsDirPath;
10
- const path_1 = __importDefault(require("path"));
11
10
  const promises_1 = __importDefault(require("fs/promises"));
11
+ const path_1 = __importDefault(require("path"));
12
12
  const uuid_1 = require("uuid");
13
13
  async function saveScriptToTemporaryFileAsync(ctx, stepId, scriptContents) {
14
14
  const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);
@@ -37,4 +37,3 @@ function getTemporaryOutputsDirPath(ctx, stepId) {
37
37
  function getTemporaryEnvsDirPath(ctx, stepId) {
38
38
  return path_1.default.join(getTemporaryStepDirPath(ctx, stepId), 'envs');
39
39
  }
40
- //# sourceMappingURL=BuildTemporaryFiles.js.map
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BuildWorkflow = void 0;
4
4
  class BuildWorkflow {
5
+ ctx;
6
+ buildSteps;
7
+ buildFunctions;
5
8
  constructor(ctx, { buildSteps, buildFunctions }) {
6
9
  this.ctx = ctx;
7
10
  this.buildSteps = buildSteps;
@@ -17,7 +20,7 @@ class BuildWorkflow {
17
20
  catch (err) {
18
21
  step.ctx.logger.error({ err });
19
22
  step.ctx.logger.error(`Runner failed to evaluate if it should execute step "${step.displayName}", using step's if condition "${step.ifCondition}". This can be caused by trying to access non-existing object property. If you think this is a bug report it here: https://github.com/expo/eas-cli/issues.`);
20
- maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err;
23
+ maybeError = maybeError ?? err;
21
24
  this.ctx.markAsFailed();
22
25
  }
23
26
  if (shouldExecuteStep) {
@@ -29,7 +32,7 @@ class BuildWorkflow {
29
32
  }
30
33
  catch (err) {
31
34
  stepResult = 'failed';
32
- maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err;
35
+ maybeError = maybeError ?? err;
33
36
  this.ctx.markAsFailed();
34
37
  }
35
38
  finally {
@@ -56,4 +59,3 @@ class BuildWorkflow {
56
59
  }
57
60
  }
58
61
  exports.BuildWorkflow = BuildWorkflow;
59
- //# sourceMappingURL=BuildWorkflow.js.map
@@ -4,14 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BuildWorkflowValidator = void 0;
7
- const path_1 = __importDefault(require("path"));
8
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
9
  const BuildStepInput_1 = require("./BuildStepInput");
10
10
  const errors_1 = require("./errors");
11
11
  const duplicates_1 = require("./utils/expodash/duplicates");
12
12
  const nullthrows_1 = require("./utils/nullthrows");
13
13
  const template_1 = require("./utils/template");
14
14
  class BuildWorkflowValidator {
15
+ workflow;
15
16
  constructor(workflow) {
16
17
  this.workflow = workflow;
17
18
  }
@@ -32,17 +33,16 @@ class BuildWorkflowValidator {
32
33
  return [];
33
34
  }
34
35
  else {
35
- const error = new errors_1.BuildConfigError(`Duplicated step IDs: ${duplicatedStepIds.map((i) => `"${i}"`).join(', ')}`);
36
+ const error = new errors_1.BuildConfigError(`Duplicated step IDs: ${duplicatedStepIds.map(i => `"${i}"`).join(', ')}`);
36
37
  return [error];
37
38
  }
38
39
  }
39
40
  validateInputs() {
40
- var _a;
41
41
  const errors = [];
42
- const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));
42
+ const allStepIds = new Set(this.workflow.buildSteps.map(s => s.id));
43
43
  const visitedStepByStepId = {};
44
44
  for (const currentStep of this.workflow.buildSteps) {
45
- for (const currentStepInput of (_a = currentStep.inputs) !== null && _a !== void 0 ? _a : []) {
45
+ for (const currentStepInput of currentStep.inputs ?? []) {
46
46
  if (currentStepInput.required && currentStepInput.rawValue === undefined) {
47
47
  const error = new errors_1.BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is required but it was not set.`);
48
48
  errors.push(error);
@@ -63,7 +63,7 @@ class BuildWorkflowValidator {
63
63
  }
64
64
  if (!currentStepInput.isRawValueOneOfAllowedValues()) {
65
65
  const error = new errors_1.BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${currentStepInput.rawValue}" which is not one of the allowed values: ${(0, nullthrows_1.nullthrows)(currentStepInput.allowedValues)
66
- .map((i) => `"${i}"`)
66
+ .map(i => `"${i}"`)
67
67
  .join(', ')}.`);
68
68
  errors.push(error);
69
69
  }
@@ -98,7 +98,7 @@ class BuildWorkflowValidator {
98
98
  for (const step of this.workflow.buildSteps) {
99
99
  if (!step.canBeRunOnRuntimePlatform()) {
100
100
  const error = new errors_1.BuildConfigError(`Step "${step.displayName}" is not allowed on platform "${step.ctx.global.runtimePlatform}". Allowed platforms for this step are: ${(0, nullthrows_1.nullthrows)(step.supportedRuntimePlatforms, `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`)
101
- .map((p) => `"${p}"`)
101
+ .map(p => `"${p}"`)
102
102
  .join(', ')}.`);
103
103
  errors.push(error);
104
104
  }
@@ -125,4 +125,3 @@ class BuildWorkflowValidator {
125
125
  }
126
126
  }
127
127
  exports.BuildWorkflowValidator = BuildWorkflowValidator;
128
- //# sourceMappingURL=BuildWorkflowValidator.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=StepMetrics.js.map
@@ -1,9 +1,9 @@
1
1
  import { Step } from '@expo/eas-build-job';
2
+ import { AbstractConfigParser } from './AbstractConfigParser';
2
3
  import { BuildFunction, BuildFunctionById } from './BuildFunction';
3
4
  import { BuildFunctionGroup } from './BuildFunctionGroup';
4
- import { BuildStepGlobalContext } from './BuildStepContext';
5
5
  import { BuildStep } from './BuildStep';
6
- import { AbstractConfigParser } from './AbstractConfigParser';
6
+ import { BuildStepGlobalContext } from './BuildStepContext';
7
7
  export declare class StepsConfigParser extends AbstractConfigParser {
8
8
  private readonly steps;
9
9
  constructor(ctx: BuildStepGlobalContext, { steps, externalFunctions, externalFunctionGroups, }: {
@@ -4,14 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.StepsConfigParser = void 0;
7
- const node_assert_1 = __importDefault(require("node:assert"));
8
7
  const eas_build_job_1 = require("@expo/eas-build-job");
8
+ const node_assert_1 = __importDefault(require("node:assert"));
9
+ const AbstractConfigParser_1 = require("./AbstractConfigParser");
9
10
  const BuildFunctionGroup_1 = require("./BuildFunctionGroup");
10
11
  const BuildStep_1 = require("./BuildStep");
11
- const AbstractConfigParser_1 = require("./AbstractConfigParser");
12
- const errors_1 = require("./errors");
13
12
  const BuildStepOutput_1 = require("./BuildStepOutput");
13
+ const errors_1 = require("./errors");
14
14
  class StepsConfigParser extends AbstractConfigParser_1.AbstractConfigParser {
15
+ steps;
15
16
  constructor(ctx, { steps, externalFunctions, externalFunctionGroups, }) {
16
17
  super(ctx, {
17
18
  externalFunctions,
@@ -20,14 +21,13 @@ class StepsConfigParser extends AbstractConfigParser_1.AbstractConfigParser {
20
21
  this.steps = steps;
21
22
  }
22
23
  async parseConfigToBuildStepsAndBuildFunctionByIdMappingAsync() {
23
- var _a;
24
24
  const validatedSteps = (0, eas_build_job_1.validateSteps)(this.steps);
25
25
  StepsConfigParser.validateAllFunctionsExist(validatedSteps, {
26
26
  externalFunctionIds: this.getExternalFunctionFullIds(),
27
27
  externalFunctionGroupIds: this.getExternalFunctionGroupFullIds(),
28
28
  });
29
29
  const buildFunctionById = this.createBuildFunctionByIdMappingForExternalFunctions();
30
- const buildFunctionGroupById = (0, BuildFunctionGroup_1.createBuildFunctionGroupByIdMapping)((_a = this.externalFunctionGroups) !== null && _a !== void 0 ? _a : []);
30
+ const buildFunctionGroupById = (0, BuildFunctionGroup_1.createBuildFunctionGroupByIdMapping)(this.externalFunctionGroups ?? []);
31
31
  const buildSteps = [];
32
32
  for (const stepConfig of validatedSteps) {
33
33
  buildSteps.push(...this.createBuildStepsFromStepConfig(stepConfig, {
@@ -106,14 +106,11 @@ class StepsConfigParser extends AbstractConfigParser_1.AbstractConfigParser {
106
106
  ];
107
107
  }
108
108
  createBuildStepOutputsFromDefinition(stepOutputs, stepDisplayName) {
109
- return stepOutputs.map((entry) => {
110
- var _a;
111
- return new BuildStepOutput_1.BuildStepOutput(this.ctx, {
112
- id: entry.name,
113
- stepDisplayName,
114
- required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
115
- });
116
- });
109
+ return stepOutputs.map(entry => new BuildStepOutput_1.BuildStepOutput(this.ctx, {
110
+ id: entry.name,
111
+ stepDisplayName,
112
+ required: entry.required ?? true,
113
+ }));
117
114
  }
118
115
  static validateAllFunctionsExist(steps, { externalFunctionIds, externalFunctionGroupIds, }) {
119
116
  const calledFunctionsOrFunctionGroupsSet = new Set();
@@ -125,16 +122,15 @@ class StepsConfigParser extends AbstractConfigParser_1.AbstractConfigParser {
125
122
  const calledFunctionsOrFunctionGroup = Array.from(calledFunctionsOrFunctionGroupsSet);
126
123
  const externalFunctionIdsSet = new Set(externalFunctionIds);
127
124
  const externalFunctionGroupsIdsSet = new Set(externalFunctionGroupIds);
128
- const nonExistentFunctionsOrFunctionGroups = calledFunctionsOrFunctionGroup.filter((calledFunctionOrFunctionGroup) => {
125
+ const nonExistentFunctionsOrFunctionGroups = calledFunctionsOrFunctionGroup.filter(calledFunctionOrFunctionGroup => {
129
126
  return (!externalFunctionIdsSet.has(calledFunctionOrFunctionGroup) &&
130
127
  !externalFunctionGroupsIdsSet.has(calledFunctionOrFunctionGroup));
131
128
  });
132
129
  if (nonExistentFunctionsOrFunctionGroups.length > 0) {
133
130
  throw new errors_1.BuildConfigError(`Calling non-existent functions: ${nonExistentFunctionsOrFunctionGroups
134
- .map((f) => `"${f}"`)
131
+ .map(f => `"${f}"`)
135
132
  .join(', ')}.`);
136
133
  }
137
134
  }
138
135
  }
139
136
  exports.StepsConfigParser = StepsConfigParser;
140
- //# sourceMappingURL=StepsConfigParser.js.map
package/dist/cli/cli.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { StaticJobInterpolationContext } from '@expo/eas-build-job';
2
2
  import { bunyan } from '@expo/logger';
3
- import { ExternalBuildContextProvider } from '../BuildStepContext';
4
3
  import { BuildRuntimePlatform } from '../BuildRuntimePlatform';
4
+ import { ExternalBuildContextProvider } from '../BuildStepContext';
5
5
  import { BuildStepEnv } from '../BuildStepEnv';
6
6
  export declare class CliContextProvider implements ExternalBuildContextProvider {
7
7
  readonly logger: bunyan;
package/dist/cli/cli.js CHANGED
@@ -2,11 +2,10 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- var _a;
6
5
  Object.defineProperty(exports, "__esModule", { value: true });
7
6
  exports.CliContextProvider = void 0;
8
- const path_1 = __importDefault(require("path"));
9
7
  const logger_1 = require("@expo/logger");
8
+ const path_1 = __importDefault(require("path"));
10
9
  const BuildConfigParser_1 = require("../BuildConfigParser");
11
10
  const BuildStepContext_1 = require("../BuildStepContext");
12
11
  const errors_1 = require("../errors");
@@ -15,6 +14,13 @@ const logger = (0, logger_1.createLogger)({
15
14
  level: 'info',
16
15
  });
17
16
  class CliContextProvider {
17
+ logger;
18
+ runtimePlatform;
19
+ projectSourceDirectory;
20
+ projectTargetDirectory;
21
+ defaultWorkingDirectory;
22
+ buildLogsDirectory;
23
+ _env = {};
18
24
  constructor(logger, runtimePlatform, projectSourceDirectory, projectTargetDirectory, defaultWorkingDirectory, buildLogsDirectory) {
19
25
  this.logger = logger;
20
26
  this.runtimePlatform = runtimePlatform;
@@ -22,7 +28,6 @@ class CliContextProvider {
22
28
  this.projectTargetDirectory = projectTargetDirectory;
23
29
  this.defaultWorkingDirectory = defaultWorkingDirectory;
24
30
  this.buildLogsDirectory = buildLogsDirectory;
25
- this._env = {};
26
31
  }
27
32
  get env() {
28
33
  return this._env;
@@ -49,14 +54,15 @@ async function runAsync(configPath, relativeProjectDirectory, runtimePlatform) {
49
54
  }
50
55
  const relativeConfigPath = process.argv[2];
51
56
  const relativeProjectDirectoryPath = process.argv[3];
52
- const platform = ((_a = process.argv[4]) !== null && _a !== void 0 ? _a : process.platform);
57
+ const platform = (process.argv[4] ??
58
+ process.platform);
53
59
  if (!relativeConfigPath || !relativeProjectDirectoryPath) {
54
60
  console.error('Usage: yarn cli config.yml path/to/project/directory [darwin|linux]');
55
61
  process.exit(1);
56
62
  }
57
63
  const configPath = path_1.default.resolve(process.cwd(), relativeConfigPath);
58
64
  const workingDirectory = path_1.default.resolve(process.cwd(), relativeProjectDirectoryPath);
59
- runAsync(configPath, workingDirectory, platform).catch((err) => {
65
+ runAsync(configPath, workingDirectory, platform).catch(err => {
60
66
  logger.error({ err }, 'Build failed');
61
67
  if (err instanceof errors_1.BuildWorkflowError) {
62
68
  logger.error('Failed to parse the custom build config file.');
@@ -65,4 +71,3 @@ runAsync(configPath, workingDirectory, platform).catch((err) => {
65
71
  }
66
72
  }
67
73
  });
68
- //# sourceMappingURL=cli.js.map