@expo/steps 0.0.5 → 0.0.7
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/package.json +5 -1
- package/dist_commonjs/BuildArtifacts.cjs +0 -9
- package/dist_commonjs/BuildArtifacts.d.ts +0 -5
- package/dist_commonjs/BuildArtifacts.js.map +0 -1
- package/dist_commonjs/BuildConfig.cjs +0 -108
- package/dist_commonjs/BuildConfig.d.ts +0 -53
- package/dist_commonjs/BuildConfig.js.map +0 -1
- package/dist_commonjs/BuildConfigParser.cjs +0 -154
- package/dist_commonjs/BuildConfigParser.d.ts +0 -19
- package/dist_commonjs/BuildConfigParser.js.map +0 -1
- package/dist_commonjs/BuildFunction.cjs +0 -40
- package/dist_commonjs/BuildFunction.d.ts +0 -32
- package/dist_commonjs/BuildFunction.js.map +0 -1
- package/dist_commonjs/BuildPlatform.cjs +0 -9
- package/dist_commonjs/BuildPlatform.d.ts +0 -4
- package/dist_commonjs/BuildPlatform.js.map +0 -1
- package/dist_commonjs/BuildStep.cjs +0 -179
- package/dist_commonjs/BuildStep.d.ts +0 -48
- package/dist_commonjs/BuildStep.js.map +0 -1
- package/dist_commonjs/BuildStepContext.cjs +0 -32
- package/dist_commonjs/BuildStepContext.d.ts +0 -13
- package/dist_commonjs/BuildStepContext.js.map +0 -1
- package/dist_commonjs/BuildStepEnv.cjs +0 -3
- package/dist_commonjs/BuildStepEnv.d.ts +0 -1
- package/dist_commonjs/BuildStepEnv.js.map +0 -1
- package/dist_commonjs/BuildStepInput.cjs +0 -36
- package/dist_commonjs/BuildStepInput.d.ts +0 -18
- package/dist_commonjs/BuildStepInput.js.map +0 -1
- package/dist_commonjs/BuildStepOutput.cjs +0 -29
- package/dist_commonjs/BuildStepOutput.d.ts +0 -16
- package/dist_commonjs/BuildStepOutput.js.map +0 -1
- package/dist_commonjs/BuildTemporaryFiles.cjs +0 -100
- package/dist_commonjs/BuildTemporaryFiles.d.ts +0 -8
- package/dist_commonjs/BuildTemporaryFiles.js.map +0 -1
- package/dist_commonjs/BuildWorkflow.cjs +0 -32
- package/dist_commonjs/BuildWorkflow.d.ts +0 -17
- package/dist_commonjs/BuildWorkflow.js.map +0 -1
- package/dist_commonjs/BuildWorkflowValidator.cjs +0 -76
- package/dist_commonjs/BuildWorkflowValidator.d.ts +0 -8
- package/dist_commonjs/BuildWorkflowValidator.js.map +0 -1
- package/dist_commonjs/bin/uploadArtifact.cjs +0 -30
- package/dist_commonjs/bin/uploadArtifact.d.ts +0 -1
- package/dist_commonjs/bin/uploadArtifact.js.map +0 -1
- package/dist_commonjs/cli/cli.cjs +0 -37
- package/dist_commonjs/cli/cli.d.ts +0 -1
- package/dist_commonjs/cli/cli.js.map +0 -1
- package/dist_commonjs/errors/BuildConfigError.cjs +0 -8
- package/dist_commonjs/errors/BuildConfigError.d.ts +0 -3
- package/dist_commonjs/errors/BuildConfigError.js.map +0 -1
- package/dist_commonjs/errors/BuildInternalError.cjs +0 -7
- package/dist_commonjs/errors/BuildInternalError.d.ts +0 -2
- package/dist_commonjs/errors/BuildInternalError.js.map +0 -1
- package/dist_commonjs/errors/BuildStepRuntimeError.cjs +0 -8
- package/dist_commonjs/errors/BuildStepRuntimeError.d.ts +0 -3
- package/dist_commonjs/errors/BuildStepRuntimeError.js.map +0 -1
- package/dist_commonjs/errors/BuildWorkflowError.cjs +0 -13
- package/dist_commonjs/errors/BuildWorkflowError.d.ts +0 -10
- package/dist_commonjs/errors/BuildWorkflowError.js.map +0 -1
- package/dist_commonjs/errors/UserError.cjs +0 -14
- package/dist_commonjs/errors/UserError.d.ts +0 -9
- package/dist_commonjs/errors/UserError.js.map +0 -1
- package/dist_commonjs/index.cjs +0 -10
- package/dist_commonjs/index.d.ts +0 -3
- package/dist_commonjs/index.js.map +0 -1
- package/dist_commonjs/utils/expodash/uniq.cjs +0 -9
- package/dist_commonjs/utils/expodash/uniq.d.ts +0 -1
- package/dist_commonjs/utils/expodash/uniq.js.map +0 -1
- package/dist_commonjs/utils/nullthrows.cjs +0 -11
- package/dist_commonjs/utils/nullthrows.d.ts +0 -1
- package/dist_commonjs/utils/nullthrows.js.map +0 -1
- package/dist_commonjs/utils/shell/bin.cjs +0 -11
- package/dist_commonjs/utils/shell/bin.d.ts +0 -1
- package/dist_commonjs/utils/shell/bin.js.map +0 -1
- package/dist_commonjs/utils/shell/command.cjs +0 -36
- package/dist_commonjs/utils/shell/command.d.ts +0 -6
- package/dist_commonjs/utils/shell/command.js.map +0 -1
- package/dist_commonjs/utils/shell/spawn.cjs +0 -25
- package/dist_commonjs/utils/shell/spawn.d.ts +0 -9
- package/dist_commonjs/utils/shell/spawn.js.map +0 -1
- package/dist_commonjs/utils/template.cjs +0 -47
- package/dist_commonjs/utils/template.d.ts +0 -11
- package/dist_commonjs/utils/template.js.map +0 -1
- package/dist_esm/BuildArtifacts.d.ts +0 -5
- package/dist_esm/BuildArtifacts.js +0 -6
- package/dist_esm/BuildArtifacts.js.map +0 -1
- package/dist_esm/BuildConfig.d.ts +0 -53
- package/dist_esm/BuildConfig.js +0 -97
- package/dist_esm/BuildConfig.js.map +0 -1
- package/dist_esm/BuildConfigParser.d.ts +0 -19
- package/dist_esm/BuildConfigParser.js +0 -147
- package/dist_esm/BuildConfigParser.js.map +0 -1
- package/dist_esm/BuildFunction.d.ts +0 -32
- package/dist_esm/BuildFunction.js +0 -36
- package/dist_esm/BuildFunction.js.map +0 -1
- package/dist_esm/BuildPlatform.d.ts +0 -4
- package/dist_esm/BuildPlatform.js +0 -6
- package/dist_esm/BuildPlatform.js.map +0 -1
- package/dist_esm/BuildStep.d.ts +0 -48
- package/dist_esm/BuildStep.js +0 -172
- package/dist_esm/BuildStep.js.map +0 -1
- package/dist_esm/BuildStepContext.d.ts +0 -13
- package/dist_esm/BuildStepContext.js +0 -25
- package/dist_esm/BuildStepContext.js.map +0 -1
- package/dist_esm/BuildStepEnv.d.ts +0 -1
- package/dist_esm/BuildStepEnv.js +0 -2
- package/dist_esm/BuildStepEnv.js.map +0 -1
- package/dist_esm/BuildStepInput.d.ts +0 -18
- package/dist_esm/BuildStepInput.js +0 -32
- package/dist_esm/BuildStepInput.js.map +0 -1
- package/dist_esm/BuildStepOutput.d.ts +0 -16
- package/dist_esm/BuildStepOutput.js +0 -25
- package/dist_esm/BuildStepOutput.js.map +0 -1
- package/dist_esm/BuildTemporaryFiles.d.ts +0 -8
- package/dist_esm/BuildTemporaryFiles.js +0 -88
- package/dist_esm/BuildTemporaryFiles.js.map +0 -1
- package/dist_esm/BuildWorkflow.d.ts +0 -17
- package/dist_esm/BuildWorkflow.js +0 -28
- package/dist_esm/BuildWorkflow.js.map +0 -1
- package/dist_esm/BuildWorkflowValidator.d.ts +0 -8
- package/dist_esm/BuildWorkflowValidator.js +0 -72
- package/dist_esm/BuildWorkflowValidator.js.map +0 -1
- package/dist_esm/bin/uploadArtifact.d.ts +0 -1
- package/dist_esm/bin/uploadArtifact.js +0 -25
- package/dist_esm/bin/uploadArtifact.js.map +0 -1
- package/dist_esm/cli/cli.d.ts +0 -1
- package/dist_esm/cli/cli.js +0 -32
- package/dist_esm/cli/cli.js.map +0 -1
- package/dist_esm/errors/BuildConfigError.d.ts +0 -3
- package/dist_esm/errors/BuildConfigError.js +0 -4
- package/dist_esm/errors/BuildConfigError.js.map +0 -1
- package/dist_esm/errors/BuildInternalError.d.ts +0 -2
- package/dist_esm/errors/BuildInternalError.js +0 -3
- package/dist_esm/errors/BuildInternalError.js.map +0 -1
- package/dist_esm/errors/BuildStepRuntimeError.d.ts +0 -3
- package/dist_esm/errors/BuildStepRuntimeError.js +0 -4
- package/dist_esm/errors/BuildStepRuntimeError.js.map +0 -1
- package/dist_esm/errors/BuildWorkflowError.d.ts +0 -10
- package/dist_esm/errors/BuildWorkflowError.js +0 -9
- package/dist_esm/errors/BuildWorkflowError.js.map +0 -1
- package/dist_esm/errors/UserError.d.ts +0 -9
- package/dist_esm/errors/UserError.js +0 -10
- package/dist_esm/errors/UserError.js.map +0 -1
- package/dist_esm/index.d.ts +0 -3
- package/dist_esm/index.js +0 -4
- package/dist_esm/index.js.map +0 -1
- package/dist_esm/utils/expodash/uniq.d.ts +0 -1
- package/dist_esm/utils/expodash/uniq.js +0 -5
- package/dist_esm/utils/expodash/uniq.js.map +0 -1
- package/dist_esm/utils/nullthrows.d.ts +0 -1
- package/dist_esm/utils/nullthrows.js +0 -7
- package/dist_esm/utils/nullthrows.js.map +0 -1
- package/dist_esm/utils/shell/bin.d.ts +0 -1
- package/dist_esm/utils/shell/bin.js +0 -5
- package/dist_esm/utils/shell/bin.js.map +0 -1
- package/dist_esm/utils/shell/command.d.ts +0 -6
- package/dist_esm/utils/shell/command.js +0 -28
- package/dist_esm/utils/shell/command.js.map +0 -1
- package/dist_esm/utils/shell/spawn.d.ts +0 -9
- package/dist_esm/utils/shell/spawn.js +0 -18
- package/dist_esm/utils/shell/spawn.js.map +0 -1
- package/dist_esm/utils/template.d.ts +0 -11
- package/dist_esm/utils/template.js +0 -40
- package/dist_esm/utils/template.js.map +0 -1
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import { BuildPlatform } from './BuildPlatform.js';
|
|
3
|
-
export interface BuildConfig {
|
|
4
|
-
build: {
|
|
5
|
-
name?: string;
|
|
6
|
-
steps: BuildStepConfig[];
|
|
7
|
-
};
|
|
8
|
-
functions?: Record<string, BuildFunctionConfig>;
|
|
9
|
-
}
|
|
10
|
-
export type BuildStepConfig = BuildStepCommandRun | BuildStepBareCommandRun | BuildStepFunctionCall | BuildStepBareFunctionCall;
|
|
11
|
-
export type BuildStepCommandRun = {
|
|
12
|
-
run: BuildFunctionCallConfig & {
|
|
13
|
-
outputs?: BuildStepOutputs;
|
|
14
|
-
command: string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
export type BuildStepBareCommandRun = {
|
|
18
|
-
run: string;
|
|
19
|
-
};
|
|
20
|
-
export type BuildStepFunctionCall = {
|
|
21
|
-
[functionId: string]: BuildFunctionCallConfig;
|
|
22
|
-
};
|
|
23
|
-
export type BuildStepBareFunctionCall = string;
|
|
24
|
-
export type BuildFunctionCallConfig = {
|
|
25
|
-
id?: string;
|
|
26
|
-
inputs?: BuildStepInputs;
|
|
27
|
-
name?: string;
|
|
28
|
-
workingDirectory?: string;
|
|
29
|
-
shell?: string;
|
|
30
|
-
};
|
|
31
|
-
export type BuildStepInputs = Record<string, string>;
|
|
32
|
-
export type BuildStepOutputs = BuildInputOutputParameters;
|
|
33
|
-
export interface BuildFunctionConfig {
|
|
34
|
-
id?: string;
|
|
35
|
-
inputs?: BuildFunctionInputs;
|
|
36
|
-
outputs?: BuildFunctionOutputs;
|
|
37
|
-
name?: string;
|
|
38
|
-
platforms?: BuildPlatform[];
|
|
39
|
-
shell?: string;
|
|
40
|
-
command: string;
|
|
41
|
-
}
|
|
42
|
-
export type BuildFunctionInputs = BuildInputOutputParameters;
|
|
43
|
-
export type BuildFunctionOutputs = BuildInputOutputParameters;
|
|
44
|
-
export type BuildInputOutputParameters = (string | {
|
|
45
|
-
name: string;
|
|
46
|
-
required?: boolean;
|
|
47
|
-
})[];
|
|
48
|
-
export declare const BuildConfigSchema: Joi.ObjectSchema<BuildConfig>;
|
|
49
|
-
export declare function isBuildStepCommandRun(step: BuildStepConfig): step is BuildStepCommandRun;
|
|
50
|
-
export declare function isBuildStepBareCommandRun(step: BuildStepConfig): step is BuildStepBareCommandRun;
|
|
51
|
-
export declare function isBuildStepFunctionCall(step: BuildStepConfig): step is BuildStepFunctionCall;
|
|
52
|
-
export declare function isBuildStepBareFunctionCall(step: BuildStepConfig): step is BuildStepBareFunctionCall;
|
|
53
|
-
export declare function validateBuildConfig(rawConfig: object): BuildConfig;
|
package/dist_esm/BuildConfig.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import Joi from 'joi';
|
|
3
|
-
import { BuildConfigError } from './errors/BuildConfigError.js';
|
|
4
|
-
import { BuildPlatform } from './BuildPlatform.js';
|
|
5
|
-
const BuildInputOutputParametersSchema = Joi.array().items(Joi.alternatives().try(Joi.string().required(), Joi.object({
|
|
6
|
-
name: Joi.string().required(),
|
|
7
|
-
required: Joi.boolean(),
|
|
8
|
-
}).required()));
|
|
9
|
-
const BuildFunctionCallSchema = Joi.object({
|
|
10
|
-
id: Joi.string(),
|
|
11
|
-
inputs: Joi.object().pattern(Joi.string(), Joi.string()),
|
|
12
|
-
name: Joi.string(),
|
|
13
|
-
workingDirectory: Joi.string(),
|
|
14
|
-
shell: Joi.string(),
|
|
15
|
-
}).rename('working_directory', 'workingDirectory');
|
|
16
|
-
const BuildStepConfigSchema = Joi.any()
|
|
17
|
-
.when(Joi.object().pattern(Joi.string().disallow('run').required(), Joi.object().unknown().required()), {
|
|
18
|
-
then: Joi.object().pattern(Joi.string().disallow('run').min(1).required(), BuildFunctionCallSchema.required(), { matches: Joi.array().length(1) }),
|
|
19
|
-
})
|
|
20
|
-
.when(Joi.object({ run: Joi.object().unknown().required() }), {
|
|
21
|
-
then: Joi.object({
|
|
22
|
-
run: BuildFunctionCallSchema.keys({
|
|
23
|
-
outputs: BuildInputOutputParametersSchema,
|
|
24
|
-
command: Joi.string().required(),
|
|
25
|
-
}),
|
|
26
|
-
}),
|
|
27
|
-
})
|
|
28
|
-
.when(Joi.object({ run: Joi.string().required() }), {
|
|
29
|
-
then: Joi.object({
|
|
30
|
-
run: Joi.string().min(1).required(),
|
|
31
|
-
}),
|
|
32
|
-
})
|
|
33
|
-
.when(Joi.string(), {
|
|
34
|
-
then: Joi.string().min(1),
|
|
35
|
-
});
|
|
36
|
-
const BuildFunctionSchema = Joi.object({
|
|
37
|
-
id: Joi.string(),
|
|
38
|
-
name: Joi.string(),
|
|
39
|
-
platforms: Joi.string().allow(...Object.values(BuildPlatform)),
|
|
40
|
-
inputs: BuildInputOutputParametersSchema,
|
|
41
|
-
outputs: BuildInputOutputParametersSchema,
|
|
42
|
-
command: Joi.string().required(),
|
|
43
|
-
shell: Joi.string(),
|
|
44
|
-
});
|
|
45
|
-
export const BuildConfigSchema = Joi.object({
|
|
46
|
-
build: Joi.object({
|
|
47
|
-
name: Joi.string(),
|
|
48
|
-
steps: Joi.array().items(BuildStepConfigSchema.required()).required(),
|
|
49
|
-
}).required(),
|
|
50
|
-
functions: Joi.object().pattern(Joi.string().min(1).required().disallow('run'), BuildFunctionSchema.required()),
|
|
51
|
-
}).required();
|
|
52
|
-
export function isBuildStepCommandRun(step) {
|
|
53
|
-
return typeof step === 'object' && typeof step.run === 'object';
|
|
54
|
-
}
|
|
55
|
-
export function isBuildStepBareCommandRun(step) {
|
|
56
|
-
return typeof step === 'object' && typeof step.run === 'string';
|
|
57
|
-
}
|
|
58
|
-
export function isBuildStepFunctionCall(step) {
|
|
59
|
-
return typeof step === 'object' && !('run' in step);
|
|
60
|
-
}
|
|
61
|
-
export function isBuildStepBareFunctionCall(step) {
|
|
62
|
-
return typeof step === 'string';
|
|
63
|
-
}
|
|
64
|
-
export function validateBuildConfig(rawConfig) {
|
|
65
|
-
const { error, value: buildConfig } = BuildConfigSchema.validate(rawConfig, {
|
|
66
|
-
allowUnknown: false,
|
|
67
|
-
abortEarly: false,
|
|
68
|
-
});
|
|
69
|
-
if (error) {
|
|
70
|
-
const errorMessage = error.details.map(({ message }) => message).join(', ');
|
|
71
|
-
throw new BuildConfigError(errorMessage, { cause: error });
|
|
72
|
-
}
|
|
73
|
-
validateAllFunctionsExist(buildConfig);
|
|
74
|
-
return buildConfig;
|
|
75
|
-
}
|
|
76
|
-
function validateAllFunctionsExist(config) {
|
|
77
|
-
const calledFunctionsSet = new Set();
|
|
78
|
-
for (const step of config.build.steps) {
|
|
79
|
-
if (typeof step === 'string') {
|
|
80
|
-
calledFunctionsSet.add(step);
|
|
81
|
-
}
|
|
82
|
-
else if (!('run' in step)) {
|
|
83
|
-
const keys = Object.keys(step);
|
|
84
|
-
assert(keys.length === 1, 'There must be at most one function call in the step (enforced by joi)');
|
|
85
|
-
calledFunctionsSet.add(keys[0]);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const calledFunctions = Array.from(calledFunctionsSet);
|
|
89
|
-
const nonExistentFunctions = calledFunctions.filter((calledFunction) => {
|
|
90
|
-
var _a;
|
|
91
|
-
return !(calledFunction in ((_a = config.functions) !== null && _a !== void 0 ? _a : {}));
|
|
92
|
-
});
|
|
93
|
-
if (nonExistentFunctions.length > 0) {
|
|
94
|
-
throw new BuildConfigError(`Calling non-existent functions: ${nonExistentFunctions.join(', ')}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=BuildConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildConfig.js","sourceRoot":"","sources":["../src/BuildConfig.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA4DnD,MAAM,gCAAgC,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CACxD,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,CACpB,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EACvB,GAAG,CAAC,MAAM,CAAC;IACT,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE;CACxB,CAAC,CAAC,QAAQ,EAAE,CACd,CACF,CAAC;AAEF,MAAM,uBAAuB,GAAG,GAAG,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;I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I,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,uEAAuE,CACxE,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,oBAAoB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,EAAE;;QACrE,OAAO,CAAC,CAAC,cAAc,IAAI,CAAC,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE;QACnC,MAAM,IAAI,gBAAgB,CACxB,mCAAmC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrE,CAAC;KACH;AACH,CAAC","sourcesContent":["import assert from 'assert';\n\nimport Joi from 'joi';\n\nimport { BuildConfigError } from './errors/BuildConfigError.js';\nimport { BuildPlatform } from './BuildPlatform.js';\n\nexport interface BuildConfig {\n build: {\n name?: string;\n steps: BuildStepConfig[];\n };\n functions?: Record<string, BuildFunctionConfig>;\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>;\nexport type BuildStepOutputs = BuildInputOutputParameters;\n\nexport interface BuildFunctionConfig {\n id?: string;\n inputs?: BuildFunctionInputs;\n outputs?: BuildFunctionOutputs;\n name?: string;\n platforms?: BuildPlatform[];\n shell?: string;\n command: string;\n}\n\nexport type BuildFunctionInputs = BuildInputOutputParameters;\nexport type BuildFunctionOutputs = BuildInputOutputParameters;\n\nexport type BuildInputOutputParameters = (\n | string\n | {\n name: string;\n required?: boolean;\n }\n)[];\n\nconst BuildInputOutputParametersSchema = 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.string()),\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: BuildInputOutputParametersSchema,\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 BuildFunctionSchema = Joi.object({\n id: Joi.string(),\n name: Joi.string(),\n platforms: Joi.string().allow(...Object.values(BuildPlatform)),\n inputs: BuildInputOutputParametersSchema,\n outputs: BuildInputOutputParametersSchema,\n command: Joi.string().required(),\n shell: Joi.string(),\n});\n\nexport const BuildConfigSchema = Joi.object<BuildConfig>({\n build: Joi.object({\n name: Joi.string(),\n steps: Joi.array().items(BuildStepConfigSchema.required()).required(),\n }).required(),\n functions: Joi.object().pattern(\n Joi.string().min(1).required().disallow('run'),\n BuildFunctionSchema.required()\n ),\n}).required();\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 validateBuildConfig(rawConfig: object): BuildConfig {\n const { error, value: buildConfig } = BuildConfigSchema.validate(rawConfig, {\n allowUnknown: false,\n abortEarly: false,\n });\n if (error) {\n const errorMessage = error.details.map(({ message }) => message).join(', ');\n throw new BuildConfigError(errorMessage, { cause: error });\n }\n validateAllFunctionsExist(buildConfig);\n return buildConfig;\n}\n\nfunction validateAllFunctionsExist(config: BuildConfig): 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 nonExistentFunctions = calledFunctions.filter((calledFunction) => {\n return !(calledFunction in (config.functions ?? {}));\n });\n if (nonExistentFunctions.length > 0) {\n throw new BuildConfigError(\n `Calling non-existent functions: ${nonExistentFunctions.join(', ')}`\n );\n }\n}\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BuildStepContext } from './BuildStepContext.js';
|
|
2
|
-
import { BuildWorkflow } from './BuildWorkflow.js';
|
|
3
|
-
export declare class BuildConfigParser {
|
|
4
|
-
private readonly ctx;
|
|
5
|
-
private readonly configPath;
|
|
6
|
-
constructor(ctx: BuildStepContext, { configPath }: {
|
|
7
|
-
configPath: string;
|
|
8
|
-
});
|
|
9
|
-
parseAsync(): Promise<BuildWorkflow>;
|
|
10
|
-
private readRawConfigAsync;
|
|
11
|
-
private createBuildStepFromConfig;
|
|
12
|
-
private createBuildFunctionsFromConfig;
|
|
13
|
-
private createBuildFunctionFromConfig;
|
|
14
|
-
private createBuildStepInputsFromBuildStepInputsDefinition;
|
|
15
|
-
private createBuildStepInputCreatorsFromBuildFunctionInputs;
|
|
16
|
-
private createBuildStepOutputsFromDefinition;
|
|
17
|
-
private createBuildStepOutputCreatorsFromBuildFunctionOutputs;
|
|
18
|
-
private getStepWorkingDirectory;
|
|
19
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import fs from 'fs/promises';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
import YAML from 'yaml';
|
|
6
|
-
import { isBuildStepBareCommandRun, isBuildStepBareFunctionCall, isBuildStepCommandRun, validateBuildConfig, } from './BuildConfig.js';
|
|
7
|
-
import { BuildFunction } from './BuildFunction.js';
|
|
8
|
-
import { BuildStep } from './BuildStep.js';
|
|
9
|
-
import { BuildStepInput } from './BuildStepInput.js';
|
|
10
|
-
import { BuildStepOutput } from './BuildStepOutput.js';
|
|
11
|
-
import { BuildWorkflow } from './BuildWorkflow.js';
|
|
12
|
-
import { BuildWorkflowValidator } from './BuildWorkflowValidator.js';
|
|
13
|
-
export class BuildConfigParser {
|
|
14
|
-
constructor(ctx, { configPath }) {
|
|
15
|
-
this.ctx = ctx;
|
|
16
|
-
this.configPath = configPath;
|
|
17
|
-
}
|
|
18
|
-
async parseAsync() {
|
|
19
|
-
const rawConfig = await this.readRawConfigAsync();
|
|
20
|
-
const config = validateBuildConfig(rawConfig);
|
|
21
|
-
const buildFunctions = this.createBuildFunctionsFromConfig(config.functions);
|
|
22
|
-
const buildSteps = config.build.steps.map((stepConfig) => this.createBuildStepFromConfig(stepConfig, buildFunctions));
|
|
23
|
-
const workflow = new BuildWorkflow(this.ctx, { buildSteps, buildFunctions });
|
|
24
|
-
new BuildWorkflowValidator(workflow).validate();
|
|
25
|
-
return workflow;
|
|
26
|
-
}
|
|
27
|
-
async readRawConfigAsync() {
|
|
28
|
-
const contents = await fs.readFile(this.configPath, 'utf-8');
|
|
29
|
-
return YAML.parse(contents);
|
|
30
|
-
}
|
|
31
|
-
createBuildStepFromConfig(buildStepConfig, buildFunctions) {
|
|
32
|
-
if (isBuildStepCommandRun(buildStepConfig)) {
|
|
33
|
-
const { id, inputs: inputsConfig, outputs: outputsConfig, name, workingDirectory, shell, command, } = buildStepConfig.run;
|
|
34
|
-
const stepId = id !== null && id !== void 0 ? id : uuidv4();
|
|
35
|
-
const inputs = inputsConfig &&
|
|
36
|
-
this.createBuildStepInputsFromBuildStepInputsDefinition(inputsConfig, stepId);
|
|
37
|
-
const outputs = outputsConfig && this.createBuildStepOutputsFromDefinition(outputsConfig, stepId);
|
|
38
|
-
return new BuildStep(this.ctx, {
|
|
39
|
-
id: stepId,
|
|
40
|
-
inputs,
|
|
41
|
-
outputs,
|
|
42
|
-
name,
|
|
43
|
-
workingDirectory: this.getStepWorkingDirectory(workingDirectory),
|
|
44
|
-
shell,
|
|
45
|
-
command,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
else if (isBuildStepBareCommandRun(buildStepConfig)) {
|
|
49
|
-
const command = buildStepConfig.run;
|
|
50
|
-
return new BuildStep(this.ctx, {
|
|
51
|
-
id: uuidv4(),
|
|
52
|
-
workingDirectory: this.ctx.workingDirectory,
|
|
53
|
-
command,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else if (isBuildStepBareFunctionCall(buildStepConfig)) {
|
|
57
|
-
const functionId = buildStepConfig;
|
|
58
|
-
const buildFunction = buildFunctions[functionId];
|
|
59
|
-
return buildFunction.createBuildStepFromFunctionCall({
|
|
60
|
-
workingDirectory: this.getStepWorkingDirectory(),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
const keys = Object.keys(buildStepConfig);
|
|
65
|
-
assert(keys.length === 1, 'There must be at most one function call in the step (enforced by joi)');
|
|
66
|
-
const functionId = keys[0];
|
|
67
|
-
const buildFunctionCallConfig = buildStepConfig[functionId];
|
|
68
|
-
const buildFunction = buildFunctions[functionId];
|
|
69
|
-
return buildFunction.createBuildStepFromFunctionCall({
|
|
70
|
-
id: buildFunctionCallConfig.id,
|
|
71
|
-
callInputs: buildFunctionCallConfig.inputs,
|
|
72
|
-
workingDirectory: this.getStepWorkingDirectory(buildFunctionCallConfig.workingDirectory),
|
|
73
|
-
shell: buildFunctionCallConfig.shell,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
createBuildFunctionsFromConfig(buildFunctionsConfig) {
|
|
78
|
-
if (!buildFunctionsConfig) {
|
|
79
|
-
return {};
|
|
80
|
-
}
|
|
81
|
-
const result = {};
|
|
82
|
-
for (const [functionId, buildFunctionConfig] of Object.entries(buildFunctionsConfig)) {
|
|
83
|
-
result[functionId] = this.createBuildFunctionFromConfig(buildFunctionConfig);
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
createBuildFunctionFromConfig({ id, name, inputs: inputsConfig, outputs: outputsConfig, shell, command, }) {
|
|
88
|
-
const inputCreators = inputsConfig && this.createBuildStepInputCreatorsFromBuildFunctionInputs(inputsConfig);
|
|
89
|
-
const outputCreators = outputsConfig && this.createBuildStepOutputCreatorsFromBuildFunctionOutputs(outputsConfig);
|
|
90
|
-
return new BuildFunction(this.ctx, { id, name, inputCreators, outputCreators, shell, command });
|
|
91
|
-
}
|
|
92
|
-
createBuildStepInputsFromBuildStepInputsDefinition(buildStepInputs, stepId) {
|
|
93
|
-
return Object.entries(buildStepInputs).map(([key, value]) => new BuildStepInput(this.ctx, {
|
|
94
|
-
id: key,
|
|
95
|
-
stepId,
|
|
96
|
-
defaultValue: value,
|
|
97
|
-
required: true,
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
createBuildStepInputCreatorsFromBuildFunctionInputs(buildFunctionInputs) {
|
|
101
|
-
return buildFunctionInputs.map((entry) => {
|
|
102
|
-
if (typeof entry === 'string') {
|
|
103
|
-
return (stepId) => new BuildStepInput(this.ctx, { id: entry, stepId });
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
return (stepId) => {
|
|
107
|
-
var _a;
|
|
108
|
-
return new BuildStepInput(this.ctx, {
|
|
109
|
-
id: entry.name,
|
|
110
|
-
required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
|
|
111
|
-
stepId,
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
createBuildStepOutputsFromDefinition(buildStepOutputs, stepId) {
|
|
118
|
-
return buildStepOutputs.map((entry) => {
|
|
119
|
-
var _a;
|
|
120
|
-
return typeof entry === 'string'
|
|
121
|
-
? new BuildStepOutput(this.ctx, { id: entry, stepId, required: true })
|
|
122
|
-
: new BuildStepOutput(this.ctx, {
|
|
123
|
-
id: entry.name,
|
|
124
|
-
stepId,
|
|
125
|
-
required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
createBuildStepOutputCreatorsFromBuildFunctionOutputs(buildFunctionOutputs) {
|
|
130
|
-
return buildFunctionOutputs.map((entry) => typeof entry === 'string'
|
|
131
|
-
? (stepId) => new BuildStepOutput(this.ctx, { id: entry, stepId, required: true })
|
|
132
|
-
: (stepId) => {
|
|
133
|
-
var _a;
|
|
134
|
-
return new BuildStepOutput(this.ctx, {
|
|
135
|
-
id: entry.name,
|
|
136
|
-
stepId,
|
|
137
|
-
required: (_a = entry.required) !== null && _a !== void 0 ? _a : true,
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
getStepWorkingDirectory(workingDirectory) {
|
|
142
|
-
return workingDirectory !== undefined
|
|
143
|
-
? path.resolve(this.ctx.workingDirectory, workingDirectory)
|
|
144
|
-
: this.ctx.workingDirectory;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=BuildConfigParser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildConfigParser.js","sourceRoot":"","sources":["../src/BuildConfigParser.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAQL,yBAAyB,EACzB,2BAA2B,EAC3B,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAyB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAA0B,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,OAAO,iBAAiB;IAG5B,YAA6B,GAAqB,EAAE,EAAE,UAAU,EAA0B;QAA7D,Q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AAoB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACxC,OAAO,KAAK,KAAK,QAAQ;YACvB,CAAC,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YAC1F,CAAC,CAAC,CAAC,MAAc,EAAE,EAAE;;gBACjB,OAAA,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE;oBAC5B,EAAE,EAAE,KAAK,CAAC,IAAI;oBACd,MAAM;oBACN,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,mCAAI,IAAI;iBACjC,CAAC,CAAA;aAAA,CACT,CAAC;IACJ,CAAC;IAEO,uBAAuB,CAAC,gBAAyB;QACvD,OAAO,gBAAgB,KAAK,SAAS;YACnC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;YAC3D,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAChC,CAAC;CACF","sourcesContent":["import assert from 'assert';\nimport fs from 'fs/promises';\nimport path from 'path';\n\nimport { v4 as uuidv4 } from 'uuid';\nimport YAML from 'yaml';\n\nimport {\n BuildConfig,\n BuildFunctionConfig,\n BuildFunctionInputs,\n BuildFunctionOutputs,\n BuildStepConfig,\n BuildStepInputs,\n BuildStepOutputs,\n isBuildStepBareCommandRun,\n isBuildStepBareFunctionCall,\n isBuildStepCommandRun,\n validateBuildConfig,\n} from './BuildConfig.js';\nimport { BuildFunction, BuildFunctionById } from './BuildFunction.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInput, BuildStepInputCreator } from './BuildStepInput.js';\nimport { BuildStepOutput, BuildStepOutputCreator } from './BuildStepOutput.js';\nimport { BuildWorkflow } from './BuildWorkflow.js';\nimport { BuildWorkflowValidator } from './BuildWorkflowValidator.js';\n\nexport class BuildConfigParser {\n private readonly configPath: string;\n\n constructor(private readonly ctx: BuildStepContext, { configPath }: { configPath: string }) {\n this.configPath = configPath;\n }\n\n public async parseAsync(): Promise<BuildWorkflow> {\n const rawConfig = await this.readRawConfigAsync();\n const config = validateBuildConfig(rawConfig);\n const buildFunctions = this.createBuildFunctionsFromConfig(config.functions);\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 async readRawConfigAsync(): Promise<any> {\n const contents = await fs.readFile(this.configPath, 'utf-8');\n return YAML.parse(contents);\n }\n\n private createBuildStepFromConfig(\n buildStepConfig: BuildStepConfig,\n buildFunctions: BuildFunctionById\n ): BuildStep {\n if (isBuildStepCommandRun(buildStepConfig)) {\n const {\n id,\n inputs: inputsConfig,\n outputs: outputsConfig,\n name,\n workingDirectory,\n shell,\n command,\n } = buildStepConfig.run;\n const stepId = id ?? uuidv4();\n const inputs =\n inputsConfig &&\n this.createBuildStepInputsFromBuildStepInputsDefinition(inputsConfig, stepId);\n const outputs =\n outputsConfig && this.createBuildStepOutputsFromDefinition(outputsConfig, stepId);\n return new BuildStep(this.ctx, {\n id: stepId,\n inputs,\n outputs,\n name,\n workingDirectory: this.getStepWorkingDirectory(workingDirectory),\n shell,\n command,\n });\n } else if (isBuildStepBareCommandRun(buildStepConfig)) {\n const command = buildStepConfig.run;\n return new BuildStep(this.ctx, {\n id: uuidv4(),\n workingDirectory: this.ctx.workingDirectory,\n command,\n });\n } else if (isBuildStepBareFunctionCall(buildStepConfig)) {\n const functionId = buildStepConfig;\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall({\n workingDirectory: this.getStepWorkingDirectory(),\n });\n } else {\n const keys = Object.keys(buildStepConfig);\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 = buildStepConfig[functionId];\n const buildFunction = buildFunctions[functionId];\n return buildFunction.createBuildStepFromFunctionCall({\n id: buildFunctionCallConfig.id,\n callInputs: buildFunctionCallConfig.inputs,\n workingDirectory: this.getStepWorkingDirectory(buildFunctionCallConfig.workingDirectory),\n shell: buildFunctionCallConfig.shell,\n });\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 result[functionId] = this.createBuildFunctionFromConfig(buildFunctionConfig);\n }\n return result;\n }\n\n private createBuildFunctionFromConfig({\n id,\n name,\n inputs: inputsConfig,\n outputs: outputsConfig,\n shell,\n command,\n }: BuildFunctionConfig): BuildFunction {\n const inputCreators =\n inputsConfig && this.createBuildStepInputCreatorsFromBuildFunctionInputs(inputsConfig);\n const outputCreators =\n outputsConfig && this.createBuildStepOutputCreatorsFromBuildFunctionOutputs(outputsConfig);\n return new BuildFunction(this.ctx, { id, name, inputCreators, outputCreators, shell, command });\n }\n\n private createBuildStepInputsFromBuildStepInputsDefinition(\n buildStepInputs: BuildStepInputs,\n stepId: string\n ): BuildStepInput[] {\n return Object.entries(buildStepInputs).map(\n ([key, value]) =>\n new BuildStepInput(this.ctx, {\n id: key,\n stepId,\n defaultValue: value,\n required: true,\n })\n );\n }\n\n private createBuildStepInputCreatorsFromBuildFunctionInputs(\n buildFunctionInputs: BuildFunctionInputs\n ): BuildStepInputCreator[] {\n return buildFunctionInputs.map((entry) => {\n if (typeof entry === 'string') {\n return (stepId: string) => new BuildStepInput(this.ctx, { id: entry, stepId });\n } else {\n return (stepId: string) =>\n new BuildStepInput(this.ctx, {\n id: entry.name,\n required: entry.required ?? true,\n stepId,\n });\n }\n });\n }\n\n private createBuildStepOutputsFromDefinition(\n buildStepOutputs: BuildStepOutputs,\n stepId: string\n ): BuildStepOutput[] {\n return buildStepOutputs.map((entry) =>\n typeof entry === 'string'\n ? new BuildStepOutput(this.ctx, { id: entry, stepId, required: true })\n : new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepId,\n required: entry.required ?? true,\n })\n );\n }\n\n private createBuildStepOutputCreatorsFromBuildFunctionOutputs(\n buildFunctionOutputs: BuildFunctionOutputs\n ): BuildStepOutputCreator[] {\n return buildFunctionOutputs.map((entry) =>\n typeof entry === 'string'\n ? (stepId: string) => new BuildStepOutput(this.ctx, { id: entry, stepId, required: true })\n : (stepId: string) =>\n new BuildStepOutput(this.ctx, {\n id: entry.name,\n stepId,\n required: entry.required ?? true,\n })\n );\n }\n\n private getStepWorkingDirectory(workingDirectory?: string): string {\n return workingDirectory !== undefined\n ? path.resolve(this.ctx.workingDirectory, workingDirectory)\n : this.ctx.workingDirectory;\n }\n}\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { BuildPlatform } from './BuildPlatform.js';
|
|
2
|
-
import { BuildStep } from './BuildStep.js';
|
|
3
|
-
import { BuildStepContext } from './BuildStepContext.js';
|
|
4
|
-
import { BuildStepInputCreator } from './BuildStepInput.js';
|
|
5
|
-
import { BuildStepOutputCreator } from './BuildStepOutput.js';
|
|
6
|
-
export type BuildFunctionById = Record<string, BuildFunction>;
|
|
7
|
-
export type BuildFunctionCallInputs = Record<string, string>;
|
|
8
|
-
export declare class BuildFunction {
|
|
9
|
-
private readonly ctx;
|
|
10
|
-
readonly id?: string;
|
|
11
|
-
readonly name?: string;
|
|
12
|
-
readonly platforms?: BuildPlatform[];
|
|
13
|
-
readonly inputCreators?: BuildStepInputCreator[];
|
|
14
|
-
readonly outputCreators?: BuildStepOutputCreator[];
|
|
15
|
-
readonly command: string;
|
|
16
|
-
readonly shell?: string;
|
|
17
|
-
constructor(ctx: BuildStepContext, { id, name, platforms, inputCreators, outputCreators, command, shell, }: {
|
|
18
|
-
id?: string;
|
|
19
|
-
name?: string;
|
|
20
|
-
platforms?: BuildPlatform[];
|
|
21
|
-
inputCreators?: BuildStepInputCreator[];
|
|
22
|
-
outputCreators?: BuildStepOutputCreator[];
|
|
23
|
-
command: string;
|
|
24
|
-
shell?: string;
|
|
25
|
-
});
|
|
26
|
-
createBuildStepFromFunctionCall({ id, callInputs, workingDirectory, shell, }: {
|
|
27
|
-
id?: string;
|
|
28
|
-
callInputs?: BuildFunctionCallInputs;
|
|
29
|
-
workingDirectory: string;
|
|
30
|
-
shell?: string;
|
|
31
|
-
}): BuildStep;
|
|
32
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { BuildStep } from './BuildStep.js';
|
|
3
|
-
export class BuildFunction {
|
|
4
|
-
constructor(ctx, { id, name, platforms, inputCreators, outputCreators, command, shell, }) {
|
|
5
|
-
this.ctx = ctx;
|
|
6
|
-
this.id = id;
|
|
7
|
-
this.name = name;
|
|
8
|
-
this.platforms = platforms;
|
|
9
|
-
this.inputCreators = inputCreators;
|
|
10
|
-
this.outputCreators = outputCreators;
|
|
11
|
-
this.command = command;
|
|
12
|
-
this.shell = shell;
|
|
13
|
-
}
|
|
14
|
-
createBuildStepFromFunctionCall({ id, callInputs = {}, workingDirectory, shell, }) {
|
|
15
|
-
var _a, _b, _c;
|
|
16
|
-
const buildStepId = (_a = id !== null && id !== void 0 ? id : this.id) !== null && _a !== void 0 ? _a : uuidv4();
|
|
17
|
-
const inputs = (_b = this.inputCreators) === null || _b === void 0 ? void 0 : _b.map((inputCreator) => {
|
|
18
|
-
const input = inputCreator(buildStepId);
|
|
19
|
-
if (input.id in callInputs) {
|
|
20
|
-
input.set(callInputs[input.id]);
|
|
21
|
-
}
|
|
22
|
-
return input;
|
|
23
|
-
});
|
|
24
|
-
const outputs = (_c = this.outputCreators) === null || _c === void 0 ? void 0 : _c.map((outputCreator) => outputCreator(buildStepId));
|
|
25
|
-
return new BuildStep(this.ctx, {
|
|
26
|
-
id: buildStepId,
|
|
27
|
-
name: this.name,
|
|
28
|
-
command: this.command,
|
|
29
|
-
workingDirectory,
|
|
30
|
-
inputs,
|
|
31
|
-
outputs,
|
|
32
|
-
shell,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=BuildFunction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildFunction.js","sourceRoot":"","sources":["../src/BuildFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAQ3C,MAAM,OAAO,aAAa;IASxB,YACmB,GAAqB,EACtC,EACE,EAAE,EACF,IAAI,EACJ,SAAS,EACT,aAAa,EACb,cAAc,EACd,OAAO,EACP,KAAK,GASN;QAjBgB,QAAG,GAAH,GAAG,CAAkB;QAmBtC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEM,+BAA+B,CAAC,EACrC,EAAE,EACF,UAAU,GAAG,EAAE,EACf,gBAAgB,EAChB,KAAK,GAMN;;QACC,MAAM,WAAW,GAAG,MAAA,EAAE,aAAF,EAAE,cAAF,EAAE,GAAI,IAAI,CAAC,EAAE,mCAAI,MAAM,EAAE,CAAC;QAE9C,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,aAAa,0CAAE,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;YACtD,MAAM,KAAK,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;YACxC,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,cAAc,0CAAE,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;QAExF,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;YAC7B,EAAE,EAAE,WAAW;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,gBAAgB;YAChB,MAAM;YACN,OAAO;YACP,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { v4 as uuidv4 } from 'uuid';\n\nimport { BuildPlatform } from './BuildPlatform.js';\nimport { BuildStep } from './BuildStep.js';\nimport { BuildStepContext } from './BuildStepContext.js';\nimport { BuildStepInputCreator } from './BuildStepInput.js';\nimport { BuildStepOutputCreator } from './BuildStepOutput.js';\n\nexport type BuildFunctionById = Record<string, BuildFunction>;\nexport type BuildFunctionCallInputs = Record<string, string>;\n\nexport class BuildFunction {\n public readonly id?: string;\n public readonly name?: string;\n public readonly platforms?: BuildPlatform[];\n public readonly inputCreators?: BuildStepInputCreator[];\n public readonly outputCreators?: BuildStepOutputCreator[];\n public readonly command: string;\n public readonly shell?: string;\n\n constructor(\n private readonly ctx: BuildStepContext,\n {\n id,\n name,\n platforms,\n inputCreators,\n outputCreators,\n command,\n shell,\n }: {\n id?: string;\n name?: string;\n platforms?: BuildPlatform[];\n inputCreators?: BuildStepInputCreator[];\n outputCreators?: BuildStepOutputCreator[];\n command: string;\n shell?: string;\n }\n ) {\n this.id = id;\n this.name = name;\n this.platforms = platforms;\n this.inputCreators = inputCreators;\n this.outputCreators = outputCreators;\n this.command = command;\n this.shell = shell;\n }\n\n public createBuildStepFromFunctionCall({\n id,\n callInputs = {},\n workingDirectory,\n shell,\n }: {\n id?: string;\n callInputs?: BuildFunctionCallInputs;\n workingDirectory: string;\n shell?: string;\n }): BuildStep {\n const buildStepId = id ?? this.id ?? uuidv4();\n\n const inputs = this.inputCreators?.map((inputCreator) => {\n const input = inputCreator(buildStepId);\n if (input.id in callInputs) {\n input.set(callInputs[input.id]);\n }\n return input;\n });\n const outputs = this.outputCreators?.map((outputCreator) => outputCreator(buildStepId));\n\n return new BuildStep(this.ctx, {\n id: buildStepId,\n name: this.name,\n command: this.command,\n workingDirectory,\n inputs,\n outputs,\n shell,\n });\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BuildPlatform.js","sourceRoot":"","sources":["../src/BuildPlatform.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,gCAAe,CAAA;AACjB,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB","sourcesContent":["export enum BuildPlatform {\n DARWIN = 'darwin',\n LINUX = 'linux',\n}\n"]}
|
package/dist_esm/BuildStep.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { BuildStepContext } from './BuildStepContext.js';
|
|
2
|
-
import { BuildStepInput } from './BuildStepInput.js';
|
|
3
|
-
import { BuildStepOutput } from './BuildStepOutput.js';
|
|
4
|
-
import { BuildStepEnv } from './BuildStepEnv.js';
|
|
5
|
-
export declare enum BuildStepStatus {
|
|
6
|
-
NEW = "new",
|
|
7
|
-
IN_PROGRESS = "in-progress",
|
|
8
|
-
CANCELED = "canceled",
|
|
9
|
-
FAIL = "fail",
|
|
10
|
-
WARNING = "warning",
|
|
11
|
-
SUCCESS = "success"
|
|
12
|
-
}
|
|
13
|
-
export declare enum BuildStepLogMarker {
|
|
14
|
-
START_STEP = "start-step",
|
|
15
|
-
END_STEP = "end-step"
|
|
16
|
-
}
|
|
17
|
-
export declare class BuildStep {
|
|
18
|
-
private readonly ctx;
|
|
19
|
-
readonly id: string;
|
|
20
|
-
readonly name?: string;
|
|
21
|
-
readonly displayName?: string;
|
|
22
|
-
readonly inputs?: BuildStepInput[];
|
|
23
|
-
readonly outputs?: BuildStepOutput[];
|
|
24
|
-
readonly command: string;
|
|
25
|
-
readonly workingDirectory: string;
|
|
26
|
-
readonly shell: string;
|
|
27
|
-
status: BuildStepStatus;
|
|
28
|
-
private readonly internalId;
|
|
29
|
-
private readonly logger;
|
|
30
|
-
private readonly outputById;
|
|
31
|
-
private executed;
|
|
32
|
-
constructor(ctx: BuildStepContext, { id, name, inputs, outputs, command, workingDirectory, shell, }: {
|
|
33
|
-
id: string;
|
|
34
|
-
name?: string;
|
|
35
|
-
inputs?: BuildStepInput[];
|
|
36
|
-
outputs?: BuildStepOutput[];
|
|
37
|
-
command: string;
|
|
38
|
-
workingDirectory: string;
|
|
39
|
-
shell?: string;
|
|
40
|
-
});
|
|
41
|
-
executeAsync(env?: BuildStepEnv): Promise<void>;
|
|
42
|
-
hasOutputParameter(name: string): boolean;
|
|
43
|
-
getOutputValueByName(name: string): string | undefined;
|
|
44
|
-
private interpolateInputsInCommand;
|
|
45
|
-
private collectAndValidateOutputsAsync;
|
|
46
|
-
private getScriptEnv;
|
|
47
|
-
private getStepDisplayName;
|
|
48
|
-
}
|