@catladder/cli 1.142.2 → 1.144.0
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.
- package/dist/apps/cli/cli.js +2 -1
- package/dist/apps/cli/cli.js.map +1 -1
- package/dist/apps/cli/commands/cloudSQL/index.js +0 -1
- package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -1
- package/dist/apps/cli/commands/general/index.js +0 -14
- package/dist/apps/cli/commands/general/index.js.map +1 -1
- package/dist/apps/cli/commands/project/commandListPods.js +2 -2
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -1
- package/dist/apps/cli/commands/project/index.js +0 -1
- package/dist/apps/cli/commands/project/index.js.map +1 -1
- package/dist/apps/cli/verify/index.js +4 -31
- package/dist/apps/cli/verify/index.js.map +1 -1
- package/dist/bundles/catenv/index.js +3 -3
- package/dist/bundles/cli/index.js +20 -282
- package/dist/config/getProjectConfig.d.ts +0 -2
- package/dist/config/getProjectConfig.js +5 -36
- package/dist/config/getProjectConfig.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/boxWithAscii.d.ts +1 -0
- package/dist/utils/boxWithAscii.js +14 -0
- package/dist/utils/boxWithAscii.js.map +1 -0
- package/dist/utils/editAsFile.js +3 -3
- package/dist/utils/editAsFile.js.map +1 -1
- package/dist/utils/files.d.ts +0 -1
- package/dist/utils/files.js +1 -19
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/preferences/index.js +3 -3
- package/dist/utils/preferences/index.js.map +1 -1
- package/package.json +4 -5
- package/src/apps/cli/cli.ts +4 -1
- package/src/apps/cli/commands/cloudSQL/index.ts +0 -1
- package/src/apps/cli/commands/general/index.ts +0 -6
- package/src/apps/cli/commands/project/commandListPods.ts +4 -2
- package/src/apps/cli/commands/project/index.ts +0 -1
- package/src/apps/cli/verify/index.ts +1 -17
- package/src/config/getProjectConfig.ts +1 -14
- package/src/utils/boxWithAscii.ts +9 -0
- package/src/utils/editAsFile.ts +4 -3
- package/src/utils/files.ts +0 -9
- package/src/utils/preferences/index.ts +4 -6
- package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +0 -3
- package/dist/apps/cli/commands/project/commandInitProject.old.js +0 -345
- package/dist/apps/cli/commands/project/commandInitProject.old.js.map +0 -1
- package/dist/apps/cli/config/writeConfig.d.ts +0 -5
- package/dist/apps/cli/config/writeConfig.js +0 -106
- package/dist/apps/cli/config/writeConfig.js.map +0 -1
- package/dist/apps/cli/verify/migration/fromv2.d.ts +0 -4
- package/dist/apps/cli/verify/migration/fromv2.js +0 -349
- package/dist/apps/cli/verify/migration/fromv2.js.map +0 -1
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +0 -4
- package/dist/apps/cli/verify/migration/migrateSecrets.js +0 -91
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +0 -1
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +0 -18
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +0 -30
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +0 -1
- package/dist/utils/passwordstore/index.d.ts +0 -7
- package/dist/utils/passwordstore/index.js +0 -315
- package/dist/utils/passwordstore/index.js.map +0 -1
- package/src/apps/cli/commands/project/commandInitProject.old.ts +0 -290
- package/src/apps/cli/config/writeConfig.ts +0 -71
- package/src/apps/cli/verify/migration/fromv2.ts +0 -262
- package/src/apps/cli/verify/migration/migrateSecrets.ts +0 -47
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +0 -48
- package/src/utils/passwordstore/index.ts +0 -162
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
exports.__esModule = true;
|
|
42
|
-
exports.trashItem = exports.insertPass = exports.syncBitwarden = exports.readPass = exports.hasBitwarden = exports.getOrganization = exports.getCollection = void 0;
|
|
43
|
-
var child_process_promise_1 = require("child-process-promise");
|
|
44
|
-
var command_exists_promise_1 = __importDefault(require("command-exists-promise"));
|
|
45
|
-
var dayjs_1 = __importDefault(require("dayjs"));
|
|
46
|
-
var preferences_1 = require("../preferences");
|
|
47
|
-
var DEBUG = false;
|
|
48
|
-
var unlockBitwarden = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var promise, session;
|
|
50
|
-
return __generator(this, function (_a) {
|
|
51
|
-
switch (_a.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
console.error("");
|
|
54
|
-
console.error("# Bitwarden is locked, please unlock:");
|
|
55
|
-
console.error("");
|
|
56
|
-
promise = (0, child_process_promise_1.spawn)("bw", ["unlock", "--raw"], {
|
|
57
|
-
stdio: ["inherit", "pipe", "inherit"]
|
|
58
|
-
});
|
|
59
|
-
session = null;
|
|
60
|
-
promise.childProcess.stdout.on("data", function (d) { return (session = d.toString("utf-8")); });
|
|
61
|
-
return [4 /*yield*/, promise];
|
|
62
|
-
case 1:
|
|
63
|
-
_a.sent();
|
|
64
|
-
return [4 /*yield*/, (0, preferences_1.setPreference)("bwsession", session)];
|
|
65
|
-
case 2:
|
|
66
|
-
_a.sent();
|
|
67
|
-
return [2 /*return*/];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}); };
|
|
71
|
-
var loginBitwarden = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
-
var promise, session;
|
|
73
|
-
return __generator(this, function (_a) {
|
|
74
|
-
switch (_a.label) {
|
|
75
|
-
case 0:
|
|
76
|
-
console.error("");
|
|
77
|
-
console.error("# Please login to Bitwarden:");
|
|
78
|
-
console.error("");
|
|
79
|
-
promise = (0, child_process_promise_1.spawn)("bw", ["login", "--raw"], {
|
|
80
|
-
stdio: ["inherit", "pipe", "inherit"]
|
|
81
|
-
});
|
|
82
|
-
session = null;
|
|
83
|
-
promise.childProcess.stdout.on("data", function (d) { return (session = d.toString("utf-8")); });
|
|
84
|
-
return [4 /*yield*/, promise];
|
|
85
|
-
case 1:
|
|
86
|
-
_a.sent();
|
|
87
|
-
return [4 /*yield*/, (0, preferences_1.setPreference)("bwsession", session)];
|
|
88
|
-
case 2:
|
|
89
|
-
_a.sent();
|
|
90
|
-
return [4 /*yield*/, (0, exports.syncBitwarden)(true)];
|
|
91
|
-
case 3:
|
|
92
|
-
_a.sent(); // needs syncing to work properly afterwards
|
|
93
|
-
return [2 /*return*/];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}); };
|
|
97
|
-
var execBitwardenCommand = function (command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
-
var session, fullCommand, stdout, e_1, isLocked, notLoggedIn;
|
|
99
|
-
return __generator(this, function (_a) {
|
|
100
|
-
switch (_a.label) {
|
|
101
|
-
case 0: return [4 /*yield*/, (0, preferences_1.hasPreference)("bwsession")];
|
|
102
|
-
case 1:
|
|
103
|
-
if (!!(_a.sent())) return [3 /*break*/, 3];
|
|
104
|
-
return [4 /*yield*/, loginBitwarden()];
|
|
105
|
-
case 2:
|
|
106
|
-
_a.sent();
|
|
107
|
-
_a.label = 3;
|
|
108
|
-
case 3: return [4 /*yield*/, (0, preferences_1.getPreference)("bwsession")];
|
|
109
|
-
case 4:
|
|
110
|
-
session = _a.sent();
|
|
111
|
-
fullCommand = "BW_SESSION='".concat(session, "' bw ").concat(command, " --raw --nointeraction");
|
|
112
|
-
if (DEBUG) {
|
|
113
|
-
console.log(fullCommand);
|
|
114
|
-
console.time(fullCommand);
|
|
115
|
-
}
|
|
116
|
-
_a.label = 5;
|
|
117
|
-
case 5:
|
|
118
|
-
_a.trys.push([5, 7, , 13]);
|
|
119
|
-
return [4 /*yield*/, (0, child_process_promise_1.exec)(fullCommand)];
|
|
120
|
-
case 6:
|
|
121
|
-
stdout = (_a.sent()).stdout;
|
|
122
|
-
if (DEBUG) {
|
|
123
|
-
console.timeEnd(fullCommand);
|
|
124
|
-
}
|
|
125
|
-
if (!stdout) {
|
|
126
|
-
return [2 /*return*/, null];
|
|
127
|
-
}
|
|
128
|
-
try {
|
|
129
|
-
return [2 /*return*/, JSON.parse(stdout)];
|
|
130
|
-
}
|
|
131
|
-
catch (e) {
|
|
132
|
-
// no json
|
|
133
|
-
return [2 /*return*/, stdout];
|
|
134
|
-
}
|
|
135
|
-
return [3 /*break*/, 13];
|
|
136
|
-
case 7:
|
|
137
|
-
e_1 = _a.sent();
|
|
138
|
-
isLocked = e_1.toString().includes("Vault is locked");
|
|
139
|
-
notLoggedIn = e_1.toString().includes("You are not logged in");
|
|
140
|
-
if (!isLocked) return [3 /*break*/, 9];
|
|
141
|
-
return [4 /*yield*/, unlockBitwarden()];
|
|
142
|
-
case 8:
|
|
143
|
-
_a.sent();
|
|
144
|
-
return [2 /*return*/, execBitwardenCommand(command)];
|
|
145
|
-
case 9:
|
|
146
|
-
if (!notLoggedIn) return [3 /*break*/, 11];
|
|
147
|
-
return [4 /*yield*/, loginBitwarden()];
|
|
148
|
-
case 10:
|
|
149
|
-
_a.sent();
|
|
150
|
-
return [2 /*return*/, execBitwardenCommand(command)];
|
|
151
|
-
case 11: throw e_1;
|
|
152
|
-
case 12: return [3 /*break*/, 13];
|
|
153
|
-
case 13: return [2 /*return*/];
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
}); };
|
|
157
|
-
var getCollection = function (collectionName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
-
return __generator(this, function (_a) {
|
|
159
|
-
return [2 /*return*/, execBitwardenCommand("get collection ".concat(collectionName))];
|
|
160
|
-
});
|
|
161
|
-
}); };
|
|
162
|
-
exports.getCollection = getCollection;
|
|
163
|
-
var getOrganization = function (organizationName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
-
return __generator(this, function (_a) {
|
|
165
|
-
return [2 /*return*/, execBitwardenCommand("get organization ".concat(organizationName))];
|
|
166
|
-
});
|
|
167
|
-
}); };
|
|
168
|
-
exports.getOrganization = getOrganization;
|
|
169
|
-
var catladderCollectionId;
|
|
170
|
-
var getCatladderCollectionId = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
-
return __generator(this, function (_a) {
|
|
172
|
-
switch (_a.label) {
|
|
173
|
-
case 0:
|
|
174
|
-
if (!!catladderCollectionId) return [3 /*break*/, 2];
|
|
175
|
-
return [4 /*yield*/, (0, exports.getCollection)("catladder")];
|
|
176
|
-
case 1:
|
|
177
|
-
catladderCollectionId = (_a.sent()).id;
|
|
178
|
-
_a.label = 2;
|
|
179
|
-
case 2: return [2 /*return*/, catladderCollectionId];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}); };
|
|
183
|
-
var panterOrganizationId;
|
|
184
|
-
var getPanterOrganizationId = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
185
|
-
return __generator(this, function (_a) {
|
|
186
|
-
switch (_a.label) {
|
|
187
|
-
case 0:
|
|
188
|
-
if (!!panterOrganizationId) return [3 /*break*/, 2];
|
|
189
|
-
return [4 /*yield*/, (0, exports.getOrganization)("Panter AG")];
|
|
190
|
-
case 1:
|
|
191
|
-
panterOrganizationId = (_a.sent()).id;
|
|
192
|
-
_a.label = 2;
|
|
193
|
-
case 2: return [2 /*return*/, panterOrganizationId];
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}); };
|
|
197
|
-
var encode = function (data) {
|
|
198
|
-
return Buffer.from(JSON.stringify(data)).toString("base64");
|
|
199
|
-
};
|
|
200
|
-
var hasBitwarden = function () { return (0, command_exists_promise_1["default"])("bw"); };
|
|
201
|
-
exports.hasBitwarden = hasBitwarden;
|
|
202
|
-
var getItem = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
203
|
-
return __generator(this, function (_a) {
|
|
204
|
-
return [2 /*return*/, execBitwardenCommand("get item ".concat(path))];
|
|
205
|
-
});
|
|
206
|
-
}); };
|
|
207
|
-
var readPass = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
-
var result;
|
|
209
|
-
var _a;
|
|
210
|
-
return __generator(this, function (_b) {
|
|
211
|
-
switch (_b.label) {
|
|
212
|
-
case 0: return [4 /*yield*/, getItem(path)];
|
|
213
|
-
case 1:
|
|
214
|
-
result = _b.sent();
|
|
215
|
-
return [2 /*return*/, result.notes || ((_a = result.login) === null || _a === void 0 ? void 0 : _a.password)];
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}); };
|
|
219
|
-
exports.readPass = readPass;
|
|
220
|
-
var MAX_SYNC_AGE_IN_MINUTES = 30;
|
|
221
|
-
var syncBitwarden = function (force) {
|
|
222
|
-
if (force === void 0) { force = true; }
|
|
223
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
-
var lastSync, _a;
|
|
225
|
-
return __generator(this, function (_b) {
|
|
226
|
-
switch (_b.label) {
|
|
227
|
-
case 0: return [4 /*yield*/, (0, preferences_1.hasPreference)("bwLastSync")];
|
|
228
|
-
case 1:
|
|
229
|
-
if (!(_b.sent())) return [3 /*break*/, 3];
|
|
230
|
-
return [4 /*yield*/, (0, preferences_1.getPreference)("bwLastSync")];
|
|
231
|
-
case 2:
|
|
232
|
-
_a = _b.sent();
|
|
233
|
-
return [3 /*break*/, 4];
|
|
234
|
-
case 3:
|
|
235
|
-
_a = null;
|
|
236
|
-
_b.label = 4;
|
|
237
|
-
case 4:
|
|
238
|
-
lastSync = _a;
|
|
239
|
-
if (!(force ||
|
|
240
|
-
!lastSync ||
|
|
241
|
-
(0, dayjs_1["default"])().diff(lastSync, "minutes") >= MAX_SYNC_AGE_IN_MINUTES)) return [3 /*break*/, 7];
|
|
242
|
-
return [4 /*yield*/, execBitwardenCommand("sync")];
|
|
243
|
-
case 5:
|
|
244
|
-
_b.sent();
|
|
245
|
-
return [4 /*yield*/, (0, preferences_1.setPreference)("bwLastSync", new Date().toISOString())];
|
|
246
|
-
case 6:
|
|
247
|
-
_b.sent();
|
|
248
|
-
return [3 /*break*/, 7];
|
|
249
|
-
case 7: return [2 /*return*/];
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
exports.syncBitwarden = syncBitwarden;
|
|
255
|
-
var insertPass = function (path, content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
256
|
-
var value, result;
|
|
257
|
-
var _a;
|
|
258
|
-
return __generator(this, function (_b) {
|
|
259
|
-
switch (_b.label) {
|
|
260
|
-
case 0:
|
|
261
|
-
_a = {
|
|
262
|
-
type: 2,
|
|
263
|
-
secureNote: { type: 0 },
|
|
264
|
-
name: path,
|
|
265
|
-
notes: content
|
|
266
|
-
};
|
|
267
|
-
return [4 /*yield*/, getCatladderCollectionId()];
|
|
268
|
-
case 1:
|
|
269
|
-
value = (_a.collectionIds = [_b.sent()],
|
|
270
|
-
_a);
|
|
271
|
-
return [4 /*yield*/, execBitwardenCommand("create item ".concat(encode(value)))];
|
|
272
|
-
case 2:
|
|
273
|
-
result = _b.sent();
|
|
274
|
-
return [4 /*yield*/, share(result.id)];
|
|
275
|
-
case 3:
|
|
276
|
-
_b.sent();
|
|
277
|
-
return [2 /*return*/];
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
}); };
|
|
281
|
-
exports.insertPass = insertPass;
|
|
282
|
-
var share = function (itemId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
283
|
-
var _a, _b, _c, _d, _e, _f;
|
|
284
|
-
return __generator(this, function (_g) {
|
|
285
|
-
switch (_g.label) {
|
|
286
|
-
case 0:
|
|
287
|
-
_a = execBitwardenCommand;
|
|
288
|
-
_d = (_c = "share ".concat(itemId, " ")).concat;
|
|
289
|
-
return [4 /*yield*/, getPanterOrganizationId()];
|
|
290
|
-
case 1:
|
|
291
|
-
_e = (_b = _d.apply(_c, [_g.sent(), " "])).concat;
|
|
292
|
-
_f = encode;
|
|
293
|
-
return [4 /*yield*/, getCatladderCollectionId()];
|
|
294
|
-
case 2: return [2 /*return*/, _a.apply(void 0, [_e.apply(_b, [_f.apply(void 0, [[
|
|
295
|
-
_g.sent()
|
|
296
|
-
]])])])];
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
}); };
|
|
300
|
-
var trashItem = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
301
|
-
var item, result;
|
|
302
|
-
return __generator(this, function (_a) {
|
|
303
|
-
switch (_a.label) {
|
|
304
|
-
case 0: return [4 /*yield*/, getItem(path)];
|
|
305
|
-
case 1:
|
|
306
|
-
item = _a.sent();
|
|
307
|
-
return [4 /*yield*/, execBitwardenCommand("delete item ".concat(item.id))];
|
|
308
|
-
case 2:
|
|
309
|
-
result = _a.sent();
|
|
310
|
-
return [2 /*return*/, result];
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
}); };
|
|
314
|
-
exports.trashItem = trashItem;
|
|
315
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/passwordstore/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAoD;AACpD,kFAAmD;AACnD,gDAA0B;AAC1B,8CAA6E;AAE7E,IAAM,KAAK,GAAG,KAAK,CAAC;AAEpB,IAAM,eAAe,GAAG;;;;;gBACtB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACl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,IAAY,EAAE,OAAe;;;;;;;oBAE1D,IAAI,EAAE,CAAC;oBACP,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;oBACvB,IAAI,EAAE,IAAI;oBAEV,KAAK,EAAE,OAAO;;gBACE,qBAAM,wBAAwB,EAAE,EAAA;;gBAN5C,KAAK,IAMT,gBAAa,IAAG,SAAgC,CAAC;uBAClD;gBACc,qBAAM,oBAAoB,CAAC,sBAAe,MAAM,CAAC,KAAK,CAAC,CAAE,CAAC,EAAA;;gBAAnE,MAAM,GAAG,SAA0D;gBACzE,qBAAM,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAA;;gBAAtB,SAAsB,CAAC;;;;KACxB,CAAC;AAXW,QAAA,UAAU,cAWrB;AAEF,IAAM,KAAK,GAAG,UAAO,MAAc;;;;;gBACjC,KAAA,oBAAoB,CAAA;2CACT,MAAM;gBAAI,qBAAM,uBAAuB,EAAE,EAAA;;yCAA/B,SAA+B;gBAAI,KAAA,MAAM,CAAA;gBAC1D,qBAAM,wBAAwB,EAAE,EAAA;oBAFpC,sBAAA,kBACE,cAAsD;gCACpD,SAAgC;+BAChC,EAAE,EACL,EAAA;;;KAAA,CAAC;AAEG,IAAM,SAAS,GAAG,UAAO,IAAY;;;;oBAC7B,qBAAM,OAAO,CAAC,IAAI,CAAC,EAAA;;gBAA1B,IAAI,GAAG,SAAmB;gBAEjB,qBAAM,oBAAoB,CAAC,sBAAe,IAAI,CAAC,EAAE,CAAE,CAAC,EAAA;;gBAA7D,MAAM,GAAG,SAAoD;gBAEnE,sBAAO,MAAM,EAAC;;;KACf,CAAC;AANW,QAAA,SAAS,aAMpB"}
|
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile } from "fs-extra";
|
|
2
|
-
import { dump } from "js-yaml";
|
|
3
|
-
import { mapKeys, snakeCase, toUpper } from "lodash";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import type Vorpal from "vorpal";
|
|
6
|
-
import { hasGitlabCiFile } from "../../../../utils/projects";
|
|
7
|
-
|
|
8
|
-
const transformVar = (key: string) => toUpper(snakeCase(key));
|
|
9
|
-
type GitlabCiIncludeObj = {
|
|
10
|
-
project: string;
|
|
11
|
-
ref: string;
|
|
12
|
-
file: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type FileToCreate = {
|
|
16
|
-
filename: string;
|
|
17
|
-
content: string | (() => Promise<string>);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type PlatformDefinition = {
|
|
21
|
-
variables: {
|
|
22
|
-
[key: string]: string;
|
|
23
|
-
};
|
|
24
|
-
gitlabCiInclude: GitlabCiIncludeObj;
|
|
25
|
-
values: { [key: string]: unknown };
|
|
26
|
-
filesToCreate?: FileToCreate[];
|
|
27
|
-
};
|
|
28
|
-
const DEFAULT_VARIABLES = {
|
|
29
|
-
clusterName: "production",
|
|
30
|
-
};
|
|
31
|
-
// TODO: we should find a way how to fetch the variables of the inclues directly from gitlab
|
|
32
|
-
const DEFAULT_NODE_asdfAPPLICATION = {};
|
|
33
|
-
|
|
34
|
-
const DEFAULT_FILES_TO_CREATE: FileToCreate[] = [
|
|
35
|
-
{
|
|
36
|
-
filename: ".envrc",
|
|
37
|
-
content: async () =>
|
|
38
|
-
readFile(path.resolve(__dirname, "../includes/envrc"), "utf8"),
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
/*
|
|
42
|
-
|
|
43
|
-
TODO: reimplement as PRESETS ?
|
|
44
|
-
const PLATFORMS: { [platformName: string]: PlatformDefinition } = {
|
|
45
|
-
nextJS: {
|
|
46
|
-
variables: {},
|
|
47
|
-
gitlabCiInclude: {
|
|
48
|
-
project: "catladder/gitlab-ci",
|
|
49
|
-
ref: "v1",
|
|
50
|
-
file: "node-kubernetes.yml",
|
|
51
|
-
},
|
|
52
|
-
values: {
|
|
53
|
-
application: DEFAULT_NODE_APPLICATION,
|
|
54
|
-
},
|
|
55
|
-
filesToCreate: [
|
|
56
|
-
{
|
|
57
|
-
content: "v14",
|
|
58
|
-
filename: ".nvmrc",
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
nestJS: {
|
|
63
|
-
variables: {},
|
|
64
|
-
gitlabCiInclude: {
|
|
65
|
-
project: "catladder/gitlab-ci",
|
|
66
|
-
ref: "v1",
|
|
67
|
-
file: "node-kubernetes.yml",
|
|
68
|
-
},
|
|
69
|
-
values: {
|
|
70
|
-
application: {
|
|
71
|
-
command: "yarn start:prod --port $(PORT)",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
filesToCreate: [
|
|
75
|
-
{
|
|
76
|
-
content: "v14",
|
|
77
|
-
filename: ".nvmrc",
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
node: {
|
|
82
|
-
variables: {},
|
|
83
|
-
gitlabCiInclude: {
|
|
84
|
-
project: "catladder/gitlab-ci",
|
|
85
|
-
ref: "v1",
|
|
86
|
-
file: "node-kubernetes.yml",
|
|
87
|
-
},
|
|
88
|
-
values: {
|
|
89
|
-
application: DEFAULT_NODE_APPLICATION,
|
|
90
|
-
},
|
|
91
|
-
filesToCreate: [
|
|
92
|
-
{
|
|
93
|
-
content: "v14",
|
|
94
|
-
filename: ".nvmrc",
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
staticJs: {
|
|
99
|
-
variables: {},
|
|
100
|
-
gitlabCiInclude: {
|
|
101
|
-
project: "catladder/gitlab-ci",
|
|
102
|
-
ref: "v1",
|
|
103
|
-
file: "static-js-kubernetes.yml",
|
|
104
|
-
},
|
|
105
|
-
values: {},
|
|
106
|
-
},
|
|
107
|
-
meteor: {
|
|
108
|
-
variables: {},
|
|
109
|
-
gitlabCiInclude: {
|
|
110
|
-
project: "gitlab-ci/meteor-kubernetes",
|
|
111
|
-
ref: "v1",
|
|
112
|
-
file: "meteor-kubernetes.yml",
|
|
113
|
-
},
|
|
114
|
-
values: {},
|
|
115
|
-
},
|
|
116
|
-
rails: {
|
|
117
|
-
variables: {},
|
|
118
|
-
gitlabCiInclude: {
|
|
119
|
-
project: "catladder/gitlab-ci",
|
|
120
|
-
ref: "v1",
|
|
121
|
-
file: "rails-kubernetes.yml",
|
|
122
|
-
},
|
|
123
|
-
values: {
|
|
124
|
-
env: {
|
|
125
|
-
public: {
|
|
126
|
-
RAILS_ENV: "production",
|
|
127
|
-
PORT: 8080,
|
|
128
|
-
},
|
|
129
|
-
secret: {
|
|
130
|
-
POSTGRESQL_PASSWORD: "app-secrets",
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
application: {
|
|
134
|
-
command: ["/cnb/process/web"],
|
|
135
|
-
livenessProbe: {
|
|
136
|
-
httpGet: {
|
|
137
|
-
path: "/robots.txt",
|
|
138
|
-
httpHeaders: null,
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
readinessProbe: {
|
|
142
|
-
httpGet: {
|
|
143
|
-
path: "/robots.txt",
|
|
144
|
-
httpHeaders: null,
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
cloudsql: { enabled: true },
|
|
149
|
-
jobs: {
|
|
150
|
-
"db-prepare": {
|
|
151
|
-
hook: "post-install,post-upgrade",
|
|
152
|
-
command: "/cnb/lifecycle/launcher bundle exec rake db:prepare",
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
filesToCreate: [
|
|
157
|
-
{
|
|
158
|
-
filename: "values-review.yml",
|
|
159
|
-
content: async () =>
|
|
160
|
-
dump({
|
|
161
|
-
jobs: {
|
|
162
|
-
"db-prepare-seed": {
|
|
163
|
-
hook: "post-install",
|
|
164
|
-
command:
|
|
165
|
-
"/cnb/lifecycle/launcher bundle exec rake db:prepare db:seed",
|
|
166
|
-
},
|
|
167
|
-
"db-prepare": {
|
|
168
|
-
hook: "post-upgrade",
|
|
169
|
-
command: "/cnb/lifecycle/launcher bundle exec rake db:prepare",
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
}),
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
other: {
|
|
177
|
-
variables: {},
|
|
178
|
-
gitlabCiInclude: {
|
|
179
|
-
project: "catladder/gitlab-ci",
|
|
180
|
-
ref: "v1",
|
|
181
|
-
file: "panter-kubernetes-base.yml",
|
|
182
|
-
},
|
|
183
|
-
values: {},
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
const PLATFORMS: any = {};
|
|
190
|
-
export default async (vorpal: Vorpal) =>
|
|
191
|
-
vorpal
|
|
192
|
-
.command("project-init", "Inits a new project")
|
|
193
|
-
.action(async function () {
|
|
194
|
-
throw new Error("needs reimplementation");
|
|
195
|
-
const hasGitlabFile = await hasGitlabCiFile();
|
|
196
|
-
if (hasGitlabFile) {
|
|
197
|
-
this.log("there is already a gitlab-ci.yml file. Skipping");
|
|
198
|
-
} else {
|
|
199
|
-
this.log("Alright. Let's do this! 😼");
|
|
200
|
-
this.log("");
|
|
201
|
-
|
|
202
|
-
const questions = [
|
|
203
|
-
{
|
|
204
|
-
type: "input",
|
|
205
|
-
name: "customerName",
|
|
206
|
-
default: "pan",
|
|
207
|
-
message: "Which customer?",
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
type: "input",
|
|
211
|
-
name: "appName",
|
|
212
|
-
message: "What is the app's name?",
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
type: "input",
|
|
216
|
-
name: "componentName",
|
|
217
|
-
default: "web",
|
|
218
|
-
message:
|
|
219
|
-
"And the componentName?\n(in multi-app projects, you have to chose a different componentName for each app, e.g. frontend and backend)\n\n",
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
type: "list",
|
|
223
|
-
name: "platform",
|
|
224
|
-
choices: Object.keys(PLATFORMS),
|
|
225
|
-
message: "What is your app platform?",
|
|
226
|
-
},
|
|
227
|
-
].map((q) => ({
|
|
228
|
-
...q,
|
|
229
|
-
validate: Boolean,
|
|
230
|
-
message: `${q.message} `,
|
|
231
|
-
}));
|
|
232
|
-
const { customerName, appName, componentName, platform } =
|
|
233
|
-
await this.prompt(questions);
|
|
234
|
-
|
|
235
|
-
const {
|
|
236
|
-
gitlabCiInclude,
|
|
237
|
-
variables: platformVariables,
|
|
238
|
-
values,
|
|
239
|
-
filesToCreate,
|
|
240
|
-
} = PLATFORMS[platform];
|
|
241
|
-
|
|
242
|
-
const allVariables = {
|
|
243
|
-
customerName,
|
|
244
|
-
appName,
|
|
245
|
-
componentName,
|
|
246
|
-
...DEFAULT_VARIABLES,
|
|
247
|
-
...platformVariables,
|
|
248
|
-
};
|
|
249
|
-
const allFilesToCreate = [
|
|
250
|
-
...DEFAULT_FILES_TO_CREATE,
|
|
251
|
-
...(filesToCreate ?? []),
|
|
252
|
-
];
|
|
253
|
-
const transformedVariables = mapKeys(allVariables, (value, key) =>
|
|
254
|
-
transformVar(key)
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
const gitlabCiContentObj = {
|
|
258
|
-
include: [gitlabCiInclude],
|
|
259
|
-
variables: transformedVariables,
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
const gitlabCiContent = dump(gitlabCiContentObj);
|
|
263
|
-
await writeFile(".gitlab-ci.yml", gitlabCiContent);
|
|
264
|
-
|
|
265
|
-
allFilesToCreate.forEach(async ({ filename, content }) => {
|
|
266
|
-
const theContent =
|
|
267
|
-
typeof content === "function" ? await content() : content;
|
|
268
|
-
await writeFile(filename, theContent);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
await writeFile("values.yml", dump(values));
|
|
272
|
-
|
|
273
|
-
this.log("");
|
|
274
|
-
this.log("gitlab-ci created! 💪😻");
|
|
275
|
-
this.log("feel free to adjust it to your needs!");
|
|
276
|
-
this.log("");
|
|
277
|
-
this.log("we also create an .envrc for you which works with direnv");
|
|
278
|
-
this.log("");
|
|
279
|
-
}
|
|
280
|
-
const { shouldContinue } = await this.prompt({
|
|
281
|
-
default: true,
|
|
282
|
-
message:
|
|
283
|
-
"should we continue with setting up your gitlab? 🤔 (connecting cluster and stuff)",
|
|
284
|
-
name: "shouldContinue",
|
|
285
|
-
type: "confirm",
|
|
286
|
-
});
|
|
287
|
-
if (shouldContinue) {
|
|
288
|
-
await vorpal.execSync(`project-init-gitlab`);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { Config } from "@catladder/pipeline";
|
|
2
|
-
import { spawn, exec } from "child-process-promise";
|
|
3
|
-
import { writeFile } from "fs-extra";
|
|
4
|
-
import { dump } from "js-yaml";
|
|
5
|
-
import { format } from "prettier";
|
|
6
|
-
import type { CommandInstance } from "vorpal";
|
|
7
|
-
import { getGitRoot } from "../../../utils/projects";
|
|
8
|
-
|
|
9
|
-
export const writeConfig = async (
|
|
10
|
-
vorpal: CommandInstance,
|
|
11
|
-
config: Config,
|
|
12
|
-
options?: {
|
|
13
|
-
endComment?: string;
|
|
14
|
-
}
|
|
15
|
-
) => {
|
|
16
|
-
const gitRoot = await getGitRoot();
|
|
17
|
-
const TS = "typescript (recommended)";
|
|
18
|
-
const { configType } = await vorpal.prompt({
|
|
19
|
-
type: "list",
|
|
20
|
-
name: "configType",
|
|
21
|
-
choices: [TS, "yaml"],
|
|
22
|
-
message: "In which format do you want the config? 🤔",
|
|
23
|
-
});
|
|
24
|
-
vorpal.log("");
|
|
25
|
-
if (configType === TS) {
|
|
26
|
-
const file = gitRoot + "/catladder.ts";
|
|
27
|
-
const content = format(
|
|
28
|
-
`
|
|
29
|
-
import type { Config } from "@catladder/pipeline";
|
|
30
|
-
|
|
31
|
-
const config: Config = ${JSON.stringify(config)};
|
|
32
|
-
|
|
33
|
-
export default config;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
${options?.endComment ? `/*${options.endComment}*/` : ""}
|
|
37
|
-
|
|
38
|
-
`,
|
|
39
|
-
{
|
|
40
|
-
parser: "babel",
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
await writeFile(file, content, {
|
|
45
|
-
encoding: "utf-8",
|
|
46
|
-
});
|
|
47
|
-
vorpal.log("adding type @catladder/pipeline....");
|
|
48
|
-
await spawn("yarn add --non-interactive @catladder/pipeline -DW", {
|
|
49
|
-
shell: true,
|
|
50
|
-
});
|
|
51
|
-
await exec("git add " + file);
|
|
52
|
-
} else {
|
|
53
|
-
const file = gitRoot + "/catladder.yml";
|
|
54
|
-
const content = dump(config);
|
|
55
|
-
|
|
56
|
-
await writeFile(
|
|
57
|
-
file,
|
|
58
|
-
content +
|
|
59
|
-
"\n\n" +
|
|
60
|
-
(options.endComment
|
|
61
|
-
? "# " + options.endComment.split("\n").join("\n# ")
|
|
62
|
-
: ""),
|
|
63
|
-
{
|
|
64
|
-
encoding: "utf-8",
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
await exec("git add " + file);
|
|
68
|
-
}
|
|
69
|
-
vorpal.log("done!");
|
|
70
|
-
vorpal.log("");
|
|
71
|
-
};
|