@catladder/cli 0.0.0-main-414c8270 → 0.0.0-main-722844ec

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 (44) hide show
  1. package/dist/apps/catenv/catenv.d.ts +2 -4
  2. package/dist/apps/catenv/catenv.js +8 -89
  3. package/dist/apps/catenv/catenv.js.map +1 -1
  4. package/dist/apps/catenv/printVariables.d.ts +3 -0
  5. package/dist/apps/catenv/printVariables.js +111 -0
  6. package/dist/apps/catenv/printVariables.js.map +1 -0
  7. package/dist/apps/catenv/types.d.ts +5 -0
  8. package/dist/apps/catenv/types.js +3 -0
  9. package/dist/apps/catenv/types.js.map +1 -0
  10. package/dist/apps/catenv/utils.d.ts +12 -0
  11. package/dist/apps/catenv/utils.js +108 -0
  12. package/dist/apps/catenv/utils.js.map +1 -0
  13. package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
  14. package/dist/apps/catenv/writeDotEnvFiles.js +93 -0
  15. package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
  16. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +1 -1
  17. package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -1
  18. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +14 -11
  19. package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -1
  20. package/dist/apps/cli/commands/project/commandConfigSecrets.js +36 -11
  21. package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -1
  22. package/dist/apps/cli/commands/project/commandEnvVars.js +1 -1
  23. package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -1
  24. package/dist/bundles/catenv/index.js +702 -122
  25. package/dist/bundles/cli/index.js +441 -85
  26. package/dist/config/getProjectConfig.d.ts +8 -1
  27. package/dist/config/getProjectConfig.js +45 -6
  28. package/dist/config/getProjectConfig.js.map +1 -1
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/dist/utils/gitlab.d.ts +4 -4
  31. package/dist/utils/gitlab.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/apps/catenv/catenv.ts +8 -62
  34. package/src/apps/catenv/printVariables.ts +51 -0
  35. package/src/apps/catenv/types.ts +6 -0
  36. package/src/apps/catenv/utils.ts +49 -0
  37. package/src/apps/catenv/writeDotEnvFiles.ts +45 -0
  38. package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +5 -2
  39. package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +18 -12
  40. package/src/apps/cli/commands/project/commandConfigSecrets.ts +26 -7
  41. package/src/apps/cli/commands/project/commandEnvVars.ts +5 -2
  42. package/src/config/getProjectConfig.ts +30 -6
  43. package/src/utils/gitlab.ts +4 -4
  44. package/tsconfig.json +1 -1
@@ -6,6 +6,75 @@
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
+ exports["default"] = (function (choice) { return __awaiter(void 0, void 0, void 0, function () {
50
+ var config;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0: return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
54
+ case 1:
55
+ config = _a.sent();
56
+ if (!config) {
57
+ return [2 /*return*/];
58
+ }
59
+ return [4 /*yield*/, (0, printVariables_1.printVariables)(config, choice)];
60
+ case 2:
61
+ _a.sent();
62
+ return [4 /*yield*/, (0, writeDotEnvFiles_1.writeDotEnvFiles)(config, choice)];
63
+ case 3:
64
+ _a.sent();
65
+ return [2 /*return*/];
66
+ }
67
+ });
68
+ }); });
69
+ //# sourceMappingURL=catenv.js.map
70
+
71
+ /***/ }),
72
+
73
+ /***/ 7770:
74
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
75
+
76
+ "use strict";
77
+
9
78
  var __assign = (this && this.__assign) || function () {
10
79
  __assign = Object.assign || function(t) {
11
80
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -54,10 +123,121 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
54
123
  }
55
124
  };
56
125
  exports.__esModule = true;
126
+ exports.printVariables = void 0;
57
127
  var getProjectConfig_1 = __nccwpck_require__(4146);
