@catladder/cli 0.0.0-main-0acdca98 → 0.0.0-main-e0262e40

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.
@@ -6,6 +6,79 @@
6
6
 
7
7
  "use strict";
8
8
 
9
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
10
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11
+ return new (P || (P = Promise))(function (resolve, reject) {
12
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
13
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
14
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
15
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
16
+ });
17
+ };
18
+ var __generator = (this && this.__generator) || function (thisArg, body) {
19
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
20
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
21
+ function verb(n) { return function (v) { return step([n, v]); }; }
22
+ function step(op) {
23
+ if (f) throw new TypeError("Generator is already executing.");
24
+ while (_) try {
25
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
26
+ if (y = 0, t) op = [op[0] & 2, t.value];
27
+ switch (op[0]) {
28
+ case 0: case 1: t = op; break;
29
+ case 4: _.label++; return { value: op[1], done: false };
30
+ case 5: _.label++; y = op[1]; op = [0]; continue;
31
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
32
+ default:
33
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
34
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
35
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
36
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
37
+ if (t[2]) _.ops.pop();
38
+ _.trys.pop(); continue;
39
+ }
40
+ op = body.call(thisArg, _);
41
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
42
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
43
+ }
44
+ };
45
+ exports.__esModule = true;
46
+ var getProjectConfig_1 = __nccwpck_require__(4146);
47
+ var printVariables_1 = __nccwpck_require__(7770);
48
+ var writeDotEnvFiles_1 = __nccwpck_require__(4295);
49
+ var writeEnvDTs_1 = __nccwpck_require__(4615);
50
+ exports["default"] = (function (choice) { return __awaiter(void 0, void 0, void 0, function () {
51
+ var config;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0: return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
55
+ case 1:
56
+ config = _a.sent();
57
+ if (!config) {
58
+ return [2 /*return*/];
59
+ }
60
+ return [4 /*yield*/, (0, printVariables_1.printVariables)(config, choice)];
61
+ case 2:
62
+ _a.sent();
63
+ return [4 /*yield*/, (0, writeDotEnvFiles_1.writeDotEnvFiles)(config, choice)];
64
+ case 3:
65
+ _a.sent();
66
+ return [4 /*yield*/, (0, writeEnvDTs_1.writeDTsFiles)(config, choice)];
67
+ case 4:
68
+ _a.sent();
69
+ return [2 /*return*/];
70
+ }
71
+ });
72
+ }); });
73
+ //# sourceMappingURL=catenv.js.map
74
+
75
+ /***/ }),
76
+
77
+ /***/ 7770:
78
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
79
+
80
+ "use strict";
81
+
9
82
  var __assign = (this && this.__assign) || function () {
10
83
  __assign = Object.assign || function(t) {
11
84
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -54,48 +127,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
54
127
  }
55
128
  };
56
129
  exports.__esModule = true;
130
+ exports.printVariables = void 0;
57
131
  var getProjectConfig_1 = __nccwpck_require__(4146);
58
- var projects_1 = __nccwpck_require__(1619);
59
- var path_1 = __nccwpck_require__(1017);
60
- var getCurrentComponentName = function (components) { return __awaiter(void 0, void 0, void 0, function () {
61
- var gitRoot, currentDir;
62
- return __generator(this, function (_a) {
63
- switch (_a.label) {
64
- case 0: return [4 /*yield*/, (0, projects_1.getGitRoot)()];
65
- case 1:
66
- gitRoot = _a.sent();
67
- currentDir = process.cwd();
68
- return [2 /*return*/, Object.keys(components).find(function (c) {
69
- return currentDir.startsWith((0, path_1.join)(gitRoot, components[c].dir));
70
- })];
71
- }
72
- });
73
- }); };
74
- var sanitizeEnvVarName = function (name) { return name.replace(/[\s\-.]+/g, "_"); };
132
+ var utils_1 = __nccwpck_require__(4640);
75
133
  var getAllVariablesToPrint = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
