@outfitter/cli 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -4
- package/dist/actions.js +0 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -2
- package/dist/{render → colors}/colors.d.ts +1 -1
- package/dist/{render → colors}/colors.js +2 -6
- package/dist/colors/index.d.ts +1 -1
- package/dist/colors/index.js +3 -4
- package/dist/command.d.ts +1 -1
- package/dist/command.js +1 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -4
- package/dist/input.d.ts +3 -26
- package/dist/input.js +1 -31
- package/dist/output.d.ts +2 -2
- package/dist/output.js +0 -1
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +0 -2
- package/dist/shared/@outfitter/{cli-ttt7r0j7.d.ts → cli-02kyvj7h.d.ts} +2 -13
- package/dist/shared/@outfitter/{cli-e6yv2764.d.ts → cli-f79bwzsp.d.ts} +1 -1
- package/dist/shared/@outfitter/{cli-d9ad0rqj.js → cli-jbj78ac5.js} +1 -6
- package/dist/shared/@outfitter/{cli-5g6rkv3d.js → cli-rk9zagkm.js} +24 -32
- package/dist/shared/@outfitter/{cli-4h4rpdra.js → cli-zahqsaby.js} +32 -10
- package/dist/terminal/detection.js +1 -5
- package/dist/terminal/index.js +1 -6
- package/dist/{shared/@outfitter/cli-4cb5g831.d.ts → text.d.ts} +1 -1
- package/dist/{shared/@outfitter/cli-mwxsh3sr.js → text.js} +15 -14
- package/dist/types.d.ts +2 -2
- package/dist/types.js +0 -2
- package/package.json +35 -213
- package/dist/borders/index.d.ts +0 -3
- package/dist/borders/index.js +0 -13
- package/dist/box/index.d.ts +0 -4
- package/dist/box/index.js +0 -13
- package/dist/demo/index.d.ts +0 -78
- package/dist/demo/index.js +0 -148
- package/dist/demo/registry.d.ts +0 -7
- package/dist/demo/registry.js +0 -28
- package/dist/demo/renderers/borders.d.ts +0 -7
- package/dist/demo/renderers/borders.js +0 -17
- package/dist/demo/renderers/box.d.ts +0 -7
- package/dist/demo/renderers/box.js +0 -18
- package/dist/demo/renderers/colors.d.ts +0 -7
- package/dist/demo/renderers/colors.js +0 -18
- package/dist/demo/renderers/indicators.d.ts +0 -7
- package/dist/demo/renderers/indicators.js +0 -17
- package/dist/demo/renderers/list.d.ts +0 -7
- package/dist/demo/renderers/list.js +0 -19
- package/dist/demo/renderers/markdown.d.ts +0 -7
- package/dist/demo/renderers/markdown.js +0 -18
- package/dist/demo/renderers/progress.d.ts +0 -7
- package/dist/demo/renderers/progress.js +0 -17
- package/dist/demo/renderers/spinner.d.ts +0 -7
- package/dist/demo/renderers/spinner.js +0 -19
- package/dist/demo/renderers/table.d.ts +0 -7
- package/dist/demo/renderers/table.js +0 -19
- package/dist/demo/renderers/text.d.ts +0 -7
- package/dist/demo/renderers/text.js +0 -16
- package/dist/demo/renderers/tree.d.ts +0 -7
- package/dist/demo/renderers/tree.js +0 -18
- package/dist/demo/section.d.ts +0 -5
- package/dist/demo/section.js +0 -23
- package/dist/demo/templates.d.ts +0 -4
- package/dist/demo/templates.js +0 -10
- package/dist/demo/types.d.ts +0 -3
- package/dist/demo/types.js +0 -8
- package/dist/list/index.d.ts +0 -3
- package/dist/list/index.js +0 -9
- package/dist/preset/full.d.ts +0 -14
- package/dist/preset/full.js +0 -41
- package/dist/preset/standard.d.ts +0 -11
- package/dist/preset/standard.js +0 -30
- package/dist/prompt/confirm.d.ts +0 -4
- package/dist/prompt/confirm.js +0 -9
- package/dist/prompt/group.d.ts +0 -4
- package/dist/prompt/group.js +0 -9
- package/dist/prompt/index.d.ts +0 -7
- package/dist/prompt/index.js +0 -32
- package/dist/prompt/select.d.ts +0 -4
- package/dist/prompt/select.js +0 -11
- package/dist/prompt/text.d.ts +0 -4
- package/dist/prompt/text.js +0 -11
- package/dist/prompt/types.d.ts +0 -3
- package/dist/prompt/types.js +0 -8
- package/dist/prompt/validators.d.ts +0 -2
- package/dist/prompt/validators.js +0 -8
- package/dist/render/borders.d.ts +0 -2
- package/dist/render/borders.js +0 -15
- package/dist/render/box.d.ts +0 -3
- package/dist/render/box.js +0 -23
- package/dist/render/date.d.ts +0 -2
- package/dist/render/date.js +0 -12
- package/dist/render/format-relative.d.ts +0 -2
- package/dist/render/format-relative.js +0 -8
- package/dist/render/format.d.ts +0 -2
- package/dist/render/format.js +0 -10
- package/dist/render/heading.d.ts +0 -3
- package/dist/render/heading.js +0 -14
- package/dist/render/index.d.ts +0 -32
- package/dist/render/index.js +0 -235
- package/dist/render/indicators.d.ts +0 -2
- package/dist/render/indicators.js +0 -16
- package/dist/render/json.d.ts +0 -2
- package/dist/render/json.js +0 -10
- package/dist/render/layout.d.ts +0 -5
- package/dist/render/layout.js +0 -25
- package/dist/render/list.d.ts +0 -2
- package/dist/render/list.js +0 -8
- package/dist/render/markdown.d.ts +0 -2
- package/dist/render/markdown.js +0 -10
- package/dist/render/progress.d.ts +0 -2
- package/dist/render/progress.js +0 -8
- package/dist/render/separator.d.ts +0 -3
- package/dist/render/separator.js +0 -14
- package/dist/render/shapes.d.ts +0 -2
- package/dist/render/shapes.js +0 -35
- package/dist/render/spinner.d.ts +0 -2
- package/dist/render/spinner.js +0 -12
- package/dist/render/stack.d.ts +0 -3
- package/dist/render/stack.js +0 -38
- package/dist/render/table.d.ts +0 -3
- package/dist/render/table.js +0 -12
- package/dist/render/text.d.ts +0 -2
- package/dist/render/text.js +0 -27
- package/dist/render/tree.d.ts +0 -2
- package/dist/render/tree.js +0 -10
- package/dist/render/types.d.ts +0 -2
- package/dist/shared/@outfitter/cli-0djg8q91.js +0 -7
- package/dist/shared/@outfitter/cli-0w242qtv.d.ts +0 -48
- package/dist/shared/@outfitter/cli-1g8tt31a.d.ts +0 -119
- package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +0 -45
- package/dist/shared/@outfitter/cli-1sb3xvnw.js +0 -95
- package/dist/shared/@outfitter/cli-1vy0vtga.js +0 -135
- package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +0 -50
- package/dist/shared/@outfitter/cli-33e97cjs.d.ts +0 -42
- package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +0 -97
- package/dist/shared/@outfitter/cli-3hk2xf3c.js +0 -82
- package/dist/shared/@outfitter/cli-3hp8qwx3.js +0 -11
- package/dist/shared/@outfitter/cli-47yw5h6a.js +0 -7
- package/dist/shared/@outfitter/cli-4b6tbp68.d.ts +0 -36
- package/dist/shared/@outfitter/cli-4fcz51qa.js +0 -70
- package/dist/shared/@outfitter/cli-4x6pqnez.js +0 -20
- package/dist/shared/@outfitter/cli-4zk2y4a2.d.ts +0 -61
- package/dist/shared/@outfitter/cli-60b5xh1r.js +0 -20
- package/dist/shared/@outfitter/cli-6bztk73z.d.ts +0 -51
- package/dist/shared/@outfitter/cli-6fxffp8k.js +0 -1
- package/dist/shared/@outfitter/cli-6hg0sg2d.d.ts +0 -93
- package/dist/shared/@outfitter/cli-6r3m2knf.js +0 -62
- package/dist/shared/@outfitter/cli-6ty1nvws.js +0 -179
- package/dist/shared/@outfitter/cli-7n610r63.js +0 -20
- package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +0 -59
- package/dist/shared/@outfitter/cli-83jwvj1t.d.ts +0 -17
- package/dist/shared/@outfitter/cli-85fg2vr5.js +0 -123
- package/dist/shared/@outfitter/cli-8bwaw3pz.js +0 -7
- package/dist/shared/@outfitter/cli-8hngbjyr.d.ts +0 -164
- package/dist/shared/@outfitter/cli-8j5k6mr3.js +0 -71
- package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +0 -223
- package/dist/shared/@outfitter/cli-914d47mt.js +0 -20
- package/dist/shared/@outfitter/cli-9bcm4zhf.d.ts +0 -87
- package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +0 -190
- package/dist/shared/@outfitter/cli-a4q87517.d.ts +0 -64
- package/dist/shared/@outfitter/cli-aem6v4c8.js +0 -146
- package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +0 -132
- package/dist/shared/@outfitter/cli-b5c2k0d7.js +0 -39
- package/dist/shared/@outfitter/cli-b5epywry.js +0 -1
- package/dist/shared/@outfitter/cli-bc17qeh2.js +0 -19
- package/dist/shared/@outfitter/cli-bcmcaz1b.js +0 -23
- package/dist/shared/@outfitter/cli-bv09nme3.d.ts +0 -56
- package/dist/shared/@outfitter/cli-c6pbxpw0.d.ts +0 -112
- package/dist/shared/@outfitter/cli-c8fqdaes.js +0 -117
- package/dist/shared/@outfitter/cli-c8q4f71g.js +0 -144
- package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +0 -30
- package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +0 -53
- package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +0 -42
- package/dist/shared/@outfitter/cli-cwgj6mcs.js +0 -214
- package/dist/shared/@outfitter/cli-d8ahdd9d.js +0 -272
- package/dist/shared/@outfitter/cli-dbyteh27.d.ts +0 -24
- package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +0 -91
- package/dist/shared/@outfitter/cli-en6zn6sj.js +0 -1
- package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +0 -300
- package/dist/shared/@outfitter/cli-f6fsaayd.js +0 -94
- package/dist/shared/@outfitter/cli-fakncnjp.d.ts +0 -106
- package/dist/shared/@outfitter/cli-ffa0jwb7.js +0 -122
- package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +0 -66
- package/dist/shared/@outfitter/cli-h3jz0bxz.js +0 -48
- package/dist/shared/@outfitter/cli-h4wpzb3f.js +0 -67
- package/dist/shared/@outfitter/cli-hda6mc28.js +0 -126
- package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +0 -328
- package/dist/shared/@outfitter/cli-j19a91ck.js +0 -30
- package/dist/shared/@outfitter/cli-jejfypgf.js +0 -85
- package/dist/shared/@outfitter/cli-jp0k3qd9.js +0 -279
- package/dist/shared/@outfitter/cli-k76e7173.js +0 -128
- package/dist/shared/@outfitter/cli-kc3ffp1v.d.ts +0 -23
- package/dist/shared/@outfitter/cli-kk5hnndk.d.ts +0 -128
- package/dist/shared/@outfitter/cli-ktqme80d.js +0 -7
- package/dist/shared/@outfitter/cli-mq0jp15z.js +0 -1
- package/dist/shared/@outfitter/cli-n0c33vba.js +0 -25
- package/dist/shared/@outfitter/cli-n17gt1dz.js +0 -19
- package/dist/shared/@outfitter/cli-n9dbh0hp.js +0 -51
- package/dist/shared/@outfitter/cli-ndem6tz8.js +0 -63
- package/dist/shared/@outfitter/cli-nj4nqy1h.d.ts +0 -24
- package/dist/shared/@outfitter/cli-nkns8p4r.js +0 -61
- package/dist/shared/@outfitter/cli-p3dqm1vd.js +0 -22
- package/dist/shared/@outfitter/cli-pndwprz8.js +0 -118
- package/dist/shared/@outfitter/cli-pvrwv6rb.js +0 -352
- package/dist/shared/@outfitter/cli-py02m79x.d.ts +0 -20
- package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +0 -71
- package/dist/shared/@outfitter/cli-regjbef6.d.ts +0 -26
- package/dist/shared/@outfitter/cli-s1tx5kha.d.ts +0 -59
- package/dist/shared/@outfitter/cli-sam2sq50.js +0 -37
- package/dist/shared/@outfitter/cli-snxj55n6.js +0 -43
- package/dist/shared/@outfitter/cli-symyxb0z.js +0 -20
- package/dist/shared/@outfitter/cli-tvw1xrdj.js +0 -20
- package/dist/shared/@outfitter/cli-v1tzwxkt.js +0 -32
- package/dist/shared/@outfitter/cli-vd60dj65.js +0 -1
- package/dist/shared/@outfitter/cli-vfcrskfj.d.ts +0 -41
- package/dist/shared/@outfitter/cli-vstbkzky.d.ts +0 -74
- package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +0 -54
- package/dist/shared/@outfitter/cli-x4cavvc0.js +0 -1
- package/dist/shared/@outfitter/cli-xep6v2c0.js +0 -52
- package/dist/shared/@outfitter/cli-xg5y5fhk.js +0 -86
- package/dist/shared/@outfitter/cli-y7k1t81k.js +0 -30
- package/dist/shared/@outfitter/cli-yfyzy95c.js +0 -67
- package/dist/shared/@outfitter/cli-z78mkrc7.js +0 -59
- package/dist/shared/@outfitter/cli-znc47004.js +0 -134
- package/dist/shared/@outfitter/cli-zx598p8q.d.ts +0 -26
- package/dist/streaming/ansi.d.ts +0 -2
- package/dist/streaming/ansi.js +0 -8
- package/dist/streaming/index.d.ts +0 -4
- package/dist/streaming/index.js +0 -17
- package/dist/streaming/spinner.d.ts +0 -3
- package/dist/streaming/spinner.js +0 -10
- package/dist/streaming/writer.d.ts +0 -2
- package/dist/streaming/writer.js +0 -9
- package/dist/table/index.d.ts +0 -4
- package/dist/table/index.js +0 -13
- package/dist/theme/context.d.ts +0 -9
- package/dist/theme/context.js +0 -14
- package/dist/theme/create.d.ts +0 -8
- package/dist/theme/create.js +0 -12
- package/dist/theme/index.d.ts +0 -17
- package/dist/theme/index.js +0 -42
- package/dist/theme/presets/bold.d.ts +0 -8
- package/dist/theme/presets/bold.js +0 -12
- package/dist/theme/presets/default.d.ts +0 -8
- package/dist/theme/presets/default.js +0 -11
- package/dist/theme/presets/index.d.ts +0 -12
- package/dist/theme/presets/index.js +0 -24
- package/dist/theme/presets/minimal.d.ts +0 -8
- package/dist/theme/presets/minimal.js +0 -12
- package/dist/theme/presets/rounded.d.ts +0 -8
- package/dist/theme/presets/rounded.js +0 -12
- package/dist/theme/resolve.d.ts +0 -8
- package/dist/theme/resolve.js +0 -11
- package/dist/theme/types.d.ts +0 -7
- package/dist/theme/types.js +0 -1
- package/dist/tree/index.d.ts +0 -3
- package/dist/tree/index.js +0 -11
- /package/dist/shared/@outfitter/{cli-ykxn7rb2.d.ts → cli-xppg982q.d.ts} +0 -0
- /package/dist/{render/types.js → shared/@outfitter/cli-zw75pdk8.js} +0 -0
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
getStringWidth,
|
|
4
|
-
init_text,
|
|
5
|
-
truncateText,
|
|
6
|
-
wrapText
|
|
7
|
-
} from "./cli-mwxsh3sr.js";
|
|
8
|
-
import {
|
|
9
|
-
getBorderCharacters,
|
|
10
|
-
init_borders
|
|
11
|
-
} from "./cli-85fg2vr5.js";
|
|
12
|
-
import {
|
|
13
|
-
__esm,
|
|
14
|
-
__export
|
|
15
|
-
} from "./cli-v1tzwxkt.js";
|
|
16
|
-
|
|
17
|
-
// packages/cli/src/render/box.ts
|
|
18
|
-
var exports_box = {};
|
|
19
|
-
__export(exports_box, {
|
|
20
|
-
renderBox: () => renderBox,
|
|
21
|
-
normalizePadding: () => normalizePadding,
|
|
22
|
-
normalizeMargin: () => normalizeMargin,
|
|
23
|
-
normalizeBorders: () => normalizeBorders,
|
|
24
|
-
createBox: () => createBox
|
|
25
|
-
});
|
|
26
|
-
function alignLine(line, width, align) {
|
|
27
|
-
const lineWidth = getStringWidth(line);
|
|
28
|
-
const padding = width - lineWidth;
|
|
29
|
-
if (padding <= 0) {
|
|
30
|
-
return line;
|
|
31
|
-
}
|
|
32
|
-
switch (align) {
|
|
33
|
-
case "center": {
|
|
34
|
-
const leftPad = Math.floor(padding / 2);
|
|
35
|
-
const rightPad = padding - leftPad;
|
|
36
|
-
return " ".repeat(leftPad) + line + " ".repeat(rightPad);
|
|
37
|
-
}
|
|
38
|
-
case "right":
|
|
39
|
-
return " ".repeat(padding) + line;
|
|
40
|
-
default:
|
|
41
|
-
return line + " ".repeat(padding);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function normalizePadding(padding, defaultValue) {
|
|
45
|
-
if (padding === undefined) {
|
|
46
|
-
return { top: 0, right: defaultValue, bottom: 0, left: defaultValue };
|
|
47
|
-
}
|
|
48
|
-
if (typeof padding === "number") {
|
|
49
|
-
return { top: 0, right: padding, bottom: 0, left: padding };
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
top: padding.top ?? 0,
|
|
53
|
-
right: padding.right ?? defaultValue,
|
|
54
|
-
bottom: padding.bottom ?? 0,
|
|
55
|
-
left: padding.left ?? defaultValue
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function normalizeMargin(margin, defaultValue) {
|
|
59
|
-
if (margin === undefined) {
|
|
60
|
-
return {
|
|
61
|
-
top: defaultValue,
|
|
62
|
-
right: defaultValue,
|
|
63
|
-
bottom: defaultValue,
|
|
64
|
-
left: defaultValue
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (typeof margin === "number") {
|
|
68
|
-
return { top: margin, right: margin, bottom: margin, left: margin };
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
top: margin.top ?? defaultValue,
|
|
72
|
-
right: margin.right ?? defaultValue,
|
|
73
|
-
bottom: margin.bottom ?? defaultValue,
|
|
74
|
-
left: margin.left ?? defaultValue
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function normalizeBorders(borders) {
|
|
78
|
-
if (borders === undefined) {
|
|
79
|
-
return { top: true, right: true, bottom: true, left: true };
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
top: borders.top ?? true,
|
|
83
|
-
right: borders.right ?? true,
|
|
84
|
-
bottom: borders.bottom ?? true,
|
|
85
|
-
left: borders.left ?? true
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function renderBox(content, options) {
|
|
89
|
-
const border = options?.border ?? "single";
|
|
90
|
-
const title = options?.title;
|
|
91
|
-
const align = options?.align ?? "left";
|
|
92
|
-
const fixedWidth = options?.width;
|
|
93
|
-
const sections = options?.sections;
|
|
94
|
-
const pad = normalizePadding(options?.padding, 1);
|
|
95
|
-
const margin = normalizeMargin(options?.margin, 0);
|
|
96
|
-
const borders = normalizeBorders(options?.borders);
|
|
97
|
-
const chars = getBorderCharacters(border);
|
|
98
|
-
let lines;
|
|
99
|
-
let sectionBoundaries = [];
|
|
100
|
-
if (sections && sections.length > 0) {
|
|
101
|
-
lines = [];
|
|
102
|
-
for (const [idx, section] of sections.entries()) {
|
|
103
|
-
const sectionLines = typeof section === "string" ? section.split(`
|
|
104
|
-
`) : section;
|
|
105
|
-
lines.push(...sectionLines);
|
|
106
|
-
if (idx < sections.length - 1) {
|
|
107
|
-
sectionBoundaries.push(lines.length);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} else if (typeof content === "string") {
|
|
111
|
-
lines = content.split(`
|
|
112
|
-
`);
|
|
113
|
-
} else {
|
|
114
|
-
lines = content;
|
|
115
|
-
}
|
|
116
|
-
const leftOverhead = (borders.left ? 1 : 0) + pad.left;
|
|
117
|
-
const rightOverhead = (borders.right ? 1 : 0) + pad.right;
|
|
118
|
-
const horizontalOverhead = leftOverhead + rightOverhead;
|
|
119
|
-
if (fixedWidth) {
|
|
120
|
-
const contentWidthForWrap = fixedWidth - horizontalOverhead;
|
|
121
|
-
if (contentWidthForWrap > 0) {
|
|
122
|
-
const wrappedLines = [];
|
|
123
|
-
const newBoundaries = [];
|
|
124
|
-
let boundaryIdx2 = 0;
|
|
125
|
-
let originalLineCount = 0;
|
|
126
|
-
for (const line of lines) {
|
|
127
|
-
if (getStringWidth(line) > contentWidthForWrap) {
|
|
128
|
-
const wrapped = wrapText(line, contentWidthForWrap);
|
|
129
|
-
wrappedLines.push(...wrapped.split(`
|
|
130
|
-
`));
|
|
131
|
-
} else {
|
|
132
|
-
wrappedLines.push(line);
|
|
133
|
-
}
|
|
134
|
-
originalLineCount++;
|
|
135
|
-
const boundary = sectionBoundaries[boundaryIdx2];
|
|
136
|
-
if (boundary !== undefined && originalLineCount === boundary) {
|
|
137
|
-
newBoundaries.push(wrappedLines.length);
|
|
138
|
-
boundaryIdx2++;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
lines = wrappedLines;
|
|
142
|
-
sectionBoundaries = newBoundaries;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
let contentWidth = 0;
|
|
146
|
-
for (const line of lines) {
|
|
147
|
-
const w = getStringWidth(line);
|
|
148
|
-
if (w > contentWidth) {
|
|
149
|
-
contentWidth = w;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
let boxWidth;
|
|
153
|
-
if (fixedWidth) {
|
|
154
|
-
boxWidth = fixedWidth;
|
|
155
|
-
contentWidth = fixedWidth - horizontalOverhead;
|
|
156
|
-
} else {
|
|
157
|
-
boxWidth = horizontalOverhead + contentWidth;
|
|
158
|
-
if (title && borders.top) {
|
|
159
|
-
const minBoxWidthForTitle = getStringWidth(title) + 4 + (borders.left ? 1 : 0) + (borders.right ? 1 : 0);
|
|
160
|
-
if (boxWidth < minBoxWidthForTitle) {
|
|
161
|
-
boxWidth = minBoxWidthForTitle;
|
|
162
|
-
contentWidth = boxWidth - horizontalOverhead;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const output = [];
|
|
167
|
-
const leftPaddingStr = " ".repeat(pad.left);
|
|
168
|
-
const rightPaddingStr = " ".repeat(pad.right);
|
|
169
|
-
const marginLeftStr = " ".repeat(margin.left);
|
|
170
|
-
const marginRightStr = " ".repeat(margin.right);
|
|
171
|
-
const buildContentLine = (lineContent) => {
|
|
172
|
-
const aligned = alignLine(lineContent, contentWidth, align);
|
|
173
|
-
const leftBorder = borders.left ? chars.vertical : "";
|
|
174
|
-
const rightBorder = borders.right ? chars.vertical : "";
|
|
175
|
-
return marginLeftStr + leftBorder + leftPaddingStr + aligned + rightPaddingStr + rightBorder + marginRightStr;
|
|
176
|
-
};
|
|
177
|
-
const innerWidth = boxWidth - (borders.left ? 1 : 0) - (borders.right ? 1 : 0);
|
|
178
|
-
for (let i = 0;i < margin.top; i++) {
|
|
179
|
-
output.push("");
|
|
180
|
-
}
|
|
181
|
-
if (borders.top) {
|
|
182
|
-
let topBorder;
|
|
183
|
-
if (title) {
|
|
184
|
-
const maxTitleWidth = Math.max(0, innerWidth - 4);
|
|
185
|
-
let displayTitle = title;
|
|
186
|
-
if (maxTitleWidth === 0) {
|
|
187
|
-
topBorder = marginLeftStr + (borders.left ? chars.topLeft : "") + chars.horizontal.repeat(Math.max(0, innerWidth)) + (borders.right ? chars.topRight : "") + marginRightStr;
|
|
188
|
-
} else {
|
|
189
|
-
if (getStringWidth(title) > maxTitleWidth) {
|
|
190
|
-
displayTitle = truncateText(title, maxTitleWidth);
|
|
191
|
-
}
|
|
192
|
-
const titlePart = `${chars.horizontal} ${displayTitle} `;
|
|
193
|
-
const remainingWidth = Math.max(0, innerWidth - getStringWidth(titlePart));
|
|
194
|
-
topBorder = marginLeftStr + (borders.left ? chars.topLeft : "") + titlePart + chars.horizontal.repeat(remainingWidth) + (borders.right ? chars.topRight : "") + marginRightStr;
|
|
195
|
-
}
|
|
196
|
-
} else {
|
|
197
|
-
topBorder = marginLeftStr + (borders.left ? chars.topLeft : "") + chars.horizontal.repeat(innerWidth) + (borders.right ? chars.topRight : "") + marginRightStr;
|
|
198
|
-
}
|
|
199
|
-
output.push(topBorder);
|
|
200
|
-
}
|
|
201
|
-
for (let i = 0;i < pad.top; i++) {
|
|
202
|
-
output.push(buildContentLine(""));
|
|
203
|
-
}
|
|
204
|
-
let boundaryIdx = 0;
|
|
205
|
-
for (const [idx, line] of lines.entries()) {
|
|
206
|
-
output.push(buildContentLine(line));
|
|
207
|
-
const boundary = sectionBoundaries[boundaryIdx];
|
|
208
|
-
if (boundary !== undefined && idx + 1 === boundary) {
|
|
209
|
-
const divider = marginLeftStr + (borders.left ? chars.leftT : "") + chars.horizontal.repeat(innerWidth) + (borders.right ? chars.rightT : "") + marginRightStr;
|
|
210
|
-
output.push(divider);
|
|
211
|
-
boundaryIdx++;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
for (let i = 0;i < pad.bottom; i++) {
|
|
215
|
-
output.push(buildContentLine(""));
|
|
216
|
-
}
|
|
217
|
-
if (borders.bottom) {
|
|
218
|
-
const bottomBorder = marginLeftStr + (borders.left ? chars.bottomLeft : "") + chars.horizontal.repeat(innerWidth) + (borders.right ? chars.bottomRight : "") + marginRightStr;
|
|
219
|
-
output.push(bottomBorder);
|
|
220
|
-
}
|
|
221
|
-
for (let i = 0;i < margin.bottom; i++) {
|
|
222
|
-
output.push("");
|
|
223
|
-
}
|
|
224
|
-
return output.join(`
|
|
225
|
-
`);
|
|
226
|
-
}
|
|
227
|
-
function isBox(value) {
|
|
228
|
-
return typeof value === "object" && value !== null && "output" in value && "width" in value && "height" in value && typeof value.output === "string" && typeof value.width === "number" && typeof value.height === "number";
|
|
229
|
-
}
|
|
230
|
-
function contentToLines(content) {
|
|
231
|
-
if (Array.isArray(content)) {
|
|
232
|
-
const lines = [];
|
|
233
|
-
for (const item of content) {
|
|
234
|
-
if (isBox(item)) {
|
|
235
|
-
lines.push(...item.output.split(`
|
|
236
|
-
`));
|
|
237
|
-
} else if (Array.isArray(item)) {
|
|
238
|
-
lines.push(...item);
|
|
239
|
-
} else {
|
|
240
|
-
lines.push(...item.split(`
|
|
241
|
-
`));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return lines;
|
|
245
|
-
}
|
|
246
|
-
if (isBox(content)) {
|
|
247
|
-
return content.output.split(`
|
|
248
|
-
`);
|
|
249
|
-
}
|
|
250
|
-
if (typeof content === "string") {
|
|
251
|
-
return content.split(`
|
|
252
|
-
`);
|
|
253
|
-
}
|
|
254
|
-
return content;
|
|
255
|
-
}
|
|
256
|
-
function createBox(content, options) {
|
|
257
|
-
const lines = contentToLines(content);
|
|
258
|
-
const output = renderBox(lines, options);
|
|
259
|
-
const outputLines = output.split(`
|
|
260
|
-
`);
|
|
261
|
-
let maxWidth = 0;
|
|
262
|
-
for (const line of outputLines) {
|
|
263
|
-
const lineWidth = getStringWidth(line);
|
|
264
|
-
if (lineWidth > maxWidth) {
|
|
265
|
-
maxWidth = lineWidth;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return {
|
|
269
|
-
output,
|
|
270
|
-
width: maxWidth,
|
|
271
|
-
height: outputLines.length
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
var init_box = __esm(() => {
|
|
275
|
-
init_borders();
|
|
276
|
-
init_text();
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
export { normalizePadding, normalizeMargin, normalizeBorders, renderBox, createBox, exports_box, init_box };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
demoSection
|
|
4
|
-
} from "./cli-sam2sq50.js";
|
|
5
|
-
import {
|
|
6
|
-
getStringWidth,
|
|
7
|
-
init_text,
|
|
8
|
-
padText,
|
|
9
|
-
pluralize,
|
|
10
|
-
slugify,
|
|
11
|
-
truncateText,
|
|
12
|
-
wrapText
|
|
13
|
-
} from "./cli-mwxsh3sr.js";
|
|
14
|
-
|
|
15
|
-
// packages/cli/src/demo/renderers/text.ts
|
|
16
|
-
init_text();
|
|
17
|
-
function renderTextDemo(config, theme) {
|
|
18
|
-
const showCode = config.showCode ?? true;
|
|
19
|
-
const lines = [];
|
|
20
|
-
lines.push(demoSection("String Width"));
|
|
21
|
-
lines.push("");
|
|
22
|
-
if (showCode) {
|
|
23
|
-
lines.push('import { getStringWidth } from "@outfitter/cli/render";');
|
|
24
|
-
lines.push("");
|
|
25
|
-
}
|
|
26
|
-
const widthExamples = [
|
|
27
|
-
{ text: "Hello", expected: 5 },
|
|
28
|
-
{ text: "\u4F60\u597D", expected: 4 },
|
|
29
|
-
{ text: "\uD83C\uDF89", expected: 2 },
|
|
30
|
-
{ text: "\x1B[32mGreen\x1B[0m", expected: 5 }
|
|
31
|
-
];
|
|
32
|
-
for (const ex of widthExamples) {
|
|
33
|
-
const width = getStringWidth(ex.text);
|
|
34
|
-
const display = ex.text.includes("\x1B") ? '"\\x1b[32mGreen\\x1b[0m"' : `"${ex.text}"`;
|
|
35
|
-
lines.push(`getStringWidth(${display.padEnd(24)}) \u2192 ${width}`);
|
|
36
|
-
}
|
|
37
|
-
lines.push("");
|
|
38
|
-
lines.push(theme.muted("Correctly handles CJK, emoji, and ANSI codes."));
|
|
39
|
-
lines.push("");
|
|
40
|
-
lines.push(demoSection("Text Wrapping"));
|
|
41
|
-
lines.push("");
|
|
42
|
-
if (showCode) {
|
|
43
|
-
lines.push('import { wrapText } from "@outfitter/cli/render";');
|
|
44
|
-
lines.push("");
|
|
45
|
-
}
|
|
46
|
-
const longText = "This is a long sentence that should be wrapped at the specified width.";
|
|
47
|
-
if (showCode) {
|
|
48
|
-
lines.push(`wrapText("${longText}", 30)`);
|
|
49
|
-
lines.push("");
|
|
50
|
-
}
|
|
51
|
-
lines.push("Result:");
|
|
52
|
-
const wrapped = wrapText(longText, 30);
|
|
53
|
-
for (const line of wrapped.split(`
|
|
54
|
-
`)) {
|
|
55
|
-
lines.push(` \u2502${line}\u2502`);
|
|
56
|
-
}
|
|
57
|
-
lines.push("");
|
|
58
|
-
lines.push(demoSection("Truncation"));
|
|
59
|
-
lines.push("");
|
|
60
|
-
if (showCode) {
|
|
61
|
-
lines.push('import { truncateText } from "@outfitter/cli/render";');
|
|
62
|
-
lines.push("");
|
|
63
|
-
}
|
|
64
|
-
const truncExamples = [
|
|
65
|
-
{ text: "Hello World", width: 8 },
|
|
66
|
-
{ text: "Short", width: 10 },
|
|
67
|
-
{ text: "Very long text that will be truncated", width: 15 }
|
|
68
|
-
];
|
|
69
|
-
for (const ex of truncExamples) {
|
|
70
|
-
const result = truncateText(ex.text, ex.width);
|
|
71
|
-
lines.push(`truncateText("${ex.text}", ${ex.width})`);
|
|
72
|
-
lines.push(` \u2192 "${result}"`);
|
|
73
|
-
lines.push("");
|
|
74
|
-
}
|
|
75
|
-
lines.push(demoSection("Padding"));
|
|
76
|
-
lines.push("");
|
|
77
|
-
if (showCode) {
|
|
78
|
-
lines.push('import { padText } from "@outfitter/cli/render";');
|
|
79
|
-
lines.push("");
|
|
80
|
-
}
|
|
81
|
-
const padExamples = ["Hi", "Hello", "Greetings"];
|
|
82
|
-
for (const text of padExamples) {
|
|
83
|
-
const padded = padText(text, 15);
|
|
84
|
-
lines.push(`padText("${text}", 15) \u2192 "${padded}"`);
|
|
85
|
-
}
|
|
86
|
-
lines.push("");
|
|
87
|
-
lines.push(demoSection("Pluralize"));
|
|
88
|
-
lines.push("");
|
|
89
|
-
if (showCode) {
|
|
90
|
-
lines.push('import { pluralize } from "@outfitter/cli/render";');
|
|
91
|
-
lines.push("");
|
|
92
|
-
}
|
|
93
|
-
const pluralExamples = [
|
|
94
|
-
{ count: 0, word: "item" },
|
|
95
|
-
{ count: 1, word: "item" },
|
|
96
|
-
{ count: 5, word: "item" },
|
|
97
|
-
{ count: 1, word: "child", plural: "children" },
|
|
98
|
-
{ count: 3, word: "child", plural: "children" }
|
|
99
|
-
];
|
|
100
|
-
for (const ex of pluralExamples) {
|
|
101
|
-
const result = pluralize(ex.count, ex.word, ex.plural);
|
|
102
|
-
const code = ex.plural ? `pluralize(${ex.count}, "${ex.word}", "${ex.plural}")` : `pluralize(${ex.count}, "${ex.word}")`;
|
|
103
|
-
lines.push(`${code.padEnd(40)} \u2192 "${result}"`);
|
|
104
|
-
}
|
|
105
|
-
lines.push("");
|
|
106
|
-
lines.push(demoSection("Slugify"));
|
|
107
|
-
lines.push("");
|
|
108
|
-
if (showCode) {
|
|
109
|
-
lines.push('import { slugify } from "@outfitter/cli/render";');
|
|
110
|
-
lines.push("");
|
|
111
|
-
}
|
|
112
|
-
const slugExamples = [
|
|
113
|
-
"Hello World!",
|
|
114
|
-
"This & That",
|
|
115
|
-
" Multiple Spaces ",
|
|
116
|
-
"CamelCase"
|
|
117
|
-
];
|
|
118
|
-
for (const text of slugExamples) {
|
|
119
|
-
const result = slugify(text);
|
|
120
|
-
lines.push(`slugify("${text}")`);
|
|
121
|
-
lines.push(` \u2192 "${result}"`);
|
|
122
|
-
lines.push("");
|
|
123
|
-
}
|
|
124
|
-
return lines.join(`
|
|
125
|
-
`);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export { renderTextDemo };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ConfirmPromptOptions, PromptResult } from "./cli-9bcm4zhf";
|
|
2
|
-
/**
|
|
3
|
-
* Prompts for yes/no confirmation with Result wrapping.
|
|
4
|
-
*
|
|
5
|
-
* @param options - Confirm prompt options
|
|
6
|
-
* @returns Ok with boolean or Err with CancelledError
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { promptConfirm } from "@outfitter/cli/prompt";
|
|
11
|
-
*
|
|
12
|
-
* const result = await promptConfirm({
|
|
13
|
-
* message: "Are you sure you want to continue?",
|
|
14
|
-
* initialValue: false,
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* if (result.isOk() && result.value) {
|
|
18
|
-
* console.log("Continuing...");
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
declare function promptConfirm(options: ConfirmPromptOptions): PromptResult<boolean>;
|
|
23
|
-
export { promptConfirm };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { CaseMode, SeparatorStyle } from "./cli-6bztk73z";
|
|
2
|
-
import { Theme } from "./cli-ykxn7rb2";
|
|
3
|
-
/**
|
|
4
|
-
* Options for creating a demo section.
|
|
5
|
-
*/
|
|
6
|
-
interface SectionOptions {
|
|
7
|
-
/** Separator character style (default: "─") */
|
|
8
|
-
separator?: SeparatorStyle;
|
|
9
|
-
/** Case transformation (default: "title") */
|
|
10
|
-
case?: CaseMode;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Options for creating a subsection.
|
|
14
|
-
*/
|
|
15
|
-
interface SubsectionOptions {
|
|
16
|
-
/** Separator character style (default: "─") */
|
|
17
|
-
separator?: SeparatorStyle;
|
|
18
|
-
/** Case transformation (default: "title") */
|
|
19
|
-
case?: CaseMode;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Creates a demo section heading.
|
|
23
|
-
*
|
|
24
|
-
* Sections are major divisions in a demo, rendered with title case text
|
|
25
|
-
* and thin Unicode line separators by default.
|
|
26
|
-
*
|
|
27
|
-
* @param title - The section title
|
|
28
|
-
* @param options - Optional rendering options
|
|
29
|
-
* @returns Formatted section heading string
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* import { demoSection } from "@outfitter/cli/demo";
|
|
34
|
-
*
|
|
35
|
-
* console.log(demoSection("Theme Colors"));
|
|
36
|
-
* // Theme Colors
|
|
37
|
-
* // ────────────
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare function demoSection(title: string, options?: SectionOptions): string;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a demo subsection heading.
|
|
43
|
-
*
|
|
44
|
-
* Subsections are minor divisions within a section, rendered with title case
|
|
45
|
-
* text and thin Unicode line separators by default.
|
|
46
|
-
*
|
|
47
|
-
* @param title - The subsection title
|
|
48
|
-
* @param options - Optional rendering options
|
|
49
|
-
* @returns Formatted subsection heading string
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* import { demoSubsection } from "@outfitter/cli/demo";
|
|
54
|
-
*
|
|
55
|
-
* console.log(demoSubsection("Status"));
|
|
56
|
-
* // Status
|
|
57
|
-
* // ──────
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
declare function demoSubsection(title: string, options?: SubsectionOptions): string;
|
|
61
|
-
/**
|
|
62
|
-
* Creates a code block for demo sections.
|
|
63
|
-
*
|
|
64
|
-
* Code blocks are displayed when `showCode` is enabled and provide
|
|
65
|
-
* usage examples for the primitives being demonstrated.
|
|
66
|
-
*
|
|
67
|
-
* @param lines - Lines of code to display
|
|
68
|
-
* @param show - Whether to show the code block (default: true)
|
|
69
|
-
* @returns Array of code lines, or empty array if hidden
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```typescript
|
|
73
|
-
* import { codeBlock } from "@outfitter/cli/demo";
|
|
74
|
-
*
|
|
75
|
-
* const code = codeBlock([
|
|
76
|
-
* 'import { renderBox } from "@outfitter/cli/render";',
|
|
77
|
-
* "",
|
|
78
|
-
* 'renderBox("Hello")',
|
|
79
|
-
* ], true);
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
declare function codeBlock(lines: string[], show?: boolean): string[];
|
|
83
|
-
/**
|
|
84
|
-
* Creates a description line styled with muted theme.
|
|
85
|
-
*
|
|
86
|
-
* Descriptions provide contextual information about a demo section
|
|
87
|
-
* when `showDescriptions` is enabled.
|
|
88
|
-
*
|
|
89
|
-
* @param text - The description text
|
|
90
|
-
* @param theme - Theme for styling
|
|
91
|
-
* @param show - Whether to show the description (default: true)
|
|
92
|
-
* @returns Array with styled description, or empty array if hidden
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* import { description } from "@outfitter/cli/demo";
|
|
97
|
-
*
|
|
98
|
-
* const desc = description(
|
|
99
|
-
* "Control padding per side with an object.",
|
|
100
|
-
* theme,
|
|
101
|
-
* true
|
|
102
|
-
* );
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
declare function description(text: string, theme: Theme, show?: boolean): string[];
|
|
106
|
-
/**
|
|
107
|
-
* Joins demo content with vertical spacing.
|
|
108
|
-
*
|
|
109
|
-
* Wraps `joinVertical` with demo-appropriate defaults.
|
|
110
|
-
*
|
|
111
|
-
* @param blocks - Content blocks to join
|
|
112
|
-
* @param gap - Lines of spacing between blocks (default: 1)
|
|
113
|
-
* @returns Combined string with blocks stacked
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* ```typescript
|
|
117
|
-
* import { demoSection, demoContent } from "@outfitter/cli/demo";
|
|
118
|
-
*
|
|
119
|
-
* const output = demoContent([
|
|
120
|
-
* demoSection("Colors"),
|
|
121
|
-
* "Color examples here...",
|
|
122
|
-
* demoSection("Borders"),
|
|
123
|
-
* "Border examples here...",
|
|
124
|
-
* ]);
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
declare function demoContent(blocks: string[], gap?: number): string;
|
|
128
|
-
export { SectionOptions, SubsectionOptions, demoSection, demoSubsection, codeBlock, description, demoContent };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
getTerminalWidth
|
|
4
|
-
} from "./cli-aem6v4c8.js";
|
|
5
|
-
|
|
6
|
-
// packages/cli/src/render/separator.ts
|
|
7
|
-
function renderSeparator(options) {
|
|
8
|
-
const style = options?.style ?? "\u2500";
|
|
9
|
-
const widthMode = options?.width ?? 40;
|
|
10
|
-
let width;
|
|
11
|
-
if (widthMode === "text") {
|
|
12
|
-
width = 40;
|
|
13
|
-
} else if (widthMode === "full") {
|
|
14
|
-
width = getTerminalWidth();
|
|
15
|
-
} else {
|
|
16
|
-
width = widthMode;
|
|
17
|
-
}
|
|
18
|
-
if (style.length === 2) {
|
|
19
|
-
const repetitions = Math.ceil(width / 2);
|
|
20
|
-
return style.repeat(repetitions).slice(0, width);
|
|
21
|
-
}
|
|
22
|
-
return style.repeat(width);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { renderSeparator };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/prompt/validators.ts
|
|
3
|
-
var validators = {
|
|
4
|
-
required: (message = "Required") => (value) => value.length > 0 ? undefined : message,
|
|
5
|
-
minLength: (length, message) => (value) => value.length >= length ? undefined : message ?? `Minimum ${length} characters`,
|
|
6
|
-
maxLength: (length, message) => (value) => value.length <= length ? undefined : message ?? `Maximum ${length} characters`,
|
|
7
|
-
pattern: (regex, message) => (value) => regex.test(value) ? undefined : message,
|
|
8
|
-
email: (message = "Invalid email") => validators.pattern(/^[^\s@]+@[^\s@]+\.[^\s@]+$/, message),
|
|
9
|
-
compose: (...fns) => (value) => {
|
|
10
|
-
for (const fn of fns) {
|
|
11
|
-
const error = fn(value);
|
|
12
|
-
if (error)
|
|
13
|
-
return error;
|
|
14
|
-
}
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { validators };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/render/spinner.ts
|
|
3
|
-
var SPINNERS = {
|
|
4
|
-
dots: {
|
|
5
|
-
frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"],
|
|
6
|
-
interval: 80
|
|
7
|
-
},
|
|
8
|
-
line: {
|
|
9
|
-
frames: ["-", "\\", "|", "/"],
|
|
10
|
-
interval: 100
|
|
11
|
-
},
|
|
12
|
-
arc: {
|
|
13
|
-
frames: ["\u25DC", "\u25DD", "\u25DE", "\u25DF"],
|
|
14
|
-
interval: 100
|
|
15
|
-
},
|
|
16
|
-
circle: {
|
|
17
|
-
frames: ["\u25D0", "\u25D3", "\u25D1", "\u25D2"],
|
|
18
|
-
interval: 100
|
|
19
|
-
},
|
|
20
|
-
bounce: {
|
|
21
|
-
frames: ["\u2801", "\u2802", "\u2804", "\u2802"],
|
|
22
|
-
interval: 120
|
|
23
|
-
},
|
|
24
|
-
ping: {
|
|
25
|
-
frames: [
|
|
26
|
-
"(\u25CF )",
|
|
27
|
-
"( \u25CF )",
|
|
28
|
-
"( \u25CF )",
|
|
29
|
-
"( \u25CF )",
|
|
30
|
-
"( \u25CF)",
|
|
31
|
-
"( \u25CF )",
|
|
32
|
-
"( \u25CF )",
|
|
33
|
-
"( \u25CF )"
|
|
34
|
-
],
|
|
35
|
-
interval: 80
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
function getSpinnerFrame(style, elapsed) {
|
|
39
|
-
const spinner = SPINNERS[style];
|
|
40
|
-
const frameIndex = Math.floor(elapsed / spinner.interval) % spinner.frames.length;
|
|
41
|
-
return spinner.frames[frameIndex] ?? spinner.frames[0] ?? "...";
|
|
42
|
-
}
|
|
43
|
-
function renderSpinner(style, message) {
|
|
44
|
-
const frame = getSpinnerFrame(style, 0);
|
|
45
|
-
if (message && message.length > 0) {
|
|
46
|
-
return `${frame} ${message}`;
|
|
47
|
-
}
|
|
48
|
-
return frame;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { SPINNERS, getSpinnerFrame, renderSpinner };
|