@catladder/cli 0.0.0-remove-unused-dep-97e2db60 → 0.0.0-remove-env-mode-none-9b62fbb1

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 (153) hide show
  1. package/dist/bundles/catenv/index.js +1044 -274
  2. package/dist/bundles/cli/index.js +1497 -351
  3. package/dist/cli/src/apps/catenv/catenv.js +5 -4
  4. package/dist/cli/src/apps/catenv/catenv.js.map +1 -1
  5. package/dist/cli/src/apps/catenv/printVariables.d.ts +2 -2
  6. package/dist/cli/src/apps/catenv/printVariables.js +2 -2
  7. package/dist/cli/src/apps/catenv/printVariables.js.map +1 -1
  8. package/dist/cli/src/apps/catenv/writeDotEnvFiles.d.ts +2 -2
  9. package/dist/cli/src/apps/catenv/writeDotEnvFiles.js +5 -6
  10. package/dist/cli/src/apps/catenv/writeDotEnvFiles.js.map +1 -1
  11. package/dist/cli/src/apps/catenv/writeEnvDTs.d.ts +2 -2
  12. package/dist/cli/src/apps/catenv/writeEnvDTs.js +5 -6
  13. package/dist/cli/src/apps/catenv/writeEnvDTs.js.map +1 -1
  14. package/dist/cli/src/apps/cli/commands/project/setup/index.js +7 -2
  15. package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
  16. package/dist/cli/src/apps/cli/commands/project/setup/logSection.d.ts +2 -0
  17. package/dist/cli/src/apps/cli/commands/project/setup/logSection.js +17 -0
  18. package/dist/cli/src/apps/cli/commands/project/setup/logSection.js.map +1 -0
  19. package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.d.ts +2 -0
  20. package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.js +157 -0
  21. package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.js.map +1 -0
  22. package/dist/cli/src/apps/cli/commands/project/setup/setupContext.js +11 -15
  23. package/dist/cli/src/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  24. package/dist/cli/src/config/getProjectConfig.js +4 -1
  25. package/dist/cli/src/config/getProjectConfig.js.map +1 -1
  26. package/dist/cli/src/git/getGetMainBranch.d.ts +1 -0
  27. package/dist/cli/src/git/getGetMainBranch.js +10 -0
  28. package/dist/cli/src/git/getGetMainBranch.js.map +1 -0
  29. package/dist/cli/src/git/index.d.ts +1 -0
  30. package/dist/cli/src/git/index.js +1 -0
  31. package/dist/cli/src/git/index.js.map +1 -1
  32. package/dist/pipeline/src/bash/bashEscape.d.ts +2 -0
  33. package/dist/pipeline/src/bash/bashEscape.js +5 -1
  34. package/dist/pipeline/src/bash/bashEscape.js.map +1 -1
  35. package/dist/pipeline/src/build/artifacts/createBuildJobArtifact.js +16 -7
  36. package/dist/pipeline/src/build/artifacts/createBuildJobArtifact.js.map +1 -1
  37. package/dist/pipeline/src/build/custom/testJob.js +0 -1
  38. package/dist/pipeline/src/build/custom/testJob.js.map +1 -1
  39. package/dist/pipeline/src/build/index.js +1 -0
  40. package/dist/pipeline/src/build/index.js.map +1 -1
  41. package/dist/pipeline/src/build/node/testJob.js +0 -1
  42. package/dist/pipeline/src/build/node/testJob.js.map +1 -1
  43. package/dist/pipeline/src/build/rails/test.js +18 -2
  44. package/dist/pipeline/src/build/rails/test.js.map +1 -1
  45. package/dist/pipeline/src/build/types.d.ts +18 -0
  46. package/dist/pipeline/src/build/types.js.map +1 -1
  47. package/dist/pipeline/src/catenv/index.d.ts +7 -0
  48. package/dist/pipeline/src/catenv/index.js +12 -0
  49. package/dist/pipeline/src/catenv/index.js.map +1 -0
  50. package/dist/pipeline/src/deploy/cloudRun/cleanup.js +5 -1
  51. package/dist/pipeline/src/deploy/cloudRun/cleanup.js.map +1 -1
  52. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +1 -1
  53. package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
  54. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js +1 -1
  55. package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/schedules.js.map +1 -1
  56. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +3 -1
  57. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js.map +1 -1
  58. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js +3 -1
  59. package/dist/pipeline/src/deploy/cloudRun/createJobs/getCloudRunStopScripts.js.map +1 -1
  60. package/dist/pipeline/src/deploy/cloudRun/index.js +10 -5
  61. package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
  62. package/dist/pipeline/src/deploy/cloudRun/utils/database.d.ts +21 -2
  63. package/dist/pipeline/src/deploy/cloudRun/utils/database.js +55 -6
  64. package/dist/pipeline/src/deploy/cloudRun/utils/database.js.map +1 -1
  65. package/dist/pipeline/src/deploy/kubernetes/kubeValues.d.ts +1 -0
  66. package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +11 -1
  67. package/dist/pipeline/src/deploy/types/googleCloudRun.js.map +1 -1
  68. package/dist/pipeline/src/deploy/types/kubernetes.d.ts +1 -0
  69. package/dist/pipeline/src/index.d.ts +1 -0
  70. package/dist/pipeline/src/index.js +1 -0
  71. package/dist/pipeline/src/index.js.map +1 -1
  72. package/dist/pipeline/src/pipeline/agent/createAgentContext.d.ts +23 -0
  73. package/dist/pipeline/src/pipeline/agent/createAgentContext.js +45 -0
  74. package/dist/pipeline/src/pipeline/agent/createAgentContext.js.map +1 -0
  75. package/dist/pipeline/src/pipeline/agent/createAgentEventJob.d.ts +2 -0
  76. package/dist/pipeline/src/pipeline/agent/createAgentEventJob.js +37 -0
  77. package/dist/pipeline/src/pipeline/agent/createAgentEventJob.js.map +1 -0
  78. package/dist/pipeline/src/pipeline/agent/createAgentReviewJob.d.ts +2 -0
  79. package/dist/pipeline/src/pipeline/agent/createAgentReviewJob.js +51 -0
  80. package/dist/pipeline/src/pipeline/agent/createAgentReviewJob.js.map +1 -0
  81. package/dist/pipeline/src/pipeline/agent/createJobsForAgentContext.d.ts +2 -0
  82. package/dist/pipeline/src/pipeline/agent/createJobsForAgentContext.js +10 -0
  83. package/dist/pipeline/src/pipeline/agent/createJobsForAgentContext.js.map +1 -0
  84. package/dist/pipeline/src/pipeline/agent/prompts.d.ts +6 -0
  85. package/dist/pipeline/src/pipeline/agent/prompts.js +268 -0
  86. package/dist/pipeline/src/pipeline/agent/prompts.js.map +1 -0
  87. package/dist/pipeline/src/pipeline/agent/shared.d.ts +6 -0
  88. package/dist/pipeline/src/pipeline/agent/shared.js +32 -0
  89. package/dist/pipeline/src/pipeline/agent/shared.js.map +1 -0
  90. package/dist/pipeline/src/pipeline/agent/utils.d.ts +3 -0
  91. package/dist/pipeline/src/pipeline/agent/utils.js +14 -0
  92. package/dist/pipeline/src/pipeline/agent/utils.js.map +1 -0
  93. package/dist/pipeline/src/pipeline/createAllJobs.d.ts +5 -1
  94. package/dist/pipeline/src/pipeline/createAllJobs.js +10 -1
  95. package/dist/pipeline/src/pipeline/createAllJobs.js.map +1 -1
  96. package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
  97. package/dist/pipeline/src/pipeline/createMainPipeline.js +15 -5
  98. package/dist/pipeline/src/pipeline/createMainPipeline.js.map +1 -1
  99. package/dist/pipeline/src/pipeline/generatePipelineFiles.d.ts +2 -1
  100. package/dist/pipeline/src/pipeline/generatePipelineFiles.js +3 -4
  101. package/dist/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
  102. package/dist/pipeline/src/pipeline/gitlab/cache.d.ts +9 -0
  103. package/dist/pipeline/src/pipeline/gitlab/cache.js +36 -0
  104. package/dist/pipeline/src/pipeline/gitlab/cache.js.map +1 -0
  105. package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.d.ts +3 -3
  106. package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.js +23 -15
  107. package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.js.map +1 -1
  108. package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js +41 -0
  109. package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js.map +1 -1
  110. package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.d.ts +2 -1
  111. package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.js +29 -3
  112. package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.js.map +1 -1
  113. package/dist/pipeline/src/rules/index.d.ts +1 -2
  114. package/dist/pipeline/src/rules/index.js +6 -29
  115. package/dist/pipeline/src/rules/index.js.map +1 -1
  116. package/dist/pipeline/src/runner/index.d.ts +1 -1
  117. package/dist/pipeline/src/runner/index.js.map +1 -1
  118. package/dist/pipeline/src/types/agent.d.ts +16 -0
  119. package/dist/pipeline/src/types/agent.js +3 -0
  120. package/dist/pipeline/src/types/agent.js.map +1 -0
  121. package/dist/pipeline/src/types/config.d.ts +12 -0
  122. package/dist/pipeline/src/types/config.js.map +1 -1
  123. package/dist/pipeline/src/types/context.d.ts +1 -0
  124. package/dist/pipeline/src/types/context.js.map +1 -1
  125. package/dist/pipeline/src/types/gitlab-types.d.ts +2 -0
  126. package/dist/pipeline/src/types/hooks.d.ts +35 -0
  127. package/dist/pipeline/src/types/hooks.js +3 -0
  128. package/dist/pipeline/src/types/hooks.js.map +1 -0
  129. package/dist/pipeline/src/types/index.d.ts +1 -0
  130. package/dist/pipeline/src/types/index.js +1 -0
  131. package/dist/pipeline/src/types/index.js.map +1 -1
  132. package/dist/pipeline/src/types/jobs.d.ts +7 -4
  133. package/dist/pipeline/src/types/jobs.js +1 -0
  134. package/dist/pipeline/src/types/jobs.js.map +1 -1
  135. package/dist/pipeline/src/types/release.d.ts +7 -0
  136. package/dist/pipeline/src/types/release.js +3 -0
  137. package/dist/pipeline/src/types/release.js.map +1 -0
  138. package/dist/pipeline/src/utils/writeFiles.d.ts +14 -4
  139. package/dist/pipeline/src/utils/writeFiles.js +54 -27
  140. package/dist/pipeline/src/utils/writeFiles.js.map +1 -1
  141. package/dist/tsconfig.tsbuildinfo +1 -1
  142. package/package.json +4 -2
  143. package/src/apps/catenv/catenv.ts +11 -5
  144. package/src/apps/catenv/printVariables.ts +6 -3
  145. package/src/apps/catenv/writeDotEnvFiles.ts +21 -8
  146. package/src/apps/catenv/writeEnvDTs.ts +15 -6
  147. package/src/apps/cli/commands/project/setup/index.ts +9 -2
  148. package/src/apps/cli/commands/project/setup/logSection.ts +22 -0
  149. package/src/apps/cli/commands/project/setup/setupAgents.ts +323 -0
  150. package/src/apps/cli/commands/project/setup/setupContext.ts +14 -19
  151. package/src/config/getProjectConfig.ts +8 -3
  152. package/src/git/getGetMainBranch.ts +5 -0
  153. package/src/git/index.ts +1 -0
@@ -18,11 +18,12 @@ exports["default"] = async (choice) => {
18
18
  if (!config) {
19
19
  return;
20
20
  }
21
+ const context = (0, pipeline_1.createCatenvContext)(config);
21
22
  await Promise.all([
22
- (0, pipeline_1.generatePipelineFiles)(config, (_a = config.pipelineType) !== null && _a !== void 0 ? _a : "gitlab"),
23
- (0, writeDotEnvFiles_1.writeDotEnvFiles)(config, choice),
24
- (0, writeEnvDTs_1.writeDTsFiles)(config, choice),
25
- (0, printVariables_1.printVariables)(config, choice),
23
+ (0, pipeline_1.generatePipelineFiles)(context, (_a = config.pipelineType) !== null && _a !== void 0 ? _a : "gitlab"),
24
+ (0, writeDotEnvFiles_1.writeDotEnvFiles)(context, choice),
25
+ (0, writeEnvDTs_1.writeDTsFiles)(context, choice),
26
+ (0, printVariables_1.printVariables)(context, choice),
26
27
  ]);
27
28
  };
28
29
  //# sourceMappingURL=catenv.js.map
@@ -72,8 +73,8 @@ const getAllVariablesToPrint = async (config, choice) => {
72
73
  }, Promise.resolve({}));
73
74
  }
74
75
  };
