@expo/steps 1.0.23 → 1.0.28

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 (92) hide show
  1. package/bin/set-env +23 -0
  2. package/dist_commonjs/BuildConfig.cjs +27 -7
  3. package/dist_commonjs/BuildConfig.d.ts +6 -3
  4. package/dist_commonjs/BuildConfig.js.map +1 -1
  5. package/dist_commonjs/BuildConfigParser.cjs +45 -8
  6. package/dist_commonjs/BuildConfigParser.d.ts +3 -4
  7. package/dist_commonjs/BuildConfigParser.js.map +1 -1
  8. package/dist_commonjs/BuildFunction.cjs +12 -5
  9. package/dist_commonjs/BuildFunction.d.ts +9 -5
  10. package/dist_commonjs/BuildFunction.js.map +1 -1
  11. package/dist_commonjs/BuildStep.cjs +101 -26
  12. package/dist_commonjs/BuildStep.d.ts +28 -8
  13. package/dist_commonjs/BuildStep.js.map +1 -1
  14. package/dist_commonjs/BuildStepContext.cjs +99 -13
  15. package/dist_commonjs/BuildStepContext.d.ts +61 -11
  16. package/dist_commonjs/BuildStepContext.js.map +1 -1
  17. package/dist_commonjs/BuildStepInput.cjs +86 -6
  18. package/dist_commonjs/BuildStepInput.d.ts +39 -19
  19. package/dist_commonjs/BuildStepInput.js.map +1 -1
  20. package/dist_commonjs/BuildStepOutput.cjs +21 -1
  21. package/dist_commonjs/BuildStepOutput.d.ts +20 -10
  22. package/dist_commonjs/BuildStepOutput.js.map +1 -1
  23. package/dist_commonjs/BuildTemporaryFiles.cjs +11 -2
  24. package/dist_commonjs/BuildTemporaryFiles.d.ts +5 -4
  25. package/dist_commonjs/BuildTemporaryFiles.js.map +1 -1
  26. package/dist_commonjs/BuildWorkflow.cjs +2 -2
  27. package/dist_commonjs/BuildWorkflow.d.ts +3 -4
  28. package/dist_commonjs/BuildWorkflow.js.map +1 -1
  29. package/dist_commonjs/BuildWorkflowValidator.cjs +35 -4
  30. package/dist_commonjs/BuildWorkflowValidator.d.ts +2 -1
  31. package/dist_commonjs/BuildWorkflowValidator.js.map +1 -1
  32. package/dist_commonjs/cli/cli.cjs +23 -4
  33. package/dist_commonjs/cli/cli.d.ts +16 -1
  34. package/dist_commonjs/cli/cli.js.map +1 -1
  35. package/dist_commonjs/index.cjs +5 -3
  36. package/dist_commonjs/index.d.ts +3 -1
  37. package/dist_commonjs/index.js.map +1 -1
  38. package/dist_commonjs/scripts/runCustomFunction.cjs +106 -0
  39. package/dist_commonjs/scripts/runCustomFunction.d.ts +1 -0
  40. package/dist_commonjs/scripts/runCustomFunction.js.map +1 -0
  41. package/dist_commonjs/utils/customFunction.cjs +89 -0
  42. package/dist_commonjs/utils/customFunction.d.ts +18 -0
  43. package/dist_commonjs/utils/customFunction.js.map +1 -0
  44. package/dist_commonjs/utils/template.cjs +40 -8
  45. package/dist_commonjs/utils/template.d.ts +5 -1
  46. package/dist_commonjs/utils/template.js.map +1 -1
  47. package/dist_esm/BuildConfig.d.ts +6 -3
  48. package/dist_esm/BuildConfig.js +28 -8
  49. package/dist_esm/BuildConfig.js.map +1 -1
  50. package/dist_esm/BuildConfigParser.d.ts +3 -4
  51. package/dist_esm/BuildConfigParser.js +46 -9
  52. package/dist_esm/BuildConfigParser.js.map +1 -1
  53. package/dist_esm/BuildFunction.d.ts +9 -5
  54. package/dist_esm/BuildFunction.js +12 -5
  55. package/dist_esm/BuildFunction.js.map +1 -1
  56. package/dist_esm/BuildStep.d.ts +28 -8
  57. package/dist_esm/BuildStep.js +101 -27
  58. package/dist_esm/BuildStep.js.map +1 -1
  59. package/dist_esm/BuildStepContext.d.ts +61 -11
  60. package/dist_esm/BuildStepContext.js +98 -13
  61. package/dist_esm/BuildStepContext.js.map +1 -1
  62. package/dist_esm/BuildStepInput.d.ts +39 -19
  63. package/dist_esm/BuildStepInput.js +87 -7
  64. package/dist_esm/BuildStepInput.js.map +1 -1
  65. package/dist_esm/BuildStepOutput.d.ts +20 -10
  66. package/dist_esm/BuildStepOutput.js +21 -1
  67. package/dist_esm/BuildStepOutput.js.map +1 -1
  68. package/dist_esm/BuildTemporaryFiles.d.ts +5 -4
  69. package/dist_esm/BuildTemporaryFiles.js +9 -1
  70. package/dist_esm/BuildTemporaryFiles.js.map +1 -1
  71. package/dist_esm/BuildWorkflow.d.ts +3 -4
  72. package/dist_esm/BuildWorkflow.js +2 -2
  73. package/dist_esm/BuildWorkflow.js.map +1 -1
  74. package/dist_esm/BuildWorkflowValidator.d.ts +2 -1
  75. package/dist_esm/BuildWorkflowValidator.js +32 -4
  76. package/dist_esm/BuildWorkflowValidator.js.map +1 -1
  77. package/dist_esm/cli/cli.d.ts +16 -1
  78. package/dist_esm/cli/cli.js +22 -5
  79. package/dist_esm/cli/cli.js.map +1 -1
  80. package/dist_esm/index.d.ts +3 -1
  81. package/dist_esm/index.js +2 -1
  82. package/dist_esm/index.js.map +1 -1
  83. package/dist_esm/scripts/runCustomFunction.d.ts +1 -0
  84. package/dist_esm/scripts/runCustomFunction.js +101 -0
  85. package/dist_esm/scripts/runCustomFunction.js.map +1 -0
  86. package/dist_esm/utils/customFunction.d.ts +18 -0
  87. package/dist_esm/utils/customFunction.js +81 -0
  88. package/dist_esm/utils/customFunction.js.map +1 -0
  89. package/dist_esm/utils/template.d.ts +5 -1
  90. package/dist_esm/utils/template.js +35 -8
  91. package/dist_esm/utils/template.js.map +1 -1
  92. package/package.json +8 -2
