@northflank/cli 0.4.5 → 0.6.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/README.md +7 -8
- package/dist/api-helpers.js +187 -1
- package/dist/cli.js +499 -1
- package/dist/command-overview.js +93 -1
- package/dist/console-format-helpers.js +104 -1
- package/dist/context/contextCommands.js +413 -1
- package/dist/defaults.js +6157 -1
- package/dist/inquirer-helper.js +832 -1
- package/dist/port-forward/index.js +269 -0
- package/dist/utils.js +201 -1
- package/package.json +4 -6
- package/postinstall.js +1 -10
- package/dist/port-forward/client/api-helper.js +0 -1
- package/dist/port-forward/client/atomic-write.js +0 -1
- package/dist/port-forward/client/host-file-ast.js +0 -1
- package/dist/port-forward/client/host-file.js +0 -1
- package/dist/port-forward/client/index.js +0 -1
- package/dist/port-forward/client/loopback.js +0 -1
- package/dist/port-forward/client/port-forwarder.js +0 -1
- package/dist/port-forward/client/port-tunnel-tcp.js +0 -1
- package/dist/port-forward/client/port-tunnel-udp.js +0 -1
- package/dist/port-forward/client/port-tunnel.js +0 -1
- package/dist/port-forward/client/promise-mutex.js +0 -1
package/README.md
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
## Northflank Command Line Interface (CLI)
|
|
2
2
|
Provides a command-line interface to the Northflank platform.
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
In case you encounter any bugs, errors or issues,
|
|
6
|
-
feel free to contact us here [https://northflank.com/contact](https://northflank.com/contact)
|
|
7
|
-
or using [feedback@northflank.com](mailto:feedback@northflank.com)**
|
|
4
|
+
*Visit our website [www.northflank.com](https://www.northflank.com)*
|
|
8
5
|
|
|
6
|
+
*Full documentation on [https://northflank.com/docs/v1/api/use-the-cli](https://northflank.com/docs/v1/api/use-the-cli)*
|
|
9
7
|
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
*Full documentation on [https://northflank.com/docs](https://northflank.com/docs/v1/api/introduction#about-the-cli)*
|
|
8
|
+
*Also use the Northflank js-client: [https://www.npmjs.com/package/@northflank/js-client](https://www.npmjs.com/package/@northflank/js-client)*
|
|
13
9
|
|
|
10
|
+
Please don’t hesitate to get in touch with us if you have a query or want to
|
|
11
|
+
give some feedback on [https://northflank.com/contact](https://northflank.com/contact)
|
|
12
|
+
or email us at [contact@northflank.com](mailto:contact@northflank.com).
|
|
14
13
|
|
|
15
14
|
### Installation
|
|
16
15
|
|
|
@@ -38,7 +37,7 @@ Having logged in, the CLI is ready to be used.
|
|
|
38
37
|
|
|
39
38
|
#### Examples
|
|
40
39
|
- Listing services in a project: ```northflank list services```
|
|
41
|
-
- Getting detailed information about a service: ```northflank get service
|
|
40
|
+
- Getting detailed information about a service: ```northflank get service```
|
|
42
41
|
- Scaling a service: ```northflank scale service```
|
|
43
42
|
- Creating a combined service: ```northflank create service combined```
|
|
44
43
|
|
package/dist/api-helpers.js
CHANGED
|
@@ -1 +1,187 @@
|
|
|
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) {
|
|
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, regions, 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.response.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.response.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({})];
|
|
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
|
+
if (!(propertyName === 'serviceId' && currentProp.projectId !== undefined)) return [3 /*break*/, 11];
|
|
91
|
+
return [4 /*yield*/, apiClient.list.services({
|
|
92
|
+
parameters: { projectId: currentProp.projectId },
|
|
93
|
+
})];
|
|
94
|
+
case 10:
|
|
95
|
+
regions = _l.sent();
|
|
96
|
+
choices = regions.data.services.map(function (service) { return service.id; });
|
|
97
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
98
|
+
case 11:
|
|
99
|
+
addonSubject = cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.includes('addon');
|
|
100
|
+
if (!addonSubject) return [3 /*break*/, 19];
|
|
101
|
+
getAddonType = function (type) { return __awaiter(_this, void 0, void 0, function () {
|
|
102
|
+
var addonTypes;
|
|
103
|
+
var _a;
|
|
104
|
+
return __generator(this, function (_b) {
|
|
105
|
+
switch (_b.label) {
|
|
106
|
+
case 0: return [4 /*yield*/, apiClient.get.addon.types({})];
|
|
107
|
+
case 1:
|
|
108
|
+
addonTypes = _b.sent();
|
|
109
|
+
return [2 /*return*/, (_a = addonTypes.data.addonTypes) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.type === type; })];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}); };
|
|
113
|
+
if (!(propertyName === 'type')) return [3 /*break*/, 13];
|
|
114
|
+
return [4 /*yield*/, apiClient.get.addon.types({})];
|
|
115
|
+
case 12:
|
|
116
|
+
addonTypes = _l.sent();
|
|
117
|
+
choices = (_a = addonTypes.data.addonTypes) === null || _a === void 0 ? void 0 : _a.map(function (type) { return type.type; });
|
|
118
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
119
|
+
case 13:
|
|
120
|
+
if (!(propertyName === 'version' && (currentProp === null || currentProp === void 0 ? void 0 : currentProp.type) !== undefined)) return [3 /*break*/, 15];
|
|
121
|
+
return [4 /*yield*/, getAddonType(currentProp.type)];
|
|
122
|
+
case 14:
|
|
123
|
+
choices = (_b = (_l.sent())) === null || _b === void 0 ? void 0 : _b.versions;
|
|
124
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
125
|
+
case 15:
|
|
126
|
+
if (!(propertyName === 'storage' && (currentProp === null || currentProp === void 0 ? void 0 : currentProp.type) !== undefined)) return [3 /*break*/, 17];
|
|
127
|
+
return [4 /*yield*/, getAddonType(currentProp.type)];
|
|
128
|
+
case 16:
|
|
129
|
+
storage = (_d = (_c = (_l.sent())) === null || _c === void 0 ? void 0 : _c.resources) === null || _d === void 0 ? void 0 : _d.storage;
|
|
130
|
+
return [2 /*return*/, { choices: storage === null || storage === void 0 ? void 0 : storage.options, defaultValue: storage === null || storage === void 0 ? void 0 : storage.default }];
|
|
131
|
+
case 17:
|
|
132
|
+
if (!(propertyName === 'replicas' && (currentProp === null || currentProp === void 0 ? void 0 : currentProp.type) !== undefined)) return [3 /*break*/, 19];
|
|
133
|
+
return [4 /*yield*/, getAddonType(currentProp.type)];
|
|
134
|
+
case 18:
|
|
135
|
+
replicas = (_f = (_e = (_l.sent())) === null || _e === void 0 ? void 0 : _e.resources) === null || _f === void 0 ? void 0 : _f.replicas;
|
|
136
|
+
return [2 /*return*/, { choices: replicas === null || replicas === void 0 ? void 0 : replicas.options, defaultValue: replicas === null || replicas === void 0 ? void 0 : replicas.default }];
|
|
137
|
+
case 19:
|
|
138
|
+
if (!(propertyName === 'addonId' && (pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId) !== undefined)) return [3 /*break*/, 21];
|
|
139
|
+
return [4 /*yield*/, apiClient.list.addons({
|
|
140
|
+
parameters: { projectId: pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId },
|
|
141
|
+
})];
|
|
142
|
+
case 20:
|
|
143
|
+
addonTypes = _l.sent();
|
|
144
|
+
if (addonTypes.data.addons.length > 0) {
|
|
145
|
+
choices = addonTypes.data.addons.map(function (addon) { return addon.id; });
|
|
146
|
+
return [2 /*return*/, { choices: choices, defaultValue: defaultValue }];
|
|
147
|
+
}
|
|
148
|
+
_l.label = 21;
|
|
149
|
+
case 21:
|
|
150
|
+
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;
|
|
151
|
+
if (!((cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.join('')) === 'updateaddonversion' &&
|
|
152
|
+
propertyName === 'version' &&
|
|
153
|
+
(pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId) !== undefined &&
|
|
154
|
+
addonId !== undefined)) return [3 /*break*/, 23];
|
|
155
|
+
return [4 /*yield*/, apiClient.get.addon.version({
|
|
156
|
+
parameters: { addonId: addonId, projectId: pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId },
|
|
157
|
+
})];
|
|
158
|
+
case 22:
|
|
159
|
+
upgradeTo = (_l.sent()).data.upgradeTo;
|
|
160
|
+
if (upgradeTo === undefined || upgradeTo.length <= 0) {
|
|
161
|
+
(0, utils_1.warning)('No available versions to upgrade to.');
|
|
162
|
+
throw new Error();
|
|
163
|
+
}
|
|
164
|
+
return [2 /*return*/, { choices: upgradeTo.map(function (u) { return u.version; }), defaultValue: defaultValue }];
|
|
165
|
+
case 23:
|
|
166
|
+
if (!(((cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.includes('secretLink')) || (cmdPath === null || cmdPath === void 0 ? void 0 : cmdPath.includes('secret'))) &&
|
|
167
|
+
propertyName === 'keyName' &&
|
|
168
|
+
addonId !== undefined &&
|
|
169
|
+
(pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId) !== undefined)) return [3 /*break*/, 25];
|
|
170
|
+
return [4 /*yield*/, apiClient.get.addon.credentials({
|
|
171
|
+
parameters: { addonId: addonId, projectId: pathVars === null || pathVars === void 0 ? void 0 : pathVars.projectId },
|
|
172
|
+
})];
|
|
173
|
+
case 24:
|
|
174
|
+
creds = (_l.sent()).data;
|
|
175
|
+
return [2 /*return*/, {
|
|
176
|
+
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),
|
|
177
|
+
}];
|
|
178
|
+
case 25: return [3 /*break*/, 27];
|
|
179
|
+
case 26:
|
|
180
|
+
e_1 = _l.sent();
|
|
181
|
+
return [3 /*break*/, 27];
|
|
182
|
+
case 27: return [2 /*return*/, { choices: undefined, defaultValue: defaultValue }];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
exports.fetchResourceList = fetchResourceList;
|