@catladder/pipeline 0.0.0-main-bc2a3387 โ†’ 0.0.0-main-03e0177e

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.
Files changed (28) hide show
  1. package/dist/build/custom/testJob.js +26 -12
  2. package/dist/build/node/buildJob.js +1 -7
  3. package/dist/build/node/yarn.d.ts +2 -5
  4. package/dist/build/node/yarn.js +27 -15
  5. package/dist/build/types.d.ts +25 -9
  6. package/dist/bundles/catladder-gitlab/index.js +57 -37
  7. package/dist/constants.js +1 -1
  8. package/dist/pipeline/packageManager.js +4 -4
  9. package/dist/tsconfig.tsbuildinfo +1 -1
  10. package/examples/__snapshots__/cloud-run-memory-limit.ts.snap +24 -12
  11. package/examples/__snapshots__/cloud-run-no-cpu-throttling.ts.snap +24 -12
  12. package/examples/__snapshots__/cloud-run-non-public.ts.snap +24 -12
  13. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.ts.snap +48 -24
  14. package/examples/__snapshots__/cloud-run-with-sql.ts.snap +48 -24
  15. package/examples/__snapshots__/custom-build-job-with-tests.ts.snap +50 -0
  16. package/examples/__snapshots__/custom-deploy.ts.snap +24 -12
  17. package/examples/__snapshots__/kubernetes-application-customization.ts.snap +24 -12
  18. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.ts.snap +24 -12
  19. package/examples/__snapshots__/kubernetes-with-cloud-sql.ts.snap +24 -12
  20. package/examples/__snapshots__/kubernetes-with-jobs.ts.snap +48 -24
  21. package/examples/__snapshots__/kubernetes-with-mongodb.ts.snap +24 -12
  22. package/examples/custom-build-job-with-tests.ts +9 -0
  23. package/package.json +1 -1
  24. package/src/build/custom/testJob.ts +36 -0
  25. package/src/build/node/buildJob.ts +3 -8
  26. package/src/build/node/yarn.ts +38 -25
  27. package/src/build/types.ts +26 -9
  28. package/src/pipeline/packageManager.ts +7 -6
@@ -43,6 +43,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
43
43
  };
44
44
  exports.__esModule = true;
45
45
  exports.createCustomTestJobs = void 0;
46
+ var path_1 = require("path");
46
47
  var utils_1 = require("../../utils");
47
48
  var types_1 = require("../types");
