@catladder/cli 0.0.0-main-18bd4513 → 0.0.0-main-0b5c90c3

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 (46) hide show
  1. package/dist/bundles/catenv/index.js +82 -49
  2. package/dist/bundles/cli/index.js +106 -49
  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 +6 -3
  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/setupContext.js +11 -15
  20. package/dist/cli/src/apps/cli/commands/project/setup/setupContext.js.map +1 -1
  21. package/dist/pipeline/src/catenv/index.d.ts +7 -0
  22. package/dist/pipeline/src/catenv/index.js +12 -0
  23. package/dist/pipeline/src/catenv/index.js.map +1 -0
  24. package/dist/pipeline/src/index.d.ts +1 -0
  25. package/dist/pipeline/src/index.js +1 -0
  26. package/dist/pipeline/src/index.js.map +1 -1
  27. package/dist/pipeline/src/pipeline/generatePipelineFiles.d.ts +2 -1
  28. package/dist/pipeline/src/pipeline/generatePipelineFiles.js +3 -4
  29. package/dist/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
  30. package/dist/pipeline/src/types/config.d.ts +5 -0
  31. package/dist/pipeline/src/types/config.js.map +1 -1
  32. package/dist/pipeline/src/types/hooks.d.ts +26 -0
  33. package/dist/pipeline/src/types/hooks.js +3 -0
  34. package/dist/pipeline/src/types/hooks.js.map +1 -0
  35. package/dist/pipeline/src/utils/writeFiles.d.ts +12 -4
  36. package/dist/pipeline/src/utils/writeFiles.js +42 -27
  37. package/dist/pipeline/src/utils/writeFiles.js.map +1 -1
  38. package/dist/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +1 -1
  40. package/src/apps/catenv/catenv.ts +11 -5
  41. package/src/apps/catenv/printVariables.ts +6 -3
  42. package/src/apps/catenv/writeDotEnvFiles.ts +21 -8
  43. package/src/apps/catenv/writeEnvDTs.ts +15 -6
  44. package/src/apps/cli/commands/project/setup/index.ts +8 -3
  45. package/src/apps/cli/commands/project/setup/logSection.ts +22 -0
  46. package/src/apps/cli/commands/project/setup/setupContext.ts +14 -19
@@ -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
  }
@@ -2696,6 +2695,25 @@ exports.isOfBuildType = isOfBuildType;
2696
2695
 
2697
2696
  /***/ }),
2698
2697
 
2698
+ /***/ 2155:
2699
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2700
+
2701
+ "use strict";
2702
+
2703
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2704
+ exports.createCatenvContext = void 0;
2705
+ const writeFiles_1 = __nccwpck_require__(2228);
2706
+ const createCatenvContext = (config) => {
2707
+ return {
2708
+ config,
2709
+ fileWriter: writeFiles_1.FileWriter.create(config),
2710
+ };
2711
+ };
2712
+ exports.createCatenvContext = createCatenvContext;
2713
+ //# sourceMappingURL=index.js.map
2714
+
2715
+ /***/ }),
2716
+
2699
2717
  /***/ 9609:
2700
2718
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2701
2719
 
@@ -5882,6 +5900,7 @@ __exportStar(__nccwpck_require__(8483), exports);
5882
5900
  __exportStar(__nccwpck_require__(2228), exports);
5883
5901
  __exportStar(__nccwpck_require__(1619), exports);
5884
5902
  __exportStar(__nccwpck_require__(2990), exports);
5903
+ __exportStar(__nccwpck_require__(2155), exports);
5885
5904
  //# sourceMappingURL=index.js.map
5886
5905
 
5887
5906
  /***/ }),
@@ -6617,16 +6636,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
6617
6636
  exports.getGitlabCompletePipeline = exports.generatePipelineFiles = void 0;
6618
6637
  const promises_1 = __nccwpck_require__(3292);
6619
6638
  const path_1 = __nccwpck_require__(1017);
6620
- const writeFiles_1 = __nccwpck_require__(2228);
6621
6639
  const createMainPipeline_1 = __nccwpck_require__(9192);
6622
6640
  const sortGitLabJobDefProps_1 = __nccwpck_require__(2361);
6623
6641
  const CATLADDER_GENERATED_FOLDER = ".catladder-generated";
6624
6642
  const GITLAB_GENERATED_FOLDER = CATLADDER_GENERATED_FOLDER + "/gitlab";
