@northflank/cli 0.8.0-beta.1 → 0.8.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 +1 -191
- package/dist/cli.js +1 -564
- package/dist/command-overview.js +1 -93
- package/dist/console-format-helpers.js +1 -108
- package/dist/context/contextCommands.js +1 -417
- package/dist/defaults.js +1 -10408
- package/dist/exec/index.js +1 -257
- package/dist/inquirer-helper.js +1 -912
- package/dist/port-forward/index.js +1 -269
- package/dist/utils.js +1 -201
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,565 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
27
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
28
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
29
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
30
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
31
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
32
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
36
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
37
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
38
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
39
|
-
function step(op) {
|
|
40
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
41
|
-
while (_) try {
|
|
42
|
-
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;
|
|
43
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
44
|
-
switch (op[0]) {
|
|
45
|
-
case 0: case 1: t = op; break;
|
|
46
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
47
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
48
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
49
|
-
default:
|
|
50
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
51
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
52
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
53
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
54
|
-
if (t[2]) _.ops.pop();
|
|
55
|
-
_.trys.pop(); continue;
|
|
56
|
-
}
|
|
57
|
-
op = body.call(thisArg, _);
|
|
58
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
59
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
63
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64
|
-
};
|
|
65
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
var js_client_1 = require("@northflank/js-client");
|
|
67
|
-
var commander_1 = __importDefault(require("commander"));
|
|
68
|
-
var fs_1 = __importDefault(require("fs"));
|
|
69
|
-
var ajv_1 = __importDefault(require("ajv"));
|
|
70
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
71
|
-
var _ = __importStar(require("lodash"));
|
|
72
|
-
var contextCommands_1 = require("./context/contextCommands");
|
|
73
|
-
var utils_1 = require("./utils");
|
|
74
|
-
var defaults = __importStar(require("./defaults"));
|
|
75
|
-
var inquirer_helper_1 = require("./inquirer-helper");
|
|
76
|
-
var console_format_helpers_1 = require("./console-format-helpers");
|
|
77
|
-
var command_overview_1 = require("./command-overview");
|
|
78
|
-
var port_forward_1 = require("./port-forward");
|
|
79
|
-
var exec_1 = require("./exec");
|
|
80
|
-
var yaml = require('js-yaml');
|
|
81
|
-
var pgk = require('../package.json');
|
|
82
|
-
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
-
var program, contextProvider, apiClient, contextCmds, portForwardCmds, execCmds, e_1;
|
|
84
|
-
return __generator(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
_a.trys.push([0, 3, , 4]);
|
|
88
|
-
program = new commander_1.default.Command('northflank');
|
|
89
|
-
program.enablePositionalOptions(true);
|
|
90
|
-
program.version("Northflank cli version: ".concat(chalk_1.default.underline(pgk.version)), '-v, --version', 'Print the current version of the Northflank cli');
|
|
91
|
-
contextProvider = new js_client_1.ApiClientFileContextProvider();
|
|
92
|
-
return [4 /*yield*/, (0, utils_1.checkUpdate)(contextProvider)];
|
|
93
|
-
case 1:
|
|
94
|
-
_a.sent();
|
|
95
|
-
apiClient = new js_client_1.ApiClient(contextProvider, {
|
|
96
|
-
throwErrorOnHttpErrorCode: false,
|
|
97
|
-
customUserAgent: utils_1.customUserAgent,
|
|
98
|
-
});
|
|
99
|
-
contextCmds = new contextCommands_1.CliContext(apiClient);
|
|
100
|
-
portForwardCmds = new port_forward_1.CliPortForward(contextProvider);
|
|
101
|
-
execCmds = new exec_1.CliExec(contextProvider);
|
|
102
|
-
program.addCommand(portForwardCmds.portFwdCmd);
|
|
103
|
-
program.addCommand(execCmds.execCmd);
|
|
104
|
-
program.addCommand(contextCmds.login);
|
|
105
|
-
program.addCommand(contextCmds.contexts);
|
|
106
|
-
generateCommands(apiClient, apiClient.endpoints, program);
|
|
107
|
-
program.addCommand((0, command_overview_1.getCommandOverview)(program));
|
|
108
|
-
return [4 /*yield*/, program.parseAsync(process.argv)];
|
|
109
|
-
case 2:
|
|
110
|
-
_a.sent();
|
|
111
|
-
return [3 /*break*/, 4];
|
|
112
|
-
case 3:
|
|
113
|
-
e_1 = _a.sent();
|
|
114
|
-
(0, utils_1.error)("Error occured while trying to run command, error: ".concat(e_1.message));
|
|
115
|
-
if (process.argv.find(function (arg) { return arg === '--verbose'; })) {
|
|
116
|
-
console.log(e_1);
|
|
117
|
-
}
|
|
118
|
-
process.exitCode = 1;
|
|
119
|
-
return [3 /*break*/, 4];
|
|
120
|
-
case 4: return [2 /*return*/];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); })();
|
|
124
|
-
function isListCommand(cliPath) {
|
|
125
|
-
var listCommands = [
|
|
126
|
-
['get', 'addon', 'backups'],
|
|
127
|
-
['get', 'job', 'runs'],
|
|
128
|
-
];
|
|
129
|
-
return cliPath.find(function (p) { return p === 'list'; }) || listCommands.some(function (cmd) { return _.isEqual(cliPath, cmd); });
|
|
130
|
-
}
|
|
131
|
-
/** Automatically adds commands recursively.
|
|
132
|
-
* @param apiClient
|
|
133
|
-
* @param endpoints
|
|
134
|
-
* @param cmd Root command to add the generated commands to
|
|
135
|
-
* @param currentDefaults
|
|
136
|
-
* @param cliPath
|
|
137
|
-
*/
|
|
138
|
-
function generateCommands(apiClient, endpoints, cmd, currentDefaults, cliPath) {
|
|
139
|
-
if (currentDefaults === void 0) { currentDefaults = defaults.defaults; }
|
|
140
|
-
if (cliPath === void 0) { cliPath = []; }
|
|
141
|
-
var inquirerHelper = new inquirer_helper_1.InquirerHelper(new js_client_1.ApiClient(apiClient.contextProvider, {
|
|
142
|
-
throwErrorOnHttpErrorCode: true,
|
|
143
|
-
customUserAgent: utils_1.customUserAgent,
|
|
144
|
-
}));
|
|
145
|
-
function isRequired(opt, defaultVal) {
|
|
146
|
-
return opt.required !== false && defaultVal === undefined;
|
|
147
|
-
}
|
|
148
|
-
function parseOptions(option, leafCommand) {
|
|
149
|
-
var opt = option.opt, name = option.name;
|
|
150
|
-
var defaultVal = opt.default;
|
|
151
|
-
var required = isRequired(opt, defaultVal);
|
|
152
|
-
var toOption = function (alias) { return (alias.length > 1 ? "--".concat(alias) : "-".concat(alias)); };
|
|
153
|
-
var alias = opt === null || opt === void 0 ? void 0 : opt.alias;
|
|
154
|
-
// eslint-disable-next-line no-nested-ternary
|
|
155
|
-
var aliases = alias
|
|
156
|
-
? _.isArray(alias)
|
|
157
|
-
? "-".concat(alias === null || alias === void 0 ? void 0 : alias.map(function (a) { return toOption(a); }).join(', -'), ",")
|
|
158
|
-
: "".concat(toOption(alias))
|
|
159
|
-
: '';
|
|
160
|
-
var optionalText = required ? '' : 'OPTIONAL: ';
|
|
161
|
-
var flags = typeof opt.type === 'boolean'
|
|
162
|
-
? "".concat(aliases, " --").concat(name)
|
|
163
|
-
: "".concat(aliases, " --").concat(name, " <").concat(name.toUpperCase(), ">");
|
|
164
|
-
var description = optionalText + opt.description;
|
|
165
|
-
leafCommand.option(flags, description, defaultVal);
|
|
166
|
-
}
|
|
167
|
-
return Object.getOwnPropertyNames(currentDefaults).forEach(function (name) {
|
|
168
|
-
var endpoint = endpoints[name];
|
|
169
|
-
var defaultOpt = currentDefaults[name];
|
|
170
|
-
var nextCliPath = cliPath.concat([name]);
|
|
171
|
-
function parseOpts(baseOpts, leafCommand) {
|
|
172
|
-
var baseOptNames = Object.getOwnPropertyNames(baseOpts || {});
|
|
173
|
-
baseOptNames
|
|
174
|
-
.map(function (optString) {
|
|
175
|
-
return { name: optString, opt: baseOpts[optString] };
|
|
176
|
-
})
|
|
177
|
-
// eslint-disable-next-line no-nested-ternary
|
|
178
|
-
.sort(function (opt1, opt2) { return (!isRequired(opt1.opt) ? (!isRequired(opt2.opt) ? 0 : 1) : -1); })
|
|
179
|
-
.forEach(function (option) {
|
|
180
|
-
parseOptions(option, leafCommand);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
function setAliases(nextCmd, cmdName) {
|
|
184
|
-
var aliases = [
|
|
185
|
-
['project', 'projects', 'prj'],
|
|
186
|
-
['service', 'services', 'svc'],
|
|
187
|
-
['credentials', 'credential', 'cred'],
|
|
188
|
-
['addon', 'addons', 'adn'],
|
|
189
|
-
['job', 'jobs'],
|
|
190
|
-
['plan', 'plans', 'pln'],
|
|
191
|
-
['region', 'regions', 'rgn'],
|
|
192
|
-
['domain', 'domains', 'dmn'],
|
|
193
|
-
['secret', 'secrets', 'scrt'],
|
|
194
|
-
['volumes', 'volume', 'vol'],
|
|
195
|
-
['branches', 'branch', 'brn'],
|
|
196
|
-
['repos', 'repository', 'repositories', 'repo'],
|
|
197
|
-
];
|
|
198
|
-
var alias = aliases.find(function (a) { return a.includes(cmdName); });
|
|
199
|
-
if (alias !== undefined)
|
|
200
|
-
nextCmd.aliases(alias.filter(function (a) { return a !== cmdName; }));
|
|
201
|
-
}
|
|
202
|
-
function setPathVariables(opt) {
|
|
203
|
-
var _a, _b;
|
|
204
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
205
|
-
/**
|
|
206
|
-
* @param resource Resource identifier
|
|
207
|
-
* @param ctx Get result from client context
|
|
208
|
-
* @param ask Get result by asking interactively
|
|
209
|
-
*/
|
|
210
|
-
function setVar(resource, ask, ctx) {
|
|
211
|
-
var _a, _b;
|
|
212
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
-
var ctxRes, id, _c;
|
|
214
|
-
return __generator(this, function (_d) {
|
|
215
|
-
switch (_d.label) {
|
|
216
|
-
case 0:
|
|
217
|
-
if (!_.has((_b = (_a = defaultOpt.opt) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : {}, resource)) return [3 /*break*/, 3];
|
|
218
|
-
ctxRes = !askExplicitly && !isDeleteCmd && ctx ? ctx() : undefined;
|
|
219
|
-
_c = opt[resource] || // Always check command arguments first
|
|
220
|
-
ctxRes;
|
|
221
|
-
if (_c) return [3 /*break*/, 2];
|
|
222
|
-
return [4 /*yield*/, ask()];
|
|
223
|
-
case 1:
|
|
224
|
-
_c = (_d.sent());
|
|
225
|
-
_d.label = 2;
|
|
226
|
-
case 2:
|
|
227
|
-
id = _c;
|
|
228
|
-
_.set(parameters, resource, id);
|
|
229
|
-
_d.label = 3;
|
|
230
|
-
case 3: return [2 /*return*/];
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
var parameters, contextProvider, isDeleteCmd, askExplicitly;
|
|
236
|
-
var _this = this;
|
|
237
|
-
return __generator(this, function (_c) {
|
|
238
|
-
switch (_c.label) {
|
|
239
|
-
case 0:
|
|
240
|
-
parameters = {};
|
|
241
|
-
contextProvider = apiClient.contextProvider;
|
|
242
|
-
isDeleteCmd = nextCliPath.includes('delete');
|
|
243
|
-
askExplicitly = opt.noDefaults === true;
|
|
244
|
-
return [4 /*yield*/, (0, utils_1.asyncSequential)(Object.entries((_b = (_a = defaultOpt.opt) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : {}), function (_a) {
|
|
245
|
-
var pathVar = _a[0], val = _a[1];
|
|
246
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
247
|
-
var projectId, _b;
|
|
248
|
-
return __generator(this, function (_c) {
|
|
249
|
-
switch (_c.label) {
|
|
250
|
-
case 0:
|
|
251
|
-
projectId = parameters === null || parameters === void 0 ? void 0 : parameters.projectId;
|
|
252
|
-
_b = pathVar;
|
|
253
|
-
switch (_b) {
|
|
254
|
-
case 'projectId': return [3 /*break*/, 1];
|
|
255
|
-
case 'serviceId': return [3 /*break*/, 3];
|
|
256
|
-
case 'addonId': return [3 /*break*/, 5];
|
|
257
|
-
case 'jobId': return [3 /*break*/, 7];
|
|
258
|
-
case 'runId': return [3 /*break*/, 9];
|
|
259
|
-
case 'secretId': return [3 /*break*/, 11];
|
|
260
|
-
case 'domain': return [3 /*break*/, 13];
|
|
261
|
-
case 'domainId': return [3 /*break*/, 13];
|
|
262
|
-
case 'credentialId': return [3 /*break*/, 15];
|
|
263
|
-
case 'volumeId': return [3 /*break*/, 17];
|
|
264
|
-
case 'subdomain': return [3 /*break*/, 19];
|
|
265
|
-
case 'subdomainId': return [3 /*break*/, 21];
|
|
266
|
-
case 'backupId': return [3 /*break*/, 23];
|
|
267
|
-
case 'buildId': return [3 /*break*/, 25];
|
|
268
|
-
}
|
|
269
|
-
return [3 /*break*/, 27];
|
|
270
|
-
case 1: return [4 /*yield*/, setVar('projectId', inquirerHelper.askForProject.bind(inquirerHelper), contextProvider.getCurrentProjectName.bind(contextProvider))];
|
|
271
|
-
case 2: return [2 /*return*/, _c.sent()];
|
|
272
|
-
case 3: return [4 /*yield*/, setVar('serviceId', inquirerHelper.askForService(projectId).bind(inquirerHelper), contextProvider.getCurrentServiceName.bind(contextProvider))];
|
|
273
|
-
case 4: return [2 /*return*/, _c.sent()];
|
|
274
|
-
case 5: return [4 /*yield*/, setVar('addonId', inquirerHelper.askForAddon(projectId).bind(inquirerHelper))];
|
|
275
|
-
case 6: return [2 /*return*/, _c.sent()];
|
|
276
|
-
case 7: return [4 /*yield*/, setVar('jobId', inquirerHelper.askForJob(projectId).bind(inquirerHelper), contextProvider.getCurrentJobName.bind(contextProvider))];
|
|
277
|
-
case 8: return [2 /*return*/, _c.sent()];
|
|
278
|
-
case 9: return [4 /*yield*/, setVar('runId', inquirerHelper.askForJobRun(parameters.jobId, projectId).bind(inquirerHelper))];
|
|
279
|
-
case 10: return [2 /*return*/, _c.sent()];
|
|
280
|
-
case 11: return [4 /*yield*/, setVar('secretId', inquirerHelper.askForSecret(projectId).bind(inquirerHelper))];
|
|
281
|
-
case 12: return [2 /*return*/, _c.sent()];
|
|
282
|
-
case 13: return [4 /*yield*/, setVar('domain', inquirerHelper.askForDomain.bind(inquirerHelper))];
|
|
283
|
-
case 14: return [2 /*return*/, _c.sent()];
|
|
284
|
-
case 15: return [4 /*yield*/, setVar('credentialId', inquirerHelper.askForCredentials.bind(inquirerHelper))];
|
|
285
|
-
case 16: return [2 /*return*/, _c.sent()];
|
|
286
|
-
case 17: return [4 /*yield*/, setVar('volumeId', inquirerHelper.askForVolume(projectId).bind(inquirerHelper))];
|
|
287
|
-
case 18: return [2 /*return*/, _c.sent()];
|
|
288
|
-
case 19: return [4 /*yield*/, setVar('subdomain', inquirerHelper.askForSubdomain(parameters.domain).bind(inquirerHelper))];
|
|
289
|
-
case 20: return [2 /*return*/, _c.sent()];
|
|
290
|
-
case 21: return [4 /*yield*/, setVar('subdomainId', inquirerHelper.askForSubdomain(parameters.domainId).bind(inquirerHelper))];
|
|
291
|
-
case 22: return [2 /*return*/, _c.sent()];
|
|
292
|
-
case 23: return [4 /*yield*/, setVar('backupId', inquirerHelper.askForAddonBackup(projectId, parameters.addonId).bind(inquirerHelper))];
|
|
293
|
-
case 24: return [2 /*return*/, _c.sent()];
|
|
294
|
-
case 25: return [4 /*yield*/, setVar('buildId', inquirerHelper
|
|
295
|
-
.askForBuild(projectId, parameters.serviceId, parameters.jobId)
|
|
296
|
-
.bind(inquirerHelper))];
|
|
297
|
-
case 26: return [2 /*return*/, _c.sent()];
|
|
298
|
-
case 27: return [4 /*yield*/, setVar(pathVar, inquirerHelper.askGeneric(pathVar, val === null || val === void 0 ? void 0 : val.description).bind(inquirerHelper))];
|
|
299
|
-
case 28: return [2 /*return*/, _c.sent()];
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
})];
|
|
304
|
-
case 1:
|
|
305
|
-
_c.sent();
|
|
306
|
-
return [2 /*return*/, parameters];
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
function setQueryVariables(opt) {
|
|
312
|
-
var _a, _b;
|
|
313
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
-
var options, queryArgs;
|
|
315
|
-
var _this = this;
|
|
316
|
-
return __generator(this, function (_c) {
|
|
317
|
-
switch (_c.label) {
|
|
318
|
-
case 0:
|
|
319
|
-
options = {};
|
|
320
|
-
queryArgs = Object.keys((_b = (_a = defaultOpt.opt) === null || _a === void 0 ? void 0 : _a.query) !== null && _b !== void 0 ? _b : {});
|
|
321
|
-
return [4 /*yield*/, (0, utils_1.asyncSequential)(queryArgs, function (key) { return __awaiter(_this, void 0, void 0, function () {
|
|
322
|
-
var result, _a, required, schema;
|
|
323
|
-
return __generator(this, function (_b) {
|
|
324
|
-
switch (_b.label) {
|
|
325
|
-
case 0:
|
|
326
|
-
result = {};
|
|
327
|
-
_a = defaultOpt.opt.query[key], required = _a.required, schema = _a.schema;
|
|
328
|
-
return [4 /*yield*/, inquirerHelper.propToType(["".concat(key)], schema, result, required)];
|
|
329
|
-
case 1:
|
|
330
|
-
_b.sent();
|
|
331
|
-
if (result[key] !== undefined) {
|
|
332
|
-
_.set(options, key, result[key]);
|
|
333
|
-
}
|
|
334
|
-
return [2 /*return*/, result];
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
}); })];
|
|
338
|
-
case 1:
|
|
339
|
-
_c.sent();
|
|
340
|
-
return [2 /*return*/, options];
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
function getDescription() {
|
|
346
|
-
switch (nextCliPath[0]) {
|
|
347
|
-
case 'get':
|
|
348
|
-
return "Get information about Northflank ".concat(nextCliPath[1] || 'resource', "s");
|
|
349
|
-
case 'update':
|
|
350
|
-
return "Update Northflank ".concat(nextCliPath[1] || 'resource', " properties");
|
|
351
|
-
default:
|
|
352
|
-
return "".concat(_.upperFirst(name), " Northflank resources");
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
function constructCommand(currentEndpoint, isEndpointCommand) {
|
|
356
|
-
var _this = this;
|
|
357
|
-
var _a, _b, _c, _d;
|
|
358
|
-
if (!isEndpointCommand) {
|
|
359
|
-
var nextCmd = (0, utils_1.getCommand)().name(_.kebabCase(name)).description(getDescription());
|
|
360
|
-
setAliases(nextCmd, name);
|
|
361
|
-
return nextCmd;
|
|
362
|
-
}
|
|
363
|
-
var leafCommand = (0, utils_1.getCommand)(true)
|
|
364
|
-
.name(_.kebabCase(name))
|
|
365
|
-
.description(currentEndpoint.description || '');
|
|
366
|
-
setAliases(leafCommand, name);
|
|
367
|
-
if ((_a = defaultOpt.opt) === null || _a === void 0 ? void 0 : _a.body) {
|
|
368
|
-
leafCommand.option('-f, --file <file-path>', 'File to load resource json from');
|
|
369
|
-
leafCommand.option('-i, --input <resource-def>', 'JSON-formatted resource definition, takes precedence over "--file"');
|
|
370
|
-
}
|
|
371
|
-
parseOpts((_b = defaultOpt.opt) === null || _b === void 0 ? void 0 : _b.path, leafCommand);
|
|
372
|
-
parseOpts((_c = defaultOpt.opt) === null || _c === void 0 ? void 0 : _c.query, leafCommand);
|
|
373
|
-
parseOpts((_d = defaultOpt.opt) === null || _d === void 0 ? void 0 : _d.base, leafCommand);
|
|
374
|
-
leafCommand.action(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
375
|
-
var opt, parameters, options, contextIndicator, contextInfoMessage, jsonResource, _a, _b, _c, data, request, errorResponse, errorDetails, nfId, id, output, columns, resourceId, resourceDescr, title, tableData;
|
|
376
|
-
var _d, _e, _f;
|
|
377
|
-
return __generator(this, function (_g) {
|
|
378
|
-
switch (_g.label) {
|
|
379
|
-
case 0:
|
|
380
|
-
(0, utils_1.assertContextExisting)(apiClient);
|
|
381
|
-
opt = leafCommand.opts();
|
|
382
|
-
return [4 /*yield*/, setPathVariables(opt)];
|
|
383
|
-
case 1:
|
|
384
|
-
parameters = _g.sent();
|
|
385
|
-
inquirerHelper.setPathVars(parameters);
|
|
386
|
-
return [4 /*yield*/, setQueryVariables(opt)];
|
|
387
|
-
case 2:
|
|
388
|
-
options = _g.sent();
|
|
389
|
-
contextIndicator = Object.keys((_e = (_d = defaultOpt.opt) === null || _d === void 0 ? void 0 : _d.path) !== null && _e !== void 0 ? _e : {})
|
|
390
|
-
.map(function (p) { return "".concat(p, "=").concat(chalk_1.default.green(parameters[p])); })
|
|
391
|
-
.join(', ');
|
|
392
|
-
if (contextIndicator.length > 0) {
|
|
393
|
-
contextInfoMessage = "=> running command with: ".concat(contextIndicator);
|
|
394
|
-
console.log(contextInfoMessage);
|
|
395
|
-
}
|
|
396
|
-
if (!((_f = defaultOpt.opt) === null || _f === void 0 ? void 0 : _f.body)) return [3 /*break*/, 4];
|
|
397
|
-
return [4 /*yield*/, parsePayload(opt, defaultOpt, nextCliPath)];
|
|
398
|
-
case 3:
|
|
399
|
-
_a = _g.sent();
|
|
400
|
-
return [3 /*break*/, 5];
|
|
401
|
-
case 4:
|
|
402
|
-
_a = undefined;
|
|
403
|
-
_g.label = 5;
|
|
404
|
-
case 5:
|
|
405
|
-
jsonResource = _a;
|
|
406
|
-
_b = !opt.force &&
|
|
407
|
-
nextCliPath.includes('delete');
|
|
408
|
-
if (!_b) return [3 /*break*/, 7];
|
|
409
|
-
return [4 /*yield*/, inquirerHelper.deleteWarningPrompt()];
|
|
410
|
-
case 6:
|
|
411
|
-
_b = !(_g.sent());
|
|
412
|
-
_g.label = 7;
|
|
413
|
-
case 7:
|
|
414
|
-
if (_b) {
|
|
415
|
-
(0, utils_1.warning)('Resource was not deleted.');
|
|
416
|
-
return [2 /*return*/];
|
|
417
|
-
}
|
|
418
|
-
return [4 /*yield*/, endpoint.call({ parameters: parameters, options: options, data: jsonResource })];
|
|
419
|
-
case 8:
|
|
420
|
-
_c = _g.sent(), data = _c.data, request = _c.request, errorResponse = _c.error;
|
|
421
|
-
if (opt === null || opt === void 0 ? void 0 : opt.verbose) {
|
|
422
|
-
console.log("VERBOSE: Using endpoint -> ".concat(request.method, ":").concat(request.url));
|
|
423
|
-
console.log("VERBOSE: Request body -> ".concat(request.body));
|
|
424
|
-
}
|
|
425
|
-
if (errorResponse) {
|
|
426
|
-
errorDetails = errorResponse.details
|
|
427
|
-
? "\n\tdetails :".concat(JSON.stringify(errorResponse.details))
|
|
428
|
-
: '';
|
|
429
|
-
nfId = (errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.id) ? ", NF error id: ".concat(errorResponse.id) : '';
|
|
430
|
-
id = "(HTTP status code: ".concat(errorResponse.status).concat(nfId, ")");
|
|
431
|
-
throw new Error("API request failed\n\tMessage: ".concat(errorResponse.message, " ").concat(id).concat(errorDetails));
|
|
432
|
-
}
|
|
433
|
-
if (!(opt === null || opt === void 0 ? void 0 : opt.quiet)) {
|
|
434
|
-
output = opt === null || opt === void 0 ? void 0 : opt.output;
|
|
435
|
-
if (output === 'json') {
|
|
436
|
-
console.log((0, console_format_helpers_1.consoleFormat)(data));
|
|
437
|
-
}
|
|
438
|
-
else if (output === 'yaml' || output === 'yml') {
|
|
439
|
-
console.log(yaml.safeDump(data));
|
|
440
|
-
}
|
|
441
|
-
else if (isListCommand(nextCliPath)) {
|
|
442
|
-
columns = (output === null || output === void 0 ? void 0 : output.startsWith('custom-columns='))
|
|
443
|
-
? output
|
|
444
|
-
.replace('custom-columns=', '')
|
|
445
|
-
.split(',')
|
|
446
|
-
.map(function (c) { return c.toLowerCase(); })
|
|
447
|
-
: undefined;
|
|
448
|
-
resourceId = nextCliPath[nextCliPath.length - 1];
|
|
449
|
-
resourceDescr = "".concat(resourceId).concat(resourceId.endsWith('s') ? '' : 's');
|
|
450
|
-
title = _.upperFirst(resourceDescr);
|
|
451
|
-
tableData = _.has(data, resourceDescr) ? data[resourceDescr] : data;
|
|
452
|
-
(0, console_format_helpers_1.printAsTable)(tableData, title, columns);
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
console.log((0, console_format_helpers_1.consoleFormat)(data));
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
return [2 /*return*/];
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}); });
|
|
462
|
-
return leafCommand;
|
|
463
|
-
}
|
|
464
|
-
var isEndpointCommand = _.has(defaultOpt, 'opt');
|
|
465
|
-
var currentEndpoint = endpoint;
|
|
466
|
-
var command = constructCommand(currentEndpoint, isEndpointCommand);
|
|
467
|
-
cmd.addCommand(command);
|
|
468
|
-
var optWithoutOpt = _.omit(defaultOpt, 'opt');
|
|
469
|
-
if (Object.keys(optWithoutOpt).length > 0) {
|
|
470
|
-
// If this command has more subcommands, add them recursively
|
|
471
|
-
generateCommands(apiClient, endpoint, command, optWithoutOpt, nextCliPath);
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
function getInput(opt, defaultOpt, cmdPath) {
|
|
475
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
476
|
-
var input, file, fileContent, jsonResource;
|
|
477
|
-
return __generator(this, function (_a) {
|
|
478
|
-
switch (_a.label) {
|
|
479
|
-
case 0:
|
|
480
|
-
input = opt.input, file = opt.file;
|
|
481
|
-
if (input !== undefined) {
|
|
482
|
-
try {
|
|
483
|
-
return [2 /*return*/, JSON.parse(input)];
|
|
484
|
-
}
|
|
485
|
-
catch (e) {
|
|
486
|
-
try {
|
|
487
|
-
return [2 /*return*/, yaml.safeLoad(input)];
|
|
488
|
-
}
|
|
489
|
-
catch (d) {
|
|
490
|
-
throw new Error('Unknown input format. Not valid json and not valid yaml.');
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
if (file !== undefined) {
|
|
495
|
-
if (!fs_1.default.existsSync(file)) {
|
|
496
|
-
throw new Error("File does not exist: ".concat(file));
|
|
497
|
-
}
|
|
498
|
-
fileContent = fs_1.default.readFileSync(file).toString();
|
|
499
|
-
jsonResource = void 0;
|
|
500
|
-
try {
|
|
501
|
-
if (_.isString(fileContent)) {
|
|
502
|
-
if (opt.file.endsWith('.json')) {
|
|
503
|
-
jsonResource = JSON.parse(fileContent);
|
|
504
|
-
}
|
|
505
|
-
else if (opt.file.endsWith('.yaml') || opt.file.endsWith('yml')) {
|
|
506
|
-
jsonResource = yaml.safeLoad(fileContent);
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
509
|
-
throw new Error("Unknown input file type: ".concat(opt.file.split('.').pop()));
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
else {
|
|
513
|
-
jsonResource = fileContent;
|
|
514
|
-
}
|
|
515
|
-
return [2 /*return*/, jsonResource];
|
|
516
|
-
}
|
|
517
|
-
catch (e) {
|
|
518
|
-
throw new Error("Failed to validate input (incorrect format): ".concat(e.message));
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
return [4 /*yield*/, inquirerHelper.retrievePayloadViaInteractiveCli(defaultOpt, { cmdPath: cmdPath })];
|
|
522
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
523
|
-
}
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
function parsePayload(opt, defaultOpt, cmdPath) {
|
|
528
|
-
var _a;
|
|
529
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
530
|
-
var bodyObject, ajv, valid, filteredErrors;
|
|
531
|
-
return __generator(this, function (_b) {
|
|
532
|
-
switch (_b.label) {
|
|
533
|
-
case 0: return [4 /*yield*/, getInput(opt, defaultOpt, cmdPath)];
|
|
534
|
-
case 1:
|
|
535
|
-
bodyObject = _b.sent();
|
|
536
|
-
ajv = new ajv_1.default({
|
|
537
|
-
allErrors: true,
|
|
538
|
-
keywords: ['example'],
|
|
539
|
-
validateFormats: false,
|
|
540
|
-
strict: false,
|
|
541
|
-
unicodeRegExp: false,
|
|
542
|
-
});
|
|
543
|
-
valid = false;
|
|
544
|
-
try {
|
|
545
|
-
valid = ajv.validate(defaultOpt.opt.body, bodyObject);
|
|
546
|
-
}
|
|
547
|
-
catch (e) {
|
|
548
|
-
if (e.message.includes('runtimeFiles/additionalProperties')) {
|
|
549
|
-
// known error, ignore
|
|
550
|
-
valid = true;
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
throw e;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
filteredErrors = (_a = ajv === null || ajv === void 0 ? void 0 : ajv.errors) === null || _a === void 0 ? void 0 : _a.filter(function (err) { var _a; return !((_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.includes('match exactly one schema in oneOf')); });
|
|
557
|
-
if (!valid && filteredErrors !== undefined && (filteredErrors === null || filteredErrors === void 0 ? void 0 : filteredErrors.length) > 0) {
|
|
558
|
-
throw new Error("Failed to validate input (schema mismatch):\n".concat(JSON.stringify(ajv.errors, null, ' ')));
|
|
559
|
-
}
|
|
560
|
-
return [2 /*return*/, bodyObject];
|
|
561
|
-
}
|
|
562
|
-
});
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
}
|
|
2
|
+
'use strict';var a1u=['__setModuleDefault','getCommand','\x20properties','iterator','addon','OPTIONAL:\x20','yml','askForJob','122134HzpqTm','endsWith',',\x20NF\x20error\x20id:\x20','has','--verbose','return','jobId','endpoints','subdomain','name','=>\x20running\x20command\x20with:\x20','backups','pop','find','message','forEach','isString','label','isEqual','253049VffUAM','hasOwnProperty','details','set','1351647Eumcrd','rgn','services','project','credentialId','file','-f,\x20--file\x20<file-path>','portFwdCmd','Update\x20Northflank\x20','branches','__importStar','askForDomain','trys','askForAddon','yaml','job','Northflank\x20cli\x20version:\x20','force','askForSecret','log','update','Failed\x20to\x20validate\x20input\x20(incorrect\x20format):\x20','subdomainId','northflank','./inquirer-helper','includes','./context/contextCommands','body','projects','opts','-i,\x20--input\x20<resource-def>','getCurrentServiceName','CliExec','./port-forward','\x20--','concat','sent','__importDefault','VERBOSE:\x20Using\x20endpoint\x20->\x20','contextProvider','\x20Northflank\x20resources','join','map','some','path','4WewqWv','customUserAgent','deleteWarningPrompt','get','JSON-formatted\x20resource\x20definition,\x20takes\x20precedence\x20over\x20\x22--file\x22','configurable','schema','data','domains','status','stringify','getOwnPropertyNames','regions','975272kiGfwF','__createBinding','default','.yaml','scrt','serviceId','checkUpdate','isArray','length','kebabCase','pln','getCommandOverview','required','addCommand','1188950zfTLqE','askForService','function','enablePositionalOptions','@northflank/js-client','ApiClient','secretId','askForVolume','addonId','argv','error','contexts','__awaiter','svc','./defaults','example','./console-format-helpers','keys','parseAsync','login','boolean','upperFirst','push','consoleFormat','sort','File\x20to\x20load\x20resource\x20json\x20from','parse','repositories','base','custom-columns=','validate','ApiClientFileContextProvider','asyncSequential','1148478BeLLEZ','action','bind','green','__esModule','projectId','retrievePayloadViaInteractiveCli','askGeneric','assertContextExisting','CliContext','repos','option','Resource\x20was\x20not\x20deleted.','Print\x20the\x20current\x20version\x20of\x20the\x20Northflank\x20cli','(HTTP\x20status\x20code:\x20','type','service','toLowerCase','repo','InquirerHelper','safeDump','volumeId','askForJobRun','4tbxYdd','__generator','toUpperCase','match\x20exactly\x20one\x20schema\x20in\x20oneOf','CliPortForward','askForProject','394GeanNK','adn','Unknown\x20input\x20file\x20type:\x20','lodash','3086IaXITa','alias','File\x20does\x20not\x20exist:\x20','buildId','existsSync','jobs','runs','.json','input','opt','throw','plans','defaults','setPathVars','version','runtimeFiles/additionalProperties','call','getOwnPropertyDescriptor','backupId','VERBOSE:\x20Request\x20body\x20->\x20','filter','create','query','commander','cred','apply','request','addons','done','domainId','API\x20request\x20failed\x0a\x09Message:\x20','runId','./exec','brn','split','safeLoad','url','value','plan','Command','delete','defineProperty','js-yaml','Generator\x20is\x20already\x20executing.','replace','askForSubdomain','description','secret','secrets','json','-v,\x20--version','warning','quiet','then','resource','prototype','domain','propToType','\x0a\x09details\x20:','noDefaults','entries','ops','credentials','repository'];var a1u8=a1F;(function(u,F){var u7=a1F;while(!![]){try{var j=-parseInt(u7(0x88))+parseInt(u7(0x133))*-parseInt(u7(0x7b))+parseInt(u7(0xb7))+parseInt(u7(0x96))+-parseInt(u7(0x120))*-parseInt(u7(0xce))+-parseInt(u7(0x137))+parseInt(u7(0xd8))*parseInt(u7(0xd4));if(j===F)break;else u['push'](u['shift']());}catch(L){u['push'](u['shift']());}}}(a1u,0xab90d));var __createBinding=this&&this[a1u8(0x89)]||(Object[a1u8(0xed)]?function(u,F,j,L){var u9=a1u8;if(L===undefined)L=j;var R=Object[u9(0xe9)](F,j);(!R||(u9(0x7e)in R?!F[u9(0xbb)]:R['writable']||R[u9(0x80)]))&&(R={'enumerable':!![],'get':function(){return F[j];}}),Object['defineProperty'](u,L,R);}:function(u,F,j,L){if(L===undefined)L=j;u[L]=F[j];}),__setModuleDefault=this&&this[a1u8(0x118)]||(Object[a1u8(0xed)]?function(u,F){var uu=a1u8;Object[uu(0x101)](u,uu(0x8a),{'enumerable':!![],'value':F});}:function(u,F){var uF=a1u8;u[uF(0x8a)]=F;}),__importStar=this&&this[a1u8(0x141)]||function(u){var uj=a1u8;if(u&&u['__esModule'])return u;var F={};if(u!=null){for(var j in u)if(j!=='default'&&Object[uj(0x10f)][uj(0x134)][uj(0xe8)](u,j))__createBinding(F,u,j);}return __setModuleDefault(F,u),F;},__awaiter=this&&this[a1u8(0xa2)]||function(u,F,j,L){function R(z){return z instanceof j?z:new j(function(y){y(z);});}return new(j||(j=Promise))(function(z,y){var uz=a1F;function V(l){try{h(L['next'](l));}catch(t){y(t);}}function g(l){var uL=a1F;try{h(L[uL(0xe2)](l));}catch(t){y(t);}}function h(l){var uR=a1F;l[uR(0xf4)]?z(l[uR(0xfd)]):R(l[uR(0xfd)])[uR(0x10d)](V,g);}h((L=L[uz(0xf1)](u,F||[]))['next']());});},__generator=this&&this[a1u8(0xcf)]||function(u,F){var uy=a1u8,j={'label':0x0,'sent':function(){if(z[0x0]&0x1)throw z[0x1];return z[0x1];},'trys':[],'ops':[]},L,R,z,V;return V={'next':h(0x0),'throw':h(0x1),'return':h(0x2)},typeof Symbol===uy(0x98)&&(V[Symbol[uy(0x11b)]]=function(){return this;}),V;function h(B){return function(O){return l([B,O]);};}function l(B){var uV=uy;if(L)throw new TypeError(uV(0x103));while(j)try{if(L=0x1,R&&(z=B[0x0]&0x2?R[uV(0x125)]:B[0x0]?R[uV(0xe2)]||((z=R[uV(0x125)])&&z[uV(0xe8)](R),0x0):R['next'])&&!(z=z[uV(0xe8)](R,B[0x1]))[uV(0xf4)])return z;if(R=0x0,z)B=[B[0x0]&0x2,z[uV(0xfd)]];switch(B[0x0]){case 0x0:case 0x1:z=B;break;case 0x4:j[uV(0x131)]++;return{'value':B[0x1],'done':![]};case 0x5:j[uV(0x131)]++,R=B[0x1],B=[0x0];continue;case 0x7:B=j[uV(0x115)][uV(0x12c)](),j['trys']['pop']();continue;default:if(!(z=j['trys'],z=z[uV(0x90)]>0x0&&z[z[uV(0x90)]-0x1])&&(B[0x0]===0x6||B[0x0]===0x2)){j=0x0;continue;}if(B[0x0]===0x3&&(!z||B[0x1]>z[0x0]&&B[0x1]<z[0x3])){j[uV(0x131)]=B[0x1];break;}if(B[0x0]===0x6&&j['label']<z[0x1]){j['label']=z[0x1],z=B;break;}if(z&&j[uV(0x131)]<z[0x2]){j[uV(0x131)]=z[0x2],j[uV(0x115)][uV(0xac)](B);break;}if(z[0x2])j[uV(0x115)]['pop']();j[uV(0x143)][uV(0x12c)]();continue;}B=F['call'](u,j);}catch(O){B=[0x6,O],R=0x0;}finally{L=z=0x0;}if(B[0x0]&0x5)throw B[0x1];return{'value':B[0x0]?B[0x1]:void 0x0,'done':!![]};}},__importDefault=this&&this[a1u8(0x73)]||function(u){return u&&u['__esModule']?u:{'default':u};};Object[a1u8(0x101)](exports,'__esModule',{'value':!![]});var js_client_1=require(a1u8(0x9a)),commander_1=__importDefault(require(a1u8(0xef))),fs_1=__importDefault(require('fs')),ajv_1=__importDefault(require('ajv')),chalk_1=__importDefault(require('chalk')),_=__importStar(require(a1u8(0xd7))),contextCommands_1=require(a1u8(0x151)),utils_1=require('./utils'),defaults=__importStar(require(a1u8(0xa4))),inquirer_helper_1=require(a1u8(0x14f)),console_format_helpers_1=require(a1u8(0xa6)),command_overview_1=require('./command-overview'),port_forward_1=require(a1u8(0x6f)),exec_1=require(a1u8(0xf8)),yaml=require(a1u8(0x102)),pgk=require('../package.json');(function(){return __awaiter(void 0x0,void 0x0,void 0x0,function(){var u,F,j,L,R,z,y;return __generator(this,function(V){var ug=a1F;switch(V[ug(0x131)]){case 0x0:V['trys'][ug(0xac)]([0x0,0x3,,0x4]),u=new commander_1[(ug(0x8a))][(ug(0xff))](ug(0x14e)),u[ug(0x99)](!![]),u[ug(0xe6)](ug(0x147)[ug(0x71)](chalk_1[ug(0x8a)]['underline'](pgk['version'])),ug(0x10a),ug(0xc4)),F=new js_client_1[(ug(0xb5))]();return[0x4,(0x0,utils_1[ug(0x8e)])(F)];case 0x1:V[ug(0x72)](),j=new js_client_1['ApiClient'](F,{'throwErrorOnHttpErrorCode':![],'customUserAgent':utils_1[ug(0x7c)]}),L=new contextCommands_1[(ug(0xc0))](j),R=new port_forward_1[(ug(0xd2))](F),z=new exec_1[(ug(0x6e))](F),u[ug(0x95)](R[ug(0x13e)]),u[ug(0x95)](z['execCmd']),u['addCommand'](L[ug(0xa9)]),u['addCommand'](L[ug(0xa1)]),generateCommands(j,j[ug(0x127)],u),u['addCommand']((0x0,command_overview_1[ug(0x93)])(u));return[0x4,u[ug(0xa8)](process[ug(0x9f)])];case 0x2:V[ug(0x72)]();return[0x3,0x4];case 0x3:y=V['sent'](),(0x0,utils_1[ug(0xa0)])('Error\x20occured\x20while\x20trying\x20to\x20run\x20command,\x20error:\x20'['concat'](y[ug(0x12e)]));process[ug(0x9f)][ug(0x12d)](function(g){var uh=ug;return g===uh(0x124);})&&console[ug(0x14a)](y);process['exitCode']=0x1;return[0x3,0x4];case 0x4:return[0x2];}});});}());function isListCommand(u){var ul=a1u8,F=[[ul(0x7e),ul(0x11c),ul(0x12b)],[ul(0x7e),'job',ul(0xde)]];return u[ul(0x12d)](function(j){return j==='list';})||F[ul(0x79)](function(j){var ut=ul;return _[ut(0x132)](u,j);});}function a1F(u,F){u=u-0x6d;var j=a1u[u];return j;}function generateCommands(u,F,j,L,R){var uB=a1u8;L===void 0x0&&(L=defaults[uB(0xe4)]);R===void 0x0&&(R=[]);var z=new inquirer_helper_1[(uB(0xca))](new js_client_1[(uB(0x9b))](u[uB(0x75)],{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1['customUserAgent']}));function y(l,t){var uO=uB;return l[uO(0x94)]!==![]&&t===undefined;}function V(l,t){var un=uB,B=l[un(0xe1)],O=l[un(0x129)],n=B[un(0x8a)],o=y(B,n),C=function(Q){var uo=un;return Q[uo(0x90)]>0x1?'--'[uo(0x71)](Q):'-'[uo(0x71)](Q);},G=B===null||B===void 0x0?void 0x0:B[un(0xd9)],f=G?_[un(0x8f)](G)?'-'[un(0x71)](G===null||G===void 0x0?void 0x0:G[un(0x78)](function(Q){return C(Q);})[un(0x77)](',\x20-'),','):''['concat'](C(G)):'',W=o?'':un(0x11d),S=typeof B[un(0xc6)]===un(0xaa)?''[un(0x71)](f,'\x20--')['concat'](O):''[un(0x71)](f,un(0x70))[un(0x71)](O,'\x20<')[un(0x71)](O[un(0xd0)](),'>'),D=W+B[un(0x106)];t[un(0xc2)](S,D,n);}return Object['getOwnPropertyNames'](L)['forEach'](function(l){var uC=uB,t=F[l],B=L[l],O=R[uC(0x71)]([l]);function n(M,a){var uG=uC,I=Object[uG(0x86)](M||{});I[uG(0x78)](function(T){return{'name':T,'opt':M[T]};})[uG(0xae)](function(T,N){var uf=uG;return!y(T[uf(0xe1)])?!y(N[uf(0xe1)])?0x0:0x1:-0x1;})[uG(0x12f)](function(T){V(T,a);});}function o(M,a){var uW=uC,I=[[uW(0x13a),uW(0x153),'prj'],[uW(0xc7),uW(0x139),uW(0xa3)],[uW(0x116),'credential',uW(0xf0)],[uW(0x11c),uW(0xf3),uW(0xd5)],[uW(0x146),uW(0xdd)],[uW(0xfe),uW(0xe3),uW(0x92)],['region',uW(0x87),uW(0x138)],[uW(0x110),uW(0x83),'dmn'],[uW(0x107),uW(0x108),uW(0x8c)],['volumes','volume','vol'],[uW(0x140),'branch',uW(0xf9)],[uW(0xc1),uW(0x117),uW(0xb1),uW(0xc9)]],T=I['find'](function(N){var uS=uW;return N[uS(0x150)](a);});if(T!==undefined)M['aliases'](T[uW(0xec)](function(N){return N!==a;}));}function C(M){var a,I;return __awaiter(this,void 0x0,void 0x0,function(){function T(c,x,i){var b,A;return __awaiter(this,void 0x0,void 0x0,function(){var Y,Z,E;return __generator(this,function(d){var uD=a1F;switch(d[uD(0x131)]){case 0x0:if(!_['has']((A=(b=B[uD(0xe1)])===null||b===void 0x0?void 0x0:b[uD(0x7a)])!==null&&A!==void 0x0?A:{},c))return[0x3,0x3];Y=!m&&!K&&i?i():undefined,E=M[c]||Y;if(E)return[0x3,0x2];return[0x4,x()];case 0x1:E=d[uD(0x72)](),d[uD(0x131)]=0x2;case 0x2:Z=E,_['set'](N,c,Z),d['label']=0x3;case 0x3:return[0x2];}});});}var N,P,K,m,e=this;return __generator(this,function(c){var uQ=a1F;switch(c[uQ(0x131)]){case 0x0:N={},P=u[uQ(0x75)],K=O[uQ(0x150)]('delete'),m=M[uQ(0x113)]===!![];return[0x4,(0x0,utils_1[uQ(0xb6)])(Object[uQ(0x114)]((I=(a=B[uQ(0xe1)])===null||a===void 0x0?void 0x0:a[uQ(0x7a)])!==null&&I!==void 0x0?I:{}),function(x){var i=x[0x0],b=x[0x1];return __awaiter(e,void 0x0,void 0x0,function(){var A,Y;return __generator(this,function(Z){var uX=a1F;switch(Z['label']){case 0x0:A=N===null||N===void 0x0?void 0x0:N[uX(0xbc)],Y=i;switch(Y){case uX(0xbc):return[0x3,0x1];case'serviceId':return[0x3,0x3];case uX(0x9e):return[0x3,0x5];case uX(0x126):return[0x3,0x7];case'runId':return[0x3,0x9];case uX(0x9c):return[0x3,0xb];case uX(0x110):return[0x3,0xd];case uX(0xf5):return[0x3,0xd];case uX(0x13b):return[0x3,0xf];case uX(0xcc):return[0x3,0x11];case uX(0x128):return[0x3,0x13];case'subdomainId':return[0x3,0x15];case uX(0xea):return[0x3,0x17];case uX(0xdb):return[0x3,0x19];}return[0x3,0x1b];case 0x1:return[0x4,T(uX(0xbc),z[uX(0xd3)]['bind'](z),P['getCurrentProjectName'][uX(0xb9)](P))];case 0x2:return[0x2,Z[uX(0x72)]()];case 0x3:return[0x4,T(uX(0x8d),z[uX(0x97)](A)[uX(0xb9)](z),P[uX(0x6d)][uX(0xb9)](P))];case 0x4:return[0x2,Z[uX(0x72)]()];case 0x5:return[0x4,T(uX(0x9e),z[uX(0x144)](A)['bind'](z))];case 0x6:return[0x2,Z[uX(0x72)]()];case 0x7:return[0x4,T(uX(0x126),z[uX(0x11f)](A)[uX(0xb9)](z),P['getCurrentJobName'][uX(0xb9)](P))];case 0x8:return[0x2,Z[uX(0x72)]()];case 0x9:return[0x4,T(uX(0xf7),z[uX(0xcd)](N['jobId'],A)['bind'](z))];case 0xa:return[0x2,Z[uX(0x72)]()];case 0xb:return[0x4,T(uX(0x9c),z[uX(0x149)](A)[uX(0xb9)](z))];case 0xc:return[0x2,Z[uX(0x72)]()];case 0xd:return[0x4,T('domain',z[uX(0x142)][uX(0xb9)](z))];case 0xe:return[0x2,Z[uX(0x72)]()];case 0xf:return[0x4,T('credentialId',z['askForCredentials'][uX(0xb9)](z))];case 0x10:return[0x2,Z[uX(0x72)]()];case 0x11:return[0x4,T(uX(0xcc),z[uX(0x9d)](A)[uX(0xb9)](z))];case 0x12:return[0x2,Z[uX(0x72)]()];case 0x13:return[0x4,T(uX(0x128),z[uX(0x105)](N['domain'])['bind'](z))];case 0x14:return[0x2,Z[uX(0x72)]()];case 0x15:return[0x4,T(uX(0x14d),z[uX(0x105)](N['domainId'])[uX(0xb9)](z))];case 0x16:return[0x2,Z[uX(0x72)]()];case 0x17:return[0x4,T('backupId',z['askForAddonBackup'](A,N['addonId'])[uX(0xb9)](z))];case 0x18:return[0x2,Z[uX(0x72)]()];case 0x19:return[0x4,T(uX(0xdb),z['askForBuild'](A,N[uX(0x8d)],N[uX(0x126)])['bind'](z))];case 0x1a:return[0x2,Z[uX(0x72)]()];case 0x1b:return[0x4,T(i,z[uX(0xbe)](i,b===null||b===void 0x0?void 0x0:b[uX(0x106)])['bind'](z))];case 0x1c:return[0x2,Z[uX(0x72)]()];}});});})];case 0x1:c['sent']();return[0x2,N];}});});}function G(M){var a,I;return __awaiter(this,void 0x0,void 0x0,function(){var T,N,P=this;return __generator(this,function(K){var uM=a1F;switch(K[uM(0x131)]){case 0x0:T={},N=Object['keys']((I=(a=B[uM(0xe1)])===null||a===void 0x0?void 0x0:a[uM(0xee)])!==null&&I!==void 0x0?I:{});return[0x4,(0x0,utils_1['asyncSequential'])(N,function(m){return __awaiter(P,void 0x0,void 0x0,function(){var e,c,x,i;return __generator(this,function(b){var ua=a1F;switch(b[ua(0x131)]){case 0x0:e={},(c=B[ua(0xe1)][ua(0xee)][m],x=c[ua(0x94)],i=c[ua(0x81)]);return[0x4,z[ua(0x111)]([''[ua(0x71)](m)],i,e,x)];case 0x1:b['sent']();e[m]!==undefined&&_[ua(0x136)](T,m,e[m]);return[0x2,e];}});});})];case 0x1:K[uM(0x72)]();return[0x2,T];}});});}function f(){var uI=uC;switch(O[0x0]){case uI(0x7e):return'Get\x20information\x20about\x20Northflank\x20'[uI(0x71)](O[0x1]||uI(0x10e),'s');case uI(0x14b):return uI(0x13f)[uI(0x71)](O[0x1]||uI(0x10e),uI(0x11a));default:return''[uI(0x71)](_[uI(0xab)](l),uI(0x76));}}function W(M,a){var uT=uC,I=this,T,N,P,K;if(!a){var m=(0x0,utils_1['getCommand'])()['name'](_[uT(0x91)](l))['description'](f());return o(m,l),m;}var e=(0x0,utils_1[uT(0x119)])(!![])[uT(0x129)](_['kebabCase'](l))[uT(0x106)](M[uT(0x106)]||'');return o(e,l),((T=B['opt'])===null||T===void 0x0?void 0x0:T['body'])&&(e['option'](uT(0x13d),uT(0xaf)),e[uT(0xc2)](uT(0x155),uT(0x7f))),n((N=B[uT(0xe1)])===null||N===void 0x0?void 0x0:N[uT(0x7a)],e),n((P=B['opt'])===null||P===void 0x0?void 0x0:P[uT(0xee)],e),n((K=B[uT(0xe1)])===null||K===void 0x0?void 0x0:K[uT(0xb2)],e),e[uT(0xb8)](function(){return __awaiter(I,void 0x0,void 0x0,function(){var c,x,i,b,A,Y,Z,E,d,s,H,J,q,p,w,k,r,v,U,u0,u1,u2,u3,u4;return __generator(this,function(u5){var uN=a1F;switch(u5[uN(0x131)]){case 0x0:(0x0,utils_1[uN(0xbf)])(u),c=e[uN(0x154)]();return[0x4,C(c)];case 0x1:x=u5[uN(0x72)](),z[uN(0xe5)](x);return[0x4,G(c)];case 0x2:i=u5['sent'](),b=Object[uN(0xa7)]((u3=(u2=B[uN(0xe1)])===null||u2===void 0x0?void 0x0:u2['path'])!==null&&u3!==void 0x0?u3:{})['map'](function(u6){var uP=uN;return''[uP(0x71)](u6,'=')[uP(0x71)](chalk_1[uP(0x8a)][uP(0xba)](x[u6]));})[uN(0x77)](',\x20');b[uN(0x90)]>0x0&&(A=uN(0x12a)[uN(0x71)](b),console[uN(0x14a)](A));if(!((u4=B[uN(0xe1)])===null||u4===void 0x0?void 0x0:u4['body']))return[0x3,0x4];return[0x4,h(c,B,O)];case 0x3:Z=u5[uN(0x72)]();return[0x3,0x5];case 0x4:Z=undefined,u5[uN(0x131)]=0x5;case 0x5:Y=Z,E=!c[uN(0x148)]&&O[uN(0x150)](uN(0x100));if(!E)return[0x3,0x7];return[0x4,z[uN(0x7d)]()];case 0x6:E=!u5[uN(0x72)](),u5[uN(0x131)]=0x7;case 0x7:if(E)return(0x0,utils_1[uN(0x10b)])(uN(0xc3)),[0x2];return[0x4,t[uN(0xe8)]({'parameters':x,'options':i,'data':Y})];case 0x8:d=u5[uN(0x72)](),s=d[uN(0x82)],H=d[uN(0xf2)],J=d['error'];(c===null||c===void 0x0?void 0x0:c['verbose'])&&(console[uN(0x14a)](uN(0x74)[uN(0x71)](H['method'],':')[uN(0x71)](H[uN(0xfc)])),console['log'](uN(0xeb)[uN(0x71)](H[uN(0x152)])));if(J){q=J['details']?uN(0x112)[uN(0x71)](JSON['stringify'](J[uN(0x135)])):'',p=(J===null||J===void 0x0?void 0x0:J['id'])?uN(0x122)[uN(0x71)](J['id']):'',w=uN(0xc5)[uN(0x71)](J[uN(0x84)])[uN(0x71)](p,')');throw new Error(uN(0xf6)[uN(0x71)](J[uN(0x12e)],'\x20')[uN(0x71)](w)[uN(0x71)](q));}if(!(c===null||c===void 0x0?void 0x0:c[uN(0x10c)])){k=c===null||c===void 0x0?void 0x0:c['output'];if(k===uN(0x109))console[uN(0x14a)]((0x0,console_format_helpers_1[uN(0xad)])(s));else{if(k===uN(0x145)||k===uN(0x11e))console[uN(0x14a)](yaml[uN(0xcb)](s));else isListCommand(O)?(r=(k===null||k===void 0x0?void 0x0:k['startsWith'](uN(0xb3)))?k[uN(0x104)](uN(0xb3),'')[uN(0xfa)](',')[uN(0x78)](function(u6){var uK=uN;return u6[uK(0xc8)]();}):undefined,v=O[O[uN(0x90)]-0x1],U=''['concat'](v)[uN(0x71)](v[uN(0x121)]('s')?'':'s'),u0=_[uN(0xab)](U),u1=_[uN(0x123)](s,U)?s[U]:s,(0x0,console_format_helpers_1['printAsTable'])(u1,u0,r)):console[uN(0x14a)]((0x0,console_format_helpers_1[uN(0xad)])(s));}}return[0x2];}});});}),e;}var S=_[uC(0x123)](B,uC(0xe1)),D=t,Q=W(D,S);j['addCommand'](Q);var X=_['omit'](B,uC(0xe1));Object[uC(0xa7)](X)[uC(0x90)]>0x0&&generateCommands(u,t,Q,X,O);});function g(l,t,B){return __awaiter(this,void 0x0,void 0x0,function(){var O,n,o,C;return __generator(this,function(G){var um=a1F;switch(G[um(0x131)]){case 0x0:O=l[um(0xe0)],n=l['file'];if(O!==undefined)try{return[0x2,JSON[um(0xb0)](O)];}catch(f){try{return[0x2,yaml[um(0xfb)](O)];}catch(W){throw new Error('Unknown\x20input\x20format.\x20Not\x20valid\x20json\x20and\x20not\x20valid\x20yaml.');}}if(n!==undefined){if(!fs_1['default'][um(0xdc)](n))throw new Error(um(0xda)['concat'](n));o=fs_1[um(0x8a)]['readFileSync'](n)['toString'](),C=void 0x0;try{if(_[um(0x130)](o)){if(l[um(0x13c)][um(0x121)](um(0xdf)))C=JSON[um(0xb0)](o);else{if(l['file'][um(0x121)](um(0x8b))||l[um(0x13c)][um(0x121)]('yml'))C=yaml[um(0xfb)](o);else throw new Error(um(0xd6)[um(0x71)](l[um(0x13c)][um(0xfa)]('.')['pop']()));}}else C=o;return[0x2,C];}catch(S){throw new Error(um(0x14c)['concat'](S[um(0x12e)]));}}return[0x4,z[um(0xbd)](t,{'cmdPath':B})];case 0x1:return[0x2,G['sent']()];}});});}function h(l,t,B){var O;return __awaiter(this,void 0x0,void 0x0,function(){var n,o,C,G;return __generator(this,function(f){var ue=a1F;switch(f['label']){case 0x0:return[0x4,g(l,t,B)];case 0x1:n=f[ue(0x72)](),o=new ajv_1[(ue(0x8a))]({'allErrors':!![],'keywords':[ue(0xa5)],'validateFormats':![],'strict':![],'unicodeRegExp':![]}),C=![];try{C=o[ue(0xb4)](t[ue(0xe1)][ue(0x152)],n);}catch(W){if(W[ue(0x12e)][ue(0x150)](ue(0xe7)))C=!![];else throw W;}G=(O=o===null||o===void 0x0?void 0x0:o['errors'])===null||O===void 0x0?void 0x0:O['filter'](function(S){var uc=ue,D;return!((D=S===null||S===void 0x0?void 0x0:S[uc(0x12e)])===null||D===void 0x0?void 0x0:D['includes'](uc(0xd1)));});if(!C&&G!==undefined&&(G===null||G===void 0x0?void 0x0:G[ue(0x90)])>0x0)throw new Error('Failed\x20to\x20validate\x20input\x20(schema\x20mismatch):\x0a'[ue(0x71)](JSON[ue(0x85)](o['errors'],null,'\x20')));return[0x2,n];}});});}}
|