48
49
  var RUNNER_CUSTOM_TEST_VARIABLES = {
@@ -52,7 +53,7 @@ var RUNNER_CUSTOM_TEST_VARIABLES = {
52
53
  KUBERNETES_MEMORY_LIMIT: "4Gi"
53
54
  };
54
55
  var createCustomTestJobs = function (context) {
55
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
56
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
56
57
  // don't run tests after release
57
58
  if (((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.trigger) === "taggedRelease") {
58
59
  return [];
@@ -71,26 +72,39 @@ var createCustomTestJobs = function (context) {
71
72
  needs: [],
72
73
  envMode: "none"
73
74
  };
74
- var auditJob = buildConfig.audit ? __assign(__assign({
75
+ var auditJob = buildConfig.audit ? __assign(__assign(__assign({
75
76
  name: "๐Ÿ›ก audit"
76
77
  }, base), {
77
78
  image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : buildConfig.jobImage,
78
79
  cache: undefined,
79
80
  script: __spreadArray([], __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : []), false),
80
81
  allow_failure: true
81
- }) : null;
82
- var lintJob = buildConfig.lint ? __assign(__assign({
82
+ }), createArtifactsConfig(context.componentConfig.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports)) : null;
83
+ var lintJob = buildConfig.lint ? __assign(__assign(__assign({
83
84
  name: "๐Ÿ‘ฎ lint"
84
85
  }, base), {
85
- image: (_h = (_g = buildConfig.lint) === null || _g === void 0 ? void 0 : _g.jobImage) !== null && _h !== void 0 ? _h : buildConfig.jobImage,
86
- script: __spreadArray([], __read((_k = (0, utils_1.ensureArray)((_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.command)) !== null && _k !== void 0 ? _k : []), false)
87
- }) : null;
88
- var testJob = buildConfig.test ? __assign(__assign({
86
+ image: (_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.jobImage) !== null && _j !== void 0 ? _j : buildConfig.jobImage,
87
+ script: __spreadArray([], __read((_l = (0, utils_1.ensureArray)((_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.command)) !== null && _l !== void 0 ? _l : []), false)
88
+ }), createArtifactsConfig(context.componentConfig.dir, (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.artifactsReports)) : null;
89
+ var testJob = buildConfig.test ? __assign(__assign(__assign({
89
90
  name: "๐Ÿงช test"
90
91
  }, base), {
91
- image: (_m = (_l = buildConfig.test) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : buildConfig.jobImage,
92
- script: __spreadArray([], __read((_p = (0, utils_1.ensureArray)((_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.command)) !== null && _p !== void 0 ? _p : []), false)
93
- }) : null;
92
+ image: (_p = (_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.jobImage) !== null && _p !== void 0 ? _p : buildConfig.jobImage,
93
+ script: __spreadArray([], __read((_r = (0, utils_1.ensureArray)((_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.command)) !== null && _r !== void 0 ? _r : []), false)
94
+ }), createArtifactsConfig(context.componentConfig.dir, (_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.artifactsReports)) : null;
94
95
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
95
96
  };
96
- exports.createCustomTestJobs = createCustomTestJobs;
97
+ exports.createCustomTestJobs = createCustomTestJobs;
98
+ var createArtifactsConfig = function (rootPath, artifactsReports) {
99
+ var _a, _b;
100
+ return artifactsReports ? {
101
+ artifacts: {
102
+ paths: [],
103
+ reports: {
104
+ junit: (_b = (_a = artifactsReports === null || artifactsReports === void 0 ? void 0 : artifactsReports.junit) === null || _a === void 0 ? void 0 : _a.map(function (p) {
105
+ return (0, path_1.join)(rootPath, p);
106
+ })) !== null && _b !== void 0 ? _b : []
107
+ }
108
+ }
109
+ } : undefined;
110
+ };
@@ -74,13 +74,7 @@ var createNodeBuildJobs = function (context) {
74
74
  cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
75
75
  variables: {
76
76
  // only required for non static
77
- YARN_INSTALL: (0, yarn_1.getYarnInstallCommand)(context, {
78
- prodOnly: true
79
- }),
80
- YARN_INSTALL_WITHOUT_SCRIPTS: (0, yarn_1.getYarnInstallCommand)(context, {
81
- prodOnly: true,
82
- noScripts: true
83
- }),
77
+ DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context),
84
78
  DOCKER_COPY_WORKSPACE_FILES: (_e = (_d = context.packageManagerInfo) === null || _d === void 0 ? void 0 : _d.pathsToCopyInDocker.map(function (dir) {
85
79
  return "COPY --chown=node:node ".concat(dir, " /app/").concat(dir);
86
80
  })) === null || _e === void 0 ? void 0 : _e.join("\n")
@@ -1,7 +1,4 @@
1
1
  import type { Context } from "../../types";
2
- export declare const getYarnInstallCommand: (context: Context, options?: {
3
- prodOnly?: boolean | undefined;
4
- noScripts?: boolean | undefined;
5
- } | undefined) => string;
6
2
  export declare const ensureNodeVersion: (context: Context) => string[];
7
- export declare const getYarnInstall: (context: Context) => string[];
3
+ export declare const getYarnInstall: (context: Context) => string[];
4
+ export declare const getDockerAppCopyAndBuildScript: (context: Context) => string;
@@ -32,28 +32,40 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
32
32
  return to.concat(ar || Array.prototype.slice.call(from));
33
33
  };
34
34
  exports.__esModule = true;
35
- exports.getYarnInstall = exports.ensureNodeVersion = exports.getYarnInstallCommand = void 0;
36
- var getYarnInstallCommand = function (context, options) {
35
+ exports.getDockerAppCopyAndBuildScript = exports.getYarnInstall = exports.ensureNodeVersion = void 0;
36
+ var YARN_INSTALL_CLASSIC = "yarn install --frozen-lockfile";
37
+ // FIXME: check why and when rebuild is needed
38
+ var YARN_BERRY_PROD_REBUILD = "yarn workspaces focus --production && yarn rebuild";
39
+ var getYarnInstallCommand = function (context) {
37
40
  var _a;
38
41
  if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
39
- return "yarn install --frozen-lockfile ".concat((options === null || options === void 0 ? void 0 : options.prodOnly) ? "--production" : "", " ").concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "--ignore-scripts" : "");
42
+ return YARN_INSTALL_CLASSIC;
40
43
  }
41
- // is modern
42
- // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
43
- // trying to import those fail on this version
44
- var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
45
- var _a;
46
- return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
47
- });
48
- return (options === null || options === void 0 ? void 0 : options.prodOnly) ? "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "").concat(doesNotShipWithBuiltInPlugins ? "yarn plugin import workspace-tools && " : " ", "yarn workspaces focus --production && yarn rebuild") // needs yarn plugin import workspace-tools
49
- : "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "", "yarn install --immutable");
44
+ return "yarn install --immutable";
50
45
  };
51
- exports.getYarnInstallCommand = getYarnInstallCommand;
52
46
  var ensureNodeVersion = function (context) {
53
47
  return ["if [ -f ./.nvmrc ]; then source /root/.nvm/nvm.sh && nvm install <<< .nvmrc; fi"];
54
48
  };
55
49
  exports.ensureNodeVersion = ensureNodeVersion;
56
50
  var getYarnInstall = function (context) {
57
- return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [(0, exports.getYarnInstallCommand)(context)], false);
51
+ return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [getYarnInstallCommand(context)], false);
52
+ };
53
+ exports.getYarnInstall = getYarnInstall;
54
+ var DOCKER_COPY_FILES = "COPY --chown=node:node $APP_DIR .";
55
+ var getDockerAppCopyAndBuildScript = function (context) {
56
+ var _a;
57
+ if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
58
+ return "\nRUN ".concat(YARN_INSTALL_CLASSIC, " --production --ignore-scripts\n").concat(DOCKER_COPY_FILES, "\nRUN ").concat(YARN_INSTALL_CLASSIC, " --production \n ").trim();
59
+ }
60
+ // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
61
+ // trying to import those fail on this version
62
+ var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
63
+ var _a;
64
+ return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
65
+ });
66
+ var maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
67
+ // copy first everything and then install
68
+ // rebuild first does not work as it will run postinstall and that might require files in the app
69
+ return "\n".concat(DOCKER_COPY_FILES, "\n").concat(maybeAddWorkspaceToolsCommand, "\nRUN ").concat(YARN_BERRY_PROD_REBUILD, "\n\n ").trim();
58
70
  };
59
- exports.getYarnInstall = getYarnInstall;
71
+ exports.getDockerAppCopyAndBuildScript = getDockerAppCopyAndBuildScript;
@@ -1,5 +1,14 @@
1
1
  import type { GitlabJobImage, GitlabJobService } from "../types";
2
2
  import type { CatladderJob } from "../types/jobs";
3
+ export declare type BuildConfigArtifactsReports = {
4
+ /**
5
+ * The junit report collects JUnit report format XML files.
6
+ * The collected Unit test reports upload to GitLab as an artifact.
7
+ * Paths are prefixed with component's root folder.
8
+ * eg. `["dist/test-results/TEST-*.xml", "dist/rspec.xml", ...]`
9
+ */
10
+ junit?: string[];
11
+ };
3
12
  export declare type BuildConfigBase = {
4
13
  /**
5
14
  * command to run on the image to start the app (e.g. yarn start)
@@ -50,15 +59,7 @@ export declare type BuildConfigBase = {
50
59
  * additional CI/CD artifacts reports,
51
60
  * use to display information in merge requests, pipeline views and security dashboards.
52
61
  */
53
- artifactsReports?: {
54
- /**
55
- * The junit report collects JUnit report format XML files.
56
- * The collected Unit test reports upload to GitLab as an artifact.
57
- * Paths are prefixed with component's root folder.
58
- * eg. `["dist/test-results/TEST-*.xml", "dist/rspec.xml", ...]`
59
- */
60
- junit?: string[];
61
- };
62
+ artifactsReports?: BuildConfigArtifactsReports;
62
63
  };
63
64
  export declare type BuildConfigNodeBase = BuildConfigBase;
64
65
  export declare type BuildConfigNode = {
@@ -102,6 +103,11 @@ export declare type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" |
102
103
  lint?: {
103
104
  command?: string | string[];
104
105
  jobImage?: GitlabJobImage;
106
+ /**
107
+ * additional CI/CD artifacts reports,
108
+ * use to display information in merge requests, pipeline views and security dashboards.
109
+ */
110
+ artifactsReports?: BuildConfigArtifactsReports;
105
111
  };
106
112
  /**
107
113
  * custom test, disabled when not set
@@ -109,6 +115,11 @@ export declare type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" |
109
115
  test?: {
110
116
  command?: string | string[];
111
117
  jobImage?: GitlabJobImage;
118
+ /**
119
+ * additional CI/CD artifacts reports,
120
+ * use to display information in merge requests, pipeline views and security dashboards.
121
+ */
122
+ artifactsReports?: BuildConfigArtifactsReports;
112
123
  };
113
124
  /**
114
125
  * custom audit, disabled when not set
@@ -116,6 +127,11 @@ export declare type BuildConfigCustom = Omit<BuildConfigBase, "lint" | "test" |
116
127
  audit?: {
117
128
  command?: string | string[];
118
129
  jobImage?: GitlabJobImage;
130
+ /**
131
+ * additional CI/CD artifacts reports,
132
+ * use to display information in merge requests, pipeline views and security dashboards.
133
+ */
134
+ artifactsReports?: BuildConfigArtifactsReports;
119
135
  };
120
136
  /**
121
137
  * custom sbom (software bill of materials), set false to disable
@@ -27188,6 +27188,7 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
27188
27188
  };
27189
27189
  exports.__esModule = true;
27190
27190
  exports.createCustomTestJobs = void 0;
27191
+ var path_1 = __nccwpck_require__(1017);
27191
27192
  var utils_1 = __nccwpck_require__(1815);
27192
27193
  var types_1 = __nccwpck_require__(6575);
27193
27194
  var RUNNER_CUSTOM_TEST_VARIABLES = {
@@ -27197,7 +27198,7 @@ var RUNNER_CUSTOM_TEST_VARIABLES = {
27197
27198
  KUBERNETES_MEMORY_LIMIT: "4Gi"
27198
27199
  };
27199
27200
  var createCustomTestJobs = function (context) {
27200
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
27201
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
27201
27202
  // don't run tests after release
27202
27203
  if (((_a = context.commitInfo) === null || _a === void 0 ? void 0 : _a.trigger) === "taggedRelease") {
27203
27204
  return [];
@@ -27216,29 +27217,42 @@ var createCustomTestJobs = function (context) {
27216
27217
  needs: [],
27217
27218
  envMode: "none"
27218
27219
  };
27219
- var auditJob = buildConfig.audit ? __assign(__assign({
27220
+ var auditJob = buildConfig.audit ? __assign(__assign(__assign({
27220
27221
  name: "๐Ÿ›ก audit"
27221
27222
  }, base), {
27222
27223
  image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : buildConfig.jobImage,
27223
27224
  cache: undefined,
27224
27225
  script: __spreadArray([], __read((_f = (0, utils_1.ensureArray)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : []), false),
27225
27226
  allow_failure: true
27226
- }) : null;
27227
- var lintJob = buildConfig.lint ? __assign(__assign({
27227
+ }), createArtifactsConfig(context.componentConfig.dir, (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.artifactsReports)) : null;
27228
+ var lintJob = buildConfig.lint ? __assign(__assign(__assign({
27228
27229
  name: "๐Ÿ‘ฎ lint"
27229
27230
  }, base), {
27230
- image: (_h = (_g = buildConfig.lint) === null || _g === void 0 ? void 0 : _g.jobImage) !== null && _h !== void 0 ? _h : buildConfig.jobImage,
27231
- script: __spreadArray([], __read((_k = (0, utils_1.ensureArray)((_j = buildConfig.lint) === null || _j === void 0 ? void 0 : _j.command)) !== null && _k !== void 0 ? _k : []), false)
27232
- }) : null;
27233
- var testJob = buildConfig.test ? __assign(__assign({
27231
+ image: (_j = (_h = buildConfig.lint) === null || _h === void 0 ? void 0 : _h.jobImage) !== null && _j !== void 0 ? _j : buildConfig.jobImage,
27232
+ script: __spreadArray([], __read((_l = (0, utils_1.ensureArray)((_k = buildConfig.lint) === null || _k === void 0 ? void 0 : _k.command)) !== null && _l !== void 0 ? _l : []), false)
27233
+ }), createArtifactsConfig(context.componentConfig.dir, (_m = buildConfig.lint) === null || _m === void 0 ? void 0 : _m.artifactsReports)) : null;
27234
+ var testJob = buildConfig.test ? __assign(__assign(__assign({
27234
27235
  name: "๐Ÿงช test"
27235
27236
  }, base), {
27236
- image: (_m = (_l = buildConfig.test) === null || _l === void 0 ? void 0 : _l.jobImage) !== null && _m !== void 0 ? _m : buildConfig.jobImage,
27237
- script: __spreadArray([], __read((_p = (0, utils_1.ensureArray)((_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.command)) !== null && _p !== void 0 ? _p : []), false)
27238
- }) : null;
27237
+ image: (_p = (_o = buildConfig.test) === null || _o === void 0 ? void 0 : _o.jobImage) !== null && _p !== void 0 ? _p : buildConfig.jobImage,
27238
+ script: __spreadArray([], __read((_r = (0, utils_1.ensureArray)((_q = buildConfig.test) === null || _q === void 0 ? void 0 : _q.command)) !== null && _r !== void 0 ? _r : []), false)
27239
+ }), createArtifactsConfig(context.componentConfig.dir, (_s = buildConfig.test) === null || _s === void 0 ? void 0 : _s.artifactsReports)) : null;
27239
27240
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
27240
27241
  };
27241
27242
  exports.createCustomTestJobs = createCustomTestJobs;
27243
+ var createArtifactsConfig = function (rootPath, artifactsReports) {
27244
+ var _a, _b;
27245
+ return artifactsReports ? {
27246
+ artifacts: {
27247
+ paths: [],
27248
+ reports: {
27249
+ junit: (_b = (_a = artifactsReports === null || artifactsReports === void 0 ? void 0 : artifactsReports.junit) === null || _a === void 0 ? void 0 : _a.map(function (p) {
27250
+ return (0, path_1.join)(rootPath, p);
27251
+ })) !== null && _b !== void 0 ? _b : []
27252
+ }
27253
+ }
27254
+ } : undefined;
27255
+ };
27242
27256
 
27243
27257
  /***/ }),
27244
27258
 
@@ -27556,13 +27570,7 @@ var createNodeBuildJobs = function (context) {
27556
27570
  cache: __spreadArray([], __read((0, cache_1.getYarnCache)(context, "pull")), false),
27557
27571
  variables: {
27558
27572
  // only required for non static
27559
- YARN_INSTALL: (0, yarn_1.getYarnInstallCommand)(context, {
27560
- prodOnly: true
27561
- }),
27562
- YARN_INSTALL_WITHOUT_SCRIPTS: (0, yarn_1.getYarnInstallCommand)(context, {
27563
- prodOnly: true,
27564
- noScripts: true
27565
- }),
27573
+ DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context),
27566
27574
  DOCKER_COPY_WORKSPACE_FILES: (_e = (_d = context.packageManagerInfo) === null || _d === void 0 ? void 0 : _d.pathsToCopyInDocker.map(function (dir) {
27567
27575
  return "COPY --chown=node:node ".concat(dir, " /app/").concat(dir);
27568
27576
  })) === null || _e === void 0 ? void 0 : _e.join("\n")
@@ -27965,31 +27973,43 @@ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
27965
27973
  return to.concat(ar || Array.prototype.slice.call(from));
27966
27974
  };
27967
27975
  exports.__esModule = true;
27968
- exports.getYarnInstall = exports.ensureNodeVersion = exports.getYarnInstallCommand = void 0;
27969
- var getYarnInstallCommand = function (context, options) {
27976
+ exports.getDockerAppCopyAndBuildScript = exports.getYarnInstall = exports.ensureNodeVersion = void 0;
27977
+ var YARN_INSTALL_CLASSIC = "yarn install --frozen-lockfile";
27978
+ // FIXME: check why and when rebuild is needed
27979
+ var YARN_BERRY_PROD_REBUILD = "yarn workspaces focus --production && yarn rebuild";
27980
+ var getYarnInstallCommand = function (context) {
27970
27981
  var _a;
27971
27982
  if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
27972
- return "yarn install --frozen-lockfile ".concat((options === null || options === void 0 ? void 0 : options.prodOnly) ? "--production" : "", " ").concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "--ignore-scripts" : "");
27983
+ return YARN_INSTALL_CLASSIC;
27973
27984
  }
27974
- // is modern
27975
- // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
27976
- // trying to import those fail on this version
27977
- var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
27978
- var _a;
27979
- return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
27980
- });
27981
- return (options === null || options === void 0 ? void 0 : options.prodOnly) ? "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "").concat(doesNotShipWithBuiltInPlugins ? "yarn plugin import workspace-tools && " : " ", "yarn workspaces focus --production && yarn rebuild") // needs yarn plugin import workspace-tools
27982
- : "".concat((options === null || options === void 0 ? void 0 : options.noScripts) ? "YARN_ENABLE_SCRIPTS=false " : "", "yarn install --immutable");
27985
+ return "yarn install --immutable";
27983
27986
  };
