@robinmordasiewicz/f5xc-xcsh 2.0.13-2601051943 → 2.0.13-2601052351

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.
Files changed (2) hide show
  1. package/dist/index.js +148 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -46994,8 +46994,8 @@ function getLogoModeFromEnv(envPrefix) {
46994
46994
  var CLI_NAME = "xcsh";
46995
46995
  var CLI_FULL_NAME = "F5 Distributed Cloud Shell";
46996
46996
  function getVersion() {
46997
- if ("v2.0.13-2601051943") {
46998
- return "v2.0.13-2601051943";
46997
+ if ("v2.0.13-2601052351") {
46998
+ return "v2.0.13-2601052351";
46999
46999
  }
47000
47000
  if (process.env.XCSH_VERSION) {
47001
47001
  return process.env.XCSH_VERSION;
@@ -47920,6 +47920,9 @@ function getValue(row, accessor) {
47920
47920
  if (accessor === "labels") {
47921
47921
  return formatLabelsValue(value);
47922
47922
  }
47923
+ if (isComplexValue(value)) {
47924
+ return formatIndentedTree(value, 0, 4, 40).join("\n");
47925
+ }
47923
47926
  return JSON.stringify(value);
47924
47927
  }
47925
47928
  return String(value);
@@ -47931,6 +47934,135 @@ function formatLabelsValue(labels) {
47931
47934
  }
47932
47935
  return `map[${entries.join(" ")}]`;
47933
47936
  }
47937
+ function isComplexValue(value) {
47938
+ if (value === null || value === void 0) return false;
47939
+ if (typeof value !== "object") return false;
47940
+ if (Array.isArray(value)) {
47941
+ return value.some((item) => typeof item === "object" && item !== null);
47942
+ }
47943
+ const obj = value;
47944
+ const keys = Object.keys(obj);
47945
+ if (keys.length > 3) return true;
47946
+ return keys.some((k) => {
47947
+ const v = obj[k];
47948
+ return typeof v === "object" && v !== null;
47949
+ });
47950
+ }
47951
+ function formatIndentedTree(value, indent = 0, maxDepth = 6, maxWidth = 60) {
47952
+ const INDENT_SIZE = 2;
47953
+ const lines = [];
47954
+ if (value === null) {
47955
+ return ["null"];
47956
+ }
47957
+ if (value === void 0) {
47958
+ return [""];
47959
+ }
47960
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
47961
+ return [String(value)];
47962
+ }
47963
+ if (indent / INDENT_SIZE >= maxDepth) {
47964
+ const json = JSON.stringify(value);
47965
+ return json.length > maxWidth ? [json.slice(0, maxWidth - 3) + "..."] : [json];
47966
+ }
47967
+ if (Array.isArray(value)) {
47968
+ if (value.length === 0) {
47969
+ return ["[]"];
47970
+ }
47971
+ const isSimple = value.every(
47972
+ (v) => typeof v === "string" || typeof v === "number" || typeof v === "boolean" || v === null
47973
+ );
47974
+ if (isSimple && value.length <= 5) {
47975
+ const inline = `[${value.map((v) => v === null ? "null" : String(v)).join(", ")}]`;
47976
+ if (inline.length <= maxWidth) {
47977
+ return [inline];
47978
+ }
47979
+ }
47980
+ for (let i = 0; i < value.length; i++) {
47981
+ const item = value[i];
47982
+ const prefix = `[${i}]: `;
47983
+ if (typeof item === "object" && item !== null) {
47984
+ lines.push(prefix);
47985
+ const subLines = formatIndentedTree(
47986
+ item,
47987
+ indent + INDENT_SIZE,
47988
+ maxDepth,
47989
+ maxWidth
47990
+ );
47991
+ for (const subLine of subLines) {
47992
+ lines.push(" ".repeat(INDENT_SIZE) + subLine);
47993
+ }
47994
+ } else {
47995
+ const formatted = formatIndentedTree(
47996
+ item,
47997
+ indent,
47998
+ maxDepth,
47999
+ maxWidth
48000
+ );
48001
+ lines.push(prefix + formatted[0]);
48002
+ }
48003
+ }
48004
+ return lines;
48005
+ }
48006
+ if (typeof value === "object") {
48007
+ const obj = value;
48008
+ const keys = Object.keys(obj);
48009
+ if (keys.length === 0) {
48010
+ return ["{}"];
48011
+ }
48012
+ if (keys.length <= 2) {
48013
+ const allSimple = keys.every((k) => {
48014
+ const v = obj[k];
48015
+ return v === null || typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "object" && v !== null && Object.keys(v).length === 0;
48016
+ });
48017
+ if (allSimple) {
48018
+ const inline = keys.map((k) => {
48019
+ const v = obj[k];
48020
+ if (v === null) return `${k}: null`;
48021
+ if (typeof v === "object" && Object.keys(v).length === 0) {
48022
+ return Array.isArray(v) ? `${k}: []` : `${k}: {}`;
48023
+ }
48024
+ return `${k}: ${v}`;
48025
+ }).join(", ");
48026
+ if (inline.length <= maxWidth) {
48027
+ return [inline];
48028
+ }
48029
+ }
48030
+ }
48031
+ for (const key of keys) {
48032
+ const childValue = obj[key];
48033
+ if (typeof childValue === "object" && childValue !== null) {
48034
+ const childObj = childValue;
48035
+ const isEmpty = Array.isArray(childObj) ? childObj.length === 0 : Object.keys(childObj).length === 0;
48036
+ if (isEmpty) {
48037
+ lines.push(
48038
+ `${key}: ${Array.isArray(childObj) ? "[]" : "{}"}`
48039
+ );
48040
+ } else {
48041
+ lines.push(`${key}:`);
48042
+ const subLines = formatIndentedTree(
48043
+ childValue,
48044
+ indent + INDENT_SIZE,
48045
+ maxDepth,
48046
+ maxWidth
48047
+ );
48048
+ for (const subLine of subLines) {
48049
+ lines.push(" ".repeat(INDENT_SIZE) + subLine);
48050
+ }
48051
+ }
48052
+ } else {
48053
+ const formatted = formatIndentedTree(
48054
+ childValue,
48055
+ indent,
48056
+ maxDepth,
48057
+ maxWidth
48058
+ );
48059
+ lines.push(`${key}: ${formatted[0]}`);
48060
+ }
48061
+ }
48062
+ return lines;
48063
+ }
48064
+ return [String(value)];
48065
+ }
47934
48066
  function calculateColumnWidths(columns, rows, maxTableWidth) {
47935
48067
  const widths = columns.map((col) => {
47936
48068
  let width = col.header.length;
@@ -48117,11 +48249,19 @@ function formatKeyValueBox(data, title, noColor = false, maxWidth) {
48117
48249
  const contentLines = [];
48118
48250
  for (const d of data) {
48119
48251
  const paddedLabel = d.label.padEnd(maxLabelWidth);
48120
- const wrappedValueLines = wrapText2(d.value, maxValueWidth);
48121
- contentLines.push(`${paddedLabel}: ${wrappedValueLines[0] ?? ""}`);
48122
48252
  const indent = " ".repeat(maxLabelWidth + 3);
48123
- for (let i = 1; i < wrappedValueLines.length; i++) {
48124
- contentLines.push(`${indent}${wrappedValueLines[i]}`);
48253
+ const valueLines = d.value.split("\n");
48254
+ let isFirstLine = true;
48255
+ for (const valueLine of valueLines) {
48256
+ const wrappedLines = wrapText2(valueLine, maxValueWidth);
48257
+ for (const wrappedLine of wrappedLines) {
48258
+ if (isFirstLine) {
48259
+ contentLines.push(`${paddedLabel}: ${wrappedLine}`);
48260
+ isFirstLine = false;
48261
+ } else {
48262
+ contentLines.push(`${indent}${wrappedLine}`);
48263
+ }
48264
+ }
48125
48265
  }
48126
48266
  }
48127
48267
  const titleText = ` ${title} `;
@@ -48181,7 +48321,7 @@ function formatDetailValue(value) {
48181
48321
  if (isSimple && value.length <= 5) {
48182
48322
  return `[${value.join(", ")}]`;
48183
48323
  }
48184
- return JSON.stringify(value);
48324
+ return formatIndentedTree(value, 0, 6, 60).join("\n");
48185
48325
  }
48186
48326
  if (typeof value === "object") {
48187
48327
  const obj = value;
@@ -48195,7 +48335,7 @@ function formatDetailValue(value) {
48195
48335
  return keys.map((k) => `${k}: ${obj[k]}`).join(", ");
48196
48336
  }
48197
48337
  }
48198
- return JSON.stringify(value);
48338
+ return formatIndentedTree(value, 0, 6, 60).join("\n");
48199
48339
  }
48200
48340
  return String(value);
48201
48341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robinmordasiewicz/f5xc-xcsh",
3
- "version": "2.0.13-2601051943",
3
+ "version": "2.0.13-2601052351",
4
4
  "description": "F5 Distributed Cloud Shell - Interactive CLI for F5 XC",
5
5
  "type": "module",
6
6
  "bin": {