@expo/steps 1.0.87 → 1.0.90

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.
@@ -83,7 +83,7 @@ const BuildFunctionCallSchema = joi_1.default.object({
83
83
  workingDirectory: joi_1.default.string(),
84
84
  shell: joi_1.default.string(),
85
85
  env: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string().allow('')),
86
- if: joi_1.default.string().pattern(template_js_1.BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP, 'allowed "if" condition values regex'),
86
+ if: joi_1.default.string(),
87
87
  }).rename('working_directory', 'workingDirectory');
88
88
  const BuildStepConfigSchema = joi_1.default.any()
89
89
  .invalid(null)
@@ -1 +1 @@
1
- {"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,2DAA6B;AAC7B,gDAAwB;AAExB,8CAAsB;AACtB,gDAAwB;AAExB,2CAAmE;AACnE,uEAAiE;AACjE,2DAI6B;AAE7B,qDAG6B;AA2E7B,MAAM,yBAAyB,GAAG,aAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACjD,aAAG,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,aAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;IAC3C,EAAE,EAAE,aAAG,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,SAAS,EAAE,aAAG,CAAC,MAAM,CAAC;QACpB,IAAI,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC7B,YAAY,EAAE,aAAG,CAAC,IAAI,CAAC,eAAe,EAAE;YACtC,EAAE,EAAE,aAAG,CAAC,KAAK,EAAE;YACf,IAAI,EAAE,aAAG,CAAC,KAAK,CAAC,aAAG,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,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IACF,IAAI,oCAAoC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,4BAAgB,CACxB,mCAAmC,oCAAoC;aACpE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;aACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;IACJ,CAAC;AACH,CAAC;AA9CD,8DA8CC;AAED,SAAS,sCAAsC,CAAC,GAAW,EAAE,kBAA0B;IACrF,IAAI,CAAC,cAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACzC,OAAO,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc;IACxC,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9B,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 {\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
+ {"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],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GAAG,CAAC,CAAC;AAC9B,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 {\n BuildStepInputValueTypeWithRequired,\n BuildStepInputValueTypeName,\n BuildStepInputValueType,\n} from './BuildStepInput.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX } from './utils/template.js';\n\nexport type BuildFunctions = Record<string, BuildFunctionConfig>;\n\ninterface BuildFunctionsConfigFile {\n configFilesToImport?: string[];\n functions?: BuildFunctions;\n}\n\nexport interface BuildConfig extends BuildFunctionsConfigFile {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n}\n\nexport type BuildStepConfig =\n | BuildStepCommandRun\n | BuildStepBareCommandRun\n | BuildStepFunctionCall\n | 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(),\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"]}
@@ -16,6 +16,7 @@ const BuildTemporaryFiles_js_1 = require("./BuildTemporaryFiles.cjs");
16
16
  const spawn_js_1 = require("./utils/shell/spawn.cjs");
17
17
  const template_js_1 = require("./utils/template.cjs");
18
18
  const errors_js_1 = require("./errors.cjs");
19
+ const jsepEval_js_1 = require("./utils/jsepEval.cjs");
19
20
  var BuildStepStatus;
20
21
  (function (BuildStepStatus) {
21
22
  BuildStepStatus["NEW"] = "new";
@@ -159,20 +160,29 @@ class BuildStep extends BuildStepOutputAccessor {
159
160
  this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform));
160
161
  }
