@expo/steps 0.0.6 → 0.0.7

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 (163) hide show
  1. package/package.json +5 -1
  2. package/dist_commonjs/BuildArtifacts.cjs +0 -9
  3. package/dist_commonjs/BuildArtifacts.d.ts +0 -5
  4. package/dist_commonjs/BuildArtifacts.js.map +0 -1
  5. package/dist_commonjs/BuildConfig.cjs +0 -108
  6. package/dist_commonjs/BuildConfig.d.ts +0 -53
  7. package/dist_commonjs/BuildConfig.js.map +0 -1
  8. package/dist_commonjs/BuildConfigParser.cjs +0 -154
  9. package/dist_commonjs/BuildConfigParser.d.ts +0 -19
  10. package/dist_commonjs/BuildConfigParser.js.map +0 -1
  11. package/dist_commonjs/BuildFunction.cjs +0 -40
  12. package/dist_commonjs/BuildFunction.d.ts +0 -32
  13. package/dist_commonjs/BuildFunction.js.map +0 -1
  14. package/dist_commonjs/BuildPlatform.cjs +0 -9
  15. package/dist_commonjs/BuildPlatform.d.ts +0 -4
  16. package/dist_commonjs/BuildPlatform.js.map +0 -1
  17. package/dist_commonjs/BuildStep.cjs +0 -179
  18. package/dist_commonjs/BuildStep.d.ts +0 -48
  19. package/dist_commonjs/BuildStep.js.map +0 -1
  20. package/dist_commonjs/BuildStepContext.cjs +0 -32
  21. package/dist_commonjs/BuildStepContext.d.ts +0 -13
  22. package/dist_commonjs/BuildStepContext.js.map +0 -1
  23. package/dist_commonjs/BuildStepEnv.cjs +0 -3
  24. package/dist_commonjs/BuildStepEnv.d.ts +0 -1
  25. package/dist_commonjs/BuildStepEnv.js.map +0 -1
  26. package/dist_commonjs/BuildStepInput.cjs +0 -36
  27. package/dist_commonjs/BuildStepInput.d.ts +0 -18
  28. package/dist_commonjs/BuildStepInput.js.map +0 -1
  29. package/dist_commonjs/BuildStepOutput.cjs +0 -29
  30. package/dist_commonjs/BuildStepOutput.d.ts +0 -16
  31. package/dist_commonjs/BuildStepOutput.js.map +0 -1
  32. package/dist_commonjs/BuildTemporaryFiles.cjs +0 -100
  33. package/dist_commonjs/BuildTemporaryFiles.d.ts +0 -8
  34. package/dist_commonjs/BuildTemporaryFiles.js.map +0 -1
  35. package/dist_commonjs/BuildWorkflow.cjs +0 -32
  36. package/dist_commonjs/BuildWorkflow.d.ts +0 -17
  37. package/dist_commonjs/BuildWorkflow.js.map +0 -1
  38. package/dist_commonjs/BuildWorkflowValidator.cjs +0 -76
  39. package/dist_commonjs/BuildWorkflowValidator.d.ts +0 -8
  40. package/dist_commonjs/BuildWorkflowValidator.js.map +0 -1
  41. package/dist_commonjs/bin/uploadArtifact.cjs +0 -30
  42. package/dist_commonjs/bin/uploadArtifact.d.ts +0 -1
  43. package/dist_commonjs/bin/uploadArtifact.js.map +0 -1
  44. package/dist_commonjs/cli/cli.cjs +0 -37
  45. package/dist_commonjs/cli/cli.d.ts +0 -1
  46. package/dist_commonjs/cli/cli.js.map +0 -1
  47. package/dist_commonjs/errors/BuildConfigError.cjs +0 -8
  48. package/dist_commonjs/errors/BuildConfigError.d.ts +0 -3
  49. package/dist_commonjs/errors/BuildConfigError.js.map +0 -1
  50. package/dist_commonjs/errors/BuildInternalError.cjs +0 -7
  51. package/dist_commonjs/errors/BuildInternalError.d.ts +0 -2
  52. package/dist_commonjs/errors/BuildInternalError.js.map +0 -1
  53. package/dist_commonjs/errors/BuildStepRuntimeError.cjs +0 -8
  54. package/dist_commonjs/errors/BuildStepRuntimeError.d.ts +0 -3
  55. package/dist_commonjs/errors/BuildStepRuntimeError.js.map +0 -1
  56. package/dist_commonjs/errors/BuildWorkflowError.cjs +0 -13
  57. package/dist_commonjs/errors/BuildWorkflowError.d.ts +0 -10
  58. package/dist_commonjs/errors/BuildWorkflowError.js.map +0 -1
  59. package/dist_commonjs/errors/UserError.cjs +0 -14
  60. package/dist_commonjs/errors/UserError.d.ts +0 -9
  61. package/dist_commonjs/errors/UserError.js.map +0 -1
  62. package/dist_commonjs/index.cjs +0 -10
  63. package/dist_commonjs/index.d.ts +0 -3
  64. package/dist_commonjs/index.js.map +0 -1
  65. package/dist_commonjs/utils/expodash/uniq.cjs +0 -9
  66. package/dist_commonjs/utils/expodash/uniq.d.ts +0 -1
  67. package/dist_commonjs/utils/expodash/uniq.js.map +0 -1
  68. package/dist_commonjs/utils/nullthrows.cjs +0 -11
  69. package/dist_commonjs/utils/nullthrows.d.ts +0 -1
  70. package/dist_commonjs/utils/nullthrows.js.map +0 -1
  71. package/dist_commonjs/utils/shell/bin.cjs +0 -11
  72. package/dist_commonjs/utils/shell/bin.d.ts +0 -1
  73. package/dist_commonjs/utils/shell/bin.js.map +0 -1
  74. package/dist_commonjs/utils/shell/command.cjs +0 -36
  75. package/dist_commonjs/utils/shell/command.d.ts +0 -6
  76. package/dist_commonjs/utils/shell/command.js.map +0 -1
  77. package/dist_commonjs/utils/shell/spawn.cjs +0 -25
  78. package/dist_commonjs/utils/shell/spawn.d.ts +0 -9
  79. package/dist_commonjs/utils/shell/spawn.js.map +0 -1
  80. package/dist_commonjs/utils/template.cjs +0 -47
  81. package/dist_commonjs/utils/template.d.ts +0 -11
  82. package/dist_commonjs/utils/template.js.map +0 -1
  83. package/dist_esm/BuildArtifacts.d.ts +0 -5
  84. package/dist_esm/BuildArtifacts.js +0 -6
  85. package/dist_esm/BuildArtifacts.js.map +0 -1
  86. package/dist_esm/BuildConfig.d.ts +0 -53
  87. package/dist_esm/BuildConfig.js +0 -97
  88. package/dist_esm/BuildConfig.js.map +0 -1
  89. package/dist_esm/BuildConfigParser.d.ts +0 -19
  90. package/dist_esm/BuildConfigParser.js +0 -147
  91. package/dist_esm/BuildConfigParser.js.map +0 -1
  92. package/dist_esm/BuildFunction.d.ts +0 -32
  93. package/dist_esm/BuildFunction.js +0 -36
  94. package/dist_esm/BuildFunction.js.map +0 -1
  95. package/dist_esm/BuildPlatform.d.ts +0 -4
  96. package/dist_esm/BuildPlatform.js +0 -6
  97. package/dist_esm/BuildPlatform.js.map +0 -1
  98. package/dist_esm/BuildStep.d.ts +0 -48
  99. package/dist_esm/BuildStep.js +0 -172
  100. package/dist_esm/BuildStep.js.map +0 -1
  101. package/dist_esm/BuildStepContext.d.ts +0 -13
  102. package/dist_esm/BuildStepContext.js +0 -25
  103. package/dist_esm/BuildStepContext.js.map +0 -1
  104. package/dist_esm/BuildStepEnv.d.ts +0 -1
  105. package/dist_esm/BuildStepEnv.js +0 -2
  106. package/dist_esm/BuildStepEnv.js.map +0 -1
  107. package/dist_esm/BuildStepInput.d.ts +0 -18
  108. package/dist_esm/BuildStepInput.js +0 -32
  109. package/dist_esm/BuildStepInput.js.map +0 -1
  110. package/dist_esm/BuildStepOutput.d.ts +0 -16
  111. package/dist_esm/BuildStepOutput.js +0 -25
  112. package/dist_esm/BuildStepOutput.js.map +0 -1
  113. package/dist_esm/BuildTemporaryFiles.d.ts +0 -8
  114. package/dist_esm/BuildTemporaryFiles.js +0 -88
  115. package/dist_esm/BuildTemporaryFiles.js.map +0 -1
  116. package/dist_esm/BuildWorkflow.d.ts +0 -17
  117. package/dist_esm/BuildWorkflow.js +0 -28
  118. package/dist_esm/BuildWorkflow.js.map +0 -1
  119. package/dist_esm/BuildWorkflowValidator.d.ts +0 -8
  120. package/dist_esm/BuildWorkflowValidator.js +0 -72
  121. package/dist_esm/BuildWorkflowValidator.js.map +0 -1
  122. package/dist_esm/bin/uploadArtifact.d.ts +0 -1
  123. package/dist_esm/bin/uploadArtifact.js +0 -25
  124. package/dist_esm/bin/uploadArtifact.js.map +0 -1
  125. package/dist_esm/cli/cli.d.ts +0 -1
  126. package/dist_esm/cli/cli.js +0 -32
  127. package/dist_esm/cli/cli.js.map +0 -1
  128. package/dist_esm/errors/BuildConfigError.d.ts +0 -3
  129. package/dist_esm/errors/BuildConfigError.js +0 -4
  130. package/dist_esm/errors/BuildConfigError.js.map +0 -1
  131. package/dist_esm/errors/BuildInternalError.d.ts +0 -2
  132. package/dist_esm/errors/BuildInternalError.js +0 -3
  133. package/dist_esm/errors/BuildInternalError.js.map +0 -1
  134. package/dist_esm/errors/BuildStepRuntimeError.d.ts +0 -3
  135. package/dist_esm/errors/BuildStepRuntimeError.js +0 -4
  136. package/dist_esm/errors/BuildStepRuntimeError.js.map +0 -1
  137. package/dist_esm/errors/BuildWorkflowError.d.ts +0 -10
  138. package/dist_esm/errors/BuildWorkflowError.js +0 -9
  139. package/dist_esm/errors/BuildWorkflowError.js.map +0 -1
  140. package/dist_esm/errors/UserError.d.ts +0 -9
  141. package/dist_esm/errors/UserError.js +0 -10
  142. package/dist_esm/errors/UserError.js.map +0 -1
  143. package/dist_esm/index.d.ts +0 -3
  144. package/dist_esm/index.js +0 -4
  145. package/dist_esm/index.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/nullthrows.d.ts +0 -1
  150. package/dist_esm/utils/nullthrows.js +0 -7
  151. package/dist_esm/utils/nullthrows.js.map +0 -1
  152. package/dist_esm/utils/shell/bin.d.ts +0 -1
  153. package/dist_esm/utils/shell/bin.js +0 -5
  154. package/dist_esm/utils/shell/bin.js.map +0 -1
  155. package/dist_esm/utils/shell/command.d.ts +0 -6
  156. package/dist_esm/utils/shell/command.js +0 -28
  157. package/dist_esm/utils/shell/command.js.map +0 -1
  158. package/dist_esm/utils/shell/spawn.d.ts +0 -9
  159. package/dist_esm/utils/shell/spawn.js +0 -18
  160. package/dist_esm/utils/shell/spawn.js.map +0 -1
  161. package/dist_esm/utils/template.d.ts +0 -11
  162. package/dist_esm/utils/template.js +0 -40
  163. package/dist_esm/utils/template.js.map +0 -1