75
- const printVariables = async (config, choice) => {
76
- const variables = await getAllVariablesToPrint(config, choice);
76
+ const printVariables = async (context, choice) => {
77
+ const variables = await getAllVariablesToPrint(context.config, choice);
77
78
  console.log(makeExportKeyValuestring(variables));
78
79
  };
79
80
  exports.printVariables = printVariables;
@@ -134,14 +135,13 @@ exports.sanitizeEnvVarName = sanitizeEnvVarName;
134
135
 
135
136
  Object.defineProperty(exports, "__esModule", ({ value: true }));
136
137
  exports.writeDotEnvFiles = void 0;
137
- const pipeline_1 = __nccwpck_require__(603);
138
138
  const path_1 = __nccwpck_require__(1017);
139
139
  const getProjectConfig_1 = __nccwpck_require__(5264);
140
140
  const projects_1 = __nccwpck_require__(9011);
141
141
  const utils_1 = __nccwpck_require__(4560);
142
- const writeDotEnvFiles = async (config, choice) => {
143
- const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice);
144
- const componentsWithEnabledDotEnvWrite = Object.entries(config.components)
142
+ const writeDotEnvFiles = async (context, choice) => {
143
+ const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(context.config, choice);
144
+ const componentsWithEnabledDotEnvWrite = Object.entries(context.config.components)
145
145
  .filter(([, component]) => { var _a; return (_a = component === null || component === void 0 ? void 0 : component.dotEnv) !== null && _a !== void 0 ? _a : true; }) // when set to true or "local"
146
146
  .map(([componentName]) => componentName);
147
147
  const componentsToActuallyWriteDotEnvNow = currentComponent
@@ -153,9 +153,9 @@ const writeDotEnvFiles = async (config, choice) => {
153
153
  for (const componentName of componentsToActuallyWriteDotEnvNow) {
154
154
  const variables = await (0, getProjectConfig_1.getEnvVarsResolved)(null, env, componentName);
155
155
  delete variables["_ALL_ENV_VAR_KEYS"];
156
- const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, config, componentName);
156
+ const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, context.config, componentName);
157
157
  const filePath = (0, path_1.join)(componentDir, ".env");
158
- await (0, pipeline_1.writeGeneratedFile)(filePath, (0, utils_1.makeKeyValueString)(variables), {
158
+ await context.fileWriter.writeGeneratedFile(filePath, (0, utils_1.makeKeyValueString)(variables), {
159
159
  commentChar: "#",
160
160
  });
161
161
  }
@@ -172,14 +172,13 @@ exports.writeDotEnvFiles = writeDotEnvFiles;
172
172
 
173
173
  Object.defineProperty(exports, "__esModule", ({ value: true }));
174
174
  exports.writeDTsFiles = void 0;
175
- const pipeline_1 = __nccwpck_require__(603);
176
175
  const path_1 = __nccwpck_require__(1017);
177
176
  const getProjectConfig_1 = __nccwpck_require__(5264);
178
177
  const projects_1 = __nccwpck_require__(9011);
179
178
  const utils_1 = __nccwpck_require__(4560);
180
- const writeDTsFiles = async (config, choice) => {
181
- const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice);
182
- const componentsWithEnabledEnvDTsWrite = Object.entries(config.components)
179
+ const writeDTsFiles = async (context, choice) => {
180
+ const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(context.config, choice);
181
+ const componentsWithEnabledEnvDTsWrite = Object.entries(context.config.components)
183
182
  .filter(([, component]) => { var _a; return (_a = component === null || component === void 0 ? void 0 : component.envDTs) !== null && _a !== void 0 ? _a : true; })
184
183
  .map(([componentName]) => componentName);
185
184
  const componentsToActuallyWriteEnvDts = currentComponent
@@ -191,9 +190,9 @@ const writeDTsFiles = async (config, choice) => {
191
190
  for (const componentName of componentsToActuallyWriteEnvDts) {
192
191
  const envNames = await getEnvsForDTs(env, componentName);
193
192
  const envDTsContent = createEnvDTsContent(envNames);
194
- const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, config, componentName);
193
+ const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, context.config, componentName);
195
194
  const filePath = (0, path_1.join)(componentDir, "env.d.ts");
196
- await (0, pipeline_1.writeGeneratedFile)(filePath, envDTsContent, {
195
+ await context.fileWriter.writeGeneratedFile(filePath, envDTsContent, {
197
196
  commentChar: "//",
198
197
  });
199
198
  }
@@ -316,7 +315,7 @@ const getAllComponentsWithAllEnvsFlat = async () => {
316
315
  if (!config) {
317
316
  return [];
318
317
  }
319
- return Object.keys(config.components).flatMap((componentName) => (0, pipeline_1.getAllEnvs)(config, componentName).map((env) => ({ env, componentName })));
318
+ return getAllComponentsWithAllEnvsFlatFromConfig(config);
320
319
  };
321
320
  exports.getAllComponentsWithAllEnvsFlat = getAllComponentsWithAllEnvsFlat;
322
321
  const getAllComponentsWithAllEnvsHierarchical = async () => {
@@ -393,6 +392,9 @@ const getJobOnlyEnvVarsResolved = async (vorpal, env, componentName) => {
393
392
  ]);
394
393
  };
395
394
  exports.getJobOnlyEnvVarsResolved = getJobOnlyEnvVarsResolved;
395
+ function getAllComponentsWithAllEnvsFlatFromConfig(config) {
396
+ return Object.keys(config.components).flatMap((componentName) => (0, pipeline_1.getAllEnvs)(config, componentName).map((env) => ({ env, componentName })));
397
+ }
396
398
  //# sourceMappingURL=getProjectConfig.js.map
397
399
 
398
400
  /***/ }),
@@ -914,7 +916,7 @@ exports.joinBashExpressions = joinBashExpressions;
914
916
  "use strict";
915
917
 
916
918
  Object.defineProperty(exports, "__esModule", ({ value: true }));
917
- exports.escapeForDotEnv = exports.escapeSingleQuotes = exports.escapeDoubleQuotes = exports.escapeBashExpression = exports.escapeString = exports.bashEscape = void 0;
919
+ exports.escapeForDotEnv = exports.escapeNewlines = exports.escapeBackTicks = exports.escapeSingleQuotes = exports.escapeDoubleQuotes = exports.escapeBashExpression = exports.escapeString = exports.bashEscape = void 0;
918
920
  const globalScriptFunctions_1 = __nccwpck_require__(2912);
919
921
  const VariableValueContainingReferences_1 = __nccwpck_require__(1592);
920
922
  const BashExpression_1 = __nccwpck_require__(2376);
@@ -955,6 +957,10 @@ const escapeDoubleQuotes = (value) => value === null || value === void 0 ? void
955
957
  exports.escapeDoubleQuotes = escapeDoubleQuotes;
956
958
  const escapeSingleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/'/g, "\\'");
957
959
  exports.escapeSingleQuotes = escapeSingleQuotes;
960
+ const escapeBackTicks = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/`/g, "\\`");
961
+ exports.escapeBackTicks = escapeBackTicks;
962
+ const escapeNewlines = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/\n/g, "\\n");
963
+ exports.escapeNewlines = escapeNewlines;
958
964
  /**
959
965
  *
960
966
  * escape env vars for .env files.
@@ -1211,10 +1217,9 @@ const createBuildJobArtifacts = (context) => {
1211
1217
  const paths = context.type === "workspace"
1212
1218
  ? context.components.flatMap((c) => getArtifactsPathForComponent(c))
1213
1219
  : getArtifactsPathForComponent(context, ["__build_info.json"]);
1214
- // esxclude .env files if generated
1215
1220
  const exclude = context.type === "workspace"
1216
- ? context.components.flatMap((c) => getDotEnvPathsForComponent(c))
1217
- : getDotEnvPathsForComponent(context);
1221
+ ? context.components.flatMap((c) => getAllArtifactExcludePathsForComponent(c))
1222
+ : getAllArtifactExcludePathsForComponent(context);
1218
1223
  return {
1219
1224
  paths: (0, lodash_1.uniq)(paths).sort((a, b) => a.localeCompare(b)),
1220
1225
  ...(exclude.length > 0 ? { exclude } : {}),
@@ -1230,12 +1235,10 @@ const createBuildJobArtifacts = (context) => {
1230
1235
  };
1231
1236
  };
1232
1237
  exports.createBuildJobArtifacts = createBuildJobArtifacts;
1233
- const getArtifactsPathForComponent = (c, additionalPaths) => {
1238
+ const _getArtifactPathsForComponent = (c, configKey, additionalPaths) => {
1234
1239
  var _a, _b;
1235
1240
  return (_b = [
1236
- ...(c.build.type !== "disabled"
1237
- ? ((_a = c.build.config.artifactsPaths) !== null && _a !== void 0 ? _a : [])
1238
- : []),
1241
+ ...(c.build.type !== "disabled" ? ((_a = c.build.config[configKey]) !== null && _a !== void 0 ? _a : []) : []),
1239
1242
  ...(additionalPaths !== null && additionalPaths !== void 0 ? additionalPaths : []),
1240
1243
  ]) === null || _b === void 0 ? void 0 : _b.flatMap((artifact) => c.build
1241
1244
  // in theory, we only need "direct",
@@ -1244,6 +1247,18 @@ const getArtifactsPathForComponent = (c, additionalPaths) => {
1244
1247
  .getComponentDirs("all")
1245
1248
  .flatMap((cDir) => (0, path_1.join)(cDir, artifact)));
1246
1249
  };
1250
+ const getArtifactsPathForComponent = (c, additionalPaths) => {
1251
+ return _getArtifactPathsForComponent(c, "artifactsPaths", additionalPaths);
1252
+ };
1253
+ const getAllArtifactExcludePathsForComponent = (c) => {
1254
+ return [
1255
+ ...getDotEnvPathsForComponent(c), // always exclude .env files
1256
+ ...getArtifactExcludePathsForComponent(c),
1257
+ ];
1258
+ };
1259
+ const getArtifactExcludePathsForComponent = (c, additionalPaths) => {
1260
+ return _getArtifactPathsForComponent(c, "artifactsExcludePaths", additionalPaths);
1261
+ };
1247
1262
  const getDotEnvPathsForComponent = (c) => {
1248
1263
  if ((0, writeDotEnv_1.componentContextNeedsBuildTimeDotEnv)(c)) {
1249
1264
  return [(0, path_1.join)(c.build.dir, ".env")];
@@ -1735,7 +1750,6 @@ const createCustomTestJobs = (context) => {
1735
1750
  cache: (0, createJobCache_1.createJobCacheFromConfig)(context, buildConfig),
1736
1751
  stage: "test",
1737
1752
  needs: [],
1738
- envMode: "none",
1739
1753
  };
1740
1754
  const auditJob = buildConfig.audit
1741
1755
  ? {
@@ -1975,6 +1989,7 @@ exports.BUILD_TYPES = {
1975
1989
  buildCommand: "yarn build",
1976
1990
  startCommand: "yarn start",
1977
1991
  artifactsPaths: ["dist", ".next"],
1992
+ artifactsExcludePaths: [".next/cache/**/*"],
1978
1993
  }),
1979
1994
  },
1980
1995
  "node-static": {
@@ -2299,7 +2314,6 @@ const createNodeTestJobs = (context) => {
2299
2314
  runnerVariables: constants_1.NODE_RUNNER_BUILD_VARIABLES,
2300
2315
  stage: "test",
2301
2316
  needs: [],
2302
- envMode: "none",
2303
2317
  };
2304
2318
  const buildConfig = context.build.config;
2305
2319
  const yarnInstall = (0, yarn_1.getYarnInstall)(context);
@@ -2512,7 +2526,7 @@ exports.createRailsTestJobs = void 0;
2512
2526
  const __1 = __nccwpck_require__(603);
2513
2527
  const utils_1 = __nccwpck_require__(2497);
2514
2528
  const createRailsTestJobs = (context) => {
2515
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
2529
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
2516
2530
  // don't run tests after release
2517
2531
  // TODO: this will be replaced by using rules
2518
2532
  if (context.trigger === "taggedRelease") {
@@ -2529,7 +2543,6 @@ const createRailsTestJobs = (context) => {
2529
2543
  },
2530
2544
  stage: "test",
2531
2545
  needs: [],
2532
- envMode: "none",
2533
2546
  };
2534
2547
  const defaultImage = "docker.io/ruby";
2535
2548
  const bundlerCacheDir = "tmp/cache";
@@ -2585,9 +2598,26 @@ const createRailsTestJobs = (context) => {
2585
2598
  `cd ${context.build.dir}`,
2586
2599
  ...bundlerInstall,
2587
2600
  ...((_q = (0, utils_1.ensureArrayOrNull)((_p = buildConfig.test) === null || _p === void 0 ? void 0 : _p.command)) !== null && _q !== void 0 ? _q : [
2601
+ "bundle exec rake db:test:prepare",
2602
+ "bundle exec rake assets:precompile assets:clean",
2588
2603
  "bundle exec rspec",
2589
2604
  ]),
2590
2605
  ],
2606
+ runnerVariables: {
2607
+ RAILS_ENV: "test",
2608
+ DATABASE_URL: "postgresql://postgres@database",
2609
+ },
2610
+ services: [
2611
+ {
2612
+ name: buildConfig.test && "databaseImage" in buildConfig.test
2613
+ ? ((_s = (_r = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.test) === null || _r === void 0 ? void 0 : _r.databaseImage) !== null && _s !== void 0 ? _s : "docker.io/postgres:latest")
2614
+ : "docker.io/postgres:latest",
2615
+ alias: "database",
2616
+ variables: {
2617
+ POSTGRES_HOST_AUTH_METHOD: "trust",
2618
+ },
2619
+ },
2620
+ ],
2591
2621
  }
2592
2622
  : null;
2593
2623
  return [auditJob, lintJob, testJob].filter(utils_1.notNil);
@@ -2672,6 +2702,25 @@ exports.isOfBuildType = isOfBuildType;
2672
2702
 
2673
2703
  /***/ }),
2674
2704
 
2705
+ /***/ 2155:
2706
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2707
+
2708
+ "use strict";
2709
+
2710
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2711
+ exports.createCatenvContext = void 0;
2712
+ const writeFiles_1 = __nccwpck_require__(2228);
2713
+ const createCatenvContext = (config) => {
2714
+ return {
2715
+ config,
2716
+ fileWriter: writeFiles_1.FileWriter.create(config),
2717
+ };
2718
+ };
2719
+ exports.createCatenvContext = createCatenvContext;
2720
+ //# sourceMappingURL=index.js.map
2721
+
2722
+ /***/ }),
2723
+
2675
2724
  /***/ 9609:
