@expo/steps 1.0.136 → 1.0.138
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/LICENSE +1 -1
- package/dist_commonjs/BuildStep.cjs +85 -75
- package/dist_commonjs/BuildStep.d.ts +7 -7
- package/dist_commonjs/BuildStep.js.map +1 -1
- package/dist_commonjs/BuildStepContext.cjs +19 -1
- package/dist_commonjs/BuildStepContext.d.ts +7 -4
- package/dist_commonjs/BuildStepContext.js.map +1 -1
- package/dist_commonjs/BuildTemporaryFiles.cjs +3 -13
- package/dist_commonjs/BuildTemporaryFiles.d.ts +2 -2
- package/dist_commonjs/BuildTemporaryFiles.js.map +1 -1
- package/dist_commonjs/BuildWorkflow.cjs +4 -7
- package/dist_commonjs/BuildWorkflow.js.map +1 -1
- package/dist_commonjs/cli/cli.d.ts +2 -2
- package/dist_commonjs/cli/cli.js.map +1 -1
- package/dist_commonjs/index.cjs +2 -0
- package/dist_commonjs/index.d.ts +2 -0
- package/dist_commonjs/index.js.map +1 -1
- package/dist_commonjs/interpolation.cjs +30 -0
- package/dist_commonjs/interpolation.d.ts +5 -0
- package/dist_commonjs/interpolation.js.map +1 -0
- package/dist_esm/BuildStep.d.ts +7 -7
- package/dist_esm/BuildStep.js +86 -76
- package/dist_esm/BuildStep.js.map +1 -1
- package/dist_esm/BuildStepContext.d.ts +7 -4
- package/dist_esm/BuildStepContext.js +19 -1
- package/dist_esm/BuildStepContext.js.map +1 -1
- package/dist_esm/BuildTemporaryFiles.d.ts +2 -2
- package/dist_esm/BuildTemporaryFiles.js +2 -12
- package/dist_esm/BuildTemporaryFiles.js.map +1 -1
- package/dist_esm/BuildWorkflow.js +4 -7
- package/dist_esm/BuildWorkflow.js.map +1 -1
- package/dist_esm/cli/cli.d.ts +2 -2
- package/dist_esm/cli/cli.js.map +1 -1
- package/dist_esm/index.d.ts +2 -0
- package/dist_esm/index.js +2 -0
- package/dist_esm/index.js.map +1 -1
- package/dist_esm/interpolation.d.ts +5 -0
- package/dist_esm/interpolation.js +26 -0
- package/dist_esm/interpolation.js.map +1 -0
- package/package.json +3 -3
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getTemporaryEnvsDirPath = exports.getTemporaryOutputsDirPath = exports.cleanUpStepTemporaryDirectoriesAsync = exports.saveScriptToTemporaryFileAsync = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
@@ -15,18 +15,6 @@ async function saveScriptToTemporaryFileAsync(ctx, stepId, scriptContents) {
|
|
|
15
15
|
return temporaryScriptPath;
|
|
16
16
|
}
|
|
17
17
|
exports.saveScriptToTemporaryFileAsync = saveScriptToTemporaryFileAsync;
|
|
18
|
-
async function createTemporaryOutputsDirectoryAsync(ctx, stepId) {
|
|
19
|
-
const directory = getTemporaryOutputsDirPath(ctx, stepId);
|
|
20
|
-
await promises_1.default.mkdir(directory, { recursive: true });
|
|
21
|
-
return directory;
|
|
22
|
-
}
|
|
23
|
-
exports.createTemporaryOutputsDirectoryAsync = createTemporaryOutputsDirectoryAsync;
|
|
24
|
-
async function createTemporaryEnvsDirectoryAsync(ctx, stepId) {
|
|
25
|
-
const directory = getTemporaryEnvsDirPath(ctx, stepId);
|
|
26
|
-
await promises_1.default.mkdir(directory, { recursive: true });
|
|
27
|
-
return directory;
|
|
28
|
-
}
|
|
29
|
-
exports.createTemporaryEnvsDirectoryAsync = createTemporaryEnvsDirectoryAsync;
|
|
30
18
|
async function cleanUpStepTemporaryDirectoriesAsync(ctx, stepId) {
|
|
31
19
|
if (ctx.skipCleanup) {
|
|
32
20
|
return;
|
|
@@ -45,7 +33,9 @@ function getTemporaryScriptsDirPath(ctx, stepId) {
|
|
|
45
33
|
function getTemporaryOutputsDirPath(ctx, stepId) {
|
|
46
34
|
return path_1.default.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');
|
|
47
35
|
}
|
|
36
|
+
exports.getTemporaryOutputsDirPath = getTemporaryOutputsDirPath;
|
|
48
37
|
function getTemporaryEnvsDirPath(ctx, stepId) {
|
|
49
38
|
return path_1.default.join(getTemporaryStepDirPath(ctx, stepId), 'envs');
|
|
50
39
|
}
|
|
40
|
+
exports.getTemporaryEnvsDirPath = getTemporaryEnvsDirPath;
|
|
51
41
|
//# sourceMappingURL=BuildTemporaryFiles.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
2
2
|
export declare function saveScriptToTemporaryFileAsync(ctx: BuildStepGlobalContext, stepId: string, scriptContents: string): Promise<string>;
|
|
3
|
-
export declare function createTemporaryOutputsDirectoryAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<string>;
|
|
4
|
-
export declare function createTemporaryEnvsDirectoryAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<string>;
|
|
5
3
|
export declare function cleanUpStepTemporaryDirectoriesAsync(ctx: BuildStepGlobalContext, stepId: string): Promise<void>;
|
|
4
|
+
export declare function getTemporaryOutputsDirPath(ctx: BuildStepGlobalContext, stepId: string): string;
|
|
5
|
+
export declare function getTemporaryEnvsDirPath(ctx: BuildStepGlobalContext, stepId: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildTemporaryFiles.js","sourceRoot":"","sources":["../src/BuildTemporaryFiles.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,2DAA6B;AAE7B,+BAAoC;AAI7B,KAAK,UAAU,8BAA8B,CAClD,GAA2B,EAC3B,MAAc,EACd,cAAsB;IAEtB,MAAM,UAAU,GAAG,0BAA0B,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,M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I,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,sBAAsB,EAAE,EAAE,kCAAkC,CAAC,CAAC;AACvF,CAAC;AAVD,oFAUC;AAED,SAAS,uBAAuB,CAAC,GAA2B,EAAE,MAAc;IAC1E,OAAO,cAAI,CAAC,IAAI,CAAC,GAAG,CAAC,2BAA2B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,0BAA0B,CAAC,GAA2B,EAAE,MAAc;IAC7E,OAAO,cAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAED,SAAgB,0BAA0B,CAAC,GAA2B,EAAE,MAAc;IACpF,OAAO,cAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC;AAFD,gEAEC;AAED,SAAgB,uBAAuB,CAAC,GAA2B,EAAE,MAAc;IACjF,OAAO,cAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AACjE,CAAC;AAFD,0DAEC","sourcesContent":["import path from 'path';\nimport fs from 'fs/promises';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\n\nexport async function saveScriptToTemporaryFileAsync(\n ctx: BuildStepGlobalContext,\n stepId: string,\n scriptContents: string\n): Promise<string> {\n const scriptsDir = getTemporaryScriptsDirPath(ctx, stepId);\n await fs.mkdir(scriptsDir, { recursive: true });\n const temporaryScriptPath = path.join(scriptsDir, `${uuidv4()}.sh`);\n await fs.writeFile(temporaryScriptPath, scriptContents);\n return temporaryScriptPath;\n}\n\nexport async function cleanUpStepTemporaryDirectoriesAsync(\n ctx: BuildStepGlobalContext,\n stepId: string\n): Promise<void> {\n if (ctx.skipCleanup) {\n return;\n }\n const stepTemporaryDirectory = getTemporaryStepDirPath(ctx, stepId);\n await fs.rm(stepTemporaryDirectory, { recursive: true, force: true });\n ctx.baseLogger.debug({ stepTemporaryDirectory }, 'Removed step temporary directory');\n}\n\nfunction getTemporaryStepDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(ctx.stepsInternalBuildDirectory, 'steps', stepId);\n}\n\nfunction getTemporaryScriptsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'scripts');\n}\n\nexport function getTemporaryOutputsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'outputs');\n}\n\nexport function getTemporaryEnvsDirPath(ctx: BuildStepGlobalContext, stepId: string): string {\n return path.join(getTemporaryStepDirPath(ctx, stepId), 'envs');\n}\n"]}
|
|
@@ -2,26 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BuildWorkflow = void 0;
|
|
4
4
|
class BuildWorkflow {
|
|
5
|
-
constructor(
|
|
6
|
-
// @ts-expect-error ctx is not used in this class but let's keep it here for consistency
|
|
7
|
-
ctx, { buildSteps, buildFunctions }) {
|
|
5
|
+
constructor(ctx, { buildSteps, buildFunctions }) {
|
|
8
6
|
this.ctx = ctx;
|
|
9
7
|
this.buildSteps = buildSteps;
|
|
10
8
|
this.buildFunctions = buildFunctions;
|
|
11
9
|
}
|
|
12
10
|
async executeAsync() {
|
|
13
11
|
let maybeError = null;
|
|
14
|
-
let hasAnyPreviousStepFailed = false;
|
|
15
12
|
for (const step of this.buildSteps) {
|
|
16
13
|
let shouldExecuteStep = false;
|
|
17
14
|
try {
|
|
18
|
-
shouldExecuteStep = step.shouldExecuteStep(
|
|
15
|
+
shouldExecuteStep = step.shouldExecuteStep();
|
|
19
16
|
}
|
|
20
17
|
catch (err) {
|
|
21
18
|
step.ctx.logger.error({ err });
|
|
22
19
|
step.ctx.logger.error(`Runner failed to evaluate if it should execute step "${step.displayName}", using step's if condition "${step.ifCondition}". This can be caused by trying to access non-existing object property. If you think this is a bug report it here: https://github.com/expo/eas-cli/issues.`);
|
|
23
20
|
maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err;
|
|
24
|
-
|
|
21
|
+
this.ctx.markAsFailed();
|
|
25
22
|
}
|
|
26
23
|
if (shouldExecuteStep) {
|
|
27
24
|
try {
|
|
@@ -29,7 +26,7 @@ class BuildWorkflow {
|
|
|
29
26
|
}
|
|
30
27
|
catch (err) {
|
|
31
28
|
maybeError = maybeError !== null && maybeError !== void 0 ? maybeError : err;
|
|
32
|
-
|
|
29
|
+
this.ctx.markAsFailed();
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":";;;AAIA,MAAa,aAAa;IAIxB
|
|
1
|
+
{"version":3,"file":"BuildWorkflow.js","sourceRoot":"","sources":["../src/BuildWorkflow.ts"],"names":[],"mappings":";;;AAIA,MAAa,aAAa;IAIxB,YACmB,GAA2B,EAC5C,EAAE,UAAU,EAAE,cAAc,EAAkE;QAD7E,QAAG,GAAH,GAAG,CAAwB;QAG5C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,IAAI,UAAU,GAAiB,IAAI,CAAC;QACpC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACnC,IAAI,iBAAiB,GAAG,KAAK,CAAC;YAC9B,IAAI,CAAC;gBACH,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC/C,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC/B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CACnB,wDAAwD,IAAI,CAAC,WAAW,iCAAiC,IAAI,CAAC,WAAW,4JAA4J,CACtR,CAAC;gBACF,UAAU,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,GAAG,CAAC;gBAC/B,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;YAC1B,CAAC;YACD,IAAI,iBAAiB,EAAE,CAAC;gBACtB,IAAI,CAAC;oBACH,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC5B,CAAC;gBAAC,OAAO,GAAQ,EAAE,CAAC;oBAClB,UAAU,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,GAAG,CAAC;oBAC/B,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;gBAC1B,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,UAAU,CAAC;QACnB,CAAC;IACH,CAAC;CACF;AA1CD,sCA0CC","sourcesContent":["import { BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepGlobalContext } from './BuildStepContext.js';\n\nexport class BuildWorkflow {\n public readonly buildSteps: BuildStep[];\n public readonly buildFunctions: BuildFunctionById;\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n { buildSteps, buildFunctions }: { buildSteps: BuildStep[]; buildFunctions: BuildFunctionById }\n ) {\n this.buildSteps = buildSteps;\n this.buildFunctions = buildFunctions;\n }\n\n public async executeAsync(): Promise<void> {\n let maybeError: Error | null = null;\n for (const step of this.buildSteps) {\n let shouldExecuteStep = false;\n try {\n shouldExecuteStep = step.shouldExecuteStep();\n } catch (err: any) {\n step.ctx.logger.error({ err });\n step.ctx.logger.error(\n `Runner failed to evaluate if it should execute step \"${step.displayName}\", using step's if condition \"${step.ifCondition}\". This can be caused by trying to access non-existing object property. If you think this is a bug report it here: https://github.com/expo/eas-cli/issues.`\n );\n maybeError = maybeError ?? err;\n this.ctx.markAsFailed();\n }\n if (shouldExecuteStep) {\n try {\n await step.executeAsync();\n } catch (err: any) {\n maybeError = maybeError ?? err;\n this.ctx.markAsFailed();\n }\n } else {\n step.skip();\n }\n }\n\n if (maybeError) {\n throw maybeError;\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StaticJobInterpolationContext } from '@expo/eas-build-job';
|
|
2
2
|
import { bunyan } from '@expo/logger';
|
|
3
3
|
import { ExternalBuildContextProvider } from '../BuildStepContext.js';
|
|
4
4
|
import { BuildRuntimePlatform } from '../BuildRuntimePlatform.js';
|
|
@@ -13,6 +13,6 @@ export declare class CliContextProvider implements ExternalBuildContextProvider
|
|
|
13
13
|
private _env;
|
|
14
14
|
constructor(logger: bunyan, runtimePlatform: BuildRuntimePlatform, projectSourceDirectory: string, projectTargetDirectory: string, defaultWorkingDirectory: string, buildLogsDirectory: string);
|
|
15
15
|
get env(): BuildStepEnv;
|
|
16
|
-
staticContext():
|
|
16
|
+
staticContext(): Omit<StaticJobInterpolationContext, 'steps'>;
|
|
17
17
|
updateEnv(env: BuildStepEnv): void;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
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,eAA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A,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,mCACrD,OAAO,CAAC,QAAQ,CAAyB,CAAC;AAE5C,IAAI,CAAC,kBAAkB,IAAI,CAAC,4BAA4B,EAAE,CAAC;IACzD,OAAO,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAC;IACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,kBAAkB,CAAC,CAAC;AACnE,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,4BAA4B,CAAC,CAAC;AAEnF,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7D,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACtC,IAAI,GAAG,YAAY,8BAAkB,EAAE,CAAC;QACtC,MAAM,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAC9D,KAAK,MAAM,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import path from 'path';\n\nimport { Env, Job, Metadata, StaticJobInterpolationContext } 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(): Omit<StaticJobInterpolationContext, 'steps'> {\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"]}
|
package/dist_commonjs/index.cjs
CHANGED
|
@@ -53,5 +53,7 @@ Object.defineProperty(exports, "BuildFunctionGroup", { enumerable: true, get: fu
|
|
|
53
53
|
var BuildStep_js_1 = require("./BuildStep.cjs");
|
|
54
54
|
Object.defineProperty(exports, "BuildStep", { enumerable: true, get: function () { return BuildStep_js_1.BuildStep; } });
|
|
55
55
|
exports.errors = __importStar(require("./errors.cjs"));
|
|
56
|
+
__exportStar(require("./interpolation.cjs"), exports);
|
|
56
57
|
__exportStar(require("./utils/shell/spawn.cjs"), exports);
|
|
58
|
+
__exportStar(require("./utils/jsepEval.cjs"), exports);
|
|
57
59
|
//# sourceMappingURL=index.js.map
|
package/dist_commonjs/index.d.ts
CHANGED
|
@@ -12,4 +12,6 @@ export { BuildStepEnv } from './BuildStepEnv.js';
|
|
|
12
12
|
export { BuildFunctionGroup } from './BuildFunctionGroup.js';
|
|
13
13
|
export { BuildStep } from './BuildStep.js';
|
|
14
14
|
export * as errors from './errors.js';
|
|
15
|
+
export * from './interpolation.js';
|
|
15
16
|
export * from './utils/shell/spawn.js';
|
|
17
|
+
export * from './utils/jsepEval.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,mDAA2E;AAAlE,yIAAA,uCAAuC,OAAA;AAChD,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,yDAAkF;AAAzE,mHAAA,cAAc,OAAA;AAAE,gIAAA,2BAA2B,OAAA;AACpD,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,6DAA6F;AAApF,6HAAA,sBAAsB,OAAA;AAC/B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,sDAAsC;AACtC,yDAAuC","sourcesContent":["export { BuildStepContext } from './BuildStepContext.js';\nexport { readAndValidateBuildConfigFromPathAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { StepsConfigParser } from './StepsConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport { BuildStepEnv } from './BuildStepEnv.js';\nexport { BuildFunctionGroup } from './BuildFunctionGroup.js';\nexport { BuildStep } from './BuildStep.js';\nexport * as errors from './errors.js';\nexport * from './utils/shell/spawn.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,mDAA2E;AAAlE,yIAAA,uCAAuC,OAAA;AAChD,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,yDAAkF;AAAzE,mHAAA,cAAc,OAAA;AAAE,gIAAA,2BAA2B,OAAA;AACpD,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,6DAA6F;AAApF,6HAAA,sBAAsB,OAAA;AAC/B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,sDAAsC;AACtC,qDAAmC;AACnC,yDAAuC;AACvC,sDAAoC","sourcesContent":["export { BuildStepContext } from './BuildStepContext.js';\nexport { readAndValidateBuildConfigFromPathAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { StepsConfigParser } from './StepsConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport { BuildStepEnv } from './BuildStepEnv.js';\nexport { BuildFunctionGroup } from './BuildFunctionGroup.js';\nexport { BuildStep } from './BuildStep.js';\nexport * as errors from './errors.js';\nexport * from './interpolation.js';\nexport * from './utils/shell/spawn.js';\nexport * from './utils/jsepEval.js';\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.interpolateJobContext = void 0;
|
|
4
|
+
const jsepEval_js_1 = require("./utils/jsepEval.cjs");
|
|
5
|
+
function interpolateJobContext({ target, context, }) {
|
|
6
|
+
if (typeof target === 'string') {
|
|
7
|
+
// If the value is e.g. `build: ${{ inputs.build }}`, we will interpolate the value
|
|
8
|
+
// without changing `inputs.build` type, i.e. if it is an object it'll be like `build: {...inputs.build}`.
|
|
9
|
+
if (target.startsWith('${{') && target.endsWith('}}')) {
|
|
10
|
+
return (0, jsepEval_js_1.jsepEval)(target.slice(3, -2), context);
|
|
11
|
+
}
|
|
12
|
+
// Otherwise we replace all occurrences of `${{...}}` with the result of the expression.
|
|
13
|
+
// e.g. `echo ${{ build.profile }}` becomes `echo production`.
|
|
14
|
+
return target.replace(/\$\{\{(.+?)\}\}/g, (_match, expression) => {
|
|
15
|
+
return `${(0, jsepEval_js_1.jsepEval)(expression, context)}`;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
else if (Array.isArray(target)) {
|
|
19
|
+
return target.map((value) => interpolateJobContext({ target: value, context }));
|
|
20
|
+
}
|
|
21
|
+
else if (typeof target === 'object' && target) {
|
|
22
|
+
return Object.fromEntries(Object.entries(target).map(([key, value]) => [
|
|
23
|
+
key,
|
|
24
|
+
interpolateJobContext({ target: value, context }),
|
|
25
|
+
]));
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
exports.interpolateJobContext = interpolateJobContext;
|
|
30
|
+
//# sourceMappingURL=interpolation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolation.js","sourceRoot":"","sources":["../src/interpolation.ts"],"names":[],"mappings":";;;AAEA,qDAA+C;AAE/C,SAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,OAAO,GAIR;IACC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,mFAAmF;QACnF,0GAA0G;QAC1G,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACtD,OAAO,IAAA,sBAAQ,EAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;QAED,wFAAwF;QACxF,8DAA8D;QAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE;YAC/D,OAAO,GAAG,IAAA,sBAAQ,EAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAClF,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,EAAE,CAAC;QAChD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YAC3C,GAAG;YACH,qBAAqB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SAClD,CAAC,CACH,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA9BD,sDA8BC","sourcesContent":["import { JobInterpolationContext } from '@expo/eas-build-job';\n\nimport { jsepEval } from './utils/jsepEval.js';\n\nexport function interpolateJobContext({\n target,\n context,\n}: {\n target: unknown;\n context: JobInterpolationContext;\n}): unknown {\n if (typeof target === 'string') {\n // If the value is e.g. `build: ${{ inputs.build }}`, we will interpolate the value\n // without changing `inputs.build` type, i.e. if it is an object it'll be like `build: {...inputs.build}`.\n if (target.startsWith('${{') && target.endsWith('}}')) {\n return jsepEval(target.slice(3, -2), context);\n }\n\n // Otherwise we replace all occurrences of `${{...}}` with the result of the expression.\n // e.g. `echo ${{ build.profile }}` becomes `echo production`.\n return target.replace(/\\$\\{\\{(.+?)\\}\\}/g, (_match, expression) => {\n return `${jsepEval(expression, context)}`;\n });\n } else if (Array.isArray(target)) {\n return target.map((value) => interpolateJobContext({ target: value, context }));\n } else if (typeof target === 'object' && target) {\n return Object.fromEntries(\n Object.entries(target).map(([key, value]) => [\n key,\n interpolateJobContext({ target: value, context }),\n ])\n );\n }\n return target;\n}\n"]}
|
package/dist_esm/BuildStep.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare class BuildStepOutputAccessor {
|
|
|
32
32
|
protected readonly executed: boolean;
|
|
33
33
|
protected readonly outputById: BuildStepOutputById;
|
|
34
34
|
constructor(id: string, displayName: string, executed: boolean, outputById: BuildStepOutputById);
|
|
35
|
+
get outputs(): BuildStepOutput[];
|
|
35
36
|
getOutputValueByName(name: string): string | undefined;
|
|
36
37
|
hasOutputParameter(name: string): boolean;
|
|
37
38
|
serialize(): SerializedBuildStepOutputAccessor;
|
|
@@ -43,7 +44,7 @@ export declare class BuildStep extends BuildStepOutputAccessor {
|
|
|
43
44
|
readonly displayName: string;
|
|
44
45
|
readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];
|
|
45
46
|
readonly inputs?: BuildStepInput[];
|
|
46
|
-
readonly
|
|
47
|
+
readonly outputById: BuildStepOutputById;
|
|
47
48
|
readonly command?: string;
|
|
48
49
|
readonly fn?: BuildStepFunction;
|
|
49
50
|
readonly shell: string;
|
|
@@ -51,9 +52,10 @@ export declare class BuildStep extends BuildStepOutputAccessor {
|
|
|
51
52
|
readonly stepEnvOverrides: BuildStepEnv;
|
|
52
53
|
readonly ifCondition?: string;
|
|
53
54
|
status: BuildStepStatus;
|
|
55
|
+
private readonly outputsDir;
|
|
56
|
+
private readonly envsDir;
|
|
54
57
|
private readonly internalId;
|
|
55
58
|
private readonly inputById;
|
|
56
|
-
protected readonly outputById: BuildStepOutputById;
|
|
57
59
|
protected executed: boolean;
|
|
58
60
|
static getNewId(userDefinedId?: string): string;
|
|
59
61
|
static getDisplayName({ id, name, command, }: {
|
|
@@ -76,16 +78,14 @@ export declare class BuildStep extends BuildStepOutputAccessor {
|
|
|
76
78
|
ifCondition?: string;
|
|
77
79
|
});
|
|
78
80
|
executeAsync(): Promise<void>;
|
|
79
|
-
hasOutputParameter(name: string): boolean;
|
|
80
|
-
getOutputValueByName(name: string): string | undefined;
|
|
81
81
|
canBeRunOnRuntimePlatform(): boolean;
|
|
82
|
-
shouldExecuteStep(
|
|
82
|
+
shouldExecuteStep(): boolean;
|
|
83
83
|
skip(): void;
|
|
84
|
+
private getInterpolationContext;
|
|
84
85
|
private executeCommandAsync;
|
|
85
|
-
private
|
|
86
|
+
private executeFnAsync;
|
|
86
87
|
private interpolateInputsOutputsAndGlobalContextInTemplate;
|
|
87
88
|
private collectAndValidateOutputsAsync;
|
|
88
89
|
private collectAndUpdateEnvsAsync;
|
|
89
|
-
private get effectiveEnv();
|
|
90
90
|
private getScriptEnv;
|
|
91
91
|
}
|
package/dist_esm/BuildStep.js
CHANGED
|
@@ -6,11 +6,12 @@ import { makeBuildStepInputByIdMap } from './BuildStepInput.js';
|
|
|
6
6
|
import { BuildStepOutput, makeBuildStepOutputByIdMap, } from './BuildStepOutput.js';
|
|
7
7
|
import { BIN_PATH } from './utils/shell/bin.js';
|
|
8
8
|
import { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';
|
|
9
|
-
import { cleanUpStepTemporaryDirectoriesAsync,
|
|
9
|
+
import { cleanUpStepTemporaryDirectoriesAsync, getTemporaryEnvsDirPath, getTemporaryOutputsDirPath, saveScriptToTemporaryFileAsync, } from './BuildTemporaryFiles.js';
|
|
10
10
|
import { spawnAsync } from './utils/shell/spawn.js';
|
|
11
11
|
import { interpolateWithInputs, interpolateWithOutputs } from './utils/template.js';
|
|
12
12
|
import { BuildStepRuntimeError } from './errors.js';
|
|
13
13
|
import { jsepEval } from './utils/jsepEval.js';
|
|
14
|
+
import { interpolateJobContext } from './interpolation.js';
|
|
14
15
|
export var BuildStepStatus;
|
|
15
16
|
(function (BuildStepStatus) {
|
|
16
17
|
BuildStepStatus["NEW"] = "new";
|
|
@@ -34,6 +35,9 @@ export class BuildStepOutputAccessor {
|
|
|
34
35
|
this.executed = executed;
|
|
35
36
|
this.outputById = outputById;
|
|
36
37
|
}
|
|
38
|
+
get outputs() {
|
|
39
|
+
return Object.values(this.outputById);
|
|
40
|
+
}
|
|
37
41
|
getOutputValueByName(name) {
|
|
38
42
|
if (!this.executed) {
|
|
39
43
|
throw new BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
|
|
@@ -95,7 +99,6 @@ export class BuildStep extends BuildStepOutputAccessor {
|
|
|
95
99
|
this.displayName = displayName;
|
|
96
100
|
this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;
|
|
97
101
|
this.inputs = inputs;
|
|
98
|
-
this.outputs = outputs;
|
|
99
102
|
this.inputById = makeBuildStepInputByIdMap(inputs);
|
|
100
103
|
this.outputById = outputById;
|
|
101
104
|
this.fn = fn;
|
|
@@ -111,17 +114,23 @@ export class BuildStep extends BuildStepOutputAccessor {
|
|
|
111
114
|
});
|
|
112
115
|
this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });
|
|
113
116
|
this.stepEnvOverrides = env !== null && env !== void 0 ? env : {};
|
|
117
|
+
this.outputsDir = getTemporaryOutputsDirPath(ctx, this.id);
|
|
118
|
+
this.envsDir = getTemporaryEnvsDirPath(ctx, this.id);
|
|
114
119
|
ctx.registerStep(this);
|
|
115
120
|
}
|
|
116
121
|
async executeAsync() {
|
|
117
122
|
try {
|
|
118
123
|
this.ctx.logger.info({ marker: BuildStepLogMarker.START_STEP }, `Executing build step "${this.displayName}"`);
|
|
119
124
|
this.status = BuildStepStatus.IN_PROGRESS;
|
|
125
|
+
await fs.mkdir(this.outputsDir, { recursive: true });
|
|
126
|
+
this.ctx.logger.debug(`Created temporary directory for step outputs: ${this.outputsDir}`);
|
|
127
|
+
await fs.mkdir(this.envsDir, { recursive: true });
|
|
128
|
+
this.ctx.logger.debug(`Created temporary directory for step environment variables: ${this.envsDir}`);
|
|
120
129
|
if (this.command !== undefined) {
|
|
121
130
|
await this.executeCommandAsync();
|
|
122
131
|
}
|
|
123
132
|
else {
|
|
124
|
-
await this.
|
|
133
|
+
await this.executeFnAsync();
|
|
125
134
|
}
|
|
126
135
|
this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS }, `Finished build step "${this.displayName}" successfully`);
|
|
127
136
|
this.status = BuildStepStatus.SUCCESS;
|
|
@@ -134,39 +143,41 @@ export class BuildStep extends BuildStepOutputAccessor {
|
|
|
134
143
|
}
|
|
135
144
|
finally {
|
|
136
145
|
this.executed = true;
|
|
146
|
+
try {
|
|
147
|
+
await this.collectAndValidateOutputsAsync(this.outputsDir);
|
|
148
|
+
await this.collectAndUpdateEnvsAsync(this.envsDir);
|
|
149
|
+
this.ctx.logger.debug('Finished collecting output parameters');
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
// If the step succeeded, we expect the outputs to be collected successfully.
|
|
153
|
+
if (this.status === BuildStepStatus.SUCCESS) {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
this.ctx.logger.debug({ err: error }, 'Failed to collect output parameters');
|
|
157
|
+
}
|
|
158
|
+
await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);
|
|
137
159
|
}
|
|
138
160
|
}
|
|
139
|
-
hasOutputParameter(name) {
|
|
140
|
-
return name in this.outputById;
|
|
141
|
-
}
|
|
142
|
-
getOutputValueByName(name) {
|
|
143
|
-
if (!this.executed) {
|
|
144
|
-
throw new BuildStepRuntimeError(`Failed getting output "${name}" from step "${this.displayName}". The step has not been executed yet.`);
|
|
145
|
-
}
|
|
146
|
-
if (!this.hasOutputParameter(name)) {
|
|
147
|
-
throw new BuildStepRuntimeError(`Step "${this.displayName}" does not have output "${name}".`);
|
|
148
|
-
}
|
|
149
|
-
return this.outputById[name].value;
|
|
150
|
-
}
|
|
151
161
|
canBeRunOnRuntimePlatform() {
|
|
152
162
|
return (!this.supportedRuntimePlatforms ||
|
|
153
163
|
this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform));
|
|
154
164
|
}
|
|
155
|
-
shouldExecuteStep(
|
|
165
|
+
shouldExecuteStep() {
|
|
156
166
|
var _a, _b;
|
|
167
|
+
const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;
|
|
157
168
|
if (!this.ifCondition) {
|
|
158
|
-
return !
|
|
169
|
+
return !hasAnyPreviousStepFailed;
|
|
159
170
|
}
|
|
160
171
|
let ifCondition = this.ifCondition;
|
|
161
172
|
if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {
|
|
162
173
|
ifCondition = ifCondition.slice(2, -1);
|
|
163
174
|
}
|
|
164
175
|
return Boolean(jsepEval(ifCondition, {
|
|
165
|
-
success: () => !
|
|
166
|
-
failure: () =>
|
|
176
|
+
success: () => !hasAnyPreviousStepFailed,
|
|
177
|
+
failure: () => hasAnyPreviousStepFailed,
|
|
167
178
|
always: () => true,
|
|
168
179
|
never: () => false,
|
|
169
|
-
env: this.
|
|
180
|
+
env: this.getScriptEnv(),
|
|
170
181
|
inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
|
|
171
182
|
acc[input.id] = input.value;
|
|
172
183
|
return acc;
|
|
@@ -183,55 +194,48 @@ export class BuildStep extends BuildStepOutputAccessor {
|
|
|
183
194
|
this.ctx.logger.info(`Skipped build step "${this.displayName}"`);
|
|
184
195
|
this.ctx.logger.info({ marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED }, `Skipped build step "${this.displayName}"`);
|
|
185
196
|
}
|
|
197
|
+
getInterpolationContext() {
|
|
198
|
+
const hasAnyPreviousStepFailed = this.ctx.global.hasAnyPreviousStepFailed;
|
|
199
|
+
return {
|
|
200
|
+
...this.ctx.global.staticContext,
|
|
201
|
+
always: () => true,
|
|
202
|
+
never: () => false,
|
|
203
|
+
success: () => !hasAnyPreviousStepFailed,
|
|
204
|
+
failure: () => hasAnyPreviousStepFailed,
|
|
205
|
+
env: this.getScriptEnv(),
|
|
206
|
+
fromJSON: (json) => JSON.parse(json),
|
|
207
|
+
toJSON: (value) => JSON.stringify(value),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
186
210
|
async executeCommandAsync() {
|
|
187
211
|
assert(this.command, 'Command must be defined.');
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
this.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this.ctx.logger.debug(`Script completed successfully`);
|
|
207
|
-
await this.collectAndValidateOutputsAsync(outputsDir);
|
|
208
|
-
await this.collectAndUpdateEnvsAsync(envsDir);
|
|
209
|
-
this.ctx.logger.debug('Finished collecting output paramters');
|
|
210
|
-
}
|
|
211
|
-
finally {
|
|
212
|
-
await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);
|
|
213
|
-
}
|
|
212
|
+
const interpolatedCommand = interpolateJobContext({
|
|
213
|
+
target: this.command,
|
|
214
|
+
context: this.getInterpolationContext(),
|
|
215
|
+
});
|
|
216
|
+
const command = this.interpolateInputsOutputsAndGlobalContextInTemplate(`${interpolatedCommand}`, this.inputs);
|
|
217
|
+
this.ctx.logger.debug(`Interpolated inputs in the command template`);
|
|
218
|
+
const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);
|
|
219
|
+
this.ctx.logger.debug(`Saved script to ${scriptPath}`);
|
|
220
|
+
const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);
|
|
221
|
+
this.ctx.logger.debug(`Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`);
|
|
222
|
+
await spawnAsync(shellCommand, args !== null && args !== void 0 ? args : [], {
|
|
223
|
+
cwd: this.ctx.workingDirectory,
|
|
224
|
+
logger: this.ctx.logger,
|
|
225
|
+
env: this.getScriptEnv(),
|
|
226
|
+
// stdin is /dev/null, std{out,err} are piped into logger.
|
|
227
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
228
|
+
});
|
|
229
|
+
this.ctx.logger.debug(`Script completed successfully`);
|
|
214
230
|
}
|
|
215
|
-
async
|
|
231
|
+
async executeFnAsync() {
|
|
216
232
|
assert(this.fn, 'Function (fn) must be defined');
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
inputs: this.inputById,
|
|
224
|
-
outputs: this.outputById,
|
|
225
|
-
env: this.getScriptEnv({ outputsDir, envsDir }),
|
|
226
|
-
});
|
|
227
|
-
this.ctx.logger.debug(`Script completed successfully`);
|
|
228
|
-
await this.collectAndValidateOutputsAsync(outputsDir);
|
|
229
|
-
await this.collectAndUpdateEnvsAsync(envsDir);
|
|
230
|
-
this.ctx.logger.debug('Finished collecting output paramters');
|
|
231
|
-
}
|
|
232
|
-
finally {
|
|
233
|
-
await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);
|
|
234
|
-
}
|
|
233
|
+
await this.fn(this.ctx, {
|
|
234
|
+
inputs: this.inputById,
|
|
235
|
+
outputs: this.outputById,
|
|
236
|
+
env: this.getScriptEnv(),
|
|
237
|
+
});
|
|
238
|
+
this.ctx.logger.debug(`Script completed successfully`);
|
|
235
239
|
}
|
|
236
240
|
interpolateInputsOutputsAndGlobalContextInTemplate(template, inputs) {
|
|
237
241
|
if (!inputs) {
|
|
@@ -248,12 +252,21 @@ export class BuildStep extends BuildStepOutputAccessor {
|
|
|
248
252
|
return interpolateWithOutputs(interpolateWithInputs(this.ctx.global.interpolate(template), vars), (path) => { var _a; return (_a = this.ctx.global.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
249
253
|
}
|
|
250
254
|
async collectAndValidateOutputsAsync(outputsDir) {
|
|
251
|
-
var _a;
|
|
252
255
|
const files = await fs.readdir(outputsDir);
|
|
253
256
|
const nonDefinedOutputIds = [];
|
|
254
257
|
for (const outputId of files) {
|
|
255
258
|
if (!(outputId in this.outputById)) {
|
|
256
259
|
nonDefinedOutputIds.push(outputId);
|
|
260
|
+
const newOutput = new BuildStepOutput(this.ctx.global, {
|
|
261
|
+
id: outputId,
|
|
262
|
+
stepDisplayName: this.displayName,
|
|
263
|
+
required: false,
|
|
264
|
+
});
|
|
265
|
+
const file = path.join(outputsDir, outputId);
|
|
266
|
+
const rawContents = await fs.readFile(file, 'utf-8');
|
|
267
|
+
const value = rawContents.trim();
|
|
268
|
+
newOutput.set(value);
|
|
269
|
+
this.outputById[outputId] = newOutput;
|
|
257
270
|
}
|
|
258
271
|
else {
|
|
259
272
|
const file = path.join(outputsDir, outputId);
|
|
@@ -267,7 +280,7 @@ export class BuildStep extends BuildStepOutputAccessor {
|
|
|
267
280
|
this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`);
|
|
268
281
|
}
|
|
269
282
|
const nonSetRequiredOutputIds = [];
|
|
270
|
-
for (const output of (
|
|
283
|
+
for (const output of Object.values(this.outputById)) {
|
|
271
284
|
try {
|
|
272
285
|
const value = output.value;
|
|
273
286
|
this.ctx.logger.debug(`Output parameter "${output.id}" is set to "${value}"`);
|
|
@@ -295,18 +308,15 @@ export class BuildStep extends BuildStepOutputAccessor {
|
|
|
295
308
|
...Object.fromEntries(entries),
|
|
296
309
|
});
|
|
297
310
|
}
|
|
298
|
-
|
|
299
|
-
return { ...this.ctx.global.env, ...this.stepEnvOverrides };
|
|
300
|
-
}
|
|
301
|
-
getScriptEnv({ envsDir, outputsDir, }) {
|
|
311
|
+
getScriptEnv() {
|
|
302
312
|
var _a;
|
|
303
|
-
const
|
|
304
|
-
const currentPath = (_a =
|
|
313
|
+
const effectiveEnv = { ...this.ctx.global.env, ...this.stepEnvOverrides };
|
|
314
|
+
const currentPath = (_a = effectiveEnv.PATH) !== null && _a !== void 0 ? _a : process.env.PATH;
|
|
305
315
|
const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;
|
|
306
316
|
return {
|
|
307
|
-
...
|
|
308
|
-
__EXPO_STEPS_OUTPUTS_DIR: outputsDir,
|
|
309
|
-
__EXPO_STEPS_ENVS_DIR: envsDir,
|
|
317
|
+
...effectiveEnv,
|
|
318
|
+
__EXPO_STEPS_OUTPUTS_DIR: this.outputsDir,
|
|
319
|
+
__EXPO_STEPS_ENVS_DIR: this.envsDir,
|
|
310
320
|
__EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,
|
|
311
321
|
PATH: newPath,
|
|
312
322
|
};
|