58
- var projects_1 = __nccwpck_require__(1619);
128
+ var utils_1 = __nccwpck_require__(4640);
129
+ var getAllVariablesToPrint = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
130
+ var _a, env, currentComponent, variables;
131
+ return __generator(this, function (_b) {
132
+ switch (_b.label) {
133
+ case 0: return [4 /*yield*/, (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice)];
134
+ case 1:
135
+ _a = _b.sent(), env = _a.env, currentComponent = _a.currentComponent;
136
+ variables = {};
137
+ if (!currentComponent) return [3 /*break*/, 3];
138
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVarsResolved)(null, env, currentComponent)];
139
+ case 2:
140
+ variables = _b.sent();
141
+ return [3 /*break*/, 5];
142
+ case 3: return [4 /*yield*/, Object.keys(config.components).reduce(function (acc, componentName) { return __awaiter(void 0, void 0, void 0, function () {
143
+ var subappvars, _a;
144
+ return __generator(this, function (_b) {
145
+ switch (_b.label) {
146
+ case 0: return [4 /*yield*/, (0, getProjectConfig_1.getEnvVarsResolved)(null, env, componentName)];
147
+ case 1:
148
+ subappvars = _b.sent();
149
+ _a = [{}];
150
+ return [4 /*yield*/, acc];
151
+ 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) {
152
+ var key = _a[0], value = _a[1];
153
+ return [
154
+ "".concat((0, utils_1.sanitizeEnvVarName)(componentName.toUpperCase()), "_").concat(key),
155
+ value,
156
+ ];
157
+ }))])];
158
+ }
159
+ });
160
+ }); }, {})];
161
+ case 4:
162
+ // when in a monorep and not in a subapp, merge all env vars.
163
+ // this is not 100% correct, but better than not exporting any vars at all
164
+ // so we also add prefixed variants
165
+ variables = _b.sent();
166
+ _b.label = 5;
167
+ case 5: return [2 /*return*/, variables];
168
+ }
169
+ });
170
+ }); };
171
+ var printVariables = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
172
+ var variables;
173
+ return __generator(this, function (_a) {
174
+ switch (_a.label) {
175
+ case 0: return [4 /*yield*/, getAllVariablesToPrint(config, choice)];
176
+ case 1:
177
+ variables = _a.sent();
178
+ console.log(makeExportKeyValuestring(variables));
179
+ return [2 /*return*/];
180
+ }
181
+ });
182
+ }); };
183
+ exports.printVariables = printVariables;
184
+ var makeExportKeyValuestring = function (variables) {
185
+ return (0, utils_1.makeKeyValueString)(variables, "export ");
186
+ };
187
+ //# sourceMappingURL=printVariables.js.map
188
+
189
+ /***/ }),
190
+
191
+ /***/ 4640:
192
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
193
+
194
+ "use strict";
195
+
196
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
197
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
198
+ return new (P || (P = Promise))(function (resolve, reject) {
199
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
200
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
201
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
202
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
203
+ });
204
+ };
205
+ var __generator = (this && this.__generator) || function (thisArg, body) {
206
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
207
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
208
+ function verb(n) { return function (v) { return step([n, v]); }; }
209
+ function step(op) {
210
+ if (f) throw new TypeError("Generator is already executing.");
211
+ while (_) try {
212
+ 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;
213
+ if (y = 0, t) op = [op[0] & 2, t.value];
214
+ switch (op[0]) {
215
+ case 0: case 1: t = op; break;
216
+ case 4: _.label++; return { value: op[1], done: false };
217
+ case 5: _.label++; y = op[1]; op = [0]; continue;
218
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
219
+ default:
220
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
221
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
222
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
223
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
224
+ if (t[2]) _.ops.pop();
225
+ _.trys.pop(); continue;
226
+ }
227
+ op = body.call(thisArg, _);
228
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
229
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
230
+ }
231
+ };
232
+ exports.__esModule = true;
233
+ exports.sanitizeEnvVarName = exports.sanitizeMultiLine = exports.makeKeyValueString = exports.getCurrentComponentAndEnvFromChoice = exports.getComponentFullPath = void 0;
59
234
  var path_1 = __nccwpck_require__(1017);
60
- var getCurrentComponentName = function (components) { return __awaiter(void 0, void 0, void 0, function () {
235
+ var projects_1 = __nccwpck_require__(1619);
236
+ var getComponentFullPath = function (gitRoot, config, componentName) {
237
+ return (0, path_1.join)(gitRoot, config.components[componentName].dir);
238
+ };
239
+ exports.getComponentFullPath = getComponentFullPath;
240
+ var getCurrentComponentName = function (config) { return __awaiter(void 0, void 0, void 0, function () {
61
241
  var gitRoot, currentDir;
62
242
  return __generator(this, function (_a) {
63
243
  switch (_a.label) {
@@ -65,89 +245,161 @@ var getCurrentComponentName = function (components) { return __awaiter(void 0, v
65
245
  case 1:
66
246
  gitRoot = _a.sent();
67
247
  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));
248
+ return [2 /*return*/, Object.keys(config.components).find(function (c) {
249
+ return currentDir.startsWith((0, exports.getComponentFullPath)(gitRoot, config, c));
70
250
  })];
71
251
  }
72
252
  });
73
253
  }); };
74
- var sanitizeEnvVarName = function (name) { return name.replace(/[\s\-.]+/g, "_"); };
75
- var getAllVariablesToPrint = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
76
- var env, components, currentComponent, _a, variables;
254
+ var getCurrentComponentAndEnvFromChoice = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
255
+ var env, currentComponent, _a;
77
256
  var _b, _c;
78
257
  return __generator(this, function (_d) {
79
258
  switch (_d.label) {
80
259
  case 0:
81
260
  env = (_b = choice === null || choice === void 0 ? void 0 : choice.env) !== null && _b !== void 0 ? _b : "local";
82
- components = config.components;
83
261
  if (!((_c = choice === null || choice === void 0 ? void 0 : choice.componentName) !== null && _c !== void 0)) return [3 /*break*/, 1];
84
262
  _a = _c;
85
263
  return [3 /*break*/, 3];
86
- case 1: return [4 /*yield*/, getCurrentComponentName(components)];
264
+ case 1: return [4 /*yield*/, getCurrentComponentName(config)];
87
265
  case 2:
88
266
  _a = (_d.sent());
89
267
  _d.label = 3;
90
268
  case 3:
91
269
  currentComponent = _a;
92
- variables = {};
93
- if (!currentComponent) return [3 /*break*/, 5];
94
- return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(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 () {
99
- var subappvars, _a;
100
- return __generator(this, function (_b) {
101
- switch (_b.label) {
102
- case 0: return [4 /*yield*/, (0, getProjectConfig_1.getEnvVars)(null, env, componentName)];
103
- case 1:
104
- subappvars = _b.sent();
105
- _a = [{}];
106
- return [4 /*yield*/, acc];
107
- 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
- var key = _a[0], value = _a[1];
109
- return [
110
- "".concat(sanitizeEnvVarName(componentName.toUpperCase()), "_").concat(key),
111
- value,
112
- ];
113
- }))])];
114
- }
115
- });
116
- }); }, {})];
117
- case 6:
118
- // when in a monorep and not in a subapp, merge all env vars.
119
- // this is not 100% correct, but better than not exporting any vars at all
120
- // so we also add prefixed variants
121
- variables = _d.sent();
122
- _d.label = 7;
123
- case 7: return [2 /*return*/, variables];
270
+ return [2 /*return*/, {
271
+ currentComponent: currentComponent,
272
+ env: env
273
+ }];
124
274
  }
125
275
  });
126
276
  }); };
