@expo/steps 1.0.57 → 1.0.67
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/BuildConfig.cjs +22 -14
- package/dist_commonjs/BuildConfig.d.ts +6 -5
- package/dist_commonjs/BuildConfig.js.map +1 -1
- package/dist_commonjs/BuildConfigParser.cjs +51 -8
- package/dist_commonjs/BuildConfigParser.d.ts +8 -1
- package/dist_commonjs/BuildConfigParser.js.map +1 -1
- package/dist_commonjs/BuildFunction.cjs +0 -3
- package/dist_commonjs/BuildFunction.d.ts +0 -1
- package/dist_commonjs/BuildFunction.js.map +1 -1
- package/dist_commonjs/BuildFunctionGroup.cjs +27 -0
- package/dist_commonjs/BuildFunctionGroup.d.ts +15 -0
- package/dist_commonjs/BuildFunctionGroup.js.map +1 -0
- package/dist_commonjs/BuildStep.cjs +2 -0
- package/dist_commonjs/BuildStep.js.map +1 -1
- package/dist_commonjs/index.cjs +5 -1
- package/dist_commonjs/index.d.ts +2 -0
- package/dist_commonjs/index.js.map +1 -1
- package/dist_commonjs/scripts/runCustomFunction.cjs +2 -0
- package/dist_commonjs/scripts/runCustomFunction.js.map +1 -1
- package/dist_commonjs/utils/customFunction.cjs +1 -0
- package/dist_commonjs/utils/customFunction.js.map +1 -1
- package/dist_commonjs/utils/shell/spawn.cjs +1 -3
- package/dist_commonjs/utils/shell/spawn.d.ts +10 -3
- package/dist_commonjs/utils/shell/spawn.js.map +1 -1
- package/dist_esm/BuildConfig.d.ts +6 -5
- package/dist_esm/BuildConfig.js +20 -12
- package/dist_esm/BuildConfig.js.map +1 -1
- package/dist_esm/BuildConfigParser.d.ts +8 -1
- package/dist_esm/BuildConfigParser.js +52 -9
- package/dist_esm/BuildConfigParser.js.map +1 -1
- package/dist_esm/BuildFunction.d.ts +0 -1
- package/dist_esm/BuildFunction.js +0 -3
- package/dist_esm/BuildFunction.js.map +1 -1
- package/dist_esm/BuildFunctionGroup.d.ts +15 -0
- package/dist_esm/BuildFunctionGroup.js +22 -0
- package/dist_esm/BuildFunctionGroup.js.map +1 -0
- package/dist_esm/BuildStep.js +2 -0
- package/dist_esm/BuildStep.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/scripts/runCustomFunction.js +2 -0
- package/dist_esm/scripts/runCustomFunction.js.map +1 -1
- package/dist_esm/utils/customFunction.js +1 -0
- package/dist_esm/utils/customFunction.js.map +1 -1
- package/dist_esm/utils/shell/spawn.d.ts +10 -3
- package/dist_esm/utils/shell/spawn.js +1 -3
- package/dist_esm/utils/shell/spawn.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AAExB,+BAAoC;AAGpC,2DAAoG;AACpG,6DAK8B;AAC9B,iDAAgD;AAChD,yDAAmF;AACnF,qEAKkC;AAClC,qDAAoD;AACpD,qDAG6B;AAC7B,2CAAoD;AAIpD,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAWD,0CAA0C;AAC1C,MAAM,UAAU,GACd,uFAAuF,CAAC;AAS1F,MAAa,uBAAuB;IAClC,YACkB,EAAU,EACV,WAAmB,EAChB,QAAiB,EACjB,UAA+B;QAHlC,OAAE,GAAF,EAAE,CAAQ;QACV,gBAAW,GAA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lWD,8BAkWC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput.js';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryEnvsDirectoryAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport {\n getSelectedStatusCheckFromIfStatementTemplate,\n interpolateWithInputs,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n SKIPPED = 'skipped',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport type BuildStepFunction = (\n ctx: BuildStepContext,\n {\n inputs,\n outputs,\n env,\n }: { inputs: BuildStepInputById; outputs: BuildStepOutputById; env: BuildStepEnv }\n) => unknown;\n\n// TODO: move to a place common with tests\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/;\n\nexport interface SerializedBuildStepOutputAccessor {\n id: string;\n executed: boolean;\n outputById: Record<string, SerializedBuildStepOutput>;\n displayName: string;\n}\n\nexport class BuildStepOutputAccessor {\n constructor(\n public readonly id: string,\n public readonly displayName: string,\n protected readonly executed: boolean,\n protected readonly outputById: BuildStepOutputById\n ) {}\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public serialize(): SerializedBuildStepOutputAccessor {\n return {\n id: this.id,\n executed: this.executed,\n outputById: Object.fromEntries(\n Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])\n ),\n displayName: this.displayName,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepOutputAccessor\n ): BuildStepOutputAccessor {\n const outputById = Object.fromEntries(\n Object.entries(serialized.outputById).map(([key, value]) => [\n key,\n BuildStepOutput.deserialize(value),\n ])\n );\n return new BuildStepOutputAccessor(\n serialized.id,\n serialized.displayName,\n serialized.executed,\n outputById\n );\n }\n}\n\nexport class BuildStep extends BuildStepOutputAccessor {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell: string;\n public readonly ctx: BuildStepContext;\n public readonly env: BuildStepEnv;\n public readonly ifCondition?: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected readonly outputById: BuildStepOutputById;\n protected executed = false;\n\n public static getNewId(userDefinedId?: string): string {\n return userDefinedId ?? uuidv4();\n }\n\n public static getDisplayName({\n id,\n name,\n command,\n }: {\n id: string;\n name?: string;\n command?: string;\n }): string {\n if (name) {\n return name;\n }\n if (!id.match(UUID_REGEX)) {\n return id;\n }\n if (command) {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return id;\n }\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n displayName,\n inputs,\n outputs,\n command,\n fn,\n workingDirectory: maybeWorkingDirectory,\n shell,\n supportedRuntimePlatforms: maybeSupportedRuntimePlatforms,\n env,\n ifCondition,\n }: {\n id: string;\n name?: string;\n displayName: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command?: string;\n fn?: BuildStepFunction;\n workingDirectory?: string;\n shell?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n env?: BuildStepEnv;\n ifCondition?: string;\n }\n ) {\n assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n const outputById = makeBuildStepOutputByIdMap(outputs);\n super(id, displayName, false, outputById);\n\n this.id = id;\n this.name = name;\n this.displayName = displayName;\n this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;\n this.inputs = inputs;\n this.outputs = outputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? getDefaultShell();\n this.ifCondition = ifCondition;\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n\n const logger = ctx.baseLogger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });\n this.env = env ?? {};\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.displayName}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n if (this.command !== undefined) {\n await this.executeCommandAsync();\n } else {\n await this.exectuteFnAsync();\n }\n\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.displayName}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.ctx.logger.error({ err });\n this.ctx.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.displayName}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n }\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean {\n const defaultStatusCheck = 'success';\n const statusCheck = this.ifCondition\n ? getSelectedStatusCheckFromIfStatementTemplate(this.ifCondition)\n : defaultStatusCheck;\n\n switch (statusCheck) {\n case 'success':\n return !hasAnyPreviousStepsFailed;\n case 'failure':\n return hasAnyPreviousStepsFailed;\n case 'always':\n return true;\n }\n }\n\n public skip(): void {\n this.status = BuildStepStatus.SKIPPED;\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n 'Executing build step \"${this.displayName}\"'\n );\n this.ctx.logger.info(`Skipped build step \"${this.displayName}\"`);\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED },\n `Skipped build step \"${this.displayName}\"`\n );\n }\n\n private async executeCommandAsync(): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n try {\n const command = this.interpolateInputsAndGlobalContextInCommand(this.command, this.inputs);\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);\n this.ctx.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.ctx.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n });\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private async exectuteFnAsync(): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n try {\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n await this.fn(this.ctx, {\n inputs: this.inputById,\n outputs: this.outputById,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private interpolateInputsAndGlobalContextInCommand(\n command: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return this.ctx.global.interpolate(command);\n }\n const vars = inputs.reduce(\n (acc, input) => {\n acc[input.id] =\n typeof input.value === 'object'\n ? JSON.stringify(input.value)\n : input.value?.toString() ?? '';\n return acc;\n },\n {} as Record<string, string>\n );\n const valueInterpolatedWithGlobalContext = this.ctx.global.interpolate(command);\n return interpolateWithInputs(valueInterpolatedWithGlobalContext, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of this.outputs ?? []) {\n try {\n const value = output.value;\n this.ctx.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.ctx.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {\n metadata: { ids: nonSetRequiredOutputIds },\n });\n }\n }\n\n private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> {\n const filenames = await fs.readdir(envsDir);\n\n const entries = await Promise.all(\n filenames.map(async (basename) => {\n const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');\n return [basename, rawContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private getScriptEnv({\n envsDir,\n outputsDir,\n }: {\n envsDir: string;\n outputsDir: string;\n }): Record<string, string> {\n const env = { ...this.ctx.global.env, ...this.env };\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_ENVS_DIR: envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildStep.js","sourceRoot":"","sources":["../src/BuildStep.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AAExB,+BAAoC;AAGpC,2DAAoG;AACpG,6DAK8B;AAC9B,iDAAgD;AAChD,yDAAmF;AACnF,qEAKkC;AAClC,qDAAoD;AACpD,qDAG6B;AAC7B,2CAAoD;AAIpD,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;AACrB,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC5B,+CAAyB,CAAA;IACzB,2CAAqB,CAAA;AACvB,CAAC,EAHW,kBAAkB,kCAAlB,kBAAkB,QAG7B;AAWD,0CAA0C;AAC1C,MAAM,UAAU,GACd,uFAAuF,CAAC;AAS1F,MAAa,uBAAuB;IAClC,YACkB,EAAU,EACV,WAAmB,EAChB,QAAiB,EAC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AAU;YACpC,qBAAqB,EAAE,OAAO;YAC9B,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF;AApWD,8BAoWC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput.js';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryEnvsDirectoryAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport {\n getSelectedStatusCheckFromIfStatementTemplate,\n interpolateWithInputs,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n SKIPPED = 'skipped',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport type BuildStepFunction = (\n ctx: BuildStepContext,\n {\n inputs,\n outputs,\n env,\n }: { inputs: BuildStepInputById; outputs: BuildStepOutputById; env: BuildStepEnv }\n) => unknown;\n\n// TODO: move to a place common with tests\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/;\n\nexport interface SerializedBuildStepOutputAccessor {\n id: string;\n executed: boolean;\n outputById: Record<string, SerializedBuildStepOutput>;\n displayName: string;\n}\n\nexport class BuildStepOutputAccessor {\n constructor(\n public readonly id: string,\n public readonly displayName: string,\n protected readonly executed: boolean,\n protected readonly outputById: BuildStepOutputById\n ) {}\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public serialize(): SerializedBuildStepOutputAccessor {\n return {\n id: this.id,\n executed: this.executed,\n outputById: Object.fromEntries(\n Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])\n ),\n displayName: this.displayName,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepOutputAccessor\n ): BuildStepOutputAccessor {\n const outputById = Object.fromEntries(\n Object.entries(serialized.outputById).map(([key, value]) => [\n key,\n BuildStepOutput.deserialize(value),\n ])\n );\n return new BuildStepOutputAccessor(\n serialized.id,\n serialized.displayName,\n serialized.executed,\n outputById\n );\n }\n}\n\nexport class BuildStep extends BuildStepOutputAccessor {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell: string;\n public readonly ctx: BuildStepContext;\n public readonly env: BuildStepEnv;\n public readonly ifCondition?: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected readonly outputById: BuildStepOutputById;\n protected executed = false;\n\n public static getNewId(userDefinedId?: string): string {\n return userDefinedId ?? uuidv4();\n }\n\n public static getDisplayName({\n id,\n name,\n command,\n }: {\n id: string;\n name?: string;\n command?: string;\n }): string {\n if (name) {\n return name;\n }\n if (!id.match(UUID_REGEX)) {\n return id;\n }\n if (command) {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return id;\n }\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n displayName,\n inputs,\n outputs,\n command,\n fn,\n workingDirectory: maybeWorkingDirectory,\n shell,\n supportedRuntimePlatforms: maybeSupportedRuntimePlatforms,\n env,\n ifCondition,\n }: {\n id: string;\n name?: string;\n displayName: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command?: string;\n fn?: BuildStepFunction;\n workingDirectory?: string;\n shell?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n env?: BuildStepEnv;\n ifCondition?: string;\n }\n ) {\n assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n const outputById = makeBuildStepOutputByIdMap(outputs);\n super(id, displayName, false, outputById);\n\n this.id = id;\n this.name = name;\n this.displayName = displayName;\n this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;\n this.inputs = inputs;\n this.outputs = outputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? getDefaultShell();\n this.ifCondition = ifCondition;\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n\n const logger = ctx.baseLogger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });\n this.env = env ?? {};\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.displayName}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n if (this.command !== undefined) {\n await this.executeCommandAsync();\n } else {\n await this.exectuteFnAsync();\n }\n\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.displayName}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.ctx.logger.error({ err });\n this.ctx.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.displayName}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n }\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean {\n const defaultStatusCheck = 'success';\n const statusCheck = this.ifCondition\n ? getSelectedStatusCheckFromIfStatementTemplate(this.ifCondition)\n : defaultStatusCheck;\n\n switch (statusCheck) {\n case 'success':\n return !hasAnyPreviousStepsFailed;\n case 'failure':\n return hasAnyPreviousStepsFailed;\n case 'always':\n return true;\n }\n }\n\n public skip(): void {\n this.status = BuildStepStatus.SKIPPED;\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n 'Executing build step \"${this.displayName}\"'\n );\n this.ctx.logger.info(`Skipped build step \"${this.displayName}\"`);\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED },\n `Skipped build step \"${this.displayName}\"`\n );\n }\n\n private async executeCommandAsync(): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n try {\n const command = this.interpolateInputsAndGlobalContextInCommand(this.command, this.inputs);\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);\n this.ctx.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.ctx.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n // stdin is /dev/null, std{out,err} are piped into logger.\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private async exectuteFnAsync(): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n try {\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n await this.fn(this.ctx, {\n inputs: this.inputById,\n outputs: this.outputById,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private interpolateInputsAndGlobalContextInCommand(\n command: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return this.ctx.global.interpolate(command);\n }\n const vars = inputs.reduce(\n (acc, input) => {\n acc[input.id] =\n typeof input.value === 'object'\n ? JSON.stringify(input.value)\n : input.value?.toString() ?? '';\n return acc;\n },\n {} as Record<string, string>\n );\n const valueInterpolatedWithGlobalContext = this.ctx.global.interpolate(command);\n return interpolateWithInputs(valueInterpolatedWithGlobalContext, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of this.outputs ?? []) {\n try {\n const value = output.value;\n this.ctx.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.ctx.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {\n metadata: { ids: nonSetRequiredOutputIds },\n });\n }\n }\n\n private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> {\n const filenames = await fs.readdir(envsDir);\n\n const entries = await Promise.all(\n filenames.map(async (basename) => {\n const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');\n return [basename, rawContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private getScriptEnv({\n envsDir,\n outputsDir,\n }: {\n envsDir: string;\n outputsDir: string;\n }): Record<string, string> {\n const env = { ...this.ctx.global.env, ...this.env };\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_ENVS_DIR: envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
|
package/dist_commonjs/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.errors = exports.BuildWorkflow = exports.BuildStepGlobalContext = exports.BuildStepOutput = exports.BuildStepInputValueTypeName = exports.BuildStepInput = exports.BuildRuntimePlatform = exports.BuildFunction = exports.BuildConfigParser = exports.readAndValidateBuildConfigAsync = exports.BuildStepContext = void 0;
|
|
26
|
+
exports.errors = exports.BuildStep = exports.BuildFunctionGroup = exports.BuildWorkflow = exports.BuildStepGlobalContext = exports.BuildStepOutput = exports.BuildStepInputValueTypeName = exports.BuildStepInput = exports.BuildRuntimePlatform = exports.BuildFunction = exports.BuildConfigParser = exports.readAndValidateBuildConfigAsync = exports.BuildStepContext = void 0;
|
|
27
27
|
var BuildStepContext_js_1 = require("./BuildStepContext.cjs");
|
|
28
28
|
Object.defineProperty(exports, "BuildStepContext", { enumerable: true, get: function () { return BuildStepContext_js_1.BuildStepContext; } });
|
|
29
29
|
var BuildConfig_js_1 = require("./BuildConfig.cjs");
|
|
@@ -43,5 +43,9 @@ var BuildStepContext_js_2 = require("./BuildStepContext.cjs");
|
|
|
43
43
|
Object.defineProperty(exports, "BuildStepGlobalContext", { enumerable: true, get: function () { return BuildStepContext_js_2.BuildStepGlobalContext; } });
|
|
44
44
|
var BuildWorkflow_js_1 = require("./BuildWorkflow.cjs");
|
|
45
45
|
Object.defineProperty(exports, "BuildWorkflow", { enumerable: true, get: function () { return BuildWorkflow_js_1.BuildWorkflow; } });
|
|
46
|
+
var BuildFunctionGroup_js_1 = require("./BuildFunctionGroup.cjs");
|
|
47
|
+
Object.defineProperty(exports, "BuildFunctionGroup", { enumerable: true, get: function () { return BuildFunctionGroup_js_1.BuildFunctionGroup; } });
|
|
48
|
+
var BuildStep_js_1 = require("./BuildStep.cjs");
|
|
49
|
+
Object.defineProperty(exports, "BuildStep", { enumerable: true, get: function () { return BuildStep_js_1.BuildStep; } });
|
|
46
50
|
exports.errors = __importStar(require("./errors.cjs"));
|
|
47
51
|
//# sourceMappingURL=index.js.map
|
package/dist_commonjs/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@ export { BuildStepOutput } from './BuildStepOutput.js';
|
|
|
8
8
|
export { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';
|
|
9
9
|
export { BuildWorkflow } from './BuildWorkflow.js';
|
|
10
10
|
export { BuildStepEnv } from './BuildStepEnv.js';
|
|
11
|
+
export { BuildFunctionGroup } from './BuildFunctionGroup.js';
|
|
12
|
+
export { BuildStep } from './BuildStep.js';
|
|
11
13
|
export * as errors from './errors.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,mDAAmE;AAA1D,iIAAA,+BAA+B,OAAA;AACxC,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,yDAAkF;AAAzE,mHAAA,cAAc,OAAA;AAAE,gIAAA,2BAA2B,OAAA;AACpD,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,6DAA6F;AAApF,6HAAA,sBAAsB,OAAA;AAC/B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,sDAAsC","sourcesContent":["export { BuildStepContext } from './BuildStepContext.js';\nexport { readAndValidateBuildConfigAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport { BuildStepEnv } from './BuildStepEnv.js';\nexport * as errors from './errors.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAAyD;AAAhD,uHAAA,gBAAgB,OAAA;AACzB,mDAAmE;AAA1D,iIAAA,+BAA+B,OAAA;AACxC,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AACtB,qEAAiE;AAAxD,+HAAA,oBAAoB,OAAA;AAC7B,yDAAkF;AAAzE,mHAAA,cAAc,OAAA;AAAE,gIAAA,2BAA2B,OAAA;AACpD,2DAAuD;AAA9C,qHAAA,eAAe,OAAA;AACxB,6DAA6F;AAApF,6HAAA,sBAAsB,OAAA;AAC/B,uDAAmD;AAA1C,iHAAA,aAAa,OAAA;AAEtB,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAClB,sDAAsC","sourcesContent":["export { BuildStepContext } from './BuildStepContext.js';\nexport { readAndValidateBuildConfigAsync } from './BuildConfig.js';\nexport { BuildConfigParser } from './BuildConfigParser.js';\nexport { BuildFunction } from './BuildFunction.js';\nexport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nexport { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';\nexport { BuildStepOutput } from './BuildStepOutput.js';\nexport { BuildStepGlobalContext, ExternalBuildContextProvider } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport { BuildStepEnv } from './BuildStepEnv.js';\nexport { BuildFunctionGroup } from './BuildFunctionGroup.js';\nexport { BuildStep } from './BuildStep.js';\nexport * as errors from './errors.js';\n"]}
|
|
@@ -89,6 +89,7 @@ async function runCustomJsFunctionAsync() {
|
|
|
89
89
|
(0, assert_1.default)(output.value, 'output.value is required');
|
|
90
90
|
promises.push((0, spawn_js_1.spawnAsync)('set-output', [output.id, output.value], {
|
|
91
91
|
env,
|
|
92
|
+
stdio: 'pipe',
|
|
92
93
|
}));
|
|
93
94
|
}
|
|
94
95
|
}
|
|
@@ -97,6 +98,7 @@ async function runCustomJsFunctionAsync() {
|
|
|
97
98
|
if (envValue !== envBefore[envName] && envValue) {
|
|
98
99
|
promises.push((0, spawn_js_1.spawnAsync)('set-env', [envName, envValue], {
|
|
99
100
|
env,
|
|
101
|
+
stdio: 'pipe',
|
|
100
102
|
}));
|
|
101
103
|
}
|
|
102
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runC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AAQ,EAAE,CAAC;YACpB,IAAA,gBAAM,EAAC,MAAM,CAAC,KAAK,EAAE,0BAA0B,CAAC,CAAC;YACjD,QAAQ,CAAC,IAAI,CACX,IAAA,qBAAU,EAAC,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE;gBAClD,GAAG;gBACH,KAAK,EAAE,MAAM;aACd,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,QAAQ,KAAK,SAAS,CAAC,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;YAChD,QAAQ,CAAC,IAAI,CACX,IAAA,qBAAU,EAAC,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;gBACzC,GAAG;gBACH,KAAK,EAAE,MAAM;aACd,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,KAAK,wBAAwB,EAAE,CAAC","sourcesContent":["import assert from 'assert';\n\nimport { createLogger } from '@expo/logger';\nimport { SpawnPromise, SpawnResult } from '@expo/spawn-async';\nimport cloneDeep from 'lodash.clonedeep';\n\nimport { BuildStepOutput } from '../BuildStepOutput.js';\nimport { BuildStepInput } from '../BuildStepInput.js';\nimport { SerializedCustomBuildFunctionArguments } from '../utils/customFunction.js';\nimport { BuildStepContext } from '../BuildStepContext.js';\nimport { BuildStepFunction } from '../BuildStep.js';\nimport { spawnAsync } from '../utils/shell/spawn.js';\n\nasync function runCustomJsFunctionAsync(): Promise<void> {\n const customJavascriptFunctionModulePath = process.argv[2];\n const functionArgs = process.argv[3];\n\n assert(customJavascriptFunctionModulePath, 'customJavascriptFunctionModulePath is required');\n assert(functionArgs, 'serializedFunctionParams is required');\n\n let serializedFunctionArguments: SerializedCustomBuildFunctionArguments;\n try {\n serializedFunctionArguments = JSON.parse(functionArgs);\n } catch (e) {\n console.error('Failed to parse serializedFunctionParams');\n throw e;\n }\n\n const logger = createLogger({\n name: 'customFunctionLogger',\n streams: [\n {\n type: 'raw',\n stream: {\n write: (rec: any) => {\n if (rec) {\n switch (rec.level) {\n case 20: // Debug level\n if (rec.msg) {\n console.debug(rec.msg);\n }\n break;\n case 30: // Info level\n if (rec.msg) {\n console.log(rec.msg);\n }\n break;\n case 40: // Warn level\n if (rec.msg) {\n console.warn(rec.msg);\n }\n break;\n case 50: // Error level\n case 60: // Fatal level\n if (rec.msg) {\n console.error(rec.msg);\n }\n break;\n default:\n break;\n }\n }\n },\n },\n },\n ],\n });\n\n const ctx = BuildStepContext.deserialize(serializedFunctionArguments.ctx, logger);\n const inputs = Object.fromEntries(\n Object.entries(serializedFunctionArguments.inputs).map(([id, input]) => [\n id,\n BuildStepInput.deserialize(input, logger),\n ])\n );\n const outputs = Object.fromEntries(\n Object.entries(serializedFunctionArguments.outputs).map(([id, output]) => [\n id,\n BuildStepOutput.deserialize(output),\n ])\n );\n const env = serializedFunctionArguments.env;\n const envBefore = cloneDeep(serializedFunctionArguments.env);\n\n let customModule: any;\n try {\n customModule = await require(customJavascriptFunctionModulePath);\n } catch (e) {\n console.error('Failed to load custom function module');\n throw e;\n }\n\n const customJavascriptFunction: BuildStepFunction = customModule.default;\n\n await customJavascriptFunction(ctx, { inputs, outputs, env });\n\n const promises: SpawnPromise<SpawnResult>[] = [];\n for (const output of Object.values(outputs)) {\n if (output.rawValue) {\n assert(output.value, 'output.value is required');\n promises.push(\n spawnAsync('set-output', [output.id, output.value], {\n env,\n stdio: 'pipe',\n })\n );\n }\n }\n for (const envName of Object.keys(env)) {\n const envValue = env[envName];\n if (envValue !== envBefore[envName] && envValue) {\n promises.push(\n spawnAsync('set-env', [envName, envValue], {\n env,\n stdio: 'pipe',\n })\n );\n }\n }\n await Promise.all(promises);\n}\n\nvoid runCustomJsFunctionAsync();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customFunction.js","sourceRoot":"","sources":["../../src/utils/customFunction.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,yCAA0C;AAC1C,wDAA0B;AAQ1B,+CAA8C;AAE9C,MAAM,WAAW,GAAG,IAAA,yBAAa,GAAE,CAAC;AAEvB,QAAA,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,6BAA6B,CAAC,CAAC;AAS1F,SAAgB,wBAAwB,CAAC,2BAAmC;IAC1E,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;QAC7C,IAAI,wBAAwB,GAAG,2BAA2B,CAAC;QAC3D,IAAI,CAAC,CAAC,MAAM,kBAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,EAAE,CAAC;YAC1D,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAC5B,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,sBAAsB,CAAC,EAC/C,wBAAwB,CACzB,CAAC;YACF,wBAAwB,GAAG,cAAI,CAAC,OAAO,CACrC,cAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CACvD,CAAC;QACJ,CAAC;QACD,MAAM,mBAAmB,GAA2C;YAClE,GAAG;YACH,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CACrE;YACD,OAAO,EAAE,MAAM,CAAC,WAAW,C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wB,GAAG,cAAI,CAAC,OAAO,CACrC,cAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CACvD,CAAC;QACJ,CAAC;QACD,MAAM,mBAAmB,GAA2C;YAClE,GAAG;YACH,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CACrE;YACD,OAAO,EAAE,MAAM,CAAC,WAAW,CACzB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CACxE;YACD,GAAG,EAAE,GAAG,CAAC,SAAS,EAAE;SACrB,CAAC;QACF,IAAI,CAAC;YACH,MAAM,IAAA,qBAAU,EACd,MAAM,EACN;gBACE,cAAI,CAAC,IAAI,CAAC,oBAAY,EAAE,uBAAuB,CAAC;gBAChD,wBAAwB;gBACxB,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;aACpC,EACD;gBACE,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,GAAG,EAAE,GAAG,CAAC,gBAAgB;gBACzB,GAAG;gBACH,KAAK,EAAE,MAAM;aACd,CACF,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAzCD,4DAyCC","sourcesContent":["import path from 'path';\n\nimport { createContext } from 'this-file';\nimport fs from 'fs-extra';\n\nimport { BuildStepFunction } from '../BuildStep.js';\nimport { BuildStepEnv } from '../BuildStepEnv.js';\nimport { SerializedBuildStepInput } from '../BuildStepInput.js';\nimport { SerializedBuildStepOutput } from '../BuildStepOutput.js';\nimport { SerializedBuildStepContext } from '../BuildStepContext.js';\n\nimport { spawnAsync } from './shell/spawn.js';\n\nconst thisFileCtx = createContext();\n\nexport const SCRIPTS_PATH = path.join(thisFileCtx.dirname, '../../dist_commonjs/scripts');\n\nexport interface SerializedCustomBuildFunctionArguments {\n env: BuildStepEnv;\n inputs: Record<string, SerializedBuildStepInput>;\n outputs: Record<string, SerializedBuildStepOutput>;\n ctx: SerializedBuildStepContext;\n}\n\nexport function createCustomFunctionCall(rawCustomFunctionModulePath: string): BuildStepFunction {\n return async (ctx, { env, inputs, outputs }) => {\n let customFunctionModulePath = rawCustomFunctionModulePath;\n if (!(await fs.exists(ctx.global.projectSourceDirectory))) {\n const relative = path.relative(\n path.resolve(ctx.global.projectSourceDirectory),\n customFunctionModulePath\n );\n customFunctionModulePath = path.resolve(\n path.join(ctx.global.projectTargetDirectory, relative)\n );\n }\n const serializedArguments: SerializedCustomBuildFunctionArguments = {\n env,\n inputs: Object.fromEntries(\n Object.entries(inputs).map(([id, input]) => [id, input.serialize()])\n ),\n outputs: Object.fromEntries(\n Object.entries(outputs).map(([id, output]) => [id, output.serialize()])\n ),\n ctx: ctx.serialize(),\n };\n try {\n await spawnAsync(\n 'node',\n [\n path.join(SCRIPTS_PATH, 'runCustomFunction.cjs'),\n customFunctionModulePath,\n JSON.stringify(serializedArguments),\n ],\n {\n logger: ctx.logger,\n cwd: ctx.workingDirectory,\n env,\n stdio: 'pipe',\n }\n );\n } catch {\n throw new Error(`Custom function exited with non-zero exit code.`);\n }\n };\n}\n"]}
|
|
@@ -6,15 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.spawnAsync = void 0;
|
|
7
7
|
const logger_1 = require("@expo/logger");
|
|
8
8
|
const spawn_async_1 = __importDefault(require("@expo/spawn-async"));
|
|
9
|
+
// If
|
|
9
10
|
// eslint-disable-next-line async-protect/async-suffix
|
|
10
11
|
function spawnAsync(command, args, allOptions = {
|
|
11
12
|
stdio: 'inherit',
|
|
12
13
|
cwd: process.cwd(),
|
|
13
14
|
}) {
|
|
14
15
|
const { logger, ...options } = allOptions;
|
|
15
|
-
if (logger) {
|
|
16
|
-
options.stdio = 'pipe';
|
|
17
|
-
}
|
|
18
16
|
const promise = (0, spawn_async_1.default)(command, args, options);
|
|
19
17
|
if (logger && promise.child) {
|
|
20
18
|
(0, logger_1.pipeSpawnOutput)(logger, promise.child, options);
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IOType } from 'child_process';
|
|
1
3
|
import { bunyan, PipeMode } from '@expo/logger';
|
|
2
4
|
import { SpawnResult, SpawnPromise, SpawnOptions as SpawnOptionsOriginal } from '@expo/spawn-async';
|
|
3
|
-
type SpawnOptions = SpawnOptionsOriginal & {
|
|
4
|
-
logger?: bunyan;
|
|
5
|
+
type SpawnOptions = Omit<SpawnOptionsOriginal, 'stdio' | 'ignoreStdio'> & {
|
|
5
6
|
lineTransformer?: (line: string) => string | null;
|
|
6
7
|
mode?: PipeMode;
|
|
7
|
-
}
|
|
8
|
+
} & ({
|
|
9
|
+
logger: bunyan;
|
|
10
|
+
stdio: 'pipe' | [IOType, 'pipe', 'pipe', ...IOType[]];
|
|
11
|
+
} | {
|
|
12
|
+
logger?: never;
|
|
13
|
+
stdio?: SpawnOptionsOriginal['stdio'];
|
|
14
|
+
});
|
|
8
15
|
export declare function spawnAsync(command: string, args: string[], allOptions?: SpawnOptions): SpawnPromise<SpawnResult>;
|
|
9
16
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../src/utils/shell/spawn.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"spawn.js","sourceRoot":"","sources":["../../../src/utils/shell/spawn.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAiE;AACjE,oEAI2B;AAoB3B,KAAK;AAEL,sDAAsD;AACtD,SAAgB,UAAU,CACxB,OAAe,EACf,IAAc,EACd,aAA2B;IACzB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;CACnB;IAED,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,UAAU,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAA,qBAAkB,EAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,IAAI,MAAM,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAA,wBAAe,EAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,gCAcC","sourcesContent":["import { IOType } from 'child_process';\n\nimport { pipeSpawnOutput, bunyan, PipeMode } from '@expo/logger';\nimport spawnAsyncOriginal, {\n SpawnResult,\n SpawnPromise,\n SpawnOptions as SpawnOptionsOriginal,\n} from '@expo/spawn-async';\n\n// We omit 'ignoreStdio' to simplify logic -- only 'stdio' governs stdio.\n// We omit 'stdio' here to add further down in a logger-based union.\ntype SpawnOptions = Omit<SpawnOptionsOriginal, 'stdio' | 'ignoreStdio'> & {\n lineTransformer?: (line: string) => string | null;\n mode?: PipeMode;\n} & (\n | {\n // If logger is passed, we require stdio to be pipe.\n logger: bunyan;\n stdio: 'pipe' | [IOType, 'pipe', 'pipe', ...IOType[]];\n }\n | {\n // If logger is not passed, stdio can be anything.\n // Defaults to inherit.\n logger?: never;\n stdio?: SpawnOptionsOriginal['stdio'];\n }\n );\n// If\n\n// eslint-disable-next-line async-protect/async-suffix\nexport function spawnAsync(\n command: string,\n args: string[],\n allOptions: SpawnOptions = {\n stdio: 'inherit',\n cwd: process.cwd(),\n }\n): SpawnPromise<SpawnResult> {\n const { logger, ...options } = allOptions;\n const promise = spawnAsyncOriginal(command, args, options);\n if (logger && promise.child) {\n pipeSpawnOutput(logger, promise.child, options);\n }\n return promise;\n}\n"]}
|
|
@@ -13,7 +13,7 @@ export interface BuildConfig extends BuildFunctionsConfigFile {
|
|
|
13
13
|
steps: BuildStepConfig[];
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
export type BuildStepConfig = BuildStepCommandRun | BuildStepBareCommandRun | BuildStepFunctionCall |
|
|
16
|
+
export type BuildStepConfig = BuildStepCommandRun | BuildStepBareCommandRun | BuildStepFunctionCall | BuildStepBareFunctionOrFunctionGroupCall;
|
|
17
17
|
export type BuildStepCommandRun = {
|
|
18
18
|
run: BuildFunctionCallConfig & {
|
|
19
19
|
outputs?: BuildStepOutputs;
|
|
@@ -26,7 +26,7 @@ export type BuildStepBareCommandRun = {
|
|
|
26
26
|
export type BuildStepFunctionCall = {
|
|
27
27
|
[functionId: string]: BuildFunctionCallConfig;
|
|
28
28
|
};
|
|
29
|
-
export type
|
|
29
|
+
export type BuildStepBareFunctionOrFunctionGroupCall = string;
|
|
30
30
|
export type BuildFunctionCallConfig = {
|
|
31
31
|
id?: string;
|
|
32
32
|
inputs?: BuildStepInputs;
|
|
@@ -62,7 +62,8 @@ export declare const BuildFunctionsConfigFileSchema: Joi.ObjectSchema<BuildFunct
|
|
|
62
62
|
export declare const BuildConfigSchema: Joi.ObjectSchema<BuildConfig>;
|
|
63
63
|
interface BuildConfigValidationParams {
|
|
64
64
|
externalFunctionIds?: string[];
|
|
65
|
-
|
|
65
|
+
externalFunctionGroupsIds?: string[];
|
|
66
|
+
skipNamespacedFunctionsOrFunctionGroupsCheck?: boolean;
|
|
66
67
|
}
|
|
67
68
|
export declare function readAndValidateBuildConfigAsync(configPath: string, params?: BuildConfigValidationParams): Promise<BuildConfig>;
|
|
68
69
|
export declare function readAndValidateBuildFunctionsConfigFileAsync(configPath: string): Promise<BuildFunctionsConfigFile>;
|
|
@@ -72,6 +73,6 @@ export declare function mergeConfigWithImportedFunctions(config: BuildConfig, im
|
|
|
72
73
|
export declare function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun;
|
|
73
74
|
export declare function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun;
|
|
74
75
|
export declare function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall;
|
|
75
|
-
export declare function
|
|
76
|
-
export declare function validateAllFunctionsExist(config: BuildConfig, { externalFunctionIds,
|
|
76
|
+
export declare function isBuildStepBareFunctionOrFunctionGroupCall(step: BuildStepConfig): step is BuildStepBareFunctionOrFunctionGroupCall;
|
|
77
|
+
export declare function validateAllFunctionsExist(config: BuildConfig, { externalFunctionIds, externalFunctionGroupsIds, skipNamespacedFunctionsOrFunctionGroupsCheck, }: BuildConfigValidationParams): void;
|
|
77
78
|
export {};
|
package/dist_esm/BuildConfig.js
CHANGED
|
@@ -5,7 +5,6 @@ import Joi from 'joi';
|
|
|
5
5
|
import YAML from 'yaml';
|
|
6
6
|
import { BuildConfigError, BuildWorkflowError } from './errors.js';
|
|
7
7
|
import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
8
|
-
import { BuildFunction } from './BuildFunction.js';
|
|
9
8
|
import { BuildStepInputValueTypeName, } from './BuildStepInput.js';
|
|
10
9
|
import { BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP, BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX, } from './utils/template.js';
|
|
11
10
|
const BuildFunctionInputsSchema = Joi.array().items(Joi.alternatives().conditional(Joi.ref('.'), {
|
|
@@ -233,32 +232,38 @@ export function isBuildStepBareCommandRun(step) {
|
|
|
233
232
|
export function isBuildStepFunctionCall(step) {
|
|
234
233
|
return Boolean(step) && typeof step === 'object' && !('run' in step);
|
|
235
234
|
}
|
|
236
|
-
export function
|
|
235
|
+
export function isBuildStepBareFunctionOrFunctionGroupCall(step) {
|
|
237
236
|
return typeof step === 'string';
|
|
238
237
|
}
|
|
239
|
-
export function validateAllFunctionsExist(config, { externalFunctionIds = [],
|
|
240
|
-
const
|
|
238
|
+
export function validateAllFunctionsExist(config, { externalFunctionIds = [], externalFunctionGroupsIds = [], skipNamespacedFunctionsOrFunctionGroupsCheck, }) {
|
|
239
|
+
const calledFunctionsOrFunctionGroupsSet = new Set();
|
|
241
240
|
for (const step of config.build.steps) {
|
|
242
241
|
if (typeof step === 'string') {
|
|
243
|
-
|
|
242
|
+
calledFunctionsOrFunctionGroupsSet.add(step);
|
|
244
243
|
}
|
|
245
244
|
else if (step !== null && !('run' in step)) {
|
|
246
245
|
const keys = Object.keys(step);
|
|
247
246
|
assert(keys.length === 1, 'There must be at most one function call in the step (enforced by joi).');
|
|
248
|
-
|
|
247
|
+
calledFunctionsOrFunctionGroupsSet.add(keys[0]);
|
|
249
248
|
}
|
|
250
249
|
}
|
|
251
|
-
const
|
|
250
|
+
const calledFunctionsOrFunctionGroup = Array.from(calledFunctionsOrFunctionGroupsSet);
|
|
252
251
|
const externalFunctionIdsSet = new Set(externalFunctionIds);
|
|
253
|
-
const
|
|
252
|
+
const externalFunctionGroupsIdsSet = new Set(externalFunctionGroupsIds);
|
|
253
|
+
const nonExistentFunctionsOrFunctionGroups = calledFunctionsOrFunctionGroup.filter((calledFunctionOrFunctionGroup) => {
|
|
254
254
|
var _a;
|
|
255
|
-
if (
|
|
255
|
+
if (isFullIdNamespaced(calledFunctionOrFunctionGroup) &&
|
|
256
|
+
skipNamespacedFunctionsOrFunctionGroupsCheck) {
|
|
256
257
|
return false;
|
|
257
258
|
}
|
|
258
|
-
return (!(
|
|
259
|
+
return (!(calledFunctionOrFunctionGroup in ((_a = config.functions) !== null && _a !== void 0 ? _a : {})) &&
|
|
260
|
+
!externalFunctionIdsSet.has(calledFunctionOrFunctionGroup) &&
|
|
261
|
+
!externalFunctionGroupsIdsSet.has(calledFunctionOrFunctionGroup));
|
|
259
262
|
});
|
|
260
|
-
if (
|
|
261
|
-
throw new BuildConfigError(`Calling non-existent functions: ${
|
|
263
|
+
if (nonExistentFunctionsOrFunctionGroups.length > 0) {
|
|
264
|
+
throw new BuildConfigError(`Calling non-existent functions: ${nonExistentFunctionsOrFunctionGroups
|
|
265
|
+
.map((f) => `"${f}"`)
|
|
266
|
+
.join(', ')}.`);
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
269
|
function maybeResolveCustomFunctionRelativePath(dir, customFunctionPath) {
|
|
@@ -267,4 +272,7 @@ function maybeResolveCustomFunctionRelativePath(dir, customFunctionPath) {
|
|
|
267
272
|
}
|
|
268
273
|
return customFunctionPath;
|
|
269
274
|
}
|
|
275
|
+
function isFullIdNamespaced(fullId) {
|
|
276
|
+
return fullId.includes('/');
|
|
277
|
+
}
|
|
270
278
|
//# sourceMappingURL=BuildConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,2BAA2B,GAE5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,yCAAyC,EACzC,kDAAkD,GACnD,MAAM,qBAAqB,CAAC;AA2E7B,MAAM,yBAAyB,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACjD,GAAG,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;IAC3C,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;IAChB,IAAI,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AAC,cAAc,IAAI,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC,CAC7F,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,gBAAgB,CACxB,mCAAmC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3F,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,sCAAsC,CAAC,GAAW,EAAE,kBAA0B;IACrF,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport Joi from 'joi';\nimport YAML from 'yaml';\n\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildFunction } from './BuildFunction.js';\nimport {\n BuildStepInputValueTypeWithRequired,\n BuildStepInputValueTypeName,\n BuildStepInputValueType,\n} from './BuildStepInput.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport {\n BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP,\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n} from './utils/template.js';\n\nexport type BuildFunctions = Record<string, BuildFunctionConfig>;\n\ninterface BuildFunctionsConfigFile {\n configFilesToImport?: string[];\n functions?: BuildFunctions;\n}\n\nexport interface BuildConfig extends BuildFunctionsConfigFile {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n}\n\nexport type BuildStepConfig =\n | BuildStepCommandRun\n | BuildStepBareCommandRun\n | BuildStepFunctionCall\n | BuildStepBareFunctionCall;\n\nexport type BuildStepCommandRun = {\n run: BuildFunctionCallConfig & {\n outputs?: BuildStepOutputs;\n command: string;\n };\n};\nexport type BuildStepBareCommandRun = { run: string };\nexport type BuildStepFunctionCall = {\n [functionId: string]: BuildFunctionCallConfig;\n};\nexport type BuildStepBareFunctionCall = string;\n\nexport type BuildFunctionCallConfig = {\n id?: string;\n inputs?: BuildStepInputs;\n name?: string;\n workingDirectory?: string;\n shell?: string;\n env?: BuildStepEnv;\n if?: string;\n};\n\nexport type BuildStepInputs = Record<string, BuildStepInputValueTypeWithRequired>;\nexport type BuildStepOutputs = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nexport interface BuildFunctionConfig {\n inputs?: BuildFunctionInputs;\n outputs?: BuildFunctionOutputs;\n name?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n shell?: string;\n command?: string;\n path?: string;\n}\n\nexport type BuildFunctionInputs = (\n | string\n | {\n name: string;\n defaultValue?: BuildStepInputValueType;\n allowedValues?: BuildStepInputValueType[];\n required?: boolean;\n allowedValueType: BuildStepInputValueTypeName;\n }\n)[];\nexport type BuildFunctionOutputs = BuildStepOutputs;\n\nconst BuildFunctionInputsSchema = Joi.array().items(\n Joi.alternatives().conditional(Joi.ref('.'), {\n is: Joi.string(),\n then: Joi.string().required(),\n otherwise: Joi.object({\n name: Joi.string().required(),\n defaultValue: Joi.when('allowedValues', {\n is: Joi.exist(),\n then: Joi.valid(Joi.in('allowedValues')).messages({\n 'any.only': '{{#label}} must be one of allowed values',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.string().allow(''),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.alternatives(\n Joi.boolean(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a boolean or reference to output or context value',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.alternatives(\n Joi.number(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a number or reference to output or context value',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.JSON,\n then: Joi.alternatives(\n Joi.object(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a object or reference to output or context value',\n }),\n }),\n allowedValues: Joi.when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.array().items(Joi.string().allow('')),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.array().items(Joi.boolean()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.array().items(Joi.number()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.JSON,\n then: Joi.array().items(Joi.object()),\n }),\n allowedValueType: Joi.string()\n .valid(...Object.values(BuildStepInputValueTypeName))\n .default(BuildStepInputValueTypeName.STRING),\n required: Joi.boolean(),\n })\n .rename('allowed_values', 'allowedValues')\n .rename('default_value', 'defaultValue')\n .rename('type', 'allowedValueType')\n .required(),\n })\n);\n\nconst BuildStepOutputsSchema = Joi.array().items(\n Joi.alternatives().try(\n Joi.string().required(),\n Joi.object({\n name: Joi.string().required(),\n required: Joi.boolean(),\n }).required()\n )\n);\n\nconst BuildFunctionCallSchema = Joi.object({\n id: Joi.string(),\n inputs: Joi.object().pattern(\n Joi.string(),\n Joi.alternatives().try(Joi.string().allow(''), Joi.boolean(), Joi.number(), Joi.object())\n ),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n env: Joi.object().pattern(Joi.string(), Joi.string().allow('')),\n if: Joi.string().pattern(\n BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP,\n 'allowed \"if\" condition values regex'\n ),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\n .invalid(null)\n .when(\n Joi.object().pattern(\n Joi.string().disallow('run').required(),\n Joi.object().unknown().required()\n ),\n {\n then: Joi.object().pattern(\n Joi.string().disallow('run').min(1).required(),\n BuildFunctionCallSchema.required(),\n { matches: Joi.array().length(1) }\n ),\n }\n )\n .when(Joi.object({ run: Joi.object().unknown().required() }), {\n then: Joi.object({\n run: BuildFunctionCallSchema.keys({\n outputs: BuildStepOutputsSchema,\n command: Joi.string().required(),\n }),\n }),\n })\n .when(Joi.object({ run: Joi.string().required() }), {\n then: Joi.object({\n run: Joi.string().min(1).required(),\n }),\n })\n .when(Joi.string(), {\n then: Joi.string().min(1),\n });\n\nconst BuildFunctionConfigSchema = Joi.object({\n name: Joi.string(),\n supportedRuntimePlatforms: Joi.array().items(...Object.values(BuildRuntimePlatform)),\n inputs: BuildFunctionInputsSchema,\n outputs: BuildStepOutputsSchema,\n command: Joi.string(),\n path: Joi.string(),\n shell: Joi.string(),\n})\n .rename('supported_platforms', 'supportedRuntimePlatforms')\n .xor('command', 'path')\n .nand('command', 'path');\n\nexport const BuildFunctionsConfigFileSchema = Joi.object<BuildFunctionsConfigFile>({\n configFilesToImport: Joi.array().items(Joi.string().pattern(/\\.y(a)?ml$/)),\n functions: Joi.object().pattern(\n Joi.string()\n .pattern(/^[\\w-]+$/, 'function names')\n .min(1)\n .required()\n .disallow('run'),\n BuildFunctionConfigSchema.required()\n ),\n})\n .rename('import', 'configFilesToImport')\n .required();\n\nexport const BuildConfigSchema = BuildFunctionsConfigFileSchema.append<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array().items(BuildStepConfigSchema.required()).required(),\n }).required(),\n}).required();\n\ninterface BuildConfigValidationParams {\n externalFunctionIds?: string[];\n skipNamespacedFunctionsCheck?: boolean;\n}\n\nexport async function readAndValidateBuildConfigAsync(\n configPath: string,\n params: BuildConfigValidationParams = {}\n): Promise<BuildConfig> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n\n const config = validateConfig(BuildConfigSchema, rawConfig);\n for (const functionName in config.functions) {\n const customFunctionPath = config.functions[functionName].path;\n if (customFunctionPath) {\n config.functions[functionName].path = maybeResolveCustomFunctionRelativePath(\n path.dirname(configPath),\n customFunctionPath\n );\n }\n }\n\n const importedFunctions = await importFunctionsAsync(configPath, config.configFilesToImport);\n mergeConfigWithImportedFunctions(config, importedFunctions);\n validateAllFunctionsExist(config, params);\n return config;\n}\n\nasync function importFunctionsAsync(\n baseConfigPath: string,\n configPathsToImport?: string[]\n): Promise<BuildFunctions> {\n if (!configPathsToImport) {\n return {};\n }\n\n const baseConfigDir = path.dirname(baseConfigPath);\n\n const errors: BuildConfigError[] = [];\n const importedFunctions: BuildFunctions = {};\n // this is a set of visited files identified by ABSOLUTE paths\n const visitedFiles = new Set<string>([baseConfigPath]);\n const configFilesToVisit = (configPathsToImport ?? []).map((childConfigRelativePath) =>\n path.resolve(baseConfigDir, childConfigRelativePath)\n );\n while (configFilesToVisit.length > 0) {\n const childConfigPath = configFilesToVisit.shift();\n assert(childConfigPath, 'Guaranteed by loop condition');\n if (visitedFiles.has(childConfigPath)) {\n continue;\n }\n visitedFiles.add(childConfigPath);\n try {\n const childConfig = await readAndValidateBuildFunctionsConfigFileAsync(childConfigPath);\n const childDir = path.dirname(childConfigPath);\n for (const functionName in childConfig.functions) {\n if (!(functionName in importedFunctions)) {\n const f = childConfig.functions[functionName];\n if (f.path) {\n f.path = maybeResolveCustomFunctionRelativePath(childDir, f.path);\n }\n importedFunctions[functionName] = f;\n }\n }\n if (childConfig.configFilesToImport) {\n configFilesToVisit.push(\n ...childConfig.configFilesToImport.map((relativePath) =>\n path.resolve(childDir, relativePath)\n )\n );\n }\n } catch (err) {\n if (err instanceof BuildConfigError) {\n errors.push(err);\n } else {\n throw err;\n }\n }\n }\n if (errors.length > 0) {\n throw new BuildWorkflowError(`Detected build config errors in imported files.`, errors);\n }\n return importedFunctions;\n}\n\nexport async function readAndValidateBuildFunctionsConfigFileAsync(\n configPath: string\n): Promise<BuildFunctionsConfigFile> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n return validateConfig(BuildFunctionsConfigFileSchema, rawConfig);\n}\n\nexport async function readRawBuildConfigAsync(configPath: string): Promise<any> {\n const contents = await fs.readFile(configPath, 'utf-8');\n return YAML.parse(contents);\n}\n\nexport function validateConfig<T>(\n schema: Joi.ObjectSchema<T>,\n config: object,\n configFilePath?: string\n): T {\n const { error, value } = schema.validate(config, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, {\n cause: error,\n ...(configFilePath && { metadata: { configFilePath } }),\n });\n }\n return value;\n}\n\nexport function mergeConfigWithImportedFunctions(\n config: BuildConfig,\n importedFunctions: BuildFunctions\n): void {\n if (Object.keys(importedFunctions).length === 0) {\n return;\n }\n config.functions = config.functions ?? {};\n for (const functionName in importedFunctions) {\n if (!(functionName in config.functions)) {\n config.functions[functionName] = importedFunctions[functionName];\n }\n }\n}\n\nexport function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun {\n return Boolean(step) && typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return Boolean(step) && typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return Boolean(step) && typeof step === 'object' && !('run' in step);\n}\n\nexport function isBuildStepBareFunctionCall(\n step: BuildStepConfig\n): step is BuildStepBareFunctionCall {\n return typeof step === 'string';\n}\n\nexport function validateAllFunctionsExist(\n config: BuildConfig,\n { externalFunctionIds = [], skipNamespacedFunctionsCheck }: BuildConfigValidationParams\n): void {\n const calledFunctionsSet = new Set<string>();\n for (const step of config.build.steps) {\n if (typeof step === 'string') {\n calledFunctionsSet.add(step);\n } else if (step !== null && !('run' in step)) {\n const keys = Object.keys(step);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n calledFunctionsSet.add(keys[0]);\n }\n }\n const calledFunctions = Array.from(calledFunctionsSet);\n const externalFunctionIdsSet = new Set(externalFunctionIds);\n const nonExistentFunctions = calledFunctions.filter((calledFunction) => {\n if (BuildFunction.isFulldIdNamespaced(calledFunction) && skipNamespacedFunctionsCheck) {\n return false;\n }\n return (\n !(calledFunction in (config.functions ?? {})) && !externalFunctionIdsSet.has(calledFunction)\n );\n });\n if (nonExistentFunctions.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctions.map((f) => `\"${f}\"`).join(', ')}.`\n );\n }\n}\n\nfunction maybeResolveCustomFunctionRelativePath(dir: string, customFunctionPath: string): string {\n if (!path.isAbsolute(customFunctionPath)) {\n return path.resolve(dir, customFunctionPath);\n }\n return customFunctionPath;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAEL,2BAA2B,GAE5B,MAAM,qBAAqB,CA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'joi';\nimport YAML from 'yaml';\n\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport {\n BuildStepInputValueTypeWithRequired,\n BuildStepInputValueTypeName,\n BuildStepInputValueType,\n} from './BuildStepInput.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport {\n BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP,\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n} from './utils/template.js';\n\nexport type BuildFunctions = Record<string, BuildFunctionConfig>;\n\ninterface BuildFunctionsConfigFile {\n configFilesToImport?: string[];\n functions?: BuildFunctions;\n}\n\nexport interface BuildConfig extends BuildFunctionsConfigFile {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n}\n\nexport type BuildStepConfig =\n | BuildStepCommandRun\n | BuildStepBareCommandRun\n | BuildStepFunctionCall\n | BuildStepBareFunctionOrFunctionGroupCall;\n\nexport type BuildStepCommandRun = {\n run: BuildFunctionCallConfig & {\n outputs?: BuildStepOutputs;\n command: string;\n };\n};\nexport type BuildStepBareCommandRun = { run: string };\nexport type BuildStepFunctionCall = {\n [functionId: string]: BuildFunctionCallConfig;\n};\nexport type BuildStepBareFunctionOrFunctionGroupCall = string;\n\nexport type BuildFunctionCallConfig = {\n id?: string;\n inputs?: BuildStepInputs;\n name?: string;\n workingDirectory?: string;\n shell?: string;\n env?: BuildStepEnv;\n if?: string;\n};\n\nexport type BuildStepInputs = Record<string, BuildStepInputValueTypeWithRequired>;\nexport type BuildStepOutputs = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nexport interface BuildFunctionConfig {\n inputs?: BuildFunctionInputs;\n outputs?: BuildFunctionOutputs;\n name?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n shell?: string;\n command?: string;\n path?: string;\n}\n\nexport type BuildFunctionInputs = (\n | string\n | {\n name: string;\n defaultValue?: BuildStepInputValueType;\n allowedValues?: BuildStepInputValueType[];\n required?: boolean;\n allowedValueType: BuildStepInputValueTypeName;\n }\n)[];\nexport type BuildFunctionOutputs = BuildStepOutputs;\n\nconst BuildFunctionInputsSchema = Joi.array().items(\n Joi.alternatives().conditional(Joi.ref('.'), {\n is: Joi.string(),\n then: Joi.string().required(),\n otherwise: Joi.object({\n name: Joi.string().required(),\n defaultValue: Joi.when('allowedValues', {\n is: Joi.exist(),\n then: Joi.valid(Joi.in('allowedValues')).messages({\n 'any.only': '{{#label}} must be one of allowed values',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.string().allow(''),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.alternatives(\n Joi.boolean(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a boolean or reference to output or context value',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.alternatives(\n Joi.number(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a number or reference to output or context value',\n }),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.JSON,\n then: Joi.alternatives(\n Joi.object(),\n Joi.string().pattern(\n BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX,\n 'context or output reference regex pattern'\n )\n ).messages({\n 'alternatives.types':\n '{{#label}} must be a object or reference to output or context value',\n }),\n }),\n allowedValues: Joi.when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.array().items(Joi.string().allow('')),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.array().items(Joi.boolean()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.array().items(Joi.number()),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.JSON,\n then: Joi.array().items(Joi.object()),\n }),\n allowedValueType: Joi.string()\n .valid(...Object.values(BuildStepInputValueTypeName))\n .default(BuildStepInputValueTypeName.STRING),\n required: Joi.boolean(),\n })\n .rename('allowed_values', 'allowedValues')\n .rename('default_value', 'defaultValue')\n .rename('type', 'allowedValueType')\n .required(),\n })\n);\n\nconst BuildStepOutputsSchema = Joi.array().items(\n Joi.alternatives().try(\n Joi.string().required(),\n Joi.object({\n name: Joi.string().required(),\n required: Joi.boolean(),\n }).required()\n )\n);\n\nconst BuildFunctionCallSchema = Joi.object({\n id: Joi.string(),\n inputs: Joi.object().pattern(\n Joi.string(),\n Joi.alternatives().try(Joi.string().allow(''), Joi.boolean(), Joi.number(), Joi.object())\n ),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n env: Joi.object().pattern(Joi.string(), Joi.string().allow('')),\n if: Joi.string().pattern(\n BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP,\n 'allowed \"if\" condition values regex'\n ),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\n .invalid(null)\n .when(\n Joi.object().pattern(\n Joi.string().disallow('run').required(),\n Joi.object().unknown().required()\n ),\n {\n then: Joi.object().pattern(\n Joi.string().disallow('run').min(1).required(),\n BuildFunctionCallSchema.required(),\n { matches: Joi.array().length(1) }\n ),\n }\n )\n .when(Joi.object({ run: Joi.object().unknown().required() }), {\n then: Joi.object({\n run: BuildFunctionCallSchema.keys({\n outputs: BuildStepOutputsSchema,\n command: Joi.string().required(),\n }),\n }),\n })\n .when(Joi.object({ run: Joi.string().required() }), {\n then: Joi.object({\n run: Joi.string().min(1).required(),\n }),\n })\n .when(Joi.string(), {\n then: Joi.string().min(1),\n });\n\nconst BuildFunctionConfigSchema = Joi.object({\n name: Joi.string(),\n supportedRuntimePlatforms: Joi.array().items(...Object.values(BuildRuntimePlatform)),\n inputs: BuildFunctionInputsSchema,\n outputs: BuildStepOutputsSchema,\n command: Joi.string(),\n path: Joi.string(),\n shell: Joi.string(),\n})\n .rename('supported_platforms', 'supportedRuntimePlatforms')\n .xor('command', 'path')\n .nand('command', 'path');\n\nexport const BuildFunctionsConfigFileSchema = Joi.object<BuildFunctionsConfigFile>({\n configFilesToImport: Joi.array().items(Joi.string().pattern(/\\.y(a)?ml$/)),\n functions: Joi.object().pattern(\n Joi.string()\n .pattern(/^[\\w-]+$/, 'function names')\n .min(1)\n .required()\n .disallow('run'),\n BuildFunctionConfigSchema.required()\n ),\n})\n .rename('import', 'configFilesToImport')\n .required();\n\nexport const BuildConfigSchema = BuildFunctionsConfigFileSchema.append<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array().items(BuildStepConfigSchema.required()).required(),\n }).required(),\n}).required();\n\ninterface BuildConfigValidationParams {\n externalFunctionIds?: string[];\n externalFunctionGroupsIds?: string[];\n skipNamespacedFunctionsOrFunctionGroupsCheck?: boolean;\n}\n\nexport async function readAndValidateBuildConfigAsync(\n configPath: string,\n params: BuildConfigValidationParams = {}\n): Promise<BuildConfig> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n\n const config = validateConfig(BuildConfigSchema, rawConfig);\n for (const functionName in config.functions) {\n const customFunctionPath = config.functions[functionName].path;\n if (customFunctionPath) {\n config.functions[functionName].path = maybeResolveCustomFunctionRelativePath(\n path.dirname(configPath),\n customFunctionPath\n );\n }\n }\n\n const importedFunctions = await importFunctionsAsync(configPath, config.configFilesToImport);\n mergeConfigWithImportedFunctions(config, importedFunctions);\n validateAllFunctionsExist(config, params);\n return config;\n}\n\nasync function importFunctionsAsync(\n baseConfigPath: string,\n configPathsToImport?: string[]\n): Promise<BuildFunctions> {\n if (!configPathsToImport) {\n return {};\n }\n\n const baseConfigDir = path.dirname(baseConfigPath);\n\n const errors: BuildConfigError[] = [];\n const importedFunctions: BuildFunctions = {};\n // this is a set of visited files identified by ABSOLUTE paths\n const visitedFiles = new Set<string>([baseConfigPath]);\n const configFilesToVisit = (configPathsToImport ?? []).map((childConfigRelativePath) =>\n path.resolve(baseConfigDir, childConfigRelativePath)\n );\n while (configFilesToVisit.length > 0) {\n const childConfigPath = configFilesToVisit.shift();\n assert(childConfigPath, 'Guaranteed by loop condition');\n if (visitedFiles.has(childConfigPath)) {\n continue;\n }\n visitedFiles.add(childConfigPath);\n try {\n const childConfig = await readAndValidateBuildFunctionsConfigFileAsync(childConfigPath);\n const childDir = path.dirname(childConfigPath);\n for (const functionName in childConfig.functions) {\n if (!(functionName in importedFunctions)) {\n const f = childConfig.functions[functionName];\n if (f.path) {\n f.path = maybeResolveCustomFunctionRelativePath(childDir, f.path);\n }\n importedFunctions[functionName] = f;\n }\n }\n if (childConfig.configFilesToImport) {\n configFilesToVisit.push(\n ...childConfig.configFilesToImport.map((relativePath) =>\n path.resolve(childDir, relativePath)\n )\n );\n }\n } catch (err) {\n if (err instanceof BuildConfigError) {\n errors.push(err);\n } else {\n throw err;\n }\n }\n }\n if (errors.length > 0) {\n throw new BuildWorkflowError(`Detected build config errors in imported files.`, errors);\n }\n return importedFunctions;\n}\n\nexport async function readAndValidateBuildFunctionsConfigFileAsync(\n configPath: string\n): Promise<BuildFunctionsConfigFile> {\n const rawConfig = await readRawBuildConfigAsync(configPath);\n return validateConfig(BuildFunctionsConfigFileSchema, rawConfig);\n}\n\nexport async function readRawBuildConfigAsync(configPath: string): Promise<any> {\n const contents = await fs.readFile(configPath, 'utf-8');\n return YAML.parse(contents);\n}\n\nexport function validateConfig<T>(\n schema: Joi.ObjectSchema<T>,\n config: object,\n configFilePath?: string\n): T {\n const { error, value } = schema.validate(config, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, {\n cause: error,\n ...(configFilePath && { metadata: { configFilePath } }),\n });\n }\n return value;\n}\n\nexport function mergeConfigWithImportedFunctions(\n config: BuildConfig,\n importedFunctions: BuildFunctions\n): void {\n if (Object.keys(importedFunctions).length === 0) {\n return;\n }\n config.functions = config.functions ?? {};\n for (const functionName in importedFunctions) {\n if (!(functionName in config.functions)) {\n config.functions[functionName] = importedFunctions[functionName];\n }\n }\n}\n\nexport function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun {\n return Boolean(step) && typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return Boolean(step) && typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return Boolean(step) && typeof step === 'object' && !('run' in step);\n}\n\nexport function isBuildStepBareFunctionOrFunctionGroupCall(\n step: BuildStepConfig\n): step is BuildStepBareFunctionOrFunctionGroupCall {\n return typeof step === 'string';\n}\n\nexport function validateAllFunctionsExist(\n config: BuildConfig,\n {\n externalFunctionIds = [],\n externalFunctionGroupsIds = [],\n skipNamespacedFunctionsOrFunctionGroupsCheck,\n }: BuildConfigValidationParams\n): void {\n const calledFunctionsOrFunctionGroupsSet = new Set<string>();\n for (const step of config.build.steps) {\n if (typeof step === 'string') {\n calledFunctionsOrFunctionGroupsSet.add(step);\n } else if (step !== null && !('run' in step)) {\n const keys = Object.keys(step);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n calledFunctionsOrFunctionGroupsSet.add(keys[0]);\n }\n }\n const calledFunctionsOrFunctionGroup = Array.from(calledFunctionsOrFunctionGroupsSet);\n const externalFunctionIdsSet = new Set(externalFunctionIds);\n const externalFunctionGroupsIdsSet = new Set(externalFunctionGroupsIds);\n const nonExistentFunctionsOrFunctionGroups = calledFunctionsOrFunctionGroup.filter(\n (calledFunctionOrFunctionGroup) => {\n if (\n isFullIdNamespaced(calledFunctionOrFunctionGroup) &&\n skipNamespacedFunctionsOrFunctionGroupsCheck\n ) {\n return false;\n }\n return (\n !(calledFunctionOrFunctionGroup in (config.functions ?? {})) &&\n !externalFunctionIdsSet.has(calledFunctionOrFunctionGroup) &&\n !externalFunctionGroupsIdsSet.has(calledFunctionOrFunctionGroup)\n );\n }\n );\n if (nonExistentFunctionsOrFunctionGroups.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctionsOrFunctionGroups\n .map((f) => `\"${f}\"`)\n .join(', ')}.`\n );\n }\n}\n\nfunction maybeResolveCustomFunctionRelativePath(dir: string, customFunctionPath: string): string {\n if (!path.isAbsolute(customFunctionPath)) {\n return path.resolve(dir, customFunctionPath);\n }\n return customFunctionPath;\n}\n\nfunction isFullIdNamespaced(fullId: string): boolean {\n return fullId.includes('/');\n}\n"]}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { BuildFunction } from './BuildFunction.js';
|
|
2
2
|
import { BuildStepGlobalContext } from './BuildStepContext.js';
|
|
3
3
|
import { BuildWorkflow } from './BuildWorkflow.js';
|
|
4
|
+
import { BuildFunctionGroup } from './BuildFunctionGroup.js';
|
|
4
5
|
export declare class BuildConfigParser {
|
|
5
6
|
private readonly ctx;
|
|
6
7
|
private readonly configPath;
|
|
7
8
|
private readonly externalFunctions?;
|
|
8
|
-
|
|
9
|
+
private readonly externalFunctionGroups?;
|
|
10
|
+
constructor(ctx: BuildStepGlobalContext, { configPath, externalFunctions, externalFunctionGroups, }: {
|
|
9
11
|
configPath: string;
|
|
10
12
|
externalFunctions?: BuildFunction[];
|
|
13
|
+
externalFunctionGroups?: BuildFunctionGroup[];
|
|
11
14
|
});
|
|
12
15
|
parseAsync(): Promise<BuildWorkflow>;
|
|
13
16
|
private createBuildStepFromConfig;
|
|
14
17
|
private createBuildStepFromBuildStepCommandRun;
|
|
15
18
|
private createBuildStepFromBuildStepBareCommandRun;
|
|
19
|
+
private createBuildStepsFromBuildStepBareFunctionGroupCall;
|
|
16
20
|
private createBuildStepFromBuildStepBareFunctionCall;
|
|
21
|
+
private createBuildStepsFromBareBuildStepFunctionOrBareBuildStepFunctionGroupCall;
|
|
17
22
|
private createBuildStepFromBuildStepFunctionCall;
|
|
18
23
|
private createBuildFunctionsFromConfig;
|
|
19
24
|
private createBuildFunctionFromConfig;
|
|
@@ -23,5 +28,7 @@ export declare class BuildConfigParser {
|
|
|
23
28
|
private createBuildStepOutputProvidersFromBuildFunctionOutputs;
|
|
24
29
|
private mergeBuildFunctionsWithExternal;
|
|
25
30
|
private validateExternalFunctions;
|
|
31
|
+
private validateExternalFunctionGroups;
|
|
26
32
|
private getExternalFunctionFullIds;
|
|
33
|
+
private getExternalFunctionGroupFullIds;
|
|
27
34
|
}
|