@robinmordasiewicz/f5xc-xcsh 1.0.91-2601040531 → 1.0.91-2601040646
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/index.js +144 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -47052,8 +47052,8 @@ function getLogoModeFromEnv(envPrefix) {
|
|
|
47052
47052
|
var CLI_NAME = "xcsh";
|
|
47053
47053
|
var CLI_FULL_NAME = "F5 Distributed Cloud Shell";
|
|
47054
47054
|
function getVersion() {
|
|
47055
|
-
if ("v1.0.91-
|
|
47056
|
-
return "v1.0.91-
|
|
47055
|
+
if ("v1.0.91-2601040646") {
|
|
47056
|
+
return "v1.0.91-2601040646";
|
|
47057
47057
|
}
|
|
47058
47058
|
if (process.env.XCSH_VERSION) {
|
|
47059
47059
|
return process.env.XCSH_VERSION;
|
|
@@ -48157,7 +48157,7 @@ function extractItems(data) {
|
|
|
48157
48157
|
}
|
|
48158
48158
|
return [];
|
|
48159
48159
|
}
|
|
48160
|
-
function formatKeyValueBox(data, title, noColor = false) {
|
|
48160
|
+
function formatKeyValueBox(data, title, noColor = false, maxWidth) {
|
|
48161
48161
|
if (data.length === 0) {
|
|
48162
48162
|
return "";
|
|
48163
48163
|
}
|
|
@@ -48166,14 +48166,27 @@ function formatKeyValueBox(data, title, noColor = false) {
|
|
|
48166
48166
|
const borderColor = colors.red;
|
|
48167
48167
|
const colorBorder = (text) => applyColor(text, borderColor, useColors);
|
|
48168
48168
|
const maxLabelWidth = Math.max(...data.map((d) => d.label.length));
|
|
48169
|
-
const
|
|
48169
|
+
const effectiveMaxWidth = maxWidth ?? getTerminalWidth();
|
|
48170
|
+
const boxOverhead = 7;
|
|
48171
|
+
const maxValueWidth = Math.max(
|
|
48172
|
+
20,
|
|
48173
|
+
effectiveMaxWidth - maxLabelWidth - boxOverhead
|
|
48174
|
+
);
|
|
48175
|
+
const contentLines = [];
|
|
48176
|
+
for (const d of data) {
|
|
48170
48177
|
const paddedLabel = d.label.padEnd(maxLabelWidth);
|
|
48171
|
-
|
|
48172
|
-
});
|
|
48178
|
+
const wrappedValueLines = wrapText2(d.value, maxValueWidth);
|
|
48179
|
+
contentLines.push(`${paddedLabel}: ${wrappedValueLines[0] ?? ""}`);
|
|
48180
|
+
const indent = " ".repeat(maxLabelWidth + 3);
|
|
48181
|
+
for (let i = 1; i < wrappedValueLines.length; i++) {
|
|
48182
|
+
contentLines.push(`${indent}${wrappedValueLines[i]}`);
|
|
48183
|
+
}
|
|
48184
|
+
}
|
|
48173
48185
|
const titleText = ` ${title} `;
|
|
48174
|
-
const maxContentWidth = Math.
|
|
48175
|
-
...contentLines.map((l) => l.length),
|
|
48176
|
-
|
|
48186
|
+
const maxContentWidth = Math.min(
|
|
48187
|
+
Math.max(...contentLines.map((l) => l.length), titleText.length),
|
|
48188
|
+
effectiveMaxWidth - 4
|
|
48189
|
+
// 4 = borders + padding on each side
|
|
48177
48190
|
);
|
|
48178
48191
|
const innerWidth = maxContentWidth + 2;
|
|
48179
48192
|
const lines = [];
|
|
@@ -48184,9 +48197,10 @@ function formatKeyValueBox(data, title, noColor = false) {
|
|
|
48184
48197
|
colorBorder(box.topLeft + box.horizontal.repeat(leftDashes)) + titleText + colorBorder(box.horizontal.repeat(rightDashes) + box.topRight)
|
|
48185
48198
|
);
|
|
48186
48199
|
for (const text of contentLines) {
|
|
48187
|
-
const
|
|
48200
|
+
const displayText = text.slice(0, innerWidth - 2);
|
|
48201
|
+
const padding = innerWidth - displayText.length;
|
|
48188
48202
|
lines.push(
|
|
48189
|
-
colorBorder(box.vertical) + ` ${
|
|
48203
|
+
colorBorder(box.vertical) + ` ${displayText}${" ".repeat(Math.max(0, padding - 1))}` + colorBorder(box.vertical)
|
|
48190
48204
|
);
|
|
48191
48205
|
}
|
|
48192
48206
|
lines.push(
|
|
@@ -48196,6 +48210,107 @@ function formatKeyValueBox(data, title, noColor = false) {
|
|
|
48196
48210
|
);
|
|
48197
48211
|
return lines.join("\n");
|
|
48198
48212
|
}
|
|
48213
|
+
var EXCLUDED_FIELDS = /* @__PURE__ */ new Set([
|
|
48214
|
+
"system_metadata",
|
|
48215
|
+
"get_spec",
|
|
48216
|
+
"status",
|
|
48217
|
+
"referring_objects",
|
|
48218
|
+
"disabled_referred_objects",
|
|
48219
|
+
"object_type"
|
|
48220
|
+
]);
|
|
48221
|
+
var PRIORITY_FIELDS = [
|
|
48222
|
+
"name",
|
|
48223
|
+
"namespace",
|
|
48224
|
+
"labels",
|
|
48225
|
+
"description",
|
|
48226
|
+
"domains"
|
|
48227
|
+
];
|
|
48228
|
+
function formatDetailValue(value) {
|
|
48229
|
+
if (value === null || value === void 0) {
|
|
48230
|
+
return "";
|
|
48231
|
+
}
|
|
48232
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
48233
|
+
return String(value);
|
|
48234
|
+
}
|
|
48235
|
+
if (Array.isArray(value)) {
|
|
48236
|
+
const isSimple = value.every(
|
|
48237
|
+
(v) => typeof v === "string" || typeof v === "number"
|
|
48238
|
+
);
|
|
48239
|
+
if (isSimple && value.length <= 5) {
|
|
48240
|
+
return `[${value.join(", ")}]`;
|
|
48241
|
+
}
|
|
48242
|
+
return JSON.stringify(value);
|
|
48243
|
+
}
|
|
48244
|
+
if (typeof value === "object") {
|
|
48245
|
+
const obj = value;
|
|
48246
|
+
const keys = Object.keys(obj);
|
|
48247
|
+
if (keys.length <= 3) {
|
|
48248
|
+
const allSimple = keys.every((k) => {
|
|
48249
|
+
const v = obj[k];
|
|
48250
|
+
return typeof v === "string" || typeof v === "number" || typeof v === "boolean";
|
|
48251
|
+
});
|
|
48252
|
+
if (allSimple) {
|
|
48253
|
+
return keys.map((k) => `${k}: ${obj[k]}`).join(", ");
|
|
48254
|
+
}
|
|
48255
|
+
}
|
|
48256
|
+
return JSON.stringify(value);
|
|
48257
|
+
}
|
|
48258
|
+
return String(value);
|
|
48259
|
+
}
|
|
48260
|
+
function flattenResourceData(data) {
|
|
48261
|
+
const result = [];
|
|
48262
|
+
const seen = /* @__PURE__ */ new Set();
|
|
48263
|
+
const addField = (key, value) => {
|
|
48264
|
+
if (EXCLUDED_FIELDS.has(key) || seen.has(key)) return;
|
|
48265
|
+
if (value === null || value === void 0) return;
|
|
48266
|
+
seen.add(key);
|
|
48267
|
+
const formatted = formatDetailValue(value);
|
|
48268
|
+
if (formatted) {
|
|
48269
|
+
result.push({ key, value: formatted });
|
|
48270
|
+
}
|
|
48271
|
+
};
|
|
48272
|
+
const metadata = data.metadata;
|
|
48273
|
+
if (metadata && typeof metadata === "object") {
|
|
48274
|
+
for (const key of PRIORITY_FIELDS) {
|
|
48275
|
+
if (key in metadata) {
|
|
48276
|
+
addField(key, metadata[key]);
|
|
48277
|
+
}
|
|
48278
|
+
}
|
|
48279
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
48280
|
+
addField(key, value);
|
|
48281
|
+
}
|
|
48282
|
+
}
|
|
48283
|
+
const spec = data.spec;
|
|
48284
|
+
if (spec && typeof spec === "object") {
|
|
48285
|
+
for (const [key, value] of Object.entries(spec)) {
|
|
48286
|
+
addField(key, value);
|
|
48287
|
+
}
|
|
48288
|
+
}
|
|
48289
|
+
for (const key of PRIORITY_FIELDS) {
|
|
48290
|
+
if (key in data && key !== "metadata" && key !== "spec") {
|
|
48291
|
+
addField(key, data[key]);
|
|
48292
|
+
}
|
|
48293
|
+
}
|
|
48294
|
+
for (const [key, value] of Object.entries(data)) {
|
|
48295
|
+
if (key !== "metadata" && key !== "spec") {
|
|
48296
|
+
addField(key, value);
|
|
48297
|
+
}
|
|
48298
|
+
}
|
|
48299
|
+
return result;
|
|
48300
|
+
}
|
|
48301
|
+
function formatResourceDetails(data, noColor = false) {
|
|
48302
|
+
const fields = flattenResourceData(data);
|
|
48303
|
+
if (fields.length === 0) {
|
|
48304
|
+
return "";
|
|
48305
|
+
}
|
|
48306
|
+
const metadata = data.metadata;
|
|
48307
|
+
const name = metadata?.name || data.name || "Resource Details";
|
|
48308
|
+
const boxData = fields.map((f) => ({
|
|
48309
|
+
label: f.key,
|
|
48310
|
+
value: f.value
|
|
48311
|
+
}));
|
|
48312
|
+
return formatKeyValueBox(boxData, name, noColor);
|
|
48313
|
+
}
|
|
48199
48314
|
|
|
48200
48315
|
// src/output/formatter.ts
|
|
48201
48316
|
function formatOutput(data, format = "table", noColor = false) {
|
|
@@ -48244,7 +48359,17 @@ function extractItems2(data) {
|
|
|
48244
48359
|
}
|
|
48245
48360
|
return [];
|
|
48246
48361
|
}
|
|
48362
|
+
function isSingleResourceResponse(data) {
|
|
48363
|
+
if (!data || typeof data !== "object") return false;
|
|
48364
|
+
if ("items" in data) return false;
|
|
48365
|
+
if (Array.isArray(data)) return false;
|
|
48366
|
+
const obj = data;
|
|
48367
|
+
return "metadata" in obj || "spec" in obj || "name" in obj && "namespace" in obj || "object_type" in obj;
|
|
48368
|
+
}
|
|
48247
48369
|
function formatTable(data, noColor = false) {
|
|
48370
|
+
if (isSingleResourceResponse(data)) {
|
|
48371
|
+
return formatResourceDetails(data, noColor);
|
|
48372
|
+
}
|
|
48248
48373
|
return formatResourceTable(data, noColor);
|
|
48249
48374
|
}
|
|
48250
48375
|
function formatTSV(data) {
|
|
@@ -152939,13 +153064,15 @@ async function executeCommand(input, session) {
|
|
|
152939
153064
|
if (cmd.isBuiltin) {
|
|
152940
153065
|
return executeBuiltin(cmd, session, ctx);
|
|
152941
153066
|
}
|
|
152942
|
-
|
|
152943
|
-
|
|
152944
|
-
|
|
152945
|
-
|
|
152946
|
-
|
|
152947
|
-
|
|
153067
|
+
const firstWord = cmd.args[0]?.toLowerCase() ?? "";
|
|
153068
|
+
const hasExtension = extensionRegistry.hasExtension(firstWord);
|
|
153069
|
+
const isDomainCommand = isValidDomain(firstWord) || isCustomDomain(firstWord) || hasExtension;
|
|
153070
|
+
if (isDomainCommand) {
|
|
153071
|
+
if (!ctx.isRoot()) {
|
|
153072
|
+
ctx.reset();
|
|
152948
153073
|
}
|
|
153074
|
+
const domainArgs = cmd.args.slice(1);
|
|
153075
|
+
return handleDomainNavigation(firstWord, domainArgs, ctx, session);
|
|
152949
153076
|
}
|
|
152950
153077
|
return await executeAPICommand(session, ctx, cmd);
|
|
152951
153078
|
}
|