@northflank/cli 0.8.2 → 0.8.3-beta.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 +273 -1
- package/dist/cli.js +630 -1
- package/dist/command-overview.js +93 -1
- package/dist/console-format-helpers.js +113 -1
- package/dist/context/contextCommands.js +522 -1
- package/dist/defaults.js +10238 -1
- package/dist/exec/index.js +262 -1
- package/dist/inquirer-helper.js +1049 -1
- package/dist/login/browser-login.js +204 -0
- package/dist/pagination/inquirer-pagination-prompt.js +156 -0
- package/dist/port-forward/index.js +271 -1
- package/dist/utils.js +201 -1
- package/package.json +10 -5
package/dist/command-overview.js
CHANGED
|
@@ -1 +1,93 @@
|
|
|
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.getCommandOverview = void 0;
|
|
43
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
44
|
+
var utils_1 = require("./utils");
|
|
45
|
+
function getCommandOverview(root) {
|
|
46
|
+
var _this = this;
|
|
47
|
+
return (0, utils_1.getCommand)()
|
|
48
|
+
.name('command-overview')
|
|
49
|
+
.description('Prints a tree view of all available commands')
|
|
50
|
+
.option('--verbose', 'Print command descriptions')
|
|
51
|
+
.action(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
52
|
+
function printBranch(command, indent) {
|
|
53
|
+
var _a;
|
|
54
|
+
var getName = function (cmd, isLeaf) {
|
|
55
|
+
if (isLeaf === void 0) { isLeaf = true; }
|
|
56
|
+
return isLeaf ? chalk_1.default.bold.green(cmd.name()) : cmd.name();
|
|
57
|
+
};
|
|
58
|
+
var isTreeRoot = indent.length === 0;
|
|
59
|
+
var children = command.commands;
|
|
60
|
+
var branchHead = '';
|
|
61
|
+
var leaf = children.length === 0;
|
|
62
|
+
var isEndpointCommand = leaf || ((_a = Object.keys(command === null || command === void 0 ? void 0 : command.opts())) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
63
|
+
if (!isTreeRoot) {
|
|
64
|
+
branchHead = children && !leaf ? '┬ ' : '─ ';
|
|
65
|
+
}
|
|
66
|
+
var description = verbose && isEndpointCommand && command.description() ? ": ".concat(command.description()) : '';
|
|
67
|
+
console.log("".concat(indent).concat(branchHead).concat(getName(command, isEndpointCommand)).concat(description));
|
|
68
|
+
var baseBranch = indent;
|
|
69
|
+
if (!isTreeRoot) {
|
|
70
|
+
var isChildOfLastBranch = indent.slice(-2) === '└─';
|
|
71
|
+
baseBranch = indent.slice(0, -2) + (isChildOfLastBranch ? ' ' : '│ ');
|
|
72
|
+
}
|
|
73
|
+
var nextBranch = "".concat(baseBranch, "\u251C\u2500");
|
|
74
|
+
var lastBranch = "".concat(baseBranch, "\u2514\u2500");
|
|
75
|
+
var leafLevel = children.every(function (child) { return child.commands.length === 0; });
|
|
76
|
+
if (leafLevel && !leaf && !verbose) {
|
|
77
|
+
console.log("".concat(lastBranch, " ").concat(children.map(function (child) { return getName(child); }).join(', ')));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
children.forEach(function (child, index) {
|
|
81
|
+
printBranch(child, children.length - 1 === index ? lastBranch : nextBranch);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
var verbose;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
verbose = options.verbose;
|
|
88
|
+
printBranch(root, '');
|
|
89
|
+
return [2 /*return*/];
|
|
90
|
+
});
|
|
91
|
+
}); });
|
|
92
|
+
}
|
|
93
|
+
exports.getCommandOverview = getCommandOverview;
|
|
@@ -1 +1,113 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.consoleFormat = exports.printAsTable = void 0;
|
|
30
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
31
|
+
var _ = __importStar(require("lodash"));
|
|
32
|
+
var util = __importStar(require("util"));
|
|
33
|
+
var columnify = require('columnify');
|
|
34
|
+
function printAsTable(data, title, columns, hideHeader, offset) {
|
|
35
|
+
if (hideHeader === void 0) { hideHeader = false; }
|
|
36
|
+
if (offset === void 0) { offset = 0; }
|
|
37
|
+
if (!hideHeader) {
|
|
38
|
+
console.log("".concat(chalk_1.default.bold(title)));
|
|
39
|
+
}
|
|
40
|
+
function formatHeader(header) {
|
|
41
|
+
return header === 'disabled' ? header : header.replace('disabled', '');
|
|
42
|
+
}
|
|
43
|
+
function formatCell(cell, header) {
|
|
44
|
+
function timeConverter(ts) {
|
|
45
|
+
var d = new Date(ts);
|
|
46
|
+
return "".concat(d.getDate(), "/").concat(d.getMonth(), "/").concat(d.getFullYear(), "\n").concat(d.getHours(), ":").concat(d.getMinutes(), ":").concat(d.getSeconds());
|
|
47
|
+
}
|
|
48
|
+
var timeHeaders = ['createdat', 'updatedat'];
|
|
49
|
+
if (timeHeaders.includes(header.toLowerCase()) &&
|
|
50
|
+
_.isFinite(cell) &&
|
|
51
|
+
cell.toString().length === 13) {
|
|
52
|
+
return timeConverter(Number(cell));
|
|
53
|
+
}
|
|
54
|
+
if (_.isBoolean(cell)) {
|
|
55
|
+
if (header !== 'disabled' && header.includes('disabled')) {
|
|
56
|
+
return cell ? 'x' : '✔'; // invert flags
|
|
57
|
+
}
|
|
58
|
+
return cell ? '✔' : 'x';
|
|
59
|
+
}
|
|
60
|
+
if (_.isObjectLike(cell)) {
|
|
61
|
+
return util.inspect(cell, {
|
|
62
|
+
showHidden: false,
|
|
63
|
+
depth: null,
|
|
64
|
+
colors: true,
|
|
65
|
+
compact: true,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return cell;
|
|
69
|
+
}
|
|
70
|
+
if (_.isArrayLike(data)) {
|
|
71
|
+
if (data.length === 0) {
|
|
72
|
+
console.log("No ".concat(title.toLowerCase(), " found"));
|
|
73
|
+
}
|
|
74
|
+
var rows = data.map(function (l, idx) {
|
|
75
|
+
var tableRow = { i: idx + offset };
|
|
76
|
+
Object.keys(l).forEach(function (r) {
|
|
77
|
+
if (_.isUndefined(columns) || columns.includes(r.toLowerCase())) {
|
|
78
|
+
_.set(tableRow, formatHeader(r), formatCell(l[r], r));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return tableRow;
|
|
82
|
+
});
|
|
83
|
+
var orderedColumns = _.clone(Object.keys((rows === null || rows === void 0 ? void 0 : rows[0]) || [])).sort(function (a, b) {
|
|
84
|
+
// eslint-disable-next-line no-nested-ternary
|
|
85
|
+
var getScore = function (s) { return (s !== 'i' ? (s !== 'internalId' ? 0 : 1) : 2); };
|
|
86
|
+
return getScore(b) - getScore(a);
|
|
87
|
+
});
|
|
88
|
+
var config = {
|
|
89
|
+
maxWidth: 30,
|
|
90
|
+
preserveNewLines: true,
|
|
91
|
+
showHeaders: !hideHeader,
|
|
92
|
+
config: { _id: { maxWidth: 5, truncate: true }, i: { showHeaders: false } },
|
|
93
|
+
columns: orderedColumns,
|
|
94
|
+
};
|
|
95
|
+
console.log(columnify(rows, config));
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log(data);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.printAsTable = printAsTable;
|
|
102
|
+
function consoleFormat(obj) {
|
|
103
|
+
if (!_.isObjectLike(obj)) {
|
|
104
|
+
return obj === null || obj === void 0 ? void 0 : obj.toString();
|
|
105
|
+
}
|
|
106
|
+
return util.inspect(obj, {
|
|
107
|
+
showHidden: false,
|
|
108
|
+
depth: null,
|
|
109
|
+
colors: true,
|
|
110
|
+
compact: true,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
exports.consoleFormat = consoleFormat;
|