76
- var env, components, currentComponent, _a, variables;
77
- var _b, _c;
78
- return __generator(this, function (_d) {
79
- switch (_d.label) {
80
- case 0:
81
- env = (_b = choice === null || choice === void 0 ? void 0 : choice.env) !== null && _b !== void 0 ? _b : "local";
82
- components = config.components;
83
- if (!((_c = choice === null || choice === void 0 ? void 0 : choice.componentName) !== null && _c !== void 0)) return [3 /*break*/, 1];
84
- _a = _c;
85
- return [3 /*break*/, 3];
86
- case 1: return [4 /*yield*/, getCurrentComponentName(components)];
87
- case 2:
88
- _a = (_d.sent());
89
- _d.label = 3;
90
- case 3:
91
- currentComponent = _a;
134
+ var _a, env, currentComponent, variables;
135
+ return __generator(this, function (_b) {
136
+ switch (_b.label) {
137
+ case 0: return [4 /*yield*/, (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice)];
138
+ case 1:
139
+ _a = _b.sent(), env = _a.env, currentComponent = _a.currentComponent;
92
140
  variables = {};
93
- if (!currentComponent) return [3 /*break*/, 5];
141
+ if (!currentComponent) return [3 /*break*/, 3];
94
142
  return [4 /*yield*/, (0, getProjectConfig_1.getEnvVarsResolved)(null, env, currentComponent)];
95
- case 4:
96
- variables = _d.sent();
97
- return [3 /*break*/, 7];
98
- case 5: return [4 /*yield*/, Object.keys(components).reduce(function (acc, componentName) { return __awaiter(void 0, void 0, void 0, function () {
143
+ case 2:
144
+ variables = _b.sent();
145
+ return [3 /*break*/, 5];
146
+ case 3: return [4 /*yield*/, Object.keys(config.components).reduce(function (acc, componentName) { return __awaiter(void 0, void 0, void 0, function () {
99
147
  var subappvars, _a;
100
148
  return __generator(this, function (_b) {
101
149
  switch (_b.label) {
@@ -107,47 +155,376 @@ var getAllVariablesToPrint = function (config, choice) { return __awaiter(void 0
107
155
  case 2: return [2 /*return*/, __assign.apply(void 0, [__assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_b.sent())])), subappvars]), Object.fromEntries(Object.entries(subappvars).map(function (_a) {
108
156
  var key = _a[0], value = _a[1];
109
157
  return [
110
- "".concat(sanitizeEnvVarName(componentName.toUpperCase()), "_").concat(key),
158
+ "".concat((0, utils_1.sanitizeEnvVarName)(componentName.toUpperCase()), "_").concat(key),
111
159
  value,
112
160
  ];
113
161
  }))])];
114
162
  }
115
163
  });
116
164
  }); }, {})];
117
- case 6:
165
+ case 4:
118
166
  // when in a monorep and not in a subapp, merge all env vars.
119
167
  // this is not 100% correct, but better than not exporting any vars at all
120
168
  // so we also add prefixed variants
121
- variables = _d.sent();
122
- _d.label = 7;
123
- case 7: return [2 /*return*/, variables];
169
+ variables = _b.sent();
170
+ _b.label = 5;
171
+ case 5: return [2 /*return*/, variables];
124
172
  }
125
173
  });
126
174
  }); };
127
- exports["default"] = (function (choice) { return __awaiter(void 0, void 0, void 0, function () {
128
- var config, variables;
175
+ var printVariables = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
176
+ var variables;
129
177
  return __generator(this, function (_a) {
130
178
  switch (_a.label) {
131
- case 0: return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
179
+ case 0: return [4 /*yield*/, getAllVariablesToPrint(config, choice)];
132
180
  case 1:
133
- config = _a.sent();
134
- if (!config) {
135
- return [2 /*return*/];
136
- }
137
- return [4 /*yield*/, getAllVariablesToPrint(config, choice)];
138
- case 2:
139
181
  variables = _a.sent();
140
- console.log(Object.entries(variables)
182
+ console.log(makeExportKeyValuestring(variables));
183
+ return [2 /*return*/];
184
+ }
185
+ });
186
+ }); };
187
+ exports.printVariables = printVariables;
188
+ var makeExportKeyValuestring = function (variables) {
189
+ return (0, utils_1.makeKeyValueString)(variables, "export ");
190
+ };
191
+ //# sourceMappingURL=printVariables.js.map
192
+
193
+ /***/ }),
194
+
195
+ /***/ 4640:
196
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
197
+
198
+ "use strict";
199
+
200
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
201
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
202
+ return new (P || (P = Promise))(function (resolve, reject) {
203
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
204
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
205
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
206
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
207
+ });
208
+ };
209
+ var __generator = (this && this.__generator) || function (thisArg, body) {
210
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
211
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
212
+ function verb(n) { return function (v) { return step([n, v]); }; }
213
+ function step(op) {
214
+ if (f) throw new TypeError("Generator is already executing.");
215
+ while (_) try {
216
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
217
+ if (y = 0, t) op = [op[0] & 2, t.value];
218
+ switch (op[0]) {
219
+ case 0: case 1: t = op; break;
220
+ case 4: _.label++; return { value: op[1], done: false };
221
+ case 5: _.label++; y = op[1]; op = [0]; continue;
222
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
223
+ default:
224
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
225
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
226
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
227
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
228
+ if (t[2]) _.ops.pop();
229
+ _.trys.pop(); continue;
230
+ }
231
+ op = body.call(thisArg, _);
232
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
233
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
234
+ }
235
+ };
236
+ exports.__esModule = true;
237
+ exports.sanitizeEnvVarName = exports.sanitizeMultiLine = exports.makeKeyValueString = exports.getCurrentComponentAndEnvFromChoice = exports.getComponentFullPath = void 0;
238
+ var path_1 = __nccwpck_require__(1017);
239
+ var projects_1 = __nccwpck_require__(1619);
240
+ var getComponentFullPath = function (gitRoot, config, componentName) {
241
+ return (0, path_1.join)(gitRoot, config.components[componentName].dir);
242
+ };
243
+ exports.getComponentFullPath = getComponentFullPath;
244
+ var getCurrentComponentName = function (config) { return __awaiter(void 0, void 0, void 0, function () {
245
+ var gitRoot, currentDir;
246
+ return __generator(this, function (_a) {
247
+ switch (_a.label) {
248
+ case 0: return [4 /*yield*/, (0, projects_1.getGitRoot)()];
249
+ case 1:
250
+ gitRoot = _a.sent();
251
+ currentDir = process.cwd();
252
+ return [2 /*return*/, Object.keys(config.components).find(function (c) {
253
+ return currentDir.startsWith((0, exports.getComponentFullPath)(gitRoot, config, c));
254
+ })];
255
+ }
256
+ });
257
+ }); };
258
+ var getCurrentComponentAndEnvFromChoice = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
259
+ var env, currentComponent, _a;
260
+ var _b, _c;
261
+ return __generator(this, function (_d) {
262
+ switch (_d.label) {
263
+ case 0:
264
+ env = (_b = choice === null || choice === void 0 ? void 0 : choice.env) !== null && _b !== void 0 ? _b : "local";
265
+ if (!((_c = choice === null || choice === void 0 ? void 0 : choice.componentName) !== null && _c !== void 0)) return [3 /*break*/, 1];
266
+ _a = _c;
267
+ return [3 /*break*/, 3];
268
+ case 1: return [4 /*yield*/, getCurrentComponentName(config)];
269
+ case 2:
270
+ _a = (_d.sent());
271
+ _d.label = 3;
272
+ case 3:
273
+ currentComponent = _a;
274
+ return [2 /*return*/, {
275
+ currentComponent: currentComponent,
276
+ env: env
277
+ }];
278
+ }
279
+ });
280
+ }); };
281
+ exports.getCurrentComponentAndEnvFromChoice = getCurrentComponentAndEnvFromChoice;
282
+ var makeKeyValueString = function (variables, keyPrefix) {
283
+ if (keyPrefix === void 0) { keyPrefix = ""; }
284
+ return Object.entries(variables)
285
+ .map(function (_a) {
286
+ var key = _a[0], value = _a[1];
287
+ return "".concat(keyPrefix).concat(key, "='").concat(value, "'");
288
+ })
289
+ .join("\n");
290
+ };
291
+ exports.makeKeyValueString = makeKeyValueString;
292
+ var sanitizeMultiLine = function (variables) {
293
+ return Object.fromEntries(Object.entries(variables).map(function (_a) {
294
+ var key = _a[0], value = _a[1];
295
+ return [
296
+ key,
297
+ value.replaceAll("\n", "\\n"),
298
+ ];
299
+ }));
300
+ };
301
+ exports.sanitizeMultiLine = sanitizeMultiLine;
302
+ var sanitizeEnvVarName = function (name) {
303
+ return name.replace(/[\s\-.]+/g, "_");
304
+ };
305
+ exports.sanitizeEnvVarName = sanitizeEnvVarName;
306
+ //# sourceMappingURL=utils.js.map
307
+
308
+ /***/ }),
309
+
310
+ /***/ 4295:
311
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
312
+
313
+ "use strict";
314
+
315
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
316
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
317
+ return new (P || (P = Promise))(function (resolve, reject) {
318
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
319
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
320
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
321
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
322
+ });
323
+ };
324
+ var __generator = (this && this.__generator) || function (thisArg, body) {
325
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
326
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
327
+ function verb(n) { return function (v) { return step([n, v]); }; }
328
+ function step(op) {
329
+ if (f) throw new TypeError("Generator is already executing.");
330
+ while (_) try {
331
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
332
+ if (y = 0, t) op = [op[0] & 2, t.value];
333
+ switch (op[0]) {
334
+ case 0: case 1: t = op; break;
335
+ case 4: _.label++; return { value: op[1], done: false };
336
+ case 5: _.label++; y = op[1]; op = [0]; continue;
337
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
338
+ default:
339
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
340
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
341
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
342
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
343
+ if (t[2]) _.ops.pop();
344
+ _.trys.pop(); continue;
345
+ }
346
+ op = body.call(thisArg, _);
347
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
348
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
349
+ }
350
+ };
351
+ exports.__esModule = true;
352
+ exports.writeDotEnvFiles = void 0;
353
+ var fs_extra_1 = __nccwpck_require__(5501);
354
+ var path_1 = __nccwpck_require__(1017);
355
+ var getProjectConfig_1 = __nccwpck_require__(4146);
356
+ var projects_1 = __nccwpck_require__(1619);
357
+ var utils_1 = __nccwpck_require__(4640);
358
+ var writeDotEnvFiles = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
359
+ var _a, env, currentComponent, componentsWithEnabledDotEnvWrite, componentsToActuallyWriteDotEnvNow, gitRoot, _i, componentsToActuallyWriteDotEnvNow_1, componentName, variables, componentDir, filePath, variablesSanitized;
360
+ return __generator(this, function (_b) {
361
+ switch (_b.label) {
362
+ case 0: return [4 /*yield*/, (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice)];
363
+ case 1:
364
+ _a = _b.sent(), env = _a.env, currentComponent = _a.currentComponent;
365
+ componentsWithEnabledDotEnvWrite = Object.entries(config.components)
366
+ .filter(function (_a) {
367
+ var component = _a[1];
368
+ return component === null || component === void 0 ? void 0 : component.dotEnv;
369
+ })
141
370
  .map(function (_a) {
142
- var key = _a[0], value = _a[1];
143
- return "export ".concat(key, "='").concat(value, "'");
371
+ var componentName = _a[0];
372
+ return componentName;
373
+ });
374
+ componentsToActuallyWriteDotEnvNow = currentComponent
375
+ ? componentsWithEnabledDotEnvWrite.includes(currentComponent)
376
+ ? [currentComponent]
377
+ : []
378
+ : componentsWithEnabledDotEnvWrite;
379
+ return [4 /*yield*/, (0, projects_1.getGitRoot)()];
380
+ case 2:
381
+ gitRoot = _b.sent();
382
+ _i = 0, componentsToActuallyWriteDotEnvNow_1 = componentsToActuallyWriteDotEnvNow;
383
+ _b.label = 3;
384
+ case 3:
385
+ if (!(_i < componentsToActuallyWriteDotEnvNow_1.length)) return [3 /*break*/, 7];
386
+ componentName = componentsToActuallyWriteDotEnvNow_1[_i];
387
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVarsResolved)(null, env, componentName)];
388
+ case 4:
389
+ variables = _b.sent();
390
+ componentDir = (0, utils_1.getComponentFullPath)(gitRoot, config, componentName);
391
+ filePath = (0, path_1.join)(componentDir, ".env");
392
+ variablesSanitized = (0, utils_1.sanitizeMultiLine)(variables);
393
+ return [4 /*yield*/, (0, fs_extra_1.writeFile)(filePath, "# automatically created by catladder. Do not modify!\n\n" +
394
+ (0, utils_1.makeKeyValueString)(variablesSanitized))];
395
+ case 5:
396
+ _b.sent();
397
+ _b.label = 6;
398
+ case 6:
399
+ _i++;
400
+ return [3 /*break*/, 3];
401
+ case 7: return [2 /*return*/];
402
+ }
403
+ });
404
+ }); };
405
+ exports.writeDotEnvFiles = writeDotEnvFiles;
406
+ //# sourceMappingURL=writeDotEnvFiles.js.map
407
+
408
+ /***/ }),
409
+
410
+ /***/ 4615:
411
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
412
+
413
+ "use strict";
414
+
415
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
416
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
417
+ return new (P || (P = Promise))(function (resolve, reject) {
418
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
419
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
420
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
421
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
422
+ });
423
+ };
424
+ var __generator = (this && this.__generator) || function (thisArg, body) {
425
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
426
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
427
+ function verb(n) { return function (v) { return step([n, v]); }; }
428
+ function step(op) {
429
+ if (f) throw new TypeError("Generator is already executing.");
430
+ while (_) try {
431
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
432
+ if (y = 0, t) op = [op[0] & 2, t.value];
433
+ switch (op[0]) {
434
+ case 0: case 1: t = op; break;
435
+ case 4: _.label++; return { value: op[1], done: false };
436
+ case 5: _.label++; y = op[1]; op = [0]; continue;
437
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
438
+ default:
439
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
440
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
441
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
442
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
443
+ if (t[2]) _.ops.pop();
444
+ _.trys.pop(); continue;
445
+ }
446
+ op = body.call(thisArg, _);
447
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
448
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
449
+ }
450
+ };
451
+ exports.__esModule = true;
452
+ exports.writeDTsFiles = void 0;
453
+ var fs_extra_1 = __nccwpck_require__(5501);
454
+ var path_1 = __nccwpck_require__(1017);
455
+ var getProjectConfig_1 = __nccwpck_require__(4146);
456
+ var projects_1 = __nccwpck_require__(1619);
457
+ var utils_1 = __nccwpck_require__(4640);
458
+ var writeDTsFiles = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
459
+ var _a, env, currentComponent, componentsWithEnabledEnvDTsWrite, componentsToActuallyWriteDotEnvNow, gitRoot, _i, componentsToActuallyWriteDotEnvNow_1, componentName, envNames, envDTsContent, componentDir, filePath;
460
+ return __generator(this, function (_b) {
461
+ switch (_b.label) {
462
+ case 0: return [4 /*yield*/, (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice)];
463
+ case 1:
464
+ _a = _b.sent(), env = _a.env, currentComponent = _a.currentComponent;
465
+ componentsWithEnabledEnvDTsWrite = Object.entries(config.components)
466
+ .filter(function (_a) {
467
+ var component = _a[1];
468
+ return component === null || component === void 0 ? void 0 : component.envDTs;
144
469
  })
145
- .join("\n"));
146
- return [2 /*return*/];
470
+ .map(function (_a) {
471
+ var componentName = _a[0];
472
+ return componentName;
473
+ });
474
+ componentsToActuallyWriteDotEnvNow = currentComponent
475
+ ? componentsWithEnabledEnvDTsWrite.includes(currentComponent)
476
+ ? [currentComponent]
477
+ : []
478
+ : componentsWithEnabledEnvDTsWrite;
479
+ return [4 /*yield*/, (0, projects_1.getGitRoot)()];
480
+ case 2:
481
+ gitRoot = _b.sent();
482
+ _i = 0, componentsToActuallyWriteDotEnvNow_1 = componentsToActuallyWriteDotEnvNow;
483
+ _b.label = 3;
484
+ case 3:
485
+ if (!(_i < componentsToActuallyWriteDotEnvNow_1.length)) return [3 /*break*/, 7];
486
+ componentName = componentsToActuallyWriteDotEnvNow_1[_i];
487
+ return [4 /*yield*/, getEnvsForDTs(env, componentName)];
488
+ case 4:
489
+ envNames = _b.sent();
490
+ envDTsContent = createEnvDTsContent(envNames);
491
+ componentDir = (0, utils_1.getComponentFullPath)(gitRoot, config, componentName);
492
+ filePath = (0, path_1.join)(componentDir, "env.d.ts");
493
+ return [4 /*yield*/, (0, fs_extra_1.writeFile)(filePath, envDTsContent)];
494
+ case 5:
495
+ _b.sent();
496
+ _b.label = 6;
497
+ case 6:
498
+ _i++;
499
+ return [3 /*break*/, 3];
500
+ case 7: return [2 /*return*/];
147
501
  }
148
502
  });
