@altertable/cli 1.6.1 → 1.6.2
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/cli.js +993 -945
- package/package.json +8 -8
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
19
19
|
return cached;
|
|
20
20
|
}
|
|
21
21
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
22
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
22
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
23
23
|
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
24
24
|
for (let key of __getOwnPropNames(mod))
|
|
25
25
|
if (!__hasOwnProp.call(to, key))
|
|
@@ -37,50 +37,50 @@ var __require = import.meta.require;
|
|
|
37
37
|
|
|
38
38
|
// node_modules/sisteransi/src/index.js
|
|
39
39
|
var require_src = __commonJS(function(exports, module) {
|
|
40
|
-
var
|
|
41
|
-
var
|
|
40
|
+
var ESC = "\x1B";
|
|
41
|
+
var CSI = `${ESC}[`;
|
|
42
42
|
var beep = "\x07";
|
|
43
43
|
var cursor = {
|
|
44
44
|
to(x, y) {
|
|
45
45
|
if (!y)
|
|
46
|
-
return `${
|
|
47
|
-
return `${
|
|
46
|
+
return `${CSI}${x + 1}G`;
|
|
47
|
+
return `${CSI}${y + 1};${x + 1}H`;
|
|
48
48
|
},
|
|
49
49
|
move(x, y) {
|
|
50
50
|
let ret = "";
|
|
51
51
|
if (x < 0)
|
|
52
|
-
ret += `${
|
|
52
|
+
ret += `${CSI}${-x}D`;
|
|
53
53
|
else if (x > 0)
|
|
54
|
-
ret += `${
|
|
54
|
+
ret += `${CSI}${x}C`;
|
|
55
55
|
if (y < 0)
|
|
56
|
-
ret += `${
|
|
56
|
+
ret += `${CSI}${-y}A`;
|
|
57
57
|
else if (y > 0)
|
|
58
|
-
ret += `${
|
|
58
|
+
ret += `${CSI}${y}B`;
|
|
59
59
|
return ret;
|
|
60
60
|
},
|
|
61
|
-
up: (count = 1) => `${
|
|
62
|
-
down: (count = 1) => `${
|
|
63
|
-
forward: (count = 1) => `${
|
|
64
|
-
backward: (count = 1) => `${
|
|
65
|
-
nextLine: (count = 1) => `${
|
|
66
|
-
prevLine: (count = 1) => `${
|
|
67
|
-
left: `${
|
|
68
|
-
hide: `${
|
|
69
|
-
show: `${
|
|
70
|
-
save: `${
|
|
71
|
-
restore: `${
|
|
61
|
+
up: (count = 1) => `${CSI}${count}A`,
|
|
62
|
+
down: (count = 1) => `${CSI}${count}B`,
|
|
63
|
+
forward: (count = 1) => `${CSI}${count}C`,
|
|
64
|
+
backward: (count = 1) => `${CSI}${count}D`,
|
|
65
|
+
nextLine: (count = 1) => `${CSI}E`.repeat(count),
|
|
66
|
+
prevLine: (count = 1) => `${CSI}F`.repeat(count),
|
|
67
|
+
left: `${CSI}G`,
|
|
68
|
+
hide: `${CSI}?25l`,
|
|
69
|
+
show: `${CSI}?25h`,
|
|
70
|
+
save: `${ESC}7`,
|
|
71
|
+
restore: `${ESC}8`
|
|
72
72
|
};
|
|
73
73
|
var scroll = {
|
|
74
|
-
up: (count = 1) => `${
|
|
75
|
-
down: (count = 1) => `${
|
|
74
|
+
up: (count = 1) => `${CSI}S`.repeat(count),
|
|
75
|
+
down: (count = 1) => `${CSI}T`.repeat(count)
|
|
76
76
|
};
|
|
77
77
|
var erase = {
|
|
78
|
-
screen: `${
|
|
79
|
-
up: (count = 1) => `${
|
|
80
|
-
down: (count = 1) => `${
|
|
81
|
-
line: `${
|
|
82
|
-
lineEnd: `${
|
|
83
|
-
lineStart: `${
|
|
78
|
+
screen: `${CSI}2J`,
|
|
79
|
+
up: (count = 1) => `${CSI}1J`.repeat(count),
|
|
80
|
+
down: (count = 1) => `${CSI}J`.repeat(count),
|
|
81
|
+
line: `${CSI}2K`,
|
|
82
|
+
lineEnd: `${CSI}K`,
|
|
83
|
+
lineStart: `${CSI}1K`,
|
|
84
84
|
lines(count) {
|
|
85
85
|
let clear = "";
|
|
86
86
|
for (let i = 0;i < count; i++)
|
|
@@ -174,15 +174,15 @@ var require_visit = __commonJS(function(exports) {
|
|
|
174
174
|
if (typeof ctrl !== "symbol") {
|
|
175
175
|
if (identity.isCollection(node)) {
|
|
176
176
|
path = Object.freeze(path.concat(node));
|
|
177
|
-
for (let
|
|
178
|
-
const ci = visit_(
|
|
177
|
+
for (let i = 0;i < node.items.length; ++i) {
|
|
178
|
+
const ci = visit_(i, node.items[i], visitor, path);
|
|
179
179
|
if (typeof ci === "number")
|
|
180
|
-
|
|
180
|
+
i = ci - 1;
|
|
181
181
|
else if (ci === BREAK)
|
|
182
182
|
return BREAK;
|
|
183
183
|
else if (ci === REMOVE) {
|
|
184
|
-
node.items.splice(
|
|
185
|
-
|
|
184
|
+
node.items.splice(i, 1);
|
|
185
|
+
i -= 1;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
} else if (identity.isPair(node)) {
|
|
@@ -222,15 +222,15 @@ var require_visit = __commonJS(function(exports) {
|
|
|
222
222
|
if (typeof ctrl !== "symbol") {
|
|
223
223
|
if (identity.isCollection(node)) {
|
|
224
224
|
path = Object.freeze(path.concat(node));
|
|
225
|
-
for (let
|
|
226
|
-
const ci = await visitAsync_(
|
|
225
|
+
for (let i = 0;i < node.items.length; ++i) {
|
|
226
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path);
|
|
227
227
|
if (typeof ci === "number")
|
|
228
|
-
|
|
228
|
+
i = ci - 1;
|
|
229
229
|
else if (ci === BREAK)
|
|
230
230
|
return BREAK;
|
|
231
231
|
else if (ci === REMOVE) {
|
|
232
|
-
node.items.splice(
|
|
233
|
-
|
|
232
|
+
node.items.splice(i, 1);
|
|
233
|
+
i -= 1;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
} else if (identity.isPair(node)) {
|
|
@@ -477,8 +477,8 @@ var require_anchors = __commonJS(function(exports) {
|
|
|
477
477
|
return anchors;
|
|
478
478
|
}
|
|
479
479
|
function findNewAnchor(prefix, exclude) {
|
|
480
|
-
for (let
|
|
481
|
-
const name = `${prefix}${
|
|
480
|
+
for (let i = 1;; ++i) {
|
|
481
|
+
const name = `${prefix}${i}`;
|
|
482
482
|
if (!exclude.has(name))
|
|
483
483
|
return name;
|
|
484
484
|
}
|
|
@@ -521,13 +521,13 @@ var require_applyReviver = __commonJS(function(exports) {
|
|
|
521
521
|
function applyReviver(reviver, obj, key, val) {
|
|
522
522
|
if (val && typeof val === "object") {
|
|
523
523
|
if (Array.isArray(val)) {
|
|
524
|
-
for (let
|
|
525
|
-
const v0 = val[
|
|
526
|
-
const v1 = applyReviver(reviver, val, String(
|
|
524
|
+
for (let i = 0, len = val.length;i < len; ++i) {
|
|
525
|
+
const v0 = val[i];
|
|
526
|
+
const v1 = applyReviver(reviver, val, String(i), v0);
|
|
527
527
|
if (v1 === undefined)
|
|
528
|
-
delete val[
|
|
528
|
+
delete val[i];
|
|
529
529
|
else if (v1 !== v0)
|
|
530
|
-
val[
|
|
530
|
+
val[i] = v1;
|
|
531
531
|
}
|
|
532
532
|
} else if (val instanceof Map) {
|
|
533
533
|
for (const k of Array.from(val.keys())) {
|
|
@@ -568,14 +568,14 @@ var require_toJS = __commonJS(function(exports) {
|
|
|
568
568
|
var identity = require_identity();
|
|
569
569
|
function toJS(value, arg, ctx) {
|
|
570
570
|
if (Array.isArray(value))
|
|
571
|
-
return value.map((v,
|
|
571
|
+
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
572
572
|
if (value && typeof value.toJSON === "function") {
|
|
573
573
|
if (!ctx || !identity.hasAnchor(value))
|
|
574
574
|
return value.toJSON(arg, ctx);
|
|
575
575
|
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
576
576
|
ctx.anchors.set(value, data);
|
|
577
|
-
ctx.onCreate = (
|
|
578
|
-
data.res =
|
|
577
|
+
ctx.onCreate = (res) => {
|
|
578
|
+
data.res = res;
|
|
579
579
|
delete ctx.onCreate;
|
|
580
580
|
};
|
|
581
581
|
const res = value.toJSON(arg, ctx);
|
|
@@ -619,8 +619,8 @@ var require_Node = __commonJS(function(exports) {
|
|
|
619
619
|
};
|
|
620
620
|
const res = toJS.toJS(this, "", ctx);
|
|
621
621
|
if (typeof onAnchor === "function")
|
|
622
|
-
for (const { count, res
|
|
623
|
-
onAnchor(
|
|
622
|
+
for (const { count, res } of ctx.anchors.values())
|
|
623
|
+
onAnchor(res, count);
|
|
624
624
|
return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
|
|
625
625
|
}
|
|
626
626
|
}
|
|
@@ -674,16 +674,16 @@ var require_Alias = __commonJS(function(exports) {
|
|
|
674
674
|
toJSON(_arg, ctx) {
|
|
675
675
|
if (!ctx)
|
|
676
676
|
return { source: this.source };
|
|
677
|
-
const { anchors
|
|
677
|
+
const { anchors, doc, maxAliasCount } = ctx;
|
|
678
678
|
const source = this.resolve(doc, ctx);
|
|
679
679
|
if (!source) {
|
|
680
680
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
681
681
|
throw new ReferenceError(msg);
|
|
682
682
|
}
|
|
683
|
-
let data =
|
|
683
|
+
let data = anchors.get(source);
|
|
684
684
|
if (!data) {
|
|
685
685
|
toJS.toJS(source, null, ctx);
|
|
686
|
-
data =
|
|
686
|
+
data = anchors.get(source);
|
|
687
687
|
}
|
|
688
688
|
if (data?.res === undefined) {
|
|
689
689
|
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
@@ -692,7 +692,7 @@ var require_Alias = __commonJS(function(exports) {
|
|
|
692
692
|
if (maxAliasCount >= 0) {
|
|
693
693
|
data.count += 1;
|
|
694
694
|
if (data.aliasCount === 0)
|
|
695
|
-
data.aliasCount = getAliasCount(doc, source,
|
|
695
|
+
data.aliasCount = getAliasCount(doc, source, anchors);
|
|
696
696
|
if (data.count * data.aliasCount > maxAliasCount) {
|
|
697
697
|
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
698
698
|
throw new ReferenceError(msg);
|
|
@@ -714,22 +714,22 @@ var require_Alias = __commonJS(function(exports) {
|
|
|
714
714
|
return src;
|
|
715
715
|
}
|
|
716
716
|
}
|
|
717
|
-
function getAliasCount(doc, node,
|
|
717
|
+
function getAliasCount(doc, node, anchors) {
|
|
718
718
|
if (identity.isAlias(node)) {
|
|
719
719
|
const source = node.resolve(doc);
|
|
720
|
-
const anchor =
|
|
720
|
+
const anchor = anchors && source && anchors.get(source);
|
|
721
721
|
return anchor ? anchor.count * anchor.aliasCount : 0;
|
|
722
722
|
} else if (identity.isCollection(node)) {
|
|
723
723
|
let count = 0;
|
|
724
724
|
for (const item of node.items) {
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
count =
|
|
725
|
+
const c = getAliasCount(doc, item, anchors);
|
|
726
|
+
if (c > count)
|
|
727
|
+
count = c;
|
|
728
728
|
}
|
|
729
729
|
return count;
|
|
730
730
|
} else if (identity.isPair(node)) {
|
|
731
|
-
const kc = getAliasCount(doc, node.key,
|
|
732
|
-
const vc = getAliasCount(doc, node.value,
|
|
731
|
+
const kc = getAliasCount(doc, node.key, anchors);
|
|
732
|
+
const vc = getAliasCount(doc, node.value, anchors);
|
|
733
733
|
return Math.max(kc, vc);
|
|
734
734
|
}
|
|
735
735
|
return 1;
|
|
@@ -773,13 +773,13 @@ var require_createNode = __commonJS(function(exports) {
|
|
|
773
773
|
var defaultTagPrefix = "tag:yaml.org,2002:";
|
|
774
774
|
function findTagObject(value, tagName, tags) {
|
|
775
775
|
if (tagName) {
|
|
776
|
-
const match = tags.filter((
|
|
777
|
-
const tagObj = match.find((
|
|
776
|
+
const match = tags.filter((t) => t.tag === tagName);
|
|
777
|
+
const tagObj = match.find((t) => !t.format) ?? match[0];
|
|
778
778
|
if (!tagObj)
|
|
779
779
|
throw new Error(`Tag ${tagName} not found`);
|
|
780
780
|
return tagObj;
|
|
781
781
|
}
|
|
782
|
-
return tags.find((
|
|
782
|
+
return tags.find((t) => t.identify?.(value) && !t.format);
|
|
783
783
|
}
|
|
784
784
|
function createNode(value, tagName, ctx) {
|
|
785
785
|
if (identity.isDocument(value))
|
|
@@ -814,10 +814,10 @@ var require_createNode = __commonJS(function(exports) {
|
|
|
814
814
|
value = value.toJSON();
|
|
815
815
|
}
|
|
816
816
|
if (!value || typeof value !== "object") {
|
|
817
|
-
const
|
|
817
|
+
const node = new Scalar.Scalar(value);
|
|
818
818
|
if (ref)
|
|
819
|
-
ref.node =
|
|
820
|
-
return
|
|
819
|
+
ref.node = node;
|
|
820
|
+
return node;
|
|
821
821
|
}
|
|
822
822
|
tagObj = value instanceof Map ? schema[identity.MAP] : (Symbol.iterator in Object(value)) ? schema[identity.SEQ] : schema[identity.MAP];
|
|
823
823
|
}
|
|
@@ -844,12 +844,12 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
844
844
|
var Node = require_Node();
|
|
845
845
|
function collectionFromPath(schema, path, value) {
|
|
846
846
|
let v = value;
|
|
847
|
-
for (let
|
|
848
|
-
const k = path[
|
|
847
|
+
for (let i = path.length - 1;i >= 0; --i) {
|
|
848
|
+
const k = path[i];
|
|
849
849
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
v =
|
|
850
|
+
const a = [];
|
|
851
|
+
a[k] = v;
|
|
852
|
+
v = a;
|
|
853
853
|
} else {
|
|
854
854
|
v = new Map([[k, v]]);
|
|
855
855
|
}
|
|
@@ -921,8 +921,8 @@ var require_Collection = __commonJS(function(exports) {
|
|
|
921
921
|
return this.items.every((node) => {
|
|
922
922
|
if (!identity.isPair(node))
|
|
923
923
|
return false;
|
|
924
|
-
const
|
|
925
|
-
return
|
|
924
|
+
const n = node.value;
|
|
925
|
+
return n == null || allowScalar && identity.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
|
|
926
926
|
});
|
|
927
927
|
}
|
|
928
928
|
hasIn(path) {
|
|
@@ -974,14 +974,14 @@ var require_foldFlowLines = __commonJS(function(exports) {
|
|
|
974
974
|
var FOLD_FLOW = "flow";
|
|
975
975
|
var FOLD_BLOCK = "block";
|
|
976
976
|
var FOLD_QUOTED = "quoted";
|
|
977
|
-
function foldFlowLines(
|
|
977
|
+
function foldFlowLines(text, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
978
978
|
if (!lineWidth || lineWidth < 0)
|
|
979
|
-
return
|
|
979
|
+
return text;
|
|
980
980
|
if (lineWidth < minContentWidth)
|
|
981
981
|
minContentWidth = 0;
|
|
982
982
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
983
|
-
if (
|
|
984
|
-
return
|
|
983
|
+
if (text.length <= endStep)
|
|
984
|
+
return text;
|
|
985
985
|
const folds = [];
|
|
986
986
|
const escapedFolds = {};
|
|
987
987
|
let end = lineWidth - indent.length;
|
|
@@ -994,47 +994,47 @@ var require_foldFlowLines = __commonJS(function(exports) {
|
|
|
994
994
|
let split = undefined;
|
|
995
995
|
let prev = undefined;
|
|
996
996
|
let overflow = false;
|
|
997
|
-
let
|
|
997
|
+
let i = -1;
|
|
998
998
|
let escStart = -1;
|
|
999
999
|
let escEnd = -1;
|
|
1000
1000
|
if (mode === FOLD_BLOCK) {
|
|
1001
|
-
|
|
1002
|
-
if (
|
|
1003
|
-
end =
|
|
1001
|
+
i = consumeMoreIndentedLines(text, i, indent.length);
|
|
1002
|
+
if (i !== -1)
|
|
1003
|
+
end = i + endStep;
|
|
1004
1004
|
}
|
|
1005
|
-
for (let ch;ch =
|
|
1005
|
+
for (let ch;ch = text[i += 1]; ) {
|
|
1006
1006
|
if (mode === FOLD_QUOTED && ch === "\\") {
|
|
1007
|
-
escStart =
|
|
1008
|
-
switch (
|
|
1007
|
+
escStart = i;
|
|
1008
|
+
switch (text[i + 1]) {
|
|
1009
1009
|
case "x":
|
|
1010
|
-
|
|
1010
|
+
i += 3;
|
|
1011
1011
|
break;
|
|
1012
1012
|
case "u":
|
|
1013
|
-
|
|
1013
|
+
i += 5;
|
|
1014
1014
|
break;
|
|
1015
1015
|
case "U":
|
|
1016
|
-
|
|
1016
|
+
i += 9;
|
|
1017
1017
|
break;
|
|
1018
1018
|
default:
|
|
1019
|
-
|
|
1019
|
+
i += 1;
|
|
1020
1020
|
}
|
|
1021
|
-
escEnd =
|
|
1021
|
+
escEnd = i;
|
|
1022
1022
|
}
|
|
1023
1023
|
if (ch === `
|
|
1024
1024
|
`) {
|
|
1025
1025
|
if (mode === FOLD_BLOCK)
|
|
1026
|
-
|
|
1027
|
-
end =
|
|
1026
|
+
i = consumeMoreIndentedLines(text, i, indent.length);
|
|
1027
|
+
end = i + indent.length + endStep;
|
|
1028
1028
|
split = undefined;
|
|
1029
1029
|
} else {
|
|
1030
1030
|
if (ch === " " && prev && prev !== " " && prev !== `
|
|
1031
1031
|
` && prev !== "\t") {
|
|
1032
|
-
const next =
|
|
1032
|
+
const next = text[i + 1];
|
|
1033
1033
|
if (next && next !== " " && next !== `
|
|
1034
1034
|
` && next !== "\t")
|
|
1035
|
-
split =
|
|
1035
|
+
split = i;
|
|
1036
1036
|
}
|
|
1037
|
-
if (
|
|
1037
|
+
if (i >= end) {
|
|
1038
1038
|
if (split) {
|
|
1039
1039
|
folds.push(split);
|
|
1040
1040
|
end = split + endStep;
|
|
@@ -1042,12 +1042,12 @@ var require_foldFlowLines = __commonJS(function(exports) {
|
|
|
1042
1042
|
} else if (mode === FOLD_QUOTED) {
|
|
1043
1043
|
while (prev === " " || prev === "\t") {
|
|
1044
1044
|
prev = ch;
|
|
1045
|
-
ch =
|
|
1045
|
+
ch = text[i += 1];
|
|
1046
1046
|
overflow = true;
|
|
1047
1047
|
}
|
|
1048
|
-
const j =
|
|
1048
|
+
const j = i > escEnd + 1 ? i - 2 : escStart - 1;
|
|
1049
1049
|
if (escapedFolds[j])
|
|
1050
|
-
return
|
|
1050
|
+
return text;
|
|
1051
1051
|
folds.push(j);
|
|
1052
1052
|
escapedFolds[j] = true;
|
|
1053
1053
|
end = j + endStep;
|
|
@@ -1062,40 +1062,40 @@ var require_foldFlowLines = __commonJS(function(exports) {
|
|
|
1062
1062
|
if (overflow && onOverflow)
|
|
1063
1063
|
onOverflow();
|
|
1064
1064
|
if (folds.length === 0)
|
|
1065
|
-
return
|
|
1065
|
+
return text;
|
|
1066
1066
|
if (onFold)
|
|
1067
1067
|
onFold();
|
|
1068
|
-
let res =
|
|
1069
|
-
for (let
|
|
1070
|
-
const fold = folds[
|
|
1071
|
-
const
|
|
1068
|
+
let res = text.slice(0, folds[0]);
|
|
1069
|
+
for (let i = 0;i < folds.length; ++i) {
|
|
1070
|
+
const fold = folds[i];
|
|
1071
|
+
const end = folds[i + 1] || text.length;
|
|
1072
1072
|
if (fold === 0)
|
|
1073
1073
|
res = `
|
|
1074
|
-
${indent}${
|
|
1074
|
+
${indent}${text.slice(0, end)}`;
|
|
1075
1075
|
else {
|
|
1076
1076
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
1077
|
-
res += `${
|
|
1077
|
+
res += `${text[fold]}\\`;
|
|
1078
1078
|
res += `
|
|
1079
|
-
${indent}${
|
|
1079
|
+
${indent}${text.slice(fold + 1, end)}`;
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
1082
|
return res;
|
|
1083
1083
|
}
|
|
1084
|
-
function consumeMoreIndentedLines(
|
|
1085
|
-
let end =
|
|
1086
|
-
let start =
|
|
1087
|
-
let ch =
|
|
1084
|
+
function consumeMoreIndentedLines(text, i, indent) {
|
|
1085
|
+
let end = i;
|
|
1086
|
+
let start = i + 1;
|
|
1087
|
+
let ch = text[start];
|
|
1088
1088
|
while (ch === " " || ch === "\t") {
|
|
1089
|
-
if (
|
|
1090
|
-
ch =
|
|
1089
|
+
if (i < start + indent) {
|
|
1090
|
+
ch = text[++i];
|
|
1091
1091
|
} else {
|
|
1092
1092
|
do {
|
|
1093
|
-
ch =
|
|
1093
|
+
ch = text[++i];
|
|
1094
1094
|
} while (ch && ch !== `
|
|
1095
1095
|
`);
|
|
1096
|
-
end =
|
|
1097
|
-
start =
|
|
1098
|
-
ch =
|
|
1096
|
+
end = i;
|
|
1097
|
+
start = i + 1;
|
|
1098
|
+
ch = text[start];
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
1101
|
return end;
|
|
@@ -1123,12 +1123,12 @@ var require_stringifyString = __commonJS(function(exports) {
|
|
|
1123
1123
|
const strLen = str.length;
|
|
1124
1124
|
if (strLen <= limit)
|
|
1125
1125
|
return false;
|
|
1126
|
-
for (let
|
|
1127
|
-
if (str[
|
|
1126
|
+
for (let i = 0, start = 0;i < strLen; ++i) {
|
|
1127
|
+
if (str[i] === `
|
|
1128
1128
|
`) {
|
|
1129
|
-
if (
|
|
1129
|
+
if (i - start > limit)
|
|
1130
1130
|
return true;
|
|
1131
|
-
start =
|
|
1131
|
+
start = i + 1;
|
|
1132
1132
|
if (strLen - start <= limit)
|
|
1133
1133
|
return false;
|
|
1134
1134
|
}
|
|
@@ -1144,19 +1144,19 @@ var require_stringifyString = __commonJS(function(exports) {
|
|
|
1144
1144
|
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
|
|
1145
1145
|
let str = "";
|
|
1146
1146
|
let start = 0;
|
|
1147
|
-
for (let
|
|
1148
|
-
if (ch === " " && json[
|
|
1149
|
-
str += json.slice(start,
|
|
1150
|
-
|
|
1151
|
-
start =
|
|
1147
|
+
for (let i = 0, ch = json[i];ch; ch = json[++i]) {
|
|
1148
|
+
if (ch === " " && json[i + 1] === "\\" && json[i + 2] === "n") {
|
|
1149
|
+
str += json.slice(start, i) + "\\ ";
|
|
1150
|
+
i += 1;
|
|
1151
|
+
start = i;
|
|
1152
1152
|
ch = "\\";
|
|
1153
1153
|
}
|
|
1154
1154
|
if (ch === "\\")
|
|
1155
|
-
switch (json[
|
|
1155
|
+
switch (json[i + 1]) {
|
|
1156
1156
|
case "u":
|
|
1157
1157
|
{
|
|
1158
|
-
str += json.slice(start,
|
|
1159
|
-
const code = json.substr(
|
|
1158
|
+
str += json.slice(start, i);
|
|
1159
|
+
const code = json.substr(i + 2, 4);
|
|
1160
1160
|
switch (code) {
|
|
1161
1161
|
case "0000":
|
|
1162
1162
|
str += "\\0";
|
|
@@ -1186,33 +1186,33 @@ var require_stringifyString = __commonJS(function(exports) {
|
|
|
1186
1186
|
if (code.substr(0, 2) === "00")
|
|
1187
1187
|
str += "\\x" + code.substr(2);
|
|
1188
1188
|
else
|
|
1189
|
-
str += json.substr(
|
|
1189
|
+
str += json.substr(i, 6);
|
|
1190
1190
|
}
|
|
1191
|
-
|
|
1192
|
-
start =
|
|
1191
|
+
i += 5;
|
|
1192
|
+
start = i + 1;
|
|
1193
1193
|
}
|
|
1194
1194
|
break;
|
|
1195
1195
|
case "n":
|
|
1196
|
-
if (implicitKey || json[
|
|
1197
|
-
|
|
1196
|
+
if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) {
|
|
1197
|
+
i += 1;
|
|
1198
1198
|
} else {
|
|
1199
|
-
str += json.slice(start,
|
|
1199
|
+
str += json.slice(start, i) + `
|
|
1200
1200
|
|
|
1201
1201
|
`;
|
|
1202
|
-
while (json[
|
|
1202
|
+
while (json[i + 2] === "\\" && json[i + 3] === "n" && json[i + 4] !== '"') {
|
|
1203
1203
|
str += `
|
|
1204
1204
|
`;
|
|
1205
|
-
|
|
1205
|
+
i += 2;
|
|
1206
1206
|
}
|
|
1207
1207
|
str += indent;
|
|
1208
|
-
if (json[
|
|
1208
|
+
if (json[i + 2] === " ")
|
|
1209
1209
|
str += "\\";
|
|
1210
|
-
|
|
1211
|
-
start =
|
|
1210
|
+
i += 1;
|
|
1211
|
+
start = i + 1;
|
|
1212
1212
|
}
|
|
1213
1213
|
break;
|
|
1214
1214
|
default:
|
|
1215
|
-
|
|
1215
|
+
i += 1;
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
1218
1218
|
str = start ? str + json.slice(start) : json;
|
|
@@ -1394,10 +1394,10 @@ ${indent}`);
|
|
|
1394
1394
|
let res = _stringify(type);
|
|
1395
1395
|
if (res === null) {
|
|
1396
1396
|
const { defaultKeyType, defaultStringType } = ctx.options;
|
|
1397
|
-
const
|
|
1398
|
-
res = _stringify(
|
|
1397
|
+
const t = implicitKey && defaultKeyType || defaultStringType;
|
|
1398
|
+
res = _stringify(t);
|
|
1399
1399
|
if (res === null)
|
|
1400
|
-
throw new Error(`Unsupported default string type ${
|
|
1400
|
+
throw new Error(`Unsupported default string type ${t}`);
|
|
1401
1401
|
}
|
|
1402
1402
|
return res;
|
|
1403
1403
|
}
|
|
@@ -1454,24 +1454,24 @@ var require_stringify = __commonJS(function(exports) {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
function getTagObject(tags, item) {
|
|
1456
1456
|
if (item.tag) {
|
|
1457
|
-
const match = tags.filter((
|
|
1457
|
+
const match = tags.filter((t) => t.tag === item.tag);
|
|
1458
1458
|
if (match.length > 0)
|
|
1459
|
-
return match.find((
|
|
1459
|
+
return match.find((t) => t.format === item.format) ?? match[0];
|
|
1460
1460
|
}
|
|
1461
1461
|
let tagObj = undefined;
|
|
1462
1462
|
let obj;
|
|
1463
1463
|
if (identity.isScalar(item)) {
|
|
1464
1464
|
obj = item.value;
|
|
1465
|
-
let match = tags.filter((
|
|
1465
|
+
let match = tags.filter((t) => t.identify?.(obj));
|
|
1466
1466
|
if (match.length > 1) {
|
|
1467
|
-
const testMatch = match.filter((
|
|
1467
|
+
const testMatch = match.filter((t) => t.test);
|
|
1468
1468
|
if (testMatch.length > 0)
|
|
1469
1469
|
match = testMatch;
|
|
1470
1470
|
}
|
|
1471
|
-
tagObj = match.find((
|
|
1471
|
+
tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
|
|
1472
1472
|
} else {
|
|
1473
1473
|
obj = item;
|
|
1474
|
-
tagObj = tags.find((
|
|
1474
|
+
tagObj = tags.find((t) => t.nodeClass && obj instanceof t.nodeClass);
|
|
1475
1475
|
}
|
|
1476
1476
|
if (!tagObj) {
|
|
1477
1477
|
const name = obj?.constructor?.name ?? (obj === null ? "null" : typeof obj);
|
|
@@ -1712,15 +1712,15 @@ var require_merge = __commonJS(function(exports) {
|
|
|
1712
1712
|
if (!identity.isMap(source))
|
|
1713
1713
|
throw new Error("Merge sources must be maps or map aliases");
|
|
1714
1714
|
const srcMap = source.toJSON(null, ctx, Map);
|
|
1715
|
-
for (const [key,
|
|
1715
|
+
for (const [key, value] of srcMap) {
|
|
1716
1716
|
if (map instanceof Map) {
|
|
1717
1717
|
if (!map.has(key))
|
|
1718
|
-
map.set(key,
|
|
1718
|
+
map.set(key, value);
|
|
1719
1719
|
} else if (map instanceof Set) {
|
|
1720
1720
|
map.add(key);
|
|
1721
1721
|
} else if (!Object.prototype.hasOwnProperty.call(map, key)) {
|
|
1722
1722
|
Object.defineProperty(map, key, {
|
|
1723
|
-
value
|
|
1723
|
+
value,
|
|
1724
1724
|
writable: true,
|
|
1725
1725
|
enumerable: true,
|
|
1726
1726
|
configurable: true
|
|
@@ -1843,23 +1843,23 @@ var require_stringifyCollection = __commonJS(function(exports) {
|
|
|
1843
1843
|
var stringifyComment = require_stringifyComment();
|
|
1844
1844
|
function stringifyCollection(collection, ctx, options) {
|
|
1845
1845
|
const flow = ctx.inFlow ?? collection.flow;
|
|
1846
|
-
const
|
|
1847
|
-
return
|
|
1846
|
+
const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
|
|
1847
|
+
return stringify(collection, ctx, options);
|
|
1848
1848
|
}
|
|
1849
1849
|
function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
|
|
1850
1850
|
const { indent, options: { commentString } } = ctx;
|
|
1851
1851
|
const itemCtx = Object.assign({}, ctx, { indent: itemIndent, type: null });
|
|
1852
1852
|
let chompKeep = false;
|
|
1853
1853
|
const lines = [];
|
|
1854
|
-
for (let
|
|
1855
|
-
const item = items[
|
|
1856
|
-
let
|
|
1854
|
+
for (let i = 0;i < items.length; ++i) {
|
|
1855
|
+
const item = items[i];
|
|
1856
|
+
let comment = null;
|
|
1857
1857
|
if (identity.isNode(item)) {
|
|
1858
1858
|
if (!chompKeep && item.spaceBefore)
|
|
1859
1859
|
lines.push("");
|
|
1860
1860
|
addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
|
|
1861
1861
|
if (item.comment)
|
|
1862
|
-
|
|
1862
|
+
comment = item.comment;
|
|
1863
1863
|
} else if (identity.isPair(item)) {
|
|
1864
1864
|
const ik = identity.isNode(item.key) ? item.key : null;
|
|
1865
1865
|
if (ik) {
|
|
@@ -1869,20 +1869,20 @@ var require_stringifyCollection = __commonJS(function(exports) {
|
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
1871
|
chompKeep = false;
|
|
1872
|
-
let
|
|
1873
|
-
if (
|
|
1874
|
-
|
|
1875
|
-
if (chompKeep &&
|
|
1872
|
+
let str = stringify.stringify(item, itemCtx, () => comment = null, () => chompKeep = true);
|
|
1873
|
+
if (comment)
|
|
1874
|
+
str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
|
|
1875
|
+
if (chompKeep && comment)
|
|
1876
1876
|
chompKeep = false;
|
|
1877
|
-
lines.push(blockItemPrefix +
|
|
1877
|
+
lines.push(blockItemPrefix + str);
|
|
1878
1878
|
}
|
|
1879
1879
|
let str;
|
|
1880
1880
|
if (lines.length === 0) {
|
|
1881
1881
|
str = flowChars.start + flowChars.end;
|
|
1882
1882
|
} else {
|
|
1883
1883
|
str = lines[0];
|
|
1884
|
-
for (let
|
|
1885
|
-
const line = lines[
|
|
1884
|
+
for (let i = 1;i < lines.length; ++i) {
|
|
1885
|
+
const line = lines[i];
|
|
1886
1886
|
str += line ? `
|
|
1887
1887
|
${indent}${line}` : `
|
|
1888
1888
|
`;
|
|
@@ -1908,8 +1908,8 @@ ${indent}${line}` : `
|
|
|
1908
1908
|
let reqNewline = false;
|
|
1909
1909
|
let linesAtValue = 0;
|
|
1910
1910
|
const lines = [];
|
|
1911
|
-
for (let
|
|
1912
|
-
const item = items[
|
|
1911
|
+
for (let i = 0;i < items.length; ++i) {
|
|
1912
|
+
const item = items[i];
|
|
1913
1913
|
let comment = null;
|
|
1914
1914
|
if (identity.isNode(item)) {
|
|
1915
1915
|
if (item.spaceBefore)
|
|
@@ -1941,7 +1941,7 @@ ${indent}${line}` : `
|
|
|
1941
1941
|
let str = stringify.stringify(item, itemCtx, () => comment = null);
|
|
1942
1942
|
reqNewline || (reqNewline = lines.length > linesAtValue || str.includes(`
|
|
1943
1943
|
`));
|
|
1944
|
-
if (
|
|
1944
|
+
if (i < items.length - 1) {
|
|
1945
1945
|
str += ",";
|
|
1946
1946
|
} else if (ctx.options.trailingComma) {
|
|
1947
1947
|
if (ctx.options.lineWidth > 0) {
|
|
@@ -2058,11 +2058,11 @@ var require_YAMLMap = __commonJS(function(exports) {
|
|
|
2058
2058
|
else
|
|
2059
2059
|
prev.value = _pair.value;
|
|
2060
2060
|
} else if (sortEntries) {
|
|
2061
|
-
const
|
|
2062
|
-
if (
|
|
2061
|
+
const i = this.items.findIndex((item) => sortEntries(_pair, item) < 0);
|
|
2062
|
+
if (i === -1)
|
|
2063
2063
|
this.items.push(_pair);
|
|
2064
2064
|
else
|
|
2065
|
-
this.items.splice(
|
|
2065
|
+
this.items.splice(i, 0, _pair);
|
|
2066
2066
|
} else {
|
|
2067
2067
|
this.items.push(_pair);
|
|
2068
2068
|
}
|
|
@@ -2124,10 +2124,10 @@ var require_map = __commonJS(function(exports) {
|
|
|
2124
2124
|
default: true,
|
|
2125
2125
|
nodeClass: YAMLMap.YAMLMap,
|
|
2126
2126
|
tag: "tag:yaml.org,2002:map",
|
|
2127
|
-
resolve(
|
|
2128
|
-
if (!identity.isMap(
|
|
2127
|
+
resolve(map, onError) {
|
|
2128
|
+
if (!identity.isMap(map))
|
|
2129
2129
|
onError("Expected a mapping for this tag");
|
|
2130
|
-
return
|
|
2130
|
+
return map;
|
|
2131
2131
|
},
|
|
2132
2132
|
createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
|
|
2133
2133
|
};
|
|
@@ -2186,9 +2186,9 @@ var require_YAMLSeq = __commonJS(function(exports) {
|
|
|
2186
2186
|
const seq = [];
|
|
2187
2187
|
if (ctx?.onCreate)
|
|
2188
2188
|
ctx.onCreate(seq);
|
|
2189
|
-
let
|
|
2189
|
+
let i = 0;
|
|
2190
2190
|
for (const item of this.items)
|
|
2191
|
-
seq.push(toJS.toJS(item, String(
|
|
2191
|
+
seq.push(toJS.toJS(item, String(i++), ctx));
|
|
2192
2192
|
return seq;
|
|
2193
2193
|
}
|
|
2194
2194
|
toString(ctx, onComment, onChompKeep) {
|
|
@@ -2206,10 +2206,10 @@ var require_YAMLSeq = __commonJS(function(exports) {
|
|
|
2206
2206
|
const { replacer } = ctx;
|
|
2207
2207
|
const seq = new this(schema);
|
|
2208
2208
|
if (obj && Symbol.iterator in Object(obj)) {
|
|
2209
|
-
let
|
|
2209
|
+
let i = 0;
|
|
2210
2210
|
for (let it of obj) {
|
|
2211
2211
|
if (typeof replacer === "function") {
|
|
2212
|
-
const key = obj instanceof Set ? it : String(
|
|
2212
|
+
const key = obj instanceof Set ? it : String(i++);
|
|
2213
2213
|
it = replacer.call(obj, key, it);
|
|
2214
2214
|
}
|
|
2215
2215
|
seq.items.push(createNode.createNode(it, undefined, ctx));
|
|
@@ -2236,10 +2236,10 @@ var require_seq = __commonJS(function(exports) {
|
|
|
2236
2236
|
default: true,
|
|
2237
2237
|
nodeClass: YAMLSeq.YAMLSeq,
|
|
2238
2238
|
tag: "tag:yaml.org,2002:seq",
|
|
2239
|
-
resolve(
|
|
2240
|
-
if (!identity.isSeq(
|
|
2239
|
+
resolve(seq, onError) {
|
|
2240
|
+
if (!identity.isSeq(seq))
|
|
2241
2241
|
onError("Expected a sequence for this tag");
|
|
2242
|
-
return
|
|
2242
|
+
return seq;
|
|
2243
2243
|
},
|
|
2244
2244
|
createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx)
|
|
2245
2245
|
};
|
|
@@ -2306,18 +2306,18 @@ var require_stringifyNumber = __commonJS(function(exports) {
|
|
|
2306
2306
|
const num = typeof value === "number" ? value : Number(value);
|
|
2307
2307
|
if (!isFinite(num))
|
|
2308
2308
|
return isNaN(num) ? ".nan" : num < 0 ? "-.inf" : ".inf";
|
|
2309
|
-
let
|
|
2310
|
-
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(
|
|
2311
|
-
let
|
|
2312
|
-
if (
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
}
|
|
2316
|
-
let d = minFractionDigits - (
|
|
2309
|
+
let n = Object.is(value, -0) ? "-0" : JSON.stringify(value);
|
|
2310
|
+
if (!format && minFractionDigits && (!tag || tag === "tag:yaml.org,2002:float") && /^-?\d/.test(n) && !n.includes("e")) {
|
|
2311
|
+
let i = n.indexOf(".");
|
|
2312
|
+
if (i < 0) {
|
|
2313
|
+
i = n.length;
|
|
2314
|
+
n += ".";
|
|
2315
|
+
}
|
|
2316
|
+
let d = minFractionDigits - (n.length - i - 1);
|
|
2317
2317
|
while (d-- > 0)
|
|
2318
|
-
|
|
2318
|
+
n += "0";
|
|
2319
2319
|
}
|
|
2320
|
-
return
|
|
2320
|
+
return n;
|
|
2321
2321
|
}
|
|
2322
2322
|
exports.stringifyNumber = stringifyNumber;
|
|
2323
2323
|
});
|
|
@@ -2511,8 +2511,8 @@ var require_binary = __commonJS(function(exports) {
|
|
|
2511
2511
|
} else if (typeof atob === "function") {
|
|
2512
2512
|
const str = atob(src.replace(/[\n\r]/g, ""));
|
|
2513
2513
|
const buffer = new Uint8Array(str.length);
|
|
2514
|
-
for (let
|
|
2515
|
-
buffer[
|
|
2514
|
+
for (let i = 0;i < str.length; ++i)
|
|
2515
|
+
buffer[i] = str.charCodeAt(i);
|
|
2516
2516
|
return buffer;
|
|
2517
2517
|
} else {
|
|
2518
2518
|
onError("This environment does not support reading binary tags; either Buffer or atob is required");
|
|
@@ -2522,14 +2522,14 @@ var require_binary = __commonJS(function(exports) {
|
|
|
2522
2522
|
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
2523
2523
|
if (!value)
|
|
2524
2524
|
return "";
|
|
2525
|
-
const
|
|
2525
|
+
const buf = value;
|
|
2526
2526
|
let str;
|
|
2527
2527
|
if (typeof node_buffer.Buffer === "function") {
|
|
2528
|
-
str =
|
|
2528
|
+
str = buf instanceof node_buffer.Buffer ? buf.toString("base64") : node_buffer.Buffer.from(buf.buffer).toString("base64");
|
|
2529
2529
|
} else if (typeof btoa === "function") {
|
|
2530
2530
|
let s = "";
|
|
2531
|
-
for (let
|
|
2532
|
-
s += String.fromCharCode(
|
|
2531
|
+
for (let i = 0;i < buf.length; ++i)
|
|
2532
|
+
s += String.fromCharCode(buf[i]);
|
|
2533
2533
|
str = btoa(s);
|
|
2534
2534
|
} else {
|
|
2535
2535
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
@@ -2537,10 +2537,10 @@ var require_binary = __commonJS(function(exports) {
|
|
|
2537
2537
|
type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
|
|
2538
2538
|
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
2539
2539
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
2540
|
-
const
|
|
2541
|
-
const lines = new Array(
|
|
2542
|
-
for (let
|
|
2543
|
-
lines[
|
|
2540
|
+
const n = Math.ceil(str.length / lineWidth);
|
|
2541
|
+
const lines = new Array(n);
|
|
2542
|
+
for (let i = 0, o = 0;i < n; ++i, o += lineWidth) {
|
|
2543
|
+
lines[i] = str.substr(o, lineWidth);
|
|
2544
2544
|
}
|
|
2545
2545
|
str = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? `
|
|
2546
2546
|
` : " ");
|
|
@@ -2559,8 +2559,8 @@ var require_pairs = __commonJS(function(exports) {
|
|
|
2559
2559
|
var YAMLSeq = require_YAMLSeq();
|
|
2560
2560
|
function resolvePairs(seq, onError) {
|
|
2561
2561
|
if (identity.isSeq(seq)) {
|
|
2562
|
-
for (let
|
|
2563
|
-
let item = seq.items[
|
|
2562
|
+
for (let i = 0;i < seq.items.length; ++i) {
|
|
2563
|
+
let item = seq.items[i];
|
|
2564
2564
|
if (identity.isPair(item))
|
|
2565
2565
|
continue;
|
|
2566
2566
|
else if (identity.isMap(item)) {
|
|
@@ -2577,7 +2577,7 @@ ${cn.comment}` : item.comment;
|
|
|
2577
2577
|
}
|
|
2578
2578
|
item = pair;
|
|
2579
2579
|
}
|
|
2580
|
-
seq.items[
|
|
2580
|
+
seq.items[i] = identity.isPair(item) ? item : new Pair.Pair(item);
|
|
2581
2581
|
}
|
|
2582
2582
|
} else
|
|
2583
2583
|
onError("Expected a sequence for this tag");
|
|
@@ -2585,13 +2585,13 @@ ${cn.comment}` : item.comment;
|
|
|
2585
2585
|
}
|
|
2586
2586
|
function createPairs(schema, iterable, ctx) {
|
|
2587
2587
|
const { replacer } = ctx;
|
|
2588
|
-
const
|
|
2589
|
-
|
|
2590
|
-
let
|
|
2588
|
+
const pairs = new YAMLSeq.YAMLSeq(schema);
|
|
2589
|
+
pairs.tag = "tag:yaml.org,2002:pairs";
|
|
2590
|
+
let i = 0;
|
|
2591
2591
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
2592
2592
|
for (let it of iterable) {
|
|
2593
2593
|
if (typeof replacer === "function")
|
|
2594
|
-
it = replacer.call(iterable, String(
|
|
2594
|
+
it = replacer.call(iterable, String(i++), it);
|
|
2595
2595
|
let key, value;
|
|
2596
2596
|
if (Array.isArray(it)) {
|
|
2597
2597
|
if (it.length === 2) {
|
|
@@ -2610,9 +2610,9 @@ ${cn.comment}` : item.comment;
|
|
|
2610
2610
|
} else {
|
|
2611
2611
|
key = it;
|
|
2612
2612
|
}
|
|
2613
|
-
|
|
2613
|
+
pairs.items.push(Pair.createPair(key, value, ctx));
|
|
2614
2614
|
}
|
|
2615
|
-
return
|
|
2615
|
+
return pairs;
|
|
2616
2616
|
}
|
|
2617
2617
|
var pairs = {
|
|
2618
2618
|
collection: "seq",
|
|
@@ -2666,9 +2666,9 @@ var require_omap = __commonJS(function(exports) {
|
|
|
2666
2666
|
}
|
|
2667
2667
|
static from(schema, iterable, ctx) {
|
|
2668
2668
|
const pairs$1 = pairs.createPairs(schema, iterable, ctx);
|
|
2669
|
-
const
|
|
2670
|
-
|
|
2671
|
-
return
|
|
2669
|
+
const omap = new this;
|
|
2670
|
+
omap.items = pairs$1.items;
|
|
2671
|
+
return omap;
|
|
2672
2672
|
}
|
|
2673
2673
|
}
|
|
2674
2674
|
YAMLOMap.tag = "tag:yaml.org,2002:omap";
|
|
@@ -2794,11 +2794,11 @@ var require_int2 = __commonJS(function(exports) {
|
|
|
2794
2794
|
str = `0x${str}`;
|
|
2795
2795
|
break;
|
|
2796
2796
|
}
|
|
2797
|
-
const
|
|
2798
|
-
return sign === "-" ? BigInt(-1) *
|
|
2797
|
+
const n = BigInt(str);
|
|
2798
|
+
return sign === "-" ? BigInt(-1) * n : n;
|
|
2799
2799
|
}
|
|
2800
|
-
const
|
|
2801
|
-
return sign === "-" ? -1 *
|
|
2800
|
+
const n = parseInt(str, radix);
|
|
2801
|
+
return sign === "-" ? -1 * n : n;
|
|
2802
2802
|
}
|
|
2803
2803
|
function intStringify(node, radix, prefix) {
|
|
2804
2804
|
const { value } = node;
|
|
@@ -2899,14 +2899,14 @@ var require_set = __commonJS(function(exports) {
|
|
|
2899
2899
|
}
|
|
2900
2900
|
static from(schema, iterable, ctx) {
|
|
2901
2901
|
const { replacer } = ctx;
|
|
2902
|
-
const
|
|
2902
|
+
const set = new this(schema);
|
|
2903
2903
|
if (iterable && Symbol.iterator in Object(iterable))
|
|
2904
2904
|
for (let value of iterable) {
|
|
2905
2905
|
if (typeof replacer === "function")
|
|
2906
2906
|
value = replacer.call(iterable, value, value);
|
|
2907
|
-
|
|
2907
|
+
set.items.push(Pair.createPair(value, null, ctx));
|
|
2908
2908
|
}
|
|
2909
|
-
return
|
|
2909
|
+
return set;
|
|
2910
2910
|
}
|
|
2911
2911
|
}
|
|
2912
2912
|
YAMLSet.tag = "tag:yaml.org,2002:set";
|
|
@@ -2938,15 +2938,15 @@ var require_timestamp = __commonJS(function(exports) {
|
|
|
2938
2938
|
function parseSexagesimal(str, asBigInt) {
|
|
2939
2939
|
const sign = str[0];
|
|
2940
2940
|
const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
|
|
2941
|
-
const num = (
|
|
2942
|
-
const res = parts.replace(/_/g, "").split(":").reduce((
|
|
2941
|
+
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
2942
|
+
const res = parts.replace(/_/g, "").split(":").reduce((res, p) => res * num(60) + num(p), num(0));
|
|
2943
2943
|
return sign === "-" ? num(-1) * res : res;
|
|
2944
2944
|
}
|
|
2945
2945
|
function stringifySexagesimal(node) {
|
|
2946
2946
|
let { value } = node;
|
|
2947
|
-
let num = (
|
|
2947
|
+
let num = (n) => n;
|
|
2948
2948
|
if (typeof value === "bigint")
|
|
2949
|
-
num = (
|
|
2949
|
+
num = (n) => BigInt(n);
|
|
2950
2950
|
else if (isNaN(value) || !isFinite(value))
|
|
2951
2951
|
return stringifyNumber.stringifyNumber(node);
|
|
2952
2952
|
let sign = "";
|
|
@@ -2966,7 +2966,7 @@ var require_timestamp = __commonJS(function(exports) {
|
|
|
2966
2966
|
parts.unshift(value);
|
|
2967
2967
|
}
|
|
2968
2968
|
}
|
|
2969
|
-
return sign + parts.map((
|
|
2969
|
+
return sign + parts.map((n) => String(n).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
|
|
2970
2970
|
}
|
|
2971
2971
|
var intTime = {
|
|
2972
2972
|
identify: (value) => typeof value === "bigint" || Number.isInteger(value),
|
|
@@ -3130,16 +3130,16 @@ var require_tags = __commonJS(function(exports) {
|
|
|
3130
3130
|
}
|
|
3131
3131
|
if (addMergeTag)
|
|
3132
3132
|
tags = tags.concat(merge.merge);
|
|
3133
|
-
return tags.reduce((
|
|
3133
|
+
return tags.reduce((tags, tag) => {
|
|
3134
3134
|
const tagObj = typeof tag === "string" ? tagsByName[tag] : tag;
|
|
3135
3135
|
if (!tagObj) {
|
|
3136
3136
|
const tagName = JSON.stringify(tag);
|
|
3137
3137
|
const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
|
|
3138
3138
|
throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
|
|
3139
3139
|
}
|
|
3140
|
-
if (!
|
|
3141
|
-
|
|
3142
|
-
return
|
|
3140
|
+
if (!tags.includes(tagObj))
|
|
3141
|
+
tags.push(tagObj);
|
|
3142
|
+
return tags;
|
|
3143
3143
|
}, []);
|
|
3144
3144
|
}
|
|
3145
3145
|
exports.coreKnownTags = coreKnownTags;
|
|
@@ -3153,7 +3153,7 @@ var require_Schema = __commonJS(function(exports) {
|
|
|
3153
3153
|
var seq = require_seq();
|
|
3154
3154
|
var string = require_string();
|
|
3155
3155
|
var tags = require_tags();
|
|
3156
|
-
var sortMapEntriesByKey = (
|
|
3156
|
+
var sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
3157
3157
|
|
|
3158
3158
|
class Schema {
|
|
3159
3159
|
constructor({ compat, customTags, merge, resolveKnownTags, schema, sortMapEntries, toStringDefaults }) {
|
|
@@ -3466,8 +3466,8 @@ var require_Document = __commonJS(function(exports) {
|
|
|
3466
3466
|
};
|
|
3467
3467
|
const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
|
|
3468
3468
|
if (typeof onAnchor === "function")
|
|
3469
|
-
for (const { count, res
|
|
3470
|
-
onAnchor(
|
|
3469
|
+
for (const { count, res } of ctx.anchors.values())
|
|
3470
|
+
onAnchor(res, count);
|
|
3471
3471
|
return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
|
|
3472
3472
|
}
|
|
3473
3473
|
toJSON(jsonArg, onAnchor) {
|
|
@@ -3748,7 +3748,7 @@ var require_util_map_includes = __commonJS(function(exports) {
|
|
|
3748
3748
|
const { uniqueKeys } = ctx.options;
|
|
3749
3749
|
if (uniqueKeys === false)
|
|
3750
3750
|
return false;
|
|
3751
|
-
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (
|
|
3751
|
+
const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || identity.isScalar(a) && identity.isScalar(b) && a.value === b.value;
|
|
3752
3752
|
return items.some((pair) => isEqual(pair.key, search));
|
|
3753
3753
|
}
|
|
3754
3754
|
exports.mapIncludes = mapIncludes;
|
|
@@ -3771,10 +3771,10 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
3771
3771
|
let offset = bm.offset;
|
|
3772
3772
|
let commentEnd = null;
|
|
3773
3773
|
for (const collItem of bm.items) {
|
|
3774
|
-
const { start, key, sep
|
|
3774
|
+
const { start, key, sep, value } = collItem;
|
|
3775
3775
|
const keyProps = resolveProps.resolveProps(start, {
|
|
3776
3776
|
indicator: "explicit-key-ind",
|
|
3777
|
-
next: key ??
|
|
3777
|
+
next: key ?? sep?.[0],
|
|
3778
3778
|
offset,
|
|
3779
3779
|
onError,
|
|
3780
3780
|
parentIndent: bm.indent,
|
|
@@ -3788,7 +3788,7 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
3788
3788
|
else if ("indent" in key && key.indent !== bm.indent)
|
|
3789
3789
|
onError(offset, "BAD_INDENT", startColMsg);
|
|
3790
3790
|
}
|
|
3791
|
-
if (!keyProps.anchor && !keyProps.tag && !
|
|
3791
|
+
if (!keyProps.anchor && !keyProps.tag && !sep) {
|
|
3792
3792
|
commentEnd = keyProps.end;
|
|
3793
3793
|
if (keyProps.comment) {
|
|
3794
3794
|
if (map.comment)
|
|
@@ -3813,7 +3813,7 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
3813
3813
|
ctx.atKey = false;
|
|
3814
3814
|
if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
|
|
3815
3815
|
onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
|
|
3816
|
-
const valueProps = resolveProps.resolveProps(
|
|
3816
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
3817
3817
|
indicator: "map-value-ind",
|
|
3818
3818
|
next: value,
|
|
3819
3819
|
offset: keyNode.range[2],
|
|
@@ -3829,7 +3829,7 @@ var require_resolve_block_map = __commonJS(function(exports) {
|
|
|
3829
3829
|
if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
|
|
3830
3830
|
onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
|
|
3831
3831
|
}
|
|
3832
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset,
|
|
3832
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
|
|
3833
3833
|
if (ctx.schema.compat)
|
|
3834
3834
|
utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
|
|
3835
3835
|
offset = valueNode.range[2];
|
|
@@ -3915,7 +3915,7 @@ var require_resolve_end = __commonJS(function(exports) {
|
|
|
3915
3915
|
let comment = "";
|
|
3916
3916
|
if (end) {
|
|
3917
3917
|
let hasSpace = false;
|
|
3918
|
-
let
|
|
3918
|
+
let sep = "";
|
|
3919
3919
|
for (const token of end) {
|
|
3920
3920
|
const { source, type } = token;
|
|
3921
3921
|
switch (type) {
|
|
@@ -3929,13 +3929,13 @@ var require_resolve_end = __commonJS(function(exports) {
|
|
|
3929
3929
|
if (!comment)
|
|
3930
3930
|
comment = cb;
|
|
3931
3931
|
else
|
|
3932
|
-
comment +=
|
|
3933
|
-
|
|
3932
|
+
comment += sep + cb;
|
|
3933
|
+
sep = "";
|
|
3934
3934
|
break;
|
|
3935
3935
|
}
|
|
3936
3936
|
case "newline":
|
|
3937
3937
|
if (comment)
|
|
3938
|
-
|
|
3938
|
+
sep += source;
|
|
3939
3939
|
hasSpace = true;
|
|
3940
3940
|
break;
|
|
3941
3941
|
default:
|
|
@@ -3973,23 +3973,23 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
3973
3973
|
if (ctx.atKey)
|
|
3974
3974
|
ctx.atKey = false;
|
|
3975
3975
|
let offset = fc.offset + fc.start.source.length;
|
|
3976
|
-
for (let
|
|
3977
|
-
const collItem = fc.items[
|
|
3978
|
-
const { start, key, sep
|
|
3976
|
+
for (let i = 0;i < fc.items.length; ++i) {
|
|
3977
|
+
const collItem = fc.items[i];
|
|
3978
|
+
const { start, key, sep, value } = collItem;
|
|
3979
3979
|
const props = resolveProps.resolveProps(start, {
|
|
3980
3980
|
flow: fcName,
|
|
3981
3981
|
indicator: "explicit-key-ind",
|
|
3982
|
-
next: key ??
|
|
3982
|
+
next: key ?? sep?.[0],
|
|
3983
3983
|
offset,
|
|
3984
3984
|
onError,
|
|
3985
3985
|
parentIndent: fc.indent,
|
|
3986
3986
|
startOnNewline: false
|
|
3987
3987
|
});
|
|
3988
3988
|
if (!props.found) {
|
|
3989
|
-
if (!props.anchor && !props.tag && !
|
|
3990
|
-
if (
|
|
3989
|
+
if (!props.anchor && !props.tag && !sep && !value) {
|
|
3990
|
+
if (i === 0 && props.comma)
|
|
3991
3991
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
3992
|
-
else if (
|
|
3992
|
+
else if (i < fc.items.length - 1)
|
|
3993
3993
|
onError(props.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${fcName}`);
|
|
3994
3994
|
if (props.comment) {
|
|
3995
3995
|
if (coll.comment)
|
|
@@ -4004,7 +4004,7 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
4004
4004
|
if (!isMap && ctx.options.strict && utilContainsNewline.containsNewline(key))
|
|
4005
4005
|
onError(key, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
|
|
4006
4006
|
}
|
|
4007
|
-
if (
|
|
4007
|
+
if (i === 0) {
|
|
4008
4008
|
if (props.comma)
|
|
4009
4009
|
onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
|
|
4010
4010
|
} else {
|
|
@@ -4038,8 +4038,8 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
4038
4038
|
}
|
|
4039
4039
|
}
|
|
4040
4040
|
}
|
|
4041
|
-
if (!isMap && !
|
|
4042
|
-
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end,
|
|
4041
|
+
if (!isMap && !sep && !props.found) {
|
|
4042
|
+
const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError);
|
|
4043
4043
|
coll.items.push(valueNode);
|
|
4044
4044
|
offset = valueNode.range[2];
|
|
4045
4045
|
if (isBlock(value))
|
|
@@ -4051,7 +4051,7 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
4051
4051
|
if (isBlock(key))
|
|
4052
4052
|
onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
4053
4053
|
ctx.atKey = false;
|
|
4054
|
-
const valueProps = resolveProps.resolveProps(
|
|
4054
|
+
const valueProps = resolveProps.resolveProps(sep ?? [], {
|
|
4055
4055
|
flow: fcName,
|
|
4056
4056
|
indicator: "map-value-ind",
|
|
4057
4057
|
next: value,
|
|
@@ -4062,8 +4062,8 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
4062
4062
|
});
|
|
4063
4063
|
if (valueProps.found) {
|
|
4064
4064
|
if (!isMap && !props.found && ctx.options.strict) {
|
|
4065
|
-
if (
|
|
4066
|
-
for (const st of
|
|
4065
|
+
if (sep)
|
|
4066
|
+
for (const st of sep) {
|
|
4067
4067
|
if (st === valueProps.found)
|
|
4068
4068
|
break;
|
|
4069
4069
|
if (st.type === "newline") {
|
|
@@ -4080,7 +4080,7 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
|
|
|
4080
4080
|
else
|
|
4081
4081
|
onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
|
|
4082
4082
|
}
|
|
4083
|
-
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end,
|
|
4083
|
+
const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) : null;
|
|
4084
4084
|
if (valueNode) {
|
|
4085
4085
|
if (isBlock(value))
|
|
4086
4086
|
onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
|
|
@@ -4175,7 +4175,7 @@ var require_compose_collection = __commonJS(function(exports) {
|
|
|
4175
4175
|
if (!tagToken || !tagName || tagName === "!" || tagName === YAMLMap.YAMLMap.tagName && expType === "map" || tagName === YAMLSeq.YAMLSeq.tagName && expType === "seq") {
|
|
4176
4176
|
return resolveCollection(CN, ctx, token, onError, tagName);
|
|
4177
4177
|
}
|
|
4178
|
-
let tag = ctx.schema.tags.find((
|
|
4178
|
+
let tag = ctx.schema.tags.find((t) => t.tag === tagName && t.collection === expType);
|
|
4179
4179
|
if (!tag) {
|
|
4180
4180
|
const kt = ctx.schema.knownTags[tagName];
|
|
4181
4181
|
if (kt?.collection === expType) {
|
|
@@ -4213,26 +4213,26 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4213
4213
|
const type = header.mode === ">" ? Scalar.Scalar.BLOCK_FOLDED : Scalar.Scalar.BLOCK_LITERAL;
|
|
4214
4214
|
const lines = scalar.source ? splitLines(scalar.source) : [];
|
|
4215
4215
|
let chompStart = lines.length;
|
|
4216
|
-
for (let
|
|
4217
|
-
const content = lines[
|
|
4216
|
+
for (let i = lines.length - 1;i >= 0; --i) {
|
|
4217
|
+
const content = lines[i][1];
|
|
4218
4218
|
if (content === "" || content === "\r")
|
|
4219
|
-
chompStart =
|
|
4219
|
+
chompStart = i;
|
|
4220
4220
|
else
|
|
4221
4221
|
break;
|
|
4222
4222
|
}
|
|
4223
4223
|
if (chompStart === 0) {
|
|
4224
|
-
const
|
|
4224
|
+
const value = header.chomp === "+" && lines.length > 0 ? `
|
|
4225
4225
|
`.repeat(Math.max(1, lines.length - 1)) : "";
|
|
4226
|
-
let
|
|
4226
|
+
let end = start + header.length;
|
|
4227
4227
|
if (scalar.source)
|
|
4228
|
-
|
|
4229
|
-
return { value
|
|
4228
|
+
end += scalar.source.length;
|
|
4229
|
+
return { value, type, comment: header.comment, range: [start, end, end] };
|
|
4230
4230
|
}
|
|
4231
4231
|
let trimIndent = scalar.indent + header.indent;
|
|
4232
4232
|
let offset = scalar.offset + header.length;
|
|
4233
4233
|
let contentStart = 0;
|
|
4234
|
-
for (let
|
|
4235
|
-
const [indent, content] = lines[
|
|
4234
|
+
for (let i = 0;i < chompStart; ++i) {
|
|
4235
|
+
const [indent, content] = lines[i];
|
|
4236
4236
|
if (content === "" || content === "\r") {
|
|
4237
4237
|
if (header.indent === 0 && indent.length > trimIndent)
|
|
4238
4238
|
trimIndent = indent.length;
|
|
@@ -4243,7 +4243,7 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4243
4243
|
}
|
|
4244
4244
|
if (header.indent === 0)
|
|
4245
4245
|
trimIndent = indent.length;
|
|
4246
|
-
contentStart =
|
|
4246
|
+
contentStart = i;
|
|
4247
4247
|
if (trimIndent === 0 && !ctx.atRoot) {
|
|
4248
4248
|
const message = "Block scalar values in collections must be indented";
|
|
4249
4249
|
onError(offset, "BAD_INDENT", message);
|
|
@@ -4252,18 +4252,18 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4252
4252
|
}
|
|
4253
4253
|
offset += indent.length + content.length + 1;
|
|
4254
4254
|
}
|
|
4255
|
-
for (let
|
|
4256
|
-
if (lines[
|
|
4257
|
-
chompStart =
|
|
4255
|
+
for (let i = lines.length - 1;i >= chompStart; --i) {
|
|
4256
|
+
if (lines[i][0].length > trimIndent)
|
|
4257
|
+
chompStart = i + 1;
|
|
4258
4258
|
}
|
|
4259
4259
|
let value = "";
|
|
4260
|
-
let
|
|
4260
|
+
let sep = "";
|
|
4261
4261
|
let prevMoreIndented = false;
|
|
4262
|
-
for (let
|
|
4263
|
-
value += lines[
|
|
4262
|
+
for (let i = 0;i < contentStart; ++i)
|
|
4263
|
+
value += lines[i][0].slice(trimIndent) + `
|
|
4264
4264
|
`;
|
|
4265
|
-
for (let
|
|
4266
|
-
let [indent, content] = lines[
|
|
4265
|
+
for (let i = contentStart;i < chompStart; ++i) {
|
|
4266
|
+
let [indent, content] = lines[i];
|
|
4267
4267
|
offset += indent.length + content.length + 1;
|
|
4268
4268
|
const crlf = content[content.length - 1] === "\r";
|
|
4269
4269
|
if (crlf)
|
|
@@ -4275,33 +4275,33 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4275
4275
|
indent = "";
|
|
4276
4276
|
}
|
|
4277
4277
|
if (type === Scalar.Scalar.BLOCK_LITERAL) {
|
|
4278
|
-
value +=
|
|
4279
|
-
|
|
4278
|
+
value += sep + indent.slice(trimIndent) + content;
|
|
4279
|
+
sep = `
|
|
4280
4280
|
`;
|
|
4281
4281
|
} else if (indent.length > trimIndent || content[0] === "\t") {
|
|
4282
|
-
if (
|
|
4283
|
-
|
|
4282
|
+
if (sep === " ")
|
|
4283
|
+
sep = `
|
|
4284
4284
|
`;
|
|
4285
|
-
else if (!prevMoreIndented &&
|
|
4285
|
+
else if (!prevMoreIndented && sep === `
|
|
4286
4286
|
`)
|
|
4287
|
-
|
|
4287
|
+
sep = `
|
|
4288
4288
|
|
|
4289
4289
|
`;
|
|
4290
|
-
value +=
|
|
4291
|
-
|
|
4290
|
+
value += sep + indent.slice(trimIndent) + content;
|
|
4291
|
+
sep = `
|
|
4292
4292
|
`;
|
|
4293
4293
|
prevMoreIndented = true;
|
|
4294
4294
|
} else if (content === "") {
|
|
4295
|
-
if (
|
|
4295
|
+
if (sep === `
|
|
4296
4296
|
`)
|
|
4297
4297
|
value += `
|
|
4298
4298
|
`;
|
|
4299
4299
|
else
|
|
4300
|
-
|
|
4300
|
+
sep = `
|
|
4301
4301
|
`;
|
|
4302
4302
|
} else {
|
|
4303
|
-
value +=
|
|
4304
|
-
|
|
4303
|
+
value += sep + content;
|
|
4304
|
+
sep = " ";
|
|
4305
4305
|
prevMoreIndented = false;
|
|
4306
4306
|
}
|
|
4307
4307
|
}
|
|
@@ -4309,9 +4309,9 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4309
4309
|
case "-":
|
|
4310
4310
|
break;
|
|
4311
4311
|
case "+":
|
|
4312
|
-
for (let
|
|
4312
|
+
for (let i = chompStart;i < lines.length; ++i)
|
|
4313
4313
|
value += `
|
|
4314
|
-
` + lines[
|
|
4314
|
+
` + lines[i][0].slice(trimIndent);
|
|
4315
4315
|
if (value[value.length - 1] !== `
|
|
4316
4316
|
`)
|
|
4317
4317
|
value += `
|
|
@@ -4334,16 +4334,16 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4334
4334
|
let indent = 0;
|
|
4335
4335
|
let chomp = "";
|
|
4336
4336
|
let error = -1;
|
|
4337
|
-
for (let
|
|
4338
|
-
const ch = source[
|
|
4337
|
+
for (let i = 1;i < source.length; ++i) {
|
|
4338
|
+
const ch = source[i];
|
|
4339
4339
|
if (!chomp && (ch === "-" || ch === "+"))
|
|
4340
4340
|
chomp = ch;
|
|
4341
4341
|
else {
|
|
4342
|
-
const
|
|
4343
|
-
if (!indent &&
|
|
4344
|
-
indent =
|
|
4342
|
+
const n = Number(ch);
|
|
4343
|
+
if (!indent && n)
|
|
4344
|
+
indent = n;
|
|
4345
4345
|
else if (error === -1)
|
|
4346
|
-
error = offset +
|
|
4346
|
+
error = offset + i;
|
|
4347
4347
|
}
|
|
4348
4348
|
}
|
|
4349
4349
|
if (error !== -1)
|
|
@@ -4351,8 +4351,8 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4351
4351
|
let hasSpace = false;
|
|
4352
4352
|
let comment = "";
|
|
4353
4353
|
let length = source.length;
|
|
4354
|
-
for (let
|
|
4355
|
-
const token = props[
|
|
4354
|
+
for (let i = 1;i < props.length; ++i) {
|
|
4355
|
+
const token = props[i];
|
|
4356
4356
|
switch (token.type) {
|
|
4357
4357
|
case "space":
|
|
4358
4358
|
hasSpace = true;
|
|
@@ -4388,8 +4388,8 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
|
|
|
4388
4388
|
const m = first.match(/^( *)/);
|
|
4389
4389
|
const line0 = m?.[1] ? [m[1], first.slice(m[1].length)] : ["", first];
|
|
4390
4390
|
const lines = [line0];
|
|
4391
|
-
for (let
|
|
4392
|
-
lines.push([split[
|
|
4391
|
+
for (let i = 1;i < split.length; i += 2)
|
|
4392
|
+
lines.push([split[i], split[i + 1]]);
|
|
4393
4393
|
return lines;
|
|
4394
4394
|
}
|
|
4395
4395
|
exports.resolveBlockScalar = resolveBlockScalar;
|
|
@@ -4482,73 +4482,73 @@ var require_resolve_flow_scalar = __commonJS(function(exports) {
|
|
|
4482
4482
|
if (!match)
|
|
4483
4483
|
return source;
|
|
4484
4484
|
let res = match[1];
|
|
4485
|
-
let
|
|
4485
|
+
let sep = " ";
|
|
4486
4486
|
let pos = first.lastIndex;
|
|
4487
4487
|
line.lastIndex = pos;
|
|
4488
4488
|
while (match = line.exec(source)) {
|
|
4489
4489
|
if (match[1] === "") {
|
|
4490
|
-
if (
|
|
4490
|
+
if (sep === `
|
|
4491
4491
|
`)
|
|
4492
|
-
res +=
|
|
4492
|
+
res += sep;
|
|
4493
4493
|
else
|
|
4494
|
-
|
|
4494
|
+
sep = `
|
|
4495
4495
|
`;
|
|
4496
4496
|
} else {
|
|
4497
|
-
res +=
|
|
4498
|
-
|
|
4497
|
+
res += sep + match[1];
|
|
4498
|
+
sep = " ";
|
|
4499
4499
|
}
|
|
4500
4500
|
pos = line.lastIndex;
|
|
4501
4501
|
}
|
|
4502
4502
|
const last = /[ \t]*(.*)/sy;
|
|
4503
4503
|
last.lastIndex = pos;
|
|
4504
4504
|
match = last.exec(source);
|
|
4505
|
-
return res +
|
|
4505
|
+
return res + sep + (match?.[1] ?? "");
|
|
4506
4506
|
}
|
|
4507
4507
|
function doubleQuotedValue(source, onError) {
|
|
4508
4508
|
let res = "";
|
|
4509
|
-
for (let
|
|
4510
|
-
const ch = source[
|
|
4511
|
-
if (ch === "\r" && source[
|
|
4509
|
+
for (let i = 1;i < source.length - 1; ++i) {
|
|
4510
|
+
const ch = source[i];
|
|
4511
|
+
if (ch === "\r" && source[i + 1] === `
|
|
4512
4512
|
`)
|
|
4513
4513
|
continue;
|
|
4514
4514
|
if (ch === `
|
|
4515
4515
|
`) {
|
|
4516
|
-
const { fold, offset } = foldNewline(source,
|
|
4516
|
+
const { fold, offset } = foldNewline(source, i);
|
|
4517
4517
|
res += fold;
|
|
4518
|
-
|
|
4518
|
+
i = offset;
|
|
4519
4519
|
} else if (ch === "\\") {
|
|
4520
|
-
let next = source[++
|
|
4520
|
+
let next = source[++i];
|
|
4521
4521
|
const cc = escapeCodes[next];
|
|
4522
4522
|
if (cc)
|
|
4523
4523
|
res += cc;
|
|
4524
4524
|
else if (next === `
|
|
4525
4525
|
`) {
|
|
4526
|
-
next = source[
|
|
4526
|
+
next = source[i + 1];
|
|
4527
4527
|
while (next === " " || next === "\t")
|
|
4528
|
-
next = source[++
|
|
4529
|
-
} else if (next === "\r" && source[
|
|
4528
|
+
next = source[++i + 1];
|
|
4529
|
+
} else if (next === "\r" && source[i + 1] === `
|
|
4530
4530
|
`) {
|
|
4531
|
-
next = source[++
|
|
4531
|
+
next = source[++i + 1];
|
|
4532
4532
|
while (next === " " || next === "\t")
|
|
4533
|
-
next = source[++
|
|
4533
|
+
next = source[++i + 1];
|
|
4534
4534
|
} else if (next === "x" || next === "u" || next === "U") {
|
|
4535
4535
|
const length = next === "x" ? 2 : next === "u" ? 4 : 8;
|
|
4536
|
-
res += parseCharCode(source,
|
|
4537
|
-
|
|
4536
|
+
res += parseCharCode(source, i + 1, length, onError);
|
|
4537
|
+
i += length;
|
|
4538
4538
|
} else {
|
|
4539
|
-
const raw = source.substr(
|
|
4540
|
-
onError(
|
|
4539
|
+
const raw = source.substr(i - 1, 2);
|
|
4540
|
+
onError(i - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
4541
4541
|
res += raw;
|
|
4542
4542
|
}
|
|
4543
4543
|
} else if (ch === " " || ch === "\t") {
|
|
4544
|
-
const wsStart =
|
|
4545
|
-
let next = source[
|
|
4544
|
+
const wsStart = i;
|
|
4545
|
+
let next = source[i + 1];
|
|
4546
4546
|
while (next === " " || next === "\t")
|
|
4547
|
-
next = source[++
|
|
4547
|
+
next = source[++i + 1];
|
|
4548
4548
|
if (next !== `
|
|
4549
|
-
` && !(next === "\r" && source[
|
|
4549
|
+
` && !(next === "\r" && source[i + 2] === `
|
|
4550
4550
|
`))
|
|
4551
|
-
res +=
|
|
4551
|
+
res += i > wsStart ? source.slice(wsStart, i + 1) : ch;
|
|
4552
4552
|
} else {
|
|
4553
4553
|
res += ch;
|
|
4554
4554
|
}
|
|
@@ -4675,9 +4675,9 @@ var require_compose_scalar = __commonJS(function(exports) {
|
|
|
4675
4675
|
return schema[identity.SCALAR];
|
|
4676
4676
|
}
|
|
4677
4677
|
function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
|
|
4678
|
-
const tag = schema.tags.find((
|
|
4678
|
+
const tag = schema.tags.find((tag) => (tag.default === true || atKey && tag.default === "key") && tag.test?.test(value)) || schema[identity.SCALAR];
|
|
4679
4679
|
if (schema.compat) {
|
|
4680
|
-
const compat = schema.compat.find((
|
|
4680
|
+
const compat = schema.compat.find((tag) => tag.default && tag.test?.test(value)) ?? schema[identity.SCALAR];
|
|
4681
4681
|
if (tag.tag !== compat.tag) {
|
|
4682
4682
|
const ts = directives.tagString(tag.tag);
|
|
4683
4683
|
const cs = directives.tagString(compat.tag);
|
|
@@ -4695,8 +4695,8 @@ var require_util_empty_scalar_position = __commonJS(function(exports) {
|
|
|
4695
4695
|
function emptyScalarPosition(offset, before, pos) {
|
|
4696
4696
|
if (before) {
|
|
4697
4697
|
pos ?? (pos = before.length);
|
|
4698
|
-
for (let
|
|
4699
|
-
let st = before[
|
|
4698
|
+
for (let i = pos - 1;i >= 0; --i) {
|
|
4699
|
+
let st = before[i];
|
|
4700
4700
|
switch (st.type) {
|
|
4701
4701
|
case "space":
|
|
4702
4702
|
case "comment":
|
|
@@ -4704,10 +4704,10 @@ var require_util_empty_scalar_position = __commonJS(function(exports) {
|
|
|
4704
4704
|
offset -= st.source.length;
|
|
4705
4705
|
continue;
|
|
4706
4706
|
}
|
|
4707
|
-
st = before[++
|
|
4707
|
+
st = before[++i];
|
|
4708
4708
|
while (st?.type === "space") {
|
|
4709
4709
|
offset += st.source.length;
|
|
4710
|
-
st = before[++
|
|
4710
|
+
st = before[++i];
|
|
4711
4711
|
}
|
|
4712
4712
|
break;
|
|
4713
4713
|
}
|
|
@@ -4881,8 +4881,8 @@ var require_composer = __commonJS(function(exports) {
|
|
|
4881
4881
|
let comment = "";
|
|
4882
4882
|
let atComment = false;
|
|
4883
4883
|
let afterEmptyLine = false;
|
|
4884
|
-
for (let
|
|
4885
|
-
const source = prelude[
|
|
4884
|
+
for (let i = 0;i < prelude.length; ++i) {
|
|
4885
|
+
const source = prelude[i];
|
|
4886
4886
|
switch (source[0]) {
|
|
4887
4887
|
case "#":
|
|
4888
4888
|
comment += (comment === "" ? "" : afterEmptyLine ? `
|
|
@@ -4893,8 +4893,8 @@ var require_composer = __commonJS(function(exports) {
|
|
|
4893
4893
|
afterEmptyLine = false;
|
|
4894
4894
|
break;
|
|
4895
4895
|
case "%":
|
|
4896
|
-
if (prelude[
|
|
4897
|
-
|
|
4896
|
+
if (prelude[i + 1]?.[0] !== "#")
|
|
4897
|
+
i += 1;
|
|
4898
4898
|
atComment = false;
|
|
4899
4899
|
break;
|
|
4900
4900
|
default:
|
|
@@ -4946,10 +4946,10 @@ ${cb}` : comment;
|
|
|
4946
4946
|
}
|
|
4947
4947
|
}
|
|
4948
4948
|
if (afterDoc) {
|
|
4949
|
-
for (let
|
|
4950
|
-
doc.errors.push(this.errors[
|
|
4951
|
-
for (let
|
|
4952
|
-
doc.warnings.push(this.warnings[
|
|
4949
|
+
for (let i = 0;i < this.errors.length; ++i)
|
|
4950
|
+
doc.errors.push(this.errors[i]);
|
|
4951
|
+
for (let i = 0;i < this.warnings.length; ++i)
|
|
4952
|
+
doc.warnings.push(this.warnings[i]);
|
|
4953
4953
|
} else {
|
|
4954
4954
|
doc.errors = this.errors;
|
|
4955
4955
|
doc.warnings = this.warnings;
|
|
@@ -5283,14 +5283,14 @@ var require_cst_stringify = __commonJS(function(exports) {
|
|
|
5283
5283
|
}
|
|
5284
5284
|
}
|
|
5285
5285
|
}
|
|
5286
|
-
function stringifyItem({ start, key, sep
|
|
5286
|
+
function stringifyItem({ start, key, sep, value }) {
|
|
5287
5287
|
let res = "";
|
|
5288
5288
|
for (const st of start)
|
|
5289
5289
|
res += st.source;
|
|
5290
5290
|
if (key)
|
|
5291
5291
|
res += stringifyToken(key);
|
|
5292
|
-
if (
|
|
5293
|
-
for (const st of
|
|
5292
|
+
if (sep)
|
|
5293
|
+
for (const st of sep)
|
|
5294
5294
|
res += st.source;
|
|
5295
5295
|
if (value)
|
|
5296
5296
|
res += stringifyToken(value);
|
|
@@ -5338,15 +5338,15 @@ var require_cst_visit = __commonJS(function(exports) {
|
|
|
5338
5338
|
for (const field of ["key", "value"]) {
|
|
5339
5339
|
const token = item[field];
|
|
5340
5340
|
if (token && "items" in token) {
|
|
5341
|
-
for (let
|
|
5342
|
-
const ci = _visit(Object.freeze(path.concat([[field,
|
|
5341
|
+
for (let i = 0;i < token.items.length; ++i) {
|
|
5342
|
+
const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
|
|
5343
5343
|
if (typeof ci === "number")
|
|
5344
|
-
|
|
5344
|
+
i = ci - 1;
|
|
5345
5345
|
else if (ci === BREAK)
|
|
5346
5346
|
return BREAK;
|
|
5347
5347
|
else if (ci === REMOVE) {
|
|
5348
|
-
token.items.splice(
|
|
5349
|
-
|
|
5348
|
+
token.items.splice(i, 1);
|
|
5349
|
+
i -= 1;
|
|
5350
5350
|
}
|
|
5351
5351
|
}
|
|
5352
5352
|
if (typeof ctrl === "function" && field === "key")
|
|
@@ -5509,20 +5509,20 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5509
5509
|
next = yield* this.parseNext(next);
|
|
5510
5510
|
}
|
|
5511
5511
|
atLineEnd() {
|
|
5512
|
-
let
|
|
5513
|
-
let ch = this.buffer[
|
|
5512
|
+
let i = this.pos;
|
|
5513
|
+
let ch = this.buffer[i];
|
|
5514
5514
|
while (ch === " " || ch === "\t")
|
|
5515
|
-
ch = this.buffer[++
|
|
5515
|
+
ch = this.buffer[++i];
|
|
5516
5516
|
if (!ch || ch === "#" || ch === `
|
|
5517
5517
|
`)
|
|
5518
5518
|
return true;
|
|
5519
5519
|
if (ch === "\r")
|
|
5520
|
-
return this.buffer[
|
|
5520
|
+
return this.buffer[i + 1] === `
|
|
5521
5521
|
`;
|
|
5522
5522
|
return false;
|
|
5523
5523
|
}
|
|
5524
|
-
charAt(
|
|
5525
|
-
return this.buffer[this.pos +
|
|
5524
|
+
charAt(n) {
|
|
5525
|
+
return this.buffer[this.pos + n];
|
|
5526
5526
|
}
|
|
5527
5527
|
continueScalar(offset) {
|
|
5528
5528
|
let ch = this.buffer[offset];
|
|
@@ -5559,8 +5559,8 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5559
5559
|
end -= 1;
|
|
5560
5560
|
return this.buffer.substring(this.pos, end);
|
|
5561
5561
|
}
|
|
5562
|
-
hasChars(
|
|
5563
|
-
return this.pos +
|
|
5562
|
+
hasChars(n) {
|
|
5563
|
+
return this.pos + n <= this.buffer.length;
|
|
5564
5564
|
}
|
|
5565
5565
|
setNext(state) {
|
|
5566
5566
|
this.buffer = this.buffer.substring(this.pos);
|
|
@@ -5569,8 +5569,8 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5569
5569
|
this.next = state;
|
|
5570
5570
|
return null;
|
|
5571
5571
|
}
|
|
5572
|
-
peek(
|
|
5573
|
-
return this.buffer.substr(this.pos,
|
|
5572
|
+
peek(n) {
|
|
5573
|
+
return this.buffer.substr(this.pos, n);
|
|
5574
5574
|
}
|
|
5575
5575
|
*parseNext(next) {
|
|
5576
5576
|
switch (next) {
|
|
@@ -5619,8 +5619,8 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5619
5619
|
else
|
|
5620
5620
|
break;
|
|
5621
5621
|
}
|
|
5622
|
-
const
|
|
5623
|
-
yield* this.pushCount(line.length -
|
|
5622
|
+
const n = (yield* this.pushCount(dirEnd)) + (yield* this.pushSpaces(true));
|
|
5623
|
+
yield* this.pushCount(line.length - n);
|
|
5624
5624
|
this.pushNewline();
|
|
5625
5625
|
return "stream";
|
|
5626
5626
|
}
|
|
@@ -5658,9 +5658,9 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5658
5658
|
if (!ch1 && !this.atEnd)
|
|
5659
5659
|
return this.setNext("block-start");
|
|
5660
5660
|
if ((ch0 === "-" || ch0 === "?" || ch0 === ":") && isEmpty(ch1)) {
|
|
5661
|
-
const
|
|
5661
|
+
const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(true));
|
|
5662
5662
|
this.indentNext = this.indentValue + 1;
|
|
5663
|
-
this.indentValue +=
|
|
5663
|
+
this.indentValue += n;
|
|
5664
5664
|
return "block-start";
|
|
5665
5665
|
}
|
|
5666
5666
|
return "doc";
|
|
@@ -5670,10 +5670,10 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5670
5670
|
const line = this.getLine();
|
|
5671
5671
|
if (line === null)
|
|
5672
5672
|
return this.setNext("doc");
|
|
5673
|
-
let
|
|
5674
|
-
switch (line[
|
|
5673
|
+
let n = yield* this.pushIndicators();
|
|
5674
|
+
switch (line[n]) {
|
|
5675
5675
|
case "#":
|
|
5676
|
-
yield* this.pushCount(line.length -
|
|
5676
|
+
yield* this.pushCount(line.length - n);
|
|
5677
5677
|
case undefined:
|
|
5678
5678
|
yield* this.pushNewline();
|
|
5679
5679
|
return yield* this.parseLineStart();
|
|
@@ -5695,9 +5695,9 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5695
5695
|
return yield* this.parseQuotedScalar();
|
|
5696
5696
|
case "|":
|
|
5697
5697
|
case ">":
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
yield* this.pushCount(line.length -
|
|
5698
|
+
n += yield* this.parseBlockScalarHeader();
|
|
5699
|
+
n += yield* this.pushSpaces(true);
|
|
5700
|
+
yield* this.pushCount(line.length - n);
|
|
5701
5701
|
yield* this.pushNewline();
|
|
5702
5702
|
return yield* this.parseBlockScalar();
|
|
5703
5703
|
default:
|
|
@@ -5728,18 +5728,18 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5728
5728
|
return yield* this.parseLineStart();
|
|
5729
5729
|
}
|
|
5730
5730
|
}
|
|
5731
|
-
let
|
|
5732
|
-
while (line[
|
|
5733
|
-
|
|
5734
|
-
|
|
5731
|
+
let n = 0;
|
|
5732
|
+
while (line[n] === ",") {
|
|
5733
|
+
n += yield* this.pushCount(1);
|
|
5734
|
+
n += yield* this.pushSpaces(true);
|
|
5735
5735
|
this.flowKey = false;
|
|
5736
5736
|
}
|
|
5737
|
-
|
|
5738
|
-
switch (line[
|
|
5737
|
+
n += yield* this.pushIndicators();
|
|
5738
|
+
switch (line[n]) {
|
|
5739
5739
|
case undefined:
|
|
5740
5740
|
return "flow";
|
|
5741
5741
|
case "#":
|
|
5742
|
-
yield* this.pushCount(line.length -
|
|
5742
|
+
yield* this.pushCount(line.length - n);
|
|
5743
5743
|
return "flow";
|
|
5744
5744
|
case "{":
|
|
5745
5745
|
case "[":
|
|
@@ -5782,10 +5782,10 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5782
5782
|
end = this.buffer.indexOf("'", end + 2);
|
|
5783
5783
|
} else {
|
|
5784
5784
|
while (end !== -1) {
|
|
5785
|
-
let
|
|
5786
|
-
while (this.buffer[end - 1 -
|
|
5787
|
-
|
|
5788
|
-
if (
|
|
5785
|
+
let n = 0;
|
|
5786
|
+
while (this.buffer[end - 1 - n] === "\\")
|
|
5787
|
+
n += 1;
|
|
5788
|
+
if (n % 2 === 0)
|
|
5789
5789
|
break;
|
|
5790
5790
|
end = this.buffer.indexOf('"', end + 1);
|
|
5791
5791
|
}
|
|
@@ -5816,9 +5816,9 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5816
5816
|
*parseBlockScalarHeader() {
|
|
5817
5817
|
this.blockScalarIndent = -1;
|
|
5818
5818
|
this.blockScalarKeep = false;
|
|
5819
|
-
let
|
|
5819
|
+
let i = this.pos;
|
|
5820
5820
|
while (true) {
|
|
5821
|
-
const ch = this.buffer[++
|
|
5821
|
+
const ch = this.buffer[++i];
|
|
5822
5822
|
if (ch === "+")
|
|
5823
5823
|
this.blockScalarKeep = true;
|
|
5824
5824
|
else if (ch > "0" && ch <= "9")
|
|
@@ -5833,18 +5833,18 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5833
5833
|
let indent = 0;
|
|
5834
5834
|
let ch;
|
|
5835
5835
|
loop:
|
|
5836
|
-
for (let
|
|
5836
|
+
for (let i = this.pos;ch = this.buffer[i]; ++i) {
|
|
5837
5837
|
switch (ch) {
|
|
5838
5838
|
case " ":
|
|
5839
5839
|
indent += 1;
|
|
5840
5840
|
break;
|
|
5841
5841
|
case `
|
|
5842
5842
|
`:
|
|
5843
|
-
nl =
|
|
5843
|
+
nl = i;
|
|
5844
5844
|
indent = 0;
|
|
5845
5845
|
break;
|
|
5846
5846
|
case "\r": {
|
|
5847
|
-
const next = this.buffer[
|
|
5847
|
+
const next = this.buffer[i + 1];
|
|
5848
5848
|
if (!next && !this.atEnd)
|
|
5849
5849
|
return this.setNext("block-scalar");
|
|
5850
5850
|
if (next === `
|
|
@@ -5876,27 +5876,27 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5876
5876
|
nl = this.buffer.length;
|
|
5877
5877
|
}
|
|
5878
5878
|
}
|
|
5879
|
-
let
|
|
5880
|
-
ch = this.buffer[
|
|
5879
|
+
let i = nl + 1;
|
|
5880
|
+
ch = this.buffer[i];
|
|
5881
5881
|
while (ch === " ")
|
|
5882
|
-
ch = this.buffer[++
|
|
5882
|
+
ch = this.buffer[++i];
|
|
5883
5883
|
if (ch === "\t") {
|
|
5884
5884
|
while (ch === "\t" || ch === " " || ch === "\r" || ch === `
|
|
5885
5885
|
`)
|
|
5886
|
-
ch = this.buffer[++
|
|
5887
|
-
nl =
|
|
5886
|
+
ch = this.buffer[++i];
|
|
5887
|
+
nl = i - 1;
|
|
5888
5888
|
} else if (!this.blockScalarKeep) {
|
|
5889
5889
|
do {
|
|
5890
|
-
let
|
|
5891
|
-
let
|
|
5892
|
-
if (
|
|
5893
|
-
|
|
5894
|
-
const lastChar =
|
|
5895
|
-
while (
|
|
5896
|
-
|
|
5897
|
-
if (
|
|
5898
|
-
` &&
|
|
5899
|
-
nl =
|
|
5890
|
+
let i = nl - 1;
|
|
5891
|
+
let ch = this.buffer[i];
|
|
5892
|
+
if (ch === "\r")
|
|
5893
|
+
ch = this.buffer[--i];
|
|
5894
|
+
const lastChar = i;
|
|
5895
|
+
while (ch === " ")
|
|
5896
|
+
ch = this.buffer[--i];
|
|
5897
|
+
if (ch === `
|
|
5898
|
+
` && i >= this.pos && i + 1 + indent > lastChar)
|
|
5899
|
+
nl = i;
|
|
5900
5900
|
else
|
|
5901
5901
|
break;
|
|
5902
5902
|
} while (true);
|
|
@@ -5908,39 +5908,39 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5908
5908
|
*parsePlainScalar() {
|
|
5909
5909
|
const inFlow = this.flowLevel > 0;
|
|
5910
5910
|
let end = this.pos - 1;
|
|
5911
|
-
let
|
|
5911
|
+
let i = this.pos - 1;
|
|
5912
5912
|
let ch;
|
|
5913
|
-
while (ch = this.buffer[++
|
|
5913
|
+
while (ch = this.buffer[++i]) {
|
|
5914
5914
|
if (ch === ":") {
|
|
5915
|
-
const next = this.buffer[
|
|
5915
|
+
const next = this.buffer[i + 1];
|
|
5916
5916
|
if (isEmpty(next) || inFlow && flowIndicatorChars.has(next))
|
|
5917
5917
|
break;
|
|
5918
|
-
end =
|
|
5918
|
+
end = i;
|
|
5919
5919
|
} else if (isEmpty(ch)) {
|
|
5920
|
-
let next = this.buffer[
|
|
5920
|
+
let next = this.buffer[i + 1];
|
|
5921
5921
|
if (ch === "\r") {
|
|
5922
5922
|
if (next === `
|
|
5923
5923
|
`) {
|
|
5924
|
-
|
|
5924
|
+
i += 1;
|
|
5925
5925
|
ch = `
|
|
5926
5926
|
`;
|
|
5927
|
-
next = this.buffer[
|
|
5927
|
+
next = this.buffer[i + 1];
|
|
5928
5928
|
} else
|
|
5929
|
-
end =
|
|
5929
|
+
end = i;
|
|
5930
5930
|
}
|
|
5931
5931
|
if (next === "#" || inFlow && flowIndicatorChars.has(next))
|
|
5932
5932
|
break;
|
|
5933
5933
|
if (ch === `
|
|
5934
5934
|
`) {
|
|
5935
|
-
const cs = this.continueScalar(
|
|
5935
|
+
const cs = this.continueScalar(i + 1);
|
|
5936
5936
|
if (cs === -1)
|
|
5937
5937
|
break;
|
|
5938
|
-
|
|
5938
|
+
i = Math.max(i, cs - 2);
|
|
5939
5939
|
}
|
|
5940
5940
|
} else {
|
|
5941
5941
|
if (inFlow && flowIndicatorChars.has(ch))
|
|
5942
5942
|
break;
|
|
5943
|
-
end =
|
|
5943
|
+
end = i;
|
|
5944
5944
|
}
|
|
5945
5945
|
}
|
|
5946
5946
|
if (!ch && !this.atEnd)
|
|
@@ -5949,16 +5949,16 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5949
5949
|
yield* this.pushToIndex(end + 1, true);
|
|
5950
5950
|
return inFlow ? "flow" : "doc";
|
|
5951
5951
|
}
|
|
5952
|
-
*pushCount(
|
|
5953
|
-
if (
|
|
5954
|
-
yield this.buffer.substr(this.pos,
|
|
5955
|
-
this.pos +=
|
|
5956
|
-
return
|
|
5952
|
+
*pushCount(n) {
|
|
5953
|
+
if (n > 0) {
|
|
5954
|
+
yield this.buffer.substr(this.pos, n);
|
|
5955
|
+
this.pos += n;
|
|
5956
|
+
return n;
|
|
5957
5957
|
}
|
|
5958
5958
|
return 0;
|
|
5959
5959
|
}
|
|
5960
|
-
*pushToIndex(
|
|
5961
|
-
const s = this.buffer.slice(this.pos,
|
|
5960
|
+
*pushToIndex(i, allowEmpty) {
|
|
5961
|
+
const s = this.buffer.slice(this.pos, i);
|
|
5962
5962
|
if (s) {
|
|
5963
5963
|
yield s;
|
|
5964
5964
|
this.pos += s.length;
|
|
@@ -5968,17 +5968,17 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5968
5968
|
return 0;
|
|
5969
5969
|
}
|
|
5970
5970
|
*pushIndicators() {
|
|
5971
|
-
let
|
|
5971
|
+
let n = 0;
|
|
5972
5972
|
loop:
|
|
5973
5973
|
while (true) {
|
|
5974
5974
|
switch (this.charAt(0)) {
|
|
5975
5975
|
case "!":
|
|
5976
|
-
|
|
5977
|
-
|
|
5976
|
+
n += yield* this.pushTag();
|
|
5977
|
+
n += yield* this.pushSpaces(true);
|
|
5978
5978
|
continue loop;
|
|
5979
5979
|
case "&":
|
|
5980
|
-
|
|
5981
|
-
|
|
5980
|
+
n += yield* this.pushUntil(isNotAnchorChar);
|
|
5981
|
+
n += yield* this.pushSpaces(true);
|
|
5982
5982
|
continue loop;
|
|
5983
5983
|
case "-":
|
|
5984
5984
|
case "?":
|
|
@@ -5990,35 +5990,35 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
5990
5990
|
this.indentNext = this.indentValue + 1;
|
|
5991
5991
|
else if (this.flowKey)
|
|
5992
5992
|
this.flowKey = false;
|
|
5993
|
-
|
|
5994
|
-
|
|
5993
|
+
n += yield* this.pushCount(1);
|
|
5994
|
+
n += yield* this.pushSpaces(true);
|
|
5995
5995
|
continue loop;
|
|
5996
5996
|
}
|
|
5997
5997
|
}
|
|
5998
5998
|
}
|
|
5999
5999
|
break loop;
|
|
6000
6000
|
}
|
|
6001
|
-
return
|
|
6001
|
+
return n;
|
|
6002
6002
|
}
|
|
6003
6003
|
*pushTag() {
|
|
6004
6004
|
if (this.charAt(1) === "<") {
|
|
6005
|
-
let
|
|
6006
|
-
let ch = this.buffer[
|
|
6005
|
+
let i = this.pos + 2;
|
|
6006
|
+
let ch = this.buffer[i];
|
|
6007
6007
|
while (!isEmpty(ch) && ch !== ">")
|
|
6008
|
-
ch = this.buffer[++
|
|
6009
|
-
return yield* this.pushToIndex(ch === ">" ?
|
|
6008
|
+
ch = this.buffer[++i];
|
|
6009
|
+
return yield* this.pushToIndex(ch === ">" ? i + 1 : i, false);
|
|
6010
6010
|
} else {
|
|
6011
|
-
let
|
|
6012
|
-
let ch = this.buffer[
|
|
6011
|
+
let i = this.pos + 1;
|
|
6012
|
+
let ch = this.buffer[i];
|
|
6013
6013
|
while (ch) {
|
|
6014
6014
|
if (tagChars.has(ch))
|
|
6015
|
-
ch = this.buffer[++
|
|
6016
|
-
else if (ch === "%" && hexDigits.has(this.buffer[
|
|
6017
|
-
ch = this.buffer[
|
|
6015
|
+
ch = this.buffer[++i];
|
|
6016
|
+
else if (ch === "%" && hexDigits.has(this.buffer[i + 1]) && hexDigits.has(this.buffer[i + 2])) {
|
|
6017
|
+
ch = this.buffer[i += 3];
|
|
6018
6018
|
} else
|
|
6019
6019
|
break;
|
|
6020
6020
|
}
|
|
6021
|
-
return yield* this.pushToIndex(
|
|
6021
|
+
return yield* this.pushToIndex(i, false);
|
|
6022
6022
|
}
|
|
6023
6023
|
}
|
|
6024
6024
|
*pushNewline() {
|
|
@@ -6033,24 +6033,24 @@ var require_lexer = __commonJS(function(exports) {
|
|
|
6033
6033
|
return 0;
|
|
6034
6034
|
}
|
|
6035
6035
|
*pushSpaces(allowTabs) {
|
|
6036
|
-
let
|
|
6036
|
+
let i = this.pos - 1;
|
|
6037
6037
|
let ch;
|
|
6038
6038
|
do {
|
|
6039
|
-
ch = this.buffer[++
|
|
6039
|
+
ch = this.buffer[++i];
|
|
6040
6040
|
} while (ch === " " || allowTabs && ch === "\t");
|
|
6041
|
-
const
|
|
6042
|
-
if (
|
|
6043
|
-
yield this.buffer.substr(this.pos,
|
|
6044
|
-
this.pos =
|
|
6041
|
+
const n = i - this.pos;
|
|
6042
|
+
if (n > 0) {
|
|
6043
|
+
yield this.buffer.substr(this.pos, n);
|
|
6044
|
+
this.pos = i;
|
|
6045
6045
|
}
|
|
6046
|
-
return
|
|
6046
|
+
return n;
|
|
6047
6047
|
}
|
|
6048
6048
|
*pushUntil(test) {
|
|
6049
|
-
let
|
|
6050
|
-
let ch = this.buffer[
|
|
6049
|
+
let i = this.pos;
|
|
6050
|
+
let ch = this.buffer[i];
|
|
6051
6051
|
while (!test(ch))
|
|
6052
|
-
ch = this.buffer[++
|
|
6053
|
-
return yield* this.pushToIndex(
|
|
6052
|
+
ch = this.buffer[++i];
|
|
6053
|
+
return yield* this.pushToIndex(i, false);
|
|
6054
6054
|
}
|
|
6055
6055
|
}
|
|
6056
6056
|
exports.Lexer = Lexer;
|
|
@@ -6090,20 +6090,20 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6090
6090
|
var cst = require_cst();
|
|
6091
6091
|
var lexer = require_lexer();
|
|
6092
6092
|
function includesToken(list, type) {
|
|
6093
|
-
for (let
|
|
6094
|
-
if (list[
|
|
6093
|
+
for (let i = 0;i < list.length; ++i)
|
|
6094
|
+
if (list[i].type === type)
|
|
6095
6095
|
return true;
|
|
6096
6096
|
return false;
|
|
6097
6097
|
}
|
|
6098
6098
|
function findNonEmptyIndex(list) {
|
|
6099
|
-
for (let
|
|
6100
|
-
switch (list[
|
|
6099
|
+
for (let i = 0;i < list.length; ++i) {
|
|
6100
|
+
switch (list[i].type) {
|
|
6101
6101
|
case "space":
|
|
6102
6102
|
case "comment":
|
|
6103
6103
|
case "newline":
|
|
6104
6104
|
break;
|
|
6105
6105
|
default:
|
|
6106
|
-
return
|
|
6106
|
+
return i;
|
|
6107
6107
|
}
|
|
6108
6108
|
}
|
|
6109
6109
|
return -1;
|
|
@@ -6137,10 +6137,10 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6137
6137
|
function getFirstKeyStartProps(prev) {
|
|
6138
6138
|
if (prev.length === 0)
|
|
6139
6139
|
return [];
|
|
6140
|
-
let
|
|
6140
|
+
let i = prev.length;
|
|
6141
6141
|
loop:
|
|
6142
|
-
while (--
|
|
6143
|
-
switch (prev[
|
|
6142
|
+
while (--i >= 0) {
|
|
6143
|
+
switch (prev[i].type) {
|
|
6144
6144
|
case "doc-start":
|
|
6145
6145
|
case "explicit-key-ind":
|
|
6146
6146
|
case "map-value-ind":
|
|
@@ -6149,15 +6149,15 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6149
6149
|
break loop;
|
|
6150
6150
|
}
|
|
6151
6151
|
}
|
|
6152
|
-
while (prev[++
|
|
6153
|
-
return prev.splice(
|
|
6152
|
+
while (prev[++i]?.type === "space") {}
|
|
6153
|
+
return prev.splice(i, prev.length);
|
|
6154
6154
|
}
|
|
6155
6155
|
function arrayPushArray(target, source) {
|
|
6156
6156
|
if (source.length < 1e5)
|
|
6157
6157
|
Array.prototype.push.apply(target, source);
|
|
6158
6158
|
else
|
|
6159
|
-
for (let
|
|
6160
|
-
target.push(source[
|
|
6159
|
+
for (let i = 0;i < source.length; ++i)
|
|
6160
|
+
target.push(source[i]);
|
|
6161
6161
|
}
|
|
6162
6162
|
function fixFlowSeqItems(fc) {
|
|
6163
6163
|
if (fc.start.type === "flow-seq-start") {
|
|
@@ -6296,8 +6296,8 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6296
6296
|
}
|
|
6297
6297
|
yield* this.pop();
|
|
6298
6298
|
}
|
|
6299
|
-
peek(
|
|
6300
|
-
return this.stack[this.stack.length -
|
|
6299
|
+
peek(n) {
|
|
6300
|
+
return this.stack[this.stack.length - n];
|
|
6301
6301
|
}
|
|
6302
6302
|
*pop(error) {
|
|
6303
6303
|
const token = error ?? this.stack.pop();
|
|
@@ -6438,18 +6438,18 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6438
6438
|
if (this.type === "map-value-ind") {
|
|
6439
6439
|
const prev = getPrevProps(this.peek(2));
|
|
6440
6440
|
const start = getFirstKeyStartProps(prev);
|
|
6441
|
-
let
|
|
6441
|
+
let sep;
|
|
6442
6442
|
if (scalar.end) {
|
|
6443
|
-
|
|
6444
|
-
|
|
6443
|
+
sep = scalar.end;
|
|
6444
|
+
sep.push(this.sourceToken);
|
|
6445
6445
|
delete scalar.end;
|
|
6446
6446
|
} else
|
|
6447
|
-
|
|
6447
|
+
sep = [this.sourceToken];
|
|
6448
6448
|
const map = {
|
|
6449
6449
|
type: "block-map",
|
|
6450
6450
|
offset: scalar.offset,
|
|
6451
6451
|
indent: scalar.indent,
|
|
6452
|
-
items: [{ start, key: scalar, sep
|
|
6452
|
+
items: [{ start, key: scalar, sep }]
|
|
6453
6453
|
};
|
|
6454
6454
|
this.onKeyLine = true;
|
|
6455
6455
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -6528,11 +6528,11 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6528
6528
|
let start = [];
|
|
6529
6529
|
if (atNextItem && it.sep && !it.value) {
|
|
6530
6530
|
const nl = [];
|
|
6531
|
-
for (let
|
|
6532
|
-
const st = it.sep[
|
|
6531
|
+
for (let i = 0;i < it.sep.length; ++i) {
|
|
6532
|
+
const st = it.sep[i];
|
|
6533
6533
|
switch (st.type) {
|
|
6534
6534
|
case "newline":
|
|
6535
|
-
nl.push(
|
|
6535
|
+
nl.push(i);
|
|
6536
6536
|
break;
|
|
6537
6537
|
case "space":
|
|
6538
6538
|
break;
|
|
@@ -6583,12 +6583,12 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6583
6583
|
if (includesToken(it.start, "newline")) {
|
|
6584
6584
|
Object.assign(it, { key: null, sep: [this.sourceToken] });
|
|
6585
6585
|
} else {
|
|
6586
|
-
const
|
|
6586
|
+
const start = getFirstKeyStartProps(it.start);
|
|
6587
6587
|
this.stack.push({
|
|
6588
6588
|
type: "block-map",
|
|
6589
6589
|
offset: this.offset,
|
|
6590
6590
|
indent: this.indent,
|
|
6591
|
-
items: [{ start
|
|
6591
|
+
items: [{ start, key: null, sep: [this.sourceToken] }]
|
|
6592
6592
|
});
|
|
6593
6593
|
}
|
|
6594
6594
|
} else if (it.value) {
|
|
@@ -6601,17 +6601,17 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6601
6601
|
items: [{ start, key: null, sep: [this.sourceToken] }]
|
|
6602
6602
|
});
|
|
6603
6603
|
} else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
|
|
6604
|
-
const
|
|
6604
|
+
const start = getFirstKeyStartProps(it.start);
|
|
6605
6605
|
const key = it.key;
|
|
6606
|
-
const
|
|
6607
|
-
|
|
6606
|
+
const sep = it.sep;
|
|
6607
|
+
sep.push(this.sourceToken);
|
|
6608
6608
|
delete it.key;
|
|
6609
6609
|
delete it.sep;
|
|
6610
6610
|
this.stack.push({
|
|
6611
6611
|
type: "block-map",
|
|
6612
6612
|
offset: this.offset,
|
|
6613
6613
|
indent: this.indent,
|
|
6614
|
-
items: [{ start
|
|
6614
|
+
items: [{ start, key, sep }]
|
|
6615
6615
|
});
|
|
6616
6616
|
} else if (start.length > 0) {
|
|
6617
6617
|
it.sep = it.sep.concat(start, this.sourceToken);
|
|
@@ -6805,13 +6805,13 @@ var require_parser = __commonJS(function(exports) {
|
|
|
6805
6805
|
const prev = getPrevProps(parent);
|
|
6806
6806
|
const start = getFirstKeyStartProps(prev);
|
|
6807
6807
|
fixFlowSeqItems(fc);
|
|
6808
|
-
const
|
|
6809
|
-
|
|
6808
|
+
const sep = fc.end.splice(1, fc.end.length);
|
|
6809
|
+
sep.push(this.sourceToken);
|
|
6810
6810
|
const map = {
|
|
6811
6811
|
type: "block-map",
|
|
6812
6812
|
offset: fc.offset,
|
|
6813
6813
|
indent: fc.indent,
|
|
6814
|
-
items: [{ start, key: fc, sep
|
|
6814
|
+
items: [{ start, key: fc, sep }]
|
|
6815
6815
|
};
|
|
6816
6816
|
this.onKeyLine = true;
|
|
6817
6817
|
this.stack[this.stack.length - 1] = map;
|
|
@@ -6955,22 +6955,22 @@ var require_public_api = __commonJS(function(exports) {
|
|
|
6955
6955
|
return { lineCounter: lineCounter$1, prettyErrors };
|
|
6956
6956
|
}
|
|
6957
6957
|
function parseAllDocuments(source, options = {}) {
|
|
6958
|
-
const { lineCounter
|
|
6959
|
-
const parser$1 = new parser.Parser(
|
|
6958
|
+
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
6959
|
+
const parser$1 = new parser.Parser(lineCounter?.addNewLine);
|
|
6960
6960
|
const composer$1 = new composer.Composer(options);
|
|
6961
6961
|
const docs = Array.from(composer$1.compose(parser$1.parse(source)));
|
|
6962
|
-
if (prettyErrors &&
|
|
6962
|
+
if (prettyErrors && lineCounter)
|
|
6963
6963
|
for (const doc of docs) {
|
|
6964
|
-
doc.errors.forEach(errors.prettifyError(source,
|
|
6965
|
-
doc.warnings.forEach(errors.prettifyError(source,
|
|
6964
|
+
doc.errors.forEach(errors.prettifyError(source, lineCounter));
|
|
6965
|
+
doc.warnings.forEach(errors.prettifyError(source, lineCounter));
|
|
6966
6966
|
}
|
|
6967
6967
|
if (docs.length > 0)
|
|
6968
6968
|
return docs;
|
|
6969
6969
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
6970
6970
|
}
|
|
6971
6971
|
function parseDocument(source, options = {}) {
|
|
6972
|
-
const { lineCounter
|
|
6973
|
-
const parser$1 = new parser.Parser(
|
|
6972
|
+
const { lineCounter, prettyErrors } = parseOptions(options);
|
|
6973
|
+
const parser$1 = new parser.Parser(lineCounter?.addNewLine);
|
|
6974
6974
|
const composer$1 = new composer.Composer(options);
|
|
6975
6975
|
let doc = null;
|
|
6976
6976
|
for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
|
|
@@ -6981,9 +6981,9 @@ var require_public_api = __commonJS(function(exports) {
|
|
|
6981
6981
|
break;
|
|
6982
6982
|
}
|
|
6983
6983
|
}
|
|
6984
|
-
if (prettyErrors &&
|
|
6985
|
-
doc.errors.forEach(errors.prettifyError(source,
|
|
6986
|
-
doc.warnings.forEach(errors.prettifyError(source,
|
|
6984
|
+
if (prettyErrors && lineCounter) {
|
|
6985
|
+
doc.errors.forEach(errors.prettifyError(source, lineCounter));
|
|
6986
|
+
doc.warnings.forEach(errors.prettifyError(source, lineCounter));
|
|
6987
6987
|
}
|
|
6988
6988
|
return doc;
|
|
6989
6989
|
}
|
|
@@ -7035,7 +7035,7 @@ var require_public_api = __commonJS(function(exports) {
|
|
|
7035
7035
|
});
|
|
7036
7036
|
|
|
7037
7037
|
// src/version.ts
|
|
7038
|
-
var VERSION = "1.6.
|
|
7038
|
+
var VERSION = "1.6.2";
|
|
7039
7039
|
var USER_AGENT = `altertable-cli/${VERSION}`;
|
|
7040
7040
|
|
|
7041
7041
|
// src/lib/transport-defaults.ts
|
|
@@ -7300,7 +7300,7 @@ function shouldShowCommandExamplesOnError(error) {
|
|
|
7300
7300
|
if (error instanceof HttpError || error instanceof NetworkError || error instanceof TimeoutError || error instanceof ParseError) {
|
|
7301
7301
|
return false;
|
|
7302
7302
|
}
|
|
7303
|
-
return error.exitCode === EXIT_GENERIC
|
|
7303
|
+
return error.exitCode === EXIT_GENERIC;
|
|
7304
7304
|
}
|
|
7305
7305
|
|
|
7306
7306
|
// src/lib/env.ts
|
|
@@ -8525,11 +8525,11 @@ class SourcePreservingJsonRedactor {
|
|
|
8525
8525
|
if (firstCharacter === '"')
|
|
8526
8526
|
return this.findStringEnd(start);
|
|
8527
8527
|
if (firstCharacter !== "{" && firstCharacter !== "[") {
|
|
8528
|
-
let
|
|
8529
|
-
while (
|
|
8530
|
-
|
|
8528
|
+
let position = start;
|
|
8529
|
+
while (position < this.source.length && !/[\s,}\]]/.test(this.source[position] ?? "")) {
|
|
8530
|
+
position += 1;
|
|
8531
8531
|
}
|
|
8532
|
-
return
|
|
8532
|
+
return position;
|
|
8533
8533
|
}
|
|
8534
8534
|
const closingCharacters = [firstCharacter === "{" ? "}" : "]"];
|
|
8535
8535
|
let position = start + 1;
|
|
@@ -8583,8 +8583,8 @@ function redactResponseBodyForDebug(body) {
|
|
|
8583
8583
|
|
|
8584
8584
|
// src/lib/sleep.ts
|
|
8585
8585
|
function sleep(milliseconds) {
|
|
8586
|
-
return new Promise((
|
|
8587
|
-
setTimeout(
|
|
8586
|
+
return new Promise((resolve) => {
|
|
8587
|
+
setTimeout(resolve, milliseconds);
|
|
8588
8588
|
});
|
|
8589
8589
|
}
|
|
8590
8590
|
|
|
@@ -9081,8 +9081,8 @@ function encodeManagementEndpoint(endpoint) {
|
|
|
9081
9081
|
var USER_AGENT2;
|
|
9082
9082
|
if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) {
|
|
9083
9083
|
const NAME = "oauth4webapi";
|
|
9084
|
-
const
|
|
9085
|
-
USER_AGENT2 = `${NAME}/${
|
|
9084
|
+
const VERSION = "v3.8.7";
|
|
9085
|
+
USER_AGENT2 = `${NAME}/${VERSION}`;
|
|
9086
9086
|
}
|
|
9087
9087
|
function looseInstanceOf(input, expected) {
|
|
9088
9088
|
if (input == null) {
|
|
@@ -9816,7 +9816,7 @@ function assertReadableResponse(response) {
|
|
|
9816
9816
|
throw CodedTypeError('"response" body has been used already', ERR_INVALID_ARG_VALUE);
|
|
9817
9817
|
}
|
|
9818
9818
|
}
|
|
9819
|
-
async function validateJwt(jws, checkAlg,
|
|
9819
|
+
async function validateJwt(jws, checkAlg, clockSkew, clockTolerance, decryptJwt) {
|
|
9820
9820
|
let { 0: protectedHeader, 1: payload, length } = jws.split(".");
|
|
9821
9821
|
if (length === 5) {
|
|
9822
9822
|
if (decryptJwt !== undefined) {
|
|
@@ -9853,13 +9853,13 @@ async function validateJwt(jws, checkAlg, clockSkew2, clockTolerance2, decryptJw
|
|
|
9853
9853
|
if (!isJsonObject(claims)) {
|
|
9854
9854
|
throw OPE("JWT Payload must be a top level object", INVALID_RESPONSE, jws);
|
|
9855
9855
|
}
|
|
9856
|
-
const now = epochTime() +
|
|
9856
|
+
const now = epochTime() + clockSkew;
|
|
9857
9857
|
if (claims.exp !== undefined) {
|
|
9858
9858
|
if (typeof claims.exp !== "number") {
|
|
9859
9859
|
throw OPE('unexpected JWT "exp" (expiration time) claim type', INVALID_RESPONSE, { claims });
|
|
9860
9860
|
}
|
|
9861
|
-
if (claims.exp <= now -
|
|
9862
|
-
throw OPE('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp', JWT_TIMESTAMP_CHECK, { claims, now, tolerance:
|
|
9861
|
+
if (claims.exp <= now - clockTolerance) {
|
|
9862
|
+
throw OPE('unexpected JWT "exp" (expiration time) claim value, expiration is past current timestamp', JWT_TIMESTAMP_CHECK, { claims, now, tolerance: clockTolerance, claim: "exp" });
|
|
9863
9863
|
}
|
|
9864
9864
|
}
|
|
9865
9865
|
if (claims.iat !== undefined) {
|
|
@@ -9876,11 +9876,11 @@ async function validateJwt(jws, checkAlg, clockSkew2, clockTolerance2, decryptJw
|
|
|
9876
9876
|
if (typeof claims.nbf !== "number") {
|
|
9877
9877
|
throw OPE('unexpected JWT "nbf" (not before) claim type', INVALID_RESPONSE, { claims });
|
|
9878
9878
|
}
|
|
9879
|
-
if (claims.nbf > now +
|
|
9879
|
+
if (claims.nbf > now + clockTolerance) {
|
|
9880
9880
|
throw OPE('unexpected JWT "nbf" (not before) claim value', JWT_TIMESTAMP_CHECK, {
|
|
9881
9881
|
claims,
|
|
9882
9882
|
now,
|
|
9883
|
-
tolerance:
|
|
9883
|
+
tolerance: clockTolerance,
|
|
9884
9884
|
claim: "nbf"
|
|
9885
9885
|
});
|
|
9886
9886
|
}
|
|
@@ -10009,8 +10009,8 @@ import { createServer } from "http";
|
|
|
10009
10009
|
import { spawn } from "child_process";
|
|
10010
10010
|
|
|
10011
10011
|
// src/ui/document.ts
|
|
10012
|
-
function rows(
|
|
10013
|
-
return { kind: "rows", rows
|
|
10012
|
+
function rows(rows) {
|
|
10013
|
+
return { kind: "rows", rows };
|
|
10014
10014
|
}
|
|
10015
10015
|
function table(displayTable) {
|
|
10016
10016
|
return { kind: "table", table: displayTable };
|
|
@@ -10018,9 +10018,9 @@ function table(displayTable) {
|
|
|
10018
10018
|
function text(lines) {
|
|
10019
10019
|
return { kind: "text", lines };
|
|
10020
10020
|
}
|
|
10021
|
-
function span(
|
|
10021
|
+
function span(text, style, href) {
|
|
10022
10022
|
return {
|
|
10023
|
-
text
|
|
10023
|
+
text,
|
|
10024
10024
|
...style ? { style } : {},
|
|
10025
10025
|
...href ? { href } : {}
|
|
10026
10026
|
};
|
|
@@ -10160,12 +10160,12 @@ function startLoopbackServer(expectedState) {
|
|
|
10160
10160
|
server.on("error", rejectServer);
|
|
10161
10161
|
server.listen(redirectPort(), "127.0.0.1", () => {
|
|
10162
10162
|
const address = server.address();
|
|
10163
|
-
const
|
|
10163
|
+
const port = typeof address === "object" && address ? address.port : 0;
|
|
10164
10164
|
const timer = setTimeout(() => {
|
|
10165
10165
|
rejectCode(new ConfigurationError("Timed out waiting for browser sign-in (3 minutes)."));
|
|
10166
10166
|
}, LOGIN_TIMEOUT_MS);
|
|
10167
10167
|
resolveServer({
|
|
10168
|
-
redirectUri: `http://127.0.0.1:${
|
|
10168
|
+
redirectUri: `http://127.0.0.1:${port}/callback`,
|
|
10169
10169
|
waitForCode: () => codePromise.finally(() => clearTimeout(timer)),
|
|
10170
10170
|
close: () => {
|
|
10171
10171
|
clearTimeout(timer);
|
|
@@ -10463,9 +10463,9 @@ async function ensureFreshAccessToken(profileName) {
|
|
|
10463
10463
|
}
|
|
10464
10464
|
|
|
10465
10465
|
// src/lib/management/views.ts
|
|
10466
|
-
function buildCatalogsTableView(
|
|
10466
|
+
function buildCatalogsTableView(rows) {
|
|
10467
10467
|
return document(section(table({
|
|
10468
|
-
rows
|
|
10468
|
+
rows,
|
|
10469
10469
|
columns: [
|
|
10470
10470
|
{ header: "SLUG", cell: (row) => [span(row.slug, "accent")] },
|
|
10471
10471
|
{ header: "NAME", cell: (row) => [span(row.name, "strong")], flex: true },
|
|
@@ -10489,11 +10489,11 @@ function nestedIndent(indent = TERMINAL_INDENT) {
|
|
|
10489
10489
|
// src/ui/terminal/table.ts
|
|
10490
10490
|
var COLUMN_GAP = " ";
|
|
10491
10491
|
var FLEX_SHRINK_MIN_WIDTH = 4;
|
|
10492
|
-
function truncateCell(
|
|
10493
|
-
return truncateTerminalText(
|
|
10492
|
+
function truncateCell(text, maxWidth) {
|
|
10493
|
+
return truncateTerminalText(text, maxWidth);
|
|
10494
10494
|
}
|
|
10495
|
-
function applyHeaderStyle(
|
|
10496
|
-
return renderDisplayText([span(
|
|
10495
|
+
function applyHeaderStyle(text) {
|
|
10496
|
+
return renderDisplayText([span(text, "subtle")]);
|
|
10497
10497
|
}
|
|
10498
10498
|
function tablePlainWidth(columnWidths, columnCount) {
|
|
10499
10499
|
return columnWidths.reduce((sum, width) => sum + width, 0) + (columnCount - 1) * COLUMN_GAP.length;
|
|
@@ -10542,12 +10542,12 @@ function computeColumnWidths(columns, renderedHeaders, renderedCells, options) {
|
|
|
10542
10542
|
}
|
|
10543
10543
|
return shrinkFlexColumnsToFit(columns, cappedWidths, terminalWidth);
|
|
10544
10544
|
}
|
|
10545
|
-
function renderFixedTable(
|
|
10546
|
-
if (
|
|
10545
|
+
function renderFixedTable(rows, columns, emptyMessage = "No rows.", options = {}) {
|
|
10546
|
+
if (rows.length === 0) {
|
|
10547
10547
|
return renderDisplayText([span(emptyMessage, "subtle")]);
|
|
10548
10548
|
}
|
|
10549
10549
|
const renderedHeaders = columns.map((column) => renderDisplayText(column.header.toUpperCase()));
|
|
10550
|
-
const renderedCells =
|
|
10550
|
+
const renderedCells = rows.map((row) => columns.map((column) => renderDisplayText(column.cell(row))));
|
|
10551
10551
|
const columnWidths = computeColumnWidths(columns, renderedHeaders, renderedCells, options);
|
|
10552
10552
|
function formatRow(rowCells, rowIndex) {
|
|
10553
10553
|
return rowCells.map((cell, columnIndex) => {
|
|
@@ -10563,13 +10563,13 @@ function renderFixedTable(rows2, columns, emptyMessage = "No rows.", options = {
|
|
|
10563
10563
|
const header = formatRow(renderedHeaders, -1);
|
|
10564
10564
|
const bodyLines = [];
|
|
10565
10565
|
for (let rowIndex = 0;rowIndex < renderedCells.length; rowIndex++) {
|
|
10566
|
-
const row =
|
|
10566
|
+
const row = rows[rowIndex];
|
|
10567
10567
|
const rowCells = renderedCells[rowIndex];
|
|
10568
10568
|
if (row === undefined || rowCells === undefined) {
|
|
10569
10569
|
continue;
|
|
10570
10570
|
}
|
|
10571
10571
|
if (rowIndex > 0 && options.groupBy) {
|
|
10572
|
-
const previousRow =
|
|
10572
|
+
const previousRow = rows[rowIndex - 1];
|
|
10573
10573
|
if (previousRow !== undefined && options.groupBy(previousRow) !== options.groupBy(row)) {
|
|
10574
10574
|
bodyLines.push("");
|
|
10575
10575
|
}
|
|
@@ -10584,12 +10584,12 @@ function renderFixedTable(rows2, columns, emptyMessage = "No rows.", options = {
|
|
|
10584
10584
|
function renderLabelValue(label, value, options) {
|
|
10585
10585
|
return `${options.indent}${renderDisplayText([span(label.padEnd(options.labelWidth), "muted")])} ${value}`;
|
|
10586
10586
|
}
|
|
10587
|
-
function renderRows(
|
|
10587
|
+
function renderRows(rows, options = {}) {
|
|
10588
10588
|
const indent = options.indent ?? TERMINAL_INDENT;
|
|
10589
10589
|
const labelWidth = options.labelWidth ?? TERMINAL_LABEL_WIDTH;
|
|
10590
10590
|
const childIndent = options.nestedIndent ?? nestedIndent(indent);
|
|
10591
10591
|
const nestedLabelWidth = options.nestedLabelWidth ?? TERMINAL_NESTED_LABEL_WIDTH;
|
|
10592
|
-
return
|
|
10592
|
+
return rows.map((row) => renderLabelValue(row.label, renderDisplayText(row.value), {
|
|
10593
10593
|
indent: row.level === 1 ? childIndent : indent,
|
|
10594
10594
|
labelWidth: row.level === 1 ? nestedLabelWidth : labelWidth
|
|
10595
10595
|
}));
|
|
@@ -10604,17 +10604,17 @@ function renderBlock(block, options) {
|
|
|
10604
10604
|
}
|
|
10605
10605
|
return renderRows(block.rows, options);
|
|
10606
10606
|
}
|
|
10607
|
-
function renderSection(
|
|
10608
|
-
return
|
|
10607
|
+
function renderSection(section, options) {
|
|
10608
|
+
return section.blocks.flatMap((block) => renderBlock(block, options));
|
|
10609
10609
|
}
|
|
10610
|
-
function renderDocument(
|
|
10611
|
-
return
|
|
10610
|
+
function renderDocument(document, options = {}) {
|
|
10611
|
+
return document.sections.flatMap((section, index) => [
|
|
10612
10612
|
...index === 0 ? [] : [""],
|
|
10613
|
-
...renderSection(
|
|
10613
|
+
...renderSection(section, options)
|
|
10614
10614
|
]);
|
|
10615
10615
|
}
|
|
10616
|
-
function renderDocumentText(
|
|
10617
|
-
return renderDocument(
|
|
10616
|
+
function renderDocumentText(document, options = {}) {
|
|
10617
|
+
return renderDocument(document, options).join(`
|
|
10618
10618
|
`);
|
|
10619
10619
|
}
|
|
10620
10620
|
var TREE_BRANCH = "\u251C\u2500\u2500 ";
|
|
@@ -10661,14 +10661,14 @@ function formatWhoamiPrincipalLine(data) {
|
|
|
10661
10661
|
}
|
|
10662
10662
|
return `User: ${principal.name ?? ""}`;
|
|
10663
10663
|
}
|
|
10664
|
-
function formatCatalogsSummary(
|
|
10665
|
-
if (
|
|
10664
|
+
function formatCatalogsSummary(rows) {
|
|
10665
|
+
if (rows.length === 0) {
|
|
10666
10666
|
return null;
|
|
10667
10667
|
}
|
|
10668
|
-
const databaseCount =
|
|
10669
|
-
const connectionCount =
|
|
10670
|
-
const catalogLabel =
|
|
10671
|
-
const summaryParts = [`${
|
|
10668
|
+
const databaseCount = rows.filter((row) => row.type === "database").length;
|
|
10669
|
+
const connectionCount = rows.filter((row) => row.type === "connection").length;
|
|
10670
|
+
const catalogLabel = rows.length === 1 ? "catalog" : "catalogs";
|
|
10671
|
+
const summaryParts = [`${rows.length} ${catalogLabel}`];
|
|
10672
10672
|
if (databaseCount > 0) {
|
|
10673
10673
|
const databaseLabel = databaseCount === 1 ? "database" : "databases";
|
|
10674
10674
|
summaryParts.push(`${databaseCount} ${databaseLabel}`);
|
|
@@ -10679,8 +10679,8 @@ function formatCatalogsSummary(rows2) {
|
|
|
10679
10679
|
}
|
|
10680
10680
|
return summaryParts.join(" \xB7 ");
|
|
10681
10681
|
}
|
|
10682
|
-
function formatCatalogsTable(
|
|
10683
|
-
return renderDocumentText(buildCatalogsTableView(
|
|
10682
|
+
function formatCatalogsTable(rows) {
|
|
10683
|
+
return renderDocumentText(buildCatalogsTableView(rows));
|
|
10684
10684
|
}
|
|
10685
10685
|
|
|
10686
10686
|
// src/lib/profile/model.ts
|
|
@@ -11314,7 +11314,9 @@ function isInteractiveTerminal2() {
|
|
|
11314
11314
|
function assertInteractiveLogin() {
|
|
11315
11315
|
if (isJsonOutput2(getCliContext()) || !isInteractiveTerminal2()) {
|
|
11316
11316
|
throw new ConfigurationError(`altertable login needs an interactive terminal with a browser and does not support --json or --agent.
|
|
11317
|
-
For headless setups
|
|
11317
|
+
` + `For headless setups, pipe a management key:
|
|
11318
|
+
` + ` printf '%s' "$KEY" | altertable profile configure --api-key-stdin --env <name>
|
|
11319
|
+
` + "Or set ALTERTABLE_API_KEY and ALTERTABLE_ENV.");
|
|
11318
11320
|
}
|
|
11319
11321
|
}
|
|
11320
11322
|
var LOGIN_PROFILE_MESSAGES = {
|
|
@@ -11605,7 +11607,7 @@ var logoutCommand = defineCommand({
|
|
|
11605
11607
|
// src/lib/stream-lines.ts
|
|
11606
11608
|
async function* readTextStreamLines(stream) {
|
|
11607
11609
|
const reader = stream.getReader();
|
|
11608
|
-
const
|
|
11610
|
+
const decoder = new TextDecoder;
|
|
11609
11611
|
let buffer = "";
|
|
11610
11612
|
try {
|
|
11611
11613
|
while (true) {
|
|
@@ -11613,7 +11615,7 @@ async function* readTextStreamLines(stream) {
|
|
|
11613
11615
|
if (done) {
|
|
11614
11616
|
break;
|
|
11615
11617
|
}
|
|
11616
|
-
buffer +=
|
|
11618
|
+
buffer += decoder.decode(value, { stream: true });
|
|
11617
11619
|
let newlineIndex = buffer.indexOf(`
|
|
11618
11620
|
`);
|
|
11619
11621
|
while (newlineIndex !== -1) {
|
|
@@ -11627,7 +11629,7 @@ async function* readTextStreamLines(stream) {
|
|
|
11627
11629
|
`);
|
|
11628
11630
|
}
|
|
11629
11631
|
}
|
|
11630
|
-
buffer +=
|
|
11632
|
+
buffer += decoder.decode();
|
|
11631
11633
|
if (buffer.length > 0) {
|
|
11632
11634
|
yield buffer.endsWith("\r") ? buffer.slice(0, -1) : buffer;
|
|
11633
11635
|
}
|
|
@@ -11742,7 +11744,7 @@ function parseLakehouseQueryResponse(responseBody) {
|
|
|
11742
11744
|
}
|
|
11743
11745
|
const metadata = parseMetadataLine(metadataLine, 1);
|
|
11744
11746
|
let columns = [];
|
|
11745
|
-
const
|
|
11747
|
+
const rows = [];
|
|
11746
11748
|
let lineIndex = 1;
|
|
11747
11749
|
if (lineIndex < lines.length) {
|
|
11748
11750
|
const columnsLine = lines[lineIndex];
|
|
@@ -11759,18 +11761,18 @@ function parseLakehouseQueryResponse(responseBody) {
|
|
|
11759
11761
|
if (line === undefined || line.trim().length === 0) {
|
|
11760
11762
|
continue;
|
|
11761
11763
|
}
|
|
11762
|
-
|
|
11764
|
+
rows.push(parseRowLine(line, lineIndex + 1));
|
|
11763
11765
|
}
|
|
11764
|
-
return { metadata, columns, rows
|
|
11766
|
+
return { metadata, columns, rows };
|
|
11765
11767
|
}
|
|
11766
11768
|
async function* parseLakehouseQueryStream(stream) {
|
|
11767
11769
|
const header = await parseLakehouseQueryHeader(readTextStreamLines(stream));
|
|
11768
|
-
const
|
|
11770
|
+
const rows = [];
|
|
11769
11771
|
let lineNumber = header.lineNumber;
|
|
11770
11772
|
if (header.pendingRowLine !== undefined) {
|
|
11771
11773
|
if (header.pendingRowLine.trim().length > 0) {
|
|
11772
11774
|
const row = parseRowLine(header.pendingRowLine, lineNumber);
|
|
11773
|
-
|
|
11775
|
+
rows.push(row);
|
|
11774
11776
|
yield row;
|
|
11775
11777
|
lineNumber += 1;
|
|
11776
11778
|
}
|
|
@@ -11785,17 +11787,17 @@ async function* parseLakehouseQueryStream(stream) {
|
|
|
11785
11787
|
continue;
|
|
11786
11788
|
}
|
|
11787
11789
|
const row = parseRowLine(line, lineNumber);
|
|
11788
|
-
|
|
11790
|
+
rows.push(row);
|
|
11789
11791
|
yield row;
|
|
11790
11792
|
lineNumber += 1;
|
|
11791
11793
|
}
|
|
11792
|
-
return { metadata: header.metadata, columns: header.columns, rows
|
|
11794
|
+
return { metadata: header.metadata, columns: header.columns, rows };
|
|
11793
11795
|
}
|
|
11794
11796
|
|
|
11795
11797
|
// src/lib/execution-context.ts
|
|
11796
|
-
function optionalAuth(
|
|
11798
|
+
function optionalAuth(resolve) {
|
|
11797
11799
|
try {
|
|
11798
|
-
return
|
|
11800
|
+
return resolve();
|
|
11799
11801
|
} catch (error) {
|
|
11800
11802
|
if (error instanceof Error && error.name === "ConfigurationError") {
|
|
11801
11803
|
return;
|
|
@@ -11868,9 +11870,9 @@ function hasLakehouseEnvCredentials() {
|
|
|
11868
11870
|
}
|
|
11869
11871
|
function resolveLakehouseCredential(profileName) {
|
|
11870
11872
|
if (isFromEnvProfile(profileName)) {
|
|
11871
|
-
const
|
|
11872
|
-
if (
|
|
11873
|
-
return
|
|
11873
|
+
const credential = envLakehouseCredential();
|
|
11874
|
+
if (credential) {
|
|
11875
|
+
return credential;
|
|
11874
11876
|
}
|
|
11875
11877
|
throw new ConfigurationError("No lakehouse credentials in the environment configuration. Set ALTERTABLE_BASIC_AUTH_TOKEN or ALTERTABLE_LAKEHOUSE_USERNAME/PASSWORD, or unset the ALTERTABLE_* configuration variables to use a stored profile.");
|
|
11876
11878
|
}
|
|
@@ -11878,7 +11880,7 @@ function resolveLakehouseCredential(profileName) {
|
|
|
11878
11880
|
if (credential) {
|
|
11879
11881
|
return credential;
|
|
11880
11882
|
}
|
|
11881
|
-
throw new ConfigurationError("No credentials. Run 'altertable login', 'altertable profile configure', or set ALTERTABLE_LAKEHOUSE_USERNAME/PASSWORD (or ALTERTABLE_BASIC_AUTH_TOKEN).");
|
|
11883
|
+
throw new ConfigurationError("No lakehouse credentials. Run 'altertable login', 'altertable profile configure', or set ALTERTABLE_LAKEHOUSE_USERNAME/PASSWORD (or ALTERTABLE_BASIC_AUTH_TOKEN).");
|
|
11882
11884
|
}
|
|
11883
11885
|
function getLakehouseAuthHeader(profileName) {
|
|
11884
11886
|
const credential = resolveLakehouseCredential(profileName);
|
|
@@ -11923,11 +11925,11 @@ function getManagementAuthHeader(profileName) {
|
|
|
11923
11925
|
}
|
|
11924
11926
|
function requireManagementEnv(profileName) {
|
|
11925
11927
|
if (isFromEnvProfile(profileName)) {
|
|
11926
|
-
const
|
|
11927
|
-
if (!
|
|
11928
|
+
const env = readEnv("ALTERTABLE_ENV") ?? "";
|
|
11929
|
+
if (!env) {
|
|
11928
11930
|
throw new ConfigurationError("No environment set in the environment configuration. Set ALTERTABLE_ENV.");
|
|
11929
11931
|
}
|
|
11930
|
-
return
|
|
11932
|
+
return env;
|
|
11931
11933
|
}
|
|
11932
11934
|
const env = configGet("api_key_env", profileName);
|
|
11933
11935
|
if (!env) {
|
|
@@ -12343,6 +12345,27 @@ function buildProfileInspectView(profile) {
|
|
|
12343
12345
|
}
|
|
12344
12346
|
return document(section(rows(profileInspectRows(profile))));
|
|
12345
12347
|
}
|
|
12348
|
+
function profileInspectNextSteps(profile, interactive = true) {
|
|
12349
|
+
if (profile.status === "configured")
|
|
12350
|
+
return [];
|
|
12351
|
+
if (interactive)
|
|
12352
|
+
return ["Run: altertable profile configure"];
|
|
12353
|
+
const nextSteps = [];
|
|
12354
|
+
if (profile.auth.management === "none") {
|
|
12355
|
+
nextSteps.push(`Run: printf '%s' "$KEY" | altertable profile configure --api-key-stdin --env <name>`);
|
|
12356
|
+
}
|
|
12357
|
+
if (profile.auth.lakehouse === "none") {
|
|
12358
|
+
nextSteps.push(`Run: printf '%s' "$PASSWORD" | altertable profile configure --user <username> --password-stdin`);
|
|
12359
|
+
}
|
|
12360
|
+
return nextSteps.length > 0 ? nextSteps : ["Run: altertable profile configure"];
|
|
12361
|
+
}
|
|
12362
|
+
function buildProfileInspectResultView(profile, interactive = true) {
|
|
12363
|
+
const nextSteps = profileInspectNextSteps(profile, interactive);
|
|
12364
|
+
return document(...buildProfileInspectView(profile).sections, ...nextSteps.length > 0 ? [section(text(["Next steps:", ...nextSteps]))] : []);
|
|
12365
|
+
}
|
|
12366
|
+
function profileInspectToJson(profile) {
|
|
12367
|
+
return { profile, next_steps: profileInspectNextSteps(profile, false) };
|
|
12368
|
+
}
|
|
12346
12369
|
function formatProfilePrincipal(profile) {
|
|
12347
12370
|
if (profile.principal.email) {
|
|
12348
12371
|
return profile.principal.name ? `${profile.principal.name} <${profile.principal.email}>` : profile.principal.email;
|
|
@@ -12477,19 +12500,19 @@ function managementCredentialRows(credential, organization) {
|
|
|
12477
12500
|
];
|
|
12478
12501
|
}
|
|
12479
12502
|
if (credential.mechanism === "management_oauth") {
|
|
12480
|
-
const
|
|
12503
|
+
const rows = [
|
|
12481
12504
|
{ label: "Authentication:", value: "browser login (OAuth)" },
|
|
12482
12505
|
{ label: "Environment:", value: credential.environment ?? "none", level: 1 }
|
|
12483
12506
|
];
|
|
12484
12507
|
const displayOrganization = organizationDisplay(organization);
|
|
12485
12508
|
if (displayOrganization) {
|
|
12486
|
-
|
|
12509
|
+
rows.push({ label: "Organization:", value: displayOrganization, level: 1 });
|
|
12487
12510
|
}
|
|
12488
12511
|
const expires = timestampMsDisplay(credential.expires);
|
|
12489
12512
|
if (expires) {
|
|
12490
|
-
|
|
12513
|
+
rows.push({ label: "Expires:", value: expires, level: 1 });
|
|
12491
12514
|
}
|
|
12492
|
-
return
|
|
12515
|
+
return rows;
|
|
12493
12516
|
}
|
|
12494
12517
|
return [
|
|
12495
12518
|
{ label: "Authentication:", value: "management API key" },
|
|
@@ -12502,22 +12525,22 @@ function lakehouseCredentialRows(credential) {
|
|
|
12502
12525
|
return [];
|
|
12503
12526
|
}
|
|
12504
12527
|
if (credential.mechanism === "lakehouse_basic_token") {
|
|
12505
|
-
const
|
|
12528
|
+
const rows = [
|
|
12506
12529
|
{
|
|
12507
12530
|
label: "Authentication:",
|
|
12508
12531
|
value: credential.source === "environment" ? "lakehouse Basic token (environment)" : "lakehouse Basic token"
|
|
12509
12532
|
}
|
|
12510
12533
|
];
|
|
12511
12534
|
if (credential.source === "environment") {
|
|
12512
|
-
|
|
12535
|
+
rows.push({ label: "source:", value: "ALTERTABLE_BASIC_AUTH_TOKEN", level: 1 });
|
|
12513
12536
|
} else {
|
|
12514
|
-
|
|
12537
|
+
rows.push({ label: "basic token:", value: credential.basic_token ?? "set", level: 1 });
|
|
12515
12538
|
const expires = timestampMsDisplay(credential.expires);
|
|
12516
12539
|
if (expires) {
|
|
12517
|
-
|
|
12540
|
+
rows.push({ label: "expires:", value: expires, level: 1 });
|
|
12518
12541
|
}
|
|
12519
12542
|
}
|
|
12520
|
-
return
|
|
12543
|
+
return rows;
|
|
12521
12544
|
}
|
|
12522
12545
|
return [
|
|
12523
12546
|
{
|
|
@@ -12541,8 +12564,8 @@ function configureAuthenticationRows(data, planes) {
|
|
|
12541
12564
|
}
|
|
12542
12565
|
|
|
12543
12566
|
// src/lib/profile/render.ts
|
|
12544
|
-
function
|
|
12545
|
-
return renderDocumentText(
|
|
12567
|
+
function formatProfileInspectResult(profile, interactive = true) {
|
|
12568
|
+
return renderDocumentText(buildProfileInspectResultView(profile, interactive));
|
|
12546
12569
|
}
|
|
12547
12570
|
function formatProfileStatus(result) {
|
|
12548
12571
|
return renderDocumentText(buildProfileStatusView(result));
|
|
@@ -12550,8 +12573,8 @@ function formatProfileStatus(result) {
|
|
|
12550
12573
|
function formatProfileList(profiles) {
|
|
12551
12574
|
return renderDocumentText(buildProfileListView(profiles));
|
|
12552
12575
|
}
|
|
12553
|
-
function renderConfigureRows(
|
|
12554
|
-
return renderRows(
|
|
12576
|
+
function renderConfigureRows(rows, options) {
|
|
12577
|
+
return renderRows(rows, {
|
|
12555
12578
|
indent: options.indent ?? TERMINAL_INDENT,
|
|
12556
12579
|
labelWidth: options.labelWidth ?? TERMINAL_LABEL_WIDTH,
|
|
12557
12580
|
nestedIndent: nestedIndent(options.indent),
|
|
@@ -12953,11 +12976,11 @@ var getClosingCode = (openingCode) => {
|
|
|
12953
12976
|
};
|
|
12954
12977
|
var wrapAnsiCode = (code) => `${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
12955
12978
|
var wrapAnsiHyperlink = (url) => `${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
12956
|
-
var wrapWord = (
|
|
12979
|
+
var wrapWord = (rows, word, columns) => {
|
|
12957
12980
|
const characters = word[Symbol.iterator]();
|
|
12958
12981
|
let isInsideEscape = false;
|
|
12959
12982
|
let isInsideLinkEscape = false;
|
|
12960
|
-
let lastRow =
|
|
12983
|
+
let lastRow = rows.at(-1);
|
|
12961
12984
|
let visible = lastRow === undefined ? 0 : dist_default2(lastRow);
|
|
12962
12985
|
let currentCharacter = characters.next();
|
|
12963
12986
|
let nextCharacter = characters.next();
|
|
@@ -12966,9 +12989,9 @@ var wrapWord = (rows2, word, columns) => {
|
|
|
12966
12989
|
const character = currentCharacter.value;
|
|
12967
12990
|
const characterLength = dist_default2(character);
|
|
12968
12991
|
if (visible + characterLength <= columns) {
|
|
12969
|
-
|
|
12992
|
+
rows[rows.length - 1] += character;
|
|
12970
12993
|
} else {
|
|
12971
|
-
|
|
12994
|
+
rows.push(character);
|
|
12972
12995
|
visible = 0;
|
|
12973
12996
|
}
|
|
12974
12997
|
if (character === ESC || character === CSI) {
|
|
@@ -12987,7 +13010,7 @@ var wrapWord = (rows2, word, columns) => {
|
|
|
12987
13010
|
} else {
|
|
12988
13011
|
visible += characterLength;
|
|
12989
13012
|
if (visible === columns && !nextCharacter.done) {
|
|
12990
|
-
|
|
13013
|
+
rows.push("");
|
|
12991
13014
|
visible = 0;
|
|
12992
13015
|
}
|
|
12993
13016
|
}
|
|
@@ -12995,9 +13018,9 @@ var wrapWord = (rows2, word, columns) => {
|
|
|
12995
13018
|
nextCharacter = characters.next();
|
|
12996
13019
|
rawCharacterIndex += character.length;
|
|
12997
13020
|
}
|
|
12998
|
-
lastRow =
|
|
12999
|
-
if (!visible && lastRow !== undefined && lastRow.length &&
|
|
13000
|
-
|
|
13021
|
+
lastRow = rows.at(-1);
|
|
13022
|
+
if (!visible && lastRow !== undefined && lastRow.length && rows.length > 1) {
|
|
13023
|
+
rows[rows.length - 2] += rows.pop();
|
|
13001
13024
|
}
|
|
13002
13025
|
};
|
|
13003
13026
|
var stringVisibleTrimSpacesRight = (string) => {
|
|
@@ -13022,25 +13045,25 @@ var exec = (string, columns, options = {}) => {
|
|
|
13022
13045
|
let escapeCode;
|
|
13023
13046
|
let escapeUrl;
|
|
13024
13047
|
const words = string.split(" ");
|
|
13025
|
-
let
|
|
13048
|
+
let rows = [""];
|
|
13026
13049
|
let rowLength = 0;
|
|
13027
13050
|
for (let index = 0;index < words.length; index++) {
|
|
13028
13051
|
const word = words[index];
|
|
13029
13052
|
if (options.trim !== false) {
|
|
13030
|
-
const row =
|
|
13053
|
+
const row = rows.at(-1) ?? "";
|
|
13031
13054
|
const trimmed = row.trimStart();
|
|
13032
13055
|
if (row.length !== trimmed.length) {
|
|
13033
|
-
|
|
13056
|
+
rows[rows.length - 1] = trimmed;
|
|
13034
13057
|
rowLength = dist_default2(trimmed);
|
|
13035
13058
|
}
|
|
13036
13059
|
}
|
|
13037
13060
|
if (index !== 0) {
|
|
13038
13061
|
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
13039
|
-
|
|
13062
|
+
rows.push("");
|
|
13040
13063
|
rowLength = 0;
|
|
13041
13064
|
}
|
|
13042
13065
|
if (rowLength || options.trim === false) {
|
|
13043
|
-
|
|
13066
|
+
rows[rows.length - 1] += " ";
|
|
13044
13067
|
rowLength++;
|
|
13045
13068
|
}
|
|
13046
13069
|
}
|
|
@@ -13050,33 +13073,33 @@ var exec = (string, columns, options = {}) => {
|
|
|
13050
13073
|
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
13051
13074
|
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
13052
13075
|
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
13053
|
-
|
|
13076
|
+
rows.push("");
|
|
13054
13077
|
}
|
|
13055
|
-
wrapWord(
|
|
13056
|
-
rowLength = dist_default2(
|
|
13078
|
+
wrapWord(rows, word, columns);
|
|
13079
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
13057
13080
|
continue;
|
|
13058
13081
|
}
|
|
13059
13082
|
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
13060
13083
|
if (options.wordWrap === false && rowLength < columns) {
|
|
13061
|
-
wrapWord(
|
|
13062
|
-
rowLength = dist_default2(
|
|
13084
|
+
wrapWord(rows, word, columns);
|
|
13085
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
13063
13086
|
continue;
|
|
13064
13087
|
}
|
|
13065
|
-
|
|
13088
|
+
rows.push("");
|
|
13066
13089
|
rowLength = 0;
|
|
13067
13090
|
}
|
|
13068
13091
|
if (rowLength + wordLength > columns && options.wordWrap === false) {
|
|
13069
|
-
wrapWord(
|
|
13070
|
-
rowLength = dist_default2(
|
|
13092
|
+
wrapWord(rows, word, columns);
|
|
13093
|
+
rowLength = dist_default2(rows.at(-1) ?? "");
|
|
13071
13094
|
continue;
|
|
13072
13095
|
}
|
|
13073
|
-
|
|
13096
|
+
rows[rows.length - 1] += word;
|
|
13074
13097
|
rowLength += wordLength;
|
|
13075
13098
|
}
|
|
13076
13099
|
if (options.trim !== false) {
|
|
13077
|
-
|
|
13100
|
+
rows = rows.map((row) => stringVisibleTrimSpacesRight(row));
|
|
13078
13101
|
}
|
|
13079
|
-
const preString =
|
|
13102
|
+
const preString = rows.join(`
|
|
13080
13103
|
`);
|
|
13081
13104
|
let inSurrogate = false;
|
|
13082
13105
|
for (let i = 0;i < preString.length; i++) {
|
|
@@ -13189,14 +13212,14 @@ function diffLines(i, s) {
|
|
|
13189
13212
|
if (i === s)
|
|
13190
13213
|
return;
|
|
13191
13214
|
const e = i.split(`
|
|
13192
|
-
`),
|
|
13193
|
-
`), r = Math.max(e.length,
|
|
13215
|
+
`), t = s.split(`
|
|
13216
|
+
`), r = Math.max(e.length, t.length), f = [];
|
|
13194
13217
|
for (let n = 0;n < r; n++)
|
|
13195
|
-
e[n] !==
|
|
13218
|
+
e[n] !== t[n] && f.push(n);
|
|
13196
13219
|
return {
|
|
13197
13220
|
lines: f,
|
|
13198
13221
|
numLinesBefore: e.length,
|
|
13199
|
-
numLinesAfter:
|
|
13222
|
+
numLinesAfter: t.length,
|
|
13200
13223
|
numLines: r
|
|
13201
13224
|
};
|
|
13202
13225
|
}
|
|
@@ -13211,7 +13234,7 @@ function setRawMode(e, r) {
|
|
|
13211
13234
|
}
|
|
13212
13235
|
var getColumns = (e) => ("columns" in e) && typeof e.columns == "number" ? e.columns : 80;
|
|
13213
13236
|
var getRows = (e) => ("rows" in e) && typeof e.rows == "number" ? e.rows : 20;
|
|
13214
|
-
function wrapTextWithPrefix(e, r, o,
|
|
13237
|
+
function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
|
|
13215
13238
|
const f = getColumns(e ?? stdout);
|
|
13216
13239
|
return wrapAnsi(r, f - o.length, {
|
|
13217
13240
|
hard: true,
|
|
@@ -13219,7 +13242,7 @@ function wrapTextWithPrefix(e, r, o, t2 = o, s = o, n) {
|
|
|
13219
13242
|
}).split(`
|
|
13220
13243
|
`).map((c, i, m) => {
|
|
13221
13244
|
const d = n ? n(c, i) : c;
|
|
13222
|
-
return i === 0 ? `${
|
|
13245
|
+
return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
|
|
13223
13246
|
}).join(`
|
|
13224
13247
|
`);
|
|
13225
13248
|
}
|
|
@@ -13248,35 +13271,35 @@ class V {
|
|
|
13248
13271
|
error = "";
|
|
13249
13272
|
value;
|
|
13250
13273
|
userInput = "";
|
|
13251
|
-
constructor(
|
|
13252
|
-
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } =
|
|
13274
|
+
constructor(t, e = true) {
|
|
13275
|
+
const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
|
|
13253
13276
|
this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
|
|
13254
13277
|
}
|
|
13255
13278
|
unsubscribe() {
|
|
13256
13279
|
this._subscribers.clear();
|
|
13257
13280
|
}
|
|
13258
|
-
setSubscriber(
|
|
13259
|
-
const i = this._subscribers.get(
|
|
13260
|
-
i.push(e), this._subscribers.set(
|
|
13281
|
+
setSubscriber(t, e) {
|
|
13282
|
+
const i = this._subscribers.get(t) ?? [];
|
|
13283
|
+
i.push(e), this._subscribers.set(t, i);
|
|
13261
13284
|
}
|
|
13262
|
-
on(
|
|
13263
|
-
this.setSubscriber(
|
|
13285
|
+
on(t, e) {
|
|
13286
|
+
this.setSubscriber(t, { cb: e });
|
|
13264
13287
|
}
|
|
13265
|
-
once(
|
|
13266
|
-
this.setSubscriber(
|
|
13288
|
+
once(t, e) {
|
|
13289
|
+
this.setSubscriber(t, { cb: e, once: true });
|
|
13267
13290
|
}
|
|
13268
|
-
emit(
|
|
13269
|
-
const i = this._subscribers.get(
|
|
13291
|
+
emit(t, ...e) {
|
|
13292
|
+
const i = this._subscribers.get(t) ?? [], n = [];
|
|
13270
13293
|
for (const s of i)
|
|
13271
13294
|
s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
|
|
13272
13295
|
for (const s of n)
|
|
13273
13296
|
s();
|
|
13274
13297
|
}
|
|
13275
13298
|
prompt() {
|
|
13276
|
-
return new Promise((
|
|
13299
|
+
return new Promise((t) => {
|
|
13277
13300
|
if (this._abortSignal) {
|
|
13278
13301
|
if (this._abortSignal.aborted)
|
|
13279
|
-
return this.state = "cancel", this.close(),
|
|
13302
|
+
return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
|
|
13280
13303
|
this._abortSignal.addEventListener("abort", () => {
|
|
13281
13304
|
this.state = "cancel", this.close();
|
|
13282
13305
|
}, { once: true });
|
|
@@ -13288,68 +13311,68 @@ class V {
|
|
|
13288
13311
|
escapeCodeTimeout: 50,
|
|
13289
13312
|
terminal: true
|
|
13290
13313
|
}), this.rl.prompt(), this.opts.initialUserInput !== undefined && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
13291
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false),
|
|
13314
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
|
|
13292
13315
|
}), this.once("cancel", () => {
|
|
13293
|
-
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false),
|
|
13316
|
+
this.output.write(import_sisteransi.cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
|
|
13294
13317
|
});
|
|
13295
13318
|
});
|
|
13296
13319
|
}
|
|
13297
|
-
_isActionKey(
|
|
13298
|
-
return
|
|
13320
|
+
_isActionKey(t, e) {
|
|
13321
|
+
return t === "\t";
|
|
13299
13322
|
}
|
|
13300
|
-
_shouldSubmit(
|
|
13323
|
+
_shouldSubmit(t, e) {
|
|
13301
13324
|
return true;
|
|
13302
13325
|
}
|
|
13303
|
-
_setValue(
|
|
13304
|
-
this.value =
|
|
13326
|
+
_setValue(t) {
|
|
13327
|
+
this.value = t, this.emit("value", this.value);
|
|
13305
13328
|
}
|
|
13306
|
-
_setUserInput(
|
|
13307
|
-
this.userInput =
|
|
13329
|
+
_setUserInput(t, e) {
|
|
13330
|
+
this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
13308
13331
|
}
|
|
13309
13332
|
_clearUserInput() {
|
|
13310
13333
|
this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
|
|
13311
13334
|
}
|
|
13312
|
-
onKeypress(
|
|
13313
|
-
if (this._track && e.name !== "return" && (e.name && this._isActionKey(
|
|
13335
|
+
onKeypress(t, e) {
|
|
13336
|
+
if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
|
|
13314
13337
|
if (this.opts.validate) {
|
|
13315
13338
|
const i = runValidation(this.opts.validate, this.value);
|
|
13316
13339
|
i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
|
|
13317
13340
|
}
|
|
13318
13341
|
this.state !== "error" && (this.state = "submit");
|
|
13319
13342
|
}
|
|
13320
|
-
isActionKey([
|
|
13343
|
+
isActionKey([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
13321
13344
|
}
|
|
13322
13345
|
close() {
|
|
13323
13346
|
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
13324
13347
|
`), setRawMode(this.input, false), this.rl?.close(), this.rl = undefined, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
13325
13348
|
}
|
|
13326
13349
|
restoreCursor() {
|
|
13327
|
-
const
|
|
13350
|
+
const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
|
|
13328
13351
|
`).length - 1;
|
|
13329
|
-
this.output.write(import_sisteransi.cursor.move(-999,
|
|
13352
|
+
this.output.write(import_sisteransi.cursor.move(-999, t * -1));
|
|
13330
13353
|
}
|
|
13331
13354
|
render() {
|
|
13332
|
-
const
|
|
13355
|
+
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
13333
13356
|
hard: true,
|
|
13334
13357
|
trim: false
|
|
13335
13358
|
});
|
|
13336
|
-
if (
|
|
13359
|
+
if (t !== this._prevFrame) {
|
|
13337
13360
|
if (this.state === "initial")
|
|
13338
13361
|
this.output.write(import_sisteransi.cursor.hide);
|
|
13339
13362
|
else {
|
|
13340
|
-
const e = diffLines(this._prevFrame,
|
|
13363
|
+
const e = diffLines(this._prevFrame, t), i = getRows(this.output);
|
|
13341
13364
|
if (this.restoreCursor(), e) {
|
|
13342
13365
|
const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
|
|
13343
13366
|
let r = e.lines.find((o) => o >= n);
|
|
13344
13367
|
if (r === undefined) {
|
|
13345
|
-
this._prevFrame =
|
|
13368
|
+
this._prevFrame = t;
|
|
13346
13369
|
return;
|
|
13347
13370
|
}
|
|
13348
13371
|
if (e.lines.length === 1) {
|
|
13349
13372
|
this.output.write(import_sisteransi.cursor.move(0, r - s)), this.output.write(import_sisteransi.erase.lines(1));
|
|
13350
|
-
const o =
|
|
13373
|
+
const o = t.split(`
|
|
13351
13374
|
`);
|
|
13352
|
-
this.output.write(o[r]), this._prevFrame =
|
|
13375
|
+
this.output.write(o[r]), this._prevFrame = t, this.output.write(import_sisteransi.cursor.move(0, o.length - r - 1));
|
|
13353
13376
|
return;
|
|
13354
13377
|
} else if (e.lines.length > 1) {
|
|
13355
13378
|
if (n < s)
|
|
@@ -13359,16 +13382,16 @@ class V {
|
|
|
13359
13382
|
h > 0 && this.output.write(import_sisteransi.cursor.move(0, h));
|
|
13360
13383
|
}
|
|
13361
13384
|
this.output.write(import_sisteransi.erase.down());
|
|
13362
|
-
const f =
|
|
13385
|
+
const f = t.split(`
|
|
13363
13386
|
`).slice(r);
|
|
13364
13387
|
this.output.write(f.join(`
|
|
13365
|
-
`)), this._prevFrame =
|
|
13388
|
+
`)), this._prevFrame = t;
|
|
13366
13389
|
return;
|
|
13367
13390
|
}
|
|
13368
13391
|
}
|
|
13369
13392
|
this.output.write(import_sisteransi.erase.down());
|
|
13370
13393
|
}
|
|
13371
|
-
this.output.write(
|
|
13394
|
+
this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
|
|
13372
13395
|
}
|
|
13373
13396
|
}
|
|
13374
13397
|
}
|
|
@@ -13379,8 +13402,8 @@ class r extends V {
|
|
|
13379
13402
|
get _value() {
|
|
13380
13403
|
return this.cursor === 0;
|
|
13381
13404
|
}
|
|
13382
|
-
constructor(
|
|
13383
|
-
super(
|
|
13405
|
+
constructor(t) {
|
|
13406
|
+
super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
|
|
13384
13407
|
this.value = this._value;
|
|
13385
13408
|
}), this.on("confirm", (i) => {
|
|
13386
13409
|
this.output.write(import_sisteransi.cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
|
|
@@ -13400,18 +13423,18 @@ var u$1 = class u extends V {
|
|
|
13400
13423
|
get userInputWithCursor() {
|
|
13401
13424
|
if (this.state === "submit" || this.state === "cancel")
|
|
13402
13425
|
return this.masked;
|
|
13403
|
-
const
|
|
13404
|
-
if (this.cursor >=
|
|
13426
|
+
const t = this.userInput;
|
|
13427
|
+
if (this.cursor >= t.length)
|
|
13405
13428
|
return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
|
|
13406
|
-
const s = this.masked,
|
|
13407
|
-
return `${
|
|
13429
|
+
const s = this.masked, r = s.slice(0, this.cursor), i = s.slice(this.cursor, this.cursor + 1), o = s.slice(this.cursor + 1);
|
|
13430
|
+
return `${r}${styleText("inverse", i)}${o}`;
|
|
13408
13431
|
}
|
|
13409
13432
|
clear() {
|
|
13410
13433
|
this._clearUserInput();
|
|
13411
13434
|
}
|
|
13412
|
-
constructor({ mask:
|
|
13413
|
-
super(s), this._mask =
|
|
13414
|
-
this._setValue(
|
|
13435
|
+
constructor({ mask: t, ...s }) {
|
|
13436
|
+
super(s), this._mask = t ?? "\u2022", this.on("userInput", (r) => {
|
|
13437
|
+
this._setValue(r);
|
|
13415
13438
|
}), this.on("finalize", () => {
|
|
13416
13439
|
this.value === undefined && (this.value = "");
|
|
13417
13440
|
});
|
|
@@ -13429,8 +13452,8 @@ var n$1 = class n extends V {
|
|
|
13429
13452
|
}
|
|
13430
13453
|
constructor(e) {
|
|
13431
13454
|
super(e, false), this.options = e.options;
|
|
13432
|
-
const o = this.options.findIndex(({ value: s }) => s === e.initialValue),
|
|
13433
|
-
this.cursor = this.options[
|
|
13455
|
+
const o = this.options.findIndex(({ value: s }) => s === e.initialValue), t = o === -1 ? 0 : o;
|
|
13456
|
+
this.cursor = this.options[t]?.disabled ? findCursor(t, 1, this.options) : t, this.changeValue(), this.on("cursor", (s) => {
|
|
13434
13457
|
switch (s) {
|
|
13435
13458
|
case "left":
|
|
13436
13459
|
case "up":
|
|
@@ -13445,27 +13468,27 @@ var n$1 = class n extends V {
|
|
|
13445
13468
|
});
|
|
13446
13469
|
}
|
|
13447
13470
|
};
|
|
13448
|
-
class
|
|
13471
|
+
class n extends V {
|
|
13449
13472
|
get userInputWithCursor() {
|
|
13450
13473
|
if (this.state === "submit")
|
|
13451
13474
|
return this.userInput;
|
|
13452
|
-
const
|
|
13453
|
-
if (this.cursor >=
|
|
13475
|
+
const t = this.userInput;
|
|
13476
|
+
if (this.cursor >= t.length)
|
|
13454
13477
|
return `${this.userInput}\u2588`;
|
|
13455
|
-
const
|
|
13456
|
-
return `${
|
|
13478
|
+
const r = t.slice(0, this.cursor), s = t.slice(this.cursor, this.cursor + 1), e = t.slice(this.cursor + 1);
|
|
13479
|
+
return `${r}${styleText("inverse", s)}${e}`;
|
|
13457
13480
|
}
|
|
13458
13481
|
get cursor() {
|
|
13459
13482
|
return this._cursor;
|
|
13460
13483
|
}
|
|
13461
|
-
constructor(
|
|
13484
|
+
constructor(t) {
|
|
13462
13485
|
super({
|
|
13463
|
-
...
|
|
13464
|
-
initialUserInput:
|
|
13465
|
-
}), this.on("userInput", (
|
|
13466
|
-
this._setValue(
|
|
13486
|
+
...t,
|
|
13487
|
+
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
13488
|
+
}), this.on("userInput", (r) => {
|
|
13489
|
+
this._setValue(r);
|
|
13467
13490
|
}), this.on("finalize", () => {
|
|
13468
|
-
this.value || (this.value =
|
|
13491
|
+
this.value || (this.value = t.defaultValue), this.value === undefined && (this.value = "");
|
|
13469
13492
|
});
|
|
13470
13493
|
}
|
|
13471
13494
|
}
|
|
@@ -13534,24 +13557,24 @@ var symbolBar = (o) => {
|
|
|
13534
13557
|
}
|
|
13535
13558
|
};
|
|
13536
13559
|
function formatInstructionFooter(o, e) {
|
|
13537
|
-
const
|
|
13538
|
-
return e &&
|
|
13560
|
+
const r = [`${e ? `${styleText2("cyan", S_BAR)} ` : ""}${o.join(" \u2022 ")}`];
|
|
13561
|
+
return e && r.push(styleText2("cyan", S_BAR_END)), r;
|
|
13539
13562
|
}
|
|
13540
13563
|
var I = (l, e, w, p, b, C = false) => {
|
|
13541
|
-
let
|
|
13564
|
+
let r = e, O = 0;
|
|
13542
13565
|
if (C)
|
|
13543
13566
|
for (let i = p - 1;i >= w; i--) {
|
|
13544
13567
|
const m = l[i];
|
|
13545
|
-
if (m && (
|
|
13568
|
+
if (m && (r -= m.length), O++, r <= b)
|
|
13546
13569
|
break;
|
|
13547
13570
|
}
|
|
13548
13571
|
else
|
|
13549
13572
|
for (let i = w;i < p; i++) {
|
|
13550
13573
|
const m = l[i];
|
|
13551
|
-
if (m && (
|
|
13574
|
+
if (m && (r -= m.length), O++, r <= b)
|
|
13552
13575
|
break;
|
|
13553
13576
|
}
|
|
13554
|
-
return { lineCount:
|
|
13577
|
+
return { lineCount: r, removals: O };
|
|
13555
13578
|
};
|
|
13556
13579
|
var limitOptions = ({
|
|
13557
13580
|
cursor: l,
|
|
@@ -13560,64 +13583,64 @@ var limitOptions = ({
|
|
|
13560
13583
|
output: p = process.stdout,
|
|
13561
13584
|
maxItems: b = Number.POSITIVE_INFINITY,
|
|
13562
13585
|
columnPadding: C = 0,
|
|
13563
|
-
rowPadding:
|
|
13586
|
+
rowPadding: r = 4
|
|
13564
13587
|
}) => {
|
|
13565
|
-
const i = getColumns(p) - C, m = getRows(p), M = styleText2("dim", "..."), v = Math.max(m -
|
|
13588
|
+
const i = getColumns(p) - C, m = getRows(p), M = styleText2("dim", "..."), v = Math.max(m - r, 0), a = Math.max(Math.min(b, v), 5);
|
|
13566
13589
|
let f = 0;
|
|
13567
|
-
l >=
|
|
13568
|
-
let d =
|
|
13569
|
-
const W = Math.min(f +
|
|
13590
|
+
l >= a - 3 && (f = Math.max(Math.min(l - a + 3, e.length - a), 0));
|
|
13591
|
+
let d = a < e.length && f > 0, c = a < e.length && f + a < e.length;
|
|
13592
|
+
const W = Math.min(f + a, e.length), s = [];
|
|
13570
13593
|
let g = 0;
|
|
13571
13594
|
d && g++, c && g++;
|
|
13572
13595
|
const T = f + (d ? 1 : 0), y = W - (c ? 1 : 0);
|
|
13573
|
-
for (let
|
|
13574
|
-
const
|
|
13596
|
+
for (let t = T;t < y; t++) {
|
|
13597
|
+
const n = e[t], o = n ? w(n, t === l) : "", h = wrapAnsi(o, i, {
|
|
13575
13598
|
hard: true,
|
|
13576
13599
|
trim: false
|
|
13577
13600
|
}).split(`
|
|
13578
13601
|
`);
|
|
13579
|
-
s.push(
|
|
13602
|
+
s.push(h), g += h.length;
|
|
13580
13603
|
}
|
|
13581
13604
|
if (g > v) {
|
|
13582
|
-
let
|
|
13583
|
-
const
|
|
13584
|
-
let
|
|
13585
|
-
const L = () => I(s, o, 0,
|
|
13586
|
-
d ? ({ lineCount: o, removals:
|
|
13605
|
+
let t = 0, n = 0, o = g;
|
|
13606
|
+
const h = l - T;
|
|
13607
|
+
let u = v;
|
|
13608
|
+
const L = () => I(s, o, 0, h, u), E = () => I(s, o, h + 1, s.length, u, true);
|
|
13609
|
+
d ? ({ lineCount: o, removals: t } = L(), o > u && (c || (u -= 1), { lineCount: o, removals: n } = E())) : (c || (u -= 1), { lineCount: o, removals: n } = E(), o > u && (u -= 1, { lineCount: o, removals: t } = L())), t > 0 && (d = true, s.splice(0, t)), n > 0 && (c = true, s.splice(s.length - n, n));
|
|
13587
13610
|
}
|
|
13588
13611
|
const x = [];
|
|
13589
13612
|
d && x.push(M);
|
|
13590
|
-
for (const
|
|
13591
|
-
for (const
|
|
13592
|
-
x.push(
|
|
13613
|
+
for (const t of s)
|
|
13614
|
+
for (const n of t)
|
|
13615
|
+
x.push(n);
|
|
13593
13616
|
return c && x.push(M), x;
|
|
13594
13617
|
};
|
|
13595
13618
|
var confirm = (i) => {
|
|
13596
|
-
const
|
|
13619
|
+
const a = i.active ?? "Yes", s = i.inactive ?? "No";
|
|
13597
13620
|
return new r({
|
|
13598
|
-
active:
|
|
13621
|
+
active: a,
|
|
13599
13622
|
inactive: s,
|
|
13600
13623
|
signal: i.signal,
|
|
13601
13624
|
input: i.input,
|
|
13602
13625
|
output: i.output,
|
|
13603
13626
|
initialValue: i.initialValue ?? true,
|
|
13604
13627
|
render() {
|
|
13605
|
-
const e = i.withGuide ?? settings.withGuide,
|
|
13628
|
+
const e = i.withGuide ?? settings.withGuide, u = `${symbol(this.state)} `, l = e ? `${styleText2("gray", S_BAR)} ` : "", f = wrapTextWithPrefix(i.output, i.message, l, u), o = `${e ? `${styleText2("gray", S_BAR)}
|
|
13606
13629
|
` : ""}${f}
|
|
13607
|
-
`, c = this.value ?
|
|
13630
|
+
`, c = this.value ? a : s;
|
|
13608
13631
|
switch (this.state) {
|
|
13609
13632
|
case "submit": {
|
|
13610
|
-
const
|
|
13611
|
-
return `${o}${
|
|
13633
|
+
const r = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
13634
|
+
return `${o}${r}${styleText2("dim", c)}`;
|
|
13612
13635
|
}
|
|
13613
13636
|
case "cancel": {
|
|
13614
|
-
const
|
|
13615
|
-
return `${o}${
|
|
13637
|
+
const r = e ? `${styleText2("gray", S_BAR)} ` : "";
|
|
13638
|
+
return `${o}${r}${styleText2(["strikethrough", "dim"], c)}${e ? `
|
|
13616
13639
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
13617
13640
|
}
|
|
13618
13641
|
default: {
|
|
13619
|
-
const
|
|
13620
|
-
return `${o}${
|
|
13642
|
+
const r = e ? `${styleText2("cyan", S_BAR)} ` : "", g = e ? styleText2("cyan", S_BAR_END) : "";
|
|
13643
|
+
return `${o}${r}${this.value ? `${styleText2("green", S_RADIO_ACTIVE)} ${a}` : `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", a)}`}${i.vertical ? e ? `
|
|
13621
13644
|
${styleText2("cyan", S_BAR)} ` : `
|
|
13622
13645
|
` : ` ${styleText2("dim", "/")} `}${this.value ? `${styleText2("dim", S_RADIO_INACTIVE)} ${styleText2("dim", s)}` : `${styleText2("green", S_RADIO_ACTIVE)} ${s}`}
|
|
13623
13646
|
${g}
|
|
@@ -13632,43 +13655,43 @@ var MULTISELECT_INSTRUCTIONS = [
|
|
|
13632
13655
|
`${styleText2("dim", "Space:")} select`,
|
|
13633
13656
|
`${styleText2("dim", "Enter:")} confirm`
|
|
13634
13657
|
];
|
|
13635
|
-
var password = (
|
|
13636
|
-
validate:
|
|
13637
|
-
mask:
|
|
13638
|
-
signal:
|
|
13639
|
-
input:
|
|
13640
|
-
output:
|
|
13658
|
+
var password = (r) => new u$1({
|
|
13659
|
+
validate: r.validate,
|
|
13660
|
+
mask: r.mask ?? S_PASSWORD_MASK,
|
|
13661
|
+
signal: r.signal,
|
|
13662
|
+
input: r.input,
|
|
13663
|
+
output: r.output,
|
|
13641
13664
|
render() {
|
|
13642
|
-
const e =
|
|
13643
|
-
` : ""}${symbol(this.state)} ${
|
|
13665
|
+
const e = r.withGuide ?? settings.withGuide, o = `${e ? `${styleText2("gray", S_BAR)}
|
|
13666
|
+
` : ""}${symbol(this.state)} ${r.message}
|
|
13644
13667
|
`, c = this.userInputWithCursor, i = this.masked;
|
|
13645
13668
|
switch (this.state) {
|
|
13646
13669
|
case "error": {
|
|
13647
|
-
const s = e ? `${styleText2("yellow", S_BAR)} ` : "",
|
|
13648
|
-
return
|
|
13670
|
+
const s = e ? `${styleText2("yellow", S_BAR)} ` : "", n = e ? `${styleText2("yellow", S_BAR_END)} ` : "", l = i ?? "";
|
|
13671
|
+
return r.clearOnError && this.clear(), `${o.trim()}
|
|
13649
13672
|
${s}${l}
|
|
13650
|
-
${
|
|
13673
|
+
${n}${styleText2("yellow", this.error)}
|
|
13651
13674
|
`;
|
|
13652
13675
|
}
|
|
13653
13676
|
case "submit": {
|
|
13654
|
-
const s = e ? `${styleText2("gray", S_BAR)} ` : "",
|
|
13655
|
-
return `${o}${s}${
|
|
13677
|
+
const s = e ? `${styleText2("gray", S_BAR)} ` : "", n = i ? styleText2("dim", i) : "";
|
|
13678
|
+
return `${o}${s}${n}`;
|
|
13656
13679
|
}
|
|
13657
13680
|
case "cancel": {
|
|
13658
|
-
const s = e ? `${styleText2("gray", S_BAR)} ` : "",
|
|
13659
|
-
return `${o}${s}${
|
|
13681
|
+
const s = e ? `${styleText2("gray", S_BAR)} ` : "", n = i ? styleText2(["strikethrough", "dim"], i) : "";
|
|
13682
|
+
return `${o}${s}${n}${i && e ? `
|
|
13660
13683
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
13661
13684
|
}
|
|
13662
13685
|
default: {
|
|
13663
|
-
const s = e ? `${styleText2("cyan", S_BAR)} ` : "",
|
|
13686
|
+
const s = e ? `${styleText2("cyan", S_BAR)} ` : "", n = e ? styleText2("cyan", S_BAR_END) : "";
|
|
13664
13687
|
return `${o}${s}${c}
|
|
13665
|
-
${
|
|
13688
|
+
${n}
|
|
13666
13689
|
`;
|
|
13667
13690
|
}
|
|
13668
13691
|
}
|
|
13669
13692
|
}
|
|
13670
13693
|
}).prompt();
|
|
13671
|
-
var
|
|
13694
|
+
var u2 = {
|
|
13672
13695
|
light: unicodeOr("\u2500", "-"),
|
|
13673
13696
|
heavy: unicodeOr("\u2501", "="),
|
|
13674
13697
|
block: unicodeOr("\u2588", "#")
|
|
@@ -13677,62 +13700,62 @@ var SELECT_INSTRUCTIONS = [
|
|
|
13677
13700
|
`${styleText2("dim", "\u2191/\u2193")} to navigate`,
|
|
13678
13701
|
`${styleText2("dim", "Enter:")} confirm`
|
|
13679
13702
|
];
|
|
13680
|
-
var c = (
|
|
13681
|
-
`) ?
|
|
13703
|
+
var c = (t, o) => t.includes(`
|
|
13704
|
+
`) ? t.split(`
|
|
13682
13705
|
`).map((d) => o(d)).join(`
|
|
13683
|
-
`) : o(
|
|
13684
|
-
var select = (
|
|
13685
|
-
const o = (
|
|
13686
|
-
if (
|
|
13706
|
+
`) : o(t);
|
|
13707
|
+
var select = (t) => {
|
|
13708
|
+
const o = (n, m) => {
|
|
13709
|
+
if (n === undefined)
|
|
13687
13710
|
return "";
|
|
13688
|
-
const s =
|
|
13711
|
+
const s = n.label ?? String(n.value);
|
|
13689
13712
|
switch (m) {
|
|
13690
13713
|
case "disabled":
|
|
13691
|
-
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (i) => styleText2("gray", i))}${
|
|
13714
|
+
return `${styleText2("gray", S_RADIO_INACTIVE)} ${c(s, (i) => styleText2("gray", i))}${n.hint ? ` ${styleText2("dim", `(${n.hint ?? "disabled"})`)}` : ""}`;
|
|
13692
13715
|
case "selected":
|
|
13693
13716
|
return `${c(s, (i) => styleText2("dim", i))}`;
|
|
13694
13717
|
case "active":
|
|
13695
|
-
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${
|
|
13718
|
+
return `${styleText2("green", S_RADIO_ACTIVE)} ${s}${n.hint ? ` ${styleText2("dim", `(${n.hint})`)}` : ""}`;
|
|
13696
13719
|
case "cancelled":
|
|
13697
13720
|
return `${c(s, (i) => styleText2(["strikethrough", "dim"], i))}`;
|
|
13698
13721
|
default:
|
|
13699
13722
|
return `${styleText2("dim", S_RADIO_INACTIVE)} ${c(s, (i) => styleText2("dim", i))}`;
|
|
13700
13723
|
}
|
|
13701
|
-
}, d =
|
|
13724
|
+
}, d = t.showInstructions ?? true;
|
|
13702
13725
|
return new n$1({
|
|
13703
|
-
options:
|
|
13704
|
-
signal:
|
|
13705
|
-
input:
|
|
13706
|
-
output:
|
|
13707
|
-
initialValue:
|
|
13726
|
+
options: t.options,
|
|
13727
|
+
signal: t.signal,
|
|
13728
|
+
input: t.input,
|
|
13729
|
+
output: t.output,
|
|
13730
|
+
initialValue: t.initialValue,
|
|
13708
13731
|
render() {
|
|
13709
|
-
const
|
|
13732
|
+
const n = t.withGuide ?? settings.withGuide, m = `${symbol(this.state)} `, s = `${symbolBar(this.state)} `, i = wrapTextWithPrefix(t.output, t.message, s, m), u = `${n ? `${styleText2("gray", S_BAR)}
|
|
13710
13733
|
` : ""}${i}
|
|
13711
13734
|
`;
|
|
13712
13735
|
switch (this.state) {
|
|
13713
13736
|
case "submit": {
|
|
13714
|
-
const
|
|
13715
|
-
return `${
|
|
13737
|
+
const r = n ? `${styleText2("gray", S_BAR)} ` : "", a = wrapTextWithPrefix(t.output, o(this.options[this.cursor], "selected"), r);
|
|
13738
|
+
return `${u}${a}`;
|
|
13716
13739
|
}
|
|
13717
13740
|
case "cancel": {
|
|
13718
|
-
const
|
|
13719
|
-
return `${
|
|
13741
|
+
const r = n ? `${styleText2("gray", S_BAR)} ` : "", a = wrapTextWithPrefix(t.output, o(this.options[this.cursor], "cancelled"), r);
|
|
13742
|
+
return `${u}${a}${n ? `
|
|
13720
13743
|
${styleText2("gray", S_BAR)}` : ""}`;
|
|
13721
13744
|
}
|
|
13722
13745
|
default: {
|
|
13723
|
-
const
|
|
13724
|
-
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS,
|
|
13746
|
+
const r = n ? `${styleText2("cyan", S_BAR)} ` : "", a = u.split(`
|
|
13747
|
+
`).length, p = d ? formatInstructionFooter(SELECT_INSTRUCTIONS, n) : n ? [styleText2("cyan", S_BAR_END)] : [], b = p.join(`
|
|
13725
13748
|
`), f = p.length + 1;
|
|
13726
|
-
return `${
|
|
13727
|
-
output:
|
|
13749
|
+
return `${u}${r}${limitOptions({
|
|
13750
|
+
output: t.output,
|
|
13728
13751
|
cursor: this.cursor,
|
|
13729
13752
|
options: this.options,
|
|
13730
|
-
maxItems:
|
|
13731
|
-
columnPadding:
|
|
13732
|
-
rowPadding:
|
|
13753
|
+
maxItems: t.maxItems,
|
|
13754
|
+
columnPadding: r.length,
|
|
13755
|
+
rowPadding: a + f,
|
|
13733
13756
|
style: (g, x) => o(g, g.disabled ? "disabled" : x ? "active" : "inactive")
|
|
13734
13757
|
}).join(`
|
|
13735
|
-
${
|
|
13758
|
+
${r}`)}
|
|
13736
13759
|
${b}
|
|
13737
13760
|
`;
|
|
13738
13761
|
}
|
|
@@ -13741,7 +13764,7 @@ ${b}
|
|
|
13741
13764
|
}).prompt();
|
|
13742
13765
|
};
|
|
13743
13766
|
var i = `${styleText2("gray", S_BAR)} `;
|
|
13744
|
-
var text2 = (e) => new
|
|
13767
|
+
var text2 = (e) => new n({
|
|
13745
13768
|
validate: e.validate,
|
|
13746
13769
|
placeholder: e.placeholder,
|
|
13747
13770
|
defaultValue: e.defaultValue,
|
|
@@ -13750,30 +13773,30 @@ var text2 = (e) => new n2({
|
|
|
13750
13773
|
signal: e.signal,
|
|
13751
13774
|
input: e.input,
|
|
13752
13775
|
render() {
|
|
13753
|
-
const
|
|
13776
|
+
const i = e?.withGuide ?? settings.withGuide, s = `${`${i ? `${styleText2("gray", S_BAR)}
|
|
13754
13777
|
` : ""}${symbol(this.state)} `}${e.message}
|
|
13755
|
-
`,
|
|
13778
|
+
`, c = e.placeholder && e.placeholder.length > 0 ? styleText2("inverse", e.placeholder[0]) + styleText2("dim", e.placeholder.slice(1)) : styleText2(["inverse", "hidden"], "_"), o = this.userInput ? this.userInputWithCursor : c, l = this.value ?? "";
|
|
13756
13779
|
switch (this.state) {
|
|
13757
13780
|
case "error": {
|
|
13758
|
-
const
|
|
13781
|
+
const n = this.error ? ` ${styleText2("yellow", this.error)}` : "", r = i ? `${styleText2("yellow", S_BAR)} ` : "", d = i ? styleText2("yellow", S_BAR_END) : "";
|
|
13759
13782
|
return `${s.trim()}
|
|
13760
|
-
${
|
|
13761
|
-
${d}${
|
|
13783
|
+
${r}${o}
|
|
13784
|
+
${d}${n}
|
|
13762
13785
|
`;
|
|
13763
13786
|
}
|
|
13764
13787
|
case "submit": {
|
|
13765
|
-
const
|
|
13766
|
-
return `${s}${
|
|
13788
|
+
const n = l ? ` ${styleText2("dim", l)}` : "", r = i ? styleText2("gray", S_BAR) : "";
|
|
13789
|
+
return `${s}${r}${n}`;
|
|
13767
13790
|
}
|
|
13768
13791
|
case "cancel": {
|
|
13769
|
-
const
|
|
13770
|
-
return `${s}${
|
|
13771
|
-
${
|
|
13792
|
+
const n = l ? ` ${styleText2(["strikethrough", "dim"], l)}` : "", r = i ? styleText2("gray", S_BAR) : "";
|
|
13793
|
+
return `${s}${r}${n}${l.trim() ? `
|
|
13794
|
+
${r}` : ""}`;
|
|
13772
13795
|
}
|
|
13773
13796
|
default: {
|
|
13774
|
-
const
|
|
13775
|
-
return `${s}${
|
|
13776
|
-
${
|
|
13797
|
+
const n = i ? `${styleText2("cyan", S_BAR)} ` : "", r = i ? styleText2("cyan", S_BAR_END) : "";
|
|
13798
|
+
return `${s}${n}${o}
|
|
13799
|
+
${r}
|
|
13777
13800
|
`;
|
|
13778
13801
|
}
|
|
13779
13802
|
}
|
|
@@ -13791,7 +13814,7 @@ function writePromptLine(line) {
|
|
|
13791
13814
|
process.stderr.write(line);
|
|
13792
13815
|
}
|
|
13793
13816
|
async function readStdinLine() {
|
|
13794
|
-
return await new Promise((
|
|
13817
|
+
return await new Promise((resolve) => {
|
|
13795
13818
|
let buffer = "";
|
|
13796
13819
|
let settled = false;
|
|
13797
13820
|
function settle() {
|
|
@@ -13800,7 +13823,7 @@ async function readStdinLine() {
|
|
|
13800
13823
|
settled = true;
|
|
13801
13824
|
input.off("data", onData);
|
|
13802
13825
|
input.off("end", settle);
|
|
13803
|
-
|
|
13826
|
+
resolve((buffer.split(`
|
|
13804
13827
|
`)[0] ?? buffer).trim());
|
|
13805
13828
|
}
|
|
13806
13829
|
function onData(chunk) {
|
|
@@ -13920,7 +13943,7 @@ function writeOutro(sink, configuredPlanes, profileName) {
|
|
|
13920
13943
|
}
|
|
13921
13944
|
function configureNonTtyErrorMessage() {
|
|
13922
13945
|
return `Interactive configure requires a TTY. Examples:
|
|
13923
|
-
` + ` altertable profile configure --api-key
|
|
13946
|
+
` + ` printf '%s' "$KEY" | altertable profile configure --api-key-stdin --env production
|
|
13924
13947
|
` + ` printf '%s' "$PASS" | altertable profile configure --user alice --password-stdin`;
|
|
13925
13948
|
}
|
|
13926
13949
|
async function runConfigureWizardInCurrentProfile(options, profileName) {
|
|
@@ -14247,13 +14270,13 @@ function formatRelativeTimestamp(isoTimestamp, nowMs = Date.now()) {
|
|
|
14247
14270
|
}
|
|
14248
14271
|
const minutes = Math.round(absDiffMs / MINUTE_MS);
|
|
14249
14272
|
if (absDiffMs < 45 * MINUTE_MS) {
|
|
14250
|
-
const
|
|
14251
|
-
return isFuture ? `in ${minutes} ${
|
|
14273
|
+
const label = pluralize(minutes, "minute");
|
|
14274
|
+
return isFuture ? `in ${minutes} ${label}` : `${minutes} ${label} ago`;
|
|
14252
14275
|
}
|
|
14253
14276
|
const hours = Math.round(absDiffMs / HOUR_MS);
|
|
14254
14277
|
if (absDiffMs < 22 * HOUR_MS) {
|
|
14255
|
-
const
|
|
14256
|
-
return isFuture ? `in ${hours} ${
|
|
14278
|
+
const label = pluralize(hours, "hour");
|
|
14279
|
+
return isFuture ? `in ${hours} ${label}` : `${hours} ${label} ago`;
|
|
14257
14280
|
}
|
|
14258
14281
|
const days = Math.round(absDiffMs / DAY_MS);
|
|
14259
14282
|
const label = pluralize(days, "day");
|
|
@@ -14319,8 +14342,8 @@ function styleQueryHeader(name, width, colorize, alignment) {
|
|
|
14319
14342
|
}
|
|
14320
14343
|
return renderDisplayText([span(padded, "accent")]);
|
|
14321
14344
|
}
|
|
14322
|
-
function styleQueryTableChrome(
|
|
14323
|
-
return shouldColorizeQueryCells(colorize) ? renderDisplayText([span(
|
|
14345
|
+
function styleQueryTableChrome(text, colorize) {
|
|
14346
|
+
return shouldColorizeQueryCells(colorize) ? renderDisplayText([span(text, "subtle")]) : text;
|
|
14324
14347
|
}
|
|
14325
14348
|
function highlightJsonForTerminal(json, enabled) {
|
|
14326
14349
|
if (!enabled) {
|
|
@@ -14345,17 +14368,17 @@ function highlightJsonForTerminal(json, enabled) {
|
|
|
14345
14368
|
return renderDisplayText([span(match, "number")]);
|
|
14346
14369
|
});
|
|
14347
14370
|
}
|
|
14348
|
-
function truncateDisplayText(
|
|
14371
|
+
function truncateDisplayText(text, maxWidth) {
|
|
14349
14372
|
if (maxWidth === undefined) {
|
|
14350
|
-
return
|
|
14373
|
+
return text;
|
|
14351
14374
|
}
|
|
14352
|
-
return truncateText(
|
|
14375
|
+
return truncateText(text, maxWidth);
|
|
14353
14376
|
}
|
|
14354
|
-
function truncateDisplayTextMiddle(
|
|
14377
|
+
function truncateDisplayTextMiddle(text, maxWidth) {
|
|
14355
14378
|
if (maxWidth === undefined) {
|
|
14356
|
-
return
|
|
14379
|
+
return text;
|
|
14357
14380
|
}
|
|
14358
|
-
return truncateTextMiddle(
|
|
14381
|
+
return truncateTextMiddle(text, maxWidth);
|
|
14359
14382
|
}
|
|
14360
14383
|
function formatTimestampQueryCell(value, options, colorize) {
|
|
14361
14384
|
const includeRelative = options.includeRelative === true;
|
|
@@ -14395,17 +14418,17 @@ function formatStringQueryCell(value, options, colorize) {
|
|
|
14395
14418
|
}
|
|
14396
14419
|
return renderDisplayText([span(display, queryDataTypeStyle(dataType))]);
|
|
14397
14420
|
}
|
|
14398
|
-
function truncateText(
|
|
14399
|
-
return truncateTerminalText(
|
|
14421
|
+
function truncateText(text, maxWidth) {
|
|
14422
|
+
return truncateTerminalText(text, maxWidth);
|
|
14400
14423
|
}
|
|
14401
|
-
function truncateTextMiddle(
|
|
14402
|
-
if (getVisibleTextWidth(
|
|
14403
|
-
return
|
|
14424
|
+
function truncateTextMiddle(text, maxWidth) {
|
|
14425
|
+
if (getVisibleTextWidth(text) <= maxWidth) {
|
|
14426
|
+
return text;
|
|
14404
14427
|
}
|
|
14405
14428
|
if (maxWidth <= 1) {
|
|
14406
14429
|
return ELLIPSIS;
|
|
14407
14430
|
}
|
|
14408
|
-
const characters = Array.from(graphemeSegmenter2.segment(
|
|
14431
|
+
const characters = Array.from(graphemeSegmenter2.segment(text), ({ segment }) => segment);
|
|
14409
14432
|
const availableWidth = maxWidth - getVisibleTextWidth(ELLIPSIS);
|
|
14410
14433
|
const prefixWidth = Math.ceil(availableWidth / 2);
|
|
14411
14434
|
const suffixWidth = Math.floor(availableWidth / 2);
|
|
@@ -14447,18 +14470,18 @@ function formatQueryCell(value, options) {
|
|
|
14447
14470
|
return colorize ? renderDisplayText([span(NULL_DISPLAY, "subtle")]) : NULL_DISPLAY;
|
|
14448
14471
|
}
|
|
14449
14472
|
if (typeof value === "boolean") {
|
|
14450
|
-
const
|
|
14473
|
+
const text = String(value);
|
|
14451
14474
|
if (!colorize) {
|
|
14452
|
-
return
|
|
14475
|
+
return text;
|
|
14453
14476
|
}
|
|
14454
14477
|
if (value === false) {
|
|
14455
|
-
return renderDisplayText([span(
|
|
14478
|
+
return renderDisplayText([span(text, "subtle")]);
|
|
14456
14479
|
}
|
|
14457
|
-
return renderDisplayText([span(
|
|
14480
|
+
return renderDisplayText([span(text, "boolean")]);
|
|
14458
14481
|
}
|
|
14459
14482
|
if (typeof value === "number" || typeof value === "bigint") {
|
|
14460
|
-
const
|
|
14461
|
-
return colorize ? renderDisplayText([span(
|
|
14483
|
+
const text = String(value);
|
|
14484
|
+
return colorize ? renderDisplayText([span(text, "number")]) : text;
|
|
14462
14485
|
}
|
|
14463
14486
|
if (typeof value === "string") {
|
|
14464
14487
|
return formatStringQueryCell(value, options, colorize);
|
|
@@ -14578,8 +14601,8 @@ function computeMinimumTableWidth(columnNames, formattedCells, maxColumnWidth) {
|
|
|
14578
14601
|
const widths = computeColumnWidths2(columnNames, formattedCells, Number.MAX_SAFE_INTEGER, maxColumnWidth);
|
|
14579
14602
|
return widths.reduce((sum, width) => sum + width, 0) + getTableFrameWidth(columnNames.length);
|
|
14580
14603
|
}
|
|
14581
|
-
function getColumnAlignment(
|
|
14582
|
-
for (const row of
|
|
14604
|
+
function getColumnAlignment(rows, columnIndex, columnName, columnTypeMap) {
|
|
14605
|
+
for (const row of rows) {
|
|
14583
14606
|
const value = row.values[columnIndex];
|
|
14584
14607
|
const dataType = resolveCellDataType(value, columnName, columnTypeMap);
|
|
14585
14608
|
if (dataType === "null") {
|
|
@@ -14603,8 +14626,8 @@ function getColumnAlignment(rows2, columnIndex, columnName, columnTypeMap) {
|
|
|
14603
14626
|
}
|
|
14604
14627
|
return "left";
|
|
14605
14628
|
}
|
|
14606
|
-
function getColumnAlignments(
|
|
14607
|
-
return columnNames.map((name, columnIndex) => getColumnAlignment(
|
|
14629
|
+
function getColumnAlignments(rows, columnNames, columnTypeMap) {
|
|
14630
|
+
return columnNames.map((name, columnIndex) => getColumnAlignment(rows, columnIndex, name, columnTypeMap));
|
|
14608
14631
|
}
|
|
14609
14632
|
function renderQueryTableBorder(columnWidths, position, colorize) {
|
|
14610
14633
|
const characters = {
|
|
@@ -14625,9 +14648,9 @@ function renderQueryTableRow(cells, columnWidths, alignments, colorize) {
|
|
|
14625
14648
|
const border = styleQueryTableChrome("\u2502", colorize);
|
|
14626
14649
|
return `${border}${renderedCells.join(border)}${border}`;
|
|
14627
14650
|
}
|
|
14628
|
-
function formatCellsForTable(
|
|
14651
|
+
function formatCellsForTable(rows, columnNames, columnWidths, options, columnTypeMap) {
|
|
14629
14652
|
const colorize = options.colorize ?? true;
|
|
14630
|
-
return
|
|
14653
|
+
return rows.map((row) => row.values.map((value, columnIndex) => {
|
|
14631
14654
|
const width = columnWidths[columnIndex] ?? DEFAULT_MAX_COLUMN_WIDTH;
|
|
14632
14655
|
return formatQueryCell(value, {
|
|
14633
14656
|
maxWidth: width,
|
|
@@ -14638,17 +14661,17 @@ function formatCellsForTable(rows2, columnNames, columnWidths, options, columnTy
|
|
|
14638
14661
|
}));
|
|
14639
14662
|
}
|
|
14640
14663
|
function renderQueryTable(model, options) {
|
|
14641
|
-
const { columnNames, columnTypeMap, rows
|
|
14642
|
-
if (
|
|
14664
|
+
const { columnNames, columnTypeMap, rows } = model;
|
|
14665
|
+
if (rows.length === 0) {
|
|
14643
14666
|
if (columnNames.length === 0) {
|
|
14644
14667
|
return "(no rows)";
|
|
14645
14668
|
}
|
|
14646
14669
|
}
|
|
14647
14670
|
const availableCellWidth = Math.max(0, options.terminalWidth - getTableFrameWidth(columnNames.length));
|
|
14648
|
-
const columnWidths = computeColumnWidths2(columnNames,
|
|
14649
|
-
const rowValues = formatCellsForTable(
|
|
14671
|
+
const columnWidths = computeColumnWidths2(columnNames, rows.map((row) => row.rawCells), options.layout === "table" ? Number.MAX_SAFE_INTEGER : availableCellWidth, options.maxColumnWidth);
|
|
14672
|
+
const rowValues = formatCellsForTable(rows, columnNames, columnWidths, options, columnTypeMap);
|
|
14650
14673
|
const colorize = options.colorize ?? true;
|
|
14651
|
-
const alignments = getColumnAlignments(
|
|
14674
|
+
const alignments = getColumnAlignments(rows, columnNames, columnTypeMap);
|
|
14652
14675
|
const headerCells = columnNames.map((name, columnIndex) => {
|
|
14653
14676
|
const width = columnWidths[columnIndex] ?? name.length;
|
|
14654
14677
|
const alignment = alignments[columnIndex] ?? "left";
|
|
@@ -14665,14 +14688,14 @@ function renderQueryTable(model, options) {
|
|
|
14665
14688
|
`);
|
|
14666
14689
|
}
|
|
14667
14690
|
function renderQueryExpanded(model, options) {
|
|
14668
|
-
const { columnNames, columnTypeMap, rows
|
|
14669
|
-
if (
|
|
14691
|
+
const { columnNames, columnTypeMap, rows } = model;
|
|
14692
|
+
if (rows.length === 0) {
|
|
14670
14693
|
return "(no rows)";
|
|
14671
14694
|
}
|
|
14672
14695
|
const colorize = options.colorize ?? true;
|
|
14673
14696
|
const labelWidth = columnNames.reduce((maxWidth, name) => Math.max(maxWidth, getVisibleTextWidth(renderDisplayText(name))), 0) + 1;
|
|
14674
|
-
const showRowNumbers =
|
|
14675
|
-
const records =
|
|
14697
|
+
const showRowNumbers = rows.length > 1;
|
|
14698
|
+
const records = rows.map((row, rowIndex) => {
|
|
14676
14699
|
const lines = columnNames.map((name, columnIndex) => {
|
|
14677
14700
|
const value = formatQueryCell(row.values[columnIndex], {
|
|
14678
14701
|
colorize,
|
|
@@ -14723,8 +14746,8 @@ function renderQueryMarkdown(result, columnNames, options) {
|
|
|
14723
14746
|
const selectedNames = selectColumnNames(columnNames, options.columns);
|
|
14724
14747
|
const columnTypeMap = getColumnTypeMap(result.columns);
|
|
14725
14748
|
if (selectedNames.length === 0 && result.rows.length === 0) {
|
|
14726
|
-
const
|
|
14727
|
-
return
|
|
14749
|
+
const footer = renderQueryFooter(result);
|
|
14750
|
+
return footer.length > 0 ? `<!-- ${footer} -->` : "(no rows)";
|
|
14728
14751
|
}
|
|
14729
14752
|
const headerRow = `| ${selectedNames.map((name) => escapeMarkdownCell(name)).join(" | ")} |`;
|
|
14730
14753
|
const separatorRow = `| ${selectedNames.map(() => "---").join(" | ")} |`;
|
|
@@ -14782,7 +14805,7 @@ function resolvePagerOptions(cliMode) {
|
|
|
14782
14805
|
const defaultPager = getQueryDefaultPager();
|
|
14783
14806
|
return { mode: defaultPager ?? "auto" };
|
|
14784
14807
|
}
|
|
14785
|
-
function shouldUsePager(
|
|
14808
|
+
function shouldUsePager(text, options) {
|
|
14786
14809
|
if (options.mode === "never") {
|
|
14787
14810
|
return false;
|
|
14788
14811
|
}
|
|
@@ -14792,29 +14815,29 @@ function shouldUsePager(text3, options) {
|
|
|
14792
14815
|
if (options.mode === "always") {
|
|
14793
14816
|
return true;
|
|
14794
14817
|
}
|
|
14795
|
-
const lineCount =
|
|
14818
|
+
const lineCount = text.split(`
|
|
14796
14819
|
`).length;
|
|
14797
|
-
const
|
|
14820
|
+
const rows = process.stdout.rows ?? 24;
|
|
14798
14821
|
const columns = process.stdout.columns ?? 80;
|
|
14799
|
-
const hasWideLine =
|
|
14822
|
+
const hasWideLine = text.split(`
|
|
14800
14823
|
`).some((line) => getVisibleTextWidth(line) > columns);
|
|
14801
|
-
return lineCount >
|
|
14824
|
+
return lineCount > rows || hasWideLine;
|
|
14802
14825
|
}
|
|
14803
14826
|
function buildPagerEnv(env = copyProcessEnv()) {
|
|
14804
14827
|
return { ...env, LESS: "FRX", LESSCHARSET: env.LESSCHARSET ?? "utf-8" };
|
|
14805
14828
|
}
|
|
14806
|
-
async function writePagedOutput(
|
|
14807
|
-
if (!shouldUsePager(
|
|
14808
|
-
sink.writeHuman(
|
|
14829
|
+
async function writePagedOutput(text, options, sink) {
|
|
14830
|
+
if (!shouldUsePager(text, options)) {
|
|
14831
|
+
sink.writeHuman(text);
|
|
14809
14832
|
return;
|
|
14810
14833
|
}
|
|
14811
14834
|
const result = spawnSync2("less", ["-SR"], {
|
|
14812
|
-
input:
|
|
14835
|
+
input: text,
|
|
14813
14836
|
stdio: ["pipe", "inherit", "inherit"],
|
|
14814
14837
|
env: buildPagerEnv()
|
|
14815
14838
|
});
|
|
14816
14839
|
if (result.error) {
|
|
14817
|
-
sink.writeHuman(
|
|
14840
|
+
sink.writeHuman(text);
|
|
14818
14841
|
}
|
|
14819
14842
|
}
|
|
14820
14843
|
|
|
@@ -14890,11 +14913,11 @@ function parseQueryResultFormat(format) {
|
|
|
14890
14913
|
return format;
|
|
14891
14914
|
}
|
|
14892
14915
|
function csvEscapeCell(value) {
|
|
14893
|
-
const
|
|
14894
|
-
if (/[",\n\r]/.test(
|
|
14895
|
-
return `"${
|
|
14916
|
+
const text = formatQueryCellRaw(value);
|
|
14917
|
+
if (/[",\n\r]/.test(text)) {
|
|
14918
|
+
return `"${text.replace(/"/g, '""')}"`;
|
|
14896
14919
|
}
|
|
14897
|
-
return
|
|
14920
|
+
return text;
|
|
14898
14921
|
}
|
|
14899
14922
|
function renderQueryCsv(result) {
|
|
14900
14923
|
const columnNames = getQueryColumnNames(result);
|
|
@@ -14991,11 +15014,11 @@ function extractManagementRows(data) {
|
|
|
14991
15014
|
}
|
|
14992
15015
|
const arrayValues = Object.values(data).filter(Array.isArray);
|
|
14993
15016
|
if (arrayValues.length === 1) {
|
|
14994
|
-
const
|
|
14995
|
-
if (
|
|
15017
|
+
const rows = arrayValues[0];
|
|
15018
|
+
if (rows === undefined) {
|
|
14996
15019
|
return [];
|
|
14997
15020
|
}
|
|
14998
|
-
const plainRows =
|
|
15021
|
+
const plainRows = rows.filter(isRecord);
|
|
14999
15022
|
return plainRows.map(redactSensitiveRow);
|
|
15000
15023
|
}
|
|
15001
15024
|
const nestedObjects = Object.entries(data).filter(([, value]) => isRecord(value));
|
|
@@ -15025,9 +15048,9 @@ function redactSensitiveRowValue(key, value) {
|
|
|
15025
15048
|
const redacted = redactSensitiveJsonValue({ [key]: value });
|
|
15026
15049
|
return redacted[key];
|
|
15027
15050
|
}
|
|
15028
|
-
function collectColumnNames(
|
|
15051
|
+
function collectColumnNames(rows) {
|
|
15029
15052
|
const columnNames = new Set;
|
|
15030
|
-
for (const row of
|
|
15053
|
+
for (const row of rows) {
|
|
15031
15054
|
for (const key of Object.keys(row)) {
|
|
15032
15055
|
columnNames.add(key);
|
|
15033
15056
|
}
|
|
@@ -15035,10 +15058,10 @@ function collectColumnNames(rows2) {
|
|
|
15035
15058
|
return [...columnNames].sort();
|
|
15036
15059
|
}
|
|
15037
15060
|
function managementDataToTabularResult(data) {
|
|
15038
|
-
const
|
|
15061
|
+
const rows = extractManagementRows(data);
|
|
15039
15062
|
return {
|
|
15040
|
-
columns: collectColumnNames(
|
|
15041
|
-
rows
|
|
15063
|
+
columns: collectColumnNames(rows),
|
|
15064
|
+
rows
|
|
15042
15065
|
};
|
|
15043
15066
|
}
|
|
15044
15067
|
function renderManagementOutput(body, format) {
|
|
@@ -15116,12 +15139,12 @@ async function writeCommandOutput(mode, sink) {
|
|
|
15116
15139
|
return;
|
|
15117
15140
|
}
|
|
15118
15141
|
const format = mode.format ?? "table";
|
|
15119
|
-
const
|
|
15142
|
+
const output = renderManagementOutput(mode.body, format);
|
|
15120
15143
|
if (format === "table") {
|
|
15121
|
-
await writePagedOutput(
|
|
15144
|
+
await writePagedOutput(output, resolvePagerOptions(), sink);
|
|
15122
15145
|
return;
|
|
15123
15146
|
}
|
|
15124
|
-
sink.writeHuman(
|
|
15147
|
+
sink.writeHuman(output);
|
|
15125
15148
|
return;
|
|
15126
15149
|
}
|
|
15127
15150
|
}
|
|
@@ -15228,9 +15251,13 @@ var profileShowCommand = defineCommand({
|
|
|
15228
15251
|
required: false
|
|
15229
15252
|
}
|
|
15230
15253
|
},
|
|
15231
|
-
async run({ args, sink }) {
|
|
15254
|
+
async run({ args, runtime, sink }) {
|
|
15232
15255
|
const profile = inspectProfile(existingProfileName(profileShowTargetName(args)));
|
|
15233
|
-
await writeCommandOutput({
|
|
15256
|
+
await writeCommandOutput({
|
|
15257
|
+
kind: "normalized",
|
|
15258
|
+
data: profileInspectToJson(profile),
|
|
15259
|
+
humanText: formatProfileInspectResult(profile, !sink.json && !runtime.context.agent && process.stdin.isTTY === true)
|
|
15260
|
+
}, sink);
|
|
15234
15261
|
}
|
|
15235
15262
|
});
|
|
15236
15263
|
|
|
@@ -15257,6 +15284,8 @@ var profileStatusCommand = defineCommand({
|
|
|
15257
15284
|
data: profileStatusToJson(result),
|
|
15258
15285
|
humanText: formatProfileStatus(result)
|
|
15259
15286
|
}, sink);
|
|
15287
|
+
const healthy = verification.configured.length > 0 && verification.configured.every((plane) => verification.verified[plane]);
|
|
15288
|
+
return { exitCode: healthy ? EXIT_SUCCESS : EXIT_GENERIC };
|
|
15260
15289
|
}
|
|
15261
15290
|
});
|
|
15262
15291
|
|
|
@@ -15412,14 +15441,14 @@ var catalogsCommand = defineCommand({
|
|
|
15412
15441
|
create: catalogsCreateCommand
|
|
15413
15442
|
},
|
|
15414
15443
|
async run({ execution, sink }) {
|
|
15415
|
-
const
|
|
15444
|
+
const rows = await fetchManagementCatalogRows(requireManagementPlane(execution.profile, {
|
|
15416
15445
|
requirement: "Listing catalogs requires the management API"
|
|
15417
15446
|
}), execution);
|
|
15418
|
-
const summary = formatCatalogsSummary(
|
|
15447
|
+
const summary = formatCatalogsSummary(rows);
|
|
15419
15448
|
await writeCommandOutput({
|
|
15420
15449
|
kind: "normalized",
|
|
15421
|
-
data: { catalogs:
|
|
15422
|
-
humanText: formatCatalogsTable(
|
|
15450
|
+
data: { catalogs: rows, ...summary !== null ? { summary } : {} },
|
|
15451
|
+
humanText: formatCatalogsTable(rows),
|
|
15423
15452
|
metadataLines: summary !== null ? ["", renderDisplayText([span(summary, "subtle")])] : undefined
|
|
15424
15453
|
}, sink);
|
|
15425
15454
|
}
|
|
@@ -15488,9 +15517,9 @@ function buildDuckdbAttachSnippet(credentials, catalogs) {
|
|
|
15488
15517
|
].join(`
|
|
15489
15518
|
`);
|
|
15490
15519
|
}
|
|
15491
|
-
function availableCatalogs(
|
|
15520
|
+
function availableCatalogs(rows) {
|
|
15492
15521
|
const available = [
|
|
15493
|
-
...new Set(
|
|
15522
|
+
...new Set(rows.map((row) => row.catalog).filter((catalog) => catalog.length > 0))
|
|
15494
15523
|
];
|
|
15495
15524
|
if (available.length === 0) {
|
|
15496
15525
|
throw new ConfigurationError("No catalogs found in this environment.");
|
|
@@ -15516,15 +15545,15 @@ async function duckdbAttachAll(execution) {
|
|
|
15516
15545
|
});
|
|
15517
15546
|
await verifyConfiguredPlanes(["management", "lakehouse"], execution);
|
|
15518
15547
|
const credentials = getLakehouseCredentialPair(execution.profile);
|
|
15519
|
-
const
|
|
15520
|
-
return { credentials, catalogs: availableCatalogs(
|
|
15548
|
+
const rows = await fetchManagementCatalogRows(managementEnv, execution);
|
|
15549
|
+
return { credentials, catalogs: availableCatalogs(rows) };
|
|
15521
15550
|
}
|
|
15522
|
-
async function runDuckdb(
|
|
15551
|
+
async function runDuckdb(input, execution) {
|
|
15523
15552
|
const duckdb = Bun.which("duckdb", { PATH: readEnv("PATH") });
|
|
15524
15553
|
if (!duckdb) {
|
|
15525
15554
|
throw new ConfigurationError("duckdb is not installed. Install it from https://duckdb.org/install/ and try again.");
|
|
15526
15555
|
}
|
|
15527
|
-
const plan =
|
|
15556
|
+
const plan = input.catalog === undefined ? await duckdbAttachAll(execution) : await duckdbAttachSingleCatalog(input.catalog, execution);
|
|
15528
15557
|
const snippet = buildDuckdbAttachSnippet(plan.credentials, plan.catalogs);
|
|
15529
15558
|
const result = spawnSync3(duckdb, ["-cmd", snippet], { stdio: "inherit" });
|
|
15530
15559
|
if (result.error) {
|
|
@@ -15533,46 +15562,46 @@ async function runDuckdb(input2, execution) {
|
|
|
15533
15562
|
}
|
|
15534
15563
|
|
|
15535
15564
|
// src/lib/lakehouse-transport.ts
|
|
15536
|
-
function buildLakehouseAppendRequest(
|
|
15565
|
+
function buildLakehouseAppendRequest(input) {
|
|
15537
15566
|
const params = new URLSearchParams({
|
|
15538
|
-
catalog:
|
|
15539
|
-
schema:
|
|
15540
|
-
table:
|
|
15567
|
+
catalog: input.catalog,
|
|
15568
|
+
schema: input.schema,
|
|
15569
|
+
table: input.table
|
|
15541
15570
|
});
|
|
15542
|
-
if (
|
|
15571
|
+
if (input.options?.sync) {
|
|
15543
15572
|
params.set("sync", "true");
|
|
15544
15573
|
}
|
|
15545
15574
|
return {
|
|
15546
15575
|
plane: "lakehouse",
|
|
15547
15576
|
method: "POST",
|
|
15548
15577
|
endpoint: `/append?${params.toString()}`,
|
|
15549
|
-
body:
|
|
15578
|
+
body: input.jsonContent
|
|
15550
15579
|
};
|
|
15551
15580
|
}
|
|
15552
|
-
function createLakehouseUploadRequest(
|
|
15581
|
+
function createLakehouseUploadRequest(input) {
|
|
15553
15582
|
const params = new URLSearchParams({
|
|
15554
|
-
catalog:
|
|
15555
|
-
schema:
|
|
15556
|
-
table:
|
|
15557
|
-
mode:
|
|
15583
|
+
catalog: input.catalog,
|
|
15584
|
+
schema: input.schema,
|
|
15585
|
+
table: input.table,
|
|
15586
|
+
mode: input.mode
|
|
15558
15587
|
});
|
|
15559
|
-
return createLakehouseFileRequest(
|
|
15588
|
+
return createLakehouseFileRequest(input, `/upload?${params.toString()}`);
|
|
15560
15589
|
}
|
|
15561
|
-
function createLakehouseUpsertRequest(
|
|
15590
|
+
function createLakehouseUpsertRequest(input) {
|
|
15562
15591
|
const params = new URLSearchParams({
|
|
15563
|
-
catalog:
|
|
15564
|
-
schema:
|
|
15565
|
-
table:
|
|
15566
|
-
primary_key:
|
|
15592
|
+
catalog: input.catalog,
|
|
15593
|
+
schema: input.schema,
|
|
15594
|
+
table: input.table,
|
|
15595
|
+
primary_key: input.primaryKey
|
|
15567
15596
|
});
|
|
15568
|
-
return createLakehouseFileRequest(
|
|
15569
|
-
}
|
|
15570
|
-
function createLakehouseFileRequest(
|
|
15571
|
-
const file = Bun.file(
|
|
15572
|
-
let body =
|
|
15573
|
-
let uploadProgress = createUploadProgressReporter(
|
|
15574
|
-
if (shouldShowProgress() &&
|
|
15575
|
-
body = wrapStreamWithByteProgress(file.stream(),
|
|
15597
|
+
return createLakehouseFileRequest(input, `/upsert?${params.toString()}`);
|
|
15598
|
+
}
|
|
15599
|
+
function createLakehouseFileRequest(input, endpoint) {
|
|
15600
|
+
const file = Bun.file(input.filePath);
|
|
15601
|
+
let body = input.contentType ? file : file.stream();
|
|
15602
|
+
let uploadProgress = createUploadProgressReporter(input.fileSizeBytes);
|
|
15603
|
+
if (shouldShowProgress() && input.fileSizeBytes > 0) {
|
|
15604
|
+
body = wrapStreamWithByteProgress(file.stream(), input.fileSizeBytes, (sentBytes, totalBytes) => {
|
|
15576
15605
|
uploadProgress.report(sentBytes, totalBytes);
|
|
15577
15606
|
});
|
|
15578
15607
|
} else {
|
|
@@ -15584,8 +15613,8 @@ function createLakehouseFileRequest(input2, endpoint) {
|
|
|
15584
15613
|
method: "POST",
|
|
15585
15614
|
endpoint,
|
|
15586
15615
|
body,
|
|
15587
|
-
contentType:
|
|
15588
|
-
...
|
|
15616
|
+
contentType: input.contentType,
|
|
15617
|
+
...input.httpOptions
|
|
15589
15618
|
},
|
|
15590
15619
|
release: () => uploadProgress.clear()
|
|
15591
15620
|
};
|
|
@@ -15637,11 +15666,11 @@ function parseLakehouseTarget(target) {
|
|
|
15637
15666
|
throw new CliError("--to must use catalog.schema.table notation.");
|
|
15638
15667
|
}
|
|
15639
15668
|
try {
|
|
15640
|
-
const [catalog, schema,
|
|
15641
|
-
if (!catalog || !schema || !
|
|
15669
|
+
const [catalog, schema, table] = components.map((component) => decodeURIComponent(component));
|
|
15670
|
+
if (!catalog || !schema || !table) {
|
|
15642
15671
|
throw new CliError("--to must use catalog.schema.table notation.");
|
|
15643
15672
|
}
|
|
15644
|
-
return { catalog, schema, table
|
|
15673
|
+
return { catalog, schema, table };
|
|
15645
15674
|
} catch (error) {
|
|
15646
15675
|
if (error instanceof CliError)
|
|
15647
15676
|
throw error;
|
|
@@ -16023,7 +16052,7 @@ var queryCommand = defineCommand({
|
|
|
16023
16052
|
json: sink.json,
|
|
16024
16053
|
rawArgs
|
|
16025
16054
|
});
|
|
16026
|
-
const
|
|
16055
|
+
const input = {
|
|
16027
16056
|
statement,
|
|
16028
16057
|
queryId: optionalStringArg(args, "query-id"),
|
|
16029
16058
|
sessionId: optionalStringArg(args, "session-id"),
|
|
@@ -16033,11 +16062,11 @@ var queryCommand = defineCommand({
|
|
|
16033
16062
|
schema
|
|
16034
16063
|
};
|
|
16035
16064
|
if (isApiNativeQueryFormat(format)) {
|
|
16036
|
-
const stream = await executeLakehouseQueryBytes({ ...
|
|
16065
|
+
const stream = await executeLakehouseQueryBytes({ ...input, format }, execution);
|
|
16037
16066
|
await writeQueryDestination(stream, { outputPath, sink });
|
|
16038
16067
|
return;
|
|
16039
16068
|
}
|
|
16040
|
-
const result = await executeLakehouseQuery(
|
|
16069
|
+
const result = await executeLakehouseQuery(input, execution, !sink.json);
|
|
16041
16070
|
await writeQueryOutput(result, format, sink, displayOptions, pagerOptions, outputPath);
|
|
16042
16071
|
}
|
|
16043
16072
|
});
|
|
@@ -16067,18 +16096,18 @@ function buildSchemaMap(result) {
|
|
|
16067
16096
|
if (tableName === null) {
|
|
16068
16097
|
continue;
|
|
16069
16098
|
}
|
|
16070
|
-
let
|
|
16071
|
-
if (!
|
|
16072
|
-
|
|
16099
|
+
let table = tables.get(tableName);
|
|
16100
|
+
if (!table) {
|
|
16101
|
+
table = {
|
|
16073
16102
|
type: textCell(row, "table_type", columnIndex),
|
|
16074
16103
|
comment: textCell(row, "table_comment", columnIndex),
|
|
16075
16104
|
columns: []
|
|
16076
16105
|
};
|
|
16077
|
-
tables.set(tableName,
|
|
16106
|
+
tables.set(tableName, table);
|
|
16078
16107
|
}
|
|
16079
16108
|
const columnName = textCell(row, "column_name", columnIndex);
|
|
16080
16109
|
if (columnName !== null) {
|
|
16081
|
-
|
|
16110
|
+
table.columns.push({
|
|
16082
16111
|
name: columnName,
|
|
16083
16112
|
dataType: textCell(row, "data_type", columnIndex) ?? "",
|
|
16084
16113
|
nullable: textCell(row, "is_nullable", columnIndex),
|
|
@@ -16104,18 +16133,18 @@ function schemaColumnNode(column, nameWidth) {
|
|
|
16104
16133
|
label
|
|
16105
16134
|
};
|
|
16106
16135
|
}
|
|
16107
|
-
function schemaTableNode(tableName,
|
|
16108
|
-
const nameWidth = Math.max(0, ...
|
|
16136
|
+
function schemaTableNode(tableName, table) {
|
|
16137
|
+
const nameWidth = Math.max(0, ...table.columns.map((column) => column.name.length));
|
|
16109
16138
|
const label = [span(tableName, "strong")];
|
|
16110
|
-
if (
|
|
16111
|
-
label.push(span(" "), span(`(${
|
|
16139
|
+
if (table.type && table.type !== "BASE TABLE") {
|
|
16140
|
+
label.push(span(" "), span(`(${table.type})`, "warning"));
|
|
16112
16141
|
}
|
|
16113
|
-
if (
|
|
16114
|
-
label.push(span(" "), span(`\u2014 ${
|
|
16142
|
+
if (table.comment) {
|
|
16143
|
+
label.push(span(" "), span(`\u2014 ${table.comment}`, "subtle"));
|
|
16115
16144
|
}
|
|
16116
16145
|
return {
|
|
16117
16146
|
label,
|
|
16118
|
-
children:
|
|
16147
|
+
children: table.columns.map((column) => schemaColumnNode(column, nameWidth))
|
|
16119
16148
|
};
|
|
16120
16149
|
}
|
|
16121
16150
|
function schemaNode(schemaName, tables) {
|
|
@@ -16123,7 +16152,7 @@ function schemaNode(schemaName, tables) {
|
|
|
16123
16152
|
return {
|
|
16124
16153
|
label: [span(schemaName, "accent")],
|
|
16125
16154
|
emptyLabel: [span("<no table>", "subtle")],
|
|
16126
|
-
children: tableEntries.map(([tableName,
|
|
16155
|
+
children: tableEntries.map(([tableName, table]) => schemaTableNode(tableName, table))
|
|
16127
16156
|
};
|
|
16128
16157
|
}
|
|
16129
16158
|
function buildSchemaTreeView(result, catalog) {
|
|
@@ -18381,8 +18410,8 @@ function getOpenapiSpecYaml() {
|
|
|
18381
18410
|
return stripOpenapiSourceHeader(openapi_default);
|
|
18382
18411
|
}
|
|
18383
18412
|
function getOpenapiSpecJson() {
|
|
18384
|
-
const
|
|
18385
|
-
return JSON.stringify(
|
|
18413
|
+
const document = $parse(openapi_default);
|
|
18414
|
+
return JSON.stringify(document, null, 2);
|
|
18386
18415
|
}
|
|
18387
18416
|
|
|
18388
18417
|
// src/commands/api/spec.ts
|
|
@@ -18523,8 +18552,8 @@ function formatApiOperationDetails(operation) {
|
|
|
18523
18552
|
}).join(`
|
|
18524
18553
|
`);
|
|
18525
18554
|
}
|
|
18526
|
-
function formatApiRoutes(
|
|
18527
|
-
return renderDocumentText(buildApiRoutesView(
|
|
18555
|
+
function formatApiRoutes(rows, emptyMessage = "No operations found.", options = {}) {
|
|
18556
|
+
return renderDocumentText(buildApiRoutesView(rows, {
|
|
18528
18557
|
emptyMessage,
|
|
18529
18558
|
terminalWidth: options.terminalWidth
|
|
18530
18559
|
}));
|
|
@@ -18582,9 +18611,9 @@ var apiCommand = defineCommand({
|
|
|
18582
18611
|
},
|
|
18583
18612
|
async run({ args, execution, sink }) {
|
|
18584
18613
|
const result = await executeApiHttp(resolveApiCommandRequest(args), execution);
|
|
18585
|
-
const
|
|
18586
|
-
if (
|
|
18587
|
-
await writeCommandOutput(
|
|
18614
|
+
const output = apiHttpResultOutput(result, sink);
|
|
18615
|
+
if (output)
|
|
18616
|
+
await writeCommandOutput(output, sink);
|
|
18588
18617
|
}
|
|
18589
18618
|
});
|
|
18590
18619
|
|
|
@@ -19508,13 +19537,13 @@ async function readOptionalFile(path) {
|
|
|
19508
19537
|
throw error;
|
|
19509
19538
|
}
|
|
19510
19539
|
}
|
|
19511
|
-
function upsertManagedBlock(existing,
|
|
19540
|
+
function upsertManagedBlock(existing, block) {
|
|
19512
19541
|
const start = existing.indexOf(START_MARKER);
|
|
19513
19542
|
const end = existing.indexOf(END_MARKER);
|
|
19514
19543
|
if (start !== -1 && end !== -1 && end > start) {
|
|
19515
19544
|
const before = existing.slice(0, start).trimEnd();
|
|
19516
19545
|
const after = existing.slice(end + END_MARKER.length).trimStart();
|
|
19517
|
-
return [before,
|
|
19546
|
+
return [before, block.trimEnd(), after].filter(Boolean).join(`
|
|
19518
19547
|
|
|
19519
19548
|
`) + `
|
|
19520
19549
|
`;
|
|
@@ -19522,7 +19551,7 @@ function upsertManagedBlock(existing, block2) {
|
|
|
19522
19551
|
const prefix = existing.trimEnd();
|
|
19523
19552
|
return prefix ? `${prefix}
|
|
19524
19553
|
|
|
19525
|
-
${
|
|
19554
|
+
${block}` : block;
|
|
19526
19555
|
}
|
|
19527
19556
|
async function formatCompletionScript(shell, rootCommand) {
|
|
19528
19557
|
const spec = await buildCompletionSpec(rootCommand);
|
|
@@ -19537,11 +19566,11 @@ async function installCompletion(shell, script, options = {}) {
|
|
|
19537
19566
|
await mkdir(dirname2(target.completionPath), { recursive: true });
|
|
19538
19567
|
await writeFile(target.completionPath, `${script.trimEnd()}
|
|
19539
19568
|
`, "utf8");
|
|
19540
|
-
const
|
|
19541
|
-
if (
|
|
19569
|
+
const block = options.updateRc === false ? undefined : rcBlock(shell, target);
|
|
19570
|
+
if (block && target.rcPath) {
|
|
19542
19571
|
await mkdir(dirname2(target.rcPath), { recursive: true });
|
|
19543
19572
|
const existing = await readOptionalFile(target.rcPath);
|
|
19544
|
-
await writeFile(target.rcPath, upsertManagedBlock(existing,
|
|
19573
|
+
await writeFile(target.rcPath, upsertManagedBlock(existing, block), "utf8");
|
|
19545
19574
|
return {
|
|
19546
19575
|
shell,
|
|
19547
19576
|
completionPath: target.completionPath,
|
|
@@ -20193,9 +20222,9 @@ async function fetchGitHubBinaryRelease(options = {}) {
|
|
|
20193
20222
|
checksumsDownloadUrl: findGitHubAsset(data, UpdaterConfig.checksumsAssetName)
|
|
20194
20223
|
};
|
|
20195
20224
|
}
|
|
20196
|
-
function parseChecksums(
|
|
20225
|
+
function parseChecksums(text) {
|
|
20197
20226
|
const checksums = new Map;
|
|
20198
|
-
for (const line of
|
|
20227
|
+
for (const line of text.split(/\r?\n/)) {
|
|
20199
20228
|
const trimmed = line.trim();
|
|
20200
20229
|
if (!trimmed) {
|
|
20201
20230
|
continue;
|
|
@@ -20221,15 +20250,15 @@ async function fetchLatestRelease(options = {}) {
|
|
|
20221
20250
|
const timeoutMs = options.timeoutMs ?? UpdaterConfig.timeoutsMs.manual;
|
|
20222
20251
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
20223
20252
|
if (source === "github") {
|
|
20224
|
-
const
|
|
20225
|
-
const
|
|
20226
|
-
if (!
|
|
20253
|
+
const data = await fetchUpdateJson(source, githubLatestReleaseUrl(), timeoutMs, fetchImpl);
|
|
20254
|
+
const version = normalizeVersion(readStringProperty(data, "tag_name"));
|
|
20255
|
+
if (!version) {
|
|
20227
20256
|
throw new CliError("GitHub release metadata did not include a tag_name.");
|
|
20228
20257
|
}
|
|
20229
20258
|
return {
|
|
20230
|
-
version
|
|
20259
|
+
version,
|
|
20231
20260
|
source,
|
|
20232
|
-
releaseUrl: readStringProperty(
|
|
20261
|
+
releaseUrl: readStringProperty(data, "html_url") || githubReleasesFallbackUrl()
|
|
20233
20262
|
};
|
|
20234
20263
|
}
|
|
20235
20264
|
const data = await fetchUpdateJson(source, npmRegistryUrl(), timeoutMs, fetchImpl);
|
|
@@ -20814,21 +20843,33 @@ function validateLakehouseProbeResponse(body) {
|
|
|
20814
20843
|
});
|
|
20815
20844
|
}
|
|
20816
20845
|
}
|
|
20817
|
-
function
|
|
20846
|
+
function managementCredentialRemediation(context) {
|
|
20847
|
+
if (context.interactive) {
|
|
20848
|
+
return ["Run: altertable login", "Or run: altertable profile configure --scope management"];
|
|
20849
|
+
}
|
|
20850
|
+
return [
|
|
20851
|
+
`Run: printf '%s' "$KEY" | altertable profile configure --api-key-stdin --env <name>`,
|
|
20852
|
+
"Or set: ALTERTABLE_API_KEY and ALTERTABLE_ENV"
|
|
20853
|
+
];
|
|
20854
|
+
}
|
|
20855
|
+
function lakehouseCredentialRemediation(context) {
|
|
20856
|
+
if (context.interactive) {
|
|
20857
|
+
return ["Run: altertable login", "Or run: altertable profile configure --scope lakehouse"];
|
|
20858
|
+
}
|
|
20859
|
+
return [
|
|
20860
|
+
`Run: printf '%s' "$PASSWORD" | altertable profile configure --user <username> --password-stdin`,
|
|
20861
|
+
"Or set: ALTERTABLE_BASIC_AUTH_TOKEN or ALTERTABLE_LAKEHOUSE_USERNAME and ALTERTABLE_LAKEHOUSE_PASSWORD"
|
|
20862
|
+
];
|
|
20863
|
+
}
|
|
20864
|
+
function checkManagementCredentialPresence(auth, context) {
|
|
20818
20865
|
if (auth.management === "none") {
|
|
20819
|
-
return failOutcome("No management credentials configured.", "configuration_error",
|
|
20820
|
-
"Run: altertable login",
|
|
20821
|
-
"Or run: altertable profile configure --scope management"
|
|
20822
|
-
]);
|
|
20866
|
+
return failOutcome("No management credentials configured.", "configuration_error", managementCredentialRemediation(context));
|
|
20823
20867
|
}
|
|
20824
20868
|
return passOutcome(`Configured (${auth.management}).`, { auth: auth.management });
|
|
20825
20869
|
}
|
|
20826
|
-
function checkLakehouseCredentialPresence(auth) {
|
|
20870
|
+
function checkLakehouseCredentialPresence(auth, context) {
|
|
20827
20871
|
if (auth.lakehouse === "none") {
|
|
20828
|
-
return failOutcome("No lakehouse credentials configured.", "configuration_error",
|
|
20829
|
-
"Run: altertable login",
|
|
20830
|
-
"Or run: altertable profile configure --scope lakehouse"
|
|
20831
|
-
]);
|
|
20872
|
+
return failOutcome("No lakehouse credentials configured.", "configuration_error", lakehouseCredentialRemediation(context));
|
|
20832
20873
|
}
|
|
20833
20874
|
return passOutcome(`Configured (${auth.lakehouse}).`, { auth: auth.lakehouse });
|
|
20834
20875
|
}
|
|
@@ -20892,7 +20933,7 @@ function createDoctorChecks() {
|
|
|
20892
20933
|
id: "management.credentials",
|
|
20893
20934
|
label: "Management auth",
|
|
20894
20935
|
requires: ["credentials.store"],
|
|
20895
|
-
run: () => checkManagementCredentialPresence(requireProfileAuth())
|
|
20936
|
+
run: (context) => checkManagementCredentialPresence(requireProfileAuth(), context)
|
|
20896
20937
|
},
|
|
20897
20938
|
{
|
|
20898
20939
|
id: "management.api",
|
|
@@ -20907,19 +20948,19 @@ function createDoctorChecks() {
|
|
|
20907
20948
|
endpoint: "/whoami",
|
|
20908
20949
|
authRecovery: false
|
|
20909
20950
|
}, context.execution);
|
|
20910
|
-
const
|
|
20911
|
-
return passOutcome(`${endpoint} \xB7 ${
|
|
20951
|
+
const identity = formatManagementIdentity(body);
|
|
20952
|
+
return passOutcome(`${endpoint} \xB7 ${identity}`, { endpoint, identity });
|
|
20912
20953
|
},
|
|
20913
|
-
remediation: () => [
|
|
20954
|
+
remediation: (context) => [
|
|
20914
20955
|
"Check the control-plane URL and management credentials.",
|
|
20915
|
-
|
|
20956
|
+
...managementCredentialRemediation(context)
|
|
20916
20957
|
]
|
|
20917
20958
|
},
|
|
20918
20959
|
{
|
|
20919
20960
|
id: "lakehouse.credentials",
|
|
20920
20961
|
label: "Lakehouse auth",
|
|
20921
20962
|
requires: ["credentials.store"],
|
|
20922
|
-
run: () => checkLakehouseCredentialPresence(requireProfileAuth())
|
|
20963
|
+
run: (context) => checkLakehouseCredentialPresence(requireProfileAuth(), context)
|
|
20923
20964
|
},
|
|
20924
20965
|
{
|
|
20925
20966
|
id: "lakehouse.api",
|
|
@@ -20932,9 +20973,9 @@ function createDoctorChecks() {
|
|
|
20932
20973
|
validateLakehouseProbeResponse(body);
|
|
20933
20974
|
return passOutcome(`${endpoint} \xB7 SELECT 1 succeeded.`, { endpoint });
|
|
20934
20975
|
},
|
|
20935
|
-
remediation: () => [
|
|
20976
|
+
remediation: (context) => [
|
|
20936
20977
|
"Check the data-plane URL and lakehouse credentials.",
|
|
20937
|
-
|
|
20978
|
+
...lakehouseCredentialRemediation(context)
|
|
20938
20979
|
]
|
|
20939
20980
|
}
|
|
20940
20981
|
];
|
|
@@ -21056,7 +21097,7 @@ async function runDoctorCheck(check, context, dependencies) {
|
|
|
21056
21097
|
code: serialized.code,
|
|
21057
21098
|
http_status: serialized.status,
|
|
21058
21099
|
details: serialized.details,
|
|
21059
|
-
remediation: check.remediation?.(
|
|
21100
|
+
remediation: check.remediation?.(context),
|
|
21060
21101
|
duration_ms: Math.round(performance.now() - startedAt)
|
|
21061
21102
|
};
|
|
21062
21103
|
}
|
|
@@ -21095,13 +21136,15 @@ var doctorCommand = defineCommand({
|
|
|
21095
21136
|
async run({ args, runtime, sink }) {
|
|
21096
21137
|
const report = await runDoctorChecks(createDoctorChecks(), {
|
|
21097
21138
|
execution: createDiagnosticExecutionContext(runtime),
|
|
21098
|
-
offline: args.offline === true
|
|
21139
|
+
offline: args.offline === true,
|
|
21140
|
+
interactive: !runtime.context.json && !runtime.context.agent && process.stdin.isTTY === true
|
|
21099
21141
|
});
|
|
21100
21142
|
await writeCommandOutput({
|
|
21101
21143
|
kind: "normalized",
|
|
21102
21144
|
data: report,
|
|
21103
21145
|
humanText: formatDoctorReport(report)
|
|
21104
21146
|
}, sink);
|
|
21147
|
+
return { exitCode: report.healthy ? EXIT_SUCCESS : EXIT_GENERIC };
|
|
21105
21148
|
}
|
|
21106
21149
|
});
|
|
21107
21150
|
|
|
@@ -21131,12 +21174,12 @@ function renderCliErrorJson(error) {
|
|
|
21131
21174
|
}
|
|
21132
21175
|
function renderCliError(error) {
|
|
21133
21176
|
if (error instanceof CliError || error instanceof Error && error.name === "CLIError") {
|
|
21134
|
-
return
|
|
21177
|
+
return renderCliErrorDetails(error.message);
|
|
21135
21178
|
}
|
|
21136
|
-
return
|
|
21179
|
+
return renderCliErrorDetails("Unexpected error.");
|
|
21137
21180
|
}
|
|
21138
21181
|
function renderCliErrorDetails(details) {
|
|
21139
|
-
return details.split(/\r\n|\r|\n/).map((line, index) => index === 0 ? renderDisplayText([span("ERROR", "error"), span(` ${line}`)]) : renderDisplayText(line)).join(`
|
|
21182
|
+
return details.split(/\r\n|\r|\n/).map((line, index) => index === 0 ? renderDisplayText([span("[ERROR]", "error"), span(` ${line}`)]) : renderDisplayText(line)).join(`
|
|
21140
21183
|
`);
|
|
21141
21184
|
}
|
|
21142
21185
|
|
|
@@ -21363,25 +21406,25 @@ function parseInvocationArguments(invocation, tokens) {
|
|
|
21363
21406
|
continue;
|
|
21364
21407
|
}
|
|
21365
21408
|
if (!afterSeparator && token.startsWith("-")) {
|
|
21366
|
-
const
|
|
21367
|
-
const binding = options.get(
|
|
21409
|
+
const name = optionName(token);
|
|
21410
|
+
const binding = options.get(name);
|
|
21368
21411
|
if (!binding)
|
|
21369
|
-
throw new CommandParseError(`Unknown option ${
|
|
21412
|
+
throw new CommandParseError(`Unknown option ${name}.`);
|
|
21370
21413
|
if (binding.argument.flagScope === "root-only" && tokens.length !== 1) {
|
|
21371
|
-
throw new CommandParseError(`${
|
|
21414
|
+
throw new CommandParseError(`${name} is only valid at the command root.`);
|
|
21372
21415
|
}
|
|
21373
21416
|
if (takesValue(binding.argument)) {
|
|
21374
21417
|
const inlineValue = inlineOptionValue(token);
|
|
21375
21418
|
const value = inlineValue ?? nextOptionValue(tokens, index, options);
|
|
21376
21419
|
if (value === undefined)
|
|
21377
|
-
throw new CommandParseError(`Missing value for ${
|
|
21420
|
+
throw new CommandParseError(`Missing value for ${name}.`);
|
|
21378
21421
|
validateArgumentValue(binding.name, binding.argument, value);
|
|
21379
21422
|
assignParsedValue(parsed, binding.name, binding.argument, value);
|
|
21380
21423
|
if (inlineValue === undefined)
|
|
21381
21424
|
index += 1;
|
|
21382
21425
|
} else {
|
|
21383
21426
|
if (inlineOptionValue(token) !== undefined) {
|
|
21384
|
-
throw new CommandParseError(`${
|
|
21427
|
+
throw new CommandParseError(`${name} does not take a value.`);
|
|
21385
21428
|
}
|
|
21386
21429
|
assignParsedValue(parsed, binding.name, binding.argument, true);
|
|
21387
21430
|
}
|
|
@@ -21419,17 +21462,19 @@ function createRunContext(command, args, rawArgs) {
|
|
|
21419
21462
|
async function executeCommand(root, rawArgs) {
|
|
21420
21463
|
const invocation = await selectInvocation(root, rawArgs, "strict");
|
|
21421
21464
|
const parsed = parseInvocationArguments(invocation, rawArgs);
|
|
21465
|
+
let runResult = undefined;
|
|
21422
21466
|
if (root.run) {
|
|
21423
|
-
await root.run(createRunContext(root, parsed, rawArgs));
|
|
21467
|
+
runResult = await root.run(createRunContext(root, parsed, rawArgs));
|
|
21424
21468
|
}
|
|
21425
21469
|
const selected = invocation.command.definition;
|
|
21426
21470
|
if (selected !== root && selected.run) {
|
|
21427
|
-
await selected.run(createRunContext(selected, parsed, rawArgs));
|
|
21471
|
+
runResult = await selected.run(createRunContext(selected, parsed, rawArgs));
|
|
21428
21472
|
}
|
|
21429
21473
|
return {
|
|
21430
21474
|
command: selected,
|
|
21431
21475
|
...invocation.parent ? { parent: invocation.parent } : {},
|
|
21432
|
-
commandPath: invocation.commandPath
|
|
21476
|
+
commandPath: invocation.commandPath,
|
|
21477
|
+
exitCode: runResult?.exitCode ?? EXIT_SUCCESS
|
|
21433
21478
|
};
|
|
21434
21479
|
}
|
|
21435
21480
|
|
|
@@ -21439,15 +21484,15 @@ var HELP_COLUMN_GAP = " ";
|
|
|
21439
21484
|
var HELP_MIN_DESCRIPTION_WIDTH = 16;
|
|
21440
21485
|
var HELP_FALLBACK_TERMINAL_WIDTH = 68;
|
|
21441
21486
|
var COMMAND_PATTERN = /altertable(?:\s+[^\s'",]+)*/g;
|
|
21442
|
-
function renderHighlightedCommands(
|
|
21487
|
+
function renderHighlightedCommands(text) {
|
|
21443
21488
|
const spans = [];
|
|
21444
21489
|
let offset = 0;
|
|
21445
|
-
for (const match of
|
|
21490
|
+
for (const match of text.matchAll(COMMAND_PATTERN)) {
|
|
21446
21491
|
const index = match.index ?? 0;
|
|
21447
|
-
spans.push(span(
|
|
21492
|
+
spans.push(span(text.slice(offset, index)), span(match[0], "accent"));
|
|
21448
21493
|
offset = index + match[0].length;
|
|
21449
21494
|
}
|
|
21450
|
-
spans.push(span(
|
|
21495
|
+
spans.push(span(text.slice(offset)));
|
|
21451
21496
|
return renderDisplayText(spans);
|
|
21452
21497
|
}
|
|
21453
21498
|
function formatCommandExamplesSection(examples) {
|
|
@@ -21466,9 +21511,9 @@ async function resolveSubCommandForUsage(command, rawArgs) {
|
|
|
21466
21511
|
const selected = await resolveCommandSelection(command, rawArgs);
|
|
21467
21512
|
return [selected.command, selected.parent];
|
|
21468
21513
|
}
|
|
21469
|
-
function wrapHelpText(
|
|
21514
|
+
function wrapHelpText(text, maxWidth) {
|
|
21470
21515
|
maxWidth = Math.max(1, maxWidth);
|
|
21471
|
-
const normalizedText =
|
|
21516
|
+
const normalizedText = text.trim().replace(/\s+/g, " ");
|
|
21472
21517
|
if (normalizedText.length === 0) {
|
|
21473
21518
|
return [""];
|
|
21474
21519
|
}
|
|
@@ -21537,9 +21582,9 @@ function formatHelpEntries(entries) {
|
|
|
21537
21582
|
});
|
|
21538
21583
|
});
|
|
21539
21584
|
}
|
|
21540
|
-
function formatHelpParagraph(
|
|
21585
|
+
function formatHelpParagraph(text, indent) {
|
|
21541
21586
|
const width = Math.max(1, getHelpTerminalWidth() - indent.length);
|
|
21542
|
-
return wrapHelpText(
|
|
21587
|
+
return wrapHelpText(text, width).map((line) => `${indent}${line}`);
|
|
21543
21588
|
}
|
|
21544
21589
|
function formatHelpGuidance(commandName) {
|
|
21545
21590
|
const invocation = `${commandName} <command> --help`;
|
|
@@ -21782,11 +21827,11 @@ async function showAltertableUsage(command, parent, root) {
|
|
|
21782
21827
|
}
|
|
21783
21828
|
async function showCommandExamplesForArgs(root, rawArgs) {
|
|
21784
21829
|
const [command] = await resolveSubCommandForUsage(root, rawArgs);
|
|
21785
|
-
const
|
|
21786
|
-
if (
|
|
21830
|
+
const section = formatCommandExamplesSection((await resolveCommandDescriptor(command)).metadata.examples);
|
|
21831
|
+
if (section.length === 0) {
|
|
21787
21832
|
return;
|
|
21788
21833
|
}
|
|
21789
|
-
console.error(`${
|
|
21834
|
+
console.error(`${section.trimStart()}
|
|
21790
21835
|
`);
|
|
21791
21836
|
}
|
|
21792
21837
|
|
|
@@ -21914,7 +21959,7 @@ function handleCliError(error) {
|
|
|
21914
21959
|
if (context.debug && error instanceof Error && error.stack) {
|
|
21915
21960
|
console.error(error.stack);
|
|
21916
21961
|
}
|
|
21917
|
-
|
|
21962
|
+
return getCliExitCode(error);
|
|
21918
21963
|
}
|
|
21919
21964
|
async function bootstrap() {
|
|
21920
21965
|
const rawArgs = process.argv.slice(2);
|
|
@@ -21930,11 +21975,11 @@ async function bootstrap() {
|
|
|
21930
21975
|
context: getCliContext(),
|
|
21931
21976
|
commandName: (await resolveCommandSelection(main, rawArgs)).commandPath.at(0) ?? "help"
|
|
21932
21977
|
});
|
|
21933
|
-
|
|
21978
|
+
return EXIT_SUCCESS;
|
|
21934
21979
|
}
|
|
21935
21980
|
if (earlyExit?.id === "version") {
|
|
21936
21981
|
console.log(VERSION);
|
|
21937
|
-
return;
|
|
21982
|
+
return EXIT_SUCCESS;
|
|
21938
21983
|
}
|
|
21939
21984
|
validateEnvironment();
|
|
21940
21985
|
const selection = await executeCommand(main, rawArgs);
|
|
@@ -21942,6 +21987,7 @@ async function bootstrap() {
|
|
|
21942
21987
|
context: getCliContext(),
|
|
21943
21988
|
commandName: selection.commandPath.at(0)
|
|
21944
21989
|
});
|
|
21990
|
+
return selection.exitCode;
|
|
21945
21991
|
} catch (error) {
|
|
21946
21992
|
const showExamplesOnHumanOutput = !isJsonOutput2(getCliContext());
|
|
21947
21993
|
if (isCommandParseError(error)) {
|
|
@@ -21952,11 +21998,13 @@ async function bootstrap() {
|
|
|
21952
21998
|
} else if (showExamplesOnHumanOutput && shouldShowCommandExamplesOnError(error)) {
|
|
21953
21999
|
await showCommandExamplesForArgs(main, rawArgs);
|
|
21954
22000
|
}
|
|
21955
|
-
handleCliError(error);
|
|
22001
|
+
return handleCliError(error);
|
|
21956
22002
|
}
|
|
21957
22003
|
}
|
|
21958
22004
|
if (import.meta.main) {
|
|
21959
|
-
bootstrap()
|
|
22005
|
+
bootstrap().then((exitCode) => {
|
|
22006
|
+
process.exitCode = exitCode;
|
|
22007
|
+
});
|
|
21960
22008
|
}
|
|
21961
22009
|
export {
|
|
21962
22010
|
buildMainCommand
|