@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.
- package/README.md +11 -0
- package/bin/set-output +16 -0
- package/dist_commonjs/BuildConfig.cjs +50 -0
- package/dist_commonjs/BuildConfig.d.ts +25 -0
- package/dist_commonjs/BuildConfig.js.map +1 -0
- package/dist_commonjs/BuildConfigParser.cjs +87 -0
- package/dist_commonjs/BuildConfigParser.d.ts +14 -0
- package/dist_commonjs/BuildConfigParser.js.map +1 -0
- package/dist_commonjs/BuildStep.cjs +146 -0
- package/dist_commonjs/BuildStep.d.ts +40 -0
- package/dist_commonjs/BuildStep.js.map +1 -0
- package/dist_commonjs/BuildStepContext.cjs +32 -0
- package/dist_commonjs/BuildStepContext.d.ts +13 -0
- package/dist_commonjs/BuildStepContext.js.map +1 -0
- package/dist_commonjs/BuildStepInput.cjs +36 -0
- package/dist_commonjs/BuildStepInput.d.ts +17 -0
- package/dist_commonjs/BuildStepInput.js.map +1 -0
- package/dist_commonjs/BuildStepOutput.cjs +29 -0
- package/dist_commonjs/BuildStepOutput.d.ts +15 -0
- package/dist_commonjs/BuildStepOutput.js.map +1 -0
- package/dist_commonjs/BuildWorkflow.cjs +15 -0
- package/dist_commonjs/BuildWorkflow.d.ts +8 -0
- package/dist_commonjs/BuildWorkflow.js.map +1 -0
- package/dist_commonjs/BuildWorkflowValidator.cjs +76 -0
- package/dist_commonjs/BuildWorkflowValidator.d.ts +8 -0
- package/dist_commonjs/BuildWorkflowValidator.js.map +1 -0
- package/dist_commonjs/cli/cli.cjs +33 -0
- package/dist_commonjs/cli/cli.d.ts +1 -0
- package/dist_commonjs/cli/cli.js.map +1 -0
- package/dist_commonjs/errors/BuildConfigError.cjs +8 -0
- package/dist_commonjs/errors/BuildConfigError.d.ts +3 -0
- package/dist_commonjs/errors/BuildConfigError.js.map +1 -0
- package/dist_commonjs/errors/BuildStepInputError.cjs +8 -0
- package/dist_commonjs/errors/BuildStepInputError.d.ts +3 -0
- package/dist_commonjs/errors/BuildStepInputError.js.map +1 -0
- package/dist_commonjs/errors/BuildStepOutputError.cjs +8 -0
- package/dist_commonjs/errors/BuildStepOutputError.d.ts +3 -0
- package/dist_commonjs/errors/BuildStepOutputError.js.map +1 -0
- package/dist_commonjs/errors/BuildStepRuntimeError.cjs +8 -0
- package/dist_commonjs/errors/BuildStepRuntimeError.d.ts +3 -0
- package/dist_commonjs/errors/BuildStepRuntimeError.js.map +1 -0
- package/dist_commonjs/errors/BuildWorkflowError.cjs +13 -0
- package/dist_commonjs/errors/BuildWorkflowError.d.ts +10 -0
- package/dist_commonjs/errors/BuildWorkflowError.js.map +1 -0
- package/dist_commonjs/errors/UserError.cjs +14 -0
- package/dist_commonjs/errors/UserError.d.ts +9 -0
- package/dist_commonjs/errors/UserError.js.map +1 -0
- package/dist_commonjs/index.cjs +8 -0
- package/dist_commonjs/index.d.ts +2 -0
- package/dist_commonjs/index.js.map +1 -0
- package/dist_commonjs/utils/expodash/uniq.cjs +9 -0
- package/dist_commonjs/utils/expodash/uniq.d.ts +1 -0
- package/dist_commonjs/utils/expodash/uniq.js.map +1 -0
- package/dist_commonjs/utils/nullthrows.cjs +11 -0
- package/dist_commonjs/utils/nullthrows.d.ts +1 -0
- package/dist_commonjs/utils/nullthrows.js.map +1 -0
- package/dist_commonjs/utils/shell/bin.cjs +11 -0
- package/dist_commonjs/utils/shell/bin.d.ts +1 -0
- package/dist_commonjs/utils/shell/bin.js.map +1 -0
- package/dist_commonjs/utils/shell/command.cjs +36 -0
- package/dist_commonjs/utils/shell/command.d.ts +6 -0
- package/dist_commonjs/utils/shell/command.js.map +1 -0
- package/dist_commonjs/utils/shell/spawn.cjs +25 -0
- package/dist_commonjs/utils/shell/spawn.d.ts +9 -0
- package/dist_commonjs/utils/shell/spawn.js.map +1 -0
- package/dist_commonjs/utils/shell/temporaryFiles.cjs +42 -0
- package/dist_commonjs/utils/shell/temporaryFiles.d.ts +4 -0
- package/dist_commonjs/utils/shell/temporaryFiles.js.map +1 -0
- package/dist_commonjs/utils/template.cjs +47 -0
- package/dist_commonjs/utils/template.d.ts +11 -0
- package/dist_commonjs/utils/template.js.map +1 -0
- package/dist_esm/BuildConfig.d.ts +25 -0
- package/dist_esm/BuildConfig.js +43 -0
- package/dist_esm/BuildConfig.js.map +1 -0
- package/dist_esm/BuildConfigParser.d.ts +14 -0
- package/dist_esm/BuildConfigParser.js +80 -0
- package/dist_esm/BuildConfigParser.js.map +1 -0
- package/dist_esm/BuildStep.d.ts +40 -0
- package/dist_esm/BuildStep.js +139 -0
- package/dist_esm/BuildStep.js.map +1 -0
- package/dist_esm/BuildStepContext.d.ts +13 -0
- package/dist_esm/BuildStepContext.js +25 -0
- package/dist_esm/BuildStepContext.js.map +1 -0
- package/dist_esm/BuildStepInput.d.ts +17 -0
- package/dist_esm/BuildStepInput.js +32 -0
- package/dist_esm/BuildStepInput.js.map +1 -0
- package/dist_esm/BuildStepOutput.d.ts +15 -0
- package/dist_esm/BuildStepOutput.js +25 -0
- package/dist_esm/BuildStepOutput.js.map +1 -0
- package/dist_esm/BuildWorkflow.d.ts +8 -0
- package/dist_esm/BuildWorkflow.js +11 -0
- package/dist_esm/BuildWorkflow.js.map +1 -0
- package/dist_esm/BuildWorkflowValidator.d.ts +8 -0
- package/dist_esm/BuildWorkflowValidator.js +72 -0
- package/dist_esm/BuildWorkflowValidator.js.map +1 -0
- package/dist_esm/cli/cli.d.ts +1 -0
- package/dist_esm/cli/cli.js +28 -0
- package/dist_esm/cli/cli.js.map +1 -0
- package/dist_esm/errors/BuildConfigError.d.ts +3 -0
- package/dist_esm/errors/BuildConfigError.js +4 -0
- package/dist_esm/errors/BuildConfigError.js.map +1 -0
- package/dist_esm/errors/BuildStepInputError.d.ts +3 -0
- package/dist_esm/errors/BuildStepInputError.js +4 -0
- package/dist_esm/errors/BuildStepInputError.js.map +1 -0
- package/dist_esm/errors/BuildStepOutputError.d.ts +3 -0
- package/dist_esm/errors/BuildStepOutputError.js +4 -0
- package/dist_esm/errors/BuildStepOutputError.js.map +1 -0
- package/dist_esm/errors/BuildStepRuntimeError.d.ts +3 -0
- package/dist_esm/errors/BuildStepRuntimeError.js +4 -0
- package/dist_esm/errors/BuildStepRuntimeError.js.map +1 -0
- package/dist_esm/errors/BuildWorkflowError.d.ts +10 -0
- package/dist_esm/errors/BuildWorkflowError.js +9 -0
- package/dist_esm/errors/BuildWorkflowError.js.map +1 -0
- package/dist_esm/errors/UserError.d.ts +9 -0
- package/dist_esm/errors/UserError.js +10 -0
- package/dist_esm/errors/UserError.js.map +1 -0
- package/dist_esm/index.d.ts +2 -0
- package/dist_esm/index.js +3 -0
- package/dist_esm/index.js.map +1 -0
- package/dist_esm/utils/expodash/uniq.d.ts +1 -0
- package/dist_esm/utils/expodash/uniq.js +5 -0
- package/dist_esm/utils/expodash/uniq.js.map +1 -0
- package/dist_esm/utils/nullthrows.d.ts +1 -0
- package/dist_esm/utils/nullthrows.js +7 -0
- package/dist_esm/utils/nullthrows.js.map +1 -0
- package/dist_esm/utils/shell/bin.d.ts +1 -0
- package/dist_esm/utils/shell/bin.js +5 -0
- package/dist_esm/utils/shell/bin.js.map +1 -0
- package/dist_esm/utils/shell/command.d.ts +6 -0
- package/dist_esm/utils/shell/command.js +28 -0
- package/dist_esm/utils/shell/command.js.map +1 -0
- package/dist_esm/utils/shell/spawn.d.ts +9 -0
- package/dist_esm/utils/shell/spawn.js +18 -0
- package/dist_esm/utils/shell/spawn.js.map +1 -0
- package/dist_esm/utils/shell/temporaryFiles.d.ts +4 -0
- package/dist_esm/utils/shell/temporaryFiles.js +33 -0
- package/dist_esm/utils/shell/temporaryFiles.js.map +1 -0
- package/dist_esm/utils/template.d.ts +11 -0
- package/dist_esm/utils/template.js +40 -0
- package/dist_esm/utils/template.js.map +1 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @expo/steps
|
|
2
|
+
|
|
3
|
+
TBD
|
|
4
|
+
|
|
5
|
+
### Examples
|
|
6
|
+
|
|
7
|
+
If you want to run config examples from the **examples** directory, e.g. **examples/simple**, follow the steps:
|
|
8
|
+
|
|
9
|
+
- Run `yarn` and `yarn build` in the root of the monorepo.
|
|
10
|
+
- Add `alias eas-steps="/REPLACE/WITH/PATH/TO/eas-build/packages/steps/cli.sh"` to your **.zshrc**/**.bashrc**/etc.
|
|
11
|
+
- cd into **examples/simple** and run `eas-steps config.yml project`. The first argument is the config file, and the second is the default working directory for the config file.
|
package/bin/set-output
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
NAME=$1
|
|
4
|
+
VALUE=$2
|
|
5
|
+
|
|
6
|
+
if [[ -z "$__EXPO_STEPS_OUTPUTS_DIR" ]]; then
|
|
7
|
+
echo "Set __EXPO_STEPS_OUTPUTS_DIR"
|
|
8
|
+
exit 1
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
if [[ -z "$NAME" || -z "$VALUE" ]]; then
|
|
12
|
+
echo "Usage: set-output NAME VALUE"
|
|
13
|
+
exit 2
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
echo $VALUE > $__EXPO_STEPS_OUTPUTS_DIR/$NAME
|
|
@@ -0,0 +1,50 @@
|
|
|
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.validateBuildConfig = exports.BuildConfigSchema = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const BuildConfigError_js_1 = require("./errors/BuildConfigError.cjs");
|
|
9
|
+
exports.BuildConfigSchema = joi_1.default.object({
|
|
10
|
+
build: joi_1.default.object({
|
|
11
|
+
name: joi_1.default.string(),
|
|
12
|
+
steps: joi_1.default.array()
|
|
13
|
+
.items(joi_1.default.object({
|
|
14
|
+
run: joi_1.default.alternatives().conditional('run', {
|
|
15
|
+
is: joi_1.default.string(),
|
|
16
|
+
then: joi_1.default.string().required(),
|
|
17
|
+
otherwise: joi_1.default.object({
|
|
18
|
+
id: joi_1.default.string(),
|
|
19
|
+
inputs: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()),
|
|
20
|
+
outputs: joi_1.default.array().items(joi_1.default.alternatives().try(joi_1.default.string().required(), joi_1.default.object({
|
|
21
|
+
name: joi_1.default.string().required(),
|
|
22
|
+
required: joi_1.default.boolean(),
|
|
23
|
+
}).required())),
|
|
24
|
+
name: joi_1.default.string(),
|
|
25
|
+
workingDirectory: joi_1.default.string(),
|
|
26
|
+
shell: joi_1.default.string(),
|
|
27
|
+
command: joi_1.default.string().required(),
|
|
28
|
+
})
|
|
29
|
+
.rename('working_directory', 'workingDirectory')
|
|
30
|
+
.required(),
|
|
31
|
+
}),
|
|
32
|
+
}))
|
|
33
|
+
.required(),
|
|
34
|
+
}).required(),
|
|
35
|
+
}).required();
|
|
36
|
+
function validateBuildConfig(rawConfig) {
|
|
37
|
+
const { error, value } = exports.BuildConfigSchema.validate(rawConfig, {
|
|
38
|
+
allowUnknown: false,
|
|
39
|
+
abortEarly: false,
|
|
40
|
+
});
|
|
41
|
+
if (error) {
|
|
42
|
+
const errorMessage = error.details.map(({ message }) => message).join(', ');
|
|
43
|
+
throw new BuildConfigError_js_1.BuildConfigError(errorMessage, { cause: error });
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.validateBuildConfig = validateBuildConfig;
|
|
50
|
+
//# sourceMappingURL=BuildConfig.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AAEtB,sEAAgE;AAmCnD,QAAA,iBAAiB,GAAG,aAAG,CAAC,MAAM,CAAc;IACvD,KAAK,EAAE,aAAG,CAAC,MAAM,CAAC;QAChB,IAAI,EAAE,aAAG,CAAC,MAAM,EAAE;QAClB,KAAK,EAAE,aAAG,CAAC,KAAK,EAAE;aACf,KAAK,CACJ,aAAG,CAAC,MAAM,CAAC;YACT,GAAG,EAAE,aAAG,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE;gBACzC,EAAE,EAAE,aAAG,CAAC,MAAM,EAAE;gBAChB,IAAI,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;gBAC7B,SAAS,EAAE,aAAG,CAAC,MAAM,CAAC;oBACpB,EAAE,EAAE,aAAG,CAAC,MAAM,EAAE;oBAChB,MAAM,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAG,CAAC,MAAM,EAAE,EAAE,aAAG,CAA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AC;AAXD,kDAWC","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,87 @@
|
|
|
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.BuildConfigParser = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
11
|
+
const BuildConfig_js_1 = require("./BuildConfig.cjs");
|
|
12
|
+
const BuildStep_js_1 = require("./BuildStep.cjs");
|
|
13
|
+
const BuildStepInput_js_1 = require("./BuildStepInput.cjs");
|
|
14
|
+
const BuildStepOutput_js_1 = require("./BuildStepOutput.cjs");
|
|
15
|
+
const BuildWorkflow_js_1 = require("./BuildWorkflow.cjs");
|
|
16
|
+
const BuildWorkflowValidator_js_1 = require("./BuildWorkflowValidator.cjs");
|
|
17
|
+
class BuildConfigParser {
|
|
18
|
+
constructor(ctx, { configPath }) {
|
|
19
|
+
this.ctx = ctx;
|
|
20
|
+
this.configPath = configPath;
|
|
21
|
+
}
|
|
22
|
+
async parseAsync() {
|
|
23
|
+
const rawConfig = await this.readRawConfigAsync();
|
|
24
|
+
const config = (0, BuildConfig_js_1.validateBuildConfig)(rawConfig);
|
|
25
|
+
const steps = config.build.steps.map((stepConfig) => this.createBuildStepFromConfig(stepConfig));
|
|
26
|
+
const workflow = new BuildWorkflow_js_1.BuildWorkflow({ buildSteps: steps });
|
|
27
|
+
new BuildWorkflowValidator_js_1.BuildWorkflowValidator(workflow).validate();
|
|
28
|
+
return workflow;
|
|
29
|
+
}
|
|
30
|
+
async readRawConfigAsync() {
|
|
31
|
+
const contents = await fs_1.default.promises.readFile(this.configPath, 'utf-8');
|
|
32
|
+
return yaml_1.default.parse(contents);
|
|
33
|
+
}
|
|
34
|
+
createBuildStepFromConfig(buildStepConfig) {
|
|
35
|
+
if (typeof buildStepConfig === 'string') {
|
|
36
|
+
// TODO: implement calling functions
|
|
37
|
+
throw new Error('Not implemented yet');
|
|
38
|
+
}
|
|
39
|
+
else if (typeof buildStepConfig.run === 'string') {
|
|
40
|
+
const command = buildStepConfig.run;
|
|
41
|
+
return new BuildStep_js_1.BuildStep(this.ctx, {
|
|
42
|
+
id: (0, uuid_1.v4)(),
|
|
43
|
+
workingDirectory: this.ctx.workingDirectory,
|
|
44
|
+
command,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const { id, inputs: inputsConfig, outputs: outputsConfig, name, workingDirectory, shell, command, } = buildStepConfig.run;
|
|
49
|
+
const stepId = id !== null && id !== void 0 ? id : (0, uuid_1.v4)();
|
|
50
|
+
const inputs = inputsConfig && this.createBuildStepInputsFromConfig(inputsConfig, stepId);
|
|
51
|
+
const outputs = outputsConfig && this.createBuildStepOutputsFromConfig(outputsConfig, stepId);
|
|
52
|
+
return new BuildStep_js_1.BuildStep(this.ctx, {
|
|
53
|
+
id: stepId,
|
|
54
|
+
inputs,
|
|
55
|
+
outputs,
|
|
56
|
+
name,
|
|
57
|
+
workingDirectory: workingDirectory !== undefined
|
|
58
|
+
? path_1.default.resolve(this.ctx.workingDirectory, workingDirectory)
|
|
59
|
+
: this.ctx.workingDirectory,
|
|
60
|
+
shell,
|
|
61
|
+
command,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
createBuildStepInputsFromConfig(buildStepInputsConfig, stepId) {
|
|
66
|
+
return Object.entries(buildStepInputsConfig).map(([key, value]) => new BuildStepInput_js_1.BuildStepInput(this.ctx, {
|
|
67
|
+
id: key,
|
|
68
|
+
stepId,
|
|
69
|
+
defaultValue: value,
|
|
70
|
+
required: true,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
createBuildStepOutputsFromConfig(buildStepOutputsConfig, stepId) {
|
|
74
|
+
return buildStepOutputsConfig.map((entry) => {
|
|
75
|
+
var _a;
|
|
76
|
+
return typeof entry === 'string'
|
|
77
|
+
? new BuildStepOutput_js_1.BuildStepOutput(this.ctx, { id: entry, stepId, required: true })
|
|
78
|
+
: new BuildStepOutput_js_1.BuildStepOutput(this.ctx, {
|
|
79
|
+
id: entry.name,
|
|
80
|
+
stepId,
|
|
81
|
+
required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.BuildConfigParser = BuildConfigParser;
|
|
87
|
+
//# sourceMappingURL=BuildConfigParser.js.map
|
|
@@ -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 @@
|
|
|
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;IAEM,KAAK,CAAC,UAAU;QACrB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAClD,MAAM,MAAM,GAAG,IAAA,oCAAmB,EAAC,SAAS,CAAC,CAAC;QAC9C,MAAM,KAAK,GAAG,M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I;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"]}
|
|
@@ -0,0 +1,146 @@
|
|
|
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.BuildStep = exports.BuildStepStatus = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
const bin_js_1 = require("./utils/shell/bin.cjs");
|
|
11
|
+
const command_js_1 = require("./utils/shell/command.cjs");
|
|
12
|
+
const temporaryFiles_js_1 = require("./utils/shell/temporaryFiles.cjs");
|
|
13
|
+
const spawn_js_1 = require("./utils/shell/spawn.cjs");
|
|
14
|
+
const template_js_1 = require("./utils/template.cjs");
|
|
15
|
+
const BuildStepRuntimeError_js_1 = require("./errors/BuildStepRuntimeError.cjs");
|
|
16
|
+
var BuildStepStatus;
|
|
17
|
+
(function (BuildStepStatus) {
|
|
18
|
+
BuildStepStatus["NEW"] = "new";
|
|
19
|
+
BuildStepStatus["IN_PROGRESS"] = "in-progress";
|
|
20
|
+
BuildStepStatus["CANCELED"] = "canceled";
|
|
21
|
+
BuildStepStatus["FAILED"] = "failed";
|
|
22
|
+
BuildStepStatus["SUCCEEDED"] = "succeeded";
|
|
23
|
+
})(BuildStepStatus = exports.BuildStepStatus || (exports.BuildStepStatus = {}));
|
|
24
|
+
class BuildStep {
|
|
25
|
+
constructor(ctx, { id, name, inputs, outputs, command, workingDirectory, shell, }) {
|
|
26
|
+
this.ctx = ctx;
|
|
27
|
+
this.executed = false;
|
|
28
|
+
this.id = id;
|
|
29
|
+
this.name = name;
|
|
30
|
+
this.inputs = inputs;
|
|
31
|
+
this.outputs = outputs;
|
|
32
|
+
this.outputById =
|
|
33
|
+
outputs === undefined
|
|
34
|
+
? {}
|
|
35
|
+
: outputs.reduce((acc, output) => {
|
|
36
|
+
acc[output.id] = output;
|
|
37
|
+
return acc;
|
|
38
|
+
}, {});
|
|
39
|
+
this.command = command;
|
|
40
|
+
this.workingDirectory = workingDirectory;
|
|
41
|
+
this.shell = shell !== null && shell !== void 0 ? shell : (0, command_js_1.getDefaultShell)();
|
|
42
|
+
this.status = BuildStepStatus.NEW;
|
|
43
|
+
this.internalId = (0, uuid_1.v4)();
|
|
44
|
+
this.logger = ctx.logger.child({ buildStepInternalId: this.internalId, buildStepId: this.id });
|
|
45
|
+
ctx.registerStep(this);
|
|
46
|
+
}
|
|
47
|
+
async executeAsync() {
|
|
48
|
+
try {
|
|
49
|
+
this.logger.debug(`Executing build step "${this.id}"`);
|
|
50
|
+
this.status = BuildStepStatus.IN_PROGRESS;
|
|
51
|
+
const command = this.interpolateInputsInCommand(this.command, this.inputs);
|
|
52
|
+
this.logger.debug(`Interpolated inputs in the command template`);
|
|
53
|
+
const outputsDir = await (0, temporaryFiles_js_1.createTemporaryOutputsDirectoryAsync)(this.ctx, this.id);
|
|
54
|
+
this.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);
|
|
55
|
+
const scriptPath = await (0, temporaryFiles_js_1.saveScriptToTemporaryFileAsync)(this.ctx, this.id, command);
|
|
56
|
+
this.logger.debug(`Saved script to ${scriptPath}`);
|
|
57
|
+
const { command: shellCommand, args } = (0, command_js_1.getShellCommandAndArgs)(this.shell, scriptPath);
|
|
58
|
+
this.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
|
|
59
|
+
await (0, spawn_js_1.spawnAsync)(shellCommand, args !== null && args !== void 0 ? args : [], {
|
|
60
|
+
cwd: this.workingDirectory,
|
|
61
|
+
logger: this.logger,
|
|
62
|
+
env: this.getScriptEnv(outputsDir),
|
|
63
|
+
});
|
|
64
|
+
this.logger.debug(`Script completed successfully`);
|
|
65
|
+
await this.collectAndValidateOutputsAsync(outputsDir);
|
|
66
|
+
this.logger.debug('Finished collecting output paramters');
|
|
67
|
+
this.logger.debug('Finished successfully');
|
|
68
|
+
this.status = BuildStepStatus.SUCCEEDED;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
this.status = BuildStepStatus.FAILED;
|
|
72
|
+
throw err;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
this.executed = true;
|
|
76
|
+
await (0, temporaryFiles_js_1.cleanUpTemporaryDirectoriesAsync)(this.ctx, this.id);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
hasOutputParameter(name) {
|
|
80
|
+
return name in this.outputById;
|
|
81
|
+
}
|
|
82
|
+
getOutputValueByName(name) {
|
|
83
|
+
if (!this.executed) {
|
|
84
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.id}". The step has not been executed yet.`);
|
|
85
|
+
}
|
|
86
|
+
if (!this.hasOutputParameter(name)) {
|
|
87
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Step "${this.id}" does not have output "${name}"`);
|
|
88
|
+
}
|
|
89
|
+
return this.outputById[name].value;
|
|
90
|
+
}
|
|
91
|
+
interpolateInputsInCommand(command, inputs) {
|
|
92
|
+
if (!inputs) {
|
|
93
|
+
return command;
|
|
94
|
+
}
|
|
95
|
+
const vars = inputs.reduce((acc, input) => {
|
|
96
|
+
var _a;
|
|
97
|
+
acc[input.id] = (_a = input.value) !== null && _a !== void 0 ? _a : '';
|
|
98
|
+
return acc;
|
|
99
|
+
}, {});
|
|
100
|
+
return (0, template_js_1.interpolateWithInputs)(command, vars);
|
|
101
|
+
}
|
|
102
|
+
async collectAndValidateOutputsAsync(outputsDir) {
|
|
103
|
+
var _a;
|
|
104
|
+
const files = await fs_1.default.promises.readdir(outputsDir);
|
|
105
|
+
const nonDefinedOutputIds = [];
|
|
106
|
+
for (const outputId of files) {
|
|
107
|
+
if (!(outputId in this.outputById)) {
|
|
108
|
+
nonDefinedOutputIds.push(outputId);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const file = path_1.default.join(outputsDir, outputId);
|
|
112
|
+
const rawContents = await fs_1.default.promises.readFile(file, 'utf-8');
|
|
113
|
+
const value = rawContents.trim();
|
|
114
|
+
this.outputById[outputId].set(value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (nonDefinedOutputIds.length > 0) {
|
|
118
|
+
const idsString = nonDefinedOutputIds.map((i) => `"${i}"`).join(', ');
|
|
119
|
+
this.logger.warn(`Some outputs are not defined in step config: ${idsString}`);
|
|
120
|
+
}
|
|
121
|
+
const nonSetRequiredOutputIds = [];
|
|
122
|
+
for (const output of (_a = this.outputs) !== null && _a !== void 0 ? _a : []) {
|
|
123
|
+
try {
|
|
124
|
+
const value = output.value;
|
|
125
|
+
this.logger.debug(`Output parameter "${output.id}" is set to "${value}"`);
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
this.logger.debug({ err }, `Getting value for output parameter "${output.id}" failed.`);
|
|
129
|
+
nonSetRequiredOutputIds.push(output.id);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (nonSetRequiredOutputIds.length > 0) {
|
|
133
|
+
const idsString = nonSetRequiredOutputIds.map((i) => `"${i}"`).join(', ');
|
|
134
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Some required output parameters have not been set: ${idsString}`, { metadata: { ids: nonSetRequiredOutputIds } });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
getScriptEnv(outputsDir) {
|
|
138
|
+
return {
|
|
139
|
+
...process.env,
|
|
140
|
+
__EXPO_STEPS_OUTPUTS_DIR: outputsDir,
|
|
141
|
+
PATH: `${bin_js_1.BIN_PATH}:${process.env.PATH}`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.BuildStep = BuildStep;
|
|
146
|
+
//# sourceMappingURL=BuildStep.js.map
|
|
@@ -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 @@
|
|
|
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,eAMX;AAND,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;IACjB,0CAAuB,CAAA;AACzB,CAAC,EANW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAM1B;AAED,MAAa,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,CAAC;QAsBvB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,C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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,gDAAqB,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,iBAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE;SACxC,CAAC;IACJ,CAAC;CACF;AAzKD,8BAyKC","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,32 @@
|
|
|
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.BuildStepContext = void 0;
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const template_js_1 = require("./utils/template.cjs");
|
|
10
|
+
const BuildStepRuntimeError_js_1 = require("./errors/BuildStepRuntimeError.cjs");
|
|
11
|
+
class BuildStepContext {
|
|
12
|
+
constructor(buildId, logger, skipCleanup, workingDirectory) {
|
|
13
|
+
this.buildId = buildId;
|
|
14
|
+
this.logger = logger;
|
|
15
|
+
this.skipCleanup = skipCleanup;
|
|
16
|
+
this.stepById = {};
|
|
17
|
+
this.baseWorkingDirectory = path_1.default.join(os_1.default.tmpdir(), 'eas-build', buildId);
|
|
18
|
+
this.workingDirectory = workingDirectory !== null && workingDirectory !== void 0 ? workingDirectory : path_1.default.join(this.baseWorkingDirectory, 'project');
|
|
19
|
+
}
|
|
20
|
+
registerStep(step) {
|
|
21
|
+
this.stepById[step.id] = step;
|
|
22
|
+
}
|
|
23
|
+
getStepOutputValue(path) {
|
|
24
|
+
const { stepId, outputId } = (0, template_js_1.parseOutputPath)(path);
|
|
25
|
+
if (!(stepId in this.stepById)) {
|
|
26
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Step "${stepId}" does not exist.`);
|
|
27
|
+
}
|
|
28
|
+
return this.stepById[stepId].getOutputValueByName(outputId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BuildStepContext = BuildStepContext;
|
|
32
|
+
//# sourceMappingURL=BuildStepContext.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAKxB,qDAAsD;AACtD,gFAA0E;AAE1E,MAAa,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,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;QACzE,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,cAAI,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,IAAA,6BAAe,EAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC9B,MAAM,IAAI,gDAAqB,CAAC,SAAS,MAAM,mBAAmB,CAAC,CAAC;SACrE;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF;AA3BD,4CA2BC","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,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildStepInput = void 0;
|
|
4
|
+
const BuildStepRuntimeError_js_1 = require("./errors/BuildStepRuntimeError.cjs");
|
|
5
|
+
const template_js_1 = require("./utils/template.cjs");
|
|
6
|
+
class BuildStepInput {
|
|
7
|
+
constructor(ctx, { id, stepId, defaultValue, required = false, }) {
|
|
8
|
+
this.ctx = ctx;
|
|
9
|
+
this.id = id;
|
|
10
|
+
this.stepId = stepId;
|
|
11
|
+
this.defaultValue = defaultValue;
|
|
12
|
+
this.required = required;
|
|
13
|
+
}
|
|
14
|
+
get value() {
|
|
15
|
+
var _a;
|
|
16
|
+
const rawValue = (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
|
|
17
|
+
if (this.required && rawValue === undefined) {
|
|
18
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepId}" is required but it was not set.`);
|
|
19
|
+
}
|
|
20
|
+
if (rawValue === undefined) {
|
|
21
|
+
return rawValue;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return (0, template_js_1.interpolateWithOutputs)(rawValue, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
set(value) {
|
|
28
|
+
if (this.required && value === undefined) {
|
|
29
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepId}" is required.`);
|
|
30
|
+
}
|
|
31
|
+
this._value = value;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.BuildStepInput = BuildStepInput;
|
|
36
|
+
//# sourceMappingURL=BuildStepInput.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":";;;AACA,gFAA0E;AAC1E,qDAA6D;AAE7D,MAAa,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,gDAAqB,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,IAAA,oCAAsB,EAAC,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,gDAAqB,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;AApDD,wCAoDC","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,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildStepOutput = void 0;
|
|
4
|
+
const BuildStepRuntimeError_js_1 = require("./errors/BuildStepRuntimeError.cjs");
|
|
5
|
+
class BuildStepOutput {
|
|
6
|
+
constructor(
|
|
7
|
+
// @ts-expect-error ctx is not used in this class but let's keep it here for consistency
|
|
8
|
+
ctx, { id, stepId, required = true }) {
|
|
9
|
+
this.ctx = ctx;
|
|
10
|
+
this.id = id;
|
|
11
|
+
this.stepId = stepId;
|
|
12
|
+
this.required = required;
|
|
13
|
+
}
|
|
14
|
+
get value() {
|
|
15
|
+
if (this.required && this._value === undefined) {
|
|
16
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required but it was not set.`);
|
|
17
|
+
}
|
|
18
|
+
return this._value;
|
|
19
|
+
}
|
|
20
|
+
set(value) {
|
|
21
|
+
if (this.required && value === undefined) {
|
|
22
|
+
throw new BuildStepRuntimeError_js_1.BuildStepRuntimeError(`Output parameter "${this.id}" for step "${this.stepId}" is required.`);
|
|
23
|
+
}
|
|
24
|
+
this._value = value;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.BuildStepOutput = BuildStepOutput;
|
|
29
|
+
//# sourceMappingURL=BuildStepOutput.js.map
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"BuildStepOutput.js","sourceRoot":"","sources":["../src/BuildStepOutput.ts"],"names":[],"mappings":";;;AACA,gFAA0E;AAE1E,MAAa,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,gDAAqB,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,gDAAqB,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;AAnCD,0CAmCC","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,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildWorkflow = void 0;
|
|
4
|
+
class BuildWorkflow {
|
|
5
|
+
constructor({ buildSteps }) {
|
|
6
|
+
this.buildSteps = buildSteps;
|
|
7
|
+
}
|
|
8
|
+
async executeAsync() {
|
|
9
|
+
for (const step of this.buildSteps) {
|
|
10
|
+
await step.executeAsync();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.BuildWorkflow = BuildWorkflow;
|
|
15
|
+
//# sourceMappingURL=BuildWorkflow.js.map
|