@@ -1 +1 @@
1
- {"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AAEA,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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AAC,UAAU,EAAE;YAC3C,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE;gBACrC,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,SAAS,IAAI,CAAC,WAAW,iCACvB,IAAI,CAAC,GAAG,CAAC,eACX,2CAA2C,UAAU,CACnD,IAAI,CAAC,yBAAyB,EAC9B,uFAAuF,CACxF;qBACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;qBACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BuildStep } from './BuildStep.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 validate(): void {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n errors.push(...this.validateAllowedPlatforms());\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 if (\n currentStepInput.rawValue !== undefined &&\n typeof currentStepInput.rawValue !== currentStepInput.allowedValueTypeName\n ) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is set to \"${currentStepInput.rawValue}\" which is not of type \"${currentStepInput.allowedValueTypeName}\".`\n );\n errors.push(error);\n }\n\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n if (!currentStepInput.isValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n currentStepInput.value\n }\" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)\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.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"]}
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;QA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K,GAAG,IAAI,gBAAgB,CAChC,gCAAgC,aAAa,CAAC,wBAAwB,mBAAmB,aAAa,CAAC,EAAE,yCAAyC,CACnJ,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;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.isValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n currentStepInput.value\n }\" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)\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 +1,16 @@
1
- export {};
1
+ import { bunyan } from '@expo/logger';
2
+ import { ExternalBuildContextProvider } from '../BuildStepContext.js';
3
+ import { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';
4
+ import { BuildStepEnv } from '../BuildStepEnv.js';
5
+ export declare class CliContextProvider implements ExternalBuildContextProvider {
6
+ readonly logger: bunyan;
7
+ readonly runtimePlatform: BuildRuntimePlatform;
8
+ readonly projectSourceDirectory: string;
9
+ readonly projectTargetDirectory: string;
10
+ readonly defaultWorkingDirectory: string;
11
+ private _env;
12
+ constructor(logger: bunyan, runtimePlatform: BuildRuntimePlatform, projectSourceDirectory: string, projectTargetDirectory: string, defaultWorkingDirectory: string);
13
+ get env(): BuildStepEnv;
14
+ staticContext(): any;
15
+ updateEnv(env: BuildStepEnv): void;
16
+ }
@@ -1,18 +1,35 @@
1
1
  var _a;
2
2
  import path from 'path';
3
3
  import { createLogger } from '@expo/logger';
4
- import { v4 as uuidv4 } from 'uuid';
5
4
  import { BuildConfigParser } from '../BuildConfigParser.js';
6
- import { BuildStepContext } from '../BuildStepContext.js';
5
+ import { BuildStepGlobalContext } from '../BuildStepContext.js';
7
6
  import { BuildWorkflowError } from '../errors.js';
8
7
  const logger = createLogger({
9
8
  name: 'steps-cli',
10
9
  level: 'info',
11
10
  });
11
+ export class CliContextProvider {
12
+ constructor(logger, runtimePlatform, projectSourceDirectory, projectTargetDirectory, defaultWorkingDirectory) {
13
+ this.logger = logger;
14
+ this.runtimePlatform = runtimePlatform;
15
+ this.projectSourceDirectory = projectSourceDirectory;
16
+ this.projectTargetDirectory = projectTargetDirectory;
17
+ this.defaultWorkingDirectory = defaultWorkingDirectory;
18
+ this._env = {};
19
+ }
20
+ get env() {
21
+ return this._env;
22
+ }
23
+ staticContext() {
24
+ return {};
25
+ }
26
+ updateEnv(env) {
27
+ this._env = env;
28
+ }
29
+ }
12
30
  async function runAsync(configPath, relativeProjectDirectory, runtimePlatform) {
13
- const fakeBuildId = uuidv4();
14
- const ctx = new BuildStepContext(fakeBuildId, logger, false, runtimePlatform, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory);
15
- const parser = new BuildConfigParser(ctx, { configPath });
31
+ const ctx = new BuildStepGlobalContext(new CliContextProvider(logger, runtimePlatform, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory), false, configPath);
32
+ const parser = new BuildConfigParser(ctx, {});
16
33
  const workflow = await parser.parseAsync();
17
34
  await workflow.executeAsync();
18
35
  }
@@ -1 +1 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EAAE;IACxD,OAAO,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACnE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,4BAA4B,CAAC,CAAC;AAEnF,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7D,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACtC,IAAI,GAAG,YAAY,kBAAkB,EAAE;QACrC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC9D,KAAK,MAAM,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE;YACpC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;SACpC;KACF;AACH,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { createLogger } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildConfigParser } from '../BuildConfigParser.js';\nimport { BuildStepContext } from '../BuildStepContext.js';\nimport { BuildWorkflowError } from '../errors.js';\nimport { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';\n\nconst logger = createLogger({\n name: 'steps-cli',\n level: 'info',\n});\n\nasync function runAsync(\n configPath: string,\n relativeProjectDirectory: string,\n runtimePlatform: BuildRuntimePlatform\n): Promise<void> {\n const fakeBuildId = uuidv4();\n const ctx = new BuildStepContext(\n fakeBuildId,\n logger,\n false,\n runtimePlatform,\n relativeProjectDirectory,\n relativeProjectDirectory,\n relativeProjectDirectory\n );\n const parser = new BuildConfigParser(ctx, { configPath });\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
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAU,YAAY,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAgC,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIlD,MAAM,MAAM,GAAG,YAAY,CAAC;IAC1B,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,MAAM;CACd,CAAC,CAAC;AAEH,MAAM,OAAO,kBAAkB;IAG7B,YACkB,MAAc,EACd,eAAqC,EACrC,sBAA8B,EAC9B,sBAA8B,EAC9B,uBAA+B;QAJ/B,WAAM,GAAN,MAAM,CAAQ;QACd,oBAAe,GAAf,eAAe,CAAsB;QACrC,2BAAsB,GAAtB,sBAAsB,CAAQ;QAC9B,2BAAsB,GAAtB,sBAAsB,CAAQ;QAC9B,4BAAuB,GAAvB,uBAAuB,CAAQ;QAPzC,SAAI,GAAiB,EAAE,CAAC;IAQ7B,C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EnF,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7D,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACtC,IAAI,GAAG,YAAY,kBAAkB,EAAE;QACrC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC9D,KAAK,MAAM,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE;YACpC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;SACpC;KACF;AACH,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\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 ) {}\n public get env(): BuildStepEnv {\n return this._env;\n }\n public staticContext(): any {\n return {};\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 ),\n false,\n configPath\n );\n const parser = new BuildConfigParser(ctx, {});\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,9 +1,11 @@
1
+ export { BuildStepContext } from './BuildStepContext.js';
1
2
  export { readAndValidateBuildConfigAsync } from './BuildConfig.js';
