@expo/steps 1.0.83 → 1.0.85
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/BuildStepContext.cjs +3 -0
- package/dist_commonjs/BuildStepContext.d.ts +1 -0
- package/dist_commonjs/BuildStepContext.js.map +1 -1
- package/dist_commonjs/BuildStepInput.cjs +18 -2
- package/dist_commonjs/BuildStepInput.d.ts +1 -0
- package/dist_commonjs/BuildStepInput.js.map +1 -1
- package/dist_esm/BuildStepContext.d.ts +1 -0
- package/dist_esm/BuildStepContext.js +3 -0
- package/dist_esm/BuildStepContext.js.map +1 -1
- package/dist_esm/BuildStepInput.d.ts +1 -0
- package/dist_esm/BuildStepInput.js +18 -2
- package/dist_esm/BuildStepInput.js.map +1 -1
- package/package.json +2 -2
|
@@ -69,6 +69,9 @@ class BuildStepGlobalContext {
|
|
|
69
69
|
this.didCheckOut = true;
|
|
70
70
|
logger.info(`Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`);
|
|
71
71
|
}
|
|
72
|
+
wasCheckedOut() {
|
|
73
|
+
return this.didCheckOut;
|
|
74
|
+
}
|
|
72
75
|
serialize() {
|
|
73
76
|
return {
|
|
74
77
|
stepsInternalBuildDirectory: this.stepsInternalBuildDirectory,
|
|
@@ -53,6 +53,7 @@ export declare class BuildStepGlobalContext {
|
|
|
53
53
|
relativeWorkingDirectory?: string;
|
|
54
54
|
}): BuildStepContext;
|
|
55
55
|
markAsCheckedOut(logger: bunyan): void;
|
|
56
|
+
wasCheckedOut(): boolean;
|
|
56
57
|
serialize(): SerializedBuildStepGlobalContext;
|
|
57
58
|
static deserialize(serialized: SerializedBuildStepGlobalContext, logger: bunyan): BuildStepGlobalContext;
|
|
58
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepContext.js","sourceRoot":"","sources":["../src/BuildStepContext.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;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B,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<InterpolableType extends string | object>(\n value: InterpolableType\n ): InterpolableType {\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,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,CAAC,kBAAkB,CAAC;IAC1C,CAAC;IA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C;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<InterpolableType extends string | object>(\n value: InterpolableType\n ): InterpolableType {\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 wasCheckedOut(): boolean {\n return this.didCheckOut;\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"]}
|
|
@@ -35,11 +35,12 @@ class BuildStepInput {
|
|
|
35
35
|
throw new errors_js_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
36
36
|
}
|
|
37
37
|
const valueDoesNotRequireInterpolation = rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number';
|
|
38
|
+
let returnValue;
|
|
38
39
|
if (valueDoesNotRequireInterpolation) {
|
|
39
40
|
if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {
|
|
40
41
|
throw new errors_js_1.BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
returnValue = rawValue;
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
// `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined
|
|
@@ -47,7 +48,22 @@ class BuildStepInput {
|
|
|
47
48
|
(0, assert_1.default)(rawValue !== undefined);
|
|
48
49
|
const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);
|
|
49
50
|
const valueInterpolatedWithOutputsAndGlobalContext = (0, template_js_1.interpolateWithOutputs)(valueInterpolatedWithGlobalContext, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
50
|
-
|
|
51
|
+
returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);
|
|
52
|
+
}
|
|
53
|
+
return this.fixEscapeCharacters(returnValue);
|
|
54
|
+
}
|
|
55
|
+
fixEscapeCharacters(input) {
|
|
56
|
+
if (typeof input === 'string') {
|
|
57
|
+
return input.replace(/\\n/g, '\n');
|
|
58
|
+
}
|
|
59
|
+
else if (typeof input === 'object') {
|
|
60
|
+
for (const property of Object.keys(input)) {
|
|
61
|
+
input[property] = this.fixEscapeCharacters(input[property]);
|
|
62
|
+
}
|
|
63
|
+
return input;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return input;
|
|
51
67
|
}
|
|
52
68
|
}
|
|
53
69
|
get rawValue() {
|
|
@@ -42,6 +42,7 @@ export declare class BuildStepInput<T extends BuildStepInputValueTypeName = Buil
|
|
|
42
42
|
static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider;
|
|
43
43
|
constructor(ctx: BuildStepGlobalContext, { id, stepDisplayName, allowedValues, defaultValue, required, allowedValueTypeName, }: BuildStepInputParams<T, R>);
|
|
44
44
|
get value(): BuildStepInputValueTypeWithRequired<T, R>;
|
|
45
|
+
private fixEscapeCharacters;
|
|
45
46
|
get rawValue(): BuildStepInputValueType<T> | undefined;
|
|
46
47
|
set(value: BuildStepInputValueType<T> | undefined): BuildStepInput;
|
|
47
48
|
isValueOneOfAllowedValues(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAI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AI,CAAC,oBAAoB,IAAI,CAClH,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,uBAAuB,CAAC,KAAa;QAC3C,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,iCAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,sBAAsB,IAAI,CAAC,oBAAoB,IAAI,EACjH;gBACE,KAAK,EAAE,CAAC;aACT,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAjLD,wCAiLC;AAED,SAAgB,yBAAyB,CAAC,MAAyB;IACjE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAClC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAwB,CAAC,CAAC;AAC/B,CAAC;AARD,8DAQC","sourcesContent":["import assert from 'assert';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStepGlobalContext, SerializedBuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport {\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n interpolateWithOutputs,\n} from './utils/template.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n JSON = 'json',\n}\n\nexport type BuildStepInputValueType<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n> = T extends BuildStepInputValueTypeName.STRING\n ? string\n : T extends BuildStepInputValueTypeName.BOOLEAN\n ? boolean\n : T extends BuildStepInputValueTypeName.NUMBER\n ? number\n : Record<string, any>;\n\nexport type BuildStepInputValueTypeWithRequired<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> = R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | undefined;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n allowedValues?: BuildStepInputValueType<T>[];\n defaultValue?: BuildStepInputValueType<T>;\n required: R;\n allowedValueTypeName: T;\n}\n\ninterface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean>\n extends BuildStepInputProviderParams<T, R> {\n stepDisplayName: string;\n}\n\nexport interface SerializedBuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n stepDisplayName: string;\n defaultValue?: BuildStepInputValueType<T>;\n allowedValues?: BuildStepInputValueType<T>[];\n allowedValueTypeName: BuildStepInputValueTypeName;\n required: R;\n value?: BuildStepInputValueType<T>;\n ctx: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: BuildStepInputValueType<T>;\n public readonly allowedValues?: BuildStepInputValueType<T>[];\n public readonly allowedValueTypeName: T;\n public readonly required: R;\n\n private _value?: BuildStepInputValueType<T>;\n\n public static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n id,\n stepDisplayName,\n allowedValues,\n defaultValue,\n required,\n allowedValueTypeName,\n }: BuildStepInputParams<T, R>\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public get value(): BuildStepInputValueTypeWithRequired<T, R> {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n\n const valueDoesNotRequireInterpolation =\n rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number';\n if (valueDoesNotRequireInterpolation) {\n if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return rawValue as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined\n // so this will never be true.\n assert(rawValue !== undefined);\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n return this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n }\n\n public get rawValue(): BuildStepInputValueType<T> | undefined {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: BuildStepInputValueType<T> | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n\n this._value = value;\n return this;\n }\n\n public isValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\n }\n\n public isRawValueStepOrContextReference(): boolean {\n return (\n typeof this.rawValue === 'string' &&\n !!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue)\n );\n }\n\n public serialize(): SerializedBuildStepInput<T, R> {\n return {\n id: this.id,\n stepDisplayName: this.stepDisplayName,\n defaultValue: this.defaultValue,\n allowedValues: this.allowedValues,\n allowedValueTypeName: this.allowedValueTypeName,\n required: this.required,\n value: this._value,\n ctx: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serializedInput: SerializedBuildStepInput,\n logger: bunyan\n ): BuildStepInput {\n const deserializedContext = BuildStepGlobalContext.deserialize(serializedInput.ctx, logger);\n const input = new BuildStepInput(deserializedContext, {\n id: serializedInput.id,\n stepDisplayName: serializedInput.stepDisplayName,\n defaultValue: serializedInput.defaultValue,\n allowedValues: serializedInput.allowedValues,\n allowedValueTypeName: serializedInput.allowedValueTypeName,\n required: serializedInput.required,\n });\n input._value = serializedInput.value;\n return input;\n }\n\n private parseInputValueToAllowedType(\n value: string | object\n ): BuildStepInputValueTypeWithRequired<T, R> {\n if (typeof value === 'object') {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n }\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n return this.parseInputValueToObject(value) as BuildStepInputValueTypeWithRequired<T, R>;\n }\n }\n\n private parseInputValueToNumber(value: string): number {\n const numberValue = Number(value);\n if (Number.isNaN(numberValue)) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return numberValue;\n }\n\n private parseInputValueToBoolean(value: string): boolean {\n if (value === 'true') {\n return true;\n } else if (value === 'false') {\n return false;\n } else {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n }\n\n private parseInputValueToObject(value: string): Record<string, any> {\n try {\n return JSON.parse(value);\n } catch (e: any) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`,\n {\n cause: e,\n }\n );\n }\n }\n}\n\nexport function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById {\n if (inputs === undefined) {\n return {};\n }\n return inputs.reduce((acc, input) => {\n acc[input.id] = input;\n return acc;\n }, {} as BuildStepInputById);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAI5B,+DAAiG;AACjG,2CAAoD;AACpD,qDAG6B;AAE7B,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,gDAAiB,CAAA;IACjB,kDAAmB,CAAA;IACnB,gDAAiB,CAAA;IACjB,4CAAa,CAAA;AACf,CAAC,EALW,2BAA2B,2CAA3B,2BAA2B,QAKtC;AAqDD,MAAa,cAAc;IAalB,MAAM,CAAC,cAAc,CAAC,MAAoC;QAC/D,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,YACmB,GAA2B,EAC5C,EACE,EAAE,EACF,eAAe,EACf,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,GACO;QARZ,QAAG,GAAH,GAAG,CAAwB;QAU5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC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C3C,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,IAAI,iCAAqB,CAC7B,oBAAoB,IAAI,CAAC,EAAE,eAAe,IAAI,CAAC,eAAe,sBAAsB,IAAI,CAAC,oBAAoB,IAAI,EACjH;gBACE,KAAK,EAAE,CAAC;aACT,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAlMD,wCAkMC;AAED,SAAgB,yBAAyB,CAAC,MAAyB;IACjE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAClC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAwB,CAAC,CAAC;AAC/B,CAAC;AARD,8DAQC","sourcesContent":["import assert from 'assert';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStepGlobalContext, SerializedBuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport {\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n interpolateWithOutputs,\n} from './utils/template.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n JSON = 'json',\n}\n\nexport type BuildStepInputValueType<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n> = T extends BuildStepInputValueTypeName.STRING\n ? string\n : T extends BuildStepInputValueTypeName.BOOLEAN\n ? boolean\n : T extends BuildStepInputValueTypeName.NUMBER\n ? number\n : Record<string, any>;\n\nexport type BuildStepInputValueTypeWithRequired<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> = R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | undefined;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n allowedValues?: BuildStepInputValueType<T>[];\n defaultValue?: BuildStepInputValueType<T>;\n required: R;\n allowedValueTypeName: T;\n}\n\ninterface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean>\n extends BuildStepInputProviderParams<T, R> {\n stepDisplayName: string;\n}\n\nexport interface SerializedBuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n stepDisplayName: string;\n defaultValue?: BuildStepInputValueType<T>;\n allowedValues?: BuildStepInputValueType<T>[];\n allowedValueTypeName: BuildStepInputValueTypeName;\n required: R;\n value?: BuildStepInputValueType<T>;\n ctx: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: BuildStepInputValueType<T>;\n public readonly allowedValues?: BuildStepInputValueType<T>[];\n public readonly allowedValueTypeName: T;\n public readonly required: R;\n\n private _value?: BuildStepInputValueType<T>;\n\n public static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n id,\n stepDisplayName,\n allowedValues,\n defaultValue,\n required,\n allowedValueTypeName,\n }: BuildStepInputParams<T, R>\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public get value(): BuildStepInputValueTypeWithRequired<T, R> {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n\n const valueDoesNotRequireInterpolation =\n rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number';\n let returnValue;\n if (valueDoesNotRequireInterpolation) {\n if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n returnValue = rawValue as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined\n // so this will never be true.\n assert(rawValue !== undefined);\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n return this.fixEscapeCharacters(returnValue);\n }\n\n private fixEscapeCharacters(\n input: BuildStepInputValueTypeWithRequired<T, R>\n ): BuildStepInputValueTypeWithRequired<T, R> {\n if (typeof input === 'string') {\n return input.replace(/\\\\n/g, '\\n') as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (typeof input === 'object') {\n for (const property of Object.keys(input)) {\n input[property] = this.fixEscapeCharacters(input[property]);\n }\n return input;\n } else {\n return input;\n }\n }\n\n public get rawValue(): BuildStepInputValueType<T> | undefined {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: BuildStepInputValueType<T> | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n\n this._value = value;\n return this;\n }\n\n public isValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\n }\n\n public isRawValueStepOrContextReference(): boolean {\n return (\n typeof this.rawValue === 'string' &&\n !!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue)\n );\n }\n\n public serialize(): SerializedBuildStepInput<T, R> {\n return {\n id: this.id,\n stepDisplayName: this.stepDisplayName,\n defaultValue: this.defaultValue,\n allowedValues: this.allowedValues,\n allowedValueTypeName: this.allowedValueTypeName,\n required: this.required,\n value: this._value,\n ctx: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serializedInput: SerializedBuildStepInput,\n logger: bunyan\n ): BuildStepInput {\n const deserializedContext = BuildStepGlobalContext.deserialize(serializedInput.ctx, logger);\n const input = new BuildStepInput(deserializedContext, {\n id: serializedInput.id,\n stepDisplayName: serializedInput.stepDisplayName,\n defaultValue: serializedInput.defaultValue,\n allowedValues: serializedInput.allowedValues,\n allowedValueTypeName: serializedInput.allowedValueTypeName,\n required: serializedInput.required,\n });\n input._value = serializedInput.value;\n return input;\n }\n\n private parseInputValueToAllowedType(\n value: string | object\n ): BuildStepInputValueTypeWithRequired<T, R> {\n if (typeof value === 'object') {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n }\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n return this.parseInputValueToObject(value) as BuildStepInputValueTypeWithRequired<T, R>;\n }\n }\n\n private parseInputValueToNumber(value: string): number {\n const numberValue = Number(value);\n if (Number.isNaN(numberValue)) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return numberValue;\n }\n\n private parseInputValueToBoolean(value: string): boolean {\n if (value === 'true') {\n return true;\n } else if (value === 'false') {\n return false;\n } else {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n }\n\n private parseInputValueToObject(value: string): Record<string, any> {\n try {\n return JSON.parse(value);\n } catch (e: any) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`,\n {\n cause: e,\n }\n );\n }\n }\n}\n\nexport function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById {\n if (inputs === undefined) {\n return {};\n }\n return inputs.reduce((acc, input) => {\n acc[input.id] = input;\n return acc;\n }, {} as BuildStepInputById);\n}\n"]}
|
|
@@ -53,6 +53,7 @@ export declare class BuildStepGlobalContext {
|
|
|
53
53
|
relativeWorkingDirectory?: string;
|
|
54
54
|
}): BuildStepContext;
|
|
55
55
|
markAsCheckedOut(logger: bunyan): void;
|
|
56
|
+
wasCheckedOut(): boolean;
|
|
56
57
|
serialize(): SerializedBuildStepGlobalContext;
|
|
57
58
|
static deserialize(serialized: SerializedBuildStepGlobalContext, logger: bunyan): BuildStepGlobalContext;
|
|
58
59
|
}
|
|
@@ -63,6 +63,9 @@ export class BuildStepGlobalContext {
|
|
|
63
63
|
this.didCheckOut = true;
|
|
64
64
|
logger.info(`Changing default working directory to ${this.defaultWorkingDirectory} (was ${this.projectTargetDirectory})`);
|
|
65
65
|
}
|
|
66
|
+
wasCheckedOut() {
|
|
67
|
+
return this.didCheckOut;
|
|
68
|
+
}
|
|
66
69
|
serialize() {
|
|
67
70
|
return {
|
|
68
71
|
stepsInternalBuild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;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","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<InterpolableType extends string | object>(\n value: InterpolableType\n ): InterpolableType {\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,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAEL,uBAAuB,GAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAmCpD,MAAM,OAAO,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,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,EA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,YACmB,GAA2B,EAC5C,EACE,MAAM,EACN,wBAAwB,GAIzB;QAPgB,QAAG,GAAH,GAAG,CAAwB;QAS5C,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,GAAG,CAAC,UAAU,CAAC;QACvC,IAAI,CAAC,wBAAwB,GAAG,wBAAwB,CAAC;IAC3D,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,wBAAwB;YAClC,CAAC,CAAC,IAAI,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","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<InterpolableType extends string | object>(\n value: InterpolableType\n ): InterpolableType {\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 wasCheckedOut(): boolean {\n return this.didCheckOut;\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"]}
|
|
@@ -42,6 +42,7 @@ export declare class BuildStepInput<T extends BuildStepInputValueTypeName = Buil
|
|
|
42
42
|
static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider;
|
|
43
43
|
constructor(ctx: BuildStepGlobalContext, { id, stepDisplayName, allowedValues, defaultValue, required, allowedValueTypeName, }: BuildStepInputParams<T, R>);
|
|
44
44
|
get value(): BuildStepInputValueTypeWithRequired<T, R>;
|
|
45
|
+
private fixEscapeCharacters;
|
|
45
46
|
get rawValue(): BuildStepInputValueType<T> | undefined;
|
|
46
47
|
set(value: BuildStepInputValueType<T> | undefined): BuildStepInput;
|
|
47
48
|
isValueOneOfAllowedValues(): boolean;
|
|
@@ -29,11 +29,12 @@ export class BuildStepInput {
|
|
|
29
29
|
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
30
30
|
}
|
|
31
31
|
const valueDoesNotRequireInterpolation = rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number';
|
|
32
|
+
let returnValue;
|
|
32
33
|
if (valueDoesNotRequireInterpolation) {
|
|
33
34
|
if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {
|
|
34
35
|
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
returnValue = rawValue;
|
|
37
38
|
}
|
|
38
39
|
else {
|
|
39
40
|
// `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined
|
|
@@ -41,7 +42,22 @@ export class BuildStepInput {
|
|
|
41
42
|
assert(rawValue !== undefined);
|
|
42
43
|
const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);
|
|
43
44
|
const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(valueInterpolatedWithGlobalContext, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
44
|
-
|
|
45
|
+
returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);
|
|
46
|
+
}
|
|
47
|
+
return this.fixEscapeCharacters(returnValue);
|
|
48
|
+
}
|
|
49
|
+
fixEscapeCharacters(input) {
|
|
50
|
+
if (typeof input === 'string') {
|
|
51
|
+
return input.replace(/\\n/g, '\n');
|
|
52
|
+
}
|
|
53
|
+
else if (typeof input === 'object') {
|
|
54
|
+
for (const property of Object.keys(input)) {
|
|
55
|
+
input[property] = this.fixEscapeCharacters(input[property]);
|
|
56
|
+
}
|
|
57
|
+
return input;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return input;
|
|
45
61
|
}
|
|
46
62
|
}
|
|
47
63
|
get rawValue() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,sBAAsB,EAAoC,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,kDAAkD,EAClD,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,CAAN,IAAY,2BAKX;AALD,WAAY,2BAA2B;IACrC,gDAAiB,CAAA;IACjB,kDAAmB,CAAA;IACnB,gDAAiB,CAAA;IACjB,4CAAa,CAAA;AACf,CAAC,EALW,2BAA2B,KAA3B,2BAA2B,QAKtC;AAqDD,MAAM,OAAO,cAAc;IAalB,MAAM,CAAC,cAAc,CAAC,MAAoC;QAC/D,OAAO,CAAC,GAAG,EAAE,eAAe,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;IAC3F,CAAC;IAED,YACmB,GAA2B,EAC5C,EACE,EAAE,EACF,eAAe,EACf,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,oBAAoB,GACO;QARZ,QAAG,GAAH,GAAG,CAAwB;QAU5C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAA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C,EAAE,CAAC,GAAG,KAAK,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAwB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import assert from 'assert';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStepGlobalContext, SerializedBuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport {\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n interpolateWithOutputs,\n} from './utils/template.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n JSON = 'json',\n}\n\nexport type BuildStepInputValueType<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n> = T extends BuildStepInputValueTypeName.STRING\n ? string\n : T extends BuildStepInputValueTypeName.BOOLEAN\n ? boolean\n : T extends BuildStepInputValueTypeName.NUMBER\n ? number\n : Record<string, any>;\n\nexport type BuildStepInputValueTypeWithRequired<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> = R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | undefined;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n allowedValues?: BuildStepInputValueType<T>[];\n defaultValue?: BuildStepInputValueType<T>;\n required: R;\n allowedValueTypeName: T;\n}\n\ninterface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean>\n extends BuildStepInputProviderParams<T, R> {\n stepDisplayName: string;\n}\n\nexport interface SerializedBuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n stepDisplayName: string;\n defaultValue?: BuildStepInputValueType<T>;\n allowedValues?: BuildStepInputValueType<T>[];\n allowedValueTypeName: BuildStepInputValueTypeName;\n required: R;\n value?: BuildStepInputValueType<T>;\n ctx: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: BuildStepInputValueType<T>;\n public readonly allowedValues?: BuildStepInputValueType<T>[];\n public readonly allowedValueTypeName: T;\n public readonly required: R;\n\n private _value?: BuildStepInputValueType<T>;\n\n public static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n id,\n stepDisplayName,\n allowedValues,\n defaultValue,\n required,\n allowedValueTypeName,\n }: BuildStepInputParams<T, R>\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public get value(): BuildStepInputValueTypeWithRequired<T, R> {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n\n const valueDoesNotRequireInterpolation =\n rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number';\n if (valueDoesNotRequireInterpolation) {\n if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return rawValue as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined\n // so this will never be true.\n assert(rawValue !== undefined);\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n return this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n }\n\n public get rawValue(): BuildStepInputValueType<T> | undefined {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: BuildStepInputValueType<T> | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n\n this._value = value;\n return this;\n }\n\n public isValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\n }\n\n public isRawValueStepOrContextReference(): boolean {\n return (\n typeof this.rawValue === 'string' &&\n !!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue)\n );\n }\n\n public serialize(): SerializedBuildStepInput<T, R> {\n return {\n id: this.id,\n stepDisplayName: this.stepDisplayName,\n defaultValue: this.defaultValue,\n allowedValues: this.allowedValues,\n allowedValueTypeName: this.allowedValueTypeName,\n required: this.required,\n value: this._value,\n ctx: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serializedInput: SerializedBuildStepInput,\n logger: bunyan\n ): BuildStepInput {\n const deserializedContext = BuildStepGlobalContext.deserialize(serializedInput.ctx, logger);\n const input = new BuildStepInput(deserializedContext, {\n id: serializedInput.id,\n stepDisplayName: serializedInput.stepDisplayName,\n defaultValue: serializedInput.defaultValue,\n allowedValues: serializedInput.allowedValues,\n allowedValueTypeName: serializedInput.allowedValueTypeName,\n required: serializedInput.required,\n });\n input._value = serializedInput.value;\n return input;\n }\n\n private parseInputValueToAllowedType(\n value: string | object\n ): BuildStepInputValueTypeWithRequired<T, R> {\n if (typeof value === 'object') {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n }\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n return this.parseInputValueToObject(value) as BuildStepInputValueTypeWithRequired<T, R>;\n }\n }\n\n private parseInputValueToNumber(value: string): number {\n const numberValue = Number(value);\n if (Number.isNaN(numberValue)) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return numberValue;\n }\n\n private parseInputValueToBoolean(value: string): boolean {\n if (value === 'true') {\n return true;\n } else if (value === 'false') {\n return false;\n } else {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n }\n\n private parseInputValueToObject(value: string): Record<string, any> {\n try {\n return JSON.parse(value);\n } catch (e: any) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`,\n {\n cause: e,\n }\n );\n }\n }\n}\n\nexport function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById {\n if (inputs === undefined) {\n return {};\n }\n return inputs.reduce((acc, input) => {\n acc[input.id] = input;\n return acc;\n }, {} as BuildStepInputById);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,OAAO,EAAE,sBAAsB,EAAoC,MAAM,uBAAuB,CAAC;AACjG,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AE,EAAE;QAClC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;QACtB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAwB,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import assert from 'assert';\n\nimport { bunyan } from '@expo/logger';\n\nimport { BuildStepGlobalContext, SerializedBuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport {\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n interpolateWithOutputs,\n} from './utils/template.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n JSON = 'json',\n}\n\nexport type BuildStepInputValueType<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n> = T extends BuildStepInputValueTypeName.STRING\n ? string\n : T extends BuildStepInputValueTypeName.BOOLEAN\n ? boolean\n : T extends BuildStepInputValueTypeName.NUMBER\n ? number\n : Record<string, any>;\n\nexport type BuildStepInputValueTypeWithRequired<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> = R extends true ? BuildStepInputValueType<T> : BuildStepInputValueType<T> | undefined;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (\n ctx: BuildStepGlobalContext,\n stepId: string\n) => BuildStepInput;\n\ninterface BuildStepInputProviderParams<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n allowedValues?: BuildStepInputValueType<T>[];\n defaultValue?: BuildStepInputValueType<T>;\n required: R;\n allowedValueTypeName: T;\n}\n\ninterface BuildStepInputParams<T extends BuildStepInputValueTypeName, R extends boolean>\n extends BuildStepInputProviderParams<T, R> {\n stepDisplayName: string;\n}\n\nexport interface SerializedBuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n id: string;\n stepDisplayName: string;\n defaultValue?: BuildStepInputValueType<T>;\n allowedValues?: BuildStepInputValueType<T>[];\n allowedValueTypeName: BuildStepInputValueTypeName;\n required: R;\n value?: BuildStepInputValueType<T>;\n ctx: SerializedBuildStepGlobalContext;\n}\n\nexport class BuildStepInput<\n T extends BuildStepInputValueTypeName = BuildStepInputValueTypeName,\n R extends boolean = boolean,\n> {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: BuildStepInputValueType<T>;\n public readonly allowedValues?: BuildStepInputValueType<T>[];\n public readonly allowedValueTypeName: T;\n public readonly required: R;\n\n private _value?: BuildStepInputValueType<T>;\n\n public static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepGlobalContext,\n {\n id,\n stepDisplayName,\n allowedValues,\n defaultValue,\n required,\n allowedValueTypeName,\n }: BuildStepInputParams<T, R>\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public get value(): BuildStepInputValueTypeWithRequired<T, R> {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n\n const valueDoesNotRequireInterpolation =\n rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number';\n let returnValue;\n if (valueDoesNotRequireInterpolation) {\n if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n returnValue = rawValue as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n // `valueDoesNotRequireInterpolation` checks that `rawValue` is not undefined\n // so this will never be true.\n assert(rawValue !== undefined);\n const valueInterpolatedWithGlobalContext = this.ctx.interpolate(rawValue);\n const valueInterpolatedWithOutputsAndGlobalContext = interpolateWithOutputs(\n valueInterpolatedWithGlobalContext,\n (path) => this.ctx.getStepOutputValue(path) ?? ''\n );\n returnValue = this.parseInputValueToAllowedType(valueInterpolatedWithOutputsAndGlobalContext);\n }\n return this.fixEscapeCharacters(returnValue);\n }\n\n private fixEscapeCharacters(\n input: BuildStepInputValueTypeWithRequired<T, R>\n ): BuildStepInputValueTypeWithRequired<T, R> {\n if (typeof input === 'string') {\n return input.replace(/\\\\n/g, '\\n') as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (typeof input === 'object') {\n for (const property of Object.keys(input)) {\n input[property] = this.fixEscapeCharacters(input[property]);\n }\n return input;\n } else {\n return input;\n }\n }\n\n public get rawValue(): BuildStepInputValueType<T> | undefined {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: BuildStepInputValueType<T> | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n\n this._value = value;\n return this;\n }\n\n public isValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\n }\n\n public isRawValueStepOrContextReference(): boolean {\n return (\n typeof this.rawValue === 'string' &&\n !!BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX.exec(this.rawValue)\n );\n }\n\n public serialize(): SerializedBuildStepInput<T, R> {\n return {\n id: this.id,\n stepDisplayName: this.stepDisplayName,\n defaultValue: this.defaultValue,\n allowedValues: this.allowedValues,\n allowedValueTypeName: this.allowedValueTypeName,\n required: this.required,\n value: this._value,\n ctx: this.ctx.serialize(),\n };\n }\n\n public static deserialize(\n serializedInput: SerializedBuildStepInput,\n logger: bunyan\n ): BuildStepInput {\n const deserializedContext = BuildStepGlobalContext.deserialize(serializedInput.ctx, logger);\n const input = new BuildStepInput(deserializedContext, {\n id: serializedInput.id,\n stepDisplayName: serializedInput.stepDisplayName,\n defaultValue: serializedInput.defaultValue,\n allowedValues: serializedInput.allowedValues,\n allowedValueTypeName: serializedInput.allowedValueTypeName,\n required: serializedInput.required,\n });\n input._value = serializedInput.value;\n return input;\n }\n\n private parseInputValueToAllowedType(\n value: string | object\n ): BuildStepInputValueTypeWithRequired<T, R> {\n if (typeof value === 'object') {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n }\n if (this.allowedValueTypeName === BuildStepInputValueTypeName.STRING) {\n return value as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.NUMBER) {\n return this.parseInputValueToNumber(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else if (this.allowedValueTypeName === BuildStepInputValueTypeName.BOOLEAN) {\n return this.parseInputValueToBoolean(value) as BuildStepInputValueTypeWithRequired<T, R>;\n } else {\n return this.parseInputValueToObject(value) as BuildStepInputValueTypeWithRequired<T, R>;\n }\n }\n\n private parseInputValueToNumber(value: string): number {\n const numberValue = Number(value);\n if (Number.isNaN(numberValue)) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n return numberValue;\n }\n\n private parseInputValueToBoolean(value: string): boolean {\n if (value === 'true') {\n return true;\n } else if (value === 'false') {\n return false;\n } else {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n }\n\n private parseInputValueToObject(value: string): Record<string, any> {\n try {\n return JSON.parse(value);\n } catch (e: any) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`,\n {\n cause: e,\n }\n );\n }\n }\n}\n\nexport function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById {\n if (inputs === undefined) {\n return {};\n }\n return inputs.reduce((acc, input) => {\n acc[input.id] = input;\n return acc;\n }, {} as BuildStepInputById);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/steps",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.85",
|
|
5
5
|
"main": "./dist_commonjs/index.cjs",
|
|
6
6
|
"types": "./dist_esm/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"node": "20.11.0",
|
|
65
65
|
"yarn": "1.22.21"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "3c991771d9659e737ffcf7449247f85446d2e5e8"
|
|
68
68
|
}
|