@robinmordasiewicz/f5xc-xcsh 1.0.91-2601040443 → 1.0.91-2601040611
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 +120 -3
- 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-2601040611") {
|
|
47056
|
+
return "v1.0.91-2601040611";
|
|
47057
47057
|
}
|
|
47058
47058
|
if (process.env.XCSH_VERSION) {
|
|
47059
47059
|
return process.env.XCSH_VERSION;
|
|
@@ -47964,7 +47964,13 @@ function getValue(row, accessor) {
|
|
|
47964
47964
|
if (typeof accessor === "function") {
|
|
47965
47965
|
return accessor(row);
|
|
47966
47966
|
}
|
|
47967
|
-
|
|
47967
|
+
let value = row[accessor];
|
|
47968
|
+
if (value === null || value === void 0) {
|
|
47969
|
+
const metadata = row["metadata"];
|
|
47970
|
+
if (metadata && typeof metadata === "object") {
|
|
47971
|
+
value = metadata[accessor];
|
|
47972
|
+
}
|
|
47973
|
+
}
|
|
47968
47974
|
if (value === null || value === void 0) {
|
|
47969
47975
|
return "";
|
|
47970
47976
|
}
|
|
@@ -48190,6 +48196,107 @@ function formatKeyValueBox(data, title, noColor = false) {
|
|
|
48190
48196
|
);
|
|
48191
48197
|
return lines.join("\n");
|
|
48192
48198
|
}
|
|
48199
|
+
var EXCLUDED_FIELDS = /* @__PURE__ */ new Set([
|
|
48200
|
+
"system_metadata",
|
|
48201
|
+
"get_spec",
|
|
48202
|
+
"status",
|
|
48203
|
+
"referring_objects",
|
|
48204
|
+
"disabled_referred_objects",
|
|
48205
|
+
"object_type"
|
|
48206
|
+
]);
|
|
48207
|
+
var PRIORITY_FIELDS = [
|
|
48208
|
+
"name",
|
|
48209
|
+
"namespace",
|
|
48210
|
+
"labels",
|
|
48211
|
+
"description",
|
|
48212
|
+
"domains"
|
|
48213
|
+
];
|
|
48214
|
+
function formatDetailValue(value) {
|
|
48215
|
+
if (value === null || value === void 0) {
|
|
48216
|
+
return "";
|
|
48217
|
+
}
|
|
48218
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
48219
|
+
return String(value);
|
|
48220
|
+
}
|
|
48221
|
+
if (Array.isArray(value)) {
|
|
48222
|
+
const isSimple = value.every(
|
|
48223
|
+
(v) => typeof v === "string" || typeof v === "number"
|
|
48224
|
+
);
|
|
48225
|
+
if (isSimple && value.length <= 5) {
|
|
48226
|
+
return `[${value.join(", ")}]`;
|
|
48227
|
+
}
|
|
48228
|
+
return JSON.stringify(value);
|
|
48229
|
+
}
|
|
48230
|
+
if (typeof value === "object") {
|
|
48231
|
+
const obj = value;
|
|
48232
|
+
const keys = Object.keys(obj);
|
|
48233
|
+
if (keys.length <= 3) {
|
|
48234
|
+
const allSimple = keys.every((k) => {
|
|
48235
|
+
const v = obj[k];
|
|
48236
|
+
return typeof v === "string" || typeof v === "number" || typeof v === "boolean";
|
|
48237
|
+
});
|
|
48238
|
+
if (allSimple) {
|
|
48239
|
+
return keys.map((k) => `${k}: ${obj[k]}`).join(", ");
|
|
48240
|
+
}
|
|
48241
|
+
}
|
|
48242
|
+
return JSON.stringify(value);
|
|
48243
|
+
}
|
|
48244
|
+
return String(value);
|
|
48245
|
+
}
|
|
48246
|
+
function flattenResourceData(data) {
|
|
48247
|
+
const result = [];
|
|
48248
|
+
const seen = /* @__PURE__ */ new Set();
|
|
48249
|
+
const addField = (key, value) => {
|
|
48250
|
+
if (EXCLUDED_FIELDS.has(key) || seen.has(key)) return;
|
|
48251
|
+
if (value === null || value === void 0) return;
|
|
48252
|
+
seen.add(key);
|
|
48253
|
+
const formatted = formatDetailValue(value);
|
|
48254
|
+
if (formatted) {
|
|
48255
|
+
result.push({ key, value: formatted });
|
|
48256
|
+
}
|
|
48257
|
+
};
|
|
48258
|
+
const metadata = data.metadata;
|
|
48259
|
+
if (metadata && typeof metadata === "object") {
|
|
48260
|
+
for (const key of PRIORITY_FIELDS) {
|
|
48261
|
+
if (key in metadata) {
|
|
48262
|
+
addField(key, metadata[key]);
|
|
48263
|
+
}
|
|
48264
|
+
}
|
|
48265
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
48266
|
+
addField(key, value);
|
|
48267
|
+
}
|
|
48268
|
+
}
|
|
48269
|
+
const spec = data.spec;
|
|
48270
|
+
if (spec && typeof spec === "object") {
|
|
48271
|
+
for (const [key, value] of Object.entries(spec)) {
|
|
48272
|
+
addField(key, value);
|
|
48273
|
+
}
|
|
48274
|
+
}
|
|
48275
|
+
for (const key of PRIORITY_FIELDS) {
|
|
48276
|
+
if (key in data && key !== "metadata" && key !== "spec") {
|
|
48277
|
+
addField(key, data[key]);
|
|
48278
|
+
}
|
|
48279
|
+
}
|
|
48280
|
+
for (const [key, value] of Object.entries(data)) {
|
|
48281
|
+
if (key !== "metadata" && key !== "spec") {
|
|
48282
|
+
addField(key, value);
|
|
48283
|
+
}
|
|
48284
|
+
}
|
|
48285
|
+
return result;
|
|
48286
|
+
}
|
|
48287
|
+
function formatResourceDetails(data, noColor = false) {
|
|
48288
|
+
const fields = flattenResourceData(data);
|
|
48289
|
+
if (fields.length === 0) {
|
|
48290
|
+
return "";
|
|
48291
|
+
}
|
|
48292
|
+
const metadata = data.metadata;
|
|
48293
|
+
const name = metadata?.name || data.name || "Resource Details";
|
|
48294
|
+
const boxData = fields.map((f) => ({
|
|
48295
|
+
label: f.key,
|
|
48296
|
+
value: f.value
|
|
48297
|
+
}));
|
|
48298
|
+
return formatKeyValueBox(boxData, name, noColor);
|
|
48299
|
+
}
|
|
48193
48300
|
|
|
48194
48301
|
// src/output/formatter.ts
|
|
48195
48302
|
function formatOutput(data, format = "table", noColor = false) {
|
|
@@ -48238,7 +48345,17 @@ function extractItems2(data) {
|
|
|
48238
48345
|
}
|
|
48239
48346
|
return [];
|
|
48240
48347
|
}
|
|
48348
|
+
function isSingleResourceResponse(data) {
|
|
48349
|
+
if (!data || typeof data !== "object") return false;
|
|
48350
|
+
if ("items" in data) return false;
|
|
48351
|
+
if (Array.isArray(data)) return false;
|
|
48352
|
+
const obj = data;
|
|
48353
|
+
return "metadata" in obj || "spec" in obj || "name" in obj && "namespace" in obj || "object_type" in obj;
|
|
48354
|
+
}
|
|
48241
48355
|
function formatTable(data, noColor = false) {
|
|
48356
|
+
if (isSingleResourceResponse(data)) {
|
|
48357
|
+
return formatResourceDetails(data, noColor);
|
|
48358
|
+
}
|
|
48242
48359
|
return formatResourceTable(data, noColor);
|
|
48243
48360
|
}
|
|
48244
48361
|
function formatTSV(data) {
|