27984
- exports.getYarnInstallCommand = getYarnInstallCommand;
27985
27987
  var ensureNodeVersion = function (context) {
27986
27988
  return ["if [ -f ./.nvmrc ]; then source /root/.nvm/nvm.sh && nvm install <<< .nvmrc; fi"];
27987
27989
  };
27988
27990
  exports.ensureNodeVersion = ensureNodeVersion;
27989
27991
  var getYarnInstall = function (context) {
27990
- return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [(0, exports.getYarnInstallCommand)(context)], false);
27992
+ return __spreadArray(__spreadArray([], __read((0, exports.ensureNodeVersion)(context)), false), [getYarnInstallCommand(context)], false);
27991
27993
  };
27992
27994
  exports.getYarnInstall = getYarnInstall;
27995
+ var DOCKER_COPY_FILES = "COPY --chown=node:node $APP_DIR .";
27996
+ var getDockerAppCopyAndBuildScript = function (context) {
27997
+ var _a;
27998
+ if ((_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.isClassic) {
27999
+ return "\nRUN ".concat(YARN_INSTALL_CLASSIC, " --production --ignore-scripts\n").concat(DOCKER_COPY_FILES, "\nRUN ").concat(YARN_INSTALL_CLASSIC, " --production \n ").trim();
28000
+ }
28001
+ // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
28002
+ // trying to import those fail on this version
28003
+ var doesNotShipWithBuiltInPlugins = ["2", "3"].some(function (v) {
28004
+ var _a;
28005
+ return (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.version.startsWith(v);
28006
+ });
28007
+ var maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
28008
+ // copy first everything and then install
28009
+ // rebuild first does not work as it will run postinstall and that might require files in the app
28010
+ return "\n".concat(DOCKER_COPY_FILES, "\n").concat(maybeAddWorkspaceToolsCommand, "\nRUN ").concat(YARN_BERRY_PROD_REBUILD, "\n\n ").trim();
28011
+ };
28012
+ exports.getDockerAppCopyAndBuildScript = getDockerAppCopyAndBuildScript;
27993
28013
 
27994
28014
  /***/ }),