2
3
  export { BuildConfigParser } from './BuildConfigParser.js';
3
4
  export { BuildFunction } from './BuildFunction.js';
4
5
  export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
5
6
  export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
6
7
  export { BuildStepOutput } from './BuildStepOutput.js';
7
- export { BuildStepContext } from './BuildStepContext.js';
8
+ export { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';
8
9
  export { BuildWorkflow } from './BuildWorkflow.js';
10
+ export { BuildStepEnv } from './BuildStepEnv.js';
9
11
  export * as errors from './errors.js';
package/dist_esm/index.js CHANGED
@@ -1,10 +1,11 @@
1
+ export { BuildStepContext } from './BuildStepContext.js';
1
2
  export { readAndValidateBuildConfigAsync } from './BuildConfig.js';
2
3
  export { BuildConfigParser } from './BuildConfigParser.js';
3
4
  export { BuildFunction } from './BuildFunction.js';
4
5
  export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
5
6
  export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
6
7
  export { BuildStepOutput } from './BuildStepOutput.js';
7
- export { BuildStepContext } from './BuildStepContext.js';
8
+ export { BuildStepGlobalContext } from './BuildStepContext.js';
8
9
  export { BuildWorkflow } from './BuildWorkflow.js';
9
10
  export * as errors from './errors.js';
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AACnE,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,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC","sourcesContent":["export { readAndValidateBuildConfigAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepContext } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport * as errors from './errors.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AACnE,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,KAAK,MAAM,MAAM,aAAa,CAAC","sourcesContent":["export { BuildStepContext } from './BuildStepContext.js';\nexport { readAndValidateBuildConfigAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.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 * as errors from './errors.js';\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,101 @@
1
+ import assert from 'assert';
2
+ import { createLogger } from '@expo/logger';
3
+ import cloneDeep from 'lodash.clonedeep';
4
+ import { BuildStepOutput } from '../BuildStepOutput.js';
5
+ import { BuildStepInput } from '../BuildStepInput.js';
6
+ import { BuildStepContext } from '../BuildStepContext.js';
7
+ import { spawnAsync } from '../utils/shell/spawn.js';
8
+ async function runCustomJsFunctionAsync() {
9
+ const customJavascriptFunctionModulePath = process.argv[2];
10
+ const functionArgs = process.argv[3];
11
+ assert(customJavascriptFunctionModulePath, 'customJavascriptFunctionModulePath is required');
12
+ assert(functionArgs, 'serializedFunctionParams is required');
13
+ let serializedFunctionArguments;
14
+ try {
15
+ serializedFunctionArguments = JSON.parse(functionArgs);
16
+ }
17
+ catch (e) {
18
+ console.error('Failed to parse serializedFunctionParams');
19
+ throw e;
20
+ }
21
+ const logger = createLogger({
22
+ name: 'customFunctionLogger',
23
+ streams: [
24
+ {
25
+ type: 'raw',
26
+ stream: {
27
+ write: (rec) => {
28
+ if (rec) {
29
+ switch (rec.level) {
30
+ case 20: // Debug level
31
+ if (rec.msg) {
32
+ console.debug(rec.msg);
33
+ }
34
+ break;
35
+ case 30: // Info level
36
+ if (rec.msg) {
37
+ console.log(rec.msg);
38
+ }
39
+ break;
40
+ case 40: // Warn level
41
+ if (rec.msg) {
42
+ console.warn(rec.msg);
43
+ }
44
+ break;
45
+ case 50: // Error level
46
+ case 60: // Fatal level
47
+ if (rec.msg) {
48
+ console.error(rec.msg);
49
+ }
50
+ break;
51
+ default:
52
+ break;
53
+ }
54
+ }
55
+ },
56
+ },
57
+ },
58
+ ],
59
+ });
60
+ const ctx = BuildStepContext.deserialize(serializedFunctionArguments.ctx, logger);
61
+ const inputs = Object.fromEntries(Object.entries(serializedFunctionArguments.inputs).map(([id, input]) => [
62
+ id,
63
+ BuildStepInput.deserialize(input, logger),
64
+ ]));
65
+ const outputs = Object.fromEntries(Object.entries(serializedFunctionArguments.outputs).map(([id, output]) => [
66
+ id,
67
+ BuildStepOutput.deserialize(output),
68
+ ]));
69
+ const env = serializedFunctionArguments.env;
70
+ const envBefore = cloneDeep(serializedFunctionArguments.env);
71
+ let customModule;
72
+ try {
73
+ customModule = await require(customJavascriptFunctionModulePath);
74
+ }
75
+ catch (e) {
76
+ console.error('Failed to load custom function module');
77
+ throw e;
78
+ }
79
+ const customJavascriptFunction = customModule.default;
80
+ await customJavascriptFunction(ctx, { inputs, outputs, env });
81
+ const promises = [];
82
+ for (const output of Object.values(outputs)) {
83
+ if (output.rawValue) {
84
+ assert(output.value, 'output.value is required');
85
+ promises.push(spawnAsync('set-output', [output.id, output.value], {
86
+ env,
87
+ }));
88
+ }
89
+ }
90
+ for (const envName of Object.keys(env)) {
91
+ const envValue = env[envName];
92
+ if (envValue !== envBefore[envName] && envValue) {
93
+ promises.push(spawnAsync('set-env', [envName, envValue], {
94
+ env,
95
+ }));
96
+ }
97
+ }
98
+ await Promise.all(promises);
99
+ }
100
+ void runCustomJsFunctionAsync();
101
+ //# sourceMappingURL=runCustomFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runCustomFunction.js","sourceRoot":"","sources":["../../src/scripts/runCustomFunction.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,KAAK,UAAU,wBAAwB;IACrC,MAAM,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAErC,MAAM,CAAC,kCAAkC,EAAE,gDAAgD,CAAC,CAAC;IAC7F,MAAM,CAAC,YAAY,EAAE,sCAAsC,CAAC,CAAC;IAE7D,IAAI,2BAAmE,CAAC;IACxE,IAAI;QACF,2BAA2B,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;KACxD;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,MAAM,CAAC,CAAC;KACT;IAED,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,IAAI,EAAE,sBAAsB;QAC5B,OAAO,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OAAO,CAAC,IAAI,QAAQ,EAAE;YAC/C,QAAQ,CAAC,IAAI,CACX,UAAU,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;gBACzC,GAAG;aACJ,CAAC,CACH,CAAC;SACH;KACF;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,KAAK,wBAAwB,EAAE,CAAC","sourcesContent":["import assert from 'assert';\n\nimport { createLogger } from '@expo/logger';\nimport { SpawnPromise, SpawnResult } from '@expo/spawn-async';\nimport cloneDeep from 'lodash.clonedeep';\n\nimport { BuildStepOutput } from '../BuildStepOutput.js';\nimport { BuildStepInput } from '../BuildStepInput.js';\nimport { SerializedCustomBuildFunctionArguments } from '../utils/customFunction.js';\nimport { BuildStepContext } from '../BuildStepContext.js';\nimport { BuildStepFunction } from '../BuildStep.js';\nimport { spawnAsync } from '../utils/shell/spawn.js';\n\nasync function runCustomJsFunctionAsync(): Promise<void> {\n const customJavascriptFunctionModulePath = process.argv[2];\n const functionArgs = process.argv[3];\n\n assert(customJavascriptFunctionModulePath, 'customJavascriptFunctionModulePath is required');\n assert(functionArgs, 'serializedFunctionParams is required');\n\n let serializedFunctionArguments: SerializedCustomBuildFunctionArguments;\n try {\n serializedFunctionArguments = JSON.parse(functionArgs);\n } catch (e) {\n console.error('Failed to parse serializedFunctionParams');\n throw e;\n }\n\n const logger = createLogger({\n name: 'customFunctionLogger',\n streams: [\n {\n type: 'raw',\n stream: {\n write: (rec: any) => {\n if (rec) {\n switch (rec.level) {\n case 20: // Debug level\n if (rec.msg) {\n console.debug(rec.msg);\n }\n break;\n case 30: // Info level\n if (rec.msg) {\n console.log(rec.msg);\n }\n break;\n case 40: // Warn level\n if (rec.msg) {\n console.warn(rec.msg);\n }\n break;\n case 50: // Error level\n case 60: // Fatal level\n if (rec.msg) {\n console.error(rec.msg);\n }\n break;\n default:\n break;\n }\n }\n },\n },\n },\n ],\n });\n\n const ctx = BuildStepContext.deserialize(serializedFunctionArguments.ctx, logger);\n const inputs = Object.fromEntries(\n Object.entries(serializedFunctionArguments.inputs).map(([id, input]) => [\n id,\n BuildStepInput.deserialize(input, logger),\n ])\n );\n const outputs = Object.fromEntries(\n Object.entries(serializedFunctionArguments.outputs).map(([id, output]) => [\n id,\n BuildStepOutput.deserialize(output),\n ])\n );\n const env = serializedFunctionArguments.env;\n const envBefore = cloneDeep(serializedFunctionArguments.env);\n\n let customModule: any;\n try {\n customModule = await require(customJavascriptFunctionModulePath);\n } catch (e) {\n console.error('Failed to load custom function module');\n throw e;\n }\n\n const customJavascriptFunction: BuildStepFunction = customModule.default;\n\n await customJavascriptFunction(ctx, { inputs, outputs, env });\n\n const promises: SpawnPromise<SpawnResult>[] = [];\n for (const output of Object.values(outputs)) {\n if (output.rawValue) {\n assert(output.value, 'output.value is required');\n promises.push(\n spawnAsync('set-output', [output.id, output.value], {\n env,\n })\n );\n }\n }\n for (const envName of Object.keys(env)) {\n const envValue = env[envName];\n if (envValue !== envBefore[envName] && envValue) {\n promises.push(\n spawnAsync('set-env', [envName, envValue], {\n env,\n })\n );\n }\n }\n await Promise.all(promises);\n}\n\nvoid runCustomJsFunctionAsync();\n"]}
@@ -0,0 +1,18 @@
1
+ import { BuildStepFunction } from '../BuildStep.js';
2
+ import { BuildStepEnv } from '../BuildStepEnv.js';
3
+ import { SerializedBuildStepInput } from '../BuildStepInput.js';
4
+ import { SerializedBuildStepOutput } from '../BuildStepOutput.js';
5
+ import { SerializedBuildStepContext } from '../BuildStepContext.js';
6
+ import { BuildFunction } from '../BuildFunction.js';
7
+ export declare const SCRIPTS_PATH: string;
8
+ export interface SerializedCustomBuildFunctionArguments {
9
+ env: BuildStepEnv;
10
+ inputs: Record<string, SerializedBuildStepInput>;
11
+ outputs: Record<string, SerializedBuildStepOutput>;
12
+ ctx: SerializedBuildStepContext;
13
+ }
14
+ export declare function createCustomFunctionCall(customFunctionModulePath: string): BuildStepFunction;
15
+ export declare const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_ID = "install_dependencies_and_compile_custom_function_modules";
16
+ export declare const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAMESPACE = "internal";
17
+ export declare const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAME = "Install dependencies and compile custom function modules";
18
+ export declare function createBuildFunctionToInstallDependenciesAndCompileCustomFunctionModules(customFunctions: BuildFunction[]): BuildFunction;
@@ -0,0 +1,81 @@
1
+ import path from 'path';
2
+ import assert from 'assert';
3
+ import { createContext } from 'this-file';
4
+ import { resolvePackageManager } from '@expo/package-manager';
5
+ import { BuildFunction } from '../BuildFunction.js';
6
+ import { spawnAsync } from './shell/spawn.js';
7
+ const thisFileCtx = createContext();
8
+ export const SCRIPTS_PATH = path.join(thisFileCtx.dirname, '../../dist_commonjs/scripts');
9
+ export function createCustomFunctionCall(customFunctionModulePath) {
10
+ return async (ctx, { env, inputs, outputs }) => {
11
+ const serializedArguments = {
12
+ env,
13
+ inputs: Object.fromEntries(Object.entries(inputs).map(([id, input]) => [id, input.serialize()])),
14
+ outputs: Object.fromEntries(Object.entries(outputs).map(([id, output]) => [id, output.serialize()])),
15
+ ctx: ctx.serialize(),
16
+ };
17
+ await spawnAsync('node', [
18
+ path.join(SCRIPTS_PATH, 'runCustomFunction.cjs'),
19
+ customFunctionModulePath,
20
+ JSON.stringify(serializedArguments),
21
+ ], {
22
+ logger: ctx.logger,
23
+ cwd: ctx.workingDirectory,
24
+ env,
25
+ });
26
+ };
27
+ }
28
+ export const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_ID = 'install_dependencies_and_compile_custom_function_modules';
29
+ export const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAMESPACE = 'internal';
30
+ export const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAME = 'Install dependencies and compile custom function modules';
31
+ export function createBuildFunctionToInstallDependenciesAndCompileCustomFunctionModules(customFunctions) {
32
+ return new BuildFunction({
33
+ namespace: INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAMESPACE,
34
+ id: INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_ID,
35
+ name: INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAME,
36
+ // eslint-disable-next-line async-protect/async-suffix
37
+ fn: async (ctx, { env }) => {
38
+ for (const customFunction of customFunctions) {
39
+ assert(customFunction.customFunctionModulePath, 'customFunctionModulePath');
40
+ const packageManager = resolvePackageManagerForCustomFunction(customFunction.customFunctionModulePath);
41
+ ctx.logger.info(`Detected package manager ${packageManager} for custom function ${customFunction.id}`);
42
+ ctx.logger.info(`Installing dependencies for custom function ${customFunction.id}...`);
43
+ await spawnAsync(packageManager, ['install'], {
44
+ cwd: customFunction.customFunctionModulePath,
45
+ logger: ctx.logger,
46
+ env,
47
+ });
48
+ ctx.logger.info(`Compiling custom function ${customFunction.id}...`);
49
+ await spawnAsync(packageManager, ['run', 'build'], {
50
+ cwd: customFunction.customFunctionModulePath,
51
+ logger: ctx.logger,
52
+ env,
53
+ });
54
+ }
55
+ },
56
+ });
57
+ }
58
+ var PackageManager;
59
+ (function (PackageManager) {
60
+ PackageManager["YARN"] = "yarn";
61
+ PackageManager["NPM"] = "npm";
62
+ PackageManager["PNPM"] = "pnpm";
63
+ })(PackageManager || (PackageManager = {}));
64
+ function resolvePackageManagerForCustomFunction(customFunctionModulePath) {
65
+ try {
66
+ const manager = resolvePackageManager(customFunctionModulePath);
67
+ if (manager === 'npm') {
68
+ return PackageManager.NPM;
69
+ }
70
+ else if (manager === 'pnpm') {
71
+ return PackageManager.PNPM;
72
+ }
73
+ else {
74
+ return PackageManager.YARN;
75
+ }
76
+ }
77
+ catch {
78
+ return PackageManager.YARN;
79
+ }
80
+ }
81
+ //# sourceMappingURL=customFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customFunction.js","sourceRoot":"","sources":["../../src/utils/customFunction.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAO9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;AAS1F,MAAM,UAAU,wBAAwB,CAAC,wBAAgC;IACvE,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QAC7C,MAAM,mBAAmB,GAA2C;YAClE,GAAG;YACH,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CACrE;YACD,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CACxE;YACD,GAAG,EAAE,GAAG,CAAC,SAAS,EAAE;SACrB,CAAC;QACF,MAAM,UAAU,CACd,MAAM,EACN;YACE,IAAI,C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6BAA6B,cAAc,CAAC,EAAE,KAAK,CAAC,CAAC;gBACrE,MAAM,UAAU,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;oBACjD,GAAG,EAAE,cAAc,CAAC,wBAAwB;oBAC5C,MAAM,EAAE,GAAG,CAAC,MAAM;oBAClB,GAAG;iBACJ,CAAC,CAAC;aACJ;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,IAAK,cAIJ;AAJD,WAAK,cAAc;IACjB,+BAAa,CAAA;IACb,6BAAW,CAAA;IACX,+BAAa,CAAA;AACf,CAAC,EAJI,cAAc,KAAd,cAAc,QAIlB;AAED,SAAS,sCAAsC,CAAC,wBAAgC;IAC9E,IAAI;QACF,MAAM,OAAO,GAAG,qBAAqB,CAAC,wBAAwB,CAAC,CAAC;QAEhE,IAAI,OAAO,KAAK,KAAK,EAAE;YACrB,OAAO,cAAc,CAAC,GAAG,CAAC;SAC3B;aAAM,IAAI,OAAO,KAAK,MAAM,EAAE;YAC7B,OAAO,cAAc,CAAC,IAAI,CAAC;SAC5B;aAAM;YACL,OAAO,cAAc,CAAC,IAAI,CAAC;SAC5B;KACF;IAAC,MAAM;QACN,OAAO,cAAc,CAAC,IAAI,CAAC;KAC5B;AACH,CAAC","sourcesContent":["import path from 'path';\nimport assert from 'assert';\n\nimport { createContext } from 'this-file';\nimport { resolvePackageManager } from '@expo/package-manager';\n\nimport { BuildStepFunction } from '../BuildStep.js';\nimport { BuildStepEnv } from '../BuildStepEnv.js';\nimport { SerializedBuildStepInput } from '../BuildStepInput.js';\nimport { SerializedBuildStepOutput } from '../BuildStepOutput.js';\nimport { SerializedBuildStepContext } from '../BuildStepContext.js';\nimport { BuildFunction } from '../BuildFunction.js';\n\nimport { spawnAsync } from './shell/spawn.js';\n\nconst thisFileCtx = createContext();\n\nexport const SCRIPTS_PATH = path.join(thisFileCtx.dirname, '../../dist_commonjs/scripts');\n\nexport interface SerializedCustomBuildFunctionArguments {\n env: BuildStepEnv;\n inputs: Record<string, SerializedBuildStepInput>;\n outputs: Record<string, SerializedBuildStepOutput>;\n ctx: SerializedBuildStepContext;\n}\n\nexport function createCustomFunctionCall(customFunctionModulePath: string): BuildStepFunction {\n return async (ctx, { env, inputs, outputs }) => {\n const serializedArguments: SerializedCustomBuildFunctionArguments = {\n env,\n inputs: Object.fromEntries(\n Object.entries(inputs).map(([id, input]) => [id, input.serialize()])\n ),\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([id, output]) => [id, output.serialize()])\n ),\n ctx: ctx.serialize(),\n };\n await spawnAsync(\n 'node',\n [\n path.join(SCRIPTS_PATH, 'runCustomFunction.cjs'),\n customFunctionModulePath,\n JSON.stringify(serializedArguments),\n ],\n {\n logger: ctx.logger,\n cwd: ctx.workingDirectory,\n env,\n }\n );\n };\n}\n\nexport const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_ID =\n 'install_dependencies_and_compile_custom_function_modules';\nexport const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAMESPACE = 'internal';\nexport const INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAME =\n 'Install dependencies and compile custom function modules';\n\nexport function createBuildFunctionToInstallDependenciesAndCompileCustomFunctionModules(\n customFunctions: BuildFunction[]\n): BuildFunction {\n return new BuildFunction({\n namespace: INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAMESPACE,\n id: INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_ID,\n name: INSTALL_DEPENDENCIES_AND_COMPILE_CUSTOM_FUNCTION_MODULES_NAME,\n // eslint-disable-next-line async-protect/async-suffix\n fn: async (ctx, { env }) => {\n for (const customFunction of customFunctions) {\n assert(customFunction.customFunctionModulePath, 'customFunctionModulePath');\n const packageManager = resolvePackageManagerForCustomFunction(\n customFunction.customFunctionModulePath\n );\n ctx.logger.info(\n `Detected package manager ${packageManager} for custom function ${customFunction.id}`\n );\n\n ctx.logger.info(`Installing dependencies for custom function ${customFunction.id}...`);\n await spawnAsync(packageManager, ['install'], {\n cwd: customFunction.customFunctionModulePath,\n logger: ctx.logger,\n env,\n });\n\n ctx.logger.info(`Compiling custom function ${customFunction.id}...`);\n await spawnAsync(packageManager, ['run', 'build'], {\n cwd: customFunction.customFunctionModulePath,\n logger: ctx.logger,\n env,\n });\n }\n },\n });\n}\n\nenum PackageManager {\n YARN = 'yarn',\n NPM = 'npm',\n PNPM = 'pnpm',\n}\n\nfunction resolvePackageManagerForCustomFunction(customFunctionModulePath: string): PackageManager {\n try {\n const manager = resolvePackageManager(customFunctionModulePath);\n\n if (manager === 'npm') {\n return PackageManager.NPM;\n } else if (manager === 'pnpm') {\n return PackageManager.PNPM;\n } else {\n return PackageManager.YARN;\n }\n } catch {\n return PackageManager.YARN;\n }\n}\n"]}
@@ -1,11 +1,15 @@
1
1
  export declare const BUILD_STEP_INPUT_EXPRESSION_REGEXP: RegExp;
2
2
  export declare const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP: RegExp;
3
+ export declare const BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP: RegExp;
4
+ export declare const BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX: RegExp;
3
5
  export declare function interpolateWithInputs(templateString: string, inputs: Record<string, string>): string;
4
6
  export declare function interpolateWithOutputs(templateString: string, fn: (path: string) => string): string;
7
+ export declare function getObjectValueForInterpolation(path: string, obj: Record<string, any>): string | number | boolean | null;
8
+ export declare function interpolateWithGlobalContext(templateString: string, fn: (path: string) => string): string;
5
9
  interface BuildOutputPath {
6
10
  stepId: string;
7
11
  outputId: string;
8
12
  }
9
13
  export declare function findOutputPaths(templateString: string): BuildOutputPath[];
10
- export declare function parseOutputPath(outputPath: string): BuildOutputPath;
14
+ export declare function parseOutputPath(outputPathWithObjectName: string): BuildOutputPath;
11
15
  export {};
@@ -1,13 +1,33 @@
1
- import { BuildConfigError } from '../errors.js';
1
+ import get from 'lodash.get';
2
+ import { BuildStepInputValueTypeName } from '../BuildStepInput.js';
3
+ import { BuildConfigError, BuildStepRuntimeError } from '../errors.js';
2
4
  import { nullthrows } from './nullthrows.js';
3
- export const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*inputs\.([\S]+)\s*}/;
4
- export const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*steps\.([\S]+)\s*}/;
5
+ export const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*(inputs\.[\S]+)\s*}/;
6
+ export const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*(steps\.[\S]+)\s*}/;
7
+ export const BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = /\${\s*(eas\.[\S]+)\s*}/;
8
+ export const BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = /\${\s*((steps|eas)\.[\S]+)\s*}/;
5
9
  export function interpolateWithInputs(templateString, inputs) {
6
10
  return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);
