@expo/steps 1.0.263 → 1.0.271

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/{dist_commonjs → dist}/AbstractConfigParser.d.ts +5 -5
  2. package/{dist_commonjs/AbstractConfigParser.cjs → dist/AbstractConfigParser.js} +13 -13
  3. package/dist/AbstractConfigParser.js.map +1 -0
  4. package/{dist_commonjs → dist}/BuildConfig.d.ts +4 -3
  5. package/{dist_commonjs/BuildConfig.cjs → dist/BuildConfig.js} +24 -22
  6. package/dist/BuildConfig.js.map +1 -0
  7. package/{dist_esm → dist}/BuildConfigParser.d.ts +5 -5
  8. package/{dist_commonjs/BuildConfigParser.cjs → dist/BuildConfigParser.js} +33 -32
  9. package/dist/BuildConfigParser.js.map +1 -0
  10. package/{dist_esm → dist}/BuildFunction.d.ts +9 -7
  11. package/{dist_commonjs/BuildFunction.cjs → dist/BuildFunction.js} +9 -7
  12. package/dist/BuildFunction.js.map +1 -0
  13. package/{dist_commonjs → dist}/BuildFunctionGroup.d.ts +4 -4
  14. package/{dist_commonjs/BuildFunctionGroup.cjs → dist/BuildFunctionGroup.js} +4 -4
  15. package/dist/BuildFunctionGroup.js.map +1 -0
  16. package/{dist_esm → dist}/BuildStep.d.ts +8 -6
  17. package/{dist_commonjs/BuildStep.cjs → dist/BuildStep.js} +31 -30
  18. package/dist/BuildStep.js.map +1 -0
  19. package/{dist_commonjs → dist}/BuildStepContext.d.ts +7 -3
  20. package/{dist_commonjs/BuildStepContext.cjs → dist/BuildStepContext.js} +17 -10
  21. package/dist/BuildStepContext.js.map +1 -0
  22. package/{dist_esm → dist}/BuildStepInput.d.ts +1 -1
  23. package/{dist_commonjs/BuildStepInput.cjs → dist/BuildStepInput.js} +12 -12
  24. package/dist/BuildStepInput.js.map +1 -0
  25. package/{dist_commonjs → dist}/BuildStepOutput.d.ts +1 -1
  26. package/{dist_commonjs/BuildStepOutput.cjs → dist/BuildStepOutput.js} +3 -3
  27. package/dist/BuildStepOutput.js.map +1 -0
  28. package/{dist_commonjs → dist}/BuildTemporaryFiles.d.ts +1 -1
  29. package/{dist_commonjs → dist}/BuildTemporaryFiles.js.map +1 -1
  30. package/{dist_commonjs → dist}/BuildWorkflow.d.ts +4 -3
  31. package/{dist_commonjs/BuildWorkflow.cjs → dist/BuildWorkflow.js} +17 -0
  32. package/dist/BuildWorkflow.js.map +1 -0
  33. package/{dist_commonjs → dist}/BuildWorkflowValidator.d.ts +1 -1
  34. package/{dist_commonjs/BuildWorkflowValidator.cjs → dist/BuildWorkflowValidator.js} +19 -19
  35. package/dist/BuildWorkflowValidator.js.map +1 -0
  36. package/dist/StepMetrics.d.ts +10 -0
  37. package/dist/StepMetrics.js +3 -0
  38. package/dist/StepMetrics.js.map +1 -0
  39. package/{dist_commonjs → dist}/StepsConfigParser.d.ts +5 -5
  40. package/{dist_commonjs/StepsConfigParser.cjs → dist/StepsConfigParser.js} +14 -13
  41. package/dist/StepsConfigParser.js.map +1 -0
  42. package/{dist_esm → dist}/cli/cli.d.ts +3 -3
  43. package/{dist_commonjs/cli/cli.cjs → dist/cli/cli.js} +6 -6
  44. package/dist/cli/cli.js.map +1 -0
  45. package/dist/index.d.ts +19 -0
  46. package/{dist_commonjs/index.cjs → dist/index.js} +30 -30
  47. package/dist/index.js.map +1 -0
  48. package/{dist_commonjs/interpolation.cjs → dist/interpolation.js} +3 -3
  49. package/dist/interpolation.js.map +1 -0
  50. package/{dist_commonjs/scripts/runCustomFunction.cjs → dist/scripts/runCustomFunction.js} +9 -9
  51. package/dist/scripts/runCustomFunction.js.map +1 -0
  52. package/{dist_commonjs → dist}/utils/customFunction.d.ts +4 -4
  53. package/{dist_commonjs/utils/customFunction.cjs → dist/utils/customFunction.js} +4 -6
  54. package/dist/utils/customFunction.js.map +1 -0
  55. package/{dist_commonjs/utils/shell/bin.cjs → dist/utils/shell/bin.js} +1 -3
  56. package/dist/utils/shell/bin.js.map +1 -0
  57. package/{dist_commonjs/utils/template.cjs → dist/utils/template.js} +7 -7
  58. package/dist/utils/template.js.map +1 -0
  59. package/package.json +12 -24
  60. package/dist_commonjs/AbstractConfigParser.js.map +0 -1
  61. package/dist_commonjs/BuildConfig.js.map +0 -1
  62. package/dist_commonjs/BuildConfigParser.d.ts +0 -33
  63. package/dist_commonjs/BuildConfigParser.js.map +0 -1
  64. package/dist_commonjs/BuildFunction.d.ts +0 -43
  65. package/dist_commonjs/BuildFunction.js.map +0 -1
  66. package/dist_commonjs/BuildFunctionGroup.js.map +0 -1
  67. package/dist_commonjs/BuildStep.d.ts +0 -98
  68. package/dist_commonjs/BuildStep.js.map +0 -1
  69. package/dist_commonjs/BuildStepContext.js.map +0 -1
  70. package/dist_commonjs/BuildStepInput.d.ts +0 -47
  71. package/dist_commonjs/BuildStepInput.js.map +0 -1
  72. package/dist_commonjs/BuildStepOutput.js.map +0 -1
  73. package/dist_commonjs/BuildWorkflow.js.map +0 -1
  74. package/dist_commonjs/BuildWorkflowValidator.js.map +0 -1
  75. package/dist_commonjs/StepsConfigParser.js.map +0 -1
  76. package/dist_commonjs/cli/cli.d.ts +0 -18
  77. package/dist_commonjs/cli/cli.js.map +0 -1
  78. package/dist_commonjs/index.d.ts +0 -18
  79. package/dist_commonjs/index.js.map +0 -1
  80. package/dist_commonjs/interpolation.js.map +0 -1
  81. package/dist_commonjs/scripts/runCustomFunction.js.map +0 -1
  82. package/dist_commonjs/utils/customFunction.js.map +0 -1
  83. package/dist_commonjs/utils/shell/bin.js.map +0 -1
  84. package/dist_commonjs/utils/template.js.map +0 -1
  85. package/dist_esm/AbstractConfigParser.d.ts +0 -23
  86. package/dist_esm/AbstractConfigParser.js +0 -61
  87. package/dist_esm/AbstractConfigParser.js.map +0 -1
  88. package/dist_esm/BuildConfig.d.ts +0 -79
  89. package/dist_esm/BuildConfig.js +0 -279
  90. package/dist_esm/BuildConfig.js.map +0 -1
  91. package/dist_esm/BuildConfigParser.js +0 -232
  92. package/dist_esm/BuildConfigParser.js.map +0 -1
  93. package/dist_esm/BuildFunction.js +0 -60
  94. package/dist_esm/BuildFunction.js.map +0 -1
  95. package/dist_esm/BuildFunctionGroup.d.ts +0 -23
  96. package/dist_esm/BuildFunctionGroup.js +0 -36
  97. package/dist_esm/BuildFunctionGroup.js.map +0 -1
  98. package/dist_esm/BuildRuntimePlatform.d.ts +0 -4
  99. package/dist_esm/BuildRuntimePlatform.js +0 -6
  100. package/dist_esm/BuildRuntimePlatform.js.map +0 -1
  101. package/dist_esm/BuildStep.js +0 -353
  102. package/dist_esm/BuildStep.js.map +0 -1
  103. package/dist_esm/BuildStepContext.d.ts +0 -82
  104. package/dist_esm/BuildStepContext.js +0 -200
  105. package/dist_esm/BuildStepContext.js.map +0 -1
  106. package/dist_esm/BuildStepEnv.d.ts +0 -1
  107. package/dist_esm/BuildStepEnv.js +0 -2
  108. package/dist_esm/BuildStepEnv.js.map +0 -1
  109. package/dist_esm/BuildStepInput.js +0 -150
  110. package/dist_esm/BuildStepInput.js.map +0 -1
  111. package/dist_esm/BuildStepOutput.d.ts +0 -33
  112. package/dist_esm/BuildStepOutput.js +0 -57
  113. package/dist_esm/BuildStepOutput.js.map +0 -1
  114. package/dist_esm/BuildTemporaryFiles.d.ts +0 -5
  115. package/dist_esm/BuildTemporaryFiles.js +0 -31
  116. package/dist_esm/BuildTemporaryFiles.js.map +0 -1
  117. package/dist_esm/BuildWorkflow.d.ts +0 -13
  118. package/dist_esm/BuildWorkflow.js +0 -38
  119. package/dist_esm/BuildWorkflow.js.map +0 -1
  120. package/dist_esm/BuildWorkflowValidator.d.ts +0 -10
  121. package/dist_esm/BuildWorkflowValidator.js +0 -121
  122. package/dist_esm/BuildWorkflowValidator.js.map +0 -1
  123. package/dist_esm/StepsConfigParser.d.ts +0 -24
  124. package/dist_esm/StepsConfigParser.js +0 -132
  125. package/dist_esm/StepsConfigParser.js.map +0 -1
  126. package/dist_esm/cli/cli.js +0 -61
  127. package/dist_esm/cli/cli.js.map +0 -1
  128. package/dist_esm/errors.d.ts +0 -24
  129. package/dist_esm/errors.js +0 -24
  130. package/dist_esm/errors.js.map +0 -1
  131. package/dist_esm/index.d.ts +0 -18
  132. package/dist_esm/index.js +0 -18
  133. package/dist_esm/index.js.map +0 -1
  134. package/dist_esm/interpolation.d.ts +0 -5
  135. package/dist_esm/interpolation.js +0 -26
  136. package/dist_esm/interpolation.js.map +0 -1
  137. package/dist_esm/scripts/runCustomFunction.d.ts +0 -1
  138. package/dist_esm/scripts/runCustomFunction.js +0 -100
  139. package/dist_esm/scripts/runCustomFunction.js.map +0 -1
  140. package/dist_esm/utils/customFunction.d.ts +0 -18
  141. package/dist_esm/utils/customFunction.js +0 -49
  142. package/dist_esm/utils/customFunction.js.map +0 -1
  143. package/dist_esm/utils/expodash/duplicates.d.ts +0 -1
  144. package/dist_esm/utils/expodash/duplicates.js +0 -14
  145. package/dist_esm/utils/expodash/duplicates.js.map +0 -1
  146. package/dist_esm/utils/expodash/uniq.d.ts +0 -1
  147. package/dist_esm/utils/expodash/uniq.js +0 -5
  148. package/dist_esm/utils/expodash/uniq.js.map +0 -1
  149. package/dist_esm/utils/hashFiles.d.ts +0 -6
  150. package/dist_esm/utils/hashFiles.js +0 -31
  151. package/dist_esm/utils/hashFiles.js.map +0 -1
  152. package/dist_esm/utils/jsepEval.d.ts +0 -1
  153. package/dist_esm/utils/jsepEval.js +0 -169
  154. package/dist_esm/utils/jsepEval.js.map +0 -1
  155. package/dist_esm/utils/nullthrows.d.ts +0 -1
  156. package/dist_esm/utils/nullthrows.js +0 -7
  157. package/dist_esm/utils/nullthrows.js.map +0 -1
  158. package/dist_esm/utils/shell/bin.d.ts +0 -1
  159. package/dist_esm/utils/shell/bin.js +0 -5
  160. package/dist_esm/utils/shell/bin.js.map +0 -1
  161. package/dist_esm/utils/shell/command.d.ts +0 -4
  162. package/dist_esm/utils/shell/command.js +0 -13
  163. package/dist_esm/utils/shell/command.js.map +0 -1
  164. package/dist_esm/utils/shell/spawn.d.ts +0 -15
  165. package/dist_esm/utils/shell/spawn.js +0 -16
  166. package/dist_esm/utils/shell/spawn.js.map +0 -1
  167. package/dist_esm/utils/template.d.ts +0 -19
  168. package/dist_esm/utils/template.js +0 -106
  169. package/dist_esm/utils/template.js.map +0 -1
  170. /package/{dist_commonjs → dist}/BuildRuntimePlatform.d.ts +0 -0
  171. /package/{dist_commonjs/BuildRuntimePlatform.cjs → dist/BuildRuntimePlatform.js} +0 -0
  172. /package/{dist_commonjs → dist}/BuildRuntimePlatform.js.map +0 -0
  173. /package/{dist_commonjs → dist}/BuildStepEnv.d.ts +0 -0
  174. /package/{dist_commonjs/BuildStepEnv.cjs → dist/BuildStepEnv.js} +0 -0
  175. /package/{dist_commonjs → dist}/BuildStepEnv.js.map +0 -0
  176. /package/{dist_commonjs/BuildTemporaryFiles.cjs → dist/BuildTemporaryFiles.js} +0 -0
  177. /package/{dist_commonjs → dist}/errors.d.ts +0 -0
  178. /package/{dist_commonjs/errors.cjs → dist/errors.js} +0 -0
  179. /package/{dist_commonjs → dist}/errors.js.map +0 -0
  180. /package/{dist_commonjs → dist}/interpolation.d.ts +0 -0
  181. /package/{dist_commonjs → dist}/scripts/runCustomFunction.d.ts +0 -0
  182. /package/{dist_commonjs → dist}/utils/expodash/duplicates.d.ts +0 -0
  183. /package/{dist_commonjs/utils/expodash/duplicates.cjs → dist/utils/expodash/duplicates.js} +0 -0
  184. /package/{dist_commonjs → dist}/utils/expodash/duplicates.js.map +0 -0
  185. /package/{dist_commonjs → dist}/utils/expodash/uniq.d.ts +0 -0
  186. /package/{dist_commonjs/utils/expodash/uniq.cjs → dist/utils/expodash/uniq.js} +0 -0
  187. /package/{dist_commonjs → dist}/utils/expodash/uniq.js.map +0 -0
  188. /package/{dist_commonjs → dist}/utils/hashFiles.d.ts +0 -0
  189. /package/{dist_commonjs/utils/hashFiles.cjs → dist/utils/hashFiles.js} +0 -0
  190. /package/{dist_commonjs → dist}/utils/hashFiles.js.map +0 -0
  191. /package/{dist_commonjs → dist}/utils/jsepEval.d.ts +0 -0
  192. /package/{dist_commonjs/utils/jsepEval.cjs → dist/utils/jsepEval.js} +0 -0
  193. /package/{dist_commonjs → dist}/utils/jsepEval.js.map +0 -0
  194. /package/{dist_commonjs → dist}/utils/nullthrows.d.ts +0 -0
  195. /package/{dist_commonjs/utils/nullthrows.cjs → dist/utils/nullthrows.js} +0 -0
  196. /package/{dist_commonjs → dist}/utils/nullthrows.js.map +0 -0
  197. /package/{dist_commonjs → dist}/utils/shell/bin.d.ts +0 -0
  198. /package/{dist_commonjs → dist}/utils/shell/command.d.ts +0 -0
  199. /package/{dist_commonjs/utils/shell/command.cjs → dist/utils/shell/command.js} +0 -0
  200. /package/{dist_commonjs → dist}/utils/shell/command.js.map +0 -0
  201. /package/{dist_commonjs → dist}/utils/shell/spawn.d.ts +0 -0
  202. /package/{dist_commonjs/utils/shell/spawn.cjs → dist/utils/shell/spawn.js} +0 -0
  203. /package/{dist_commonjs → dist}/utils/shell/spawn.js.map +0 -0
  204. /package/{dist_commonjs → dist}/utils/template.d.ts +0 -0