27995
28015
 
@@ -28455,7 +28475,7 @@ exports.readConfigSync = readConfigSync;
28455
28475
 
28456
28476
  exports.__esModule = true;
28457
28477
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
28458
- exports.PIPELINE_IMAGE_TAG = "main-bc2a3387" || 0;
28478
+ exports.PIPELINE_IMAGE_TAG = "main-03e0177e" || 0;
28459
28479
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
28460
28480
 
28461
28481
  /***/ }),
@@ -32472,7 +32492,7 @@ var path_equal_1 = __nccwpck_require__(4843);
32472
32492
  var yarnUtils_1 = __nccwpck_require__(9181);
32473
32493
  var getPackageManagerInfo = function (config, componentName) {
32474
32494
  return __awaiter(void 0, void 0, void 0, function () {
32475
- var version, isClassic, component, workspaces, currentWorkspace, componentIsInWorkspace, workspaceRoot, packageJson, workspacePackageJson, lockFile, configFiles, rcFiles, workspaceDependencies, pathsToCopyInDocker;
32495
+ var version, isClassic, component, workspaces, currentWorkspace, componentIsInWorkspace, workspaceRoot, packageJson, workspacePackageJson, lockFile, configFiles, configFilePaths, workspaceDependencies, pathsToCopyInDocker;
32476
32496
  return __generator(this, function (_a) {
32477
32497
  switch (_a.label) {
32478
32498
  case 0:
@@ -32494,9 +32514,9 @@ var getPackageManagerInfo = function (config, componentName) {
32494
32514
  workspacePackageJson = componentIsInWorkspace ? (0, path_1.join)(workspaceRoot, "package.json") : null;
32495
32515
  lockFile = componentIsInWorkspace ? (0, path_1.join)(workspaceRoot, "yarn.lock") : (0, path_1.join)(component.dir, "yarn.lock");
32496
32516
  configFiles = [".yarnrc", ".yarnrc.yml", ".npmrc", ".yarn"];
32497
- rcFiles = (componentIsInWorkspace ? configFiles : configFiles.map(function (f) {
32517
+ configFilePaths = __spreadArray(__spreadArray([], __read(configFiles), false), __read(configFiles.map(function (f) {
32498
32518
  return (0, path_1.join)(component.dir, f);
32499
- })).filter(function (f) {
32519
+ })), false).filter(function (f) {
32500
32520
  return (0, fs_1.existsSync)(f);
32501
32521
  });
32502
32522
  workspaceDependencies = currentWorkspace ? __spreadArray(__spreadArray([], __read(currentWorkspace.workspaceDependencies), false), __read(currentWorkspace.mismatchedWorkspaceDependencies), false).map(function (name) {
@@ -32505,7 +32525,7 @@ var getPackageManagerInfo = function (config, componentName) {
32505
32525
  return w.name === name;
32506
32526
  })) === null || _a === void 0 ? void 0 : _a.location;
32507
32527
  }).filter(Boolean) : [];
32508
- pathsToCopyInDocker = __spreadArray(__spreadArray(__spreadArray(__spreadArray([packageJson], __read(workspacePackageJson ? [workspacePackageJson] : []), false), [lockFile], false), __read(rcFiles), false), __read(workspaceDependencies), false);
32528
+ pathsToCopyInDocker = __spreadArray(__spreadArray(__spreadArray(__spreadArray([packageJson], __read(workspacePackageJson ? [workspacePackageJson] : []), false), [lockFile], false), __read(configFilePaths), false), __read(workspaceDependencies), false);
32509
32529
  return [2 /*return*/, {
32510
32530
  type: "yarn",
32511
32531
  workspaces: workspaces,
package/dist/constants.js CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
5
- exports.PIPELINE_IMAGE_TAG = "main-bc2a3387" || "";
5
+ exports.PIPELINE_IMAGE_TAG = "main-03e0177e" || "";
6
6
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || "";
@@ -154,7 +154,7 @@ var path_equal_1 = require("path-equal");
154
154
  var yarnUtils_1 = require("./yarn/yarnUtils");
155
155
  var getPackageManagerInfo = function (config, componentName) {
156
156
  return __awaiter(void 0, void 0, void 0, function () {
157
- var version, isClassic, component, workspaces, currentWorkspace, componentIsInWorkspace, workspaceRoot, packageJson, workspacePackageJson, lockFile, configFiles, rcFiles, workspaceDependencies, pathsToCopyInDocker;
157
+ var version, isClassic, component, workspaces, currentWorkspace, componentIsInWorkspace, workspaceRoot, packageJson, workspacePackageJson, lockFile, configFiles, configFilePaths, workspaceDependencies, pathsToCopyInDocker;
158
158
  return __generator(this, function (_a) {
159
159
  switch (_a.label) {
160
160
  case 0:
@@ -176,9 +176,9 @@ var getPackageManagerInfo = function (config, componentName) {
176
176
  workspacePackageJson = componentIsInWorkspace ? (0, path_1.join)(workspaceRoot, "package.json") : null;
177
177
  lockFile = componentIsInWorkspace ? (0, path_1.join)(workspaceRoot, "yarn.lock") : (0, path_1.join)(component.dir, "yarn.lock");
178
178
  configFiles = [".yarnrc", ".yarnrc.yml", ".npmrc", ".yarn"];
179
- rcFiles = (componentIsInWorkspace ? configFiles : configFiles.map(function (f) {
179
+ configFilePaths = __spreadArray(__spreadArray([], __read(configFiles), false), __read(configFiles.map(function (f) {
180
180
  return (0, path_1.join)(component.dir, f);
181
- })).filter(function (f) {
181
+ })), false).filter(function (f) {
182
182
  return (0, fs_1.existsSync)(f);
183
183
  });
184
184
  workspaceDependencies = currentWorkspace ? __spreadArray(__spreadArray([], __read(currentWorkspace.workspaceDependencies), false), __read(currentWorkspace.mismatchedWorkspaceDependencies), false).map(function (name) {
@@ -187,7 +187,7 @@ var getPackageManagerInfo = function (config, componentName) {
187
187
  return w.name === name;
188
188
  })) === null || _a === void 0 ? void 0 : _a.location;
189
189
  }).filter(Boolean) : [];
190
- pathsToCopyInDocker = __spreadArray(__spreadArray(__spreadArray(__spreadArray([packageJson], __read(workspacePackageJson ? [workspacePackageJson] : []), false), [lockFile], false), __read(rcFiles), false), __read(workspaceDependencies), false);
190
+ pathsToCopyInDocker = __spreadArray(__spreadArray(__spreadArray(__spreadArray([packageJson], __read(workspacePackageJson ? [workspacePackageJson] : []), false), [lockFile], false), __read(configFilePaths), false), __read(workspaceDependencies), false);
191
191
  return [2 /*return*/, {
192
192
  type: "yarn",
193
193
  workspaces: workspaces,