149
- }); });
150
- //# sourceMappingURL=catenv.js.map
503
+ }); };
504
+ exports.writeDTsFiles = writeDTsFiles;
505
+ function getEnvsForDTs(env, componentName) {
506
+ return __awaiter(this, void 0, void 0, function () {
507
+ var environment, allEnvKeys, hiddenEnvKeys, dTsEnvKeys;
508
+ return __generator(this, function (_a) {
509
+ switch (_a.label) {
510
+ case 0: return [4 /*yield*/, (0, getProjectConfig_1.getEnvironment)(env, componentName)];
511
+ case 1:
512
+ environment = _a.sent();
513
+ allEnvKeys = Object.keys(environment.envVars);
514
+ hiddenEnvKeys = new Set(environment.secretEnvVarKeys
515
+ .filter(function (s) { return s.hidden; })
516
+ .map(function (s) { return s.key; })
517
+ .concat(["_ALL_ENV_VAR_KEYS"]));
518
+ dTsEnvKeys = allEnvKeys.filter(function (k) { return !hiddenEnvKeys.has(k); });
519
+ return [2 /*return*/, dTsEnvKeys];
520
+ }
521
+ });
522
+ });
523
+ }
524
+ function createEnvDTsContent(envNames) {
525
+ return "/* tslint:disable prettier/prettier */\n/* eslint-disable prettier/prettier */\n/* prettier-ignore */\n// automatically generated by catladder. Do not modify!\nexport {}\n\ndeclare global {\n namespace NodeJS {\n interface ProcessEnv {\n".concat(envNames.map(function (name) { return " ".concat(name, ": string"); }).join("\n"), "\n }\n }\n}\n");
526
+ }
527
+ //# sourceMappingURL=writeEnvDTs.js.map
151
528
 
