@northflank/cli 0.7.6 → 0.8.0-beta.1
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/api-helpers.js +191 -1
- package/dist/cli.js +564 -1
- package/dist/command-overview.js +93 -1
- package/dist/console-format-helpers.js +108 -1
- package/dist/context/contextCommands.js +417 -1
- package/dist/defaults.js +10408 -1
- package/dist/exec/index.js +257 -0
- package/dist/inquirer-helper.js +912 -1
- package/dist/port-forward/index.js +269 -1
- package/dist/utils.js +201 -1
- package/package.json +3 -3
package/dist/api-helpers.js
CHANGED
|
@@ -1 +1,191 @@
|
|
|
1
|
-
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.fetchResourceList = void 0;
|
|
49
|
+
var utils_1 = require("./utils");
|
|
50
|
+
function fetchResourceList(propertyName, apiClient, cmdPath, currentProp, pathVars, propPath) {
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var defaultValue, plans, choices, regions, choices, regions, choices, regions, choices, projectId, serviceResourceRequested, services, choices, addonSubject, getAddonType, addonTypes, choices, choices, storage, replicas, addonTypes, choices, addonId, upgradeTo, creds, e_1;
|
|
54
|
+
var _this = this;
|
|
55
|
+
return __generator(this, function (_l) {
|
|
56
|
+
switch (_l.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
defaultValue = undefined;
|
|
59
|
+
_l.label = 1;
|
|
60
|
+
case 1:
|
|
61
|
+
_l.trys.push([1, 26, , 27]);
|
|
62
|
+
if (!(propertyName === 'deploymentPlan')) return [3 /*break*/, 3];
|
|
63
|
+
return [4 /*yield*/, apiClient.list.plans({})];
|
|
64
|
+
case 2:
|
|
65
|
+
plans = _l.sent();
|
|
66
|
+
choices = plans.data.plans.map(function (pln) { var _a; return (_a = pln === null || pln === void 0 ? void 0 : pln.internalId) !== null && _a !== void 0 ? _a : pln === null || pln === void 0 ? void 0 : pln.id; });
|
|
67
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
68
|
+
case 3:
|
|
69
|
+
if (!(propertyName === 'region')) return [3 /*break*/, 5];
|
|
70
|
+
return [4 /*yield*/, apiClient.list.regions({})];
|
|
71
|
+
case 4:
|
|
72
|
+
regions = _l.sent();
|
|
73
|
+
choices = regions.data.regions.map(function (region) { var _a; return (_a = region === null || region === void 0 ? void 0 : region.internalId) !== null && _a !== void 0 ? _a : region === null || region === void 0 ? void 0 : region.id; });
|
|
74
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
75
|
+
case 5:
|
|
76
|
+
if (!(propertyName === 'projectId')) return [3 /*break*/, 7];
|
|
77
|
+
return [4 /*yield*/, apiClient.list.projects({ options: { per_page: 100 } })];
|
|
78
|
+
case 6:
|
|
79
|
+
regions = _l.sent();
|
|
80
|
+
choices = regions.data.projects.map(function (project) { return project.id; });
|
|
81
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
82
|
+
case 7:
|
|
83
|
+
if (!(propertyName === 'credentials')) return [3 /*break*/, 9];
|
|
84
|
+
return [4 /*yield*/, apiClient.list.registryCredentials({})];
|
|
85
|
+
case 8:
|
|
86
|
+
regions = _l.sent();
|
|
87
|
+
choices = regions.data.credentials.map(function (cred) { return cred.id; });
|
|
88
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
89
|
+
case 9:
|
|
90
|
+
projectId = pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId;
|
|
91
|
+
serviceResourceRequested = propertyName === 'serviceId' || (propertyName === 'id' && (propPath === null || propPath === void 0 ? void 0 : propPath.includes('owningObject')));
|
|
92
|
+
if (!(projectId !== undefined && serviceResourceRequested)) return [3 /*break*/, 11];
|
|
93
|
+
return [4 /*yield*/, apiClient.list.services({
|
|
94
|
+
parameters: { projectId: projectId },
|
|
95
|
+
options: { per_page: 100 },
|
|
96
|
+
})];
|
|
97
|
+
case 10:
|
|
98
|
+
services = _l.sent();
|
|
99
|
+
choices = services.data.services.map(function (service) { return service.id; });
|
|
100
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
101
|
+
case 11:
|
|
102
|
+
addonSubject = cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.includes('addon');
|
|
103
|
+
if (!addonSubject) return [3 /*break*/, 19];
|
|
104
|
+
getAddonType = function (type) { return __awaiter(_this, void 0, void 0, function () {
|
|
105
|
+
var addonTypes;
|
|
106
|
+
var _a;
|
|
107
|
+
return __generator(this, function (_b) {
|
|
108
|
+
switch (_b.label) {
|
|
109
|
+
case 0: return [4 /*yield*/, apiClient.get.addon.types({})];
|
|
110
|
+
case 1:
|
|
111
|
+
addonTypes = _b.sent();
|
|
112
|
+
return [2 /*return*/, (_a = addonTypes.data.addonTypes) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.type === type; })];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}); };
|
|
116
|
+
if (!(propertyName === 'type')) return [3 /*break*/, 13];
|
|
117
|
+
return [4 /*yield*/, apiClient.get.addon.types({})];
|
|
118
|
+
case 12:
|
|
119
|
+
addonTypes = _l.sent();
|
|
120
|
+
choices = (_a = addonTypes.data.addonTypes) === null || _a === void 0 ? void 0 : _a.map(function (type) { return type.type; });
|
|
121
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
122
|
+
case 13:
|
|
123
|
+
if (!(propertyName === 'version' && (currentProp === null || currentProp === void 0 ? void 0 : currentProp.type) !== undefined)) return [3 /*break*/, 15];
|
|
124
|
+
return [4 /*yield*/, getAddonType(currentProp.type)];
|
|
125
|
+
case 14:
|
|
126
|
+
choices = (_b = (_l.sent())) === null || _b === void 0 ? void 0 : _b.versions;
|
|
127
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
128
|
+
case 15:
|
|
129
|
+
if (!(propertyName === 'storage' && (currentProp === null || currentProp === void 0 ? void 0 : currentProp.type) !== undefined)) return [3 /*break*/, 17];
|
|
130
|
+
return [4 /*yield*/, getAddonType(currentProp.type)];
|
|
131
|
+
case 16:
|
|
132
|
+
storage = (_d = (_c = (_l.sent())) === null || _c === void 0 ? void 0 : _c.resources) === null || _d === void 0 ? void 0 : _d.storage;
|
|
133
|
+
return [2 /*return*/, { choices: storage === null || storage === void 0 ? void 0 : storage.options, defaultValue: storage === null || storage === void 0 ? void 0 : storage.default }];
|
|
134
|
+
case 17:
|
|
135
|
+
if (!(propertyName === 'replicas' && (currentProp === null || currentProp === void 0 ? void 0 : currentProp.type) !== undefined)) return [3 /*break*/, 19];
|
|
136
|
+
return [4 /*yield*/, getAddonType(currentProp.type)];
|
|
137
|
+
case 18:
|
|
138
|
+
replicas = (_f = (_e = (_l.sent())) === null || _e === void 0 ? void 0 : _e.resources) === null || _f === void 0 ? void 0 : _f.replicas;
|
|
139
|
+
return [2 /*return*/, { choices: replicas === null || replicas === void 0 ? void 0 : replicas.options, defaultValue: replicas === null || replicas === void 0 ? void 0 : replicas.default }];
|
|
140
|
+
case 19:
|
|
141
|
+
if (!(propertyName === 'addonId' && (pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId) !== undefined)) return [3 /*break*/, 21];
|
|
142
|
+
return [4 /*yield*/, apiClient.list.addons({
|
|
143
|
+
parameters: { projectId: pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId },
|
|
144
|
+
options: { per_page: 100 },
|
|
145
|
+
})];
|
|
146
|
+
case 20:
|
|
147
|
+
addonTypes = _l.sent();
|
|
148
|
+
if (addonTypes.data.addons.length > 0) {
|
|
149
|
+
choices = addonTypes.data.addons.map(function (addon) { return addon.id; });
|
|
150
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
151
|
+
}
|
|
152
|
+
_l.label = 21;
|
|
153
|
+
case 21:
|
|
154
|
+
addonId = (_g = pathVars === null || pathVars === void 0 ? void 0 : pathVars.addonId) !== null && _g !== void 0 ? _g : (_h = currentProp === null || currentProp === void 0 ? void 0 : currentProp.addonDependencies) === null || _h === void 0 ? void 0 : _h.addonId;
|
|
155
|
+
if (!((cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.join('')) === 'updateaddonversion' &&
|
|
156
|
+
propertyName === 'version' &&
|
|
157
|
+
(pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId) !== undefined &&
|
|
158
|
+
addonId !== undefined)) return [3 /*break*/, 23];
|
|
159
|
+
return [4 /*yield*/, apiClient.get.addon.version({
|
|
160
|
+
parameters: { addonId: addonId, projectId: pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId },
|
|
161
|
+
})];
|
|
162
|
+
case 22:
|
|
163
|
+
upgradeTo = (_l.sent()).data.upgradeTo;
|
|
164
|
+
if (upgradeTo === undefined || upgradeTo.length <= 0) {
|
|
165
|
+
(0, utils_1.warning)('No available versions to upgrade to.');
|
|
166
|
+
throw new Error();
|
|
167
|
+
}
|
|
168
|
+
return [2 /*return*/, { choices: upgradeTo.map(function (u) { return u.version; }), defaultValue: defaultValue }];
|
|
169
|
+
case 23:
|
|
170
|
+
if (!(((cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.includes('secretLink')) || (cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.includes('secret'))) &&
|
|
171
|
+
propertyName === 'keyName' &&
|
|
172
|
+
addonId !== undefined &&
|
|
173
|
+
(pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId) !== undefined)) return [3 /*break*/, 25];
|
|
174
|
+
return [4 /*yield*/, apiClient.get.addon.credentials({
|
|
175
|
+
parameters: { addonId: addonId, projectId: pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId },
|
|
176
|
+
})];
|
|
177
|
+
case 24:
|
|
178
|
+
creds = (_l.sent()).data;
|
|
179
|
+
return [2 /*return*/, {
|
|
180
|
+
choices: __spreadArray(__spreadArray([], ((_j = Object.keys(creds === null || creds === void 0 ? void 0 : creds.envs)) !== null && _j !== void 0 ? _j : []), true), ((_k = Object.keys(creds === null || creds === void 0 ? void 0 : creds.secrets)) !== null && _k !== void 0 ? _k : []), true),
|
|
181
|
+
}];
|
|
182
|
+
case 25: return [3 /*break*/, 27];
|
|
183
|
+
case 26:
|
|
184
|
+
e_1 = _l.sent();
|
|
185
|
+
return [3 /*break*/, 27];
|
|
186
|
+
case 27: return [2 /*return*/, { choices: undefined, defaultValue: defaultValue }];
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
exports.fetchResourceList = fetchResourceList;
|