@catladder/cli 0.0.0-new-cli-52525b58 → 0.0.0-new-cli-51a5f8b1

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 (72) hide show
  1. package/dist/bundles/catenv/index.js +103 -66
  2. package/dist/bundles/cli/index.js +43454 -43373
  3. package/dist/cli/src/adapters/baseContext.d.ts +2 -2
  4. package/dist/cli/src/adapters/baseContext.js +10 -1
  5. package/dist/cli/src/adapters/baseContext.js.map +1 -1
  6. package/dist/cli/src/catenv.js +4 -3
  7. package/dist/cli/src/catenv.js.map +1 -1
  8. package/dist/cli/src/cli.js +3 -3
  9. package/dist/cli/src/cli.js.map +1 -1
  10. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.d.ts +2 -2
  11. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js +9 -9
  12. package/dist/cli/src/commands/cloudSQL/commandRestoreDb.js.map +1 -1
  13. package/dist/cli/src/commands/project/commandConfigSecrets.d.ts +1 -0
  14. package/dist/cli/src/commands/project/commandConfigSecrets.js +1 -0
  15. package/dist/cli/src/commands/project/commandConfigSecrets.js.map +1 -1
  16. package/dist/cli/src/commands/project/commandSetup.d.ts +1 -0
  17. package/dist/cli/src/commands/project/commandSetup.js +2 -1
  18. package/dist/cli/src/commands/project/commandSetup.js.map +1 -1
  19. package/dist/cli/src/completion.d.ts +2 -2
  20. package/dist/cli/src/completion.js +40 -6
  21. package/dist/cli/src/completion.js.map +1 -1
  22. package/dist/cli/src/core/types.d.ts +7 -2
  23. package/dist/cli/src/core/types.js.map +1 -1
  24. package/dist/pipeline/src/build/index.d.ts +2 -2
  25. package/dist/pipeline/src/build/index.js.map +1 -1
  26. package/dist/pipeline/src/build/node/buildJob.d.ts +3 -3
  27. package/dist/pipeline/src/build/node/buildJob.js +13 -12
  28. package/dist/pipeline/src/build/node/buildJob.js.map +1 -1
  29. package/dist/pipeline/src/build/node/cache.d.ts +3 -3
  30. package/dist/pipeline/src/build/node/cache.js +12 -9
  31. package/dist/pipeline/src/build/node/cache.js.map +1 -1
  32. package/dist/pipeline/src/build/node/index.d.ts +3 -3
  33. package/dist/pipeline/src/build/node/index.js +8 -6
  34. package/dist/pipeline/src/build/node/index.js.map +1 -1
  35. package/dist/pipeline/src/build/node/meteor.d.ts +1 -1
  36. package/dist/pipeline/src/build/node/meteor.js +8 -7
  37. package/dist/pipeline/src/build/node/meteor.js.map +1 -1
  38. package/dist/pipeline/src/build/node/testJob.d.ts +1 -1
  39. package/dist/pipeline/src/build/node/testJob.js +5 -5
  40. package/dist/pipeline/src/build/node/testJob.js.map +1 -1
  41. package/dist/pipeline/src/build/node/yarn.d.ts +2 -2
  42. package/dist/pipeline/src/build/node/yarn.js +10 -8
  43. package/dist/pipeline/src/build/node/yarn.js.map +1 -1
  44. package/dist/pipeline/src/constants.js +1 -1
  45. package/dist/pipeline/src/context/createComponentContext.js +3 -3
  46. package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
  47. package/dist/pipeline/src/context/createWorkspaceContext.js +1 -1
  48. package/dist/pipeline/src/context/createWorkspaceContext.js.map +1 -1
  49. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
  50. package/dist/pipeline/src/deploy/custom/deployJob.d.ts +1 -1
  51. package/dist/pipeline/src/deploy/custom/deployJob.js +2 -2
  52. package/dist/pipeline/src/deploy/custom/deployJob.js.map +1 -1
  53. package/dist/pipeline/src/deploy/index.d.ts +1 -1
  54. package/dist/pipeline/src/pipeline/createAllJobs.js +4 -4
  55. package/dist/pipeline/src/pipeline/createAllJobs.js.map +1 -1
  56. package/dist/pipeline/src/pipeline/createJobsForComponent.d.ts +1 -1
  57. package/dist/pipeline/src/pipeline/createJobsForComponent.js +2 -3
  58. package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
  59. package/dist/pipeline/src/pipeline/createJobsForWorkspace.d.ts +1 -1
  60. package/dist/pipeline/src/pipeline/createJobsForWorkspace.js +2 -2
  61. package/dist/pipeline/src/pipeline/createJobsForWorkspace.js.map +1 -1
  62. package/dist/pipeline/src/types/context.d.ts +3 -3
  63. package/dist/tsconfig.tsbuildinfo +1 -1
  64. package/package.json +1 -1
  65. package/src/adapters/baseContext.ts +15 -2
  66. package/src/catenv.ts +15 -8
  67. package/src/cli.ts +7 -2
  68. package/src/commands/cloudSQL/commandRestoreDb.ts +9 -9
  69. package/src/commands/project/commandConfigSecrets.ts +1 -0
  70. package/src/commands/project/commandSetup.ts +6 -1
  71. package/src/completion.ts +43 -6
  72. package/src/core/types.ts +8 -2
