@northflank/cli 0.8.3-beta.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-helpers.js +1 -273
- package/dist/cli.js +1 -630
- package/dist/command-overview.js +1 -93
- package/dist/console-format-helpers.js +1 -113
- package/dist/context/contextCommands.js +1 -522
- package/dist/defaults.js +1 -10238
- package/dist/exec/index.js +1 -262
- package/dist/inquirer-helper.js +1 -1049
- package/dist/login/browser-login.js +1 -204
- package/dist/pagination/inquirer-pagination-prompt.js +1 -156
- package/dist/port-forward/index.js +1 -271
- package/dist/utils.js +1 -201
- package/package.json +4 -3
package/dist/exec/index.js
CHANGED
|
@@ -1,262 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.CliExec = void 0;
|
|
43
|
-
var js_client_1 = require("@northflank/js-client");
|
|
44
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
45
|
-
var utils_1 = require("../utils");
|
|
46
|
-
var inquirer_helper_1 = require("../inquirer-helper");
|
|
47
|
-
var CliExec = /** @class */ (function () {
|
|
48
|
-
function CliExec(apiContext) {
|
|
49
|
-
var _this = this;
|
|
50
|
-
this.getStandardExecCommand = function (type) {
|
|
51
|
-
return (0, utils_1.getCommand)(true)
|
|
52
|
-
.name(type)
|
|
53
|
-
.description("Command exec for the specified ".concat(type))
|
|
54
|
-
.option('--project --projectId [NAME]', 'Project for exec')
|
|
55
|
-
.option("--".concat(type, " --").concat(type, "Id [NAME]"), "".concat(type.charAt(0).toUpperCase() + type.slice(1), " to exec into"))
|
|
56
|
-
.option('--container --containerId [NAME]', 'Container to exec into (random container will be chosen if not specified)')
|
|
57
|
-
.option('--shell-cmd [SHELL-CMD]', 'Run command with shell (e.g. bash,sh). If not set and no command is provided, several standard shells will be attempted. If not set and a command is provided, the command will run without shell')
|
|
58
|
-
.option('--user [USER]', 'Run command with this user')
|
|
59
|
-
.option('--group [GROUP]', 'Run command with this group')
|
|
60
|
-
.option('--noDefaults', "Don't use context default values, explicitly use options or ask.", false)
|
|
61
|
-
.option('--cmd --command [COMMAND]', 'Command to execute, if --shell option is present, it will run in the specified shell, otherwise');
|
|
62
|
-
};
|
|
63
|
-
this.getTerminalSize = function () { return ({ columns: process.stdout.columns, rows: process.stdout.rows }); };
|
|
64
|
-
this.execStartLog = function (type, id, project, shell, user, group, command, quiet) {
|
|
65
|
-
if (quiet === true)
|
|
66
|
-
return;
|
|
67
|
-
var noShell = shell === 'none';
|
|
68
|
-
// eslint-disable-next-line no-nested-ternary
|
|
69
|
-
var shellMsg = noShell
|
|
70
|
-
? 'without shell'
|
|
71
|
-
: shell === undefined
|
|
72
|
-
? "with shell session"
|
|
73
|
-
: "shell command ".concat(chalk_1.default.greenBright(shell));
|
|
74
|
-
var userMsg = user !== undefined ? "with user:".concat(user) : '';
|
|
75
|
-
var groupMsg = group !== undefined ? "with group:".concat(group) : '';
|
|
76
|
-
var cmdMsg = command !== undefined ? "with command '".concat(chalk_1.default.greenBright(command), "'") : '';
|
|
77
|
-
var addInfo = [cmdMsg, shellMsg, userMsg, groupMsg].filter(function (m) { return m !== ''; }).join(' ');
|
|
78
|
-
var exitHint = "(exit with 'Ctrl+D')";
|
|
79
|
-
console.log("Exec ".concat(type, " ").concat(chalk_1.default.bold(id), " in project ").concat(chalk_1.default.bold(project), " ").concat(addInfo, " ").concat(exitHint));
|
|
80
|
-
};
|
|
81
|
-
this.handleShellSession = function (commandRunner, type, quiet) {
|
|
82
|
-
if (quiet === void 0) { quiet = false; }
|
|
83
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
84
|
-
var commandResult, status_1, exitCode, message;
|
|
85
|
-
var _this = this;
|
|
86
|
-
var _a, _b;
|
|
87
|
-
return __generator(this, function (_c) {
|
|
88
|
-
switch (_c.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
_c.trys.push([0, , 2, 3]);
|
|
91
|
-
if (process.stdin.isTTY) {
|
|
92
|
-
process.stdin.setRawMode(true);
|
|
93
|
-
process.stdout.on('resize', function () {
|
|
94
|
-
commandRunner.resizeTerminal(_this.getTerminalSize());
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
process.stdin.pipe(commandRunner.stdIn);
|
|
98
|
-
commandRunner.stdErr.pipe(process.stderr);
|
|
99
|
-
commandRunner.stdOut.pipe(process.stdout);
|
|
100
|
-
commandRunner.on('error', function (res) {
|
|
101
|
-
var _a;
|
|
102
|
-
(0, utils_1.error)("Error occured during ".concat(type, " command exec: ").concat((_a = res.message) !== null && _a !== void 0 ? _a : res));
|
|
103
|
-
if (process.stdin.isTTY) {
|
|
104
|
-
process.stdin.setRawMode(false);
|
|
105
|
-
}
|
|
106
|
-
process.exit(-1);
|
|
107
|
-
});
|
|
108
|
-
return [4 /*yield*/, commandRunner.waitForCommandResult()];
|
|
109
|
-
case 1:
|
|
110
|
-
commandResult = _c.sent();
|
|
111
|
-
if (quiet !== true) {
|
|
112
|
-
status_1 = (_a = commandResult === null || commandResult === void 0 ? void 0 : commandResult.status) !== null && _a !== void 0 ? _a : 'Unknown';
|
|
113
|
-
exitCode = (_b = commandResult === null || commandResult === void 0 ? void 0 : commandResult.exitCode) !== null && _b !== void 0 ? _b : -1;
|
|
114
|
-
message = (commandResult === null || commandResult === void 0 ? void 0 : commandResult.message) ? ", details: ".concat(commandResult.message) : '';
|
|
115
|
-
if (status_1 === 'Success') {
|
|
116
|
-
(0, utils_1.success)("Command completed successfully, exit code: ".concat(exitCode));
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
(0, utils_1.warning)("Command didn't complete successfully, status: ".concat(status_1, ", exit code: ").concat(exitCode).concat(message));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return [2 /*return*/, commandResult];
|
|
123
|
-
case 2:
|
|
124
|
-
if (process.stdin.isTTY) {
|
|
125
|
-
process.stdin.setRawMode(false);
|
|
126
|
-
}
|
|
127
|
-
return [7 /*endfinally*/];
|
|
128
|
-
case 3: return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
this.apiClient = new js_client_1.ApiClient(apiContext, {
|
|
134
|
-
throwErrorOnHttpErrorCode: true,
|
|
135
|
-
customUserAgent: utils_1.customUserAgent,
|
|
136
|
-
});
|
|
137
|
-
var inquirerHelper = new inquirer_helper_1.InquirerHelper(this.apiClient);
|
|
138
|
-
this.execCmd = (0, utils_1.getCommand)()
|
|
139
|
-
.name('command-exec')
|
|
140
|
-
.alias('exec')
|
|
141
|
-
.description('Command execution (exec) for Northflank services and jobs.');
|
|
142
|
-
var serviceExecCmd = this.getStandardExecCommand('service').action(function (opts) { return __awaiter(_this, void 0, void 0, function () {
|
|
143
|
-
var noDefaults, projectId, serviceId, containerId, shellCmd, user, group, command, quiet, projectFromContext, project, _a, serviceFromContext, service, _b, shell, ttyColumns, ttyRows, id, commandRunner, e_1;
|
|
144
|
-
return __generator(this, function (_c) {
|
|
145
|
-
switch (_c.label) {
|
|
146
|
-
case 0:
|
|
147
|
-
noDefaults = opts.noDefaults, projectId = opts.projectId, serviceId = opts.serviceId, containerId = opts.containerId, shellCmd = opts.shellCmd, user = opts.user, group = opts.group, command = opts.command, quiet = opts.quiet;
|
|
148
|
-
(0, utils_1.assertContextExisting)(this.apiClient);
|
|
149
|
-
_c.label = 1;
|
|
150
|
-
case 1:
|
|
151
|
-
_c.trys.push([1, 8, 9, 10]);
|
|
152
|
-
projectFromContext = noDefaults ? undefined : apiContext.getCurrentProjectName();
|
|
153
|
-
_a = projectId || projectFromContext;
|
|
154
|
-
if (_a) return [3 /*break*/, 3];
|
|
155
|
-
return [4 /*yield*/, inquirerHelper.askForProject()];
|
|
156
|
-
case 2:
|
|
157
|
-
_a = (_c.sent());
|
|
158
|
-
_c.label = 3;
|
|
159
|
-
case 3:
|
|
160
|
-
project = _a;
|
|
161
|
-
serviceFromContext = noDefaults ? undefined : apiContext.getCurrentServiceName();
|
|
162
|
-
_b = serviceId || serviceFromContext;
|
|
163
|
-
if (_b) return [3 /*break*/, 5];
|
|
164
|
-
return [4 /*yield*/, inquirerHelper.askForService(project)()];
|
|
165
|
-
case 4:
|
|
166
|
-
_b = (_c.sent());
|
|
167
|
-
_c.label = 5;
|
|
168
|
-
case 5:
|
|
169
|
-
service = _b;
|
|
170
|
-
shell = shellCmd !== null && shellCmd !== void 0 ? shellCmd : (command !== undefined ? 'none' : undefined);
|
|
171
|
-
this.execStartLog('service', service, project, shell, user, group, command, quiet);
|
|
172
|
-
ttyColumns = process.stdout.columns;
|
|
173
|
-
ttyRows = process.stdout.rows;
|
|
174
|
-
id = { projectId: project, serviceId: service };
|
|
175
|
-
return [4 /*yield*/, this.apiClient.exec.execServiceSession(id, {
|
|
176
|
-
containerName: containerId,
|
|
177
|
-
command: command,
|
|
178
|
-
shell: shell,
|
|
179
|
-
user: user,
|
|
180
|
-
group: group,
|
|
181
|
-
ttyColumns: ttyColumns,
|
|
182
|
-
ttyRows: ttyRows,
|
|
183
|
-
})];
|
|
184
|
-
case 6:
|
|
185
|
-
commandRunner = _c.sent();
|
|
186
|
-
return [4 /*yield*/, this.handleShellSession(commandRunner, 'service', quiet)];
|
|
187
|
-
case 7:
|
|
188
|
-
_c.sent();
|
|
189
|
-
return [3 /*break*/, 10];
|
|
190
|
-
case 8:
|
|
191
|
-
e_1 = _c.sent();
|
|
192
|
-
(0, utils_1.error)("".concat(e_1.message));
|
|
193
|
-
return [3 /*break*/, 10];
|
|
194
|
-
case 9:
|
|
195
|
-
process.exit();
|
|
196
|
-
return [7 /*endfinally*/];
|
|
197
|
-
case 10: return [2 /*return*/];
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}); });
|
|
201
|
-
var jobExecCmd = this.getStandardExecCommand('job').action(function (opts) { return __awaiter(_this, void 0, void 0, function () {
|
|
202
|
-
var projectId, jobId, containerId, noDefaults, shellCmd, user, group, command, quiet, projectFromContext, project, _a, job, _b, _c, rows, columns, id, commandRunner, e_2;
|
|
203
|
-
return __generator(this, function (_d) {
|
|
204
|
-
switch (_d.label) {
|
|
205
|
-
case 0:
|
|
206
|
-
projectId = opts.projectId, jobId = opts.jobId, containerId = opts.containerId, noDefaults = opts.noDefaults, shellCmd = opts.shellCmd, user = opts.user, group = opts.group, command = opts.command, quiet = opts.quiet;
|
|
207
|
-
(0, utils_1.assertContextExisting)(this.apiClient);
|
|
208
|
-
_d.label = 1;
|
|
209
|
-
case 1:
|
|
210
|
-
_d.trys.push([1, 8, 9, 10]);
|
|
211
|
-
projectFromContext = noDefaults ? undefined : apiContext.getCurrentProjectName();
|
|
212
|
-
_a = projectId || projectFromContext;
|
|
213
|
-
if (_a) return [3 /*break*/, 3];
|
|
214
|
-
return [4 /*yield*/, inquirerHelper.askForProject()];
|
|
215
|
-
case 2:
|
|
216
|
-
_a = (_d.sent());
|
|
217
|
-
_d.label = 3;
|
|
218
|
-
case 3:
|
|
219
|
-
project = _a;
|
|
220
|
-
_b = jobId;
|
|
221
|
-
if (_b) return [3 /*break*/, 5];
|
|
222
|
-
return [4 /*yield*/, inquirerHelper.askForJob(project)()];
|
|
223
|
-
case 4:
|
|
224
|
-
_b = (_d.sent());
|
|
225
|
-
_d.label = 5;
|
|
226
|
-
case 5:
|
|
227
|
-
job = _b;
|
|
228
|
-
this.execStartLog('job', job, project, shellCmd, quiet);
|
|
229
|
-
_c = this.getTerminalSize(), rows = _c.rows, columns = _c.columns;
|
|
230
|
-
id = { projectId: project, jobId: job };
|
|
231
|
-
return [4 /*yield*/, this.apiClient.exec.execJobSession(id, {
|
|
232
|
-
containerName: containerId,
|
|
233
|
-
command: command,
|
|
234
|
-
shell: shellCmd,
|
|
235
|
-
user: user,
|
|
236
|
-
group: group,
|
|
237
|
-
ttyColumns: columns,
|
|
238
|
-
ttyRows: rows,
|
|
239
|
-
})];
|
|
240
|
-
case 6:
|
|
241
|
-
commandRunner = _d.sent();
|
|
242
|
-
return [4 /*yield*/, this.handleShellSession(commandRunner, 'job', quiet)];
|
|
243
|
-
case 7:
|
|
244
|
-
_d.sent();
|
|
245
|
-
return [3 /*break*/, 10];
|
|
246
|
-
case 8:
|
|
247
|
-
e_2 = _d.sent();
|
|
248
|
-
(0, utils_1.error)("".concat(e_2.message));
|
|
249
|
-
return [3 /*break*/, 10];
|
|
250
|
-
case 9:
|
|
251
|
-
process.exit();
|
|
252
|
-
return [7 /*endfinally*/];
|
|
253
|
-
case 10: return [2 /*return*/];
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}); });
|
|
257
|
-
this.execCmd.addCommand(serviceExecCmd);
|
|
258
|
-
this.execCmd.addCommand(jobExecCmd);
|
|
259
|
-
}
|
|
260
|
-
return CliExec;
|
|
261
|
-
}());
|
|
262
|
-
exports.CliExec = CliExec;
|
|
1
|
+
'use strict';var a6c=a6L;function a6L(g,L){var S=a6g();return a6L=function(q,e){q=q-0x19d;var H=S[q];return H;},a6L(g,L);}(function(g,L){var C=a6L,S=g();while(!![]){try{var q=parseInt(C(0x20c))/0x1+parseInt(C(0x1d6))/0x2*(-parseInt(C(0x1e6))/0x3)+-parseInt(C(0x1d5))/0x4+parseInt(C(0x1b9))/0x5*(parseInt(C(0x1a3))/0x6)+-parseInt(C(0x1b4))/0x7+-parseInt(C(0x1a0))/0x8*(-parseInt(C(0x1cf))/0x9)+parseInt(C(0x1b6))/0xa;if(q===L)break;else S['push'](S['shift']());}catch(e){S['push'](S['shift']());}}}(a6g,0x61130));var __awaiter=this&&this[a6c(0x1f5)]||function(g,L,S,q){function e(H){return H instanceof S?H:new S(function(I){I(H);});}return new(S||(S=Promise))(function(H,I){var h=a6L;function y(Y){var j=a6L;try{O(q[j(0x1b0)](Y));}catch(B){I(B);}}function k(Y){try{O(q['throw'](Y));}catch(B){I(B);}}function O(Y){var G=a6L;Y['done']?H(Y[G(0x1fc)]):e(Y[G(0x1fc)])[G(0x19d)](y,k);}O((q=q[h(0x1c9)](g,L||[]))[h(0x1b0)]());});},__generator=this&&this['__generator']||function(L,S){var v=a6c,q={'label':0x0,'sent':function(){if(I[0x0]&0x1)throw I[0x1];return I[0x1];},'trys':[],'ops':[]},e,H,I,k;return k={'next':O(0x0),'throw':O(0x1),'return':O(0x2)},typeof Symbol===v(0x1c6)&&(k[Symbol[v(0x1bf)]]=function(){return this;}),k;function O(B){return function(P){return Y([B,P]);};}function Y(B){var p=v;if(e)throw new TypeError(p(0x216));while(q)try{if(e=0x1,H&&(I=B[0x0]&0x2?H[p(0x1ae)]:B[0x0]?H['throw']||((I=H[p(0x1ae)])&&I['call'](H),0x0):H[p(0x1b0)])&&!(I=I[p(0x1a8)](H,B[0x1]))['done'])return I;if(H=0x0,I)B=[B[0x0]&0x2,I['value']];switch(B[0x0]){case 0x0:case 0x1:I=B;break;case 0x4:q[p(0x1db)]++;return{'value':B[0x1],'done':![]};case 0x5:q[p(0x1db)]++,H=B[0x1],B=[0x0];continue;case 0x7:B=q[p(0x1c7)][p(0x204)](),q[p(0x1ba)][p(0x204)]();continue;default:if(!(I=q[p(0x1ba)],I=I[p(0x1d1)]>0x0&&I[I['length']-0x1])&&(B[0x0]===0x6||B[0x0]===0x2)){q=0x0;continue;}if(B[0x0]===0x3&&(!I||B[0x1]>I[0x0]&&B[0x1]<I[0x3])){q[p(0x1db)]=B[0x1];break;}if(B[0x0]===0x6&&q['label']<I[0x1]){q[p(0x1db)]=I[0x1],I=B;break;}if(I&&q[p(0x1db)]<I[0x2]){q[p(0x1db)]=I[0x2],q[p(0x1c7)][p(0x1c5)](B);break;}if(I[0x2])q[p(0x1c7)][p(0x204)]();q['trys'][p(0x204)]();continue;}B=S['call'](L,q);}catch(P){B=[0x6,P],H=0x0;}finally{e=I=0x0;}if(B[0x0]&0x5)throw B[0x1];return{'value':B[0x0]?B[0x1]:void 0x0,'done':!![]};}},__importDefault=this&&this[a6c(0x1fe)]||function(g){var t=a6c;return g&&g[t(0x201)]?g:{'default':g};};Object[a6c(0x1ac)](exports,a6c(0x201),{'value':!![]}),exports[a6c(0x21a)]=void 0x0;function a6g(){var Q=['next','\x20--','alias',',\x20details:\x20','5426470VqAYYB','columns','6718850YvYsRx','exit','getCurrentServiceName','1997675GzgTkN','trys','pipe','Command\x20to\x20execute,\x20if\x20--shell\x20option\x20is\x20present,\x20it\x20will\x20run\x20in\x20the\x20specified\x20shell,\x20otherwise','serviceId','\x20to\x20exec\x20into','iterator','--user\x20[USER]','error','--shell-cmd\x20[SHELL-CMD]','concat','noDefaults','push','function','ops','assertContextExisting','apply','stdOut','greenBright','Command\x20completed\x20successfully,\x20exit\x20code:\x20','--group\x20[GROUP]','execJobSession','1225503ZXSiMT','status','length','customUserAgent','charAt','Unknown','1126032EhvhqP','83684xqCFVo','apiClient','execStartLog','Command\x20exec\x20for\x20the\x20specified\x20','default','label','stdErr','getCurrentProjectName','resize','\x20in\x20project\x20','none','with\x20command\x20\x27','getTerminalSize','isTTY','Project\x20for\x20exec','warning','45dytfAM','bold','Error\x20occured\x20during\x20','../utils','option','stdIn','shell\x20command\x20','Don\x27t\x20use\x20context\x20default\x20values,\x20explicitly\x20use\x20options\x20or\x20ask.','success','waitForCommandResult','group','name','InquirerHelper','chalk','--container\x20--containerId\x20[NAME]','__awaiter','Container\x20to\x20exec\x20into\x20(random\x20container\x20will\x20be\x20chosen\x20if\x20not\x20specified)','\x20command\x20exec:\x20','job','rows','filter','Run\x20command\x20with\x20this\x20user','value','stderr','__importDefault','resizeTerminal','log','__esModule','getStandardExecCommand','quiet','pop','../inquirer-helper','askForProject','command-exec','Run\x20command\x20with\x20shell\x20(e.g.\x20bash,sh).\x20If\x20not\x20set\x20and\x20no\x20command\x20is\x20provided,\x20several\x20standard\x20shells\x20will\x20be\x20attempted.\x20If\x20not\x20set\x20and\x20a\x20command\x20is\x20provided,\x20the\x20command\x20will\x20run\x20without\x20shell','message',',\x20exit\x20code:\x20','setRawMode','329709Urzckm','action','with\x20group:','(exit\x20with\x20\x27Ctrl+D\x27)','service','addCommand','user','ApiClient','askForJob','--noDefaults','Generator\x20is\x20already\x20executing.','Exec\x20','sent','stdin','CliExec','then','execCmd','Id\x20[NAME]','40RSIAcF','execServiceSession','exec','6IfeDBZ','with\x20user:','shellCmd','stdout','containerId','call','projectId','Run\x20command\x20with\x20this\x20group','command','defineProperty','handleShellSession','return','Success'];a6g=function(){return Q;};return a6g();}var js_client_1=require('@northflank/js-client'),chalk_1=__importDefault(require(a6c(0x1f3))),utils_1=require(a6c(0x1e9)),inquirer_helper_1=require(a6c(0x205)),CliExec=(function(){function g(L){var s=a6L,S=this;this[s(0x202)]=function(I){var D=s;return(0x0,utils_1['getCommand'])(!![])[D(0x1f1)](I)['description'](D(0x1d9)[D(0x1c3)](I))['option']('--project\x20--projectId\x20[NAME]',D(0x1e4))[D(0x1ea)]('--'[D(0x1c3)](I,D(0x1b1))[D(0x1c3)](I,D(0x19f)),''[D(0x1c3)](I[D(0x1d3)](0x0)['toUpperCase']()+I['slice'](0x1),D(0x1be)))[D(0x1ea)](D(0x1f4),D(0x1f6))[D(0x1ea)](D(0x1c2),D(0x208))[D(0x1ea)](D(0x1c0),D(0x1fb))['option'](D(0x1cd),D(0x1aa))[D(0x1ea)](D(0x215),D(0x1ed),![])['option']('--cmd\x20--command\x20[COMMAND]',D(0x1bc));},this[s(0x1e2)]=function(){var T=s;return{'columns':process[T(0x1a6)][T(0x1b5)],'rows':process['stdout'][T(0x1f9)]};},this[s(0x1d8)]=function(I,y,k,O,Y,B,P,Z){var V=s;if(Z===!![])return;var a=O===V(0x1e0),A=a?'without\x20shell':O===undefined?'with\x20shell\x20session':V(0x1ec)[V(0x1c3)](chalk_1[V(0x1da)]['greenBright'](O)),n=Y!==undefined?V(0x1a4)[V(0x1c3)](Y):'',U=B!==undefined?V(0x20e)['concat'](B):'',f=P!==undefined?V(0x1e1)[V(0x1c3)](chalk_1[V(0x1da)][V(0x1cb)](P),'\x27'):'',J=[f,A,n,U][V(0x1fa)](function(d){return d!=='';})['join']('\x20'),o=V(0x20f);console[V(0x200)](V(0x217)[V(0x1c3)](I,'\x20')[V(0x1c3)](chalk_1[V(0x1da)][V(0x1e7)](y),V(0x1df))['concat'](chalk_1[V(0x1da)][V(0x1e7)](k),'\x20')['concat'](J,'\x20')[V(0x1c3)](o));},this[s(0x1ad)]=function(I,y,k){return k===void 0x0&&(k=![]),__awaiter(S,void 0x0,void 0x0,function(){var O,Y,B,P,Z=this,a,A;return __generator(this,function(n){var r=a6L;switch(n['label']){case 0x0:n[r(0x1ba)]['push']([0x0,,0x2,0x3]);process['stdin'][r(0x1e3)]&&(process['stdin'][r(0x20b)](!![]),process[r(0x1a6)]['on'](r(0x1de),function(){var b=r;I[b(0x1ff)](Z['getTerminalSize']());}));process['stdin'][r(0x1bb)](I[r(0x1eb)]),I[r(0x1dc)][r(0x1bb)](process[r(0x1fd)]),I[r(0x1ca)][r(0x1bb)](process[r(0x1a6)]),I['on']('error',function(U){var w=r,f;(0x0,utils_1[w(0x1c1)])(w(0x1e8)[w(0x1c3)](y,w(0x1f7))[w(0x1c3)]((f=U[w(0x209)])!==null&&f!==void 0x0?f:U)),process['stdin'][w(0x1e3)]&&process[w(0x219)][w(0x20b)](![]),process[w(0x1b7)](-0x1);});return[0x4,I[r(0x1ef)]()];case 0x1:O=n[r(0x218)]();k!==!![]&&(Y=(a=O===null||O===void 0x0?void 0x0:O[r(0x1d0)])!==null&&a!==void 0x0?a:r(0x1d4),B=(A=O===null||O===void 0x0?void 0x0:O['exitCode'])!==null&&A!==void 0x0?A:-0x1,P=(O===null||O===void 0x0?void 0x0:O[r(0x209)])?r(0x1b3)['concat'](O[r(0x209)]):'',Y===r(0x1af)?(0x0,utils_1[r(0x1ee)])(r(0x1cc)['concat'](B)):(0x0,utils_1[r(0x1e5)])('Command\x20didn\x27t\x20complete\x20successfully,\x20status:\x20'['concat'](Y,r(0x20a))[r(0x1c3)](B)[r(0x1c3)](P)));return[0x2,O];case 0x2:process['stdin'][r(0x1e3)]&&process[r(0x219)][r(0x20b)](![]);return[0x7];case 0x3:return[0x2];}});});},this[s(0x1d7)]=new js_client_1[(s(0x213))](L,{'throwErrorOnHttpErrorCode':!![],'customUserAgent':utils_1[s(0x1d2)]});var q=new inquirer_helper_1[(s(0x1f2))](this[s(0x1d7)]);this[s(0x19e)]=(0x0,utils_1['getCommand'])()['name'](s(0x207))[s(0x1b2)]('exec')['description']('Command\x20execution\x20(exec)\x20for\x20Northflank\x20services\x20and\x20jobs.');var e=this[s(0x202)](s(0x210))[s(0x20d)](function(I){return __awaiter(S,void 0x0,void 0x0,function(){var y,k,O,Y,B,P,Z,a,A,n,U,f,J,o,d,i,u,X,F,z,W;return __generator(this,function(M){var m=a6L;switch(M[m(0x1db)]){case 0x0:y=I[m(0x1c4)],k=I['projectId'],O=I[m(0x1bd)],Y=I[m(0x1a7)],B=I[m(0x1a5)],P=I[m(0x212)],Z=I[m(0x1f0)],a=I[m(0x1ab)],A=I[m(0x203)],(0x0,utils_1[m(0x1c8)])(this['apiClient']),M[m(0x1db)]=0x1;case 0x1:M[m(0x1ba)]['push']([0x1,0x8,0x9,0xa]),n=y?undefined:L[m(0x1dd)](),f=k||n;if(f)return[0x3,0x3];return[0x4,q['askForProject']()];case 0x2:f=M[m(0x218)](),M[m(0x1db)]=0x3;case 0x3:U=f,J=y?undefined:L[m(0x1b8)](),d=O||J;if(d)return[0x3,0x5];return[0x4,q['askForService'](U)()];case 0x4:d=M['sent'](),M[m(0x1db)]=0x5;case 0x5:o=d,i=B!==null&&B!==void 0x0?B:a!==undefined?m(0x1e0):undefined,this['execStartLog'](m(0x210),o,U,i,P,Z,a,A),u=process[m(0x1a6)]['columns'],X=process[m(0x1a6)]['rows'],F={'projectId':U,'serviceId':o};return[0x4,this[m(0x1d7)][m(0x1a2)][m(0x1a1)](F,{'containerName':Y,'command':a,'shell':i,'user':P,'group':Z,'ttyColumns':u,'ttyRows':X})];case 0x6:z=M[m(0x218)]();return[0x4,this[m(0x1ad)](z,m(0x210),A)];case 0x7:M[m(0x218)]();return[0x3,0xa];case 0x8:W=M[m(0x218)](),(0x0,utils_1[m(0x1c1)])(''[m(0x1c3)](W['message']));return[0x3,0xa];case 0x9:process[m(0x1b7)]();return[0x7];case 0xa:return[0x2];}});});}),H=this['getStandardExecCommand'](s(0x1f8))[s(0x20d)](function(I){return __awaiter(S,void 0x0,void 0x0,function(){var y,k,O,Y,B,P,Z,a,A,n,U,f,J,o,d,i,u,X,F,z;return __generator(this,function(W){var K=a6L;switch(W[K(0x1db)]){case 0x0:y=I[K(0x1a9)],k=I['jobId'],O=I['containerId'],Y=I[K(0x1c4)],B=I[K(0x1a5)],P=I[K(0x212)],Z=I[K(0x1f0)],a=I['command'],A=I['quiet'],(0x0,utils_1[K(0x1c8)])(this['apiClient']),W['label']=0x1;case 0x1:W[K(0x1ba)][K(0x1c5)]([0x1,0x8,0x9,0xa]),n=Y?undefined:L[K(0x1dd)](),f=y||n;if(f)return[0x3,0x3];return[0x4,q[K(0x206)]()];case 0x2:f=W[K(0x218)](),W[K(0x1db)]=0x3;case 0x3:U=f,o=k;if(o)return[0x3,0x5];return[0x4,q[K(0x214)](U)()];case 0x4:o=W[K(0x218)](),W[K(0x1db)]=0x5;case 0x5:J=o,this[K(0x1d8)]('job',J,U,B,A),(d=this['getTerminalSize'](),i=d['rows'],u=d[K(0x1b5)]),X={'projectId':U,'jobId':J};return[0x4,this[K(0x1d7)]['exec'][K(0x1ce)](X,{'containerName':O,'command':a,'shell':B,'user':P,'group':Z,'ttyColumns':u,'ttyRows':i})];case 0x6:F=W[K(0x218)]();return[0x4,this[K(0x1ad)](F,K(0x1f8),A)];case 0x7:W[K(0x218)]();return[0x3,0xa];case 0x8:z=W['sent'](),(0x0,utils_1[K(0x1c1)])(''[K(0x1c3)](z[K(0x209)]));return[0x3,0xa];case 0x9:process[K(0x1b7)]();return[0x7];case 0xa:return[0x2];}});});});this['execCmd'][s(0x211)](e),this[s(0x19e)]['addCommand'](H);}return g;}());exports['CliExec']=CliExec;
|