127
- exports["default"] = (function (choice) { return __awaiter(void 0, void 0, void 0, function () {
128
- var config, variables;
129
- return __generator(this, function (_a) {
130
- switch (_a.label) {
131
- case 0: return [4 /*yield*/, (0, getProjectConfig_1.getProjectConfig)()];
277
+ exports.getCurrentComponentAndEnvFromChoice = getCurrentComponentAndEnvFromChoice;
278
+ var makeKeyValueString = function (variables, keyPrefix) {
279
+ if (keyPrefix === void 0) { keyPrefix = ""; }
280
+ return Object.entries(variables)
281
+ .map(function (_a) {
282
+ var key = _a[0], value = _a[1];
283
+ return "".concat(keyPrefix).concat(key, "='").concat(value, "'");
284
+ })
285
+ .join("\n");
286
+ };
287
+ exports.makeKeyValueString = makeKeyValueString;
288
+ var sanitizeMultiLine = function (variables) {
289
+ return Object.fromEntries(Object.entries(variables).map(function (_a) {
290
+ var key = _a[0], value = _a[1];
291
+ return [
292
+ key,
293
+ value.replaceAll("\n", "\\n"),
294
+ ];
295
+ }));
296
+ };
297
+ exports.sanitizeMultiLine = sanitizeMultiLine;
298
+ var sanitizeEnvVarName = function (name) {
299
+ return name.replace(/[\s\-.]+/g, "_");
300
+ };
301
+ exports.sanitizeEnvVarName = sanitizeEnvVarName;
302
+ //# sourceMappingURL=utils.js.map
303
+
304
+ /***/ }),
305
+
306
+ /***/ 4295:
307
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
308
+
309
+ "use strict";
310
+
311
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
312
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
313
+ return new (P || (P = Promise))(function (resolve, reject) {
314
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
315
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
316
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
317
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
318
+ });
319
+ };
320
+ var __generator = (this && this.__generator) || function (thisArg, body) {
321
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
322
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
323
+ function verb(n) { return function (v) { return step([n, v]); }; }
324
+ function step(op) {
325
+ if (f) throw new TypeError("Generator is already executing.");
326
+ while (_) try {
327
+ 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;
328
+ if (y = 0, t) op = [op[0] & 2, t.value];
329
+ switch (op[0]) {
330
+ case 0: case 1: t = op; break;
331
+ case 4: _.label++; return { value: op[1], done: false };
332
+ case 5: _.label++; y = op[1]; op = [0]; continue;
333
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
334
+ default:
335
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
336
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
337
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
338
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
339
+ if (t[2]) _.ops.pop();
340
+ _.trys.pop(); continue;
341
+ }
342
+ op = body.call(thisArg, _);
343
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
344
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
345
+ }
346
+ };
347
+ exports.__esModule = true;
348
+ exports.writeDotEnvFiles = void 0;
349
+ var fs_extra_1 = __nccwpck_require__(5501);
350
+ var path_1 = __nccwpck_require__(1017);
351
+ var getProjectConfig_1 = __nccwpck_require__(4146);
352
+ var projects_1 = __nccwpck_require__(1619);
353
+ var utils_1 = __nccwpck_require__(4640);
354
+ var writeDotEnvFiles = function (config, choice) { return __awaiter(void 0, void 0, void 0, function () {
355
+ var _a, env, currentComponent, componentsWithEnabledDotEnvWrite, componentsToActuallyWriteDotEnvNow, gitRoot, _i, componentsToActuallyWriteDotEnvNow_1, componentName, variables, componentDir, filePath, variablesSanitized;
356
+ return __generator(this, function (_b) {
357
+ switch (_b.label) {
358
+ case 0: return [4 /*yield*/, (0, utils_1.getCurrentComponentAndEnvFromChoice)(config, choice)];
132
359
  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
- variables = _a.sent();
140
- console.log(Object.entries(variables)
141
- .map(function (_a) {
142
- var key = _a[0], value = _a[1];
143
- return "export ".concat(key, "='").concat(value, "'");
360
+ _a = _b.sent(), env = _a.env, currentComponent = _a.currentComponent;
361
+ componentsWithEnabledDotEnvWrite = Object.entries(config.components)
362
+ .filter(function (_a) {
363
+ var component = _a[1];
364
+ return component === null || component === void 0 ? void 0 : component.dotEnv;
144
365
  })
145
- .join("\n"));
146
- return [2 /*return*/];
366
+ .map(function (_a) {
367
+ var componentName = _a[0];
368
+ return componentName;
369
+ });
370
+ componentsToActuallyWriteDotEnvNow = currentComponent
371
+ ? componentsWithEnabledDotEnvWrite.includes(currentComponent)
372
+ ? [currentComponent]
373
+ : []
374
+ : componentsWithEnabledDotEnvWrite;
375
+ return [4 /*yield*/, (0, projects_1.getGitRoot)()];
376
+ case 2:
377
+ gitRoot = _b.sent();
378
+ _i = 0, componentsToActuallyWriteDotEnvNow_1 = componentsToActuallyWriteDotEnvNow;
379
+ _b.label = 3;
380
+ case 3:
381
+ if (!(_i < componentsToActuallyWriteDotEnvNow_1.length)) return [3 /*break*/, 7];
382
+ componentName = componentsToActuallyWriteDotEnvNow_1[_i];
383
+ return [4 /*yield*/, (0, getProjectConfig_1.getEnvVarsResolved)(null, env, componentName)];
384
+ case 4:
385
+ variables = _b.sent();
386
+ componentDir = (0, utils_1.getComponentFullPath)(gitRoot, config, componentName);
387
+ filePath = (0, path_1.join)(componentDir, ".env");
388
+ variablesSanitized = (0, utils_1.sanitizeMultiLine)(variables);
389
+ return [4 /*yield*/, (0, fs_extra_1.writeFile)(filePath, "# automatically created by catladder. Do not modify!\n\n" +
390
+ (0, utils_1.makeKeyValueString)(variablesSanitized))];
391
+ case 5:
392
+ _b.sent();
393
+ _b.label = 6;
394
+ case 6:
395
+ _i++;
396
+ return [3 /*break*/, 3];
397
+ case 7: return [2 /*return*/];
147
398
  }
148
399
  });
149
- }); });
150
- //# sourceMappingURL=catenv.js.map
400
+ }); };
401
+ exports.writeDotEnvFiles = writeDotEnvFiles;
402
+ //# sourceMappingURL=writeDotEnvFiles.js.map
151
403
 
152
404
  /***/ }),
153
405
 
@@ -176,6 +428,17 @@ var choice = process.argv[2] ? (0, parseChoice_1.parseChoice)(process.argv[2]) :
176
428
 
177
429
  "use strict";
178
430
 
431
+ var __assign = (this && this.__assign) || function () {
432
+ __assign = Object.assign || function(t) {
433
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
434
+ s = arguments[i];
435
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
436
+ t[p] = s[p];
437
+ }
438
+ return t;
439
+ };
440
+ return __assign.apply(this, arguments);
441
+ };
179
442
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
180
443
  if (k2 === undefined) k2 = k;
181
444
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -220,7 +483,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
220
483
  }
221
484
  };
222
485
  exports.__esModule = true;
