@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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { GlyphPair, SemanticState, VisualTheme } from "./cli-s0kkx9m1";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a glyph pair to a single character based on terminal capability.
|
|
4
|
+
*
|
|
5
|
+
* Uses terminal detection to choose between unicode and fallback characters.
|
|
6
|
+
* Can be overridden with the `forceUnicode` parameter.
|
|
7
|
+
*
|
|
8
|
+
* @param glyph - The glyph pair to resolve
|
|
9
|
+
* @param forceUnicode - Override terminal detection (true = unicode, false = fallback)
|
|
10
|
+
* @returns The appropriate character for the terminal
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const bullet: GlyphPair = { unicode: "•", fallback: "*" };
|
|
15
|
+
*
|
|
16
|
+
* // Auto-detect terminal capability
|
|
17
|
+
* resolveGlyph(bullet); // "•" or "*" based on terminal
|
|
18
|
+
*
|
|
19
|
+
* // Force unicode
|
|
20
|
+
* resolveGlyph(bullet, true); // "•"
|
|
21
|
+
*
|
|
22
|
+
* // Force fallback
|
|
23
|
+
* resolveGlyph(bullet, false); // "*"
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare function resolveGlyph(glyph: GlyphPair, forceUnicode?: boolean): string;
|
|
27
|
+
/**
|
|
28
|
+
* Resolves a semantic state to its visual marker character.
|
|
29
|
+
*
|
|
30
|
+
* Looks up the marker specification in the theme and returns the
|
|
31
|
+
* appropriate character. Supports both indicator-type markers (from
|
|
32
|
+
* the INDICATORS registry) and custom glyph pairs.
|
|
33
|
+
*
|
|
34
|
+
* @param theme - The visual theme containing marker definitions
|
|
35
|
+
* @param state - The semantic state to resolve
|
|
36
|
+
* @param forceUnicode - Override terminal detection
|
|
37
|
+
* @returns The marker character for the given state
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { defaultTheme, resolveStateMarker } from "@outfitter/cli/theme";
|
|
42
|
+
*
|
|
43
|
+
* // Resolve success marker (indicator-type)
|
|
44
|
+
* resolveStateMarker(defaultTheme, "success", true); // "✔"
|
|
45
|
+
* resolveStateMarker(defaultTheme, "success", false); // "[ok]"
|
|
46
|
+
*
|
|
47
|
+
* // Resolve with custom theme marker
|
|
48
|
+
* const theme = createVisualTheme({
|
|
49
|
+
* overrides: {
|
|
50
|
+
* markers: {
|
|
51
|
+
* current: { type: "custom", glyph: { unicode: "★", fallback: "*" } }
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* });
|
|
55
|
+
* resolveStateMarker(theme, "current", true); // "★"
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
declare function resolveStateMarker(theme: VisualTheme, state: SemanticState, forceUnicode?: boolean): string;
|
|
59
|
+
export { resolveGlyph, resolveStateMarker };
|
|
@@ -45,6 +45,8 @@ declare function getStringWidth(text: string): number;
|
|
|
45
45
|
* - Respecting word boundaries (no mid-word breaks)
|
|
46
46
|
* - Trimming trailing whitespace from lines
|
|
47
47
|
*
|
|
48
|
+
* Uses Bun's native `Bun.wrapAnsi()` for high performance.
|
|
49
|
+
*
|
|
48
50
|
* @param text - Text to wrap (may contain ANSI codes)
|
|
49
51
|
* @param width - Maximum visible width per line
|
|
50
52
|
* @returns Wrapped text with newlines
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConfirmPromptOptions, PromptResult } from "./cli-3f12z5kf";
|
|
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 };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
createCancelledError
|
|
4
|
+
} from "./cli-8bwaw3pz.js";
|
|
5
|
+
|
|
6
|
+
// packages/cli/src/prompt/group.ts
|
|
7
|
+
import { Result as R } from "better-result";
|
|
8
|
+
async function promptGroup(steps) {
|
|
9
|
+
const result = {};
|
|
10
|
+
for (const [key, step] of Object.entries(steps)) {
|
|
11
|
+
const stepResult = await step();
|
|
12
|
+
if (stepResult.isErr()) {
|
|
13
|
+
return R.err(createCancelledError(stepResult.error.message));
|
|
14
|
+
}
|
|
15
|
+
result[key] = stepResult.value;
|
|
16
|
+
}
|
|
17
|
+
return R.ok(result);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { promptGroup };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
init_box,
|
|
4
|
+
normalizeBorders,
|
|
5
|
+
normalizePadding
|
|
6
|
+
} from "./cli-vp88gxev.js";
|
|
7
|
+
|
|
8
|
+
// packages/cli/src/render/layout.ts
|
|
9
|
+
init_box();
|
|
10
|
+
function getTerminalWidth() {
|
|
11
|
+
return process.stdout.columns ?? 80;
|
|
12
|
+
}
|
|
13
|
+
function getBoxOverhead(options) {
|
|
14
|
+
const pad = normalizePadding(options.padding, 1);
|
|
15
|
+
const borders = normalizeBorders(options.borders);
|
|
16
|
+
return {
|
|
17
|
+
horizontal: (borders.left ? 1 : 0) + (borders.right ? 1 : 0) + pad.left + pad.right,
|
|
18
|
+
vertical: (borders.top ? 1 : 0) + (borders.bottom ? 1 : 0) + pad.top + pad.bottom
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function getContentWidth(options) {
|
|
22
|
+
const { horizontal } = getBoxOverhead(options);
|
|
23
|
+
if (options.width) {
|
|
24
|
+
const content = options.width - horizontal;
|
|
25
|
+
return Math.max(0, content);
|
|
26
|
+
}
|
|
27
|
+
return Math.max(0, getTerminalWidth() - horizontal);
|
|
28
|
+
}
|
|
29
|
+
function resolveWidth(mode, ctx) {
|
|
30
|
+
if (typeof mode === "number") {
|
|
31
|
+
return mode;
|
|
32
|
+
}
|
|
33
|
+
if (mode === "text") {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
if (mode === "full") {
|
|
37
|
+
return getTerminalWidth();
|
|
38
|
+
}
|
|
39
|
+
if (mode === "container") {
|
|
40
|
+
if (!ctx) {
|
|
41
|
+
throw new Error("container width mode requires LayoutContext");
|
|
42
|
+
}
|
|
43
|
+
return ctx.width;
|
|
44
|
+
}
|
|
45
|
+
const percent = Number.parseInt(mode.slice(0, -1), 10);
|
|
46
|
+
const baseWidth = ctx?.width ?? getTerminalWidth();
|
|
47
|
+
return Math.floor(baseWidth * (percent / 100));
|
|
48
|
+
}
|
|
49
|
+
function createLayoutContext(options, parent) {
|
|
50
|
+
const effectiveOptions = { ...options };
|
|
51
|
+
if (effectiveOptions.width === undefined && parent) {
|
|
52
|
+
effectiveOptions.width = parent.width;
|
|
53
|
+
}
|
|
54
|
+
const width = getContentWidth(effectiveOptions);
|
|
55
|
+
return {
|
|
56
|
+
width,
|
|
57
|
+
...parent && { parent }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function getWidth(text) {
|
|
61
|
+
return Bun.stringWidth(text);
|
|
62
|
+
}
|
|
63
|
+
function splitLines(block) {
|
|
64
|
+
return block.split(`
|
|
65
|
+
`);
|
|
66
|
+
}
|
|
67
|
+
function padToWidth(text, width) {
|
|
68
|
+
const currentWidth = getWidth(text);
|
|
69
|
+
if (currentWidth >= width)
|
|
70
|
+
return text;
|
|
71
|
+
return text + " ".repeat(width - currentWidth);
|
|
72
|
+
}
|
|
73
|
+
function createFilledArray(length, value) {
|
|
74
|
+
const result = [];
|
|
75
|
+
for (let i = 0;i < length; i++) {
|
|
76
|
+
result.push(value);
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function joinHorizontal(blocks, options) {
|
|
81
|
+
if (blocks.length === 0)
|
|
82
|
+
return "";
|
|
83
|
+
const first = blocks[0];
|
|
84
|
+
if (first === undefined)
|
|
85
|
+
return "";
|
|
86
|
+
if (blocks.length === 1)
|
|
87
|
+
return first;
|
|
88
|
+
const gap = options?.gap ?? 0;
|
|
89
|
+
const align = options?.align ?? "top";
|
|
90
|
+
const gapString = " ".repeat(gap);
|
|
91
|
+
const blockLines = blocks.map(splitLines);
|
|
92
|
+
const maxHeight = Math.max(...blockLines.map((lines) => lines.length));
|
|
93
|
+
const blockWidths = blockLines.map((lines) => Math.max(...lines.map(getWidth)));
|
|
94
|
+
const paddedBlocks = blockLines.map((lines, blockIndex) => {
|
|
95
|
+
const width = blockWidths[blockIndex] ?? 0;
|
|
96
|
+
const height = lines.length;
|
|
97
|
+
const padding = maxHeight - height;
|
|
98
|
+
let topPadding;
|
|
99
|
+
switch (align) {
|
|
100
|
+
case "top":
|
|
101
|
+
topPadding = 0;
|
|
102
|
+
break;
|
|
103
|
+
case "center":
|
|
104
|
+
topPadding = Math.floor(padding / 2);
|
|
105
|
+
break;
|
|
106
|
+
case "bottom":
|
|
107
|
+
topPadding = padding;
|
|
108
|
+
break;
|
|
109
|
+
default: {
|
|
110
|
+
const _exhaustive = align;
|
|
111
|
+
topPadding = _exhaustive;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const bottomPadding = padding - topPadding;
|
|
115
|
+
const emptyLine = " ".repeat(width);
|
|
116
|
+
const paddedLines = [
|
|
117
|
+
...createFilledArray(topPadding, emptyLine),
|
|
118
|
+
...lines.map((line) => padToWidth(line, width)),
|
|
119
|
+
...createFilledArray(bottomPadding, emptyLine)
|
|
120
|
+
];
|
|
121
|
+
return paddedLines;
|
|
122
|
+
});
|
|
123
|
+
const resultLines = [];
|
|
124
|
+
for (let i = 0;i < maxHeight; i++) {
|
|
125
|
+
const lineSegments = paddedBlocks.map((block) => block[i] ?? "");
|
|
126
|
+
resultLines.push(lineSegments.join(gapString));
|
|
127
|
+
}
|
|
128
|
+
return resultLines.join(`
|
|
129
|
+
`);
|
|
130
|
+
}
|
|
131
|
+
function joinVertical(blocks, options) {
|
|
132
|
+
if (blocks.length === 0)
|
|
133
|
+
return "";
|
|
134
|
+
const first = blocks[0];
|
|
135
|
+
if (first === undefined)
|
|
136
|
+
return "";
|
|
137
|
+
if (blocks.length === 1)
|
|
138
|
+
return first;
|
|
139
|
+
const gap = options?.gap ?? 0;
|
|
140
|
+
const gapLines = gap > 0 ? `
|
|
141
|
+
`.repeat(gap) : "";
|
|
142
|
+
return blocks.join(`
|
|
143
|
+
${gapLines}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export { getTerminalWidth, getBoxOverhead, getContentWidth, resolveWidth, createLayoutContext, joinHorizontal, joinVertical };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WidthMode } from "./cli-2g8bx1aq";
|
|
2
|
+
/**
|
|
3
|
+
* Separator style for headings.
|
|
4
|
+
*/
|
|
5
|
+
type SeparatorStyle = "=" | "-" | "─" | "━" | "═";
|
|
6
|
+
/**
|
|
7
|
+
* Width mode for headings.
|
|
8
|
+
*
|
|
9
|
+
* Note: Headings only support "text", "full", and numeric widths.
|
|
10
|
+
* Use the shared WidthMode type for full container-relative support.
|
|
11
|
+
*
|
|
12
|
+
* @see WidthMode for the complete type definition
|
|
13
|
+
*/
|
|
14
|
+
type HeadingWidthMode = Extract<WidthMode, "text" | "full" | number>;
|
|
15
|
+
/**
|
|
16
|
+
* Case transformation for heading text.
|
|
17
|
+
*/
|
|
18
|
+
type CaseMode = "upper" | "lower" | "title" | "none";
|
|
19
|
+
/**
|
|
20
|
+
* Options for rendering a heading.
|
|
21
|
+
*/
|
|
22
|
+
interface HeadingOptions {
|
|
23
|
+
/** Separator character/style (default: "=") */
|
|
24
|
+
separator?: SeparatorStyle;
|
|
25
|
+
/** Width mode (default: "text") */
|
|
26
|
+
width?: HeadingWidthMode;
|
|
27
|
+
/** Case transformation (default: "upper") */
|
|
28
|
+
case?: CaseMode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Renders a section heading with a separator line below.
|
|
32
|
+
*
|
|
33
|
+
* @param text - The heading text
|
|
34
|
+
* @param options - Rendering options
|
|
35
|
+
* @returns Formatted heading string
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* import { renderHeading } from "@outfitter/cli/render";
|
|
40
|
+
*
|
|
41
|
+
* console.log(renderHeading("Theme Colors"));
|
|
42
|
+
* // THEME COLORS
|
|
43
|
+
* // ============
|
|
44
|
+
*
|
|
45
|
+
* console.log(renderHeading("Status", { separator: "─", case: "none" }));
|
|
46
|
+
* // Status
|
|
47
|
+
* // ──────
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
declare function renderHeading(text: string, options?: HeadingOptions): string;
|
|
51
|
+
export { SeparatorStyle, HeadingWidthMode, CaseMode, HeadingOptions, renderHeading };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
INDICATORS,
|
|
4
|
+
getIndicator,
|
|
5
|
+
getProgressIndicator
|
|
6
|
+
} from "./cli-p1m5dhrs.js";
|
|
7
|
+
import {
|
|
8
|
+
demoSection,
|
|
9
|
+
demoSubsection
|
|
10
|
+
} from "./cli-34fqr7bp.js";
|
|
11
|
+
|
|
12
|
+
// packages/cli/src/demo/renderers/indicators.ts
|
|
13
|
+
function renderIndicatorsDemo(config, _theme) {
|
|
14
|
+
const showCode = config.showCode ?? true;
|
|
15
|
+
const lines = [];
|
|
16
|
+
lines.push(demoSection("Indicators"));
|
|
17
|
+
lines.push("");
|
|
18
|
+
if (showCode) {
|
|
19
|
+
lines.push('import { getIndicator, getProgressIndicator, INDICATORS } from "@outfitter/cli/render";');
|
|
20
|
+
lines.push("");
|
|
21
|
+
}
|
|
22
|
+
lines.push("Semantic indicators with Unicode and ASCII fallback support.");
|
|
23
|
+
lines.push("");
|
|
24
|
+
lines.push(demoSubsection("Status"));
|
|
25
|
+
lines.push("");
|
|
26
|
+
for (const [name, indicator] of Object.entries(INDICATORS.status)) {
|
|
27
|
+
const colorInfo = indicator.color ? ` (${indicator.color})` : "";
|
|
28
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(10)} \u2192 ${indicator.fallback}${colorInfo}`);
|
|
29
|
+
}
|
|
30
|
+
lines.push("");
|
|
31
|
+
if (showCode) {
|
|
32
|
+
lines.push('getIndicator("status", "success") // ' + getIndicator("status", "success", true));
|
|
33
|
+
lines.push('getIndicator("status", "error") // ' + getIndicator("status", "error", true));
|
|
34
|
+
lines.push("");
|
|
35
|
+
}
|
|
36
|
+
lines.push(demoSubsection("Markers"));
|
|
37
|
+
lines.push("");
|
|
38
|
+
const markerGroups = {
|
|
39
|
+
Circles: [
|
|
40
|
+
"circle",
|
|
41
|
+
"circleOutline",
|
|
42
|
+
"circleDotted",
|
|
43
|
+
"circleSmall",
|
|
44
|
+
"circleDot",
|
|
45
|
+
"circleDotOutline"
|
|
46
|
+
],
|
|
47
|
+
Squares: ["square", "squareOutline", "squareSmall", "squareSmallOutline"],
|
|
48
|
+
Lozenges: ["lozenge", "lozengeOutline"],
|
|
49
|
+
Checkboxes: ["checkbox", "checkboxChecked", "checkboxCross"],
|
|
50
|
+
Pointers: ["pointer", "pointerSmall", "dash"]
|
|
51
|
+
};
|
|
52
|
+
for (const [groupName, names] of Object.entries(markerGroups)) {
|
|
53
|
+
lines.push(` ${groupName}:`);
|
|
54
|
+
for (const name of names) {
|
|
55
|
+
const indicator = INDICATORS.marker[name];
|
|
56
|
+
if (indicator) {
|
|
57
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(18)} \u2192 ${indicator.fallback}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
lines.push("");
|
|
61
|
+
}
|
|
62
|
+
lines.push(demoSubsection("Progress"));
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push(" Circle: \u25CB \u25D4 \u25D1 \u25D5 \u25CF");
|
|
65
|
+
lines.push(" Vertical: \u2581 \u2582 \u2583 \u2584 \u2585 \u2586 \u2587 \u2588");
|
|
66
|
+
lines.push(" Horizontal: \u258F \u258E \u258D \u258C \u258B \u258A \u2589 \u2588");
|
|
67
|
+
lines.push(" Shade: \u2591 \u2592 \u2593");
|
|
68
|
+
lines.push("");
|
|
69
|
+
if (showCode) {
|
|
70
|
+
lines.push("// Get progress indicator by percentage:");
|
|
71
|
+
lines.push('getProgressIndicator("circle", 50, 100) // ' + getProgressIndicator("circle", 50, 100, true));
|
|
72
|
+
lines.push('getProgressIndicator("vertical", 6, 8) // ' + getProgressIndicator("vertical", 6, 8, true));
|
|
73
|
+
lines.push('getProgressIndicator("horizontal", 4, 8) // ' + getProgressIndicator("horizontal", 4, 8, true));
|
|
74
|
+
lines.push('getProgressIndicator("shade", 100, 100) // ' + getProgressIndicator("shade", 100, 100, true));
|
|
75
|
+
lines.push("");
|
|
76
|
+
}
|
|
77
|
+
lines.push(demoSubsection("Triangles"));
|
|
78
|
+
lines.push("");
|
|
79
|
+
const triangleGroups = {
|
|
80
|
+
Up: ["up", "upSmall", "upOutline"],
|
|
81
|
+
Down: ["down", "downSmall", "downOutline"],
|
|
82
|
+
Left: ["left", "leftSmall", "leftOutline"],
|
|
83
|
+
Right: ["right", "rightSmall", "rightOutline"]
|
|
84
|
+
};
|
|
85
|
+
for (const [groupName, names] of Object.entries(triangleGroups)) {
|
|
86
|
+
const indicators = names.map((n) => INDICATORS.triangle[n]?.unicode ?? "").join(" ");
|
|
87
|
+
lines.push(` ${groupName.padEnd(6)} ${indicators}`);
|
|
88
|
+
}
|
|
89
|
+
lines.push("");
|
|
90
|
+
lines.push(demoSubsection("Special"));
|
|
91
|
+
lines.push("");
|
|
92
|
+
for (const [name, indicator] of Object.entries(INDICATORS.special)) {
|
|
93
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(14)} \u2192 ${indicator.fallback}`);
|
|
94
|
+
}
|
|
95
|
+
lines.push("");
|
|
96
|
+
lines.push(demoSubsection("Directional"));
|
|
97
|
+
lines.push("");
|
|
98
|
+
for (const [name, indicator] of Object.entries(INDICATORS.directional)) {
|
|
99
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(16)} \u2192 ${indicator.fallback}`);
|
|
100
|
+
}
|
|
101
|
+
lines.push("");
|
|
102
|
+
lines.push(demoSubsection("Math"));
|
|
103
|
+
lines.push("");
|
|
104
|
+
for (const [name, indicator] of Object.entries(INDICATORS.math)) {
|
|
105
|
+
lines.push(` ${indicator.unicode} ${name.padEnd(16)} \u2192 ${indicator.fallback}`);
|
|
106
|
+
}
|
|
107
|
+
lines.push("");
|
|
108
|
+
lines.push(demoSubsection("Usage"));
|
|
109
|
+
lines.push("");
|
|
110
|
+
lines.push("\u2022 getIndicator(category, name) \u2014 auto-detects Unicode support");
|
|
111
|
+
lines.push("\u2022 getProgressIndicator(style, current, max) \u2014 maps value to step");
|
|
112
|
+
lines.push("\u2022 INDICATORS[category][name] \u2014 direct access to unicode/fallback");
|
|
113
|
+
lines.push("\u2022 Status indicators include semantic color hints");
|
|
114
|
+
return lines.join(`
|
|
115
|
+
`);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { renderIndicatorsDemo };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PartialVisualTheme, VisualTheme } from "./cli-s0kkx9m1";
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a visual theme.
|
|
4
|
+
*/
|
|
5
|
+
interface CreateVisualThemeOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Base theme to extend from.
|
|
8
|
+
* Properties not overridden will be inherited from this theme.
|
|
9
|
+
* @default defaultTheme
|
|
10
|
+
*/
|
|
11
|
+
extends?: VisualTheme;
|
|
12
|
+
/**
|
|
13
|
+
* Properties to override on the base/extended theme.
|
|
14
|
+
* Supports partial overrides for nested objects (colors, spacing, markers).
|
|
15
|
+
*/
|
|
16
|
+
overrides?: PartialVisualTheme;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a visual theme by extending and/or overriding a base theme.
|
|
20
|
+
*
|
|
21
|
+
* This is the primary factory for creating custom themes. You can:
|
|
22
|
+
* - Start from scratch (no options → defaultTheme)
|
|
23
|
+
* - Extend an existing preset
|
|
24
|
+
* - Override specific properties
|
|
25
|
+
* - Combine extension and overrides
|
|
26
|
+
*
|
|
27
|
+
* When changing the `border` property, `borderChars` is automatically
|
|
28
|
+
* updated to match the new border style.
|
|
29
|
+
*
|
|
30
|
+
* @param options - Configuration for theme creation
|
|
31
|
+
* @returns A complete VisualTheme
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Start with defaults
|
|
36
|
+
* const theme = createVisualTheme();
|
|
37
|
+
*
|
|
38
|
+
* // Extend a preset
|
|
39
|
+
* const rounded = createVisualTheme({ extends: roundedTheme });
|
|
40
|
+
*
|
|
41
|
+
* // Override specific properties
|
|
42
|
+
* const custom = createVisualTheme({
|
|
43
|
+
* overrides: {
|
|
44
|
+
* border: "double",
|
|
45
|
+
* colors: { success: "\x1b[38;5;82m" },
|
|
46
|
+
* spacing: { boxPadding: 2 }
|
|
47
|
+
* }
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Extend and override
|
|
51
|
+
* const brandTheme = createVisualTheme({
|
|
52
|
+
* extends: roundedTheme,
|
|
53
|
+
* overrides: {
|
|
54
|
+
* name: "brand",
|
|
55
|
+
* colors: { accent: "\x1b[38;5;39m" }
|
|
56
|
+
* }
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function createVisualTheme(options?: CreateVisualThemeOptions): VisualTheme;
|
|
61
|
+
export { CreateVisualThemeOptions, createVisualTheme };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
getThemeMethodsByCategory
|
|
4
|
+
} from "./cli-kc84wmch.js";
|
|
5
|
+
import {
|
|
6
|
+
getExample
|
|
7
|
+
} from "./cli-xep6v2c0.js";
|
|
8
|
+
import {
|
|
9
|
+
demoSection
|
|
10
|
+
} from "./cli-34fqr7bp.js";
|
|
11
|
+
import {
|
|
12
|
+
ANSI,
|
|
13
|
+
applyColor,
|
|
14
|
+
createTokens,
|
|
15
|
+
init_colors,
|
|
16
|
+
resolveTokenColorEnabled
|
|
17
|
+
} from "./cli-9nbyj2bt.js";
|
|
18
|
+
import {
|
|
19
|
+
hasNoColorEnv,
|
|
20
|
+
init_detection,
|
|
21
|
+
resolveForceColorEnv
|
|
22
|
+
} from "./cli-d9ad0rqj.js";
|
|
23
|
+
|
|
24
|
+
// packages/cli/src/demo/renderers/colors.ts
|
|
25
|
+
init_colors();
|
|
26
|
+
init_detection();
|
|
27
|
+
function renderColorsDemo(config, theme) {
|
|
28
|
+
const showCode = config.showCode ?? true;
|
|
29
|
+
const tokens = createTokens();
|
|
30
|
+
const colorEnabled = resolveTokenColorEnabled();
|
|
31
|
+
const lines = [];
|
|
32
|
+
lines.push(demoSection("Theme Colors (createTheme)", { case: "none" }));
|
|
33
|
+
lines.push("");
|
|
34
|
+
if (showCode) {
|
|
35
|
+
lines.push('import { createTheme } from "@outfitter/cli/render";');
|
|
36
|
+
lines.push("const theme = createTheme();");
|
|
37
|
+
lines.push("");
|
|
38
|
+
}
|
|
39
|
+
const { semantic } = getThemeMethodsByCategory();
|
|
40
|
+
for (const method of semantic) {
|
|
41
|
+
const text = getExample(method, config.examples);
|
|
42
|
+
const fn = theme[method];
|
|
43
|
+
const output = fn(text);
|
|
44
|
+
const code = `theme.${method}("${text}")`;
|
|
45
|
+
lines.push(`${code.padEnd(42)} \u2192 ${output}`);
|
|
46
|
+
}
|
|
47
|
+
lines.push("");
|
|
48
|
+
lines.push(demoSection("Utility Methods"));
|
|
49
|
+
lines.push("");
|
|
50
|
+
const { utility } = getThemeMethodsByCategory();
|
|
51
|
+
for (const method of utility) {
|
|
52
|
+
const text = getExample(method, config.examples);
|
|
53
|
+
const fn = theme[method];
|
|
54
|
+
const output = fn(text);
|
|
55
|
+
const code = `theme.${method}("${text}")`;
|
|
56
|
+
lines.push(`${code.padEnd(42)} \u2192 ${output}`);
|
|
57
|
+
}
|
|
58
|
+
lines.push("");
|
|
59
|
+
lines.push(demoSection("Direct Colors (applyColor)", { case: "none" }));
|
|
60
|
+
lines.push("");
|
|
61
|
+
if (showCode) {
|
|
62
|
+
lines.push('import { applyColor } from "@outfitter/cli/render";');
|
|
63
|
+
lines.push("");
|
|
64
|
+
}
|
|
65
|
+
const colors = [
|
|
66
|
+
"green",
|
|
67
|
+
"yellow",
|
|
68
|
+
"red",
|
|
69
|
+
"blue",
|
|
70
|
+
"cyan",
|
|
71
|
+
"magenta",
|
|
72
|
+
"gray"
|
|
73
|
+
];
|
|
74
|
+
for (const color of colors) {
|
|
75
|
+
const code = `applyColor("text", "${color}")`;
|
|
76
|
+
const output = applyColor("text", color);
|
|
77
|
+
lines.push(`${code.padEnd(32)} \u2192 ${output}`);
|
|
78
|
+
}
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push(demoSection("Raw Tokens (createTokens)", { case: "none" }));
|
|
81
|
+
lines.push("");
|
|
82
|
+
if (showCode) {
|
|
83
|
+
lines.push('import { createTokens, ANSI } from "@outfitter/cli/render";');
|
|
84
|
+
lines.push("const t = createTokens();");
|
|
85
|
+
lines.push("");
|
|
86
|
+
}
|
|
87
|
+
const d = "$";
|
|
88
|
+
const tokenExamples = [
|
|
89
|
+
{
|
|
90
|
+
code: `\`${d}{t.success}Done${d}{ANSI.reset}\``,
|
|
91
|
+
token: tokens.success,
|
|
92
|
+
text: "Done"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
code: `\`${d}{t.error}Fail${d}{ANSI.reset}\``,
|
|
96
|
+
token: tokens.error,
|
|
97
|
+
text: "Fail"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
code: `\`${d}{t.warning}Warn${d}{ANSI.reset}\``,
|
|
101
|
+
token: tokens.warning,
|
|
102
|
+
text: "Warn"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
code: `\`${d}{t.info}Info${d}{ANSI.reset}\``,
|
|
106
|
+
token: tokens.info,
|
|
107
|
+
text: "Info"
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
for (const example of tokenExamples) {
|
|
111
|
+
const reset = example.token ? ANSI.reset : "";
|
|
112
|
+
const output = `${example.token}${example.text}${reset}`;
|
|
113
|
+
lines.push(`${example.code.padEnd(36)} \u2192 ${output}`);
|
|
114
|
+
}
|
|
115
|
+
lines.push("");
|
|
116
|
+
lines.push(demoSection("Environment"));
|
|
117
|
+
const noColor = hasNoColorEnv();
|
|
118
|
+
const forceColor = resolveForceColorEnv();
|
|
119
|
+
let forceColorDisplay;
|
|
120
|
+
if (forceColor === true) {
|
|
121
|
+
forceColorDisplay = theme.success("enabled");
|
|
122
|
+
} else if (forceColor === false) {
|
|
123
|
+
forceColorDisplay = theme.error("disabled");
|
|
124
|
+
} else {
|
|
125
|
+
forceColorDisplay = theme.muted("not set");
|
|
126
|
+
}
|
|
127
|
+
lines.push(`Colors: ${colorEnabled ? theme.success("enabled") : theme.muted("disabled")} ${theme.muted(colorEnabled ? "(TTY detected)" : "(non-TTY or NO_COLOR set)")}`);
|
|
128
|
+
lines.push(`NO_COLOR: ${noColor ? theme.warning("set") : theme.muted("not set")}`);
|
|
129
|
+
lines.push(`FORCE_COLOR: ${forceColorDisplay}`);
|
|
130
|
+
return lines.join(`
|
|
131
|
+
`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { renderColorsDemo };
|