@catladder/pipeline 4.1.0 → 4.2.0
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/artifacts/createBuildJobArtifact.d.ts +1 -1
- package/dist/build/artifacts/createBuildJobArtifact.js +193 -30
- package/dist/build/base/createAppBuildJob.d.ts +1 -1
- package/dist/build/base/createAppBuildJob.js +149 -22
- package/dist/build/base/index.d.ts +2 -2
- package/dist/build/base/index.js +159 -9
- package/dist/build/custom/buildJob.d.ts +1 -1
- package/dist/build/custom/buildJob.js +130 -10
- package/dist/build/custom/index.d.ts +1 -1
- package/dist/build/custom/index.js +127 -1
- package/dist/build/rails/build.d.ts +1 -1
- package/dist/build/rails/build.js +153 -33
- package/dist/build/rails/index.d.ts +1 -1
- package/dist/build/rails/index.js +127 -1
- package/dist/constants.js +1 -1
- package/dist/context/createComponentContext.js +27 -9
- package/dist/context/createWorkspaceContext.js +15 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/context.d.ts +1 -1
- package/package.json +1 -1
- package/src/build/artifacts/createBuildJobArtifact.ts +28 -21
- package/src/build/base/createAppBuildJob.ts +3 -3
- package/src/build/base/index.ts +6 -6
- package/src/build/custom/buildJob.ts +2 -2
- package/src/build/custom/index.ts +6 -3
- package/src/build/rails/build.ts +2 -2
- package/src/build/rails/index.ts +6 -3
- package/src/context/createComponentContext.ts +3 -6
- package/src/context/createWorkspaceContext.ts +8 -2
- package/src/types/context.ts +1 -1
|
@@ -11,20 +11,28 @@ import { componentContextNeedsBuildTimeDotEnv } from "../base/writeDotEnv";
|
|
|
11
11
|
const uniqueAndAlphabeticalSort = (arr: string[]): string[] => {
|
|
12
12
|
return uniq(arr).sort((a, b) => a.localeCompare(b));
|
|
13
13
|
};
|
|
14
|
-
export const createBuildJobArtifacts = (
|
|
14
|
+
export const createBuildJobArtifacts = async (
|
|
15
15
|
context: Context,
|
|
16
|
-
): CatladderJob["artifacts"] => {
|
|
16
|
+
): Promise<CatladderJob["artifacts"]> => {
|
|
17
17
|
const paths =
|
|
18
18
|
context.type === "workspace"
|
|
19
|
-
?
|
|
20
|
-
|
|
19
|
+
? (
|
|
20
|
+
await Promise.all(
|
|
21
|
+
context.components.map((c) => getArtifactsPathForComponent(c)),
|
|
22
|
+
)
|
|
23
|
+
).flat()
|
|
24
|
+
: await getArtifactsPathForComponent(context, ["__build_info.json"]);
|
|
21
25
|
|
|
22
26
|
const exclude =
|
|
23
27
|
context.type === "workspace"
|
|
24
|
-
?
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
? (
|
|
29
|
+
await Promise.all(
|
|
30
|
+
context.components.map((c) =>
|
|
31
|
+
getAllArtifactExcludePathsForComponent(c),
|
|
32
|
+
),
|
|
33
|
+
)
|
|
34
|
+
).flat()
|
|
35
|
+
: await getAllArtifactExcludePathsForComponent(context);
|
|
28
36
|
return {
|
|
29
37
|
paths: uniqueAndAlphabeticalSort(paths),
|
|
30
38
|
...(exclude.length > 0
|
|
@@ -43,44 +51,43 @@ export const createBuildJobArtifacts = (
|
|
|
43
51
|
: {},
|
|
44
52
|
};
|
|
45
53
|
};
|
|
46
|
-
const _getArtifactPathsForComponent = (
|
|
54
|
+
const _getArtifactPathsForComponent = async (
|
|
47
55
|
c: ComponentContext,
|
|
48
56
|
configKey: "artifactsPaths" | "artifactsExcludePaths",
|
|
49
57
|
additionalPaths?: string[],
|
|
50
|
-
): string[] => {
|
|
58
|
+
): Promise<string[]> => {
|
|
59
|
+
// in theory, we only need "direct",
|
|
60
|
+
// but in some cases project may have packages in the workspace that create build artifacts, which aren't components
|
|
61
|
+
// this highly depends on the build tool. To be safe, we get all
|
|
62
|
+
const componentDirs = await c.build.getComponentDirs("all");
|
|
51
63
|
return [
|
|
52
64
|
...(c.build.type !== "disabled" ? (c.build.config[configKey] ?? []) : []),
|
|
53
65
|
...(additionalPaths ?? []),
|
|
54
66
|
]?.flatMap((artifact) =>
|
|
55
|
-
|
|
56
|
-
// in theory, we only need "direct",
|
|
57
|
-
// but in some cases project may have packages in the workspace that create build artifacts, which aren't components
|
|
58
|
-
// this highly depends on the build tool. To be safe, we get all
|
|
59
|
-
.getComponentDirs("all")
|
|
60
|
-
.flatMap((cDir) => join(cDir, artifact)),
|
|
67
|
+
componentDirs.flatMap((cDir: string) => join(cDir, artifact)),
|
|
61
68
|
);
|
|
62
69
|
};
|
|
63
70
|
|
|
64
71
|
const getArtifactsPathForComponent = (
|
|
65
72
|
c: ComponentContext,
|
|
66
73
|
additionalPaths?: string[],
|
|
67
|
-
): string[] => {
|
|
74
|
+
): Promise<string[]> => {
|
|
68
75
|
return _getArtifactPathsForComponent(c, "artifactsPaths", additionalPaths);
|
|
69
76
|
};
|
|
70
77
|
|
|
71
|
-
const getAllArtifactExcludePathsForComponent = (
|
|
78
|
+
const getAllArtifactExcludePathsForComponent = async (
|
|
72
79
|
c: ComponentContext,
|
|
73
|
-
): string[] => {
|
|
80
|
+
): Promise<string[]> => {
|
|
74
81
|
return [
|
|
75
82
|
...getDotEnvPathsForComponent(c), // always exclude .env files
|
|
76
|
-
...getArtifactExcludePathsForComponent(c),
|
|
83
|
+
...(await getArtifactExcludePathsForComponent(c)),
|
|
77
84
|
];
|
|
78
85
|
};
|
|
79
86
|
|
|
80
87
|
const getArtifactExcludePathsForComponent = (
|
|
81
88
|
c: ComponentContext,
|
|
82
89
|
additionalPaths?: string[],
|
|
83
|
-
): string[] => {
|
|
90
|
+
): Promise<string[]> => {
|
|
84
91
|
return _getArtifactPathsForComponent(
|
|
85
92
|
c,
|
|
86
93
|
"artifactsExcludePaths",
|
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
writeDotEnv,
|
|
22
22
|
} from "./writeDotEnv";
|
|
23
23
|
|
|
24
|
-
export const createAppBuildJob = (
|
|
24
|
+
export const createAppBuildJob = async (
|
|
25
25
|
context: ComponentContext<BuildContextStandalone> | WorkspaceContext,
|
|
26
26
|
{ script, variables, runnerVariables, cache, ...def }: AppBuildJobDefinition,
|
|
27
|
-
): CatladderJob => {
|
|
27
|
+
): Promise<CatladderJob> => {
|
|
28
28
|
return merge(
|
|
29
29
|
{
|
|
30
30
|
name: APP_BUILD_JOB_NAME,
|
|
@@ -63,7 +63,7 @@ export const createAppBuildJob = (
|
|
|
63
63
|
`cd ${context.build.dir}`,
|
|
64
64
|
...ensureArray(script),
|
|
65
65
|
],
|
|
66
|
-
artifacts: createBuildJobArtifacts(context),
|
|
66
|
+
artifacts: await createBuildJobArtifacts(context),
|
|
67
67
|
},
|
|
68
68
|
def,
|
|
69
69
|
);
|
package/src/build/base/index.ts
CHANGED
|
@@ -15,16 +15,16 @@ import { createDockerBuildJobBase, requiresDockerBuild } from "../docker";
|
|
|
15
15
|
import { APP_BUILD_JOB_NAME } from "./constants";
|
|
16
16
|
import { createAppBuildJob } from "./createAppBuildJob";
|
|
17
17
|
|
|
18
|
-
export const createComponentBuildJobs = (
|
|
18
|
+
export const createComponentBuildJobs = async (
|
|
19
19
|
context: ComponentContextWithBuild,
|
|
20
20
|
definitions: {
|
|
21
21
|
appBuild?: AppBuildJobDefinition;
|
|
22
22
|
dockerBuild: DockerBuildJobDefinition;
|
|
23
23
|
},
|
|
24
|
-
): CatladderJob[] => {
|
|
24
|
+
): Promise<CatladderJob[]> => {
|
|
25
25
|
return [
|
|
26
26
|
...(definitions.appBuild && componentContextIsStandaloneBuild(context)
|
|
27
|
-
? [createAppBuildJob(context, definitions.appBuild)]
|
|
27
|
+
? [await createAppBuildJob(context, definitions.appBuild)]
|
|
28
28
|
: []),
|
|
29
29
|
...(requiresDockerBuild(context)
|
|
30
30
|
? [
|
|
@@ -51,13 +51,13 @@ export const createComponentBuildJobs = (
|
|
|
51
51
|
];
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export const createWorkspaceBuildJobs = (
|
|
54
|
+
export const createWorkspaceBuildJobs = async (
|
|
55
55
|
context: WorkspaceContext,
|
|
56
56
|
definitions: {
|
|
57
57
|
appBuild?: AppBuildJobDefinition;
|
|
58
58
|
},
|
|
59
|
-
): CatladderJob[] => {
|
|
59
|
+
): Promise<CatladderJob[]> => {
|
|
60
60
|
return definitions.appBuild
|
|
61
|
-
? [createAppBuildJob(context, definitions.appBuild)]
|
|
61
|
+
? [await createAppBuildJob(context, definitions.appBuild)]
|
|
62
62
|
: [];
|
|
63
63
|
};
|
|
@@ -6,9 +6,9 @@ import type { CatladderJob } from "../../types/jobs";
|
|
|
6
6
|
import { createComponentBuildJobs } from "../base";
|
|
7
7
|
import { createBuildJobDefinition } from "../base/createBuildJobDefinition";
|
|
8
8
|
|
|
9
|
-
export const createCustomBuildJobs = (
|
|
9
|
+
export const createCustomBuildJobs = async (
|
|
10
10
|
context: ComponentContextWithBuild,
|
|
11
|
-
): CatladderJob[] => {
|
|
11
|
+
): Promise<CatladderJob[]> => {
|
|
12
12
|
const buildConfig = context.build.config;
|
|
13
13
|
|
|
14
14
|
if (!isOfBuildType(buildConfig, "custom")) {
|
|
@@ -3,8 +3,11 @@ import type { CatladderJob } from "../../types/jobs";
|
|
|
3
3
|
import { createCustomBuildJobs } from "./buildJob";
|
|
4
4
|
import { createCustomTestJobs } from "./testJob";
|
|
5
5
|
|
|
6
|
-
export const createCustomJobs = (
|
|
6
|
+
export const createCustomJobs = async (
|
|
7
7
|
context: ComponentContextWithBuild,
|
|
8
|
-
): CatladderJob[] => {
|
|
9
|
-
return [
|
|
8
|
+
): Promise<CatladderJob[]> => {
|
|
9
|
+
return [
|
|
10
|
+
...createCustomTestJobs(context),
|
|
11
|
+
...(await createCustomBuildJobs(context)),
|
|
12
|
+
];
|
|
10
13
|
};
|
package/src/build/rails/build.ts
CHANGED
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
} from "../docker";
|
|
10
10
|
import { isOfBuildType } from "../types";
|
|
11
11
|
|
|
12
|
-
export const createRailsBuildJobs = (
|
|
12
|
+
export const createRailsBuildJobs = async (
|
|
13
13
|
context: ComponentContextWithBuild,
|
|
14
|
-
): CatladderJob[] => {
|
|
14
|
+
): Promise<CatladderJob[]> => {
|
|
15
15
|
const buildConfig = context.build.config;
|
|
16
16
|
if (!isOfBuildType(buildConfig, "rails")) {
|
|
17
17
|
// should not happen
|
package/src/build/rails/index.ts
CHANGED
|
@@ -3,8 +3,11 @@ import type { CatladderJob } from "../../types/jobs";
|
|
|
3
3
|
import { createRailsBuildJobs } from "./build";
|
|
4
4
|
import { createRailsTestJobs } from "./testJob";
|
|
5
5
|
|
|
6
|
-
export const createRailsJobs = (
|
|
6
|
+
export const createRailsJobs = async (
|
|
7
7
|
context: ComponentContextWithBuild,
|
|
8
|
-
): CatladderJob[] => {
|
|
9
|
-
return [
|
|
8
|
+
): Promise<CatladderJob[]> => {
|
|
9
|
+
return [
|
|
10
|
+
...createRailsTestJobs(context),
|
|
11
|
+
...(await createRailsBuildJobs(context)),
|
|
12
|
+
];
|
|
10
13
|
};
|
|
@@ -75,16 +75,13 @@ export const createComponentContext = async (
|
|
|
75
75
|
componentConfigWithoutDefaults,
|
|
76
76
|
);
|
|
77
77
|
|
|
78
|
-
const
|
|
79
|
-
getEnvironment(ctx),
|
|
80
|
-
packageManagerInfoPromise,
|
|
81
|
-
]);
|
|
78
|
+
const environment = await getEnvironment(ctx);
|
|
82
79
|
const { deploy, build, customJobs, dir } = componentConfig;
|
|
83
|
-
const getComponentDirs: BuildContext["getComponentDirs"] = (mode) => [
|
|
80
|
+
const getComponentDirs: BuildContext["getComponentDirs"] = async (mode) => [
|
|
84
81
|
dir,
|
|
85
82
|
// also copy workspace dependencies in monorepo if packages are shared and they create build artifacts
|
|
86
83
|
...(mode === "all"
|
|
87
|
-
? (
|
|
84
|
+
? ((await packageManagerInfoPromise).currentWorkspaceDependencies ?? [])
|
|
88
85
|
: []),
|
|
89
86
|
];
|
|
90
87
|
const _getBuildContext = (): BuildContextComponent => {
|
|
@@ -47,8 +47,14 @@ export async function createWorkspaceContext({
|
|
|
47
47
|
build: {
|
|
48
48
|
type: "workspace",
|
|
49
49
|
dir: workspaceConfig.dir ?? ".",
|
|
50
|
-
getComponentDirs: (mode) =>
|
|
51
|
-
uniq(
|
|
50
|
+
getComponentDirs: async (mode) =>
|
|
51
|
+
uniq(
|
|
52
|
+
(
|
|
53
|
+
await Promise.all(
|
|
54
|
+
components.map((c) => c.build.getComponentDirs(mode)),
|
|
55
|
+
)
|
|
56
|
+
).flat(),
|
|
57
|
+
),
|
|
52
58
|
buildType: workspaceConfig.type,
|
|
53
59
|
config: workspaceConfig,
|
|
54
60
|
},
|
package/src/types/context.ts
CHANGED
|
@@ -104,7 +104,7 @@ export type BuildContextBase = {
|
|
|
104
104
|
*
|
|
105
105
|
* in case of a workspace this contains all components in the workspace (+ yarn workspace dependencies if mode = all)
|
|
106
106
|
*/
|
|
107
|
-
getComponentDirs: (mode: "direct" | "all") => string[]
|
|
107
|
+
getComponentDirs: (mode: "direct" | "all") => Promise<string[]>;
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
export type BuildContextComponentBase = BuildContextBase;
|