@catladder/cli 0.0.1-bla → 1.0.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/.nvmrc +1 -1
- package/bin/catenv +3 -0
- package/bin/catladder +1 -1
- package/dist/apps/catenv/catenv.d.ts +2 -0
- package/dist/apps/catenv/catenv.js +135 -0
- package/dist/apps/catenv/catenv.js.map +1 -0
- package/dist/apps/cli/cli.d.ts +2 -0
- package/dist/apps/cli/cli.js +81 -0
- package/dist/apps/cli/cli.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +4 -0
- package/dist/apps/cli/commands/general/index.js +274 -0
- package/dist/apps/cli/commands/general/index.js.map +1 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.d.ts +3 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js +56 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js.map +1 -0
- package/dist/apps/cli/commands/general/portForward.d.ts +3 -0
- package/dist/apps/cli/commands/general/portForward.js +98 -0
- package/dist/apps/cli/commands/general/portForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/index.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/index.js +53 -0
- package/dist/apps/cli/commands/mongodb/index.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +190 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js +96 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +105 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/utils/index.d.ts +13 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js +167 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +128 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +254 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCopyDB.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandCopyDB.js +102 -0
- package/dist/apps/cli/commands/project/commandCopyDB.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js +119 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js +97 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js +74 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +58 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetShell.js +92 -0
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js +185 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.js +245 -0
- package/dist/apps/cli/commands/project/commandInitGitlab.js.map +1 -0
- package/dist/apps/cli/commands/project/commandInitProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitProject.js +345 -0
- package/dist/apps/cli/commands/project/commandInitProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandListPods.js +78 -0
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js +113 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
- package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +92 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js +56 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +99 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js +87 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPortForward.js +106 -0
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.js +62 -0
- package/dist/apps/cli/commands/project/commandReloadConfig.js.map +1 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
- package/dist/apps/cli/commands/project/index.d.ts +3 -0
- package/dist/apps/cli/commands/project/index.js +97 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +92 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
- package/dist/apps/cli/commands/shared/index.d.ts +2 -0
- package/dist/apps/cli/commands/shared/index.js +72 -0
- package/dist/apps/cli/commands/shared/index.js.map +1 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +131 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
- package/dist/apps/cli/config/writeConfig.d.ts +5 -0
- package/dist/apps/cli/config/writeConfig.js +104 -0
- package/dist/apps/cli/config/writeConfig.js.map +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
- package/dist/apps/cli/verify/index.d.ts +2 -0
- package/dist/apps/cli/verify/index.js +90 -0
- package/dist/apps/cli/verify/index.js.map +1 -0
- package/dist/apps/cli/verify/migration/fromv2.d.ts +3 -0
- package/dist/apps/cli/verify/migration/fromv2.js +322 -0
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js +88 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +17 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +26 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
- package/dist/catenv.d.ts +1 -0
- package/dist/catenv.js +8 -0
- package/dist/catenv.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/clusters.d.ts +14 -0
- package/dist/config/clusters.js +72 -0
- package/dist/config/clusters.js.map +1 -0
- package/dist/config/constants.d.ts +4 -0
- package/dist/config/constants.js +8 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/getProjectConfig.d.ts +21 -0
- package/dist/config/getProjectConfig.js +212 -0
- package/dist/config/getProjectConfig.js.map +1 -0
- package/dist/k8sApi/index.d.ts +5 -0
- package/dist/k8sApi/index.js +11 -0
- package/dist/k8sApi/index.js.map +1 -0
- package/dist/packageInfos.d.ts +2 -0
- package/dist/packageInfos.js +6 -0
- package/dist/packageInfos.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types.d.ts +18 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/cluster.d.ts +12 -0
- package/dist/utils/cluster.js +100 -0
- package/dist/utils/cluster.js.map +1 -0
- package/dist/utils/dashboardToken.d.ts +2 -0
- package/dist/utils/dashboardToken.js +89 -0
- package/dist/utils/dashboardToken.js.map +1 -0
- package/dist/utils/editAsFile.d.ts +1 -0
- package/dist/utils/editAsFile.js +85 -0
- package/dist/utils/editAsFile.js.map +1 -0
- package/dist/utils/files.d.ts +2 -0
- package/dist/utils/files.js +83 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/formatEnvVars.d.ts +2 -0
- package/dist/utils/formatEnvVars.js +10 -0
- package/dist/utils/formatEnvVars.js.map +1 -0
- package/dist/utils/getEditor.d.ts +4 -0
- package/dist/utils/getEditor.js +70 -0
- package/dist/utils/getEditor.js.map +1 -0
- package/dist/utils/gitlab.d.ts +21 -0
- package/dist/utils/gitlab.js +258 -0
- package/dist/utils/gitlab.js.map +1 -0
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/passwordstore/index.d.ts +8 -0
- package/dist/utils/passwordstore/index.js +378 -0
- package/dist/utils/passwordstore/index.js.map +1 -0
- package/dist/utils/portForward.d.ts +4 -0
- package/dist/utils/portForward.js +116 -0
- package/dist/utils/portForward.js.map +1 -0
- package/dist/utils/preferences/index.d.ts +3 -0
- package/dist/utils/preferences/index.js +119 -0
- package/dist/utils/preferences/index.js.map +1 -0
- package/dist/utils/projects/index.d.ts +8 -0
- package/dist/utils/projects/index.js +150 -0
- package/dist/utils/projects/index.js.map +1 -0
- package/dist/utils/promise.d.ts +2 -0
- package/dist/utils/promise.js +62 -0
- package/dist/utils/promise.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.js +81 -0
- package/dist/utils/shell.js.map +1 -0
- package/package.json +10 -11
- package/src/apps/catenv/catenv.ts +48 -27
- package/src/apps/{shell/shell.ts → cli/cli.ts} +12 -2
- package/src/apps/{shell → cli}/commands/general/index.ts +1 -1
- package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
- package/src/apps/{shell → cli}/commands/general/portForward.ts +1 -1
- package/src/apps/{shell → cli}/commands/mongodb/index.ts +1 -1
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +18 -18
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +12 -10
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoPortForward.ts +13 -8
- package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +9 -8
- package/src/apps/{shell → cli}/commands/project/commandCloudSqlProxy.ts +23 -17
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +204 -0
- package/src/apps/{shell → cli}/commands/project/commandCopyDB.ts +22 -23
- package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +8 -9
- package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +7 -8
- package/src/apps/cli/commands/project/commandEnvVars.ts +15 -0
- package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +2 -2
- package/src/apps/{shell → cli}/commands/project/commandGetShell.ts +10 -10
- package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +1 -1
- package/src/apps/cli/commands/project/commandInitGitlab.ts +203 -0
- package/src/apps/{shell → cli}/commands/project/commandInitProject.ts +14 -6
- package/src/apps/cli/commands/project/commandListPods.ts +18 -0
- package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +16 -7
- package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenCostDashboard.ts +10 -7
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +45 -0
- package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +1 -1
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +7 -7
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +9 -10
- package/src/apps/{shell → cli}/commands/project/commandOpenLogs.ts +7 -7
- package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +9 -7
- package/src/apps/{shell → cli}/commands/project/commandPortForward.ts +8 -8
- package/src/apps/cli/commands/project/commandReloadConfig.ts +12 -0
- package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +7 -7
- package/src/apps/{shell → cli}/commands/project/index.ts +4 -3
- package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
- package/src/apps/cli/commands/project/utils/ensureCluster.ts +37 -0
- package/src/apps/{shell → cli}/commands/project/utils/ensureNamespace.ts +2 -3
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
- package/src/apps/{shell → cli}/commands/shared/index.ts +0 -0
- package/src/apps/{shell → cli}/commands/theStuffThatReallyMatters/index.ts +11 -11
- package/src/apps/cli/config/writeConfig.ts +69 -0
- package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
- package/src/apps/cli/verify/index.ts +34 -0
- package/src/apps/cli/verify/migration/fromv2.ts +242 -0
- package/src/apps/cli/verify/migration/migrateSecrets.ts +37 -0
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +43 -0
- package/src/catenv.ts +3 -0
- package/src/cli.ts +8 -0
- package/src/config/getProjectConfig.ts +118 -0
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +15 -2
- package/src/utils/editAsFile.ts +31 -0
- package/src/utils/files.ts +6 -2
- package/src/utils/gitlab.ts +126 -32
- package/src/utils/passwordstore/index.ts +19 -21
- package/src/utils/preferences/index.ts +6 -3
- package/src/utils/projects/index.ts +14 -134
- package/tsconfig.json +3 -7
- package/bin/catenv.sh +0 -1
- package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
- package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
- package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
- package/src/apps/shell/commands/project/commandListPods.ts +0 -21
- package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
- package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
- package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
- package/src/apps/shell/commands/project/commandVariables.ts +0 -13
- package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
- package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
- package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
- package/src/index.ts +0 -17
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
exports.__esModule = true;
|
|
53
|
+
exports.editPass = exports.trashItem = exports.insertPass = exports.syncBitwarden = exports.readPass = exports.hasBitwarden = exports.getOrganization = exports.getCollection = void 0;
|
|
54
|
+
var child_process_promise_1 = require("child-process-promise");
|
|
55
|
+
var command_exists_promise_1 = __importDefault(require("command-exists-promise"));
|
|
56
|
+
var dayjs_1 = __importDefault(require("dayjs"));
|
|
57
|
+
var fs_extra_1 = require("fs-extra");
|
|
58
|
+
var tmp_promise_1 = require("tmp-promise");
|
|
59
|
+
var getEditor_1 = __importDefault(require("../getEditor"));
|
|
60
|
+
var preferences_1 = require("../preferences");
|
|
61
|
+
var DEBUG = false;
|
|
62
|
+
var unlockBitwarden = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
63
|
+
var promise, session;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
console.error("");
|
|
68
|
+
console.error("# Bitwarden is locked, please unlock:");
|
|
69
|
+
console.error("");
|
|
70
|
+
promise = (0, child_process_promise_1.spawn)("bw", ["unlock", "--raw"], {
|
|
71
|
+
stdio: ["inherit", "pipe", "inherit"]
|
|
72
|
+
});
|
|
73
|
+
session = null;
|
|
74
|
+
promise.childProcess.stdout.on("data", function (d) { return (session = d.toString("utf-8")); });
|
|
75
|
+
return [4 /*yield*/, promise];
|
|
76
|
+
case 1:
|
|
77
|
+
_a.sent();
|
|
78
|
+
return [4 /*yield*/, (0, preferences_1.setPreference)("bwsession", session)];
|
|
79
|
+
case 2:
|
|
80
|
+
_a.sent();
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); };
|
|
85
|
+
var loginBitwarden = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
+
var promise, session;
|
|
87
|
+
return __generator(this, function (_a) {
|
|
88
|
+
switch (_a.label) {
|
|
89
|
+
case 0:
|
|
90
|
+
console.error("");
|
|
91
|
+
console.error("# Please login to Bitwarden:");
|
|
92
|
+
console.error("");
|
|
93
|
+
promise = (0, child_process_promise_1.spawn)("bw", ["login", "--raw"], {
|
|
94
|
+
stdio: ["inherit", "pipe", "inherit"]
|
|
95
|
+
});
|
|
96
|
+
session = null;
|
|
97
|
+
promise.childProcess.stdout.on("data", function (d) { return (session = d.toString("utf-8")); });
|
|
98
|
+
return [4 /*yield*/, promise];
|
|
99
|
+
case 1:
|
|
100
|
+
_a.sent();
|
|
101
|
+
return [4 /*yield*/, (0, preferences_1.setPreference)("bwsession", session)];
|
|
102
|
+
case 2:
|
|
103
|
+
_a.sent();
|
|
104
|
+
return [4 /*yield*/, (0, exports.syncBitwarden)(true)];
|
|
105
|
+
case 3:
|
|
106
|
+
_a.sent(); // needs syncing to work properly afterwards
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); };
|
|
111
|
+
var execBitwardenCommand = function (command) { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var session, fullCommand, stdout, e_1, isLocked, notLoggedIn;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0: return [4 /*yield*/, (0, preferences_1.hasPreference)("bwsession")];
|
|
116
|
+
case 1:
|
|
117
|
+
if (!!(_a.sent())) return [3 /*break*/, 3];
|
|
118
|
+
return [4 /*yield*/, loginBitwarden()];
|
|
119
|
+
case 2:
|
|
120
|
+
_a.sent();
|
|
121
|
+
_a.label = 3;
|
|
122
|
+
case 3: return [4 /*yield*/, (0, preferences_1.getPreference)("bwsession")];
|
|
123
|
+
case 4:
|
|
124
|
+
session = _a.sent();
|
|
125
|
+
fullCommand = "BW_SESSION='".concat(session, "' bw ").concat(command, " --raw --nointeraction");
|
|
126
|
+
if (DEBUG) {
|
|
127
|
+
console.log(fullCommand);
|
|
128
|
+
console.time(fullCommand);
|
|
129
|
+
}
|
|
130
|
+
_a.label = 5;
|
|
131
|
+
case 5:
|
|
132
|
+
_a.trys.push([5, 7, , 13]);
|
|
133
|
+
return [4 /*yield*/, (0, child_process_promise_1.exec)(fullCommand)];
|
|
134
|
+
case 6:
|
|
135
|
+
stdout = (_a.sent()).stdout;
|
|
136
|
+
if (DEBUG) {
|
|
137
|
+
console.timeEnd(fullCommand);
|
|
138
|
+
}
|
|
139
|
+
if (!stdout) {
|
|
140
|
+
return [2 /*return*/, null];
|
|
141
|
+
}
|
|
142
|
+
try {
|
|
143
|
+
return [2 /*return*/, JSON.parse(stdout)];
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
// no json
|
|
147
|
+
return [2 /*return*/, stdout];
|
|
148
|
+
}
|
|
149
|
+
return [3 /*break*/, 13];
|
|
150
|
+
case 7:
|
|
151
|
+
e_1 = _a.sent();
|
|
152
|
+
isLocked = e_1.toString().includes("Vault is locked");
|
|
153
|
+
notLoggedIn = e_1.toString().includes("You are not logged in");
|
|
154
|
+
if (!isLocked) return [3 /*break*/, 9];
|
|
155
|
+
return [4 /*yield*/, unlockBitwarden()];
|
|
156
|
+
case 8:
|
|
157
|
+
_a.sent();
|
|
158
|
+
return [2 /*return*/, execBitwardenCommand(command)];
|
|
159
|
+
case 9:
|
|
160
|
+
if (!notLoggedIn) return [3 /*break*/, 11];
|
|
161
|
+
return [4 /*yield*/, loginBitwarden()];
|
|
162
|
+
case 10:
|
|
163
|
+
_a.sent();
|
|
164
|
+
return [2 /*return*/, execBitwardenCommand(command)];
|
|
165
|
+
case 11: throw e_1;
|
|
166
|
+
case 12: return [3 /*break*/, 13];
|
|
167
|
+
case 13: return [2 /*return*/];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}); };
|
|
171
|
+
var getCollection = function (collectionName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
172
|
+
return __generator(this, function (_a) {
|
|
173
|
+
return [2 /*return*/, execBitwardenCommand("get collection ".concat(collectionName))];
|
|
174
|
+
});
|
|
175
|
+
}); };
|
|
176
|
+
exports.getCollection = getCollection;
|
|
177
|
+
var getOrganization = function (organizationName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
+
return __generator(this, function (_a) {
|
|
179
|
+
return [2 /*return*/, execBitwardenCommand("get organization ".concat(organizationName))];
|
|
180
|
+
});
|
|
181
|
+
}); };
|
|
182
|
+
exports.getOrganization = getOrganization;
|
|
183
|
+
var catladderCollectionId;
|
|
184
|
+
var getCatladderCollectionId = 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 (!!catladderCollectionId) return [3 /*break*/, 2];
|
|
189
|
+
return [4 /*yield*/, (0, exports.getCollection)("catladder")];
|
|
190
|
+
case 1:
|
|
191
|
+
catladderCollectionId = (_a.sent()).id;
|
|
192
|
+
_a.label = 2;
|
|
193
|
+
case 2: return [2 /*return*/, catladderCollectionId];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}); };
|
|
197
|
+
var panterOrganizationId;
|
|
198
|
+
var getPanterOrganizationId = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
switch (_a.label) {
|
|
201
|
+
case 0:
|
|
202
|
+
if (!!panterOrganizationId) return [3 /*break*/, 2];
|
|
203
|
+
return [4 /*yield*/, (0, exports.getOrganization)("Panter AG")];
|
|
204
|
+
case 1:
|
|
205
|
+
panterOrganizationId = (_a.sent()).id;
|
|
206
|
+
_a.label = 2;
|
|
207
|
+
case 2: return [2 /*return*/, panterOrganizationId];
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}); };
|
|
211
|
+
var encode = function (data) {
|
|
212
|
+
return Buffer.from(JSON.stringify(data)).toString("base64");
|
|
213
|
+
};
|
|
214
|
+
var hasBitwarden = function () { return (0, command_exists_promise_1["default"])("bw"); };
|
|
215
|
+
exports.hasBitwarden = hasBitwarden;
|
|
216
|
+
var getItem = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
return [2 /*return*/, execBitwardenCommand("get item ".concat(path))];
|
|
219
|
+
});
|
|
220
|
+
}); };
|
|
221
|
+
var readPass = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
222
|
+
var result;
|
|
223
|
+
var _a;
|
|
224
|
+
return __generator(this, function (_b) {
|
|
225
|
+
switch (_b.label) {
|
|
226
|
+
case 0: return [4 /*yield*/, getItem(path)];
|
|
227
|
+
case 1:
|
|
228
|
+
result = _b.sent();
|
|
229
|
+
return [2 /*return*/, result.notes || ((_a = result.login) === null || _a === void 0 ? void 0 : _a.password)];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}); };
|
|
233
|
+
exports.readPass = readPass;
|
|
234
|
+
var update = function (type, itemId, value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
235
|
+
var result;
|
|
236
|
+
return __generator(this, function (_a) {
|
|
237
|
+
switch (_a.label) {
|
|
238
|
+
case 0: return [4 /*yield*/, execBitwardenCommand("edit ".concat(type, " ").concat(itemId, " ").concat(encode(value)))];
|
|
239
|
+
case 1:
|
|
240
|
+
result = _a.sent();
|
|
241
|
+
return [2 /*return*/, result];
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}); };
|
|
245
|
+
var MAX_SYNC_AGE_IN_MINUTES = 30;
|
|
246
|
+
var syncBitwarden = function (force) {
|
|
247
|
+
if (force === void 0) { force = true; }
|
|
248
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
249
|
+
var lastSync, _a;
|
|
250
|
+
return __generator(this, function (_b) {
|
|
251
|
+
switch (_b.label) {
|
|
252
|
+
case 0: return [4 /*yield*/, (0, preferences_1.hasPreference)("bwLastSync")];
|
|
253
|
+
case 1:
|
|
254
|
+
if (!(_b.sent())) return [3 /*break*/, 3];
|
|
255
|
+
return [4 /*yield*/, (0, preferences_1.getPreference)("bwLastSync")];
|
|
256
|
+
case 2:
|
|
257
|
+
_a = _b.sent();
|
|
258
|
+
return [3 /*break*/, 4];
|
|
259
|
+
case 3:
|
|
260
|
+
_a = null;
|
|
261
|
+
_b.label = 4;
|
|
262
|
+
case 4:
|
|
263
|
+
lastSync = _a;
|
|
264
|
+
if (!(force ||
|
|
265
|
+
!lastSync ||
|
|
266
|
+
(0, dayjs_1["default"])().diff(lastSync, "minutes") >= MAX_SYNC_AGE_IN_MINUTES)) return [3 /*break*/, 7];
|
|
267
|
+
return [4 /*yield*/, execBitwardenCommand("sync")];
|
|
268
|
+
case 5:
|
|
269
|
+
_b.sent();
|
|
270
|
+
return [4 /*yield*/, (0, preferences_1.setPreference)("bwLastSync", new Date().toISOString())];
|
|
271
|
+
case 6:
|
|
272
|
+
_b.sent();
|
|
273
|
+
return [3 /*break*/, 7];
|
|
274
|
+
case 7: return [2 /*return*/];
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
exports.syncBitwarden = syncBitwarden;
|
|
280
|
+
var insertPass = function (path, content) { return __awaiter(void 0, void 0, void 0, function () {
|
|
281
|
+
var value, result;
|
|
282
|
+
var _a;
|
|
283
|
+
return __generator(this, function (_b) {
|
|
284
|
+
switch (_b.label) {
|
|
285
|
+
case 0:
|
|
286
|
+
_a = {
|
|
287
|
+
type: 2,
|
|
288
|
+
secureNote: { type: 0 },
|
|
289
|
+
name: path,
|
|
290
|
+
notes: content
|
|
291
|
+
};
|
|
292
|
+
return [4 /*yield*/, getCatladderCollectionId()];
|
|
293
|
+
case 1:
|
|
294
|
+
value = (_a.collectionIds = [_b.sent()],
|
|
295
|
+
_a);
|
|
296
|
+
return [4 /*yield*/, execBitwardenCommand("create item ".concat(encode(value)))];
|
|
297
|
+
case 2:
|
|
298
|
+
result = _b.sent();
|
|
299
|
+
return [4 /*yield*/, share(result.id)];
|
|
300
|
+
case 3:
|
|
301
|
+
_b.sent();
|
|
302
|
+
return [2 /*return*/];
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}); };
|
|
306
|
+
exports.insertPass = insertPass;
|
|
307
|
+
var share = function (itemId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
308
|
+
var _a, _b, _c, _d, _e, _f;
|
|
309
|
+
return __generator(this, function (_g) {
|
|
310
|
+
switch (_g.label) {
|
|
311
|
+
case 0:
|
|
312
|
+
_a = execBitwardenCommand;
|
|
313
|
+
_d = (_c = "share ".concat(itemId, " ")).concat;
|
|
314
|
+
return [4 /*yield*/, getPanterOrganizationId()];
|
|
315
|
+
case 1:
|
|
316
|
+
_e = (_b = _d.apply(_c, [_g.sent(), " "])).concat;
|
|
317
|
+
_f = encode;
|
|
318
|
+
return [4 /*yield*/, getCatladderCollectionId()];
|
|
319
|
+
case 2: return [2 /*return*/, _a.apply(void 0, [_e.apply(_b, [_f.apply(void 0, [[
|
|
320
|
+
_g.sent()
|
|
321
|
+
]])])])];
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}); };
|
|
325
|
+
var trashItem = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
326
|
+
var item, result;
|
|
327
|
+
return __generator(this, function (_a) {
|
|
328
|
+
switch (_a.label) {
|
|
329
|
+
case 0: return [4 /*yield*/, getItem(path)];
|
|
330
|
+
case 1:
|
|
331
|
+
item = _a.sent();
|
|
332
|
+
return [4 /*yield*/, execBitwardenCommand("delete item ".concat(item.id))];
|
|
333
|
+
case 2:
|
|
334
|
+
result = _a.sent();
|
|
335
|
+
return [2 /*return*/, result];
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}); };
|
|
339
|
+
exports.trashItem = trashItem;
|
|
340
|
+
var editPass = function (path) { return __awaiter(void 0, void 0, void 0, function () {
|
|
341
|
+
var item;
|
|
342
|
+
return __generator(this, function (_a) {
|
|
343
|
+
switch (_a.label) {
|
|
344
|
+
case 0: return [4 /*yield*/, getItem(path)];
|
|
345
|
+
case 1:
|
|
346
|
+
item = _a.sent();
|
|
347
|
+
return [4 /*yield*/, (0, tmp_promise_1.withFile)(function (_a) {
|
|
348
|
+
var tmpFilePath = _a.path;
|
|
349
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
350
|
+
var newContent;
|
|
351
|
+
return __generator(this, function (_b) {
|
|
352
|
+
switch (_b.label) {
|
|
353
|
+
case 0: return [4 /*yield*/, (0, fs_extra_1.writeFile)(tmpFilePath, item.notes)];
|
|
354
|
+
case 1:
|
|
355
|
+
_b.sent();
|
|
356
|
+
return [4 /*yield*/, (0, getEditor_1["default"])()];
|
|
357
|
+
case 2: return [4 /*yield*/, (_b.sent()).open(tmpFilePath)];
|
|
358
|
+
case 3:
|
|
359
|
+
_b.sent();
|
|
360
|
+
return [4 /*yield*/, (0, fs_extra_1.readFile)(tmpFilePath)];
|
|
361
|
+
case 4:
|
|
362
|
+
newContent = (_b.sent()).toString("utf-8");
|
|
363
|
+
return [4 /*yield*/, update("item", item.id, __assign(__assign({}, item), { notes: newContent }))];
|
|
364
|
+
case 5:
|
|
365
|
+
_b.sent();
|
|
366
|
+
return [2 /*return*/];
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
}, { postfix: ".yml" })];
|
|
371
|
+
case 2:
|
|
372
|
+
_a.sent();
|
|
373
|
+
return [2 /*return*/];
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}); };
|
|
377
|
+
exports.editPass = editPass;
|
|
378
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/passwordstore/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAoD;AACpD,kFAAmD;AACnD,gDAA0B;AAC1B,qCAA+C;AAC/C,2CAAuC;AACvC,2DAAqC;AACrC,8CAA6E;AAE7E,IAAM,KAAK,GAAG,KAAK,CAAC;AAEpB,IAAM,eAAe,GAAG;;;;;gBACtB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAClB,OAAO,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;gBACvD,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACZ,OAAO,GAAG,IAAA,6BAAK,EAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE;oBAC/C,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC;iBACtC,CAAC,CAAC;gBACC,OAAO,GAAG,IAAI,CAAC;gBACnB,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAC5B,MAAM,EACN,UAAC,CAAM,IAAK,OAAA,CAAC,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAA/B,CAA+B,CAC5C,CAAC;gBACF,qBAAM,OAAO,EAAA;;gBAAb,SAAa,CAAC;gBACd,qBAAM,IAAA,2BAAa,EAAC,WAAW,EAAE,OAAO,CAAC,EAAA;;gBAAzC,SAAyC,CAAC;;;;KAC3C,CAAC;AACF,IAAM,cAAc,GAAG;;;;;gBACrB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAClB,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC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EAAA;;gBAZD,SAYC,CAAC;;;;KACH,CAAC;AAhBW,QAAA,QAAQ,YAgBnB"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const stopPortForward: (name: string) => Promise<void>;
|
|
2
|
+
export declare const getAllRunningPortForwards: () => any[];
|
|
3
|
+
export declare const startPortForward: (podname: string, localPort: number, remotePort: number, namespace: string) => Promise<void>;
|
|
4
|
+
export declare const stopAllPortForwards: () => Promise<void>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
exports.stopAllPortForwards = exports.startPortForward = exports.getAllRunningPortForwards = exports.stopPortForward = void 0;
|
|
51
|
+
var child_process_promise_1 = require("child-process-promise");
|
|
52
|
+
var portForwards = new Map();
|
|
53
|
+
var stopPortForward = function (name) { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
var old, e_1;
|
|
55
|
+
return __generator(this, function (_a) {
|
|
56
|
+
switch (_a.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
old = portForwards.get(name);
|
|
59
|
+
if (!old) return [3 /*break*/, 5];
|
|
60
|
+
_a.label = 1;
|
|
61
|
+
case 1:
|
|
62
|
+
_a.trys.push([1, 3, , 4]);
|
|
63
|
+
old.childProcess.kill();
|
|
64
|
+
return [4 /*yield*/, old];
|
|
65
|
+
case 2:
|
|
66
|
+
_a.sent();
|
|
67
|
+
return [3 /*break*/, 4];
|
|
68
|
+
case 3:
|
|
69
|
+
e_1 = _a.sent();
|
|
70
|
+
return [3 /*break*/, 4];
|
|
71
|
+
case 4:
|
|
72
|
+
portForwards["delete"](name);
|
|
73
|
+
_a.label = 5;
|
|
74
|
+
case 5: return [2 /*return*/];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); };
|
|
78
|
+
exports.stopPortForward = stopPortForward;
|
|
79
|
+
var getAllRunningPortForwards = function () {
|
|
80
|
+
return Array.from(portForwards.keys());
|
|
81
|
+
};
|
|
82
|
+
exports.getAllRunningPortForwards = getAllRunningPortForwards;
|
|
83
|
+
var startPortForward = function (podname, localPort, remotePort, namespace) { return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
+
var name, promise;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0:
|
|
88
|
+
name = "".concat(namespace, "/").concat(podname, "/").concat(localPort, ":").concat(remotePort);
|
|
89
|
+
// stop if already there
|
|
90
|
+
if (portForwards.has(name)) {
|
|
91
|
+
(0, exports.stopPortForward)(name);
|
|
92
|
+
}
|
|
93
|
+
promise = (0, child_process_promise_1.spawn)("kubectl", ["port-forward", podname, "".concat(localPort, ":").concat(remotePort), "-n", namespace], {
|
|
94
|
+
env: __assign(__assign({}, process.env), { DEBUG: "" })
|
|
95
|
+
});
|
|
96
|
+
portForwards.set(name, promise);
|
|
97
|
+
// wait a moment so that is surley started, unfortunatly we don't know that
|
|
98
|
+
return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, 1000); })];
|
|
99
|
+
case 1:
|
|
100
|
+
// wait a moment so that is surley started, unfortunatly we don't know that
|
|
101
|
+
_a.sent();
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); };
|
|
106
|
+
exports.startPortForward = startPortForward;
|
|
107
|
+
var stopAllPortForwards = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
(0, exports.getAllRunningPortForwards)().forEach(function (name) {
|
|
110
|
+
(0, exports.stopPortForward)(name);
|
|
111
|
+
});
|
|
112
|
+
return [2 /*return*/];
|
|
113
|
+
});
|
|
114
|
+
}); };
|
|
115
|
+
exports.stopAllPortForwards = stopAllPortForwards;
|
|
116
|
+
//# sourceMappingURL=portForward.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portForward.js","sourceRoot":"","sources":["../../src/utils/portForward.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA8C;AAE9C,IAAM,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;AAExB,IAAM,eAAe,GAAG,UAAO,IAAY;;;;;gBAC1C,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;qBAE/B,GAAG,EAAH,wBAAG;;;;gBAEH,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;gBACxB,qBAAM,GAAG,EAAA;;gBAAT,SAAS,CAAC;;;;;;gBAIZ,YAAY,CAAC,QAAM,CAAA,CAAC,IAAI,CAAC,CAAC;;;;;KAE7B,CAAC;AAZW,QAAA,eAAe,mBAY1B;AAEK,IAAM,yBAAyB,GAAG;IACvC,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;AACzC,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC;AACK,IAAM,gBAAgB,GAAG,UAC9B,OAAe,EACf,SAAiB,EACjB,UAAkB,EAClB,SAAiB;;;;;gBAEX,IAAI,GAAG,UAAG,SAAS,cAAI,OAAO,cAAI,SAAS,cAAI,UAAU,CAAE,CAAC;gBAClE,wBAAwB;gBACxB,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBAC1B,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAC;iBACvB;gBACK,OAAO,GAAG,IAAA,6BAAK,EACnB,SAAS,EACT,CAAC,cAAc,EAAE,OAAO,EAAE,UAAG,SAAS,cAAI,UAAU,CAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EACxE;oBACE,GAAG,wBACE,OAAO,CAAC,GAAG,KACd,KAAK,EAAE,EAAE,GACV;iBACF,CACF,CAAC;gBACF,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAChC,2EAA2E;gBAC3E,qBAAM,IAAI,OAAO,CAAC,UAAC,CAAC,IAAK,OAAA,UAAU,CAAC,CAAC,EAAE,IAAI,CAAC,EAAnB,CAAmB,CAAC,EAAA;;gBAD7C,2EAA2E;gBAC3E,SAA6C,CAAC;;;;KAC/C,CAAC;AAxBW,QAAA,gBAAgB,oBAwB3B;AAEK,IAAM,mBAAmB,GAAG;;QACjC,IAAA,iCAAyB,GAAE,CAAC,OAAO,CAAC,UAAC,IAAI;YACvC,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;;;KACJ,CAAC;AAJW,QAAA,mBAAmB,uBAI9B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
exports.__esModule = true;
|
|
53
|
+
exports.setPreference = exports.getPreference = exports.hasPreference = void 0;
|
|
54
|
+
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
55
|
+
var os_1 = require("os");
|
|
56
|
+
var js_yaml_1 = require("js-yaml");
|
|
57
|
+
var directory = "".concat((0, os_1.homedir)(), "/.catladder");
|
|
58
|
+
var file = "".concat(directory, "/preferences.yml");
|
|
59
|
+
var getPreferences = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
+
var _a;
|
|
61
|
+
var _b;
|
|
62
|
+
return __generator(this, function (_c) {
|
|
63
|
+
switch (_c.label) {
|
|
64
|
+
case 0: return [4 /*yield*/, fs_extra_1["default"].pathExists(file)];
|
|
65
|
+
case 1:
|
|
66
|
+
if (!!(_c.sent())) return [3 /*break*/, 3];
|
|
67
|
+
return [4 /*yield*/, fs_extra_1["default"].createFile(file)];
|
|
68
|
+
case 2:
|
|
69
|
+
_c.sent();
|
|
70
|
+
_c.label = 3;
|
|
71
|
+
case 3:
|
|
72
|
+
_a = js_yaml_1.load;
|
|
73
|
+
return [4 /*yield*/, fs_extra_1["default"].readFile(file, { encoding: "utf-8" })];
|
|
74
|
+
case 4: return [2 /*return*/, ((_b = _a.apply(void 0, [_c.sent()])) !== null && _b !== void 0 ? _b : {})];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}); };
|
|
78
|
+
var hasPreference = function (key) { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
+
var preferences;
|
|
80
|
+
return __generator(this, function (_a) {
|
|
81
|
+
switch (_a.label) {
|
|
82
|
+
case 0: return [4 /*yield*/, getPreferences()];
|
|
83
|
+
case 1:
|
|
84
|
+
preferences = _a.sent();
|
|
85
|
+
return [2 /*return*/, key in preferences];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); };
|
|
89
|
+
exports.hasPreference = hasPreference;
|
|
90
|
+
var getPreference = function (key) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
var preferences;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0: return [4 /*yield*/, getPreferences()];
|
|
95
|
+
case 1:
|
|
96
|
+
preferences = _a.sent();
|
|
97
|
+
return [2 /*return*/, preferences[key]];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}); };
|
|
101
|
+
exports.getPreference = getPreference;
|
|
102
|
+
var setPreference = function (key, value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
103
|
+
var preferences, newPreferences;
|
|
104
|
+
var _a;
|
|
105
|
+
return __generator(this, function (_b) {
|
|
106
|
+
switch (_b.label) {
|
|
107
|
+
case 0: return [4 /*yield*/, getPreferences()];
|
|
108
|
+
case 1:
|
|
109
|
+
preferences = _b.sent();
|
|
110
|
+
newPreferences = __assign(__assign({}, preferences), (_a = {}, _a[key] = value, _a));
|
|
111
|
+
return [4 /*yield*/, fs_extra_1["default"].writeFile(file, (0, js_yaml_1.dump)(newPreferences))];
|
|
112
|
+
case 2:
|
|
113
|
+
_b.sent();
|
|
114
|
+
return [2 /*return*/];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}); };
|
|
118
|
+
exports.setPreference = setPreference;
|
|
119
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/preferences/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA0B;AAC1B,yBAA6B;AAE7B,mCAAqC;AACrC,IAAM,SAAS,GAAG,UAAG,IAAA,YAAO,GAAE,gBAAa,CAAC;AAC5C,IAAM,IAAI,GAAG,UAAG,SAAS,qBAAkB,CAAC;AAE5C,IAAM,cAAc,GAAG;;;;;oBACf,qBAAM,qBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;qBAA3B,CAAC,CAAC,SAAyB,CAAC,EAA5B,wBAA4B;gBAC9B,qBAAM,qBAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAA;;gBAAzB,SAAyB,CAAC;;;gBAEpB,KAAA,cAAI,CAAA;gBAAC,qBAAM,qBAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAA;oBAA3D,sBAAO,CAAC,MAAA,kBAAK,SAA8C,EAAC,mCAAI,EAAE,CAGjE,EAAC;;;KACH,CAAC;AAEK,IAAM,aAAa,GAAG,UAAO,GAAW;;;;oBACzB,qBAAM,cAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBAC1C,sBAAO,GAAG,IAAI,WAAW,EAAC;;;KAC3B,CAAC;AAHW,QAAA,aAAa,iBAGxB;AACK,IAAM,aAAa,GAAG,UAAO,GAAW;;;;oBACzB,qBAAM,cAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBAC1C,sBAAO,WAAW,CAAC,GAAG,CAAC,EAAC;;;KACzB,CAAC;AAHW,QAAA,aAAa,iBAGxB;AAEK,IAAM,aAAa,GAAG,UAAO,GAAW,EAAE,KAAsB;;;;;oBACjD,qBAAM,cAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBAEpC,cAAc,yBACf,WAAW,gBACb,GAAG,IAAG,KAAK,MACb,CAAC;gBAEF,qBAAM,qBAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAA,cAAI,EAAC,cAAc,CAAC,CAAC,EAAA;;gBAA9C,SAA8C,CAAC;;;;KAChD,CAAC;AATW,QAAA,aAAa,iBASxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const getGitRoot: () => Promise<string>;
|
|
2
|
+
export declare const getRootGitlabCiFile: () => Promise<string>;
|
|
3
|
+
export declare const readRootGitlabCiFile: () => Promise<any[]>;
|
|
4
|
+
export declare const hasGitlabCiFile: () => Promise<boolean>;
|
|
5
|
+
export declare const getProjectNamespace: (envComponent: string) => Promise<string>;
|
|
6
|
+
export declare const getProjectPods: (envComponent: string) => Promise<import("@kubernetes/client-node").V1Pod[]>;
|
|
7
|
+
export declare const getProjectPvcs: (envComponent: string) => Promise<import("@kubernetes/client-node").V1PersistentVolumeClaim[]>;
|
|
8
|
+
export declare const getProjectPodNames: (envComponent: string) => Promise<string[]>;
|