zard-cli 1.0.0-beta.98 → 1.0.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 +92 -36
- package/commands/add/component-installer.d.ts +3 -0
- package/commands/add/component-installer.d.ts.map +1 -1
- package/commands/add/component-installer.js +10 -4
- package/commands/add/component-installer.js.map +1 -1
- package/commands/add/component-selector.d.ts +6 -0
- package/commands/add/component-selector.d.ts.map +1 -1
- package/commands/add/component-selector.js +9 -27
- package/commands/add/component-selector.js.map +1 -1
- package/commands/add/dark-mode-setup.d.ts.map +1 -1
- package/commands/add/dark-mode-setup.js +2 -11
- package/commands/add/dark-mode-setup.js.map +1 -1
- package/commands/add/dependency-resolver.d.ts +8 -1
- package/commands/add/dependency-resolver.d.ts.map +1 -1
- package/commands/add/dependency-resolver.js +87 -16
- package/commands/add/dependency-resolver.js.map +1 -1
- package/commands/add/index.d.ts.map +1 -1
- package/commands/add/index.js +128 -96
- package/commands/add/index.js.map +1 -1
- package/commands/add/stylesheet-setup.d.ts +3 -0
- package/commands/add/stylesheet-setup.d.ts.map +1 -0
- package/commands/add/stylesheet-setup.js +92 -0
- package/commands/add/stylesheet-setup.js.map +1 -0
- package/commands/add/wizard.d.ts +35 -0
- package/commands/add/wizard.d.ts.map +1 -0
- package/commands/add/wizard.js +299 -0
- package/commands/add/wizard.js.map +1 -0
- package/commands/init/config-prompter.d.ts +55 -3
- package/commands/init/config-prompter.d.ts.map +1 -1
- package/commands/init/config-prompter.js +92 -74
- package/commands/init/config-prompter.js.map +1 -1
- package/commands/init/dependencies.d.ts +1 -8
- package/commands/init/dependencies.d.ts.map +1 -1
- package/commands/init/dependencies.js +51 -25
- package/commands/init/dependencies.js.map +1 -1
- package/commands/init/index.d.ts.map +1 -1
- package/commands/init/index.js +147 -81
- package/commands/init/index.js.map +1 -1
- package/commands/init/project-kind.d.ts +82 -0
- package/commands/init/project-kind.d.ts.map +1 -0
- package/commands/init/project-kind.js +166 -0
- package/commands/init/project-kind.js.map +1 -0
- package/commands/init/steps.d.ts +15 -0
- package/commands/init/steps.d.ts.map +1 -0
- package/commands/init/steps.js +154 -0
- package/commands/init/steps.js.map +1 -0
- package/commands/init/tailwind-setup.d.ts +9 -2
- package/commands/init/tailwind-setup.d.ts.map +1 -1
- package/commands/init/tailwind-setup.js +33 -12
- package/commands/init/tailwind-setup.js.map +1 -1
- package/commands/init/tsconfig-updater.d.ts +8 -1
- package/commands/init/tsconfig-updater.d.ts.map +1 -1
- package/commands/init/tsconfig-updater.js +30 -11
- package/commands/init/tsconfig-updater.js.map +1 -1
- package/commands/init/update-angular-config.d.ts.map +1 -1
- package/commands/init/update-angular-config.js +28 -50
- package/commands/init/update-angular-config.js.map +1 -1
- package/commands/init/vite-setup.d.ts +11 -0
- package/commands/init/vite-setup.d.ts.map +1 -0
- package/commands/init/vite-setup.js +61 -0
- package/commands/init/vite-setup.js.map +1 -0
- package/commands/init/wizard.d.ts +30 -0
- package/commands/init/wizard.d.ts.map +1 -0
- package/commands/init/wizard.js +560 -0
- package/commands/init/wizard.js.map +1 -0
- package/constants/app.constants.d.ts +17 -0
- package/constants/app.constants.d.ts.map +1 -1
- package/constants/app.constants.js +39 -16
- package/constants/app.constants.js.map +1 -1
- package/core/icons/families.d.ts +38 -0
- package/core/icons/families.d.ts.map +1 -0
- package/core/icons/families.js +26 -0
- package/core/icons/families.js.map +1 -0
- package/core/icons/icon-map.d.ts +24 -0
- package/core/icons/icon-map.d.ts.map +1 -0
- package/core/icons/icon-map.js +141 -0
- package/core/icons/icon-map.js.map +1 -0
- package/core/icons/index.d.ts +107 -0
- package/core/icons/index.d.ts.map +1 -0
- package/core/icons/index.js +183 -0
- package/core/icons/index.js.map +1 -0
- package/core/registry/registry-data.d.ts.map +1 -1
- package/core/registry/registry-data.js +482 -37
- package/core/registry/registry-data.js.map +1 -1
- package/core/themes/theme-definitions.d.ts.map +1 -1
- package/core/themes/theme-definitions.js +61 -72
- package/core/themes/theme-definitions.js.map +1 -1
- package/index.js +6 -3
- package/index.js.map +1 -1
- package/package.json +6 -11
- package/ui/blocks.d.ts +71 -0
- package/ui/blocks.d.ts.map +1 -0
- package/ui/blocks.js +116 -0
- package/ui/blocks.js.map +1 -0
- package/ui/brand.d.ts +14 -0
- package/ui/brand.d.ts.map +1 -0
- package/ui/brand.js +35 -0
- package/ui/brand.js.map +1 -0
- package/ui/engine/animation/index.d.ts +38 -0
- package/ui/engine/animation/index.d.ts.map +1 -0
- package/ui/engine/animation/index.js +102 -0
- package/ui/engine/animation/index.js.map +1 -0
- package/ui/engine/ansi/index.d.ts +51 -0
- package/ui/engine/ansi/index.d.ts.map +1 -0
- package/ui/engine/ansi/index.js +116 -0
- package/ui/engine/ansi/index.js.map +1 -0
- package/ui/engine/components/index.d.ts +211 -0
- package/ui/engine/components/index.d.ts.map +1 -0
- package/ui/engine/components/index.js +109 -0
- package/ui/engine/components/index.js.map +1 -0
- package/ui/engine/cursor/index.d.ts +16 -0
- package/ui/engine/cursor/index.d.ts.map +1 -0
- package/ui/engine/cursor/index.js +40 -0
- package/ui/engine/cursor/index.js.map +1 -0
- package/ui/engine/diff/index.d.ts +26 -0
- package/ui/engine/diff/index.d.ts.map +1 -0
- package/ui/engine/diff/index.js +56 -0
- package/ui/engine/diff/index.js.map +1 -0
- package/ui/engine/events/index.d.ts +24 -0
- package/ui/engine/events/index.d.ts.map +1 -0
- package/ui/engine/events/index.js +60 -0
- package/ui/engine/events/index.js.map +1 -0
- package/ui/engine/focus/index.d.ts +25 -0
- package/ui/engine/focus/index.d.ts.map +1 -0
- package/ui/engine/focus/index.js +77 -0
- package/ui/engine/focus/index.js.map +1 -0
- package/ui/engine/frame/index.d.ts +48 -0
- package/ui/engine/frame/index.d.ts.map +1 -0
- package/ui/engine/frame/index.js +0 -0
- package/ui/engine/frame/index.js.map +1 -0
- package/ui/engine/index.d.ts +28 -0
- package/ui/engine/index.d.ts.map +1 -0
- package/ui/engine/index.js +28 -0
- package/ui/engine/index.js.map +1 -0
- package/ui/engine/input/index.d.ts +36 -0
- package/ui/engine/input/index.d.ts.map +1 -0
- package/ui/engine/input/index.js +224 -0
- package/ui/engine/input/index.js.map +1 -0
- package/ui/engine/layout/index.d.ts +42 -0
- package/ui/engine/layout/index.d.ts.map +1 -0
- package/ui/engine/layout/index.js +241 -0
- package/ui/engine/layout/index.js.map +1 -0
- package/ui/engine/renderer/index.d.ts +43 -0
- package/ui/engine/renderer/index.d.ts.map +1 -0
- package/ui/engine/renderer/index.js +619 -0
- package/ui/engine/renderer/index.js.map +1 -0
- package/ui/engine/scheduler/index.d.ts +22 -0
- package/ui/engine/scheduler/index.d.ts.map +1 -0
- package/ui/engine/scheduler/index.js +77 -0
- package/ui/engine/scheduler/index.js.map +1 -0
- package/ui/engine/screen/index.d.ts +39 -0
- package/ui/engine/screen/index.d.ts.map +1 -0
- package/ui/engine/screen/index.js +255 -0
- package/ui/engine/screen/index.js.map +1 -0
- package/ui/engine/terminal/index.d.ts +84 -0
- package/ui/engine/terminal/index.d.ts.map +1 -0
- package/ui/engine/terminal/index.js +235 -0
- package/ui/engine/terminal/index.js.map +1 -0
- package/ui/engine/testing/index.d.ts +27 -0
- package/ui/engine/testing/index.d.ts.map +1 -0
- package/ui/engine/testing/index.js +63 -0
- package/ui/engine/testing/index.js.map +1 -0
- package/ui/engine/theme/index.d.ts +26 -0
- package/ui/engine/theme/index.d.ts.map +1 -0
- package/ui/engine/theme/index.js +128 -0
- package/ui/engine/theme/index.js.map +1 -0
- package/ui/engine/utils/index.d.ts +12 -0
- package/ui/engine/utils/index.d.ts.map +1 -0
- package/ui/engine/utils/index.js +143 -0
- package/ui/engine/utils/index.js.map +1 -0
- package/ui/gate.d.ts +19 -0
- package/ui/gate.d.ts.map +1 -0
- package/ui/gate.js +36 -0
- package/ui/gate.js.map +1 -0
- package/ui/index.d.ts +18 -0
- package/ui/index.d.ts.map +1 -0
- package/ui/index.js +18 -0
- package/ui/index.js.map +1 -0
- package/ui/log-sink.d.ts +24 -0
- package/ui/log-sink.d.ts.map +1 -0
- package/ui/log-sink.js +35 -0
- package/ui/log-sink.js.map +1 -0
- package/ui/output.d.ts +14 -0
- package/ui/output.d.ts.map +1 -0
- package/ui/output.js +28 -0
- package/ui/output.js.map +1 -0
- package/ui/report.d.ts +30 -0
- package/ui/report.d.ts.map +1 -0
- package/ui/report.js +45 -0
- package/ui/report.js.map +1 -0
- package/ui/runner.d.ts +66 -0
- package/ui/runner.d.ts.map +1 -0
- package/ui/runner.js +135 -0
- package/ui/runner.js.map +1 -0
- package/ui/style.d.ts +24 -0
- package/ui/style.d.ts.map +1 -0
- package/ui/style.js +44 -0
- package/ui/style.js.map +1 -0
- package/ui/testing/fake-tty.d.ts +26 -0
- package/ui/testing/fake-tty.d.ts.map +1 -0
- package/ui/testing/fake-tty.js +61 -0
- package/ui/testing/fake-tty.js.map +1 -0
- package/ui/text-input.d.ts +31 -0
- package/ui/text-input.d.ts.map +1 -0
- package/ui/text-input.js +89 -0
- package/ui/text-input.js.map +1 -0
- package/ui/theme.d.ts +10 -0
- package/ui/theme.d.ts.map +1 -0
- package/ui/theme.js +20 -0
- package/ui/theme.js.map +1 -0
- package/utils/angular-compat.d.ts +21 -0
- package/utils/angular-compat.d.ts.map +1 -0
- package/utils/angular-compat.js +52 -0
- package/utils/angular-compat.js.map +1 -0
- package/utils/config.d.ts +29 -0
- package/utils/config.d.ts.map +1 -1
- package/utils/config.js +50 -4
- package/utils/config.js.map +1 -1
- package/utils/errors.d.ts +11 -0
- package/utils/errors.d.ts.map +1 -1
- package/utils/errors.js +14 -0
- package/utils/errors.js.map +1 -1
- package/utils/get-project-info.d.ts +29 -0
- package/utils/get-project-info.d.ts.map +1 -1
- package/utils/get-project-info.js +176 -1
- package/utils/get-project-info.js.map +1 -1
- package/utils/http-client.d.ts.map +1 -1
- package/utils/http-client.js +18 -3
- package/utils/http-client.js.map +1 -1
- package/utils/icon-catalog.d.ts +34 -0
- package/utils/icon-catalog.d.ts.map +1 -0
- package/utils/icon-catalog.js +63 -0
- package/utils/icon-catalog.js.map +1 -0
- package/utils/logger.d.ts +13 -1
- package/utils/logger.d.ts.map +1 -1
- package/utils/logger.js +95 -15
- package/utils/logger.js.map +1 -1
- package/utils/package-manager.d.ts +42 -1
- package/utils/package-manager.d.ts.map +1 -1
- package/utils/package-manager.js +204 -11
- package/utils/package-manager.js.map +1 -1
- package/utils/registry.d.ts +84 -2
- package/utils/registry.d.ts.map +1 -1
- package/utils/registry.js +121 -18
- package/utils/registry.js.map +1 -1
- package/utils/schema-version.d.ts +21 -0
- package/utils/schema-version.d.ts.map +1 -0
- package/utils/schema-version.js +28 -0
- package/utils/schema-version.js.map +1 -0
- package/utils/source-file.d.ts +40 -0
- package/utils/source-file.d.ts.map +1 -0
- package/utils/source-file.js +104 -0
- package/utils/source-file.js.map +1 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* utils — pure string/Unicode helpers. No I/O, no dependencies.
|
|
3
|
+
* Enough for ASCII, wide characters and emoji.
|
|
4
|
+
*/
|
|
5
|
+
const SEG = typeof Intl.Segmenter === 'function'
|
|
6
|
+
? new Intl.Segmenter('en', { granularity: 'grapheme' })
|
|
7
|
+
: null;
|
|
8
|
+
export function graphemes(text) {
|
|
9
|
+
if (SEG) {
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const s of SEG.segment(text))
|
|
12
|
+
out.push(s.segment);
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
return Array.from(text);
|
|
16
|
+
}
|
|
17
|
+
/** true se o code point ocupa 2 colunas (East Asian Wide/Fullwidth, emoji). */
|
|
18
|
+
function isWide(cp) {
|
|
19
|
+
return ((cp >= 0x1100 && cp <= 0x115f) || // Hangul Jamo
|
|
20
|
+
cp === 0x2329 ||
|
|
21
|
+
cp === 0x232a ||
|
|
22
|
+
(cp >= 0x2e80 && cp <= 0x303e) || // CJK radicals, Kangxi
|
|
23
|
+
(cp >= 0x3041 && cp <= 0x33ff) || // Hiragana … CJK symbols
|
|
24
|
+
(cp >= 0x3400 && cp <= 0x4dbf) || // CJK Ext A
|
|
25
|
+
(cp >= 0x4e00 && cp <= 0x9fff) || // CJK Unified
|
|
26
|
+
(cp >= 0xa000 && cp <= 0xa4cf) || // Yi
|
|
27
|
+
(cp >= 0xac00 && cp <= 0xd7a3) || // Hangul Syllables
|
|
28
|
+
(cp >= 0xf900 && cp <= 0xfaff) || // CJK Compat
|
|
29
|
+
(cp >= 0xfe10 && cp <= 0xfe19) ||
|
|
30
|
+
(cp >= 0xfe30 && cp <= 0xfe6f) ||
|
|
31
|
+
(cp >= 0xff00 && cp <= 0xff60) || // Fullwidth forms
|
|
32
|
+
(cp >= 0xffe0 && cp <= 0xffe6) ||
|
|
33
|
+
(cp >= 0x1f300 && cp <= 0x1faff) || // emoji & symbols
|
|
34
|
+
(cp >= 0x20000 && cp <= 0x3fffd) // CJK Ext B+
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
/** true se combinante / largura zero. */
|
|
38
|
+
function isZeroWidth(cp) {
|
|
39
|
+
return ((cp >= 0x0300 && cp <= 0x036f) ||
|
|
40
|
+
(cp >= 0x1ab0 && cp <= 0x1aff) ||
|
|
41
|
+
(cp >= 0x1dc0 && cp <= 0x1dff) ||
|
|
42
|
+
(cp >= 0x200b && cp <= 0x200f) ||
|
|
43
|
+
(cp >= 0x20d0 && cp <= 0x20ff) ||
|
|
44
|
+
(cp >= 0xfe20 && cp <= 0xfe2f) ||
|
|
45
|
+
cp === 0xfeff);
|
|
46
|
+
}
|
|
47
|
+
export function charWidth(grapheme) {
|
|
48
|
+
const cp = grapheme.codePointAt(0);
|
|
49
|
+
if (cp === undefined)
|
|
50
|
+
return 0;
|
|
51
|
+
if (cp < 0x20 || (cp >= 0x7f && cp <= 0x9f))
|
|
52
|
+
return 0; // controle
|
|
53
|
+
if (isZeroWidth(cp))
|
|
54
|
+
return 0;
|
|
55
|
+
if (isWide(cp))
|
|
56
|
+
return 2;
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
export function stringWidth(text) {
|
|
60
|
+
let w = 0;
|
|
61
|
+
for (const g of graphemes(stripAnsi(text)))
|
|
62
|
+
w += charWidth(g);
|
|
63
|
+
return w;
|
|
64
|
+
}
|
|
65
|
+
export function wrapText(text, width) {
|
|
66
|
+
if (width <= 0)
|
|
67
|
+
return [text];
|
|
68
|
+
const out = [];
|
|
69
|
+
for (const rawLine of text.split('\n')) {
|
|
70
|
+
let line = '';
|
|
71
|
+
let lineW = 0;
|
|
72
|
+
for (const word of splitWords(rawLine)) {
|
|
73
|
+
const ww = stringWidth(word);
|
|
74
|
+
if (lineW + ww > width && lineW > 0) {
|
|
75
|
+
out.push(line);
|
|
76
|
+
line = '';
|
|
77
|
+
lineW = 0;
|
|
78
|
+
}
|
|
79
|
+
if (ww > width) {
|
|
80
|
+
// palavra maior que a largura: quebra dura por grapheme
|
|
81
|
+
if (line) {
|
|
82
|
+
out.push(line);
|
|
83
|
+
line = '';
|
|
84
|
+
lineW = 0;
|
|
85
|
+
}
|
|
86
|
+
for (const g of graphemes(word)) {
|
|
87
|
+
const gw = charWidth(g);
|
|
88
|
+
if (lineW + gw > width) {
|
|
89
|
+
out.push(line);
|
|
90
|
+
line = '';
|
|
91
|
+
lineW = 0;
|
|
92
|
+
}
|
|
93
|
+
line += g;
|
|
94
|
+
lineW += gw;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
line += word;
|
|
99
|
+
lineW += ww;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
out.push(line);
|
|
103
|
+
}
|
|
104
|
+
return out.length ? out : [''];
|
|
105
|
+
}
|
|
106
|
+
function splitWords(line) {
|
|
107
|
+
// keeps spaces attached to the following word so simple indents survive
|
|
108
|
+
return line.length ? (line.match(/\s*\S+\s*|\s+/g) ?? [line]) : [''];
|
|
109
|
+
}
|
|
110
|
+
export function truncate(text, width, ellipsis = '…') {
|
|
111
|
+
if (stringWidth(text) <= width)
|
|
112
|
+
return text;
|
|
113
|
+
const ew = stringWidth(ellipsis);
|
|
114
|
+
const budget = Math.max(0, width - ew);
|
|
115
|
+
let out = '';
|
|
116
|
+
let w = 0;
|
|
117
|
+
for (const g of graphemes(text)) {
|
|
118
|
+
const gw = charWidth(g);
|
|
119
|
+
if (w + gw > budget)
|
|
120
|
+
break;
|
|
121
|
+
out += g;
|
|
122
|
+
w += gw;
|
|
123
|
+
}
|
|
124
|
+
return out + ellipsis;
|
|
125
|
+
}
|
|
126
|
+
export function sliceByWidth(text, start, end) {
|
|
127
|
+
let out = '';
|
|
128
|
+
let col = 0;
|
|
129
|
+
for (const g of graphemes(text)) {
|
|
130
|
+
const gw = charWidth(g);
|
|
131
|
+
if (col >= start && col + gw <= end)
|
|
132
|
+
out += g;
|
|
133
|
+
col += gw;
|
|
134
|
+
if (col >= end)
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
const ANSI_RE = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
|
|
140
|
+
export function stripAnsi(text) {
|
|
141
|
+
return text.replace(ANSI_RE, '');
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/engine/utils/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,GAAG,GACP,OAAQ,IAAgC,CAAC,SAAS,KAAK,UAAU;IAC/D,CAAC,CAAC,IAAK,IAA2B,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IAC/E,CAAC,CAAC,IAAI,CAAC;AAEX,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,GAAG,EAAE,CAAC;QACR,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,GAAG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C;IACZ,KAAK,MAAM,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,GAAG,EAAE,IAAI,GAAG;YAAE,GAAG,IAAI,CAAC,CAAC;QAC9C,GAAG,IAAI,EAAE,CAAC;QACV,IAAI,GAAG,IAAI,GAAG;YAAE,MAAM;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,OAAO,GAAG,4BAA4B,CAAC;AAC7C,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
package/ui/gate.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate — lets an async flow wait for an answer from the keyboard.
|
|
3
|
+
*
|
|
4
|
+
* Linear wizards (choose → resolve → confirm → install) read far better written
|
|
5
|
+
* as one async function than as a state machine inside `onKey`. The gate is the
|
|
6
|
+
* missing piece: the flow awaits `wait()`, and the key handler calls `settle()`
|
|
7
|
+
* when the user decides.
|
|
8
|
+
*/
|
|
9
|
+
export interface Gate<T> {
|
|
10
|
+
wait(): Promise<T>;
|
|
11
|
+
/** Delivers the answer. Later calls are ignored. */
|
|
12
|
+
settle(value: T): void;
|
|
13
|
+
/** Interrompe quem espera, propagando o erro. */
|
|
14
|
+
fail(error: unknown): void;
|
|
15
|
+
/** True while somebody is waiting for an answer. */
|
|
16
|
+
readonly pending: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function createGate<T>(): Gate<T>;
|
|
19
|
+
//# sourceMappingURL=gate.d.ts.map
|
package/ui/gate.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/ui/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,oDAAoD;IACpD,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACvB,iDAAiD;IACjD,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,UAAU,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CA2BvC"}
|
package/ui/gate.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate — lets an async flow wait for an answer from the keyboard.
|
|
3
|
+
*
|
|
4
|
+
* Linear wizards (choose → resolve → confirm → install) read far better written
|
|
5
|
+
* as one async function than as a state machine inside `onKey`. The gate is the
|
|
6
|
+
* missing piece: the flow awaits `wait()`, and the key handler calls `settle()`
|
|
7
|
+
* when the user decides.
|
|
8
|
+
*/
|
|
9
|
+
export function createGate() {
|
|
10
|
+
let resolveFn = null;
|
|
11
|
+
let rejectFn = null;
|
|
12
|
+
return {
|
|
13
|
+
wait() {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
resolveFn = resolve;
|
|
16
|
+
rejectFn = reject;
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
settle(value) {
|
|
20
|
+
const resolve = resolveFn;
|
|
21
|
+
resolveFn = null;
|
|
22
|
+
rejectFn = null;
|
|
23
|
+
resolve?.(value);
|
|
24
|
+
},
|
|
25
|
+
fail(error) {
|
|
26
|
+
const reject = rejectFn;
|
|
27
|
+
resolveFn = null;
|
|
28
|
+
rejectFn = null;
|
|
29
|
+
reject?.(error);
|
|
30
|
+
},
|
|
31
|
+
get pending() {
|
|
32
|
+
return resolveFn !== null;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=gate.js.map
|
package/ui/gate.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../../src/ui/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,MAAM,UAAU,UAAU;IACxB,IAAI,SAAS,GAAgC,IAAI,CAAC;IAClD,IAAI,QAAQ,GAAsC,IAAI,CAAC;IAEvD,OAAO;QACL,IAAI;YACF,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACxC,SAAS,GAAG,OAAO,CAAC;gBACpB,QAAQ,GAAG,MAAM,CAAC;YACpB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,CAAC,KAAK;YACV,MAAM,OAAO,GAAG,SAAS,CAAC;YAC1B,SAAS,GAAG,IAAI,CAAC;YACjB,QAAQ,GAAG,IAAI,CAAC;YAChB,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,KAAK;YACR,MAAM,MAAM,GAAG,QAAQ,CAAC;YACxB,SAAS,GAAG,IAAI,CAAC;YACjB,QAAQ,GAAG,IAAI,CAAC;YAChB,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QACD,IAAI,OAAO;YACT,OAAO,SAAS,KAAK,IAAI,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/ui/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public surface of the CLI's UI.
|
|
3
|
+
*
|
|
4
|
+
* Commands import from here — never from `./engine` directly — so that replacing
|
|
5
|
+
* or upgrading the engine stays contained in this layer.
|
|
6
|
+
*/
|
|
7
|
+
export * from './engine/index.js';
|
|
8
|
+
export * from './blocks.js';
|
|
9
|
+
export * from './brand.js';
|
|
10
|
+
export * from './gate.js';
|
|
11
|
+
export * from './log-sink.js';
|
|
12
|
+
export * from './output.js';
|
|
13
|
+
export * from './report.js';
|
|
14
|
+
export * from './runner.js';
|
|
15
|
+
export * from './style.js';
|
|
16
|
+
export * from './text-input.js';
|
|
17
|
+
export * from './theme.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
package/ui/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public surface of the CLI's UI.
|
|
3
|
+
*
|
|
4
|
+
* Commands import from here — never from `./engine` directly — so that replacing
|
|
5
|
+
* or upgrading the engine stays contained in this layer.
|
|
6
|
+
*/
|
|
7
|
+
export * from './engine/index.js';
|
|
8
|
+
export * from './blocks.js';
|
|
9
|
+
export * from './brand.js';
|
|
10
|
+
export * from './gate.js';
|
|
11
|
+
export * from './log-sink.js';
|
|
12
|
+
export * from './output.js';
|
|
13
|
+
export * from './report.js';
|
|
14
|
+
export * from './runner.js';
|
|
15
|
+
export * from './style.js';
|
|
16
|
+
export * from './text-input.js';
|
|
17
|
+
export * from './theme.js';
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/ui/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC"}
|
package/ui/log-sink.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message sink — diverts the logger's output while the interactive screen is
|
|
3
|
+
* mounted.
|
|
4
|
+
*
|
|
5
|
+
* In the alt-screen, any `console.log` fired by an internal module
|
|
6
|
+
* (tsconfig-updater, theme-loader, package manager…) would tear the frame the
|
|
7
|
+
* engine just painted. While capturing, messages are held here and re-emitted
|
|
8
|
+
* into the terminal's history after unmount, alongside the summary.
|
|
9
|
+
*/
|
|
10
|
+
export type LogLevel = 'info' | 'warn' | 'error' | 'success' | 'debug';
|
|
11
|
+
export interface LogRecord {
|
|
12
|
+
readonly level: LogLevel;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
}
|
|
15
|
+
/** Starts holding the logger's messages instead of writing them to the terminal. */
|
|
16
|
+
export declare function beginCapture(): void;
|
|
17
|
+
/** Encerra a captura e devolve o que foi retido, na ordem em que chegou. */
|
|
18
|
+
export declare function endCapture(): LogRecord[];
|
|
19
|
+
export declare function isCapturing(): boolean;
|
|
20
|
+
/** Holds one message. Returns false when no capture is active. */
|
|
21
|
+
export declare function capture(level: LogLevel, message: string): boolean;
|
|
22
|
+
/** The messages held so far, without ending the capture (for display in the UI). */
|
|
23
|
+
export declare function captured(): readonly LogRecord[];
|
|
24
|
+
//# sourceMappingURL=log-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-sink.d.ts","sourceRoot":"","sources":["../../src/ui/log-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAEvE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAID,oFAAoF;AACpF,wBAAgB,YAAY,IAAI,IAAI,CAEnC;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,IAAI,SAAS,EAAE,CAIxC;AAED,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAIjE;AAED,oFAAoF;AACpF,wBAAgB,QAAQ,IAAI,SAAS,SAAS,EAAE,CAE/C"}
|
package/ui/log-sink.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message sink — diverts the logger's output while the interactive screen is
|
|
3
|
+
* mounted.
|
|
4
|
+
*
|
|
5
|
+
* In the alt-screen, any `console.log` fired by an internal module
|
|
6
|
+
* (tsconfig-updater, theme-loader, package manager…) would tear the frame the
|
|
7
|
+
* engine just painted. While capturing, messages are held here and re-emitted
|
|
8
|
+
* into the terminal's history after unmount, alongside the summary.
|
|
9
|
+
*/
|
|
10
|
+
let buffer = null;
|
|
11
|
+
/** Starts holding the logger's messages instead of writing them to the terminal. */
|
|
12
|
+
export function beginCapture() {
|
|
13
|
+
buffer = [];
|
|
14
|
+
}
|
|
15
|
+
/** Encerra a captura e devolve o que foi retido, na ordem em que chegou. */
|
|
16
|
+
export function endCapture() {
|
|
17
|
+
const captured = buffer ?? [];
|
|
18
|
+
buffer = null;
|
|
19
|
+
return captured;
|
|
20
|
+
}
|
|
21
|
+
export function isCapturing() {
|
|
22
|
+
return buffer !== null;
|
|
23
|
+
}
|
|
24
|
+
/** Holds one message. Returns false when no capture is active. */
|
|
25
|
+
export function capture(level, message) {
|
|
26
|
+
if (buffer === null)
|
|
27
|
+
return false;
|
|
28
|
+
buffer.push({ level, message });
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/** The messages held so far, without ending the capture (for display in the UI). */
|
|
32
|
+
export function captured() {
|
|
33
|
+
return buffer ?? [];
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=log-sink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-sink.js","sourceRoot":"","sources":["../../src/ui/log-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH,IAAI,MAAM,GAAuB,IAAI,CAAC;AAEtC,oFAAoF;AACpF,MAAM,UAAU,YAAY;IAC1B,MAAM,GAAG,EAAE,CAAC;AACd,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU;IACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAC;IAC9B,MAAM,GAAG,IAAI,CAAC;IACd,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,MAAM,KAAK,IAAI,CAAC;AACzB,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,OAAO,CAAC,KAAe,EAAE,OAAe;IACtD,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAClC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,QAAQ;IACtB,OAAO,MAAM,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
package/ui/output.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Line output — the only door through which the CLI writes loose text to the
|
|
3
|
+
* terminal, outside the interactive screen.
|
|
4
|
+
*
|
|
5
|
+
* Concentrating writes here guarantees the logger, the final summary and the
|
|
6
|
+
* messages re-emitted from the sink all use exactly the same level markers and
|
|
7
|
+
* the same palette.
|
|
8
|
+
*/
|
|
9
|
+
import { type LogRecord } from './log-sink.js';
|
|
10
|
+
export declare function writeLine(text?: string): void;
|
|
11
|
+
export declare function formatRecord(record: LogRecord): string;
|
|
12
|
+
/** Re-emits into the terminal's history the messages held while the screen was up. */
|
|
13
|
+
export declare function flushRecords(records: readonly LogRecord[]): void;
|
|
14
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/ui/output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,eAAe,CAAC;AAW9D,wBAAgB,SAAS,CAAC,IAAI,SAAK,GAAG,IAAI,CAEzC;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAEtD;AAED,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAEhE"}
|
package/ui/output.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Line output — the only door through which the CLI writes loose text to the
|
|
3
|
+
* terminal, outside the interactive screen.
|
|
4
|
+
*
|
|
5
|
+
* Concentrating writes here guarantees the logger, the final summary and the
|
|
6
|
+
* messages re-emitted from the sink all use exactly the same level markers and
|
|
7
|
+
* the same palette.
|
|
8
|
+
*/
|
|
9
|
+
import { style } from './style.js';
|
|
10
|
+
const MARKS = {
|
|
11
|
+
info: text => `${style.primary('›')} ${text}`,
|
|
12
|
+
success: text => `${style.success('✔')} ${text}`,
|
|
13
|
+
warn: text => `${style.warning('⚠')} ${text}`,
|
|
14
|
+
error: text => `${style.danger('✖')} ${text}`,
|
|
15
|
+
debug: text => style.dim(`[debug] ${text}`),
|
|
16
|
+
};
|
|
17
|
+
export function writeLine(text = '') {
|
|
18
|
+
process.stdout.write(`${text}\n`);
|
|
19
|
+
}
|
|
20
|
+
export function formatRecord(record) {
|
|
21
|
+
return MARKS[record.level](record.message);
|
|
22
|
+
}
|
|
23
|
+
/** Re-emits into the terminal's history the messages held while the screen was up. */
|
|
24
|
+
export function flushRecords(records) {
|
|
25
|
+
for (const record of records)
|
|
26
|
+
writeLine(formatRecord(record));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=output.js.map
|
package/ui/output.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/ui/output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,KAAK,GAA+C;IACxD,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE;IAC7C,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE;IAChD,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE;IAC7C,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE;IAC7C,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC;CAC5C,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,IAAI,GAAG,EAAE;IACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC5C,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,YAAY,CAAC,OAA6B;IACxD,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
package/ui/report.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-run summary — what stays in the history after the alt-screen.
|
|
3
|
+
*
|
|
4
|
+
* On leaving the full screen, everything the wizard drew disappears. What the
|
|
5
|
+
* user needs to keep (what was written, what to run next, what went wrong) is
|
|
6
|
+
* reprinted here, in the terminal's normal flow, where it stays scrollable and
|
|
7
|
+
* copyable after the command ends.
|
|
8
|
+
*/
|
|
9
|
+
import { type LogRecord } from './log-sink.js';
|
|
10
|
+
export type ReportStatus = 'success' | 'cancelled' | 'error';
|
|
11
|
+
export interface ReportCommand {
|
|
12
|
+
readonly command: string;
|
|
13
|
+
/** Trecho final destacado, como o `[component]` de `zard-cli add`. */
|
|
14
|
+
readonly argument?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface Report {
|
|
17
|
+
readonly status: ReportStatus;
|
|
18
|
+
/** Uma frase: o desfecho do comando. */
|
|
19
|
+
readonly headline: string;
|
|
20
|
+
/** What was actually done. */
|
|
21
|
+
readonly items?: readonly string[];
|
|
22
|
+
/** Supporting text, shown in a secondary tone. */
|
|
23
|
+
readonly notes?: readonly string[];
|
|
24
|
+
/** Suggested next steps. */
|
|
25
|
+
readonly commands?: readonly ReportCommand[];
|
|
26
|
+
/** Mensagens retidas enquanto a tela estava montada. */
|
|
27
|
+
readonly logs?: readonly LogRecord[];
|
|
28
|
+
}
|
|
29
|
+
export declare function printReport(report: Report): void;
|
|
30
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/ui/report.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAI/C,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,4BAA4B;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAC7C,wDAAwD;IACxD,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;CACtC;AAQD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CA+BhD"}
|
package/ui/report.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The post-run summary — what stays in the history after the alt-screen.
|
|
3
|
+
*
|
|
4
|
+
* On leaving the full screen, everything the wizard drew disappears. What the
|
|
5
|
+
* user needs to keep (what was written, what to run next, what went wrong) is
|
|
6
|
+
* reprinted here, in the terminal's normal flow, where it stays scrollable and
|
|
7
|
+
* copyable after the command ends.
|
|
8
|
+
*/
|
|
9
|
+
import { flushRecords, writeLine } from './output.js';
|
|
10
|
+
import { style } from './style.js';
|
|
11
|
+
const HEADLINE = {
|
|
12
|
+
success: text => `${style.success('✔')} ${style.bold(text)}`,
|
|
13
|
+
cancelled: text => `${style.warning('■')} ${style.bold(text)}`,
|
|
14
|
+
error: text => `${style.danger('✖')} ${style.bold(text)}`,
|
|
15
|
+
};
|
|
16
|
+
export function printReport(report) {
|
|
17
|
+
writeLine();
|
|
18
|
+
writeLine(HEADLINE[report.status](report.headline));
|
|
19
|
+
if (report.logs?.length) {
|
|
20
|
+
writeLine();
|
|
21
|
+
flushRecords(report.logs);
|
|
22
|
+
}
|
|
23
|
+
if (report.items?.length) {
|
|
24
|
+
writeLine();
|
|
25
|
+
for (const item of report.items)
|
|
26
|
+
writeLine(` ${style.success('✔')} ${item}`);
|
|
27
|
+
}
|
|
28
|
+
if (report.notes?.length) {
|
|
29
|
+
writeLine();
|
|
30
|
+
for (const note of report.notes)
|
|
31
|
+
writeLine(` ${style.muted(note)}`);
|
|
32
|
+
}
|
|
33
|
+
if (report.commands?.length) {
|
|
34
|
+
writeLine();
|
|
35
|
+
for (const { command, argument } of report.commands) {
|
|
36
|
+
const suffix = argument ? ` ${style.primary(argument)}` : '';
|
|
37
|
+
writeLine(` ${style.foreground(command)}${suffix}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Two lines, not one: the shell prompt comes back right below and, pressed up
|
|
41
|
+
// against it, the last suggested command looks like part of it.
|
|
42
|
+
writeLine();
|
|
43
|
+
writeLine();
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=report.js.map
|
package/ui/report.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/ui/report.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAwBnC,MAAM,QAAQ,GAAmD;IAC/D,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,C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AG,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,SAAS,CAAC,KAAK,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,8EAA8E;IAC9E,gEAAgE;IAChE,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;AACd,CAAC"}
|
package/ui/runner.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runner — the bridge between the engine's frame loop and the CLI's async flow.
|
|
3
|
+
*
|
|
4
|
+
* Commands are sequential (`const config = await promptForConfig(...)`), while
|
|
5
|
+
* the engine is an event-driven render loop. The runner reconciles the two: it
|
|
6
|
+
* mounts the screen, hands control to `onKey`/`run`, and resolves a Promise when
|
|
7
|
+
* the flow calls `done()`.
|
|
8
|
+
*
|
|
9
|
+
* Three invariants hold for every wizard:
|
|
10
|
+
* 1. the terminal is restored on every exit path — errors, SIGINT and a
|
|
11
|
+
* process crash included;
|
|
12
|
+
* 2. with no TTY the screen is never mounted: the caller gets a
|
|
13
|
+
* NonInteractiveError and follows the headless path;
|
|
14
|
+
* 3. whatever the logger would write during the mount is held in the sink and
|
|
15
|
+
* re-emitted afterwards, so the frame is not torn.
|
|
16
|
+
*/
|
|
17
|
+
import { type KeyEvent, type Node, type Screen, type TerminalStreams } from './engine/index.js';
|
|
18
|
+
import { type LogRecord } from './log-sink.js';
|
|
19
|
+
/** Signals that the command has to carry on without an interactive UI (CI, pipe, --yes). */
|
|
20
|
+
export declare class NonInteractiveError extends Error {
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
23
|
+
/** The user abandoned the wizard (Ctrl+C, or a step that cancels the flow). */
|
|
24
|
+
export declare class WizardCancelledError extends Error {
|
|
25
|
+
constructor(message?: string);
|
|
26
|
+
}
|
|
27
|
+
export interface WizardContext<T> {
|
|
28
|
+
/** Encerra a tela e resolve o wizard com este valor. */
|
|
29
|
+
done(value: T): void;
|
|
30
|
+
/** Encerra a tela e rejeita com WizardCancelledError. */
|
|
31
|
+
cancel(message?: string): void;
|
|
32
|
+
/** Agenda um novo frame depois de alterar o estado. */
|
|
33
|
+
refresh(): void;
|
|
34
|
+
/** Access to the screen, for cases that need the scheduler or the capabilities. */
|
|
35
|
+
readonly screen: Screen;
|
|
36
|
+
}
|
|
37
|
+
export interface WizardOptions<T> {
|
|
38
|
+
/** Pure view, rebuilt every frame. */
|
|
39
|
+
view: () => Node;
|
|
40
|
+
/** Keys the view handles on its own. */
|
|
41
|
+
onKey?: (event: KeyEvent, ctx: WizardContext<T>) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Async work run with the screen alive — installing packages, writing files.
|
|
44
|
+
* The UI keeps animating until the promise resolves.
|
|
45
|
+
*/
|
|
46
|
+
run?: (ctx: WizardContext<T>) => Promise<void> | void;
|
|
47
|
+
fps?: number;
|
|
48
|
+
/** How to find the terminal. Injectable for tests; the default resolves it itself. */
|
|
49
|
+
resolveStreams?: () => TerminalStreams | null;
|
|
50
|
+
}
|
|
51
|
+
export interface WizardResult<T> {
|
|
52
|
+
readonly value: T;
|
|
53
|
+
/** Mensagens que o logger reteve enquanto a tela estava montada. */
|
|
54
|
+
readonly logs: readonly LogRecord[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* True when there is a terminal to mount the screen on.
|
|
58
|
+
*
|
|
59
|
+
* Looking at `process.stdout.isTTY && process.stdin.isTTY` is not enough: that
|
|
60
|
+
* is what made `npx zard-cli init` fall back to text mode on macOS and Linux,
|
|
61
|
+
* where npm runs the binary through a shell and hands over stdin as a pipe. The
|
|
62
|
+
* controlling terminal is still reachable, and it is what decides.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isInteractive(resolve?: () => TerminalStreams | null): boolean;
|
|
65
|
+
export declare function runWizard<T>(options: WizardOptions<T>): Promise<WizardResult<T>>;
|
|
66
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/ui/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,IAAI,EACT,KAAK,MAAM,EACX,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAIzE,4FAA4F;AAC5F,qBAAa,mBAAoB,SAAQ,KAAK;gBAChC,OAAO,SAAsC;CAI1D;AAED,+EAA+E;AAC/E,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,SAAyB;CAI7C;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,wDAAwD;IACxD,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;IACrB,yDAAyD;IACzD,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,uDAAuD;IACvD,OAAO,IAAI,IAAI,CAAC;IAChB,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,sCAAsC;IACtC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,wCAAwC;IACxC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACzD;;;OAGG;IACH,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACtD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,eAAe,GAAG,IA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