6625
- async function generatePipelineFiles(config, pipelineType) {
6643
+ async function generatePipelineFiles(context, pipelineType) {
6626
6644
  if (pipelineType !== "gitlab") {
6627
6645
  throw new Error("Pipeline type not supported");
6628
6646
  }
6629
- const includes = await getGitlabPipelineIncludes(config);
6647
+ const includes = await getGitlabPipelineIncludes(context.config);
6630
6648
  const mainFile = {
6631
6649
  path: ".gitlab-ci.yml",
6632
6650
  content: {
@@ -6639,7 +6657,7 @@ async function generatePipelineFiles(config, pipelineType) {
6639
6657
  // write files
6640
6658
  await Promise.all(files.map(async ({ path, content }) => {
6641
6659
  await (0, promises_1.mkdir)((0, path_1.dirname)(path), { recursive: true });
6642
- await (0, writeFiles_1.writeYamlfile)(path, content);
6660
+ await context.fileWriter.writeYamlfile(path, content);
6643
6661
  }));
6644
6662
  }
6645
6663
  exports.generatePipelineFiles = generatePipelineFiles;
@@ -7692,29 +7710,9 @@ exports.removeUndefined = removeUndefined;
7692
7710
  "use strict";
7693
7711
 
7694
7712
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7695
- exports.writeYamlfile = exports.yamlStringifyOptions = exports.writeGeneratedFile = exports.getAutoGeneratedHeader = void 0;
7713
+ exports.FileWriter = exports.yamlStringifyOptions = void 0;
7696
7714
  const promises_1 = __nccwpck_require__(3292);
7697
7715
  const yaml_1 = __nccwpck_require__(8033);
7698
- const getAutoGeneratedHeader = (commentChar) => {
7699
- return [
7700
- "-------------------------------------------------",
7701
- `🐱 🔨 This file is generated by catladder`,
7702
- `🚨 Do not edit this file manually 🚨`,
7703
- "-------------------------------------------------",
7704
- ]
7705
- .map((line) => `${commentChar} ${line}`)
7706
- .join("\n")
7707
- .concat("\n");
7708
- };
7709
- exports.getAutoGeneratedHeader = getAutoGeneratedHeader;
7710
- const writeGeneratedFile = async (path, content, { commentChar, }) => {
7711
- await (0, promises_1.writeFile)(path,
7712
- // need to spread out the jobs, forgot why
7713
- [(0, exports.getAutoGeneratedHeader)(commentChar), content].join("\n"), {
7714
- encoding: "utf-8",
7715
- });
7716
- };
7717
- exports.writeGeneratedFile = writeGeneratedFile;
7718
7716
  exports.yamlStringifyOptions = {
7719
7717
  // prevents colapsing long command statements into multiple lines
7720
7718
  lineWidth: 0,
@@ -7723,12 +7721,47 @@ exports.yamlStringifyOptions = {
7723
7721
  // Better readability when bash commands most often use double quotes
7724
7722
  singleQuote: true,
7725
7723
  };
7726
- const writeYamlfile = async (path, data) => {
7727
- await (0, exports.writeGeneratedFile)(path, (0, yaml_1.stringify)(data, exports.yamlStringifyOptions), {
7728
- commentChar: "#",
7729
- });
7730
- };
7731
- exports.writeYamlfile = writeYamlfile;
7724
+ class FileWriter {
7725
+ static create(config) {
7726
+ return new FileWriter(config);
7727
+ }
7728
+ constructor(config) {
7729
+ this.config = config;
7730
+ this.config = config;
7731
+ }
7732
+ async writeTheFile(path, content) {
7733
+ var _a, _b;
7734
+ const transformedContent = await ((_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite({
7735
+ filename: path,
7736
+ content,
7737
+ extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
7738
+ path,
7739
+ }));
7740
+ await (0, promises_1.writeFile)(path, transformedContent !== null && transformedContent !== void 0 ? transformedContent : content, {
7741
+ encoding: "utf-8",
7742
+ });
7743
+ }
7744
+ async writeGeneratedFile(path, content, options) {
7745
+ await this.writeTheFile(path, [this.getAutoGeneratedHeader(options.commentChar), content].join("\n"));
7746
+ }
7747
+ writeYamlfile(path, data) {
7748
+ return this.writeGeneratedFile(path, (0, yaml_1.stringify)(data, exports.yamlStringifyOptions), {
7749
+ commentChar: "#",
7750
+ });
7751
+ }
7752
+ getAutoGeneratedHeader(commentChar) {
7753
+ return [
7754
+ "-------------------------------------------------",
7755
+ `🐱 🔨 This file is generated by catladder`,
7756
+ `🚨 Do not edit this file manually 🚨`,
7757
+ "-------------------------------------------------",
7758
+ ]
7759
+ .map((line) => `${commentChar} ${line}`)
7760
+ .join("\n")
7761
+ .concat("\n");
7762
+ }
7763
+ }
7764
+ exports.FileWriter = FileWriter;
7732
7765
  //# sourceMappingURL=writeFiles.js.map
7733
7766
 
7734
7767
  /***/ }),
@@ -1985,18 +1985,21 @@ const setupAccessTokens_1 = __nccwpck_require__(84195);
1985
1985
  const setupContext_1 = __nccwpck_require__(44310);
1986
1986
  const setupTopic_1 = __nccwpck_require__(84290);
1987
1987
  const setupAgents_1 = __nccwpck_require__(19287);
1988
+ const logSection_1 = __nccwpck_require__(96183);
1988
1989
  const setupProject = async (instance, onlyComponents) => {
1989
1990
  const allContext = await (0, getProjectConfig_1.getAllPipelineContexts)(onlyComponents);
1990
1991
  instance.log("will setup those contexts:");
1991
1992
  allContext.forEach((context) => {
1992
1993
  instance.log(` - ${context.name}:${context.env}`);
1993
1994
  });
1995
+ await (0, logSection_1.logSection)(instance, "base setup", async () => {
1996
+ await (0, setupAccessTokens_1.setupAccessTokens)(instance);
1997
+ await (0, setupTopic_1.setupTopic)(instance);
1998
+ await (0, setupAgents_1.setupAgents)(instance);
1999
+ });
1994
2000
  for (const context of allContext) {
1995
2001
  await (0, setupContext_1.setupContext)(instance, context);
1996
2002
  }
1997
- await (0, setupAccessTokens_1.setupAccessTokens)(instance);
1998
- await (0, setupTopic_1.setupTopic)(instance);
1999
- await (0, setupAgents_1.setupAgents)(instance);
2000
2003
  instance.log("");
2001
2004
  instance.log("gitlab is ready! 🥂");
2002
2005
  instance.log("\n");
@@ -2016,6 +2019,30 @@ exports.setupProject = setupProject;
2016
2019
 
2017
2020
  /***/ }),
2018
2021
 
2022
+ /***/ 96183:
2023
+ /***/ ((__unused_webpack_module, exports) => {
2024
+
2025
+ "use strict";
2026
+
2027
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
2028
+ exports.logSection = void 0;
2029
+ const logSection = async (instance, title, work) => {
2030
+ instance.log("");
2031
+ instance.log("==================================================================================");
2032
+ instance.log("🐱 🔧 " + title + "...");
2033
+ instance.log("");
2034
+ await work();
2035
+ instance.log("");
2036
+ instance.log("✅ " + title + " done!");
2037
+ instance.log("");
2038
+ instance.log("==================================================================================");
2039
+ instance.log("");
2040
+ };
2041
+ exports.logSection = logSection;
2042
+ //# sourceMappingURL=logSection.js.map
2043
+
2044
+ /***/ }),
2045
+
2019
2046
  /***/ 84195:
2020
2047
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2021
2048
 
@@ -2302,22 +2329,18 @@ exports.setupContext = void 0;
2302
2329
  const pipeline_1 = __nccwpck_require__(10603);
2303
2330
  const setupCloudRun_1 = __nccwpck_require__(1082);
2304
2331
  const setupKubernetes_1 = __nccwpck_require__(88412);
2332
+ const logSection_1 = __nccwpck_require__(96183);
2305
2333
  const setupContext = async (instance, context) => {
2306
- var _a, _b;
2307
- instance.log("");
2308
- instance.log("==================================================================================");
2309
- instance.log("🐱 🔧 setting up " + context.env + ":" + context.name + "...");
2310
- instance.log("");
2311
- if ((0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "google-cloudrun")) {
2312
- await (0, setupCloudRun_1.setupCloudRun)(instance, context);
2313
- }
2314
- const deployConfig = (_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config;
2315
- if ((0, pipeline_1.isOfDeployType)(deployConfig, "kubernetes")) {
2316
- await (0, setupKubernetes_1.setupKubernetes)(instance, context);
2317
- }
2318
- instance.log("");
2319
- instance.log("✅ " + context.env + ":" + context.name + " done!");
2320
- instance.log("");
2334
+ await (0, logSection_1.logSection)(instance, "setting up " + context.env + ":" + context.name, async () => {
2335
+ var _a, _b;
2336
+ if ((0, pipeline_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "google-cloudrun")) {
2337
+ await (0, setupCloudRun_1.setupCloudRun)(instance, context);
2338
+ }
2339
+ const deployConfig = (_b = context.deploy) === null || _b === void 0 ? void 0 : _b.config;
2340
+ if ((0, pipeline_1.isOfDeployType)(deployConfig, "kubernetes")) {
2341
+ await (0, setupKubernetes_1.setupKubernetes)(instance, context);
2342
+ }
2343
+ });
2321
2344
  };
2322
2345
  exports.setupContext = setupContext;
2323
2346
  //# sourceMappingURL=setupContext.js.map
@@ -5927,6 +5950,25 @@ exports.isOfBuildType = isOfBuildType;
5927
5950
 
5928
5951
  /***/ }),
5929
5952
 
5953
+ /***/ 32155:
5954
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5955
+
5956
+ "use strict";
5957
+
5958
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
5959
+ exports.createCatenvContext = void 0;
5960
+ const writeFiles_1 = __nccwpck_require__(92228);
5961
+ const createCatenvContext = (config) => {
5962
+ return {
5963
+ config,
5964
+ fileWriter: writeFiles_1.FileWriter.create(config),
5965
+ };
5966
+ };
5967
+ exports.createCatenvContext = createCatenvContext;
5968
+ //# sourceMappingURL=index.js.map
5969
+
5970
+ /***/ }),
5971
+
5930
5972
  /***/ 45449:
