@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
@@ -5,10 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BuildFunction = void 0;
7
7
  const assert_1 = __importDefault(require("assert"));
8
- const BuildStep_js_1 = require("./BuildStep.cjs");
9
- const customFunction_js_1 = require("./utils/customFunction.cjs");
8
+ const BuildStep_1 = require("./BuildStep");
9
+ const customFunction_1 = require("./utils/customFunction");
10
10
  class BuildFunction {
11
- constructor({ namespace, id, name, supportedRuntimePlatforms, inputProviders, outputProviders, command, fn, customFunctionModulePath, shell, }) {
11
+ constructor({ namespace, id, name, supportedRuntimePlatforms, inputProviders, outputProviders, command, fn, customFunctionModulePath, shell, __metricsId, }) {
12
12
  (0, assert_1.default)(command !== undefined || fn !== undefined || customFunctionModulePath !== undefined, 'Either command, fn or path must be defined.');
13
13
  (0, assert_1.default)(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');
14
14
  (0, assert_1.default)(!(command !== undefined && customFunctionModulePath !== undefined), 'Command and path cannot be both set.');
@@ -23,15 +23,16 @@ class BuildFunction {
23
23
  this.fn = fn;
24
24
  this.shell = shell;
25
25
  this.customFunctionModulePath = customFunctionModulePath;
26
+ this.__metricsId = __metricsId;
26
27
  }
27
28
  getFullId() {
28
29
  return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;
29
30
  }
30
31
  createBuildStepFromFunctionCall(ctx, { id, name, callInputs = {}, workingDirectory, shell, env, ifCondition, timeoutMs, } = {}) {
31
32
  var _a, _b, _c;
32
- const buildStepId = BuildStep_js_1.BuildStep.getNewId(id);
33
+ const buildStepId = BuildStep_1.BuildStep.getNewId(id);
33
34
  const buildStepName = name !== null && name !== void 0 ? name : this.name;
34
- const buildStepDisplayName = BuildStep_js_1.BuildStep.getDisplayName({
35
+ const buildStepDisplayName = BuildStep_1.BuildStep.getDisplayName({
35
36
  id: buildStepId,
36
37
  command: this.command,
37
38
  name: buildStepName,
@@ -44,13 +45,13 @@ class BuildFunction {
44
45
  return input;
45
46
  });
46
47
  const outputs = (_b = this.outputProviders) === null || _b === void 0 ? void 0 : _b.map((outputProvider) => outputProvider(ctx, buildStepId));
47
- return new BuildStep_js_1.BuildStep(ctx, {
48
+ return new BuildStep_1.BuildStep(ctx, {
48
49
  id: buildStepId,
49
50
  name: buildStepName,
50
51
  displayName: buildStepDisplayName,
51
52
  command: this.command,
52
53
  fn: (_c = this.fn) !== null && _c !== void 0 ? _c : (this.customFunctionModulePath
53
- ? (0, customFunction_js_1.createCustomFunctionCall)(this.customFunctionModulePath)
54
+ ? (0, customFunction_1.createCustomFunctionCall)(this.customFunctionModulePath)
54
55
  : undefined),
55
56
  workingDirectory,
56
57
  inputs,
@@ -60,6 +61,7 @@ class BuildFunction {
60
61
  env,
61
62
  ifCondition,
62
63
  timeoutMs,
64
+ __metricsId: this.__metricsId,
63
65
  });
64
66
  }
65
67
  }
@@ -0,0 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AE,aAAa;YACnB,WAAW,EAAE,oBAAoB;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,EAAE,EACA,MAAA,IAAI,CAAC,EAAE,mCACP,CAAC,IAAI,CAAC,wBAAwB;gBAC5B,CAAC,CAAC,IAAA,yCAAwB,EAAC,IAAI,CAAC,wBAAwB,CAAC;gBACzD,CAAC,CAAC,SAAS,CAAC;YAChB,gBAAgB;YAChB,MAAM;YACN,OAAO;YACP,KAAK;YACL,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;YACzD,GAAG;YACH,WAAW;YACX,SAAS;YACT,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;CACF;AAlID,sCAkIC","sourcesContent":["import assert from 'assert';\n\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform';\nimport { BuildStep, BuildStepFunction } from './BuildStep';\nimport { BuildStepGlobalContext } from './BuildStepContext';\nimport { BuildStepInputProvider } from './BuildStepInput';\nimport { BuildStepOutputProvider } from './BuildStepOutput';\nimport { BuildStepEnv } from './BuildStepEnv';\nimport { createCustomFunctionCall } from './utils/customFunction';\n\nexport type BuildFunctionById = Record<string, BuildFunction>;\nexport type BuildFunctionCallInputs = Record<string, unknown>;\n\nexport class BuildFunction {\n public readonly namespace?: string;\n public readonly id: string;\n public readonly name?: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputProviders?: BuildStepInputProvider[];\n public readonly outputProviders?: BuildStepOutputProvider[];\n public readonly command?: string;\n public readonly customFunctionModulePath?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell?: string;\n public readonly __metricsId?: string;\n\n constructor({\n namespace,\n id,\n name,\n supportedRuntimePlatforms,\n inputProviders,\n outputProviders,\n command,\n fn,\n customFunctionModulePath,\n shell,\n __metricsId,\n }: {\n namespace?: string;\n id: string;\n name?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n inputProviders?: BuildStepInputProvider[];\n outputProviders?: BuildStepOutputProvider[];\n command?: string;\n customFunctionModulePath?: string;\n fn?: BuildStepFunction;\n shell?: string;\n __metricsId?: string;\n }) {\n assert(\n command !== undefined || fn !== undefined || customFunctionModulePath !== undefined,\n 'Either command, fn or path must be defined.'\n );\n\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n assert(\n !(command !== undefined && customFunctionModulePath !== undefined),\n 'Command and path cannot be both set.'\n );\n assert(\n !(fn !== undefined && customFunctionModulePath !== undefined),\n 'Fn and path cannot be both set.'\n );\n\n this.namespace = namespace;\n this.id = id;\n this.name = name;\n this.supportedRuntimePlatforms = supportedRuntimePlatforms;\n this.inputProviders = inputProviders;\n this.outputProviders = outputProviders;\n this.command = command;\n this.fn = fn;\n this.shell = shell;\n this.customFunctionModulePath = customFunctionModulePath;\n this.__metricsId = __metricsId;\n }\n\n public getFullId(): string {\n return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;\n }\n\n public createBuildStepFromFunctionCall(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n callInputs = {},\n workingDirectory,\n shell,\n env,\n ifCondition,\n timeoutMs,\n }: {\n id?: string;\n name?: string;\n callInputs?: BuildFunctionCallInputs;\n workingDirectory?: string;\n shell?: string;\n env?: BuildStepEnv;\n ifCondition?: string;\n timeoutMs?: number;\n } = {}\n ): BuildStep {\n const buildStepId = BuildStep.getNewId(id);\n const buildStepName = name ?? this.name;\n const buildStepDisplayName = BuildStep.getDisplayName({\n id: buildStepId,\n command: this.command,\n name: buildStepName,\n });\n\n const inputs = this.inputProviders?.map((inputProvider) => {\n const input = inputProvider(ctx, buildStepId);\n if (input.id in callInputs) {\n input.set(callInputs[input.id]);\n }\n return input;\n });\n const outputs = this.outputProviders?.map((outputProvider) => outputProvider(ctx, buildStepId));\n\n return new BuildStep(ctx, {\n id: buildStepId,\n name: buildStepName,\n displayName: buildStepDisplayName,\n command: this.command,\n fn:\n this.fn ??\n (this.customFunctionModulePath\n ? createCustomFunctionCall(this.customFunctionModulePath)\n : undefined),\n workingDirectory,\n inputs,\n outputs,\n shell,\n supportedRuntimePlatforms: this.supportedRuntimePlatforms,\n env,\n ifCondition,\n timeoutMs,\n __metricsId: this.__metricsId,\n });\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { BuildFunctionCallInputs } from './BuildFunction.js';
2
- import { BuildStep } from './BuildStep.js';
3
- import { BuildStepGlobalContext } from './BuildStepContext.js';
4
- import { BuildStepInputById, BuildStepInputProvider } from './BuildStepInput.js';
1
+ import { BuildFunctionCallInputs } from './BuildFunction';
2
+ import { BuildStep } from './BuildStep';
3
+ import { BuildStepGlobalContext } from './BuildStepContext';
4
+ import { BuildStepInputById, BuildStepInputProvider } from './BuildStepInput';
5
5
  export type BuildFunctionGroupById = Record<string, BuildFunctionGroup | undefined>;
6
6
  export declare class BuildFunctionGroup {
7
7
  readonly namespace: string;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BuildFunctionGroup = void 0;
4
4
  exports.createBuildFunctionGroupByIdMapping = createBuildFunctionGroupByIdMapping;
5
- const BuildStepInput_js_1 = require("./BuildStepInput.cjs");
6
- const errors_js_1 = require("./errors.cjs");
5
+ const BuildStepInput_1 = require("./BuildStepInput");
6
+ const errors_1 = require("./errors");
7
7
  class BuildFunctionGroup {
8
8
  constructor({ namespace, id, inputProviders, createBuildStepsFromFunctionGroupCall, }) {
9
9
  this.namespace = namespace;
@@ -19,7 +19,7 @@ class BuildFunctionGroup {
19
19
  return input;
20
20
  });
21
21
  return createBuildStepsFromFunctionGroupCall(ctx, {
22
- inputs: (0, BuildStepInput_js_1.makeBuildStepInputByIdMap)(inputs),
22
+ inputs: (0, BuildStepInput_1.makeBuildStepInputByIdMap)(inputs),
23
23
  });
24
24
  };
25
25
  }
@@ -32,7 +32,7 @@ function createBuildFunctionGroupByIdMapping(buildFunctionGroups) {
32
32
  const buildFunctionGroupById = {};
33
33
  for (const buildFunctionGroup of buildFunctionGroups) {
34
34
  if (buildFunctionGroupById[buildFunctionGroup.getFullId()] !== undefined) {
35
- throw new errors_js_1.BuildConfigError(`Build function group with id ${buildFunctionGroup.getFullId()} is already defined.`);
35
+ throw new errors_1.BuildConfigError(`Build function group with id ${buildFunctionGroup.getFullId()} is already defined.`);
36
36
  }
37
37
  buildFunctionGroupById[buildFunctionGroup.getFullId()] = buildFunctionGroup;
38
38
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildFunctionGroup.js","sourceRoot":"","sources":["../src/BuildFunctionGroup.ts"],"names":[],"mappings":";;;AAgEA,kFAaC;AA1ED,qDAI0B;AAC1B,qCAA4C;AAI5C,MAAa,kBAAkB;IAW7B,YAAY,EACV,SAAS,EACT,EAAE,EACF,cAAc,EACd,qCAAqC,GAatC;QACC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,qCAAqC,GAAG,CAAC,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;;YAC7E,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,cAAc,0CAAE,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE;gBACxD,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBACrC,IAAI,KAAK,CAAC,EAAE,IAAI,UAAU,EAAE,CAAC;oBAC3B,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;YACH,OAAO,qCAAqC,CAAC,GAAG,EAAE;gBAChD,MAAM,EAAE,IAAA,0CAAyB,EAAC,MAAM,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;IACjF,CAAC;CACF;AAlDD,gDAkDC;AAED,SAAgB,mCAAmC,CACjD,mBAAyC;IAEzC,MAAM,sBAAsB,GAA2B,EAAE,CAAC;IAC1D,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,IAAI,sBAAsB,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;YACzE,MAAM,IAAI,yBAAgB,CACxB,gCAAgC,kBAAkB,CAAC,SAAS,EAAE,sBAAsB,CACrF,CAAC;QACJ,CAAC;QACD,sBAAsB,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9E,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { BuildFunctionCallInputs } from './BuildFunction';\nimport { BuildStep } from './BuildStep';\nimport { BuildStepGlobalContext } from './BuildStepContext';\nimport {\n BuildStepInputById,\n BuildStepInputProvider,\n makeBuildStepInputByIdMap,\n} from './BuildStepInput';\nimport { BuildConfigError } from './errors';\n\nexport type BuildFunctionGroupById = Record<string, BuildFunctionGroup | undefined>;\n\nexport class BuildFunctionGroup {\n public readonly namespace: string;\n public readonly id: string;\n public readonly inputProviders?: BuildStepInputProvider[];\n public readonly createBuildStepsFromFunctionGroupCall: (\n globalCtx: BuildStepGlobalContext,\n options?: {\n callInputs?: BuildFunctionCallInputs;\n }\n ) => BuildStep[];\n\n constructor({\n namespace,\n id,\n inputProviders,\n createBuildStepsFromFunctionGroupCall,\n }: {\n namespace: string;\n id: string;\n inputProviders?: BuildStepInputProvider[];\n createBuildStepsFromFunctionGroupCall: (\n globalCtx: BuildStepGlobalContext,\n {\n inputs,\n }: {\n inputs: BuildStepInputById;\n }\n ) => BuildStep[];\n }) {\n this.namespace = namespace;\n this.id = id;\n this.inputProviders = inputProviders;\n\n this.createBuildStepsFromFunctionGroupCall = (ctx, { callInputs = {} } = {}) => {\n const inputs = this.inputProviders?.map((inputProvider) => {\n const input = inputProvider(ctx, id);\n if (input.id in callInputs) {\n input.set(callInputs[input.id]);\n }\n return input;\n });\n return createBuildStepsFromFunctionGroupCall(ctx, {\n inputs: makeBuildStepInputByIdMap(inputs),\n });\n };\n }\n\n public getFullId(): string {\n return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;\n }\n}\n\nexport function createBuildFunctionGroupByIdMapping(\n buildFunctionGroups: BuildFunctionGroup[]\n): BuildFunctionGroupById {\n const buildFunctionGroupById: BuildFunctionGroupById = {};\n for (const buildFunctionGroup of buildFunctionGroups) {\n if (buildFunctionGroupById[buildFunctionGroup.getFullId()] !== undefined) {\n throw new BuildConfigError(\n `Build function group with id ${buildFunctionGroup.getFullId()} is already defined.`\n );\n }\n buildFunctionGroupById[buildFunctionGroup.getFullId()] = buildFunctionGroup;\n }\n return buildFunctionGroupById;\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js';
2
- import { BuildStepInput } from './BuildStepInput.js';
3
- import { BuildStepOutput, BuildStepOutputById, SerializedBuildStepOutput } from './BuildStepOutput.js';
4
- import { BuildStepEnv } from './BuildStepEnv.js';
5
- import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
1
+ import { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext';
2
+ import { BuildStepInput } from './BuildStepInput';
3
+ import { BuildStepOutput, BuildStepOutputById, SerializedBuildStepOutput } from './BuildStepOutput';
4
+ import { BuildStepEnv } from './BuildStepEnv';
5
+ import { BuildRuntimePlatform } from './BuildRuntimePlatform';
6
6
  export declare enum BuildStepStatus {
7
7
  NEW = "new",
8
8
  IN_PROGRESS = "in-progress",
@@ -57,6 +57,7 @@ export declare class BuildStep extends BuildStepOutputAccessor {
57
57
  readonly stepEnvOverrides: BuildStepEnv;
58
58
  readonly ifCondition?: string;
59
59
  readonly timeoutMs?: number;
60
+ readonly __metricsId?: string;
60
61
  status: BuildStepStatus;
61
62
  private readonly outputsDir;
62
63
  private readonly envsDir;
@@ -69,7 +70,7 @@ export declare class BuildStep extends BuildStepOutputAccessor {
69
70
  name?: string;
70
71
  command?: string;
71
72
  }): string;
72
- constructor(ctx: BuildStepGlobalContext, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, }: {
73
+ constructor(ctx: BuildStepGlobalContext, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }: {
73
74
  id: string;
74
75
  name?: string;
75
76
  displayName: string;
@@ -83,6 +84,7 @@ export declare class BuildStep extends BuildStepOutputAccessor {
83
84
  env?: BuildStepEnv;
84
85
  ifCondition?: string;
85
86
  timeoutMs?: number;
87
+ __metricsId?: string;
86
88
  });
87
89
  executeAsync(): Promise<void>;
88
90
  canBeRunOnRuntimePlatform(): boolean;
@@ -9,16 +9,16 @@ const promises_1 = __importDefault(require("fs/promises"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const buffer_1 = require("buffer");
11
11
  const uuid_1 = require("uuid");
12
- const BuildStepInput_js_1 = require("./BuildStepInput.cjs");
13
- const BuildStepOutput_js_1 = require("./BuildStepOutput.cjs");
14
- const bin_js_1 = require("./utils/shell/bin.cjs");
15
- const command_js_1 = require("./utils/shell/command.cjs");
16
- const BuildTemporaryFiles_js_1 = require("./BuildTemporaryFiles.cjs");
17
- const spawn_js_1 = require("./utils/shell/spawn.cjs");
18
- const template_js_1 = require("./utils/template.cjs");
19
- const errors_js_1 = require("./errors.cjs");
20
- const jsepEval_js_1 = require("./utils/jsepEval.cjs");
21
- const interpolation_js_1 = require("./interpolation.cjs");
12
+ const BuildStepInput_1 = require("./BuildStepInput");
13
+ const BuildStepOutput_1 = require("./BuildStepOutput");
14
+ const bin_1 = require("./utils/shell/bin");
15
+ const command_1 = require("./utils/shell/command");
16
+ const BuildTemporaryFiles_1 = require("./BuildTemporaryFiles");
17
+ const spawn_1 = require("./utils/shell/spawn");
18
+ const template_1 = require("./utils/template");
19
+ const errors_1 = require("./errors");
20
+ const jsepEval_1 = require("./utils/jsepEval");
21
+ const interpolation_1 = require("./interpolation");
22
22
  var BuildStepStatus;
23
23
  (function (BuildStepStatus) {
24
24
  BuildStepStatus["NEW"] = "new";
@@ -47,10 +47,10 @@ class BuildStepOutputAccessor {
47
47
  }
48
48
  getOutputValueByName(name) {
49
49
  if (!this.executed) {
50
- throw new errors_js_1.BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
50
+ throw new errors_1.BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
51
51
  }
52
52
  if (!this.hasOutputParameter(name)) {
53
- throw new errors_js_1.BuildStepRuntimeError(`Step "${this.displayName}" does not have output "${name}".`);
53
+ throw new errors_1.BuildStepRuntimeError(`Step "${this.displayName}" does not have output "${name}".`);
54
54
  }
55
55
  return this.outputById[name].value;
56
56
  }
@@ -68,7 +68,7 @@ class BuildStepOutputAccessor {
68
68
  static deserialize(serialized) {
69
69
  const outputById = Object.fromEntries(Object.entries(serialized.outputById).map(([key, value]) => [
70
70
  key,
71
- BuildStepOutput_js_1.BuildStepOutput.deserialize(value),
71
+ BuildStepOutput_1.BuildStepOutput.deserialize(value),
72
72
  ]));
73
73
  return new BuildStepOutputAccessor(serialized.id, serialized.displayName, serialized.executed, outputById);
74
74
  }
@@ -96,10 +96,10 @@ class BuildStep extends BuildStepOutputAccessor {
96
96
  }
97
97
  return id;
98
98
  }
99
- constructor(ctx, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, }) {
99
+ constructor(ctx, { id, name, displayName, inputs, outputs, command, fn, workingDirectory: maybeWorkingDirectory, shell, supportedRuntimePlatforms: maybeSupportedRuntimePlatforms, env, ifCondition, timeoutMs, __metricsId, }) {
100
100
  (0, assert_1.default)(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');
101
101
  (0, assert_1.default)(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');
102
- const outputById = (0, BuildStepOutput_js_1.makeBuildStepOutputByIdMap)(outputs);
102
+ const outputById = (0, BuildStepOutput_1.makeBuildStepOutputByIdMap)(outputs);
103
103
  super(id, displayName, false, outputById);
104
104
  this.executed = false;
105
105
  this.id = id;
@@ -107,13 +107,14 @@ class BuildStep extends BuildStepOutputAccessor {
107
107
  this.displayName = displayName;
108
108
  this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;
109
109
  this.inputs = inputs;
110
- this.inputById = (0, BuildStepInput_js_1.makeBuildStepInputByIdMap)(inputs);
110
+ this.inputById = (0, BuildStepInput_1.makeBuildStepInputByIdMap)(inputs);
111
111
  this.outputById = outputById;
112
112
  this.fn = fn;
113
113
  this.command = command;
114
114
  this.shell = shell !== null && shell !== void 0 ? shell : '/bin/bash -eo pipefail';
115
115
  this.ifCondition = ifCondition;
116
116
  this.timeoutMs = timeoutMs;
117
+ this.__metricsId = __metricsId;
117
118
  this.status = BuildStepStatus.NEW;
118
119
  this.internalId = (0, uuid_1.v4)();
119
120
  const logger = ctx.baseLogger.child({
@@ -123,8 +124,8 @@ class BuildStep extends BuildStepOutputAccessor {
123
124
  });
124
125
  this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });
125
126
  this.stepEnvOverrides = env !== null && env !== void 0 ? env : {};
126
- this.outputsDir = (0, BuildTemporaryFiles_js_1.getTemporaryOutputsDirPath)(ctx, this.id);
127
- this.envsDir = (0, BuildTemporaryFiles_js_1.getTemporaryEnvsDirPath)(ctx, this.id);
127
+ this.outputsDir = (0, BuildTemporaryFiles_1.getTemporaryOutputsDirPath)(ctx, this.id);
128
+ this.envsDir = (0, BuildTemporaryFiles_1.getTemporaryEnvsDirPath)(ctx, this.id);
128
129
  ctx.registerStep(this);
129
130
  }
130
131
  async executeAsync() {
@@ -142,7 +143,7 @@ class BuildStep extends BuildStepOutputAccessor {
142
143
  timeoutId = setTimeout(() => {
143
144
  // Reject with timeout error FIRST, before killing the process
144
145
  // This ensures the timeout error wins the race
145
- reject(new errors_js_1.BuildStepRuntimeError(`Build step "${this.displayName}" timed out after ${this.timeoutMs}ms`));
146
+ reject(new errors_1.BuildStepRuntimeError(`Build step "${this.displayName}" timed out after ${this.timeoutMs}ms`));
146
147
  abortController.abort();
147
148
  }, this.timeoutMs);
148
149
  });
@@ -189,7 +190,7 @@ class BuildStep extends BuildStepOutputAccessor {
189
190
  }
190
191
  this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');
191
192
  }
192
- await (0, BuildTemporaryFiles_js_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx.global, this.id);
193
+ await (0, BuildTemporaryFiles_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx.global, this.id);
193
194
  }
194
195
  }
195
196
  canBeRunOnRuntimePlatform() {
@@ -209,7 +210,7 @@ class BuildStep extends BuildStepOutputAccessor {
209
210
  else if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {
210
211
  ifCondition = ifCondition.slice(2, -1);
211
212
  }
212
- return Boolean((0, jsepEval_js_1.jsepEval)(ifCondition, {
213
+ return Boolean((0, jsepEval_1.jsepEval)(ifCondition, {
213
214
  inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
214
215
  acc[input.id] = input.getValue({
215
216
  interpolationContext: this.getInterpolationContext(),
@@ -238,15 +239,15 @@ class BuildStep extends BuildStepOutputAccessor {
238
239
  }
239
240
  async executeCommandAsync({ signal }) {
240
241
  (0, assert_1.default)(this.command, 'Command must be defined.');
241
- const interpolatedCommand = (0, interpolation_js_1.interpolateJobContext)({
242
+ const interpolatedCommand = (0, interpolation_1.interpolateJobContext)({
242
243
  target: this.command,
243
244
  context: this.getInterpolationContext(),
244
245
  });
245
246
  const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(`${interpolatedCommand}`, this.inputs);
246
247
  this.ctx.logger.debug(`Interpolated inputs in the command template`);
247
- const scriptPath = await (0, BuildTemporaryFiles_js_1.saveScriptToTemporaryFileAsync)(this.ctx.global, this.id, command);
248
+ const scriptPath = await (0, BuildTemporaryFiles_1.saveScriptToTemporaryFileAsync)(this.ctx.global, this.id, command);
248
249
  this.ctx.logger.debug(`Saved script to ${scriptPath}`);
249
- const { command: shellCommand, args } = (0, command_js_1.getShellCommandAndArgs)(this.shell, scriptPath);
250
+ const { command: shellCommand, args } = (0, command_1.getShellCommandAndArgs)(this.shell, scriptPath);
250
251
  this.ctx.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
251
252
  try {
252
253
  const workingDirectoryStat = await promises_1.default.stat(this.ctx.workingDirectory);
@@ -262,7 +263,7 @@ class BuildStep extends BuildStepOutputAccessor {
262
263
  this.ctx.logger.error({ err }, `Cannot access working directory "${this.ctx.workingDirectory}"`);
263
264
  }
264
265
  }
265
- await (0, spawn_js_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
266
+ await (0, spawn_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
266
267
  cwd: this.ctx.workingDirectory,
267
268
  logger: this.ctx.logger,
268
269
  env: this.getScriptEnv(),
@@ -287,7 +288,7 @@ class BuildStep extends BuildStepOutputAccessor {
287
288
  }
288
289
  interpolateInputsOutputsAndGlobalContextInTemplate(template, inputs) {
289
290
  if (!inputs) {
290
- return (0, template_js_1.interpolateWithOutputs)(this.ctx.global.interpolate(template), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
291
+ return (0, template_1.interpolateWithOutputs)(this.ctx.global.interpolate(template), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
291
292
  }
292
293
  const vars = inputs.reduce((acc, input) => {
293
294
  var _a;
@@ -295,13 +296,13 @@ class BuildStep extends BuildStepOutputAccessor {
295
296
  acc[input.id] = typeof value === 'object' ? JSON.stringify(value) : (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '';
296
297
  return acc;
297
298
  }, {});
298
- return (0, template_js_1.interpolateWithOutputs)((0, template_js_1.interpolateWithInputs)(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
299
+ return (0, template_1.interpolateWithOutputs)((0, template_1.interpolateWithInputs)(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
299
300
  }
300
301
  async collectAndValidateOutputsAsync(outputsDir) {
301
302
  const files = await promises_1.default.readdir(outputsDir);
302
303
  for (const outputId of files) {
303
304
  if (!(outputId in this.outputById)) {
304
- const newOutput = new BuildStepOutput_js_1.BuildStepOutput(this.ctx.global, {
305
+ const newOutput = new BuildStepOutput_1.BuildStepOutput(this.ctx.global, {
305
306
  id: outputId,
306
307
  stepDisplayName: this.displayName,
307
308
  required: false,
@@ -326,7 +327,7 @@ class BuildStep extends BuildStepOutputAccessor {
326
327
  }
327
328
  if (nonSetRequiredOutputIds.length > 0) {
328
329
  const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
329
- throw new errors_js_1.BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {
330
+ throw new errors_1.BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {
330
331
  metadata: { ids: nonSetRequiredOutputIds },
331
332
  });
332
333
  }
@@ -347,7 +348,7 @@ class BuildStep extends BuildStepOutputAccessor {
347
348
  var _a;
348
349
  const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };
349
350
  const currentPath = (_a = effectiveEnv.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
350
- const newPath = currentPath ? `${bin_js_1.BIN_PATH}:${currentPath}` : bin_js_1.BIN_PATH;
351
+ const newPath = currentPath ? `${bin_1.BIN_PATH}:${currentPath}` : bin_1.BIN_PATH;
351
352
  return {
352
353
  ...effectiveEnv,
353
354
  __EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AACxB,mCAAgC;AAEhC,+BAAoC;AAIpC,qDAAiG;AACjG,uDAK2B;AAC3B,2CAA6C;AAC7C,mDAA+D;AAC/D,+DAK+B;AAC/B,+CAAiD;AACjD,+CAAiF;AACjF,qCAAiD;AAGjD,+CAA4C;AAC5C,mDAAwD;AAExD,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAgBD,0CAA0C;AAC1C,MAAM,UAAU,GACd,uFAAuF,CAAC;AAS1F,MAAa,uBAAuB;IAClC,YACkB,EAAU,EACV,WAAmB,EAChB,QAAiB,EACjB,UAA+B;QAHlC,OAAE,GAAF,EAAE,CAAQ;QACV,gBAAW,GAAX,WAAW,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAS;QACjB,e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GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAEO,YAAY;;QAClB,MAAM,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1E,MAAM,WAAW,GAAG,MAAA,YAAY,CAAC,IAAI,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QAC1D,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,cAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,cAAQ,CAAC;QACtE,OAAO;YACL,GAAG,YAAY;YACf,wBAAwB,EAAE,IAAI,CAAC,UAAU;YACzC,qBAAqB,EAAE,IAAI,CAAC,OAAO;YACnC,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF;AApbD,8BAobC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\nimport { Buffer } from 'buffer';\n\nimport { v4 as uuidv4 } from 'uuid';\nimport { JobInterpolationContext } from '@expo/eas-build-job';\n\nimport { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput';\nimport { BIN_PATH } from './utils/shell/bin';\nimport { getShellCommandAndArgs } from './utils/shell/command';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n getTemporaryEnvsDirPath,\n getTemporaryOutputsDirPath,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles';\nimport { spawnAsync } from './utils/shell/spawn';\nimport { interpolateWithInputs, interpolateWithOutputs } from './utils/template';\nimport { BuildStepRuntimeError } from './errors';\nimport { BuildStepEnv } from './BuildStepEnv';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform';\nimport { jsepEval } from './utils/jsepEval';\nimport { interpolateJobContext } from './interpolation';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n SKIPPED = 'skipped',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport type BuildStepFunction = (\n ctx: BuildStepContext,\n {\n inputs,\n outputs,\n env,\n }: {\n inputs: { [key: string]: { value: unknown } };\n outputs: BuildStepOutputById;\n env: BuildStepEnv;\n signal?: AbortSignal;\n }\n) => unknown;\n\n// TODO: move to a place common with tests\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/;\n\nexport interface SerializedBuildStepOutputAccessor {\n id: string;\n executed: boolean;\n outputById: Record<string, SerializedBuildStepOutput>;\n displayName: string;\n}\n\nexport class BuildStepOutputAccessor {\n constructor(\n public readonly id: string,\n public readonly displayName: string,\n protected readonly executed: boolean,\n protected readonly outputById: BuildStepOutputById\n ) {}\n\n public get outputs(): BuildStepOutput[] {\n return Object.values(this.outputById);\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public serialize(): SerializedBuildStepOutputAccessor {\n return {\n id: this.id,\n executed: this.executed,\n outputById: Object.fromEntries(\n Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])\n ),\n displayName: this.displayName,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepOutputAccessor\n ): BuildStepOutputAccessor {\n const outputById = Object.fromEntries(\n Object.entries(serialized.outputById).map(([key, value]) => [\n key,\n BuildStepOutput.deserialize(value),\n ])\n );\n return new BuildStepOutputAccessor(\n serialized.id,\n serialized.displayName,\n serialized.executed,\n outputById\n );\n }\n}\n\nexport class BuildStep extends BuildStepOutputAccessor {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputs?: BuildStepInput[];\n public readonly outputById: BuildStepOutputById;\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell: string;\n public readonly ctx: BuildStepContext;\n public readonly stepEnvOverrides: BuildStepEnv;\n public readonly ifCondition?: string;\n public readonly timeoutMs?: number;\n public readonly __metricsId?: string;\n public status: BuildStepStatus;\n private readonly outputsDir: string;\n private readonly envsDir: string;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected executed = false;\n\n public static getNewId(userDefinedId?: string): string {\n return userDefinedId ?? uuidv4();\n }\n\n public static getDisplayName({\n id,\n name,\n command,\n }: {\n id: string;\n name?: string;\n command?: string;\n }): string {\n if (name) {\n return name;\n }\n if (!id.match(UUID_REGEX)) {\n return id;\n }\n if (command) {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return id;\n }\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n displayName,\n inputs,\n outputs,\n command,\n fn,\n workingDirectory: maybeWorkingDirectory,\n shell,\n supportedRuntimePlatforms: maybeSupportedRuntimePlatforms,\n env,\n ifCondition,\n timeoutMs,\n __metricsId,\n }: {\n id: string;\n name?: string;\n displayName: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command?: string;\n fn?: BuildStepFunction;\n workingDirectory?: string;\n shell?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n env?: BuildStepEnv;\n ifCondition?: string;\n timeoutMs?: number;\n __metricsId?: string;\n }\n ) {\n assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n const outputById = makeBuildStepOutputByIdMap(outputs);\n super(id, displayName, false, outputById);\n\n this.id = id;\n this.name = name;\n this.displayName = displayName;\n this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;\n this.inputs = inputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? '/bin/bash -eo pipefail';\n this.ifCondition = ifCondition;\n this.timeoutMs = timeoutMs;\n this.__metricsId = __metricsId;\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n\n const logger = ctx.baseLogger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });\n this.stepEnvOverrides = env ?? {};\n\n this.outputsDir = getTemporaryOutputsDirPath(ctx, this.id);\n this.envsDir = getTemporaryEnvsDirPath(ctx, this.id);\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.displayName}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n await fs.mkdir(this.outputsDir, { recursive: true });\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${this.outputsDir}`);\n\n await fs.mkdir(this.envsDir, { recursive: true });\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${this.envsDir}`\n );\n\n if (this.timeoutMs !== undefined) {\n const abortController = new AbortController();\n\n let timeoutId: NodeJS.Timeout | undefined;\n const timeoutPromise = new Promise<void>((_, reject) => {\n timeoutId = setTimeout(() => {\n // Reject with timeout error FIRST, before killing the process\n // This ensures the timeout error wins the race\n reject(\n new BuildStepRuntimeError(\n `Build step \"${this.displayName}\" timed out after ${this.timeoutMs}ms`\n )\n );\n\n abortController.abort();\n }, this.timeoutMs);\n });\n\n try {\n await Promise.race([\n this.command !== undefined\n ? this.executeCommandAsync({ signal: abortController.signal })\n : this.executeFnAsync({ signal: abortController.signal }),\n timeoutPromise,\n ]);\n } finally {\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n }\n } else {\n const executionPromise =\n this.command !== undefined\n ? this.executeCommandAsync({ signal: null })\n : this.executeFnAsync({ signal: null });\n await executionPromise;\n }\n\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.displayName}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.ctx.logger.error({ err });\n this.ctx.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.displayName}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n\n try {\n await this.collectAndValidateOutputsAsync(this.outputsDir);\n await this.collectAndUpdateEnvsAsync(this.envsDir);\n this.ctx.logger.debug('Finished collecting output parameters');\n } catch (error) {\n // If the step succeeded, we expect the outputs to be collected successfully.\n if (this.status === BuildStepStatus.SUCCESS) {\n throw error;\n }\n\n this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');\n }\n\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n public canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(): boolean {\n const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;\n\n if (!this.ifCondition) {\n return !hasAnyPreviousStepFailed;\n }\n\n let ifCondition = this.ifCondition;\n\n if (ifCondition.startsWith('${{') && ifCondition.endsWith('}}')) {\n ifCondition = ifCondition.slice(3, -2);\n } else if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {\n ifCondition = ifCondition.slice(2, -1);\n }\n\n return Boolean(\n jsepEval(ifCondition, {\n inputs:\n this.inputs?.reduce(\n (acc, input) => {\n acc[input.id] = input.getValue({\n interpolationContext: this.getInterpolationContext(),\n });\n return acc;\n },\n {} as Record<string, unknown>\n ) ?? {},\n eas: {\n runtimePlatform: this.ctx.global.runtimePlatform,\n ...this.ctx.global.staticContext,\n env: this.getScriptEnv(),\n },\n ...this.getInterpolationContext(),\n })\n );\n }\n\n public skip(): void {\n this.status = BuildStepStatus.SKIPPED;\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n 'Executing build step \"${this.displayName}\"'\n );\n this.ctx.logger.info(`Skipped build step \"${this.displayName}\"`);\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED },\n `Skipped build step \"${this.displayName}\"`\n );\n }\n\n private getInterpolationContext(): JobInterpolationContext {\n return {\n ...this.ctx.global.getInterpolationContext(),\n env: this.getScriptEnv(),\n };\n }\n\n private async executeCommandAsync({ signal }: { signal: AbortSignal | null }): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n const interpolatedCommand = interpolateJobContext({\n target: this.command,\n context: this.getInterpolationContext(),\n });\n\n const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(\n `${interpolatedCommand}`,\n this.inputs\n );\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);\n this.ctx.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.ctx.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n\n try {\n const workingDirectoryStat = await fs.stat(this.ctx.workingDirectory);\n if (!workingDirectoryStat.isDirectory()) {\n this.ctx.logger.error(\n `Working directory \"${this.ctx.workingDirectory}\" exists, but is not a directory`\n );\n }\n } catch (err: any) {\n if (err?.code === 'ENOENT') {\n this.ctx.logger.error(\n { err },\n `Working directory \"${this.ctx.workingDirectory}\" does not exist`\n );\n } else {\n this.ctx.logger.error(\n { err },\n `Cannot access working directory \"${this.ctx.workingDirectory}\"`\n );\n }\n }\n\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv(),\n // stdin is /dev/null, std{out,err} are piped into logger.\n stdio: ['ignore', 'pipe', 'pipe'],\n signal: signal ?? undefined,\n });\n this.ctx.logger.debug(`Script completed successfully`);\n }\n\n private async executeFnAsync({ signal }: { signal: AbortSignal | null }): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n await this.fn(this.ctx, {\n inputs: Object.fromEntries(\n Object.entries(this.inputById).map(([key, input]) => [\n key,\n { value: input.getValue({ interpolationContext: this.getInterpolationContext() }) },\n ])\n ),\n outputs: this.outputById,\n env: this.getScriptEnv(),\n signal: signal ?? undefined,\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n }\n\n private interpolateInputsOutputsAndGlobalContextInTemplate(\n template: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return interpolateWithOutputs(\n this.ctx.global.interpolate(template),\n (path) => this.ctx.global.getStepOutputValue(path) ?? ''\n );\n }\n const vars = inputs.reduce(\n (acc, input) => {\n const value = input.getValue({ interpolationContext: this.getInterpolationContext() });\n acc[input.id] = typeof value === 'object' ? JSON.stringify(value) : value?.toString() ?? '';\n return acc;\n },\n {} as Record<string, string>\n );\n return interpolateWithOutputs(\n interpolateWithInputs(this.ctx.global.interpolate(template), vars),\n (path) => this.ctx.global.getStepOutputValue(path) ?? ''\n );\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n const newOutput = new BuildStepOutput(this.ctx.global, {\n id: outputId,\n stepDisplayName: this.displayName,\n required: false,\n });\n this.outputById[outputId] = newOutput;\n }\n\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');\n this.outputById[outputId].set(decodedContents);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of Object.values(this.outputById)) {\n try {\n const value = output.value;\n this.ctx.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.ctx.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {\n metadata: { ids: nonSetRequiredOutputIds },\n });\n }\n }\n\n private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> {\n const filenames = await fs.readdir(envsDir);\n\n const entries = await Promise.all(\n filenames.map(async (basename) => {\n const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');\n const decodedContents = Buffer.from(rawContents, 'base64').toString('utf-8');\n return [basename, decodedContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private getScriptEnv(): Record<string, string> {\n const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };\n const currentPath = effectiveEnv.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...effectiveEnv,\n __EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,\n __EXPO_STEPS_ENVS_DIR: this.envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  import { JobInterpolationContext, StaticJobInterpolationContext } from '@expo/eas-build-job';
2
2
  import { bunyan } from '@expo/logger';
3
- import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep.js';
4
- import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
5
- import { BuildStepEnv } from './BuildStepEnv.js';
3
+ import { StepMetricInput, StepMetricsCollection } from './StepMetrics';
4
+ import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep';
5
+ import { BuildRuntimePlatform } from './BuildRuntimePlatform';
6
+ import { BuildStepEnv } from './BuildStepEnv';
6
7
  interface SerializedExternalBuildContextProvider {
7
8
  projectSourceDirectory: string;
8
9
  projectTargetDirectory: string;
@@ -38,6 +39,7 @@ export declare class BuildStepGlobalContext {
38
39
  private didCheckOut;
39
40
  private _hasAnyPreviousStepFailed;
40
41
  private stepById;
42
+ private readonly _stepMetrics;
41
43
  constructor(provider: ExternalBuildContextProvider, skipCleanup: boolean);
42
44
  get projectSourceDirectory(): string;
43
45
  get projectTargetDirectory(): string;
@@ -57,6 +59,8 @@ export declare class BuildStepGlobalContext {
57
59
  markAsCheckedOut(logger: bunyan): void;
58
60
  get hasAnyPreviousStepFailed(): boolean;
59
61
  markAsFailed(): void;
62
+ get stepMetrics(): StepMetricsCollection;
63
+ addStepMetric(metric: StepMetricInput): void;
60
64
  wasCheckedOut(): boolean;
61
65
  hashFiles(...patterns: string[]): string;
62
66
  serialize(): SerializedBuildStepGlobalContext;
@@ -8,10 +8,10 @@ const os_1 = __importDefault(require("os"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fast_glob_1 = __importDefault(require("fast-glob"));
10
10
  const uuid_1 = require("uuid");
11
- const hashFiles_js_1 = require("./utils/hashFiles.cjs");
12
- const BuildStep_js_1 = require("./BuildStep.cjs");
13
- const template_js_1 = require("./utils/template.cjs");
14
- const errors_js_1 = require("./errors.cjs");
11
+ const hashFiles_1 = require("./utils/hashFiles");
12
+ const BuildStep_1 = require("./BuildStep");
13
+ const template_1 = require("./utils/template");
14
+ const errors_1 = require("./errors");
15
15
  class BuildStepGlobalContext {
16
16
  constructor(provider, skipCleanup) {
17
17
  this.provider = provider;
@@ -19,6 +19,7 @@ class BuildStepGlobalContext {
19
19
  this.didCheckOut = false;
20
20
  this._hasAnyPreviousStepFailed = false;
21
21
  this.stepById = {};
22
+ this._stepMetrics = [];
22
23
  this.stepsInternalBuildDirectory = path_1.default.join(os_1.default.tmpdir(), 'eas-build', (0, uuid_1.v4)());
23
24
  this.runtimePlatform = provider.runtimePlatform;
24
25
  this.baseLogger = provider.logger;
@@ -59,9 +60,9 @@ class BuildStepGlobalContext {
59
60
  this.stepById[step.id] = step;
60
61
  }
61
62
  getStepOutputValue(path) {
62
- const { stepId, outputId } = (0, template_js_1.parseOutputPath)(path);
63
+ const { stepId, outputId } = (0, template_1.parseOutputPath)(path);
63
64
  if (!(stepId in this.stepById)) {
64
- throw new errors_js_1.BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
65
+ throw new errors_1.BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
65
66
  }
66
67
  return this.stepById[stepId].getOutputValueByName(outputId);
67
68
  }
@@ -90,9 +91,9 @@ class BuildStepGlobalContext {
90
91
  };
91
92
  }
92
93
  interpolate(value) {
93
- return (0, template_js_1.interpolateWithGlobalContext)(value, (path) => {
94
+ return (0, template_1.interpolateWithGlobalContext)(value, (path) => {
94
95
  var _a, _b;
95
- return ((_b = (_a = (0, template_js_1.getObjectValueForInterpolation)(path, {
96
+ return ((_b = (_a = (0, template_1.getObjectValueForInterpolation)(path, {
96
97
  eas: {
97
98
  runtimePlatform: this.runtimePlatform,
98
99
  ...this.staticContext,
@@ -114,6 +115,12 @@ class BuildStepGlobalContext {
114
115
  markAsFailed() {
115
116
  this._hasAnyPreviousStepFailed = true;
116
117
  }
118
+ get stepMetrics() {
119
+ return this._stepMetrics;
120
+ }
121
+ addStepMetric(metric) {
122
+ this._stepMetrics.push({ ...metric, platform: this.runtimePlatform });
123
+ }
117
124
  wasCheckedOut() {
118
125
  return this.didCheckOut;
119
126
  }
@@ -133,7 +140,7 @@ class BuildStepGlobalContext {
133
140
  if (validFilePaths.length === 0) {
134
141
  return '';
135
142
  }
136
- return (0, hashFiles_js_1.hashFiles)(validFilePaths);
143
+ return (0, hashFiles_1.hashFiles)(validFilePaths);
137
144
  }
138
145
  serialize() {
139
146
  return {
@@ -165,7 +172,7 @@ class BuildStepGlobalContext {
165
172
  };
166
173
  const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);
167
174
  for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {
168
- ctx.stepById[id] = BuildStep_js_1.BuildStepOutputAccessor.deserialize(stepOutputAccessor);
175
+ ctx.stepById[id] = BuildStep_1.BuildStepOutputAccessor.deserialize(stepOutputAccessor);
169
176
  }
170
177
  ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;
171
178
  return ctx;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,0DAA2B;AAG3B,+BAAoC;AAGpC,iDAA8C;AAC9C,2CAAoG;AACpG,+CAI0B;AAC1B,qCAAiD;AAoCjD,MAAa,sBAAsB;IASjC,YACmB,QAAsC,EACvC,WAAoB;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QACvC,gBAAW,GAAX,WAAW,CAAS;QAP9B,gBAAW,GAAG,KAAK,CAAC;QACpB,8BAAyB,GAAG,KAAK,CAAC;QAClC,aAAQ,GAA4C,EAAE,CAAC;QAC9C,iBAAY,GAA0B,EAAE,CAAC;QAMxD,IAAI,CAAC,2BAA2B,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAA,SAAM,GAAE,CAAC,CAAC;QACjF,IAAI,CAAC,eAAe,G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AC7B,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,WAAW,CACvB,UAAsC,EACtC,MAAc;QAEd,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzF,OAAO,IAAI,gBAAgB,CAAC,kBAAkB,EAAE;YAC9C,MAAM;YACN,wBAAwB,EAAE,UAAU,CAAC,wBAAwB;SAC9D,CAAC,CAAC;IACL,CAAC;CACF;AAnDD,4CAmDC","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport fg from 'fast-glob';\nimport { Env, JobInterpolationContext, StaticJobInterpolationContext } from '@expo/eas-build-job';\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { StepMetricInput, StepMetricsCollection } from './StepMetrics';\nimport { hashFiles } from './utils/hashFiles';\nimport { BuildStep, BuildStepOutputAccessor, SerializedBuildStepOutputAccessor } from './BuildStep';\nimport {\n getObjectValueForInterpolation,\n interpolateWithGlobalContext,\n parseOutputPath,\n} from './utils/template';\nimport { BuildStepRuntimeError } from './errors';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform';\nimport { BuildStepEnv } from './BuildStepEnv';\n\ninterface SerializedExternalBuildContextProvider {\n projectSourceDirectory: string;\n projectTargetDirectory: string;\n defaultWorkingDirectory: string;\n buildLogsDirectory: string;\n runtimePlatform: BuildRuntimePlatform;\n // We omit steps, because they should be calculated live based on global context.\n staticContext: Omit<StaticJobInterpolationContext, 'steps'>;\n env: BuildStepEnv;\n}\n\nexport interface ExternalBuildContextProvider {\n readonly projectSourceDirectory: string;\n readonly projectTargetDirectory: string;\n readonly defaultWorkingDirectory: string;\n readonly buildLogsDirectory: string;\n readonly runtimePlatform: BuildRuntimePlatform;\n readonly logger: bunyan;\n\n readonly staticContext: () => Omit<StaticJobInterpolationContext, 'steps'>;\n\n readonly env: BuildStepEnv;\n updateEnv(env: BuildStepEnv): void;\n}\n\nexport interface SerializedBuildStepGlobalContext {\n stepsInternalBuildDirectory: string;\n stepById: Record<string, SerializedBuildStepOutputAccessor>;\n provider: SerializedExternalBuildContextProvider;\n skipCleanup: boolean;\n}\n\nexport class BuildStepGlobalContext {\n public stepsInternalBuildDirectory: string;\n public readonly runtimePlatform: BuildRuntimePlatform;\n public readonly baseLogger: bunyan;\n private didCheckOut = false;\n private _hasAnyPreviousStepFailed = false;\n private stepById: Record<string, BuildStepOutputAccessor> = {};\n private readonly _stepMetrics: StepMetricsCollection = [];\n\n constructor(\n private readonly provider: ExternalBuildContextProvider,\n public readonly skipCleanup: boolean\n ) {\n this.stepsInternalBuildDirectory = path.join(os.tmpdir(), 'eas-build', uuidv4());\n this.runtimePlatform = provider.runtimePlatform;\n this.baseLogger = provider.logger;\n this._hasAnyPreviousStepFailed = false;\n }\n\n public get projectSourceDirectory(): string {\n return this.provider.projectSourceDirectory;\n }\n\n public get projectTargetDirectory(): string {\n return this.provider.projectTargetDirectory;\n }\n\n public get defaultWorkingDirectory(): string {\n return this.didCheckOut ? this.provider.defaultWorkingDirectory : this.projectTargetDirectory;\n }\n\n public get buildLogsDirectory(): string {\n return this.provider.buildLogsDirectory;\n }\n\n public get env(): BuildStepEnv {\n return this.provider.env;\n }\n\n public get staticContext(): StaticJobInterpolationContext {\n return {\n ...this.provider.staticContext(),\n steps: Object.fromEntries(\n Object.values(this.stepById).map((step) => [\n step.id,\n {\n outputs: Object.fromEntries(\n step.outputs.map((output) => {\n return [output.id, output.rawValue];\n })\n ),\n },\n ])\n ),\n };\n }\n\n public updateEnv(updatedEnv: BuildStepEnv): void {\n this.provider.updateEnv(updatedEnv);\n }\n\n public registerStep(step: BuildStep): void {\n this.stepById[step.id] = step;\n }\n\n public getStepOutputValue(path: string): string | undefined {\n const { stepId, outputId } = parseOutputPath(path);\n if (!(stepId in this.stepById)) {\n throw new BuildStepRuntimeError(`Step \"${stepId}\" does not exist.`);\n }\n return this.stepById[stepId].getOutputValueByName(outputId);\n }\n\n public getInterpolationContext(): JobInterpolationContext {\n const hasAnyPreviousStepFailed = this.hasAnyPreviousStepFailed;\n\n return {\n ...this.staticContext,\n always: () => true,\n never: () => false,\n success: () => !hasAnyPreviousStepFailed,\n failure: () => hasAnyPreviousStepFailed,\n env: this.env as Env,\n fromJSON: (json: string) => JSON.parse(json),\n toJSON: (value: unknown) => JSON.stringify(value),\n contains: (value, substring) => value.includes(substring),\n startsWith: (value, prefix) => value.startsWith(prefix),\n endsWith: (value, suffix) => value.endsWith(suffix),\n hashFiles: (...patterns: string[]) => this.hashFiles(...patterns),\n replaceAll: (input: string, stringToReplace: string, replacementString: string) => {\n while (input.includes(stringToReplace)) {\n input = input.replace(stringToReplace, replacementString);\n }\n return input;\n },\n substring: (input: string, start: number, end?: number) => input.substring(start, end),\n };\n }\n\n public interpolate<InterpolableType extends string | object>(\n value: InterpolableType\n ): InterpolableType {\n return interpolateWithGlobalContext(value, (path) => {\n return (\n getObjectValueForInterpolation(path, {\n eas: {\n runtimePlatform: this.runtimePlatform,\n ...this.staticContext,\n env: this.env,\n },\n })?.toString() ?? ''\n );\n });\n }\n\n public stepCtx(options: { logger: bunyan; relativeWorkingDirectory?: string }): BuildStepContext {\n return new BuildStepContext(this, options);\n }\n\n public markAsCheckedOut(logger: bunyan): void {\n this.didCheckOut = true;\n logger.info(\n `Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`\n );\n }\n\n public get hasAnyPreviousStepFailed(): boolean {\n return this._hasAnyPreviousStepFailed;\n }\n\n public markAsFailed(): void {\n this._hasAnyPreviousStepFailed = true;\n }\n\n public get stepMetrics(): StepMetricsCollection {\n return this._stepMetrics;\n }\n\n public addStepMetric(metric: StepMetricInput): void {\n this._stepMetrics.push({ ...metric, platform: this.runtimePlatform });\n }\n\n public wasCheckedOut(): boolean {\n return this.didCheckOut;\n }\n\n public hashFiles(...patterns: string[]): string {\n const cwd = this.defaultWorkingDirectory;\n const workspacePath = path.resolve(cwd);\n\n // Use glob to find matching files across all patterns\n const filePaths = fg.sync(patterns, {\n cwd,\n absolute: true,\n onlyFiles: true,\n });\n\n if (filePaths.length === 0) {\n return '';\n }\n\n const validFilePaths = filePaths.filter((file) =>\n file.startsWith(`${workspacePath}${path.sep}`)\n );\n\n if (validFilePaths.length === 0) {\n return '';\n }\n\n return hashFiles(validFilePaths);\n }\n\n public serialize(): SerializedBuildStepGlobalContext {\n return {\n stepsInternalBuildDirectory: this.stepsInternalBuildDirectory,\n stepById: Object.fromEntries(\n Object.entries(this.stepById).map(([id, step]) => [id, step.serialize()])\n ),\n provider: {\n projectSourceDirectory: this.provider.projectSourceDirectory,\n projectTargetDirectory: this.provider.projectTargetDirectory,\n defaultWorkingDirectory: this.provider.defaultWorkingDirectory,\n buildLogsDirectory: this.provider.buildLogsDirectory,\n runtimePlatform: this.provider.runtimePlatform,\n staticContext: this.provider.staticContext(),\n env: this.provider.env,\n },\n skipCleanup: this.skipCleanup,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepGlobalContext,\n logger: bunyan\n ): BuildStepGlobalContext {\n const deserializedProvider: ExternalBuildContextProvider = {\n projectSourceDirectory: serialized.provider.projectSourceDirectory,\n projectTargetDirectory: serialized.provider.projectTargetDirectory,\n defaultWorkingDirectory: serialized.provider.defaultWorkingDirectory,\n buildLogsDirectory: serialized.provider.buildLogsDirectory,\n runtimePlatform: serialized.provider.runtimePlatform,\n logger,\n staticContext: () => serialized.provider.staticContext,\n env: serialized.provider.env,\n updateEnv: () => {},\n };\n const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);\n for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {\n ctx.stepById[id] = BuildStepOutputAccessor.deserialize(stepOutputAccessor);\n }\n ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;\n\n return ctx;\n }\n}\n\nexport interface SerializedBuildStepContext {\n relativeWorkingDirectory?: string;\n global: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepContext {\n public readonly logger: bunyan;\n public readonly relativeWorkingDirectory?: string;\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n logger,\n relativeWorkingDirectory,\n }: {\n logger: bunyan;\n relativeWorkingDirectory?: string;\n }\n ) {\n this.logger = logger ?? ctx.baseLogger;\n this.relativeWorkingDirectory = relativeWorkingDirectory;\n }\n\n public get global(): BuildStepGlobalContext {\n return this.ctx;\n }\n\n public get workingDirectory(): string {\n if (!this.relativeWorkingDirectory) {\n return this.ctx.defaultWorkingDirectory;\n }\n\n if (path.isAbsolute(this.relativeWorkingDirectory)) {\n return path.join(this.ctx.projectTargetDirectory, this.relativeWorkingDirectory);\n }\n\n return path.join(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory);\n }\n\n public serialize(): SerializedBuildStepContext {\n return {\n relativeWorkingDirectory: this.relativeWorkingDirectory,\n global: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepContext,\n logger: bunyan\n ): BuildStepContext {\n const deserializedGlobal = BuildStepGlobalContext.deserialize(serialized.global, logger);\n return new BuildStepContext(deserializedGlobal, {\n logger,\n relativeWorkingDirectory: serialized.relativeWorkingDirectory,\n });\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { JobInterpolationContext } from '@expo/eas-build-job';
2
- import { BuildStepGlobalContext } from './BuildStepContext.js';
2
+ import { BuildStepGlobalContext } from './BuildStepContext';
3
3
  export declare enum BuildStepInputValueTypeName {
4
4
  STRING = "string",
5
5
  BOOLEAN = "boolean",