@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,10 +0,0 @@
1
- import { BuildWorkflow } from './BuildWorkflow.js';
2
- export declare class BuildWorkflowValidator {
3
- private readonly workflow;
4
- constructor(workflow: BuildWorkflow);
5
- validateAsync(): Promise<void>;
6
- private validateUniqueStepIds;
7
- private validateInputs;
8
- private validateAllowedPlatforms;
9
- private validateCustomFunctionModulesAsync;
10
- }
@@ -1,121 +0,0 @@
1
- import path from 'path';
2
- import fs from 'fs-extra';
3
- import { BuildStepInputValueTypeName } from './BuildStepInput.js';
4
- import { BuildConfigError, BuildWorkflowError } from './errors.js';
5
- import { duplicates } from './utils/expodash/duplicates.js';
6
- import { nullthrows } from './utils/nullthrows.js';
7
- import { findOutputPaths } from './utils/template.js';
8
- export class BuildWorkflowValidator {
9
- constructor(workflow) {
10
- this.workflow = workflow;
11
- }
12
- async validateAsync() {
13
- const errors = [];
14
- errors.push(...this.validateUniqueStepIds());
15
- errors.push(...this.validateInputs());
16
- errors.push(...this.validateAllowedPlatforms());
17
- errors.push(...(await this.validateCustomFunctionModulesAsync()));
18
- if (errors.length !== 0) {
19
- throw new BuildWorkflowError('Build workflow is invalid.', errors);
20
- }
21
- }
22
- validateUniqueStepIds() {
23
- const stepIds = this.workflow.buildSteps.map(({ id }) => id);
24
- const duplicatedStepIds = duplicates(stepIds);
25
- if (duplicatedStepIds.length === 0) {
26
- return [];
27
- }
28
- else {
29
- const error = new BuildConfigError(`Duplicated step IDs: ${duplicatedStepIds.map((i) => `"${i}"`).join(', ')}`);
30
- return [error];
31
- }
32
- }
33
- validateInputs() {
34
- var _a;
35
- const errors = [];
36
- const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));
37
- const visitedStepByStepId = {};
38
- for (const currentStep of this.workflow.buildSteps) {
39
- for (const currentStepInput of (_a = currentStep.inputs) !== null && _a !== void 0 ? _a : []) {
40
- if (currentStepInput.required && currentStepInput.rawValue === undefined) {
41
- const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is required but it was not set.`);
42
- errors.push(error);
43
- }
44
- const currentType = typeof currentStepInput.rawValue === 'object'
45
- ? BuildStepInputValueTypeName.JSON
46
- : typeof currentStepInput.rawValue;
47
- if (currentStepInput.rawValue !== undefined &&
48
- !currentStepInput.isRawValueStepOrContextReference() &&
49
- currentType !== currentStepInput.allowedValueTypeName) {
50
- const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${typeof currentStepInput.rawValue === 'object'
51
- ? JSON.stringify(currentStepInput.rawValue)
52
- : currentStepInput.rawValue}" which is not of type "${currentStepInput.allowedValueTypeName}" or is not step or context reference.`);
53
- errors.push(error);
54
- }
55
- if (currentStepInput.defaultValue === undefined) {
56
- continue;
57
- }
58
- if (!currentStepInput.isRawValueOneOfAllowedValues()) {
59
- const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${currentStepInput.rawValue}" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)
60
- .map((i) => `"${i}"`)
61
- .join(', ')}.`);
62
- errors.push(error);
63
- }
64
- const paths = typeof currentStepInput.defaultValue === 'string'
65
- ? findOutputPaths(currentStepInput.defaultValue)
66
- : [];
67
- for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {
68
- if (!(referencedStepId in visitedStepByStepId)) {
69
- if (allStepIds.has(referencedStepId)) {
70
- const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an output parameter from the future step "${referencedStepId}".`);
71
- errors.push(error);
72
- }
73
- else {
74
- const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an output parameter from a non-existent step "${referencedStepId}".`);
75
- errors.push(error);
76
- }
77
- }
78
- else {
79
- if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {
80
- const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" uses an expression that references an undefined output parameter "${referencedStepOutputId}" from step "${referencedStepId}".`);
81
- errors.push(error);
82
- }
83
- }
84
- }
85
- }
86
- visitedStepByStepId[currentStep.id] = currentStep;
87
- }
88
- return errors;
89
- }
90
- validateAllowedPlatforms() {
91
- const errors = [];
92
- for (const step of this.workflow.buildSteps) {
93
- if (!step.canBeRunOnRuntimePlatform()) {
94
- const error = new BuildConfigError(`Step "${step.displayName}" is not allowed on platform "${step.ctx.global.runtimePlatform}". Allowed platforms for this step are: ${nullthrows(step.supportedRuntimePlatforms, `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`)
95
- .map((p) => `"${p}"`)
96
- .join(', ')}.`);
97
- errors.push(error);
98
- }
99
- }
100
- return errors;
101
- }
102
- async validateCustomFunctionModulesAsync() {
103
- const errors = [];
104
- for (const buildFunction of Object.values(this.workflow.buildFunctions)) {
105
- if (!buildFunction.customFunctionModulePath) {
106
- continue;
107
- }
108
- if (!(await fs.exists(buildFunction.customFunctionModulePath))) {
109
- const error = new BuildConfigError(`Custom function module path "${buildFunction.customFunctionModulePath}" for function "${buildFunction.id}" does not exist.`);
110
- errors.push(error);
111
- continue;
112
- }
113
- if (!(await fs.exists(path.join(buildFunction.customFunctionModulePath, 'package.json')))) {
114
- const error = new BuildConfigError(`Custom function module path "${buildFunction.customFunctionModulePath}" for function "${buildFunction.id}" does not contain a package.json file.`);
115
- errors.push(error);
116
- }
117
- }
118
- return errors;
119
- }
120
- }
121
- //# sourceMappingURL=BuildWorkflowValidator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,UAAU,CAAC;AAG1B,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,sBAAsB;IACjC,YAA6B,QAAuB;QAAvB,aAAQ,GAAR,QAAQ,CAAe;IAAG,CAAC;IAEjD,KAAK,CAAC,aAAa;QACxB,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,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,CAAC,CAAC;gBACnB,SAAS;YACX,CAAC;YAED,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1F,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,gCAAgC,aAAa,CAAC,wBAAwB,mBAAmB,aAAa,CAAC,EAAE,yCAAyC,CACnJ,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import path from 'path';\n\nimport fs from 'fs-extra';\n\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepInputValueTypeName } from './BuildStepInput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { nullthrows } from './utils/nullthrows.js';\nimport { findOutputPaths } from './utils/template.js';\n\nexport class BuildWorkflowValidator {\n constructor(private readonly workflow: BuildWorkflow) {}\n\n public async validateAsync(): Promise<void> {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n errors.push(...this.validateAllowedPlatforms());\n errors.push(...(await this.validateCustomFunctionModulesAsync()));\n if (errors.length !== 0) {\n throw new BuildWorkflowError('Build workflow is invalid.', errors);\n }\n }\n\n private validateUniqueStepIds(): BuildConfigError[] {\n const stepIds = this.workflow.buildSteps.map(({ id }) => id);\n const duplicatedStepIds = duplicates(stepIds);\n if (duplicatedStepIds.length === 0) {\n return [];\n } else {\n const error = new BuildConfigError(\n `Duplicated step IDs: ${duplicatedStepIds.map((i) => `\"${i}\"`).join(', ')}`\n );\n return [error];\n }\n }\n\n private validateInputs(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n\n const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));\n const visitedStepByStepId: Record<string, BuildStep> = {};\n for (const currentStep of this.workflow.buildSteps) {\n for (const currentStepInput of currentStep.inputs ?? []) {\n if (currentStepInput.required && currentStepInput.rawValue === undefined) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is required but it was not set.`\n );\n errors.push(error);\n }\n\n const currentType =\n typeof currentStepInput.rawValue === 'object'\n ? BuildStepInputValueTypeName.JSON\n : typeof currentStepInput.rawValue;\n if (\n currentStepInput.rawValue !== undefined &&\n !currentStepInput.isRawValueStepOrContextReference() &&\n currentType !== currentStepInput.allowedValueTypeName\n ) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n typeof currentStepInput.rawValue === 'object'\n ? JSON.stringify(currentStepInput.rawValue)\n : currentStepInput.rawValue\n }\" which is not of type \"${\n currentStepInput.allowedValueTypeName\n }\" or is not step or context reference.`\n );\n errors.push(error);\n }\n\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n if (!currentStepInput.isRawValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${currentStepInput.rawValue}\" which is not one of the allowed values: ${nullthrows(\n currentStepInput.allowedValues\n )\n .map((i) => `\"${i}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n const paths =\n typeof currentStepInput.defaultValue === 'string'\n ? findOutputPaths(currentStepInput.defaultValue)\n : [];\n for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {\n if (!(referencedStepId in visitedStepByStepId)) {\n if (allStepIds.has(referencedStepId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from the future step \"${referencedStepId}\".`\n );\n errors.push(error);\n } else {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from a non-existent step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n } else {\n if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an undefined output parameter \"${referencedStepOutputId}\" from step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n }\n }\n }\n visitedStepByStepId[currentStep.id] = currentStep;\n }\n\n return errors;\n }\n\n private validateAllowedPlatforms(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n for (const step of this.workflow.buildSteps) {\n if (!step.canBeRunOnRuntimePlatform()) {\n const error = new BuildConfigError(\n `Step \"${step.displayName}\" is not allowed on platform \"${\n step.ctx.global.runtimePlatform\n }\". Allowed platforms for this step are: ${nullthrows(\n step.supportedRuntimePlatforms,\n `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`\n )\n .map((p) => `\"${p}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n\n private async validateCustomFunctionModulesAsync(): Promise<BuildConfigError[]> {\n const errors: BuildConfigError[] = [];\n for (const buildFunction of Object.values(this.workflow.buildFunctions)) {\n if (!buildFunction.customFunctionModulePath) {\n continue;\n }\n\n if (!(await fs.exists(buildFunction.customFunctionModulePath))) {\n const error = new BuildConfigError(\n `Custom function module path \"${buildFunction.customFunctionModulePath}\" for function \"${buildFunction.id}\" does not exist.`\n );\n errors.push(error);\n continue;\n }\n\n if (!(await fs.exists(path.join(buildFunction.customFunctionModulePath, 'package.json')))) {\n const error = new BuildConfigError(\n `Custom function module path \"${buildFunction.customFunctionModulePath}\" for function \"${buildFunction.id}\" does not contain a package.json file.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n}\n"]}
@@ -1,24 +0,0 @@
1
- import { Step } from '@expo/eas-build-job';
2
- import { BuildFunction, BuildFunctionById } from './BuildFunction.js';
3
- import { BuildFunctionGroup } from './BuildFunctionGroup.js';
4
- import { BuildStepGlobalContext } from './BuildStepContext.js';
5
- import { BuildStep } from './BuildStep.js';
6
- import { AbstractConfigParser } from './AbstractConfigParser.js';
7
- export declare class StepsConfigParser extends AbstractConfigParser {
8
- private readonly steps;
9
- constructor(ctx: BuildStepGlobalContext, { steps, externalFunctions, externalFunctionGroups, }: {
10
- steps: Step[];
11
- externalFunctions?: BuildFunction[];
12
- externalFunctionGroups?: BuildFunctionGroup[];
13
- });
14
- protected parseConfigToBuildStepsAndBuildFunctionByIdMappingAsync(): Promise<{
15
- buildSteps: BuildStep[];
16
- buildFunctionById: BuildFunctionById;
17
- }>;
18
- private createBuildFunctionByIdMappingForExternalFunctions;
19
- private createBuildStepsFromStepConfig;
20
- private createBuildStepFromShellStepConfig;
21
- private createBuildStepsFromFunctionStepConfig;
22
- private createBuildStepOutputsFromDefinition;
23
- private static validateAllFunctionsExist;
24
- }
@@ -1,132 +0,0 @@
1
- import assert from 'node:assert';
2
- import { isStepFunctionStep, isStepShellStep, validateSteps, } from '@expo/eas-build-job';
3
- import { createBuildFunctionGroupByIdMapping, } from './BuildFunctionGroup.js';
4
- import { BuildStep } from './BuildStep.js';
5
- import { AbstractConfigParser } from './AbstractConfigParser.js';
6
- import { BuildConfigError } from './errors.js';
7
- import { BuildStepOutput } from './BuildStepOutput.js';
8
- export class StepsConfigParser extends AbstractConfigParser {
9
- constructor(ctx, { steps, externalFunctions, externalFunctionGroups, }) {
10
- super(ctx, {
11
- externalFunctions,
12
- externalFunctionGroups,
13
- });
14
- this.steps = steps;
15
- }
16
- async parseConfigToBuildStepsAndBuildFunctionByIdMappingAsync() {
17
- var _a;
18
- const validatedSteps = validateSteps(this.steps);
19
- StepsConfigParser.validateAllFunctionsExist(validatedSteps, {
20
- externalFunctionIds: this.getExternalFunctionFullIds(),
21
- externalFunctionGroupIds: this.getExternalFunctionGroupFullIds(),
22
- });
23
- const buildFunctionById = this.createBuildFunctionByIdMappingForExternalFunctions();
24
- const buildFunctionGroupById = createBuildFunctionGroupByIdMapping((_a = this.externalFunctionGroups) !== null && _a !== void 0 ? _a : []);
25
- const buildSteps = [];
26
- for (const stepConfig of validatedSteps) {
27
- buildSteps.push(...this.createBuildStepsFromStepConfig(stepConfig, {
28
- buildFunctionById,
29
- buildFunctionGroupById,
30
- }));
31
- }
32
- return {
33
- buildSteps,
34
- buildFunctionById,
35
- };
36
- }
37
- createBuildFunctionByIdMappingForExternalFunctions() {
38
- const result = {};
39
- if (this.externalFunctions === undefined) {
40
- return result;
41
- }
42
- for (const buildFunction of this.externalFunctions) {
43
- const fullId = buildFunction.getFullId();
44
- result[fullId] = buildFunction;
45
- }
46
- return result;
47
- }
48
- createBuildStepsFromStepConfig(stepConfig, { buildFunctionById, buildFunctionGroupById, }) {
49
- if (isStepShellStep(stepConfig)) {
50
- return [this.createBuildStepFromShellStepConfig(stepConfig)];
51
- }
52
- else if (isStepFunctionStep(stepConfig)) {
53
- return this.createBuildStepsFromFunctionStepConfig(stepConfig, {
54
- buildFunctionById,
55
- buildFunctionGroupById,
56
- });
57
- }
58
- else {
59
- throw new BuildConfigError('Invalid job step configuration detected. Step must be shell or function step');
60
- }
61
- }
62
- createBuildStepFromShellStepConfig(step) {
63
- const id = BuildStep.getNewId(step.id);
64
- const displayName = BuildStep.getDisplayName({ id, name: step.name, command: step.run });
65
- const outputs = step.outputs && this.createBuildStepOutputsFromDefinition(step.outputs, displayName);
66
- return new BuildStep(this.ctx, {
67
- id,
68
- outputs,
69
- name: step.name,
70
- displayName,
71
- workingDirectory: step.working_directory,
72
- shell: step.shell,
73
- command: step.run,
74
- env: step.env,
75
- ifCondition: step.if,
76
- });
77
- }
78
- createBuildStepsFromFunctionStepConfig(step, { buildFunctionById, buildFunctionGroupById, }) {
79
- const functionId = step.uses;
80
- const maybeFunctionGroup = buildFunctionGroupById[functionId];
81
- if (maybeFunctionGroup) {
82
- // TODO: allow to set id, name, working_directory, shell, env and if for function groups
83
- return maybeFunctionGroup.createBuildStepsFromFunctionGroupCall(this.ctx, {
84
- callInputs: step.with,
85
- });
86
- }
87
- const buildFunction = buildFunctionById[functionId];
88
- assert(buildFunction, 'function ID must be ID of function or function group');
89
- return [
90
- buildFunction.createBuildStepFromFunctionCall(this.ctx, {
91
- id: step.id,
92
- name: step.name,
93
- callInputs: step.with,
94
- workingDirectory: step.working_directory,
95
- shell: step.shell,
96
- env: step.env,
97
- ifCondition: step.if,
98
- }),
99
- ];
100
- }
101
- createBuildStepOutputsFromDefinition(stepOutputs, stepDisplayName) {
102
- return stepOutputs.map((entry) => {
103
- var _a;
104
- return new BuildStepOutput(this.ctx, {
105
- id: entry.name,
106
- stepDisplayName,
107
- required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
108
- });
109
- });
110
- }
111
- static validateAllFunctionsExist(steps, { externalFunctionIds, externalFunctionGroupIds, }) {
112
- const calledFunctionsOrFunctionGroupsSet = new Set();
113
- for (const step of steps) {
114
- if (step.uses) {
115
- calledFunctionsOrFunctionGroupsSet.add(step.uses);
116
- }
117
- }
118
- const calledFunctionsOrFunctionGroup = Array.from(calledFunctionsOrFunctionGroupsSet);
119
- const externalFunctionIdsSet = new Set(externalFunctionIds);
120
- const externalFunctionGroupsIdsSet = new Set(externalFunctionGroupIds);
121
- const nonExistentFunctionsOrFunctionGroups = calledFunctionsOrFunctionGroup.filter((calledFunctionOrFunctionGroup) => {
122
- return (!externalFunctionIdsSet.has(calledFunctionOrFunctionGroup) &&
123
- !externalFunctionGroupsIdsSet.has(calledFunctionOrFunctionGroup));
124
- });
125
- if (nonExistentFunctionsOrFunctionGroups.length > 0) {
126
- throw new BuildConfigError(`Calling non-existent functions: ${nonExistentFunctionsOrFunctionGroups
127
- .map((f) => `"${f}"`)
128
- .join(', ')}.`);
129
- }
130
- }
131
- }
132
- //# sourceMappingURL=StepsConfigParser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StepsConfigParser.js","sourceRoot":"","sources":["../src/StepsConfigParser.ts"],"names":[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B,CAAC;QACJ,CAAC;IACH,CAAC;CACF","sourcesContent":["import assert from 'node:assert';\n\nimport {\n FunctionStep,\n isStepFunctionStep,\n isStepShellStep,\n ShellStep,\n Step,\n validateSteps,\n} from '@expo/eas-build-job';\n\nimport { BuildFunction, BuildFunctionById } from './BuildFunction.js';\nimport {\n BuildFunctionGroup,\n BuildFunctionGroupById,\n createBuildFunctionGroupByIdMapping,\n} from './BuildFunctionGroup.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStep } from './BuildStep.js';\nimport { AbstractConfigParser } from './AbstractConfigParser.js';\nimport { BuildConfigError } from './errors.js';\nimport { BuildStepOutput } from './BuildStepOutput.js';\n\nexport class StepsConfigParser extends AbstractConfigParser {\n private readonly steps: Step[];\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n steps,\n externalFunctions,\n externalFunctionGroups,\n }: {\n steps: Step[];\n externalFunctions?: BuildFunction[];\n externalFunctionGroups?: BuildFunctionGroup[];\n }\n ) {\n super(ctx, {\n externalFunctions,\n externalFunctionGroups,\n });\n\n this.steps = steps;\n }\n\n protected async parseConfigToBuildStepsAndBuildFunctionByIdMappingAsync(): Promise<{\n buildSteps: BuildStep[];\n buildFunctionById: BuildFunctionById;\n }> {\n const validatedSteps = validateSteps(this.steps);\n StepsConfigParser.validateAllFunctionsExist(validatedSteps, {\n externalFunctionIds: this.getExternalFunctionFullIds(),\n externalFunctionGroupIds: this.getExternalFunctionGroupFullIds(),\n });\n\n const buildFunctionById = this.createBuildFunctionByIdMappingForExternalFunctions();\n const buildFunctionGroupById = createBuildFunctionGroupByIdMapping(\n this.externalFunctionGroups ?? []\n );\n\n const buildSteps: BuildStep[] = [];\n for (const stepConfig of validatedSteps) {\n buildSteps.push(\n ...this.createBuildStepsFromStepConfig(stepConfig, {\n buildFunctionById,\n buildFunctionGroupById,\n })\n );\n }\n\n return {\n buildSteps,\n buildFunctionById,\n };\n }\n\n private createBuildFunctionByIdMappingForExternalFunctions(): BuildFunctionById {\n const result: BuildFunctionById = {};\n\n if (this.externalFunctions === undefined) {\n return result;\n }\n\n for (const buildFunction of this.externalFunctions) {\n const fullId = buildFunction.getFullId();\n result[fullId] = buildFunction;\n }\n return result;\n }\n\n private createBuildStepsFromStepConfig(\n stepConfig: Step,\n {\n buildFunctionById,\n buildFunctionGroupById,\n }: {\n buildFunctionById: BuildFunctionById;\n buildFunctionGroupById: BuildFunctionGroupById;\n }\n ): BuildStep[] {\n if (isStepShellStep(stepConfig)) {\n return [this.createBuildStepFromShellStepConfig(stepConfig)];\n } else if (isStepFunctionStep(stepConfig)) {\n return this.createBuildStepsFromFunctionStepConfig(stepConfig, {\n buildFunctionById,\n buildFunctionGroupById,\n });\n } else {\n throw new BuildConfigError(\n 'Invalid job step configuration detected. Step must be shell or function step'\n );\n }\n }\n\n private createBuildStepFromShellStepConfig(step: ShellStep): BuildStep {\n const id = BuildStep.getNewId(step.id);\n const displayName = BuildStep.getDisplayName({ id, name: step.name, command: step.run });\n const outputs =\n step.outputs && this.createBuildStepOutputsFromDefinition(step.outputs, displayName);\n return new BuildStep(this.ctx, {\n id,\n outputs,\n name: step.name,\n displayName,\n workingDirectory: step.working_directory,\n shell: step.shell,\n command: step.run,\n env: step.env,\n ifCondition: step.if,\n });\n }\n\n private createBuildStepsFromFunctionStepConfig(\n step: FunctionStep,\n {\n buildFunctionById,\n buildFunctionGroupById,\n }: {\n buildFunctionById: BuildFunctionById;\n buildFunctionGroupById: BuildFunctionGroupById;\n }\n ): BuildStep[] {\n const functionId = step.uses;\n const maybeFunctionGroup = buildFunctionGroupById[functionId];\n if (maybeFunctionGroup) {\n // TODO: allow to set id, name, working_directory, shell, env and if for function groups\n return maybeFunctionGroup.createBuildStepsFromFunctionGroupCall(this.ctx, {\n callInputs: step.with,\n });\n }\n\n const buildFunction = buildFunctionById[functionId];\n assert(buildFunction, 'function ID must be ID of function or function group');\n\n return [\n buildFunction.createBuildStepFromFunctionCall(this.ctx, {\n id: step.id,\n name: step.name,\n callInputs: step.with,\n workingDirectory: step.working_directory,\n shell: step.shell,\n env: step.env,\n ifCondition: step.if,\n }),\n ];\n }\n\n private createBuildStepOutputsFromDefinition(\n stepOutputs: Required<ShellStep>['outputs'],\n stepDisplayName: string\n ): BuildStepOutput[] {\n return stepOutputs.map(\n (entry) =>\n new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepDisplayName,\n required: entry.required ?? true,\n })\n );\n }\n\n private static validateAllFunctionsExist(\n steps: Step[],\n {\n externalFunctionIds,\n externalFunctionGroupIds,\n }: {\n externalFunctionIds: string[];\n externalFunctionGroupIds: string[];\n }\n ): void {\n const calledFunctionsOrFunctionGroupsSet = new Set<string>();\n for (const step of steps) {\n if (step.uses) {\n calledFunctionsOrFunctionGroupsSet.add(step.uses);\n }\n }\n const calledFunctionsOrFunctionGroup = Array.from(calledFunctionsOrFunctionGroupsSet);\n const externalFunctionIdsSet = new Set(externalFunctionIds);\n const externalFunctionGroupsIdsSet = new Set(externalFunctionGroupIds);\n const nonExistentFunctionsOrFunctionGroups = calledFunctionsOrFunctionGroup.filter(\n (calledFunctionOrFunctionGroup) => {\n return (\n !externalFunctionIdsSet.has(calledFunctionOrFunctionGroup) &&\n !externalFunctionGroupsIdsSet.has(calledFunctionOrFunctionGroup)\n );\n }\n );\n if (nonExistentFunctionsOrFunctionGroups.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctionsOrFunctionGroups\n .map((f) => `\"${f}\"`)\n .join(', ')}.`\n );\n }\n }\n}\n"]}
@@ -1,61 +0,0 @@
1
- var _a;
2
- import path from 'path';
3
- import { createLogger } from '@expo/logger';
4
- import { BuildConfigParser } from '../BuildConfigParser.js';
5
- import { BuildStepGlobalContext } from '../BuildStepContext.js';
6
- import { BuildWorkflowError } from '../errors.js';
7
- const logger = createLogger({
8
- name: 'steps-cli',
9
- level: 'info',
10
- });
11
- export class CliContextProvider {
12
- constructor(logger, runtimePlatform, projectSourceDirectory, projectTargetDirectory, defaultWorkingDirectory, buildLogsDirectory) {
13
- this.logger = logger;
14
- this.runtimePlatform = runtimePlatform;
15
- this.projectSourceDirectory = projectSourceDirectory;
16
- this.projectTargetDirectory = projectTargetDirectory;
17
- this.defaultWorkingDirectory = defaultWorkingDirectory;
18
- this.buildLogsDirectory = buildLogsDirectory;
19
- this._env = {};
20
- }
21
- get env() {
22
- return this._env;
23
- }
24
- staticContext() {
25
- return {
26
- job: {},
27
- metadata: {},
28
- expoApiServerURL: 'http://api.expo.test',
29
- };
30
- }
31
- updateEnv(env) {
32
- this._env = env;
33
- }
34
- }
35
- async function runAsync(configPath, relativeProjectDirectory, runtimePlatform) {
36
- const ctx = new BuildStepGlobalContext(new CliContextProvider(logger, runtimePlatform, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory), false);
37
- const parser = new BuildConfigParser(ctx, {
38
- configPath,
39
- });
40
- const workflow = await parser.parseAsync();
41
- await workflow.executeAsync();
42
- }
43
- const relativeConfigPath = process.argv[2];
44
- const relativeProjectDirectoryPath = process.argv[3];
45
- const platform = ((_a = process.argv[4]) !== null && _a !== void 0 ? _a : process.platform);
46
- if (!relativeConfigPath || !relativeProjectDirectoryPath) {
47
- console.error('Usage: yarn cli config.yml path/to/project/directory [darwin|linux]');
48
- process.exit(1);
49
- }
50
- const configPath = path.resolve(process.cwd(), relativeConfigPath);
51
- const workingDirectory = path.resolve(process.cwd(), relativeProjectDirectoryPath);
52
- runAsync(configPath, workingDirectory, platform).catch((err) => {
53
- logger.error({ err }, 'Build failed');
54
- if (err instanceof BuildWorkflowError) {
55
- logger.error('Failed to parse the custom build config file.');
56
- for (const detailedErr of err.errors) {
57
- logger.error({ err: detailedErr });
58
- }
59
- }
60
- });
61
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,E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import path from 'path';\n\nimport { Job, Metadata, StaticJobInterpolationContext } from '@expo/eas-build-job';\nimport { bunyan, createLogger } from '@expo/logger';\n\nimport { BuildConfigParser } from '../BuildConfigParser.js';\nimport { ExternalBuildContextProvider, BuildStepGlobalContext } from '../BuildStepContext.js';\nimport { BuildWorkflowError } from '../errors.js';\nimport { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';\nimport { BuildStepEnv } from '../BuildStepEnv.js';\n\nconst logger = createLogger({\n name: 'steps-cli',\n level: 'info',\n});\n\nexport class CliContextProvider implements ExternalBuildContextProvider {\n private _env: BuildStepEnv = {};\n\n constructor(\n public readonly logger: bunyan,\n public readonly runtimePlatform: BuildRuntimePlatform,\n public readonly projectSourceDirectory: string,\n public readonly projectTargetDirectory: string,\n public readonly defaultWorkingDirectory: string,\n public readonly buildLogsDirectory: string\n ) {}\n public get env(): BuildStepEnv {\n return this._env;\n }\n public staticContext(): Omit<StaticJobInterpolationContext, 'steps'> {\n return {\n job: {} as Job,\n metadata: {} as Metadata,\n expoApiServerURL: 'http://api.expo.test',\n };\n }\n public updateEnv(env: BuildStepEnv): void {\n this._env = env;\n }\n}\n\nasync function runAsync(\n configPath: string,\n relativeProjectDirectory: string,\n runtimePlatform: BuildRuntimePlatform\n): Promise<void> {\n const ctx = new BuildStepGlobalContext(\n new CliContextProvider(\n logger,\n runtimePlatform,\n relativeProjectDirectory,\n relativeProjectDirectory,\n relativeProjectDirectory,\n relativeProjectDirectory\n ),\n false\n );\n const parser = new BuildConfigParser(ctx, {\n configPath,\n });\n const workflow = await parser.parseAsync();\n await workflow.executeAsync();\n}\n\nconst relativeConfigPath = process.argv[2];\nconst relativeProjectDirectoryPath = process.argv[3];\nconst platform: BuildRuntimePlatform = (process.argv[4] ??\n process.platform) as BuildRuntimePlatform;\n\nif (!relativeConfigPath || !relativeProjectDirectoryPath) {\n console.error('Usage: yarn cli config.yml path/to/project/directory [darwin|linux]');\n process.exit(1);\n}\n\nconst configPath = path.resolve(process.cwd(), relativeConfigPath);\nconst workingDirectory = path.resolve(process.cwd(), relativeProjectDirectoryPath);\n\nrunAsync(configPath, workingDirectory, platform).catch((err) => {\n logger.error({ err }, 'Build failed');\n if (err instanceof BuildWorkflowError) {\n logger.error('Failed to parse the custom build config file.');\n for (const detailedErr of err.errors) {\n logger.error({ err: detailedErr });\n }\n }\n});\n"]}
@@ -1,24 +0,0 @@
1
- declare abstract class UserError extends Error {
2
- readonly message: string;
3
- readonly cause?: Error;
4
- readonly metadata: object;
5
- constructor(message: string, extra?: {
6
- metadata?: object;
7
- cause?: Error;
8
- });
9
- }
10
- export declare class BuildConfigError extends UserError {
11
- }
12
- export { YAMLParseError as BuildConfigYAMLError } from 'yaml';
13
- export declare class BuildInternalError extends Error {
14
- }
15
- export declare class BuildStepRuntimeError extends UserError {
16
- }
17
- export declare class BuildWorkflowError extends UserError {
18
- readonly message: string;
19
- readonly errors: BuildConfigError[];
20
- constructor(message: string, errors: BuildConfigError[], extra?: {
21
- metadata?: object;
22
- cause?: Error;
23
- });
24
- }
@@ -1,24 +0,0 @@
1
- class UserError extends Error {
2
- constructor(message, extra) {
3
- var _a;
4
- super(message);
5
- this.message = message;
6
- this.metadata = (_a = extra === null || extra === void 0 ? void 0 : extra.cause) !== null && _a !== void 0 ? _a : {};
7
- this.cause = extra === null || extra === void 0 ? void 0 : extra.cause;
8
- }
9
- }
10
- export class BuildConfigError extends UserError {
11
- }
12
- export { YAMLParseError as BuildConfigYAMLError } from 'yaml';
13
- export class BuildInternalError extends Error {
14
- }
15
- export class BuildStepRuntimeError extends UserError {
16
- }
17
- export class BuildWorkflowError extends UserError {
18
- constructor(message, errors, extra) {
19
- super(message, extra);
20
- this.message = message;
21
- this.errors = errors;
22
- }
23
- }
24
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAe,SAAU,SAAQ,KAAK;IAIpC,YAC2B,OAAe,EACxC,KAGC;;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QANU,YAAO,GAAP,OAAO,CAAQ;QAOxC,IAAI,CAAC,QAAQ,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,mCAAI,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,SAAS;CAAG;AAElD,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAE9D,MAAM,OAAO,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,MAAM,OAAO,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,MAAM,OAAO,kBAAmB,SAAQ,SAAS;IAC/C,YAC2B,OAAe,EACxB,MAA0B,EAC1C,KAGC;QAED,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAPG,YAAO,GAAP,OAAO,CAAQ;QACxB,WAAM,GAAN,MAAM,CAAoB;IAO5C,CAAC;CACF","sourcesContent":["abstract class UserError extends Error {\n public readonly cause?: Error;\n public readonly metadata: object;\n\n constructor(\n public override readonly message: string,\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message);\n this.metadata = extra?.cause ?? {};\n this.cause = extra?.cause;\n }\n}\n\nexport class BuildConfigError extends UserError {}\n\nexport { YAMLParseError as BuildConfigYAMLError } from 'yaml';\n\nexport class BuildInternalError extends Error {}\n\nexport class BuildStepRuntimeError extends UserError {}\n\nexport class BuildWorkflowError extends UserError {\n constructor(\n public override readonly message: string,\n public readonly errors: BuildConfigError[],\n extra?: {\n metadata?: object;\n cause?: Error;\n }\n ) {\n super(message, extra);\n }\n}\n"]}
@@ -1,18 +0,0 @@
1
- export { BuildStepContext } from './BuildStepContext.js';
2
- export { readAndValidateBuildConfigFromPathAsync } from './BuildConfig.js';
3
- export { BuildConfigParser } from './BuildConfigParser.js';
4
- export { StepsConfigParser } from './StepsConfigParser.js';
5
- export { BuildFunction } from './BuildFunction.js';
6
- export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
7
- export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
8
- export { BuildStepOutput } from './BuildStepOutput.js';
9
- export { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';
10
- export { BuildWorkflow } from './BuildWorkflow.js';
11
- export { BuildStepEnv } from './BuildStepEnv.js';
12
- export { BuildFunctionGroup } from './BuildFunctionGroup.js';
13
- export { BuildStep } from './BuildStep.js';
14
- export * as errors from './errors.js';
15
- export * from './interpolation.js';
16
- export * from './utils/shell/spawn.js';
17
- export * from './utils/jsepEval.js';
18
- export * from './utils/hashFiles.js';
package/dist_esm/index.js DELETED
@@ -1,18 +0,0 @@
1
- export { BuildStepContext } from './BuildStepContext.js';
2
- export { readAndValidateBuildConfigFromPathAsync } from './BuildConfig.js';
3
- export { BuildConfigParser } from './BuildConfigParser.js';
4
- export { StepsConfigParser } from './StepsConfigParser.js';
5
- export { BuildFunction } from './BuildFunction.js';
6
- export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
7
- export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
8
- export { BuildStepOutput } from './BuildStepOutput.js';
9
- export { BuildStepGlobalContext } from './BuildStepContext.js';
10
- export { BuildWorkflow } from './BuildWorkflow.js';
11
- export { BuildFunctionGroup } from './BuildFunctionGroup.js';
12
- export { BuildStep } from './BuildStep.js';
13
- export * as errors from './errors.js';
14
- export * from './interpolation.js';
15
- export * from './utils/shell/spawn.js';
16
- export * from './utils/jsepEval.js';
17
- export * from './utils/hashFiles.js';
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uCAAuC,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAgC,MAAM,uBAAuB,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC","sourcesContent":["export { BuildStepContext } from './BuildStepContext.js';\nexport { readAndValidateBuildConfigFromPathAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { StepsConfigParser } from './StepsConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport { BuildStepEnv } from './BuildStepEnv.js';\nexport { BuildFunctionGroup } from './BuildFunctionGroup.js';\nexport { BuildStep } from './BuildStep.js';\nexport * as errors from './errors.js';\nexport * from './interpolation.js';\nexport * from './utils/shell/spawn.js';\nexport * from './utils/jsepEval.js';\nexport * from './utils/hashFiles.js';\n"]}
@@ -1,5 +0,0 @@
1
- import { JobInterpolationContext } from '@expo/eas-build-job';
2
- export declare function interpolateJobContext({ target, context, }: {
3
- target: unknown;
4
- context: JobInterpolationContext;
5
- }): unknown;
@@ -1,26 +0,0 @@
1
- import { jsepEval } from './utils/jsepEval.js';
2
- export function interpolateJobContext({ target, context, }) {
3
- if (typeof target === 'string') {
4
- // If the value is e.g. `build: ${{ inputs.build }}`, we will interpolate the value
5
- // without changing `inputs.build` type, i.e. if it is an object it'll be like `build: {...inputs.build}`.
6
- if (target.startsWith('${{') && target.endsWith('}}')) {
7
- return jsepEval(target.slice(3, -2), context);
8
- }
9
- // Otherwise we replace all occurrences of `${{...}}` with the result of the expression.
10
- // e.g. `echo ${{ build.profile }}` becomes `echo production`.
11
- return target.replace(/\$\{\{(.+?)\}\}/g, (_match, expression) => {
12
- return `${jsepEval(expression, context)}`;
13
- });
14
- }
15
- else if (Array.isArray(target)) {
16
- return target.map((value) => interpolateJobContext({ target: value, context }));
17
- }
18
- else if (typeof target === 'object' && target) {
19
- return Object.fromEntries(Object.entries(target).map(([key, value]) => [
20
- key,
21
- interpolateJobContext({ target: value, context }),
22
- ]));
23
- }
24
- return target;
25
- }
26
- //# sourceMappingURL=interpolation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interpolation.js","sourceRoot":"","sources":["../src/interpolation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,UAAU,qBAAqB,CAAC,EACpC,MAAM,EACN,OAAO,GAIR;IACC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,mFAAmF;QACnF,0GAA0G;QAC1G,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACtD,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;QAED,wFAAwF;QACxF,8DAA8D;QAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;YAC/D,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAClF,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,EAAE,CAAC;QAChD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YAC3C,GAAG;YACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SAClD,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { JobInterpolationContext } from '@expo/eas-build-job';\n\nimport { jsepEval } from './utils/jsepEval.js';\n\nexport function interpolateJobContext({\n target,\n context,\n}: {\n target: unknown;\n context: JobInterpolationContext;\n}): unknown {\n if (typeof target === 'string') {\n // If the value is e.g. `build: ${{ inputs.build }}`, we will interpolate the value\n // without changing `inputs.build` type, i.e. if it is an object it'll be like `build: {...inputs.build}`.\n if (target.startsWith('${{') && target.endsWith('}}')) {\n return jsepEval(target.slice(3, -2), context);\n }\n\n // Otherwise we replace all occurrences of `${{...}}` with the result of the expression.\n // e.g. `echo ${{ build.profile }}` becomes `echo production`.\n return target.replace(/\\$\\{\\{(.+?)\\}\\}/g, (_match, expression) => {\n return `${jsepEval(expression, context)}`;\n });\n } else if (Array.isArray(target)) {\n return target.map((value) => interpolateJobContext({ target: value, context }));\n } else if (typeof target === 'object' && target) {\n return Object.fromEntries(\n Object.entries(target).map(([key, value]) => [\n key,\n interpolateJobContext({ target: value, context }),\n ])\n );\n }\n return target;\n}\n"]}
@@ -1 +0,0 @@
1
- export {};