161
162
  shouldExecuteStep(hasAnyPreviousStepsFailed) {
162
- const defaultStatusCheck = 'success';
163
- const statusCheck = this.ifCondition
164
- ? (0, template_js_1.getSelectedStatusCheckFromIfStatementTemplate)(this.ifCondition)
165
- : defaultStatusCheck;
166
- switch (statusCheck) {
167
- case 'success':
168
- return !hasAnyPreviousStepsFailed;
169
- case 'failure':
170
- return hasAnyPreviousStepsFailed;
171
- case 'always':
172
- return true;
173
- case 'never':
174
- return false;
163
+ var _a, _b;
164
+ if (!this.ifCondition) {
165
+ return !hasAnyPreviousStepsFailed;
175
166
  }
167
+ let ifCondition = this.ifCondition;
168
+ if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {
169
+ ifCondition = ifCondition.slice(2, -1);
170
+ }
171
+ return Boolean((0, jsepEval_js_1.jsepEval)(ifCondition, {
172
+ success: () => !hasAnyPreviousStepsFailed,
173
+ failure: () => hasAnyPreviousStepsFailed,
174
+ always: () => true,
175
+ never: () => false,
176
+ env: this.env,
177
+ inputs: (_b = (_a = this.inputs) === null || _a === void 0 ? void 0 : _a.reduce((acc, input) => {
178
+ acc[input.id] = input.value;
179
+ return acc;
180
+ }, {})) !== null && _b !== void 0 ? _b : {},
181
+ eas: {
182
+ runtimePlatform: this.ctx.global.runtimePlatform,
183
+ ...this.ctx.global.staticContext,
184
+ },
185
+ }));
176
186
  }
177
187
  skip() {
178
188
  this.status = BuildStepStatus.SKIPPED;
@@ -183,7 +193,7 @@ class BuildStep extends BuildStepOutputAccessor {
183
193
  async executeCommandAsync() {
184
194
  (0, assert_1.default)(this.command, 'Command must be defined.');
185
195
  try {
186
- const command = this.interpolateInputsAndGlobalContextInCommand(this.command, this.inputs);
196
+ const command = this.interpolateInputsAndGlobalContextInTemplate(this.command, this.inputs);
187
197
  this.ctx.logger.debug(`Interpolated inputs in the command template`);
188
198
  const outputsDir = await (0, BuildTemporaryFiles_js_1.createTemporaryOutputsDirectoryAsync)(this.ctx.global, this.id);
189
199
  this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);
@@ -230,9 +240,9 @@ class BuildStep extends BuildStepOutputAccessor {
230
240
  await (0, BuildTemporaryFiles_js_1.cleanUpStepTemporaryDirectoriesAsync)(this.ctx.global, this.id);
231
241
  }
232
242
  }
233
- interpolateInputsAndGlobalContextInCommand(command, inputs) {
243
+ interpolateInputsAndGlobalContextInTemplate(template, inputs) {
234
244
  if (!inputs) {
235
- return this.ctx.global.interpolate(command);
245
+ return this.ctx.global.interpolate(template);
236
246
  }
237
247
  const vars = inputs.reduce((acc, input) => {
238
248
  var _a, _b;
@@ -242,7 +252,7 @@ class BuildStep extends BuildStepOutputAccessor {
242
252
  : (_b = (_a = input.value) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
243
253
  return acc;
244
254
  }, {});
245
- const valueInterpolatedWithGlobalContext = this.ctx.global.interpolate(command);
255
+ const valueInterpolatedWithGlobalContext = this.ctx.global.interpolate(template);
246
256
  return (0, template_js_1.interpolateWithInputs)(valueInterpolatedWithGlobalContext, vars);
247
257
  }
248
258
  async collectAndValidateOutputsAsync(outputsDir) {
@@ -83,7 +83,7 @@ export declare class BuildStep extends BuildStepOutputAccessor {
83
83
  skip(): void;
84
84
  private executeCommandAsync;
85
85
  private exectuteFnAsync;
86
- private interpolateInputsAndGlobalContextInCommand;
86
+ private interpolateInputsAndGlobalContextInTemplate;
87
87
  private collectAndValidateOutputsAsync;
88
88
  private collectAndUpdateEnvsAsync;
89
89
  private getScriptEnv;
@@ -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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I,WAAW,EAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC;QACtE,OAAO;YACL,GAAG,GAAG;YACN,wBAAwB,EAAE,UAAU;YACpC,qBAAqB,EAAE,OAAO;YAC9B,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF;AAtWD,8BAsWC","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\n\nimport { BuildStepContext, BuildStepGlobalContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputById, makeBuildStepInputByIdMap } from './BuildStepInput.js';\nimport {\n BuildStepOutput,\n BuildStepOutputById,\n SerializedBuildStepOutput,\n makeBuildStepOutputByIdMap,\n} from './BuildStepOutput.js';\nimport { BIN_PATH } from './utils/shell/bin.js';\nimport { getDefaultShell, getShellCommandAndArgs } from './utils/shell/command.js';\nimport {\n cleanUpStepTemporaryDirectoriesAsync,\n createTemporaryEnvsDirectoryAsync,\n createTemporaryOutputsDirectoryAsync,\n saveScriptToTemporaryFileAsync,\n} from './BuildTemporaryFiles.js';\nimport { spawnAsync } from './utils/shell/spawn.js';\nimport {\n getSelectedStatusCheckFromIfStatementTemplate,\n interpolateWithInputs,\n} from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\n\nexport enum BuildStepStatus {\n NEW = 'new',\n IN_PROGRESS = 'in-progress',\n SKIPPED = 'skipped',\n FAIL = 'fail',\n WARNING = 'warning',\n SUCCESS = 'success',\n}\n\nexport enum BuildStepLogMarker {\n START_STEP = 'start-step',\n END_STEP = 'end-step',\n}\n\nexport type BuildStepFunction = (\n ctx: BuildStepContext,\n {\n inputs,\n outputs,\n env,\n }: { inputs: BuildStepInputById; outputs: BuildStepOutputById; env: BuildStepEnv }\n) => unknown;\n\n// TODO: move to a place common with tests\nconst UUID_REGEX =\n /^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$/;\n\nexport interface SerializedBuildStepOutputAccessor {\n id: string;\n executed: boolean;\n outputById: Record<string, SerializedBuildStepOutput>;\n displayName: string;\n}\n\nexport class BuildStepOutputAccessor {\n constructor(\n public readonly id: string,\n public readonly displayName: string,\n protected readonly executed: boolean,\n protected readonly outputById: BuildStepOutputById\n ) {}\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public serialize(): SerializedBuildStepOutputAccessor {\n return {\n id: this.id,\n executed: this.executed,\n outputById: Object.fromEntries(\n Object.entries(this.outputById).map(([key, value]) => [key, value.serialize()])\n ),\n displayName: this.displayName,\n };\n }\n\n public static deserialize(\n serialized: SerializedBuildStepOutputAccessor\n ): BuildStepOutputAccessor {\n const outputById = Object.fromEntries(\n Object.entries(serialized.outputById).map(([key, value]) => [\n key,\n BuildStepOutput.deserialize(value),\n ])\n );\n return new BuildStepOutputAccessor(\n serialized.id,\n serialized.displayName,\n serialized.executed,\n outputById\n );\n }\n}\n\nexport class BuildStep extends BuildStepOutputAccessor {\n public readonly id: string;\n public readonly name?: string;\n public readonly displayName: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputs?: BuildStepInput[];\n public readonly outputs?: BuildStepOutput[];\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell: string;\n public readonly ctx: BuildStepContext;\n public readonly env: BuildStepEnv;\n public readonly ifCondition?: string;\n public status: BuildStepStatus;\n\n private readonly internalId: string;\n private readonly inputById: BuildStepInputById;\n protected readonly outputById: BuildStepOutputById;\n protected executed = false;\n\n public static getNewId(userDefinedId?: string): string {\n return userDefinedId ?? uuidv4();\n }\n\n public static getDisplayName({\n id,\n name,\n command,\n }: {\n id: string;\n name?: string;\n command?: string;\n }): string {\n if (name) {\n return name;\n }\n if (!id.match(UUID_REGEX)) {\n return id;\n }\n if (command) {\n const splits = command.trim().split('\\n');\n for (const split of splits) {\n const trimmed = split.trim();\n if (trimmed && !trimmed.startsWith('#')) {\n return trimmed;\n }\n }\n }\n return id;\n }\n\n constructor(\n ctx: BuildStepGlobalContext,\n {\n id,\n name,\n displayName,\n inputs,\n outputs,\n command,\n fn,\n workingDirectory: maybeWorkingDirectory,\n shell,\n supportedRuntimePlatforms: maybeSupportedRuntimePlatforms,\n env,\n ifCondition,\n }: {\n id: string;\n name?: string;\n displayName: string;\n inputs?: BuildStepInput[];\n outputs?: BuildStepOutput[];\n command?: string;\n fn?: BuildStepFunction;\n workingDirectory?: string;\n shell?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n env?: BuildStepEnv;\n ifCondition?: string;\n }\n ) {\n assert(command !== undefined || fn !== undefined, 'Either command or fn must be defined.');\n assert(!(command !== undefined && fn !== undefined), 'Command and fn cannot be both set.');\n const outputById = makeBuildStepOutputByIdMap(outputs);\n super(id, displayName, false, outputById);\n\n this.id = id;\n this.name = name;\n this.displayName = displayName;\n this.supportedRuntimePlatforms = maybeSupportedRuntimePlatforms;\n this.inputs = inputs;\n this.outputs = outputs;\n this.inputById = makeBuildStepInputByIdMap(inputs);\n this.outputById = outputById;\n this.fn = fn;\n this.command = command;\n this.shell = shell ?? getDefaultShell();\n this.ifCondition = ifCondition;\n this.status = BuildStepStatus.NEW;\n\n this.internalId = uuidv4();\n\n const logger = ctx.baseLogger.child({\n buildStepInternalId: this.internalId,\n buildStepId: this.id,\n buildStepDisplayName: this.displayName,\n });\n this.ctx = ctx.stepCtx({ logger, relativeWorkingDirectory: maybeWorkingDirectory });\n this.env = env ?? {};\n\n ctx.registerStep(this);\n }\n\n public async executeAsync(): Promise<void> {\n try {\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n `Executing build step \"${this.displayName}\"`\n );\n this.status = BuildStepStatus.IN_PROGRESS;\n\n if (this.command !== undefined) {\n await this.executeCommandAsync();\n } else {\n await this.exectuteFnAsync();\n }\n\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SUCCESS },\n `Finished build step \"${this.displayName}\" successfully`\n );\n this.status = BuildStepStatus.SUCCESS;\n } catch (err) {\n this.ctx.logger.error({ err });\n this.ctx.logger.error(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.FAIL },\n `Build step \"${this.displayName}\" failed`\n );\n this.status = BuildStepStatus.FAIL;\n throw err;\n } finally {\n this.executed = true;\n }\n }\n\n public hasOutputParameter(name: string): boolean {\n return name in this.outputById;\n }\n\n public getOutputValueByName(name: string): string | undefined {\n if (!this.executed) {\n throw new BuildStepRuntimeError(\n `Failed getting output \"${name}\" from step \"${this.displayName}\". The step has not been executed yet.`\n );\n }\n if (!this.hasOutputParameter(name)) {\n throw new BuildStepRuntimeError(`Step \"${this.displayName}\" does not have output \"${name}\".`);\n }\n return this.outputById[name].value;\n }\n\n public canBeRunOnRuntimePlatform(): boolean {\n return (\n !this.supportedRuntimePlatforms ||\n this.supportedRuntimePlatforms.includes(this.ctx.global.runtimePlatform)\n );\n }\n\n public shouldExecuteStep(hasAnyPreviousStepsFailed: boolean): boolean {\n const defaultStatusCheck = 'success';\n const statusCheck = this.ifCondition\n ? getSelectedStatusCheckFromIfStatementTemplate(this.ifCondition)\n : defaultStatusCheck;\n\n switch (statusCheck) {\n case 'success':\n return !hasAnyPreviousStepsFailed;\n case 'failure':\n return hasAnyPreviousStepsFailed;\n case 'always':\n return true;\n case 'never':\n return false;\n }\n }\n\n public skip(): void {\n this.status = BuildStepStatus.SKIPPED;\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.START_STEP },\n 'Executing build step \"${this.displayName}\"'\n );\n this.ctx.logger.info(`Skipped build step \"${this.displayName}\"`);\n this.ctx.logger.info(\n { marker: BuildStepLogMarker.END_STEP, result: BuildStepStatus.SKIPPED },\n `Skipped build step \"${this.displayName}\"`\n );\n }\n\n private async executeCommandAsync(): Promise<void> {\n assert(this.command, 'Command must be defined.');\n\n try {\n const command = this.interpolateInputsAndGlobalContextInCommand(this.command, this.inputs);\n this.ctx.logger.debug(`Interpolated inputs in the command template`);\n\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n const scriptPath = await saveScriptToTemporaryFileAsync(this.ctx.global, this.id, command);\n this.ctx.logger.debug(`Saved script to ${scriptPath}`);\n\n const { command: shellCommand, args } = getShellCommandAndArgs(this.shell, scriptPath);\n this.ctx.logger.debug(\n `Executing script: ${shellCommand}${args !== undefined ? ` ${args.join(' ')}` : ''}`\n );\n await spawnAsync(shellCommand, args ?? [], {\n cwd: this.ctx.workingDirectory,\n logger: this.ctx.logger,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n // stdin is /dev/null, std{out,err} are piped into logger.\n stdio: ['ignore', 'pipe', 'pipe'],\n });\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private async exectuteFnAsync(): Promise<void> {\n assert(this.fn, 'Function (fn) must be defined');\n\n try {\n const outputsDir = await createTemporaryOutputsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(`Created temporary directory for step outputs: ${outputsDir}`);\n\n const envsDir = await createTemporaryEnvsDirectoryAsync(this.ctx.global, this.id);\n this.ctx.logger.debug(\n `Created temporary directory for step environment variables: ${outputsDir}`\n );\n\n await this.fn(this.ctx, {\n inputs: this.inputById,\n outputs: this.outputById,\n env: this.getScriptEnv({ outputsDir, envsDir }),\n });\n\n this.ctx.logger.debug(`Script completed successfully`);\n\n await this.collectAndValidateOutputsAsync(outputsDir);\n await this.collectAndUpdateEnvsAsync(envsDir);\n this.ctx.logger.debug('Finished collecting output paramters');\n } finally {\n await cleanUpStepTemporaryDirectoriesAsync(this.ctx.global, this.id);\n }\n }\n\n private interpolateInputsAndGlobalContextInCommand(\n command: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return this.ctx.global.interpolate(command);\n }\n const vars = inputs.reduce(\n (acc, input) => {\n acc[input.id] =\n typeof input.value === 'object'\n ? JSON.stringify(input.value)\n : input.value?.toString() ?? '';\n return acc;\n },\n {} as Record<string, string>\n );\n const valueInterpolatedWithGlobalContext = this.ctx.global.interpolate(command);\n return interpolateWithInputs(valueInterpolatedWithGlobalContext, vars);\n }\n\n private async collectAndValidateOutputsAsync(outputsDir: string): Promise<void> {\n const files = await fs.readdir(outputsDir);\n\n const nonDefinedOutputIds: string[] = [];\n for (const outputId of files) {\n if (!(outputId in this.outputById)) {\n nonDefinedOutputIds.push(outputId);\n } else {\n const file = path.join(outputsDir, outputId);\n const rawContents = await fs.readFile(file, 'utf-8');\n const value = rawContents.trim();\n this.outputById[outputId].set(value);\n }\n }\n\n if (nonDefinedOutputIds.length > 0) {\n const idsString = nonDefinedOutputIds.map((i) => `\"${i}\"`).join(', ');\n this.ctx.logger.warn(`Some outputs are not defined in step config: ${idsString}`);\n }\n\n const nonSetRequiredOutputIds: string[] = [];\n for (const output of this.outputs ?? []) {\n try {\n const value = output.value;\n this.ctx.logger.debug(`Output parameter \"${output.id}\" is set to \"${value}\"`);\n } catch (err) {\n this.ctx.logger.debug({ err }, `Getting value for output parameter \"${output.id}\" failed.`);\n nonSetRequiredOutputIds.push(output.id);\n }\n }\n if (nonSetRequiredOutputIds.length > 0) {\n const idsString = nonSetRequiredOutputIds.map((i) => `\"${i}\"`).join(', ');\n throw new BuildStepRuntimeError(`Some required outputs have not been set: ${idsString}`, {\n metadata: { ids: nonSetRequiredOutputIds },\n });\n }\n }\n\n private async collectAndUpdateEnvsAsync(envsDir: string): Promise<void> {\n const filenames = await fs.readdir(envsDir);\n\n const entries = await Promise.all(\n filenames.map(async (basename) => {\n const rawContents = await fs.readFile(path.join(envsDir, basename), 'utf-8');\n return [basename, rawContents];\n })\n );\n this.ctx.global.updateEnv({\n ...this.ctx.global.env,\n ...Object.fromEntries(entries),\n });\n }\n\n private getScriptEnv({\n envsDir,\n outputsDir,\n }: {\n envsDir: string;\n outputsDir: string;\n }): Record<string, string> {\n const env = { ...this.ctx.global.env, ...this.env };\n const currentPath = env.PATH ?? process.env.PATH;\n const newPath = currentPath ? `${BIN_PATH}:${currentPath}` : BIN_PATH;\n return {\n ...env,\n __EXPO_STEPS_OUTPUTS_DIR: outputsDir,\n __EXPO_STEPS_ENVS_DIR: envsDir,\n __EXPO_STEPS_WORKING_DIRECTORY: this.ctx.workingDirectory,\n PATH: newPath,\n };\n }\n}\n"]}
1
+ {"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,qDAA4D;AAC5D,2CAAoD;AAGpD,qDAA+C;AAE/C,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,8CAA2B,CAAA;IAC3B,sCAAmB,CAAA;IACnB,gCAAa,CAAA;IACb,sCAAmB,CA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AAM,kBAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE5C,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YAC/B,MAAM,WAAW,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;YAC7E,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QACjC,CAAC,CAAC,CACH,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;YACxB,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG;YACtB,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,EACnB,OAAO,EACP,UAAU,GAIX;;QACC,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACpD,MAAM,WAAW,GAAG,MAAA,GAAG,CAAC,IAAI,mCAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,iBAAQ,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,iBAAQ,CAAC;QACtE,OAAO;YACL,GAAG,GAAG;YACN,wBAAwB,EAAE,UAAU;YACpC,qBAAqB,EAAE,OAAO;YAC9B,8BAA8B,EAAE,IAAI,CAAC,GAAG,CAAC,gBAAgB;YACzD,IAAI,EAAE,OAAO;SACd,CAAC;IACJ,CAAC;CACF;AAtXD,8BAsXC","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 { interpolateWithInputs } from './utils/template.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { BuildStepEnv } from './BuildStepEnv.js';\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { jsepEval } from './utils/jsepEval.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 if (!this.ifCondition) {\n return !hasAnyPreviousStepsFailed;\n }\n\n let ifCondition = this.ifCondition;\n\n if (ifCondition.startsWith('${') && ifCondition.endsWith('}')) {\n ifCondition = ifCondition.slice(2, -1);\n }\n\n return Boolean(\n jsepEval(ifCondition, {\n success: () => !hasAnyPreviousStepsFailed,\n failure: () => hasAnyPreviousStepsFailed,\n always: () => true,\n never: () => false,\n env: this.env,\n inputs:\n this.inputs?.reduce(\n (acc, input) => {\n acc[input.id] = input.value;\n return acc;\n },\n {} as Record<string, unknown>\n ) ?? {},\n eas: {\n runtimePlatform: this.ctx.global.runtimePlatform,\n ...this.ctx.global.staticContext,\n },\n })\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.interpolateInputsAndGlobalContextInTemplate(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 interpolateInputsAndGlobalContextInTemplate(\n template: string,\n inputs?: BuildStepInput[]\n ): string {\n if (!inputs) {\n return this.ctx.global.interpolate(template);\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(template);\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"]}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ // https://github.com/Sensative/jsep-eval/blob/master/src/jsep-eval.js
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.jsepEval = void 0;
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const lodash_get_1 = __importDefault(require("lodash.get"));
10
+ const jsep_1 = __importDefault(require("jsep"));
11
+ const binaryOperatorFunctions = {
12
+ '===': (a, b) => a === b,
13
+ '!==': (a, b) => a !== b,
14
+ '==': (a, b) => a == b, // eslint-disable-line
15
+ '!=': (a, b) => a != b, // eslint-disable-line
16
+ '>': (a, b) => a > b,
17
+ '<': (a, b) => a < b,
18
+ '>=': (a, b) => a >= b,
19
+ '<=': (a, b) => a <= b,
20
+ '+': (a, b) => a + b,
21
+ '-': (a, b) => a - b,
22
+ '*': (a, b) => a * b,
23
+ '/': (a, b) => a / b,
24
+ '%': (a, b) => a % b, // remainder
25
+ '**': (a, b) => a ** b, // exponentiation
26
+ '&': (a, b) => a & b, // bitwise AND
27
+ '|': (a, b) => a | b, // bitwise OR
28
+ '^': (a, b) => a ^ b, // bitwise XOR
29
+ '<<': (a, b) => a << b, // left shift
30
+ '>>': (a, b) => a >> b, // sign-propagating right shift
31
+ '>>>': (a, b) => a >>> b, // zero-fill right shift
32
+ // Let's make a home for the logical operators here as well
33
+ '||': (a, b) => a || b,
34
+ '&&': (a, b) => a && b,
35
+ };
36
+ const unaryOperatorFunctions = {
37
+ '!': (a) => !a,
38
+ '~': (a) => ~a, // bitwise NOT
39
+ '+': (a) => +a, // unary plus
40
+ '-': (a) => -a, // unary negation
41
+ '++': (a) => ++a, // increment
42
+ '--': (a) => --a, // decrement
43
+ };
44
+ function isValid(expression, types) {
45
+ return types.includes(expression.type);
46
+ }
47
+ const getParameterPath = (node, context) => {
48
+ // it's a MEMBER expression
49
+ // EXAMPLES: a[b] (computed)
50
+ // a.b (not computed)
51
+ const computed = node.computed;
52
+ const object = node.object;
53
+ const property = node.property;
54
+ // object is either 'IDENTIFIER', 'MEMBER', or 'THIS'
55
+ (0, assert_1.default)(isValid(object, ['MemberExpression', 'Identifier', 'ThisExpression']), 'Invalid object type');
56
+ (0, assert_1.default)(property, 'Member expression property is missing');
57
+ let objectPath = '';
58
+ if (object.type === 'ThisExpression') {
59
+ objectPath = '';
60
+ }
61
+ else if (isValid(object, ['Identifier'])) {
62
+ objectPath = object.name;
63
+ }
64
+ else {
65
+ objectPath = getParameterPath(object, context);
66
+ }
67
+ if (computed) {
68
+ // if computed -> evaluate anew
69
+ const propertyPath = evaluateExpressionNode(property, context);
70
+ return objectPath + '[' + propertyPath + ']';
71
+ }
72
+ else if (isValid(property, ['Identifier'])) {
73
+ return (objectPath ? objectPath + '.' : '') + property.name;
74
+ }
75
+ else {
76
+ (0, assert_1.default)(isValid(property, ['MemberExpression']), 'Invalid object type');
77
+ const propertyPath = getParameterPath(property, context);
78
+ return (objectPath ? objectPath + '.' : '') + propertyPath;
79
+ }
80
+ };
81
+ const evaluateExpressionNode = (node, context) => {
82
+ switch (node.type) {
83
+ case 'Literal': {
84
+ return node.value;
85
+ }
86
+ case 'ThisExpression': {
87
+ return context;
88
+ }
89
+ case 'Compound': {
90
+ const compoundNode = node;
91
+ const expressions = compoundNode.body.map((el) => evaluateExpressionNode(el, context));
92
+ return expressions.pop();
93
+ }
94
+ case 'UnaryExpression': {
95
+ const unaryNode = node;
96
+ if (!(unaryNode.operator in unaryOperatorFunctions)) {
97
+ throw new Error(`Unsupported unary operator: ${unaryNode.operator}`);
98
+ }
99
+ const operatorFn = unaryOperatorFunctions[unaryNode.operator];
100
+ const argument = evaluateExpressionNode(unaryNode.argument, context);
101
+ return operatorFn(argument);
102
+ }
103
+ case 'BinaryExpression': {
104
+ const binaryNode = node;
105
+ if (!(binaryNode.operator in binaryOperatorFunctions)) {
106
+ throw new Error(`Unsupported binary operator: ${binaryNode.operator}`);
107
+ }
108
+ const operator = binaryOperatorFunctions[binaryNode.operator];
109
+ const left = evaluateExpressionNode(binaryNode.left, context);
110
+ const right = evaluateExpressionNode(binaryNode.right, context);
111
+ return operator(left, right);
112
+ }
113
+ case 'ConditionalExpression': {
114
+ const conditionalNode = node;
115
+ const test = evaluateExpressionNode(conditionalNode.test, context);
116
+ const consequent = evaluateExpressionNode(conditionalNode.consequent, context);
117
+ const alternate = evaluateExpressionNode(conditionalNode.alternate, context);
118
+ return test ? consequent : alternate;
119
+ }
120
+ case 'CallExpression': {
121
+ const allowedCalleeTypes = [
122
+ 'MemberExpression',
123
+ 'Identifier',
124
+ 'ThisExpression',
125
+ ];
126
+ const callNode = node;
127
+ if (!allowedCalleeTypes.includes(callNode.callee.type)) {
128
+ throw new Error(`Invalid function callee type: ${callNode.callee.type}. Expected one of ${allowedCalleeTypes.join(', ')}.`);
129
+ }
130
+ const callee = evaluateExpressionNode(callNode.callee, context);
131
+ const args = callNode.arguments.map((arg) => evaluateExpressionNode(arg, context));
132
+ // eslint-disable-next-line prefer-spread
133
+ return callee.apply(null, args);
134
+ }
135
+ case 'Identifier': {
136
+ const identifier = node.name;
137
+ if (!(identifier in context)) {
138
+ throw new Error(`Invalid identifier "${identifier}". Expected one of ${Object.keys(context).join(', ')}`);
139
+ }
140
+ return (0, lodash_get_1.default)(context, identifier);
141
+ }
142
+ case 'MemberExpression': {
143
+ const path = getParameterPath(node, context);
144
+ return (0, lodash_get_1.default)(context, path);
145
+ }
146
+ case 'ArrayExpression': {
147
+ const elements = node.elements.map((el) => evaluateExpressionNode(el, context));
148
+ return elements;
149
+ }
150
+ default:
151
+ throw new Error(`Unsupported expression type: ${node.type}`);
152
+ }
153
+ };
154
+ const jsepEval = (expression, context) => {
155
+ const tree = (0, jsep_1.default)(expression);
156
+ return evaluateExpressionNode(tree, context !== null && context !== void 0 ? context : {});
157
+ };
158
+ exports.jsepEval = jsepEval;
159
+ //# sourceMappingURL=jsepEval.js.map
@@ -0,0 +1 @@
1
+ export declare const jsepEval: (expression: string, context?: Record<string, unknown>) => any;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsepEval.js","sourceRoot":"","sources":["../../src/utils/jsepEval.ts"],"names":[],"mappings":";AAAA,sEAAsE;;;;;;AAEtE,oDAA4B;AAE5B,4DAA6B;AAC7B,gDAAwB;AAExB,MAAM,uBAAuB,GAAG;IAC9B,KAAK,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;IAClC,KAAK,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;IAClC,IAAI,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,sBAAsB;IACxD,IAAI,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAA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OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAHW,QAAA,QAAQ,YAGnB","sourcesContent":["// https://github.com/Sensative/jsep-eval/blob/master/src/jsep-eval.js\n\nimport assert from 'assert';\n\nimport get from 'lodash.get';\nimport jsep from 'jsep';\n\nconst binaryOperatorFunctions = {\n '===': (a: any, b: any) => a === b,\n '!==': (a: any, b: any) => a !== b,\n '==': (a: any, b: any) => a == b, // eslint-disable-line\n '!=': (a: any, b: any) => a != b, // eslint-disable-line\n '>': (a: any, b: any) => a > b,\n '<': (a: any, b: any) => a < b,\n '>=': (a: any, b: any) => a >= b,\n '<=': (a: any, b: any) => a <= b,\n '+': (a: any, b: any) => a + b,\n '-': (a: any, b: any) => a - b,\n '*': (a: any, b: any) => a * b,\n '/': (a: any, b: any) => a / b,\n '%': (a: any, b: any) => a % b, // remainder\n '**': (a: any, b: any) => a ** b, // exponentiation\n '&': (a: any, b: any) => a & b, // bitwise AND\n '|': (a: any, b: any) => a | b, // bitwise OR\n '^': (a: any, b: any) => a ^ b, // bitwise XOR\n '<<': (a: any, b: any) => a << b, // left shift\n '>>': (a: any, b: any) => a >> b, // sign-propagating right shift\n '>>>': (a: any, b: any) => a >>> b, // zero-fill right shift\n // Let's make a home for the logical operators here as well\n '||': (a: any, b: any) => a || b,\n '&&': (a: any, b: any) => a && b,\n};\ntype BinaryOperator = keyof typeof binaryOperatorFunctions;\n\nconst unaryOperatorFunctions = {\n '!': (a: any) => !a,\n '~': (a: any) => ~a, // bitwise NOT\n '+': (a: any) => +a, // unary plus\n '-': (a: any) => -a, // unary negation\n '++': (a: any) => ++a, // increment\n '--': (a: any) => --a, // decrement\n};\ntype UnaryOperator = keyof typeof unaryOperatorFunctions;\n\nfunction isValid<T extends jsep.ExpressionType>(\n expression: jsep.Expression,\n types: T[]\n): expression is jsep.CoreExpression & { type: T } {\n return types.includes(expression.type as T);\n}\n\nconst getParameterPath = (\n node: jsep.MemberExpression,\n context: Record<string, unknown>\n): string => {\n // it's a MEMBER expression\n // EXAMPLES: a[b] (computed)\n // a.b (not computed)\n const computed = node.computed;\n const object = node.object;\n const property = node.property;\n\n // object is either 'IDENTIFIER', 'MEMBER', or 'THIS'\n assert(\n isValid(object, ['MemberExpression', 'Identifier', 'ThisExpression']),\n 'Invalid object type'\n );\n assert(property, 'Member expression property is missing');\n\n let objectPath = '';\n if (object.type === 'ThisExpression') {\n objectPath = '';\n } else if (isValid(object, ['Identifier'])) {\n objectPath = object.name;\n } else {\n objectPath = getParameterPath(object, context);\n }\n\n if (computed) {\n // if computed -> evaluate anew\n const propertyPath = evaluateExpressionNode(property, context);\n return objectPath + '[' + propertyPath + ']';\n } else if (isValid(property, ['Identifier'])) {\n return (objectPath ? objectPath + '.' : '') + property.name;\n } else {\n assert(isValid(property, ['MemberExpression']), 'Invalid object type');\n const propertyPath = getParameterPath(property, context);\n return (objectPath ? objectPath + '.' : '') + propertyPath;\n }\n};\n\nconst evaluateExpressionNode = (node: jsep.Expression, context: Record<string, unknown>): any => {\n switch (node.type as jsep.ExpressionType) {\n case 'Literal': {\n return (node as jsep.Literal).value;\n }\n case 'ThisExpression': {\n return context;\n }\n case 'Compound': {\n const compoundNode = node as jsep.Compound;\n const expressions = compoundNode.body.map((el) => evaluateExpressionNode(el, context));\n return expressions.pop();\n }\n case 'UnaryExpression': {\n const unaryNode = node as jsep.UnaryExpression;\n if (!(unaryNode.operator in unaryOperatorFunctions)) {\n throw new Error(`Unsupported unary operator: ${unaryNode.operator}`);\n }\n const operatorFn = unaryOperatorFunctions[unaryNode.operator as UnaryOperator];\n const argument = evaluateExpressionNode(unaryNode.argument, context);\n return operatorFn(argument);\n }\n case 'BinaryExpression': {\n const binaryNode = node as jsep.BinaryExpression;\n if (!(binaryNode.operator in binaryOperatorFunctions)) {\n throw new Error(`Unsupported binary operator: ${binaryNode.operator}`);\n }\n const operator = binaryOperatorFunctions[binaryNode.operator as BinaryOperator];\n const left = evaluateExpressionNode(binaryNode.left, context);\n const right = evaluateExpressionNode(binaryNode.right, context);\n return operator(left, right);\n }\n case 'ConditionalExpression': {\n const conditionalNode = node as jsep.ConditionalExpression;\n const test = evaluateExpressionNode(conditionalNode.test, context);\n const consequent = evaluateExpressionNode(conditionalNode.consequent, context);\n const alternate = evaluateExpressionNode(conditionalNode.alternate, context);\n return test ? consequent : alternate;\n }\n case 'CallExpression': {\n const allowedCalleeTypes: jsep.ExpressionType[] = [\n 'MemberExpression',\n 'Identifier',\n 'ThisExpression',\n ];\n const callNode = node as jsep.CallExpression;\n if (!allowedCalleeTypes.includes(callNode.callee.type as jsep.ExpressionType)) {\n throw new Error(\n `Invalid function callee type: ${\n callNode.callee.type\n }. Expected one of ${allowedCalleeTypes.join(', ')}.`\n );\n }\n const callee = evaluateExpressionNode(callNode.callee, context);\n const args = callNode.arguments.map((arg) => evaluateExpressionNode(arg, context));\n // eslint-disable-next-line prefer-spread\n return callee.apply(null, args);\n }\n case 'Identifier': {\n const identifier = (node as jsep.Identifier).name;\n if (!(identifier in context)) {\n throw new Error(\n `Invalid identifier \"${identifier}\". Expected one of ${Object.keys(context).join(', ')}`\n );\n }\n return get(context, identifier);\n }\n case 'MemberExpression': {\n const path = getParameterPath(node as jsep.MemberExpression, context);\n return get(context, path);\n }\n case 'ArrayExpression': {\n const elements = (node as jsep.ArrayExpression).elements.map((el) =>\n evaluateExpressionNode(el, context)\n );\n return elements;\n }\n default:\n throw new Error(`Unsupported expression type: ${node.type}`);\n }\n};\n\nexport const jsepEval = (expression: string, context?: Record<string, unknown>): any => {\n const tree = jsep(expression);\n return evaluateExpressionNode(tree, context ?? {});\n};\n"]}
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.parseOutputPath = exports.findOutputPaths = exports.interpolateObjectWithGlobalContext = exports.interpolateStringWithGlobalContext = exports.interpolateWithGlobalContext = exports.getObjectValueForInterpolation = exports.getSelectedStatusCheckFromIfStatementTemplate = exports.interpolateObjectWithOutputs = exports.interpolateStringWithOutputs = exports.interpolateWithOutputs = exports.interpolateWithInputs = exports.BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP = exports.BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = exports.BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = void 0;
6
+ exports.parseOutputPath = exports.findOutputPaths = exports.interpolateObjectWithGlobalContext = exports.interpolateStringWithGlobalContext = exports.interpolateWithGlobalContext = exports.getObjectValueForInterpolation = exports.interpolateObjectWithOutputs = exports.interpolateStringWithOutputs = exports.interpolateWithOutputs = exports.interpolateWithInputs = exports.BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = exports.BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = void 0;
7
7
  const lodash_get_1 = __importDefault(require("lodash.get"));
8
8
  const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
9
9
  const BuildStepInput_js_1 = require("../BuildStepInput.cjs");
@@ -13,7 +13,6 @@ exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP = /\${\s*(inputs\.[\S]+)\s*}/;
13
13
  exports.BUILD_STEP_OUTPUT_EXPRESSION_REGEXP = /\${\s*(steps\.[\S]+)\s*}/;
14
14
  exports.BUILD_GLOBAL_CONTEXT_EXPRESSION_REGEXP = /\${\s*(eas\.[\S]+)\s*}/;
15
15
  exports.BUILD_STEP_OR_BUILD_GLOBAL_CONTEXT_REFERENCE_REGEX = /\${\s*((steps|eas)\.[\S]+)\s*}/;
16
- exports.BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP = /\${\s*(always|success|failure|never)\(\)\s*}/;
17
16
  function interpolateWithInputs(templateString, inputs) {
18
17
  return interpolate(templateString, exports.BUILD_STEP_INPUT_EXPRESSION_REGEXP, inputs);
19
18
  }
@@ -43,20 +42,6 @@ function interpolateObjectWithOutputs(interpolableObject, fn) {
43
42
  return interpolableObjectCopy;
44
43
  }
45
44
  exports.interpolateObjectWithOutputs = interpolateObjectWithOutputs;
46
- /**
47
- * Returns the selected status check from the if statement template.
48
- * Example: `${ success() }` -> `success`
49
- */
50
- function getSelectedStatusCheckFromIfStatementTemplate(ifCondition) {
51
- const matched = ifCondition.match(new RegExp(exports.BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP, 'g'));
52
- if (!matched) {
53
- // this should never happen because of regex pattern validation
54
- throw new errors_js_1.BuildConfigError(`Invalid if condition template.`);
55
- }
56
- const [, selectedStatusCheck] = (0, nullthrows_js_1.nullthrows)(matched[0].match(exports.BUILD_STEP_IF_CONDITION_EXPRESSION_REGEXP));
57
- return selectedStatusCheck;
58
- }
59
- exports.getSelectedStatusCheckFromIfStatementTemplate = getSelectedStatusCheckFromIfStatementTemplate;
60
45
  function getObjectValueForInterpolation(path, obj) {
61
46
  const value = (0, lodash_get_1.default)(obj, path);
62
47
  if (value === undefined) {