@expo/steps 0.0.2 → 0.0.4

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 (65) hide show
  1. package/bin/set-output +2 -0
  2. package/bin/upload-artifact +12 -0
  3. package/dist_commonjs/BuildArtifacts.cjs +9 -0
  4. package/dist_commonjs/BuildArtifacts.d.ts +5 -0
  5. package/dist_commonjs/BuildArtifacts.js.map +1 -0
  6. package/dist_commonjs/BuildConfigParser.cjs +3 -3
  7. package/dist_commonjs/BuildConfigParser.js.map +1 -1
  8. package/dist_commonjs/BuildStep.cjs +17 -12
  9. package/dist_commonjs/BuildStep.d.ts +2 -1
  10. package/dist_commonjs/BuildStep.js.map +1 -1
  11. package/dist_commonjs/BuildStepEnv.cjs +3 -0
  12. package/dist_commonjs/BuildStepEnv.d.ts +1 -0
  13. package/dist_commonjs/BuildStepEnv.js.map +1 -0
  14. package/dist_commonjs/BuildTemporaryFiles.cjs +100 -0
  15. package/dist_commonjs/BuildTemporaryFiles.d.ts +8 -0
  16. package/dist_commonjs/BuildTemporaryFiles.js.map +1 -0
  17. package/dist_commonjs/BuildWorkflow.cjs +17 -3
  18. package/dist_commonjs/BuildWorkflow.d.ts +8 -2
  19. package/dist_commonjs/BuildWorkflow.js.map +1 -1
  20. package/dist_commonjs/bin/uploadArtifact.cjs +30 -0
  21. package/dist_commonjs/bin/uploadArtifact.d.ts +1 -0
  22. package/dist_commonjs/bin/uploadArtifact.js.map +1 -0
  23. package/dist_commonjs/cli/cli.cjs +4 -0
  24. package/dist_commonjs/cli/cli.js.map +1 -1
  25. package/dist_commonjs/errors/BuildInternalError.cjs +7 -0
  26. package/dist_commonjs/errors/BuildInternalError.d.ts +2 -0
  27. package/dist_commonjs/errors/BuildInternalError.js.map +1 -0
  28. package/dist_commonjs/index.cjs +3 -1
  29. package/dist_commonjs/index.d.ts +1 -0
  30. package/dist_commonjs/index.js.map +1 -1
  31. package/dist_esm/BuildArtifacts.d.ts +5 -0
  32. package/dist_esm/BuildArtifacts.js +6 -0
  33. package/dist_esm/BuildArtifacts.js.map +1 -0
  34. package/dist_esm/BuildConfigParser.js +3 -3
  35. package/dist_esm/BuildConfigParser.js.map +1 -1
  36. package/dist_esm/BuildStep.d.ts +2 -1
  37. package/dist_esm/BuildStep.js +15 -10
  38. package/dist_esm/BuildStep.js.map +1 -1
  39. package/dist_esm/BuildStepEnv.d.ts +1 -0
  40. package/dist_esm/BuildStepEnv.js +2 -0
  41. package/dist_esm/BuildStepEnv.js.map +1 -0
  42. package/dist_esm/BuildTemporaryFiles.d.ts +8 -0
  43. package/dist_esm/BuildTemporaryFiles.js +88 -0
  44. package/dist_esm/BuildTemporaryFiles.js.map +1 -0
  45. package/dist_esm/BuildWorkflow.d.ts +8 -2
  46. package/dist_esm/BuildWorkflow.js +17 -3
  47. package/dist_esm/BuildWorkflow.js.map +1 -1
  48. package/dist_esm/bin/uploadArtifact.d.ts +1 -0
  49. package/dist_esm/bin/uploadArtifact.js +25 -0
  50. package/dist_esm/bin/uploadArtifact.js.map +1 -0
  51. package/dist_esm/cli/cli.js +4 -0
  52. package/dist_esm/cli/cli.js.map +1 -1
  53. package/dist_esm/errors/BuildInternalError.d.ts +2 -0
  54. package/dist_esm/errors/BuildInternalError.js +3 -0
  55. package/dist_esm/errors/BuildInternalError.js.map +1 -0
  56. package/dist_esm/index.d.ts +1 -0
  57. package/dist_esm/index.js +1 -0
  58. package/dist_esm/index.js.map +1 -1
  59. package/package.json +2 -1
  60. package/dist_commonjs/utils/shell/temporaryFiles.cjs +0 -42
  61. package/dist_commonjs/utils/shell/temporaryFiles.d.ts +0 -4
  62. package/dist_commonjs/utils/shell/temporaryFiles.js.map +0 -1
  63. package/dist_esm/utils/shell/temporaryFiles.d.ts +0 -4
  64. package/dist_esm/utils/shell/temporaryFiles.js +0 -33
  65. package/dist_esm/utils/shell/temporaryFiles.js.map +0 -1
package/bin/set-output CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
+ set -eo pipefail
4
+
3
5
  NAME=$1
4
6
  VALUE=$2