5931
5973
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
5932
5974
 
@@ -9113,6 +9155,7 @@ __exportStar(__nccwpck_require__(68483), exports);
9113
9155
  __exportStar(__nccwpck_require__(92228), exports);
9114
9156
  __exportStar(__nccwpck_require__(51619), exports);
9115
9157
  __exportStar(__nccwpck_require__(22990), exports);
9158
+ __exportStar(__nccwpck_require__(32155), exports);
9116
9159
  //# sourceMappingURL=index.js.map
9117
9160
 
9118
9161
  /***/ }),
@@ -9848,16 +9891,15 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
9848
9891
  exports.getGitlabCompletePipeline = exports.generatePipelineFiles = void 0;
9849
9892
  const promises_1 = __nccwpck_require__(73292);
9850
9893
  const path_1 = __nccwpck_require__(71017);
9851
- const writeFiles_1 = __nccwpck_require__(92228);
9852
9894
  const createMainPipeline_1 = __nccwpck_require__(39192);
9853
9895
  const sortGitLabJobDefProps_1 = __nccwpck_require__(72361);
9854
9896
  const CATLADDER_GENERATED_FOLDER = ".catladder-generated";
9855
9897
  const GITLAB_GENERATED_FOLDER = CATLADDER_GENERATED_FOLDER + "/gitlab";
