@expo/steps 0.0.1

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 (141) hide show
  1. package/README.md +11 -0
  2. package/bin/set-output +16 -0
  3. package/dist_commonjs/BuildConfig.cjs +50 -0
  4. package/dist_commonjs/BuildConfig.d.ts +25 -0
  5. package/dist_commonjs/BuildConfig.js.map +1 -0
  6. package/dist_commonjs/BuildConfigParser.cjs +87 -0
  7. package/dist_commonjs/BuildConfigParser.d.ts +14 -0
  8. package/dist_commonjs/BuildConfigParser.js.map +1 -0
  9. package/dist_commonjs/BuildStep.cjs +146 -0
  10. package/dist_commonjs/BuildStep.d.ts +40 -0
  11. package/dist_commonjs/BuildStep.js.map +1 -0
  12. package/dist_commonjs/BuildStepContext.cjs +32 -0
  13. package/dist_commonjs/BuildStepContext.d.ts +13 -0
  14. package/dist_commonjs/BuildStepContext.js.map +1 -0
  15. package/dist_commonjs/BuildStepInput.cjs +36 -0
  16. package/dist_commonjs/BuildStepInput.d.ts +17 -0
  17. package/dist_commonjs/BuildStepInput.js.map +1 -0
  18. package/dist_commonjs/BuildStepOutput.cjs +29 -0
  19. package/dist_commonjs/BuildStepOutput.d.ts +15 -0
  20. package/dist_commonjs/BuildStepOutput.js.map +1 -0
  21. package/dist_commonjs/BuildWorkflow.cjs +15 -0
  22. package/dist_commonjs/BuildWorkflow.d.ts +8 -0
  23. package/dist_commonjs/BuildWorkflow.js.map +1 -0
  24. package/dist_commonjs/BuildWorkflowValidator.cjs +76 -0
  25. package/dist_commonjs/BuildWorkflowValidator.d.ts +8 -0
  26. package/dist_commonjs/BuildWorkflowValidator.js.map +1 -0
  27. package/dist_commonjs/cli/cli.cjs +33 -0
  28. package/dist_commonjs/cli/cli.d.ts +1 -0
  29. package/dist_commonjs/cli/cli.js.map +1 -0
  30. package/dist_commonjs/errors/BuildConfigError.cjs +8 -0
  31. package/dist_commonjs/errors/BuildConfigError.d.ts +3 -0
  32. package/dist_commonjs/errors/BuildConfigError.js.map +1 -0
  33. package/dist_commonjs/errors/BuildStepInputError.cjs +8 -0
  34. package/dist_commonjs/errors/BuildStepInputError.d.ts +3 -0
  35. package/dist_commonjs/errors/BuildStepInputError.js.map +1 -0
  36. package/dist_commonjs/errors/BuildStepOutputError.cjs +8 -0
  37. package/dist_commonjs/errors/BuildStepOutputError.d.ts +3 -0
  38. package/dist_commonjs/errors/BuildStepOutputError.js.map +1 -0
  39. package/dist_commonjs/errors/BuildStepRuntimeError.cjs +8 -0
  40. package/dist_commonjs/errors/BuildStepRuntimeError.d.ts +3 -0
  41. package/dist_commonjs/errors/BuildStepRuntimeError.js.map +1 -0
  42. package/dist_commonjs/errors/BuildWorkflowError.cjs +13 -0
  43. package/dist_commonjs/errors/BuildWorkflowError.d.ts +10 -0
  44. package/dist_commonjs/errors/BuildWorkflowError.js.map +1 -0
  45. package/dist_commonjs/errors/UserError.cjs +14 -0
  46. package/dist_commonjs/errors/UserError.d.ts +9 -0
  47. package/dist_commonjs/errors/UserError.js.map +1 -0
  48. package/dist_commonjs/index.cjs +8 -0
  49. package/dist_commonjs/index.d.ts +2 -0
  50. package/dist_commonjs/index.js.map +1 -0
  51. package/dist_commonjs/utils/expodash/uniq.cjs +9 -0
  52. package/dist_commonjs/utils/expodash/uniq.d.ts +1 -0
  53. package/dist_commonjs/utils/expodash/uniq.js.map +1 -0
  54. package/dist_commonjs/utils/nullthrows.cjs +11 -0
  55. package/dist_commonjs/utils/nullthrows.d.ts +1 -0
  56. package/dist_commonjs/utils/nullthrows.js.map +1 -0
  57. package/dist_commonjs/utils/shell/bin.cjs +11 -0
  58. package/dist_commonjs/utils/shell/bin.d.ts +1 -0
  59. package/dist_commonjs/utils/shell/bin.js.map +1 -0
  60. package/dist_commonjs/utils/shell/command.cjs +36 -0
  61. package/dist_commonjs/utils/shell/command.d.ts +6 -0
  62. package/dist_commonjs/utils/shell/command.js.map +1 -0
  63. package/dist_commonjs/utils/shell/spawn.cjs +25 -0
  64. package/dist_commonjs/utils/shell/spawn.d.ts +9 -0
  65. package/dist_commonjs/utils/shell/spawn.js.map +1 -0
  66. package/dist_commonjs/utils/shell/temporaryFiles.cjs +42 -0
  67. package/dist_commonjs/utils/shell/temporaryFiles.d.ts +4 -0
  68. package/dist_commonjs/utils/shell/temporaryFiles.js.map +1 -0
  69. package/dist_commonjs/utils/template.cjs +47 -0
  70. package/dist_commonjs/utils/template.d.ts +11 -0
  71. package/dist_commonjs/utils/template.js.map +1 -0
  72. package/dist_esm/BuildConfig.d.ts +25 -0
  73. package/dist_esm/BuildConfig.js +43 -0
  74. package/dist_esm/BuildConfig.js.map +1 -0
  75. package/dist_esm/BuildConfigParser.d.ts +14 -0
  76. package/dist_esm/BuildConfigParser.js +80 -0
  77. package/dist_esm/BuildConfigParser.js.map +1 -0
  78. package/dist_esm/BuildStep.d.ts +40 -0
  79. package/dist_esm/BuildStep.js +139 -0
  80. package/dist_esm/BuildStep.js.map +1 -0
  81. package/dist_esm/BuildStepContext.d.ts +13 -0
  82. package/dist_esm/BuildStepContext.js +25 -0
  83. package/dist_esm/BuildStepContext.js.map +1 -0
  84. package/dist_esm/BuildStepInput.d.ts +17 -0
  85. package/dist_esm/BuildStepInput.js +32 -0
  86. package/dist_esm/BuildStepInput.js.map +1 -0
  87. package/dist_esm/BuildStepOutput.d.ts +15 -0
  88. package/dist_esm/BuildStepOutput.js +25 -0
  89. package/dist_esm/BuildStepOutput.js.map +1 -0
  90. package/dist_esm/BuildWorkflow.d.ts +8 -0
  91. package/dist_esm/BuildWorkflow.js +11 -0
  92. package/dist_esm/BuildWorkflow.js.map +1 -0
  93. package/dist_esm/BuildWorkflowValidator.d.ts +8 -0
  94. package/dist_esm/BuildWorkflowValidator.js +72 -0
  95. package/dist_esm/BuildWorkflowValidator.js.map +1 -0
  96. package/dist_esm/cli/cli.d.ts +1 -0
  97. package/dist_esm/cli/cli.js +28 -0
  98. package/dist_esm/cli/cli.js.map +1 -0
  99. package/dist_esm/errors/BuildConfigError.d.ts +3 -0
  100. package/dist_esm/errors/BuildConfigError.js +4 -0
  101. package/dist_esm/errors/BuildConfigError.js.map +1 -0
  102. package/dist_esm/errors/BuildStepInputError.d.ts +3 -0
  103. package/dist_esm/errors/BuildStepInputError.js +4 -0
  104. package/dist_esm/errors/BuildStepInputError.js.map +1 -0
  105. package/dist_esm/errors/BuildStepOutputError.d.ts +3 -0
  106. package/dist_esm/errors/BuildStepOutputError.js +4 -0
  107. package/dist_esm/errors/BuildStepOutputError.js.map +1 -0
  108. package/dist_esm/errors/BuildStepRuntimeError.d.ts +3 -0
  109. package/dist_esm/errors/BuildStepRuntimeError.js +4 -0
  110. package/dist_esm/errors/BuildStepRuntimeError.js.map +1 -0
  111. package/dist_esm/errors/BuildWorkflowError.d.ts +10 -0
  112. package/dist_esm/errors/BuildWorkflowError.js +9 -0
  113. package/dist_esm/errors/BuildWorkflowError.js.map +1 -0
  114. package/dist_esm/errors/UserError.d.ts +9 -0
  115. package/dist_esm/errors/UserError.js +10 -0
  116. package/dist_esm/errors/UserError.js.map +1 -0
  117. package/dist_esm/index.d.ts +2 -0
  118. package/dist_esm/index.js +3 -0
  119. package/dist_esm/index.js.map +1 -0
  120. package/dist_esm/utils/expodash/uniq.d.ts +1 -0
  121. package/dist_esm/utils/expodash/uniq.js +5 -0
  122. package/dist_esm/utils/expodash/uniq.js.map +1 -0
  123. package/dist_esm/utils/nullthrows.d.ts +1 -0
  124. package/dist_esm/utils/nullthrows.js +7 -0
  125. package/dist_esm/utils/nullthrows.js.map +1 -0
  126. package/dist_esm/utils/shell/bin.d.ts +1 -0
  127. package/dist_esm/utils/shell/bin.js +5 -0
  128. package/dist_esm/utils/shell/bin.js.map +1 -0
  129. package/dist_esm/utils/shell/command.d.ts +6 -0
  130. package/dist_esm/utils/shell/command.js +28 -0
  131. package/dist_esm/utils/shell/command.js.map +1 -0
  132. package/dist_esm/utils/shell/spawn.d.ts +9 -0
  133. package/dist_esm/utils/shell/spawn.js +18 -0
  134. package/dist_esm/utils/shell/spawn.js.map +1 -0
  135. package/dist_esm/utils/shell/temporaryFiles.d.ts +4 -0
  136. package/dist_esm/utils/shell/temporaryFiles.js +33 -0
  137. package/dist_esm/utils/shell/temporaryFiles.js.map +1 -0
  138. package/dist_esm/utils/template.d.ts +11 -0
  139. package/dist_esm/utils/template.js +40 -0
  140. package/dist_esm/utils/template.js.map +1 -0
  141. package/package.json +54 -0