2676
2725
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2677
2726
 
@@ -3806,6 +3855,7 @@ exports.getDeleteUnusedImagesCommands = getDeleteUnusedImagesCommands;
3806
3855
 
3807
3856
  Object.defineProperty(exports, "__esModule", ({ value: true }));
3808
3857
  exports.getRemoveOldRevisionsAndImagesCommand = void 0;
3858
+ const gitlab_1 = __nccwpck_require__(8490);
3809
3859
  const artifactsRegistry_1 = __nccwpck_require__(4963);
3810
3860
  const cloudRunRevisions_1 = __nccwpck_require__(9067);
3811
3861
  const getRemoveOldRevisionsAndImagesCommand = (context, when) => {
@@ -3819,7 +3869,10 @@ const getRemoveOldRevisionsAndImagesCommand = (context, when) => {
3819
3869
  const imagesToKeep = revisionsToKeep + 1;
3820
3870
  const deleteOldRevisionsCommands = (0, cloudRunRevisions_1.getDeleteUnusedRevisionsCommands)(context, revisionsToKeep);
3821
3871
  const deleteOldImagesCommands = (0, artifactsRegistry_1.getDeleteUnusedImagesCommands)(context, imagesToKeep);
3822
- return [...deleteOldRevisionsCommands, ...deleteOldImagesCommands];
3872
+ return (0, gitlab_1.allowFailureInScripts)([
3873
+ ...deleteOldRevisionsCommands,
3874
+ ...deleteOldImagesCommands,
3875
+ ]);
3823
3876
  };
3824
3877
  exports.getRemoveOldRevisionsAndImagesCommand = getRemoveOldRevisionsAndImagesCommand;
3825
3878
  //# sourceMappingURL=cleanup.js.map
@@ -3941,7 +3994,7 @@ const getJobCreateScripts = (context) => (0, exports.getCloudRunJobsWithNames)(c
3941
3994
  ? `exist_job_names="$(\n ${(0, common_1.gcloudRunCmd)()} jobs list --filter='metadata.name ~ ${context.env}.*${context.name}' --format='value(name)' --limit=999 --project='${project}' --region='${region}'\n)"`
3942
3995
  : null,
3943
3996
  `current_job_name="${fullJobName}"`,
3944
- 'if grep "$current_job_name" <<<"$exist_job_names" >/dev/null; then',
3997
+ 'if echo "$exist_job_names" | grep -Fx "$current_job_name" >/dev/null; then',
3945
3998
  ` ${(0, common_1.gcloudRunCmd)()} jobs update "$current_job_name" ${commonDeployArgsString}`,
3946
3999
  "else",
3947
4000
  ` ${(0, common_1.gcloudRunCmd)()} jobs create "$current_job_name" ${commonDeployArgsString}`,
@@ -4274,7 +4327,7 @@ const getCreateScheduleScript = (context) => {
4274
4327
  : null,
4275
4328
  `current_job_uri="${uri}"`,
4276
4329
  `current_scheduler_name="${fullName}"`,
4277
- `if grep "$current_scheduler_name" <<<"$exist_scheduler_names" >/dev/null; then`,
4330
+ `if echo "$exist_scheduler_names" | grep -Fx "$current_scheduler_name" >/dev/null; then`,
4278
4331
  ` ${(0, common_1.gcloudSchedulerCmd)()} jobs update http "$current_scheduler_name" ${argsString}`,
4279
4332
  `else`,
4280
4333
  ` ${(0, common_1.gcloudSchedulerCmd)()} jobs create http "$current_scheduler_name" ${argsString}`,
@@ -4410,7 +4463,9 @@ function getCloudRunDeployScripts(context) {
4410
4463
  ...(deployConfig.service !== false
4411
4464
  ? [(0, cloudRunServices_1.getServiceDeployScript)(context, deployConfig.service)]
4412
4465
  : []),
4413
- ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).map(([name, service]) => (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name)),
4466
+ ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {})
4467
+ .filter(([_, service]) => service !== false && service !== null)
4468
+ .map(([name, service]) => (0, cloudRunServices_1.getServiceDeployScript)(context, service, "-" + name)),
4414
4469
  ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postDeploy"),
4415
4470
  ]),
4416
4471
  ...(0, gitlab_1.collapseableSection)("cleanup", "Cleanup")((0, cleanup_1.getRemoveOldRevisionsAndImagesCommand)(context, "postDeploy")),
@@ -4445,7 +4500,9 @@ function getCloudRunStopScripts(context) {
4445
4500
  ...(0, gcloudServiceAccountLoginCommands_1.gcloudServiceAccountLoginCommands)(context),
4446
4501
  ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "preStop"),
4447
4502
  ...(deployConfig.service !== false ? (0, cloudRunServices_1.getServiceDeleteScript)(context) : []),
4448
- ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {}).flatMap(([name]) => (0, cloudRunServices_1.getServiceDeleteScript)(context, name)),
4503
+ ...Object.entries((_a = deployConfig.additionalServices) !== null && _a !== void 0 ? _a : {})
4504
+ .filter(([_, service]) => service !== false && service !== null)
4505
+ .flatMap(([name]) => (0, cloudRunServices_1.getServiceDeleteScript)(context, name)),
4449
4506
  ...(0, onDeploy_1.getOnDeployExecuteScript)(context, "postStop"),
4450
4507
  ...(0, schedules_1.getDeleteSchedulesScript)(context),
4451
4508
  ...(0, cloudRunJobs_1.getDeleteJobsScripts)(context),
@@ -4616,19 +4673,22 @@ exports.GCLOUD_DEPLOY_CREDENTIALS_KEY = "GCLOUD_DEPLOY_credentialsKey";
4616
4673
  // FIXME: rename to internalHostSuffix, but this means that project-setup needs to be rerun, so its kindof a breaking change
4617
4674
  exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX = "GCLOUD_RUN_canonicalHostSuffix";