152
529
  /***/ }),
153
530
 
@@ -38817,6 +39194,7 @@ var utils_1 = __nccwpck_require__(7461);
38817
39194
  var yarn_1 = __nccwpck_require__(464);
38818
39195
  var constants_1 = __nccwpck_require__(1542);
38819
39196
  var writeBuildInfo_1 = __nccwpck_require__(1754);
39197
+ var writeDotEnv_1 = __nccwpck_require__(1298);
38820
39198
  var createBuildJob = function (context, _a) {
38821
39199
  var _b, _c, _d, _e;
38822
39200
  var script = _a.script,
@@ -38830,7 +39208,7 @@ var createBuildJob = function (context, _a) {
38830
39208
  needs: [],
38831
39209
  cache: [],
38832
39210
  variables: __assign(__assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), context.environment.jobOnlyVars.build.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
38833
- script: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
39211
+ script: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(context.componentConfig.dotEnv ? (0, writeDotEnv_1.writeDotEnv)(context) : []), false), __read((0, writeBuildInfo_1.writeBuildInfo)(context)), false), __read((0, yarn_1.ensureNodeVersion)(context)), false), ["cd ".concat(context.componentConfig.dir)], false), __read((_c = (0, utils_1.ensureArray)(script)) !== null && _c !== void 0 ? _c : []), false),
38834
39212
  artifacts: {
38835
39213
  paths: [(0, path_1.join)(context.componentConfig.dir, "__build_info.json")],
38836
39214
  reports: {
@@ -38861,6 +39239,56 @@ exports.writeBuildInfo = writeBuildInfo;
38861
39239
 
38862
39240
  /***/ }),
