@hobui/viui-cli 0.0.6 → 0.0.7
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 +138 -139
- package/dist/adapters/adapter-registry.d.ts +12 -0
- package/dist/adapters/adapter-registry.d.ts.map +1 -0
- package/dist/adapters/adapter-registry.js +49 -0
- package/dist/adapters/adapter-types.d.ts +20 -0
- package/dist/adapters/adapter-types.d.ts.map +1 -0
- package/dist/adapters/adapter-types.js +1 -0
- package/dist/adapters/aider-adapter.d.ts +3 -0
- package/dist/adapters/aider-adapter.d.ts.map +1 -0
- package/dist/adapters/aider-adapter.js +8 -0
- package/dist/adapters/claude-adapter.d.ts +3 -0
- package/dist/adapters/claude-adapter.d.ts.map +1 -0
- package/dist/adapters/claude-adapter.js +15 -0
- package/dist/adapters/cline-adapter.d.ts +3 -0
- package/dist/adapters/cline-adapter.d.ts.map +1 -0
- package/dist/adapters/cline-adapter.js +8 -0
- package/dist/adapters/copilot-adapter.d.ts +5 -0
- package/dist/adapters/copilot-adapter.d.ts.map +1 -0
- package/dist/adapters/copilot-adapter.js +20 -0
- package/dist/adapters/cursor-adapter.d.ts +3 -0
- package/dist/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/adapters/cursor-adapter.js +18 -0
- package/dist/adapters/external/bolt-adapter.d.ts +3 -0
- package/dist/adapters/external/bolt-adapter.d.ts.map +1 -0
- package/dist/adapters/external/bolt-adapter.js +15 -0
- package/dist/adapters/external/chatgpt-adapter.d.ts +3 -0
- package/dist/adapters/external/chatgpt-adapter.d.ts.map +1 -0
- package/dist/adapters/external/chatgpt-adapter.js +14 -0
- package/dist/adapters/external/external-adapter-base.d.ts +15 -0
- package/dist/adapters/external/external-adapter-base.d.ts.map +1 -0
- package/dist/adapters/external/external-adapter-base.js +92 -0
- package/dist/adapters/external/gemini-adapter.d.ts +3 -0
- package/dist/adapters/external/gemini-adapter.d.ts.map +1 -0
- package/dist/adapters/external/gemini-adapter.js +14 -0
- package/dist/adapters/external/lovable-adapter.d.ts +3 -0
- package/dist/adapters/external/lovable-adapter.d.ts.map +1 -0
- package/dist/adapters/external/lovable-adapter.js +14 -0
- package/dist/adapters/external/v0-adapter.d.ts +3 -0
- package/dist/adapters/external/v0-adapter.d.ts.map +1 -0
- package/dist/adapters/external/v0-adapter.js +15 -0
- package/dist/adapters/windsurf-adapter.d.ts +3 -0
- package/dist/adapters/windsurf-adapter.d.ts.map +1 -0
- package/dist/adapters/windsurf-adapter.js +23 -0
- package/dist/assets/plugins/viui-conf/apply-theme-body.ts +23 -4
- package/dist/assets/plugins/viui-conf/defaults/README.md +2 -0
- package/dist/assets/plugins/viui-conf/defaults/app-bar.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/buttons.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/by-theme/minimalist-2.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/cards.ts +1 -1
- package/dist/assets/plugins/viui-conf/defaults/expansion-panels.ts +16 -0
- package/dist/assets/plugins/viui-conf/defaults/index.ts +3 -0
- package/dist/assets/plugins/viui-conf/defaults/inputs.ts +11 -1
- package/dist/assets/plugins/viui-conf/design-tokens.ts +135 -0
- package/dist/assets/plugins/viui-conf/theme-base.ts +1 -1
- package/dist/assets/plugins/viui-conf/v-dark.ts +3 -5
- package/dist/assets/plugins/viui-conf/v-light.ts +3 -5
- package/dist/assets/plugins/vuetify.ts +36 -0
- package/dist/assets/prompt-data/components.json +106 -0
- package/dist/assets/prompt-data/tokens.json +83 -0
- package/dist/assets/themes/_bento-grid.scss +8 -0
- package/dist/assets/themes/_glassmorphism.scss +8 -0
- package/dist/assets/themes/_material.scss +8 -0
- package/dist/assets/themes/_minimalist-2.scss +375 -0
- package/dist/assets/themes/_minimalist.scss +9 -0
- package/dist/assets/themes/_neo-brutalism.scss +199 -0
- package/dist/assets/themes/bento-grid.scss +4 -0
- package/dist/assets/themes/glassmorphism.scss +4 -0
- package/dist/assets/themes/index.scss +11 -0
- package/dist/assets/themes/material.scss +4 -0
- package/dist/assets/themes/minimalist-2.scss +5 -0
- package/dist/assets/themes/minimalist.scss +4 -0
- package/dist/assets/themes/neo-brutalism.scss +5 -0
- package/dist/assets/viui-themes/_neo-brutalism.scss +70 -152
- package/dist/cli-paths.d.ts +7 -0
- package/dist/cli-paths.d.ts.map +1 -0
- package/dist/cli-paths.js +19 -0
- package/dist/cli.js +28 -578
- package/dist/cli.legacy.d.ts +3 -0
- package/dist/cli.legacy.d.ts.map +1 -0
- package/dist/cli.legacy.js +597 -0
- package/dist/commands/audit.d.ts +3 -0
- package/dist/commands/audit.d.ts.map +1 -0
- package/dist/commands/audit.js +152 -0
- package/dist/commands/config/config-export.d.ts +6 -0
- package/dist/commands/config/config-export.d.ts.map +1 -0
- package/dist/commands/config/config-export.js +23 -0
- package/dist/commands/config/config-health.d.ts +6 -0
- package/dist/commands/config/config-health.d.ts.map +1 -0
- package/dist/commands/config/config-health.js +42 -0
- package/dist/commands/config/config-import.d.ts +6 -0
- package/dist/commands/config/config-import.d.ts.map +1 -0
- package/dist/commands/config/config-import.js +63 -0
- package/dist/commands/config/config-rollback.d.ts +6 -0
- package/dist/commands/config/config-rollback.d.ts.map +1 -0
- package/dist/commands/config/config-rollback.js +47 -0
- package/dist/commands/config/config-setup.d.ts +6 -0
- package/dist/commands/config/config-setup.d.ts.map +1 -0
- package/dist/commands/config/config-setup.js +103 -0
- package/dist/commands/config/config-status.d.ts +6 -0
- package/dist/commands/config/config-status.d.ts.map +1 -0
- package/dist/commands/config/config-status.js +42 -0
- package/dist/commands/config/config-uninstall.d.ts +6 -0
- package/dist/commands/config/config-uninstall.d.ts.map +1 -0
- package/dist/commands/config/config-uninstall.js +74 -0
- package/dist/commands/config.d.ts +6 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +19 -0
- package/dist/commands/docs.d.ts +3 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +17 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +93 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +183 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +73 -0
- package/dist/commands/theme.d.ts +3 -0
- package/dist/commands/theme.d.ts.map +1 -0
- package/dist/commands/theme.js +86 -0
- package/dist/commands/update.d.ts +3 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +97 -0
- package/dist/prompts/prompt-builder.d.ts +4 -0
- package/dist/prompts/prompt-builder.d.ts.map +1 -0
- package/dist/prompts/prompt-builder.js +18 -0
- package/dist/prompts/prompt-data-loader.d.ts +11 -0
- package/dist/prompts/prompt-data-loader.d.ts.map +1 -0
- package/dist/prompts/prompt-data-loader.js +15 -0
- package/dist/prompts/prompt-sections/section-code-examples.d.ts +2 -0
- package/dist/prompts/prompt-sections/section-code-examples.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-code-examples.js +36 -0
- package/dist/prompts/prompt-sections/section-color-tokens.d.ts +2 -0
- package/dist/prompts/prompt-sections/section-color-tokens.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-color-tokens.js +19 -0
- package/dist/prompts/prompt-sections/section-component-map.d.ts +3 -0
- package/dist/prompts/prompt-sections/section-component-map.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-component-map.js +12 -0
- package/dist/prompts/prompt-sections/section-typography-spacing.d.ts +2 -0
- package/dist/prompts/prompt-sections/section-typography-spacing.d.ts.map +1 -0
- package/dist/prompts/prompt-sections/section-typography-spacing.js +29 -0
- package/dist/services/backup-service.d.ts +7 -0
- package/dist/services/backup-service.d.ts.map +1 -0
- package/dist/services/backup-service.js +54 -0
- package/dist/services/config-service.d.ts +17 -0
- package/dist/services/config-service.d.ts.map +1 -0
- package/dist/services/config-service.js +64 -0
- package/dist/services/diff-engine.d.ts +13 -0
- package/dist/services/diff-engine.d.ts.map +1 -0
- package/dist/services/diff-engine.js +59 -0
- package/dist/services/ide-detector.d.ts +9 -0
- package/dist/services/ide-detector.d.ts.map +1 -0
- package/dist/services/ide-detector.js +113 -0
- package/dist/services/ide-detector.spec.d.ts +2 -0
- package/dist/services/ide-detector.spec.d.ts.map +1 -0
- package/dist/services/ide-detector.spec.js +108 -0
- package/dist/services/lock-file-service.d.ts +15 -0
- package/dist/services/lock-file-service.d.ts.map +1 -0
- package/dist/services/lock-file-service.js +74 -0
- package/dist/services/mcp-config-reader.d.ts +11 -0
- package/dist/services/mcp-config-reader.d.ts.map +1 -0
- package/dist/services/mcp-config-reader.js +40 -0
- package/dist/services/mcp-config-reader.spec.d.ts +2 -0
- package/dist/services/mcp-config-reader.spec.d.ts.map +1 -0
- package/dist/services/mcp-config-reader.spec.js +125 -0
- package/dist/services/mcp-config-writer.d.ts +11 -0
- package/dist/services/mcp-config-writer.d.ts.map +1 -0
- package/dist/services/mcp-config-writer.js +98 -0
- package/dist/services/mcp-config-writer.spec.d.ts +2 -0
- package/dist/services/mcp-config-writer.spec.d.ts.map +1 -0
- package/dist/services/mcp-config-writer.spec.js +162 -0
- package/dist/services/merge-engine.d.ts +12 -0
- package/dist/services/merge-engine.d.ts.map +1 -0
- package/dist/services/merge-engine.js +54 -0
- package/dist/services/vuetify-scaffold-service.d.ts +5 -0
- package/dist/services/vuetify-scaffold-service.d.ts.map +1 -0
- package/dist/services/vuetify-scaffold-service.js +67 -0
- package/dist/templates/vuetify-plugin.d.ts +90 -0
- package/dist/templates/vuetify-plugin.d.ts.map +1 -0
- package/dist/templates/vuetify-plugin.js +33 -0
- package/dist/types/command-types.d.ts +15 -0
- package/dist/types/command-types.d.ts.map +1 -0
- package/dist/types/command-types.js +2 -0
- package/dist/types/config-types.d.ts +29 -0
- package/dist/types/config-types.d.ts.map +1 -0
- package/dist/types/config-types.js +10 -0
- package/dist/types/ide-types.d.ts +29 -0
- package/dist/types/ide-types.d.ts.map +1 -0
- package/dist/types/ide-types.js +4 -0
- package/dist/types/lock-file-types.d.ts +27 -0
- package/dist/types/lock-file-types.d.ts.map +1 -0
- package/dist/types/lock-file-types.js +2 -0
- package/dist/utils/diff-display.d.ts +18 -0
- package/dist/utils/diff-display.d.ts.map +1 -0
- package/dist/utils/diff-display.js +61 -0
- package/dist/utils/fs-safe.d.ts +9 -0
- package/dist/utils/fs-safe.d.ts.map +1 -0
- package/dist/utils/fs-safe.js +44 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +28 -0
- package/dist/utils/open-browser.d.ts +3 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +13 -0
- package/package.json +11 -6
- package/dist/assets/cursor/.design-system-version +0 -1
- package/dist/assets/cursor/commands/audit-accessibility.md +0 -25
- package/dist/assets/cursor/commands/audit-ui.md +0 -35
- package/dist/assets/cursor/commands/component.md +0 -18
- package/dist/assets/cursor/commands/fix-storybook.md +0 -24
- package/dist/assets/cursor/commands/generate-component-from-figma.md +0 -26
- package/dist/assets/cursor/commands/generate-page-from-figma.md +0 -26
- package/dist/assets/cursor/plans/DESIGN_SYSTEM_PLAN.md +0 -177
- package/dist/assets/cursor/plans/PLANS_INDEX.md +0 -35
- package/dist/assets/cursor/rules/accessibility-contrast.mdc +0 -38
- package/dist/assets/cursor/rules/bem-class-style.mdc +0 -107
- package/dist/assets/cursor/rules/component-naming.mdc +0 -57
- package/dist/assets/cursor/rules/design-system-component-library.mdc +0 -59
- package/dist/assets/cursor/rules/design-system-workflow.mdc +0 -48
- package/dist/assets/cursor/rules/figma-mapping.mdc +0 -37
- package/dist/assets/cursor/rules/icons.mdc +0 -42
- package/dist/assets/cursor/rules/project-structure.mdc +0 -137
- package/dist/assets/cursor/rules/storybook-component-template.mdc +0 -103
- package/dist/assets/cursor/rules/storybook.mdc +0 -68
- package/dist/assets/cursor/rules/tokens.mdc +0 -32
- package/dist/assets/cursor/rules/viui-themes.mdc +0 -53
- package/dist/assets/cursor/rules/vuetify-layout.mdc +0 -52
- package/dist/assets/cursor/skills/accessibility.md +0 -75
- package/dist/assets/cursor/skills/design-system-thinking.md +0 -40
- package/dist/assets/cursor/skills/figma-interpretation.md +0 -38
- package/dist/assets/cursor/skills/vue-vuetify-design-system-architect.md +0 -60
- package/dist/assets/cursor/sync-manifest.json +0 -6
- package/dist/assets/viui-themes/bento-grid-global.scss +0 -5
- package/dist/assets/viui-themes/glassmorphism-global.scss +0 -5
- package/dist/assets/viui-themes/material-global.scss +0 -5
- package/dist/assets/viui-themes/minimalist-2-global.scss +0 -5
- package/dist/assets/viui-themes/minimalist-global.scss +0 -5
- package/dist/assets/viui-themes/neo-brutalism-global.scss +0 -5
package/dist/cli.js
CHANGED
|
@@ -1,581 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* Commands: init, sync,
|
|
5
|
-
* After `pnpm add @viui/cli`, postinstall runs `setup --postinstall` for step-by-step UX.
|
|
3
|
+
* viui CLI — manage themes, tokens, and config for iNET Design System.
|
|
4
|
+
* Commands: init, sync, update, theme, doctor, docs, audit.
|
|
6
5
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function getDesignSystemVersion(assetsDir) {
|
|
34
|
-
const p = path.join(assetsDir, '.design-system-version');
|
|
35
|
-
if (!fs.existsSync(p))
|
|
36
|
-
return '0.0.0';
|
|
37
|
-
return fs.readFileSync(p, 'utf8').trim();
|
|
38
|
-
}
|
|
39
|
-
function copyRecursive(src, dest, opts) {
|
|
40
|
-
if (!fs.existsSync(src))
|
|
41
|
-
return;
|
|
42
|
-
if (!opts.dryRun)
|
|
43
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
44
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
45
|
-
for (const e of entries) {
|
|
46
|
-
const srcPath = path.join(src, e.name);
|
|
47
|
-
const destPath = path.join(dest, e.name);
|
|
48
|
-
if (e.isDirectory()) {
|
|
49
|
-
copyRecursive(srcPath, destPath, opts);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
if (opts.dryRun) {
|
|
53
|
-
console.log(`Would copy: ${path.relative(process.cwd(), destPath) || destPath}`);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
if (opts.backup && fs.existsSync(destPath)) {
|
|
57
|
-
const backupPath = destPath + '.backup.' + Date.now();
|
|
58
|
-
fs.copyFileSync(destPath, backupPath);
|
|
59
|
-
}
|
|
60
|
-
fs.copyFileSync(srcPath, destPath);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* List all relative paths under dir (files and dirs), with forward slashes.
|
|
67
|
-
*/
|
|
68
|
-
function listRelativePaths(dir, prefix = '') {
|
|
69
|
-
if (!fs.existsSync(dir))
|
|
70
|
-
return [];
|
|
71
|
-
const out = [];
|
|
72
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
73
|
-
for (const e of entries) {
|
|
74
|
-
const rel = prefix ? `${prefix}/${e.name}` : e.name;
|
|
75
|
-
out.push(rel);
|
|
76
|
-
if (e.isDirectory()) {
|
|
77
|
-
out.push(...listRelativePaths(path.join(dir, e.name), rel));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return out;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Remove from destDir any path that does not exist in sourceSet (mirror bundle).
|
|
84
|
-
* Deletes deeper paths first so dirs can be removed after their contents.
|
|
85
|
-
*/
|
|
86
|
-
function removePathsNotInSource(destDir, sourceSet, opts) {
|
|
87
|
-
if (!fs.existsSync(destDir))
|
|
88
|
-
return;
|
|
89
|
-
const destPaths = listRelativePaths(destDir);
|
|
90
|
-
const sorted = destPaths.sort((a, b) => b.split('/').length - a.split('/').length);
|
|
91
|
-
for (const rel of sorted) {
|
|
92
|
-
const relNorm = rel.replace(/\\/g, '/');
|
|
93
|
-
if (sourceSet.has(relNorm))
|
|
94
|
-
continue;
|
|
95
|
-
const destPath = path.join(destDir, relNorm);
|
|
96
|
-
if (!fs.existsSync(destPath))
|
|
97
|
-
continue;
|
|
98
|
-
if (opts.dryRun) {
|
|
99
|
-
console.log(`Would remove: ${path.relative(process.cwd(), destPath) || destPath}`);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
fs.rmSync(destPath, { recursive: true });
|
|
103
|
-
console.log('Removed:', path.relative(process.cwd(), destPath) || destPath);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function runInit(cwd, assetsDir, opts) {
|
|
108
|
-
const manifest = loadManifest(assetsDir);
|
|
109
|
-
const version = getDesignSystemVersion(assetsDir);
|
|
110
|
-
const cursorDir = path.join(cwd, '.cursor');
|
|
111
|
-
const dirs = ['rules', 'skills', 'commands'];
|
|
112
|
-
if (!opts.noPlans)
|
|
113
|
-
dirs.push('plans');
|
|
114
|
-
if (opts.dryRun) {
|
|
115
|
-
console.log('Dry run: would create .cursor and copy:');
|
|
116
|
-
for (const key of Object.keys(manifest)) {
|
|
117
|
-
if (key === 'plans' && opts.noPlans)
|
|
118
|
-
continue;
|
|
119
|
-
const src = path.join(assetsDir, manifest[key].dir);
|
|
120
|
-
if (fs.existsSync(src)) {
|
|
121
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
122
|
-
entries.forEach(e => console.log(` .cursor/${manifest[key].dir}/${e.name}`));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
console.log(` .cursor/.design-system-version (${version})`);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (!fs.existsSync(cursorDir))
|
|
129
|
-
fs.mkdirSync(cursorDir, { recursive: true });
|
|
130
|
-
for (const d of dirs) {
|
|
131
|
-
const sub = path.join(cursorDir, d);
|
|
132
|
-
if (!fs.existsSync(sub))
|
|
133
|
-
fs.mkdirSync(sub, { recursive: true });
|
|
134
|
-
}
|
|
135
|
-
for (const key of Object.keys(manifest)) {
|
|
136
|
-
if (key === 'plans' && opts.noPlans)
|
|
137
|
-
continue;
|
|
138
|
-
const src = path.join(assetsDir, manifest[key].dir);
|
|
139
|
-
const dest = path.join(cursorDir, manifest[key].dir);
|
|
140
|
-
if (fs.existsSync(src))
|
|
141
|
-
copyRecursive(src, dest, { dryRun: false });
|
|
142
|
-
}
|
|
143
|
-
fs.writeFileSync(path.join(cursorDir, '.design-system-version'), version, 'utf8');
|
|
144
|
-
console.log('Initialized .cursor with design system version', version);
|
|
145
|
-
// Sync viui-conf (theme + defaults) — trừ vuetify.ts
|
|
146
|
-
const viuiConfSrc = path.join(getAssetsPluginsDir(), 'viui-conf');
|
|
147
|
-
const viuiConfDest = path.join(cwd, 'src', 'plugins', 'viui-conf');
|
|
148
|
-
if (fs.existsSync(viuiConfSrc)) {
|
|
149
|
-
if (opts.dryRun) {
|
|
150
|
-
console.log('Would sync viui-conf to src/plugins/viui-conf');
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
if (!fs.existsSync(path.join(cwd, 'src', 'plugins')))
|
|
154
|
-
fs.mkdirSync(path.join(cwd, 'src', 'plugins'), { recursive: true });
|
|
155
|
-
copyRecursive(viuiConfSrc, viuiConfDest, { dryRun: false });
|
|
156
|
-
}
|
|
157
|
-
if (!opts.dryRun)
|
|
158
|
-
console.log('Synced viui-conf to src/plugins/viui-conf');
|
|
159
|
-
}
|
|
160
|
-
syncViuiThemesAndEntry(cwd, opts.dryRun ?? false);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Sync viui-themes SCSS to consumer and ensure theme SCSS is loaded.
|
|
164
|
-
* - Copies dist/assets/viui-themes → src/assets/styles/viui-themes
|
|
165
|
-
* - Writes viui-themes-entry.scss that @use's viui-themes/index.scss
|
|
166
|
-
* - Injects import into main.scss if present and not already there
|
|
167
|
-
*/
|
|
168
|
-
function syncViuiThemesAndEntry(cwd, dryRun) {
|
|
169
|
-
const themesSrc = getAssetsViuiThemesDir();
|
|
170
|
-
const stylesDir = path.join(cwd, 'src', 'assets', 'styles');
|
|
171
|
-
const themesDest = path.join(stylesDir, 'viui-themes');
|
|
172
|
-
const entryPath = path.join(stylesDir, 'viui-themes-entry.scss');
|
|
173
|
-
const mainScssPath = path.join(stylesDir, 'main.scss');
|
|
174
|
-
const entryImport = "@use './viui-themes-entry' as *;";
|
|
175
|
-
if (!fs.existsSync(themesSrc))
|
|
176
|
-
return;
|
|
177
|
-
if (dryRun) {
|
|
178
|
-
console.log('Would sync viui-themes to src/assets/styles/viui-themes');
|
|
179
|
-
console.log('Would write src/assets/styles/viui-themes-entry.scss');
|
|
180
|
-
console.log('Would ensure main.scss imports viui-themes-entry');
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
if (!fs.existsSync(path.join(cwd, 'src', 'assets')))
|
|
184
|
-
fs.mkdirSync(path.join(cwd, 'src', 'assets'), { recursive: true });
|
|
185
|
-
if (!fs.existsSync(stylesDir))
|
|
186
|
-
fs.mkdirSync(stylesDir, { recursive: true });
|
|
187
|
-
copyRecursive(themesSrc, themesDest, { dryRun: false });
|
|
188
|
-
console.log('Synced viui-themes to src/assets/styles/viui-themes');
|
|
189
|
-
const entryContent = `/**
|
|
190
|
-
* ViUi design style themes — auto-loaded when using viui-conf (VITE_VIUI_THEME).
|
|
191
|
-
* Do not edit: generated by viui-cli sync. Styles apply when body has .design-style-<id> or wrapper has .design-style-<id>.
|
|
192
|
-
*/
|
|
193
|
-
@use './viui-themes/index.scss' as *;
|
|
194
|
-
`;
|
|
195
|
-
fs.writeFileSync(entryPath, entryContent, 'utf8');
|
|
196
|
-
console.log('Wrote viui-themes-entry.scss');
|
|
197
|
-
if (fs.existsSync(mainScssPath)) {
|
|
198
|
-
const mainContent = fs.readFileSync(mainScssPath, 'utf8');
|
|
199
|
-
const hasEntry = /viui-themes-entry/.test(mainContent);
|
|
200
|
-
if (!hasEntry) {
|
|
201
|
-
const appended = mainContent.trimEnd() + '\n' + entryImport + '\n';
|
|
202
|
-
fs.writeFileSync(mainScssPath, appended, 'utf8');
|
|
203
|
-
console.log('Added viui-themes-entry import to main.scss');
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function runSync(cwd, assetsDir, opts) {
|
|
208
|
-
const manifest = loadManifest(assetsDir);
|
|
209
|
-
const version = getDesignSystemVersion(assetsDir);
|
|
210
|
-
const cursorDir = path.join(cwd, '.cursor');
|
|
211
|
-
console.log('Syncing .cursor at:', path.resolve(cursorDir));
|
|
212
|
-
let keys = Object.keys(manifest);
|
|
213
|
-
if (opts.rulesOnly)
|
|
214
|
-
keys = keys.filter(k => k === 'rules');
|
|
215
|
-
if (opts.skillsOnly)
|
|
216
|
-
keys = keys.filter(k => k === 'skills');
|
|
217
|
-
if (opts.commandsOnly)
|
|
218
|
-
keys = keys.filter(k => k === 'commands');
|
|
219
|
-
if (opts.dryRun) {
|
|
220
|
-
console.log('Dry run: would overwrite:');
|
|
221
|
-
for (const key of keys) {
|
|
222
|
-
const src = path.join(assetsDir, manifest[key].dir);
|
|
223
|
-
if (fs.existsSync(src)) {
|
|
224
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
225
|
-
entries.forEach(e => console.log(` .cursor/${manifest[key].dir}/${e.name}`));
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
console.log(` .cursor/.design-system-version (${version})`);
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
if (!fs.existsSync(cursorDir))
|
|
232
|
-
fs.mkdirSync(cursorDir, { recursive: true });
|
|
233
|
-
for (const key of keys) {
|
|
234
|
-
const src = path.join(assetsDir, manifest[key].dir);
|
|
235
|
-
const dest = path.join(cursorDir, manifest[key].dir);
|
|
236
|
-
if (fs.existsSync(src)) {
|
|
237
|
-
if (!fs.existsSync(dest))
|
|
238
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
239
|
-
copyRecursive(src, dest, { dryRun: opts.dryRun, backup: opts.backup });
|
|
240
|
-
const sourceRelPaths = listRelativePaths(src).map(p => p.replace(/\\/g, '/'));
|
|
241
|
-
const sourceSet = new Set(sourceRelPaths);
|
|
242
|
-
removePathsNotInSource(dest, sourceSet, { dryRun: opts.dryRun });
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
fs.writeFileSync(path.join(cursorDir, '.design-system-version'), version, 'utf8');
|
|
246
|
-
console.log('Synced .cursor with design system version', version);
|
|
247
|
-
// Sync viui-conf (theme + defaults) — trừ vuetify.ts
|
|
248
|
-
const viuiConfSrc = path.join(getAssetsPluginsDir(), 'viui-conf');
|
|
249
|
-
const viuiConfDest = path.join(cwd, 'src', 'plugins', 'viui-conf');
|
|
250
|
-
if (fs.existsSync(viuiConfSrc)) {
|
|
251
|
-
if (opts.dryRun) {
|
|
252
|
-
console.log('Would sync viui-conf to src/plugins/viui-conf');
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
if (!fs.existsSync(path.join(cwd, 'src', 'plugins')))
|
|
256
|
-
fs.mkdirSync(path.join(cwd, 'src', 'plugins'), { recursive: true });
|
|
257
|
-
copyRecursive(viuiConfSrc, viuiConfDest, { dryRun: false, backup: opts.backup });
|
|
258
|
-
console.log('Synced viui-conf to src/plugins/viui-conf');
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
syncViuiThemesAndEntry(cwd, opts.dryRun ?? false);
|
|
262
|
-
}
|
|
263
|
-
function detectPackageManager(cwd) {
|
|
264
|
-
if (fs.existsSync(path.join(cwd, 'pnpm-lock.yaml')))
|
|
265
|
-
return 'pnpm';
|
|
266
|
-
if (fs.existsSync(path.join(cwd, 'yarn.lock')))
|
|
267
|
-
return 'yarn';
|
|
268
|
-
return 'npm';
|
|
269
|
-
}
|
|
270
|
-
function addPostinstallScript(cwd, pm) {
|
|
271
|
-
const pkgPath = path.join(cwd, 'package.json');
|
|
272
|
-
if (!fs.existsSync(pkgPath))
|
|
273
|
-
return false;
|
|
274
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
275
|
-
const scripts = pkg.scripts ?? {};
|
|
276
|
-
const cmd = pm === 'pnpm' ? 'pnpm exec viui-cli sync' : pm === 'yarn' ? 'yarn viui-cli sync' : 'npx viui-cli sync';
|
|
277
|
-
if (scripts.postinstall?.includes('viui-cli'))
|
|
278
|
-
return false;
|
|
279
|
-
scripts.postinstall = scripts.postinstall ? `${scripts.postinstall} && ${cmd}` : cmd;
|
|
280
|
-
pkg.scripts = scripts;
|
|
281
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
282
|
-
return true;
|
|
283
|
-
}
|
|
284
|
-
const VIUI_THEME_IDS = ['minimalist-2', 'neo-brutalism', 'material'];
|
|
285
|
-
function setEnvTheme(cwd, themeId) {
|
|
286
|
-
const envPath = path.join(cwd, '.env');
|
|
287
|
-
const examplePath = path.join(cwd, '.env.example');
|
|
288
|
-
const line = `VITE_VIUI_THEME=${themeId}`;
|
|
289
|
-
const targets = [envPath, examplePath].filter((p) => fs.existsSync(p));
|
|
290
|
-
if (targets.length === 0) {
|
|
291
|
-
fs.writeFileSync(envPath, line + '\n', 'utf8');
|
|
292
|
-
console.log('Created .env with', line);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
for (const p of targets) {
|
|
296
|
-
let content = fs.readFileSync(p, 'utf8');
|
|
297
|
-
const re = /^\s*VITE_VIUI_THEME=.*/m;
|
|
298
|
-
if (re.test(content)) {
|
|
299
|
-
content = content.replace(re, line);
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
content = content.trimEnd() + '\n' + line + '\n';
|
|
303
|
-
}
|
|
304
|
-
fs.writeFileSync(p, content, 'utf8');
|
|
305
|
-
console.log('Set', line, 'in', path.basename(p));
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function ensureApplyThemeBodyInVuetify(cwd) {
|
|
309
|
-
const vuetifyPath = path.join(cwd, 'src', 'plugins', 'vuetify.ts');
|
|
310
|
-
if (!fs.existsSync(vuetifyPath))
|
|
311
|
-
return false;
|
|
312
|
-
const content = fs.readFileSync(vuetifyPath, 'utf8');
|
|
313
|
-
if (/apply-theme-body|applyThemeBody/.test(content))
|
|
314
|
-
return false;
|
|
315
|
-
const importLine = "import './viui-conf/apply-theme-body'";
|
|
316
|
-
const defaultsImportMatch = content.match(/import\s+.+\s+from\s+['"]\.\/viui-conf\/defaults[^'"]*['"]/);
|
|
317
|
-
const insert = defaultsImportMatch
|
|
318
|
-
? content.replace(defaultsImportMatch[0], defaultsImportMatch[0] + '\n' + importLine)
|
|
319
|
-
: content.trimStart().replace(/^(\s*)/, `$1${importLine}\n$1`);
|
|
320
|
-
fs.writeFileSync(vuetifyPath, insert, 'utf8');
|
|
321
|
-
console.log('Added apply-theme-body import to src/plugins/vuetify.ts');
|
|
322
|
-
return true;
|
|
323
|
-
}
|
|
324
|
-
function showHelpDocs(cwd) {
|
|
325
|
-
console.log('\n--- Design system setup ---');
|
|
326
|
-
console.log('Design themes (viui-themes) are in: src/assets/styles/viui-themes/');
|
|
327
|
-
console.log('Available theme ids: minimalist-2 (default), neo-brutalism, material');
|
|
328
|
-
console.log('To use a theme: set VITE_VIUI_THEME in .env and add in vuetify.ts:');
|
|
329
|
-
console.log(" import './viui-conf/apply-theme-body'");
|
|
330
|
-
console.log('Details: src/plugins/viui-conf/defaults/README.md');
|
|
331
|
-
console.log('CLI docs: pnpm exec viui-cli --help');
|
|
332
|
-
console.log('---\n');
|
|
333
|
-
}
|
|
334
|
-
async function runConfigureTheme(cwd, rl, opts) {
|
|
335
|
-
console.log('\n Design theme (viui-themes)');
|
|
336
|
-
console.log(' Available: minimalist-2 (default), neo-brutalism, material\n');
|
|
337
|
-
console.log(' a) Use minimalist-2 (default) — thin borders, flat');
|
|
338
|
-
console.log(' b) Use neo-brutalism — thick borders, hard shadow');
|
|
339
|
-
console.log(' c) Use material — elevated, standard Material');
|
|
340
|
-
console.log(' d) Skip / configure manually — set .env yourself\n');
|
|
341
|
-
const a = await rl.question(' Choose (a-d, or Enter for a): ');
|
|
342
|
-
const choice = (a.trim().toLowerCase() || 'a')[0];
|
|
343
|
-
const map = {
|
|
344
|
-
a: 'minimalist-2',
|
|
345
|
-
b: 'neo-brutalism',
|
|
346
|
-
c: 'material',
|
|
347
|
-
d: 'skip',
|
|
348
|
-
};
|
|
349
|
-
const themeId = map[choice] ?? map.a;
|
|
350
|
-
if (themeId === 'skip') {
|
|
351
|
-
console.log(' Skipped. Set VITE_VIUI_THEME in .env and add import in vuetify.ts. See src/plugins/viui-conf/defaults/README.md');
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
setEnvTheme(cwd, themeId);
|
|
355
|
-
const vuetifyPath = path.join(cwd, 'src', 'plugins', 'vuetify.ts');
|
|
356
|
-
const hasImport = fs.existsSync(vuetifyPath) && /apply-theme-body|applyThemeBody/.test(fs.readFileSync(vuetifyPath, 'utf8'));
|
|
357
|
-
if (!hasImport && fs.existsSync(vuetifyPath)) {
|
|
358
|
-
const ans = await rl.question(' Add apply-theme-body import to vuetify.ts? (Y/n): ');
|
|
359
|
-
const add = opts.yes || (ans.trim().toLowerCase() === '' || ans.trim().toLowerCase() === 'y' || ans.trim().toLowerCase() === 'yes');
|
|
360
|
-
if (add)
|
|
361
|
-
ensureApplyThemeBodyInVuetify(cwd);
|
|
362
|
-
}
|
|
363
|
-
console.log(' Theme configured:', themeId);
|
|
364
|
-
}
|
|
365
|
-
async function runSetup(cwd, assetsDir, opts) {
|
|
366
|
-
const isPostinstall = opts.postinstall === true;
|
|
367
|
-
if (isPostinstall && !process.stdin.isTTY) {
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
if (!fs.existsSync(assetsDir)) {
|
|
371
|
-
if (isPostinstall)
|
|
372
|
-
return;
|
|
373
|
-
console.error('Assets not found. Run "pnpm build" in packages/cli first.');
|
|
374
|
-
throw new Error('Assets not found');
|
|
375
|
-
}
|
|
376
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
377
|
-
const ask = async (q, defaultYes) => {
|
|
378
|
-
const a = await rl.question(`${q} (${defaultYes ? 'Y/n' : 'y/N'}): `);
|
|
379
|
-
const s = a.trim().toLowerCase();
|
|
380
|
-
if (s === '')
|
|
381
|
-
return defaultYes;
|
|
382
|
-
return s === 'y' || s === 'yes';
|
|
383
|
-
};
|
|
384
|
-
console.log(`\n${pkg.name ?? '@viui/cli'} — Setup i-design-system in this repo\n`);
|
|
385
|
-
console.log(' This will: sync .cursor, viui-conf, viui-themes; optional @viui/web, theme config, postinstall.\n');
|
|
386
|
-
const runNow = opts.yes || (await ask('Run setup now?', true));
|
|
387
|
-
if (!runNow) {
|
|
388
|
-
console.log('Skipped. Run later: pnpm exec viui-cli setup');
|
|
389
|
-
rl.close();
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
const pm = detectPackageManager(cwd);
|
|
393
|
-
const cursorDir = path.join(cwd, '.cursor');
|
|
394
|
-
for (;;) {
|
|
395
|
-
console.log('\n What do you want to do?\n');
|
|
396
|
-
console.log(' 1) Full setup (recommended) — init/sync .cursor + viui-conf + viui-themes, install @viui/web, configure theme, add postinstall');
|
|
397
|
-
console.log(' 2) Sync only — update .cursor, viui-conf, viui-themes (no npm install)');
|
|
398
|
-
console.log(' 3) Install @viui/web only — add Vi* components dependency');
|
|
399
|
-
console.log(' 4) Configure design theme — set VITE_VIUI_THEME in .env and ensure body class is applied');
|
|
400
|
-
console.log(' 5) Add postinstall script — auto-sync on every pnpm install');
|
|
401
|
-
console.log(' 6) Show help / docs — print links and next steps\n');
|
|
402
|
-
const choiceInput = await rl.question(' Choose (1-6, or Enter for 1): ');
|
|
403
|
-
const choice = (choiceInput.trim() || '1').replace(/[^1-6]/, '1');
|
|
404
|
-
const n = parseInt(choice, 10);
|
|
405
|
-
if (n < 1 || n > 6)
|
|
406
|
-
continue;
|
|
407
|
-
if (n === 1) {
|
|
408
|
-
if (!fs.existsSync(cursorDir)) {
|
|
409
|
-
console.log('\nStep: Initializing .cursor, viui-conf, viui-themes...');
|
|
410
|
-
runInit(cwd, assetsDir, { yes: true, dryRun: false, noPlans: false });
|
|
411
|
-
}
|
|
412
|
-
else {
|
|
413
|
-
console.log('\nStep: Syncing .cursor, viui-conf, viui-themes...');
|
|
414
|
-
runSync(cwd, assetsDir, { dryRun: false, backup: false });
|
|
415
|
-
}
|
|
416
|
-
console.log('\nStep: Installing @viui/web...');
|
|
417
|
-
const { execSync } = await import('node:child_process');
|
|
418
|
-
const addCmd = pm === 'pnpm' ? 'pnpm add @viui/web' : pm === 'yarn' ? 'yarn add @viui/web' : 'npm install @viui/web';
|
|
419
|
-
execSync(addCmd, { cwd, stdio: 'inherit' });
|
|
420
|
-
await runConfigureTheme(cwd, rl, { yes: opts.yes });
|
|
421
|
-
if (!isPostinstall && (opts.yes || (await ask('\nAdd postinstall to auto-sync on install?', false)))) {
|
|
422
|
-
if (addPostinstallScript(cwd, pm))
|
|
423
|
-
console.log('Added postinstall script to package.json.');
|
|
424
|
-
}
|
|
425
|
-
console.log('\nDone. Use: import { ViButton, ViInput, ... } from \'@viui/web\'');
|
|
426
|
-
console.log('Design themes: src/assets/styles/viui-themes/ — set VITE_VIUI_THEME in .env; see src/plugins/viui-conf/defaults/README.md');
|
|
427
|
-
break;
|
|
428
|
-
}
|
|
429
|
-
if (n === 2) {
|
|
430
|
-
if (!fs.existsSync(cursorDir)) {
|
|
431
|
-
console.log('\nInitializing .cursor, viui-conf, viui-themes...');
|
|
432
|
-
runInit(cwd, assetsDir, { yes: true, dryRun: false, noPlans: false });
|
|
433
|
-
}
|
|
434
|
-
else {
|
|
435
|
-
console.log('\nSyncing .cursor, viui-conf, viui-themes...');
|
|
436
|
-
runSync(cwd, assetsDir, { dryRun: false, backup: false });
|
|
437
|
-
}
|
|
438
|
-
console.log('Sync done.');
|
|
439
|
-
break;
|
|
440
|
-
}
|
|
441
|
-
if (n === 3) {
|
|
442
|
-
const { execSync } = await import('node:child_process');
|
|
443
|
-
const addCmd = pm === 'pnpm' ? 'pnpm add @viui/web' : pm === 'yarn' ? 'yarn add @viui/web' : 'npm install @viui/web';
|
|
444
|
-
console.log('\nRunning:', addCmd);
|
|
445
|
-
execSync(addCmd, { cwd, stdio: 'inherit' });
|
|
446
|
-
console.log('Done. Use: import { ViButton, ViInput, ... } from \'@viui/web\'');
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
if (n === 4) {
|
|
450
|
-
await runConfigureTheme(cwd, rl, { yes: opts.yes });
|
|
451
|
-
break;
|
|
452
|
-
}
|
|
453
|
-
if (n === 5) {
|
|
454
|
-
if (addPostinstallScript(cwd, pm)) {
|
|
455
|
-
console.log('\nAdded postinstall script to package.json.');
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
console.log('\npostinstall already contains viui-cli or package.json not found.');
|
|
459
|
-
}
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
if (n === 6) {
|
|
463
|
-
showHelpDocs(cwd);
|
|
464
|
-
const again = opts.yes || (await ask('Show menu again?', true));
|
|
465
|
-
if (!again)
|
|
466
|
-
break;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
rl.close();
|
|
470
|
-
}
|
|
471
|
-
const result = parseArgs({
|
|
472
|
-
options: {
|
|
473
|
-
help: { type: 'boolean', short: 'h', default: false },
|
|
474
|
-
version: { type: 'boolean', short: 'v', default: false },
|
|
475
|
-
yes: { type: 'boolean', short: 'y', default: false },
|
|
476
|
-
postinstall: { type: 'boolean', default: false },
|
|
477
|
-
'dry-run': { type: 'boolean', default: false },
|
|
478
|
-
'no-plans': { type: 'boolean', default: false },
|
|
479
|
-
backup: { type: 'boolean', default: false },
|
|
480
|
-
'rules-only': { type: 'boolean', default: false },
|
|
481
|
-
'skills-only': { type: 'boolean', default: false },
|
|
482
|
-
'commands-only': { type: 'boolean', default: false },
|
|
483
|
-
},
|
|
484
|
-
allowPositionals: true,
|
|
485
|
-
});
|
|
486
|
-
const { values } = result;
|
|
487
|
-
const positionals = result.positionals ?? [];
|
|
488
|
-
const [command] = positionals;
|
|
489
|
-
if (values.version && !command) {
|
|
490
|
-
console.log(`${pkg.name ?? '@viui/cli'} ${pkg.version}`);
|
|
491
|
-
const cwd = process.cwd();
|
|
492
|
-
const versionFile = path.join(cwd, '.cursor', '.design-system-version');
|
|
493
|
-
if (fs.existsSync(versionFile)) {
|
|
494
|
-
console.log('Design system (synced):', fs.readFileSync(versionFile, 'utf8').trim());
|
|
495
|
-
}
|
|
496
|
-
process.exit(0);
|
|
497
|
-
}
|
|
498
|
-
if (values.help || !command || command === 'help') {
|
|
499
|
-
console.log(`
|
|
500
|
-
${pkg.name ?? '@viui/cli'} — Sync design system .cursor into your repo
|
|
501
|
-
|
|
502
|
-
Usage: viui-cli <command> [options]
|
|
503
|
-
|
|
504
|
-
Commands:
|
|
505
|
-
init Create .cursor and copy rules, skills, commands (run once at repo root)
|
|
506
|
-
sync Update .cursor from design system (overwrite)
|
|
507
|
-
setup Interactive setup: init/sync .cursor, install @viui/web, optional postinstall (runs after pnpm add ${pkg.name ?? '@viui/cli'})
|
|
508
|
-
version Print CLI and design system version
|
|
509
|
-
|
|
510
|
-
Setup options:
|
|
511
|
-
-y, --yes Non-interactive: run all steps (init/sync, add @viui/web, skip postinstall prompt)
|
|
512
|
-
--postinstall Used by postinstall hook; skips wizard when not TTY (e.g. CI)
|
|
513
|
-
|
|
514
|
-
Init options:
|
|
515
|
-
-y, --yes Skip confirmation
|
|
516
|
-
--dry-run Print what would be copied
|
|
517
|
-
--no-plans Do not sync plans
|
|
518
|
-
|
|
519
|
-
Sync options:
|
|
520
|
-
--dry-run Print what would be overwritten
|
|
521
|
-
--backup Backup existing files before overwrite
|
|
522
|
-
--rules-only Sync only rules
|
|
523
|
-
--skills-only Sync only skills
|
|
524
|
-
--commands-only Sync only commands
|
|
525
|
-
|
|
526
|
-
Global:
|
|
527
|
-
-h, --help Show this help
|
|
528
|
-
-v, --version Print version
|
|
529
|
-
|
|
530
|
-
One-command UX: pnpm add ${pkg.name ?? '@viui/cli'} — then follow the setup steps. Or run: viui-cli setup
|
|
531
|
-
`);
|
|
532
|
-
process.exit(0);
|
|
533
|
-
}
|
|
534
|
-
if (command === 'version') {
|
|
535
|
-
console.log(`${pkg.name ?? '@viui/cli'} ${pkg.version}`);
|
|
536
|
-
const cwd = process.cwd();
|
|
537
|
-
const versionFile = path.join(cwd, '.cursor', '.design-system-version');
|
|
538
|
-
if (fs.existsSync(versionFile)) {
|
|
539
|
-
console.log('Design system (synced):', fs.readFileSync(versionFile, 'utf8').trim());
|
|
540
|
-
}
|
|
541
|
-
process.exit(0);
|
|
542
|
-
}
|
|
543
|
-
const assetsDir = getAssetsCursorDir();
|
|
544
|
-
const cwd = process.cwd();
|
|
545
|
-
if (!fs.existsSync(assetsDir) && command !== 'setup') {
|
|
546
|
-
console.error('Assets not found. Run "pnpm build" in packages/cli first.');
|
|
547
|
-
process.exit(1);
|
|
548
|
-
}
|
|
549
|
-
if (command === 'init') {
|
|
550
|
-
runInit(cwd, assetsDir, {
|
|
551
|
-
yes: values.yes,
|
|
552
|
-
dryRun: values['dry-run'],
|
|
553
|
-
noPlans: values['no-plans'],
|
|
554
|
-
});
|
|
555
|
-
process.exit(0);
|
|
556
|
-
}
|
|
557
|
-
if (command === 'sync') {
|
|
558
|
-
runSync(cwd, assetsDir, {
|
|
559
|
-
dryRun: values['dry-run'],
|
|
560
|
-
backup: values.backup,
|
|
561
|
-
rulesOnly: values['rules-only'],
|
|
562
|
-
skillsOnly: values['skills-only'],
|
|
563
|
-
commandsOnly: values['commands-only'],
|
|
564
|
-
});
|
|
565
|
-
process.exit(0);
|
|
566
|
-
}
|
|
567
|
-
if (command === 'setup') {
|
|
568
|
-
runSetup(cwd, assetsDir, {
|
|
569
|
-
postinstall: values.postinstall,
|
|
570
|
-
yes: values.yes,
|
|
571
|
-
})
|
|
572
|
-
.then(() => process.exit(0))
|
|
573
|
-
.catch((err) => {
|
|
574
|
-
console.error(err);
|
|
575
|
-
process.exit(1);
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
console.error(`Unknown command: ${command}. Use --help for usage.`);
|
|
580
|
-
process.exit(1);
|
|
581
|
-
}
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import { getCliVersion, getCliName } from './cli-paths.js';
|
|
8
|
+
import { registerInitCommand } from './commands/init.js';
|
|
9
|
+
import { registerSyncCommand } from './commands/sync.js';
|
|
10
|
+
import { registerUpdateCommand } from './commands/update.js';
|
|
11
|
+
import { registerThemeCommand } from './commands/theme.js';
|
|
12
|
+
import { registerDoctorCommand } from './commands/doctor.js';
|
|
13
|
+
import { registerDocsCommand } from './commands/docs.js';
|
|
14
|
+
import { registerAuditCommand } from './commands/audit.js';
|
|
15
|
+
import { registerConfigCommand } from './commands/config.js';
|
|
16
|
+
const program = new Command();
|
|
17
|
+
program
|
|
18
|
+
.name('viui')
|
|
19
|
+
.description(`${getCliName()} — CLI for iNET Design System`)
|
|
20
|
+
.version(getCliVersion(), '-v, --version')
|
|
21
|
+
.option('--verbose', 'Enable verbose output');
|
|
22
|
+
// Register all commands
|
|
23
|
+
registerInitCommand(program);
|
|
24
|
+
registerSyncCommand(program);
|
|
25
|
+
registerUpdateCommand(program);
|
|
26
|
+
registerThemeCommand(program);
|
|
27
|
+
registerDoctorCommand(program);
|
|
28
|
+
registerDocsCommand(program);
|
|
29
|
+
registerAuditCommand(program);
|
|
30
|
+
registerConfigCommand(program);
|
|
31
|
+
program.parse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.legacy.d.ts","sourceRoot":"","sources":["../src/cli.legacy.ts"],"names":[],"mappings":""}
|