7
11
  }
8
12
  export function interpolateWithOutputs(templateString, fn) {
9
13
  return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);
10
14
  }
15
+ export function getObjectValueForInterpolation(path, obj) {
16
+ const value = get(obj, path);
17
+ if (value === undefined) {
18
+ throw new BuildStepRuntimeError(`Object field "${path}" does not exist. Ensure you are using the correct field name.`);
19
+ }
20
+ if (!isAllowedValueTypeForObjectInterpolation(value)) {
21
+ throw new BuildStepRuntimeError(`EAS context field "${path}" is not of type ${Object.values(BuildStepInputValueTypeName).join(', ')}, or undefined. It is of type "${typeof value}". We currently only support accessing string or undefined values from the EAS context.`);
22
+ }
23
+ if (value !== null && typeof value === 'object') {
24
+ return JSON.stringify(value);
25
+ }
26
+ return value;
27
+ }
28
+ export function interpolateWithGlobalContext(templateString, fn) {
29
+ return interpolate(templateString, BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP, fn);
30
+ }
11
31
  function interpolate(templateString, regex, varsOrFn) {
12
32
  const matched = templateString.match(new RegExp(regex, 'g'));
13
33
  if (!matched) {
@@ -15,12 +35,19 @@ function interpolate(templateString, regex, varsOrFn) {
15
35
  }
16
36
  let result = templateString;
17
37
  for (const match of matched) {
18
- const [, key] = nullthrows(match.match(regex));
19
- const value = typeof varsOrFn === 'function' ? varsOrFn(key) : varsOrFn[key];
38
+ const [, path] = nullthrows(match.match(regex));
39
+ const value = typeof varsOrFn === 'function' ? varsOrFn(path) : varsOrFn[path.split('.')[1]];
20
40
  result = result.replace(match, value);
21
41
  }
22
42
  return result;
23
43
  }
44
+ function isAllowedValueTypeForObjectInterpolation(value) {
45
+ return (typeof value === 'string' ||
46
+ typeof value === 'number' ||
47
+ typeof value === 'boolean' ||
48
+ typeof value === 'object' ||
49
+ value === null);
50
+ }
24
51
  export function findOutputPaths(templateString) {
25
52
  const result = [];
26
53
  const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));