38863
39241
 
39242
+ /***/ 1298:
39243
+ /***/ (function(__unused_webpack_module, exports) {
39244
+
39245
+ "use strict";
39246
+
39247
+
39248
+ var __read = this && this.__read || function (o, n) {
39249
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
39250
+ if (!m) return o;
39251
+ var i = m.call(o),
39252
+ r,
39253
+ ar = [],
39254
+ e;
39255
+ try {
39256
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
39257
+ } catch (error) {
39258
+ e = {
39259
+ error: error
39260
+ };
39261
+ } finally {
39262
+ try {
39263
+ if (r && !r.done && (m = i["return"])) m.call(i);
39264
+ } finally {
39265
+ if (e) throw e.error;
39266
+ }
39267
+ }
39268
+ return ar;
39269
+ };
39270
+ exports.__esModule = true;
39271
+ exports.writeDotEnv = void 0;
39272
+ /**
39273
+ * writes a .env file in the components folder
39274
+ * @param context
39275
+ * @returns
39276
+ */
39277
+ var writeDotEnv = function (context) {
39278
+ var envVars = context.environment.envVars;
39279
+ // make key=value and sanitize multiline
39280
+ var keyValueString = Object.entries(envVars).map(function (_a) {
39281
+ var _b = __read(_a, 2),
39282
+ key = _b[0],
39283
+ value = _b[1];
39284
+ return "".concat(key, "=").concat(value.replaceAll("\n", "\\n"));
39285
+ }).join("\n");
39286
+ return ["cat <<EOF > ".concat(context.componentConfig.dir, "/.env\n").concat(keyValueString, "\nEOF")];
39287
+ };
39288
+ exports.writeDotEnv = writeDotEnv;
39289
+
39290
+ /***/ }),
39291
+
38864
39292
  /***/ 2644:
38865
39293
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
38866
39294
 
@@ -40281,7 +40709,7 @@ exports.readConfigSync = readConfigSync;
40281
40709
 
40282
40710
  exports.__esModule = true;
40283
40711
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
40284
- exports.PIPELINE_IMAGE_TAG = "main-0acdca98" || 0;
40712
+ exports.PIPELINE_IMAGE_TAG = "main-e0262e40" || 0;
40285
40713
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
40286
40714
 
40287
40715
  /***/ }),