@@ -0,0 +1,25 @@
1
+ import Joi from 'joi';
2
+ export interface BuildConfig {
3
+ build: {
4
+ name?: string;
5
+ steps: BuildStepConfig[];
6
+ };
7
+ }
8
+ export type BuildStepInputsConfig = Record<string, string>;
9
+ export type BuildStepOutputsConfig = (string | {
10
+ name: string;
11
+ required?: boolean;
12
+ })[];
13
+ export type BuildStepConfig = string | {
14
+ run: string | {
15
+ id?: string;
16
+ inputs?: BuildStepInputsConfig;
17
+ outputs?: BuildStepOutputsConfig;
18
+ name?: string;
19
+ workingDirectory?: string;
20
+ shell?: string;
21
+ command: string;
22
+ };
23
+ };
24
+ export declare const BuildConfigSchema: Joi.ObjectSchema<BuildConfig>;
25
+ export declare function validateBuildConfig(rawConfig: object): BuildConfig;
@@ -0,0 +1,43 @@
1
+ import Joi from 'joi';
2
+ import { BuildConfigError } from './errors/BuildConfigError.js';
3
+ export const BuildConfigSchema = Joi.object({
4
+ build: Joi.object({
5
+ name: Joi.string(),
6
+ steps: Joi.array()
7
+ .items(Joi.object({
8
+ run: Joi.alternatives().conditional('run', {
9
+ is: Joi.string(),
10
+ then: Joi.string().required(),
11
+ otherwise: Joi.object({
12
+ id: Joi.string(),
13
+ inputs: Joi.object().pattern(Joi.string(), Joi.string()),
14
+ outputs: Joi.array().items(Joi.alternatives().try(Joi.string().required(), Joi.object({
15
+ name: Joi.string().required(),
16
+ required: Joi.boolean(),
17
+ }).required())),
18
+ name: Joi.string(),
19
+ workingDirectory: Joi.string(),
20
+ shell: Joi.string(),
21
+ command: Joi.string().required(),
22
+ })
23
+ .rename('working_directory', 'workingDirectory')
24
+ .required(),
25
+ }),
26
+ }))
27
+ .required(),
28
+ }).required(),
29
+ }).required();
30
+ export function validateBuildConfig(rawConfig) {
31
+ const { error, value } = BuildConfigSchema.validate(rawConfig, {
32
+ allowUnknown: false,
33
+ abortEarly: false,
34
+ });
35
+ if (error) {
36
+ const errorMessage = error.details.map(({ message }) => message).join(', ');
37
+ throw new BuildConfigError(errorMessage, { cause: error });
38
+ }
39
+ else {
40
+ return value;
41
+ }
42
+ }
43
+ //# sourceMappingURL=BuildConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAmChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,CAAc;IACvD,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE;aACf,KAAK,CACJ,GAAG,CAAC,MAAM,CAAC;YACT,GAAG,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE;gBACzC,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;gBAChB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gBAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC;oBACpB,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;oBAChB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;oBACxD,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACxB,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,CACpB,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EACvB,GAAG,CAAC,MAAM,CAAC;wBACT,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;wBAC7B,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE;qBACxB,CAAC,CAAC,QAAQ,EAAE,CACd,CACF;oBACD,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;oBAClB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;oBAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;oBACnB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;iBACjC,CAAC;qBACC,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC;qBAC/C,QAAQ,EAAE;aACd,CAAC;SACH,CAAC,CACH;aACA,QAAQ,EAAE;KACd,CAAC,CAAC,QAAQ,EAAE;CACd,CAAC,CAAC,QAAQ,EAAE,CAAC;AAEd,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC,QAAQ,CAAC,SAAS,EAAE;QAC7D,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IACH,IAAI,KAAK,EAAE;QACT,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5E,MAAM,IAAI,gBAAgB,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;KAC5D;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC","sourcesContent":["import Joi from 'joi';\n\nimport { BuildConfigError } from './errors/BuildConfigError.js';\n\nexport interface BuildConfig {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n}\n\nexport type BuildStepInputsConfig = Record<string, string>;\n\nexport type BuildStepOutputsConfig = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nexport type BuildStepConfig =\n | string\n | {\n run:\n | string\n | {\n id?: string;\n inputs?: BuildStepInputsConfig;\n outputs?: BuildStepOutputsConfig;\n name?: string;\n workingDirectory?: string;\n shell?: string;\n command: string;\n };\n };\n\nexport const BuildConfigSchema = Joi.object<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array()\n .items(\n Joi.object({\n run: Joi.alternatives().conditional('run', {\n is: Joi.string(),\n then: Joi.string().required(),\n otherwise: Joi.object({\n id: Joi.string(),\n inputs: Joi.object().pattern(Joi.string(), Joi.string()),\n outputs: Joi.array().items(\n Joi.alternatives().try(\n Joi.string().required(),\n Joi.object({\n name: Joi.string().required(),\n required: Joi.boolean(),\n }).required()\n )\n ),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n command: Joi.string().required(),\n })\n .rename('working_directory', 'workingDirectory')\n .required(),\n }),\n })\n )\n .required(),\n }).required(),\n}).required();\n\nexport function validateBuildConfig(rawConfig: object): BuildConfig {\n const { error, value } = BuildConfigSchema.validate(rawConfig, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, { cause: error });\n } else {\n return value;\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { BuildStepContext } from './BuildStepContext.js';
2
+ import { BuildWorkflow } from './BuildWorkflow.js';
3
+ export declare class BuildConfigParser {
4
+ private readonly ctx;
5
+ private readonly configPath;
6
+ constructor(ctx: BuildStepContext, { configPath }: {
7
+ configPath: string;
8
+ });
9
+ parseAsync(): Promise<BuildWorkflow>;
10
+ private readRawConfigAsync;
11
+ private createBuildStepFromConfig;
12
+ private createBuildStepInputsFromConfig;
13
+ private createBuildStepOutputsFromConfig;
14
+ }
@@ -0,0 +1,80 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ import YAML from 'yaml';
5
+ import { validateBuildConfig, } from './BuildConfig.js';
6
+ import { BuildStep } from './BuildStep.js';
7
+ import { BuildStepInput } from './BuildStepInput.js';
8
+ import { BuildStepOutput } from './BuildStepOutput.js';
9
+ import { BuildWorkflow } from './BuildWorkflow.js';
10
+ import { BuildWorkflowValidator } from './BuildWorkflowValidator.js';
11
+ export class BuildConfigParser {
12
+ constructor(ctx, { configPath }) {
13
+ this.ctx = ctx;
14
+ this.configPath = configPath;
15
+ }
16
+ async parseAsync() {
17
+ const rawConfig = await this.readRawConfigAsync();
18
+ const config = validateBuildConfig(rawConfig);
19
+ const steps = config.build.steps.map((stepConfig) => this.createBuildStepFromConfig(stepConfig));
20
+ const workflow = new BuildWorkflow({ buildSteps: steps });
21
+ new BuildWorkflowValidator(workflow).validate();
22
+ return workflow;
23
+ }
24
+ async readRawConfigAsync() {
25
+ const contents = await fs.promises.readFile(this.configPath, 'utf-8');
26
+ return YAML.parse(contents);
27
+ }
28
+ createBuildStepFromConfig(buildStepConfig) {
29
+ if (typeof buildStepConfig === 'string') {
30
+ // TODO: implement calling functions
31
+ throw new Error('Not implemented yet');
32
+ }
33
+ else if (typeof buildStepConfig.run === 'string') {
34
+ const command = buildStepConfig.run;
35
+ return new BuildStep(this.ctx, {
36
+ id: uuidv4(),
37
+ workingDirectory: this.ctx.workingDirectory,
38
+ command,
39
+ });
40
+ }
41
+ else {
42
+ const { id, inputs: inputsConfig, outputs: outputsConfig, name, workingDirectory, shell, command, } = buildStepConfig.run;
43
+ const stepId = id !== null && id !== void 0 ? id : uuidv4();
44
+ const inputs = inputsConfig && this.createBuildStepInputsFromConfig(inputsConfig, stepId);
45
+ const outputs = outputsConfig && this.createBuildStepOutputsFromConfig(outputsConfig, stepId);
46
+ return new BuildStep(this.ctx, {
47
+ id: stepId,
48
+ inputs,
49
+ outputs,
50
+ name,
51
+ workingDirectory: workingDirectory !== undefined
52
+ ? path.resolve(this.ctx.workingDirectory, workingDirectory)
53
+ : this.ctx.workingDirectory,
54
+ shell,
55
+ command,
56
+ });
57
+ }
58
+ }
59
+ createBuildStepInputsFromConfig(buildStepInputsConfig, stepId) {
60
+ return Object.entries(buildStepInputsConfig).map(([key, value]) => new BuildStepInput(this.ctx, {
61
+ id: key,
62
+ stepId,
63
+ defaultValue: value,
64
+ required: true,
65
+ }));
66
+ }
67
+ createBuildStepOutputsFromConfig(buildStepOutputsConfig, stepId) {
68
+ return buildStepOutputsConfig.map((entry) => {
69
+ var _a;
70
+ return typeof entry === 'string'
71
+ ? new BuildStepOutput(this.ctx, { id: entry, stepId, required: true })
72
+ : new BuildStepOutput(this.ctx, {
73
+ id: entry.name,
74
+ stepId,
75
+ required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
76
+ });
77
+ });
78
+ }
79
+ }
80
+ //# sourceMappingURL=BuildConfigParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAIL,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,OAAO,iBAAiB;IAG5B,YAA6B,GAAqB,EAAE,EAAE,UAA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K,KAAK,QAAQ;gBACvB,CAAC,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACtE,CAAC,CAAC,IAAI,eAAe,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","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"]}
@@ -0,0 +1,40 @@
1
+ import { BuildStepContext } from './BuildStepContext.js';
2
+ import { BuildStepInput } from './BuildStepInput.js';
3
+ import { BuildStepOutput } from './BuildStepOutput.js';
4
+ export declare enum BuildStepStatus {
5
+ NEW = "new",
6
+ IN_PROGRESS = "in-progress",
7
+ CANCELED = "canceled",
8
+ FAILED = "failed",
9
+ SUCCEEDED = "succeeded"
10
+ }
11
+ export declare class BuildStep {
12
+ private readonly ctx;
13
+ readonly id: string;
14
+ readonly name?: string;
15
+ readonly inputs?: BuildStepInput[];
16
+ readonly outputs?: BuildStepOutput[];
17
+ readonly command: string;
18
+ readonly workingDirectory: string;
19
+ readonly shell: string;
20
+ status: BuildStepStatus;
21
+ private readonly internalId;
22
+ private readonly logger;
23
+ private readonly outputById;
24
+ private executed;
25
+ constructor(ctx: BuildStepContext, { id, name, inputs, outputs, command, workingDirectory, shell, }: {
26
+ id: string;
27
+ name?: string;
28
+ inputs?: BuildStepInput[];
29
+ outputs?: BuildStepOutput[];
30
+ command: string;
31
+ workingDirectory: string;
32
+ shell?: string;
33
+ });
34
+ executeAsync(): Promise<void>;
35
+ hasOutputParameter(name: string): boolean;
36
+ getOutputValueByName(name: string): string | undefined;
37
+ private interpolateInputsInCommand;
38
+ private collectAndValidateOutputsAsync;
39
+ private getScriptEnv;
40
+ }
@@ -0,0 +1,139 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { v4 as uuidv4 } from 'uuid';
4
+ import { BIN_PATH } from './utils/shell/bin.js';
5
+ import { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';
6
+ import { cleanUpTemporaryDirectoriesAsync, createTemporaryOutputsDirectoryAsync, saveScriptToTemporaryFileAsync, } from './utils/shell/temporaryFiles.js';
7
+ import { spawnAsync } from './utils/shell/spawn.js';
8
+ import { interpolateWithInputs } from './utils/template.js';
9
+ import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
10
+ export var BuildStepStatus;
11
+ (function (BuildStepStatus) {
12
+ BuildStepStatus["NEW"] = "new";
13
+ BuildStepStatus["IN_PROGRESS"] = "in-progress";
14
+ BuildStepStatus["CANCELED"] = "canceled";
15
+ BuildStepStatus["FAILED"] = "failed";
16
+ BuildStepStatus["SUCCEEDED"] = "succeeded";
17
+ })(BuildStepStatus || (BuildStepStatus = {}));
18
+ export class BuildStep {
19
+ constructor(ctx, { id, name, inputs, outputs, command, workingDirectory, shell, }) {
20
+ this.ctx = ctx;
21
+ this.executed = false;
22
+ this.id = id;
23
+ this.name = name;
24
+ this.inputs = inputs;
25
+ this.outputs = outputs;
26
+ this.outputById =
27
+ outputs === undefined
28
+ ? {}
29
+ : outputs.reduce((acc, output) => {
30
+ acc[output.id] = output;
31
+ return acc;
32
+ }, {});
33
+ this.command = command;
34
+ this.workingDirectory = workingDirectory;
35
+ this.shell = shell !== null && shell !== void 0 ? shell : getDefaultShell();
36
+ this.status = BuildStepStatus.NEW;
37
+ this.internalId = uuidv4();
38
+ this.logger = ctx.logger.child({ buildStepInternalId: this.internalId, buildStepId: this.id });
39
+ ctx.registerStep(this);
40
+ }
41
+ async executeAsync() {
42
+ try {
43
+ this.logger.debug(`Executing build step "${this.id}"`);
44
+ this.status = BuildStepStatus.IN_PROGRESS;
45
+ const command = this.interpolateInputsInCommand(this.command, this.inputs);
46
+ this.logger.debug(`Interpolated inputs in the command template`);
47
+ const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx, this.id);
48
+ this.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);
49
+ const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx, this.id, command);
50
+ this.logger.debug(`Saved script to ${scriptPath}`);
51
+ const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);
52
+ this.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
53
+ await spawnAsync(shellCommand, args !== null && args !== void 0 ? args : [], {
54
+ cwd: this.workingDirectory,
55
+ logger: this.logger,
56
+ env: this.getScriptEnv(outputsDir),
57
+ });
58
+ this.logger.debug(`Script completed successfully`);
59
+ await this.collectAndValidateOutputsAsync(outputsDir);
60
+ this.logger.debug('Finished collecting output paramters');
61
+ this.logger.debug('Finished successfully');
62
+ this.status = BuildStepStatus.SUCCEEDED;
63
+ }
64
+ catch (err) {
65
+ this.status = BuildStepStatus.FAILED;
66
+ throw err;
67
+ }
68
+ finally {
69
+ this.executed = true;
70
+ await cleanUpTemporaryDirectoriesAsync(this.ctx, this.id);
71
+ }
72
+ }
73
+ hasOutputParameter(name) {
74
+ return name in this.outputById;
75
+ }
76
+ getOutputValueByName(name) {
77
+ if (!this.executed) {
78
+ throw new BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.id}". The step has not been executed yet.`);
79
+ }
80
+ if (!this.hasOutputParameter(name)) {
81
+ throw new BuildStepRuntimeError(`Step "${this.id}" does not have output "${name}"`);
82
+ }
83
+ return this.outputById[name].value;
84
+ }
85
+ interpolateInputsInCommand(command, inputs) {
86
+ if (!inputs) {
87
+ return command;
88
+ }
89
+ const vars = inputs.reduce((acc, input) => {
90
+ var _a;
91
+ acc[input.id] = (_a = input.value) !== null && _a !== void 0 ? _a : '';
92
+ return acc;
93
+ }, {});
94
+ return interpolateWithInputs(command, vars);
95
+ }
96
+ async collectAndValidateOutputsAsync(outputsDir) {
97
+ var _a;
98
+ const files = await fs.promises.readdir(outputsDir);
99
+ const nonDefinedOutputIds = [];
100
+ for (const outputId of files) {
101
+ if (!(outputId in this.outputById)) {
102
+ nonDefinedOutputIds.push(outputId);
103
+ }
104
+ else {
105
+ const file = path.join(outputsDir, outputId);
106
+ const rawContents = await fs.promises.readFile(file, 'utf-8');
107
+ const value = rawContents.trim();
108
+ this.outputById[outputId].set(value);
109
+ }
110
+ }
111
+ if (nonDefinedOutputIds.length > 0) {
112
+ const idsString = nonDefinedOutputIds.map((i) => `"${i}"`).join(', ');
113
+ this.logger.warn(`Some outputs are not defined in step config: ${idsString}`);
114
+ }
115
+ const nonSetRequiredOutputIds = [];
116
+ for (const output of (_a = this.outputs) !== null && _a !== void 0 ? _a : []) {
117
+ try {
118
+ const value = output.value;
119
+ this.logger.debug(`Output parameter "${output.id}" is set to "${value}"`);
120
+ }
121
+ catch (err) {
122
+ this.logger.debug({ err }, `Getting value for output parameter "${output.id}" failed.`);
123
+ nonSetRequiredOutputIds.push(output.id);
124
+ }
125
+ }
126
+ if (nonSetRequiredOutputIds.length > 0) {
127
+ const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
128
+ throw new BuildStepRuntimeError(`Some required output parameters have not been set: ${idsString}`, { metadata: { ids: nonSetRequiredOutputIds } });
129
+ }
130
+ }
131
+ getScriptEnv(outputsDir) {
132
+ return {
133
+ ...process.env,
134
+ __EXPO_STEPS_OUTPUTS_DIR: outputsDir,
135
+ PATH: `${BIN_PATH}:${process.env.PATH}`,
136
+ };
137
+ }
138
+ }
139
+ //# sourceMappingURL=BuildStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAKpC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EACL,gCAAgC,EAChC,oCAAoC,EACpC,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;IACjB,0CAAuB,CAAA;AACzB,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B;AAED,MAAM,OAAO,SAAS;IAepB,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,CA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AM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,uCAAuC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;gBACxF,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;aACzC;SACF;QACD,IAAI,uBAAuB,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,MAAM,SAAS,GAAG,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1E,MAAM,IAAI,qBAAqB,CAC7B,sDAAsD,SAAS,EAAE,EACjE,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,uBAAuB,EAAE,EAAE,CAC/C,CAAC;SACH;IACH,CAAC;IAEO,YAAY,CAAC,UAAkB;QACrC,OAAO;YACL,GAAG,OAAO,CAAC,GAAG;YACd,wBAAwB,EAAE,UAAU;YACpC,IAAI,EAAE,GAAG,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;SACxC,CAAC;IACJ,CAAC;CACF","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 FAILED = 'failed',\n SUCCEEDED = 'succeeded',\n}\n\nexport class BuildStep {\n public readonly id: string;\n public readonly name?: 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.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({ buildStepInternalId: this.internalId, buildStepId: this.id });\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.logger.debug(`Executing build step \"${this.id}\"`);\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.debug('Finished successfully');\n this.status = BuildStepStatus.SUCCEEDED;\n } catch (err) {\n this.status = BuildStepStatus.FAILED;\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"]}
@@ -0,0 +1,13 @@
1
+ import { bunyan } from '@expo/logger';
2
+ import { BuildStep } from './BuildStep.js';
3
+ export declare class BuildStepContext {
4
+ readonly buildId: string;
5
+ readonly logger: bunyan;
6
+ readonly skipCleanup: boolean;
7
+ readonly baseWorkingDirectory: string;
8
+ readonly workingDirectory: string;
9
+ private stepById;
10
+ constructor(buildId: string, logger: bunyan, skipCleanup: boolean, workingDirectory?: string);
11
+ registerStep(step: BuildStep): void;
12
+ getStepOutputValue(path: string): string | undefined;
13
+ }
@@ -0,0 +1,25 @@
1
+ import os from 'os';
2
+ import path from 'path';
3
+ import { parseOutputPath } from './utils/template.js';
4
+ import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
5
+ export class BuildStepContext {
6
+ constructor(buildId, logger, skipCleanup, workingDirectory) {
7
+ this.buildId = buildId;
8
+ this.logger = logger;
9
+ this.skipCleanup = skipCleanup;
10
+ this.stepById = {};
11
+ this.baseWorkingDirectory = path.join(os.tmpdir(), 'eas-build', buildId);
12
+ this.workingDirectory = workingDirectory !== null && workingDirectory !== void 0 ? workingDirectory : path.join(this.baseWorkingDirectory, 'project');
13
+ }
14
+ registerStep(step) {
15
+ this.stepById[step.id] = step;
16
+ }
17
+ getStepOutputValue(path) {
18
+ const { stepId, outputId } = parseOutputPath(path);
19
+ if (!(stepId in this.stepById)) {
20
+ throw new BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
21
+ }
22
+ return this.stepById[stepId].getOutputValueByName(outputId);
23
+ }
24
+ }
25
+ //# sourceMappingURL=BuildStepContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,OAAO,gBAAgB;IAM3B,YACkB,OAAe,EACf,MAAc,EACd,WAAoB,EACpC,gBAAyB;QAHT,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAS;QAL9B,aAAQ,GAA8B,EAAE,CAAC;QAQ/C,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;IAC9F,CAAC;IAEM,YAAY,CAAC,IAAe;QACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;IAChC,CAAC;IAEM,kBAAkB,CAAC,IAAY;QACpC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC9B,MAAM,IAAI,qBAAqB,CAAC,SAAS,MAAM,mBAAmB,CAAC,CAAC;SACrE;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStep } from './BuildStep.js';\nimport { parseOutputPath } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\n\nexport class BuildStepContext {\n public readonly baseWorkingDirectory: string;\n public readonly workingDirectory: string;\n\n private stepById: Record<string, BuildStep> = {};\n\n constructor(\n public readonly buildId: string,\n public readonly logger: bunyan,\n public readonly skipCleanup: boolean,\n workingDirectory?: string\n ) {\n this.baseWorkingDirectory = path.join(os.tmpdir(), 'eas-build', buildId);\n this.workingDirectory = workingDirectory ?? path.join(this.baseWorkingDirectory, 'project');\n }\n\n public registerStep(step: BuildStep): void {\n this.stepById[step.id] = step;\n }\n\n public getStepOutputValue(path: string): string | undefined {\n const { stepId, outputId } = parseOutputPath(path);\n if (!(stepId in this.stepById)) {\n throw new BuildStepRuntimeError(`Step \"${stepId}\" does not exist.`);\n }\n return this.stepById[stepId].getOutputValueByName(outputId);\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { BuildStepContext } from './BuildStepContext.js';
2
+ export declare class BuildStepInput {
3
+ private readonly ctx;
4
+ readonly id: string;
5
+ readonly stepId: string;
6
+ readonly defaultValue?: string;
7
+ readonly required: boolean;
8
+ private _value?;
9
+ constructor(ctx: BuildStepContext, { id, stepId, defaultValue, required, }: {
10
+ id: string;
11
+ stepId: string;
12
+ defaultValue?: string;
13
+ required?: boolean;
14
+ });
15
+ get value(): string | undefined;
16
+ set(value: string | undefined): BuildStepInput;
17
+ }
@@ -0,0 +1,32 @@
1
+ import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
2
+ import { interpolateWithOutputs } from './utils/template.js';
3
+ export class BuildStepInput {
4
+ constructor(ctx, { id, stepId, defaultValue, required = false, }) {
5
+ this.ctx = ctx;
6
+ this.id = id;
7
+ this.stepId = stepId;
8
+ this.defaultValue = defaultValue;
9
+ this.required = required;
10
+ }
11
+ get value() {
12
+ var _a;
13
+ const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
14
+ if (this.required && rawValue === undefined) {
15
+ throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepId}" is required but it was not set.`);
16
+ }
17
+ if (rawValue === undefined) {
18
+ return rawValue;
19
+ }
20
+ else {
21
+ return interpolateWithOutputs(rawValue, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
22
+ }
23
+ }
24
+ set(value) {
25
+ if (this.required && value === undefined) {
26
+ throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepId}" is required.`);
27
+ }
28
+ this._value = value;
29
+ return this;
30
+ }
31
+ }
32
+ //# sourceMappingURL=BuildStepInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,OAAO,cAAc;IAQzB,YACmB,GAAqB,EACtC,EACE,EAAE,EACF,MAAM,EACN,YAAY,EACZ,QAAQ,GAAG,KAAK,GAMjB;QAXgB,QAAG,GAAH,GAAG,CAAkB;QAatC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;;QACP,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,MAAM,mCAAI,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3C,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,mCAAmC,CACzF,CAAC;SACH;QAED,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,OAAO,QAAQ,CAAC;SACjB;aAAM;YACL,OAAO,sBAAsB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,MAAA,IAAI,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAA,EAAA,CAAC,CAAC;SAC5F;IACH,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,gBAAgB,CACtE,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\nimport { interpolateWithOutputs } from './utils/template.js';\n\nexport class BuildStepInput {\n public readonly id: string;\n public readonly stepId: string;\n public readonly defaultValue?: string;\n public readonly required: boolean;\n\n private _value?: string;\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n stepId,\n defaultValue,\n required = false,\n }: {\n id: string;\n stepId: string;\n defaultValue?: string;\n required?: boolean;\n }\n ) {\n this.id = id;\n this.stepId = stepId;\n this.defaultValue = defaultValue;\n this.required = required;\n }\n\n get value(): string | undefined {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepId}\" is required but it was not set.`\n );\n }\n\n if (rawValue === undefined) {\n return rawValue;\n } else {\n return interpolateWithOutputs(rawValue, (path) => this.ctx.getStepOutputValue(path) ?? '');\n }\n }\n\n set(value: string | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepId}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { BuildStepContext } from './BuildStepContext.js';
2
+ export declare class BuildStepOutput {
3
+ private readonly ctx;
4
+ readonly id: string;
5
+ readonly stepId: string;
6
+ readonly required: boolean;
7
+ private _value?;
8
+ constructor(ctx: BuildStepContext, { id, stepId, required }: {
9
+ id: string;
10
+ stepId: string;
11
+ required?: boolean;
12
+ });
13
+ get value(): string | undefined;
14
+ set(value: string | undefined): BuildStepOutput;
15
+ }
@@ -0,0 +1,25 @@
1
+ import { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';
2
+ export class BuildStepOutput {
3
+ constructor(
4
+ // @ts-expect-error ctx is not used in this class but let's keep it here for consistency
5
+ ctx, { id, stepId, required = true }) {
6
+ this.ctx = ctx;
7
+ this.id = id;
8
+ this.stepId = stepId;
9
+ this.required = required;
10
+ }
11
+ get value() {
12
+ if (this.required && this._value === undefined) {
13
+ throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required but it was not set.`);
14
+ }
15
+ return this._value;
16
+ }
17
+ set(value) {
18
+ if (this.required && value === undefined) {
19
+ throw new BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required.`);
20
+ }
21
+ this._value = value;
22
+ return this;
23
+ }
24
+ }
25
+ //# sourceMappingURL=BuildStepOutput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,MAAM,OAAO,eAAe;IAO1B;IACE,wFAAwF;IACvE,GAAqB,EACtC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,EAAsD;QADlE,QAAG,GAAH,GAAG,CAAkB;QAGtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,KAAK;QACP,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC9C,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,mCAAmC,CAC1F,CAAC;SACH;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,GAAG,CAAC,KAAyB;QAC3B,IAAI,IAAI,CAAC,QAAQ,IAAI,KAAK,KAAK,SAAS,EAAE;YACxC,MAAM,IAAI,qBAAqB,CAC7B,qBAAqB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,MAAM,gBAAgB,CACvE,CAAC;SACH;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors/BuildStepRuntimeError.js';\n\nexport class BuildStepOutput {\n public readonly id: string;\n public readonly stepId: string;\n public readonly required: boolean;\n\n private _value?: string;\n\n constructor(\n // @ts-expect-error ctx is not used in this class but let's keep it here for consistency\n private readonly ctx: BuildStepContext,\n { id, stepId, required = true }: { id: string; stepId: string; required?: boolean }\n ) {\n this.id = id;\n this.stepId = stepId;\n this.required = required;\n }\n\n get value(): string | undefined {\n if (this.required && this._value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepId}\" is required but it was not set.`\n );\n }\n return this._value;\n }\n\n set(value: string | undefined): BuildStepOutput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Output parameter \"${this.id}\" for step \"${this.stepId}\" is required.`\n );\n }\n this._value = value;\n return this;\n }\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { BuildStep } from './BuildStep.js';
2
+ export declare class BuildWorkflow {
3
+ readonly buildSteps: BuildStep[];
4
+ constructor({ buildSteps }: {
5
+ buildSteps: BuildStep[];
6
+ });
7
+ executeAsync(): Promise<void>;
8
+ }
@@ -0,0 +1,11 @@
1
+ export class BuildWorkflow {
2
+ constructor({ buildSteps }) {
3
+ this.buildSteps = buildSteps;
4
+ }
5
+ async executeAsync() {
6
+ for (const step of this.buildSteps) {
7
+ await step.executeAsync();
8
+ }
9
+ }
10
+ }
11
+ //# sourceMappingURL=BuildWorkflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,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","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"]}
@@ -0,0 +1,8 @@
1
+ import { BuildWorkflow } from './BuildWorkflow.js';
2
+ export declare class BuildWorkflowValidator {
3
+ private readonly workflow;
4
+ constructor(workflow: BuildWorkflow);
5
+ validate(): void;
6
+ private validateUniqueStepIds;
7
+ private validateInputs;
8
+ }