@expo/steps 1.0.23 → 1.0.25
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/bin/set-env +23 -0
- package/dist_commonjs/BuildConfig.cjs +21 -5
- package/dist_commonjs/BuildConfig.d.ts +2 -0
- package/dist_commonjs/BuildConfig.js.map +1 -1
- package/dist_commonjs/BuildConfigParser.cjs +6 -2
- package/dist_commonjs/BuildConfigParser.d.ts +2 -2
- package/dist_commonjs/BuildConfigParser.js.map +1 -1
- package/dist_commonjs/BuildFunction.cjs +2 -1
- package/dist_commonjs/BuildFunction.d.ts +4 -2
- package/dist_commonjs/BuildFunction.js.map +1 -1
- package/dist_commonjs/BuildStep.cjs +49 -22
- package/dist_commonjs/BuildStep.d.ts +7 -4
- package/dist_commonjs/BuildStep.js.map +1 -1
- package/dist_commonjs/BuildStepContext.cjs +50 -13
- package/dist_commonjs/BuildStepContext.d.ts +35 -10
- package/dist_commonjs/BuildStepContext.js.map +1 -1
- package/dist_commonjs/BuildStepInput.cjs +59 -5
- package/dist_commonjs/BuildStepInput.d.ts +11 -5
- package/dist_commonjs/BuildStepInput.js.map +1 -1
- package/dist_commonjs/BuildStepOutput.d.ts +3 -3
- package/dist_commonjs/BuildStepOutput.js.map +1 -1
- package/dist_commonjs/BuildTemporaryFiles.cjs +11 -2
- package/dist_commonjs/BuildTemporaryFiles.d.ts +5 -4
- package/dist_commonjs/BuildTemporaryFiles.js.map +1 -1
- package/dist_commonjs/BuildWorkflow.cjs +2 -2
- package/dist_commonjs/BuildWorkflow.d.ts +3 -4
- package/dist_commonjs/BuildWorkflow.js.map +1 -1
- package/dist_commonjs/BuildWorkflowValidator.cjs +10 -3
- package/dist_commonjs/BuildWorkflowValidator.js.map +1 -1
- package/dist_commonjs/cli/cli.cjs +22 -3
- package/dist_commonjs/cli/cli.d.ts +16 -1
- package/dist_commonjs/cli/cli.js.map +1 -1
- package/dist_commonjs/index.cjs +2 -2
- package/dist_commonjs/index.d.ts +2 -1
- package/dist_commonjs/index.js.map +1 -1
- package/dist_commonjs/utils/template.cjs +40 -8
- package/dist_commonjs/utils/template.d.ts +5 -1
- package/dist_commonjs/utils/template.js.map +1 -1
- package/dist_esm/BuildConfig.d.ts +2 -0
- package/dist_esm/BuildConfig.js +21 -5
- package/dist_esm/BuildConfig.js.map +1 -1
- package/dist_esm/BuildConfigParser.d.ts +2 -2
- package/dist_esm/BuildConfigParser.js +7 -3
- package/dist_esm/BuildConfigParser.js.map +1 -1
- package/dist_esm/BuildFunction.d.ts +4 -2
- package/dist_esm/BuildFunction.js +2 -1
- package/dist_esm/BuildFunction.js.map +1 -1
- package/dist_esm/BuildStep.d.ts +7 -4
- package/dist_esm/BuildStep.js +50 -23
- package/dist_esm/BuildStep.js.map +1 -1
- package/dist_esm/BuildStepContext.d.ts +35 -10
- package/dist_esm/BuildStepContext.js +49 -13
- package/dist_esm/BuildStepContext.js.map +1 -1
- package/dist_esm/BuildStepInput.d.ts +11 -5
- package/dist_esm/BuildStepInput.js +60 -6
- package/dist_esm/BuildStepInput.js.map +1 -1
- package/dist_esm/BuildStepOutput.d.ts +3 -3
- package/dist_esm/BuildStepOutput.js.map +1 -1
- package/dist_esm/BuildTemporaryFiles.d.ts +5 -4
- package/dist_esm/BuildTemporaryFiles.js +9 -1
- package/dist_esm/BuildTemporaryFiles.js.map +1 -1
- package/dist_esm/BuildWorkflow.d.ts +3 -4
- package/dist_esm/BuildWorkflow.js +2 -2
- package/dist_esm/BuildWorkflow.js.map +1 -1
- package/dist_esm/BuildWorkflowValidator.js +10 -3
- package/dist_esm/BuildWorkflowValidator.js.map +1 -1
- package/dist_esm/cli/cli.d.ts +16 -1
- package/dist_esm/cli/cli.js +21 -4
- package/dist_esm/cli/cli.js.map +1 -1
- package/dist_esm/index.d.ts +2 -1
- package/dist_esm/index.js +1 -1
- package/dist_esm/index.js.map +1 -1
- package/dist_esm/utils/template.d.ts +5 -1
- package/dist_esm/utils/template.js +35 -8
- package/dist_esm/utils/template.js.map +1 -1
- package/package.json +4 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuildWorkflowValidator = void 0;
|
|
4
|
+
const BuildStepInput_js_1 = require("./BuildStepInput.cjs");
|
|
4
5
|
const errors_js_1 = require("./errors.cjs");
|
|
5
6
|
const duplicates_js_1 = require("./utils/expodash/duplicates.cjs");
|
|
6
7
|
const nullthrows_js_1 = require("./utils/nullthrows.cjs");
|
|
@@ -40,9 +41,15 @@ class BuildWorkflowValidator {
|
|
|
40
41
|
const error = new errors_js_1.BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is required but it was not set.`);
|
|
41
42
|
errors.push(error);
|
|
42
43
|
}
|
|
44
|
+
const currentType = typeof currentStepInput.rawValue === 'object'
|
|
45
|
+
? BuildStepInput_js_1.BuildStepInputValueTypeName.JSON
|
|
46
|
+
: typeof currentStepInput.rawValue;
|
|
43
47
|
if (currentStepInput.rawValue !== undefined &&
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
!currentStepInput.isRawValueStepOrContextReference() &&
|
|
49
|
+
currentType !== currentStepInput.allowedValueTypeName) {
|
|
50
|
+
const error = new errors_js_1.BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${typeof currentStepInput.rawValue === 'object'
|
|
51
|
+
? JSON.stringify(currentStepInput.rawValue)
|
|
52
|
+
: currentStepInput.rawValue}" which is not of type "${currentStepInput.allowedValueTypeName}" or is not step or context reference.`);
|
|
46
53
|
errors.push(error);
|
|
47
54
|
}
|
|
48
55
|
if (currentStepInput.defaultValue === undefined) {
|
|
@@ -84,7 +91,7 @@ class BuildWorkflowValidator {
|
|
|
84
91
|
const errors = [];
|
|
85
92
|
for (const step of this.workflow.buildSteps) {
|
|
86
93
|
if (!step.canBeRunOnRuntimePlatform()) {
|
|
87
|
-
const error = new errors_js_1.BuildConfigError(`Step "${step.displayName}" is not allowed on platform "${step.ctx.runtimePlatform}". Allowed platforms for this step are: ${(0, nullthrows_js_1.nullthrows)(step.supportedRuntimePlatforms, `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`)
|
|
94
|
+
const error = new errors_js_1.BuildConfigError(`Step "${step.displayName}" is not allowed on platform "${step.ctx.global.runtimePlatform}". Allowed platforms for this step are: ${(0, nullthrows_js_1.nullthrows)(step.supportedRuntimePlatforms, `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`)
|
|
88
95
|
.map((p) => `"${p}"`)
|
|
89
96
|
.join(', ')}.`);
|
|
90
97
|
errors.push(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":";;;AAEA,2CAAmE;AACnE,kEAA4D;AAC5D,yDAAmD;AACnD,qDAAsD;AAEtD,MAAa,sBAAsB;IACjC,YAA6B,QAAuB;QAAvB,aAAQ,GAAR,QAAQ,CAAe;IAAG,CAAC;IAEjD,QAAQ;QACb,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,8BAAkB,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;SACpE;IACH,CAAC;IAEO,qBAAqB;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAA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BuildWorkflow.js';\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { nullthrows } from './utils/nullthrows.js';\nimport { findOutputPaths } from './utils/template.js';\n\nexport class BuildWorkflowValidator {\n constructor(private readonly workflow: BuildWorkflow) {}\n\n public validate(): void {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n errors.push(...this.validateAllowedPlatforms());\n if (errors.length !== 0) {\n throw new BuildWorkflowError('Build workflow is invalid.', errors);\n }\n }\n\n private validateUniqueStepIds(): BuildConfigError[] {\n const stepIds = this.workflow.buildSteps.map(({ id }) => id);\n const duplicatedStepIds = duplicates(stepIds);\n if (duplicatedStepIds.length === 0) {\n return [];\n } else {\n const error = new BuildConfigError(\n `Duplicated step IDs: ${duplicatedStepIds.map((i) => `\"${i}\"`).join(', ')}`\n );\n return [error];\n }\n }\n\n private validateInputs(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n\n const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));\n const visitedStepByStepId: Record<string, BuildStep> = {};\n for (const currentStep of this.workflow.buildSteps) {\n for (const currentStepInput of currentStep.inputs ?? []) {\n if (currentStepInput.required && currentStepInput.rawValue === undefined) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is required but it was not set.`\n );\n errors.push(error);\n }\n\n if (\n currentStepInput.rawValue !== undefined &&\n typeof currentStepInput.rawValue !== currentStepInput.allowedValueTypeName\n ) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is set to \"${currentStepInput.rawValue}\" which is not of type \"${currentStepInput.allowedValueTypeName}\".`\n );\n errors.push(error);\n }\n\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n if (!currentStepInput.isValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n currentStepInput.value\n }\" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)\n .map((i) => `\"${i}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n const paths =\n typeof currentStepInput.defaultValue === 'string'\n ? findOutputPaths(currentStepInput.defaultValue)\n : [];\n for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {\n if (!(referencedStepId in visitedStepByStepId)) {\n if (allStepIds.has(referencedStepId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from the future step \"${referencedStepId}\".`\n );\n errors.push(error);\n } else {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from a non-existent step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n } else {\n if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an undefined output parameter \"${referencedStepOutputId}\" from step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n }\n }\n }\n visitedStepByStepId[currentStep.id] = currentStep;\n }\n\n return errors;\n }\n\n private validateAllowedPlatforms(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n for (const step of this.workflow.buildSteps) {\n if (!step.canBeRunOnRuntimePlatform()) {\n const error = new BuildConfigError(\n `Step \"${step.displayName}\" is not allowed on platform \"${\n step.ctx.runtimePlatform\n }\". Allowed platforms for this step are: ${nullthrows(\n step.supportedRuntimePlatforms,\n `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`\n )\n .map((p) => `\"${p}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"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AgB,CAAC,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,EAAE;4BACrF,MAAM,KAAK,GAAG,IAAI,4BAAgB,CAChC,oBAAoB,gBAAgB,CAAC,EAAE,eAAe,WAAW,CAAC,WAAW,uEAAuE,sBAAsB,gBAAgB,gBAAgB,IAAI,CAC/M,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;qBACF;iBACF;aACF;YACD,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;SACnD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,wBAAwB;QAC9B,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;YAC3C,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE;gBACrC,MAAM,KAAK,GAAG,IAAI,4BAAgB,CAChC,SAAS,IAAI,CAAC,WAAW,iCACvB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,eAClB,2CAA2C,IAAA,0BAAU,EACnD,IAAI,CAAC,yBAAyB,EAC9B,uFAAuF,CACxF;qBACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;qBACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlID,wDAkIC","sourcesContent":["import { BuildStep } from './BuildStep.js';\nimport { BuildStepInputValueTypeName } from './BuildStepInput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { nullthrows } from './utils/nullthrows.js';\nimport { findOutputPaths } from './utils/template.js';\n\nexport class BuildWorkflowValidator {\n constructor(private readonly workflow: BuildWorkflow) {}\n\n public validate(): void {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n errors.push(...this.validateAllowedPlatforms());\n if (errors.length !== 0) {\n throw new BuildWorkflowError('Build workflow is invalid.', errors);\n }\n }\n\n private validateUniqueStepIds(): BuildConfigError[] {\n const stepIds = this.workflow.buildSteps.map(({ id }) => id);\n const duplicatedStepIds = duplicates(stepIds);\n if (duplicatedStepIds.length === 0) {\n return [];\n } else {\n const error = new BuildConfigError(\n `Duplicated step IDs: ${duplicatedStepIds.map((i) => `\"${i}\"`).join(', ')}`\n );\n return [error];\n }\n }\n\n private validateInputs(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n\n const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));\n const visitedStepByStepId: Record<string, BuildStep> = {};\n for (const currentStep of this.workflow.buildSteps) {\n for (const currentStepInput of currentStep.inputs ?? []) {\n if (currentStepInput.required && currentStepInput.rawValue === undefined) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is required but it was not set.`\n );\n errors.push(error);\n }\n\n const currentType =\n typeof currentStepInput.rawValue === 'object'\n ? BuildStepInputValueTypeName.JSON\n : typeof currentStepInput.rawValue;\n if (\n currentStepInput.rawValue !== undefined &&\n !currentStepInput.isRawValueStepOrContextReference() &&\n currentType !== currentStepInput.allowedValueTypeName\n ) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n typeof currentStepInput.rawValue === 'object'\n ? JSON.stringify(currentStepInput.rawValue)\n : currentStepInput.rawValue\n }\" which is not of type \"${\n currentStepInput.allowedValueTypeName\n }\" or is not step or context reference.`\n );\n errors.push(error);\n }\n\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n if (!currentStepInput.isValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n currentStepInput.value\n }\" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)\n .map((i) => `\"${i}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n const paths =\n typeof currentStepInput.defaultValue === 'string'\n ? findOutputPaths(currentStepInput.defaultValue)\n : [];\n for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {\n if (!(referencedStepId in visitedStepByStepId)) {\n if (allStepIds.has(referencedStepId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from the future step \"${referencedStepId}\".`\n );\n errors.push(error);\n } else {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from a non-existent step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n } else {\n if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an undefined output parameter \"${referencedStepOutputId}\" from step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n }\n }\n }\n visitedStepByStepId[currentStep.id] = currentStep;\n }\n\n return errors;\n }\n\n private validateAllowedPlatforms(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n for (const step of this.workflow.buildSteps) {\n if (!step.canBeRunOnRuntimePlatform()) {\n const error = new BuildConfigError(\n `Step \"${step.displayName}\" is not allowed on platform \"${\n step.ctx.global.runtimePlatform\n }\". Allowed platforms for this step are: ${nullthrows(\n step.supportedRuntimePlatforms,\n `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`\n )\n .map((p) => `\"${p}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n}\n"]}
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.CliContextProvider = void 0;
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const logger_1 = require("@expo/logger");
|
|
9
|
-
const uuid_1 = require("uuid");
|
|
10
10
|
const BuildConfigParser_js_1 = require("../BuildConfigParser.cjs");
|
|
11
11
|
const BuildStepContext_js_1 = require("../BuildStepContext.cjs");
|
|
12
12
|
const errors_js_1 = require("../errors.cjs");
|
|
@@ -14,9 +14,28 @@ const logger = (0, logger_1.createLogger)({
|
|
|
14
14
|
name: 'steps-cli',
|
|
15
15
|
level: 'info',
|
|
16
16
|
});
|
|
17
|
+
class CliContextProvider {
|
|
18
|
+
constructor(logger, runtimePlatform, projectSourceDirectory, projectTargetDirectory, defaultWorkingDirectory) {
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
this.runtimePlatform = runtimePlatform;
|
|
21
|
+
this.projectSourceDirectory = projectSourceDirectory;
|
|
22
|
+
this.projectTargetDirectory = projectTargetDirectory;
|
|
23
|
+
this.defaultWorkingDirectory = defaultWorkingDirectory;
|
|
24
|
+
this._env = {};
|
|
25
|
+
}
|
|
26
|
+
get env() {
|
|
27
|
+
return this._env;
|
|
28
|
+
}
|
|
29
|
+
staticContext() {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
updateEnv(env) {
|
|
33
|
+
this._env = env;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.CliContextProvider = CliContextProvider;
|
|
17
37
|
async function runAsync(configPath, relativeProjectDirectory, runtimePlatform) {
|
|
18
|
-
const
|
|
19
|
-
const ctx = new BuildStepContext_js_1.BuildStepContext(fakeBuildId, logger, false, runtimePlatform, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory);
|
|
38
|
+
const ctx = new BuildStepContext_js_1.BuildStepGlobalContext(new CliContextProvider(logger, runtimePlatform, relativeProjectDirectory, relativeProjectDirectory, relativeProjectDirectory), false);
|
|
20
39
|
const parser = new BuildConfigParser_js_1.BuildConfigParser(ctx, { configPath });
|
|
21
40
|
const workflow = await parser.parseAsync();
|
|
22
41
|
await workflow.executeAsync();
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { bunyan } from '@expo/logger';
|
|
2
|
+
import { ExternalBuildContextProvider } from '../BuildStepContext.js';
|
|
3
|
+
import { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';
|
|
4
|
+
import { BuildStepEnv } from '../BuildStepEnv.js';
|
|
5
|
+
export declare class CliContextProvider implements ExternalBuildContextProvider {
|
|
6
|
+
readonly logger: bunyan;
|
|
7
|
+
readonly runtimePlatform: BuildRuntimePlatform;
|
|
8
|
+
readonly projectSourceDirectory: string;
|
|
9
|
+
readonly projectTargetDirectory: string;
|
|
10
|
+
readonly defaultWorkingDirectory: string;
|
|
11
|
+
private _env;
|
|
12
|
+
constructor(logger: bunyan, runtimePlatform: BuildRuntimePlatform, projectSourceDirectory: string, projectTargetDirectory: string, defaultWorkingDirectory: string);
|
|
13
|
+
get env(): BuildStepEnv;
|
|
14
|
+
staticContext(): any;
|
|
15
|
+
updateEnv(env: BuildStepEnv): void;
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;;;AAAA,gDAAwB;AAExB,yCAAoD;AAEpD,kEAA4D;AAC5D,gEAA8F;AAC9F,4CAAkD;AAIlD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC;IAC1B,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,MAAM;CACd,CAAC,CAAC;AAEH,MAAa,kBAAkB;IAG7B,YACkB,MAAc,EACd,eAAqC,EACrC,sBAA8B,EAC9B,sBAA8B,EAC9B,uBAA+B;QAJ/B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CAAC,CAAC,CAAC,CAAC;CACjB;AAED,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACnE,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,4BAA4B,CAAC,CAAC;AAEnF,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7D,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACtC,IAAI,GAAG,YAAY,8BAAkB,EAAE;QACrC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC9D,KAAK,MAAM,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE;YACpC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;SACpC;KACF;AACH,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { bunyan, createLogger } from '@expo/logger';\n\nimport { BuildConfigParser } from '../BuildConfigParser.js';\nimport { ExternalBuildContextProvider, BuildStepGlobalContext } from '../BuildStepContext.js';\nimport { BuildWorkflowError } from '../errors.js';\nimport { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';\nimport { BuildStepEnv } from '../BuildStepEnv.js';\n\nconst logger = createLogger({\n name: 'steps-cli',\n level: 'info',\n});\n\nexport class CliContextProvider implements ExternalBuildContextProvider {\n private _env: BuildStepEnv = {};\n\n constructor(\n public readonly logger: bunyan,\n public readonly runtimePlatform: BuildRuntimePlatform,\n public readonly projectSourceDirectory: string,\n public readonly projectTargetDirectory: string,\n public readonly defaultWorkingDirectory: string\n ) {}\n public get env(): BuildStepEnv {\n return this._env;\n }\n public staticContext(): any {\n return {};\n }\n public updateEnv(env: BuildStepEnv): void {\n this._env = env;\n }\n}\n\nasync function runAsync(\n configPath: string,\n relativeProjectDirectory: string,\n runtimePlatform: BuildRuntimePlatform\n): Promise<void> {\n const ctx = new BuildStepGlobalContext(\n new CliContextProvider(\n logger,\n runtimePlatform,\n relativeProjectDirectory,\n relativeProjectDirectory,\n relativeProjectDirectory\n ),\n false\n );\n const parser = new BuildConfigParser(ctx, { configPath });\n const workflow = await parser.parseAsync();\n await workflow.executeAsync();\n}\n\nconst relativeConfigPath = process.argv[2];\nconst relativeProjectDirectoryPath = process.argv[3];\nconst platform: BuildRuntimePlatform = (process.argv[4] ??\n process.platform) as BuildRuntimePlatform;\n\nif (!relativeConfigPath || !relativeProjectDirectoryPath) {\n console.error('Usage: yarn cli config.yml path/to/project/directory [darwin|linux]');\n process.exit(1);\n}\n\nconst configPath = path.resolve(process.cwd(), relativeConfigPath);\nconst workingDirectory = path.resolve(process.cwd(), relativeProjectDirectoryPath);\n\nrunAsync(configPath, workingDirectory, platform).catch((err) => {\n logger.error({ err }, 'Build failed');\n if (err instanceof BuildWorkflowError) {\n logger.error('Failed to parse the custom build config file.');\n for (const detailedErr of err.errors) {\n logger.error({ err: detailedErr });\n }\n }\n});\n"]}
|
package/dist_commonjs/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.errors = exports.BuildWorkflow = exports.
|
|
26
|
+
exports.errors = exports.BuildWorkflow = exports.BuildStepGlobalContext = exports.BuildStepOutput = exports.BuildStepInputValueTypeName = exports.BuildStepInput = exports.BuildRuntimePlatform = exports.BuildFunction = exports.BuildConfigParser = exports.readAndValidateBuildConfigAsync = void 0;
|
|
27
27
|
var BuildConfig_js_1 = require("./BuildConfig.cjs");
|
|
28
28
|
Object.defineProperty(exports, "readAndValidateBuildConfigAsync", { enumerable: true, get: function () { return BuildConfig_js_1.readAndValidateBuildConfigAsync; } });
|
|
29
29
|
var BuildConfigParser_js_1 = require("./BuildConfigParser.cjs");
|
|
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "BuildStepInputValueTypeName", { enumerable: true
|
|
|
38
38
|
var BuildStepOutput_js_1 = require("./BuildStepOutput.cjs");
|
|
39
39
|
Object.defineProperty(exports, "BuildStepOutput", { enumerable: true, get: function () { return BuildStepOutput_js_1.BuildStepOutput; } });
|
|
40
40
|
var BuildStepContext_js_1 = require("./BuildStepContext.cjs");
|
|
41
|
-
Object.defineProperty(exports, "
|
|
41
|
+
Object.defineProperty(exports, "BuildStepGlobalContext", { enumerable: true, get: function () { return BuildStepContext_js_1.BuildStepGlobalContext; } });
|
|
42
42
|
var BuildWorkflow_js_1 = require("./BuildWorkflow.cjs");
|
|
43
43
|
Object.defineProperty(exports, "BuildWorkflow", { enumerable: true, get: function () { return BuildWorkflow_js_1.BuildWorkflow; } });
|
|
44
44
|
exports.errors = __importStar(require("./errors.cjs"));
|
package/dist_commonjs/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { BuildFunction } from './BuildFunction.js';
|
|
|
4
4
|
export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
5
5
|
export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
6
6
|
export { BuildStepOutput } from './BuildStepOutput.js';
|
|
7
|
-
export {
|
|
7
|
+
export { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';
|
|
8
8
|
export { BuildWorkflow } from './BuildWorkflow.js';
|
|
9
|
+
export { BuildStepEnv } from './BuildStepEnv.js';
|
|
9
10
|
export * as errors from './errors.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAmE;AAA1D,iIAAA,+BAA+B,OAAA;AACxC,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,yDAAkF;AAAzE,mHAAA,cAAc,OAAA;AAAE,gIAAA,2BAA2B,OAAA;AACpD,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAmE;AAA1D,iIAAA,+BAA+B,OAAA;AACxC,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,yDAAkF;AAAzE,mHAAA,cAAc,OAAA;AAAE,gIAAA,2BAA2B,OAAA;AACpD,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,6DAA6F;AAApF,6HAAA,sBAAsB,OAAA;AAC/B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,sDAAsC","sourcesContent":["export { readAndValidateBuildConfigAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport { BuildStepEnv } from './BuildStepEnv.js';\nexport * as errors from './errors.js';\n"]}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseOutputPath = exports.findOutputPaths = exports.interpolateWithOutputs = exports.interpolateWithInputs = exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = void 0;
|
|
6
|
+
exports.parseOutputPath = exports.findOutputPaths = exports.interpolateWithGlobalContext = exports.getObjectValueForInterpolation = exports.interpolateWithOutputs = exports.interpolateWithInputs = exports.BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = exports.BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = void 0;
|
|
7
|
+
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
8
|
+
const BuildStepInput_js_1 = require("../BuildStepInput.cjs");
|
|
4
9
|
const errors_js_1 = require("../errors.cjs");
|
|
5
10
|
const nullthrows_js_1 = require("./nullthrows.cjs");
|
|
6
|
-
exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*inputs\.
|
|
7
|
-
exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*steps\.
|
|
11
|
+
exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*(inputs\.[\S]+)\s*}/;
|
|
12
|
+
exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*(steps\.[\S]+)\s*}/;
|
|
13
|
+
exports.BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = /\${\s*(eas\.[\S]+)\s*}/;
|
|
14
|
+
exports.BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = /\${\s*((steps|eas)\.[\S]+)\s*}/;
|
|
8
15
|
function interpolateWithInputs(templateString, inputs) {
|
|
9
16
|
return interpolate(templateString, exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);
|
|
10
17
|
}
|
|
@@ -13,6 +20,24 @@ function interpolateWithOutputs(templateString, fn) {
|
|
|
13
20
|
return interpolate(templateString, exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);
|
|
14
21
|
}
|
|
15
22
|
exports.interpolateWithOutputs = interpolateWithOutputs;
|
|
23
|
+
function getObjectValueForInterpolation(path, obj) {
|
|
24
|
+
const value = (0, lodash_get_1.default)(obj, path);
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
throw new errors_js_1.BuildStepRuntimeError(`Object field "${path}" does not exist. Ensure you are using the correct field name.`);
|
|
27
|
+
}
|
|
28
|
+
if (!isAllowedValueTypeForObjectInterpolation(value)) {
|
|
29
|
+
throw new errors_js_1.BuildStepRuntimeError(`EAS context field "${path}" is not of type ${Object.values(BuildStepInput_js_1.BuildStepInputValueTypeName).join(', ')}, or undefined. It is of type "${typeof value}". We currently only support accessing string or undefined values from the EAS context.`);
|
|
30
|
+
}
|
|
31
|
+
if (value !== null && typeof value === 'object') {
|
|
32
|
+
return JSON.stringify(value);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
exports.getObjectValueForInterpolation = getObjectValueForInterpolation;
|
|
37
|
+
function interpolateWithGlobalContext(templateString, fn) {
|
|
38
|
+
return interpolate(templateString, exports.BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP, fn);
|
|
39
|
+
}
|
|
40
|
+
exports.interpolateWithGlobalContext = interpolateWithGlobalContext;
|
|
16
41
|
function interpolate(templateString, regex, varsOrFn) {
|
|
17
42
|
const matched = templateString.match(new RegExp(regex, 'g'));
|
|
18
43
|
if (!matched) {
|
|
@@ -20,12 +45,19 @@ function interpolate(templateString, regex, varsOrFn) {
|
|
|
20
45
|
}
|
|
21
46
|
let result = templateString;
|
|
22
47
|
for (const match of matched) {
|
|
23
|
-
const [,
|
|
24
|
-
const value = typeof varsOrFn === 'function' ? varsOrFn(
|
|
48
|
+
const [, path] = (0, nullthrows_js_1.nullthrows)(match.match(regex));
|
|
49
|
+
const value = typeof varsOrFn === 'function' ? varsOrFn(path) : varsOrFn[path.split('.')[1]];
|
|
25
50
|
result = result.replace(match, value);
|
|
26
51
|
}
|
|
27
52
|
return result;
|
|
28
53
|
}
|
|
54
|
+
function isAllowedValueTypeForObjectInterpolation(value) {
|
|
55
|
+
return (typeof value === 'string' ||
|
|
56
|
+
typeof value === 'number' ||
|
|
57
|
+
typeof value === 'boolean' ||
|
|
58
|
+
typeof value === 'object' ||
|
|
59
|
+
value === null);
|
|
60
|
+
}
|
|
29
61
|
function findOutputPaths(templateString) {
|
|
30
62
|
const result = [];
|
|
31
63
|
const matches = templateString.matchAll(new RegExp(exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));
|
|
@@ -35,10 +67,10 @@ function findOutputPaths(templateString) {
|
|
|
35
67
|
return result;
|
|
36
68
|
}
|
|
37
69
|
exports.findOutputPaths = findOutputPaths;
|
|
38
|
-
function parseOutputPath(
|
|
39
|
-
const splits =
|
|
70
|
+
function parseOutputPath(outputPathWithObjectName) {
|
|
71
|
+
const splits = outputPathWithObjectName.split('.').slice(1);
|
|
40
72
|
if (splits.length !== 2) {
|
|
41
|
-
throw new errors_js_1.BuildConfigError(`Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. "step3.output1". Passed: "${
|
|
73
|
+
throw new errors_js_1.BuildConfigError(`Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. "step3.output1". Passed: "${outputPathWithObjectName}"`);
|
|
42
74
|
}
|
|
43
75
|
const [stepId, outputId] = splits;
|
|
44
76
|
return { stepId, outputId };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export declare const BUILD_STEP_INPUT_EXPRESSION_REGEXP: RegExp;
|
|
2
2
|
export declare const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP: RegExp;
|
|
3
|
+
export declare const BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP: RegExp;
|
|
4
|
+
export declare const BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX: RegExp;
|
|
3
5
|
export declare function interpolateWithInputs(templateString: string, inputs: Record<string, string>): string;
|
|
4
6
|
export declare function interpolateWithOutputs(templateString: string, fn: (path: string) => string): string;
|
|
7
|
+
export declare function getObjectValueForInterpolation(path: string, obj: Record<string, any>): string | number | boolean | null;
|
|
8
|
+
export declare function interpolateWithGlobalContext(templateString: string, fn: (path: string) => string): string;
|
|
5
9
|
interface BuildOutputPath {
|
|
6
10
|
stepId: string;
|
|
7
11
|
outputId: string;
|
|
8
12
|
}
|
|
9
13
|
export declare function findOutputPaths(templateString: string): BuildOutputPath[];
|
|
10
|
-
export declare function parseOutputPath(
|
|
14
|
+
export declare function parseOutputPath(outputPathWithObjectName: string): BuildOutputPath;
|
|
11
15
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/utils/template.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA6B;AAE7B,4DAAmE;AACnE,4CAAuE;AAEvE,mDAA6C;AAEhC,QAAA,kCAAkC,GAAG,2BAA2B,CAAC;AACjE,QAAA,mCAAmC,GAAG,0BAA0B,CAAC;AACjE,QAAA,sCAAsC,GAAG,wBAAwB,CAAC;AAClE,QAAA,kDAAkD,GAAG,gCAAgC,CAAC;AAEnG,SAAgB,qBAAqB,CACnC,cAAsB,EACtB,MAA8B;IAE9B,OAAO,WAAW,CAAC,cAAc,EAAE,0CAAkC,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AALD,sDAKC;AAED,SAAgB,sBAAsB,CACpC,cAAsB,EACtB,EAA4B;IAE5B,OAAO,WAAW,CAAC,cAAc,EAAE,2CAAmC,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AALD,wDAKC;AAED,SAAgB,8BAA8B,CAC5C,IAAY,EACZ,GAAwB;IAExB,MAAM,KAAK,GAA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C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7F,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;KACvC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,wCAAwC,CAC/C,KAAU;IAEV,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI,CACf,CAAC;AACJ,CAAC;AAOD,SAAgB,eAAe,CAAC,cAAsB;IACpD,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,2CAAmC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9F,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;QAC3B,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KACxC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAPD,0CAOC;AAED,SAAgB,eAAe,CAAC,wBAAgC;IAC9D,MAAM,MAAM,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,MAAM,IAAI,4BAAgB,CACxB,gKAAgK,wBAAwB,GAAG,CAC5L,CAAC;KACH;IACD,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,MAAM,CAAC;IAClC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC;AATD,0CASC","sourcesContent":["import get from 'lodash.get';\n\nimport { BuildStepInputValueTypeName } from '../BuildStepInput.js';\nimport { BuildConfigError, BuildStepRuntimeError } from '../errors.js';\n\nimport { nullthrows } from './nullthrows.js';\n\nexport const BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\\${\\s*(inputs\\.[\\S]+)\\s*}/;\nexport const BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\\${\\s*(steps\\.[\\S]+)\\s*}/;\nexport const BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = /\\${\\s*(eas\\.[\\S]+)\\s*}/;\nexport const BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = /\\${\\s*((steps|eas)\\.[\\S]+)\\s*}/;\n\nexport function interpolateWithInputs(\n templateString: string,\n inputs: Record<string, string>\n): string {\n return interpolate(templateString, BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);\n}\n\nexport function interpolateWithOutputs(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, fn);\n}\n\nexport function getObjectValueForInterpolation(\n path: string,\n obj: Record<string, any>\n): string | number | boolean | null {\n const value = get(obj, path);\n\n if (value === undefined) {\n throw new BuildStepRuntimeError(\n `Object field \"${path}\" does not exist. Ensure you are using the correct field name.`\n );\n }\n\n if (!isAllowedValueTypeForObjectInterpolation(value)) {\n throw new BuildStepRuntimeError(\n `EAS context field \"${path}\" is not of type ${Object.values(BuildStepInputValueTypeName).join(\n ', '\n )}, or undefined. It is of type \"${typeof value}\". We currently only support accessing string or undefined values from the EAS context.`\n );\n }\n\n if (value !== null && typeof value === 'object') {\n return JSON.stringify(value);\n }\n\n return value;\n}\n\nexport function interpolateWithGlobalContext(\n templateString: string,\n fn: (path: string) => string\n): string {\n return interpolate(templateString, BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP, fn);\n}\n\nfunction interpolate(\n templateString: string,\n regex: RegExp,\n varsOrFn: Record<string, string> | ((key: string) => string)\n): string {\n const matched = templateString.match(new RegExp(regex, 'g'));\n if (!matched) {\n return templateString;\n }\n let result = templateString;\n for (const match of matched) {\n const [, path] = nullthrows(match.match(regex));\n const value = typeof varsOrFn === 'function' ? varsOrFn(path) : varsOrFn[path.split('.')[1]];\n result = result.replace(match, value);\n }\n return result;\n}\n\nfunction isAllowedValueTypeForObjectInterpolation(\n value: any\n): value is string | number | boolean | object | null {\n return (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'object' ||\n value === null\n );\n}\n\ninterface BuildOutputPath {\n stepId: string;\n outputId: string;\n}\n\nexport function findOutputPaths(templateString: string): BuildOutputPath[] {\n const result: BuildOutputPath[] = [];\n const matches = templateString.matchAll(new RegExp(BUILD_STEP_OUTPUT_EXPRESSION_REGEXP, 'g'));\n for (const match of matches) {\n result.push(parseOutputPath(match[1]));\n }\n return result;\n}\n\nexport function parseOutputPath(outputPathWithObjectName: string): BuildOutputPath {\n const splits = outputPathWithObjectName.split('.').slice(1);\n if (splits.length !== 2) {\n throw new BuildConfigError(\n `Step output path must consist of two components joined with a dot, where first is the step ID, and second is the output name, e.g. \"step3.output1\". Passed: \"${outputPathWithObjectName}\"`\n );\n }\n const [stepId, outputId] = splits;\n return { stepId, outputId };\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Joi from 'joi';
|
|
2
2
|
import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
3
3
|
import { BuildStepInputValueType, BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
4
|
+
import { BuildStepEnv } from './BuildStepEnv.js';
|
|
4
5
|
export type BuildFunctions = Record<string, BuildFunctionConfig>;
|
|
5
6
|
interface BuildFunctionsConfigFile {
|
|
6
7
|
configFilesToImport?: string[];
|
|
@@ -32,6 +33,7 @@ export type BuildFunctionCallConfig = {
|
|
|
32
33
|
name?: string;
|
|
33
34
|
workingDirectory?: string;
|
|
34
35
|
shell?: string;
|
|
36
|
+
env?: BuildStepEnv;
|
|
35
37
|
};
|
|
36
38
|
export type BuildStepInputs = Record<string, BuildStepInputValueType>;
|
|
37
39
|
export type BuildStepOutputs = (string | {
|
package/dist_esm/BuildConfig.js
CHANGED
|
@@ -7,6 +7,7 @@ import { BuildConfigError, BuildWorkflowError } from './errors.js';
|
|
|
7
7
|
import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
8
8
|
import { BuildFunction } from './BuildFunction.js';
|
|
9
9
|
import { BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
10
|
+
import { BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX } from './utils/template.js';
|
|
10
11
|
const BuildFunctionInputsSchema = Joi.array().items(Joi.alternatives().conditional(Joi.ref('.'), {
|
|
11
12
|
is: Joi.string(),
|
|
12
13
|
then: Joi.string().required(),
|
|
@@ -20,19 +21,29 @@ const BuildFunctionInputsSchema = Joi.array().items(Joi.alternatives().condition
|
|
|
20
21
|
})
|
|
21
22
|
.when('allowedValueType', {
|
|
22
23
|
is: BuildStepInputValueTypeName.STRING,
|
|
23
|
-
then: Joi.string(),
|
|
24
|
+
then: Joi.string().allow(''),
|
|
24
25
|
})
|
|
25
26
|
.when('allowedValueType', {
|
|
26
27
|
is: BuildStepInputValueTypeName.BOOLEAN,
|
|
27
|
-
then: Joi.boolean(),
|
|
28
|
+
then: Joi.alternatives(Joi.boolean(), Joi.string().pattern(BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX, 'context or output reference regex pattern')).messages({
|
|
29
|
+
'alternatives.types': '{{#label}} must be a boolean or reference to output or context value',
|
|
30
|
+
}),
|
|
28
31
|
})
|
|
29
32
|
.when('allowedValueType', {
|
|
30
33
|
is: BuildStepInputValueTypeName.NUMBER,
|
|
31
|
-
then: Joi.number(),
|
|
34
|
+
then: Joi.alternatives(Joi.number(), Joi.string().pattern(BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX, 'context or output reference regex pattern')).messages({
|
|
35
|
+
'alternatives.types': '{{#label}} must be a number or reference to output or context value',
|
|
36
|
+
}),
|
|
37
|
+
})
|
|
38
|
+
.when('allowedValueType', {
|
|
39
|
+
is: BuildStepInputValueTypeName.JSON,
|
|
40
|
+
then: Joi.alternatives(Joi.object(), Joi.string().pattern(BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX, 'context or output reference regex pattern')).messages({
|
|
41
|
+
'alternatives.types': '{{#label}} must be a object or reference to output or context value',
|
|
42
|
+
}),
|
|
32
43
|
}),
|
|
33
44
|
allowedValues: Joi.when('allowedValueType', {
|
|
34
45
|
is: BuildStepInputValueTypeName.STRING,
|
|
35
|
-
then: Joi.array().items(Joi.string()),
|
|
46
|
+
then: Joi.array().items(Joi.string().allow('')),
|
|
36
47
|
})
|
|
37
48
|
.when('allowedValueType', {
|
|
38
49
|
is: BuildStepInputValueTypeName.BOOLEAN,
|
|
@@ -41,6 +52,10 @@ const BuildFunctionInputsSchema = Joi.array().items(Joi.alternatives().condition
|
|
|
41
52
|
.when('allowedValueType', {
|
|
42
53
|
is: BuildStepInputValueTypeName.NUMBER,
|
|
43
54
|
then: Joi.array().items(Joi.number()),
|
|
55
|
+
})
|
|
56
|
+
.when('allowedValueType', {
|
|
57
|
+
is: BuildStepInputValueTypeName.JSON,
|
|
58
|
+
then: Joi.array().items(Joi.object()),
|
|
44
59
|
}),
|
|
45
60
|
allowedValueType: Joi.string()
|
|
46
61
|
.valid(...Object.values(BuildStepInputValueTypeName))
|
|
@@ -58,10 +73,11 @@ const BuildStepOutputsSchema = Joi.array().items(Joi.alternatives().try(Joi.stri
|
|
|
58
73
|
}).required()));
|
|
59
74
|
const BuildFunctionCallSchema = Joi.object({
|
|
60
75
|
id: Joi.string(),
|
|
61
|
-
inputs: Joi.object().pattern(Joi.string(), Joi.alternatives().try(Joi.string(), Joi.boolean(), Joi.number())),
|
|
76
|
+
inputs: Joi.object().pattern(Joi.string(), Joi.alternatives().try(Joi.string().allow(''), Joi.boolean(), Joi.number(), Joi.object())),
|
|
62
77
|
name: Joi.string(),
|
|
63
78
|
workingDirectory: Joi.string(),
|
|
64
79
|
shell: Joi.string(),
|
|
80
|
+
env: Joi.object().pattern(Joi.string(), Joi.string().allow('')),
|
|
65
81
|
}).rename('working_directory', 'workingDirectory');
|
|
66
82
|
const BuildStepConfigSchema = Joi.any()
|
|
67
83
|
.when(Joi.object().pattern(Joi.string().disallow('run').required(), Joi.object().unknown().required()), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAA2B,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAwE3F,MAAM,yBAAyB,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACjD,GAAG,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;IAC3C,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC7B,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE;YACtC,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE;YACf,IAAI,EAAE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OAAO,KAAK,CAAC;SACd;QACD,OAAO,CACL,CAAC,CAAC,cAAc,IAAI,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC,CAC7F,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;QACnC,MAAM,IAAI,gBAAgB,CACxB,mCAAmC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3F,CAAC;KACH;AACH,CAAC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport Joi from 'joi';\nimport YAML from 'yaml';\n\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildFunction } from './BuildFunction.js';\nimport { BuildStepInputValueType, BuildStepInputValueTypeName } from './BuildStepInput.js';\n\nexport type BuildFunctions = Record<string, BuildFunctionConfig>;\n\ninterface BuildFunctionsConfigFile {\n configFilesToImport?: string[];\n functions?: BuildFunctions;\n}\n\nexport interface BuildConfig extends BuildFunctionsConfigFile {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n}\n\nexport type BuildStepConfig =\n | BuildStepCommandRun\n | BuildStepBareCommandRun\n | BuildStepFunctionCall\n | BuildStepBareFunctionCall;\n\nexport type BuildStepCommandRun = {\n run: BuildFunctionCallConfig & {\n outputs?: BuildStepOutputs;\n command: string;\n };\n};\nexport type BuildStepBareCommandRun = { run: string };\nexport type BuildStepFunctionCall = {\n [functionId: string]: BuildFunctionCallConfig;\n};\nexport type BuildStepBareFunctionCall = string;\n\nexport type BuildFunctionCallConfig = {\n id?: string;\n inputs?: BuildStepInputs;\n name?: string;\n workingDirectory?: string;\n shell?: string;\n};\n\nexport type BuildStepInputs = Record<string, BuildStepInputValueType>;\nexport type BuildStepOutputs = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nexport interface BuildFunctionConfig {\n inputs?: BuildFunctionInputs;\n outputs?: BuildFunctionOutputs;\n name?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n shell?: string;\n command: string;\n}\n\nexport type BuildFunctionInputs = (\n | string\n | {\n name: string;\n defaultValue?: BuildStepInputValueType;\n allowedValues?: BuildStepInputValueType[];\n required?: boolean;\n allowedValueType: BuildStepInputValueTypeName;\n }\n)[];\nexport type BuildFunctionOutputs = BuildStepOutputs;\n\nconst BuildFunctionInputsSchema = Joi.array().items(\n Joi.alternatives().conditional(Joi.ref('.'), {\n is: Joi.string(),\n then: Joi.string().required(),\n otherwise: Joi.object({\n name: Joi.string().required(),\n defaultValue: Joi.when('allowedValues', {\n is: Joi.exist(),\n then: Joi.valid(Joi.in('allowedValues')).messages({\n 'any.only': '{{#label}} must be one of allowed values',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.string(),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.boolean(),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.number(),\n }),\n allowedValues: Joi.when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.array().items(Joi.string()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.array().items(Joi.boolean()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.array().items(Joi.number()),\n }),\n allowedValueType: Joi.string()\n .valid(...Object.values(BuildStepInputValueTypeName))\n .default(BuildStepInputValueTypeName.STRING),\n required: Joi.boolean(),\n })\n .rename('allowed_values', 'allowedValues')\n .rename('default_value', 'defaultValue')\n .rename('type', 'allowedValueType')\n .required(),\n })\n);\n\nconst BuildStepOutputsSchema = 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\nconst BuildFunctionCallSchema = Joi.object({\n id: Joi.string(),\n inputs: Joi.object().pattern(\n Joi.string(),\n Joi.alternatives().try(Joi.string(), Joi.boolean(), Joi.number())\n ),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\n .when(\n Joi.object().pattern(\n Joi.string().disallow('run').required(),\n Joi.object().unknown().required()\n ),\n {\n then: Joi.object().pattern(\n Joi.string().disallow('run').min(1).required(),\n BuildFunctionCallSchema.required(),\n { matches: Joi.array().length(1) }\n ),\n }\n )\n .when(Joi.object({ run: Joi.object().unknown().required() }), {\n then: Joi.object({\n run: BuildFunctionCallSchema.keys({\n outputs: BuildStepOutputsSchema,\n command: Joi.string().required(),\n }),\n }),\n })\n .when(Joi.object({ run: Joi.string().required() }), {\n then: Joi.object({\n run: Joi.string().min(1).required(),\n }),\n })\n .when(Joi.string(), {\n then: Joi.string().min(1),\n });\n\nconst BuildFunctionConfigSchema = Joi.object({\n name: Joi.string(),\n supportedRuntimePlatforms: Joi.array().items(...Object.values(BuildRuntimePlatform)),\n inputs: BuildFunctionInputsSchema,\n outputs: BuildStepOutputsSchema,\n command: Joi.string().required(),\n shell: Joi.string(),\n}).rename('supported_platforms', 'supportedRuntimePlatforms');\n\nexport const BuildFunctionsConfigFileSchema = Joi.object<BuildFunctionsConfigFile>({\n configFilesToImport: Joi.array().items(Joi.string().pattern(/\\.y(a)?ml$/)),\n functions: Joi.object().pattern(\n Joi.string()\n .pattern(/^[\\w-]+$/, 'function names')\n .min(1)\n .required()\n .disallow('run'),\n BuildFunctionConfigSchema.required()\n ),\n})\n .rename('import', 'configFilesToImport')\n .required();\n\nexport const BuildConfigSchema = BuildFunctionsConfigFileSchema.append<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array().items(BuildStepConfigSchema.required()).required(),\n }).required(),\n}).required();\n\ninterface BuildConfigValidationParams {\n externalFunctionIds?: string[];\n skipNamespacedFunctionsCheck?: boolean;\n}\n\nexport async function readAndValidateBuildConfigAsync(\n configPath: string,\n params: BuildConfigValidationParams = {}\n): Promise<BuildConfig> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n\n const config = validateConfig(BuildConfigSchema, rawConfig);\n const importedFunctions = await importFunctionsAsync(configPath, config.configFilesToImport);\n mergeConfigWithImportedFunctions(config, importedFunctions);\n validateAllFunctionsExist(config, params);\n return config;\n}\n\nasync function importFunctionsAsync(\n baseConfigPath: string,\n configPathsToImport?: string[]\n): Promise<BuildFunctions> {\n if (!configPathsToImport) {\n return {};\n }\n\n const baseConfigDir = path.dirname(baseConfigPath);\n\n const errors: BuildConfigError[] = [];\n const importedFunctions: BuildFunctions = {};\n // this is a set of visited files identified by ABSOLUTE paths\n const visitedFiles = new Set<string>([baseConfigPath]);\n const configFilesToVisit = (configPathsToImport ?? []).map((childConfigRelativePath) =>\n path.resolve(baseConfigDir, childConfigRelativePath)\n );\n while (configFilesToVisit.length > 0) {\n const childConfigPath = configFilesToVisit.shift();\n assert(childConfigPath, 'Guaranteed by loop condition');\n if (visitedFiles.has(childConfigPath)) {\n continue;\n }\n visitedFiles.add(childConfigPath);\n try {\n const childConfig = await readAndValidateBuildFunctionsConfigFileAsync(childConfigPath);\n for (const functionName in childConfig.functions) {\n if (!(functionName in importedFunctions)) {\n importedFunctions[functionName] = childConfig.functions[functionName];\n }\n }\n if (childConfig.configFilesToImport) {\n const childDir = path.dirname(childConfigPath);\n configFilesToVisit.push(\n ...childConfig.configFilesToImport.map((relativePath) =>\n path.resolve(childDir, relativePath)\n )\n );\n }\n } catch (err) {\n if (err instanceof BuildConfigError) {\n errors.push(err);\n } else {\n throw err;\n }\n }\n }\n if (errors.length > 0) {\n throw new BuildWorkflowError(`Detected build config errors in imported files.`, errors);\n }\n return importedFunctions;\n}\n\nexport async function readAndValidateBuildFunctionsConfigFileAsync(\n configPath: string\n): Promise<BuildFunctionsConfigFile> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n return validateConfig(BuildFunctionsConfigFileSchema, rawConfig);\n}\n\nexport async function readRawBuildConfigAsync(configPath: string): Promise<any> {\n const contents = await fs.readFile(configPath, 'utf-8');\n return YAML.parse(contents);\n}\n\nexport function validateConfig<T>(\n schema: Joi.ObjectSchema<T>,\n config: object,\n configFilePath?: string\n): T {\n const { error, value } = schema.validate(config, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, {\n cause: error,\n ...(configFilePath && { metadata: { configFilePath } }),\n });\n }\n return value;\n}\n\nexport function mergeConfigWithImportedFunctions(\n config: BuildConfig,\n importedFunctions: BuildFunctions\n): void {\n if (Object.keys(importedFunctions).length === 0) {\n return;\n }\n config.functions = config.functions ?? {};\n for (const functionName in importedFunctions) {\n if (!(functionName in config.functions)) {\n config.functions[functionName] = importedFunctions[functionName];\n }\n }\n}\n\nexport function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun {\n return typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return typeof step === 'object' && !('run' in step);\n}\n\nexport function isBuildStepBareFunctionCall(\n step: BuildStepConfig\n): step is BuildStepBareFunctionCall {\n return typeof step === 'string';\n}\n\nexport function validateAllFunctionsExist(\n config: BuildConfig,\n { externalFunctionIds = [], skipNamespacedFunctionsCheck }: BuildConfigValidationParams\n): void {\n const calledFunctionsSet = new Set<string>();\n for (const step of config.build.steps) {\n if (typeof step === 'string') {\n calledFunctionsSet.add(step);\n } else if (!('run' in step)) {\n const keys = Object.keys(step);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n calledFunctionsSet.add(keys[0]);\n }\n }\n const calledFunctions = Array.from(calledFunctionsSet);\n const externalFunctionIdsSet = new Set(externalFunctionIds);\n const nonExistentFunctions = calledFunctions.filter((calledFunction) => {\n if (BuildFunction.isFulldIdNamespaced(calledFunction) && skipNamespacedFunctionsCheck) {\n return false;\n }\n return (\n !(calledFunction in (config.functions ?? {})) && !externalFunctionIdsSet.has(calledFunction)\n );\n });\n if (nonExistentFunctions.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctions.map((f) => `\"${f}\"`).join(', ')}.`\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAA2B,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAE,kDAAkD,EAAE,MAAM,qBAAqB,CAAC;AAyEzF,MAAM,yBAAyB,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACjD,GAAG,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;IAC3C,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CA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AI,aAAa,CAAC,mBAAmB,CAAC,cAAc,CAAC,IAAI,4BAA4B,EAAE;YACrF,OAAO,KAAK,CAAC;SACd;QACD,OAAO,CACL,CAAC,CAAC,cAAc,IAAI,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC,CAC7F,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;QACnC,MAAM,IAAI,gBAAgB,CACxB,mCAAmC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3F,CAAC;KACH;AACH,CAAC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport Joi from 'joi';\nimport YAML from 'yaml';\n\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildFunction } from './BuildFunction.js';\nimport { BuildStepInputValueType, BuildStepInputValueTypeName } from './BuildStepInput.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX } from './utils/template.js';\n\nexport type BuildFunctions = Record<string, BuildFunctionConfig>;\n\ninterface BuildFunctionsConfigFile {\n configFilesToImport?: string[];\n functions?: BuildFunctions;\n}\n\nexport interface BuildConfig extends BuildFunctionsConfigFile {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n}\n\nexport type BuildStepConfig =\n | BuildStepCommandRun\n | BuildStepBareCommandRun\n | BuildStepFunctionCall\n | BuildStepBareFunctionCall;\n\nexport type BuildStepCommandRun = {\n run: BuildFunctionCallConfig & {\n outputs?: BuildStepOutputs;\n command: string;\n };\n};\nexport type BuildStepBareCommandRun = { run: string };\nexport type BuildStepFunctionCall = {\n [functionId: string]: BuildFunctionCallConfig;\n};\nexport type BuildStepBareFunctionCall = string;\n\nexport type BuildFunctionCallConfig = {\n id?: string;\n inputs?: BuildStepInputs;\n name?: string;\n workingDirectory?: string;\n shell?: string;\n env?: BuildStepEnv;\n};\n\nexport type BuildStepInputs = Record<string, BuildStepInputValueType>;\nexport type BuildStepOutputs = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nexport interface BuildFunctionConfig {\n inputs?: BuildFunctionInputs;\n outputs?: BuildFunctionOutputs;\n name?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n shell?: string;\n command: string;\n}\n\nexport type BuildFunctionInputs = (\n | string\n | {\n name: string;\n defaultValue?: BuildStepInputValueType;\n allowedValues?: BuildStepInputValueType[];\n required?: boolean;\n allowedValueType: BuildStepInputValueTypeName;\n }\n)[];\nexport type BuildFunctionOutputs = BuildStepOutputs;\n\nconst BuildFunctionInputsSchema = Joi.array().items(\n Joi.alternatives().conditional(Joi.ref('.'), {\n is: Joi.string(),\n then: Joi.string().required(),\n otherwise: Joi.object({\n name: Joi.string().required(),\n defaultValue: Joi.when('allowedValues', {\n is: Joi.exist(),\n then: Joi.valid(Joi.in('allowedValues')).messages({\n 'any.only': '{{#label}} must be one of allowed values',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.string().allow(''),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.alternatives(\n Joi.boolean(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a boolean or reference to output or context value',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.alternatives(\n Joi.number(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a number or reference to output or context value',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.JSON,\n then: Joi.alternatives(\n Joi.object(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a object or reference to output or context value',\n }),\n }),\n allowedValues: Joi.when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.array().items(Joi.string().allow('')),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.array().items(Joi.boolean()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.array().items(Joi.number()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.JSON,\n then: Joi.array().items(Joi.object()),\n }),\n allowedValueType: Joi.string()\n .valid(...Object.values(BuildStepInputValueTypeName))\n .default(BuildStepInputValueTypeName.STRING),\n required: Joi.boolean(),\n })\n .rename('allowed_values', 'allowedValues')\n .rename('default_value', 'defaultValue')\n .rename('type', 'allowedValueType')\n .required(),\n })\n);\n\nconst BuildStepOutputsSchema = 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\nconst BuildFunctionCallSchema = Joi.object({\n id: Joi.string(),\n inputs: Joi.object().pattern(\n Joi.string(),\n Joi.alternatives().try(Joi.string().allow(''), Joi.boolean(), Joi.number(), Joi.object())\n ),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n env: Joi.object().pattern(Joi.string(), Joi.string().allow('')),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\n .when(\n Joi.object().pattern(\n Joi.string().disallow('run').required(),\n Joi.object().unknown().required()\n ),\n {\n then: Joi.object().pattern(\n Joi.string().disallow('run').min(1).required(),\n BuildFunctionCallSchema.required(),\n { matches: Joi.array().length(1) }\n ),\n }\n )\n .when(Joi.object({ run: Joi.object().unknown().required() }), {\n then: Joi.object({\n run: BuildFunctionCallSchema.keys({\n outputs: BuildStepOutputsSchema,\n command: Joi.string().required(),\n }),\n }),\n })\n .when(Joi.object({ run: Joi.string().required() }), {\n then: Joi.object({\n run: Joi.string().min(1).required(),\n }),\n })\n .when(Joi.string(), {\n then: Joi.string().min(1),\n });\n\nconst BuildFunctionConfigSchema = Joi.object({\n name: Joi.string(),\n supportedRuntimePlatforms: Joi.array().items(...Object.values(BuildRuntimePlatform)),\n inputs: BuildFunctionInputsSchema,\n outputs: BuildStepOutputsSchema,\n command: Joi.string().required(),\n shell: Joi.string(),\n}).rename('supported_platforms', 'supportedRuntimePlatforms');\n\nexport const BuildFunctionsConfigFileSchema = Joi.object<BuildFunctionsConfigFile>({\n configFilesToImport: Joi.array().items(Joi.string().pattern(/\\.y(a)?ml$/)),\n functions: Joi.object().pattern(\n Joi.string()\n .pattern(/^[\\w-]+$/, 'function names')\n .min(1)\n .required()\n .disallow('run'),\n BuildFunctionConfigSchema.required()\n ),\n})\n .rename('import', 'configFilesToImport')\n .required();\n\nexport const BuildConfigSchema = BuildFunctionsConfigFileSchema.append<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array().items(BuildStepConfigSchema.required()).required(),\n }).required(),\n}).required();\n\ninterface BuildConfigValidationParams {\n externalFunctionIds?: string[];\n skipNamespacedFunctionsCheck?: boolean;\n}\n\nexport async function readAndValidateBuildConfigAsync(\n configPath: string,\n params: BuildConfigValidationParams = {}\n): Promise<BuildConfig> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n\n const config = validateConfig(BuildConfigSchema, rawConfig);\n const importedFunctions = await importFunctionsAsync(configPath, config.configFilesToImport);\n mergeConfigWithImportedFunctions(config, importedFunctions);\n validateAllFunctionsExist(config, params);\n return config;\n}\n\nasync function importFunctionsAsync(\n baseConfigPath: string,\n configPathsToImport?: string[]\n): Promise<BuildFunctions> {\n if (!configPathsToImport) {\n return {};\n }\n\n const baseConfigDir = path.dirname(baseConfigPath);\n\n const errors: BuildConfigError[] = [];\n const importedFunctions: BuildFunctions = {};\n // this is a set of visited files identified by ABSOLUTE paths\n const visitedFiles = new Set<string>([baseConfigPath]);\n const configFilesToVisit = (configPathsToImport ?? []).map((childConfigRelativePath) =>\n path.resolve(baseConfigDir, childConfigRelativePath)\n );\n while (configFilesToVisit.length > 0) {\n const childConfigPath = configFilesToVisit.shift();\n assert(childConfigPath, 'Guaranteed by loop condition');\n if (visitedFiles.has(childConfigPath)) {\n continue;\n }\n visitedFiles.add(childConfigPath);\n try {\n const childConfig = await readAndValidateBuildFunctionsConfigFileAsync(childConfigPath);\n for (const functionName in childConfig.functions) {\n if (!(functionName in importedFunctions)) {\n importedFunctions[functionName] = childConfig.functions[functionName];\n }\n }\n if (childConfig.configFilesToImport) {\n const childDir = path.dirname(childConfigPath);\n configFilesToVisit.push(\n ...childConfig.configFilesToImport.map((relativePath) =>\n path.resolve(childDir, relativePath)\n )\n );\n }\n } catch (err) {\n if (err instanceof BuildConfigError) {\n errors.push(err);\n } else {\n throw err;\n }\n }\n }\n if (errors.length > 0) {\n throw new BuildWorkflowError(`Detected build config errors in imported files.`, errors);\n }\n return importedFunctions;\n}\n\nexport async function readAndValidateBuildFunctionsConfigFileAsync(\n configPath: string\n): Promise<BuildFunctionsConfigFile> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n return validateConfig(BuildFunctionsConfigFileSchema, rawConfig);\n}\n\nexport async function readRawBuildConfigAsync(configPath: string): Promise<any> {\n const contents = await fs.readFile(configPath, 'utf-8');\n return YAML.parse(contents);\n}\n\nexport function validateConfig<T>(\n schema: Joi.ObjectSchema<T>,\n config: object,\n configFilePath?: string\n): T {\n const { error, value } = schema.validate(config, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, {\n cause: error,\n ...(configFilePath && { metadata: { configFilePath } }),\n });\n }\n return value;\n}\n\nexport function mergeConfigWithImportedFunctions(\n config: BuildConfig,\n importedFunctions: BuildFunctions\n): void {\n if (Object.keys(importedFunctions).length === 0) {\n return;\n }\n config.functions = config.functions ?? {};\n for (const functionName in importedFunctions) {\n if (!(functionName in config.functions)) {\n config.functions[functionName] = importedFunctions[functionName];\n }\n }\n}\n\nexport function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun {\n return typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return typeof step === 'object' && !('run' in step);\n}\n\nexport function isBuildStepBareFunctionCall(\n step: BuildStepConfig\n): step is BuildStepBareFunctionCall {\n return typeof step === 'string';\n}\n\nexport function validateAllFunctionsExist(\n config: BuildConfig,\n { externalFunctionIds = [], skipNamespacedFunctionsCheck }: BuildConfigValidationParams\n): void {\n const calledFunctionsSet = new Set<string>();\n for (const step of config.build.steps) {\n if (typeof step === 'string') {\n calledFunctionsSet.add(step);\n } else if (!('run' in step)) {\n const keys = Object.keys(step);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n calledFunctionsSet.add(keys[0]);\n }\n }\n const calledFunctions = Array.from(calledFunctionsSet);\n const externalFunctionIdsSet = new Set(externalFunctionIds);\n const nonExistentFunctions = calledFunctions.filter((calledFunction) => {\n if (BuildFunction.isFulldIdNamespaced(calledFunction) && skipNamespacedFunctionsCheck) {\n return false;\n }\n return (\n !(calledFunction in (config.functions ?? {})) && !externalFunctionIdsSet.has(calledFunction)\n );\n });\n if (nonExistentFunctions.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctions.map((f) => `\"${f}\"`).join(', ')}.`\n );\n }\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { BuildFunction } from './BuildFunction.js';
|
|
2
|
-
import {
|
|
2
|
+
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
3
3
|
import { BuildWorkflow } from './BuildWorkflow.js';
|
|
4
4
|
export declare class BuildConfigParser {
|
|
5
5
|
private readonly ctx;
|
|
6
6
|
private readonly configPath;
|
|
7
7
|
private readonly externalFunctions?;
|
|
8
|
-
constructor(ctx:
|
|
8
|
+
constructor(ctx: BuildStepGlobalContext, { configPath, externalFunctions }: {
|
|
9
9
|
configPath: string;
|
|
10
10
|
externalFunctions?: BuildFunction[];
|
|
11
11
|
});
|
|
@@ -2,7 +2,7 @@ import assert from 'assert';
|
|
|
2
2
|
import { isBuildStepBareCommandRun, isBuildStepBareFunctionCall, isBuildStepCommandRun, readAndValidateBuildConfigAsync, } from './BuildConfig.js';
|
|
3
3
|
import { BuildFunction } from './BuildFunction.js';
|
|
4
4
|
import { BuildStep } from './BuildStep.js';
|
|
5
|
-
import { BuildStepInput, } from './BuildStepInput.js';
|
|
5
|
+
import { BuildStepInput, BuildStepInputValueTypeName, } from './BuildStepInput.js';
|
|
6
6
|
import { BuildStepOutput } from './BuildStepOutput.js';
|
|
7
7
|
import { BuildWorkflow } from './BuildWorkflow.js';
|
|
8
8
|
import { BuildWorkflowValidator } from './BuildWorkflowValidator.js';
|
|
@@ -42,7 +42,7 @@ export class BuildConfigParser {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
createBuildStepFromBuildStepCommandRun({ run }) {
|
|
45
|
-
const { id: maybeId, inputs: inputsConfig, outputs: outputsConfig, name, workingDirectory, shell, command, } = run;
|
|
45
|
+
const { id: maybeId, inputs: inputsConfig, outputs: outputsConfig, name, workingDirectory, shell, command, env, } = run;
|
|
46
46
|
const id = BuildStep.getNewId(maybeId);
|
|
47
47
|
const displayName = BuildStep.getDisplayName({ id, name, command });
|
|
48
48
|
const inputs = inputsConfig && this.createBuildStepInputsFromDefinition(inputsConfig, displayName);
|
|
@@ -56,6 +56,7 @@ export class BuildConfigParser {
|
|
|
56
56
|
workingDirectory,
|
|
57
57
|
shell,
|
|
58
58
|
command,
|
|
59
|
+
env,
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
createBuildStepFromBuildStepBareCommandRun({ run: command, }) {
|
|
@@ -83,6 +84,7 @@ export class BuildConfigParser {
|
|
|
83
84
|
callInputs: buildFunctionCallConfig.inputs,
|
|
84
85
|
workingDirectory: buildFunctionCallConfig.workingDirectory,
|
|
85
86
|
shell: buildFunctionCallConfig.shell,
|
|
87
|
+
env: buildFunctionCallConfig.env,
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
createBuildFunctionsFromConfig(buildFunctionsConfig) {
|
|
@@ -118,7 +120,9 @@ export class BuildConfigParser {
|
|
|
118
120
|
stepDisplayName,
|
|
119
121
|
defaultValue: value,
|
|
120
122
|
required: true,
|
|
121
|
-
allowedValueTypeName: typeof value
|
|
123
|
+
allowedValueTypeName: typeof value === 'object'
|
|
124
|
+
? BuildStepInputValueTypeName.JSON
|
|
125
|
+
: typeof value,
|
|
122
126
|
}));
|
|
123
127
|
}
|
|
124
128
|
createBuildStepInputProvidersFromBuildFunctionInputs(buildFunctionInputs) {
|