@outfitter/cli 0.1.0-rc.2 → 0.1.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 +21 -32
- package/dist/actions.d.ts +12 -1
- package/dist/actions.js +170 -3
- package/dist/borders/index.d.ts +3 -0
- package/dist/borders/index.js +13 -0
- package/dist/box/index.d.ts +4 -0
- package/dist/box/index.js +13 -0
- package/dist/cli.js +1 -1
- package/dist/colors/index.d.ts +3 -0
- package/dist/colors/index.js +18 -0
- package/dist/command.d.ts +40 -3
- package/dist/command.js +45 -3
- package/dist/demo/index.d.ts +78 -0
- package/dist/demo/index.js +148 -0
- package/dist/demo/registry.d.ts +7 -0
- package/dist/demo/registry.js +28 -0
- package/dist/demo/renderers/borders.d.ts +7 -0
- package/dist/demo/renderers/borders.js +17 -0
- package/dist/demo/renderers/box.d.ts +7 -0
- package/dist/demo/renderers/box.js +18 -0
- package/dist/demo/renderers/colors.d.ts +7 -0
- package/dist/demo/renderers/colors.js +18 -0
- package/dist/demo/renderers/indicators.d.ts +7 -0
- package/dist/demo/renderers/indicators.js +17 -0
- package/dist/demo/renderers/list.d.ts +7 -0
- package/dist/demo/renderers/list.js +19 -0
- package/dist/demo/renderers/markdown.d.ts +7 -0
- package/dist/demo/renderers/markdown.js +18 -0
- package/dist/demo/renderers/progress.d.ts +7 -0
- package/dist/demo/renderers/progress.js +17 -0
- package/dist/demo/renderers/spinner.d.ts +7 -0
- package/dist/demo/renderers/spinner.js +19 -0
- package/dist/demo/renderers/table.d.ts +7 -0
- package/dist/demo/renderers/table.js +19 -0
- package/dist/demo/renderers/text.d.ts +7 -0
- package/dist/demo/renderers/text.js +16 -0
- package/dist/demo/renderers/tree.d.ts +7 -0
- package/dist/demo/renderers/tree.js +18 -0
- package/dist/demo/section.d.ts +5 -0
- package/dist/demo/section.js +23 -0
- package/dist/demo/templates.d.ts +4 -0
- package/dist/demo/templates.js +10 -0
- package/dist/demo/types.d.ts +3 -0
- package/dist/demo/types.js +8 -0
- package/dist/index.d.ts +5 -8
- package/dist/index.js +9 -43
- package/dist/input.d.ts +163 -2
- package/dist/input.js +425 -11
- package/dist/list/index.d.ts +3 -0
- package/dist/list/index.js +9 -0
- package/dist/output.js +1 -1
- package/dist/pagination.d.ts +62 -2
- package/dist/pagination.js +84 -6
- package/dist/preset/full.d.ts +14 -0
- package/dist/preset/full.js +41 -0
- package/dist/preset/standard.d.ts +11 -0
- package/dist/preset/standard.js +30 -0
- package/dist/prompt/confirm.d.ts +4 -0
- package/dist/prompt/confirm.js +9 -0
- package/dist/prompt/group.d.ts +4 -0
- package/dist/prompt/group.js +9 -0
- package/dist/prompt/index.d.ts +7 -0
- package/dist/prompt/index.js +32 -0
- package/dist/prompt/select.d.ts +4 -0
- package/dist/prompt/select.js +11 -0
- package/dist/prompt/text.d.ts +4 -0
- package/dist/prompt/text.js +11 -0
- package/dist/prompt/types.d.ts +3 -0
- package/dist/prompt/types.js +8 -0
- package/dist/prompt/validators.d.ts +2 -0
- package/dist/prompt/validators.js +8 -0
- package/dist/render/borders.d.ts +2 -0
- package/dist/render/borders.js +15 -0
- package/dist/render/box.d.ts +3 -0
- package/dist/render/box.js +23 -0
- package/dist/render/colors.d.ts +1 -1
- package/dist/render/colors.js +6 -3
- package/dist/render/date.js +1 -1
- package/dist/render/format-relative.js +1 -1
- package/dist/render/format.js +1 -1
- package/dist/render/heading.d.ts +3 -0
- package/dist/render/heading.js +14 -0
- package/dist/render/index.d.ts +26 -7
- package/dist/render/index.js +160 -26
- package/dist/render/indicators.d.ts +2 -0
- package/dist/render/indicators.js +14 -0
- package/dist/render/json.js +1 -1
- package/dist/render/layout.d.ts +5 -0
- package/dist/render/layout.js +25 -0
- package/dist/render/list.d.ts +2 -2
- package/dist/render/list.js +2 -2
- package/dist/render/markdown.js +4 -4
- package/dist/render/progress.js +1 -1
- package/dist/render/separator.d.ts +3 -0
- package/dist/render/separator.js +14 -0
- package/dist/render/shapes.js +10 -9
- package/dist/render/spinner.d.ts +2 -0
- package/dist/render/spinner.js +12 -0
- package/dist/render/stack.d.ts +3 -0
- package/dist/render/stack.js +38 -0
- package/dist/render/table.d.ts +2 -1
- package/dist/render/table.js +6 -5
- package/dist/render/text.d.ts +1 -1
- package/dist/render/text.js +7 -4
- package/dist/render/tree.d.ts +2 -2
- package/dist/render/tree.js +5 -3
- package/dist/render/types.d.ts +2 -0
- package/dist/render/types.js +1 -0
- package/dist/shared/@outfitter/cli-0ggcy7fa.js +20 -0
- package/dist/shared/@outfitter/cli-0psys2vm.js +7 -0
- package/dist/shared/@outfitter/cli-1bghjef6.js +352 -0
- package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +45 -0
- package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +50 -0
- package/dist/shared/@outfitter/cli-34fqr7bp.js +37 -0
- package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +97 -0
- package/dist/shared/@outfitter/cli-3dxmmy4c.d.ts +20 -0
- package/dist/shared/@outfitter/cli-3f12z5kf.d.ts +83 -0
- package/dist/shared/@outfitter/cli-3t2zaenc.d.ts +59 -0
- package/dist/shared/@outfitter/{cli-dds0qqvm.d.ts → cli-4cb5g831.d.ts} +2 -0
- package/dist/shared/@outfitter/cli-4w2a1rfy.d.ts +23 -0
- package/dist/shared/@outfitter/cli-4x6pqnez.js +20 -0
- package/dist/shared/@outfitter/cli-671sxkhj.js +146 -0
- package/dist/shared/@outfitter/cli-6bztk73z.d.ts +51 -0
- package/dist/shared/@outfitter/cli-6fxffp8k.js +1 -0
- package/dist/shared/@outfitter/cli-6j9qynm8.js +118 -0
- package/dist/shared/@outfitter/cli-6m988kh0.d.ts +61 -0
- package/dist/shared/@outfitter/cli-74ba31gz.js +134 -0
- package/dist/shared/@outfitter/cli-7gnrb8cr.js +214 -0
- package/dist/shared/@outfitter/cli-7nm6edvh.d.ts +17 -0
- package/dist/shared/@outfitter/cli-85fg2vr5.js +123 -0
- package/dist/shared/@outfitter/cli-8a8xrzhy.js +20 -0
- package/dist/shared/@outfitter/cli-8bwaw3pz.js +7 -0
- package/dist/shared/@outfitter/cli-8rx4g3s5.d.ts +41 -0
- package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +223 -0
- package/dist/shared/@outfitter/cli-96b2p4td.d.ts +56 -0
- package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +190 -0
- package/dist/shared/@outfitter/cli-9mtjjykw.js +67 -0
- package/dist/shared/@outfitter/{cli-ag0w4pk0.js → cli-9nbyj2bt.js} +60 -21
- package/dist/shared/@outfitter/{cli-azzk8a1d.js → cli-afhjqmg3.js} +7 -3
- package/dist/shared/@outfitter/cli-an9j0h80.js +117 -0
- package/dist/shared/@outfitter/cli-ay411nbr.js +122 -0
- package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +132 -0
- package/dist/shared/@outfitter/cli-b5c2k0d7.js +39 -0
- package/dist/shared/@outfitter/cli-b5epywry.js +1 -0
- package/dist/shared/@outfitter/cli-bcmcaz1b.js +23 -0
- package/dist/shared/@outfitter/cli-bf3vma4q.js +61 -0
- package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +53 -0
- package/dist/shared/@outfitter/cli-cs45xd6q.js +59 -0
- package/dist/shared/@outfitter/cli-d7jpshq5.d.ts +128 -0
- package/dist/shared/@outfitter/{cli-jbj78ac5.js → cli-d9ad0rqj.js} +6 -1
- package/dist/shared/@outfitter/cli-daw296mv.js +61 -0
- package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +91 -0
- package/dist/shared/@outfitter/cli-e73v3qqy.d.ts +93 -0
- package/dist/shared/@outfitter/cli-en6zn6sj.js +1 -0
- package/dist/shared/@outfitter/cli-ep2cvtk8.js +48 -0
- package/dist/shared/@outfitter/cli-f75h8e94.js +7 -0
- package/dist/shared/@outfitter/cli-fakncnjp.d.ts +106 -0
- package/dist/shared/@outfitter/cli-feb5j90n.js +94 -0
- package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +66 -0
- package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +328 -0
- package/dist/shared/@outfitter/cli-j4n8gaf3.js +95 -0
- package/dist/shared/@outfitter/cli-jejfypgf.js +85 -0
- package/dist/shared/@outfitter/{cli-wqc652mx.js → cli-jhcdwvpn.js} +8 -8
- package/dist/shared/@outfitter/{cli-v9mjsvjh.js → cli-jjemfdta.js} +13 -46
- package/dist/shared/@outfitter/cli-kc84wmch.js +267 -0
- package/dist/shared/@outfitter/cli-ktqme80d.js +7 -0
- package/dist/shared/@outfitter/cli-mq0jp15z.js +1 -0
- package/dist/shared/@outfitter/cli-mymyavvj.d.ts +26 -0
- package/dist/shared/@outfitter/cli-n17gt1dz.js +19 -0
- package/dist/shared/@outfitter/cli-n9dbh0hp.js +51 -0
- package/dist/shared/@outfitter/cli-nvvc92c8.js +128 -0
- package/dist/shared/@outfitter/cli-p1m5dhrs.js +169 -0
- package/dist/shared/@outfitter/cli-p38sfxyk.js +25 -0
- package/dist/shared/@outfitter/cli-p3dqm1vd.js +22 -0
- package/dist/shared/@outfitter/cli-p9j1phge.js +20 -0
- package/dist/shared/@outfitter/cli-pkxmzavm.js +62 -0
- package/dist/shared/@outfitter/cli-q8r6jarq.d.ts +24 -0
- package/dist/shared/@outfitter/{cli-2y3kxew8.d.ts → cli-qj83y5wj.d.ts} +22 -9
- package/dist/shared/@outfitter/cli-qjfc3j11.d.ts +112 -0
- package/dist/shared/@outfitter/cli-qp4cbhqr.js +70 -0
- package/dist/shared/@outfitter/cli-s0kkx9m1.d.ts +164 -0
- package/dist/shared/@outfitter/cli-snxj55n6.js +43 -0
- package/dist/shared/@outfitter/cli-swwxvjvm.d.ts +24 -0
- package/dist/shared/@outfitter/cli-sx67mmfx.d.ts +98 -0
- package/dist/shared/@outfitter/cli-tarpsa8a.js +30 -0
- package/dist/shared/@outfitter/cli-thvzhjd1.js +126 -0
- package/dist/shared/@outfitter/cli-tqewy503.d.ts +36 -0
- package/dist/shared/@outfitter/cli-tvw1xrdj.js +20 -0
- package/dist/shared/@outfitter/cli-v1tzwxkt.js +32 -0
- package/dist/shared/@outfitter/cli-vd60dj65.js +1 -0
- package/dist/shared/@outfitter/cli-vp88gxev.js +279 -0
- package/dist/shared/@outfitter/cli-vstbkzky.d.ts +74 -0
- package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +54 -0
- package/dist/shared/@outfitter/cli-w5y3xepp.js +20 -0
- package/dist/shared/@outfitter/cli-x4cavvc0.js +1 -0
- package/dist/shared/@outfitter/cli-xep6v2c0.js +52 -0
- package/dist/shared/@outfitter/cli-xg5y5fhk.js +86 -0
- package/dist/shared/@outfitter/{cli-n51t773m.d.ts → cli-xsaheemc.d.ts} +44 -4
- package/dist/shared/@outfitter/cli-xvqtqjxk.js +82 -0
- package/dist/shared/@outfitter/cli-y25tt8nc.d.ts +48 -0
- package/dist/streaming/ansi.d.ts +2 -0
- package/dist/streaming/ansi.js +8 -0
- package/dist/streaming/index.d.ts +4 -0
- package/dist/streaming/index.js +17 -0
- package/dist/streaming/spinner.d.ts +3 -0
- package/dist/streaming/spinner.js +10 -0
- package/dist/streaming/writer.d.ts +2 -0
- package/dist/streaming/writer.js +9 -0
- package/dist/table/index.d.ts +4 -0
- package/dist/table/index.js +13 -0
- package/dist/terminal/detection.js +5 -2
- package/dist/terminal/index.js +6 -2
- package/dist/theme/context.d.ts +9 -0
- package/dist/theme/context.js +14 -0
- package/dist/theme/create.d.ts +8 -0
- package/dist/theme/create.js +12 -0
- package/dist/theme/index.d.ts +17 -0
- package/dist/theme/index.js +42 -0
- package/dist/theme/presets/bold.d.ts +8 -0
- package/dist/theme/presets/bold.js +12 -0
- package/dist/theme/presets/default.d.ts +8 -0
- package/dist/theme/presets/default.js +11 -0
- package/dist/theme/presets/index.d.ts +12 -0
- package/dist/theme/presets/index.js +24 -0
- package/dist/theme/presets/minimal.d.ts +8 -0
- package/dist/theme/presets/minimal.js +12 -0
- package/dist/theme/presets/rounded.d.ts +8 -0
- package/dist/theme/presets/rounded.js +12 -0
- package/dist/theme/resolve.d.ts +8 -0
- package/dist/theme/resolve.js +11 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/types.js +1 -0
- package/dist/tree/index.d.ts +3 -0
- package/dist/tree/index.js +11 -0
- package/dist/types.js +1 -1
- package/package.json +168 -54
- package/dist/shared/@outfitter/cli-2vs2gxa8.js +0 -429
- package/dist/shared/@outfitter/cli-2yq94zst.d.ts +0 -39
- package/dist/shared/@outfitter/cli-6xc869x1.js +0 -26
- package/dist/shared/@outfitter/cli-7km1e58p.js +0 -85
- package/dist/shared/@outfitter/cli-8r0bnyyx.js +0 -43
- package/dist/shared/@outfitter/cli-afecwfrn.d.ts +0 -13
- package/dist/shared/@outfitter/cli-bt423m6y.js +0 -4
- package/dist/shared/@outfitter/cli-d4fegbad.d.ts +0 -66
- package/dist/shared/@outfitter/cli-e0ecw3x1.js +0 -64
- package/dist/shared/@outfitter/cli-fheaaa6b.js +0 -25
- package/dist/shared/@outfitter/cli-j361wp3g.d.ts +0 -41
- package/dist/shared/@outfitter/cli-p0m2fc51.js +0 -172
- package/dist/shared/@outfitter/cli-tyajr8qa.d.ts +0 -63
- package/dist/shared/@outfitter/cli-zs6jy1am.d.ts +0 -164
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List rendering utilities.
|
|
3
|
-
*
|
|
4
|
-
* Renders arrays as bullet lists with optional nesting.
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* A list item with optional nested children for {@link renderList}.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const item: NestedListItem = {
|
|
14
|
-
* text: "Parent item",
|
|
15
|
-
* children: ["Child 1", "Child 2"],
|
|
16
|
-
* };
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
interface NestedListItem {
|
|
20
|
-
/** The text content of this list item */
|
|
21
|
-
text: string;
|
|
22
|
-
/** Optional nested child items (strings or nested items) */
|
|
23
|
-
children?: Array<string | NestedListItem>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* A list item that can be either a simple string or a nested item with children.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const items: ListItem[] = [
|
|
31
|
-
* "Simple item",
|
|
32
|
-
* { text: "Parent", children: ["Child 1", "Child 2"] },
|
|
33
|
-
* ];
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
type ListItem = string | NestedListItem;
|
|
37
|
-
/**
|
|
38
|
-
* Renders items as a bullet list with optional nesting.
|
|
39
|
-
*
|
|
40
|
-
* Supports both simple string items and nested items with children.
|
|
41
|
-
* Nested items are indented with 2 spaces per level.
|
|
42
|
-
*
|
|
43
|
-
* @param items - Array of list items (strings or nested items)
|
|
44
|
-
* @returns Formatted bullet list string
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // Simple list
|
|
49
|
-
* console.log(renderList(["First", "Second", "Third"]));
|
|
50
|
-
* // - First
|
|
51
|
-
* // - Second
|
|
52
|
-
* // - Third
|
|
53
|
-
*
|
|
54
|
-
* // Nested list
|
|
55
|
-
* console.log(renderList([
|
|
56
|
-
* "Parent item",
|
|
57
|
-
* { text: "Item with children", children: ["Child 1", "Child 2"] },
|
|
58
|
-
* ]));
|
|
59
|
-
* // - Parent item
|
|
60
|
-
* // - Item with children
|
|
61
|
-
* // - Child 1
|
|
62
|
-
* // - Child 2
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
declare function renderList(items: ListItem[]): string;
|
|
66
|
-
export { NestedListItem, ListItem, renderList };
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
getStringWidth,
|
|
4
|
-
padText,
|
|
5
|
-
truncateText
|
|
6
|
-
} from "./cli-v9mjsvjh.js";
|
|
7
|
-
|
|
8
|
-
// packages/cli/src/render/table.ts
|
|
9
|
-
function renderTable(data, options) {
|
|
10
|
-
if (data.length === 0) {
|
|
11
|
-
return "";
|
|
12
|
-
}
|
|
13
|
-
const allKeys = new Set;
|
|
14
|
-
for (const row of data) {
|
|
15
|
-
for (const key of Object.keys(row)) {
|
|
16
|
-
allKeys.add(key);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const keys = Array.from(allKeys);
|
|
20
|
-
const headers = options?.headers ?? {};
|
|
21
|
-
const getHeader = (key) => headers[key] ?? key;
|
|
22
|
-
const columnWidths = {};
|
|
23
|
-
for (const key of keys) {
|
|
24
|
-
const headerWidth = getStringWidth(getHeader(key));
|
|
25
|
-
let maxDataWidth = 0;
|
|
26
|
-
for (const row of data) {
|
|
27
|
-
const value = row[key];
|
|
28
|
-
const strValue = value === undefined || value === null ? "" : String(value);
|
|
29
|
-
const width = getStringWidth(strValue);
|
|
30
|
-
if (width > maxDataWidth) {
|
|
31
|
-
maxDataWidth = width;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const optionWidth = options?.columnWidths?.[key];
|
|
35
|
-
columnWidths[key] = optionWidth ?? Math.max(headerWidth, maxDataWidth);
|
|
36
|
-
}
|
|
37
|
-
const lines = [];
|
|
38
|
-
const headerSep = `+${keys.map((k) => "-".repeat((columnWidths[k] ?? 0) + 2)).join("+")}+`;
|
|
39
|
-
const headerRow = `|${keys.map((k) => {
|
|
40
|
-
const header = getHeader(k);
|
|
41
|
-
const width = columnWidths[k] ?? 0;
|
|
42
|
-
return ` ${padText(header, width)} `;
|
|
43
|
-
}).join("|")}|`;
|
|
44
|
-
lines.push(headerSep);
|
|
45
|
-
lines.push(headerRow);
|
|
46
|
-
lines.push(headerSep);
|
|
47
|
-
for (const row of data) {
|
|
48
|
-
const rowStr = `|${keys.map((k) => {
|
|
49
|
-
const value = row[k];
|
|
50
|
-
let strValue = value === undefined || value === null ? "" : String(value);
|
|
51
|
-
const width = columnWidths[k] ?? 0;
|
|
52
|
-
if (getStringWidth(strValue) > width) {
|
|
53
|
-
strValue = truncateText(strValue, width);
|
|
54
|
-
}
|
|
55
|
-
return ` ${padText(strValue, width)} `;
|
|
56
|
-
}).join("|")}|`;
|
|
57
|
-
lines.push(rowStr);
|
|
58
|
-
}
|
|
59
|
-
lines.push(headerSep);
|
|
60
|
-
return lines.join(`
|
|
61
|
-
`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export { renderTable };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/render/list.ts
|
|
3
|
-
function renderList(items) {
|
|
4
|
-
const lines = [];
|
|
5
|
-
const renderItem = (item, indent) => {
|
|
6
|
-
const prefix = `${" ".repeat(indent)}- `;
|
|
7
|
-
if (typeof item === "string") {
|
|
8
|
-
lines.push(prefix + item);
|
|
9
|
-
} else {
|
|
10
|
-
lines.push(prefix + item.text);
|
|
11
|
-
if (item.children) {
|
|
12
|
-
for (const child of item.children) {
|
|
13
|
-
renderItem(child, indent + 1);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
for (const item of items) {
|
|
19
|
-
renderItem(item, 0);
|
|
20
|
-
}
|
|
21
|
-
return lines.join(`
|
|
22
|
-
`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { renderList };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tree rendering utilities.
|
|
3
|
-
*
|
|
4
|
-
* Renders hierarchical data as ASCII trees with box-drawing characters.
|
|
5
|
-
*
|
|
6
|
-
* @packageDocumentation
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Renders hierarchical data as a tree with unicode box-drawing characters.
|
|
10
|
-
*
|
|
11
|
-
* Uses unicode characters (not, not, |, -) for tree structure.
|
|
12
|
-
* Nested objects are rendered as child nodes; leaf values (null, primitives)
|
|
13
|
-
* are rendered as terminal nodes.
|
|
14
|
-
*
|
|
15
|
-
* @param tree - Hierarchical object to render
|
|
16
|
-
* @returns Formatted tree string with box-drawing characters
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const tree = {
|
|
21
|
-
* src: {
|
|
22
|
-
* components: {
|
|
23
|
-
* Button: null,
|
|
24
|
-
* Input: null,
|
|
25
|
-
* },
|
|
26
|
-
* utils: null,
|
|
27
|
-
* },
|
|
28
|
-
* tests: null,
|
|
29
|
-
* };
|
|
30
|
-
*
|
|
31
|
-
* console.log(renderTree(tree));
|
|
32
|
-
* // +-- src
|
|
33
|
-
* // | +-- components
|
|
34
|
-
* // | | +-- Button
|
|
35
|
-
* // | | L-- Input
|
|
36
|
-
* // | L-- utils
|
|
37
|
-
* // L-- tests
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
declare function renderTree(tree: Record<string, unknown>): string;
|
|
41
|
-
export { renderTree };
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/cli/src/actions.ts
|
|
3
|
-
import {
|
|
4
|
-
createContext as createHandlerContext,
|
|
5
|
-
DEFAULT_REGISTRY_SURFACES,
|
|
6
|
-
validateInput
|
|
7
|
-
} from "@outfitter/contracts";
|
|
8
|
-
import { Command } from "commander";
|
|
9
|
-
var ARGUMENT_PREFIXES = ["<", "["];
|
|
10
|
-
function isArgumentToken(token) {
|
|
11
|
-
if (!token) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
return ARGUMENT_PREFIXES.some((prefix) => token.startsWith(prefix));
|
|
15
|
-
}
|
|
16
|
-
function splitCommandSpec(spec) {
|
|
17
|
-
const parts = spec.trim().split(/\s+/).filter(Boolean);
|
|
18
|
-
if (parts.length === 0) {
|
|
19
|
-
return { name: undefined, args: [] };
|
|
20
|
-
}
|
|
21
|
-
return { name: parts[0], args: parts.slice(1) };
|
|
22
|
-
}
|
|
23
|
-
function applyArguments(command, args) {
|
|
24
|
-
for (const arg of args) {
|
|
25
|
-
command.argument(arg);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function applyCliOptions(command, action) {
|
|
29
|
-
const options = action.cli?.options ?? [];
|
|
30
|
-
for (const option of options) {
|
|
31
|
-
if (option.required) {
|
|
32
|
-
command.requiredOption(option.flags, option.description, option.defaultValue);
|
|
33
|
-
} else {
|
|
34
|
-
command.option(option.flags, option.description, option.defaultValue);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function resolveDescription(action) {
|
|
39
|
-
return action.cli?.description ?? action.description ?? action.id;
|
|
40
|
-
}
|
|
41
|
-
function resolveAliases(action) {
|
|
42
|
-
return action.cli?.aliases ?? [];
|
|
43
|
-
}
|
|
44
|
-
function resolveCommandSpec(action) {
|
|
45
|
-
return action.cli?.command ?? action.id;
|
|
46
|
-
}
|
|
47
|
-
function resolveFlags(command) {
|
|
48
|
-
return command.optsWithGlobals?.() ?? command.opts();
|
|
49
|
-
}
|
|
50
|
-
function resolveInput(action, context) {
|
|
51
|
-
if (action.cli?.mapInput) {
|
|
52
|
-
return action.cli.mapInput(context);
|
|
53
|
-
}
|
|
54
|
-
const hasFlags = Object.keys(context.flags).length > 0;
|
|
55
|
-
if (!hasFlags && context.args.length === 0) {
|
|
56
|
-
return {};
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
...context.flags,
|
|
60
|
-
...context.args.length > 0 ? { args: context.args } : {}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
async function runAction(action, command, createContext) {
|
|
64
|
-
const flags = resolveFlags(command);
|
|
65
|
-
const args = command.args;
|
|
66
|
-
const inputContext = { args, flags };
|
|
67
|
-
const input = resolveInput(action, inputContext);
|
|
68
|
-
const validation = validateInput(action.input, input);
|
|
69
|
-
if (validation.isErr()) {
|
|
70
|
-
throw validation.error;
|
|
71
|
-
}
|
|
72
|
-
const ctx = createContext({ action, args, flags });
|
|
73
|
-
const result = await action.handler(validation.value, ctx);
|
|
74
|
-
if (result.isErr()) {
|
|
75
|
-
throw result.error;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function createCommand(action, createContext, spec) {
|
|
79
|
-
const commandSpec = spec ?? resolveCommandSpec(action);
|
|
80
|
-
const { name, args } = splitCommandSpec(commandSpec);
|
|
81
|
-
if (!name) {
|
|
82
|
-
throw new Error(`Missing CLI command name for action ${action.id}`);
|
|
83
|
-
}
|
|
84
|
-
const command = new Command(name);
|
|
85
|
-
command.description(resolveDescription(action));
|
|
86
|
-
applyCliOptions(command, action);
|
|
87
|
-
applyArguments(command, args);
|
|
88
|
-
for (const alias of resolveAliases(action)) {
|
|
89
|
-
command.alias(alias);
|
|
90
|
-
}
|
|
91
|
-
command.action(async (...argsList) => {
|
|
92
|
-
const commandInstance = argsList.at(-1);
|
|
93
|
-
await runAction(action, commandInstance, createContext);
|
|
94
|
-
});
|
|
95
|
-
return command;
|
|
96
|
-
}
|
|
97
|
-
function buildCliCommands(source, options = {}) {
|
|
98
|
-
const actions = isActionRegistry(source) ? source.list() : source;
|
|
99
|
-
const includeSurfaces = options.includeSurfaces ?? [
|
|
100
|
-
"cli"
|
|
101
|
-
];
|
|
102
|
-
const commands = [];
|
|
103
|
-
const createContext = options.createContext ?? ((_input) => createHandlerContext({
|
|
104
|
-
cwd: process.cwd(),
|
|
105
|
-
env: process.env
|
|
106
|
-
}));
|
|
107
|
-
const grouped = new Map;
|
|
108
|
-
const ungrouped = [];
|
|
109
|
-
for (const action of actions) {
|
|
110
|
-
const surfaces = action.surfaces ?? DEFAULT_REGISTRY_SURFACES;
|
|
111
|
-
if (!surfaces.some((surface) => includeSurfaces.includes(surface))) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
const group = action.cli?.group;
|
|
115
|
-
if (group) {
|
|
116
|
-
const groupActions = grouped.get(group) ?? [];
|
|
117
|
-
groupActions.push(action);
|
|
118
|
-
grouped.set(group, groupActions);
|
|
119
|
-
} else {
|
|
120
|
-
ungrouped.push(action);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
for (const action of ungrouped) {
|
|
124
|
-
commands.push(createCommand(action, createContext));
|
|
125
|
-
}
|
|
126
|
-
for (const [groupName, groupActions] of grouped.entries()) {
|
|
127
|
-
const groupCommand = new Command(groupName);
|
|
128
|
-
let baseAction;
|
|
129
|
-
const subcommands = [];
|
|
130
|
-
for (const action of groupActions) {
|
|
131
|
-
const spec = action.cli?.command?.trim() ?? "";
|
|
132
|
-
const { name, args } = splitCommandSpec(spec);
|
|
133
|
-
if (!name || isArgumentToken(name)) {
|
|
134
|
-
if (baseAction) {
|
|
135
|
-
throw new Error(`Group '${groupName}' defines multiple base actions: '${baseAction.id}' and '${action.id}'.`);
|
|
136
|
-
}
|
|
137
|
-
baseAction = action;
|
|
138
|
-
groupCommand.description(resolveDescription(action));
|
|
139
|
-
applyCliOptions(groupCommand, action);
|
|
140
|
-
applyArguments(groupCommand, name ? [name, ...args] : args);
|
|
141
|
-
for (const alias of resolveAliases(action)) {
|
|
142
|
-
groupCommand.alias(alias);
|
|
143
|
-
}
|
|
144
|
-
groupCommand.action(async (...argsList) => {
|
|
145
|
-
const commandInstance = argsList.at(-1);
|
|
146
|
-
await runAction(action, commandInstance, createContext);
|
|
147
|
-
});
|
|
148
|
-
} else {
|
|
149
|
-
subcommands.push(action);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
for (const action of subcommands) {
|
|
153
|
-
const spec = resolveCommandSpec(action);
|
|
154
|
-
const { name, args } = splitCommandSpec(spec);
|
|
155
|
-
if (!name) {
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
const subcommand = createCommand(action, createContext, [name, ...args].join(" "));
|
|
159
|
-
groupCommand.addCommand(subcommand);
|
|
160
|
-
}
|
|
161
|
-
if (!baseAction) {
|
|
162
|
-
groupCommand.description(groupName);
|
|
163
|
-
}
|
|
164
|
-
commands.push(groupCommand);
|
|
165
|
-
}
|
|
166
|
-
return commands;
|
|
167
|
-
}
|
|
168
|
-
function isActionRegistry(source) {
|
|
169
|
-
return "list" in source;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export { buildCliCommands };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { CursorOptions, PaginationState } from "./cli-ttt7r0j7";
|
|
2
|
-
/**
|
|
3
|
-
* Load persisted pagination state for a command.
|
|
4
|
-
*
|
|
5
|
-
* @param options - Cursor options specifying command and context
|
|
6
|
-
* @returns The pagination state if it exists, undefined otherwise
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const state = loadCursor({
|
|
11
|
-
* command: "list",
|
|
12
|
-
* toolName: "waymark",
|
|
13
|
-
* });
|
|
14
|
-
*
|
|
15
|
-
* if (state) {
|
|
16
|
-
* // Continue from last position
|
|
17
|
-
* const results = await listNotes({ cursor: state.cursor });
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
declare function loadCursor(options: CursorOptions): PaginationState | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Save pagination state for a command.
|
|
24
|
-
*
|
|
25
|
-
* The cursor is persisted to XDG state directory, scoped by
|
|
26
|
-
* tool name, command, and optional context.
|
|
27
|
-
*
|
|
28
|
-
* @param cursor - The cursor string to persist
|
|
29
|
-
* @param options - Cursor options specifying command and context
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const results = await listNotes({ limit: 20 });
|
|
34
|
-
*
|
|
35
|
-
* if (results.hasMore) {
|
|
36
|
-
* saveCursor(results.cursor, {
|
|
37
|
-
* command: "list",
|
|
38
|
-
* toolName: "waymark",
|
|
39
|
-
* });
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
declare function saveCursor(cursor: string, options: CursorOptions): void;
|
|
44
|
-
/**
|
|
45
|
-
* Clear persisted pagination state for a command.
|
|
46
|
-
*
|
|
47
|
-
* Called when --reset flag is passed or when pagination completes.
|
|
48
|
-
*
|
|
49
|
-
* @param options - Cursor options specifying command and context
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* // User passed --reset flag
|
|
54
|
-
* if (flags.reset) {
|
|
55
|
-
* clearCursor({
|
|
56
|
-
* command: "list",
|
|
57
|
-
* toolName: "waymark",
|
|
58
|
-
* });
|
|
59
|
-
* }
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
declare function clearCursor(options: CursorOptions): void;
|
|
63
|
-
export { loadCursor, saveCursor, clearCursor };
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { CollectIdsOptions, ConfirmDestructiveOptions, ExpandFileOptions, FilterExpression, KeyValuePair, NormalizeIdOptions, ParseGlobOptions, Range, SortCriteria } from "./cli-ttt7r0j7";
|
|
2
|
-
import { CancelledError, ValidationError } from "@outfitter/contracts";
|
|
3
|
-
import { Result } from "better-result";
|
|
4
|
-
/**
|
|
5
|
-
* Collect IDs from various input formats.
|
|
6
|
-
*
|
|
7
|
-
* Handles space-separated, comma-separated, repeated flags, @file, and stdin.
|
|
8
|
-
*
|
|
9
|
-
* @param input - Raw input from CLI arguments
|
|
10
|
-
* @param options - Collection options
|
|
11
|
-
* @returns Array of collected IDs
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // All these produce the same result:
|
|
16
|
-
* // wm show id1 id2 id3
|
|
17
|
-
* // wm show id1,id2,id3
|
|
18
|
-
* // wm show --ids id1 --ids id2
|
|
19
|
-
* // wm show @ids.txt
|
|
20
|
-
* const ids = await collectIds(args.ids, {
|
|
21
|
-
* allowFile: true,
|
|
22
|
-
* allowStdin: true,
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
declare function collectIds(input: string | readonly string[], options?: CollectIdsOptions): Promise<string[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Expand @file references to file contents.
|
|
29
|
-
*
|
|
30
|
-
* If the input starts with @, reads the file and returns its contents.
|
|
31
|
-
* Otherwise, returns the input unchanged.
|
|
32
|
-
*
|
|
33
|
-
* @param input - Raw input that may be a @file reference
|
|
34
|
-
* @param options - Expansion options
|
|
35
|
-
* @returns File contents or original input
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* // wm create @template.md
|
|
40
|
-
* const content = await expandFileArg(args.content);
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
declare function expandFileArg(input: string, options?: ExpandFileOptions): Promise<string>;
|
|
44
|
-
/**
|
|
45
|
-
* Parse and expand glob patterns.
|
|
46
|
-
*
|
|
47
|
-
* Uses Bun.Glob with workspace constraints.
|
|
48
|
-
*
|
|
49
|
-
* @param pattern - Glob pattern to expand
|
|
50
|
-
* @param options - Glob options
|
|
51
|
-
* @returns Array of matched file paths
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```typescript
|
|
55
|
-
* // wm index "src/**\/*.ts"
|
|
56
|
-
* const files = await parseGlob(args.pattern, {
|
|
57
|
-
* cwd: workspaceRoot,
|
|
58
|
-
* ignore: ["node_modules/**"],
|
|
59
|
-
* });
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
declare function parseGlob(pattern: string, options?: ParseGlobOptions): Promise<string[]>;
|
|
63
|
-
/**
|
|
64
|
-
* Parse key=value pairs from CLI input.
|
|
65
|
-
*
|
|
66
|
-
* @param input - Raw input containing key=value pairs
|
|
67
|
-
* @returns Array of parsed key-value pairs
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* // --set key=value --set key2=value2
|
|
72
|
-
* // --set key=value,key2=value2
|
|
73
|
-
* const pairs = parseKeyValue(args.set);
|
|
74
|
-
* // => [{ key: "key", value: "value" }, { key: "key2", value: "value2" }]
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
declare function parseKeyValue(input: string | readonly string[]): Result<KeyValuePair[], InstanceType<typeof ValidationError>>;
|
|
78
|
-
/**
|
|
79
|
-
* Parse range inputs (numeric or date).
|
|
80
|
-
*
|
|
81
|
-
* @param input - Range string (e.g., "1-10" or "2024-01-01..2024-12-31")
|
|
82
|
-
* @param type - Type of range to parse
|
|
83
|
-
* @returns Parsed range
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* parseRange("1-10", "number");
|
|
88
|
-
* // => Result<{ type: "number", min: 1, max: 10 }, ValidationError>
|
|
89
|
-
*
|
|
90
|
-
* parseRange("2024-01-01..2024-12-31", "date");
|
|
91
|
-
* // => Result<{ type: "date", start: Date, end: Date }, ValidationError>
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
declare function parseRange(input: string, type: "number" | "date"): Result<Range, InstanceType<typeof ValidationError>>;
|
|
95
|
-
/**
|
|
96
|
-
* Parse filter expressions from CLI input.
|
|
97
|
-
*
|
|
98
|
-
* @param input - Filter string (e.g., "status:active,priority:high")
|
|
99
|
-
* @returns Array of parsed filter expressions
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* parseFilter("status:active,priority:high");
|
|
104
|
-
* // => Result<[
|
|
105
|
-
* // { field: "status", value: "active" },
|
|
106
|
-
* // { field: "priority", value: "high" }
|
|
107
|
-
* // ], ValidationError>
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
declare function parseFilter(input: string): Result<FilterExpression[], InstanceType<typeof ValidationError>>;
|
|
111
|
-
/**
|
|
112
|
-
* Parse sort specification from CLI input.
|
|
113
|
-
*
|
|
114
|
-
* @param input - Sort string (e.g., "modified:desc,title:asc")
|
|
115
|
-
* @returns Array of parsed sort criteria
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* parseSortSpec("modified:desc,title:asc");
|
|
120
|
-
* // => Result<[
|
|
121
|
-
* // { field: "modified", direction: "desc" },
|
|
122
|
-
* // { field: "title", direction: "asc" }
|
|
123
|
-
* // ], ValidationError>
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
declare function parseSortSpec(input: string): Result<SortCriteria[], InstanceType<typeof ValidationError>>;
|
|
127
|
-
/**
|
|
128
|
-
* Normalize an identifier (trim, lowercase where appropriate).
|
|
129
|
-
*
|
|
130
|
-
* @param input - Raw identifier input
|
|
131
|
-
* @param options - Normalization options
|
|
132
|
-
* @returns Normalized identifier
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ```typescript
|
|
136
|
-
* normalizeId(" MY-ID ", { lowercase: true, trim: true });
|
|
137
|
-
* // => Result<"my-id", ValidationError>
|
|
138
|
-
* ```
|
|
139
|
-
*/
|
|
140
|
-
declare function normalizeId(input: string, options?: NormalizeIdOptions): Result<string, InstanceType<typeof ValidationError>>;
|
|
141
|
-
/**
|
|
142
|
-
* Prompt for confirmation before destructive operations.
|
|
143
|
-
*
|
|
144
|
-
* Respects --yes flag for non-interactive mode.
|
|
145
|
-
*
|
|
146
|
-
* @param options - Confirmation options
|
|
147
|
-
* @returns Whether the user confirmed
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* const confirmed = await confirmDestructive({
|
|
152
|
-
* message: "Delete 5 notes?",
|
|
153
|
-
* bypassFlag: flags.yes,
|
|
154
|
-
* itemCount: 5,
|
|
155
|
-
* });
|
|
156
|
-
*
|
|
157
|
-
* if (confirmed.isErr()) {
|
|
158
|
-
* // User cancelled
|
|
159
|
-
* process.exit(0);
|
|
160
|
-
* }
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
declare function confirmDestructive(options: ConfirmDestructiveOptions): Promise<Result<boolean, InstanceType<typeof CancelledError>>>;
|
|
164
|
-
export { collectIds, expandFileArg, parseGlob, parseKeyValue, parseRange, parseFilter, parseSortSpec, normalizeId, confirmDestructive };
|