@@ -1,200 +0,0 @@
1
- import os from 'os';
2
- import path from 'path';
3
- import fg from 'fast-glob';
4
- import { v4 as uuidv4 } from 'uuid';
5
- import { hashFiles } from './utils/hashFiles.js';
6
- import { BuildStepOutputAccessor, } from './BuildStep.js';
7
- import { getObjectValueForInterpolation, interpolateWithGlobalContext, parseOutputPath, } from './utils/template.js';
8
- import { BuildStepRuntimeError } from './errors.js';
9
- export class BuildStepGlobalContext {
10
- constructor(provider, skipCleanup) {
11
- this.provider = provider;
12
- this.skipCleanup = skipCleanup;
13
- this.didCheckOut = false;
14
- this._hasAnyPreviousStepFailed = false;
15
- this.stepById = {};
16
- this.stepsInternalBuildDirectory = path.join(os.tmpdir(), 'eas-build', uuidv4());
17
- this.runtimePlatform = provider.runtimePlatform;
18
- this.baseLogger = provider.logger;
19
- this._hasAnyPreviousStepFailed = false;
20
- }
21
- get projectSourceDirectory() {
22
- return this.provider.projectSourceDirectory;
23
- }
24
- get projectTargetDirectory() {
25
- return this.provider.projectTargetDirectory;
26
- }
27
- get defaultWorkingDirectory() {
28
- return this.didCheckOut ? this.provider.defaultWorkingDirectory : this.projectTargetDirectory;
29
- }
30
- get buildLogsDirectory() {
31
- return this.provider.buildLogsDirectory;
32
- }
33
- get env() {
34
- return this.provider.env;
35
- }
36
- get staticContext() {
37
- return {
38
- ...this.provider.staticContext(),
39
- steps: Object.fromEntries(Object.values(this.stepById).map((step) => [
40
- step.id,
41
- {
42
- outputs: Object.fromEntries(step.outputs.map((output) => {
43
- return [output.id, output.rawValue];
44
- })),
45
- },
46
- ])),
47
- };
48
- }
49
- updateEnv(updatedEnv) {
50
- this.provider.updateEnv(updatedEnv);
51
- }
52
- registerStep(step) {
53
- this.stepById[step.id] = step;
54
- }
55
- getStepOutputValue(path) {
56
- const { stepId, outputId } = parseOutputPath(path);
57
- if (!(stepId in this.stepById)) {
58
- throw new BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
59
- }
60
- return this.stepById[stepId].getOutputValueByName(outputId);
61
- }
62
- getInterpolationContext() {
63
- const hasAnyPreviousStepFailed = this.hasAnyPreviousStepFailed;
64
- return {
65
- ...this.staticContext,
66
- always: () => true,
67
- never: () => false,
68
- success: () => !hasAnyPreviousStepFailed,
69
- failure: () => hasAnyPreviousStepFailed,
70
- env: this.env,
71
- fromJSON: (json) => JSON.parse(json),
72
- toJSON: (value) => JSON.stringify(value),
73
- contains: (value, substring) => value.includes(substring),
74
- startsWith: (value, prefix) => value.startsWith(prefix),
75
- endsWith: (value, suffix) => value.endsWith(suffix),
76
- hashFiles: (...patterns) => this.hashFiles(...patterns),
77
- replaceAll: (input, stringToReplace, replacementString) => {
78
- while (input.includes(stringToReplace)) {
79
- input = input.replace(stringToReplace, replacementString);
80
- }
81
- return input;
82
- },
83
- substring: (input, start, end) => input.substring(start, end),
84
- };
85
- }
86
- interpolate(value) {
87
- return interpolateWithGlobalContext(value, (path) => {
88
- var _a, _b;
89
- return ((_b = (_a = getObjectValueForInterpolation(path, {
90
- eas: {
91
- runtimePlatform: this.runtimePlatform,
92
- ...this.staticContext,
93
- env: this.env,
94
- },
95
- })) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '');
96
- });
97
- }
98
- stepCtx(options) {
99
- return new BuildStepContext(this, options);
100
- }
101
- markAsCheckedOut(logger) {
102
- this.didCheckOut = true;
103
- logger.info(`Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`);
104
- }
105
- get hasAnyPreviousStepFailed() {
106
- return this._hasAnyPreviousStepFailed;
107
- }
108
- markAsFailed() {
109
- this._hasAnyPreviousStepFailed = true;
110
- }
111
- wasCheckedOut() {
112
- return this.didCheckOut;
113
- }
114
- hashFiles(...patterns) {
115
- const cwd = this.defaultWorkingDirectory;
116
- const workspacePath = path.resolve(cwd);
117
- // Use glob to find matching files across all patterns
118
- const filePaths = fg.sync(patterns, {
119
- cwd,
120
- absolute: true,
121
- onlyFiles: true,
122
- });
123
- if (filePaths.length === 0) {
124
- return '';
125
- }
126
- const validFilePaths = filePaths.filter((file) => file.startsWith(`${workspacePath}${path.sep}`));
127
- if (validFilePaths.length === 0) {
128
- return '';
129
- }
130
- return hashFiles(validFilePaths);
131
- }
132
- serialize() {
133
- return {
134
- stepsInternalBuildDirectory: this.stepsInternalBuildDirectory,
135
- stepById: Object.fromEntries(Object.entries(this.stepById).map(([id, step]) => [id, step.serialize()])),
136
- provider: {
137
- projectSourceDirectory: this.provider.projectSourceDirectory,
138
- projectTargetDirectory: this.provider.projectTargetDirectory,
139
- defaultWorkingDirectory: this.provider.defaultWorkingDirectory,
140
- buildLogsDirectory: this.provider.buildLogsDirectory,
141
- runtimePlatform: this.provider.runtimePlatform,
142
- staticContext: this.provider.staticContext(),
143
- env: this.provider.env,
144
- },
145
- skipCleanup: this.skipCleanup,
146
- };
147
- }
148
- static deserialize(serialized, logger) {
149
- const deserializedProvider = {
150
- projectSourceDirectory: serialized.provider.projectSourceDirectory,
151
- projectTargetDirectory: serialized.provider.projectTargetDirectory,
152
- defaultWorkingDirectory: serialized.provider.defaultWorkingDirectory,
153
- buildLogsDirectory: serialized.provider.buildLogsDirectory,
154
- runtimePlatform: serialized.provider.runtimePlatform,
155
- logger,
156
- staticContext: () => serialized.provider.staticContext,
157
- env: serialized.provider.env,
158
- updateEnv: () => { },
159
- };
160
- const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);
161
- for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {
162
- ctx.stepById[id] = BuildStepOutputAccessor.deserialize(stepOutputAccessor);
163
- }
164
- ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;
165
- return ctx;
166
- }
167
- }
168
- export class BuildStepContext {
169
- constructor(ctx, { logger, relativeWorkingDirectory, }) {
170
- this.ctx = ctx;
171
- this.logger = logger !== null && logger !== void 0 ? logger : ctx.baseLogger;
172
- this.relativeWorkingDirectory = relativeWorkingDirectory;
173
- }
174
- get global() {
175
- return this.ctx;
176
- }
177
- get workingDirectory() {
178
- if (!this.relativeWorkingDirectory) {
179
- return this.ctx.defaultWorkingDirectory;
180
- }
181
- if (path.isAbsolute(this.relativeWorkingDirectory)) {
182
- return path.join(this.ctx.projectTargetDirectory, this.relativeWorkingDirectory);
183
- }
184
- return path.join(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory);
185
- }
186
- serialize() {
187
- return {
188
- relativeWorkingDirectory: this.relativeWorkingDirectory,
189
- global: this.ctx.serialize(),
190
- };
191
- }
192
- static deserialize(serialized, logger) {
193
- const deserializedGlobal = BuildStepGlobalContext.deserialize(serialized.global, logger);
194
- return new BuildStepContext(deserializedGlobal, {
195
- logger,
196
- relativeWorkingDirectory: serialized.relativeWorkingDirectory,
197
- });
198
- }
199
- }
200
- //# sourceMappingURL=BuildStepContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/Build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AAgB;QACzB,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC;QAC1C,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC;YACnD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;QACnF,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACpF,CAAC;IAEM,SAAS;QACd,OAAO;YACL,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;YACvD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;SAC7B,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,WAAW,CACvB,UAAsC,EACtC,MAAc;QAEd,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzF,OAAO,IAAI,gBAAgB,CAAC,kBAAkB,EAAE;YAC9C,MAAM;YACN,wBAAwB,EAAE,UAAU,CAAC,wBAAwB;SAC9D,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport fg from 'fast-glob';\nimport { Env, JobInterpolationContext, StaticJobInterpolationContext } from '@expo/eas-build-job';\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { hashFiles } from './utils/hashFiles.js';\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 getInterpolationContext(): JobInterpolationContext {\n const hasAnyPreviousStepFailed = this.hasAnyPreviousStepFailed;\n\n return {\n ...this.staticContext,\n always: () => true,\n never: () => false,\n success: () => !hasAnyPreviousStepFailed,\n failure: () => hasAnyPreviousStepFailed,\n env: this.env as Env,\n fromJSON: (json: string) => JSON.parse(json),\n toJSON: (value: unknown) => JSON.stringify(value),\n contains: (value, substring) => value.includes(substring),\n startsWith: (value, prefix) => value.startsWith(prefix),\n endsWith: (value, suffix) => value.endsWith(suffix),\n hashFiles: (...patterns: string[]) => this.hashFiles(...patterns),\n replaceAll: (input: string, stringToReplace: string, replacementString: string) => {\n while (input.includes(stringToReplace)) {\n input = input.replace(stringToReplace, replacementString);\n }\n return input;\n },\n substring: (input: string, start: number, end?: number) => input.substring(start, end),\n };\n }\n\n public interpolate<InterpolableType extends string | object>(\n value: InterpolableType\n ): InterpolableType {\n return interpolateWithGlobalContext(value, (path) => {\n return (\n getObjectValueForInterpolation(path, {\n eas: {\n runtimePlatform: this.runtimePlatform,\n ...this.staticContext,\n env: this.env,\n },\n })?.toString() ?? ''\n );\n });\n }\n\n public stepCtx(options: { logger: bunyan; relativeWorkingDirectory?: string }): BuildStepContext {\n return new BuildStepContext(this, options);\n }\n\n public markAsCheckedOut(logger: bunyan): void {\n this.didCheckOut = true;\n logger.info(\n `Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`\n );\n }\n\n public get hasAnyPreviousStepFailed(): boolean {\n return this._hasAnyPreviousStepFailed;\n }\n\n public markAsFailed(): void {\n this._hasAnyPreviousStepFailed = true;\n }\n\n public wasCheckedOut(): boolean {\n return this.didCheckOut;\n }\n\n public hashFiles(...patterns: string[]): string {\n const cwd = this.defaultWorkingDirectory;\n const workspacePath = path.resolve(cwd);\n\n // Use glob to find matching files across all patterns\n const filePaths = fg.sync(patterns, {\n cwd,\n absolute: true,\n onlyFiles: true,\n });\n\n if (filePaths.length === 0) {\n return '';\n }\n\n const validFilePaths = filePaths.filter((file) =>\n file.startsWith(`${workspacePath}${path.sep}`)\n );\n\n if (validFilePaths.length === 0) {\n return '';\n }\n\n return hashFiles(validFilePaths);\n }\n\n public serialize(): SerializedBuildStepGlobalContext {\n return {\n stepsInternalBuildDirectory: this.stepsInternalBuildDirectory,\n stepById: Object.fromEntries(\n Object.entries(this.stepById).map(([id, step]) => [id, step.serialize()])\n ),\n provider: {\n projectSourceDirectory: this.provider.projectSourceDirectory,\n projectTargetDirectory: this.provider.projectTargetDirectory,\n defaultWorkingDirectory: this.provider.defaultWorkingDirectory,\n buildLogsDirectory: this.provider.buildLogsDirectory,\n runtimePlatform: this.provider.runtimePlatform,\n staticContext: this.provider.staticContext(),\n env: this.provider.env,\n },\n skipCleanup: this.skipCleanup,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepGlobalContext,\n logger: bunyan\n ): BuildStepGlobalContext {\n const deserializedProvider: ExternalBuildContextProvider = {\n projectSourceDirectory: serialized.provider.projectSourceDirectory,\n projectTargetDirectory: serialized.provider.projectTargetDirectory,\n defaultWorkingDirectory: serialized.provider.defaultWorkingDirectory,\n buildLogsDirectory: serialized.provider.buildLogsDirectory,\n runtimePlatform: serialized.provider.runtimePlatform,\n logger,\n staticContext: () => serialized.provider.staticContext,\n env: serialized.provider.env,\n updateEnv: () => {},\n };\n const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);\n for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {\n ctx.stepById[id] = BuildStepOutputAccessor.deserialize(stepOutputAccessor);\n }\n ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;\n\n return ctx;\n }\n}\n\nexport interface SerializedBuildStepContext {\n relativeWorkingDirectory?: string;\n global: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepContext {\n public readonly logger: bunyan;\n public readonly relativeWorkingDirectory?: string;\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n logger,\n relativeWorkingDirectory,\n }: {\n logger: bunyan;\n relativeWorkingDirectory?: string;\n }\n ) {\n this.logger = logger ?? ctx.baseLogger;\n this.relativeWorkingDirectory = relativeWorkingDirectory;\n }\n\n public get global(): BuildStepGlobalContext {\n return this.ctx;\n }\n\n public get workingDirectory(): string {\n if (!this.relativeWorkingDirectory) {\n return this.ctx.defaultWorkingDirectory;\n }\n\n if (path.isAbsolute(this.relativeWorkingDirectory)) {\n return path.join(this.ctx.projectTargetDirectory, this.relativeWorkingDirectory);\n }\n\n return path.join(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory);\n }\n\n public serialize(): SerializedBuildStepContext {\n return {\n relativeWorkingDirectory: this.relativeWorkingDirectory,\n global: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepContext,\n logger: bunyan\n ): BuildStepContext {\n const deserializedGlobal = BuildStepGlobalContext.deserialize(serialized.global, logger);\n return new BuildStepContext(deserializedGlobal, {\n logger,\n relativeWorkingDirectory: serialized.relativeWorkingDirectory,\n });\n }\n}\n"]}
@@ -1 +0,0 @@
1
- export type BuildStepEnv = Record<string, string | undefined>;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=BuildStepEnv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepEnv.js","sourceRoot":"","sources":["../src/BuildStepEnv.ts"],"names":[],"mappings":"","sourcesContent":["export type BuildStepEnv = Record<string, string | undefined>;\n"]}
@@ -1,150 +0,0 @@
1
- import assert from 'assert';
2
- import { BuildStepRuntimeError } from './errors.js';
3
- import { BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX, interpolateWithOutputs, } from './utils/template.js';
4
- import { interpolateJobContext } from './interpolation.js';
5
- export var BuildStepInputValueTypeName;
6
- (function (BuildStepInputValueTypeName) {
7
- BuildStepInputValueTypeName["STRING"] = "string";
8
- BuildStepInputValueTypeName["BOOLEAN"] = "boolean";
9
- BuildStepInputValueTypeName["NUMBER"] = "number";
10
- BuildStepInputValueTypeName["JSON"] = "json";
11
- })(BuildStepInputValueTypeName || (BuildStepInputValueTypeName = {}));
12
- export class BuildStepInput {
13
- static createProvider(params) {
14
- return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });
15
- }
16
- constructor(ctx, { id, stepDisplayName, allowedValues, defaultValue, required, allowedValueTypeName, }) {
17
- this.ctx = ctx;
18
- this.id = id;
19
- this.stepDisplayName = stepDisplayName;
20
- this.allowedValues = allowedValues;
21
- this.defaultValue = defaultValue;
22
- this.required = required;
23
- this.allowedValueTypeName = allowedValueTypeName;
24
- }
25
- getValue({ interpolationContext, }) {
26
- var _a;
27
- const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
28
- if (this.required && rawValue === undefined) {
29
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
30
- }
31
- const interpolatedValue = interpolateJobContext({
32
- target: rawValue,
33
- context: interpolationContext,
34
- });
35
- const valueDoesNotRequireInterpolation = interpolatedValue === undefined ||
36
- interpolatedValue === null ||
37
- typeof interpolatedValue === 'boolean' ||
38
- typeof interpolatedValue === 'number';
39
- let returnValue;
40
- if (valueDoesNotRequireInterpolation) {
41
- if (typeof interpolatedValue !== this.allowedValueTypeName &&
42
- interpolatedValue !== undefined) {
43
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
44
- }
45
- returnValue = interpolatedValue;
46
- }
47
- else {
48
- // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined
49
- // so this will never be true.
50
- assert(interpolatedValue !== undefined);
51
- const valueInterpolatedWithGlobalContext = this.ctx.interpolate(interpolatedValue);
52
- const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(valueInterpolatedWithGlobalContext, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
53
- returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);
54
- }
55
- return returnValue;
56
- }
57
- get rawValue() {
58
- var _a;
59
- return (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
60
- }
61
- set(value) {
62
- if (this.required && value === undefined) {
63
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
64
- }
65
- this._value = value;
66
- return this;
67
- }
68
- isRawValueOneOfAllowedValues() {
69
- var _a;
70
- const value = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
71
- if (this.allowedValues === undefined || value === undefined) {
72
- return true;
73
- }
74
- return this.allowedValues.includes(value);
75
- }
76
- isRawValueStepOrContextReference() {
77
- return (typeof this.rawValue === 'string' &&
78
- (!!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue) ||
79
- // If value is an interpolation reference we're going to render whatever it evaluates to.
80
- // See `interpolateJobContext`.
81
- (this.rawValue.startsWith('${{') && this.rawValue.endsWith('}}'))));
82
- }
83
- parseInputValueToAllowedType(value) {
84
- if (typeof value === 'object') {
85
- return value;
86
- }
87
- if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {
88
- return this.parseInputValueToString(value);
89
- }
90
- else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {
91
- return this.parseInputValueToNumber(value);
92
- }
93
- else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {
94
- return this.parseInputValueToBoolean(value);
95
- }
96
- else {
97
- return this.parseInputValueToObject(value);
98
- }
99
- }
100
- parseInputValueToString(value) {
101
- let parsedValue = value;
102
- try {
103
- parsedValue = JSON.parse(`"${value}"`);
104
- }
105
- catch (err) {
106
- if (!(err instanceof SyntaxError)) {
107
- throw err;
108
- }
109
- }
110
- return parsedValue;
111
- }
112
- parseInputValueToNumber(value) {
113
- const numberValue = Number(value);
114
- if (Number.isNaN(numberValue)) {
115
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
116
- }
117
- return numberValue;
118
- }
119
- parseInputValueToBoolean(value) {
120
- if (value === 'true' || value === true) {
121
- return true;
122
- }
123
- else if (value === 'false' || value === false) {
124
- return false;
125
- }
126
- else {
127
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
128
- }
129
- }
130
- parseInputValueToObject(value) {
131
- try {
132
- return JSON.parse(value);
133
- }
134
- catch (e) {
135
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`, {
136
- cause: e,
137
- });
138
- }
139
- }
140
- }
141
- export function makeBuildStepInputByIdMap(inputs) {
142
- if (inputs === undefined) {
143
- return {};
144
- }
145
- return inputs.reduce((acc, input) => {
146
- acc[input.id] = input;
147
- return acc;
148
- }, {});
149
- }
150
- //# sourceMappingURL=BuildStepInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAK5B,OAAO,EAAE,qB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AAe,IAAI,CAAC,eAAe,sBAAsB,IAAI,CAAC,oBAAoB,IAAI,CAClH,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,uBAAuB,CAAC,KAAgC;QAC9D,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAe,CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,sBAAsB,IAAI,CAAC,oBAAoB,IAAI,EACjH;gBACE,KAAK,EAAE,CAAC;aACT,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CAAC,MAAyB;IACjE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAClC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAwB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import assert from 'assert';\n\nimport { JobInterpolationContext } from '@expo/eas-build-job';\n\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport {\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n interpolateWithOutputs,\n} from './utils/template.js';\nimport { interpolateJobContext } from './interpolation.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n JSON = 'json',\n}\n\nexport type BuildStepInputValueType<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n> = T extends BuildStepInputValueTypeName.STRING\n ? string\n : T extends BuildStepInputValueTypeName.BOOLEAN\n ? boolean\n : T extends BuildStepInputValueTypeName.NUMBER\n ? number\n : Record<string, unknown>;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n allowedValues?: unknown[];\n defaultValue?: unknown;\n required: R;\n allowedValueTypeName: T;\n}\n\ninterface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean>\n extends BuildStepInputProviderParams<T, R> {\n stepDisplayName: string;\n}\n\nexport class BuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: unknown;\n public readonly allowedValues?: unknown[];\n public readonly allowedValueTypeName: T;\n public readonly required: R;\n\n private _value?: unknown;\n\n public static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n id,\n stepDisplayName,\n allowedValues,\n defaultValue,\n required,\n allowedValueTypeName,\n }: BuildStepInputParams<T, R>\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public getValue({\n interpolationContext,\n }: {\n interpolationContext: JobInterpolationContext;\n }): R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | undefined {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n\n const interpolatedValue = interpolateJobContext({\n target: rawValue,\n context: interpolationContext,\n });\n\n const valueDoesNotRequireInterpolation =\n interpolatedValue === undefined ||\n interpolatedValue === null ||\n typeof interpolatedValue === 'boolean' ||\n typeof interpolatedValue === 'number';\n let returnValue;\n if (valueDoesNotRequireInterpolation) {\n if (\n typeof interpolatedValue !== this.allowedValueTypeName &&\n interpolatedValue !== undefined\n ) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n returnValue = interpolatedValue as BuildStepInputValueType<T>;\n } else {\n // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined\n // so this will never be true.\n assert(interpolatedValue !== undefined);\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(interpolatedValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n return returnValue;\n }\n\n public get rawValue(): unknown {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: unknown): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n\n this._value = value;\n return this;\n }\n\n public isRawValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\n }\n\n public isRawValueStepOrContextReference(): boolean {\n return (\n typeof this.rawValue === 'string' &&\n (!!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue) ||\n // If value is an interpolation reference we're going to render whatever it evaluates to.\n // See `interpolateJobContext`.\n (this.rawValue.startsWith('${{') && this.rawValue.endsWith('}}')))\n );\n }\n\n private parseInputValueToAllowedType(\n value: string | object | boolean | number\n ): BuildStepInputValueType<T> {\n if (typeof value === 'object') {\n return value as BuildStepInputValueType<T>;\n }\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return this.parseInputValueToString(value) as BuildStepInputValueType<T>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value) as BuildStepInputValueType<T>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value) as BuildStepInputValueType<T>;\n } else {\n return this.parseInputValueToObject(value) as BuildStepInputValueType<T>;\n }\n }\n\n private parseInputValueToString(value: string | boolean | number): string {\n let parsedValue = value;\n try {\n parsedValue = JSON.parse(`\"${value}\"`);\n } catch (err) {\n if (!(err instanceof SyntaxError)) {\n throw err;\n }\n }\n return parsedValue as string;\n }\n\n private parseInputValueToNumber(value: string | boolean | number): number {\n const numberValue = Number(value);\n if (Number.isNaN(numberValue)) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return numberValue;\n }\n\n private parseInputValueToBoolean(value: string | boolean | number): boolean {\n if (value === 'true' || value === true) {\n return true;\n } else if (value === 'false' || value === false) {\n return false;\n } else {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n }\n\n private parseInputValueToObject(value: string | boolean | number): Record<string, any> {\n try {\n return JSON.parse(value as string);\n } catch (e: any) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`,\n {\n cause: e,\n }\n );\n }\n }\n}\n\nexport function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById {\n if (inputs === undefined) {\n return {};\n }\n return inputs.reduce((acc, input) => {\n acc[input.id] = input;\n return acc;\n }, {} as BuildStepInputById);\n}\n"]}
@@ -1,33 +0,0 @@
1
- import { BuildStepGlobalContext } from './BuildStepContext.js';
2
- export type BuildStepOutputById = Record<string, BuildStepOutput>;
3
- export type BuildStepOutputProvider = (ctx: BuildStepGlobalContext, stepDisplayName: string) => BuildStepOutput;
4
- interface BuildStepOutputProviderParams<R extends boolean = boolean> {
5
- id: string;
6
- required: R;
7
- }
8
- interface BuildStepOutputParams<R extends boolean = boolean> extends BuildStepOutputProviderParams<R> {
9
- stepDisplayName: string;
10
- }
11
- type BuildStepOutputValueType<R extends boolean = boolean> = R extends true ? string : string | undefined;
12
- export interface SerializedBuildStepOutput<R extends boolean = boolean> {
13
- id: string;
14
- stepDisplayName: string;
15
- required: R;
16
- value?: string;
17
- }
18
- export declare class BuildStepOutput<R extends boolean = boolean> {
19
- private readonly ctx;
20
- readonly id: string;
21
- readonly stepDisplayName: string;
22
- readonly required: R;
23
- private _value?;
24
- static createProvider(params: BuildStepOutputProviderParams): BuildStepOutputProvider;
25
- constructor(ctx: BuildStepGlobalContext | undefined, { id, stepDisplayName, required }: BuildStepOutputParams<R>);
26
- get rawValue(): string | undefined;
27
- get value(): BuildStepOutputValueType<R>;
28
- set(value: BuildStepOutputValueType<R>): BuildStepOutput;
29
- serialize(): SerializedBuildStepOutput;
30
- static deserialize(serialized: SerializedBuildStepOutput): BuildStepOutput;
31
- }
32
- export declare function makeBuildStepOutputByIdMap(outputs?: BuildStepOutput[]): BuildStepOutputById;
33
- export {};
@@ -1,57 +0,0 @@
1
- import { BuildStepRuntimeError } from './errors.js';
2
- export class BuildStepOutput {
3
- static createProvider(params) {
4
- return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });
5
- }
6
- constructor(
7
- // @ts-expect-error ctx is not used in this class but let's keep it here for consistency
8
- ctx, { id, stepDisplayName, required }) {
9
- this.ctx = ctx;
10
- this.id = id;
11
- this.stepDisplayName = stepDisplayName;
12
- this.required = required;
13
- }
14
- get rawValue() {
15
- return this._value;
16
- }
17
- get value() {
18
- if (this.required && this._value === undefined) {
19
- throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
20
- }
21
- return this._value;
22
- }
23
- set(value) {
24
- if (this.required && value === undefined) {
25
- throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
26
- }
27
- this._value = value;
28
- return this;
29
- }
30
- serialize() {
31
- return {
32
- id: this.id,
33
- stepDisplayName: this.stepDisplayName,
34
- required: this.required,
35
- value: this._value,
36
- };
37
- }
38
- static deserialize(serialized) {
39
- const deserialized = new BuildStepOutput(undefined, {
40
- id: serialized.id,
41
- stepDisplayName: serialized.stepDisplayName,
42
- required: serialized.required,
43
- });
44
- deserialized._value = serialized.value;
45
- return deserialized;
46
- }
47
- }
48
- export function makeBuildStepOutputByIdMap(outputs) {
49
- if (outputs === undefined) {
50
- return {};
51
- }
52
- return outputs.reduce((acc, output) => {
53
- acc[output.id] = output;
54
- return acc;
55
- }, {});
56
- }
57
- //# sourceMappingURL=BuildStepOutput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA6BpD,MAAM,OAAO,eAAe;IAOnB,MAAM,CAAC,cAAc,CAAC,MAAqC;QAChE,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC5F,CAAC;IAED;IACE,wFAAwF;IACvE,GAAuC,EACxD,EAAE,EAAE,EAAE,eAAe,EAAE,QAAQ,EAA4B;QAD1C,QAAG,GAAH,GAAG,CAAoC;QAGxD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAW,QAAQ;QACjB,OAAO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C,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACpC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC;QACxB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAyB,CAAC,CAAC;AAChC,CAAC","sourcesContent":["import { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\n\nexport type BuildStepOutputById = Record<string, BuildStepOutput>;\nexport type BuildStepOutputProvider = (\n ctx: BuildStepGlobalContext,\n stepDisplayName: string\n) => BuildStepOutput;\n\ninterface BuildStepOutputProviderParams<R extends boolean = boolean> {\n id: string;\n required: R;\n}\n\ninterface BuildStepOutputParams<R extends boolean = boolean>\n extends BuildStepOutputProviderParams<R> {\n stepDisplayName: string;\n}\n\ntype BuildStepOutputValueType<R extends boolean = boolean> = R extends true\n ? string\n : string | undefined;\n\nexport interface SerializedBuildStepOutput<R extends boolean = boolean> {\n id: string;\n stepDisplayName: string;\n required: R;\n value?: string;\n}\n\nexport class BuildStepOutput<R extends boolean = boolean> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly required: R;\n\n private _value?: string;\n\n public static createProvider(params: BuildStepOutputProviderParams): BuildStepOutputProvider {\n return (ctx, stepDisplayName) => new BuildStepOutput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n // @ts-expect-error ctx is not used in this class but let's keep it here for consistency\n private readonly ctx: BuildStepGlobalContext | undefined,\n { id, stepDisplayName, required }: BuildStepOutputParams<R>\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.required = required;\n }\n\n public get rawValue(): string | undefined {\n return this._value;\n }\n\n public get value(): BuildStepOutputValueType<R> {\n if (this.required && this._value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n return this._value as BuildStepOutputValueType<R>;\n }\n\n public set(value: BuildStepOutputValueType<R>): BuildStepOutput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n\n public serialize(): SerializedBuildStepOutput {\n return {\n id: this.id,\n stepDisplayName: this.stepDisplayName,\n required: this.required,\n value: this._value,\n };\n }\n\n public static deserialize(serialized: SerializedBuildStepOutput): BuildStepOutput {\n const deserialized = new BuildStepOutput(undefined, {\n id: serialized.id,\n stepDisplayName: serialized.stepDisplayName,\n required: serialized.required,\n });\n deserialized._value = serialized.value;\n return deserialized;\n }\n}\n\nexport function makeBuildStepOutputByIdMap(outputs?: BuildStepOutput[]): BuildStepOutputById {\n if (outputs === undefined) {\n return {};\n }\n return outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as BuildStepOutputById);\n}\n"]}
@@ -1,5 +0,0 @@
1
- import { BuildStepGlobalContext } from './BuildStepContext.js';
2
- export declare function saveScriptToTemporaryFileAsync(ctx: BuildStepGlobalContext, stepId: string, scriptContents: string): Promise<string>;
3
- export declare function cleanUpStepTemporaryDirectoriesAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<void>;
4
- export declare function getTemporaryOutputsDirPath(ctx: BuildStepGlobalContext, stepId: string): string;
5
- export declare function getTemporaryEnvsDirPath(ctx: BuildStepGlobalContext, stepId: string): string;
@@ -1,31 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs/promises';
3
- import { v4 as uuidv4 } from 'uuid';
4
- export async function saveScriptToTemporaryFileAsync(ctx, stepId, scriptContents) {
5
- const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);
6
- await fs.mkdir(scriptsDir, { recursive: true });
7
- const temporaryScriptPath = path.join(scriptsDir, `${uuidv4()}.sh`);
8
- await fs.writeFile(temporaryScriptPath, scriptContents);
9
- return temporaryScriptPath;
10
- }
11
- export async function cleanUpStepTemporaryDirectoriesAsync(ctx, stepId) {
12
- if (ctx.skipCleanup) {
13
- return;
14
- }
15
- const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);
16
- await fs.rm(stepTemporaryDirectory, { recursive: true, force: true });
17
- ctx.baseLogger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');
18
- }
19
- function getTemporaryStepDirPath(ctx, stepId) {
20
- return path.join(ctx.stepsInternalBuildDirectory, 'steps', stepId);
21
- }
22
- function getTemporaryScriptsDirPath(ctx, stepId) {
23
- return path.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');
24
- }
25
- export function getTemporaryOutputsDirPath(ctx, stepId) {
26
- return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');
27
- }
28
- export function getTemporaryEnvsDirPath(ctx, stepId) {
29
- return path.join(getTemporaryStepDirPath(ctx, stepId), 'envs');
30
- }
31
- //# sourceMappingURL=BuildTemporaryFiles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildTemporaryFiles.js","sourceRoot":"","sources":["../src/BuildTemporaryFiles.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAIpC,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,GAA2B,EAC3B,MAAc,EACd,cAAsB;IAEtB,MAAM,UAAU,GAAG,0BAA0B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,CAAC;IACpE,MAAM,EAAE,CAAC,SAAS,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;IACxD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oCAAoC,CACxD,GAA2B,EAC3B,MAAc;IAEd,IAAI,GAAG,CAAC,WAAW,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IACD,MAAM,sBAAsB,GAAG,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpE,MAAM,EAAE,CAAC,EAAE,CAAC,sBAAsB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,sBAAsB,EAAE,EAAE,kCAAkC,CAAC,CAAC;AACvF,CAAC;AAED,SAAS,uBAAuB,CAAC,GAA2B,EAAE,MAAc;IAC1E,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,2BAA2B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,0BAA0B,CAAC,GAA2B,EAAE,MAAc;IAC7E,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,GAA2B,EAAE,MAAc;IACpF,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,GAA2B,EAAE,MAAc;IACjF,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC","sourcesContent":["import path from 'path';\nimport fs from 'fs/promises';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\n\nexport async function saveScriptToTemporaryFileAsync(\n ctx: BuildStepGlobalContext,\n stepId: string,\n scriptContents: string\n): Promise<string> {\n const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);\n await fs.mkdir(scriptsDir, { recursive: true });\n const temporaryScriptPath = path.join(scriptsDir, `${uuidv4()}.sh`);\n await fs.writeFile(temporaryScriptPath, scriptContents);\n return temporaryScriptPath;\n}\n\nexport async function cleanUpStepTemporaryDirectoriesAsync(\n ctx: BuildStepGlobalContext,\n stepId: string\n): Promise<void> {\n if (ctx.skipCleanup) {\n return;\n }\n const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);\n await fs.rm(stepTemporaryDirectory, { recursive: true, force: true });\n ctx.baseLogger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');\n}\n\nfunction getTemporaryStepDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(ctx.stepsInternalBuildDirectory, 'steps', stepId);\n}\n\nfunction getTemporaryScriptsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');\n}\n\nexport function getTemporaryOutputsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');\n}\n\nexport function getTemporaryEnvsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'envs');\n}\n"]}
@@ -1,13 +0,0 @@
1
- import { BuildFunctionById } from './BuildFunction.js';
2
- import { BuildStep } from './BuildStep.js';
3
- import { BuildStepGlobalContext } from './BuildStepContext.js';
4
- export declare class BuildWorkflow {
5
- private readonly ctx;
6
- readonly buildSteps: BuildStep[];
7
- readonly buildFunctions: BuildFunctionById;
8
- constructor(ctx: BuildStepGlobalContext, { buildSteps, buildFunctions }: {
9
- buildSteps: BuildStep[];
10
- buildFunctions: BuildFunctionById;
11
- });
12
- executeAsync(): Promise<void>;
13
- }
@@ -1,38 +0,0 @@
1
- export class BuildWorkflow {
2
- constructor(ctx, { buildSteps, buildFunctions }) {
3
- this.ctx = ctx;
4
- this.buildSteps = buildSteps;
5
- this.buildFunctions = buildFunctions;
6
- }
7
- async executeAsync() {
8
- let maybeError = null;
9
- for (const step of this.buildSteps) {
10
- let shouldExecuteStep = false;
11
- try {
12
- shouldExecuteStep = step.shouldExecuteStep();
13
- }
14
- catch (err) {
15
- step.ctx.logger.error({ err });
16
- 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.`);
17
- maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err;
18
- this.ctx.markAsFailed();
19
- }
20
- if (shouldExecuteStep) {
21
- try {
22
- await step.executeAsync();
23
- }
24
- catch (err) {
25
- maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err;
26
- this.ctx.markAsFailed();
27
- }
28
- }
29
- else {
30
- step.skip();
31
- }
32
- }
33
- if (maybeError) {
34
- throw maybeError;
35
- }
36
- }
37
- }
38
- //# sourceMappingURL=BuildWorkflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,aAAa;IAIxB,YACmB,GAA2B,EAC5C,EAAE,UAAU,EAAE,cAAc,EAAkE;QAD7E,QAAG,GAAH,GAAG,CAAwB;QAG5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,IAAI,UAAU,GAAiB,IAAI,CAAC;QACpC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACnC,IAAI,iBAAiB,GAAG,KAAK,CAAC;YAC9B,IAAI,CAAC;gBACH,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC/C,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC/B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CACnB,wDAAwD,IAAI,CAAC,WAAW,iCAAiC,IAAI,CAAC,WAAW,4JAA4J,CACtR,CAAC;gBACF,UAAU,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,GAAG,CAAC;gBAC/B,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;YAC1B,CAAC;YACD,IAAI,iBAAiB,EAAE,CAAC;gBACtB,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC5B,CAAC;gBAAC,OAAO,GAAQ,EAAE,CAAC;oBAClB,UAAU,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,GAAG,CAAC;oBAC/B,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;gBAC1B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,UAAU,CAAC;QACnB,CAAC;IACH,CAAC;CACF","sourcesContent":["import { BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\n\nexport class BuildWorkflow {\n public readonly buildSteps: BuildStep[];\n public readonly buildFunctions: BuildFunctionById;\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n { buildSteps, buildFunctions }: { buildSteps: BuildStep[]; buildFunctions: BuildFunctionById }\n ) {\n this.buildSteps = buildSteps;\n this.buildFunctions = buildFunctions;\n }\n\n public async executeAsync(): Promise<void> {\n let maybeError: Error | null = null;\n for (const step of this.buildSteps) {\n let shouldExecuteStep = false;\n try {\n shouldExecuteStep = step.shouldExecuteStep();\n } catch (err: any) {\n step.ctx.logger.error({ err });\n step.ctx.logger.error(\n `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.`\n );\n maybeError = maybeError ?? err;\n this.ctx.markAsFailed();\n }\n if (shouldExecuteStep) {\n try {\n await step.executeAsync();\n } catch (err: any) {\n maybeError = maybeError ?? err;\n this.ctx.markAsFailed();\n }\n } else {\n step.skip();\n }\n }\n\n if (maybeError) {\n throw maybeError;\n }\n }\n}\n"]}