223
- exports.getEnvVars = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.getGitlabCi = exports.getGitlabCiFilePath = exports.getProjectConfig = exports.parseChoice = void 0;
486
+ exports.getJobOnlyEnvVarsResolved = exports.getEnvVarsResolved = exports.getGitlabVar = exports.getEnvironment = exports.getAllPipelineContexts = exports.getAllComponentsWithAllEnvsHierarchical = exports.getAllComponentsWithAllEnvsFlat = exports.getPipelineContextByChoice = exports.getProjectComponents = exports.getGitlabCi = exports.getGitlabCiFilePath = exports.getProjectConfig = exports.parseChoice = void 0;
224
487
  var pipeline_1 = __nccwpck_require__(5355);
225
488
  var gitlab_1 = __nccwpck_require__(9818);
226
489
  var projects_1 = __nccwpck_require__(1619);
@@ -424,27 +687,55 @@ var resolveSecrets = function (vorpal, allEnvVars) { return __awaiter(void 0, vo
424
687
  }
425
688
  });
426
689
  }); };
427
- var getEnvVars = function (vorpal, env, componentName) { return __awaiter(void 0, void 0, void 0, function () {
690
+ var getEnvVarsResolved = function (vorpal, env, componentName) { return __awaiter(void 0, void 0, void 0, function () {
428
691
  var envionment, e_2;
429
692
  return __generator(this, function (_a) {
430
693
  switch (_a.label) {
431
694
  case 0:
432
- _a.trys.push([0, 2, , 3]);
433
- return [4 /*yield*/, (0, exports.getEnvironment)(env, componentName)];
695
+ if (!componentName) {
696
+ return [2 /*return*/, {}];
697
+ }
698
+ _a.label = 1;
434
699
  case 1:
700
+ _a.trys.push([1, 3, , 4]);
701
+ return [4 /*yield*/, (0, exports.getEnvironment)(env, componentName)];
702
+ case 2:
435
703
  envionment = _a.sent();
436
704
  // in the pipeline the secrets alreadyy exists and bash will expand them
437
705
  // but here we need to manually load them
438
706
  return [2 /*return*/, resolveSecrets(vorpal, envionment.envVars)];
439
- case 2:
707
+ case 3:
440
708
  e_2 = _a.sent();
441
709
  // env is disabled
442
710
  return [2 /*return*/, {}];
711
+ case 4: return [2 /*return*/];
712
+ }
713
+ });
714
+ }); };
715
+ exports.getEnvVarsResolved = getEnvVarsResolved;
716
+ /**
717
+ *
718
+ * is used to get job only vars that should also be editable locally with catladder.
719
+ */
720
+ var getJobOnlyEnvVarsResolved = function (vorpal, env, componentName) { return __awaiter(void 0, void 0, void 0, function () {
721
+ var envionment, e_3;
722
+ return __generator(this, function (_a) {
723
+ switch (_a.label) {
724
+ case 0:
725
+ _a.trys.push([0, 2, , 3]);
726
+ return [4 /*yield*/, (0, exports.getEnvironment)(env, componentName)];
727
+ case 1:
728
+ envionment = _a.sent();
729
+ return [2 /*return*/, resolveSecrets(vorpal, __assign(__assign({}, envionment.jobOnlyVars.build.envVars), envionment.jobOnlyVars.deploy.envVars))];
730
+ case 2:
731
+ e_3 = _a.sent();
732
+ // env is disabled
733
+ return [2 /*return*/, {}];
443
734
  case 3: return [2 /*return*/];
444
735
  }
445
736
  });
446
737
  }); };
447
- exports.getEnvVars = getEnvVars;
738
+ exports.getJobOnlyEnvVarsResolved = getJobOnlyEnvVarsResolved;
448
739
  //# sourceMappingURL=getProjectConfig.js.map
449
740
 
450
741
  /***/ }),
@@ -38778,6 +39069,7 @@ var utils_1 = __nccwpck_require__(7461);
38778
39069
  var yarn_1 = __nccwpck_require__(464);
38779
39070
  var constants_1 = __nccwpck_require__(1542);
38780
39071
  var writeBuildInfo_1 = __nccwpck_require__(1754);
39072
+ var writeDotEnv_1 = __nccwpck_require__(1298);
38781
39073
  var createBuildJob = function (context, _a) {
38782
39074
  var _b, _c, _d, _e;
38783
39075
  var script = _a.script,
@@ -38790,8 +39082,8 @@ var createBuildJob = function (context, _a) {
38790
39082
  image: (0, __1.getRunnerImage)("jobs-default"),
38791
39083
  needs: [],
38792
39084
  cache: [],
38793
- variables: __assign(__assign(__assign(__assign({}, constants_1.RUNNER_BUILD_RESOURCE_VARIABLES), variables !== null && variables !== void 0 ? variables : {}), context.environment.envVars), (_b = context.componentConfig.build.extraVars) !== null && _b !== void 0 ? _b : {}),
38794
- 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),
39085
+ 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 : {}),
39086
+ 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),
38795
39087
  artifacts: {
38796
39088
  paths: [(0, path_1.join)(context.componentConfig.dir, "__build_info.json")],
38797
39089
  reports: {
@@ -38822,6 +39114,56 @@ exports.writeBuildInfo = writeBuildInfo;
38822
39114
 
38823
39115
  /***/ }),
38824
39116
 
39117
+ /***/ 1298:
39118
+ /***/ (function(__unused_webpack_module, exports) {
39119
+
39120
+ "use strict";
39121
+
39122
+
39123
+ var __read = this && this.__read || function (o, n) {
39124
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
39125
+ if (!m) return o;
39126
+ var i = m.call(o),
39127
+ r,
39128
+ ar = [],
39129
+ e;
39130
+ try {
39131
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
39132
+ } catch (error) {
39133
+ e = {
39134
+ error: error
39135
+ };
39136
+ } finally {
39137
+ try {
39138
+ if (r && !r.done && (m = i["return"])) m.call(i);
39139
+ } finally {
39140
+ if (e) throw e.error;
39141
+ }
39142
+ }
39143
+ return ar;
39144
+ };
39145
+ exports.__esModule = true;
39146
+ exports.writeDotEnv = void 0;
39147
+ /**
39148
+ * writes a .env file in the components folder
39149
+ * @param context
39150
+ * @returns
39151
+ */
39152
+ var writeDotEnv = function (context) {
39153
+ var envVars = context.environment.envVars;
39154
+ // make key=value and sanitize multiline
39155
+ var keyValueString = Object.entries(envVars).map(function (_a) {
39156
+ var _b = __read(_a, 2),
39157
+ key = _b[0],
39158
+ value = _b[1];
39159
+ return "".concat(key, "=").concat(value.replaceAll("\n", "\\n"));
39160
+ }).join("\n");
39161
+ return ["cat <<EOF > ".concat(context.componentConfig.dir, "/.env\n").concat(keyValueString, "\nEOF")];
39162
+ };
39163
+ exports.writeDotEnv = writeDotEnv;
39164
+
39165
+ /***/ }),
39166
+
38825
39167
  /***/ 2644:
38826
39168
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
38827
39169
 
@@ -39029,9 +39371,9 @@ var createCustomTestJobs = function (context) {
39029
39371
  throw new Error("deploy config is not custom");
39030
39372
  }
39031
39373
  var base = {
39032
- variables: __assign(__assign({
39374
+ variables: __assign(__assign(__assign({
39033
39375
  APP_PATH: context.componentConfig.dir
39034
- }, RUNNER_CUSTOM_TEST_VARIABLES), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
39376
+ }, RUNNER_CUSTOM_TEST_VARIABLES), context.environment.jobOnlyVars.build.envVars), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
39035
39377
  services: buildConfig.jobServices,
39036
39378
  cache: buildConfig.jobCache,
39037
39379
  stage: "test",
@@ -39722,9 +40064,9 @@ var createNodeTestJobs = function (context) {
39722
40064
  }
39723
40065
  var buildConfig = context.componentConfig.build;
39724
40066
  var base = {
39725
- variables: __assign(__assign({
40067
+ variables: __assign(__assign(__assign({
39726
40068
  APP_PATH: context.componentConfig.dir
39727
- }, constants_1.NODE_RUNNER_BUILD_VARIABLES), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
40069
+ }, constants_1.NODE_RUNNER_BUILD_VARIABLES), context.environment.jobOnlyVars.build.envVars), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
39728
40070
  stage: "test",
39729
40071
  needs: [],
39730
40072
  envMode: "none"
@@ -39841,6 +40183,16 @@ exports.getDockerAppCopyAndBuildScript = getDockerAppCopyAndBuildScript;
39841
40183
  "use strict";
39842
40184
 
39843
40185
 
40186
+ var __assign = this && this.__assign || function () {
40187
+ __assign = Object.assign || function (t) {
40188
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
40189
+ s = arguments[i];
40190
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
40191
+ }
40192
+ return t;
40193
+ };
40194
+ return __assign.apply(this, arguments);
40195
+ };
39844
40196
  var __read = this && this.__read || function (o, n) {
39845
40197
  var m = typeof Symbol === "function" && o[Symbol.iterator];
39846
40198
  if (!m) return o;
@@ -39882,7 +40234,7 @@ var createRailsBuildJobs = function (context) {
39882
40234
  return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
39883
40235
  }).join(" ");
39884
40236
  return [(0, docker_1.createDockerBuildJobBase)(context, {
39885
- variables: context.componentConfig.build.extraVars,
40237
+ variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), context.componentConfig.build.extraVars),
39886
40238
  // custom script
39887
40239
  script: [docker_1.gitlabDockerLogin, "docker pull $DOCKER_CACHE_IMAGE || true", "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
39888
40240
  // replace private git ssh gem sources with https to make bundler with credentials via env var work
@@ -39999,7 +40351,7 @@ var createRailsTestJobs = function (context) {
39999
40351
  }
40000
40352
  var buildConfig = context.componentConfig.build;
40001
40353
  var base = {
40002
- variables: (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {},
40354
+ variables: __assign(__assign({}, context.environment.jobOnlyVars.build.envVars), (_b = buildConfig.extraVars) !== null && _b !== void 0 ? _b : {}),
40003
40355
  stage: "test",
40004
40356
  needs: [],
40005
40357
  envMode: "none"
@@ -40232,7 +40584,7 @@ exports.readConfigSync = readConfigSync;
40232
40584
 
40233
40585
  exports.__esModule = true;
40234
40586
  exports.DOCKER_REGISTRY = exports.PIPELINE_IMAGE_TAG = void 0;
40235
- exports.PIPELINE_IMAGE_TAG = "main-414c8270" || 0;
40587
+ exports.PIPELINE_IMAGE_TAG = "main-722844ec" || 0;
40236
40588
  exports.DOCKER_REGISTRY = "git.panter.ch:5001/catladder/catladder" || 0;
40237
40589
 
40238
40590
  /***/ }),
@@ -40288,6 +40640,16 @@ exports.getEnvType = getEnvType;
40288
40640
  "use strict";
40289
40641
 
40290
40642
 
40643
+ var __assign = this && this.__assign || function () {
40644
+ __assign = Object.assign || function (t) {
40645
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
40646
+ s = arguments[i];
40647
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
40648
+ }
40649
+ return t;
40650
+ };
40651
+ return __assign.apply(this, arguments);
40652
+ };
40291
40653
  var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
40292
40654
  function adopt(value) {
40293
40655
  return value instanceof P ? value : new P(function (resolve) {
@@ -40409,30 +40771,26 @@ var getEnvironmentContext_1 = __nccwpck_require__(4650);
40409
40771
  var getEnvironmentVariables_1 = __nccwpck_require__(6602);
40410
40772
  var getEnvironment = function (config, componentName, env, commitInfo) {
40411
40773
  return __awaiter(void 0, void 0, void 0, function () {
40412
- var _a, envVars, secretEnvVarKeys, host, url, envContext, envType;
40413
- return __generator(this, function (_b) {
40414
- switch (_b.label) {
40774
+ var variables, envContext, envType;
40775
+ return __generator(this, function (_a) {
40776
+ switch (_a.label) {
40415
40777
  case 0:
40416
40778
  return [4 /*yield*/, (0, getEnvironmentVariables_1.getEnvironmentVariables)(config, componentName, env, commitInfo)];
40417
40779
  case 1:
40418
- _a = _b.sent(), envVars = _a.envVars, secretEnvVarKeys = _a.secretEnvVarKeys, host = _a.host, url = _a.url;
40780
+ variables = _a.sent();
40419
40781
  envContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
40420
40782
  envType = envContext.envType;
40421
- return [2 /*return*/, {
40783
+ return [2 /*return*/, __assign({
40422
40784
  envType: envType,
40423
- host: host,
40424
- url: url,
40425
40785
  gitlabEnvironment: {
40426
40786
  name: envContext.gitlabEnvironmentName,
40427
- url: url
40787
+ url: variables.url
40428
40788
  },
40429
40789
  fullName: envContext.fullName,
40430
40790
  slugPrefix: envContext.environmentSlugPrefix,
40431
40791
  slug: envContext.environmentSlug,
40432
- shortName: env,
40433
- envVars: envVars,
40434
- secretEnvVarKeys: secretEnvVarKeys
40435
- }];
40792
+ shortName: env
40793
+ }, variables)];
40436
40794
  }
40437
40795
  });
40438
40796
  });
@@ -40649,19 +41007,22 @@ var lodash_1 = __nccwpck_require__(3255);
40649
41007
  var deploy_1 = __nccwpck_require__(223);
40650
41008
  var getEnvironmentContext_1 = __nccwpck_require__(4650);
40651
41009
  var resolveReferences_1 = __nccwpck_require__(928);
41010
+ var envVars_1 = __nccwpck_require__(7185);
41011
+ var transformJobOnlyVars_1 = __nccwpck_require__(4674);
40652
41012
  var getEnvironmentVariables = function (config, componentName, env, commitInfo, alreadyVisited // to prevent endless loop
40653
41013
  ) {
40654
41014
  if (alreadyVisited === void 0) {
40655
41015
  alreadyVisited = {};
40656
41016
  }
40657
41017
  return __awaiter(void 0, void 0, void 0, function () {
40658
- var environmentContext, envConfigRaw, deployConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegasyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
40659
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
40660
- return __generator(this, function (_k) {
40661
- switch (_k.label) {
41018
+ var environmentContext, envConfigRaw, deployConfigRaw, buildConfigRaw, envType, basePredefinedVariables, predefinedVariables, host, url, devLocalConfig, port, additionalEnvVars, publicEnvVarsRaw, additionalSecretKeys, secretEnvVarKeys, secretEnvVars, legacyFromComponents, publicEnvVarsRawWithLegacyFromComponents, publicEnvVarsRawSanitized, envVarsRaw, envVars;
41019
+ var _a, _b;
41020
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l;
41021
+ return __generator(this, function (_m) {
41022
+ switch (_m.label) {
40662
41023
  case 0:
40663
41024
  environmentContext = (0, getEnvironmentContext_1.getEnvironmentContext)(config, env, componentName, commitInfo);
40664
- envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, envType = environmentContext.envType;
41025
+ envConfigRaw = environmentContext.envConfigRaw, deployConfigRaw = environmentContext.deployConfigRaw, buildConfigRaw = environmentContext.buildConfigRaw, envType = environmentContext.envType;
40665
41026
  basePredefinedVariables = {
40666
41027
  ENV_SHORT: env,
40667
41028
  APP_DIR: envConfigRaw.dir,
@@ -40672,7 +41033,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
40672
41033
  };
40673
41034
  if (envType === "local") {
40674
41035
  devLocalConfig = envConfigRaw;
40675
- port = (_a = devLocalConfig.port) !== null && _a !== void 0 ? _a : 3000;
41036
+ port = (_c = devLocalConfig.port) !== null && _c !== void 0 ? _c : 3000;
40676
41037
  host = "localhost:" + port;
40677
41038
  url = "http://" + host;
40678
41039
  predefinedVariables = {
@@ -40682,7 +41043,7 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
40682
41043
  };
40683
41044
  } else {
40684
41045
  additionalEnvVars = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].getAdditionalEnvVars(environmentContext) : {};
40685
- host = (_c = (_b = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _b !== void 0 ? _b : additionalEnvVars.HOST_CANONICAL) !== null && _c !== void 0 ? _c : "unknown-host.example.com";
41046
+ host = (_e = (_d = envConfigRaw === null || envConfigRaw === void 0 ? void 0 : envConfigRaw.host) !== null && _d !== void 0 ? _d : additionalEnvVars.HOST_CANONICAL) !== null && _e !== void 0 ? _e : "unknown-host.example.com";
40686
41047
  url = "https://".concat(host);
40687
41048
  predefinedVariables = __assign(__assign(__assign(__assign({}, basePredefinedVariables), config.components[componentName].build.type === "rails" ? {} : {
40688
41049
  HOST: host
@@ -40690,25 +41051,13 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
40690
41051
  ROOT_URL: url
40691
41052
  }), additionalEnvVars);
40692
41053
  }
40693
- publicEnvVarsRaw = (_e = (_d = envConfigRaw.vars) === null || _d === void 0 ? void 0 : _d.public) !== null && _e !== void 0 ? _e : {};
41054
+ publicEnvVarsRaw = (_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.public) !== null && _g !== void 0 ? _g : {};
40694
41055
  additionalSecretKeys = deployConfigRaw ? deploy_1.DEPLOY_TYPES[deployConfigRaw.type].additionalSecretKeys(environmentContext) : [];
40695
- secretEnvVarKeys = __spreadArray(__spreadArray([], __read(((_g = (_f = envConfigRaw.vars) === null || _f === void 0 ? void 0 : _f.secret) !== null && _g !== void 0 ? _g : []).map(function (key) {
40696
- return {
40697
- key: key
40698
- };
40699
- })), false), __read(additionalSecretKeys), false);
40700
- secretEnvVars = Object.fromEntries(secretEnvVarKeys.map(function (_a) {
40701
- var key = _a.key;
40702
- return [key, "$".concat((0, exports.getSecretVarName)(env, componentName, key))];
40703
- }));
40704
- legacyFromComponents = (_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.fromComponents) !== null && _j !== void 0 ? _j : {};
40705
- publicEnvVarsRawWithLegasyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
40706
- publicEnvVarsRawSanitized = Object.fromEntries(Object.entries(publicEnvVarsRawWithLegasyFromComponents).map(function (_a) {
40707
- var _b = __read(_a, 2),
40708
- key = _b[0],
40709
- value = _b[1];
40710
- return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
40711
- }));
41056
+ secretEnvVarKeys = __spreadArray(__spreadArray([], __read((0, envVars_1.stringListToSecreteEnvVarList)((_j = (_h = envConfigRaw.vars) === null || _h === void 0 ? void 0 : _h.secret) !== null && _j !== void 0 ? _j : [])), false), __read(additionalSecretKeys), false);
41057
+ secretEnvVars = (0, envVars_1.makeSecretEnvVarMapping)(env, componentName, secretEnvVarKeys);
41058
+ legacyFromComponents = (_l = (_k = envConfigRaw.vars) === null || _k === void 0 ? void 0 : _k.fromComponents) !== null && _l !== void 0 ? _l : {};
41059
+ publicEnvVarsRawWithLegacyFromComponents = (0, lodash_1.merge)({}, (0, resolveReferences_1.translateLegacyFromComponents)(legacyFromComponents), publicEnvVarsRaw);
41060
+ publicEnvVarsRawSanitized = (0, envVars_1.stringifyValues)(publicEnvVarsRawWithLegacyFromComponents);
40712
41061
  envVarsRaw = addIndexVar(__assign(__assign(__assign({}, predefinedVariables), secretEnvVars), publicEnvVarsRawSanitized));
40713
41062
  return [4 /*yield*/, (0, resolveReferences_1.resolveReferences)(envVarsRaw, function (otherComponentName, alreadyVisited) {
40714
41063
  return __awaiter(void 0, void 0, void 0, function () {
@@ -40725,13 +41074,18 @@ var getEnvironmentVariables = function (config, componentName, env, commitInfo,
40725
41074
  });
40726
41075
  }, alreadyVisited)];
40727
41076
  case 1:
40728
- envVars = _k.sent();
40729
- return [2 /*return*/, {
41077
+ envVars = _m.sent();
41078
+ _a = {
40730
41079
  envVars: envVars,
40731
- secretEnvVarKeys: secretEnvVarKeys,
40732
- host: host,
40733
- url: url
40734
- }];
41080
+ secretEnvVarKeys: secretEnvVarKeys
41081
+ };
41082
+ _b = {};
41083
+ return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, buildConfigRaw && buildConfigRaw.jobVars || null)];
41084
+ case 2:
41085
+ _b.build = _m.sent();
41086
+ return [4 /*yield*/, (0, transformJobOnlyVars_1.transformJobOnlyVars)(env, componentName, deployConfigRaw && deployConfigRaw.jobVars || null)];
41087
+ case 3:
41088
+ return [2 /*return*/, (_a.jobOnlyVars = (_b.deploy = _m.sent(), _b), _a.host = host, _a.url = url, _a)];
40735
41089
  }
40736
41090
  });
40737
41091
  });
@@ -41243,6 +41597,232 @@ exports.translateLegacyFromComponents = translateLegacyFromComponents;
41243
41597
 
41244
41598
  /***/ }),
41245
41599
 
41600
+ /***/ 4674:
41601
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
41602
+
41603
+ "use strict";
41604
+
41605
+
41606
+ var __assign = this && this.__assign || function () {
41607
+ __assign = Object.assign || function (t) {
41608
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
41609
+ s = arguments[i];
41610
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41611
+ }
41612
+ return t;
41613
+ };
41614
+ return __assign.apply(this, arguments);
41615
+ };
41616
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
41617
+ function adopt(value) {
41618
+ return value instanceof P ? value : new P(function (resolve) {
41619
+ resolve(value);
41620
+ });
41621
+ }
41622
+ return new (P || (P = Promise))(function (resolve, reject) {
41623
+ function fulfilled(value) {
41624
+ try {
41625
+ step(generator.next(value));
41626
+ } catch (e) {
41627
+ reject(e);
41628
+ }
41629
+ }
41630
+ function rejected(value) {
41631
+ try {
41632
+ step(generator["throw"](value));
41633
+ } catch (e) {
41634
+ reject(e);
41635
+ }
41636
+ }
41637
+ function step(result) {
41638
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
41639
+ }
41640
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
41641
+ });
41642
+ };
41643
+ var __generator = this && this.__generator || function (thisArg, body) {
41644
+ var _ = {
41645
+ label: 0,
41646
+ sent: function () {
41647
+ if (t[0] & 1) throw t[1];
41648
+ return t[1];
41649
+ },
41650
+ trys: [],
41651
+ ops: []
41652
+ },
41653
+ f,
41654
+ y,
41655
+ t,
41656
+ g;
41657
+ return g = {
41658
+ next: verb(0),
41659
+ "throw": verb(1),
41660
+ "return": verb(2)
41661
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
41662
+ return this;
41663
+ }), g;
41664
+ function verb(n) {
41665
+ return function (v) {
41666
+ return step([n, v]);
41667
+ };
41668
+ }
41669
+ function step(op) {
41670
+ if (f) throw new TypeError("Generator is already executing.");
41671
+ while (_) try {
41672
+ 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;
41673
+ if (y = 0, t) op = [op[0] & 2, t.value];
41674
+ switch (op[0]) {
41675
+ case 0:
41676
+ case 1:
41677
+ t = op;
41678
+ break;
41679
+ case 4:
41680
+ _.label++;
41681
+ return {
41682
+ value: op[1],
41683
+ done: false
41684
+ };
41685
+ case 5:
41686
+ _.label++;
41687
+ y = op[1];
41688
+ op = [0];
41689
+ continue;
41690
+ case 7:
41691
+ op = _.ops.pop();
41692
+ _.trys.pop();
41693
+ continue;
41694
+ default:
41695
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
41696
+ _ = 0;
41697
+ continue;
41698
+ }
41699
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
41700
+ _.label = op[1];
41701
+ break;
41702
+ }
41703
+ if (op[0] === 6 && _.label < t[1]) {
41704
+ _.label = t[1];
41705
+ t = op;
41706
+ break;
41707
+ }
41708
+ if (t && _.label < t[2]) {
41709
+ _.label = t[2];
41710
+ _.ops.push(op);
41711
+ break;
41712
+ }
41713
+ if (t[2]) _.ops.pop();
41714
+ _.trys.pop();
41715
+ continue;
41716
+ }
41717
+ op = body.call(thisArg, _);
41718
+ } catch (e) {
41719
+ op = [6, e];
41720
+ y = 0;
41721
+ } finally {
41722
+ f = t = 0;
41723
+ }
41724
+ if (op[0] & 5) throw op[1];
41725
+ return {
41726
+ value: op[0] ? op[1] : void 0,
41727
+ done: true
41728
+ };
41729
+ }
41730
+ };
41731
+ exports.__esModule = true;
41732
+ exports.transformJobOnlyVars = void 0;
41733
+ var envVars_1 = __nccwpck_require__(7185);
41734
+ /**
41735
+ * transform EnvVars for environment.
41736
+ *
41737
+ * currently does not resolve references and is only used for additional job-only-vars
41738
+ * @param vars
41739
+ * @returns
41740
+ */
41741
+ var transformJobOnlyVars = function (env, componentName, vars) {
41742
+ return __awaiter(void 0, void 0, void 0, function () {
41743
+ var publicVars, secretEnvVarKeys, deployJobOnlySecretEnvVars, envVars;
41744
+ var _a, _b;
41745
+ return __generator(this, function (_c) {
41746
+ if (!vars) {
41747
+ return [2 /*return*/, {
41748
+ envVars: {},
41749
+ secretEnvVarKeys: []
41750
+ }];
41751
+ }
41752
+ publicVars = (0, envVars_1.stringifyValues)((_a = vars === null || vars === void 0 ? void 0 : vars.public) !== null && _a !== void 0 ? _a : {});
41753
+ secretEnvVarKeys = (0, envVars_1.stringListToSecreteEnvVarList)((_b = vars === null || vars === void 0 ? void 0 : vars.secret) !== null && _b !== void 0 ? _b : []);
41754
+ deployJobOnlySecretEnvVars = (vars === null || vars === void 0 ? void 0 : vars.secret) ? (0, envVars_1.makeSecretEnvVarMapping)(env, componentName, secretEnvVarKeys) : {};
41755
+ envVars = __assign(__assign({}, deployJobOnlySecretEnvVars), publicVars);
41756
+ return [2 /*return*/, {
41757
+ envVars: envVars,
41758
+ secretEnvVarKeys: secretEnvVarKeys
41759
+ }];
41760
+ });
41761
+ });
41762
+ };
41763
+ exports.transformJobOnlyVars = transformJobOnlyVars;
41764
+
41765
+ /***/ }),
41766
+
41767
+ /***/ 7185:
41768
+ /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
41769
+
41770
+ "use strict";
41771
+
41772
+
41773
+ var __read = this && this.__read || function (o, n) {
41774
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
41775
+ if (!m) return o;
41776
+ var i = m.call(o),
41777
+ r,
41778
+ ar = [],
41779
+ e;
41780
+ try {
41781
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
41782
+ } catch (error) {
41783
+ e = {
41784
+ error: error
41785
+ };
41786
+ } finally {
41787
+ try {
41788
+ if (r && !r.done && (m = i["return"])) m.call(i);
41789
+ } finally {
41790
+ if (e) throw e.error;
41791
+ }
41792
+ }
41793
+ return ar;
41794
+ };
41795
+ exports.__esModule = true;
41796
+ exports.makeSecretEnvVarMapping = exports.stringListToSecreteEnvVarList = exports.stringifyValues = void 0;
41797
+ var lodash_1 = __nccwpck_require__(3255);
41798
+ var getEnvironmentVariables_1 = __nccwpck_require__(6602);
41799
+ var stringifyValues = function (obj) {
41800
+ return Object.fromEntries(Object.entries(obj).map(function (_a) {
41801
+ var _b = __read(_a, 2),
41802
+ key = _b[0],
41803
+ value = _b[1];
41804
+ return [key, (0, lodash_1.isObject)(value) ? JSON.stringify(value) : "".concat(value)];
41805
+ }));
41806
+ };
41807
+ exports.stringifyValues = stringifyValues;
41808
+ var stringListToSecreteEnvVarList = function (keys) {
41809
+ return keys.map(function (key) {
41810
+ return {
41811
+ key: key
41812
+ };
41813
+ });
41814
+ };
41815
+ exports.stringListToSecreteEnvVarList = stringListToSecreteEnvVarList;
41816
+ var makeSecretEnvVarMapping = function (env, componentName, secretEnvVars) {
41817
+ return Object.fromEntries(secretEnvVars.map(function (_a) {
41818
+ var key = _a.key;
41819
+ return [key, "$".concat((0, getEnvironmentVariables_1.getSecretVarName)(env, componentName, key))];
41820
+ }));
41821
+ };
41822
+ exports.makeSecretEnvVarMapping = makeSecretEnvVarMapping;
41823
+
41824
+ /***/ }),
41825
+
41246
41826
  /***/ 7383:
41247
41827
  /***/ ((__unused_webpack_module, exports) => {
41248
41828
 
@@ -41324,7 +41904,7 @@ var getBaseDeploymentJob = function (context) {
41324
41904
  }],
41325
41905
  allow_failure: whenDeploy === "manual" ? true : false,
41326
41906
  stage: "deploy",
41327
- variables: __assign(__assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.componentConfig.deploy ? (_d = context.componentConfig.deploy.extraVars) !== null && _d !== void 0 ? _d : {} : {}),
41907
+ variables: __assign(__assign(__assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.envVars), hasDocker ? (0, docker_1.getDockerImageVariables)(context) : {}), context.environment.jobOnlyVars.deploy.envVars), context.componentConfig.deploy ? (_d = context.componentConfig.deploy.extraVars) !== null && _d !== void 0 ? _d : {} : {}),
41328
41908
  environment: __assign(__assign({}, context.environment.gitlabEnvironment), isStoppable ? {
41329
41909
  on_stop: exports.STOP_JOB_NAME,
41330
41910
  auto_stop_in: autoStop
@@ -41346,7 +41926,7 @@ var getBaseDeploymentStopJob = function (context) {
41346
41926
  when: "manual",
41347
41927
  allow_failure: true
41348
41928
  }],
41349
- variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
41929
+ variables: __assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.jobOnlyVars.deploy.envVars), {
41350
41930
  GIT_STRATEGY: "none"
41351
41931
  }),
41352
41932
  stage: "stop",
@@ -41365,7 +41945,7 @@ var getBaseRollbackJob = function (context) {
41365
41945
  when: "manual",
41366
41946
  allow_failure: true
41367
41947
  }],
41368
- variables: __assign(__assign({}, DEPLOY_RUNNER_VARIABLES), {
41948
+ variables: __assign(__assign(__assign({}, DEPLOY_RUNNER_VARIABLES), context.environment.jobOnlyVars.deploy.envVars), {
41369
41949
  GIT_STRATEGY: "none"
41370
41950
  }),
41371
41951
  stage: "rollback",