@@ -29,10 +56,10 @@ export function findOutputPaths(templateString) {
29
56
  }
30
57
  return result;
31
58
  }
32
- export function parseOutputPath(outputPath) {
33
- const splits = outputPath.split('.');
59
+ export function parseOutputPath(outputPathWithObjectName) {
60
+ const splits = outputPathWithObjectName.split('.').slice(1);
34
61
  if (splits.length !== 2) {
35
- throw new BuildConfigError(`Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. "step3.output1". Passed: "${outputPath}"`);
62
+ throw new BuildConfigError(`Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. "step3.output1". Passed: "${outputPathWithObjectName}"`);
36
63
  }
37
64
  const [stepId, outputId] = splits;
38
65
  return { stepId, outputId };
@@ -1 +1 @@
1
- {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,c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AM,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9F,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACxC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,UAAkB;IAChD,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAI,gBAAgB,CACxB,gKAAgK,UAAU,GAAG,CAC9K,CAAC;KACH;IACD,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import { BuildConfigError } from '../errors.js';\n\nimport { nullthrows } from './nullthrows.js';\n\nexport const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\\${\\s*inputs\\.([\\S]+)\\s*}/;\nexport const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\\${\\s*steps\\.([\\S]+)\\s*}/;\n\nexport function interpolateWithInputs(\n templateString: string,\n inputs: Record<string, string>\n): string {\n return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);\n}\n\nexport function interpolateWithOutputs(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);\n}\n\nfunction interpolate(\n templateString: string,\n regex: RegExp,\n varsOrFn: Record<string, string> | ((key: string) => string)\n): string {\n const matched = templateString.match(new RegExp(regex, 'g'));\n if (!matched) {\n return templateString;\n }\n let result = templateString;\n for (const match of matched) {\n const [, key] = nullthrows(match.match(regex));\n const value = typeof varsOrFn === 'function' ? varsOrFn(key) : varsOrFn[key];\n result = result.replace(match, value);\n }\n return result;\n}\n\ninterface BuildOutputPath {\n stepId: string;\n outputId: string;\n}\n\nexport function findOutputPaths(templateString: string): BuildOutputPath[] {\n const result: BuildOutputPath[] = [];\n const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));\n for (const match of matches) {\n result.push(parseOutputPath(match[1]));\n }\n return result;\n}\n\nexport function parseOutputPath(outputPath: string): BuildOutputPath {\n const splits = outputPath.split('.');\n if (splits.length !== 2) {\n throw new BuildConfigError(\n `Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. \"step3.output1\". Passed: \"${outputPath}\"`\n );\n }\n const [stepId, outputId] = splits;\n return { stepId, outputId };\n}\n"]}
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,YAAY,CAAC;AAE7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,MAAM,kCAAkC,GAAG,2BAA2B,CAAC;AAC9E,MAAM,CAAC,MAAM,mCAAmC,GAAG,0BAA0B,CAAC;AAC9E,MAAM,CAAC,MAAM,sCAAsC,GAAG,wBAAwB,CAAC;AAC/E,MAAM,CAAC,MAAM,kDAAkD,GAAG,gCAAgC,CAAC;AAEnG,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,MAA8B;IAE9B,OAAO,WAAW,CAAC,cAAc,EAAE,kCAAkC,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,cAAsB,EACtB,EAA4B;IAE5B,OAAO,WAAW,CAAC,cAAc,EAAE,mCAAmC,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,8BAA8B,C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Error } from '../errors.js';\n\nimport { nullthrows } from './nullthrows.js';\n\nexport const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\\${\\s*(inputs\\.[\\S]+)\\s*}/;\nexport const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\\${\\s*(steps\\.[\\S]+)\\s*}/;\nexport const BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = /\\${\\s*(eas\\.[\\S]+)\\s*}/;\nexport const BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = /\\${\\s*((steps|eas)\\.[\\S]+)\\s*}/;\n\nexport function interpolateWithInputs(\n templateString: string,\n inputs: Record<string, string>\n): string {\n return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);\n}\n\nexport function interpolateWithOutputs(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);\n}\n\nexport function getObjectValueForInterpolation(\n path: string,\n obj: Record<string, any>\n): string | number | boolean | null {\n const value = get(obj, path);\n\n if (value === undefined) {\n throw new BuildStepRuntimeError(\n `Object field \"${path}\" does not exist. Ensure you are using the correct field name.`\n );\n }\n\n if (!isAllowedValueTypeForObjectInterpolation(value)) {\n throw new BuildStepRuntimeError(\n `EAS context field \"${path}\" is not of type ${Object.values(BuildStepInputValueTypeName).join(\n ', '\n )}, or undefined. It is of type \"${typeof value}\". We currently only support accessing string or undefined values from the EAS context.`\n );\n }\n\n if (value !== null && typeof value === 'object') {\n return JSON.stringify(value);\n }\n\n return value;\n}\n\nexport function interpolateWithGlobalContext(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP, fn);\n}\n\nfunction interpolate(\n templateString: string,\n regex: RegExp,\n varsOrFn: Record<string, string> | ((key: string) => string)\n): string {\n const matched = templateString.match(new RegExp(regex, 'g'));\n if (!matched) {\n return templateString;\n }\n let result = templateString;\n for (const match of matched) {\n const [, path] = nullthrows(match.match(regex));\n const value = typeof varsOrFn === 'function' ? varsOrFn(path) : varsOrFn[path.split('.')[1]];\n result = result.replace(match, value);\n }\n return result;\n}\n\nfunction isAllowedValueTypeForObjectInterpolation(\n value: any\n): value is string | number | boolean | object | null {\n return (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'object' ||\n value === null\n );\n}\n\ninterface BuildOutputPath {\n stepId: string;\n outputId: string;\n}\n\nexport function findOutputPaths(templateString: string): BuildOutputPath[] {\n const result: BuildOutputPath[] = [];\n const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));\n for (const match of matches) {\n result.push(parseOutputPath(match[1]));\n }\n return result;\n}\n\nexport function parseOutputPath(outputPathWithObjectName: string): BuildOutputPath {\n const splits = outputPathWithObjectName.split('.').slice(1);\n if (splits.length !== 2) {\n throw new BuildConfigError(\n `Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. \"step3.output1\". Passed: \"${outputPathWithObjectName}\"`\n );\n }\n const [stepId, outputId] = splits;\n return { stepId, outputId };\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@expo/steps",
3
3
  "type": "module",
4
- "version": "1.0.23",
4
+ "version": "1.0.28",
5
5
  "main": "./dist_commonjs/index.cjs",
6
6
  "types": "./dist_esm/index.d.ts",
7
7
  "exports": {
@@ -33,6 +33,8 @@
33
33
  "devDependencies": {
34
34
  "@jest/globals": "^29.4.1",
35
35
  "@types/jest": "^29.4.0",
36
+ "@types/lodash.clonedeep": "^4.5.7",
37
+ "@types/lodash.get": "^4.4.7",
36
38
  "@types/node": "^18.11.18",
37
39
  "chokidar-cli": "^3.0.0",
38
40
  "eslint-plugin-async-protect": "^3.0.0",
@@ -47,9 +49,13 @@
47
49
  },
48
50
  "dependencies": {
49
51
  "@expo/logger": "1.0.21",
52
+ "@expo/package-manager": "^1.0.2",
50
53
  "@expo/spawn-async": "^1.7.0",
51
54
  "arg": "^5.0.2",
55
+ "fs-extra": "^11.1.1",
52
56
  "joi": "^17.7.0",
57
+ "lodash.clonedeep": "^4.5.0",
58
+ "lodash.get": "^4.4.2",
53
59
  "this-file": "^2.0.3",
54
60
  "uuid": "^9.0.0",
55
61
  "yaml": "^2.2.1"
@@ -58,5 +64,5 @@
58
64
  "node": "18.13.0",
59
65
  "yarn": "1.22.19"
60
66
  },
61
- "gitHead": "40fb0b2ffecf14b2cbd63dc51b910cf486351783"
67
+ "gitHead": "8882fcc1d594bc5a077e811408772085ad639590"
62
68
  }