@expo/steps 1.0.67 → 1.0.72
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/dist_commonjs/BuildConfigParser.cjs +23 -4
- package/dist_commonjs/BuildConfigParser.d.ts +2 -0
- package/dist_commonjs/BuildConfigParser.js.map +1 -1
- package/dist_commonjs/BuildFunctionGroup.cjs +16 -2
- package/dist_commonjs/BuildFunctionGroup.d.ts +11 -3
- package/dist_commonjs/BuildFunctionGroup.js.map +1 -1
- package/dist_commonjs/BuildStep.cjs +2 -0
- package/dist_commonjs/BuildStep.js.map +1 -1
- package/dist_commonjs/BuildStepContext.d.ts +4 -3
- package/dist_commonjs/BuildStepContext.js.map +1 -1
- package/dist_commonjs/cli/cli.cjs +5 -1
- package/dist_commonjs/cli/cli.d.ts +2 -1
- package/dist_commonjs/cli/cli.js.map +1 -1
- package/dist_commonjs/scripts/runCustomFunction.js.map +1 -1
- package/dist_commonjs/utils/expodash/duplicates.d.ts +1 -1
- package/dist_commonjs/utils/expodash/duplicates.js.map +1 -1
- package/dist_commonjs/utils/expodash/uniq.d.ts +1 -1
- package/dist_commonjs/utils/expodash/uniq.js.map +1 -1
- package/dist_commonjs/utils/template.cjs +1 -1
- package/dist_commonjs/utils/template.d.ts +2 -2
- package/dist_commonjs/utils/template.js.map +1 -1
- package/dist_esm/BuildConfigParser.d.ts +2 -0
- package/dist_esm/BuildConfigParser.js +23 -4
- package/dist_esm/BuildConfigParser.js.map +1 -1
- package/dist_esm/BuildFunctionGroup.d.ts +11 -3
- package/dist_esm/BuildFunctionGroup.js +16 -2
- package/dist_esm/BuildFunctionGroup.js.map +1 -1
- package/dist_esm/BuildStep.js +2 -0
- package/dist_esm/BuildStep.js.map +1 -1
- package/dist_esm/BuildStepContext.d.ts +4 -3
- package/dist_esm/BuildStepContext.js.map +1 -1
- package/dist_esm/cli/cli.d.ts +2 -1
- package/dist_esm/cli/cli.js +5 -1
- package/dist_esm/cli/cli.js.map +1 -1
- package/dist_esm/scripts/runCustomFunction.js.map +1 -1
- package/dist_esm/utils/expodash/duplicates.d.ts +1 -1
- package/dist_esm/utils/expodash/duplicates.js.map +1 -1
- package/dist_esm/utils/expodash/uniq.d.ts +1 -1
- package/dist_esm/utils/expodash/uniq.js.map +1 -1
- package/dist_esm/utils/template.d.ts +2 -2
- package/dist_esm/utils/template.js +1 -1
- package/dist_esm/utils/template.js.map +1 -1
- package/package.json +3 -2
|
@@ -53,7 +53,7 @@ class BuildConfigParser {
|
|
|
53
53
|
return this.createBuildStepsFromBareBuildStepFunctionOrBareBuildStepFunctionGroupCall(buildFunctions, buildFunctionGroups, buildStepConfig);
|
|
54
54
|
}
|
|
55
55
|
else if (buildStepConfig !== null) {
|
|
56
|
-
return
|
|
56
|
+
return this.createBuildStepsFromBuildStepFunctionOrBuildStepFunctionGroupCall(buildFunctions, buildFunctionGroups, buildStepConfig);
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
59
|
throw new errors_js_1.BuildConfigError('Invalid build step configuration detected. Build step cannot be empty.');
|
|
@@ -87,6 +87,14 @@ class BuildConfigParser {
|
|
|
87
87
|
command,
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
createBuildStepsFromBuildStepFunctionGroupCall(buildFunctionGroups, buildStepFunctionCall) {
|
|
91
|
+
const functionId = getFunctionIdFromBuildStepFunctionCall(buildStepFunctionCall);
|
|
92
|
+
const buildFunctionGroup = buildFunctionGroups[functionId];
|
|
93
|
+
(0, assert_1.default)(buildFunctionGroup, `Build function group with id "${functionId}" is not defined.`);
|
|
94
|
+
return buildFunctionGroup.createBuildStepsFromFunctionGroupCall(this.ctx, {
|
|
95
|
+
callInputs: buildStepFunctionCall[functionId].inputs,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
90
98
|
createBuildStepsFromBuildStepBareFunctionGroupCall(buildFunctionGroups, functionGroupId) {
|
|
91
99
|
const buildFunctionGroup = buildFunctionGroups[functionGroupId];
|
|
92
100
|
(0, assert_1.default)(buildFunctionGroup, `Build function group with id "${functionGroupId}" is not defined.`);
|
|
@@ -105,10 +113,16 @@ class BuildConfigParser {
|
|
|
105
113
|
this.createBuildStepFromBuildStepBareFunctionCall(buildFunctions, functionOrFunctionGroupId),
|
|
106
114
|
];
|
|
107
115
|
}
|
|
116
|
+
createBuildStepsFromBuildStepFunctionOrBuildStepFunctionGroupCall(buildFunctions, buildFunctionGroups, buildStepFunctionCall) {
|
|
117
|
+
const functionId = getFunctionIdFromBuildStepFunctionCall(buildStepFunctionCall);
|
|
118
|
+
const maybeFunctionGroup = buildFunctionGroups[functionId];
|
|
119
|
+
if (maybeFunctionGroup) {
|
|
120
|
+
return this.createBuildStepsFromBuildStepFunctionGroupCall(buildFunctionGroups, buildStepFunctionCall);
|
|
121
|
+
}
|
|
122
|
+
return [this.createBuildStepFromBuildStepFunctionCall(buildFunctions, buildStepFunctionCall)];
|
|
123
|
+
}
|
|
108
124
|
createBuildStepFromBuildStepFunctionCall(buildFunctions, buildStepFunctionCall) {
|
|
109
|
-
const
|
|
110
|
-
(0, assert_1.default)(keys.length === 1, 'There must be at most one function call in the step (enforced by joi).');
|
|
111
|
-
const functionId = keys[0];
|
|
125
|
+
const functionId = getFunctionIdFromBuildStepFunctionCall(buildStepFunctionCall);
|
|
112
126
|
const buildFunctionCallConfig = buildStepFunctionCall[functionId];
|
|
113
127
|
const buildFunction = buildFunctions[functionId];
|
|
114
128
|
return buildFunction.createBuildStepFromFunctionCall(this.ctx, {
|
|
@@ -254,4 +268,9 @@ class BuildConfigParser {
|
|
|
254
268
|
}
|
|
255
269
|
}
|
|
256
270
|
exports.BuildConfigParser = BuildConfigParser;
|
|
271
|
+
function getFunctionIdFromBuildStepFunctionCall(buildStepFunctionCall) {
|
|
272
|
+
const keys = Object.keys(buildStepFunctionCall);
|
|
273
|
+
(0, assert_1.default)(keys.length === 1, 'There must be at most one function call in the step (enforced by joi).');
|
|
274
|
+
return keys[0];
|
|
275
|
+
}
|
|
257
276
|
//# sourceMappingURL=BuildConfigParser.js.map
|
|
@@ -16,9 +16,11 @@ export declare class BuildConfigParser {
|
|
|
16
16
|
private createBuildStepFromConfig;
|
|
17
17
|
private createBuildStepFromBuildStepCommandRun;
|
|
18
18
|
private createBuildStepFromBuildStepBareCommandRun;
|
|
19
|
+
private createBuildStepsFromBuildStepFunctionGroupCall;
|
|
19
20
|
private createBuildStepsFromBuildStepBareFunctionGroupCall;
|
|
20
21
|
private createBuildStepFromBuildStepBareFunctionCall;
|
|
21
22
|
private createBuildStepsFromBareBuildStepFunctionOrBareBuildStepFunctionGroupCall;
|
|
23
|
+
private createBuildStepsFromBuildStepFunctionOrBuildStepFunctionGroupCall;
|
|
22
24
|
private createBuildStepFromBuildStepFunctionCall;
|
|
23
25
|
private createBuildFunctionsFromConfig;
|
|
24
26
|
private createBuildFunctionFromConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,qDAgB0B;AAC1B,yDAAsE;AACtE,iDAA2C;AAC3C,2DAI6B;AAE7B,6DAAgF;AAChF,yDAAmD;AACnD,2EAAqE;AACrE,2CAA+C;AAC/C,kEAA4D;AAC5D,sDAAgD;AAChD,mEAIiC;AAEjC,MAAa,iBAAiB;IAK5B,YACmB,GAA2B,EAC5C,EACE,UAAU,EACV,iBAAiB,EACjB,sBAAsB,GAKvB;QATgB,QAAG,GAAH,GAAG,CAAwB;QAW5C,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;QAClD,IAAI,CAAC,8BAA8B,CAAC,sBAAsB,CAAC,CAAC;QAE5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,UA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EAAE,GAAG,CAAC;aACtB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IACJ,CAAC;IAEO,0BAA0B;QAChC,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACzC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7D,OAAO,IAAA,cAAI,EAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAEO,+BAA+B;QACrC,IAAI,IAAI,CAAC,sBAAsB,KAAK,SAAS,EAAE,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAClE,OAAO,IAAA,cAAI,EAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CACF;AA1VD,8CA0VC","sourcesContent":["import assert from 'assert';\n\nimport {\n BuildConfig,\n BuildFunctionConfig,\n BuildFunctionInputs,\n BuildFunctionOutputs,\n BuildStepBareCommandRun,\n BuildStepBareFunctionOrFunctionGroupCall,\n BuildStepCommandRun,\n BuildStepConfig,\n BuildStepFunctionCall,\n BuildStepInputs,\n BuildStepOutputs,\n isBuildStepBareCommandRun,\n isBuildStepBareFunctionOrFunctionGroupCall,\n isBuildStepCommandRun,\n readAndValidateBuildConfigAsync,\n} from './BuildConfig.js';\nimport { BuildFunction, BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport {\n BuildStepInput,\n BuildStepInputProvider,\n BuildStepInputValueTypeName,\n} from './BuildStepInput.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepOutput, BuildStepOutputProvider } from './BuildStepOutput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildWorkflowValidator } from './BuildWorkflowValidator.js';\nimport { BuildConfigError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { uniq } from './utils/expodash/uniq.js';\nimport {\n BuildFunctionGroup,\n BuildFunctionGroupById,\n createBuildFunctionGroupByIdMapping,\n} from './BuildFunctionGroup.js';\n\nexport class BuildConfigParser {\n private readonly configPath: string;\n private readonly externalFunctions?: BuildFunction[];\n private readonly externalFunctionGroups?: BuildFunctionGroup[];\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n configPath,\n externalFunctions,\n externalFunctionGroups,\n }: {\n configPath: string;\n externalFunctions?: BuildFunction[];\n externalFunctionGroups?: BuildFunctionGroup[];\n }\n ) {\n this.validateExternalFunctions(externalFunctions);\n this.validateExternalFunctionGroups(externalFunctionGroups);\n\n this.configPath = configPath;\n this.externalFunctions = externalFunctions;\n this.externalFunctionGroups = externalFunctionGroups;\n }\n\n public async parseAsync(): Promise<BuildWorkflow> {\n const config = await readAndValidateBuildConfigAsync(this.configPath, {\n externalFunctionIds: this.getExternalFunctionFullIds(),\n externalFunctionGroupsIds: this.getExternalFunctionGroupFullIds(),\n });\n const configBuildFunctions = this.createBuildFunctionsFromConfig(config.functions);\n const buildFunctions = this.mergeBuildFunctionsWithExternal(\n configBuildFunctions,\n this.externalFunctions\n );\n const buildFunctionGroups = createBuildFunctionGroupByIdMapping(\n this.externalFunctionGroups ?? []\n );\n const buildSteps: BuildStep[] = [];\n for (const stepConfig of config.build.steps) {\n buildSteps.push(\n ...this.createBuildStepFromConfig(stepConfig, buildFunctions, buildFunctionGroups)\n );\n }\n const workflow = new BuildWorkflow(this.ctx, { buildSteps, buildFunctions });\n await new BuildWorkflowValidator(workflow).validateAsync();\n return workflow;\n }\n\n private createBuildStepFromConfig(\n buildStepConfig: BuildStepConfig,\n buildFunctions: BuildFunctionById,\n buildFunctionGroups: BuildFunctionGroupById\n ): BuildStep[] {\n if (isBuildStepCommandRun(buildStepConfig)) {\n return [this.createBuildStepFromBuildStepCommandRun(buildStepConfig)];\n } else if (isBuildStepBareCommandRun(buildStepConfig)) {\n return [this.createBuildStepFromBuildStepBareCommandRun(buildStepConfig)];\n } else if (isBuildStepBareFunctionOrFunctionGroupCall(buildStepConfig)) {\n return this.createBuildStepsFromBareBuildStepFunctionOrBareBuildStepFunctionGroupCall(\n buildFunctions,\n buildFunctionGroups,\n buildStepConfig\n );\n } else if (buildStepConfig !== null) {\n return [this.createBuildStepFromBuildStepFunctionCall(buildFunctions, buildStepConfig)];\n } else {\n throw new BuildConfigError(\n 'Invalid build step configuration detected. Build step cannot be empty.'\n );\n }\n }\n\n private createBuildStepFromBuildStepCommandRun({ run }: BuildStepCommandRun): BuildStep {\n const {\n id: maybeId,\n inputs: inputsConfig,\n outputs: outputsConfig,\n name,\n workingDirectory,\n shell,\n command,\n env,\n if: ifCondition,\n } = run;\n const id = BuildStep.getNewId(maybeId);\n const displayName = BuildStep.getDisplayName({ id, name, command });\n const inputs =\n inputsConfig && this.createBuildStepInputsFromDefinition(inputsConfig, displayName);\n const outputs =\n outputsConfig && this.createBuildStepOutputsFromDefinition(outputsConfig, displayName);\n return new BuildStep(this.ctx, {\n id,\n inputs,\n outputs,\n name,\n displayName,\n workingDirectory,\n shell,\n command,\n env,\n ifCondition,\n });\n }\n\n private createBuildStepFromBuildStepBareCommandRun({\n run: command,\n }: BuildStepBareCommandRun): BuildStep {\n const id = BuildStep.getNewId();\n const displayName = BuildStep.getDisplayName({ id, command });\n return new BuildStep(this.ctx, {\n id,\n displayName,\n command,\n });\n }\n\n private createBuildStepsFromBuildStepBareFunctionGroupCall(\n buildFunctionGroups: BuildFunctionGroupById,\n functionGroupId: string\n ): BuildStep[] {\n const buildFunctionGroup = buildFunctionGroups[functionGroupId];\n assert(buildFunctionGroup, `Build function group with id \"${functionGroupId}\" is not defined.`);\n return buildFunctionGroup.createBuildStepsFromFunctionGroupCall(this.ctx);\n }\n\n private createBuildStepFromBuildStepBareFunctionCall(\n buildFunctions: BuildFunctionById,\n functionId: BuildStepBareFunctionOrFunctionGroupCall\n ): BuildStep {\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx);\n }\n\n private createBuildStepsFromBareBuildStepFunctionOrBareBuildStepFunctionGroupCall(\n buildFunctions: BuildFunctionById,\n buildFunctionGroups: BuildFunctionGroupById,\n functionOrFunctionGroupId: string\n ): BuildStep[] {\n const maybeFunctionGroup = buildFunctionGroups[functionOrFunctionGroupId];\n if (maybeFunctionGroup) {\n return this.createBuildStepsFromBuildStepBareFunctionGroupCall(\n buildFunctionGroups,\n functionOrFunctionGroupId\n );\n }\n return [\n this.createBuildStepFromBuildStepBareFunctionCall(buildFunctions, functionOrFunctionGroupId),\n ];\n }\n\n private createBuildStepFromBuildStepFunctionCall(\n buildFunctions: BuildFunctionById,\n buildStepFunctionCall: BuildStepFunctionCall\n ): BuildStep {\n const keys = Object.keys(buildStepFunctionCall);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n const functionId = keys[0];\n const buildFunctionCallConfig = buildStepFunctionCall[functionId];\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx, {\n id: buildFunctionCallConfig.id,\n name: buildFunctionCallConfig.name,\n callInputs: buildFunctionCallConfig.inputs,\n workingDirectory: buildFunctionCallConfig.workingDirectory,\n shell: buildFunctionCallConfig.shell,\n env: buildFunctionCallConfig.env,\n ifCondition: buildFunctionCallConfig.if,\n });\n }\n\n private createBuildFunctionsFromConfig(\n buildFunctionsConfig: BuildConfig['functions']\n ): BuildFunctionById {\n if (!buildFunctionsConfig) {\n return {};\n }\n const result: BuildFunctionById = {};\n for (const [functionId, buildFunctionConfig] of Object.entries(buildFunctionsConfig)) {\n const buildFunction = this.createBuildFunctionFromConfig({\n id: functionId,\n ...buildFunctionConfig,\n });\n result[buildFunction.getFullId()] = buildFunction;\n }\n return result;\n }\n\n private createBuildFunctionFromConfig({\n id,\n name,\n inputs: inputsConfig,\n outputs: outputsConfig,\n shell,\n command,\n supportedRuntimePlatforms,\n path: customFunctionModulePath,\n }: BuildFunctionConfig & { id: string }): BuildFunction {\n const inputProviders =\n inputsConfig && this.createBuildStepInputProvidersFromBuildFunctionInputs(inputsConfig);\n const outputProviders =\n outputsConfig && this.createBuildStepOutputProvidersFromBuildFunctionOutputs(outputsConfig);\n return new BuildFunction({\n id,\n name,\n inputProviders,\n outputProviders,\n shell,\n command,\n customFunctionModulePath,\n supportedRuntimePlatforms,\n });\n }\n\n private createBuildStepInputsFromDefinition(\n buildStepInputs: BuildStepInputs,\n stepDisplayName: string\n ): BuildStepInput[] {\n return Object.entries(buildStepInputs).map(\n ([key, value]) =>\n new BuildStepInput(this.ctx, {\n id: key,\n stepDisplayName,\n defaultValue: value,\n required: true,\n allowedValueTypeName:\n typeof value === 'object'\n ? BuildStepInputValueTypeName.JSON\n : (typeof value as BuildStepInputValueTypeName),\n })\n );\n }\n\n private createBuildStepInputProvidersFromBuildFunctionInputs(\n buildFunctionInputs: BuildFunctionInputs\n ): BuildStepInputProvider[] {\n return buildFunctionInputs.map((entry) => {\n return typeof entry === 'string'\n ? BuildStepInput.createProvider({\n id: entry,\n required: true,\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n })\n : BuildStepInput.createProvider({\n id: entry.name,\n required: entry.required ?? true,\n defaultValue: entry.defaultValue,\n allowedValues: entry.allowedValues,\n allowedValueTypeName: entry.allowedValueType,\n });\n });\n }\n\n private createBuildStepOutputsFromDefinition(\n buildStepOutputs: BuildStepOutputs,\n stepDisplayName: string\n ): BuildStepOutput[] {\n return buildStepOutputs.map((entry) =>\n typeof entry === 'string'\n ? new BuildStepOutput(this.ctx, { id: entry, stepDisplayName, required: true })\n : new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepDisplayName,\n required: entry.required ?? true,\n })\n );\n }\n\n private createBuildStepOutputProvidersFromBuildFunctionOutputs(\n buildFunctionOutputs: BuildFunctionOutputs\n ): BuildStepOutputProvider[] {\n return buildFunctionOutputs.map((entry) =>\n typeof entry === 'string'\n ? BuildStepOutput.createProvider({ id: entry, required: true })\n : BuildStepOutput.createProvider({ id: entry.name, required: entry.required ?? true })\n );\n }\n\n private mergeBuildFunctionsWithExternal(\n configFunctions: BuildFunctionById,\n externalFunctions?: BuildFunction[]\n ): BuildFunctionById {\n const result: BuildFunctionById = { ...configFunctions };\n if (externalFunctions === undefined) {\n return result;\n }\n for (const buildFunction of externalFunctions) {\n // functions defined in config shadow the external ones\n const fullId = buildFunction.getFullId();\n if (!(fullId in result)) {\n result[fullId] = buildFunction;\n }\n }\n return result;\n }\n\n private validateExternalFunctions(externalFunctions?: BuildFunction[]): void {\n if (externalFunctions === undefined) {\n return;\n }\n const externalFunctionIds = externalFunctions.map((f) => f.getFullId());\n const duplicatedExternalFunctionIds = duplicates(externalFunctionIds);\n if (duplicatedExternalFunctionIds.length === 0) {\n return;\n }\n throw new BuildConfigError(\n `Provided external functions with duplicated IDs: ${duplicatedExternalFunctionIds\n .map((id) => `\"${id}\"`)\n .join(', ')}`\n );\n }\n\n private validateExternalFunctionGroups(externalFunctionGroups?: BuildFunctionGroup[]): void {\n if (externalFunctionGroups === undefined) {\n return;\n }\n const externalFunctionGroupIds = externalFunctionGroups.map((f) => f.getFullId());\n const duplicatedExternalFunctionGroupIds = duplicates(externalFunctionGroupIds);\n if (duplicatedExternalFunctionGroupIds.length === 0) {\n return;\n }\n throw new BuildConfigError(\n `Provided external function groups with duplicated IDs: ${duplicatedExternalFunctionGroupIds\n .map((id) => `\"${id}\"`)\n .join(', ')}`\n );\n }\n\n private getExternalFunctionFullIds(): string[] {\n if (this.externalFunctions === undefined) {\n return [];\n }\n const ids = this.externalFunctions.map((f) => f.getFullId());\n return uniq(ids);\n }\n\n private getExternalFunctionGroupFullIds(): string[] {\n if (this.externalFunctionGroups === undefined) {\n return [];\n }\n const ids = this.externalFunctionGroups.map((f) => f.getFullId());\n return uniq(ids);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,qDAgB0B;AAC1B,yDAAsE;AACtE,iDAA2C;AAC3C,2DAI6B;AAE7B,6DAAgF;AAChF,yDAAmD;AACnD,2EAAqE;AACrE,2CAA+C;AAC/C,kEAA4D;AAC5D,sDAAgD;AAChD,mEAIiC;AAEjC,MAAa,iBAAiB;IAK5B,YACmB,GAA2B,EAC5C,EACE,UAAU,EACV,iBAAiB,EACjB,sBAAsB,GAKvB;QATgB,QAAG,GAAH,GAAG,CAAwB;QAW5C,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;QAClD,IAAI,CAAC,8BAA8B,CAAC,sBAAsB,CAAC,CAAC;QAE5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;IACvD,CAAC;IAEM,KAAK,CAAC,UAAU;;QACrB,MAAM,MAAM,GAAG,MAAM,IAAA,gDAA+B,EAAC,IAAI,CAAC,UAAU,EAAE;YACpE,mBAAmB,EAAE,IAAI,CAAC,0BAA0B,EAAE;YACtD,yBAAyB,EAAE,IAAI,CAAC,+BAA+B,EAAE;SAClE,CAAC,CAAC;QACH,MAAM,oBAAoB,GAAG,IAAI,CAAC,8BAA8B,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnF,MAAM,cAAc,GAAG,IAAI,CAAC,+BAA+B,CACzD,oBAAoB,EACpB,IAAI,CAAC,iBAAiB,CACvB,CAAC;QACF,MAAM,mBAAmB,GAAG,IAAA,2DAAmC,EAC7D,MAAA,IAAI,CAAC,sBAAsB,mCAAI,EAAE,CAClC,CAAC;QACF,MAAM,UAAU,GAAgB,EAAE,CAAC;QACnC,KAAK,MAAM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O;QACT,CAAC;QACD,MAAM,IAAI,4BAAgB,CACxB,0DAA0D,kCAAkC;aACzF,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;aACtB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IACJ,CAAC;IAEO,0BAA0B;QAChC,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YACzC,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7D,OAAO,IAAA,cAAI,EAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAEO,+BAA+B;QACrC,IAAI,IAAI,CAAC,sBAAsB,KAAK,SAAS,EAAE,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAClE,OAAO,IAAA,cAAI,EAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CACF;AAtXD,8CAsXC;AAED,SAAS,sCAAsC,CAC7C,qBAA4C;IAE5C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAChD,IAAA,gBAAM,EACJ,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,wEAAwE,CACzE,CAAC;IACF,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC","sourcesContent":["import assert from 'assert';\n\nimport {\n BuildConfig,\n BuildFunctionConfig,\n BuildFunctionInputs,\n BuildFunctionOutputs,\n BuildStepBareCommandRun,\n BuildStepBareFunctionOrFunctionGroupCall,\n BuildStepCommandRun,\n BuildStepConfig,\n BuildStepFunctionCall,\n BuildStepInputs,\n BuildStepOutputs,\n isBuildStepBareCommandRun,\n isBuildStepBareFunctionOrFunctionGroupCall,\n isBuildStepCommandRun,\n readAndValidateBuildConfigAsync,\n} from './BuildConfig.js';\nimport { BuildFunction, BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport {\n BuildStepInput,\n BuildStepInputProvider,\n BuildStepInputValueTypeName,\n} from './BuildStepInput.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepOutput, BuildStepOutputProvider } from './BuildStepOutput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildWorkflowValidator } from './BuildWorkflowValidator.js';\nimport { BuildConfigError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { uniq } from './utils/expodash/uniq.js';\nimport {\n BuildFunctionGroup,\n BuildFunctionGroupById,\n createBuildFunctionGroupByIdMapping,\n} from './BuildFunctionGroup.js';\n\nexport class BuildConfigParser {\n private readonly configPath: string;\n private readonly externalFunctions?: BuildFunction[];\n private readonly externalFunctionGroups?: BuildFunctionGroup[];\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n configPath,\n externalFunctions,\n externalFunctionGroups,\n }: {\n configPath: string;\n externalFunctions?: BuildFunction[];\n externalFunctionGroups?: BuildFunctionGroup[];\n }\n ) {\n this.validateExternalFunctions(externalFunctions);\n this.validateExternalFunctionGroups(externalFunctionGroups);\n\n this.configPath = configPath;\n this.externalFunctions = externalFunctions;\n this.externalFunctionGroups = externalFunctionGroups;\n }\n\n public async parseAsync(): Promise<BuildWorkflow> {\n const config = await readAndValidateBuildConfigAsync(this.configPath, {\n externalFunctionIds: this.getExternalFunctionFullIds(),\n externalFunctionGroupsIds: this.getExternalFunctionGroupFullIds(),\n });\n const configBuildFunctions = this.createBuildFunctionsFromConfig(config.functions);\n const buildFunctions = this.mergeBuildFunctionsWithExternal(\n configBuildFunctions,\n this.externalFunctions\n );\n const buildFunctionGroups = createBuildFunctionGroupByIdMapping(\n this.externalFunctionGroups ?? []\n );\n const buildSteps: BuildStep[] = [];\n for (const stepConfig of config.build.steps) {\n buildSteps.push(\n ...this.createBuildStepFromConfig(stepConfig, buildFunctions, buildFunctionGroups)\n );\n }\n const workflow = new BuildWorkflow(this.ctx, { buildSteps, buildFunctions });\n await new BuildWorkflowValidator(workflow).validateAsync();\n return workflow;\n }\n\n private createBuildStepFromConfig(\n buildStepConfig: BuildStepConfig,\n buildFunctions: BuildFunctionById,\n buildFunctionGroups: BuildFunctionGroupById\n ): BuildStep[] {\n if (isBuildStepCommandRun(buildStepConfig)) {\n return [this.createBuildStepFromBuildStepCommandRun(buildStepConfig)];\n } else if (isBuildStepBareCommandRun(buildStepConfig)) {\n return [this.createBuildStepFromBuildStepBareCommandRun(buildStepConfig)];\n } else if (isBuildStepBareFunctionOrFunctionGroupCall(buildStepConfig)) {\n return this.createBuildStepsFromBareBuildStepFunctionOrBareBuildStepFunctionGroupCall(\n buildFunctions,\n buildFunctionGroups,\n buildStepConfig\n );\n } else if (buildStepConfig !== null) {\n return this.createBuildStepsFromBuildStepFunctionOrBuildStepFunctionGroupCall(\n buildFunctions,\n buildFunctionGroups,\n buildStepConfig\n );\n } else {\n throw new BuildConfigError(\n 'Invalid build step configuration detected. Build step cannot be empty.'\n );\n }\n }\n\n private createBuildStepFromBuildStepCommandRun({ run }: BuildStepCommandRun): BuildStep {\n const {\n id: maybeId,\n inputs: inputsConfig,\n outputs: outputsConfig,\n name,\n workingDirectory,\n shell,\n command,\n env,\n if: ifCondition,\n } = run;\n const id = BuildStep.getNewId(maybeId);\n const displayName = BuildStep.getDisplayName({ id, name, command });\n const inputs =\n inputsConfig && this.createBuildStepInputsFromDefinition(inputsConfig, displayName);\n const outputs =\n outputsConfig && this.createBuildStepOutputsFromDefinition(outputsConfig, displayName);\n return new BuildStep(this.ctx, {\n id,\n inputs,\n outputs,\n name,\n displayName,\n workingDirectory,\n shell,\n command,\n env,\n ifCondition,\n });\n }\n\n private createBuildStepFromBuildStepBareCommandRun({\n run: command,\n }: BuildStepBareCommandRun): BuildStep {\n const id = BuildStep.getNewId();\n const displayName = BuildStep.getDisplayName({ id, command });\n return new BuildStep(this.ctx, {\n id,\n displayName,\n command,\n });\n }\n\n private createBuildStepsFromBuildStepFunctionGroupCall(\n buildFunctionGroups: BuildFunctionGroupById,\n buildStepFunctionCall: BuildStepFunctionCall\n ): BuildStep[] {\n const functionId = getFunctionIdFromBuildStepFunctionCall(buildStepFunctionCall);\n const buildFunctionGroup = buildFunctionGroups[functionId];\n assert(buildFunctionGroup, `Build function group with id \"${functionId}\" is not defined.`);\n return buildFunctionGroup.createBuildStepsFromFunctionGroupCall(this.ctx, {\n callInputs: buildStepFunctionCall[functionId].inputs,\n });\n }\n\n private createBuildStepsFromBuildStepBareFunctionGroupCall(\n buildFunctionGroups: BuildFunctionGroupById,\n functionGroupId: string\n ): BuildStep[] {\n const buildFunctionGroup = buildFunctionGroups[functionGroupId];\n assert(buildFunctionGroup, `Build function group with id \"${functionGroupId}\" is not defined.`);\n return buildFunctionGroup.createBuildStepsFromFunctionGroupCall(this.ctx);\n }\n\n private createBuildStepFromBuildStepBareFunctionCall(\n buildFunctions: BuildFunctionById,\n functionId: BuildStepBareFunctionOrFunctionGroupCall\n ): BuildStep {\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx);\n }\n\n private createBuildStepsFromBareBuildStepFunctionOrBareBuildStepFunctionGroupCall(\n buildFunctions: BuildFunctionById,\n buildFunctionGroups: BuildFunctionGroupById,\n functionOrFunctionGroupId: string\n ): BuildStep[] {\n const maybeFunctionGroup = buildFunctionGroups[functionOrFunctionGroupId];\n if (maybeFunctionGroup) {\n return this.createBuildStepsFromBuildStepBareFunctionGroupCall(\n buildFunctionGroups,\n functionOrFunctionGroupId\n );\n }\n return [\n this.createBuildStepFromBuildStepBareFunctionCall(buildFunctions, functionOrFunctionGroupId),\n ];\n }\n\n private createBuildStepsFromBuildStepFunctionOrBuildStepFunctionGroupCall(\n buildFunctions: BuildFunctionById,\n buildFunctionGroups: BuildFunctionGroupById,\n buildStepFunctionCall: BuildStepFunctionCall\n ): BuildStep[] {\n const functionId = getFunctionIdFromBuildStepFunctionCall(buildStepFunctionCall);\n\n const maybeFunctionGroup = buildFunctionGroups[functionId];\n if (maybeFunctionGroup) {\n return this.createBuildStepsFromBuildStepFunctionGroupCall(\n buildFunctionGroups,\n buildStepFunctionCall\n );\n }\n return [this.createBuildStepFromBuildStepFunctionCall(buildFunctions, buildStepFunctionCall)];\n }\n\n private createBuildStepFromBuildStepFunctionCall(\n buildFunctions: BuildFunctionById,\n buildStepFunctionCall: BuildStepFunctionCall\n ): BuildStep {\n const functionId = getFunctionIdFromBuildStepFunctionCall(buildStepFunctionCall);\n const buildFunctionCallConfig = buildStepFunctionCall[functionId];\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx, {\n id: buildFunctionCallConfig.id,\n name: buildFunctionCallConfig.name,\n callInputs: buildFunctionCallConfig.inputs,\n workingDirectory: buildFunctionCallConfig.workingDirectory,\n shell: buildFunctionCallConfig.shell,\n env: buildFunctionCallConfig.env,\n ifCondition: buildFunctionCallConfig.if,\n });\n }\n\n private createBuildFunctionsFromConfig(\n buildFunctionsConfig: BuildConfig['functions']\n ): BuildFunctionById {\n if (!buildFunctionsConfig) {\n return {};\n }\n const result: BuildFunctionById = {};\n for (const [functionId, buildFunctionConfig] of Object.entries(buildFunctionsConfig)) {\n const buildFunction = this.createBuildFunctionFromConfig({\n id: functionId,\n ...buildFunctionConfig,\n });\n result[buildFunction.getFullId()] = buildFunction;\n }\n return result;\n }\n\n private createBuildFunctionFromConfig({\n id,\n name,\n inputs: inputsConfig,\n outputs: outputsConfig,\n shell,\n command,\n supportedRuntimePlatforms,\n path: customFunctionModulePath,\n }: BuildFunctionConfig & { id: string }): BuildFunction {\n const inputProviders =\n inputsConfig && this.createBuildStepInputProvidersFromBuildFunctionInputs(inputsConfig);\n const outputProviders =\n outputsConfig && this.createBuildStepOutputProvidersFromBuildFunctionOutputs(outputsConfig);\n return new BuildFunction({\n id,\n name,\n inputProviders,\n outputProviders,\n shell,\n command,\n customFunctionModulePath,\n supportedRuntimePlatforms,\n });\n }\n\n private createBuildStepInputsFromDefinition(\n buildStepInputs: BuildStepInputs,\n stepDisplayName: string\n ): BuildStepInput[] {\n return Object.entries(buildStepInputs).map(\n ([key, value]) =>\n new BuildStepInput(this.ctx, {\n id: key,\n stepDisplayName,\n defaultValue: value,\n required: true,\n allowedValueTypeName:\n typeof value === 'object'\n ? BuildStepInputValueTypeName.JSON\n : (typeof value as BuildStepInputValueTypeName),\n })\n );\n }\n\n private createBuildStepInputProvidersFromBuildFunctionInputs(\n buildFunctionInputs: BuildFunctionInputs\n ): BuildStepInputProvider[] {\n return buildFunctionInputs.map((entry) => {\n return typeof entry === 'string'\n ? BuildStepInput.createProvider({\n id: entry,\n required: true,\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n })\n : BuildStepInput.createProvider({\n id: entry.name,\n required: entry.required ?? true,\n defaultValue: entry.defaultValue,\n allowedValues: entry.allowedValues,\n allowedValueTypeName: entry.allowedValueType,\n });\n });\n }\n\n private createBuildStepOutputsFromDefinition(\n buildStepOutputs: BuildStepOutputs,\n stepDisplayName: string\n ): BuildStepOutput[] {\n return buildStepOutputs.map((entry) =>\n typeof entry === 'string'\n ? new BuildStepOutput(this.ctx, { id: entry, stepDisplayName, required: true })\n : new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepDisplayName,\n required: entry.required ?? true,\n })\n );\n }\n\n private createBuildStepOutputProvidersFromBuildFunctionOutputs(\n buildFunctionOutputs: BuildFunctionOutputs\n ): BuildStepOutputProvider[] {\n return buildFunctionOutputs.map((entry) =>\n typeof entry === 'string'\n ? BuildStepOutput.createProvider({ id: entry, required: true })\n : BuildStepOutput.createProvider({ id: entry.name, required: entry.required ?? true })\n );\n }\n\n private mergeBuildFunctionsWithExternal(\n configFunctions: BuildFunctionById,\n externalFunctions?: BuildFunction[]\n ): BuildFunctionById {\n const result: BuildFunctionById = { ...configFunctions };\n if (externalFunctions === undefined) {\n return result;\n }\n for (const buildFunction of externalFunctions) {\n // functions defined in config shadow the external ones\n const fullId = buildFunction.getFullId();\n if (!(fullId in result)) {\n result[fullId] = buildFunction;\n }\n }\n return result;\n }\n\n private validateExternalFunctions(externalFunctions?: BuildFunction[]): void {\n if (externalFunctions === undefined) {\n return;\n }\n const externalFunctionIds = externalFunctions.map((f) => f.getFullId());\n const duplicatedExternalFunctionIds = duplicates(externalFunctionIds);\n if (duplicatedExternalFunctionIds.length === 0) {\n return;\n }\n throw new BuildConfigError(\n `Provided external functions with duplicated IDs: ${duplicatedExternalFunctionIds\n .map((id) => `\"${id}\"`)\n .join(', ')}`\n );\n }\n\n private validateExternalFunctionGroups(externalFunctionGroups?: BuildFunctionGroup[]): void {\n if (externalFunctionGroups === undefined) {\n return;\n }\n const externalFunctionGroupIds = externalFunctionGroups.map((f) => f.getFullId());\n const duplicatedExternalFunctionGroupIds = duplicates(externalFunctionGroupIds);\n if (duplicatedExternalFunctionGroupIds.length === 0) {\n return;\n }\n throw new BuildConfigError(\n `Provided external function groups with duplicated IDs: ${duplicatedExternalFunctionGroupIds\n .map((id) => `\"${id}\"`)\n .join(', ')}`\n );\n }\n\n private getExternalFunctionFullIds(): string[] {\n if (this.externalFunctions === undefined) {\n return [];\n }\n const ids = this.externalFunctions.map((f) => f.getFullId());\n return uniq(ids);\n }\n\n private getExternalFunctionGroupFullIds(): string[] {\n if (this.externalFunctionGroups === undefined) {\n return [];\n }\n const ids = this.externalFunctionGroups.map((f) => f.getFullId());\n return uniq(ids);\n }\n}\n\nfunction getFunctionIdFromBuildStepFunctionCall(\n buildStepFunctionCall: BuildStepFunctionCall\n): string {\n const keys = Object.keys(buildStepFunctionCall);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n return keys[0];\n}\n"]}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createBuildFunctionGroupByIdMapping = exports.BuildFunctionGroup = void 0;
|
|
4
|
+
const BuildStepInput_js_1 = require("./BuildStepInput.cjs");
|
|
4
5
|
const errors_js_1 = require("./errors.cjs");
|
|
5
6
|
class BuildFunctionGroup {
|
|
6
|
-
constructor({ namespace, id, createBuildStepsFromFunctionGroupCall, }) {
|
|
7
|
+
constructor({ namespace, id, inputProviders, createBuildStepsFromFunctionGroupCall, }) {
|
|
7
8
|
this.namespace = namespace;
|
|
8
9
|
this.id = id;
|
|
9
|
-
this.
|
|
10
|
+
this.inputProviders = inputProviders;
|
|
11
|
+
this.createBuildStepsFromFunctionGroupCall = (ctx, { callInputs = {} } = {}) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const inputs = (_a = this.inputProviders) === null || _a === void 0 ? void 0 : _a.map((inputProvider) => {
|
|
14
|
+
const input = inputProvider(ctx, id);
|
|
15
|
+
if (input.id in callInputs) {
|
|
16
|
+
input.set(callInputs[input.id]);
|
|
17
|
+
}
|
|
18
|
+
return input;
|
|
19
|
+
});
|
|
20
|
+
return createBuildStepsFromFunctionGroupCall(ctx, {
|
|
21
|
+
inputs: (0, BuildStepInput_js_1.makeBuildStepInputByIdMap)(inputs),
|
|
22
|
+
});
|
|
23
|
+
};
|
|
10
24
|
}
|
|
11
25
|
getFullId() {
|
|
12
26
|
return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
import { BuildFunctionCallInputs } from './BuildFunction.js';
|
|
1
2
|
import { BuildStep } from './BuildStep.js';
|
|
2
3
|
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
4
|
+
import { BuildStepInputById, BuildStepInputProvider } from './BuildStepInput.js';
|
|
3
5
|
export type BuildFunctionGroupById = Record<string, BuildFunctionGroup | undefined>;
|
|
4
6
|
export declare class BuildFunctionGroup {
|
|
5
7
|
readonly namespace: string;
|
|
6
8
|
readonly id: string;
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
+
readonly inputProviders?: BuildStepInputProvider[];
|
|
10
|
+
readonly createBuildStepsFromFunctionGroupCall: (globalCtx: BuildStepGlobalContext, options?: {
|
|
11
|
+
callInputs?: BuildFunctionCallInputs;
|
|
12
|
+
}) => BuildStep[];
|
|
13
|
+
constructor({ namespace, id, inputProviders, createBuildStepsFromFunctionGroupCall, }: {
|
|
9
14
|
namespace: string;
|
|
10
15
|
id: string;
|
|
11
|
-
|
|
16
|
+
inputProviders?: BuildStepInputProvider[];
|
|
17
|
+
createBuildStepsFromFunctionGroupCall: (globalCtx: BuildStepGlobalContext, { inputs, }: {
|
|
18
|
+
inputs: BuildStepInputById;
|
|
19
|
+
}) => BuildStep[];
|
|
12
20
|
});
|
|
13
21
|
getFullId(): string;
|
|
14
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildFunctionGroup.js","sourceRoot":"","sources":["../src/BuildFunctionGroup.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"BuildFunctionGroup.js","sourceRoot":"","sources":["../src/BuildFunctionGroup.ts"],"names":[],"mappings":";;;AAGA,2DAI6B;AAC7B,2CAA+C;AAI/C,MAAa,kBAAkB;IAW7B,YAAY,EACV,SAAS,EACT,EAAE,EACF,cAAc,EACd,qCAAqC,GAatC;QACC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,qCAAqC,GAAG,CAAC,GAAG,EAAE,EAAE,UAAU,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;;YAC7E,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,cAAc,0CAAE,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE;gBACxD,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBACrC,IAAI,KAAK,CAAC,EAAE,IAAI,UAAU,EAAE,CAAC;oBAC3B,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClC,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CAAC;YACH,OAAO,qCAAqC,CAAC,GAAG,EAAE;gBAChD,MAAM,EAAE,IAAA,6CAAyB,EAAC,MAAM,CAAC;aAC1C,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;IACjF,CAAC;CACF;AAlDD,gDAkDC;AAED,SAAgB,mCAAmC,CACjD,mBAAyC;IAEzC,MAAM,sBAAsB,GAA2B,EAAE,CAAC;IAC1D,KAAK,MAAM,kBAAkB,IAAI,mBAAmB,EAAE,CAAC;QACrD,IAAI,sBAAsB,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;YACzE,MAAM,IAAI,4BAAgB,CACxB,gCAAgC,kBAAkB,CAAC,SAAS,EAAE,sBAAsB,CACrF,CAAC;QACJ,CAAC;QACD,sBAAsB,CAAC,kBAAkB,CAAC,SAAS,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9E,CAAC;IACD,OAAO,sBAAsB,CAAC;AAChC,CAAC;AAbD,kFAaC","sourcesContent":["import { BuildFunctionCallInputs } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\nimport {\n BuildStepInputById,\n BuildStepInputProvider,\n makeBuildStepInputByIdMap,\n} from './BuildStepInput.js';\nimport { BuildConfigError } from './errors.js';\n\nexport type BuildFunctionGroupById = Record<string, BuildFunctionGroup | undefined>;\n\nexport class BuildFunctionGroup {\n public readonly namespace: string;\n public readonly id: string;\n public readonly inputProviders?: BuildStepInputProvider[];\n public readonly createBuildStepsFromFunctionGroupCall: (\n globalCtx: BuildStepGlobalContext,\n options?: {\n callInputs?: BuildFunctionCallInputs;\n }\n ) => BuildStep[];\n\n constructor({\n namespace,\n id,\n inputProviders,\n createBuildStepsFromFunctionGroupCall,\n }: {\n namespace: string;\n id: string;\n inputProviders?: BuildStepInputProvider[];\n createBuildStepsFromFunctionGroupCall: (\n globalCtx: BuildStepGlobalContext,\n {\n inputs,\n }: {\n inputs: BuildStepInputById;\n }\n ) => BuildStep[];\n }) {\n this.namespace = namespace;\n this.id = id;\n this.inputProviders = inputProviders;\n\n this.createBuildStepsFromFunctionGroupCall = (ctx, { callInputs = {} } = {}) => {\n const inputs = this.inputProviders?.map((inputProvider) => {\n const input = inputProvider(ctx, id);\n if (input.id in callInputs) {\n input.set(callInputs[input.id]);\n }\n return input;\n });\n return createBuildStepsFromFunctionGroupCall(ctx, {\n inputs: makeBuildStepInputByIdMap(inputs),\n });\n };\n }\n\n public getFullId(): string {\n return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;\n }\n}\n\nexport function createBuildFunctionGroupByIdMapping(\n buildFunctionGroups: BuildFunctionGroup[]\n): BuildFunctionGroupById {\n const buildFunctionGroupById: BuildFunctionGroupById = {};\n for (const buildFunctionGroup of buildFunctionGroups) {\n if (buildFunctionGroupById[buildFunctionGroup.getFullId()] !== undefined) {\n throw new BuildConfigError(\n `Build function group with id ${buildFunctionGroup.getFullId()} is already defined.`\n );\n }\n buildFunctionGroupById[buildFunctionGroup.getFullId()] = buildFunctionGroup;\n }\n return buildFunctionGroupById;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;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;QACjC,CAAC,CAAC,CACH,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;YACxB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG;YACtB,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,EACnB,OAAO,EACP,UAAU,GAIX;;QACC,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACpD,MAAM,WAAW,GAAG,MAAA,GAAG,CAAC,IAAI,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,iBAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC;QACtE,OAAO;YACL,GAAG,GAAG;YACN,wBAAwB,EAAE,UAAU;YACpC,qBAAqB,EAAE,OAAO;YAC9B,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF;AApWD,8BAoWC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput.js';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryEnvsDirectoryAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport {\n getSelectedStatusCheckFromIfStatementTemplate,\n interpolateWithInputs,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n SKIPPED = 'skipped',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport type BuildStepFunction = (\n ctx: BuildStepContext,\n {\n inputs,\n outputs,\n env,\n }: { inputs: BuildStepInputById; outputs: BuildStepOutputById; env: BuildStepEnv }\n) => unknown;\n\n// TODO: move to a place common with tests\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/;\n\nexport interface SerializedBuildStepOutputAccessor {\n id: string;\n executed: boolean;\n outputById: Record<string, SerializedBuildStepOutput>;\n displayName: string;\n}\n\nexport class BuildStepOutputAccessor {\n constructor(\n public readonly id: string,\n public readonly displayName: string,\n protected readonly executed: boolean,\n protected readonly outputById: BuildStepOutputById\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.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public serialize(): SerializedBuildStepOutputAccessor {\n return {\n id: this.id,\n executed: this.executed,\n outputById: Object.fromEntries(\n Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])\n ),\n displayName: this.displayName,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepOutputAccessor\n ): BuildStepOutputAccessor {\n const outputById = Object.fromEntries(\n Object.entries(serialized.outputById).map(([key, value]) => [\n key,\n BuildStepOutput.deserialize(value),\n ])\n );\n return new BuildStepOutputAccessor(\n serialized.id,\n serialized.displayName,\n serialized.executed,\n outputById\n );\n }\n}\n\nexport class BuildStep extends BuildStepOutputAccessor {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell: string;\n public readonly ctx: BuildStepContext;\n public readonly env: BuildStepEnv;\n public readonly ifCondition?: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected readonly outputById: BuildStepOutputById;\n protected executed = false;\n\n public static getNewId(userDefinedId?: string): string {\n return userDefinedId ?? uuidv4();\n }\n\n public static getDisplayName({\n id,\n name,\n command,\n }: {\n id: string;\n name?: string;\n command?: string;\n }): string {\n if (name) {\n return name;\n }\n if (!id.match(UUID_REGEX)) {\n return id;\n }\n if (command) {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return id;\n }\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n displayName,\n inputs,\n outputs,\n command,\n fn,\n workingDirectory: maybeWorkingDirectory,\n shell,\n supportedRuntimePlatforms: maybeSupportedRuntimePlatforms,\n env,\n ifCondition,\n }: {\n id: string;\n name?: string;\n displayName: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command?: string;\n fn?: BuildStepFunction;\n workingDirectory?: string;\n shell?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n env?: BuildStepEnv;\n ifCondition?: string;\n }\n ) {\n assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n const outputById = makeBuildStepOutputByIdMap(outputs);\n super(id, displayName, false, outputById);\n\n this.id = id;\n this.name = name;\n this.displayName = displayName;\n this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;\n this.inputs = inputs;\n this.outputs = outputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? getDefaultShell();\n this.ifCondition = ifCondition;\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n\n const logger = ctx.baseLogger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });\n this.env = env ?? {};\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.displayName}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n if (this.command !== undefined) {\n await this.executeCommandAsync();\n } else {\n await this.exectuteFnAsync();\n }\n\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.displayName}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.ctx.logger.error({ err });\n this.ctx.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.displayName}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\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.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean {\n const defaultStatusCheck = 'success';\n const statusCheck = this.ifCondition\n ? getSelectedStatusCheckFromIfStatementTemplate(this.ifCondition)\n : defaultStatusCheck;\n\n switch (statusCheck) {\n case 'success':\n return !hasAnyPreviousStepsFailed;\n case 'failure':\n return hasAnyPreviousStepsFailed;\n case 'always':\n return true;\n }\n }\n\n public skip(): void {\n this.status = BuildStepStatus.SKIPPED;\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n 'Executing build step \"${this.displayName}\"'\n );\n this.ctx.logger.info(`Skipped build step \"${this.displayName}\"`);\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED },\n `Skipped build step \"${this.displayName}\"`\n );\n }\n\n private async executeCommandAsync(): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n try {\n const command = this.interpolateInputsAndGlobalContextInCommand(this.command, this.inputs);\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);\n this.ctx.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.ctx.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n // stdin is /dev/null, std{out,err} are piped into logger.\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private async exectuteFnAsync(): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n try {\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n await this.fn(this.ctx, {\n inputs: this.inputById,\n outputs: this.outputById,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private interpolateInputsAndGlobalContextInCommand(\n command: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return this.ctx.global.interpolate(command);\n }\n const vars = inputs.reduce(\n (acc, input) => {\n acc[input.id] =\n typeof input.value === 'object'\n ? JSON.stringify(input.value)\n : input.value?.toString() ?? '';\n return acc;\n },\n {} as Record<string, string>\n );\n const valueInterpolatedWithGlobalContext = this.ctx.global.interpolate(command);\n return interpolateWithInputs(valueInterpolatedWithGlobalContext, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.ctx.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.ctx.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.ctx.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(`Some required outputs have not been set: ${idsString}`, {\n metadata: { ids: nonSetRequiredOutputIds },\n });\n }\n }\n\n private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> {\n const filenames = await fs.readdir(envsDir);\n\n const entries = await Promise.all(\n filenames.map(async (basename) => {\n const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');\n return [basename, rawContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private getScriptEnv({\n envsDir,\n outputsDir,\n }: {\n envsDir: string;\n outputsDir: string;\n }): Record<string, string> {\n const env = { ...this.ctx.global.env, ...this.env };\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_ENVS_DIR: envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AAExB,+BAAoC;AAGpC,2DAAoG;AACpG,6DAK8B;AAC9B,iDAAgD;AAChD,yDAAmF;AACnF,qEAKkC;AAClC,qDAAoD;AACpD,qDAG6B;AAC7B,2CAAoD;AAIpD,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAWD,0CAA0C;AAC1C,MAAM,UAAU,GACd,uFAAuF,CAAC;AAS1F,MAAa,uBAAuB;IAClC,YACkB,EAAU,EACV,WAAmB,EAChB,QAAiB,EACjB,UAA+B;QAHlC,OAAE,GAAF,EAAE,CAAQ;QACV,gBAAW,GAAX,WAAW,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAS;QACjB,eAAU,GAAV,UAAU,CAAqB;IACjD,CAAC;IAEG,oBAAoB,CAAC,IAAY;QACtC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,iCAAqB,CAC7B,0BAA0B,IAAI,gBAAgB,IAAI,CAAC,WAAW,wCAAwC,CACvG,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,C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C/B,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAC/B,MAAM,WAAW,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;YAC7E,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACjC,CAAC,CAAC,CACH,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;YACxB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG;YACtB,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,EACnB,OAAO,EACP,UAAU,GAIX;;QACC,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACpD,MAAM,WAAW,GAAG,MAAA,GAAG,CAAC,IAAI,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,iBAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC;QACtE,OAAO;YACL,GAAG,GAAG;YACN,wBAAwB,EAAE,UAAU;YACpC,qBAAqB,EAAE,OAAO;YAC9B,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF;AAtWD,8BAsWC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput.js';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryEnvsDirectoryAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport {\n getSelectedStatusCheckFromIfStatementTemplate,\n interpolateWithInputs,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n SKIPPED = 'skipped',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport type BuildStepFunction = (\n ctx: BuildStepContext,\n {\n inputs,\n outputs,\n env,\n }: { inputs: BuildStepInputById; outputs: BuildStepOutputById; env: BuildStepEnv }\n) => unknown;\n\n// TODO: move to a place common with tests\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/;\n\nexport interface SerializedBuildStepOutputAccessor {\n id: string;\n executed: boolean;\n outputById: Record<string, SerializedBuildStepOutput>;\n displayName: string;\n}\n\nexport class BuildStepOutputAccessor {\n constructor(\n public readonly id: string,\n public readonly displayName: string,\n protected readonly executed: boolean,\n protected readonly outputById: BuildStepOutputById\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.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public serialize(): SerializedBuildStepOutputAccessor {\n return {\n id: this.id,\n executed: this.executed,\n outputById: Object.fromEntries(\n Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])\n ),\n displayName: this.displayName,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepOutputAccessor\n ): BuildStepOutputAccessor {\n const outputById = Object.fromEntries(\n Object.entries(serialized.outputById).map(([key, value]) => [\n key,\n BuildStepOutput.deserialize(value),\n ])\n );\n return new BuildStepOutputAccessor(\n serialized.id,\n serialized.displayName,\n serialized.executed,\n outputById\n );\n }\n}\n\nexport class BuildStep extends BuildStepOutputAccessor {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell: string;\n public readonly ctx: BuildStepContext;\n public readonly env: BuildStepEnv;\n public readonly ifCondition?: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected readonly outputById: BuildStepOutputById;\n protected executed = false;\n\n public static getNewId(userDefinedId?: string): string {\n return userDefinedId ?? uuidv4();\n }\n\n public static getDisplayName({\n id,\n name,\n command,\n }: {\n id: string;\n name?: string;\n command?: string;\n }): string {\n if (name) {\n return name;\n }\n if (!id.match(UUID_REGEX)) {\n return id;\n }\n if (command) {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return id;\n }\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n displayName,\n inputs,\n outputs,\n command,\n fn,\n workingDirectory: maybeWorkingDirectory,\n shell,\n supportedRuntimePlatforms: maybeSupportedRuntimePlatforms,\n env,\n ifCondition,\n }: {\n id: string;\n name?: string;\n displayName: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command?: string;\n fn?: BuildStepFunction;\n workingDirectory?: string;\n shell?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n env?: BuildStepEnv;\n ifCondition?: string;\n }\n ) {\n assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n const outputById = makeBuildStepOutputByIdMap(outputs);\n super(id, displayName, false, outputById);\n\n this.id = id;\n this.name = name;\n this.displayName = displayName;\n this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;\n this.inputs = inputs;\n this.outputs = outputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? getDefaultShell();\n this.ifCondition = ifCondition;\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n\n const logger = ctx.baseLogger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });\n this.env = env ?? {};\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.displayName}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n if (this.command !== undefined) {\n await this.executeCommandAsync();\n } else {\n await this.exectuteFnAsync();\n }\n\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.displayName}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.ctx.logger.error({ err });\n this.ctx.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.displayName}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\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.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean {\n const defaultStatusCheck = 'success';\n const statusCheck = this.ifCondition\n ? getSelectedStatusCheckFromIfStatementTemplate(this.ifCondition)\n : defaultStatusCheck;\n\n switch (statusCheck) {\n case 'success':\n return !hasAnyPreviousStepsFailed;\n case 'failure':\n return hasAnyPreviousStepsFailed;\n case 'always':\n return true;\n case 'never':\n return false;\n }\n }\n\n public skip(): void {\n this.status = BuildStepStatus.SKIPPED;\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n 'Executing build step \"${this.displayName}\"'\n );\n this.ctx.logger.info(`Skipped build step \"${this.displayName}\"`);\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED },\n `Skipped build step \"${this.displayName}\"`\n );\n }\n\n private async executeCommandAsync(): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n try {\n const command = this.interpolateInputsAndGlobalContextInCommand(this.command, this.inputs);\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);\n this.ctx.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.ctx.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n // stdin is /dev/null, std{out,err} are piped into logger.\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private async exectuteFnAsync(): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n try {\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n await this.fn(this.ctx, {\n inputs: this.inputById,\n outputs: this.outputById,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private interpolateInputsAndGlobalContextInCommand(\n command: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return this.ctx.global.interpolate(command);\n }\n const vars = inputs.reduce(\n (acc, input) => {\n acc[input.id] =\n typeof input.value === 'object'\n ? JSON.stringify(input.value)\n : input.value?.toString() ?? '';\n return acc;\n },\n {} as Record<string, string>\n );\n const valueInterpolatedWithGlobalContext = this.ctx.global.interpolate(command);\n return interpolateWithInputs(valueInterpolatedWithGlobalContext, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.ctx.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.ctx.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.ctx.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(`Some required outputs have not been set: ${idsString}`, {\n metadata: { ids: nonSetRequiredOutputIds },\n });\n }\n }\n\n private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> {\n const filenames = await fs.readdir(envsDir);\n\n const entries = await Promise.all(\n filenames.map(async (basename) => {\n const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');\n return [basename, rawContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private getScriptEnv({\n envsDir,\n outputsDir,\n }: {\n envsDir: string;\n outputsDir: string;\n }): Record<string, string> {\n const env = { ...this.ctx.global.env, ...this.env };\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_ENVS_DIR: envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BuildStaticContext } from '@expo/eas-build-job';
|
|
1
2
|
import { bunyan } from '@expo/logger';
|
|
2
3
|
import { BuildStep, SerializedBuildStepOutputAccessor } from './BuildStep.js';
|
|
3
4
|
import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
@@ -8,7 +9,7 @@ interface SerializedExternalBuildContextProvider {
|
|
|
8
9
|
defaultWorkingDirectory: string;
|
|
9
10
|
buildLogsDirectory: string;
|
|
10
11
|
runtimePlatform: BuildRuntimePlatform;
|
|
11
|
-
staticContext:
|
|
12
|
+
staticContext: BuildStaticContext;
|
|
12
13
|
env: BuildStepEnv;
|
|
13
14
|
}
|
|
14
15
|
export interface ExternalBuildContextProvider {
|
|
@@ -18,7 +19,7 @@ export interface ExternalBuildContextProvider {
|
|
|
18
19
|
readonly buildLogsDirectory: string;
|
|
19
20
|
readonly runtimePlatform: BuildRuntimePlatform;
|
|
20
21
|
readonly logger: bunyan;
|
|
21
|
-
readonly staticContext: () =>
|
|
22
|
+
readonly staticContext: () => BuildStaticContext;
|
|
22
23
|
readonly env: BuildStepEnv;
|
|
23
24
|
updateEnv(env: BuildStepEnv): void;
|
|
24
25
|
}
|
|
@@ -42,7 +43,7 @@ export declare class BuildStepGlobalContext {
|
|
|
42
43
|
get defaultWorkingDirectory(): string;
|
|
43
44
|
get buildLogsDirectory(): string;
|
|
44
45
|
get env(): BuildStepEnv;
|
|
45
|
-
get staticContext():
|
|
46
|
+
get staticContext(): BuildStaticContext;
|
|
46
47
|
updateEnv(updatedEnv: BuildStepEnv): void;
|
|
47
48
|
registerStep(step: BuildStep): void;
|
|
48
49
|
getStepOutputValue(path: string): string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAGxB,+BAAoC;AAEpC,iDAIwB;AACxB,qDAI6B;AAC7B,2CAAoD;AAmCpD,MAAa,sBAAsB;IAQjC,YACmB,QAAsC,EACvC,WAAoB;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QACvC,gBAAW,GAAX,WAAW,CAAS;QAN9B,gBAAW,GAAG,KAAK,CAAC;QAEpB,aAAQ,GAA4C,EAAE,CAAC;QAM7D,IAAI,CAAC,2BAA2B,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAA,SAAM,GAAE,CAAC,CAAC;QACjF,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;IACpC,CAAC;IAED,IAAW,sBAAsB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAC9C,CAAC;IAED,IAAW,sBAAsB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAC9C,CAAC;IAED,IAAW,uBAAuB;QAChC,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAChG,CAAC;IAED,IAAW,kBAAkB;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAA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,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;YACvD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;SAC7B,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,WAAW,CACvB,UAAsC,EACtC,MAAc;QAEd,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzF,OAAO,IAAI,gBAAgB,CAAC,kBAAkB,EAAE;YAC9C,MAAM;YACN,wBAAwB,EAAE,UAAU,CAAC,wBAAwB;SAC9D,CAAC,CAAC;IACL,CAAC;CACF;AA7CD,4CA6CC","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n BuildStep,\n BuildStepOutputAccessor,\n SerializedBuildStepOutputAccessor,\n} from './BuildStep.js';\nimport {\n getObjectValueForInterpolation,\n interpolateWithGlobalContext,\n parseOutputPath,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\n\ninterface SerializedExternalBuildContextProvider {\n projectSourceDirectory: string;\n projectTargetDirectory: string;\n defaultWorkingDirectory: string;\n buildLogsDirectory: string;\n runtimePlatform: BuildRuntimePlatform;\n staticContext: Record<string, any>;\n env: BuildStepEnv;\n}\n\nexport interface ExternalBuildContextProvider {\n readonly projectSourceDirectory: string;\n readonly projectTargetDirectory: string;\n readonly defaultWorkingDirectory: string;\n readonly buildLogsDirectory: string;\n readonly runtimePlatform: BuildRuntimePlatform;\n readonly logger: bunyan;\n\n readonly staticContext: () => Record<string, any>;\n\n readonly env: BuildStepEnv;\n updateEnv(env: BuildStepEnv): void;\n}\n\nexport interface SerializedBuildStepGlobalContext {\n stepsInternalBuildDirectory: string;\n stepById: Record<string, SerializedBuildStepOutputAccessor>;\n provider: SerializedExternalBuildContextProvider;\n skipCleanup: boolean;\n}\n\nexport class BuildStepGlobalContext {\n public stepsInternalBuildDirectory: string;\n public readonly runtimePlatform: BuildRuntimePlatform;\n public readonly baseLogger: bunyan;\n private didCheckOut = false;\n\n private stepById: Record<string, BuildStepOutputAccessor> = {};\n\n constructor(\n private readonly provider: ExternalBuildContextProvider,\n public readonly skipCleanup: boolean\n ) {\n this.stepsInternalBuildDirectory = path.join(os.tmpdir(), 'eas-build', uuidv4());\n this.runtimePlatform = provider.runtimePlatform;\n this.baseLogger = provider.logger;\n }\n\n public get projectSourceDirectory(): string {\n return this.provider.projectSourceDirectory;\n }\n\n public get projectTargetDirectory(): string {\n return this.provider.projectTargetDirectory;\n }\n\n public get defaultWorkingDirectory(): string {\n return this.didCheckOut ? this.provider.defaultWorkingDirectory : this.projectTargetDirectory;\n }\n\n public get buildLogsDirectory(): string {\n return this.provider.buildLogsDirectory;\n }\n\n public get env(): BuildStepEnv {\n return this.provider.env;\n }\n\n public get staticContext(): Record<string, any> {\n return this.provider.staticContext();\n }\n\n public updateEnv(updatedEnv: BuildStepEnv): void {\n this.provider.updateEnv(updatedEnv);\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 public interpolate(value: string): string {\n return interpolateWithGlobalContext(value, (path) => {\n return (\n getObjectValueForInterpolation(path, {\n eas: {\n runtimePlatform: this.runtimePlatform,\n ...this.staticContext,\n },\n })?.toString() ?? ''\n );\n });\n }\n\n public stepCtx(options: { logger: bunyan; relativeWorkingDirectory?: string }): BuildStepContext {\n return new BuildStepContext(this, options);\n }\n\n public markAsCheckedOut(logger: bunyan): void {\n this.didCheckOut = true;\n logger.info(\n `Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`\n );\n }\n\n public serialize(): SerializedBuildStepGlobalContext {\n return {\n stepsInternalBuildDirectory: this.stepsInternalBuildDirectory,\n stepById: Object.fromEntries(\n Object.entries(this.stepById).map(([id, step]) => [id, step.serialize()])\n ),\n provider: {\n projectSourceDirectory: this.provider.projectSourceDirectory,\n projectTargetDirectory: this.provider.projectTargetDirectory,\n defaultWorkingDirectory: this.provider.defaultWorkingDirectory,\n buildLogsDirectory: this.provider.buildLogsDirectory,\n runtimePlatform: this.provider.runtimePlatform,\n staticContext: this.provider.staticContext(),\n env: this.provider.env,\n },\n skipCleanup: this.skipCleanup,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepGlobalContext,\n logger: bunyan\n ): BuildStepGlobalContext {\n const deserializedProvider: ExternalBuildContextProvider = {\n projectSourceDirectory: serialized.provider.projectSourceDirectory,\n projectTargetDirectory: serialized.provider.projectTargetDirectory,\n defaultWorkingDirectory: serialized.provider.defaultWorkingDirectory,\n buildLogsDirectory: serialized.provider.buildLogsDirectory,\n runtimePlatform: serialized.provider.runtimePlatform,\n logger,\n staticContext: () => serialized.provider.staticContext,\n env: serialized.provider.env,\n updateEnv: () => {},\n };\n const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);\n for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {\n ctx.stepById[id] = BuildStepOutputAccessor.deserialize(stepOutputAccessor);\n }\n ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;\n\n return ctx;\n }\n}\n\nexport interface SerializedBuildStepContext {\n relativeWorkingDirectory?: string;\n global: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepContext {\n public readonly logger: bunyan;\n public readonly relativeWorkingDirectory?: string;\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n logger,\n relativeWorkingDirectory,\n }: {\n logger: bunyan;\n relativeWorkingDirectory?: string;\n }\n ) {\n this.logger = logger ?? ctx.baseLogger;\n this.relativeWorkingDirectory = relativeWorkingDirectory;\n }\n\n public get global(): BuildStepGlobalContext {\n return this.ctx;\n }\n\n public get workingDirectory(): string {\n return this.relativeWorkingDirectory\n ? path.resolve(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory)\n : this.ctx.defaultWorkingDirectory;\n }\n\n public serialize(): SerializedBuildStepContext {\n return {\n relativeWorkingDirectory: this.relativeWorkingDirectory,\n global: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepContext,\n logger: bunyan\n ): BuildStepContext {\n const deserializedGlobal = BuildStepGlobalContext.deserialize(serialized.global, logger);\n return new BuildStepContext(deserializedGlobal, {\n logger,\n relativeWorkingDirectory: serialized.relativeWorkingDirectory,\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AAIxB,+BAAoC;AAEpC,iDAIwB;AACxB,qDAI6B;AAC7B,2CAAoD;AAmCpD,MAAa,sBAAsB;IAQjC,YACmB,QAAsC,EACvC,WAAoB;QADnB,aAAQ,GAAR,QAAQ,CAA8B;QACvC,gBAAW,GAAX,WAAW,CAAS;QAN9B,gBAAW,GAAG,KAAK,CAAC;QAEpB,aAAQ,GAA4C,EAAE,CAAC;QAM7D,IAAI,CAAC,2BAA2B,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAA,SAAM,GAAE,CAAC,CAAC;QACjF,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC;IACpC,CAAC;IAED,IAAW,sBAAsB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IAC9C,CAAC;IAED,IAAW,sBAAsB;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,sBAAsB,CAA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AAO,IAAI,CAAC,wBAAwB;YAClC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,EAAE,IAAI,CAAC,wBAAwB,CAAC;YAC/E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC;IACvC,CAAC;IAEM,SAAS;QACd,OAAO;YACL,wBAAwB,EAAE,IAAI,CAAC,wBAAwB;YACvD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;SAC7B,CAAC;IACJ,CAAC;IAEM,MAAM,CAAC,WAAW,CACvB,UAAsC,EACtC,MAAc;QAEd,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,WAAW,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzF,OAAO,IAAI,gBAAgB,CAAC,kBAAkB,EAAE;YAC9C,MAAM;YACN,wBAAwB,EAAE,UAAU,CAAC,wBAAwB;SAC9D,CAAC,CAAC;IACL,CAAC;CACF;AA7CD,4CA6CC","sourcesContent":["import os from 'os';\nimport path from 'path';\n\nimport { BuildStaticContext } from '@expo/eas-build-job';\nimport { bunyan } from '@expo/logger';\nimport { v4 as uuidv4 } from 'uuid';\n\nimport {\n BuildStep,\n BuildStepOutputAccessor,\n SerializedBuildStepOutputAccessor,\n} from './BuildStep.js';\nimport {\n getObjectValueForInterpolation,\n interpolateWithGlobalContext,\n parseOutputPath,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\n\ninterface SerializedExternalBuildContextProvider {\n projectSourceDirectory: string;\n projectTargetDirectory: string;\n defaultWorkingDirectory: string;\n buildLogsDirectory: string;\n runtimePlatform: BuildRuntimePlatform;\n staticContext: BuildStaticContext;\n env: BuildStepEnv;\n}\n\nexport interface ExternalBuildContextProvider {\n readonly projectSourceDirectory: string;\n readonly projectTargetDirectory: string;\n readonly defaultWorkingDirectory: string;\n readonly buildLogsDirectory: string;\n readonly runtimePlatform: BuildRuntimePlatform;\n readonly logger: bunyan;\n\n readonly staticContext: () => BuildStaticContext;\n\n readonly env: BuildStepEnv;\n updateEnv(env: BuildStepEnv): void;\n}\n\nexport interface SerializedBuildStepGlobalContext {\n stepsInternalBuildDirectory: string;\n stepById: Record<string, SerializedBuildStepOutputAccessor>;\n provider: SerializedExternalBuildContextProvider;\n skipCleanup: boolean;\n}\n\nexport class BuildStepGlobalContext {\n public stepsInternalBuildDirectory: string;\n public readonly runtimePlatform: BuildRuntimePlatform;\n public readonly baseLogger: bunyan;\n private didCheckOut = false;\n\n private stepById: Record<string, BuildStepOutputAccessor> = {};\n\n constructor(\n private readonly provider: ExternalBuildContextProvider,\n public readonly skipCleanup: boolean\n ) {\n this.stepsInternalBuildDirectory = path.join(os.tmpdir(), 'eas-build', uuidv4());\n this.runtimePlatform = provider.runtimePlatform;\n this.baseLogger = provider.logger;\n }\n\n public get projectSourceDirectory(): string {\n return this.provider.projectSourceDirectory;\n }\n\n public get projectTargetDirectory(): string {\n return this.provider.projectTargetDirectory;\n }\n\n public get defaultWorkingDirectory(): string {\n return this.didCheckOut ? this.provider.defaultWorkingDirectory : this.projectTargetDirectory;\n }\n\n public get buildLogsDirectory(): string {\n return this.provider.buildLogsDirectory;\n }\n\n public get env(): BuildStepEnv {\n return this.provider.env;\n }\n\n public get staticContext(): BuildStaticContext {\n return this.provider.staticContext();\n }\n\n public updateEnv(updatedEnv: BuildStepEnv): void {\n this.provider.updateEnv(updatedEnv);\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 public interpolate(value: string): string {\n return interpolateWithGlobalContext(value, (path) => {\n return (\n getObjectValueForInterpolation(path, {\n eas: {\n runtimePlatform: this.runtimePlatform,\n ...this.staticContext,\n },\n })?.toString() ?? ''\n );\n });\n }\n\n public stepCtx(options: { logger: bunyan; relativeWorkingDirectory?: string }): BuildStepContext {\n return new BuildStepContext(this, options);\n }\n\n public markAsCheckedOut(logger: bunyan): void {\n this.didCheckOut = true;\n logger.info(\n `Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`\n );\n }\n\n public serialize(): SerializedBuildStepGlobalContext {\n return {\n stepsInternalBuildDirectory: this.stepsInternalBuildDirectory,\n stepById: Object.fromEntries(\n Object.entries(this.stepById).map(([id, step]) => [id, step.serialize()])\n ),\n provider: {\n projectSourceDirectory: this.provider.projectSourceDirectory,\n projectTargetDirectory: this.provider.projectTargetDirectory,\n defaultWorkingDirectory: this.provider.defaultWorkingDirectory,\n buildLogsDirectory: this.provider.buildLogsDirectory,\n runtimePlatform: this.provider.runtimePlatform,\n staticContext: this.provider.staticContext(),\n env: this.provider.env,\n },\n skipCleanup: this.skipCleanup,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepGlobalContext,\n logger: bunyan\n ): BuildStepGlobalContext {\n const deserializedProvider: ExternalBuildContextProvider = {\n projectSourceDirectory: serialized.provider.projectSourceDirectory,\n projectTargetDirectory: serialized.provider.projectTargetDirectory,\n defaultWorkingDirectory: serialized.provider.defaultWorkingDirectory,\n buildLogsDirectory: serialized.provider.buildLogsDirectory,\n runtimePlatform: serialized.provider.runtimePlatform,\n logger,\n staticContext: () => serialized.provider.staticContext,\n env: serialized.provider.env,\n updateEnv: () => {},\n };\n const ctx = new BuildStepGlobalContext(deserializedProvider, serialized.skipCleanup);\n for (const [id, stepOutputAccessor] of Object.entries(serialized.stepById)) {\n ctx.stepById[id] = BuildStepOutputAccessor.deserialize(stepOutputAccessor);\n }\n ctx.stepsInternalBuildDirectory = serialized.stepsInternalBuildDirectory;\n\n return ctx;\n }\n}\n\nexport interface SerializedBuildStepContext {\n relativeWorkingDirectory?: string;\n global: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepContext {\n public readonly logger: bunyan;\n public readonly relativeWorkingDirectory?: string;\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n logger,\n relativeWorkingDirectory,\n }: {\n logger: bunyan;\n relativeWorkingDirectory?: string;\n }\n ) {\n this.logger = logger ?? ctx.baseLogger;\n this.relativeWorkingDirectory = relativeWorkingDirectory;\n }\n\n public get global(): BuildStepGlobalContext {\n return this.ctx;\n }\n\n public get workingDirectory(): string {\n return this.relativeWorkingDirectory\n ? path.resolve(this.ctx.defaultWorkingDirectory, this.relativeWorkingDirectory)\n : this.ctx.defaultWorkingDirectory;\n }\n\n public serialize(): SerializedBuildStepContext {\n return {\n relativeWorkingDirectory: this.relativeWorkingDirectory,\n global: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepContext,\n logger: bunyan\n ): BuildStepContext {\n const deserializedGlobal = BuildStepGlobalContext.deserialize(serialized.global, logger);\n return new BuildStepContext(deserializedGlobal, {\n logger,\n relativeWorkingDirectory: serialized.relativeWorkingDirectory,\n });\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BuildStaticContext } from '@expo/eas-build-job';
|
|
1
2
|
import { bunyan } from '@expo/logger';
|
|
2
3
|
import { ExternalBuildContextProvider } from '../BuildStepContext.js';
|
|
3
4
|
import { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';
|
|
@@ -12,6 +13,6 @@ export declare class CliContextProvider implements ExternalBuildContextProvider
|
|
|
12
13
|
private _env;
|
|
13
14
|
constructor(logger: bunyan, runtimePlatform: BuildRuntimePlatform, projectSourceDirectory: string, projectTargetDirectory: string, defaultWorkingDirectory: string, buildLogsDirectory: string);
|
|
14
15
|
get env(): BuildStepEnv;
|
|
15
|
-
staticContext():
|
|
16
|
+
staticContext(): BuildStaticContext;
|
|
16
17
|
updateEnv(env: BuildStepEnv): void;
|
|
17
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;;;AAAA,gDAAwB;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;;;;;;AAAA,gDAAwB;AAGxB,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,EAC/B,kBAA0B;QAL1B,WAAM,GAAN,MAAM,CAAQ;QACd,oBAAe,GAAf,eAAe,CAAsB;QACrC,2BAAsB,GAAtB,sBAAsB,CAAQ;QAC9B,2BAAsB,GAAtB,sBAAsB,CAAQ;QAC9B,4BAAuB,GAAvB,uBAAuB,CAAQ;QAC/B,uBAAkB,GAAlB,kBAAkB,CAAQ;QARpC,SAAI,GAAiB,EAAE,CAAC;IAS7B,CAAC;IACJ,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IACM,aAAa;QAClB,OAAO;YACL,GAAG,EAAE,EAAS;YACd,QAAQ,EAAE,EAAc;YACxB,GAAG,EAAE,IAAI,CAAC,GAAU;SACrB,CAAC;IACJ,CAAC;IACM,SAAS,CAAC,GAAiB;QAChC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;CACF;AAxBD,gDAwBC;AAED,KAAK,UAAU,QAAQ,CACrB,UAAkB,EAClB,wBAAgC,EAChC,eAAqC;IAErC,MAAM,GAAG,GAAG,IAAI,4CAAsB,CACpC,IAAI,kBAAkB,CACpB,MAAM,EACN,eAAe,EACf,wBAAwB,EACxB,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AAC,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { BuildStaticContext, Env, Job, Metadata } from '@expo/eas-build-job';\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 public readonly buildLogsDirectory: string\n ) {}\n public get env(): BuildStepEnv {\n return this._env;\n }\n public staticContext(): BuildStaticContext {\n return {\n job: {} as Job,\n metadata: {} as Metadata,\n env: this.env as Env,\n };\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 relativeProjectDirectory\n ),\n false\n );\n const parser = new BuildConfigParser(ctx, {\n configPath,\n });\n const workflow = await parser.parseAsync();\n await workflow.executeAsync();\n}\n\nconst relativeConfigPath = process.argv[2];\nconst relativeProjectDirectoryPath = process.argv[3];\nconst platform: BuildRuntimePlatform = (process.argv[4] ??\n process.platform) as BuildRuntimePlatform;\n\nif (!relativeConfigPath || !relativeProjectDirectoryPath) {\n console.error('Usage: yarn cli config.yml path/to/project/directory [darwin|linux]');\n process.exit(1);\n}\n\nconst configPath = path.resolve(process.cwd(), relativeConfigPath);\nconst workingDirectory = path.resolve(process.cwd(), relativeProjectDirectoryPath);\n\nrunAsync(configPath, workingDirectory, platform).catch((err) => {\n logger.error({ err }, 'Build failed');\n if (err instanceof BuildWorkflowError) {\n logger.error('Failed to parse the custom build config file.');\n for (const detailedErr of err.errors) {\n logger.error({ err: detailedErr });\n }\n }\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCustomFunction.js","sourceRoot":"","sources":["../../src/scripts/runCustomFunction.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,yCAA4C;AAE5C,wEAAyC;AAEzC,8DAAwD;AACxD,4DAAsD;AAEtD,gEAA0D;AAE1D,sDAAqD;AAErD,KAAK,UAAU,wBAAwB;IACrC,MAAM,kCAAkC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3D,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAErC,IAAA,gBAAM,EAAC,kCAAkC,EAAE,gDAAgD,CAAC,CAAC;IAC7F,IAAA,gBAAM,EAAC,YAAY,EAAE,sCAAsC,CAAC,CAAC;IAE7D,IAAI,2BAAmE,CAAC;IACxE,IAAI,CAAC;QACH,2BAA2B,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACzD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC1D,MAAM,CAAC,CAAC;IACV,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC;QAC1B,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,KAAK;gBACX,MAAM,EAAE;oBACN,KAAK,EAAE,CAAC,GAAQ,EAAE,EAAE;wBAClB,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vC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,QAAQ,KAAK,SAAS,CAAC,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;YAChD,QAAQ,CAAC,IAAI,CACX,IAAA,qBAAU,EAAC,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;gBACzC,GAAG;gBACH,KAAK,EAAE,MAAM;aACd,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,KAAK,wBAAwB,EAAE,CAAC","sourcesContent":["import assert from 'assert';\n\nimport { createLogger } from '@expo/logger';\nimport { SpawnPromise, SpawnResult } from '@expo/spawn-async';\nimport cloneDeep from 'lodash.clonedeep';\n\nimport { BuildStepOutput } from '../BuildStepOutput.js';\nimport { BuildStepInput } from '../BuildStepInput.js';\nimport { SerializedCustomBuildFunctionArguments } from '../utils/customFunction.js';\nimport { BuildStepContext } from '../BuildStepContext.js';\nimport { BuildStepFunction } from '../BuildStep.js';\nimport { spawnAsync } from '../utils/shell/spawn.js';\n\nasync function runCustomJsFunctionAsync(): Promise<void> {\n const customJavascriptFunctionModulePath = process.argv[2];\n const functionArgs = process.argv[3];\n\n assert(customJavascriptFunctionModulePath, 'customJavascriptFunctionModulePath is required');\n assert(functionArgs, 'serializedFunctionParams is required');\n\n let serializedFunctionArguments: SerializedCustomBuildFunctionArguments;\n try {\n serializedFunctionArguments = JSON.parse(functionArgs);\n } catch (e) {\n console.error('Failed to parse serializedFunctionParams');\n throw e;\n }\n\n const logger = createLogger({\n name: 'customFunctionLogger',\n streams: [\n {\n type: 'raw',\n stream: {\n write: (rec: any) => {\n if (rec) {\n switch (rec.level) {\n case 20: // Debug level\n if (rec.msg) {\n console.debug(rec.msg);\n }\n break;\n case 30: // Info level\n if (rec.msg) {\n console.log(rec.msg);\n }\n break;\n case 40: // Warn level\n if (rec.msg) {\n console.warn(rec.msg);\n }\n break;\n case 50: // Error level\n case 60: // Fatal level\n if (rec.msg) {\n console.error(rec.msg);\n }\n break;\n default:\n break;\n }\n }\n },\n },\n },\n ],\n });\n\n const ctx = BuildStepContext.deserialize(serializedFunctionArguments.ctx, logger);\n const inputs = Object.fromEntries(\n Object.entries(serializedFunctionArguments.inputs).map(([id, input]) => [\n id,\n BuildStepInput.deserialize(input, logger),\n ])\n );\n const outputs = Object.fromEntries(\n Object.entries(serializedFunctionArguments.outputs).map(([id, output]) => [\n id,\n BuildStepOutput.deserialize(output),\n ])\n );\n const env = serializedFunctionArguments.env;\n const envBefore = cloneDeep(serializedFunctionArguments.env);\n\n let customModule: { default: BuildStepFunction };\n try {\n customModule = await require(customJavascriptFunctionModulePath);\n } catch (e) {\n console.error('Failed to load custom function module');\n throw e;\n }\n\n const customJavascriptFunction = customModule.default;\n\n await customJavascriptFunction(ctx, { inputs, outputs, env });\n\n const promises: SpawnPromise<SpawnResult>[] = [];\n for (const output of Object.values(outputs)) {\n if (output.rawValue) {\n assert(output.value, 'output.value is required');\n promises.push(\n spawnAsync('set-output', [output.id, output.value], {\n env,\n stdio: 'pipe',\n })\n );\n }\n }\n for (const envName of Object.keys(env)) {\n const envValue = env[envName];\n if (envValue !== envBefore[envName] && envValue) {\n promises.push(\n spawnAsync('set-env', [envName, envValue], {\n env,\n stdio: 'pipe',\n })\n );\n }\n }\n await Promise.all(promises);\n}\n\nvoid runCustomJsFunctionAsync();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function duplicates<T
|
|
1
|
+
export declare function duplicates<T>(items: T[]): T[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duplicates.js","sourceRoot":"","sources":["../../../src/utils/expodash/duplicates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"duplicates.js","sourceRoot":"","sources":["../../../src/utils/expodash/duplicates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAI,KAAU;IACtC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAK,CAAC;IACrC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAK,CAAC;IACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,kBAAkB,CAAC,CAAC;AACjC,CAAC;AAXD,gCAWC","sourcesContent":["export function duplicates<T>(items: T[]): T[] {\n const visitedItemsSet = new Set<T>();\n const duplicatedItemsSet = new Set<T>();\n for (const item of items) {\n if (visitedItemsSet.has(item)) {\n duplicatedItemsSet.add(item);\n } else {\n visitedItemsSet.add(item);\n }\n }\n return [...duplicatedItemsSet];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function uniq<T
|
|
1
|
+
export declare function uniq<T>(items: T[]): T[];
|