5
7
 
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -eo pipefail
4
+
5
+ if [[ -z "$__EXPO_STEPS_BUILD_ID" || -z "$__EXPO_STEPS_WORKING_DIRECTORY" ]]; then
6
+ echo "Set __EXPO_STEPS_BUILD_ID and __EXPO_STEPS_WORKING_DIRECTORY"
7
+ exit 1
8
+ fi
9
+
10
+ STEPS_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. && pwd )"
11
+
12
+ node $STEPS_ROOT_DIR/dist_commonjs/bin/uploadArtifact.cjs $@
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BuildArtifactType = void 0;
4
+ var BuildArtifactType;
5
+ (function (BuildArtifactType) {
6
+ BuildArtifactType["APPLICATION_ARCHIVE"] = "application-archive";
7
+ BuildArtifactType["BUILD_ARTIFACT"] = "build-artifact";
8
+ })(BuildArtifactType = exports.BuildArtifactType || (exports.BuildArtifactType = {}));
9
+ //# sourceMappingURL=BuildArtifacts.js.map
@@ -0,0 +1,5 @@
1
+ export declare enum BuildArtifactType {
2
+ APPLICATION_ARCHIVE = "application-archive",
3
+ BUILD_ARTIFACT = "build-artifact"
4
+ }
5
+ export type BuildArtifacts = Partial<Record<BuildArtifactType, string[]>>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildArtifacts.js","sourceRoot":"","sources":["../src/BuildArtifacts.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,gEAA2C,CAAA;IAC3C,sDAAiC,CAAA;AACnC,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B","sourcesContent":["export enum BuildArtifactType {\n APPLICATION_ARCHIVE = 'application-archive',\n BUILD_ARTIFACT = 'build-artifact',\n}\n\nexport type BuildArtifacts = Partial<Record<BuildArtifactType, string[]>>;\n"]}
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BuildConfigParser = void 0;
7
- const fs_1 = __importDefault(require("fs"));
7
+ const promises_1 = __importDefault(require("fs/promises"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const uuid_1 = require("uuid");
10
10
  const yaml_1 = __importDefault(require("yaml"));
@@ -23,12 +23,12 @@ class BuildConfigParser {
23
23
  const rawConfig = await this.readRawConfigAsync();
24
24
  const config = (0, BuildConfig_js_1.validateBuildConfig)(rawConfig);
25
25
  const steps = config.build.steps.map((stepConfig) => this.createBuildStepFromConfig(stepConfig));
26
- const workflow = new BuildWorkflow_js_1.BuildWorkflow({ buildSteps: steps });
26
+ const workflow = new BuildWorkflow_js_1.BuildWorkflow(this.ctx, { buildSteps: steps });
27
27
  new BuildWorkflowValidator_js_1.BuildWorkflowValidator(workflow).validate();
28
28
  return workflow;
29
29
  }
30
30
  async readRawConfigAsync() {
31
- const contents = await fs_1.default.promises.readFile(this.configPath, 'utf-8');
31
+ const contents = await promises_1.default.readFile(this.configPath, 'utf-8');
32
32
  return yaml_1.default.parse(contents);
33
33
  }
34
34
  createBuildStepFromConfig(buildStepConfig) {
@@ -1 +1 @@
1
- {"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAExB,+BAAoC;AACpC,gDAAwB;AAExB,qDAK0B;AAC1B,iDAA2C;AAE3C,2DAAqD;AACrD,6DAAuD;AACvD,yDAAmD;AACnD,2EAAqE;AAErE,MAAa,iBAAiB;IAG5B,YAA6B,GAAqB,EAAE,EAAE,UAAU,EAA0B;QAA7D,QAAG,GAAH,GAAG,CAAkB;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAE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EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACtE,CAAC,CAAC,IAAI,oCAAe,CAAC,IAAI,CAAC,GAAG,EAAE;oBAC5B,EAAE,EAAE,KAAK,CAAC,IAAI;oBACd,MAAM;oBACN,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,mCAAI,IAAI;iBACjC,CAAC,CAAA;SAAA,CACP,CAAC;IACJ,CAAC;CACF;AA3FD,8CA2FC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\nimport YAML from 'yaml';\n\nimport {\n BuildStepConfig,\n BuildStepInputsConfig,\n BuildStepOutputsConfig,\n validateBuildConfig,\n} from './BuildConfig.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInput } from './BuildStepInput.js';\nimport { BuildStepOutput } from './BuildStepOutput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildWorkflowValidator } from './BuildWorkflowValidator.js';\n\nexport class BuildConfigParser {\n private readonly configPath: string;\n\n constructor(private readonly ctx: BuildStepContext, { configPath }: { configPath: string }) {\n this.configPath = configPath;\n }\n\n public async parseAsync(): Promise<BuildWorkflow> {\n const rawConfig = await this.readRawConfigAsync();\n const config = validateBuildConfig(rawConfig);\n const steps = config.build.steps.map((stepConfig) =>\n this.createBuildStepFromConfig(stepConfig)\n );\n const workflow = new BuildWorkflow({ buildSteps: steps });\n new BuildWorkflowValidator(workflow).validate();\n return workflow;\n }\n\n private async readRawConfigAsync(): Promise<any> {\n const contents = await fs.promises.readFile(this.configPath, 'utf-8');\n return YAML.parse(contents);\n }\n\n private createBuildStepFromConfig(buildStepConfig: BuildStepConfig): BuildStep {\n if (typeof buildStepConfig === 'string') {\n // TODO: implement calling functions\n throw new Error('Not implemented yet');\n } else if (typeof buildStepConfig.run === 'string') {\n const command = buildStepConfig.run;\n return new BuildStep(this.ctx, {\n id: uuidv4(),\n workingDirectory: this.ctx.workingDirectory,\n command,\n });\n } else {\n const {\n id,\n inputs: inputsConfig,\n outputs: outputsConfig,\n name,\n workingDirectory,\n shell,\n command,\n } = buildStepConfig.run;\n const stepId = id ?? uuidv4();\n const inputs = inputsConfig && this.createBuildStepInputsFromConfig(inputsConfig, stepId);\n const outputs = outputsConfig && this.createBuildStepOutputsFromConfig(outputsConfig, stepId);\n return new BuildStep(this.ctx, {\n id: stepId,\n inputs,\n outputs,\n name,\n workingDirectory:\n workingDirectory !== undefined\n ? path.resolve(this.ctx.workingDirectory, workingDirectory)\n : this.ctx.workingDirectory,\n shell,\n command,\n });\n }\n }\n\n private createBuildStepInputsFromConfig(\n buildStepInputsConfig: BuildStepInputsConfig,\n stepId: string\n ): BuildStepInput[] {\n return Object.entries(buildStepInputsConfig).map(\n ([key, value]) =>\n new BuildStepInput(this.ctx, {\n id: key,\n stepId,\n defaultValue: value,\n required: true,\n })\n );\n }\n\n private createBuildStepOutputsFromConfig(\n buildStepOutputsConfig: BuildStepOutputsConfig,\n stepId: string\n ): BuildStepOutput[] {\n return buildStepOutputsConfig.map((entry) =>\n typeof entry === 'string'\n ? new BuildStepOutput(this.ctx, { id: entry, stepId, required: true })\n : new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepId,\n required: entry.required ?? true,\n })\n );\n }\n}\n"]}
1
+ {"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AAExB,+BAAoC;AACpC,gDAAwB;AAExB,qDAK0B;AAC1B,iDAA2C;AAE3C,2DAAqD;AACrD,6DAAuD;AACvD,yDAAmD;AACnD,2EAAqE;AAErE,MAAa,iBAAiB;IAG5B,YAA6B,GAAqB,EAAE,EAAE,UAAU,EAA0B;QAA7D,QAAG,GAAH,GAAG,CAAkB;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,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AI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACtE,CAAC,CAAC,IAAI,oCAAe,CAAC,IAAI,CAAC,GAAG,EAAE;oBAC5B,EAAE,EAAE,KAAK,CAAC,IAAI;oBACd,MAAM;oBACN,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,mCAAI,IAAI;iBACjC,CAAC,CAAA;SAAA,CACP,CAAC;IACJ,CAAC;CACF;AA3FD,8CA2FC","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\nimport YAML from 'yaml';\n\nimport {\n BuildStepConfig,\n BuildStepInputsConfig,\n BuildStepOutputsConfig,\n validateBuildConfig,\n} from './BuildConfig.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInput } from './BuildStepInput.js';\nimport { BuildStepOutput } from './BuildStepOutput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildWorkflowValidator } from './BuildWorkflowValidator.js';\n\nexport class BuildConfigParser {\n private readonly configPath: string;\n\n constructor(private readonly ctx: BuildStepContext, { configPath }: { configPath: string }) {\n this.configPath = configPath;\n }\n\n public async parseAsync(): Promise<BuildWorkflow> {\n const rawConfig = await this.readRawConfigAsync();\n const config = validateBuildConfig(rawConfig);\n const steps = config.build.steps.map((stepConfig) =>\n this.createBuildStepFromConfig(stepConfig)\n );\n const workflow = new BuildWorkflow(this.ctx, { buildSteps: steps });\n new BuildWorkflowValidator(workflow).validate();\n return workflow;\n }\n\n private async readRawConfigAsync(): Promise<any> {\n const contents = await fs.readFile(this.configPath, 'utf-8');\n return YAML.parse(contents);\n }\n\n private createBuildStepFromConfig(buildStepConfig: BuildStepConfig): BuildStep {\n if (typeof buildStepConfig === 'string') {\n // TODO: implement calling functions\n throw new Error('Not implemented yet');\n } else if (typeof buildStepConfig.run === 'string') {\n const command = buildStepConfig.run;\n return new BuildStep(this.ctx, {\n id: uuidv4(),\n workingDirectory: this.ctx.workingDirectory,\n command,\n });\n } else {\n const {\n id,\n inputs: inputsConfig,\n outputs: outputsConfig,\n name,\n workingDirectory,\n shell,\n command,\n } = buildStepConfig.run;\n const stepId = id ?? uuidv4();\n const inputs = inputsConfig && this.createBuildStepInputsFromConfig(inputsConfig, stepId);\n const outputs = outputsConfig && this.createBuildStepOutputsFromConfig(outputsConfig, stepId);\n return new BuildStep(this.ctx, {\n id: stepId,\n inputs,\n outputs,\n name,\n workingDirectory:\n workingDirectory !== undefined\n ? path.resolve(this.ctx.workingDirectory, workingDirectory)\n : this.ctx.workingDirectory,\n shell,\n command,\n });\n }\n }\n\n private createBuildStepInputsFromConfig(\n buildStepInputsConfig: BuildStepInputsConfig,\n stepId: string\n ): BuildStepInput[] {\n return Object.entries(buildStepInputsConfig).map(\n ([key, value]) =>\n new BuildStepInput(this.ctx, {\n id: key,\n stepId,\n defaultValue: value,\n required: true,\n })\n );\n }\n\n private createBuildStepOutputsFromConfig(\n buildStepOutputsConfig: BuildStepOutputsConfig,\n stepId: string\n ): BuildStepOutput[] {\n return buildStepOutputsConfig.map((entry) =>\n typeof entry === 'string'\n ? new BuildStepOutput(this.ctx, { id: entry, stepId, required: true })\n : new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepId,\n required: entry.required ?? true,\n })\n );\n }\n}\n"]}
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.BuildStep = exports.BuildStepLogMarker = exports.BuildStepStatus = void 0;
7
- const fs_1 = __importDefault(require("fs"));
7
+ const promises_1 = __importDefault(require("fs/promises"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const uuid_1 = require("uuid");
10
10
  const bin_js_1 = require("./utils/shell/bin.cjs");
11
11
  const command_js_1 = require("./utils/shell/command.cjs");
12
- const temporaryFiles_js_1 = require("./utils/shell/temporaryFiles.cjs");
12
+ const BuildTemporaryFiles_js_1 = require("./BuildTemporaryFiles.cjs");
13
13
  const spawn_js_1 = require("./utils/shell/spawn.cjs");
14
14
  const template_js_1 = require("./utils/template.cjs");
15
15
  const BuildStepRuntimeError_js_1 = require("./errors/BuildStepRuntimeError.cjs");
@@ -55,22 +55,22 @@ class BuildStep {
55
55
  });
56
56
  ctx.registerStep(this);
57
57
  }
58
- async executeAsync() {
58
+ async executeAsync(env = process.env) {
59
59
  try {
60
60
  this.logger.info({ marker: BuildStepLogMarker.START_STEP }, `Executing build step "${this.id}"`);
61
61
  this.status = BuildStepStatus.IN_PROGRESS;
62
62
  const command = this.interpolateInputsInCommand(this.command, this.inputs);
63
63
  this.logger.debug(`Interpolated inputs in the command template`);
64
- const outputsDir = await (0, temporaryFiles_js_1.createTemporaryOutputsDirectoryAsync)(this.ctx, this.id);
64
+ const outputsDir = await (0, BuildTemporaryFiles_js_1.createTemporaryOutputsDirectoryAsync)(this.ctx, this.id);
65
65
  this.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);
66
- const scriptPath = await (0, temporaryFiles_js_1.saveScriptToTemporaryFileAsync)(this.ctx, this.id, command);
66
+ const scriptPath = await (0, BuildTemporaryFiles_js_1.saveScriptToTemporaryFileAsync)(this.ctx, this.id, command);
67
67
  this.logger.debug(`Saved script to ${scriptPath}`);
68
68
  const { command: shellCommand, args } = (0, command_js_1.getShellCommandAndArgs)(this.shell, scriptPath);
69
69
  this.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
70
70
  await (0, spawn_js_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
71
71
  cwd: this.workingDirectory,
72
72
  logger: this.logger,
73
- env: this.getScriptEnv(outputsDir),
73
+ env: this.getScriptEnv(env, outputsDir),
74
74
  });
75
75
  this.logger.debug(`Script completed successfully`);
76
76
  await this.collectAndValidateOutputsAsync(outputsDir);
@@ -86,7 +86,7 @@ class BuildStep {
86
86
  }
87
87
  finally {
88
88
  this.executed = true;
89
- await (0, temporaryFiles_js_1.cleanUpTemporaryDirectoriesAsync)(this.ctx, this.id);
89
+ await (0, BuildTemporaryFiles_js_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx, this.id);
90
90
  }
91
91
  }
92
92
  hasOutputParameter(name) {
@@ -114,7 +114,7 @@ class BuildStep {
114
114
  }
115
115
  async collectAndValidateOutputsAsync(outputsDir) {
116
116
  var _a;
117
- const files = await fs_1.default.promises.readdir(outputsDir);
117
+ const files = await promises_1.default.readdir(outputsDir);
118
118
  const nonDefinedOutputIds = [];
119
119
  for (const outputId of files) {
120
120
  if (!(outputId in this.outputById)) {
@@ -122,7 +122,7 @@ class BuildStep {
122
122
  }
123
123
  else {
124
124
  const file = path_1.default.join(outputsDir, outputId);
125
- const rawContents = await fs_1.default.promises.readFile(file, 'utf-8');
125
+ const rawContents = await promises_1.default.readFile(file, 'utf-8');
126
126
  const value = rawContents.trim();
127
127
  this.outputById[outputId].set(value);
128
128
  }
@@ -147,11 +147,16 @@ class BuildStep {
147
147
  throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Some required output parameters have not been set: ${idsString}`, { metadata: { ids: nonSetRequiredOutputIds } });
148
148
  }
149
149
  }
150
- getScriptEnv(outputsDir) {
150
+ getScriptEnv(env, outputsDir) {
151
+ var _a;
152
+ const currentPath = (_a = env.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
153
+ const newPath = currentPath ? `${bin_js_1.BIN_PATH}:${currentPath}` : bin_js_1.BIN_PATH;
151
154
  return {
152
- ...process.env,
155
+ ...env,
156
+ __EXPO_STEPS_BUILD_ID: this.ctx.buildId,
153
157
  __EXPO_STEPS_OUTPUTS_DIR: outputsDir,
154
- PATH: `${bin_js_1.BIN_PATH}:${process.env.PATH}`,
158
+ __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,
159
+ PATH: newPath,
155
160
  };
156
161
  }
157
162
  getStepDisplayName(name, command) {
@@ -1,6 +1,7 @@
1
1
  import { BuildStepContext } from './BuildStepContext.js';
2
2
  import { BuildStepInput } from './BuildStepInput.js';
3
3
  import { BuildStepOutput } from './BuildStepOutput.js';
4
+ import { BuildStepEnv } from './BuildStepEnv.js';
4
5
  export declare enum BuildStepStatus {
5
6
  NEW = "new",
6
7
  IN_PROGRESS = "in-progress",
@@ -37,7 +38,7 @@ export declare class BuildStep {
37
38
  workingDirectory: string;
38
39
  shell?: string;
39
40
  });
40
- executeAsync(): Promise<void>;
41
+ executeAsync(env?: BuildStepEnv): Promise<void>;
41
42
  hasOutputParameter(name: string): boolean;
42
43
  getOutputValueByName(name: string): string | undefined;
43
44
  private interpolateInputsInCommand;
@@ -1 +1 @@
1
- {"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAGxB,+BAAoC;AAKpC,iDAAgD;AAChD,yDAAmF;AACnF,uEAIyC;AACzC,qDAAoD;AACpD,qDAA4D;AAC5D,gFAA0E;AAE1E,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAO1B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B;AAED,MAAa,SAAS;IAgBpB,YACmB,GAAqB,EACtC,EACE,EAAE,EACF,IAAI,EACJ,MAAM,EACN,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,KAAK,GASN;QAjBgB,QAAG,GAAH,GAAG,CAAkB;QAHhC,aAAQ,GAAG,KAAK,CAAC;QAsB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,EAAE;SACxC,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,IAAwB,EAAE,OAAe;QAClE,IAAI,IAAI,EAAE;YACR,OAAO,IAAI,CAAC;SACb;QACD,IAAI,OAAO,KAAK,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;gBAC7B,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;oBACvC,OAAO,OAAO,CAAC;iBAChB;aACF;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA1MD,8BA0MC","sourcesContent":["import fs from 'fs';\nimport path from 'path';\n\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInput } from './BuildStepInput.js';\nimport { BuildStepOutput } from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpTemporaryDirectoriesAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './utils/shell/temporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport { interpolateWithInputs } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n CANCELED = 'canceled',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport class BuildStep {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName?: string;\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command: string;\n public readonly workingDirectory: string;\n public readonly shell: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly logger: bunyan;\n private readonly outputById: Record<string, BuildStepOutput>;\n private executed = false;\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n name,\n inputs,\n outputs,\n command,\n workingDirectory,\n shell,\n }: {\n id: string;\n name?: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command: string;\n workingDirectory: string;\n shell?: string;\n }\n ) {\n this.id = id;\n this.name = name;\n this.displayName = this.getStepDisplayName(name, command);\n this.inputs = inputs;\n this.outputs = outputs;\n this.outputById =\n outputs === undefined\n ? {}\n : outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as Record<string, BuildStepOutput>);\n this.command = command;\n this.workingDirectory = workingDirectory;\n this.shell = shell ?? getDefaultShell();\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n this.logger = ctx.logger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.id}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n const command = this.interpolateInputsInCommand(this.command, this.inputs);\n this.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx, this.id);\n this.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx, this.id, command);\n this.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.workingDirectory,\n logger: this.logger,\n env: this.getScriptEnv(outputsDir),\n });\n this.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n this.logger.debug('Finished collecting output paramters');\n\n this.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.id}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.logger.error({ err });\n this.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.id}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n await cleanUpTemporaryDirectoriesAsync(this.ctx, this.id);\n }\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.id}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.id}\" does not have output \"${name}\"`);\n }\n return this.outputById[name].value;\n }\n\n private interpolateInputsInCommand(command: string, inputs?: BuildStepInput[]): string {\n if (!inputs) {\n return command;\n }\n const vars = inputs.reduce((acc, input) => {\n acc[input.id] = input.value ?? '';\n return acc;\n }, {} as Record<string, string>);\n return interpolateWithInputs(command, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.promises.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.promises.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of this.outputs ?? []) {\n try {\n const value = output.value;\n this.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(\n `Some required output parameters have not been set: ${idsString}`,\n { metadata: { ids: nonSetRequiredOutputIds } }\n );\n }\n }\n\n private getScriptEnv(outputsDir: string): Record<string, string> {\n return {\n ...process.env,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n PATH: `${BIN_PATH}:${process.env.PATH}`,\n };\n }\n\n private getStepDisplayName(name: string | undefined, command: string): string | undefined {\n if (name) {\n return name;\n }\n if (command !== '') {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,2DAA6B;AAC7B,gDAAwB;AAGxB,+BAAoC;AAKpC,iDAAgD;AAChD,yDAAmF;AACnF,qEAIkC;AAClC,qDAAoD;AACpD,qDAA4D;AAC5D,gFAA0E;AAG1E,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,wCAAqB,CAAA;IACrB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAO1B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,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sDAAsD,SAAS,EAAE,EACjE,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,uBAAuB,EAAE,EAAE,CAC/C,CAAC;SACH;IACH,CAAC;IAEO,YAAY,CAAC,GAAiB,EAAE,UAAkB;;QACxD,MAAM,WAAW,GAAG,MAAA,GAAG,CAAC,IAAI,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,iBAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC;QACtE,OAAO;YACL,GAAG,GAAG;YACN,qBAAqB,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO;YACvC,wBAAwB,EAAE,UAAU;YACpC,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;IAEO,kBAAkB,CAAC,IAAwB,EAAE,OAAe;QAClE,IAAI,IAAI,EAAE;YACR,OAAO,IAAI,CAAC;SACb;QACD,IAAI,OAAO,KAAK,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC1C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;gBAC7B,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;oBACvC,OAAO,OAAO,CAAC;iBAChB;aACF;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA9MD,8BA8MC","sourcesContent":["import fs from 'fs/promises';\nimport path from 'path';\n\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInput } from './BuildStepInput.js';\nimport { BuildStepOutput } from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport { interpolateWithInputs } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n CANCELED = 'canceled',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport class BuildStep {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName?: string;\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command: string;\n public readonly workingDirectory: string;\n public readonly shell: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly logger: bunyan;\n private readonly outputById: Record<string, BuildStepOutput>;\n private executed = false;\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n name,\n inputs,\n outputs,\n command,\n workingDirectory,\n shell,\n }: {\n id: string;\n name?: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command: string;\n workingDirectory: string;\n shell?: string;\n }\n ) {\n this.id = id;\n this.name = name;\n this.displayName = this.getStepDisplayName(name, command);\n this.inputs = inputs;\n this.outputs = outputs;\n this.outputById =\n outputs === undefined\n ? {}\n : outputs.reduce((acc, output) => {\n acc[output.id] = output;\n return acc;\n }, {} as Record<string, BuildStepOutput>);\n this.command = command;\n this.workingDirectory = workingDirectory;\n this.shell = shell ?? getDefaultShell();\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n this.logger = ctx.logger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(env: BuildStepEnv = process.env): Promise<void> {\n try {\n this.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.id}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n const command = this.interpolateInputsInCommand(this.command, this.inputs);\n this.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx, this.id);\n this.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx, this.id, command);\n this.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.workingDirectory,\n logger: this.logger,\n env: this.getScriptEnv(env, outputsDir),\n });\n this.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n this.logger.debug('Finished collecting output paramters');\n\n this.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.id}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.logger.error({ err });\n this.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.id}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx, this.id);\n }\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.id}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.id}\" does not have output \"${name}\"`);\n }\n return this.outputById[name].value;\n }\n\n private interpolateInputsInCommand(command: string, inputs?: BuildStepInput[]): string {\n if (!inputs) {\n return command;\n }\n const vars = inputs.reduce((acc, input) => {\n acc[input.id] = input.value ?? '';\n return acc;\n }, {} as Record<string, string>);\n return interpolateWithInputs(command, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of this.outputs ?? []) {\n try {\n const value = output.value;\n this.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(\n `Some required output parameters have not been set: ${idsString}`,\n { metadata: { ids: nonSetRequiredOutputIds } }\n );\n }\n }\n\n private getScriptEnv(env: BuildStepEnv, outputsDir: string): Record<string, string> {\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_BUILD_ID: this.ctx.buildId,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n\n private getStepDisplayName(name: string | undefined, command: string): string | undefined {\n if (name) {\n return name;\n }\n if (command !== '') {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return undefined;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=BuildStepEnv.js.map
@@ -0,0 +1 @@
1
+ export type BuildStepEnv = Record<string, string | undefined>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildStepEnv.js","sourceRoot":"","sources":["../src/BuildStepEnv.ts"],"names":[],"mappings":"","sourcesContent":["export type BuildStepEnv = Record<string, string | undefined>;\n"]}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cleanUpWorkflowTemporaryDirectoriesAsync = exports.cleanUpStepTemporaryDirectoriesAsync = exports.findArtifactsByTypeAsync = exports.createTemporaryOutputsDirectoryAsync = exports.saveArtifactToTemporaryDirectoryAsync = exports.saveScriptToTemporaryFileAsync = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ const uuid_1 = require("uuid");
10
+ const BuildArtifacts_js_1 = require("./BuildArtifacts.cjs");
11
+ const BuildInternalError_js_1 = require("./errors/BuildInternalError.cjs");
12
+ async function saveScriptToTemporaryFileAsync(ctx, stepId, scriptContents) {
13
+ const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);
14
+ await promises_1.default.mkdir(scriptsDir, { recursive: true });
15
+ const temporaryScriptPath = path_1.default.join(scriptsDir, `${(0, uuid_1.v4)()}.sh`);
16
+ await promises_1.default.writeFile(temporaryScriptPath, scriptContents);
17
+ return temporaryScriptPath;
18
+ }
19
+ exports.saveScriptToTemporaryFileAsync = saveScriptToTemporaryFileAsync;
20
+ async function saveArtifactToTemporaryDirectoryAsync(ctx, type, artifactPath) {
21
+ let targetArtifactPath;
22
+ if (type === BuildArtifacts_js_1.BuildArtifactType.APPLICATION_ARCHIVE) {
23
+ targetArtifactPath = path_1.default.join(getTemporaryApplicationArchiveDirPath(ctx), path_1.default.basename(artifactPath));
24
+ }
25
+ else if (type === BuildArtifacts_js_1.BuildArtifactType.BUILD_ARTIFACT) {
26
+ targetArtifactPath = path_1.default.join(getTemporaryBuildArtifactsDirPath(ctx), path_1.default.basename(artifactPath));
27
+ }
28
+ else {
29
+ throw new BuildInternalError_js_1.BuildInternalError(`Uploading artifacts of type "${type}" is not implemented.`);
30
+ }
31
+ await promises_1.default.mkdir(path_1.default.dirname(targetArtifactPath), { recursive: true });
32
+ await promises_1.default.copyFile(artifactPath, targetArtifactPath);
33
+ return targetArtifactPath;
34
+ }
35
+ exports.saveArtifactToTemporaryDirectoryAsync = saveArtifactToTemporaryDirectoryAsync;
36
+ async function createTemporaryOutputsDirectoryAsync(ctx, stepId) {
37
+ const directory = getTemporaryOutputsDirPath(ctx, stepId);
38
+ await promises_1.default.mkdir(directory, { recursive: true });
39
+ return directory;
40
+ }
41
+ exports.createTemporaryOutputsDirectoryAsync = createTemporaryOutputsDirectoryAsync;
42
+ async function findArtifactsByTypeAsync(ctx, type) {
43
+ let artifactsDirPath;
44
+ if (type === BuildArtifacts_js_1.BuildArtifactType.APPLICATION_ARCHIVE) {
45
+ artifactsDirPath = getTemporaryApplicationArchiveDirPath(ctx);
46
+ }
47
+ else if (type === BuildArtifacts_js_1.BuildArtifactType.BUILD_ARTIFACT) {
48
+ artifactsDirPath = getTemporaryBuildArtifactsDirPath(ctx);
49
+ }
50
+ else {
51
+ throw new BuildInternalError_js_1.BuildInternalError(`Finding artifacts of type "${type}" is not implemented.`);
52
+ }
53
+ try {
54
+ const filenames = await promises_1.default.readdir(artifactsDirPath);
55
+ return filenames.map((filename) => path_1.default.join(artifactsDirPath, filename));
56
+ }
57
+ catch (err) {
58
+ ctx.logger.debug({ err }, `Failed reading artifacts of type "${type}" from "${artifactsDirPath}". The directory probably doesn't exist.`);
59
+ return [];
60
+ }
61
+ }
62
+ exports.findArtifactsByTypeAsync = findArtifactsByTypeAsync;
63
+ async function cleanUpStepTemporaryDirectoriesAsync(ctx, stepId) {
64
+ if (ctx.skipCleanup) {
65
+ return;
66
+ }
67
+ const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);
68
+ await promises_1.default.rm(stepTemporaryDirectory, { recursive: true });
69
+ ctx.logger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');
70
+ }
71
+ exports.cleanUpStepTemporaryDirectoriesAsync = cleanUpStepTemporaryDirectoriesAsync;
72
+ async function cleanUpWorkflowTemporaryDirectoriesAsync(ctx) {
73
+ if (ctx.skipCleanup) {
74
+ return;
75
+ }
76
+ const temporaryDirectories = [getTemporaryArtifactsDirPath(ctx)];
77
+ const rmPromises = temporaryDirectories.map((dir) => promises_1.default.rm(dir, { recursive: true }));
78
+ await Promise.all(rmPromises);
79
+ ctx.logger.debug({ temporaryDirectories }, 'Removed temporary directories');
80
+ }
81
+ exports.cleanUpWorkflowTemporaryDirectoriesAsync = cleanUpWorkflowTemporaryDirectoriesAsync;
82
+ function getTemporaryStepDirPath(ctx, stepId) {
83
+ return path_1.default.join(ctx.baseWorkingDirectory, 'steps', stepId);
84
+ }
85
+ function getTemporaryScriptsDirPath(ctx, stepId) {
86
+ return path_1.default.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');
87
+ }
88
+ function getTemporaryOutputsDirPath(ctx, stepId) {
89
+ return path_1.default.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');
90
+ }
91
+ function getTemporaryApplicationArchiveDirPath(ctx) {
92
+ return path_1.default.join(getTemporaryArtifactsDirPath(ctx), 'application-archive');
93
+ }
94
+ function getTemporaryBuildArtifactsDirPath(ctx) {
95
+ return path_1.default.join(getTemporaryArtifactsDirPath(ctx), 'build-artifacts');
96
+ }
97
+ function getTemporaryArtifactsDirPath(ctx) {
98
+ return path_1.default.join(ctx.baseWorkingDirectory, 'artifacts');
99
+ }
100
+ //# sourceMappingURL=BuildTemporaryFiles.js.map
@@ -0,0 +1,8 @@
1
+ import { BuildStepContext } from './BuildStepContext.js';
2
+ import { BuildArtifactType } from './BuildArtifacts.js';
3
+ export declare function saveScriptToTemporaryFileAsync(ctx: BuildStepContext, stepId: string, scriptContents: string): Promise<string>;
4
+ export declare function saveArtifactToTemporaryDirectoryAsync(ctx: BuildStepContext, type: BuildArtifactType, artifactPath: string): Promise<string>;
5
+ export declare function createTemporaryOutputsDirectoryAsync(ctx: BuildStepContext, stepId: string): Promise<string>;
6
+ export declare function findArtifactsByTypeAsync(ctx: BuildStepContext, type: BuildArtifactType): Promise<string[]>;
7
+ export declare function cleanUpStepTemporaryDirectoriesAsync(ctx: BuildStepContext, stepId: string): Promise<void>;
8
+ export declare function cleanUpWorkflowTemporaryDirectoriesAsync(ctx: BuildStepContext): Promise<void>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildTemporaryFiles.js","sourceRoot":"","sources":["../src/BuildTemporaryFiles.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,2DAA6B;AAE7B,+BAAoC;AAGpC,2DAAwD;AACxD,0EAAoE;AAE7D,KAAK,UAAU,8BAA8B,CAClD,GAAqB,EACrB,MAAc,EACd,cAAsB;IAEtB,MAAM,UAAU,GAAG,0BAA0B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,MAAM,kBAAE,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,IAAA,SAAM,GAAE,KAAK,CAAC,CAAC;IACpE,MAAM,kBAAE,CAAC,SAAS,C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Content":["import path from 'path';\nimport fs from 'fs/promises';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildArtifactType } from './BuildArtifacts.js';\nimport { BuildInternalError } from './errors/BuildInternalError.js';\n\nexport async function saveScriptToTemporaryFileAsync(\n ctx: BuildStepContext,\n stepId: string,\n scriptContents: string\n): Promise<string> {\n const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);\n await fs.mkdir(scriptsDir, { recursive: true });\n const temporaryScriptPath = path.join(scriptsDir, `${uuidv4()}.sh`);\n await fs.writeFile(temporaryScriptPath, scriptContents);\n return temporaryScriptPath;\n}\n\nexport async function saveArtifactToTemporaryDirectoryAsync(\n ctx: BuildStepContext,\n type: BuildArtifactType,\n artifactPath: string\n): Promise<string> {\n let targetArtifactPath: string;\n if (type === BuildArtifactType.APPLICATION_ARCHIVE) {\n targetArtifactPath = path.join(\n getTemporaryApplicationArchiveDirPath(ctx),\n path.basename(artifactPath)\n );\n } else if (type === BuildArtifactType.BUILD_ARTIFACT) {\n targetArtifactPath = path.join(\n getTemporaryBuildArtifactsDirPath(ctx),\n path.basename(artifactPath)\n );\n } else {\n throw new BuildInternalError(`Uploading artifacts of type \"${type}\" is not implemented.`);\n }\n\n await fs.mkdir(path.dirname(targetArtifactPath), { recursive: true });\n await fs.copyFile(artifactPath, targetArtifactPath);\n return targetArtifactPath;\n}\n\nexport async function createTemporaryOutputsDirectoryAsync(\n ctx: BuildStepContext,\n stepId: string\n): Promise<string> {\n const directory = getTemporaryOutputsDirPath(ctx, stepId);\n await fs.mkdir(directory, { recursive: true });\n return directory;\n}\n\nexport async function findArtifactsByTypeAsync(\n ctx: BuildStepContext,\n type: BuildArtifactType\n): Promise<string[]> {\n let artifactsDirPath: string;\n if (type === BuildArtifactType.APPLICATION_ARCHIVE) {\n artifactsDirPath = getTemporaryApplicationArchiveDirPath(ctx);\n } else if (type === BuildArtifactType.BUILD_ARTIFACT) {\n artifactsDirPath = getTemporaryBuildArtifactsDirPath(ctx);\n } else {\n throw new BuildInternalError(`Finding artifacts of type \"${type}\" is not implemented.`);\n }\n try {\n const filenames = await fs.readdir(artifactsDirPath);\n return filenames.map((filename) => path.join(artifactsDirPath, filename));\n } catch (err) {\n ctx.logger.debug(\n { err },\n `Failed reading artifacts of type \"${type}\" from \"${artifactsDirPath}\". The directory probably doesn't exist.`\n );\n return [];\n }\n}\n\nexport async function cleanUpStepTemporaryDirectoriesAsync(\n ctx: BuildStepContext,\n stepId: string\n): Promise<void> {\n if (ctx.skipCleanup) {\n return;\n }\n const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);\n await fs.rm(stepTemporaryDirectory, { recursive: true });\n ctx.logger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');\n}\n\nexport async function cleanUpWorkflowTemporaryDirectoriesAsync(\n ctx: BuildStepContext\n): Promise<void> {\n if (ctx.skipCleanup) {\n return;\n }\n\n const temporaryDirectories: string[] = [getTemporaryArtifactsDirPath(ctx)];\n const rmPromises = temporaryDirectories.map((dir) => fs.rm(dir, { recursive: true }));\n await Promise.all(rmPromises);\n ctx.logger.debug({ temporaryDirectories }, 'Removed temporary directories');\n}\n\nfunction getTemporaryStepDirPath(ctx: BuildStepContext, stepId: string): string {\n return path.join(ctx.baseWorkingDirectory, 'steps', stepId);\n}\n\nfunction getTemporaryScriptsDirPath(ctx: BuildStepContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');\n}\n\nfunction getTemporaryOutputsDirPath(ctx: BuildStepContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');\n}\n\nfunction getTemporaryApplicationArchiveDirPath(ctx: BuildStepContext): string {\n return path.join(getTemporaryArtifactsDirPath(ctx), 'application-archive');\n}\n\nfunction getTemporaryBuildArtifactsDirPath(ctx: BuildStepContext): string {\n return path.join(getTemporaryArtifactsDirPath(ctx), 'build-artifacts');\n}\n\nfunction getTemporaryArtifactsDirPath(ctx: BuildStepContext): string {\n return path.join(ctx.baseWorkingDirectory, 'artifacts');\n}\n"]}
@@ -1,15 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BuildWorkflow = void 0;
4
+ const BuildArtifacts_js_1 = require("./BuildArtifacts.cjs");
5
+ const BuildTemporaryFiles_js_1 = require("./BuildTemporaryFiles.cjs");
4
6
  class BuildWorkflow {
5
- constructor({ buildSteps }) {
7
+ constructor(ctx, { buildSteps }) {
8
+ this.ctx = ctx;
6
9
  this.buildSteps = buildSteps;
7
10
  }
8
- async executeAsync() {
11
+ async executeAsync(env = process.env) {
9
12
  for (const step of this.buildSteps) {
10
- await step.executeAsync();
13
+ await step.executeAsync(env);
11
14
  }
12
15
  }
16
+ async collectArtifactsAsync() {
17
+ const applicationArchives = await (0, BuildTemporaryFiles_js_1.findArtifactsByTypeAsync)(this.ctx, BuildArtifacts_js_1.BuildArtifactType.APPLICATION_ARCHIVE);
18
+ const buildArtifacts = await (0, BuildTemporaryFiles_js_1.findArtifactsByTypeAsync)(this.ctx, BuildArtifacts_js_1.BuildArtifactType.BUILD_ARTIFACT);
19
+ return {
20
+ [BuildArtifacts_js_1.BuildArtifactType.APPLICATION_ARCHIVE]: applicationArchives,
21
+ [BuildArtifacts_js_1.BuildArtifactType.BUILD_ARTIFACT]: buildArtifacts,
22
+ };
23
+ }
24
+ async cleanUpAsync() {
25
+ await (0, BuildTemporaryFiles_js_1.cleanUpWorkflowTemporaryDirectoriesAsync)(this.ctx);
26
+ }
13
27
  }
14
28
  exports.BuildWorkflow = BuildWorkflow;
15
29
  //# sourceMappingURL=BuildWorkflow.js.map
@@ -1,8 +1,14 @@
1
+ import { BuildArtifacts } from './BuildArtifacts.js';
1
2
  import { BuildStep } from './BuildStep.js';
3
+ import { BuildStepContext } from './BuildStepContext.js';
4
+ import { BuildStepEnv } from './BuildStepEnv.js';
2
5
  export declare class BuildWorkflow {
6
+ private readonly ctx;
3
7
  readonly buildSteps: BuildStep[];
4
- constructor({ buildSteps }: {
8
+ constructor(ctx: BuildStepContext, { buildSteps }: {
5
9
  buildSteps: BuildStep[];
6
10
  });
7
- executeAsync(): Promise<void>;
11
+ executeAsync(env?: BuildStepEnv): Promise<void>;
12
+ collectArtifactsAsync(): Promise<BuildArtifacts>;
13
+ cleanUpAsync(): Promise<void>;
8
14
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAGxB,YAAY,EAAE,UAAU,EAA+B;QACrD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YAClC,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;SAC3B;IACH,CAAC;CACF;AAZD,sCAYC","sourcesContent":["import { BuildStep } from './BuildStep.js';\n\nexport class BuildWorkflow {\n public readonly buildSteps: BuildStep[];\n\n constructor({ buildSteps }: { buildSteps: BuildStep[] }) {\n this.buildSteps = buildSteps;\n }\n\n public async executeAsync(): Promise<void> {\n for (const step of this.buildSteps) {\n await step.executeAsync();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":";;;AAAA,2DAAwE;AAIxE,qEAGkC;AAElC,MAAa,aAAa;IAGxB,YAA6B,GAAqB,EAAE,EAAE,UAAU,EAA+B;QAAlE,QAAG,GAAH,GAAG,CAAkB;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,MAAoB,OAAO,CAAC,GAAG;QACvD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE;YAClC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;SAC9B;IACH,CAAC;IAEM,KAAK,CAAC,qBAAqB;QAChC,MAAM,mBAAmB,GAAG,MAAM,IAAA,iDAAwB,EACxD,IAAI,CAAC,GAAG,EACR,qCAAiB,CAAC,mBAAmB,CACtC,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,IAAA,iDAAwB,EACnD,IAAI,CAAC,GAAG,EACR,qCAAiB,CAAC,cAAc,CACjC,CAAC;QACF,OAAO;YACL,CAAC,qCAAiB,CAAC,mBAAmB,CAAC,EAAE,mBAAmB;YAC5D,CAAC,qCAAiB,CAAC,cAAc,CAAC,EAAE,cAAc;SACnD,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,MAAM,IAAA,iEAAwC,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF;AA/BD,sCA+BC","sourcesContent":["import { BuildArtifacts, BuildArtifactType } from './BuildArtifacts.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport {\n cleanUpWorkflowTemporaryDirectoriesAsync,\n findArtifactsByTypeAsync,\n} from './BuildTemporaryFiles.js';\n\nexport class BuildWorkflow {\n public readonly buildSteps: BuildStep[];\n\n constructor(private readonly ctx: BuildStepContext, { buildSteps }: { buildSteps: BuildStep[] }) {\n this.buildSteps = buildSteps;\n }\n\n public async executeAsync(env: BuildStepEnv = process.env): Promise<void> {\n for (const step of this.buildSteps) {\n await step.executeAsync(env);\n }\n }\n\n public async collectArtifactsAsync(): Promise<BuildArtifacts> {\n const applicationArchives = await findArtifactsByTypeAsync(\n this.ctx,\n BuildArtifactType.APPLICATION_ARCHIVE\n );\n const buildArtifacts = await findArtifactsByTypeAsync(\n this.ctx,\n BuildArtifactType.BUILD_ARTIFACT\n );\n return {\n [BuildArtifactType.APPLICATION_ARCHIVE]: applicationArchives,\n [BuildArtifactType.BUILD_ARTIFACT]: buildArtifacts,\n };\n }\n\n public async cleanUpAsync(): Promise<void> {\n await cleanUpWorkflowTemporaryDirectoriesAsync(this.ctx);\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var _a;
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const path_1 = __importDefault(require("path"));
8
+ const logger_1 = require("@expo/logger");
9
+ const arg_1 = __importDefault(require("arg"));
10
+ const nullthrows_js_1 = require("../utils/nullthrows.cjs");
11
+ const BuildArtifacts_js_1 = require("../BuildArtifacts.cjs");
12
+ const BuildStepContext_js_1 = require("../BuildStepContext.cjs");
13
+ const BuildTemporaryFiles_js_1 = require("../BuildTemporaryFiles.cjs");
14
+ const args = (0, arg_1.default)({
15
+ '--type': String,
16
+ });
17
+ const artifactPathArg = (0, nullthrows_js_1.nullthrows)((_a = args._) === null || _a === void 0 ? void 0 : _a[0], 'upload-artifact must be run with the artifact path, e.g. "upload-artifact path/to/app.ipa"');
18
+ const artifactPath = path_1.default.resolve(process.cwd(), artifactPathArg);
19
+ const logger = (0, logger_1.createLogger)({
20
+ name: 'eas-build',
21
+ level: 'info',
22
+ });
23
+ const ctx = new BuildStepContext_js_1.BuildStepContext((0, nullthrows_js_1.nullthrows)(process.env.__EXPO_STEPS_BUILD_ID, 'Set __EXPO_STEPS_BUILD_ID.'), logger, false, (0, nullthrows_js_1.nullthrows)(process.env.__EXPO_STEPS_WORKING_DIRECTORY, 'Set __EXPO_STEPS_BUILD_ID.'));
24
+ const rawType = args['--type'];
25
+ const type = rawType !== null && rawType !== void 0 ? rawType : BuildArtifacts_js_1.BuildArtifactType.APPLICATION_ARCHIVE;
26
+ (0, BuildTemporaryFiles_js_1.saveArtifactToTemporaryDirectoryAsync)(ctx, type, artifactPath).catch((err) => {
27
+ console.error(`Failed preparing "${artifactPath}" for upload.`, err);
28
+ process.exit(2);
29
+ });
30
+ //# sourceMappingURL=uplo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AAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { createLogger } from '@expo/logger';\nimport arg from 'arg';\n\nimport { nullthrows } from '../utils/nullthrows.js';\nimport { BuildArtifactType } from '../BuildArtifacts.js';\nimport { BuildStepContext } from '../BuildStepContext.js';\nimport { saveArtifactToTemporaryDirectoryAsync } from '../BuildTemporaryFiles.js';\n\nconst args = arg({\n '--type': String,\n});\n\nconst artifactPathArg = nullthrows(\n args._?.[0],\n 'upload-artifact must be run with the artifact path, e.g. \"upload-artifact path/to/app.ipa\"'\n);\nconst artifactPath = path.resolve(process.cwd(), artifactPathArg);\n\nconst logger = createLogger({\n name: 'eas-build',\n level: 'info',\n});\n\nconst ctx = new BuildStepContext(\n nullthrows(process.env.__EXPO_STEPS_BUILD_ID, 'Set __EXPO_STEPS_BUILD_ID.'),\n logger,\n false,\n nullthrows(process.env.__EXPO_STEPS_WORKING_DIRECTORY, 'Set __EXPO_STEPS_BUILD_ID.')\n);\n\nconst rawType = args['--type'] as BuildArtifactType | undefined;\nconst type = rawType ?? BuildArtifactType.APPLICATION_ARCHIVE;\n\nsaveArtifactToTemporaryDirectoryAsync(ctx, type, artifactPath).catch((err) => {\n console.error(`Failed preparing \"${artifactPath}\" for upload.`, err);\n process.exit(2);\n});\n"]}
@@ -18,6 +18,10 @@ async function runAsync(configPath, workingDirectory) {
18
18
  const parser = new BuildConfigParser_js_1.BuildConfigParser(ctx, { configPath });
19
19
  const workflow = await parser.parseAsync();
20
20
  await workflow.executeAsync();
21
+ const artifacts = await workflow.collectArtifactsAsync();
22
+ if (Object.keys(artifacts).length > 0) {
23
+ logger.info({ artifacts }, 'The workflow produced artifacts');
24
+ }
21
25
  }
22
26
  const relativeConfigPath = process.argv[2];
23
27
  const relativeWorkingDirectoryPath = process.argv[3];
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;AAAA,g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CAAC,CAAC;AACxC,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';\n\nconst logger = createLogger({\n name: 'steps-cli',\n level: 'info',\n});\n\nasync function runAsync(configPath: string, workingDirectory: string): Promise<void> {\n const fakeBuildId = uuidv4();\n const ctx = new BuildStepContext(fakeBuildId, logger, false, workingDirectory);\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 relativeWorkingDirectoryPath = process.argv[3];\n\nif (!relativeConfigPath && !relativeWorkingDirectoryPath) {\n console.error('Usage: yarn cli config.yml path/to/working/directory');\n process.exit(1);\n}\n\nconst configPath = path.resolve(process.cwd(), relativeConfigPath);\nconst workingDirectory = path.resolve(process.cwd(), relativeWorkingDirectoryPath);\n\nrunAsync(configPath, workingDirectory).catch((err) => {\n logger.error({ err }, 'Build failed');\n});\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAExB,yCAA4C;AAC5C,+BAAoC;AAEpC,kEAA4D;AAC5D,gEAA0D;AAE1D,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC;IAC1B,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,MAAM;CACd,CAAC,CAAC;AAEH,KAAK,UAAU,QAAQ,CAAC,UAAkB,EAAE,gBAAwB;IAClE,MAAM,WAAW,GAAG,IAAA,SAAM,GAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,IAAI,sCAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,IAAI,wCAAiB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC3C,MAAM,QAAQ,CAAC,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,qBAAqB,EAAE,CAAC;IACzD,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACrC,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,EAAE,iCAAiC,CAAC,CAAC;KAC/D;AACH,CAAC;AAED,MAAM,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3C,MAAM,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAErD,IAAI,CAAC,kBAAkB,IAAI,CAAC,4BAA4B,EAAE;IACxD,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACnE,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,4BAA4B,CAAC,CAAC;AAEnF,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnD,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;AACxC,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';\n\nconst logger = createLogger({\n name: 'steps-cli',\n level: 'info',\n});\n\nasync function runAsync(configPath: string, workingDirectory: string): Promise<void> {\n const fakeBuildId = uuidv4();\n const ctx = new BuildStepContext(fakeBuildId, logger, false, workingDirectory);\n const parser = new BuildConfigParser(ctx, { configPath });\n const workflow = await parser.parseAsync();\n await workflow.executeAsync();\n const artifacts = await workflow.collectArtifactsAsync();\n if (Object.keys(artifacts).length > 0) {\n logger.info({ artifacts }, 'The workflow produced artifacts');\n }\n}\n\nconst relativeConfigPath = process.argv[2];\nconst relativeWorkingDirectoryPath = process.argv[3];\n\nif (!relativeConfigPath && !relativeWorkingDirectoryPath) {\n console.error('Usage: yarn cli config.yml path/to/working/directory');\n process.exit(1);\n}\n\nconst configPath = path.resolve(process.cwd(), relativeConfigPath);\nconst workingDirectory = path.resolve(process.cwd(), relativeWorkingDirectoryPath);\n\nrunAsync(configPath, workingDirectory).catch((err) => {\n logger.error({ err }, 'Build failed');\n});\n"]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BuildInternalError = void 0;
4
+ class BuildInternalError extends Error {
5
+ }
6
+ exports.BuildInternalError = BuildInternalError;
7
+ //# sourceMappingURL=BuildInternalError.js.map
@@ -0,0 +1,2 @@
1
+ export declare class BuildInternalError extends Error {
2
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildInternalError.js","sourceRoot":"","sources":["../../src/errors/BuildInternalError.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAmB,SAAQ,KAAK;CAAG;AAAhD,gDAAgD","sourcesContent":["export class BuildInternalError extends Error {}\n"]}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildStepContext = exports.BuildConfigParser = void 0;
3
+ exports.BuildStepContext = exports.BuildConfigParser = exports.BuildArtifactType = void 0;
4
+ var BuildArtifacts_js_1 = require("./BuildArtifacts.cjs");
5
+ Object.defineProperty(exports, "BuildArtifactType", { enumerable: true, get: function () { return BuildArtifacts_js_1.BuildArtifactType; } });
4
6
  var BuildConfigParser_js_1 = require("./BuildConfigParser.cjs");
5
7
  Object.defineProperty(exports, "BuildConfigParser", { enumerable: true, get: function () { return BuildConfigParser_js_1.BuildConfigParser; } });
6
8
  var BuildStepContext_js_1 = require("./BuildStepContext.cjs");
@@ -1,2 +1,3 @@
1
+ export { BuildArtifactType } from './BuildArtifacts.js';
1
2
  export { BuildConfigParser } from './BuildConfigParser.js';
2
3
  export { BuildStepContext } from './BuildStepContext.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA","sourcesContent":["export { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildStepContext } from './BuildStepContext.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA","sourcesContent":["export { BuildArtifactType } from './BuildArtifacts.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildStepContext } from './BuildStepContext.js';\n"]}
@@ -0,0 +1,5 @@
1
+ export declare enum BuildArtifactType {
2
+ APPLICATION_ARCHIVE = "application-archive",
3
+ BUILD_ARTIFACT = "build-artifact"
4
+ }
5
+ export type BuildArtifacts = Partial<Record<BuildArtifactType, string[]>>;
@@ -0,0 +1,6 @@
1
+ export var BuildArtifactType;
2
+ (function (BuildArtifactType) {
3
+ BuildArtifactType["APPLICATION_ARCHIVE"] = "application-archive";
4
+ BuildArtifactType["BUILD_ARTIFACT"] = "build-artifact";
5
+ })(BuildArtifactType || (BuildArtifactType = {}));
6
+ //# sourceMappingURL=BuildArtifacts.js.map