4618
4675
  const getCloudSqlVariables = ({ deployConfigRaw, environmentSlugPrefix, env, componentName, fullConfig, }) => {
4619
- var _a, _b;
4676
+ var _a, _b, _c;
4620
4677
  if (deployConfigRaw && deployConfigRaw.cloudSql) {
4621
4678
  const DB_NAME = (0, utils_1.getFullDbName)(deployConfigRaw.cloudSql, fullConfig, environmentSlugPrefix, componentName);
4622
4679
  const additionalQueryParamsString = Object.entries((_a = deployConfigRaw.cloudSql.dbAdditionalQueryParams) !== null && _a !== void 0 ? _a : {})
4623
4680
  .map(([key, value]) => `&${key}=${value}`)
4624
4681
  .join("");
4625
- return {
4682
+ const dbVars = {
4626
4683
  CLOUD_SQL_INSTANCE_CONNECTION_NAME: deployConfigRaw.cloudSql.instanceConnectionName,
4627
4684
  DB_NAME: DB_NAME,
4628
4685
  DB_USER: (_b = deployConfigRaw.cloudSql.dbUser) !== null && _b !== void 0 ? _b : "postgres",
4629
4686
  DB_PASSWORD: "$" + (0, context_1.getSecretVarName)(env, componentName, "DB_PASSWORD"),
4630
- DATABASE_URL: `${(0, database_1.getDatabaseConnectionString)(deployConfigRaw.cloudSql)}${additionalQueryParamsString}`,
4631
- DATABASE_JDBC_URL: database_1.DATABASE_JDBC_URL,
4687
+ };
4688
+ return {
4689
+ ...dbVars,
4690
+ DATABASE_URL: (0, database_1.getDatabaseConnectionString)(deployConfigRaw.cloudSql, dbVars).concat(additionalQueryParamsString),
4691
+ DATABASE_JDBC_URL: (0, database_1.getDatabaseJdbcUrl)(dbVars, (_c = deployConfigRaw.cloudSql.dbConnectionStringVariablesMode) !== null && _c !== void 0 ? _c : database_1.DEFAULT_DB_VARIABLES_MODE),
4632
4692
  };
4633
4693
  }
4634
4694
  return {};
@@ -4665,7 +4725,9 @@ exports.GCLOUD_RUN_DEPLOY_TYPE = {
4665
4725
  (0, BashExpression_1.getBashVariable)((0, context_1.getSecretVarName)(env, componentName, exports.GCLOUD_RUN_CANONICAL_HOST_SUFFIX)),
4666
4726
  ], "-").toLowerCase();
4667
4727
  const jobTriggers = deployConfigRaw && deployConfigRaw.jobs
4668
- ? Object.fromEntries(Object.entries(deployConfigRaw.jobs).map(([name, job]) => [
4728
+ ? Object.fromEntries(Object.entries(deployConfigRaw.jobs)
4729
+ .filter(([name, job]) => Boolean(job))
4730
+ .map(([name, job]) => [
4669
4731
  "CLOUD_RUN_JOB_TRIGGER_URL_" + (0, gitlab_1.sanitizeForBashVariable)(name),
4670
4732
  (0, cloudRunExecutionUrl_1.getCloudRunJobExecuteUrl)(name, {
4671
4733
  appFullName: fullName,
@@ -4752,7 +4814,8 @@ exports.createArgsString = createArgsString;
4752
4814
  "use strict";
4753
4815
 
4754
4816
  Object.defineProperty(exports, "__esModule", ({ value: true }));
4755
- exports.getDatabaseConnectionString = exports.DATABASE_JDBC_URL = exports.getDatabaseCreateScript = exports.getDatabaseDeleteScript = void 0;
4817
+ exports.getDatabaseConnectionString = exports.getPrismaDatabaseConnectionString = exports.getRailsDatabaseConnectionString = exports.getDatabaseJdbcUrl = exports.DEFAULT_DB_VARIABLES_MODE = exports.getDatabaseCreateScript = exports.getDatabaseDeleteScript = void 0;
4818
+ const bash_1 = __nccwpck_require__(2990);
4756
4819
  const gitlab_1 = __nccwpck_require__(8490);
4757
4820
  const getDatabaseDeleteScript = (context, deployConfig) => {
4758
4821
  if (!deployConfig.cloudSql || !deployConfig.cloudSql.deleteDatabaseOnStop) {
@@ -4790,16 +4853,64 @@ const getDatabaseCreateScript = (context, deployConfig) => {
4790
4853
  ]);
4791
4854
  };
4792
4855
  exports.getDatabaseCreateScript = getDatabaseCreateScript;
4793
- exports.DATABASE_JDBC_URL = "jdbc:postgresql:///$DB_NAME?cloudSqlInstance=$CLOUD_SQL_INSTANCE_CONNECTION_NAME&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=$DB_USER&password=$DB_PASSWORD";
4794
- const getDatabaseConnectionString = (config) => {
4856
+ exports.DEFAULT_DB_VARIABLES_MODE = "legacy";
4857
+ const getVariableOrValue = (key, variables, mode) => {
4858
+ return mode === "legacy" ? `$${key}` : variables[key];
4859
+ };
4860
+ const getDatabaseJdbcUrl = (variables, mode) => {
4861
+ const parts = [
4862
+ "jdbc:postgresql:///",
4863
+ getVariableOrValue("DB_NAME", variables, mode),
4864
+ "?cloudSqlInstance=",
4865
+ getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", variables, mode),
4866
+ "&socketFactory=com.google.cloud.sql.postgres.SocketFactory&user=",
4867
+ getVariableOrValue("DB_USER", variables, mode),
4868
+ "&password=",
4869
+ getVariableOrValue("DB_PASSWORD", variables, mode),
4870
+ ];
4871
+ return (0, bash_1.joinBashExpressions)(parts);
4872
+ };
4873
+ exports.getDatabaseJdbcUrl = getDatabaseJdbcUrl;
4874
+ const getRailsDatabaseConnectionString = (variables, mode) => {
4875
+ const parts = [
4876
+ "postgresql://",
4877
+ getVariableOrValue("DB_USER", variables, mode),
4878
+ ":",
4879
+ getVariableOrValue("DB_PASSWORD", variables, mode),
4880
+ "@",
4881
+ encodeURIComponent(`/cloudsql/${variables.CLOUD_SQL_INSTANCE_CONNECTION_NAME}`),
4882
+ "/",
4883
+ getVariableOrValue("DB_NAME", variables, mode),
4884
+ "?",
4885
+ ];
4886
+ return (0, bash_1.joinBashExpressions)(parts);
4887
+ };
4888
+ exports.getRailsDatabaseConnectionString = getRailsDatabaseConnectionString;
4889
+ const getPrismaDatabaseConnectionString = (variables, mode) => {
4890
+ const parts = [
4891
+ "postgresql://",
4892
+ getVariableOrValue("DB_USER", variables, mode),
4893
+ ":",
4894
+ getVariableOrValue("DB_PASSWORD", variables, mode),
4895
+ "@localhost/",
4896
+ getVariableOrValue("DB_NAME", variables, mode),
4897
+ "?host=/cloudsql/",
4898
+ getVariableOrValue("CLOUD_SQL_INSTANCE_CONNECTION_NAME", variables, mode),
4899
+ ];
4900
+ return (0, bash_1.joinBashExpressions)(parts);
4901
+ };
4902
+ exports.getPrismaDatabaseConnectionString = getPrismaDatabaseConnectionString;
4903
+ const getDatabaseConnectionString = (config, variables) => {
4904
+ var _a;
4905
+ const mode = (_a = config.dbConnectionStringVariablesMode) !== null && _a !== void 0 ? _a : exports.DEFAULT_DB_VARIABLES_MODE;
4795
4906
  switch (config.dbConnectionStringFormat) {
4796
4907
  case "jdbc":
4797
- return exports.DATABASE_JDBC_URL;
4908
+ return (0, exports.getDatabaseJdbcUrl)(variables, mode);
4798
4909
  case "rails":
4799
- return `postgresql://$DB_USER:$DB_PASSWORD@${encodeURIComponent(`/cloudsql/${config.instanceConnectionName}`)}/$DB_NAME?`;
4910
+ return (0, exports.getRailsDatabaseConnectionString)(variables, mode);
4800
4911
  default:
4801
4912
  // prisma
4802
- return "postgresql://$DB_USER:$DB_PASSWORD@localhost/$DB_NAME?host=/cloudsql/$CLOUD_SQL_INSTANCE_CONNECTION_NAME";
4913
+ return (0, exports.getPrismaDatabaseConnectionString)(variables, mode);
4803
4914
  }
4804
4915
  };
4805
4916
  exports.getDatabaseConnectionString = getDatabaseConnectionString;
@@ -5796,10 +5907,517 @@ __exportStar(__nccwpck_require__(8483), exports);
5796
5907
  __exportStar(__nccwpck_require__(2228), exports);
5797
5908
  __exportStar(__nccwpck_require__(1619), exports);
5798
5909
  __exportStar(__nccwpck_require__(2990), exports);
5910
+ __exportStar(__nccwpck_require__(2155), exports);
5799
5911
  //# sourceMappingURL=index.js.map
5800
5912
 
5801
5913
  /***/ }),
5802
5914
 
5915
+ /***/ 2636:
5916
+ /***/ ((__unused_webpack_module, exports) => {
5917
+
5918
+ "use strict";
5919
+
5920
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5921
+ exports.createAgentContext = exports.AgentContext = void 0;
5922
+ class AgentContext {
5923
+ constructor(agentName, config) {
5924
+ this.agentName = agentName;
5925
+ this.config = config;
5926
+ this.type = "agent";
5927
+ }
5928
+ get name() {
5929
+ return this.agentName;
5930
+ }
5931
+ get agentConfig() {
5932
+ var _a;
5933
+ const agentConfig = (_a = this.config.agents) === null || _a === void 0 ? void 0 : _a[this.agentName];
5934
+ if (!agentConfig) {
5935
+ throw new Error(`Agent ${this.agentName} not found in config`);
5936
+ }
5937
+ return agentConfig;
5938
+ }
5939
+ get agentUser() {
5940
+ var _a, _b, _c, _d;
5941
+ return {
5942
+ username: (_b = (_a = this.agentConfig.agentUser) === null || _a === void 0 ? void 0 : _a.username) !== null && _b !== void 0 ? _b : "agent.claude",
5943
+ userId: (_d = (_c = this.agentConfig.agentUser) === null || _c === void 0 ? void 0 : _c.userId) !== null && _d !== void 0 ? _d : "$DEFAULT_AGENT_USER_ID",
5944
+ };
5945
+ }
5946
+ get reviews() {
5947
+ var _a, _b;
5948
+ return {
5949
+ byUser: (_b = (_a = this.agentConfig.reviews) === null || _a === void 0 ? void 0 : _a.byUser) !== null && _b !== void 0 ? _b : {
5950
+ [this.agentUser.username]: { automatic: true },
5951
+ },
5952
+ };
5953
+ }
5954
+ get fullConfig() {
5955
+ return this.config;
5956
+ }
5957
+ }
5958
+ exports.AgentContext = AgentContext;
5959
+ const createAgentContext = async (ctx) => {
5960
+ return new AgentContext(ctx.agentName, ctx.config);
5961
+ };
5962
+ exports.createAgentContext = createAgentContext;
5963
+ //# sourceMappingURL=createAgentContext.js.map
5964
+
5965
+ /***/ }),
5966
+
5967
+ /***/ 9404:
5968
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5969
+
5970
+ "use strict";
5971
+
5972
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5973
+ exports.createAgentEventJob = void 0;
5974
+ const prompts_1 = __nccwpck_require__(8698);
5975
+ const shared_1 = __nccwpck_require__(732);
5976
+ const utils_1 = __nccwpck_require__(9133);
5977
+ const createAgentEventJob = (context) => {
5978
+ const baseJob = (0, shared_1.createBaseAgentJob)(context);
5979
+ // unfortunatly, we need to manage both, because the "@mention"-feature only works with the username
5980
+ const agentUserId = (0, utils_1.getAgentUserId)(context);
5981
+ const agentUserName = (0, utils_1.getAgentUserName)(context);
5982
+ return {
5983
+ interruptible: false, // do not cancel this job if it is running. Otherwise a commit to main will cancel it
5984
+ ...baseJob,
5985
+ variables: {
5986
+ ...baseJob.variables,
5987
+ },
5988
+ name: context.name + "-agent-event",
5989
+ rules: [
5990
+ {
5991
+ if: `$CI_PIPELINE_SOURCE == "trigger" && ($ASSIGNEE_USER_ID == ${agentUserId} || $OBJECT_DESCRIPTION =~ /@${agentUserName}/)`,
5992
+ when: "always",
5993
+ },
5994
+ {
5995
+ when: "never",
5996
+ },
5997
+ ],
5998
+ script: [
5999
+ ...shared_1.baseSetupScript,
6000
+ ...(0, shared_1.callClaude)({
6001
+ prompt: (0, prompts_1.getEventPrompt)({ agentUserName: agentUserName }),
6002
+ }),
6003
+ ],
6004
+ };
6005
+ };
6006
+ exports.createAgentEventJob = createAgentEventJob;
6007
+ //# sourceMappingURL=createAgentEventJob.js.map
6008
+
6009
+ /***/ }),
6010
+
6011
+ /***/ 8672:
6012
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6013
+
6014
+ "use strict";
6015
+
6016
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6017
+ exports.createAgentReviewJob = void 0;
6018
+ const rules_1 = __nccwpck_require__(7551);
6019
+ const prompts_1 = __nccwpck_require__(8698);
6020
+ const shared_1 = __nccwpck_require__(732);
6021
+ const utils_1 = __nccwpck_require__(9133);
6022
+ const createAgentReviewJob = (context) => {
6023
+ const baseJob = (0, shared_1.createBaseAgentJob)(context);
6024
+ const agentUserName = (0, utils_1.getAgentUserName)(context);
6025
+ const rules = context.reviews.byUser === "all-automatic"
6026
+ ? [
6027
+ {
6028
+ ...rules_1.RULE_IS_MERGE_REQUEST,
6029
+ when: "always",
6030
+ },
6031
+ ]
6032
+ : Object.entries(context.reviews.byUser)
6033
+ .filter(([_, { automatic }]) => automatic)
6034
+ .map(([username]) => ({
6035
+ // GITLAB_USER_LOGIN is the username of the user who created the pipeline
6036
+ if: `${rules_1.RULE_IS_MERGE_REQUEST.if} && $GITLAB_USER_LOGIN == "${username}"`,
6037
+ when: "always",
6038
+ }));
6039
+ return {
6040
+ ...baseJob,
6041
+ envMode: "jobPerEnv",
6042
+ name: context.name + "-agent-review",
6043
+ allow_failure: true, // make it optional
6044
+ rules: [
6045
+ ...rules,
6046
+ {
6047
+ ...rules_1.RULE_IS_MERGE_REQUEST,
6048
+ when: "manual",
6049
+ },
6050
+ {
6051
+ when: "never",
6052
+ },
6053
+ ],
6054
+ script: [
6055
+ ...shared_1.baseSetupScript,
6056
+ ...(0, shared_1.callClaude)({
6057
+ prompt: (0, prompts_1.getMergeRequestPrompt)({
6058
+ agentUserName: agentUserName,
6059
+ }),
6060
+ }),
6061
+ ],
6062
+ };
6063
+ };
6064
+ exports.createAgentReviewJob = createAgentReviewJob;
6065
+ //# sourceMappingURL=createAgentReviewJob.js.map
6066
+
6067
+ /***/ }),
6068
+
6069
+ /***/ 1455:
6070
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6071
+
6072
+ "use strict";
6073
+
6074
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6075
+ exports.createJobsForAgentContext = void 0;
6076
+ const createAgentEventJob_1 = __nccwpck_require__(9404);
6077
+ const createAgentReviewJob_1 = __nccwpck_require__(8672);
6078
+ const createJobsForAgentContext = (context) => {
6079
+ return [(0, createAgentEventJob_1.createAgentEventJob)(context), (0, createAgentReviewJob_1.createAgentReviewJob)(context)];
6080
+ };
6081
+ exports.createJobsForAgentContext = createJobsForAgentContext;
6082
+ //# sourceMappingURL=createJobsForAgentContext.js.map
6083
+
6084
+ /***/ }),
6085
+
6086
+ /***/ 8698:
6087
+ /***/ ((__unused_webpack_module, exports) => {
6088
+
6089
+ "use strict";
6090
+
6091
+ // prompts.ts — MCP-only, DRY, review-first-then-push, CI diagnosis (no retries),
6092
+ // self-mention guard, conversations-aware (issues & MRs), inline replies, de-duplication.
6093
+ // Review-on-demand: resolves MR pipeline and triggers manual "agent-review" when present.
6094
+ // Single-runner guard: cancels running "agent-review" on the MR pipeline before acting.
6095
+ // Stdout summaries included for both event and MR flows.
6096
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6097
+ exports.getMergeRequestPrompt = exports.getEventPrompt = void 0;
6098
+ /* ---------- Shared blocks ---------- */
6099
+ const header = () => `
6100
+ Project ID: $CI_PROJECT_ID
6101
+ GitLab Host: $CI_SERVER_URL
6102
+ Default Branch: $CI_DEFAULT_BRANCH
6103
+ `;
6104
+ const identity = ({ agentUserName }) => `
6105
+ ## Identity
6106
+ - Your GitLab username is "${agentUserName}".
6107
+ `;
6108
+ const goldenRules = ({ agentUserName }) => `
6109
+ ## Golden Rules
6110
+ - Use the \`gitlab-mcp\` tool for ALL GitLab actions. Do not call any other APIs.
6111
+ - If a needed \`gitlab-mcp\` capability is unavailable, post a short comment explaining the limitation and stop.
6112
+ - NEVER mention yourself ("@${agentUserName}") anywhere (comments, descriptions, titles, commit messages).
6113
+ - NEVER push to $CI_DEFAULT_BRANCH or any protected branch. Always create a new branch and open a Merge Request (MR).
6114
+ - Always assign yourself as the assignee of any MR you create.
6115
+ - Do not create an MR for a **closed** issue.
6116
+ - Keep actions minimal and idempotent. Avoid duplicate comments or duplicate MRs.
6117
+ - Use ONE stable \`source_branch\` per run; do not regenerate its name later.
6118
+ `;
6119
+ /* ---------- Conversations + threading ---------- */
6120
+ const conversationsIntake = ({ agentUserName }) => `
6121
+ ## Conversations Intake & Threading (MANDATORY before acting)
6122
+ Always load and reason about the current conversation to avoid duplicates and to respond in the right place.
6123
+
6124
+ - **MRs**: Use \`mr_discussions({ projectId: $CI_PROJECT_ID, mergeRequestIid })\`.
6125
+ - **Issues**: Use issue discussions if available; if not, rely on event payload and note IDs.
6126
+
6127
+ Rules:
6128
+ 1) Detect latest human note (exclude "${agentUserName}"). If it replies to you or is in a discussion you started, reply **in the same thread**.
6129
+ 2) If your last message is still the latest and no one else replied, prefer **update_note** instead of creating a new one.
6130
+ 3) For MR code discussions: reply inline in the same discussion.
6131
+ 4) Always sanitize (see Self-mention Guard) before writing.
6132
+ `;
6133
+ const selfMentionGuard = ({ agentUserName }) => `
6134
+ ## Self-mention Guard
6135
+ Before ANY write (comment/MR/issue/commit message):
6136
+ - Remove all occurrences of "@${agentUserName}" (case-insensitive).
6137
+ - If the text becomes empty, skip the write.
6138
+ - If the last actor is you, skip acknowledgement comments.
6139
+ - To assign yourself, use assignee fields, not mentions.
6140
+ `;
6141
+ const commentGuidelines = () => `
6142
+ ## Comment Guidelines
6143
+ - Professional, friendly, concise.
6144
+ - Always @-mention the human author when replying; never mention yourself.
6145
+ - Acknowledge requests, answer questions directly, confirm fixes or updates.
6146
+ - Avoid repeating boilerplate.
6147
+ `;
6148
+ /* ---------- gitlab-mcp tool usage ---------- */
6149
+ const mcpOnly = () => `
6150
+ ## gitlab-mcp Operations
6151
+
6152
+ - **Comments / Notes**
6153
+ - create_issue_note({ projectId, issueIid, body })
6154
+ - update_issue_note({ projectId, issueIid, noteId, body })
6155
+ - create_merge_request_note({ projectId, mergeRequestIid, body })
6156
+ - update_merge_request_note({ projectId, mergeRequestIid, noteId, body })
6157
+ - mr_discussions({ projectId, mergeRequestIid })
6158
+
6159
+ - **Issues**
6160
+ - create_issue({ projectId, title, description, assigneeUsernames?: string[] })
6161
+
6162
+ - **Branch & Files**
6163
+ - create_branch({ projectId, branchName, ref })
6164
+ - push_files({ projectId, branch, commitMessage, files: [{ filePath, content }] })
6165
+ - create_or_update_file({ projectId, branch, filePath, content, commitMessage })
6166
+ - get_branch_diffs({ projectId, from, to })
6167
+
6168
+ - **Merge Requests**
6169
+ - create_merge_request({ projectId, sourceBranch, targetBranch, title, description, assigneeUsernames?: string[] })
6170
+ - get_merge_request({ projectId, mergeRequestIid })
6171
+ - get_merge_request_diffs({ projectId, mergeRequestIid })
6172
+ - list_merge_request_diffs({ projectId, mergeRequestIid, page?, perPage? })
6173
+ - update_merge_request({ projectId, mergeRequestIid, title?, description?, draft?, assigneeUsernames? })
6174
+
6175
+ - **Pipelines / Jobs**
6176
+ - list_pipelines({ projectId, ref?, sha?, status?, orderBy?, sort? })
6177
+ - list_pipeline_jobs({ projectId, pipelineId })
6178
+ - get_pipeline_job_output({ projectId, pipelineId, jobId })
6179
+ - play_pipeline_job({ projectId, jobId })
6180
+ - cancel_pipeline_job({ projectId, jobId })
6181
+ `;
6182
+ const outputDiscipline = ({ agentUserName }) => `
6183
+ ## Output Discipline
6184
+ - Output only \`gitlab-mcp\` tool calls and plain-text summaries where requested.
6185
+ - Keep comments concise and professional.
6186
+ - Never include "@${agentUserName}" in any body.
6187
+ `;
6188
+ /* ---------- Event-specific helpers ---------- */
6189
+ const eventSelfParse = () => `
6190
+ ## Self-Parse Raw Payload
6191
+ From \`event_json\`, extract:
6192
+ - kind: "issue" | "merge_request" | "note"
6193
+ - iid from URL (/issues/<n>, /merge_requests/<n>)
6194
+ - note_id if present (#note_<id>)
6195
+ - description/body, state, author, timestamps
6196
+ - project id/path
6197
+ - discussion id if available for inline replies
6198
+ `;
6199
+ /* Resolve MR pipeline from MR IID */
6200
+ const resolveMrPipeline = () => `
6201
+ ## Resolve MR Pipeline
6202
+ 1) get_merge_request({ projectId, mergeRequestIid }) → sourceBranch, sha
6203
+ 2) Prefer: list_pipelines({ projectId, sha })
6204
+ 3) Else: list_pipelines({ projectId, ref: sourceBranch, orderBy: "updated_at", sort: "desc" })
6205
+ 4) Pick newest → mr_pipeline_id
6206
+ `;
6207
+ /* Guard against double agent-review jobs */
6208
+ const singleRunnerGuard = () => `
6209
+ ## Single-Runner Guard
6210
+ - If mr_pipeline_id available:
6211
+ - list_pipeline_jobs({ projectId, pipelineId: mr_pipeline_id })
6212
+ - cancel_pipeline_job on any running/pending job ending with "agent-review"
6213
+ - If not available, note limitation and proceed
6214
+ `;
6215
+ /* If user asks for review from an event, try manual agent-review job first on the MR's pipeline */
6216
+ const reviewOnDemandFromEvents = () => `
6217
+ ## Review-on-Demand
6218
+ If the text asks for a review ("review", "please review", "PTAL", "needs review", "can you look at", "LGTM?"):
6219
+ 1) Resolve MR IID (from target or text).
6220
+ 2) Resolve MR pipeline (do NOT use the event pipeline).
6221
+ 3) If a manual "agent-review" job exists, play it → confirm in-thread → STOP.
6222
+ 4) Else run Single-Runner Guard, then enter MR Review Mode.
6223
+ `;
6224
+ /* ---------- Event workflow ---------- */
6225
+ const eventWorkflow = ({ agentUserName }) => `
6226
+ ## Event Workflow
6227
+ 0) Conversations Intake first
6228
+ 1) Acknowledge with note (unless last actor is you)
6229
+ 2) Default branch: use \`$CI_DEFAULT_BRANCH\`
6230
+ 3) Create branch from \`$CI_DEFAULT_BRANCH\`:
6231
+ create_branch({ projectId: $CI_PROJECT_ID, branchName: "<source_branch>", ref: $CI_DEFAULT_BRANCH })
6232
+ 4) Write changes → commit → push:
6233
+ push_files({ projectId: $CI_PROJECT_ID, branch: "<source_branch>", commitMessage, files })
6234
+ - Ensure files list is not empty before calling push_files; if empty, skip pushing.
6235
+ 5) Verify:
6236
+ get_branch_diffs({ projectId: $CI_PROJECT_ID, from: $CI_DEFAULT_BRANCH, to: "<source_branch>" })
6237
+ - Require non-empty diffs
6238
+ 6) Create MR (if diffs exist):
6239
+ create_merge_request({
6240
+ projectId: $CI_PROJECT_ID,
6241
+ sourceBranch: "<source_branch>",
6242
+ targetBranch: $CI_DEFAULT_BRANCH,
6243
+ title,
6244
+ description, // include "Closes #<issue_iid>" when applicable
6245
+ assigneeUsernames: ["${agentUserName}"]
6246
+ })
6247
+ 7) Follow-up note (in correct thread) with branch, short SHA if available, files-changed count, and MR link (unless last actor is you)
6248
+ 8) If verification fails: comment error and STOP
6249
+
6250
+ ## Stdout Summary (Event)
6251
+ Print a plain-text summary with:
6252
+ - action: "event"
6253
+ - source_branch
6254
+ - target_branch: $CI_DEFAULT_BRANCH
6255
+ - diff_count (from get_branch_diffs)
6256
+ - mr_iid and/or mr_url if created
6257
+ - any note ids created/updated
6258
+ - any limitations encountered (e.g., missing discussions tool)
6259
+ `;
6260
+ /* ---------- MR-specific ---------- */
6261
+ const mrScope = ({ agentUserName }) => `
6262
+ ## MR Scope
6263
+ - You are reviewing a single MR
6264
+ - Never merge the MR yourself
6265
+ - Work only on the MR's source branch
6266
+ `;
6267
+ const mrWorkflow = () => `
6268
+ ## MR Workflow
6269
+ 1) get_merge_request + get_merge_request_diffs + mr_discussions
6270
+ 2) Conversations Intake
6271
+ 3) Post review comments first via create_merge_request_note (sanitize)
6272
+ 4) If will_push_changes = true:
6273
+ - push_files to source branch
6274
+ - verify with get_branch_diffs({ from: targetBranch || $CI_DEFAULT_BRANCH, to: sourceBranch })
6275
+ - follow-up note summarizing changes in the right thread (sanitize)
6276
+
6277
+ ## Stdout Summary (MR)
6278
+ Print a plain-text summary with:
6279
+ - action: "mr"
6280
+ - mr_iid
6281
+ - source_branch and target_branch (fallback to $CI_DEFAULT_BRANCH)
6282
+ - will_push_changes: true|false
6283
+ - diff_count (post-push, if applicable)
6284
+ - discussions: number of notes added/updated
6285
+ - ci: whether mr_pipeline_id was resolved
6286
+ - blocking_failed_jobs (names+stages) if inspected
6287
+ `;
6288
+ /* ---------- CI Inspection (shared) ---------- */
6289
+ const ciInspection = () => `
6290
+ ## CI Inspection (diagnose only)
6291
+ - Use mr_pipeline_id if available
6292
+ - list_pipeline_jobs → for each failed + allow_failure=false:
6293
+ - get_pipeline_job_output
6294
+ - classify: code vs infra
6295
+ - Do not retry; only report diagnosis in a note
6296
+ - If no mr_pipeline_id, note limitation
6297
+ `;
6298
+ const outputDisciplineMR = ({ agentUserName }) => `
6299
+ ## Output Discipline (MR)
6300
+ - Only gitlab-mcp calls + final summary
6301
+ - Never merge MR
6302
+ - Never mention "@${agentUserName}"
6303
+ `;
6304
+ /* ---------- MR Review Bundle ---------- */
6305
+ const mrReviewBundle = (ctx) => `
6306
+ ## MR Review Mode
6307
+ ${mrScope(ctx)}
6308
+ ${mrWorkflow()}
6309
+ ${ciInspection()}
6310
+ `;
6311
+ /* ---------- Public builders ---------- */
6312
+ const getEventPrompt = (ctx) => `
6313
+ You are a GitLab assistant bot. You receive ONE raw GitLab webhook JSON payload.
6314
+
6315
+ ${header()}
6316
+ ---
6317
+ event_json:
6318
+ $(cat $TRIGGER_PAYLOAD)
6319
+ ---
6320
+
6321
+ ${identity(ctx)}
6322
+ ${goldenRules(ctx)}
6323
+ ${selfMentionGuard(ctx)}
6324
+ ${conversationsIntake(ctx)}
6325
+ ${eventSelfParse()}
6326
+ ${resolveMrPipeline()}
6327
+ ${singleRunnerGuard()}
6328
+ ${reviewOnDemandFromEvents()}
6329
+ ${mrReviewBundle(ctx)}
6330
+ ${eventWorkflow(ctx)}
6331
+ ${commentGuidelines()}
6332
+ ${mcpOnly()}
6333
+ ${outputDiscipline(ctx)}
6334
+ `;
6335
+ exports.getEventPrompt = getEventPrompt;
6336
+ const getMergeRequestPrompt = (ctx) => `
6337
+ You are a GitLab assistant bot reviewing and updating a single Merge Request (MR).
6338
+
6339
+ ${header()}
6340
+ ---
6341
+ merge_request_iid: $CI_MERGE_REQUEST_IID
6342
+ title: $CI_MERGE_REQUEST_TITLE
6343
+ description: $CI_MERGE_REQUEST_DESCRIPTION
6344
+ ---
6345
+
6346
+ ${mrScope(ctx)}
6347
+ ${goldenRules(ctx)}
6348
+ ${selfMentionGuard(ctx)}
6349
+ ${conversationsIntake(ctx)}
6350
+ ${mrWorkflow()}
6351
+ ${ciInspection()}
6352
+ ${commentGuidelines()}
6353
+ ${mcpOnly()}
6354
+ ${outputDisciplineMR(ctx)}
6355
+ `;
6356
+ exports.getMergeRequestPrompt = getMergeRequestPrompt;
6357
+ //# sourceMappingURL=prompts.js.map
6358
+
6359
+ /***/ }),
6360
+
6361
+ /***/ 732:
6362
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6363
+
6364
+ "use strict";
6365
+
6366
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6367
+ exports.callClaude = exports.baseSetupScript = exports.createBaseAgentJob = void 0;
6368
+ const bashEscape_1 = __nccwpck_require__(2463);
6369
+ const runner_1 = __nccwpck_require__(4058);
6370
+ const createBaseAgentJob = (context) => ({
6371
+ stage: "agents",
6372
+ // image: "node:24-alpine3.21",
6373
+ image: (0, runner_1.getRunnerImage)("agent-claude"),
6374
+ variables: {
6375
+ MAX_MCP_OUTPUT_TOKENS: "75000",
6376
+ GITLAB_PERSONAL_ACCESS_TOKEN: "$AGENT_GITLAB_PERSONAL_ACCESS_TOKEN", // TODO: we don't have global secret keys to configure yet
6377
+ GITLAB_API_URL: "$CI_API_V4_URL",
6378
+ },
6379
+ });
6380
+ exports.createBaseAgentJob = createBaseAgentJob;
6381
+ exports.baseSetupScript = [
6382
+ // these are done in the image already
6383
+ // "apk update",
6384
+ // "apk add --no-cache git curl bash",
6385
+ //"npm install -g @anthropic-ai/claude-code",
6386
+ "claude mcp add gitlab --env GITLAB_PERSONAL_ACCESS_TOKEN=$GITLAB_PERSONAL_ACCESS_TOKEN --env GITLAB_API_URL=$GITLAB_API_URL --env USE_PIPELINE='true' -- npx -y @zereight/mcp-gitlab",
6387
+ ];
6388
+ const callClaude = ({ prompt }) => {
6389
+ return [
6390
+ `export PROMPT="${(0, bashEscape_1.escapeNewlines)((0, bashEscape_1.escapeDoubleQuotes)((0, bashEscape_1.escapeBackTicks)(prompt)))}"`,
6391
+ //'echo "$PROMPT"',
6392
+ `claude -p "$PROMPT" --permission-mode acceptEdits --allowedTools "Bash Read(*) Edit(*) Write(*) mcp__gitlab" --verbose --debug`,
6393
+ ];
6394
+ };
6395
+ exports.callClaude = callClaude;
6396
+ //# sourceMappingURL=shared.js.map
6397
+
6398
+ /***/ }),
6399
+
6400
+ /***/ 9133:
6401
+ /***/ ((__unused_webpack_module, exports) => {
6402
+
6403
+ "use strict";
6404
+
6405
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6406
+ exports.getAgentUserId = exports.getAgentUserName = void 0;
6407
+ const getAgentUserName = (context) => {
6408
+ var _a, _b;
6409
+ return (_b = (_a = context.agentConfig.agentUser) === null || _a === void 0 ? void 0 : _a.username) !== null && _b !== void 0 ? _b : "agent.claude";
6410
+ };
6411
+ exports.getAgentUserName = getAgentUserName;
6412
+ const getAgentUserId = (context) => {
6413
+ var _a, _b;
6414
+ return (_b = (_a = context.agentConfig.agentUser) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : "$DEFAULT_AGENT_USER_ID";
6415
+ };
6416
+ exports.getAgentUserId = getAgentUserId;
6417
+ //# sourceMappingURL=utils.js.map
6418
+
6419
+ /***/ }),
6420
+
5803
6421
  /***/ 3579:
5804
6422
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5805
6423
 
@@ -5812,8 +6430,10 @@ const createWorkspaceContext_1 = __nccwpck_require__(6558);
5812
6430
  const types_1 = __nccwpck_require__(1853);
5813
6431
  const createJobsForComponent_1 = __nccwpck_require__(2321);
5814
6432
  const createJobsForWorkspace_1 = __nccwpck_require__(803);
6433
+ const createJobsForAgentContext_1 = __nccwpck_require__(1455);
6434
+ const createAgentContext_1 = __nccwpck_require__(2636);
5815
6435
  const createAllJobs = async ({ config, trigger, pipelineType, }) => {
5816
- var _a;
6436
+ var _a, _b;
5817
6437
  const allComponentsContext = await (0, createAllComponentsContext_1.createAllComponentsContext)({
5818
6438
  config,
5819
6439
  trigger,
@@ -5845,6 +6465,13 @@ const createAllJobs = async ({ config, trigger, pipelineType, }) => {
5845
6465
  jobs: (0, createJobsForComponent_1.createJobsForComponentContext)(context),
5846
6466
  };
5847
6467
  }),
6468
+ agents: await Promise.all(Object.keys((_b = config.agents) !== null && _b !== void 0 ? _b : {}).map(async (agentName) => {
6469
+ const context = await (0, createAgentContext_1.createAgentContext)({ agentName, config });
6470
+ return {
6471
+ context,
6472
+ jobs: (0, createJobsForAgentContext_1.createJobsForAgentContext)(context),
6473
+ };
6474
+ })).then((f) => f.flat()),
5848
6475
  };
5849
6476
  };
