@catladder/pipeline 1.149.2 → 1.149.4
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/build/base/createAppBuildJob.js +1 -2
- package/dist/build/base/writeDotEnv.d.ts +2 -1
- package/dist/build/base/writeDotEnv.js +7 -2
- package/dist/build/node/buildJob.js +4 -4
- package/dist/build/node/cache.js +5 -6
- package/dist/build/node/testJob.js +9 -9
- package/dist/build/node/yarn.js +3 -6
- package/dist/build/sbom.js +4 -4
- package/dist/bundles/catladder-gitlab/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.d.ts +1 -2
- package/dist/context/createComponentContext.js +8 -4
- package/dist/pipeline/createAllJobs.js +75 -7
- package/dist/pipeline/createJobsForComponent.d.ts +3 -3
- package/dist/pipeline/createJobsForComponent.js +3 -143
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +2 -2
- package/package.json +1 -1
- package/src/build/base/createAppBuildJob.ts +5 -2
- package/src/build/base/writeDotEnv.ts +6 -0
- package/src/build/node/buildJob.ts +2 -2
- package/src/build/node/cache.ts +3 -3
- package/src/build/node/testJob.ts +1 -1
- package/src/build/node/yarn.ts +3 -3
- package/src/build/sbom.ts +1 -1
- package/src/context/createComponentContext.ts +9 -4
- package/src/pipeline/createAllJobs.ts +44 -9
- package/src/pipeline/createJobsForComponent.ts +4 -25
- package/src/types/context.ts +2 -2
|
@@ -5,11 +5,12 @@ import { DEPLOY_TYPES } from "../deploy";
|
|
|
5
5
|
import type { DeployConfig, DeployConfigType } from "../deploy/types";
|
|
6
6
|
import type { PipelineType } from "../types";
|
|
7
7
|
import type { Config, PipelineTrigger } from "../types/config";
|
|
8
|
-
import type { ComponentContext
|
|
8
|
+
import type { ComponentContext } from "../types/context";
|
|
9
9
|
import type { PartialDeep } from "../types/utils";
|
|
10
10
|
import { mergeWithMergingArrays } from "../utils";
|
|
11
11
|
import { getEnvironment } from "./getEnvironment";
|
|
12
12
|
import { getEnvironmentContext } from "./getEnvironmentContext";
|
|
13
|
+
import { getPackageManagerInfo } from "../pipeline/packageManager";
|
|
13
14
|
|
|
14
15
|
export type CreateComponentContextContext = {
|
|
15
16
|
config: Config;
|
|
@@ -17,7 +18,6 @@ export type CreateComponentContextContext = {
|
|
|
17
18
|
env: string;
|
|
18
19
|
pipelineType?: PipelineType;
|
|
19
20
|
trigger?: PipelineTrigger;
|
|
20
|
-
packageManagerInfo?: PackageManagerInfo;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
export const createComponentContext = async (
|
|
@@ -29,6 +29,11 @@ export const createComponentContext = async (
|
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const packageManagerInfo = await getPackageManagerInfo(
|
|
33
|
+
ctx.config,
|
|
34
|
+
ctx.componentName,
|
|
35
|
+
);
|
|
36
|
+
|
|
32
37
|
const envContext = getEnvironmentContext(ctx);
|
|
33
38
|
|
|
34
39
|
const componentConfigWithoutDefaults = envContext.envConfigRaw;
|
|
@@ -62,7 +67,7 @@ export const createComponentContext = async (
|
|
|
62
67
|
|
|
63
68
|
build: {
|
|
64
69
|
dir: dir,
|
|
65
|
-
packageManagerInfo:
|
|
70
|
+
packageManagerInfo: packageManagerInfo,
|
|
66
71
|
config: build,
|
|
67
72
|
},
|
|
68
73
|
deploy: deploy
|
|
@@ -72,7 +77,7 @@ export const createComponentContext = async (
|
|
|
72
77
|
: null,
|
|
73
78
|
componentName: ctx.componentName,
|
|
74
79
|
environment,
|
|
75
|
-
packageManagerInfo:
|
|
80
|
+
packageManagerInfo: packageManagerInfo,
|
|
76
81
|
pipelineType: ctx.pipelineType,
|
|
77
82
|
trigger: ctx.trigger,
|
|
78
83
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { getAllEnvsByTrigger } from "../config";
|
|
2
|
+
import { createComponentContext } from "../context";
|
|
2
3
|
import type {
|
|
3
4
|
CatladderJobWithContext,
|
|
5
|
+
ComponentContext,
|
|
4
6
|
Config,
|
|
5
7
|
PipelineTrigger,
|
|
6
8
|
PipelineType,
|
|
7
9
|
} from "../types";
|
|
8
|
-
import {
|
|
10
|
+
import { createJobsForComponentContext } from "./createJobsForComponent";
|
|
9
11
|
|
|
10
12
|
export type AllCatladderJobs = {
|
|
11
13
|
[componentName: string]: {
|
|
@@ -19,11 +21,17 @@ export type AllJobsContext = {
|
|
|
19
21
|
pipelineType: PipelineType;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
type AllComponentContext = {
|
|
25
|
+
[componentName: string]: {
|
|
26
|
+
[env: string]: ComponentContext;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const createAllComponentContext = async ({
|
|
23
31
|
config,
|
|
24
32
|
trigger,
|
|
25
33
|
pipelineType,
|
|
26
|
-
}: AllJobsContext): Promise<
|
|
34
|
+
}: AllJobsContext): Promise<AllComponentContext> => {
|
|
27
35
|
return Object.fromEntries(
|
|
28
36
|
await Promise.all(
|
|
29
37
|
Object.keys(config.components).map(async (componentName) => {
|
|
@@ -32,17 +40,17 @@ export const createAllJobs = async ({
|
|
|
32
40
|
componentName,
|
|
33
41
|
Object.fromEntries(
|
|
34
42
|
await Promise.all(
|
|
35
|
-
envs.map(async (env) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
await createJobsForComponent({
|
|
43
|
+
envs.map(async (env) => {
|
|
44
|
+
const context = await createComponentContext({
|
|
39
45
|
config,
|
|
40
46
|
componentName,
|
|
41
47
|
env,
|
|
42
48
|
trigger,
|
|
43
49
|
pipelineType,
|
|
44
|
-
})
|
|
45
|
-
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return [env, context];
|
|
53
|
+
}),
|
|
46
54
|
),
|
|
47
55
|
),
|
|
48
56
|
];
|
|
@@ -50,3 +58,30 @@ export const createAllJobs = async ({
|
|
|
50
58
|
),
|
|
51
59
|
);
|
|
52
60
|
};
|
|
61
|
+
|
|
62
|
+
export const createAllJobs = async ({
|
|
63
|
+
config,
|
|
64
|
+
trigger,
|
|
65
|
+
pipelineType,
|
|
66
|
+
}: AllJobsContext): Promise<AllCatladderJobs> => {
|
|
67
|
+
const allComponentContext = await createAllComponentContext({
|
|
68
|
+
config,
|
|
69
|
+
trigger,
|
|
70
|
+
pipelineType,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return Object.fromEntries(
|
|
74
|
+
Object.entries(allComponentContext).map(([componentName, envs]) => [
|
|
75
|
+
componentName,
|
|
76
|
+
Object.fromEntries(
|
|
77
|
+
Object.entries(envs).map(([env, context]) => [
|
|
78
|
+
env,
|
|
79
|
+
createJobsForComponentContext(context).map((job) => ({
|
|
80
|
+
...job,
|
|
81
|
+
context,
|
|
82
|
+
})),
|
|
83
|
+
]),
|
|
84
|
+
),
|
|
85
|
+
]),
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { isFunction } from "lodash";
|
|
2
1
|
import { BUILD_TYPES } from "../build";
|
|
3
|
-
import type { CreateComponentContextContext } from "../context";
|
|
4
|
-
import { createComponentContext } from "../context";
|
|
5
2
|
import { DEPLOY_TYPES } from "../deploy";
|
|
6
|
-
import type {
|
|
7
|
-
CatladderJobWithContext,
|
|
8
|
-
ComponentContext,
|
|
9
|
-
Context,
|
|
10
|
-
} from "../types/context";
|
|
3
|
+
import type { ComponentContext } from "../types/context";
|
|
11
4
|
import type { CatladderJob } from "../types/jobs";
|
|
12
|
-
import { getPackageManagerInfo } from "./packageManager";
|
|
13
5
|
|
|
14
6
|
const injectDefaultVarsInCustomJobs = (
|
|
15
7
|
context: ComponentContext,
|
|
@@ -29,7 +21,9 @@ const getCustomJobs = (context: ComponentContext) => {
|
|
|
29
21
|
const rawJobs = context.customJobs;
|
|
30
22
|
return injectDefaultVarsInCustomJobs(context, rawJobs);
|
|
31
23
|
};
|
|
32
|
-
const
|
|
24
|
+
export const createJobsForComponentContext = (
|
|
25
|
+
context: ComponentContext,
|
|
26
|
+
): CatladderJob[] => {
|
|
33
27
|
const buildJobs = BUILD_TYPES[context.build.config.type].jobs(context);
|
|
34
28
|
const deployJobs = context.deploy?.config
|
|
35
29
|
? DEPLOY_TYPES[context.deploy?.config.type].jobs(context)
|
|
@@ -38,18 +32,3 @@ const createRawJobs = (context: Context): CatladderJob[] => {
|
|
|
38
32
|
const customJobs = getCustomJobs(context);
|
|
39
33
|
return [...buildJobs, ...deployJobs, ...customJobs];
|
|
40
34
|
};
|
|
41
|
-
|
|
42
|
-
export const createJobsForComponent = async (
|
|
43
|
-
contextContext: Omit<CreateComponentContextContext, "packageManagerInfo">,
|
|
44
|
-
): Promise<Array<CatladderJobWithContext>> => {
|
|
45
|
-
const packageManagerInfo = await getPackageManagerInfo(
|
|
46
|
-
contextContext.config,
|
|
47
|
-
contextContext.componentName,
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const context = await createComponentContext({
|
|
51
|
-
...contextContext,
|
|
52
|
-
packageManagerInfo,
|
|
53
|
-
});
|
|
54
|
-
return createRawJobs(context).map((job) => ({ ...job, context }));
|
|
55
|
-
};
|
package/src/types/context.ts
CHANGED
|
@@ -87,7 +87,7 @@ export type ContextBeforeConfig = {
|
|
|
87
87
|
|
|
88
88
|
export type BuildContext = {
|
|
89
89
|
dir: string;
|
|
90
|
-
packageManagerInfo
|
|
90
|
+
packageManagerInfo: PackageManagerInfo;
|
|
91
91
|
config: BuildConfig;
|
|
92
92
|
};
|
|
93
93
|
|
|
@@ -114,7 +114,7 @@ export type ComponentContext = {
|
|
|
114
114
|
/**
|
|
115
115
|
* @deprecated use buildContext.packageManagerInfo instead
|
|
116
116
|
*/
|
|
117
|
-
packageManagerInfo
|
|
117
|
+
packageManagerInfo: PackageManagerInfo;
|
|
118
118
|
|
|
119
119
|
customJobs?: CatladderJob[];
|
|
120
120
|
};
|