@expo/steps 1.0.21 → 1.0.23
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 +46 -15
- package/dist_commonjs/BuildConfig.d.ts +5 -3
- package/dist_commonjs/BuildConfig.js.map +1 -1
- package/dist_commonjs/BuildConfigParser.cjs +2 -0
- package/dist_commonjs/BuildConfigParser.js.map +1 -1
- package/dist_commonjs/BuildFunction.d.ts +2 -2
- package/dist_commonjs/BuildFunction.js.map +1 -1
- package/dist_commonjs/BuildStepInput.cjs +17 -3
- package/dist_commonjs/BuildStepInput.d.ts +16 -7
- package/dist_commonjs/BuildStepInput.js.map +1 -1
- package/dist_commonjs/BuildWorkflowValidator.cjs +10 -1
- package/dist_commonjs/BuildWorkflowValidator.js.map +1 -1
- package/dist_commonjs/index.cjs +2 -1
- package/dist_commonjs/index.d.ts +1 -1
- package/dist_commonjs/index.js.map +1 -1
- package/dist_esm/BuildConfig.d.ts +5 -3
- package/dist_esm/BuildConfig.js +46 -15
- package/dist_esm/BuildConfig.js.map +1 -1
- package/dist_esm/BuildConfigParser.js +3 -1
- package/dist_esm/BuildConfigParser.js.map +1 -1
- package/dist_esm/BuildFunction.d.ts +2 -2
- package/dist_esm/BuildFunction.js.map +1 -1
- package/dist_esm/BuildStepInput.d.ts +16 -7
- package/dist_esm/BuildStepInput.js +16 -2
- package/dist_esm/BuildStepInput.js.map +1 -1
- package/dist_esm/BuildWorkflowValidator.js +10 -1
- package/dist_esm/BuildWorkflowValidator.js.map +1 -1
- package/dist_esm/index.d.ts +1 -1
- package/dist_esm/index.js +1 -1
- package/dist_esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist_esm/BuildConfig.js
CHANGED
|
@@ -6,28 +6,59 @@ import YAML from 'yaml';
|
|
|
6
6
|
import { BuildConfigError, BuildWorkflowError } from './errors.js';
|
|
7
7
|
import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
8
8
|
import { BuildFunction } from './BuildFunction.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
import { BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
10
|
+
const BuildFunctionInputsSchema = Joi.array().items(Joi.alternatives().conditional(Joi.ref('.'), {
|
|
11
|
+
is: Joi.string(),
|
|
12
|
+
then: Joi.string().required(),
|
|
13
|
+
otherwise: Joi.object({
|
|
14
|
+
name: Joi.string().required(),
|
|
15
|
+
defaultValue: Joi.when('allowedValues', {
|
|
16
|
+
is: Joi.exist(),
|
|
17
|
+
then: Joi.valid(Joi.in('allowedValues')).messages({
|
|
18
|
+
'any.only': '{{#label}} must be one of allowed values',
|
|
19
|
+
}),
|
|
20
|
+
})
|
|
21
|
+
.when('allowedValueType', {
|
|
22
|
+
is: BuildStepInputValueTypeName.STRING,
|
|
23
|
+
then: Joi.string(),
|
|
24
|
+
})
|
|
25
|
+
.when('allowedValueType', {
|
|
26
|
+
is: BuildStepInputValueTypeName.BOOLEAN,
|
|
27
|
+
then: Joi.boolean(),
|
|
28
|
+
})
|
|
29
|
+
.when('allowedValueType', {
|
|
30
|
+
is: BuildStepInputValueTypeName.NUMBER,
|
|
31
|
+
then: Joi.number(),
|
|
15
32
|
}),
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
allowedValues: Joi.when('allowedValueType', {
|
|
34
|
+
is: BuildStepInputValueTypeName.STRING,
|
|
35
|
+
then: Joi.array().items(Joi.string()),
|
|
36
|
+
})
|
|
37
|
+
.when('allowedValueType', {
|
|
38
|
+
is: BuildStepInputValueTypeName.BOOLEAN,
|
|
39
|
+
then: Joi.array().items(Joi.boolean()),
|
|
40
|
+
})
|
|
41
|
+
.when('allowedValueType', {
|
|
42
|
+
is: BuildStepInputValueTypeName.NUMBER,
|
|
43
|
+
then: Joi.array().items(Joi.number()),
|
|
44
|
+
}),
|
|
45
|
+
allowedValueType: Joi.string()
|
|
46
|
+
.valid(...Object.values(BuildStepInputValueTypeName))
|
|
47
|
+
.default(BuildStepInputValueTypeName.STRING),
|
|
48
|
+
required: Joi.boolean(),
|
|
49
|
+
})
|
|
50
|
+
.rename('allowed_values', 'allowedValues')
|
|
51
|
+
.rename('default_value', 'defaultValue')
|
|
52
|
+
.rename('type', 'allowedValueType')
|
|
53
|
+
.required(),
|
|
54
|
+
}));
|
|
24
55
|
const BuildStepOutputsSchema = Joi.array().items(Joi.alternatives().try(Joi.string().required(), Joi.object({
|
|
25
56
|
name: Joi.string().required(),
|
|
26
57
|
required: Joi.boolean(),
|
|
27
58
|
}).required()));
|
|
28
59
|
const BuildFunctionCallSchema = Joi.object({
|
|
29
60
|
id: Joi.string(),
|
|
30
|
-
inputs: Joi.object().pattern(Joi.string(), Joi.alternatives().try(Joi.string(), Joi.boolean())),
|
|
61
|
+
inputs: Joi.object().pattern(Joi.string(), Joi.alternatives().try(Joi.string(), Joi.boolean(), Joi.number())),
|
|
31
62
|
name: Joi.string(),
|
|
32
63
|
workingDirectory: Joi.string(),
|
|
33
64
|
shell: Joi.string(),
|
|
@@ -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;AAuEnD,MAAM,yBAAyB,GA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K,EAAE;QACrC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAC9B;aAAM,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE;YAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,CACJ,IAAI,CAAC,MAAM,KAAK,CAAC,EACjB,wEAAwE,CACzE,CAAC;YACF,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACjC;KACF;IACD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACvD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE;;QACrE,IAAI,aAAa,CAAC,mBAAmB,CAAC,cAAc,CAAC,IAAI,4BAA4B,EAAE;YACrF,OAAO,KAAK,CAAC;SACd;QACD,OAAO,CACL,CAAC,CAAC,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;QACnC,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;KACH;AACH,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';\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};\n\nexport type BuildStepInputs = Record<string, string | boolean>;\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}\n\nexport type BuildFunctionInputs = (\n | string\n | {\n name: string;\n defaultValue?: string | boolean;\n allowedValues?: (string | boolean)[];\n required?: boolean;\n }\n)[];\nexport type BuildFunctionOutputs = BuildStepOutputs;\n\nconst BuildFunctionInputsSchema = Joi.array().items(\n Joi.alternatives().try(\n Joi.string().required(),\n Joi.object({\n name: Joi.string().required(),\n defaultValue: Joi.alternatives().conditional('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 otherwise: Joi.alternatives().try(Joi.string(), Joi.boolean()),\n }),\n allowedValues: Joi.array().items(Joi.string(), Joi.boolean()),\n required: Joi.boolean(),\n })\n .rename('allowed_values', 'allowedValues')\n .rename('default_value', 'defaultValue')\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(Joi.string(), Joi.alternatives().try(Joi.string(), Joi.boolean())),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\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().required(),\n shell: Joi.string(),\n}).rename('supported_platforms', 'supportedRuntimePlatforms');\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 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 for (const functionName in childConfig.functions) {\n if (!(functionName in importedFunctions)) {\n importedFunctions[functionName] = childConfig.functions[functionName];\n }\n }\n if (childConfig.configFilesToImport) {\n const childDir = path.dirname(childConfigPath);\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 typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return 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 (!('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"]}
|
|
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,EAA2B,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAwE3F,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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AAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACvD,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAC5D,MAAM,oBAAoB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE;;QACrE,IAAI,aAAa,CAAC,mBAAmB,CAAC,cAAc,CAAC,IAAI,4BAA4B,EAAE;YACrF,OAAO,KAAK,CAAC;SACd;QACD,OAAO,CACL,CAAC,CAAC,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;QACnC,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;KACH;AACH,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 { BuildStepInputValueType, BuildStepInputValueTypeName } from './BuildStepInput.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};\n\nexport type BuildStepInputs = Record<string, BuildStepInputValueType>;\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}\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(),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.BOOLEAN,\n then: Joi.boolean(),\n })\n .when('allowedValueType', {\n is: BuildStepInputValueTypeName.NUMBER,\n then: Joi.number(),\n }),\n allowedValues: Joi.when('allowedValueType', {\n is: BuildStepInputValueTypeName.STRING,\n then: Joi.array().items(Joi.string()),\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 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(), Joi.boolean(), Joi.number())\n ),\n name: Joi.string(),\n workingDirectory: Joi.string(),\n shell: Joi.string(),\n}).rename('working_directory', 'workingDirectory');\n\nconst BuildStepConfigSchema = Joi.any<BuildStepConfig>()\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().required(),\n shell: Joi.string(),\n}).rename('supported_platforms', 'supportedRuntimePlatforms');\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 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 for (const functionName in childConfig.functions) {\n if (!(functionName in importedFunctions)) {\n importedFunctions[functionName] = childConfig.functions[functionName];\n }\n }\n if (childConfig.configFilesToImport) {\n const childDir = path.dirname(childConfigPath);\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 typeof step === 'object' && typeof step.run === 'object';\n}\n\nexport function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun {\n return typeof step === 'object' && typeof step.run === 'string';\n}\n\nexport function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall {\n return 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 (!('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"]}
|
|
@@ -2,7 +2,7 @@ import assert from 'assert';
|
|
|
2
2
|
import { isBuildStepBareCommandRun, isBuildStepBareFunctionCall, isBuildStepCommandRun, readAndValidateBuildConfigAsync, } from './BuildConfig.js';
|
|
3
3
|
import { BuildFunction } from './BuildFunction.js';
|
|
4
4
|
import { BuildStep } from './BuildStep.js';
|
|
5
|
-
import { BuildStepInput } from './BuildStepInput.js';
|
|
5
|
+
import { BuildStepInput, } from './BuildStepInput.js';
|
|
6
6
|
import { BuildStepOutput } from './BuildStepOutput.js';
|
|
7
7
|
import { BuildWorkflow } from './BuildWorkflow.js';
|
|
8
8
|
import { BuildWorkflowValidator } from './BuildWorkflowValidator.js';
|
|
@@ -118,6 +118,7 @@ export class BuildConfigParser {
|
|
|
118
118
|
stepDisplayName,
|
|
119
119
|
defaultValue: value,
|
|
120
120
|
required: true,
|
|
121
|
+
allowedValueTypeName: typeof value,
|
|
121
122
|
}));
|
|
122
123
|
}
|
|
123
124
|
createBuildStepInputProvidersFromBuildFunctionInputs(buildFunctionInputs) {
|
|
@@ -130,6 +131,7 @@ export class BuildConfigParser {
|
|
|
130
131
|
required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
|
|
131
132
|
defaultValue: entry.defaultValue,
|
|
132
133
|
allowedValues: entry.allowedValues,
|
|
134
|
+
allowedValueTypeName: entry.allowedValueType,
|
|
133
135
|
});
|
|
134
136
|
});
|
|
135
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAYL,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAA0B,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,eAAe,EAA2B,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAEhD,MAAM,OAAO,iBAAiB;IAI5B,YACmB,GAAqB,EACtC,EAAE,UAAU,EAAE,iBAAiB,EAA+D;QAD7E,QAAG,GAAH,GAAG,CAAkB;QAGtC,IAAI,CAAC,yBAAyB,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AC;aAChC;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,yBAAyB,CAAC,iBAAmC;QACnE,IAAI,iBAAiB,KAAK,SAAS,EAAE;YACnC,OAAO;SACR;QACD,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QACxE,MAAM,6BAA6B,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;QACtE,IAAI,6BAA6B,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9C,OAAO;SACR;QACD,MAAM,IAAI,qBAAqB,CAC7B,oDAAoD,6BAA6B;aAC9E,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC;aACtB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;IACJ,CAAC;IAEO,0BAA0B;QAChC,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE;YACxC,OAAO,EAAE,CAAC;SACX;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CACF","sourcesContent":["import assert from 'assert';\n\nimport {\n BuildConfig,\n BuildFunctionConfig,\n BuildFunctionInputs,\n BuildFunctionOutputs,\n BuildStepBareCommandRun,\n BuildStepBareFunctionCall,\n BuildStepCommandRun,\n BuildStepConfig,\n BuildStepFunctionCall,\n BuildStepInputs,\n BuildStepOutputs,\n isBuildStepBareCommandRun,\n isBuildStepBareFunctionCall,\n isBuildStepCommandRun,\n readAndValidateBuildConfigAsync,\n} from './BuildConfig.js';\nimport { BuildFunction, BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputProvider } from './BuildStepInput.js';\nimport { BuildStepOutput, BuildStepOutputProvider } from './BuildStepOutput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildWorkflowValidator } from './BuildWorkflowValidator.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { uniq } from './utils/expodash/uniq.js';\n\nexport class BuildConfigParser {\n private readonly configPath: string;\n private readonly externalFunctions?: BuildFunction[];\n\n constructor(\n private readonly ctx: BuildStepContext,\n { configPath, externalFunctions }: { configPath: string; externalFunctions?: BuildFunction[] }\n ) {\n this.validateExternalFunctions(externalFunctions);\n\n this.configPath = configPath;\n this.externalFunctions = externalFunctions;\n }\n\n public async parseAsync(): Promise<BuildWorkflow> {\n const config = await readAndValidateBuildConfigAsync(this.configPath, {\n externalFunctionIds: this.getExternalFunctionFullIds(),\n });\n const configBuildFunctions = this.createBuildFunctionsFromConfig(config.functions);\n const buildFunctions = this.mergeBuildFunctionsWithExternal(\n configBuildFunctions,\n this.externalFunctions\n );\n const buildSteps = config.build.steps.map((stepConfig) =>\n this.createBuildStepFromConfig(stepConfig, buildFunctions)\n );\n const workflow = new BuildWorkflow(this.ctx, { buildSteps, buildFunctions });\n new BuildWorkflowValidator(workflow).validate();\n return workflow;\n }\n\n private createBuildStepFromConfig(\n buildStepConfig: BuildStepConfig,\n buildFunctions: BuildFunctionById\n ): BuildStep {\n if (isBuildStepCommandRun(buildStepConfig)) {\n return this.createBuildStepFromBuildStepCommandRun(buildStepConfig);\n } else if (isBuildStepBareCommandRun(buildStepConfig)) {\n return this.createBuildStepFromBuildStepBareCommandRun(buildStepConfig);\n } else if (isBuildStepBareFunctionCall(buildStepConfig)) {\n return this.createBuildStepFromBuildStepBareFunctionCall(buildFunctions, buildStepConfig);\n } else {\n return this.createBuildStepFromBuildStepFunctionCall(buildFunctions, buildStepConfig);\n }\n }\n\n private createBuildStepFromBuildStepCommandRun({ run }: BuildStepCommandRun): BuildStep {\n const {\n id: maybeId,\n inputs: inputsConfig,\n outputs: outputsConfig,\n name,\n workingDirectory,\n shell,\n command,\n } = run;\n const id = BuildStep.getNewId(maybeId);\n const displayName = BuildStep.getDisplayName({ id, name, command });\n const inputs =\n inputsConfig && this.createBuildStepInputsFromDefinition(inputsConfig, displayName);\n const outputs =\n outputsConfig && this.createBuildStepOutputsFromDefinition(outputsConfig, displayName);\n return new BuildStep(this.ctx, {\n id,\n inputs,\n outputs,\n name,\n displayName,\n workingDirectory,\n shell,\n command,\n });\n }\n\n private createBuildStepFromBuildStepBareCommandRun({\n run: command,\n }: BuildStepBareCommandRun): BuildStep {\n const id = BuildStep.getNewId();\n const displayName = BuildStep.getDisplayName({ id, command });\n return new BuildStep(this.ctx, {\n id,\n displayName,\n command,\n });\n }\n\n private createBuildStepFromBuildStepBareFunctionCall(\n buildFunctions: BuildFunctionById,\n functionId: BuildStepBareFunctionCall\n ): BuildStep {\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx);\n }\n\n private createBuildStepFromBuildStepFunctionCall(\n buildFunctions: BuildFunctionById,\n buildStepFunctionCall: BuildStepFunctionCall\n ): BuildStep {\n const keys = Object.keys(buildStepFunctionCall);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n const functionId = keys[0];\n const buildFunctionCallConfig = buildStepFunctionCall[functionId];\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx, {\n id: buildFunctionCallConfig.id,\n name: buildFunctionCallConfig.name,\n callInputs: buildFunctionCallConfig.inputs,\n workingDirectory: buildFunctionCallConfig.workingDirectory,\n shell: buildFunctionCallConfig.shell,\n });\n }\n\n private createBuildFunctionsFromConfig(\n buildFunctionsConfig: BuildConfig['functions']\n ): BuildFunctionById {\n if (!buildFunctionsConfig) {\n return {};\n }\n const result: BuildFunctionById = {};\n for (const [functionId, buildFunctionConfig] of Object.entries(buildFunctionsConfig)) {\n const buildFunction = this.createBuildFunctionFromConfig({\n id: functionId,\n ...buildFunctionConfig,\n });\n result[buildFunction.getFullId()] = buildFunction;\n }\n return result;\n }\n\n private createBuildFunctionFromConfig({\n id,\n name,\n inputs: inputsConfig,\n outputs: outputsConfig,\n shell,\n command,\n supportedRuntimePlatforms,\n }: BuildFunctionConfig & { id: string }): BuildFunction {\n const inputProviders =\n inputsConfig && this.createBuildStepInputProvidersFromBuildFunctionInputs(inputsConfig);\n const outputProviders =\n outputsConfig && this.createBuildStepOutputProvidersFromBuildFunctionOutputs(outputsConfig);\n return new BuildFunction({\n id,\n name,\n inputProviders,\n outputProviders,\n shell,\n command,\n supportedRuntimePlatforms,\n });\n }\n\n private createBuildStepInputsFromDefinition(\n buildStepInputs: BuildStepInputs,\n stepDisplayName: string\n ): BuildStepInput[] {\n return Object.entries(buildStepInputs).map(\n ([key, value]) =>\n new BuildStepInput(this.ctx, {\n id: key,\n stepDisplayName,\n defaultValue: value,\n required: true,\n })\n );\n }\n\n private createBuildStepInputProvidersFromBuildFunctionInputs(\n buildFunctionInputs: BuildFunctionInputs\n ): BuildStepInputProvider[] {\n return buildFunctionInputs.map((entry) => {\n return typeof entry === 'string'\n ? BuildStepInput.createProvider({ id: entry })\n : BuildStepInput.createProvider({\n id: entry.name,\n required: entry.required ?? true,\n defaultValue: entry.defaultValue,\n allowedValues: entry.allowedValues,\n });\n });\n }\n\n private createBuildStepOutputsFromDefinition(\n buildStepOutputs: BuildStepOutputs,\n stepDisplayName: string\n ): BuildStepOutput[] {\n return buildStepOutputs.map((entry) =>\n typeof entry === 'string'\n ? new BuildStepOutput(this.ctx, { id: entry, stepDisplayName, required: true })\n : new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepDisplayName,\n required: entry.required ?? true,\n })\n );\n }\n\n private createBuildStepOutputProvidersFromBuildFunctionOutputs(\n buildFunctionOutputs: BuildFunctionOutputs\n ): BuildStepOutputProvider[] {\n return buildFunctionOutputs.map((entry) =>\n typeof entry === 'string'\n ? BuildStepOutput.createProvider({ id: entry, required: true })\n : BuildStepOutput.createProvider({ id: entry.name, required: entry.required ?? true })\n );\n }\n\n private mergeBuildFunctionsWithExternal(\n configFunctions: BuildFunctionById,\n externalFunctions?: BuildFunction[]\n ): BuildFunctionById {\n const result: BuildFunctionById = { ...configFunctions };\n if (externalFunctions === undefined) {\n return result;\n }\n for (const buildFunction of externalFunctions) {\n // functions defined in config shadow the external ones\n const fullId = buildFunction.getFullId();\n if (!(fullId in result)) {\n result[fullId] = buildFunction;\n }\n }\n return result;\n }\n\n private validateExternalFunctions(externalFunctions?: BuildFunction[]): void {\n if (externalFunctions === undefined) {\n return;\n }\n const externalFunctionIds = externalFunctions.map((f) => f.getFullId());\n const duplicatedExternalFunctionIds = duplicates(externalFunctionIds);\n if (duplicatedExternalFunctionIds.length === 0) {\n return;\n }\n throw new BuildStepRuntimeError(\n `Provided external functions with duplicated IDs: ${duplicatedExternalFunctionIds\n .map((id) => `\"${id}\"`)\n .join(', ')}`\n );\n }\n\n private getExternalFunctionFullIds(): string[] {\n if (this.externalFunctions === undefined) {\n return [];\n }\n const ids = this.externalFunctions.map((f) => f.getFullId());\n return uniq(ids);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAYL,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EACL,cAAc,GAGf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAA2B,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAA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AI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;CACF","sourcesContent":["import assert from 'assert';\n\nimport {\n BuildConfig,\n BuildFunctionConfig,\n BuildFunctionInputs,\n BuildFunctionOutputs,\n BuildStepBareCommandRun,\n BuildStepBareFunctionCall,\n BuildStepCommandRun,\n BuildStepConfig,\n BuildStepFunctionCall,\n BuildStepInputs,\n BuildStepOutputs,\n isBuildStepBareCommandRun,\n isBuildStepBareFunctionCall,\n isBuildStepCommandRun,\n readAndValidateBuildConfigAsync,\n} from './BuildConfig.js';\nimport { BuildFunction, BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport {\n BuildStepInput,\n BuildStepInputProvider,\n BuildStepInputValueTypeName,\n} from './BuildStepInput.js';\nimport { BuildStepOutput, BuildStepOutputProvider } from './BuildStepOutput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildWorkflowValidator } from './BuildWorkflowValidator.js';\nimport { BuildStepRuntimeError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { uniq } from './utils/expodash/uniq.js';\n\nexport class BuildConfigParser {\n private readonly configPath: string;\n private readonly externalFunctions?: BuildFunction[];\n\n constructor(\n private readonly ctx: BuildStepContext,\n { configPath, externalFunctions }: { configPath: string; externalFunctions?: BuildFunction[] }\n ) {\n this.validateExternalFunctions(externalFunctions);\n\n this.configPath = configPath;\n this.externalFunctions = externalFunctions;\n }\n\n public async parseAsync(): Promise<BuildWorkflow> {\n const config = await readAndValidateBuildConfigAsync(this.configPath, {\n externalFunctionIds: this.getExternalFunctionFullIds(),\n });\n const configBuildFunctions = this.createBuildFunctionsFromConfig(config.functions);\n const buildFunctions = this.mergeBuildFunctionsWithExternal(\n configBuildFunctions,\n this.externalFunctions\n );\n const buildSteps = config.build.steps.map((stepConfig) =>\n this.createBuildStepFromConfig(stepConfig, buildFunctions)\n );\n const workflow = new BuildWorkflow(this.ctx, { buildSteps, buildFunctions });\n new BuildWorkflowValidator(workflow).validate();\n return workflow;\n }\n\n private createBuildStepFromConfig(\n buildStepConfig: BuildStepConfig,\n buildFunctions: BuildFunctionById\n ): BuildStep {\n if (isBuildStepCommandRun(buildStepConfig)) {\n return this.createBuildStepFromBuildStepCommandRun(buildStepConfig);\n } else if (isBuildStepBareCommandRun(buildStepConfig)) {\n return this.createBuildStepFromBuildStepBareCommandRun(buildStepConfig);\n } else if (isBuildStepBareFunctionCall(buildStepConfig)) {\n return this.createBuildStepFromBuildStepBareFunctionCall(buildFunctions, buildStepConfig);\n } else {\n return this.createBuildStepFromBuildStepFunctionCall(buildFunctions, buildStepConfig);\n }\n }\n\n private createBuildStepFromBuildStepCommandRun({ run }: BuildStepCommandRun): BuildStep {\n const {\n id: maybeId,\n inputs: inputsConfig,\n outputs: outputsConfig,\n name,\n workingDirectory,\n shell,\n command,\n } = run;\n const id = BuildStep.getNewId(maybeId);\n const displayName = BuildStep.getDisplayName({ id, name, command });\n const inputs =\n inputsConfig && this.createBuildStepInputsFromDefinition(inputsConfig, displayName);\n const outputs =\n outputsConfig && this.createBuildStepOutputsFromDefinition(outputsConfig, displayName);\n return new BuildStep(this.ctx, {\n id,\n inputs,\n outputs,\n name,\n displayName,\n workingDirectory,\n shell,\n command,\n });\n }\n\n private createBuildStepFromBuildStepBareCommandRun({\n run: command,\n }: BuildStepBareCommandRun): BuildStep {\n const id = BuildStep.getNewId();\n const displayName = BuildStep.getDisplayName({ id, command });\n return new BuildStep(this.ctx, {\n id,\n displayName,\n command,\n });\n }\n\n private createBuildStepFromBuildStepBareFunctionCall(\n buildFunctions: BuildFunctionById,\n functionId: BuildStepBareFunctionCall\n ): BuildStep {\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx);\n }\n\n private createBuildStepFromBuildStepFunctionCall(\n buildFunctions: BuildFunctionById,\n buildStepFunctionCall: BuildStepFunctionCall\n ): BuildStep {\n const keys = Object.keys(buildStepFunctionCall);\n assert(\n keys.length === 1,\n 'There must be at most one function call in the step (enforced by joi).'\n );\n const functionId = keys[0];\n const buildFunctionCallConfig = buildStepFunctionCall[functionId];\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall(this.ctx, {\n id: buildFunctionCallConfig.id,\n name: buildFunctionCallConfig.name,\n callInputs: buildFunctionCallConfig.inputs,\n workingDirectory: buildFunctionCallConfig.workingDirectory,\n shell: buildFunctionCallConfig.shell,\n });\n }\n\n private createBuildFunctionsFromConfig(\n buildFunctionsConfig: BuildConfig['functions']\n ): BuildFunctionById {\n if (!buildFunctionsConfig) {\n return {};\n }\n const result: BuildFunctionById = {};\n for (const [functionId, buildFunctionConfig] of Object.entries(buildFunctionsConfig)) {\n const buildFunction = this.createBuildFunctionFromConfig({\n id: functionId,\n ...buildFunctionConfig,\n });\n result[buildFunction.getFullId()] = buildFunction;\n }\n return result;\n }\n\n private createBuildFunctionFromConfig({\n id,\n name,\n inputs: inputsConfig,\n outputs: outputsConfig,\n shell,\n command,\n supportedRuntimePlatforms,\n }: BuildFunctionConfig & { id: string }): BuildFunction {\n const inputProviders =\n inputsConfig && this.createBuildStepInputProvidersFromBuildFunctionInputs(inputsConfig);\n const outputProviders =\n outputsConfig && this.createBuildStepOutputProvidersFromBuildFunctionOutputs(outputsConfig);\n return new BuildFunction({\n id,\n name,\n inputProviders,\n outputProviders,\n shell,\n command,\n supportedRuntimePlatforms,\n });\n }\n\n private createBuildStepInputsFromDefinition(\n buildStepInputs: BuildStepInputs,\n stepDisplayName: string\n ): BuildStepInput[] {\n return Object.entries(buildStepInputs).map(\n ([key, value]) =>\n new BuildStepInput(this.ctx, {\n id: key,\n stepDisplayName,\n defaultValue: value,\n required: true,\n allowedValueTypeName: typeof value as BuildStepInputValueTypeName,\n })\n );\n }\n\n private createBuildStepInputProvidersFromBuildFunctionInputs(\n buildFunctionInputs: BuildFunctionInputs\n ): BuildStepInputProvider[] {\n return buildFunctionInputs.map((entry) => {\n return typeof entry === 'string'\n ? BuildStepInput.createProvider({ id: entry })\n : BuildStepInput.createProvider({\n id: entry.name,\n required: entry.required ?? true,\n defaultValue: entry.defaultValue,\n allowedValues: entry.allowedValues,\n allowedValueTypeName: entry.allowedValueType,\n });\n });\n }\n\n private createBuildStepOutputsFromDefinition(\n buildStepOutputs: BuildStepOutputs,\n stepDisplayName: string\n ): BuildStepOutput[] {\n return buildStepOutputs.map((entry) =>\n typeof entry === 'string'\n ? new BuildStepOutput(this.ctx, { id: entry, stepDisplayName, required: true })\n : new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepDisplayName,\n required: entry.required ?? true,\n })\n );\n }\n\n private createBuildStepOutputProvidersFromBuildFunctionOutputs(\n buildFunctionOutputs: BuildFunctionOutputs\n ): BuildStepOutputProvider[] {\n return buildFunctionOutputs.map((entry) =>\n typeof entry === 'string'\n ? BuildStepOutput.createProvider({ id: entry, required: true })\n : BuildStepOutput.createProvider({ id: entry.name, required: entry.required ?? true })\n );\n }\n\n private mergeBuildFunctionsWithExternal(\n configFunctions: BuildFunctionById,\n externalFunctions?: BuildFunction[]\n ): BuildFunctionById {\n const result: BuildFunctionById = { ...configFunctions };\n if (externalFunctions === undefined) {\n return result;\n }\n for (const buildFunction of externalFunctions) {\n // functions defined in config shadow the external ones\n const fullId = buildFunction.getFullId();\n if (!(fullId in result)) {\n result[fullId] = buildFunction;\n }\n }\n return result;\n }\n\n private validateExternalFunctions(externalFunctions?: BuildFunction[]): void {\n if (externalFunctions === undefined) {\n return;\n }\n const externalFunctionIds = externalFunctions.map((f) => f.getFullId());\n const duplicatedExternalFunctionIds = duplicates(externalFunctionIds);\n if (duplicatedExternalFunctionIds.length === 0) {\n return;\n }\n throw new BuildStepRuntimeError(\n `Provided external functions with duplicated IDs: ${duplicatedExternalFunctionIds\n .map((id) => `\"${id}\"`)\n .join(', ')}`\n );\n }\n\n private getExternalFunctionFullIds(): string[] {\n if (this.externalFunctions === undefined) {\n return [];\n }\n const ids = this.externalFunctions.map((f) => f.getFullId());\n return uniq(ids);\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
2
2
|
import { BuildStep, BuildStepFunction } from './BuildStep.js';
|
|
3
3
|
import { BuildStepContext } from './BuildStepContext.js';
|
|
4
|
-
import { BuildStepInputProvider } from './BuildStepInput.js';
|
|
4
|
+
import { BuildStepInputProvider, BuildStepInputValueType } from './BuildStepInput.js';
|
|
5
5
|
import { BuildStepOutputProvider } from './BuildStepOutput.js';
|
|
6
6
|
export type BuildFunctionById = Record<string, BuildFunction>;
|
|
7
|
-
export type BuildFunctionCallInputs = Record<string,
|
|
7
|
+
export type BuildFunctionCallInputs = Record<string, BuildStepInputValueType>;
|
|
8
8
|
export declare class BuildFunction {
|
|
9
9
|
readonly namespace?: string;
|
|
10
10
|
readonly id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildFunction.js","sourceRoot":"","sources":["../src/BuildFunction.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAQ9D,MAAM,OAAO,aAAa;IAWjB,MAAM,CAAC,mBAAmB,CAAC,MAAc;QAC9C,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,YAAY,EACV,SAAS,EACT,EAAE,EACF,IAAI,EACJ,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,OAAO,EACP,EAAE,EACF,KAAK,GAWN;QACC,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,KAAK,SAAS,EAAE,uCAAuC,CAAC,CAAC;QAC3F,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,KAAK,SAAS,CAAC,EAAE,oCAAoC,CAAC,CAAC;QAE3F,IAAI,CAAC,SAAS,GAAG,SA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AAE,CAAC,CAAC,CAAC;aACjC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,eAAe,0CAAE,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;QAEhG,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE;YACxB,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,oBAAoB;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,gBAAgB;YAChB,MAAM;YACN,OAAO;YACP,KAAK;YACL,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;SAC1D,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import assert from 'assert';\n\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildStep, BuildStepFunction } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInputProvider } from './BuildStepInput.js';\nimport { BuildStepOutputProvider } from './BuildStepOutput.js';\n\nexport type BuildFunctionById = Record<string, BuildFunction>;\nexport type BuildFunctionCallInputs = Record<string,
|
|
1
|
+
{"version":3,"file":"BuildFunction.js","sourceRoot":"","sources":["../src/BuildFunction.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAQ9D,MAAM,OAAO,aAAa;IAWjB,MAAM,CAAC,mBAAmB,CAAC,MAAc;QAC9C,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED,YAAY,EACV,SAAS,EACT,EAAE,EACF,IAAI,EACJ,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,OAAO,EACP,EAAE,EACF,KAAK,GAWN;QACC,MAAM,CAA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,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE;YACxD,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YAC9C,IAAI,KAAK,CAAC,EAAE,IAAI,UAAU,EAAE;gBAC1B,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;aACjC;YACD,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,eAAe,0CAAE,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;QAEhG,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE;YACxB,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,oBAAoB;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,gBAAgB;YAChB,MAAM;YACN,OAAO;YACP,KAAK;YACL,yBAAyB,EAAE,IAAI,CAAC,yBAAyB;SAC1D,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import assert from 'assert';\n\nimport { BuildRuntimePlatform } from './BuildRuntimePlatform.js';\nimport { BuildStep, BuildStepFunction } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInputProvider, BuildStepInputValueType } from './BuildStepInput.js';\nimport { BuildStepOutputProvider } from './BuildStepOutput.js';\n\nexport type BuildFunctionById = Record<string, BuildFunction>;\nexport type BuildFunctionCallInputs = Record<string, BuildStepInputValueType>;\n\nexport class BuildFunction {\n public readonly namespace?: string;\n public readonly id: string;\n public readonly name?: string;\n public readonly supportedRuntimePlatforms?: BuildRuntimePlatform[];\n public readonly inputProviders?: BuildStepInputProvider[];\n public readonly outputProviders?: BuildStepOutputProvider[];\n public readonly command?: string;\n public readonly fn?: BuildStepFunction;\n public readonly shell?: string;\n\n public static isFulldIdNamespaced(fullId: string): boolean {\n return fullId.includes('/');\n }\n\n constructor({\n namespace,\n id,\n name,\n supportedRuntimePlatforms,\n inputProviders,\n outputProviders,\n command,\n fn,\n shell,\n }: {\n namespace?: string;\n id: string;\n name?: string;\n supportedRuntimePlatforms?: BuildRuntimePlatform[];\n inputProviders?: BuildStepInputProvider[];\n outputProviders?: BuildStepOutputProvider[];\n command?: string;\n fn?: BuildStepFunction;\n shell?: string;\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\n this.namespace = namespace;\n this.id = id;\n this.name = name;\n this.supportedRuntimePlatforms = supportedRuntimePlatforms;\n this.inputProviders = inputProviders;\n this.outputProviders = outputProviders;\n this.command = command;\n this.fn = fn;\n this.shell = shell;\n }\n\n public getFullId(): string {\n return this.namespace === undefined ? this.id : `${this.namespace}/${this.id}`;\n }\n\n public createBuildStepFromFunctionCall(\n ctx: BuildStepContext,\n {\n id,\n name,\n callInputs = {},\n workingDirectory,\n shell,\n }: {\n id?: string;\n name?: string;\n callInputs?: BuildFunctionCallInputs;\n workingDirectory?: string;\n shell?: string;\n } = {}\n ): BuildStep {\n const buildStepId = BuildStep.getNewId(id);\n const buildStepName = name ?? this.name;\n const buildStepDisplayName = BuildStep.getDisplayName({\n id: buildStepId,\n command: this.command,\n name: buildStepName,\n });\n\n const inputs = this.inputProviders?.map((inputProvider) => {\n const input = inputProvider(ctx, buildStepId);\n if (input.id in callInputs) {\n input.set(callInputs[input.id]);\n }\n return input;\n });\n const outputs = this.outputProviders?.map((outputProvider) => outputProvider(ctx, buildStepId));\n\n return new BuildStep(ctx, {\n id: buildStepId,\n name: buildStepName,\n displayName: buildStepDisplayName,\n command: this.command,\n fn: this.fn,\n workingDirectory,\n inputs,\n outputs,\n shell,\n supportedRuntimePlatforms: this.supportedRuntimePlatforms,\n });\n }\n}\n"]}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { BuildStepContext } from './BuildStepContext.js';
|
|
2
|
+
export declare enum BuildStepInputValueTypeName {
|
|
3
|
+
STRING = "string",
|
|
4
|
+
BOOLEAN = "boolean",
|
|
5
|
+
NUMBER = "number"
|
|
6
|
+
}
|
|
7
|
+
export type BuildStepInputValueType = string | boolean | number;
|
|
2
8
|
export type BuildStepInputById = Record<string, BuildStepInput>;
|
|
3
9
|
export type BuildStepInputProvider = (ctx: BuildStepContext, stepId: string) => BuildStepInput;
|
|
4
10
|
interface BuildStepInputProviderParams {
|
|
5
11
|
id: string;
|
|
6
|
-
allowedValues?:
|
|
7
|
-
defaultValue?:
|
|
12
|
+
allowedValues?: BuildStepInputValueType[];
|
|
13
|
+
defaultValue?: BuildStepInputValueType;
|
|
8
14
|
required?: boolean;
|
|
15
|
+
allowedValueTypeName?: BuildStepInputValueTypeName;
|
|
9
16
|
}
|
|
10
17
|
interface BuildStepInputParams extends BuildStepInputProviderParams {
|
|
11
18
|
stepDisplayName: string;
|
|
@@ -14,14 +21,16 @@ export declare class BuildStepInput {
|
|
|
14
21
|
private readonly ctx;
|
|
15
22
|
readonly id: string;
|
|
16
23
|
readonly stepDisplayName: string;
|
|
17
|
-
readonly defaultValue?:
|
|
18
|
-
readonly allowedValues?:
|
|
24
|
+
readonly defaultValue?: BuildStepInputValueType;
|
|
25
|
+
readonly allowedValues?: BuildStepInputValueType[];
|
|
26
|
+
readonly allowedValueTypeName: BuildStepInputValueTypeName;
|
|
19
27
|
readonly required: boolean;
|
|
20
28
|
private _value?;
|
|
21
29
|
static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider;
|
|
22
|
-
constructor(ctx: BuildStepContext, { id, stepDisplayName, allowedValues, defaultValue, required }: BuildStepInputParams);
|
|
23
|
-
get value():
|
|
24
|
-
|
|
30
|
+
constructor(ctx: BuildStepContext, { id, stepDisplayName, allowedValues, defaultValue, required, allowedValueTypeName, }: BuildStepInputParams);
|
|
31
|
+
get value(): BuildStepInputValueType | undefined;
|
|
32
|
+
get rawValue(): BuildStepInputValueType | undefined;
|
|
33
|
+
set(value: BuildStepInputValueType | undefined): BuildStepInput;
|
|
25
34
|
isValueOneOfAllowedValues(): boolean;
|
|
26
35
|
}
|
|
27
36
|
export declare function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById;
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { BuildStepRuntimeError } from './errors.js';
|
|
2
2
|
import { interpolateWithOutputs } from './utils/template.js';
|
|
3
|
+
export var BuildStepInputValueTypeName;
|
|
4
|
+
(function (BuildStepInputValueTypeName) {
|
|
5
|
+
BuildStepInputValueTypeName["STRING"] = "string";
|
|
6
|
+
BuildStepInputValueTypeName["BOOLEAN"] = "boolean";
|
|
7
|
+
BuildStepInputValueTypeName["NUMBER"] = "number";
|
|
8
|
+
})(BuildStepInputValueTypeName || (BuildStepInputValueTypeName = {}));
|
|
3
9
|
export class BuildStepInput {
|
|
4
10
|
static createProvider(params) {
|
|
5
11
|
return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });
|
|
6
12
|
}
|
|
7
|
-
constructor(ctx, { id, stepDisplayName, allowedValues, defaultValue, required = true }) {
|
|
13
|
+
constructor(ctx, { id, stepDisplayName, allowedValues, defaultValue, required = true, allowedValueTypeName = BuildStepInputValueTypeName.STRING, }) {
|
|
8
14
|
this.ctx = ctx;
|
|
9
15
|
this.id = id;
|
|
10
16
|
this.stepDisplayName = stepDisplayName;
|
|
11
17
|
this.allowedValues = allowedValues;
|
|
12
18
|
this.defaultValue = defaultValue;
|
|
13
19
|
this.required = required;
|
|
20
|
+
this.allowedValueTypeName = allowedValueTypeName;
|
|
14
21
|
}
|
|
15
22
|
get value() {
|
|
16
23
|
var _a;
|
|
@@ -18,13 +25,20 @@ export class BuildStepInput {
|
|
|
18
25
|
if (this.required && rawValue === undefined) {
|
|
19
26
|
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required but it was not set.`);
|
|
20
27
|
}
|
|
21
|
-
if (rawValue
|
|
28
|
+
if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {
|
|
29
|
+
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" must be of type "${this.allowedValueTypeName}".`);
|
|
30
|
+
}
|
|
31
|
+
if (rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number') {
|
|
22
32
|
return rawValue;
|
|
23
33
|
}
|
|
24
34
|
else {
|
|
25
35
|
return interpolateWithOutputs(rawValue, (path) => { var _a; return (_a = this.ctx.getStepOutputValue(path)) !== null && _a !== void 0 ? _a : ''; });
|
|
26
36
|
}
|
|
27
37
|
}
|
|
38
|
+
get rawValue() {
|
|
39
|
+
var _a;
|
|
40
|
+
return (_a = this._value) !== null && _a !== void 0 ? _a : this.defaultValue;
|
|
41
|
+
}
|
|
28
42
|
set(value) {
|
|
29
43
|
if (this.required && value === undefined) {
|
|
30
44
|
throw new BuildStepRuntimeError(`Input parameter "${this.id}" for step "${this.stepDisplayName}" is required.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"BuildStepInput.js","sourceRoot":"","sources":["../src/BuildStepInput.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,CAAN,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,gDAAiB,CAAA;IACjB,kDAAmB,CAAA;IACnB,gDAAiB,CAAA;AACnB,CAAC,EAJW,2BAA2B,KAA3B,2BAA2B,QAItC;AAk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nimport { BuildStepRuntimeError } from './errors.js';\nimport { interpolateWithOutputs } from './utils/template.js';\n\nexport enum BuildStepInputValueTypeName {\n STRING = 'string',\n BOOLEAN = 'boolean',\n NUMBER = 'number',\n}\nexport type BuildStepInputValueType = string | boolean | number;\n\nexport type BuildStepInputById = Record<string, BuildStepInput>;\nexport type BuildStepInputProvider = (ctx: BuildStepContext, stepId: string) => BuildStepInput;\n\ninterface BuildStepInputProviderParams {\n id: string;\n allowedValues?: BuildStepInputValueType[];\n defaultValue?: BuildStepInputValueType;\n required?: boolean;\n allowedValueTypeName?: BuildStepInputValueTypeName;\n}\n\ninterface BuildStepInputParams extends BuildStepInputProviderParams {\n stepDisplayName: string;\n}\n\nexport class BuildStepInput {\n public readonly id: string;\n public readonly stepDisplayName: string;\n public readonly defaultValue?: BuildStepInputValueType;\n public readonly allowedValues?: BuildStepInputValueType[];\n public readonly allowedValueTypeName: BuildStepInputValueTypeName;\n public readonly required: boolean;\n\n private _value?: BuildStepInputValueType;\n\n public static createProvider(params: BuildStepInputProviderParams): BuildStepInputProvider {\n return (ctx, stepDisplayName) => new BuildStepInput(ctx, { ...params, stepDisplayName });\n }\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n stepDisplayName,\n allowedValues,\n defaultValue,\n required = true,\n allowedValueTypeName = BuildStepInputValueTypeName.STRING,\n }: BuildStepInputParams\n ) {\n this.id = id;\n this.stepDisplayName = stepDisplayName;\n this.allowedValues = allowedValues;\n this.defaultValue = defaultValue;\n this.required = required;\n this.allowedValueTypeName = allowedValueTypeName;\n }\n\n public get value(): BuildStepInputValueType | undefined {\n const rawValue = this._value ?? this.defaultValue;\n if (this.required && rawValue === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required but it was not set.`\n );\n }\n if (typeof rawValue !== this.allowedValueTypeName && rawValue !== undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" must be of type \"${this.allowedValueTypeName}\".`\n );\n }\n\n if (rawValue === undefined || typeof rawValue === 'boolean' || typeof rawValue === 'number') {\n return rawValue;\n } else {\n return interpolateWithOutputs(rawValue, (path) => this.ctx.getStepOutputValue(path) ?? '');\n }\n }\n\n public get rawValue(): BuildStepInputValueType | undefined {\n return this._value ?? this.defaultValue;\n }\n\n public set(value: BuildStepInputValueType | undefined): BuildStepInput {\n if (this.required && value === undefined) {\n throw new BuildStepRuntimeError(\n `Input parameter \"${this.id}\" for step \"${this.stepDisplayName}\" is required.`\n );\n }\n\n this._value = value;\n return this;\n }\n\n public isValueOneOfAllowedValues(): boolean {\n const value = this._value ?? this.defaultValue;\n if (this.allowedValues === undefined || value === undefined) {\n return true;\n }\n return this.allowedValues.includes(value);\n }\n}\n\nexport function makeBuildStepInputByIdMap(inputs?: BuildStepInput[]): BuildStepInputById {\n if (inputs === undefined) {\n return {};\n }\n return inputs.reduce((acc, input) => {\n acc[input.id] = input;\n return acc;\n }, {} as BuildStepInputById);\n}\n"]}
|
|
@@ -33,6 +33,15 @@ export class BuildWorkflowValidator {
|
|
|
33
33
|
const visitedStepByStepId = {};
|
|
34
34
|
for (const currentStep of this.workflow.buildSteps) {
|
|
35
35
|
for (const currentStepInput of (_a = currentStep.inputs) !== null && _a !== void 0 ? _a : []) {
|
|
36
|
+
if (currentStepInput.required && currentStepInput.rawValue === undefined) {
|
|
37
|
+
const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is required but it was not set.`);
|
|
38
|
+
errors.push(error);
|
|
39
|
+
}
|
|
40
|
+
if (currentStepInput.rawValue !== undefined &&
|
|
41
|
+
typeof currentStepInput.rawValue !== currentStepInput.allowedValueTypeName) {
|
|
42
|
+
const error = new BuildConfigError(`Input parameter "${currentStepInput.id}" for step "${currentStep.displayName}" is set to "${currentStepInput.rawValue}" which is not of type "${currentStepInput.allowedValueTypeName}".`);
|
|
43
|
+
errors.push(error);
|
|
44
|
+
}
|
|
36
45
|
if (currentStepInput.defaultValue === undefined) {
|
|
37
46
|
continue;
|
|
38
47
|
}
|
|
@@ -42,7 +51,7 @@ export class BuildWorkflowValidator {
|
|
|
42
51
|
.join(', ')}.`);
|
|
43
52
|
errors.push(error);
|
|
44
53
|
}
|
|
45
|
-
const paths = typeof currentStepInput.defaultValue
|
|
54
|
+
const paths = typeof currentStepInput.defaultValue === 'string'
|
|
46
55
|
? findOutputPaths(currentStepInput.defaultValue)
|
|
47
56
|
: [];
|
|
48
57
|
for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildWorkflowValidator.js","sourceRoot":"","sources":["../src/BuildWorkflowValidator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,OAAO,sBAAsB;IACjC,YAA6B,QAAuB;QAAvB,aAAQ,GAAR,QAAQ,CAAe;IAAG,CAAC;IAEjD,QAAQ;QACb,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,IAAI,kBAAkB,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;SACpE;IACH,CAAC;IAEO,qBAAqB;QAC3B,MAAM,OAAO,GAAG,IAAI,CAA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AAC,KAAK,CAAC,CAAC;yBACpB;qBACF;yBAAM;wBACL,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,EAAE;4BACrF,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,oBAAoB,gBAAgB,CAAC,EAAE,eAAe,WAAW,CAAC,WAAW,uEAAuE,sBAAsB,gBAAgB,gBAAgB,IAAI,CAC/M,CAAC;4BACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;yBACpB;qBACF;iBACF;aACF;YACD,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;SACnD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,wBAAwB;QAC9B,MAAM,MAAM,GAAuB,EAAE,CAAC;QACtC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;YAC3C,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE;gBACrC,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAChC,SAAS,IAAI,CAAC,WAAW,iCACvB,IAAI,CAAC,GAAG,CAAC,eACX,2CAA2C,UAAU,CACnD,IAAI,CAAC,yBAAyB,EAC9B,uFAAuF,CACxF;qBACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;qBACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;gBACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACpB;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { BuildStep } from './BuildStep.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildConfigError, BuildWorkflowError } from './errors.js';\nimport { duplicates } from './utils/expodash/duplicates.js';\nimport { nullthrows } from './utils/nullthrows.js';\nimport { findOutputPaths } from './utils/template.js';\n\nexport class BuildWorkflowValidator {\n constructor(private readonly workflow: BuildWorkflow) {}\n\n public validate(): void {\n const errors: BuildConfigError[] = [];\n errors.push(...this.validateUniqueStepIds());\n errors.push(...this.validateInputs());\n errors.push(...this.validateAllowedPlatforms());\n if (errors.length !== 0) {\n throw new BuildWorkflowError('Build workflow is invalid.', errors);\n }\n }\n\n private validateUniqueStepIds(): BuildConfigError[] {\n const stepIds = this.workflow.buildSteps.map(({ id }) => id);\n const duplicatedStepIds = duplicates(stepIds);\n if (duplicatedStepIds.length === 0) {\n return [];\n } else {\n const error = new BuildConfigError(\n `Duplicated step IDs: ${duplicatedStepIds.map((i) => `\"${i}\"`).join(', ')}`\n );\n return [error];\n }\n }\n\n private validateInputs(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n\n const allStepIds = new Set(this.workflow.buildSteps.map((s) => s.id));\n const visitedStepByStepId: Record<string, BuildStep> = {};\n for (const currentStep of this.workflow.buildSteps) {\n for (const currentStepInput of currentStep.inputs ?? []) {\n if (currentStepInput.required && currentStepInput.rawValue === undefined) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is required but it was not set.`\n );\n errors.push(error);\n }\n\n if (\n currentStepInput.rawValue !== undefined &&\n typeof currentStepInput.rawValue !== currentStepInput.allowedValueTypeName\n ) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" is set to \"${currentStepInput.rawValue}\" which is not of type \"${currentStepInput.allowedValueTypeName}\".`\n );\n errors.push(error);\n }\n\n if (currentStepInput.defaultValue === undefined) {\n continue;\n }\n if (!currentStepInput.isValueOneOfAllowedValues()) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${\n currentStep.displayName\n }\" is set to \"${\n currentStepInput.value\n }\" which is not one of the allowed values: ${nullthrows(currentStepInput.allowedValues)\n .map((i) => `\"${i}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n const paths =\n typeof currentStepInput.defaultValue === 'string'\n ? findOutputPaths(currentStepInput.defaultValue)\n : [];\n for (const { stepId: referencedStepId, outputId: referencedStepOutputId } of paths) {\n if (!(referencedStepId in visitedStepByStepId)) {\n if (allStepIds.has(referencedStepId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from the future step \"${referencedStepId}\".`\n );\n errors.push(error);\n } else {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an output parameter from a non-existent step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n } else {\n if (!visitedStepByStepId[referencedStepId].hasOutputParameter(referencedStepOutputId)) {\n const error = new BuildConfigError(\n `Input parameter \"${currentStepInput.id}\" for step \"${currentStep.displayName}\" uses an expression that references an undefined output parameter \"${referencedStepOutputId}\" from step \"${referencedStepId}\".`\n );\n errors.push(error);\n }\n }\n }\n }\n visitedStepByStepId[currentStep.id] = currentStep;\n }\n\n return errors;\n }\n\n private validateAllowedPlatforms(): BuildConfigError[] {\n const errors: BuildConfigError[] = [];\n for (const step of this.workflow.buildSteps) {\n if (!step.canBeRunOnRuntimePlatform()) {\n const error = new BuildConfigError(\n `Step \"${step.displayName}\" is not allowed on platform \"${\n step.ctx.runtimePlatform\n }\". Allowed platforms for this step are: ${nullthrows(\n step.supportedRuntimePlatforms,\n `step.supportedRuntimePlatforms can't be falsy if canBeRunOnRuntimePlatform() is false`\n )\n .map((p) => `\"${p}\"`)\n .join(', ')}.`\n );\n errors.push(error);\n }\n }\n return errors;\n }\n}\n"]}
|
package/dist_esm/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { readAndValidateBuildConfigAsync } from './BuildConfig.js';
|
|
|
2
2
|
export { BuildConfigParser } from './BuildConfigParser.js';
|
|
3
3
|
export { BuildFunction } from './BuildFunction.js';
|
|
4
4
|
export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
5
|
-
export { BuildStepInput } from './BuildStepInput.js';
|
|
5
|
+
export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
6
6
|
export { BuildStepOutput } from './BuildStepOutput.js';
|
|
7
7
|
export { BuildStepContext } from './BuildStepContext.js';
|
|
8
8
|
export { BuildWorkflow } from './BuildWorkflow.js';
|
package/dist_esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { readAndValidateBuildConfigAsync } from './BuildConfig.js';
|
|
|
2
2
|
export { BuildConfigParser } from './BuildConfigParser.js';
|
|
3
3
|
export { BuildFunction } from './BuildFunction.js';
|
|
4
4
|
export { BuildRuntimePlatform } from './BuildRuntimePlatform.js';
|
|
5
|
-
export { BuildStepInput } from './BuildStepInput.js';
|
|
5
|
+
export { BuildStepInput, BuildStepInputValueTypeName } from './BuildStepInput.js';
|
|
6
6
|
export { BuildStepOutput } from './BuildStepOutput.js';
|
|
7
7
|
export { BuildStepContext } from './BuildStepContext.js';
|
|
8
8
|
export { BuildWorkflow } from './BuildWorkflow.js';
|
package/dist_esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC","sourcesContent":["export { 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 { BuildStepContext } from './BuildStepContext.js';\nexport { BuildWorkflow } from './BuildWorkflow.js';\nexport * as errors from './errors.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/steps",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.23",
|
|
5
5
|
"main": "./dist_commonjs/index.cjs",
|
|
6
6
|
"types": "./dist_esm/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"node": "18.13.0",
|
|
59
59
|
"yarn": "1.22.19"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "40fb0b2ffecf14b2cbd63dc51b910cf486351783"
|
|
62
62
|
}
|