9856
- async function generatePipelineFiles(config, pipelineType) {
9898
+ async function generatePipelineFiles(context, pipelineType) {
9857
9899
  if (pipelineType !== "gitlab") {
9858
9900
  throw new Error("Pipeline type not supported");
9859
9901
  }
9860
- const includes = await getGitlabPipelineIncludes(config);
9902
+ const includes = await getGitlabPipelineIncludes(context.config);
9861
9903
  const mainFile = {
9862
9904
  path: ".gitlab-ci.yml",
9863
9905
  content: {
@@ -9870,7 +9912,7 @@ async function generatePipelineFiles(config, pipelineType) {
9870
9912
  // write files
9871
9913
  await Promise.all(files.map(async ({ path, content }) => {
9872
9914
  await (0, promises_1.mkdir)((0, path_1.dirname)(path), { recursive: true });
9873
- await (0, writeFiles_1.writeYamlfile)(path, content);
9915
+ await context.fileWriter.writeYamlfile(path, content);
9874
9916
  }));
9875
9917
  }
9876
9918
  exports.generatePipelineFiles = generatePipelineFiles;
@@ -10923,29 +10965,9 @@ exports.removeUndefined = removeUndefined;
10923
10965
  "use strict";
10924
10966
 
10925
10967
  Object.defineProperty(exports, "__esModule", ({ value: true }));
10926
- exports.writeYamlfile = exports.yamlStringifyOptions = exports.writeGeneratedFile = exports.getAutoGeneratedHeader = void 0;
10968
+ exports.FileWriter = exports.yamlStringifyOptions = void 0;
10927
10969
  const promises_1 = __nccwpck_require__(73292);
10928
10970
  const yaml_1 = __nccwpck_require__(68033);
10929
- const getAutoGeneratedHeader = (commentChar) => {
10930
- return [
10931
- "-------------------------------------------------",
10932
- `🐱 🔨 This file is generated by catladder`,
10933
- `🚨 Do not edit this file manually 🚨`,
10934
- "-------------------------------------------------",
10935
- ]
10936
- .map((line) => `${commentChar} ${line}`)
10937
- .join("\n")
10938
- .concat("\n");
10939
- };
10940
- exports.getAutoGeneratedHeader = getAutoGeneratedHeader;
10941
- const writeGeneratedFile = async (path, content, { commentChar, }) => {
10942
- await (0, promises_1.writeFile)(path,
10943
- // need to spread out the jobs, forgot why
10944
- [(0, exports.getAutoGeneratedHeader)(commentChar), content].join("\n"), {
10945
- encoding: "utf-8",
10946
- });
10947
- };
10948
- exports.writeGeneratedFile = writeGeneratedFile;
10949
10971
  exports.yamlStringifyOptions = {
10950
10972
  // prevents colapsing long command statements into multiple lines
10951
10973
  lineWidth: 0,
@@ -10954,12 +10976,47 @@ exports.yamlStringifyOptions = {
10954
10976
  // Better readability when bash commands most often use double quotes
10955
10977
  singleQuote: true,
10956
10978
  };
10957
- const writeYamlfile = async (path, data) => {
10958
- await (0, exports.writeGeneratedFile)(path, (0, yaml_1.stringify)(data, exports.yamlStringifyOptions), {
10959
- commentChar: "#",
10960
- });
10961
- };
10962
- exports.writeYamlfile = writeYamlfile;
10979
+ class FileWriter {
10980
+ static create(config) {
10981
+ return new FileWriter(config);
10982
+ }
10983
+ constructor(config) {
10984
+ this.config = config;
10985
+ this.config = config;
10986
+ }
10987
+ async writeTheFile(path, content) {
10988
+ var _a, _b;
10989
+ const transformedContent = await ((_a = this.config.hooks) === null || _a === void 0 ? void 0 : _a.transformFileBeforeWrite({
10990
+ filename: path,
10991
+ content,
10992
+ extension: (_b = path.split(".").pop()) !== null && _b !== void 0 ? _b : "",
10993
+ path,
10994
+ }));
10995
+ await (0, promises_1.writeFile)(path, transformedContent !== null && transformedContent !== void 0 ? transformedContent : content, {
10996
+ encoding: "utf-8",
10997
+ });
10998
+ }
10999
+ async writeGeneratedFile(path, content, options) {
11000
+ await this.writeTheFile(path, [this.getAutoGeneratedHeader(options.commentChar), content].join("\n"));
11001
+ }
11002
+ writeYamlfile(path, data) {
11003
+ return this.writeGeneratedFile(path, (0, yaml_1.stringify)(data, exports.yamlStringifyOptions), {
11004
+ commentChar: "#",
11005
+ });
11006
+ }
11007
+ getAutoGeneratedHeader(commentChar) {
11008
+ return [
11009
+ "-------------------------------------------------",
11010
+ `🐱 🔨 This file is generated by catladder`,
11011
+ `🚨 Do not edit this file manually 🚨`,
11012
+ "-------------------------------------------------",
11013
+ ]
11014
+ .map((line) => `${commentChar} ${line}`)
11015
+ .join("\n")
11016
+ .concat("\n");
11017
+ }
11018
+ }
11019
+ exports.FileWriter = FileWriter;
10963
11020
  //# sourceMappingURL=writeFiles.js.map
10964
11021
 
10965
11022
  /***/ }),
@@ -11,11 +11,12 @@ exports.default = async (choice) => {
11
11
  if (!config) {
12
12
  return;
13
13
  }
14
+ const context = (0, pipeline_1.createCatenvContext)(config);
14
15
  await Promise.all([
15
- (0, pipeline_1.generatePipelineFiles)(config, (_a = config.pipelineType) !== null && _a !== void 0 ? _a : "gitlab"),
16
- (0, writeDotEnvFiles_1.writeDotEnvFiles)(config, choice),
17
- (0, writeEnvDTs_1.writeDTsFiles)(config, choice),
18
- (0, printVariables_1.printVariables)(config, choice),
16
+ (0, pipeline_1.generatePipelineFiles)(context, (_a = config.pipelineType) !== null && _a !== void 0 ? _a : "gitlab"),
17
+ (0, writeDotEnvFiles_1.writeDotEnvFiles)(context, choice),
18
+ (0, writeEnvDTs_1.writeDTsFiles)(context, choice),
19
+ (0, printVariables_1.printVariables)(context, choice),
19
20
  ]);
20
21
  };
21
22
  //# sourceMappingURL=catenv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"catenv.js","sourceRoot":"","sources":["../../../../../src/apps/catenv/catenv.ts"],"names":[],"mappings":";;AAAA,oEAAiE;AACjE,qDAAkD;AAElD,yDAAsD;AACtD,+CAA8C;AAC9C,kDAA4D;AAE5D,kBAAe,KAAK,EAAE,MAAe,EAAE,EAAE;;IACvC,MAAM,MAAM,GAAG,MAAM,IAAA,mCAAgB,GAAE,CAAC;IACxC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAA,gCAAqB,EAAC,MAAM,EAAE,MAAA,MAAM,CAAC,YAAY,mCAAI,QAAQ,CAAC;QAC9D,IAAA,mCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC;QAEhC,IAAA,2BAAa,EAAC,MAAM,EAAE,MAAM,CAAC;QAE7B,IAAA,+BAAc,EAAC,MAAM,EAAE,MAAM,CAAC;KAC/B,CAAC,CAAC;AACL,CAAC,CAAC"}
1
+ {"version":3,"file":"catenv.js","sourceRoot":"","sources":["../../../../../src/apps/catenv/catenv.ts"],"names":[],"mappings":";;AAAA,oEAAiE;AACjE,qDAAkD;AAElD,yDAAsD;AACtD,+CAA8C;AAC9C,kDAI6B;AAE7B,kBAAe,KAAK,EAAE,MAAe,EAAE,EAAE;;IACvC,MAAM,MAAM,GAAG,MAAM,IAAA,mCAAgB,GAAE,CAAC;IACxC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,IAAA,8BAAmB,EAAC,MAAM,CAAC,CAAC;IAE5C,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAA,gCAAqB,EAAC,OAAO,EAAE,MAAA,MAAM,CAAC,YAAY,mCAAI,QAAQ,CAAC;QAC/D,IAAA,mCAAgB,EAAC,OAAO,EAAE,MAAM,CAAC;QAEjC,IAAA,2BAAa,EAAC,OAAO,EAAE,MAAM,CAAC;QAE9B,IAAA,+BAAc,EAAC,OAAO,EAAE,MAAM,CAAC;KAChC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
- import type { Config } from "../../../../pipeline/src/index.js";
1
+ import type { CatenvContext } from "../../../../pipeline/src/index.js";
2
2
  import type { Choice } from "./types";
3
- export declare const printVariables: (config: Config, choice?: Choice) => Promise<void>;
3
+ export declare const printVariables: (context: CatenvContext, choice?: Choice) => Promise<void>;
@@ -37,8 +37,8 @@ const getAllVariablesToPrint = async (config, choice) => {
37
37
  }, Promise.resolve({}));
38
38
  }
39
39
  };
40
- const printVariables = async (config, choice) => {
41
- const variables = await getAllVariablesToPrint(config, choice);
40
+ const printVariables = async (context, choice) => {
41
+ const variables = await getAllVariablesToPrint(context.config, choice);
42
42
  console.log(makeExportKeyValuestring(variables));
43
43
  };
44
44
  exports.printVariables = printVariables;
@@ -1 +1 @@
1
- {"version":3,"file":"printVariables.js","sourceRoot":"","sources":["../../../../../src/apps/catenv/printVariables.ts"],"names":[],"mappings":";;;AACA,oEAAmE;AAEnE,mCAIiB;AAEjB,MAAM,sBAAsB,GAAG,KAAK,EAAE,MAAc,EAAE,MAAe,EAAE,EAAE;;IACvE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,2CAAmC,EACzE,MAAM,EACN,MAAM,CACP,CAAC;IAEF,IAAI,gBAAgB,EAAE,CAAC;QACrB,wCAAwC;QACxC,IAAI,MAAA,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,MAAM,mCAAI,IAAI,EAAE,CAAC;YACvD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,MAAM,IAAA,qCAAkB,EAAC,IAAI,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,6DAA6D;QAC7D,0EAA0E;QAC1E,mCAAmC;QACnC,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,CAChD,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE;;YAC3B,wCAAwC;YACxC,IAAI,MAAA,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,MAAM,mCAAI,IAAI,EAAE,CAAC;gBACpD,OAAO,MAAM,GAAG,CAAC;YACnB,CAAC;YACD,MAAM,UAAU,GAAG,MAAM,IAAA,qCAAkB,EAAC,IAAI,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;YACtE,OAAO,UAAU,CAAC,mBAAmB,CAAC,CAAC;YACvC,OAAO;gBACL,GAAG,CAAC,MAAM,GAAG,CAAC;gBACd,GAAG,UAAU;gBACb,qCAAqC;gBACrC,GAAG,MAAM,CAAC,WAAW,CACnB,MAAM,CAAC,OAAO,CAAC,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AAPW,QAAA,cAAc,kBAOzB;AAEF,MAAM,wBAAwB,GAAG,CAAC,SAAiC,EAAE,EAAE,CACrE,IAAA,0BAAkB,EAAC,SAAS,EAAE;IAC5B,SAAS,EAAE,SAAS;IACpB,aAAa,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;CACvC,CAAC,CAAC"}
@@ -1,3 +1,3 @@
1
- import { type Config } from "../../../../pipeline/src/index.js";
2
1
  import type { Choice } from "./types";
3
- export declare const writeDotEnvFiles: (config: Config, choice?: Choice) => Promise<void>;
2
+ import type { CatenvContext } from "../../../../pipeline/src/index.js";
3
+ export declare const writeDotEnvFiles: (context: CatenvContext, choice?: Choice) => Promise<void>;
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writeDotEnvFiles = void 0;
4
- const pipeline_1 = require("../../../../pipeline/src/index.js");
5
4
  const path_1 = require("path");
6
5
  const getProjectConfig_1 = require("../../config/getProjectConfig");
7
6
  const projects_1 = require("../../utils/projects");
8
7
  const utils_1 = require("./utils");
9
- const writeDotEnvFiles = async (config, choice) => {
10
- const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice);
11
- const componentsWithEnabledDotEnvWrite = Object.entries(config.components)
8
+ const writeDotEnvFiles = async (context, choice) => {
9
+ const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(context.config, choice);
10
+ const componentsWithEnabledDotEnvWrite = Object.entries(context.config.components)
12
11
  .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"
13
12
  .map(([componentName]) => componentName);
14
13
  const componentsToActuallyWriteDotEnvNow = currentComponent
@@ -20,9 +19,9 @@ const writeDotEnvFiles = async (config, choice) => {
20
19
  for (const componentName of componentsToActuallyWriteDotEnvNow) {
21
20
  const variables = await (0, getProjectConfig_1.getEnvVarsResolved)(null, env, componentName);
22
21
  delete variables["_ALL_ENV_VAR_KEYS"];
23
- const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, config, componentName);
22
+ const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, context.config, componentName);
24
23
  const filePath = (0, path_1.join)(componentDir, ".env");
25
- await (0, pipeline_1.writeGeneratedFile)(filePath, (0, utils_1.makeKeyValueString)(variables), {
24
+ await context.fileWriter.writeGeneratedFile(filePath, (0, utils_1.makeKeyValueString)(variables), {
26
25
  commentChar: "#",
27
26
  });
28
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"writeDotEnvFiles.js","sourceRoot":"","sources":["../../../../../src/apps/catenv/writeDotEnvFiles.ts"],"names":[],"mappings":";;;AAAA,kDAAsE;AACtE,+BAA4B;AAC5B,oEAAmE;AACnE,mDAAkD;AAElD,mCAIiB;AAEV,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAc,EAAE,MAAe,EAAE,EAAE;IACxE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,2CAAmC,EACzE,MAAM,EACN,MAAM,CACP,CAAC;IAEF,MAAM,gCAAgC,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;SACvE,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,WAAC,OAAA,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,mCAAI,IAAI,CAAA,EAAA,CAAC,CAAC,8BAA8B;SACnF,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC;IAE3C,MAAM,kCAAkC,GAAG,gBAAgB;QACzD,CAAC,CAAC,gCAAgC,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YAC3D,CAAC,CAAC,CAAC,gBAAgB,CAAC;YACpB,CAAC,CAAC,EAAE;QACN,CAAC,CAAC,gCAAgC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,IAA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AC;IAE3C,MAAM,kCAAkC,GAAG,gBAAgB;QACzD,CAAC,CAAC,gCAAgC,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YAC3D,CAAC,CAAC,CAAC,gBAAgB,CAAC;YACpB,CAAC,CAAC,EAAE;QACN,CAAC,CAAC,gCAAgC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAU,GAAE,CAAC;IAEnC,KAAK,MAAM,aAAa,IAAI,kCAAkC,EAAE,CAAC;QAC/D,MAAM,SAAS,GAAG,MAAM,IAAA,qCAAkB,EAAC,IAAI,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC;QACrE,OAAO,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACtC,MAAM,YAAY,GAAG,IAAA,4BAAoB,EACvC,OAAO,EACP,OAAO,CAAC,MAAM,EACd,aAAa,CACd,CAAC;QACF,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAE5C,MAAM,OAAO,CAAC,UAAU,CAAC,kBAAkB,CACzC,QAAQ,EACR,IAAA,0BAAkB,EAAC,SAAS,CAAC,EAC7B;YACE,WAAW,EAAE,GAAG;SACjB,CACF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAxCW,QAAA,gBAAgB,oBAwC3B"}
@@ -1,3 +1,3 @@
1
- import { type Config } from "../../../../pipeline/src/index.js";
1
+ import type { CatenvContext } from "../../../../pipeline/src/index.js";
2
2
  import type { Choice } from "./types";
3
- export declare const writeDTsFiles: (config: Config, choice?: Choice) => Promise<void>;
3
+ export declare const writeDTsFiles: (context: CatenvContext, choice?: Choice) => Promise<void>;
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writeDTsFiles = void 0;
4
- const pipeline_1 = require("../../../../pipeline/src/index.js");
5
4
  const path_1 = require("path");
6
5
  const getProjectConfig_1 = require("../../config/getProjectConfig");
7
6
  const projects_1 = require("../../utils/projects");
8
7
  const utils_1 = require("./utils");
9
- const writeDTsFiles = async (config, choice) => {
10
- const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice);
11
- const componentsWithEnabledEnvDTsWrite = Object.entries(config.components)
8
+ const writeDTsFiles = async (context, choice) => {
9
+ const { env, currentComponent } = await (0, utils_1.getCurrentComponentAndEnvFromChoice)(context.config, choice);
10
+ const componentsWithEnabledEnvDTsWrite = Object.entries(context.config.components)
12
11
  .filter(([, component]) => { var _a; return (_a = component === null || component === void 0 ? void 0 : component.envDTs) !== null && _a !== void 0 ? _a : true; })
13
12
  .map(([componentName]) => componentName);
14
13
  const componentsToActuallyWriteEnvDts = currentComponent
@@ -20,9 +19,9 @@ const writeDTsFiles = async (config, choice) => {
20
19
  for (const componentName of componentsToActuallyWriteEnvDts) {
21
20
  const envNames = await getEnvsForDTs(env, componentName);
22
21
  const envDTsContent = createEnvDTsContent(envNames);
23
- const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, config, componentName);
22
+ const componentDir = (0, utils_1.getComponentFullPath)(gitRoot, context.config, componentName);
24
23
  const filePath = (0, path_1.join)(componentDir, "env.d.ts");
25
- await (0, pipeline_1.writeGeneratedFile)(filePath, envDTsContent, {
24
+ await context.fileWriter.writeGeneratedFile(filePath, envDTsContent, {
26
25
  commentChar: "//",
27
26
  });
28
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"writeEnvDTs.js","sourceRoot":"","sources":["../../../../../src/apps/catenv/writeEnvDTs.ts"],"names":[],"mappings":";;;AAAA,kDAAsE;AACtE,+BAA4B;AAC5B,oEAA+D;AAC/D,mDAAkD;AAElD,mCAGiB;AAEV,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAE,MAAe,EAAE,EAAE;IACrE,MAAM,EAAE,GAAG,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,2CAAmC,EACzE,MAAM,EACN,MAAM,CACP,CAAC;IAEF,MAAM,gCAAgC,GAAG,MAA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AAG,CAAC;SACjB,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC,CACjC,CAAC;IACF,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAkB;IAC7C,OAAO;;;;;;;;;EASP,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;CAI3D,CAAC;AACF,CAAC"}
@@ -6,18 +6,21 @@ const setupAccessTokens_1 = require("./setupAccessTokens");
6
6
  const setupContext_1 = require("./setupContext");
7
7
  const setupTopic_1 = require("./setupTopic");
8
8
  const setupAgents_1 = require("./setupAgents");
9
+ const logSection_1 = require("./logSection");
9
10
  const setupProject = async (instance, onlyComponents) => {
10
11
  const allContext = await (0, getProjectConfig_1.getAllPipelineContexts)(onlyComponents);
11
12
  instance.log("will setup those contexts:");
12
13
  allContext.forEach((context) => {
13
14
  instance.log(` - ${context.name}:${context.env}`);
14
15
  });
16
+ await (0, logSection_1.logSection)(instance, "base setup", async () => {
17
+ await (0, setupAccessTokens_1.setupAccessTokens)(instance);
18
+ await (0, setupTopic_1.setupTopic)(instance);
19
+ await (0, setupAgents_1.setupAgents)(instance);
20
+ });
15
21
  for (const context of allContext) {
16
22
  await (0, setupContext_1.setupContext)(instance, context);
17
23
  }
18
- await (0, setupAccessTokens_1.setupAccessTokens)(instance);
19
- await (0, setupTopic_1.setupTopic)(instance);
20
- await (0, setupAgents_1.setupAgents)(instance);
21
24
  instance.log("");
22
25
  instance.log("gitlab is ready! 🥂");
23
26
  instance.log("\n");