@@ -1,172 +0,0 @@
1
- import fs from 'fs/promises';
2
- import path from 'path';
3
- import { v4 as uuidv4 } from 'uuid';
4
- import { BIN_PATH } from './utils/shell/bin.js';
5
- import { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';
6
- import { cleanUpStepTemporaryDirectoriesAsync, createTemporaryOutputsDirectoryAsync, saveScriptToTemporaryFileAsync, } from './BuildTemporaryFiles.js';
7
- import { spawnAsync } from './utils/shell/spawn.js';
8
- import { interpolateWithInputs } from './utils/template.js';
9
- import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
10
- export var BuildStepStatus;
11
- (function (BuildStepStatus) {
12
- BuildStepStatus["NEW"] = "new";
13
- BuildStepStatus["IN_PROGRESS"] = "in-progress";
14
- BuildStepStatus["CANCELED"] = "canceled";
15
- BuildStepStatus["FAIL"] = "fail";
16
- BuildStepStatus["WARNING"] = "warning";
17
- BuildStepStatus["SUCCESS"] = "success";
18
- })(BuildStepStatus || (BuildStepStatus = {}));
19
- export var BuildStepLogMarker;
20
- (function (BuildStepLogMarker) {
21
- BuildStepLogMarker["START_STEP"] = "start-step";
22
- BuildStepLogMarker["END_STEP"] = "end-step";
23
- })(BuildStepLogMarker || (BuildStepLogMarker = {}));
24
- export class BuildStep {
25
- constructor(ctx, { id, name, inputs, outputs, command, workingDirectory, shell, }) {
26
- this.ctx = ctx;
27
- this.executed = false;
28
- this.id = id;
29
- this.name = name;
30
- this.displayName = this.getStepDisplayName(name, command);
31
- this.inputs = inputs;
32
- this.outputs = outputs;
33
- this.outputById =
34
- outputs === undefined
35
- ? {}
36
- : outputs.reduce((acc, output) => {
37
- acc[output.id] = output;
38
- return acc;
39
- }, {});
40
- this.command = command;
41
- this.workingDirectory = workingDirectory;
42
- this.shell = shell !== null && shell !== void 0 ? shell : getDefaultShell();
43
- this.status = BuildStepStatus.NEW;
44
- this.internalId = uuidv4();
45
- this.logger = ctx.logger.child({
46
- buildStepInternalId: this.internalId,
47
- buildStepId: this.id,
48
- buildStepDisplayName: this.displayName,
49
- });
50
- ctx.registerStep(this);
51
- }
52
- async executeAsync(env = process.env) {
53
- try {
54
- this.logger.info({ marker: BuildStepLogMarker.START_STEP }, `Executing build step "${this.id}"`);
55
- this.status = BuildStepStatus.IN_PROGRESS;
56
- const command = this.interpolateInputsInCommand(this.command, this.inputs);
57
- this.logger.debug(`Interpolated inputs in the command template`);
58
- const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx, this.id);
59
- this.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);
60
- const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx, this.id, command);
61
- this.logger.debug(`Saved script to ${scriptPath}`);
62
- const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);
63
- this.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
64
- await spawnAsync(shellCommand, args !== null && args !== void 0 ? args : [], {
65
- cwd: this.workingDirectory,
66
- logger: this.logger,
67
- env: this.getScriptEnv(env, outputsDir),
68
- });
69
- this.logger.debug(`Script completed successfully`);
70
- await this.collectAndValidateOutputsAsync(outputsDir);
71
- this.logger.debug('Finished collecting output paramters');
72
- this.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS }, `Finished build step "${this.id}" successfully`);
73
- this.status = BuildStepStatus.SUCCESS;
74
- }
75
- catch (err) {
76
- this.logger.error({ err });
77
- this.logger.error({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL }, `Build step "${this.id}" failed`);
78
- this.status = BuildStepStatus.FAIL;
79
- throw err;
80
- }
81
- finally {
82
- this.executed = true;
83
- await cleanUpStepTemporaryDirectoriesAsync(this.ctx, this.id);
84
- }
85
- }
86
- hasOutputParameter(name) {
87
- return name in this.outputById;
88
- }
89
- getOutputValueByName(name) {
90
- if (!this.executed) {
91
- throw new BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.id}". The step has not been executed yet.`);
92
- }
93
- if (!this.hasOutputParameter(name)) {
94
- throw new BuildStepRuntimeError(`Step "${this.id}" does not have output "${name}"`);
95
- }
96
- return this.outputById[name].value;
97
- }
98
- interpolateInputsInCommand(command, inputs) {
99
- if (!inputs) {
100
- return command;
101
- }
102
- const vars = inputs.reduce((acc, input) => {
103
- var _a;
104
- acc[input.id] = (_a = input.value) !== null && _a !== void 0 ? _a : '';
105
- return acc;
106
- }, {});
107
- return interpolateWithInputs(command, vars);
108
- }
109
- async collectAndValidateOutputsAsync(outputsDir) {
110
- var _a;
111
- const files = await fs.readdir(outputsDir);
112
- const nonDefinedOutputIds = [];
113
- for (const outputId of files) {
114
- if (!(outputId in this.outputById)) {
115
- nonDefinedOutputIds.push(outputId);
116
- }
117
- else {
118
- const file = path.join(outputsDir, outputId);
119
- const rawContents = await fs.readFile(file, 'utf-8');
120
- const value = rawContents.trim();
121
- this.outputById[outputId].set(value);
122
- }
123
- }
124
- if (nonDefinedOutputIds.length > 0) {
125
- const idsString = nonDefinedOutputIds.map((i) => `"${i}"`).join(', ');
126
- this.logger.warn(`Some outputs are not defined in step config: ${idsString}`);
127
- }
128
- const nonSetRequiredOutputIds = [];
129
- for (const output of (_a = this.outputs) !== null && _a !== void 0 ? _a : []) {
130
- try {
131
- const value = output.value;
132
- this.logger.debug(`Output parameter "${output.id}" is set to "${value}"`);
133
- }
134
- catch (err) {
135
- this.logger.debug({ err }, `Getting value for output parameter "${output.id}" failed.`);
136
- nonSetRequiredOutputIds.push(output.id);
137
- }
138
- }
139
- if (nonSetRequiredOutputIds.length > 0) {
140
- const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
141
- throw new BuildStepRuntimeError(`Some required output parameters have not been set: ${idsString}`, { metadata: { ids: nonSetRequiredOutputIds } });
142
- }
143
- }
144
- getScriptEnv(env, outputsDir) {
145
- var _a;
146
- const currentPath = (_a = env.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
147
- const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;
148
- return {
149
- ...env,
150
- __EXPO_STEPS_BUILD_ID: this.ctx.buildId,
151
- __EXPO_STEPS_OUTPUTS_DIR: outputsDir,
152
- __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,
153
- PATH: newPath,
154
- };
155
- }
156
- getStepDisplayName(name, command) {
157
- if (name) {
158
- return name;
159
- }
160
- if (command !== '') {
161
- const splits = command.trim().split('\n');
162
- for (const split of splits) {
163
- const trimmed = split.trim();
164
- if (trimmed && !trimmed.startsWith('#')) {
165
- return trimmed;
166
- }
167
- }
168
- }
169
- return undefined;
170
- }
171
- }
172
- //# sourceMappingURL=BuildStep.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAKpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EACL,oCAAoC,EACpC,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,MAAM,CAAN,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,KAAf,eAAe,QAO1B;AAED,MAAM,CAAN,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,QAG7B;AAED,MAAM,OAAO,SAAS;IAgBpB,YACmB,GAAqB,EACtC,EACE,EAAE,EACF,IAAI,EACJ,MAAM,E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AG,CAAC,IAAI,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,QAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QACtE,OAAO;YACL,GAAG,GAAG;YACN,qBAAqB,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;YACvC,wBAAwB,EAAE,UAAU;YACpC,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,IAAwB,EAAE,OAAe;QAClE,IAAI,IAAI,EAAE;YACR,OAAO,IAAI,CAAC;SACb;QACD,IAAI,OAAO,KAAK,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;gBAC7B,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;oBACvC,OAAO,OAAO,CAAC;iBAChB;aACF;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInput } from './BuildStepInput.js';\nimport { BuildStepOutput } from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport { interpolateWithInputs } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n CANCELED = 'canceled',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport class BuildStep {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName?: string;\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command: string;\n public readonly workingDirectory: string;\n public readonly shell: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly logger: bunyan;\n private readonly outputById: Record<string, BuildStepOutput>;\n private executed = false;\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n name,\n inputs,\n outputs,\n command,\n workingDirectory,\n shell,\n }: {\n id: string;\n name?: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command: string;\n workingDirectory: string;\n shell?: string;\n }\n ) {\n this.id = id;\n this.name = name;\n this.displayName = this.getStepDisplayName(name, command);\n this.inputs = inputs;\n this.outputs = outputs;\n this.outputById =\n outputs === undefined\n ? {}\n : outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as Record<string, BuildStepOutput>);\n this.command = command;\n this.workingDirectory = workingDirectory;\n this.shell = shell ?? getDefaultShell();\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n this.logger = ctx.logger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(env: BuildStepEnv = process.env): Promise<void> {\n try {\n this.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.id}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n const command = this.interpolateInputsInCommand(this.command, this.inputs);\n this.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx, this.id);\n this.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx, this.id, command);\n this.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.workingDirectory,\n logger: this.logger,\n env: this.getScriptEnv(env, outputsDir),\n });\n this.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n this.logger.debug('Finished collecting output paramters');\n\n this.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.id}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.logger.error({ err });\n this.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.id}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx, this.id);\n }\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.id}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.id}\" does not have output \"${name}\"`);\n }\n return this.outputById[name].value;\n }\n\n private interpolateInputsInCommand(command: string, inputs?: BuildStepInput[]): string {\n if (!inputs) {\n return command;\n }\n const vars = inputs.reduce((acc, input) => {\n acc[input.id] = input.value ?? '';\n return acc;\n }, {} as Record<string, string>);\n return interpolateWithInputs(command, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of this.outputs ?? []) {\n try {\n const value = output.value;\n this.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(\n `Some required output parameters have not been set: ${idsString}`,\n { metadata: { ids: nonSetRequiredOutputIds } }\n );\n }\n }\n\n private getScriptEnv(env: BuildStepEnv, outputsDir: string): Record<string, string> {\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_BUILD_ID: this.ctx.buildId,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n\n private getStepDisplayName(name: string | undefined, command: string): string | undefined {\n if (name) {\n return name;\n }\n if (command !== '') {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return undefined;\n }\n}\n"]}
@@ -1,13 +0,0 @@
1
- import { bunyan } from '@expo/logger';
2
- import { BuildStep } from './BuildStep.js';
3
- export declare class BuildStepContext {
4
- readonly buildId: string;
5
- readonly logger: bunyan;
6
- readonly skipCleanup: boolean;
7
- readonly baseWorkingDirectory: string;
8
- readonly workingDirectory: string;
9
- private stepById;
10
- constructor(buildId: string, logger: bunyan, skipCleanup: boolean, workingDirectory?: string);
11
- registerStep(step: BuildStep): void;
12
- getStepOutputValue(path: string): string | undefined;
13
- }
@@ -1,25 +0,0 @@
1
- import os from 'os';
2
- import path from 'path';
3
- import { parseOutputPath } from './utils/template.js';
4
- import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
5
- export class BuildStepContext {
6
- constructor(buildId, logger, skipCleanup, workingDirectory) {
7
- this.buildId = buildId;
8
- this.logger = logger;
9
- this.skipCleanup = skipCleanup;
10
- this.stepById = {};
11
- this.baseWorkingDirectory = path.join(os.tmpdir(), 'eas-build', buildId);
12
- this.workingDirectory = workingDirectory !== null && workingDirectory !== void 0 ? workingDirectory : path.join(this.baseWorkingDirectory, 'project');
13
- }
14
- registerStep(step) {
15
- this.stepById[step.id] = step;
16
- }
17
- getStepOutputValue(path) {
18
- const { stepId, outputId } = parseOutputPath(path);
19
- if (!(stepId in this.stepById)) {
20
- throw new BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
21
- }
22
- return this.stepById[stepId].getOutputValueByName(outputId);
23
- }
24
- }
25
- //# sourceMappingURL=BuildStepContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,OAAO,gBAAgB;IAM3B,YACkB,OAAe,EACf,MAAc,EACd,WAAoB,EACpC,gBAAyB;QAHT,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAS;QAL9B,aAAQ,GAA8B,EAAE,CAAC;QAQ/C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;IAC9F,CAAC;IAEM,YAAY,CAAC,IAAe;QACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC;IAEM,kBAAkB,CAAC,IAAY;QACpC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC9B,MAAM,IAAI,qBAAqB,CAAC,SAAS,MAAM,mBAAmB,CAAC,CAAC;SACrE;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStep } from './BuildStep.js';\nimport { parseOutputPath } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\n\nexport class BuildStepContext {\n public readonly baseWorkingDirectory: string;\n public readonly workingDirectory: string;\n\n private stepById: Record<string, BuildStep> = {};\n\n constructor(\n public readonly buildId: string,\n public readonly logger: bunyan,\n public readonly skipCleanup: boolean,\n workingDirectory?: string\n ) {\n this.baseWorkingDirectory = path.join(os.tmpdir(), 'eas-build', buildId);\n this.workingDirectory = workingDirectory ?? path.join(this.baseWorkingDirectory, 'project');\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"]}
@@ -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,18 +0,0 @@
1
- import { BuildStepContext } from './BuildStepContext.js';
2
- export type BuildStepInputCreator = (stepId: string) => BuildStepInput;
3
- export declare class BuildStepInput {
4
- private readonly ctx;
5
- readonly id: string;
6
- readonly stepId: string;
7
- readonly defaultValue?: string;
8
- readonly required: boolean;
9
- private _value?;
10
- constructor(ctx: BuildStepContext, { id, stepId, defaultValue, required, }: {
11
- id: string;
12
- stepId: string;
13
- defaultValue?: string;
14
- required?: boolean;
15
- });
16
- get value(): string | undefined;
17
- set(value: string | undefined): BuildStepInput;
18
- }
@@ -1,32 +0,0 @@
1
- import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
2
- import { interpolateWithOutputs } from './utils/template.js';
3
- export class BuildStepInput {
4
- constructor(ctx, { id, stepId, defaultValue, required = true, }) {
5
- this.ctx = ctx;
6
- this.id = id;
7
- this.stepId = stepId;
8
- this.defaultValue = defaultValue;
9
- this.required = required;
10
- }
11
- get value() {
12
- var _a;
13
- const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
14
- if (this.required && rawValue === undefined) {
15
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepId}" is required but it was not set.`);
16
- }
17
- if (rawValue === undefined) {
18
- return rawValue;
19
- }
20
- else {
21
- return interpolateWithOutputs(rawValue, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
22
- }
23
- }
24
- set(value) {
25
- if (this.required && value === undefined) {
26
- throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepId}" is required.`);
27
- }
28
- this._value = value;
29
- return this;
30
- }
31
- }
32
- //# sourceMappingURL=BuildStepInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,MAAM,OAAO,cAAc;IAQzB,YACmB,GAAqB,EACtC,EACE,EAAE,EACF,MAAM,EACN,YAAY,EACZ,QAAQ,GAAG,IAAI,GAMhB;QAXgB,QAAG,GAAH,GAAG,CAAkB;QAatC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;;QACP,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,mCAAmC,CACzF,CAAC;SACH;QAED,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,OAAO,QAAQ,CAAC;SACjB;aAAM;YACL,OAAO,sBAAsB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAA,EAAA,CAAC,CAAC;SAC5F;IACH,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,gBAAgB,CACtE,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\nimport { interpolateWithOutputs } from './utils/template.js';\n\nexport type BuildStepInputCreator = (stepId: string) => BuildStepInput;\n\nexport class BuildStepInput {\n public readonly id: string;\n public readonly stepId: string;\n public readonly defaultValue?: string;\n public readonly required: boolean;\n\n private _value?: string;\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n stepId,\n defaultValue,\n required = true,\n }: {\n id: string;\n stepId: string;\n defaultValue?: string;\n required?: boolean;\n }\n ) {\n this.id = id;\n this.stepId = stepId;\n this.defaultValue = defaultValue;\n this.required = required;\n }\n\n get value(): string | 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.stepId}\" is required but it was not set.`\n );\n }\n\n if (rawValue === undefined) {\n return rawValue;\n } else {\n return interpolateWithOutputs(rawValue, (path) => this.ctx.getStepOutputValue(path) ?? '');\n }\n }\n\n set(value: string | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepId}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n"]}
@@ -1,16 +0,0 @@
1
- import { BuildStepContext } from './BuildStepContext.js';
2
- export type BuildStepOutputCreator = (stepId: string) => BuildStepOutput;
3
- export declare class BuildStepOutput {
4
- private readonly ctx;
5
- readonly id: string;
6
- readonly stepId: string;
7
- readonly required: boolean;
8
- private _value?;
9
- constructor(ctx: BuildStepContext, { id, stepId, required }: {
10
- id: string;
11
- stepId: string;
12
- required?: boolean;
13
- });
14
- get value(): string | undefined;
15
- set(value: string | undefined): BuildStepOutput;
16
- }
@@ -1,25 +0,0 @@
1
- import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
2
- export class BuildStepOutput {
3
- constructor(
4
- // @ts-expect-error ctx is not used in this class but let's keep it here for consistency
5
- ctx, { id, stepId, required = true }) {
6
- this.ctx = ctx;
7
- this.id = id;
8
- this.stepId = stepId;
9
- this.required = required;
10
- }
11
- get value() {
12
- if (this.required && this._value === undefined) {
13
- throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required but it was not set.`);
14
- }
15
- return this._value;
16
- }
17
- set(value) {
18
- if (this.required && value === undefined) {
19
- throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required.`);
20
- }
21
- this._value = value;
22
- return this;
23
- }
24
- }
25
- //# 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,mCAAmC,CAAC;AAI1E,MAAM,OAAO,eAAe;IAO1B;IACE,wFAAwF;IACvE,GAAqB,EACtC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAsD;QADlE,QAAG,GAAH,GAAG,CAAkB;QAGtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9C,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,mCAAmC,CAC1F,CAAC;SACH;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,gBAAgB,CACvE,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\n\nexport type BuildStepOutputCreator = (stepId: string) => BuildStepOutput;\n\nexport class BuildStepOutput {\n public readonly id: string;\n public readonly stepId: string;\n public readonly required: boolean;\n\n private _value?: string;\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: BuildStepContext,\n { id, stepId, required = true }: { id: string; stepId: string; required?: boolean }\n ) {\n this.id = id;\n this.stepId = stepId;\n this.required = required;\n }\n\n get value(): string | undefined {\n if (this.required && this._value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepId}\" is required but it was not set.`\n );\n }\n return this._value;\n }\n\n set(value: string | undefined): BuildStepOutput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepId}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n"]}
@@ -1,8 +0,0 @@
1
- import { BuildStepContext } from './BuildStepContext.js';
2
- import { BuildArtifactType } from './BuildArtifacts.js';
3
- export declare function saveScriptToTemporaryFileAsync(ctx: BuildStepContext, stepId: string, scriptContents: string): Promise<string>;
4
- export declare function saveArtifactToTemporaryDirectoryAsync(ctx: BuildStepContext, type: BuildArtifactType, artifactPath: string): Promise<string>;
5
- export declare function createTemporaryOutputsDirectoryAsync(ctx: BuildStepContext, stepId: string): Promise<string>;
6
- export declare function findArtifactsByTypeAsync(ctx: BuildStepContext, type: BuildArtifactType): Promise<string[]>;
7
- export declare function cleanUpStepTemporaryDirectoriesAsync(ctx: BuildStepContext, stepId: string): Promise<void>;
8
- export declare function cleanUpWorkflowTemporaryDirectoriesAsync(ctx: BuildStepContext): Promise<void>;
@@ -1,88 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs/promises';
3
- import { v4 as uuidv4 } from 'uuid';
4
- import { BuildArtifactType } from './BuildArtifacts.js';
5
- import { BuildInternalError } from './errors/BuildInternalError.js';
6
- export async function saveScriptToTemporaryFileAsync(ctx, stepId, scriptContents) {
7
- const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);
8
- await fs.mkdir(scriptsDir, { recursive: true });
9
- const temporaryScriptPath = path.join(scriptsDir, `${uuidv4()}.sh`);
10
- await fs.writeFile(temporaryScriptPath, scriptContents);
11
- return temporaryScriptPath;
12
- }
13
- export async function saveArtifactToTemporaryDirectoryAsync(ctx, type, artifactPath) {
14
- let targetArtifactPath;
15
- if (type === BuildArtifactType.APPLICATION_ARCHIVE) {
16
- targetArtifactPath = path.join(getTemporaryApplicationArchiveDirPath(ctx), path.basename(artifactPath));
17
- }
18
- else if (type === BuildArtifactType.BUILD_ARTIFACT) {
19
- targetArtifactPath = path.join(getTemporaryBuildArtifactsDirPath(ctx), path.basename(artifactPath));
20
- }
21
- else {
22
- throw new BuildInternalError(`Uploading artifacts of type "${type}" is not implemented.`);
23
- }
24
- await fs.mkdir(path.dirname(targetArtifactPath), { recursive: true });
25
- await fs.copyFile(artifactPath, targetArtifactPath);
26
- return targetArtifactPath;
27
- }
28
- export async function createTemporaryOutputsDirectoryAsync(ctx, stepId) {
29
- const directory = getTemporaryOutputsDirPath(ctx, stepId);
30
- await fs.mkdir(directory, { recursive: true });
31
- return directory;
32
- }
33
- export async function findArtifactsByTypeAsync(ctx, type) {
34
- let artifactsDirPath;
35
- if (type === BuildArtifactType.APPLICATION_ARCHIVE) {
36
- artifactsDirPath = getTemporaryApplicationArchiveDirPath(ctx);
37
- }
38
- else if (type === BuildArtifactType.BUILD_ARTIFACT) {
39
- artifactsDirPath = getTemporaryBuildArtifactsDirPath(ctx);
40
- }
41
- else {
42
- throw new BuildInternalError(`Finding artifacts of type "${type}" is not implemented.`);
43
- }
44
- try {
45
- const filenames = await fs.readdir(artifactsDirPath);
46
- return filenames.map((filename) => path.join(artifactsDirPath, filename));
47
- }
48
- catch (err) {
49
- ctx.logger.debug({ err }, `Failed reading artifacts of type "${type}" from "${artifactsDirPath}". The directory probably doesn't exist.`);
50
- return [];
51
- }
52
- }
53
- export async function cleanUpStepTemporaryDirectoriesAsync(ctx, stepId) {
54
- if (ctx.skipCleanup) {
55
- return;
56
- }
57
- const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);
58
- await fs.rm(stepTemporaryDirectory, { recursive: true });
59
- ctx.logger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');
60
- }
61
- export async function cleanUpWorkflowTemporaryDirectoriesAsync(ctx) {
62
- if (ctx.skipCleanup) {
63
- return;
64
- }
65
- const temporaryDirectories = [getTemporaryArtifactsDirPath(ctx)];
66
- const rmPromises = temporaryDirectories.map((dir) => fs.rm(dir, { recursive: true }));
67
- await Promise.all(rmPromises);
68
- ctx.logger.debug({ temporaryDirectories }, 'Removed temporary directories');
69
- }
70
- function getTemporaryStepDirPath(ctx, stepId) {
71
- return path.join(ctx.baseWorkingDirectory, 'steps', stepId);
72
- }
73
- function getTemporaryScriptsDirPath(ctx, stepId) {
74
- return path.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');
75
- }
76
- function getTemporaryOutputsDirPath(ctx, stepId) {
77
- return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');
78
- }
79
- function getTemporaryApplicationArchiveDirPath(ctx) {
80
- return path.join(getTemporaryArtifactsDirPath(ctx), 'application-archive');
81
- }
82
- function getTemporaryBuildArtifactsDirPath(ctx) {
83
- return path.join(getTemporaryArtifactsDirPath(ctx), 'build-artifacts');
84
- }
85
- function getTemporaryArtifactsDirPath(ctx) {
86
- return path.join(ctx.baseWorkingDirectory, 'artifacts');
87
- }
88
- //# 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;AAGpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,GAAqB,EACrB,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,UA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,EAAE,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtF,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9B,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,oBAAoB,EAAE,EAAE,+BAA+B,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAqB,EAAE,MAAc;IACpE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,0BAA0B,CAAC,GAAqB,EAAE,MAAc;IACvE,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,0BAA0B,CAAC,GAAqB,EAAE,MAAc;IACvE,OAAO,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,qCAAqC,CAAC,GAAqB;IAClE,OAAO,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,iCAAiC,CAAC,GAAqB;IAC9D,OAAO,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,4BAA4B,CAAC,GAAqB;IACzD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import path from 'path';\nimport fs from 'fs/promises';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildArtifactType } from './BuildArtifacts.js';\nimport { BuildInternalError } from './errors/BuildInternalError.js';\n\nexport async function saveScriptToTemporaryFileAsync(\n ctx: BuildStepContext,\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 saveArtifactToTemporaryDirectoryAsync(\n ctx: BuildStepContext,\n type: BuildArtifactType,\n artifactPath: string\n): Promise<string> {\n let targetArtifactPath: string;\n if (type === BuildArtifactType.APPLICATION_ARCHIVE) {\n targetArtifactPath = path.join(\n getTemporaryApplicationArchiveDirPath(ctx),\n path.basename(artifactPath)\n );\n } else if (type === BuildArtifactType.BUILD_ARTIFACT) {\n targetArtifactPath = path.join(\n getTemporaryBuildArtifactsDirPath(ctx),\n path.basename(artifactPath)\n );\n } else {\n throw new BuildInternalError(`Uploading artifacts of type \"${type}\" is not implemented.`);\n }\n\n await fs.mkdir(path.dirname(targetArtifactPath), { recursive: true });\n await fs.copyFile(artifactPath, targetArtifactPath);\n return targetArtifactPath;\n}\n\nexport async function createTemporaryOutputsDirectoryAsync(\n ctx: BuildStepContext,\n stepId: string\n): Promise<string> {\n const directory = getTemporaryOutputsDirPath(ctx, stepId);\n await fs.mkdir(directory, { recursive: true });\n return directory;\n}\n\nexport async function findArtifactsByTypeAsync(\n ctx: BuildStepContext,\n type: BuildArtifactType\n): Promise<string[]> {\n let artifactsDirPath: string;\n if (type === BuildArtifactType.APPLICATION_ARCHIVE) {\n artifactsDirPath = getTemporaryApplicationArchiveDirPath(ctx);\n } else if (type === BuildArtifactType.BUILD_ARTIFACT) {\n artifactsDirPath = getTemporaryBuildArtifactsDirPath(ctx);\n } else {\n throw new BuildInternalError(`Finding artifacts of type \"${type}\" is not implemented.`);\n }\n try {\n const filenames = await fs.readdir(artifactsDirPath);\n return filenames.map((filename) => path.join(artifactsDirPath, filename));\n } catch (err) {\n ctx.logger.debug(\n { err },\n `Failed reading artifacts of type \"${type}\" from \"${artifactsDirPath}\". The directory probably doesn't exist.`\n );\n return [];\n }\n}\n\nexport async function cleanUpStepTemporaryDirectoriesAsync(\n ctx: BuildStepContext,\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 });\n ctx.logger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');\n}\n\nexport async function cleanUpWorkflowTemporaryDirectoriesAsync(\n ctx: BuildStepContext\n): Promise<void> {\n if (ctx.skipCleanup) {\n return;\n }\n\n const temporaryDirectories: string[] = [getTemporaryArtifactsDirPath(ctx)];\n const rmPromises = temporaryDirectories.map((dir) => fs.rm(dir, { recursive: true }));\n await Promise.all(rmPromises);\n ctx.logger.debug({ temporaryDirectories }, 'Removed temporary directories');\n}\n\nfunction getTemporaryStepDirPath(ctx: BuildStepContext, stepId: string): string {\n return path.join(ctx.baseWorkingDirectory, 'steps', stepId);\n}\n\nfunction getTemporaryScriptsDirPath(ctx: BuildStepContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');\n}\n\nfunction getTemporaryOutputsDirPath(ctx: BuildStepContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');\n}\n\nfunction getTemporaryApplicationArchiveDirPath(ctx: BuildStepContext): string {\n return path.join(getTemporaryArtifactsDirPath(ctx), 'application-archive');\n}\n\nfunction getTemporaryBuildArtifactsDirPath(ctx: BuildStepContext): string {\n return path.join(getTemporaryArtifactsDirPath(ctx), 'build-artifacts');\n}\n\nfunction getTemporaryArtifactsDirPath(ctx: BuildStepContext): string {\n return path.join(ctx.baseWorkingDirectory, 'artifacts');\n}\n"]}
@@ -1,17 +0,0 @@
1
- import { BuildArtifacts } from './BuildArtifacts.js';
2
- import { BuildFunctionById } from './BuildFunction.js';
3
- import { BuildStep } from './BuildStep.js';
4
- import { BuildStepContext } from './BuildStepContext.js';
5
- import { BuildStepEnv } from './BuildStepEnv.js';
6
- export declare class BuildWorkflow {
7
- private readonly ctx;
8
- readonly buildSteps: BuildStep[];
9
- readonly buildFunctions: BuildFunctionById;
10
- constructor(ctx: BuildStepContext, { buildSteps, buildFunctions }: {
11
- buildSteps: BuildStep[];
12
- buildFunctions: BuildFunctionById;
13
- });
14
- executeAsync(env?: BuildStepEnv): Promise<void>;
15
- collectArtifactsAsync(): Promise<BuildArtifacts>;
16
- cleanUpAsync(): Promise<void>;
17
- }
@@ -1,28 +0,0 @@
1
- import { BuildArtifactType } from './BuildArtifacts.js';
2
- import { cleanUpWorkflowTemporaryDirectoriesAsync, findArtifactsByTypeAsync, } from './BuildTemporaryFiles.js';
3
- export class BuildWorkflow {
4
- constructor(ctx, { buildSteps, buildFunctions }) {
5
- this.ctx = ctx;
6
- this.buildSteps = buildSteps;
7
- this.buildFunctions = buildFunctions;
8
- }
9
- async executeAsync(env = process.env) {
10
- for (const step of this.buildSteps) {
11
- await step.executeAsync(env);
12
- }
13
- }
14
- async collectArtifactsAsync() {
15
- const applicationArchives = await findArtifactsByTypeAsync(this.ctx, BuildArtifactType.APPLICATION_ARCHIVE);
16
- const buildArtifacts = await findArtifactsByTypeAsync(this.ctx, BuildArtifactType.BUILD_ARTIFACT);
17
- return {
18
- ...(applicationArchives.length > 0 && {
19
- [BuildArtifactType.APPLICATION_ARCHIVE]: applicationArchives,
20
- }),
21
- ...(buildArtifacts.length > 0 && { [BuildArtifactType.BUILD_ARTIFACT]: buildArtifacts }),
22
- };
23
- }
24
- async cleanUpAsync() {
25
- await cleanUpWorkflowTemporaryDirectoriesAsync(this.ctx);
26
- }
27
- }
28
- //# sourceMappingURL=BuildWorkflow.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKxE,OAAO,EACL,wCAAwC,EACxC,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAElC,MAAM,OAAO,aAAa;IAIxB,YACmB,GAAqB,EACtC,EAAE,UAAU,EAAE,cAAc,EAAkE;QAD7E,QAAG,GAAH,GAAG,CAAkB;QAGtC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,MAAoB,OAAO,CAAC,GAAG;QACvD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YAClC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;SAC9B;IACH,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAChC,MAAM,mBAAmB,GAAG,MAAM,wBAAwB,CACxD,IAAI,CAAC,GAAG,EACR,iBAAiB,CAAC,mBAAmB,CACtC,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,wBAAwB,CACnD,IAAI,CAAC,GAAG,EACR,iBAAiB,CAAC,cAAc,CACjC,CAAC;QACF,OAAO;YACL,GAAG,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,IAAI;gBACpC,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,mBAAmB;aAC7D,CAAC;YACF,GAAG,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,cAAc,EAAE,CAAC;SACzF,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,MAAM,wCAAwC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF","sourcesContent":["import { BuildArtifacts, BuildArtifactType } from './BuildArtifacts.js';\nimport { BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport {\n cleanUpWorkflowTemporaryDirectoriesAsync,\n findArtifactsByTypeAsync,\n} from './BuildTemporaryFiles.js';\n\nexport class BuildWorkflow {\n public readonly buildSteps: BuildStep[];\n public readonly buildFunctions: BuildFunctionById;\n\n constructor(\n private readonly ctx: BuildStepContext,\n { buildSteps, buildFunctions }: { buildSteps: BuildStep[]; buildFunctions: BuildFunctionById }\n ) {\n this.buildSteps = buildSteps;\n this.buildFunctions = buildFunctions;\n }\n\n public async executeAsync(env: BuildStepEnv = process.env): Promise<void> {\n for (const step of this.buildSteps) {\n await step.executeAsync(env);\n }\n }\n\n public async collectArtifactsAsync(): Promise<BuildArtifacts> {\n const applicationArchives = await findArtifactsByTypeAsync(\n this.ctx,\n BuildArtifactType.APPLICATION_ARCHIVE\n );\n const buildArtifacts = await findArtifactsByTypeAsync(\n this.ctx,\n BuildArtifactType.BUILD_ARTIFACT\n );\n return {\n ...(applicationArchives.length > 0 && {\n [BuildArtifactType.APPLICATION_ARCHIVE]: applicationArchives,\n }),\n ...(buildArtifacts.length > 0 && { [BuildArtifactType.BUILD_ARTIFACT]: buildArtifacts }),\n };\n }\n\n public async cleanUpAsync(): Promise<void> {\n await cleanUpWorkflowTemporaryDirectoriesAsync(this.ctx);\n }\n}\n"]}
@@ -1,8 +0,0 @@
1
- import { BuildWorkflow } from './BuildWorkflow.js';
2
- export declare class BuildWorkflowValidator {
3
- private readonly workflow;
4
- constructor(workflow: BuildWorkflow);
5
- validate(): void;
6
- private validateUniqueStepIds;
7
- private validateInputs;
8
- }
@@ -1,72 +0,0 @@
1
- import { BuildConfigError } from './errors/BuildConfigError.js';
2
- import { BuildWorkflowError } from './errors/BuildWorkflowError.js';
3
- import { findOutputPaths } from './utils/template.js';
4
- export class BuildWorkflowValidator {
5
- constructor(workflow) {
6
- this.workflow = workflow;
7
- }
8
- validate() {
9
- const errors = [];
10
- errors.push(...this.validateUniqueStepIds());
11
- errors.push(...this.validateInputs());
12
- if (errors.length !== 0) {
13
- throw new BuildWorkflowError('Build workflow is invalid', errors);
14
- }
15
- }
16
- validateUniqueStepIds() {
17
- const stepIds = this.workflow.buildSteps.map(({ id }) => id);
18
- const visitedStepIdsSet = new Set();
19
- const duplicatedStepIdsSet = new Set();
20
- for (const stepId of stepIds) {
21
- if (visitedStepIdsSet.has(stepId)) {
22
- duplicatedStepIdsSet.add(stepId);
23
- }
24
- else {
25
- visitedStepIdsSet.add(stepId);
26
- }
27
- }
28
- const duplicatedStepIds = [...duplicatedStepIdsSet];
29
- if (duplicatedStepIds.length === 0) {
30
- return [];
31
- }
32
- else {
33
- const error = new BuildConfigError(`Duplicated step IDs: ${duplicatedStepIds.map((i) => `"${i}"`).join(', ')}`);
34
- return [error];
35
- }
36
- }
37
- validateInputs() {
38
- var _a;
39
- const errors = [];
40
- const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));
41
- const stepByStepId = {};
42
- for (const step of this.workflow.buildSteps) {
43
- for (const input of (_a = step.inputs) !== null && _a !== void 0 ? _a : []) {
44
- if (input.defaultValue === undefined) {
45
- continue;
46
- }
47
- const paths = findOutputPaths(input.defaultValue);
48
- for (const { stepId, outputId } of paths) {
49
- if (!(stepId in stepByStepId)) {
50
- if (allStepIds.has(stepId)) {
51
- const error = new BuildConfigError(`Input parameter "${input.id}" for step "${step.id}" uses an expression that references an output parameter from the future step "${stepId}".`);
52
- errors.push(error);
53
- }
54
- else {
55
- const error = new BuildConfigError(`Input parameter "${input.id}" for step "${step.id}" uses an expression that references an output parameter from a non-existent step "${stepId}".`);
56
- errors.push(error);
57
- }
58
- }
59
- else {
60
- if (!stepByStepId[stepId].hasOutputParameter(outputId)) {
61
- const error = new BuildConfigError(`Input parameter "${input.id}" for step "${step.id}" uses an expression that references an undefined output parameter "${outputId}" from step "${stepId}".`);
62
- errors.push(error);
63
- }
64
- }
65
- }
66
- }
67
- stepByStepId[step.id] = step;
68
- }
69
- return errors;
70
- }
71
- }
72
- //# sourceMappingURL=BuildWorkflowValidator.js.map