5850
6477
  exports.createAllJobs = createAllJobs;
@@ -5949,10 +6576,16 @@ const createMainPipeline = async (pipelineType, config) => {
5949
6576
  const bIndex = componentNames.findIndex((c) => c === b.context.name);
5950
6577
  return aIndex - bIndex;
5951
6578
  });
5952
- const allJobs = [...allWorkspaceJobs, ...allComponentJobs].reduce((acc, { gitlabJob, name, context }) => {
6579
+ const allGlobalJobs = allJobsPerTrigger.filter((j) => { var _a; return ((_a = j.context) === null || _a === void 0 ? void 0 : _a.type) === "agent"; });
6580
+ const allJobs = [
6581
+ ...allWorkspaceJobs,
6582
+ ...allComponentJobs,
6583
+ ...allGlobalJobs,
6584
+ ].reduce((acc, { gitlabJob, name, context }) => {
5953
6585
  var _a, _b;
5954
6586
  // merge jobs, if a job is already there, merge the rules
5955
6587
  // this is currently needed because of envMode: "none", which creates the same job for all triggers, so it can appear multiple times
6588
+ // NOTICE: envNode none has been removed and this may no longer be needed
5956
6589
  if (acc[name]) {
5957
6590
  acc[name].gitlabJob.rules = [
5958
6591
  ...((_a = acc[name].gitlabJob.rules) !== null && _a !== void 0 ? _a : []),
@@ -5968,7 +6601,7 @@ const createMainPipeline = async (pipelineType, config) => {
5968
6601
  stages: [...stages, "release"],
5969
6602
  jobs: {
5970
6603
  ...allJobs,
5971
- ...Object.fromEntries(Object.entries((0, gitlabReleaseJobs_1.getGitlabReleaseJobs)()).map(([name, gitlabJob]) => [
6604
+ ...Object.fromEntries(Object.entries((0, gitlabReleaseJobs_1.getGitlabReleaseJobs)(config)).map(([name, gitlabJob]) => [
5972
6605
  name,
5973
6606
  {
5974
6607
  gitlabJob,
@@ -5988,12 +6621,16 @@ function getGitlabRulesForTrigger(trigger) {
5988
6621
  // taggedRelease: on tag
5989
6622
  switch (trigger) {
5990
6623
  case "mainBranch":
5991
- return [rules_1.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT];
6624
+ return [
6625
+ rules_1.RULE_NEVER_ON_AGENT_TRIGGER,
6626
+ rules_1.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT,
6627
+ ];
5992
6628
  case "mr":
5993
- return [rules_1.RULE_IS_MERGE_REQUEST];
6629
+ return [rules_1.RULE_NEVER_ON_AGENT_TRIGGER, rules_1.RULE_IS_MERGE_REQUEST];
5994
6630
  case "taggedRelease":
5995
- return [rules_1.RULE_IS_TAGGED_RELEASE];
6631
+ return [rules_1.RULE_NEVER_ON_AGENT_TRIGGER, rules_1.RULE_IS_TAGGED_RELEASE];
5996
6632
  }
6633
+ throw new Error(`${trigger} is not supported`);
5997
6634
  }
5998
6635
  //# sourceMappingURL=createMainPipeline.js.map
5999
6636
 
@@ -6008,16 +6645,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
6008
6645
  exports.getGitlabCompletePipeline = exports.generatePipelineFiles = void 0;
6009
6646
  const promises_1 = __nccwpck_require__(3292);
6010
6647
  const path_1 = __nccwpck_require__(1017);
6011
- const writeFiles_1 = __nccwpck_require__(2228);
6012
6648
  const createMainPipeline_1 = __nccwpck_require__(9192);
6013
6649
  const sortGitLabJobDefProps_1 = __nccwpck_require__(2361);
6014
6650
  const CATLADDER_GENERATED_FOLDER = ".catladder-generated";
6015
6651
  const GITLAB_GENERATED_FOLDER = CATLADDER_GENERATED_FOLDER + "/gitlab";
6016
- async function generatePipelineFiles(config, pipelineType) {
6652
+ async function generatePipelineFiles(context, pipelineType) {
6017
6653
  if (pipelineType !== "gitlab") {
6018
6654
  throw new Error("Pipeline type not supported");
6019
6655
  }
6020
- const includes = await getGitlabPipelineIncludes(config);
6656
+ const includes = await getGitlabPipelineIncludes(context.config);
6021
6657
  const mainFile = {
6022
6658
  path: ".gitlab-ci.yml",
6023
6659
  content: {
@@ -6030,7 +6666,7 @@ async function generatePipelineFiles(config, pipelineType) {
6030
6666
  // write files
6031
6667
  await Promise.all(files.map(async ({ path, content }) => {
6032
6668
  await (0, promises_1.mkdir)((0, path_1.dirname)(path), { recursive: true });
6033
- await (0, writeFiles_1.writeYamlfile)(path, content);
6669
+ await context.fileWriter.writeYamlfile(path, content);
6034
6670
  }));
6035
6671
  }
6036
6672
  exports.generatePipelineFiles = generatePipelineFiles;
@@ -6114,6 +6750,49 @@ exports.getPipelineStages = getPipelineStages;
6114
6750
 
6115
6751
  /***/ }),
6116
6752
 
6753
+ /***/ 4025:
6754
+ /***/ ((__unused_webpack_module, exports) => {
6755
+
6756
+ "use strict";
6757
+
6758
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6759
+ exports.addCacheFallback = exports.getCacheKeyWithFallbackForMR = void 0;
6760
+ const getCacheKeyWithFallbackForMR = (baseKey, context) => {
6761
+ // if its a branch, create a key with the branch name with fallback to the base key
6762
+ if (context.trigger === "mr") {
6763
+ return {
6764
+ key: baseKey + "-mr$CI_MERGE_REQUEST_IID",
6765
+ fallback_keys: [baseKey],
6766
+ };
6767
+ }
6768
+ return {
6769
+ key: baseKey,
6770
+ };
6771
+ };
6772
+ exports.getCacheKeyWithFallbackForMR = getCacheKeyWithFallbackForMR;
6773
+ const addCacheFallback = (cache, context) => {
6774
+ if (context.type !== "agent" && context.trigger === "mr") {
6775
+ if (Array.isArray(cache)) {
6776
+ return cache.map((c) => addCacheFallbackToSingleCacheForMR(c, context));
6777
+ }
6778
+ return addCacheFallbackToSingleCacheForMR(cache, context);
6779
+ }
6780
+ return cache;
6781
+ };
6782
+ exports.addCacheFallback = addCacheFallback;
6783
+ const addCacheFallbackToSingleCacheForMR = (cache, context) => {
6784
+ if (typeof cache.key === "string") {
6785
+ return {
6786
+ ...cache,
6787
+ ...(0, exports.getCacheKeyWithFallbackForMR)(cache.key, context),
6788
+ };
6789
+ }
6790
+ return cache; // as is
6791
+ };
6792
+ //# sourceMappingURL=cache.js.map
6793
+
6794
+ /***/ }),
6795
+
6117
6796
  /***/ 8862:
6118
6797
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6119
6798
 
@@ -6128,10 +6807,11 @@ const utils_1 = __nccwpck_require__(2497);
6128
6807
  const gitlab_1 = __nccwpck_require__(8490);
6129
6808
  const removeUndefined_1 = __nccwpck_require__(1073);
6130
6809
  const BashExpression_1 = __nccwpck_require__(2376);
6810
+ const cache_1 = __nccwpck_require__(4025);
6131
6811
  exports.GITLAB_ENVIRONMENT_URL_VARIABLE = "CL_GITLAB_ENVIRONMENT_URL";
6132
6812
  const getFullJobName = ({ type, name, baseName, allJobs, env, }) => {
6133
6813
  const shouldAddIcon = allJobs.workspaces.length > 0;
6134
- const icon = type === "component" ? "🔹" : "🔸";
6814
+ const icon = type === "component" ? "🔹" : type === "agent" ? "🤖" : "🔸";
6135
6815
  const prefix = shouldAddIcon ? icon + " " : "";
6136
6816
  if (env) {
6137
6817
  return `${prefix}${baseName} ${name} | ${env} `;
@@ -6145,12 +6825,11 @@ const getFullReferencedJobNameFromComponent = (referencedJobName, componentName,
6145
6825
  if (!referencedJob) {
6146
6826
  throw new Error(`unknown job referenced: '${referencedJobName}' from '${env}:${componentName}'`);
6147
6827
  }
6148
- const envToSet = referencedJob.envMode !== "none" ? env : null;
6149
6828
  return getFullJobName({
6150
6829
  type: "component",
6151
6830
  name: referencedJobName,
6152
6831
  baseName: componentName,
6153
- env: envToSet,
6832
+ env,
6154
6833
  allJobs,
6155
6834
  });
6156
6835
  };
@@ -6161,26 +6840,27 @@ const getFullReferencedJobNameFromWorkspace = (referencedJobName, workspaceName,
6161
6840
  if (!referencedJob) {
6162
6841
  throw new Error(`unknown job referenced: '${referencedJobName}' from workspace ${env}:${workspaceName}'`);
6163
6842
  }
6164
- const envToSet = referencedJob.envMode !== "none" ? env : null;
6165
6843
  return getFullJobName({
6166
6844
  type: "workspace",
6167
6845
  name: referencedJobName,
6168
6846
  baseName: workspaceName,
6169
- env: envToSet,
6847
+ env,
6170
6848
  allJobs,
6171
6849
  });
6172
6850
  };
6173
6851
  const getJobName = (need) => (0, lodash_1.isObject)(need) ? need.job : need;
6174
6852
  const makeGitlabJob = (context, job, allJobs, baseRules) => {
6175
6853
  var _a, _b;
6176
- const { environment, envMode, needsStages, name, needs, jobTags, script, variables, runnerVariables, when, ...rest } = job;
6177
- const stage = envMode === "stagePerEnv" ? `${job.stage} ${context.env}` : job.stage;
6854
+ const { environment, envMode, needsStages, name, needs, jobTags, script, variables, runnerVariables, when, cache, ...rest } = job;
6855
+ const stage = envMode === "stagePerEnv" && context.type !== "agent"
6856
+ ? `${job.stage} ${context.env}`
6857
+ : job.stage;
6178
6858
  const deduplicatedGitlabNeeds = getGitlabNeeds(context, job, allJobs);
6179
6859
  const fullJobName = getFullJobName({
6180
6860
  type: context.type,
6181
6861
  name,
6182
6862
  baseName: context.name,
6183
- env: envMode !== "none" ? context.env : undefined,
6863
+ env: context.type !== "agent" ? context.env : undefined,
6184
6864
  allJobs,
6185
6865
  });
6186
6866
  // backwards compatibility, some may still use KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, etc. in variables.
@@ -6213,7 +6893,10 @@ const makeGitlabJob = (context, job, allJobs, baseRules) => {
6213
6893
  : []),
6214
6894
  ];
6215
6895
  const gitlabJob = {
6896
+ retry: defaults_1.BASE_RETRY,
6897
+ interruptible: true,
6216
6898
  ...rest,
6899
+ cache: cache ? (0, cache_1.addCacheFallback)(cache, context) : undefined,
6217
6900
  rules: rules.length > 0 ? rules : undefined,
6218
6901
  variables: {
6219
6902
  ...legacyRunnerVariables,
@@ -6224,8 +6907,6 @@ const makeGitlabJob = (context, job, allJobs, baseRules) => {
6224
6907
  stage,
6225
6908
  // sort in a predictable manner for snapshot tests
6226
6909
  needs: deduplicatedGitlabNeeds,
6227
- retry: defaults_1.BASE_RETRY,
6228
- interruptible: true,
6229
6910
  };
6230
6911
  const modified = addGitlabEnvironment(context, environment, gitlabJob, allJobs);
6231
6912
  return [fullJobName, (0, removeUndefined_1.removeUndefined)(modified)];
@@ -6237,7 +6918,7 @@ const addGitlabEnvironment = (context, catladderJobEnvironment, job, allJobs) =>
6237
6918
  return job;
6238
6919
  }
6239
6920
  if (context.type !== "component") {
6240
- // don't add enviornment for workspace jobs atm.
6921
+ // don't add enviornment for workspace and agent jobs atm.
6241
6922
  return job;
6242
6923
  }
6243
6924
  const { env, name, environment } = context;
@@ -6278,8 +6959,11 @@ const addGitlabEnvironment = (context, catladderJobEnvironment, job, allJobs) =>
6278
6959
  };
6279
6960
  };
6280
6961
  const createGitlabJobs = async (allJobs, baseRules) => {
6281
- // TODO: add workspace jobs
6282
- return [...allJobs.workspaces, ...allJobs.components].flatMap(({ context, jobs }) => {
6962
+ return [
6963
+ ...allJobs.workspaces,
6964
+ ...allJobs.components,
6965
+ ...allJobs.agents,
6966
+ ].flatMap(({ context, jobs }) => {
6283
6967
  return jobs.map((job) => {
6284
6968
  const [fullJobName, gitlabJob] = (0, exports.makeGitlabJob)(context, job, allJobs, baseRules);
6285
6969
  return {
@@ -6292,10 +6976,13 @@ const createGitlabJobs = async (allJobs, baseRules) => {
6292
6976
  };
6293
6977
  exports.createGitlabJobs = createGitlabJobs;
6294
6978
  function getGitlabNeeds(context, job, allJobs) {
6979
+ var _a;
6295
6980
  const needs = context.type === "workspace"
6296
6981
  ? getGitlabNeedsForWorkspaceJob(context, job, allJobs)
6297
- : getGitlabNeedsForComponentJob(context, job, allJobs);
6298
- return deduplicateNeeds(needs);
6982
+ : context.type === "agent"
6983
+ ? ((_a = job.needs) !== null && _a !== void 0 ? _a : null)
6984
+ : getGitlabNeedsForComponentJob(context, job, allJobs);
6985
+ return needs ? deduplicateNeeds(needs) : undefined;
6299
6986
  }
6300
6987
  function deduplicateNeeds(needs) {
6301
6988
  return needs
@@ -6398,6 +7085,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
6398
7085
  exports.createGitlabPipelineWithDefaults = void 0;
6399
7086
  const runner_1 = __nccwpck_require__(4058);
6400
7087
  const globalScriptFunctions_1 = __nccwpck_require__(2912);
7088
+ const rules_1 = __nccwpck_require__(7551);
6401
7089
  const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...config }) => {
6402
7090
  return {
6403
7091
  image: image !== null && image !== void 0 ? image : (0, runner_1.getRunnerImage)("jobs-default"), // default image
@@ -6413,6 +7101,46 @@ const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...
6413
7101
  ...[...globalScriptFunctions_1.globalScriptFunctions.values()].map((script) => script.toBashFunction()),
6414
7102
  ...(before_script !== null && before_script !== void 0 ? before_script : []),
6415
7103
  ],
7104
+ workflow: {
7105
+ name: "$PIPELINE_ICON $PIPELINE_NAME",
7106
+ rules: [
7107
+ {
7108
+ if: '$CI_PIPELINE_SOURCE == "trigger"',
7109
+ variables: {
7110
+ PIPELINE_ICON: "🤖",
7111
+ PIPELINE_NAME: "Thinking...",
7112
+ },
7113
+ },
7114
+ {
7115
+ if: rules_1.RULE_IS_MERGE_REQUEST.if,
7116
+ variables: {
7117
+ PIPELINE_ICON: "🐱🔨",
7118
+ PIPELINE_NAME: "mr$CI_MERGE_REQUEST_IID - $CI_MERGE_REQUEST_TITLE",
7119
+ },
7120
+ },
7121
+ {
7122
+ if: rules_1.RULE_IS_TAGGED_RELEASE.if,
7123
+ variables: {
7124
+ PIPELINE_ICON: "🐱📦",
7125
+ PIPELINE_NAME: "Release $CI_COMMIT_TAG",
7126
+ },
7127
+ },
7128
+ {
7129
+ if: rules_1.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT.if,
7130
+ variables: {
7131
+ PIPELINE_ICON: "🐱🔨",
7132
+ PIPELINE_NAME: "Main - $CI_COMMIT_TITLE",
7133
+ },
7134
+ },
7135
+ {
7136
+ when: "always", // fallback
7137
+ variables: {
7138
+ PIPELINE_ICON: "🐱❓",
7139
+ PIPELINE_NAME: "Default",
7140
+ },
7141
+ },
7142
+ ],
7143
+ },
6416
7144
  ...config,
6417
7145
  };
6418
7146
  };
@@ -6431,20 +7159,46 @@ exports.getGitlabReleaseJobs = void 0;
6431
7159
  const rules_1 = __nccwpck_require__(7551);
6432
7160
  const runner_1 = __nccwpck_require__(4058);
6433
7161
  const EXPIRED_TOKEN_HELP = "echo '👉 The project access token might be invald - run `project-renew-token` in catladder CLI to fix.'";
6434
- const getGitlabReleaseJobs = () => {
7162
+ const baseReleaseRules = [
7163
+ rules_1.RULE_NEVER_ON_RELEASE_COMMIT,
7164
+ rules_1.RULE_NEVER_ON_AGENT_TRIGGER,
7165
+ rules_1.RULE_NEVER_ON_SCHEDULE,
7166
+ ];
7167
+ const getGitlabReleaseJobs = (config) => {
7168
+ var _a;
6435
7169
  return {
6436
7170
  ["create release"]: {
6437
7171
  stage: "release",
6438
7172
  image: (0, runner_1.getRunnerImage)("semantic-release"),
6439
7173
  script: ["semanticRelease", EXPIRED_TOKEN_HELP],
6440
- rules: rules_1.RULES_RELEASE,
7174
+ rules: [
7175
+ ...baseReleaseRules,
7176
+ {
7177
+ if: rules_1.RULE_CONDITION_MAIN_BRANCH,
7178
+ when: ((_a = config.releases) === null || _a === void 0 ? void 0 : _a.when) === "auto" ? "on_success" : "manual",
7179
+ },
7180
+ {
7181
+ if: rules_1.RULE_CONDITION_HOTFIX_BRANCH,
7182
+ when: "manual",
7183
+ },
7184
+ ],
6441
7185
  },
6442
7186
  ["⚠️ force create release"]: {
6443
7187
  stage: "release",
6444
7188
  image: (0, runner_1.getRunnerImage)("semantic-release"),
6445
7189
  script: ["semanticRelease", EXPIRED_TOKEN_HELP],
6446
7190
  needs: [],
6447
- rules: rules_1.RULES_MANUAL_RELEASE,
7191
+ rules: [
7192
+ ...baseReleaseRules,
7193
+ {
7194
+ if: rules_1.RULE_CONDITION_MAIN_BRANCH,
7195
+ when: "manual",
7196
+ },
7197
+ {
7198
+ if: rules_1.RULE_CONDITION_HOTFIX_BRANCH,
7199
+ when: "manual",
7200
+ },
7201
+ ],
6448
7202
  },
6449
7203
  };
6450
7204
  };
@@ -6681,7 +7435,7 @@ exports.getWorkspaceDependencies = getWorkspaceDependencies;
6681
7435
  "use strict";
6682
7436
 
6683
7437
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6684
- exports.RULES_MANUAL_RELEASE = exports.RULES_RELEASE = exports.RULE_CONDITION_HOTFIX_BRANCH = exports.RULE_IS_TAGGED_RELEASE = exports.RULE_IS_MERGE_REQUEST = exports.RULE_NEVER_ON_SCHEDULE = exports.RULE_NEVER_ON_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH = exports.RULE_CONDITION_NOT_RELEASE_COMMIT = exports.RULE_CONDITION_RELEASE_COMMIT = exports.RULE_CONDITION_MAIN_BRANCH = void 0;
7438
+ exports.RULE_CONDITION_HOTFIX_BRANCH = exports.RULE_IS_TAGGED_RELEASE = exports.RULE_IS_MERGE_REQUEST = exports.RULE_NEVER_ON_SCHEDULE = exports.RULE_NEVER_ON_AGENT_TRIGGER = exports.RULE_NEVER_ON_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH = exports.RULE_CONDITION_NOT_RELEASE_COMMIT = exports.RULE_CONDITION_RELEASE_COMMIT = exports.RULE_CONDITION_MAIN_BRANCH = void 0;
6685
7439
  exports.RULE_CONDITION_MAIN_BRANCH = "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH";
6686
7440
  exports.RULE_CONDITION_RELEASE_COMMIT = "$CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/";
6687
7441
  exports.RULE_CONDITION_NOT_RELEASE_COMMIT = "$CI_COMMIT_MESSAGE !~ /^chore\\(release\\).*/";
@@ -6695,6 +7449,11 @@ exports.RULE_NEVER_ON_RELEASE_COMMIT = {
6695
7449
  if: exports.RULE_CONDITION_RELEASE_COMMIT,
6696
7450
  when: "never",
6697
7451
  };
7452
+ // currently, we consider all triggered pipelines as agent triggers
7453
+ exports.RULE_NEVER_ON_AGENT_TRIGGER = {
7454
+ if: '$CI_PIPELINE_SOURCE == "trigger"',
7455
+ when: "never",
7456
+ };
6698
7457
  exports.RULE_NEVER_ON_SCHEDULE = {
6699
7458
  if: '$CI_PIPELINE_SOURCE == "schedule"',
6700
7459
  when: "never",
@@ -6706,34 +7465,6 @@ exports.RULE_IS_TAGGED_RELEASE = {
6706
7465
  if: "$CI_COMMIT_TAG",
6707
7466
  };
6708
7467
  exports.RULE_CONDITION_HOTFIX_BRANCH = "$CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/";
6709
- exports.RULES_RELEASE = [
6710
- exports.RULE_NEVER_ON_RELEASE_COMMIT,
6711
- exports.RULE_NEVER_ON_SCHEDULE,
6712
- {
6713
- if: exports.RULE_CONDITION_MAIN_BRANCH + ' && $AUTO_RELEASE == "true"',
6714
- when: "on_success",
6715
- },
6716
- {
6717
- if: exports.RULE_CONDITION_MAIN_BRANCH,
6718
- when: "manual",
6719
- },
6720
- {
6721
- if: exports.RULE_CONDITION_HOTFIX_BRANCH,
6722
- when: "manual",
6723
- },
6724
- ];
6725
- exports.RULES_MANUAL_RELEASE = [
6726
- exports.RULE_NEVER_ON_RELEASE_COMMIT,
6727
- exports.RULE_NEVER_ON_SCHEDULE,
6728
- {
6729
- if: exports.RULE_CONDITION_MAIN_BRANCH,
6730
- when: "manual",
6731
- },
6732
- {
6733
- if: exports.RULE_CONDITION_HOTFIX_BRANCH,
6734
- when: "manual",
6735
- },
6736
- ];
6737
7468
  //# sourceMappingURL=index.js.map
6738
7469
 
6739
7470
  /***/ }),
@@ -6752,6 +7483,16 @@ exports.getRunnerImage = getRunnerImage;
6752
7483
 
6753
7484
  /***/ }),
6754
7485
 
7486
+ /***/ 9632:
7487
+ /***/ ((__unused_webpack_module, exports) => {
7488
+
7489
+ "use strict";
7490
+
7491
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7492
+ //# sourceMappingURL=agent.js.map
7493
+
7494
+ /***/ }),
7495
+
6755
7496
  /***/ 7770:
6756
7497
  /***/ ((__unused_webpack_module, exports) => {
6757
7498
 
@@ -6859,6 +7600,7 @@ __exportStar(__nccwpck_require__(1724), exports);
6859
7600
  __exportStar(__nccwpck_require__(8207), exports);
6860
7601
  __exportStar(__nccwpck_require__(2074), exports);
6861
7602
  __exportStar(__nccwpck_require__(7432), exports);
7603
+ __exportStar(__nccwpck_require__(9632), exports);
6862
7604
  //# sourceMappingURL=index.js.map
6863
7605
 
6864
7606
  /***/ }),
@@ -6886,6 +7628,7 @@ exports.BASE_STAGES = [
6886
7628
  "build",
6887
7629
  "deploy",
6888
7630
  "verify",
7631
+ "agents",
6889
7632
  "rollback",
6890
7633
  "stop",
6891
7634
  ];
@@ -7014,29 +7757,9 @@ exports.removeUndefined = removeUndefined;
7014
7757
  "use strict";
7015
7758
 
7016
7759
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7017
- exports.writeYamlfile = exports.yamlStringifyOptions = exports.writeGeneratedFile = exports.getAutoGeneratedHeader = void 0;
7760
+ exports.FileWriter = exports.yamlStringifyOptions = void 0;
7018
7761
  const promises_1 = __nccwpck_require__(3292);
7019
7762
  const yaml_1 = __nccwpck_require__(8033);
7020
- const getAutoGeneratedHeader = (commentChar) => {
7021
- return [
7022
- "-------------------------------------------------",
7023
- `🐱 🔨 This file is generated by catladder`,
7024
- `🚨 Do not edit this file manually 🚨`,
7025
- "-------------------------------------------------",
7026
- ]
7027
- .map((line) => `${commentChar} ${line}`)
7028
- .join("\n")
7029
- .concat("\n");
7030
- };
7031
- exports.getAutoGeneratedHeader = getAutoGeneratedHeader;
7032
- const writeGeneratedFile = async (path, content, { commentChar, }) => {
7033
- await (0, promises_1.writeFile)(path,
7034
- // need to spread out the jobs, forgot why
7035
- [(0, exports.getAutoGeneratedHeader)(commentChar), content].join("\n"), {
7036
- encoding: "utf-8",
7037
- });
7038
- };
7039
- exports.writeGeneratedFile = writeGeneratedFile;
7040
7763
  exports.yamlStringifyOptions = {
7041
7764
  // prevents colapsing long command statements into multiple lines
7042
7765
  lineWidth: 0,
@@ -7045,12 +7768,59 @@ exports.yamlStringifyOptions = {
7045
7768
  // Better readability when bash commands most often use double quotes
7046
7769
  singleQuote: true,
7047
7770
  };
7048
- const writeYamlfile = async (path, data) => {
7049
- await (0, exports.writeGeneratedFile)(path, (0, yaml_1.stringify)(data, exports.yamlStringifyOptions), {
7050
- commentChar: "#",
7051
- });
7052
- };
7053
- exports.writeYamlfile = writeYamlfile;
7771
+ class FileWriter {
7772
+ static create(config) {
7773
+ return new FileWriter(config);
7774
+ }
7775
+ constructor(config) {
7776
+ this.config = config;
7777
+ this.config = config;
7778
+ }
7779
+ async writeTheFile(path, content) {
7780
+ var _a, _b;
7781
+ const transformedContent = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
7782
+ ...(await this.getBaseHookContext(path)),
7783
+ content,
7784
+ }));
7785
+ await (0, promises_1.writeFile)(path, transformedContent !== null && transformedContent !== void 0 ? transformedContent : content, {
7786
+ encoding: "utf-8",
7787
+ });
7788
+ }
7789
+ async getBaseHookContext(path) {
7790
+ var _a, _b;
7791
+ const filename = (_a = path.split("/").pop()) !== null && _a !== void 0 ? _a : "";
7792
+ return {
7793
+ filename,
7794
+ path,
7795
+ extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
7796
+ };
7797
+ }
7798
+ async writeGeneratedFile(path, content, options) {
7799
+ await this.writeTheFile(path, [this.getAutoGeneratedHeader(options.commentChar), content].join("\n"));
7800
+ }
7801
+ async writeYamlfile(path, data) {
7802
+ var _a, _b;
7803
+ const dataTransformed = await ((_b = (_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformYamlBeforeWrite) === null || _b === void 0 ? void 0 : _b.call(_a, {
7804
+ ...(await this.getBaseHookContext(path)),
7805
+ data,
7806
+ }));
7807
+ return this.writeGeneratedFile(path, (0, yaml_1.stringify)(dataTransformed !== null && dataTransformed !== void 0 ? dataTransformed : data, exports.yamlStringifyOptions), {
7808
+ commentChar: "#",
7809
+ });
7810
+ }
7811
+ getAutoGeneratedHeader(commentChar) {
7812
+ return [
7813
+ "-------------------------------------------------",
7814
+ `🐱 🔨 This file is generated by catladder`,
7815
+ `🚨 Do not edit this file manually 🚨`,
7816
+ "-------------------------------------------------",
7817
+ ]
7818
+ .map((line) => `${commentChar} ${line}`)
7819
+ .join("\n")
7820
+ .concat("\n");
7821
+ }
7822
+ }
7823
+ exports.FileWriter = FileWriter;
7054
7824
  //# sourceMappingURL=writeFiles.js.map
7055
7825
 
7056
7826
  /***/ }),
@@ -8138,7 +8908,7 @@ module.exports = parse;
8138
8908
 
8139
8909
 
8140
8910
  var path = __nccwpck_require__(1017);
8141
- var which = __nccwpck_require__(3623);
8911
+ var which = __nccwpck_require__(3672);
8142
8912
  var LRU = __nccwpck_require__(4144);
8143
8913
 
8144
8914
  var commandCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec
@@ -8644,6 +9414,148 @@ function Entry (key, value, length, now, maxAge) {
8644
9414
  }
8645
9415
 
8646
9416
 
9417
+ /***/ }),
9418
+
9419
+ /***/ 3672:
9420
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
9421
+
9422
+ module.exports = which
9423
+ which.sync = whichSync
9424
+
9425
+ var isWindows = process.platform === 'win32' ||
9426
+ process.env.OSTYPE === 'cygwin' ||
9427
+ process.env.OSTYPE === 'msys'
9428
+
9429
+ var path = __nccwpck_require__(1017)
9430
+ var COLON = isWindows ? ';' : ':'
9431
+ var isexe = __nccwpck_require__(5930)
9432
+
9433
+ function getNotFoundError (cmd) {
9434
+ var er = new Error('not found: ' + cmd)
9435
+ er.code = 'ENOENT'
9436
+
9437
+ return er
9438
+ }
9439
+
9440
+ function getPathInfo (cmd, opt) {
9441
+ var colon = opt.colon || COLON
9442
+ var pathEnv = opt.path || process.env.PATH || ''
9443
+ var pathExt = ['']
9444
+
9445
+ pathEnv = pathEnv.split(colon)
9446
+
9447
+ var pathExtExe = ''
9448
+ if (isWindows) {
9449
+ pathEnv.unshift(process.cwd())
9450
+ pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
9451
+ pathExt = pathExtExe.split(colon)
9452
+
9453
+
9454
+ // Always test the cmd itself first. isexe will check to make sure
9455
+ // it's found in the pathExt set.
9456
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
9457
+ pathExt.unshift('')
9458
+ }
9459
+
9460
+ // If it has a slash, then we don't bother searching the pathenv.
9461
+ // just check the file itself, and that's it.
9462
+ if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
9463
+ pathEnv = ['']
9464
+
9465
+ return {
9466
+ env: pathEnv,
9467
+ ext: pathExt,
9468
+ extExe: pathExtExe
9469
+ }
9470
+ }
9471
+
9472
+ function which (cmd, opt, cb) {
9473
+ if (typeof opt === 'function') {
9474
+ cb = opt
9475
+ opt = {}
9476
+ }
9477
+
9478
+ var info = getPathInfo(cmd, opt)
9479
+ var pathEnv = info.env
9480
+ var pathExt = info.ext
9481
+ var pathExtExe = info.extExe
9482
+ var found = []
9483
+
9484
+ ;(function F (i, l) {
9485
+ if (i === l) {
9486
+ if (opt.all && found.length)
9487
+ return cb(null, found)
9488
+ else
9489
+ return cb(getNotFoundError(cmd))
9490
+ }
9491
+
9492
+ var pathPart = pathEnv[i]
9493
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
9494
+ pathPart = pathPart.slice(1, -1)
9495
+
9496
+ var p = path.join(pathPart, cmd)
9497
+ if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
9498
+ p = cmd.slice(0, 2) + p
9499
+ }
9500
+ ;(function E (ii, ll) {
9501
+ if (ii === ll) return F(i + 1, l)
9502
+ var ext = pathExt[ii]
9503
+ isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
9504
+ if (!er && is) {
9505
+ if (opt.all)
9506
+ found.push(p + ext)
9507
+ else
9508
+ return cb(null, p + ext)
9509
+ }
9510
+ return E(ii + 1, ll)
9511
+ })
9512
+ })(0, pathExt.length)
9513
+ })(0, pathEnv.length)
9514
+ }
9515
+
9516
+ function whichSync (cmd, opt) {
9517
+ opt = opt || {}
9518
+
9519
+ var info = getPathInfo(cmd, opt)
9520
+ var pathEnv = info.env
9521
+ var pathExt = info.ext
9522
+ var pathExtExe = info.extExe
9523
+ var found = []
9524
+
9525
+ for (var i = 0, l = pathEnv.length; i < l; i ++) {
9526
+ var pathPart = pathEnv[i]
9527
+ if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
9528
+ pathPart = pathPart.slice(1, -1)
9529
+
9530
+ var p = path.join(pathPart, cmd)
9531
+ if (!pathPart && /^\.[\\\/]/.test(cmd)) {
9532
+ p = cmd.slice(0, 2) + p
9533
+ }
9534
+ for (var j = 0, ll = pathExt.length; j < ll; j ++) {
9535
+ var cur = p + pathExt[j]
9536
+ var is
9537
+ try {
9538
+ is = isexe.sync(cur, { pathExt: pathExtExe })
9539
+ if (is) {
9540
+ if (opt.all)
9541
+ found.push(cur)
9542
+ else
9543
+ return cur
9544
+ }
9545
+ } catch (ex) {}
9546
+ }
9547
+ }
9548
+
9549
+ if (opt.all && found.length)
9550
+ return found
9551
+
9552
+ if (opt.nothrow)
9553
+ return null
9554
+
9555
+ throw getNotFoundError(cmd)
9556
+ }
9557
+
9558
+
8647
9559
  /***/ }),
8648
9560
 
8649
9561
  /***/ 4071:
@@ -40424,148 +41336,6 @@ module.exports.implForWrapper = function (wrapper) {
40424
41336
 
40425
41337
 
40426
41338
 
40427
- /***/ }),
40428
-
40429
- /***/ 3623:
40430
- /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
40431
-
40432
- module.exports = which
40433
- which.sync = whichSync
40434
-
40435
- var isWindows = process.platform === 'win32' ||
40436
- process.env.OSTYPE === 'cygwin' ||
40437
- process.env.OSTYPE === 'msys'
40438
-
40439
- var path = __nccwpck_require__(1017)
40440
- var COLON = isWindows ? ';' : ':'
40441
- var isexe = __nccwpck_require__(5930)
40442
-
40443
- function getNotFoundError (cmd) {
40444
- var er = new Error('not found: ' + cmd)
40445
- er.code = 'ENOENT'
40446
-
40447
- return er
40448
- }
40449
-
40450
- function getPathInfo (cmd, opt) {
40451
- var colon = opt.colon || COLON
40452
- var pathEnv = opt.path || process.env.PATH || ''
40453
- var pathExt = ['']
40454
-
40455
- pathEnv = pathEnv.split(colon)
40456
-
40457
- var pathExtExe = ''
40458
- if (isWindows) {
40459
- pathEnv.unshift(process.cwd())
40460
- pathExtExe = (opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM')
40461
- pathExt = pathExtExe.split(colon)
40462
-
40463
-
40464
- // Always test the cmd itself first. isexe will check to make sure
40465
- // it's found in the pathExt set.
40466
- if (cmd.indexOf('.') !== -1 && pathExt[0] !== '')
40467
- pathExt.unshift('')
40468
- }
40469
-
40470
- // If it has a slash, then we don't bother searching the pathenv.
40471
- // just check the file itself, and that's it.
40472
- if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
40473
- pathEnv = ['']
40474
-
40475
- return {
40476
- env: pathEnv,
40477
- ext: pathExt,
40478
- extExe: pathExtExe
40479
- }
40480
- }
40481
-
40482
- function which (cmd, opt, cb) {
40483
- if (typeof opt === 'function') {
40484
- cb = opt
40485
- opt = {}
40486
- }
40487
-
40488
- var info = getPathInfo(cmd, opt)
40489
- var pathEnv = info.env
40490
- var pathExt = info.ext
40491
- var pathExtExe = info.extExe
40492
- var found = []
40493
-
40494
- ;(function F (i, l) {
40495
- if (i === l) {
40496
- if (opt.all && found.length)
40497
- return cb(null, found)
40498
- else
40499
- return cb(getNotFoundError(cmd))
40500
- }
40501
-
40502
- var pathPart = pathEnv[i]
40503
- if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
40504
- pathPart = pathPart.slice(1, -1)
40505
-
40506
- var p = path.join(pathPart, cmd)
40507
- if (!pathPart && (/^\.[\\\/]/).test(cmd)) {
40508
- p = cmd.slice(0, 2) + p
40509
- }
40510
- ;(function E (ii, ll) {
40511
- if (ii === ll) return F(i + 1, l)
40512
- var ext = pathExt[ii]
40513
- isexe(p + ext, { pathExt: pathExtExe }, function (er, is) {
40514
- if (!er && is) {
40515
- if (opt.all)
40516
- found.push(p + ext)
40517
- else
40518
- return cb(null, p + ext)
40519
- }
40520
- return E(ii + 1, ll)
40521
- })
40522
- })(0, pathExt.length)
40523
- })(0, pathEnv.length)
40524
- }
40525
-
40526
- function whichSync (cmd, opt) {
40527
- opt = opt || {}
40528
-
40529
- var info = getPathInfo(cmd, opt)
40530
- var pathEnv = info.env
40531
- var pathExt = info.ext
40532
- var pathExtExe = info.extExe
40533
- var found = []
40534
-
40535
- for (var i = 0, l = pathEnv.length; i < l; i ++) {
40536
- var pathPart = pathEnv[i]
40537
- if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
40538
- pathPart = pathPart.slice(1, -1)
40539
-
40540
- var p = path.join(pathPart, cmd)
40541
- if (!pathPart && /^\.[\\\/]/.test(cmd)) {
40542
- p = cmd.slice(0, 2) + p
40543
- }
40544
- for (var j = 0, ll = pathExt.length; j < ll; j ++) {
40545
- var cur = p + pathExt[j]
40546
- var is
40547
- try {
40548
- is = isexe.sync(cur, { pathExt: pathExtExe })
40549
- if (is) {
40550
- if (opt.all)
40551
- found.push(cur)
40552
- else
40553
- return cur
40554
- }
40555
- } catch (ex) {}
40556
- }
40557
- }
40558
-
40559
- if (opt.all && found.length)
40560
- return found
40561
-
40562
- if (opt.nothrow)
40563
- return null
40564
-
40565
- throw getNotFoundError(cmd)
40566
- }
40567
-
40568
-
40569
41339
  /***/ }),
40570
41340
 
40571
41341
  /***/ 9904: