@catladder/pipeline 1.149.2 → 1.149.3
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/createJobsForComponent.d.ts +1 -1
- package/dist/pipeline/createJobsForComponent.js +2 -8
- 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/createJobsForComponent.ts +2 -12
- package/src/types/context.ts +2 -2
package/src/build/node/cache.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const getYarnCache = (
|
|
|
9
9
|
policy = "pull-push",
|
|
10
10
|
): GitlabJobCache[] => {
|
|
11
11
|
const componentIsInWorkspace =
|
|
12
|
-
context.packageManagerInfo
|
|
12
|
+
context.packageManagerInfo.componentIsInWorkspace;
|
|
13
13
|
return [
|
|
14
14
|
componentIsInWorkspace
|
|
15
15
|
? {
|
|
@@ -30,7 +30,7 @@ export const getNodeModulesCache = (
|
|
|
30
30
|
policy = "pull-push",
|
|
31
31
|
): GitlabJobCache[] => {
|
|
32
32
|
const componentIsInWorkspace =
|
|
33
|
-
context.packageManagerInfo
|
|
33
|
+
context.packageManagerInfo.componentIsInWorkspace;
|
|
34
34
|
|
|
35
35
|
// We intentionally do not use the contents of yarn.lock as a cache key, as yarn install should always guarantee that the files are updated, but it can still use part of the cache if not all packages are up-to-date.
|
|
36
36
|
// It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
|
|
@@ -45,7 +45,7 @@ export const getNodeModulesCache = (
|
|
|
45
45
|
...(componentIsInWorkspace
|
|
46
46
|
? uniq([
|
|
47
47
|
"node_modules",
|
|
48
|
-
...(context.packageManagerInfo
|
|
48
|
+
...(context.packageManagerInfo.workspaces.map((w) =>
|
|
49
49
|
join(w.location, "node_modules"),
|
|
50
50
|
) ?? []),
|
|
51
51
|
])
|
|
@@ -41,7 +41,7 @@ export const createNodeTestJobs = (
|
|
|
41
41
|
script: [
|
|
42
42
|
`cd ${context.build.dir}`,
|
|
43
43
|
...(ensureArray(buildConfig.audit?.command) ?? [
|
|
44
|
-
context.build.packageManagerInfo
|
|
44
|
+
context.build.packageManagerInfo.isClassic
|
|
45
45
|
? "yarn audit"
|
|
46
46
|
: "yarn npm audit --environment production", // yarn 2
|
|
47
47
|
]),
|
package/src/build/node/yarn.ts
CHANGED
|
@@ -9,7 +9,7 @@ const YARN_INSTALL_CLASSIC = `yarn install --frozen-lockfile`;
|
|
|
9
9
|
const YARN_BERRY_PROD_REBUILD = `yarn workspaces focus --production && yarn rebuild`;
|
|
10
10
|
|
|
11
11
|
const getYarnInstallCommand = (context: BuildContext) => {
|
|
12
|
-
if (context.packageManagerInfo
|
|
12
|
+
if (context.packageManagerInfo.isClassic) {
|
|
13
13
|
return YARN_INSTALL_CLASSIC;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -51,7 +51,7 @@ export const getYarnInstall = (
|
|
|
51
51
|
const DOCKER_COPY_FILES = `COPY --chown=node:node $APP_DIR .`;
|
|
52
52
|
|
|
53
53
|
export const getDockerAppCopyAndBuildScript = (context: BuildContext) => {
|
|
54
|
-
if (context.packageManagerInfo
|
|
54
|
+
if (context.packageManagerInfo.isClassic) {
|
|
55
55
|
return new BashExpression(
|
|
56
56
|
`
|
|
57
57
|
RUN ${YARN_INSTALL_CLASSIC} --production --ignore-scripts
|
|
@@ -64,7 +64,7 @@ RUN ${YARN_INSTALL_CLASSIC} --production
|
|
|
64
64
|
// yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
|
|
65
65
|
// trying to import those fail on this version
|
|
66
66
|
const doesNotShipWithBuiltInPlugins = ["2", "3"].some((v) =>
|
|
67
|
-
context.packageManagerInfo
|
|
67
|
+
context.packageManagerInfo.version.startsWith(v),
|
|
68
68
|
);
|
|
69
69
|
const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins
|
|
70
70
|
? "RUN yarn plugin import workspace-tools"
|
package/src/build/sbom.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const createSbomBuildJob = (context: ComponentContext): CatladderJob => {
|
|
|
11
11
|
const defaultImage = "aquasec/trivy:0.38.3";
|
|
12
12
|
const defaultScript = [
|
|
13
13
|
`trivy fs --quiet --format cyclonedx --output "${SBOM_FILE}" ${
|
|
14
|
-
context.build.packageManagerInfo
|
|
14
|
+
context.build.packageManagerInfo.componentIsInWorkspace
|
|
15
15
|
? "."
|
|
16
16
|
: context.build.dir
|
|
17
17
|
}`,
|
|
@@ -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,4 +1,3 @@
|
|
|
1
|
-
import { isFunction } from "lodash";
|
|
2
1
|
import { BUILD_TYPES } from "../build";
|
|
3
2
|
import type { CreateComponentContextContext } from "../context";
|
|
4
3
|
import { createComponentContext } from "../context";
|
|
@@ -9,7 +8,6 @@ import type {
|
|
|
9
8
|
Context,
|
|
10
9
|
} from "../types/context";
|
|
11
10
|
import type { CatladderJob } from "../types/jobs";
|
|
12
|
-
import { getPackageManagerInfo } from "./packageManager";
|
|
13
11
|
|
|
14
12
|
const injectDefaultVarsInCustomJobs = (
|
|
15
13
|
context: ComponentContext,
|
|
@@ -40,16 +38,8 @@ const createRawJobs = (context: Context): CatladderJob[] => {
|
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
export const createJobsForComponent = async (
|
|
43
|
-
contextContext:
|
|
41
|
+
contextContext: CreateComponentContextContext,
|
|
44
42
|
): Promise<Array<CatladderJobWithContext>> => {
|
|
45
|
-
const
|
|
46
|
-
contextContext.config,
|
|
47
|
-
contextContext.componentName,
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
const context = await createComponentContext({
|
|
51
|
-
...contextContext,
|
|
52
|
-
packageManagerInfo,
|
|
53
|
-
});
|
|
43
|
+
const context = await createComponentContext(contextContext);
|
|
54
44
|
return createRawJobs(context).map((job) => ({ ...job, context }));
|
|
55
45
|
};
|
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
|
};
|