zard-cli 1.0.0-beta.99 → 1.0.1
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 +98 -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 +31 -8
- 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 +2 -0
- package/commands/add/dark-mode-setup.d.ts.map +1 -1
- package/commands/add/dark-mode-setup.js +16 -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 +142 -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 +65 -3
- package/commands/init/config-prompter.d.ts.map +1 -1
- package/commands/init/config-prompter.js +93 -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 +54 -24
- package/commands/init/dependencies.js.map +1 -1
- package/commands/init/index.d.ts.map +1 -1
- package/commands/init/index.js +175 -81
- package/commands/init/index.js.map +1 -1
- package/commands/init/library-peers.d.ts +28 -0
- package/commands/init/library-peers.d.ts.map +1 -0
- package/commands/init/library-peers.js +61 -0
- package/commands/init/library-peers.js.map +1 -0
- 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 +188 -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 +47 -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 +33 -0
- package/commands/init/wizard.d.ts.map +1 -0
- package/commands/init/wizard.js +561 -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 +498 -36
- 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 +246 -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 +106 -2
- package/utils/registry.d.ts.map +1 -1
- package/utils/registry.js +155 -21
- 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
package/ui/runner.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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 { createScreen, createTerminal, resolveTerminalStreams, } from './engine/index.js';
|
|
18
|
+
import { beginCapture, endCapture } from './log-sink.js';
|
|
19
|
+
import { flushRecords } from './output.js';
|
|
20
|
+
import { zardTheme } from './theme.js';
|
|
21
|
+
/** Signals that the command has to carry on without an interactive UI (CI, pipe, --yes). */
|
|
22
|
+
export class NonInteractiveError extends Error {
|
|
23
|
+
constructor(message = 'This terminal is not interactive.') {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'NonInteractiveError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** The user abandoned the wizard (Ctrl+C, or a step that cancels the flow). */
|
|
29
|
+
export class WizardCancelledError extends Error {
|
|
30
|
+
constructor(message = 'Operation cancelled.') {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = 'WizardCancelledError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* True when there is a terminal to mount the screen on.
|
|
37
|
+
*
|
|
38
|
+
* Looking at `process.stdout.isTTY && process.stdin.isTTY` is not enough: that
|
|
39
|
+
* is what made `npx zard-cli init` fall back to text mode on macOS and Linux,
|
|
40
|
+
* where npm runs the binary through a shell and hands over stdin as a pipe. The
|
|
41
|
+
* controlling terminal is still reachable, and it is what decides.
|
|
42
|
+
*/
|
|
43
|
+
export function isInteractive(resolve = resolveTerminalStreams) {
|
|
44
|
+
const streams = resolve();
|
|
45
|
+
if (!streams)
|
|
46
|
+
return false;
|
|
47
|
+
streams.close();
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
export async function runWizard(options) {
|
|
51
|
+
const streams = (options.resolveStreams ?? resolveTerminalStreams)();
|
|
52
|
+
if (!streams)
|
|
53
|
+
throw new NonInteractiveError();
|
|
54
|
+
const screen = createScreen({
|
|
55
|
+
theme: zardTheme,
|
|
56
|
+
fps: options.fps ?? 30,
|
|
57
|
+
terminal: createTerminal({ stdin: streams.input, stdout: streams.output }),
|
|
58
|
+
// Teardown is ours: we intercept Ctrl+C to end the wizard with a message,
|
|
59
|
+
// instead of killing the process from inside the engine.
|
|
60
|
+
handleExitSignals: false,
|
|
61
|
+
});
|
|
62
|
+
let settled = false;
|
|
63
|
+
let teardownDone = false;
|
|
64
|
+
const teardown = () => {
|
|
65
|
+
if (teardownDone)
|
|
66
|
+
return;
|
|
67
|
+
teardownDone = true;
|
|
68
|
+
screen.unmount();
|
|
69
|
+
// After the unmount: that is what returns the terminal to its normal state,
|
|
70
|
+
// and closing the streams first would leave the alt-screen and raw mode on.
|
|
71
|
+
streams.close();
|
|
72
|
+
process.off('exit', teardown);
|
|
73
|
+
process.off('SIGINT', onSignal);
|
|
74
|
+
process.off('SIGTERM', onSignal);
|
|
75
|
+
};
|
|
76
|
+
// Safety net: if the process dies with the screen mounted, the terminal still
|
|
77
|
+
// returns to normal (cursor visible, no raw mode, out of the alt-screen).
|
|
78
|
+
function onSignal() {
|
|
79
|
+
teardown();
|
|
80
|
+
process.exit(130);
|
|
81
|
+
}
|
|
82
|
+
process.on('exit', teardown);
|
|
83
|
+
process.on('SIGINT', onSignal);
|
|
84
|
+
process.on('SIGTERM', onSignal);
|
|
85
|
+
beginCapture();
|
|
86
|
+
try {
|
|
87
|
+
const value = await new Promise((resolve, reject) => {
|
|
88
|
+
const settle = (fn) => {
|
|
89
|
+
if (settled)
|
|
90
|
+
return;
|
|
91
|
+
settled = true;
|
|
92
|
+
teardown();
|
|
93
|
+
fn();
|
|
94
|
+
};
|
|
95
|
+
const ctx = {
|
|
96
|
+
done: v => settle(() => resolve(v)),
|
|
97
|
+
cancel: message => settle(() => reject(new WizardCancelledError(message))),
|
|
98
|
+
refresh: () => screen.scheduler.requestRender(),
|
|
99
|
+
screen,
|
|
100
|
+
};
|
|
101
|
+
screen.setView(options.view);
|
|
102
|
+
screen.onKey(event => {
|
|
103
|
+
if (settled)
|
|
104
|
+
return;
|
|
105
|
+
if (event.ctrl && (event.key === 'c' || event.key === 'd')) {
|
|
106
|
+
ctx.cancel();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
options.onKey?.(event, ctx);
|
|
110
|
+
});
|
|
111
|
+
screen.mount();
|
|
112
|
+
if (options.run) {
|
|
113
|
+
void (async () => {
|
|
114
|
+
try {
|
|
115
|
+
await options.run?.(ctx);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
settle(() => reject(error));
|
|
119
|
+
}
|
|
120
|
+
})();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return { value, logs: endCapture() };
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
// Last chance to show what was held: the screen is already down and whoever
|
|
127
|
+
// handles the error above will only see the exception's message.
|
|
128
|
+
flushRecords(endCapture());
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
teardown();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=runner.js.map
|
package/ui/runner.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/ui/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,sBAAsB,GAKvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAkB,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,4FAA4F;AAC5F,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAO,GAAG,mCAAmC;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,+EAA+E;AAC/E,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAA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,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;oBAC3D,GAAG,CAAC,MAAM,EAAE,CAAC;oBACb,OAAO;gBACT,CAAC;gBACD,OAAO,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,KAAK,EAAE,CAAC;YAEf,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;gBAChB,KAAK,CAAC,KAAK,IAAI,EAAE;oBACf,IAAI,CAAC;wBACH,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;oBAC3B,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;oBAC9B,CAAC;gBACH,CAAC,CAAC,EAAE,CAAC;YACP,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC;IACvC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,4EAA4E;QAC5E,iEAAiE;QACjE,YAAY,CAAC,UAAU,EAAE,CAAC,CAAC;QAC3B,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,CAAC;IACb,CAAC;AACH,CAAC"}
|
package/ui/style.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styling for line output — what the CLI writes outside the interactive screen.
|
|
3
|
+
*
|
|
4
|
+
* Replaces chalk using the engine's own ANSI vocabulary, which keeps a single
|
|
5
|
+
* source of truth for colour: the same theme tokens apply to the wizard in the
|
|
6
|
+
* alt-screen and to the text left behind in the terminal's history.
|
|
7
|
+
*/
|
|
8
|
+
/** Re-evaluates the colour capability — used in tests, when stdout is swapped. */
|
|
9
|
+
export declare function resetColorLevel(): void;
|
|
10
|
+
export declare const style: {
|
|
11
|
+
primary: (text: string) => string;
|
|
12
|
+
success: (text: string) => string;
|
|
13
|
+
warning: (text: string) => string;
|
|
14
|
+
danger: (text: string) => string;
|
|
15
|
+
muted: (text: string) => string;
|
|
16
|
+
foreground: (text: string) => string;
|
|
17
|
+
bold: (text: string) => string;
|
|
18
|
+
dim: (text: string) => string;
|
|
19
|
+
/** Highlights a file name, command or path inside a sentence. */
|
|
20
|
+
code: (text: string) => string;
|
|
21
|
+
};
|
|
22
|
+
/** True when the terminal accepts the UI's Unicode boxes and glyphs. */
|
|
23
|
+
export declare function supportsUnicode(): boolean;
|
|
24
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/ui/style.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAaH,kFAAkF;AAClF,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAWD,eAAO,MAAM,KAAK;oBACA,MAAM;oBACN,MAAM;oBACN,MAAM;mBACP,MAAM;kBACP,MAAM;uBACD,MAAM;iBACZ,MAAM;gBACP,MAAM;IAClB,iEAAiE;iBACpD,MAAM;CACpB,CAAC;AAEF,wEAAwE;AACxE,wBAAgB,eAAe,IAAI,OAAO,CAEzC"}
|
package/ui/style.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styling for line output — what the CLI writes outside the interactive screen.
|
|
3
|
+
*
|
|
4
|
+
* Replaces chalk using the engine's own ANSI vocabulary, which keeps a single
|
|
5
|
+
* source of truth for colour: the same theme tokens apply to the wizard in the
|
|
6
|
+
* alt-screen and to the text left behind in the terminal's history.
|
|
7
|
+
*/
|
|
8
|
+
import { Attr, createSgrBuilder, createTerminal } from './engine/index.js';
|
|
9
|
+
import { zardTheme } from './theme.js';
|
|
10
|
+
let cachedLevel = null;
|
|
11
|
+
/** The current terminal's colour depth, resolved once per process. */
|
|
12
|
+
function colorLevel() {
|
|
13
|
+
cachedLevel ??= createTerminal().caps.colors;
|
|
14
|
+
return cachedLevel;
|
|
15
|
+
}
|
|
16
|
+
/** Re-evaluates the colour capability — used in tests, when stdout is swapped. */
|
|
17
|
+
export function resetColorLevel() {
|
|
18
|
+
cachedLevel = null;
|
|
19
|
+
}
|
|
20
|
+
function paint(text, token, attrs = Attr.None) {
|
|
21
|
+
const level = colorLevel();
|
|
22
|
+
if (level === 'none' || (token === undefined && attrs === Attr.None))
|
|
23
|
+
return text;
|
|
24
|
+
const sgr = createSgrBuilder();
|
|
25
|
+
const fg = zardTheme.resolve(token, level);
|
|
26
|
+
return sgr.transition(fg, { kind: 'default' }, attrs) + text + sgr.reset();
|
|
27
|
+
}
|
|
28
|
+
export const style = {
|
|
29
|
+
primary: (text) => paint(text, 'primary'),
|
|
30
|
+
success: (text) => paint(text, 'success'),
|
|
31
|
+
warning: (text) => paint(text, 'warning'),
|
|
32
|
+
danger: (text) => paint(text, 'danger'),
|
|
33
|
+
muted: (text) => paint(text, 'muted'),
|
|
34
|
+
foreground: (text) => paint(text, 'foreground'),
|
|
35
|
+
bold: (text) => paint(text, undefined, Attr.Bold),
|
|
36
|
+
dim: (text) => paint(text, undefined, Attr.Dim),
|
|
37
|
+
/** Highlights a file name, command or path inside a sentence. */
|
|
38
|
+
code: (text) => paint(text, 'primary', Attr.Bold),
|
|
39
|
+
};
|
|
40
|
+
/** True when the terminal accepts the UI's Unicode boxes and glyphs. */
|
|
41
|
+
export function supportsUnicode() {
|
|
42
|
+
return createTerminal().caps.unicode;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=style.js.map
|
package/ui/style.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/ui/style.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,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,EAAE,QAAQ,CAAC;IAC/C,KAAK,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;IAC7C,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC;IACvD,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;IACzD,GAAG,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC;IACvD,iEAAiE;IACjE,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;CAC1D,CAAC;AAEF,wEAAwE;AACxE,MAAM,UAAU,eAAe;IAC7B,OAAO,cAAc,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simulated TTY, to exercise wizards without a real terminal.
|
|
3
|
+
*
|
|
4
|
+
* `runWizard` refuses to mount outside a TTY — that is what protects the user
|
|
5
|
+
* from a full-screen UI inside a pipe. To test the wizard itself, then, stdout
|
|
6
|
+
* becomes a buffer and stdin an emitter we inject keyboard bytes into.
|
|
7
|
+
*/
|
|
8
|
+
export interface FakeTty {
|
|
9
|
+
/** Tudo o que foi escrito, concatenado. */
|
|
10
|
+
output(): string;
|
|
11
|
+
isRawMode(): boolean;
|
|
12
|
+
/** Injeta bytes de teclado — `\r` para enter, `\x1b[B` para seta abaixo. */
|
|
13
|
+
press(bytes: string): void;
|
|
14
|
+
restore(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare const KEY: {
|
|
17
|
+
readonly enter: "\r";
|
|
18
|
+
readonly up: "\u001B[A";
|
|
19
|
+
readonly down: "\u001B[B";
|
|
20
|
+
readonly left: "\u001B[D";
|
|
21
|
+
readonly right: "\u001B[C";
|
|
22
|
+
readonly backspace: "";
|
|
23
|
+
readonly escape: "\u001B";
|
|
24
|
+
};
|
|
25
|
+
export declare function fakeTty(): FakeTty;
|
|
26
|
+
//# sourceMappingURL=fake-tty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-tty.d.ts","sourceRoot":"","sources":["../../../src/ui/testing/fake-tty.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,OAAO;IACtB,2CAA2C;IAC3C,MAAM,IAAI,MAAM,CAAC;IACjB,SAAS,IAAI,OAAO,CAAC;IACrB,4EAA4E;IAC5E,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,eAAO,MAAM,GAAG;;;;;;;;CAQN,CAAC;AAEX,wBAAgB,OAAO,IAAI,OAAO,CAiDjC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simulated TTY, to exercise wizards without a real terminal.
|
|
3
|
+
*
|
|
4
|
+
* `runWizard` refuses to mount outside a TTY — that is what protects the user
|
|
5
|
+
* from a full-screen UI inside a pipe. To test the wizard itself, then, stdout
|
|
6
|
+
* becomes a buffer and stdin an emitter we inject keyboard bytes into.
|
|
7
|
+
*/
|
|
8
|
+
import { EventEmitter } from 'node:events';
|
|
9
|
+
export const KEY = {
|
|
10
|
+
enter: '\r',
|
|
11
|
+
up: '\x1b[A',
|
|
12
|
+
down: '\x1b[B',
|
|
13
|
+
left: '\x1b[D',
|
|
14
|
+
right: '\x1b[C',
|
|
15
|
+
backspace: '\x7f',
|
|
16
|
+
escape: '\x1b',
|
|
17
|
+
};
|
|
18
|
+
export function fakeTty() {
|
|
19
|
+
const written = [];
|
|
20
|
+
const originalWrite = process.stdout.write.bind(process.stdout);
|
|
21
|
+
const originalStdin = process.stdin;
|
|
22
|
+
const descriptors = {
|
|
23
|
+
isTTY: Object.getOwnPropertyDescriptor(process.stdout, 'isTTY'),
|
|
24
|
+
columns: Object.getOwnPropertyDescriptor(process.stdout, 'columns'),
|
|
25
|
+
rows: Object.getOwnPropertyDescriptor(process.stdout, 'rows'),
|
|
26
|
+
};
|
|
27
|
+
process.stdout.write = ((chunk) => {
|
|
28
|
+
written.push(String(chunk));
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(process.stdout, 'isTTY', { value: true, configurable: true });
|
|
32
|
+
Object.defineProperty(process.stdout, 'columns', { value: 80, configurable: true });
|
|
33
|
+
Object.defineProperty(process.stdout, 'rows', { value: 24, configurable: true });
|
|
34
|
+
const stdin = new EventEmitter();
|
|
35
|
+
let rawMode = false;
|
|
36
|
+
stdin.isTTY = true;
|
|
37
|
+
stdin.setRawMode = value => {
|
|
38
|
+
rawMode = value;
|
|
39
|
+
};
|
|
40
|
+
stdin.resume = () => undefined;
|
|
41
|
+
stdin.pause = () => undefined;
|
|
42
|
+
Object.defineProperty(process, 'stdin', { value: stdin, configurable: true });
|
|
43
|
+
return {
|
|
44
|
+
output: () => written.join(''),
|
|
45
|
+
isRawMode: () => rawMode,
|
|
46
|
+
press: bytes => {
|
|
47
|
+
stdin.emit('data', Buffer.from(bytes, 'utf8'));
|
|
48
|
+
},
|
|
49
|
+
restore: () => {
|
|
50
|
+
process.stdout.write = originalWrite;
|
|
51
|
+
Object.defineProperty(process, 'stdin', { value: originalStdin, configurable: true });
|
|
52
|
+
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
53
|
+
if (descriptor)
|
|
54
|
+
Object.defineProperty(process.stdout, key, descriptor);
|
|
55
|
+
else
|
|
56
|
+
delete process.stdout[key];
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=fake-tty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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AW,CAAC,EAAE,CAAC;gBAC5D,IAAI,UAAU;oBAAE,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;;oBAClE,OAAQ,OAAO,CAAC,MAA6C,CAAC,GAAG,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editing a single line of text in a wizard field.
|
|
3
|
+
*
|
|
4
|
+
* The field accepted exactly two things — typing at the end and deleting
|
|
5
|
+
* backwards. Anyone who wanted to change the middle of an alias
|
|
6
|
+
* (`@/shared/components` to `@app/shared/components`) pressed the arrow keys,
|
|
7
|
+
* saw nothing happen, and was left with no option but to delete everything and
|
|
8
|
+
* retype it. Here the cursor is real: it moves, inserts in the middle, and
|
|
9
|
+
* deletes in both directions.
|
|
10
|
+
*/
|
|
11
|
+
import type { KeyEvent } from '../ui/engine/index.js';
|
|
12
|
+
export interface TextInput {
|
|
13
|
+
readonly value: string;
|
|
14
|
+
/** Cursor position, in characters — never outside `[0, length]`. */
|
|
15
|
+
readonly caret: number;
|
|
16
|
+
/**
|
|
17
|
+
* True while the field still shows the suggestion and the user has not touched
|
|
18
|
+
* it: the first key typed replaces the whole suggestion instead of appending
|
|
19
|
+
* to it. Moving the cursor or deleting adopts the value and starts editing it.
|
|
20
|
+
*/
|
|
21
|
+
readonly pristine: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function startInput(value: string): TextInput;
|
|
24
|
+
/**
|
|
25
|
+
* Applies one key to the field.
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` when the key is not an editing key — `enter` and `escape`
|
|
28
|
+
* belong to the wizard's flow, and it decides what to do with them.
|
|
29
|
+
*/
|
|
30
|
+
export declare function editInput(state: TextInput, event: KeyEvent): TextInput | null;
|
|
31
|
+
//# sourceMappingURL=text-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-input.d.ts","sourceRoot":"","sources":["../../src/ui/text-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CA2C7E"}
|
package/ui/text-input.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editing a single line of text in a wizard field.
|
|
3
|
+
*
|
|
4
|
+
* The field accepted exactly two things — typing at the end and deleting
|
|
5
|
+
* backwards. Anyone who wanted to change the middle of an alias
|
|
6
|
+
* (`@/shared/components` to `@app/shared/components`) pressed the arrow keys,
|
|
7
|
+
* saw nothing happen, and was left with no option but to delete everything and
|
|
8
|
+
* retype it. Here the cursor is real: it moves, inserts in the middle, and
|
|
9
|
+
* deletes in both directions.
|
|
10
|
+
*/
|
|
11
|
+
export function startInput(value) {
|
|
12
|
+
return { value, caret: [...value].length, pristine: true };
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Applies one key to the field.
|
|
16
|
+
*
|
|
17
|
+
* Returns `null` when the key is not an editing key — `enter` and `escape`
|
|
18
|
+
* belong to the wizard's flow, and it decides what to do with them.
|
|
19
|
+
*/
|
|
20
|
+
export function editInput(state, event) {
|
|
21
|
+
const chars = [...state.value];
|
|
22
|
+
const caret = clamp(state.caret, chars.length);
|
|
23
|
+
if (event.ctrl)
|
|
24
|
+
return editWithControl(state, chars, caret, event.key);
|
|
25
|
+
if (event.alt)
|
|
26
|
+
return null;
|
|
27
|
+
if (event.key.length === 1) {
|
|
28
|
+
// The whole suggestion goes on the first key: someone who already knows what
|
|
29
|
+
// they want types straight over it, rather than deleting the CLI's proposal
|
|
30
|
+
// one character at a time.
|
|
31
|
+
if (state.pristine)
|
|
32
|
+
return { value: event.key, caret: 1, pristine: false };
|
|
33
|
+
chars.splice(caret, 0, event.key);
|
|
34
|
+
return { value: chars.join(''), caret: caret + 1, pristine: false };
|
|
35
|
+
}
|
|
36
|
+
switch (event.key) {
|
|
37
|
+
case 'backspace':
|
|
38
|
+
if (caret === 0)
|
|
39
|
+
return { ...state, caret, pristine: false };
|
|
40
|
+
chars.splice(caret - 1, 1);
|
|
41
|
+
return { value: chars.join(''), caret: caret - 1, pristine: false };
|
|
42
|
+
case 'delete':
|
|
43
|
+
if (caret >= chars.length)
|
|
44
|
+
return { ...state, caret, pristine: false };
|
|
45
|
+
chars.splice(caret, 1);
|
|
46
|
+
return { value: chars.join(''), caret, pristine: false };
|
|
47
|
+
case 'left':
|
|
48
|
+
return { ...state, caret: Math.max(0, caret - 1), pristine: false };
|
|
49
|
+
case 'right':
|
|
50
|
+
return { ...state, caret: Math.min(chars.length, caret + 1), pristine: false };
|
|
51
|
+
case 'home':
|
|
52
|
+
return { ...state, caret: 0, pristine: false };
|
|
53
|
+
case 'end':
|
|
54
|
+
return { ...state, caret: chars.length, pristine: false };
|
|
55
|
+
default:
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** Os atalhos de linha que qualquer shell oferece. */
|
|
60
|
+
function editWithControl(state, chars, caret, key) {
|
|
61
|
+
switch (key) {
|
|
62
|
+
case 'u': // clear to the start
|
|
63
|
+
return { value: chars.slice(caret).join(''), caret: 0, pristine: false };
|
|
64
|
+
case 'k': // clear to the end
|
|
65
|
+
return { value: chars.slice(0, caret).join(''), caret, pristine: false };
|
|
66
|
+
case 'w': {
|
|
67
|
+
// apaga a palavra anterior, incluindo os separadores que a antecedem
|
|
68
|
+
let start = caret;
|
|
69
|
+
while (start > 0 && isSeparator(chars[start - 1]))
|
|
70
|
+
start--;
|
|
71
|
+
while (start > 0 && !isSeparator(chars[start - 1]))
|
|
72
|
+
start--;
|
|
73
|
+
return { value: [...chars.slice(0, start), ...chars.slice(caret)].join(''), caret: start, pristine: false };
|
|
74
|
+
}
|
|
75
|
+
case 'a':
|
|
76
|
+
return { ...state, caret: 0, pristine: false };
|
|
77
|
+
case 'e':
|
|
78
|
+
return { ...state, caret: chars.length, pristine: false };
|
|
79
|
+
default:
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function isSeparator(char) {
|
|
84
|
+
return char === ' ' || char === '/' || char === '\\' || char === '.' || char === '-';
|
|
85
|
+
}
|
|
86
|
+
function clamp(caret, length) {
|
|
87
|
+
return Math.max(0, Math.min(caret, length));
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=text-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-input.js","sourceRoot":"","sources":["../../src/ui/text-input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgBH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAAgB,EAAE,KAAe;IACzD,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,KAAK,CAAC,IAAI;QAAE,OAAO,eAAe,CAAC,KAAK,EAAE,KAAK,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me — semantic tokens consumed by the whole terminal UI.
|
|
3
|
+
*
|
|
4
|
+
* The palette follows ZardUI's neutral base (zinc) for text and borders, with
|
|
5
|
+
* the accents reserved for state: primary marks the active step and the cursor,
|
|
6
|
+
* while success/warning/danger communicate each step's outcome.
|
|
7
|
+
*/
|
|
8
|
+
import { type Theme } from './engine/index.js';
|
|
9
|
+
export declare const zardTheme: Theme;
|
|
10
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/ui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE5D,eAAO,MAAM,SAAS,EAAE,KAUtB,CAAC"}
|
package/ui/theme.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's theme — semantic tokens consumed by the whole terminal UI.
|
|
3
|
+
*
|
|
4
|
+
* The palette follows ZardUI's neutral base (zinc) for text and borders, with
|
|
5
|
+
* the accents reserved for state: primary marks the active step and the cursor,
|
|
6
|
+
* while success/warning/danger communicate each step's outcome.
|
|
7
|
+
*/
|
|
8
|
+
import { createTheme } from './engine/index.js';
|
|
9
|
+
export const zardTheme = createTheme({
|
|
10
|
+
primary: '#7c93ff',
|
|
11
|
+
secondary: '#a78bfa',
|
|
12
|
+
success: '#4ade80',
|
|
13
|
+
warning: '#fbbf24',
|
|
14
|
+
danger: '#f87171',
|
|
15
|
+
muted: '#a1a1aa',
|
|
16
|
+
foreground: '#fafafa',
|
|
17
|
+
background: '#09090b',
|
|
18
|
+
border: '#27272a',
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=theme.js.map
|
package/ui/theme.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/ui/theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAc,MAAM,mBAAmB,CAAC;AAE5D,MAAM,CAAC,MAAM,SAAS,GAAU,WAAW,CAAC;IAC1C,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,SAAS;IACrB,MAAM,EAAE,SAAS;CAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pins the dependencies whose releases are tied to an Angular major.
|
|
3
|
+
*
|
|
4
|
+
* Zard supports Angular 19 and above, but several of the packages it installs
|
|
5
|
+
* ship one release per Angular major and peer on `>=` that major. Asking for
|
|
6
|
+
* them by name resolves to `latest`, which peers on an Angular newer than the
|
|
7
|
+
* project's: npm then fails the whole install with ERESOLVE, and the retry with
|
|
8
|
+
* `--legacy-peer-deps` "succeeds" while leaving a version that cannot compile.
|
|
9
|
+
*/
|
|
10
|
+
/** The major of an Angular version string, or null when it could not be read. */
|
|
11
|
+
export declare function angularMajorOf(angularVersion: string | null | undefined): number | null;
|
|
12
|
+
/**
|
|
13
|
+
* The install specifier for one package.
|
|
14
|
+
*
|
|
15
|
+
* Returns the name unchanged whenever nothing is known to constrain it — an
|
|
16
|
+
* unrecognized package, or an Angular major this package has no history for.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pinForAngular(packageName: string, angularMajor: number | null): string;
|
|
19
|
+
/** `pinForAngular` over a batch, keeping the order the caller passed. */
|
|
20
|
+
export declare function pinAllForAngular(packageNames: Iterable<string>, angularVersion: string | null): string[];
|
|
21
|
+
//# sourceMappingURL=angular-compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-compat.d.ts","sourceRoot":"","sources":["../../src/utils/angular-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAoBH,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAKvF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAOtF;AAED,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,CAGxG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pins the dependencies whose releases are tied to an Angular major.
|
|
3
|
+
*
|
|
4
|
+
* Zard supports Angular 19 and above, but several of the packages it installs
|
|
5
|
+
* ship one release per Angular major and peer on `>=` that major. Asking for
|
|
6
|
+
* them by name resolves to `latest`, which peers on an Angular newer than the
|
|
7
|
+
* project's: npm then fails the whole install with ERESOLVE, and the retry with
|
|
8
|
+
* `--legacy-peer-deps` "succeeds" while leaving a version that cannot compile.
|
|
9
|
+
*/
|
|
10
|
+
/** Packages whose own major is the Angular major, so the pin is arithmetic. */
|
|
11
|
+
const TRACKS_ANGULAR_MAJOR = new Set(['@angular/cdk', 'embla-carousel-angular', 'ngx-echarts']);
|
|
12
|
+
/**
|
|
13
|
+
* The newest release of a package that still accepts a given Angular major, for
|
|
14
|
+
* the packages that version on their own schedule.
|
|
15
|
+
*
|
|
16
|
+
* Entries are only ever needed for a superseded Angular major, and those never
|
|
17
|
+
* go stale: once Angular N is behind us, the last release built for it is
|
|
18
|
+
* history. The current major is deliberately absent — it falls through
|
|
19
|
+
* unconstrained to `latest`, which is the release made for it. So when Angular
|
|
20
|
+
* N+1 ships, N gets its entry here.
|
|
21
|
+
*/
|
|
22
|
+
const LAST_COMPATIBLE = {
|
|
23
|
+
'@ng-icons/core': { 19: '^31', 20: '^32', 21: '^34' },
|
|
24
|
+
'@ng-icons/lucide': { 19: '^31', 20: '^32', 21: '^34' },
|
|
25
|
+
};
|
|
26
|
+
/** The major of an Angular version string, or null when it could not be read. */
|
|
27
|
+
export function angularMajorOf(angularVersion) {
|
|
28
|
+
if (!angularVersion)
|
|
29
|
+
return null;
|
|
30
|
+
const major = Number.parseInt(angularVersion.split('.')[0], 10);
|
|
31
|
+
return Number.isNaN(major) ? null : major;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The install specifier for one package.
|
|
35
|
+
*
|
|
36
|
+
* Returns the name unchanged whenever nothing is known to constrain it — an
|
|
37
|
+
* unrecognized package, or an Angular major this package has no history for.
|
|
38
|
+
*/
|
|
39
|
+
export function pinForAngular(packageName, angularMajor) {
|
|
40
|
+
if (angularMajor === null)
|
|
41
|
+
return packageName;
|
|
42
|
+
if (TRACKS_ANGULAR_MAJOR.has(packageName))
|
|
43
|
+
return `${packageName}@^${angularMajor}`;
|
|
44
|
+
const range = LAST_COMPATIBLE[packageName]?.[angularMajor];
|
|
45
|
+
return range ? `${packageName}@${range}` : packageName;
|
|
46
|
+
}
|
|
47
|
+
/** `pinForAngular` over a batch, keeping the order the caller passed. */
|
|
48
|
+
export function pinAllForAngular(packageNames, angularVersion) {
|
|
49
|
+
const major = angularMajorOf(angularVersion);
|
|
50
|
+
return Array.from(packageNames, name => pinForAngular(name, major));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=angular-compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"angular-compat.js","sourceRoot":"","sources":["../../src/utils/angular-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,+EAA+E;AAC/E,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,wBAAwB,EAAE,aAAa,CAAC,CAAC,CAAC;AAEhG;;;;;;;;;GASG;AACH,MAAM,eAAe,GAA2C;IAC9D,gBAAgB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|
@@ -5,6 +5,15 @@ declare const configSchema: z.ZodObject<{
|
|
|
5
5
|
style: z.ZodDefault<z.ZodEnum<{
|
|
6
6
|
css: "css";
|
|
7
7
|
}>>;
|
|
8
|
+
icons: z.ZodDefault<z.ZodString>;
|
|
9
|
+
rtl: z.ZodDefault<z.ZodBoolean>;
|
|
10
|
+
projectType: z.ZodDefault<z.ZodEnum<{
|
|
11
|
+
angular: "angular";
|
|
12
|
+
analog: "analog";
|
|
13
|
+
nx: "nx";
|
|
14
|
+
"angular-library": "angular-library";
|
|
15
|
+
"nx-library": "nx-library";
|
|
16
|
+
}>>;
|
|
8
17
|
packageManager: z.ZodDefault<z.ZodEnum<{
|
|
9
18
|
npm: "npm";
|
|
10
19
|
yarn: "yarn";
|
|
@@ -22,11 +31,26 @@ declare const configSchema: z.ZodObject<{
|
|
|
22
31
|
utils: z.ZodDefault<z.ZodString>;
|
|
23
32
|
core: z.ZodDefault<z.ZodString>;
|
|
24
33
|
services: z.ZodDefault<z.ZodString>;
|
|
34
|
+
blocks: z.ZodDefault<z.ZodString>;
|
|
25
35
|
}, z.core.$strip>>;
|
|
26
36
|
}, z.core.$strip>;
|
|
27
37
|
export type Config = z.infer<typeof configSchema>;
|
|
28
38
|
export declare const DEFAULT_CONFIG: Config;
|
|
29
39
|
export declare function getConfig(cwd: string): Promise<Config | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Splits an alias prefix from the path that follows it.
|
|
42
|
+
*
|
|
43
|
+
* `@`, `@app`, `~` — the name does not matter: the prefix is a nickname for
|
|
44
|
+
* `baseUrl`, and the rest is the path inside the project. Handling only `@/`
|
|
45
|
+
* let an alias like `@app/components` escape the substitution and become a
|
|
46
|
+
* literal folder named `@app` at the root, outside anything the tsconfig maps.
|
|
47
|
+
*/
|
|
48
|
+
export declare function splitAlias(alias: string): {
|
|
49
|
+
prefix: string;
|
|
50
|
+
rest: string;
|
|
51
|
+
};
|
|
52
|
+
/** The alias prefix, with `/*` — the key the tsconfig has to map. */
|
|
53
|
+
export declare function aliasPattern(alias: string): string;
|
|
30
54
|
export declare function resolveAliasToPath(alias: string, baseUrl: string): string;
|
|
31
55
|
export declare function resolveConfigPaths(cwd: string, config: Config): Promise<{
|
|
32
56
|
resolvedPaths: {
|
|
@@ -36,9 +60,13 @@ export declare function resolveConfigPaths(cwd: string, config: Config): Promise
|
|
|
36
60
|
utils: string;
|
|
37
61
|
core: string;
|
|
38
62
|
services: string;
|
|
63
|
+
blocks: string;
|
|
39
64
|
};
|
|
40
65
|
appConfigFile: string;
|
|
41
66
|
style: "css";
|
|
67
|
+
icons: string;
|
|
68
|
+
rtl: boolean;
|
|
69
|
+
projectType: "angular" | "analog" | "nx" | "angular-library" | "nx-library";
|
|
42
70
|
packageManager: "npm" | "yarn" | "pnpm" | "bun";
|
|
43
71
|
tailwind: {
|
|
44
72
|
css: string;
|
|
@@ -50,6 +78,7 @@ export declare function resolveConfigPaths(cwd: string, config: Config): Promise
|
|
|
50
78
|
utils: string;
|
|
51
79
|
core: string;
|
|
52
80
|
services: string;
|
|
81
|
+
blocks: string;
|
|
53
82
|
};
|
|
54
83
|
$schema?: string;
|
|
55
84
|
registryUrl?: string;
|