@@ -280,10 +280,11 @@ const catenv_1 = __importDefault(__nccwpck_require__(6057));
280
280
  const parseChoice_1 = __nccwpck_require__(4272);
281
281
  const packageInfos_1 = __importDefault(__nccwpck_require__(3568));
282
282
  const program = new commander_1.Command();
283
- program.name("catenv").description("Environment variable and pipeline generation via direnv").version(packageInfos_1.default.version).argument("[envComponent]", "env or env:component").option("-v, --verbose", "verbose output").action((envComponent, opts) => {
284
- var _a;
283
+ program.name("catenv").description("Environment variable and pipeline generation via direnv").version(packageInfos_1.default.version).argument("[envComponent]", "env or env:component").option("-v, --verbose", "verbose output").option("-p, --print-variables", "print variables").action((envComponent, opts) => {
284
+ var _a, _b;
285
285
  (0, catenv_1.default)(envComponent ? (0, parseChoice_1.parseChoice)(envComponent) : null, {
286
- verbose: (_a = opts.verbose) !== null && _a !== void 0 ? _a : false
286
+ verbose: (_a = opts.verbose) !== null && _a !== void 0 ? _a : false,
287
+ printVariables: (_b = opts.printVariables) !== null && _b !== void 0 ? _b : false
287
288
  }).then(() => {
288
289
  // we have to exit manually, because we have some file watches
289
290
  process.exit();
@@ -2113,38 +2114,39 @@ const createBuildJobDefinition_1 = __nccwpck_require__(6254);
2113
2114
  const docker_1 = __nccwpck_require__(2764);
2114
2115
  const cache_1 = __nccwpck_require__(4189);
2115
2116
  const yarn_1 = __nccwpck_require__(8897);
2116
- const createNodeBuildJobs = context => {
2117
+ const createNodeBuildJobs = async context => {
2117
2118
  if (context.type === "workspace") {
2118
2119
  return (0, base_1.createWorkspaceBuildJobs)(context, {
2119
- appBuild: (0, exports.createNodeBuildJobDefinition)(context)
2120
+ appBuild: await (0, exports.createNodeBuildJobDefinition)(context)
2120
2121
  });
2121
2122
  }
2122
2123
  return (0, base_1.createComponentBuildJobs)(context, {
2123
- appBuild: (0, context_1.componentContextIsStandaloneBuild)(context) ? (0, exports.createNodeBuildJobDefinition)(context) : undefined,
2124
- dockerBuild: (0, exports.createNodeDockerJobDefinition)(context)
2124
+ appBuild: (0, context_1.componentContextIsStandaloneBuild)(context) ? await (0, exports.createNodeBuildJobDefinition)(context) : undefined,
2125
+ dockerBuild: await (0, exports.createNodeDockerJobDefinition)(context)
2125
2126
  });
2126
2127
  };
2127
2128
  exports.createNodeBuildJobs = createNodeBuildJobs;
2128
- const createNodeBuildJobDefinition = context => {
2129
+ const createNodeBuildJobDefinition = async context => {
2129
2130
  const buildConfig = context.build.config;
2130
- const yarnInstall = (0, yarn_1.getYarnInstall)(context);
2131
+ const [yarnInstall, nodeCache] = await Promise.all([(0, yarn_1.getYarnInstall)(context), (0, cache_1.getNodeCache)(context)]);
2131
2132
  return (0, createBuildJobDefinition_1.createBuildJobDefinition)(context, buildConfig, {
2132
2133
  prescript: yarnInstall,
2133
- cache: (0, cache_1.getNodeCache)(context)
2134
+ cache: nodeCache
2134
2135
  });
2135
2136
  };
2136
2137
  exports.createNodeBuildJobDefinition = createNodeBuildJobDefinition;
2137
- const createNodeDockerJobDefinition = context => {
2138
- var _a, _b;
2138
+ const createNodeDockerJobDefinition = async context => {
2139
+ var _a;
2139
2140
  // get the default docker built-in type based on the build type
2140
2141
  const dockerDefaultBuiltIn = context.build.buildType === "node-static" || context.build.buildType === "storybook" ? "nginx" : "node";
2142
+ const [yarnCache, dockerAppCopyAndBuildScript, packageManagerInfo] = await Promise.all([(0, cache_1.getYarnCache)(context, "pull"), (0, yarn_1.getDockerAppCopyAndBuildScript)(context), context.packageManagerInfo]);
2141
2143
  return {
2142
2144
  script: (0, docker_1.getDockerBuildScriptWithBuiltInDockerFile)(context, dockerDefaultBuiltIn),
2143
- cache: [...(0, cache_1.getYarnCache)(context, "pull")],
2145
+ cache: [...yarnCache],
2144
2146
  variables: {
2145
2147
  // only required for non static
2146
- DOCKER_COPY_AND_INSTALL_APP: (0, yarn_1.getDockerAppCopyAndBuildScript)(context),
2147
- DOCKER_COPY_WORKSPACE_FILES: (_b = (_a = context.packageManagerInfo) === null || _a === void 0 ? void 0 : _a.pathsToCopyInDocker.map(dir => `COPY --chown=node:node ${dir} /app/${dir}`)) === null || _b === void 0 ? void 0 : _b.join("\n")
2148
+ DOCKER_COPY_AND_INSTALL_APP: dockerAppCopyAndBuildScript,
2149
+ DOCKER_COPY_WORKSPACE_FILES: (_a = packageManagerInfo === null || packageManagerInfo === void 0 ? void 0 : packageManagerInfo.pathsToCopyInDocker.map(dir => `COPY --chown=node:node ${dir} /app/${dir}`)) === null || _a === void 0 ? void 0 : _a.join("\n")
2148
2150
  }
2149
2151
  };
2150
2152
  };
@@ -2170,8 +2172,9 @@ exports.getNodeCache = exports.getNodeModulesCache = exports.getYarnCache = void
2170
2172
  const lodash_1 = __nccwpck_require__(9250);
2171
2173
  const path_1 = __nccwpck_require__(6928);
2172
2174
  const slugify_1 = __importDefault(__nccwpck_require__(4206));
2173
- const getYarnCache = (context, policy = "pull-push") => {
2174
- const componentIsInWorkspace = context.type === "component" && context.packageManagerInfo.componentIsInWorkspace;
2175
+ const getYarnCache = async (context, policy = "pull-push") => {
2176
+ const packageManagerInfo = await context.packageManagerInfo;
2177
+ const componentIsInWorkspace = context.type === "component" && "componentIsInWorkspace" in packageManagerInfo && packageManagerInfo.componentIsInWorkspace;
2175
2178
  return [{
2176
2179
  scope: componentIsInWorkspace ? "global" : "buildDir",
2177
2180
  pathMode: componentIsInWorkspace ? "absolute" : "relative",
@@ -2181,12 +2184,14 @@ const getYarnCache = (context, policy = "pull-push") => {
2181
2184
  }];
2182
2185
  };
2183
2186
  exports.getYarnCache = getYarnCache;
2184
- const getNodeModulesCache = (context, policy = "pull-push") => {
2187
+ const getNodeModulesCache = async (context, policy = "pull-push") => {
2185
2188
  var _a, _b;
2186
- const componentIsInWorkspace = context.type === "component" && context.packageManagerInfo.componentIsInWorkspace;
2189
+ const packageManagerInfo = await context.packageManagerInfo;
2190
+ const componentIsInWorkspace = context.type === "component" && "componentIsInWorkspace" in packageManagerInfo && packageManagerInfo.componentIsInWorkspace;
2187
2191
  const {
2188
- isClassic
2189
- } = context.packageManagerInfo;
2192
+ isClassic,
2193
+ workspaces
2194
+ } = packageManagerInfo;
2190
2195
  // 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.
2191
2196
  // It would slow down all pipelines whenever one adds a new dependency as it will need to download all node_modules again.
2192
2197
  return [{
@@ -2196,12 +2201,12 @@ const getNodeModulesCache = (context, policy = "pull-push") => {
2196
2201
  key: componentIsInWorkspace ? "node-modules-workspace" : (0, slugify_1.default)(context.build.dir) + "-node-modules",
2197
2202
  // we use the dirname, not the component name, because in certain cases we have two apps in the same directory and want to share the cache, e.g. when having storybook in the same package.json
2198
2203
  policy,
2199
- paths: [...(componentIsInWorkspace ? (0, lodash_1.uniq)(["node_modules", ...((_a = context.packageManagerInfo.workspaces.map(w => (0, path_1.join)(w.location, "node_modules"))) !== null && _a !== void 0 ? _a : []), ...(!isClassic ? [".yarn/install-state.gz", ...((_b = context.packageManagerInfo.workspaces.map(w => (0, path_1.join)(w.location, ".yarn/install-state.gz"))) !== null && _b !== void 0 ? _b : [])] : [])]) : [(0, path_1.join)(context.build.dir, "node_modules"), ...(!isClassic ? [(0, path_1.join)(context.build.dir, ".yarn/install-state.gz")] : [])])]
2204
+ paths: [...(componentIsInWorkspace ? (0, lodash_1.uniq)(["node_modules", ...((_a = workspaces.map(w => (0, path_1.join)(w.location, "node_modules"))) !== null && _a !== void 0 ? _a : []), ...(!isClassic ? [".yarn/install-state.gz", ...((_b = workspaces.map(w => (0, path_1.join)(w.location, ".yarn/install-state.gz"))) !== null && _b !== void 0 ? _b : [])] : [])]) : [(0, path_1.join)(context.build.dir, "node_modules"), ...(!isClassic ? [(0, path_1.join)(context.build.dir, ".yarn/install-state.gz")] : [])])]
2200
2205
  }];
2201
2206
  };
2202
2207
  exports.getNodeModulesCache = getNodeModulesCache;
2203
- const getNodeCache = (context, policy = "pull-push") => {
2204
- return [...(0, exports.getYarnCache)(context, policy), ...(0, exports.getNodeModulesCache)(context, policy)];
2208
+ const getNodeCache = async (context, policy = "pull-push") => {
2209
+ return [...(await (0, exports.getYarnCache)(context, policy)), ...(await (0, exports.getNodeModulesCache)(context, policy))];
2205
2210
  };
2206
2211
  exports.getNodeCache = getNodeCache;
2207
2212
 
@@ -2238,16 +2243,18 @@ exports.createMeteorJobs = exports.createStorybookJobs = exports.createNodeJobs
2238
2243
  const buildJob_1 = __nccwpck_require__(5464);
2239
2244
  const meteor_1 = __nccwpck_require__(6055);
2240
2245
  const testJob_1 = __nccwpck_require__(9884);
2241
- const createNodeJobs = context => {
2242
- return [...(0, testJob_1.createNodeTestJobs)(context), ...(0, buildJob_1.createNodeBuildJobs)(context)];
2246
+ const createNodeJobs = async context => {
2247
+ const [testJobs, buildJobs] = await Promise.all([(0, testJob_1.createNodeTestJobs)(context), (0, buildJob_1.createNodeBuildJobs)(context)]);
2248
+ return [...testJobs, ...buildJobs];
2243
2249
  };
2244
2250
  exports.createNodeJobs = createNodeJobs;
2245
- const createStorybookJobs = context => {
2246
- return [...(0, buildJob_1.createNodeBuildJobs)(context)];
2251
+ const createStorybookJobs = async context => {
2252
+ return [...(await (0, buildJob_1.createNodeBuildJobs)(context))];
2247
2253
  };
2248
2254
  exports.createStorybookJobs = createStorybookJobs;
2249
- const createMeteorJobs = context => {
2250
- return [...(0, testJob_1.createNodeTestJobs)(context), ...(0, meteor_1.createMeteorBuildJobs)(context)];
2255
+ const createMeteorJobs = async context => {
2256
+ const [testJobs, buildJobs] = await Promise.all([(0, testJob_1.createNodeTestJobs)(context), (0, meteor_1.createMeteorBuildJobs)(context)]);
2257
+ return [...testJobs, ...buildJobs];
2251
2258
  };
2252
2259
  exports.createMeteorJobs = createMeteorJobs;
2253
2260
 
@@ -2275,8 +2282,9 @@ const getMeteorCache = context => [{
2275
2282
  policy: "pull-push",
2276
2283
  paths: [".meteor/local/resolver-result-cache.json", ".meteor/local/plugin-cache", ".meteor/local/isopacks", ".meteor/local/bundler-cache/scanner"]
2277
2284
  }];
2278
- const getMeteorDockerInstallScripts = context => {
2279
- if (context.packageManagerInfo.isClassic) {
2285
+ const getMeteorDockerInstallScripts = async context => {
2286
+ const packageManagerInfo = await context.packageManagerInfo;
2287
+ if (packageManagerInfo.isClassic) {
2280
2288
  return new BashExpression_1.BashExpression(`
2281
2289
  COPY $APP_DIR/package.json $APP_DIR/yarn.lock ./
2282
2290
 
@@ -2286,7 +2294,7 @@ RUN yarn --frozen-lockfile --production=true --ignore-engines
2286
2294
  `.trim());
2287
2295
  }
2288
2296
  // yarn >= 4 ships with built-in plugins, see https://github.com/yarnpkg/berry/pull/4253
2289
- const doesNotShipWithBuiltInPlugins = ["2", "3"].some(v => context.packageManagerInfo.version.startsWith(v));
2297
+ const doesNotShipWithBuiltInPlugins = ["2", "3"].some(v => packageManagerInfo.version.startsWith(v));
2290
2298
  const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
2291
2299
  return new BashExpression_1.BashExpression(`
2292
2300
  ENV YARN_ENABLE_INLINE_BUILDS=1
@@ -2295,15 +2303,15 @@ ${maybeAddWorkspaceToolsCommand}
2295
2303
  RUN yarn workspaces focus --production
2296
2304
  `.trim());
2297
2305
  };
2298
- const createMeteorBuildJobs = context => {
2306
+ const createMeteorBuildJobs = async context => {
2299
2307
  const buildConfig = context.build.config;
2300
2308
  if (!(0, types_1.isOfBuildType)(buildConfig, "meteor")) {
2301
2309
  throw new Error("deploy config is not meteor");
2302
2310
  }
2303
- const yarnInstall = (0, yarn_1.getYarnInstall)(context);
2311
+ const [yarnInstall, nodeCache, meteorInstallScripts] = await Promise.all([(0, yarn_1.getYarnInstall)(context), (0, cache_1.getNodeCache)(context), buildConfig.installScripts ? getMeteorDockerInstallScripts(context) : Promise.resolve("")]);
2304
2312
  return (0, base_1.createComponentBuildJobs)(context, {
2305
2313
  appBuild: buildConfig.buildCommand !== null && buildConfig.buildCommand !== false ? {
2306
- cache: [...(0, cache_1.getNodeCache)(context), ...getMeteorCache(context)],
2314
+ cache: [...nodeCache, ...getMeteorCache(context)],
2307
2315
  image: (0, runner_1.getRunnerImage)("jobs-meteor"),
2308
2316
  variables: {
2309
2317
  METEOR_DISABLE_OPTIMISTIC_CACHING: "1" // see https://forums.meteor.com/t/veeery-long-building-time-inside-docker-container/58673/17?u=macrozone
@@ -2313,7 +2321,7 @@ const createMeteorBuildJobs = context => {
2313
2321
  dockerBuild: {
2314
2322
  script: (0, docker_1.getDockerBuildScriptWithBuiltInDockerFile)(context, "meteor"),
2315
2323
  variables: {
2316
- METEOR_INSTALL_SCRIPTS: buildConfig.installScripts ? getMeteorDockerInstallScripts(context) : ""
2324
+ METEOR_INSTALL_SCRIPTS: meteorInstallScripts
2317
2325
  }
2318
2326
  }
2319
2327
  });
@@ -2340,7 +2348,7 @@ const cache_1 = __nccwpck_require__(4189);
2340
2348
  const constants_1 = __nccwpck_require__(5497);
2341
2349
  const yarn_1 = __nccwpck_require__(8897);
2342
2350
  const createJobCache_1 = __nccwpck_require__(5644);
2343
- const createNodeTestJobs = context => {
2351
+ const createNodeTestJobs = async context => {
2344
2352
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
2345
2353
  // don't run tests after release
2346
2354
  // TODO: this will be replaced by using rules
@@ -2363,7 +2371,7 @@ const createNodeTestJobs = context => {
2363
2371
  needs: []
2364
2372
  };
2365
2373
  const buildConfig = context.build.config;
2366
- const yarnInstall = (0, yarn_1.getYarnInstall)(context);
2374
+ const [yarnInstall, packageManagerInfo, nodeCache] = await Promise.all([(0, yarn_1.getYarnInstall)(context), context.packageManagerInfo, (0, cache_1.getNodeCache)(context)]);
2367
2375
  const auditJob = buildConfig.audit !== false ? {
2368
2376
  name: "🛡 audit",
2369
2377
  ...base,
@@ -2374,7 +2382,7 @@ const createNodeTestJobs = context => {
2374
2382
  image: (_d = (_c = buildConfig.audit) === null || _c === void 0 ? void 0 : _c.jobImage) !== null && _d !== void 0 ? _d : defaultImage,
2375
2383
  cache: undefined,
2376
2384
  // audit does not need yarn install and no cache
2377
- script: [`cd ${context.build.dir}`, ...((_f = (0, utils_1.ensureArrayOrNull)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : [context.packageManagerInfo.isClassic ? "yarn audit --level critical" : "yarn npm audit --environment production --severity critical" // yarn 2
2385
+ script: [`cd ${context.build.dir}`, ...((_f = (0, utils_1.ensureArrayOrNull)((_e = buildConfig.audit) === null || _e === void 0 ? void 0 : _e.command)) !== null && _f !== void 0 ? _f : [packageManagerInfo.isClassic ? "yarn audit --level critical" : "yarn npm audit --environment production --severity critical" // yarn 2
2378
2386
  ])],
2379
2387
  allow_failure: (_h = (_g = buildConfig.audit) === null || _g === void 0 ? void 0 : _g.allowFailure) !== null && _h !== void 0 ? _h : true,
2380
2388
  ...(0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_j = buildConfig.audit) === null || _j === void 0 ? void 0 : _j.artifactsReports, (_k = buildConfig.audit) === null || _k === void 0 ? void 0 : _k.artifacts)
@@ -2387,7 +2395,7 @@ const createNodeTestJobs = context => {
2387
2395
  ...((_m = (_l = buildConfig.lint) === null || _l === void 0 ? void 0 : _l.runnerVariables) !== null && _m !== void 0 ? _m : {})
2388
2396
  },
2389
2397
  image: (_p = (_o = buildConfig.lint) === null || _o === void 0 ? void 0 : _o.jobImage) !== null && _p !== void 0 ? _p : defaultImage,
2390
- cache: (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, (0, cache_1.getNodeCache)(context)),
2398
+ cache: (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, nodeCache),
2391
2399
  script: [...(0, yarn_1.ensureNodeVersion)(context), `cd ${context.build.dir}`, ...yarnInstall, ...((_r = (0, utils_1.ensureArrayOrNull)((_q = buildConfig.lint) === null || _q === void 0 ? void 0 : _q.command)) !== null && _r !== void 0 ? _r : ["yarn lint"])],
2392
2400
  allow_failure: (_s = buildConfig.lint) === null || _s === void 0 ? void 0 : _s.allowFailure,
2393
2401
  ...(0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_t = buildConfig.lint) === null || _t === void 0 ? void 0 : _t.artifactsReports, (_u = buildConfig.lint) === null || _u === void 0 ? void 0 : _u.artifacts)
@@ -2400,7 +2408,7 @@ const createNodeTestJobs = context => {
2400
2408
  ...((_w = (_v = buildConfig.test) === null || _v === void 0 ? void 0 : _v.runnerVariables) !== null && _w !== void 0 ? _w : {})
2401
2409
  },
2402
2410
  image: (_y = (_x = buildConfig.test) === null || _x === void 0 ? void 0 : _x.jobImage) !== null && _y !== void 0 ? _y : (0, runner_1.getRunnerImage)("jobs-testing-chrome"),
2403
- cache: (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, (0, cache_1.getNodeCache)(context)),
2411
+ cache: (0, createJobCache_1.createJobCacheFromCacheConfigs)(context, nodeCache),
2404
2412
  script: [...(0, yarn_1.ensureNodeVersion)(context), `cd ${context.build.dir}`, ...yarnInstall, ...((_0 = (0, utils_1.ensureArrayOrNull)((_z = buildConfig.test) === null || _z === void 0 ? void 0 : _z.command)) !== null && _0 !== void 0 ? _0 : ["yarn test"])],
2405
2413
  allow_failure: (_1 = buildConfig.test) === null || _1 === void 0 ? void 0 : _1.allowFailure,
2406
2414
  ...(0, createArtifactsConfig_1.createArtifactsConfig)(context.build.dir, (_2 = buildConfig.test) === null || _2 === void 0 ? void 0 : _2.artifactsReports, (_3 = buildConfig.test) === null || _3 === void 0 ? void 0 : _3.artifacts)
@@ -2428,8 +2436,9 @@ const YARN_INSTALL_CLASSIC = `yarn install --frozen-lockfile`;
2428
2436
  const YARN_BERRY_PROD_INSTALL = `yarn workspaces focus --production`;
2429
2437
  // FIXME: check why and when rebuild is needed
2430
2438
  const YARN_BERRY_PROD_REBUILD = `yarn rebuild`;
2431
- const getYarnInstallCommand = context => {
2432
- if (context.packageManagerInfo.isClassic) {
2439
+ const getYarnInstallCommand = async context => {
2440
+ const packageManagerInfo = await context.packageManagerInfo;
2441
+ if (packageManagerInfo.isClassic) {
2433
2442
  return YARN_INSTALL_CLASSIC;
2434
2443
  }
2435
2444
  // inline builds make debugging easier as it prints it out in the logs, instead of writing it in temp files
@@ -2437,26 +2446,27 @@ const getYarnInstallCommand = context => {
2437
2446
  };
2438
2447
  const ensureNodeVersion = context => (0, gitlab_1.collapseableSection)("nodeinstall", "Ensure node version")(["if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi", "if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi"]);
2439
2448
  exports.ensureNodeVersion = ensureNodeVersion;
2440
- const getYarnInstall = (context, options) => {
2449
+ const getYarnInstall = async (context, options) => {
2441
2450
  const postInstall = context.type !== "workspace" && context.build.type !== "disabled" && "postInstall" in context.build.config ? context.build.config.postInstall : null;
2442
- return [...(0, exports.ensureNodeVersion)(context), ...(0, gitlab_1.collapseableSection)("yarninstall", "Yarn install")([getYarnInstallCommand(context)]), ...(postInstall && !(options === null || options === void 0 ? void 0 : options.noCustomPostInstall) ? (0, gitlab_1.collapseableSection)("postinstall", "Custom post install")((0, utils_1.ensureArray)(postInstall)) : [])];
2451
+ return [...(0, exports.ensureNodeVersion)(context), ...(0, gitlab_1.collapseableSection)("yarninstall", "Yarn install")([await getYarnInstallCommand(context)]), ...(postInstall && !(options === null || options === void 0 ? void 0 : options.noCustomPostInstall) ? (0, gitlab_1.collapseableSection)("postinstall", "Custom post install")((0, utils_1.ensureArray)(postInstall)) : [])];
2443
2452
  };
2444
2453
  exports.getYarnInstall = getYarnInstall;
2445
2454
  const DOCKER_COPY_FILES = `COPY --chown=node:node $APP_DIR .`;
2446
- const getDockerAppCopyAndBuildScript = context => {
2455
+ const getDockerAppCopyAndBuildScript = async context => {
2447
2456
  var _a, _b, _c;
2448
- if (context.packageManagerInfo.isClassic) {
2457
+ const packageManagerInfo = await context.packageManagerInfo;
2458
+ if (packageManagerInfo.isClassic) {
2449
2459
  return new BashExpression_1.BashExpression(`
2450
2460
  RUN ${YARN_INSTALL_CLASSIC} --production --ignore-scripts
2451
2461
  ${DOCKER_COPY_FILES}
2452
- RUN ${YARN_INSTALL_CLASSIC} --production
2462
+ RUN ${YARN_INSTALL_CLASSIC} --production
2453
2463
  `.trim());
2454
2464
  }
2455
2465
  const yarnRebuildEnabledDefault = context.build.type === "fromWorkspace" ? (_b = (_a = context.build.workspaceBuildConfig.dockerDefaults) === null || _a === void 0 ? void 0 : _a.yarnRebuildEnabled) !== null && _b !== void 0 ? _b : true : true;
2456
2466
  const yarnRebuildEnabled = "docker" in context.build.config && context.build.config.docker && "yarnRebuildEnabled" in context.build.config.docker ? (_c = context.build.config.docker.yarnRebuildEnabled) !== null && _c !== void 0 ? _c : yarnRebuildEnabledDefault : yarnRebuildEnabledDefault;
2457
2467
  // yarn >= 4 ships with build in plugins, see https://github.com/yarnpkg/berry/pull/4253
2458
2468
  // trying to import those fail on this version
2459
- const doesNotShipWithBuiltInPlugins = ["2", "3"].some(v => context.packageManagerInfo.version.startsWith(v));
2469
+ const doesNotShipWithBuiltInPlugins = ["2", "3"].some(v => packageManagerInfo.version.startsWith(v));
2460
2470
  const maybeAddWorkspaceToolsCommand = doesNotShipWithBuiltInPlugins ? "RUN yarn plugin import workspace-tools" : "";
2461
2471
  // copy first everything and then install
2462
2472
  // rebuild first does not work as it will run postinstall and that might require files in the app
@@ -2814,7 +2824,7 @@ Object.defineProperty(exports, "__esModule", ({
2814
2824
  value: true
2815
2825
  }));
2816
2826
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
2817
- exports.PIPELINE_IMAGE_TAG = "new-cli-52525b58" || 0;
2827
+ exports.PIPELINE_IMAGE_TAG = "new-cli-51a5f8b1" || 0;
2818
2828
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
2819
2829
 
2820
2830
  /***/ }),
@@ -2875,7 +2885,7 @@ const createComponentContext = async ctx => {
2875
2885
  if (!/^[a-z0-9-]+$/.test(ctx.componentName)) {
2876
2886
  throw new Error("componentName may only contain lower case letters, numbers and -");
2877
2887
  }
2878
- const packageManagerInfo = await (0, packageManager_1.getPackageManagerInfoForComponent)(ctx.config, ctx.componentName);
2888
+ const packageManagerInfoPromise = (0, packageManager_1.getPackageManagerInfoForComponent)(ctx.config, ctx.componentName);
2879
2889
  const envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(ctx);
2880
2890
  const componentConfigWithoutDefaults = envContext.envConfigRaw;
2881
2891
  const resolvedBuildType = componentConfigWithoutDefaults.build === false ? false : (0, build_1.isStandaloneBuildConfig)(componentConfigWithoutDefaults.build) ? componentConfigWithoutDefaults.build.type : (_a = ctx.config.builds) === null || _a === void 0 ? void 0 : _a[componentConfigWithoutDefaults.build.from].type;
@@ -2890,7 +2900,7 @@ const createComponentContext = async ctx => {
2890
2900
  deploy: {}
2891
2901
  };
2892
2902
  const componentConfig = (0, utils_1.mergeWithMergingArrays)(defaults, componentConfigWithoutDefaults);
2893
- const environment = await (0, getEnvironment_1.getEnvironment)(ctx);
2903
+ const [environment, packageManagerInfo] = await Promise.all([(0, getEnvironment_1.getEnvironment)(ctx), packageManagerInfoPromise]);
2894
2904
  const {
2895
2905
  deploy,
2896
2906
  build,
@@ -2948,7 +2958,7 @@ const createComponentContext = async ctx => {
2948
2958
  config: deploy
2949
2959
  } : null,
2950
2960
  environment,
2951
- packageManagerInfo: packageManagerInfo,
2961
+ packageManagerInfo: packageManagerInfoPromise,
2952
2962
  pipelineType: ctx.pipelineType,
2953
2963
  trigger: ctx.trigger
2954
2964
  };
@@ -3000,7 +3010,7 @@ async function createWorkspaceContext({
3000
3010
  env,
3001
3011
  components,
3002
3012
  fullConfig: config,
3003
- packageManagerInfo: await (0, packageManager_1.getPackageManagerInfoBase)(),
3013
+ packageManagerInfo: (0, packageManager_1.getPackageManagerInfoBase)(),
3004
3014
  build: {
3005
3015
  type: "workspace",
3006
3016
  dir: (_b = workspaceConfig.dir) !== null && _b !== void 0 ? _b : ".",
@@ -4990,7 +5000,7 @@ const yarn_1 = __nccwpck_require__(8897);
4990
5000
  const runner_1 = __nccwpck_require__(2348);
4991
5001
  const base_1 = __nccwpck_require__(8563);
4992
5002
  const types_1 = __nccwpck_require__(2383);
4993
- const createCustomDeployJobs = context => {
5003
+ const createCustomDeployJobs = async context => {
4994
5004
  var _a, _b, _c;
4995
5005
  const deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
4996
5006
  if (!(0, types_1.isOfDeployType)(deployConfig, "custom")) {
@@ -4998,7 +5008,7 @@ const createCustomDeployJobs = context => {
4998
5008
  throw new Error("deploy config is not custom");
4999
5009
  }
5000
5010
  // FIXME: custom deploy currently assumes yarn-based project
5001
- const yarnInstall = (0, yarn_1.getYarnInstall)(context, {
5011
+ const yarnInstall = await (0, yarn_1.getYarnInstall)(context, {
5002
5012
  noCustomPostInstall: true
5003
5013
  });
5004
5014
  const result = (0, base_1.createDeployementJobs)(context, {
@@ -6420,16 +6430,16 @@ const createAllJobs = async ({
6420
6430
  });
6421
6431
  return {
6422
6432
  context: workspaceContext,
6423
- jobs: (0, createJobsForWorkspace_1.createJobsForWorkspace)(workspaceContext)
6433
+ jobs: await (0, createJobsForWorkspace_1.createJobsForWorkspace)(workspaceContext)
6424
6434
  };
6425
6435
  }));
6426
6436
  })).then(f => f.flat()),
6427
- components: allComponentsContext.map(context => {
6437
+ components: await Promise.all(allComponentsContext.map(async context => {
6428
6438
  return {
6429
6439
  context,
6430
- jobs: (0, createJobsForComponent_1.createJobsForComponentContext)(context)
6440
+ jobs: await (0, createJobsForComponent_1.createJobsForComponentContext)(context)
6431
6441
  };
6432
- }),
6442
+ })),
6433
6443
  agents: await Promise.all(Object.keys((_b = config.agents) !== null && _b !== void 0 ? _b : {}).map(async agentName => {
6434
6444
  const context = await (0, createAgentContext_1.createAgentContext)({
6435
6445
  agentName,
@@ -6478,9 +6488,8 @@ const getCustomJobs = context => {
6478
6488
  const rawJobs = context.customJobs;
6479
6489
  return injectDefaultVarsInCustomJobs(context, rawJobs);
6480
6490
  };
6481
- const createJobsForComponentContext = context => {
6482
- const buildJobs = context.build.type !== "disabled" ? build_1.BUILD_TYPES[context.build.buildType].jobs(context) : [];
6483
- const deployJobs = context.componentConfig.deploy !== false ? deploy_1.DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context) : [];
6491
+ const createJobsForComponentContext = async context => {
6492
+ const [buildJobs, deployJobs] = await Promise.all([context.build.type !== "disabled" ? build_1.BUILD_TYPES[context.build.buildType].jobs(context) : [], context.componentConfig.deploy !== false ? deploy_1.DEPLOY_TYPES[context.componentConfig.deploy.type].jobs(context) : []]);
6484
6493
  const customJobs = getCustomJobs(context);
6485
6494
  return [...buildJobs, ...deployJobs, ...customJobs];
6486
6495
  };
@@ -6499,8 +6508,8 @@ Object.defineProperty(exports, "__esModule", ({
6499
6508
  }));
6500
6509
  exports.createJobsForWorkspace = void 0;
6501
6510
  const build_1 = __nccwpck_require__(1398);
6502
- const createJobsForWorkspace = context => {
6503
- const buildJobs = build_1.WORKSPACE_BUILD_TYPES[context.build.buildType].jobs(context);
6511
+ const createJobsForWorkspace = async context => {
6512
+ const buildJobs = await build_1.WORKSPACE_BUILD_TYPES[context.build.buildType].jobs(context);
6504
6513
  return buildJobs;
6505
6514
  };
6506
6515
  exports.createJobsForWorkspace = createJobsForWorkspace;
@@ -7334,6 +7343,8 @@ Object.defineProperty(exports, "__esModule", ({
7334
7343
  }));
7335
7344
  exports.getWorkspaceDependencies = exports.getWorkspaces = exports.getYarnVersion = void 0;
7336
7345
  const child_process_promise_1 = __nccwpck_require__(1748);
7346
+ const promises_1 = __nccwpck_require__(1943);
7347
+ const path_1 = __nccwpck_require__(6928);
7337
7348
  const memoizee_1 = __importDefault(__nccwpck_require__(7009));
7338
7349
  const jsonParse_1 = __nccwpck_require__(502);
7339
7350
  const execOrFail = async (cmd, onFail) => {
@@ -7343,8 +7354,34 @@ const execOrFail = async (cmd, onFail) => {
7343
7354
  return onFail !== null && onFail !== void 0 ? onFail : null;
7344
7355
  }
7345
7356
  };
7357
+ const readPackageManagerVersion = async dir => {
7358
+ var _a;
7359
+ try {
7360
+ const pkg = JSON.parse(await (0, promises_1.readFile)((0, path_1.join)(dir, "package.json"), "utf-8"));
7361
+ const match = /^yarn@(.+)$/.exec(pkg.packageManager);
7362
+ return (_a = match === null || match === void 0 ? void 0 : match[1]) !== null && _a !== void 0 ? _a : null;
7363
+ } catch (_b) {
7364
+ return null;
7365
+ }
7366
+ };
7367
+ const getGitRoot = async () => {
7368
+ try {
7369
+ return (await (0, child_process_promise_1.exec)("git rev-parse --show-toplevel")).stdout.trim();
7370
+ } catch (_a) {
7371
+ return null;
7372
+ }
7373
+ };
7346
7374
  // export for mocking
7347
7375
  exports.getYarnVersion = (0, memoizee_1.default)(async () => {
7376
+ // Fast path: read from package.json packageManager field
7377
+ const fromCwd = await readPackageManagerVersion(process.cwd());
7378
+ if (fromCwd) return fromCwd;
7379
+ const gitRoot = await getGitRoot();
7380
+ if (gitRoot && gitRoot !== process.cwd()) {
7381
+ const fromGitRoot = await readPackageManagerVersion(gitRoot);
7382
+ if (fromGitRoot) return fromGitRoot;
7383
+ }
7384
+ // Fallback: invoke yarn CLI
7348
7385
  return await execOrFail("yarn --version", "");
7349
7386
  }, {
7350
7387
  promise: true