@blankways/ui 0.0.0-stage → 0.1.0-alpha.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 +228 -2
- package/dist/cli/cli.options.d.ts +5 -0
- package/dist/cli/cli.options.js +53 -0
- package/dist/cli/cli.registry.d.ts +6 -0
- package/dist/cli/cli.registry.js +37 -0
- package/dist/cli/cli.types.d.ts +32 -0
- package/dist/cli/cli.types.js +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +47 -0
- package/dist/commands/add.command.d.ts +2 -0
- package/dist/commands/add.command.js +101 -0
- package/dist/commands/doctor.command.d.ts +3 -0
- package/dist/commands/doctor.command.js +92 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.js +6 -0
- package/dist/commands/init.command.d.ts +2 -0
- package/dist/commands/init.command.js +38 -0
- package/dist/commands/list.command.d.ts +2 -0
- package/dist/commands/list.command.js +54 -0
- package/dist/commands/meta.command.d.ts +1 -0
- package/dist/commands/meta.command.js +19 -0
- package/dist/commands/styles.command.d.ts +6 -0
- package/dist/commands/styles.command.js +68 -0
- package/dist/config/config.helpers.d.ts +7 -0
- package/dist/config/config.helpers.js +63 -0
- package/dist/config/framework.helpers.d.ts +3 -0
- package/dist/config/framework.helpers.js +14 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +2 -0
- package/dist/constants/cli.constants.d.ts +9 -0
- package/dist/constants/cli.constants.js +15 -0
- package/dist/constants/framework.constants.d.ts +3 -0
- package/dist/constants/framework.constants.js +2 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +2 -0
- package/dist/doctor/checks/entries.check.d.ts +1 -0
- package/dist/doctor/checks/entries.check.js +21 -0
- package/dist/doctor/checks/icons.check.d.ts +1 -0
- package/dist/doctor/checks/icons.check.js +55 -0
- package/dist/doctor/checks/imports.check.d.ts +1 -0
- package/dist/doctor/checks/imports.check.js +45 -0
- package/dist/doctor/checks/index.d.ts +7 -0
- package/dist/doctor/checks/index.js +7 -0
- package/dist/doctor/checks/motion.check.d.ts +1 -0
- package/dist/doctor/checks/motion.check.js +66 -0
- package/dist/doctor/checks/peers.check.d.ts +1 -0
- package/dist/doctor/checks/peers.check.js +55 -0
- package/dist/doctor/checks/styles.check.d.ts +1 -0
- package/dist/doctor/checks/styles.check.js +45 -0
- package/dist/doctor/checks/themes.check.d.ts +1 -0
- package/dist/doctor/checks/themes.check.js +64 -0
- package/dist/doctor/doctor.helpers.d.ts +6 -0
- package/dist/doctor/doctor.helpers.js +39 -0
- package/dist/doctor/doctor.registry.d.ts +10 -0
- package/dist/doctor/doctor.registry.js +24 -0
- package/dist/doctor/doctor.types.d.ts +27 -0
- package/dist/doctor/doctor.types.js +1 -0
- package/dist/doctor/index.d.ts +3 -0
- package/dist/doctor/index.js +3 -0
- package/dist/errors/cli-error.d.ts +3 -0
- package/dist/errors/cli-error.js +6 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/helpers/args.helpers.d.ts +4 -0
- package/dist/helpers/args.helpers.js +75 -0
- package/dist/helpers/help.helpers.d.ts +1 -0
- package/dist/helpers/help.helpers.js +30 -0
- package/dist/helpers/index.d.ts +5 -0
- package/dist/helpers/index.js +5 -0
- package/dist/helpers/package.helpers.d.ts +2 -0
- package/dist/helpers/package.helpers.js +12 -0
- package/dist/helpers/path.helpers.d.ts +3 -0
- package/dist/helpers/path.helpers.js +15 -0
- package/dist/helpers/styles.helpers.d.ts +21 -0
- package/dist/helpers/styles.helpers.js +164 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/registry/index.d.ts +1 -0
- package/dist/registry/index.js +1 -0
- package/dist/registry/registry.helpers.d.ts +22 -0
- package/dist/registry/registry.helpers.js +328 -0
- package/dist/registry-data/README.md +71 -0
- package/dist/registry-data/avatar/Avatar.tsx +64 -0
- package/dist/registry-data/avatar/component.json +30 -0
- package/dist/registry-data/avatar/index.ts +1 -0
- package/dist/registry-data/badge/Badge.tsx +76 -0
- package/dist/registry-data/badge/component.json +30 -0
- package/dist/registry-data/badge/index.ts +1 -0
- package/dist/registry-data/brand-logo/BrandLogo.tsx +24 -0
- package/dist/registry-data/brand-logo/component.json +26 -0
- package/dist/registry-data/brand-logo/index.ts +1 -0
- package/dist/registry-data/button/Button.tsx +76 -0
- package/dist/registry-data/button/component.json +33 -0
- package/dist/registry-data/button/index.ts +1 -0
- package/dist/registry-data/button-link/ButtonLink.tsx +83 -0
- package/dist/registry-data/button-link/component.json +33 -0
- package/dist/registry-data/button-link/index.ts +5 -0
- package/dist/registry-data/button-styles/component.json +19 -0
- package/dist/registry-data/button-styles/index.ts +45 -0
- package/dist/registry-data/cn/cn.ts +6 -0
- package/dist/registry-data/cn/component.json +16 -0
- package/dist/registry-data/confirm-dialog/ConfirmDialog.tsx +134 -0
- package/dist/registry-data/confirm-dialog/component.json +34 -0
- package/dist/registry-data/confirm-dialog/index.ts +1 -0
- package/dist/registry-data/container/Container.tsx +22 -0
- package/dist/registry-data/container/component.json +28 -0
- package/dist/registry-data/container/index.ts +1 -0
- package/dist/registry-data/cursor-glow/CursorGlow.tsx +29 -0
- package/dist/registry-data/cursor-glow/component.json +28 -0
- package/dist/registry-data/cursor-glow/index.ts +1 -0
- package/dist/registry-data/dropdown-menu/DropdownMenu.tsx +157 -0
- package/dist/registry-data/dropdown-menu/component.json +34 -0
- package/dist/registry-data/dropdown-menu/index.ts +5 -0
- package/dist/registry-data/empty-state/EmptyState.tsx +92 -0
- package/dist/registry-data/empty-state/component.json +30 -0
- package/dist/registry-data/empty-state/index.ts +5 -0
- package/dist/registry-data/eyebrow/Eyebrow.tsx +68 -0
- package/dist/registry-data/eyebrow/component.json +30 -0
- package/dist/registry-data/eyebrow/index.ts +1 -0
- package/dist/registry-data/field-styles/component.json +19 -0
- package/dist/registry-data/field-styles/index.ts +42 -0
- package/dist/registry-data/form-dialog/FormDialog.tsx +128 -0
- package/dist/registry-data/form-dialog/component.json +34 -0
- package/dist/registry-data/form-dialog/index.ts +1 -0
- package/dist/registry-data/icons/component.json +22 -0
- package/dist/registry-data/icons/index.ts +21 -0
- package/dist/registry-data/icons-form/component.json +17 -0
- package/dist/registry-data/icons-form/index.ts +1 -0
- package/dist/registry-data/icons-sidebar/component.json +17 -0
- package/dist/registry-data/icons-sidebar/index.ts +1 -0
- package/dist/registry-data/icons-theme/component.json +17 -0
- package/dist/registry-data/icons-theme/index.ts +1 -0
- package/dist/registry-data/icons-toast/component.json +17 -0
- package/dist/registry-data/icons-toast/index.ts +1 -0
- package/dist/registry-data/info-dialog/InfoDialog.tsx +119 -0
- package/dist/registry-data/info-dialog/component.json +36 -0
- package/dist/registry-data/info-dialog/index.ts +1 -0
- package/dist/registry-data/input/Input.tsx +96 -0
- package/dist/registry-data/input/component.json +33 -0
- package/dist/registry-data/input/index.ts +1 -0
- package/dist/registry-data/multi-combobox/MultiCombobox.tsx +205 -0
- package/dist/registry-data/multi-combobox/component.json +35 -0
- package/dist/registry-data/multi-combobox/index.ts +5 -0
- package/dist/registry-data/remote-provider/RemoteProvider.tsx +8 -0
- package/dist/registry-data/remote-provider/component.json +25 -0
- package/dist/registry-data/remote-provider/index.ts +3 -0
- package/dist/registry-data/reveal/Reveal.tsx +22 -0
- package/dist/registry-data/reveal/component.json +30 -0
- package/dist/registry-data/reveal/index.ts +1 -0
- package/dist/registry-data/section/Section.tsx +80 -0
- package/dist/registry-data/section/component.json +30 -0
- package/dist/registry-data/section/index.ts +1 -0
- package/dist/registry-data/section-heading/SectionHeading.tsx +105 -0
- package/dist/registry-data/section-heading/component.json +32 -0
- package/dist/registry-data/section-heading/index.ts +1 -0
- package/dist/registry-data/select/Select.tsx +197 -0
- package/dist/registry-data/select/component.json +34 -0
- package/dist/registry-data/select/index.ts +1 -0
- package/dist/registry-data/sidebar/Sidebar.tsx +432 -0
- package/dist/registry-data/sidebar/SidebarCollapsible.tsx +77 -0
- package/dist/registry-data/sidebar/SidebarParts.tsx +373 -0
- package/dist/registry-data/sidebar/component.json +47 -0
- package/dist/registry-data/sidebar/index.ts +4 -0
- package/dist/registry-data/sidebar/useSidebar.ts +29 -0
- package/dist/registry-data/styles-base/component.json +19 -0
- package/dist/registry-data/styles-base/index.css +67 -0
- package/dist/registry-data/styles-components/component.json +19 -0
- package/dist/registry-data/styles-components/index.css +30 -0
- package/dist/registry-data/styles-motion/component.json +20 -0
- package/dist/registry-data/styles-motion/index.css +381 -0
- package/dist/registry-data/styles-tokens/component.json +17 -0
- package/dist/registry-data/styles-tokens/index.css +77 -0
- package/dist/registry-data/styles-utilities/component.json +19 -0
- package/dist/registry-data/styles-utilities/index.css +29 -0
- package/dist/registry-data/switch/Switch.tsx +91 -0
- package/dist/registry-data/switch/component.json +34 -0
- package/dist/registry-data/switch/index.ts +1 -0
- package/dist/registry-data/tabs/Tabs.tsx +226 -0
- package/dist/registry-data/tabs/component.json +32 -0
- package/dist/registry-data/tabs/index.ts +1 -0
- package/dist/registry-data/textarea/Textarea.tsx +94 -0
- package/dist/registry-data/textarea/component.json +33 -0
- package/dist/registry-data/textarea/index.ts +1 -0
- package/dist/registry-data/theme-core/component.json +17 -0
- package/dist/registry-data/theme-core/theme.ts +84 -0
- package/dist/registry-data/theme-dark/component.json +19 -0
- package/dist/registry-data/theme-dark/index.ts +7 -0
- package/dist/registry-data/theme-light/component.json +19 -0
- package/dist/registry-data/theme-light/index.ts +7 -0
- package/dist/registry-data/theme-provider/ThemeContext.tsx +177 -0
- package/dist/registry-data/theme-provider/component.json +30 -0
- package/dist/registry-data/theme-provider/index.ts +2 -0
- package/dist/registry-data/theme-selector/ThemeSelector.tsx +269 -0
- package/dist/registry-data/theme-selector/component.json +35 -0
- package/dist/registry-data/theme-selector/selector.ts +1 -0
- package/dist/registry-data/theme-system/component.json +19 -0
- package/dist/registry-data/theme-system/index.ts +7 -0
- package/dist/registry-data/theme-toggle/ThemeToggle.tsx +71 -0
- package/dist/registry-data/theme-toggle/component.json +31 -0
- package/dist/registry-data/theme-toggle/toggle.ts +1 -0
- package/dist/registry-data/toast/Toast.tsx +260 -0
- package/dist/registry-data/toast/ToastTypeIcon.tsx +83 -0
- package/dist/registry-data/toast/component.json +43 -0
- package/dist/registry-data/toast/index.ts +3 -0
- package/dist/registry-data/toast/useToast.ts +47 -0
- package/dist/types/cli.types.d.ts +6 -0
- package/dist/types/cli.types.js +1 -0
- package/dist/types/config.types.d.ts +41 -0
- package/dist/types/config.types.js +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/dist/types/registry.types.d.ts +37 -0
- package/dist/types/registry.types.js +1 -0
- package/package.json +35 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
4
|
+
import { assertFramework, createDefaultConfig, resolveComponentsDir, writeConfig } from '../config/index.js';
|
|
5
|
+
import { CLI_NAME, DEFAULT_COMPONENTS_DIR, DEFAULT_STYLES } from '../constants/index.js';
|
|
6
|
+
import { toDisplayPath } from '../helpers/path.helpers.js';
|
|
7
|
+
import { addCommand } from './add.command.js';
|
|
8
|
+
export async function initCommand(options = {}) {
|
|
9
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
10
|
+
const framework = assertFramework(options.framework ?? options.variant);
|
|
11
|
+
const config = createDefaultConfig(options.componentsDir ?? DEFAULT_COMPONENTS_DIR, framework);
|
|
12
|
+
const componentsDir = resolveComponentsDir(cwd, config);
|
|
13
|
+
await writeConfig(cwd, config, Boolean(options.force));
|
|
14
|
+
await mkdir(componentsDir, { recursive: true });
|
|
15
|
+
console.log('Created components.json');
|
|
16
|
+
console.log(`Framework: ${framework}`);
|
|
17
|
+
console.log(`Created ${toDisplayPath(cwd, componentsDir)}/`);
|
|
18
|
+
await addCommand({
|
|
19
|
+
cwd,
|
|
20
|
+
componentsDir,
|
|
21
|
+
names: [...DEFAULT_STYLES],
|
|
22
|
+
force: Boolean(options.force)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
registerCliCommand({
|
|
26
|
+
name: 'init',
|
|
27
|
+
description: 'Create components.json, select the framework and the output directory',
|
|
28
|
+
usage: 'init [options]',
|
|
29
|
+
order: 10,
|
|
30
|
+
examples: [`${CLI_NAME} init --framework react`],
|
|
31
|
+
run: context => initCommand({
|
|
32
|
+
cwd: context.cwd,
|
|
33
|
+
componentsDir: context.componentsDir,
|
|
34
|
+
framework: context.framework,
|
|
35
|
+
variant: context.variant,
|
|
36
|
+
force: context.force
|
|
37
|
+
})
|
|
38
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
3
|
+
import { readConfig } from '../config/index.js';
|
|
4
|
+
import { CLI_NAME, DEFAULT_FRAMEWORK } from '../constants/index.js';
|
|
5
|
+
import { assertValidRegistryKind, listRegistryItems } from '../registry/index.js';
|
|
6
|
+
const KIND_LABELS = {
|
|
7
|
+
component: 'components',
|
|
8
|
+
icon: 'icons',
|
|
9
|
+
theme: 'themes',
|
|
10
|
+
style: 'styles',
|
|
11
|
+
utility: 'utilities'
|
|
12
|
+
};
|
|
13
|
+
const KIND_ORDER = ['component', 'icon', 'theme', 'style', 'utility'];
|
|
14
|
+
export async function listCommand(options = {}) {
|
|
15
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
16
|
+
const config = await readConfig(cwd);
|
|
17
|
+
const framework = options.framework ?? config?.framework ?? DEFAULT_FRAMEWORK;
|
|
18
|
+
const kind = assertValidRegistryKind(options.kind);
|
|
19
|
+
const items = await listRegistryItems({ framework });
|
|
20
|
+
const visible = items.filter(item => !item.hidden && (kind === undefined || item.kind === kind));
|
|
21
|
+
if (visible.length === 0) {
|
|
22
|
+
console.log(kind
|
|
23
|
+
? `No "${kind}" entries available for ${framework} yet.`
|
|
24
|
+
: `No entries available for ${framework} yet. Add files to registry/<name> in the package.`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.log(`Available ${framework} registry entries (${visible.length}):`);
|
|
28
|
+
for (const group of KIND_ORDER) {
|
|
29
|
+
const groupItems = visible.filter(item => item.kind === group);
|
|
30
|
+
if (groupItems.length === 0)
|
|
31
|
+
continue;
|
|
32
|
+
console.log(`\n${KIND_LABELS[group]} (${groupItems.length}):`);
|
|
33
|
+
for (const item of groupItems)
|
|
34
|
+
printItem(item);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function printItem(item) {
|
|
38
|
+
console.log(` ${item.name.padEnd(18)} ${item.description}`);
|
|
39
|
+
if (item.dependencies.length > 0) {
|
|
40
|
+
console.log(`${' '.repeat(21)}deps: ${item.dependencies.join(', ')}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
registerCliCommand({
|
|
44
|
+
name: 'list',
|
|
45
|
+
aliases: ['ls'],
|
|
46
|
+
description: 'List entries grouped by kind',
|
|
47
|
+
usage: 'list [options]',
|
|
48
|
+
order: 50,
|
|
49
|
+
examples: [`${CLI_NAME} list --kind icon`],
|
|
50
|
+
run: context => listCommand({
|
|
51
|
+
cwd: context.cwd,
|
|
52
|
+
kind: context.kind
|
|
53
|
+
})
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
2
|
+
import { getPackageVersion } from '../helpers/package.helpers.js';
|
|
3
|
+
import { printHelp } from '../helpers/help.helpers.js';
|
|
4
|
+
registerCliCommand({
|
|
5
|
+
name: 'help',
|
|
6
|
+
description: 'Show this help',
|
|
7
|
+
usage: 'help',
|
|
8
|
+
hidden: true,
|
|
9
|
+
run: () => printHelp()
|
|
10
|
+
});
|
|
11
|
+
registerCliCommand({
|
|
12
|
+
name: 'version',
|
|
13
|
+
description: 'Show the CLI version',
|
|
14
|
+
usage: 'version',
|
|
15
|
+
hidden: true,
|
|
16
|
+
run: async () => {
|
|
17
|
+
console.log(await getPackageVersion());
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CliContext } from '../cli/cli.types.js';
|
|
2
|
+
import { type StylesSyncResult } from '../helpers/styles.helpers.js';
|
|
3
|
+
import type { StylesOptions } from '../types/config.types.js';
|
|
4
|
+
export declare function stylesLinkCommand(options?: StylesOptions): Promise<void>;
|
|
5
|
+
export declare function printStylesSync(result: StylesSyncResult, cwd: string, dryRun: boolean): void;
|
|
6
|
+
export declare function stylesCommand(context: CliContext): Promise<void>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
3
|
+
import { readConfig, resolveComponentsDir } from '../config/index.js';
|
|
4
|
+
import { CLI_NAME } from '../constants/index.js';
|
|
5
|
+
import { CliError } from '../errors/index.js';
|
|
6
|
+
import { toDisplayPath } from '../helpers/path.helpers.js';
|
|
7
|
+
import { syncStyles } from '../helpers/styles.helpers.js';
|
|
8
|
+
export async function stylesLinkCommand(options = {}) {
|
|
9
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
10
|
+
const config = await readConfig(cwd);
|
|
11
|
+
if (!config) {
|
|
12
|
+
throw new CliError(`components.json not found. Run "${CLI_NAME} init" first.`);
|
|
13
|
+
}
|
|
14
|
+
const componentsDir = resolveComponentsDir(cwd, config, options.componentsDir);
|
|
15
|
+
const result = await syncStyles({
|
|
16
|
+
cwd,
|
|
17
|
+
componentsDir,
|
|
18
|
+
globalCss: options.globalCss,
|
|
19
|
+
dryRun: options.dryRun
|
|
20
|
+
});
|
|
21
|
+
if (result.skippedReason === 'no-styles') {
|
|
22
|
+
console.log(`No styles installed in ${toDisplayPath(cwd, componentsDir)}/styles. Run "${CLI_NAME} add styles-tokens styles-base styles-motion" first.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
printStylesSync(result, cwd, Boolean(options.dryRun));
|
|
26
|
+
}
|
|
27
|
+
export function printStylesSync(result, cwd, dryRun) {
|
|
28
|
+
if (result.skippedReason === 'no-styles')
|
|
29
|
+
return;
|
|
30
|
+
if (result.skippedReason === 'no-global-css') {
|
|
31
|
+
const label = dryRun && result.barrelChanged
|
|
32
|
+
? 'Would create styles barrel:'
|
|
33
|
+
: 'Styles barrel ready:';
|
|
34
|
+
console.log(`\n${label} ${toDisplayPath(cwd, result.barrel ?? '')}`);
|
|
35
|
+
console.log('No global stylesheet found. Connect it manually or use --global-css <path>.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const cssPath = toDisplayPath(cwd, result.css ?? '');
|
|
39
|
+
if (dryRun) {
|
|
40
|
+
console.log(`\nWould link styles: ${cssPath} ← ${result.importLine}`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (result.cssChanged || result.barrelChanged) {
|
|
44
|
+
console.log(`\nLinked styles: ${cssPath} ← ${result.importLine}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
console.log(`\nStyles already linked: ${cssPath}`);
|
|
48
|
+
}
|
|
49
|
+
export async function stylesCommand(context) {
|
|
50
|
+
const subcommand = context.names[0] ?? 'link';
|
|
51
|
+
if (subcommand !== 'link') {
|
|
52
|
+
throw new CliError(`Unknown styles command "${subcommand}". Run "${CLI_NAME} --help".`);
|
|
53
|
+
}
|
|
54
|
+
await stylesLinkCommand({
|
|
55
|
+
cwd: context.cwd,
|
|
56
|
+
componentsDir: context.componentsDir,
|
|
57
|
+
globalCss: context.globalCss,
|
|
58
|
+
dryRun: context.dryRun
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
registerCliCommand({
|
|
62
|
+
name: 'styles',
|
|
63
|
+
description: 'Build ui/styles/index.css and import it from your global CSS',
|
|
64
|
+
usage: 'styles link [options]',
|
|
65
|
+
order: 30,
|
|
66
|
+
examples: [`${CLI_NAME} styles link --global-css src/app/globals.css`],
|
|
67
|
+
run: context => stylesCommand(context)
|
|
68
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SupportedFramework } from '../constants/index.js';
|
|
2
|
+
import type { ComponentsConfig } from '../types/config.types.js';
|
|
3
|
+
export declare function getConfigPath(cwd: string): string;
|
|
4
|
+
export declare function createDefaultConfig(componentsDir?: string, framework?: SupportedFramework): ComponentsConfig;
|
|
5
|
+
export declare function readConfig(cwd: string): Promise<ComponentsConfig | null>;
|
|
6
|
+
export declare function writeConfig(cwd: string, config: ComponentsConfig, force?: boolean): Promise<void>;
|
|
7
|
+
export declare function resolveComponentsDir(cwd: string, config: ComponentsConfig, override?: string): string;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { CONFIG_FILE_NAME, DEFAULT_COMPONENTS_DIR, DEFAULT_FRAMEWORK } from '../constants/index.js';
|
|
4
|
+
import { CliError } from '../errors/index.js';
|
|
5
|
+
import { resolveProjectPath } from '../helpers/path.helpers.js';
|
|
6
|
+
import { assertFramework } from './framework.helpers.js';
|
|
7
|
+
async function pathExists(path) {
|
|
8
|
+
try {
|
|
9
|
+
await stat(path);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function getConfigPath(cwd) {
|
|
17
|
+
return join(cwd, CONFIG_FILE_NAME);
|
|
18
|
+
}
|
|
19
|
+
export function createDefaultConfig(componentsDir = DEFAULT_COMPONENTS_DIR, framework = DEFAULT_FRAMEWORK) {
|
|
20
|
+
return {
|
|
21
|
+
componentsDir,
|
|
22
|
+
framework,
|
|
23
|
+
overwrite: false
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export async function readConfig(cwd) {
|
|
27
|
+
const configPath = getConfigPath(cwd);
|
|
28
|
+
if (!(await pathExists(configPath)))
|
|
29
|
+
return null;
|
|
30
|
+
let parsed;
|
|
31
|
+
try {
|
|
32
|
+
parsed = JSON.parse((await readFile(configPath, 'utf8')).replace(/^\uFEFF/, ''));
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
36
|
+
throw new CliError(`Invalid JSON in ${CONFIG_FILE_NAME}: ${message}`);
|
|
37
|
+
}
|
|
38
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
39
|
+
throw new CliError(`${CONFIG_FILE_NAME} must contain a JSON object.`);
|
|
40
|
+
}
|
|
41
|
+
const record = parsed;
|
|
42
|
+
const componentsDir = record.componentsDir ?? DEFAULT_COMPONENTS_DIR;
|
|
43
|
+
const framework = assertFramework(record.framework ?? record.variant ?? DEFAULT_FRAMEWORK);
|
|
44
|
+
const overwrite = record.overwrite ?? false;
|
|
45
|
+
if (typeof componentsDir !== 'string' || componentsDir.trim() === '') {
|
|
46
|
+
throw new CliError(`${CONFIG_FILE_NAME}: "componentsDir" must be a non-empty string.`);
|
|
47
|
+
}
|
|
48
|
+
if (typeof overwrite !== 'boolean') {
|
|
49
|
+
throw new CliError(`${CONFIG_FILE_NAME}: "overwrite" must be a boolean.`);
|
|
50
|
+
}
|
|
51
|
+
return { componentsDir, framework, overwrite };
|
|
52
|
+
}
|
|
53
|
+
export async function writeConfig(cwd, config, force = false) {
|
|
54
|
+
const configPath = getConfigPath(cwd);
|
|
55
|
+
if ((await pathExists(configPath)) && !force) {
|
|
56
|
+
throw new CliError(`${CONFIG_FILE_NAME} already exists. Use --force to overwrite.`);
|
|
57
|
+
}
|
|
58
|
+
await mkdir(cwd, { recursive: true });
|
|
59
|
+
await writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
|
60
|
+
}
|
|
61
|
+
export function resolveComponentsDir(cwd, config, override) {
|
|
62
|
+
return resolveProjectPath(cwd, override ?? config.componentsDir);
|
|
63
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DEFAULT_FRAMEWORK, SUPPORTED_FRAMEWORKS } from '../constants/index.js';
|
|
2
|
+
import { CliError } from '../errors/index.js';
|
|
3
|
+
export function isSupportedFramework(value) {
|
|
4
|
+
return (typeof value === 'string' &&
|
|
5
|
+
SUPPORTED_FRAMEWORKS.includes(value));
|
|
6
|
+
}
|
|
7
|
+
export function assertFramework(value) {
|
|
8
|
+
if (value === undefined || value === null || value === '')
|
|
9
|
+
return DEFAULT_FRAMEWORK;
|
|
10
|
+
if (!isSupportedFramework(value)) {
|
|
11
|
+
throw new CliError(`Unsupported framework "${String(value)}". Available: ${SUPPORTED_FRAMEWORKS.join(', ')}.`);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CLI_NAME = "ui";
|
|
2
|
+
export declare const CONFIG_FILE_NAME = "components.json";
|
|
3
|
+
export declare const DEFAULT_COMPONENTS_DIR = "ui";
|
|
4
|
+
export declare const DEFAULT_STYLES: readonly ['styles-tokens', 'styles-base', 'styles-components', 'styles-utilities', 'styles-motion'];
|
|
5
|
+
export declare const COMPONENTS_SUBDIR = "components";
|
|
6
|
+
export declare const REGISTRY_DIR_NAME = "registry";
|
|
7
|
+
export declare const BUNDLED_REGISTRY_DIR_NAME = "registry-data";
|
|
8
|
+
export declare const MANIFEST_FILE_NAME = "component.json";
|
|
9
|
+
export declare const COMPONENT_NAME_PATTERN: RegExp;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const CLI_NAME = 'ui';
|
|
2
|
+
export const CONFIG_FILE_NAME = 'components.json';
|
|
3
|
+
export const DEFAULT_COMPONENTS_DIR = 'ui';
|
|
4
|
+
export const DEFAULT_STYLES = [
|
|
5
|
+
'styles-tokens',
|
|
6
|
+
'styles-base',
|
|
7
|
+
'styles-components',
|
|
8
|
+
'styles-utilities',
|
|
9
|
+
'styles-motion'
|
|
10
|
+
];
|
|
11
|
+
export const COMPONENTS_SUBDIR = 'components';
|
|
12
|
+
export const REGISTRY_DIR_NAME = 'registry';
|
|
13
|
+
export const BUNDLED_REGISTRY_DIR_NAME = 'registry-data';
|
|
14
|
+
export const MANIFEST_FILE_NAME = 'component.json';
|
|
15
|
+
export const COMPONENT_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CLI_NAME } from '../../constants/index.js';
|
|
2
|
+
import { getInstalledItems } from '../doctor.helpers.js';
|
|
3
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
4
|
+
registerDoctorCheck({
|
|
5
|
+
id: 'entries',
|
|
6
|
+
async run(context) {
|
|
7
|
+
if (context.files.length === 0) {
|
|
8
|
+
return {
|
|
9
|
+
summary: 'none detected',
|
|
10
|
+
problems: [
|
|
11
|
+
{
|
|
12
|
+
level: 'warn',
|
|
13
|
+
message: `No files found in ${context.displayDir}/. Run "${CLI_NAME} add button" first.`
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const items = await getInstalledItems(context);
|
|
19
|
+
return { summary: `${items.length} detected` };
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { toDisplayPath } from '../../helpers/path.helpers.js';
|
|
3
|
+
import { localNames } from '../doctor.helpers.js';
|
|
4
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
5
|
+
function parseIconExports(content) {
|
|
6
|
+
const names = new Set();
|
|
7
|
+
const pattern = /export\s*\{([^}]*)\}\s*from\s*['"][^'"]*lucide-react['"]/g;
|
|
8
|
+
for (const match of content.matchAll(pattern)) {
|
|
9
|
+
for (const name of localNames(match[1]))
|
|
10
|
+
names.add(name);
|
|
11
|
+
}
|
|
12
|
+
return names;
|
|
13
|
+
}
|
|
14
|
+
function parseIconImports(content) {
|
|
15
|
+
const names = new Set();
|
|
16
|
+
const pattern = /import\s*\{([^}]*)\}\s*from\s*['"][^'"]*\/icons\/[^'"]+['"]/g;
|
|
17
|
+
for (const match of content.matchAll(pattern)) {
|
|
18
|
+
for (const name of localNames(match[1]))
|
|
19
|
+
names.add(name);
|
|
20
|
+
}
|
|
21
|
+
return Array.from(names);
|
|
22
|
+
}
|
|
23
|
+
registerDoctorCheck({
|
|
24
|
+
id: 'icons',
|
|
25
|
+
async run(context) {
|
|
26
|
+
const iconFiles = context.files.filter(file => /[\\/]icons[\\/].*\.tsx?$/.test(file));
|
|
27
|
+
const iconFileSet = new Set(iconFiles);
|
|
28
|
+
const exported = new Set();
|
|
29
|
+
for (const file of iconFiles) {
|
|
30
|
+
const content = await readFile(file, 'utf8');
|
|
31
|
+
for (const name of parseIconExports(content))
|
|
32
|
+
exported.add(name);
|
|
33
|
+
}
|
|
34
|
+
let checked = 0;
|
|
35
|
+
const problems = [];
|
|
36
|
+
for (const file of context.sourceFiles) {
|
|
37
|
+
if (iconFileSet.has(file))
|
|
38
|
+
continue;
|
|
39
|
+
const content = await readFile(file, 'utf8');
|
|
40
|
+
for (const name of parseIconImports(content)) {
|
|
41
|
+
checked += 1;
|
|
42
|
+
if (!exported.has(name)) {
|
|
43
|
+
problems.push({
|
|
44
|
+
level: 'error',
|
|
45
|
+
message: `${toDisplayPath(context.cwd, file)} imports "${name}" not exported from ${context.displayDir}/icons`
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
summary: `${checked} imports checked${problems.length > 0 ? `, ${problems.length} missing` : ''}`,
|
|
52
|
+
problems
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, extname, join, resolve } from 'node:path';
|
|
3
|
+
import { toDisplayPath } from '../../helpers/path.helpers.js';
|
|
4
|
+
import { isFile } from '../doctor.helpers.js';
|
|
5
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
6
|
+
async function resolveImportTarget(specifier, fromFile) {
|
|
7
|
+
const base = resolve(dirname(fromFile), specifier);
|
|
8
|
+
const candidates = [base];
|
|
9
|
+
if (base.endsWith('.js')) {
|
|
10
|
+
candidates.push(base.replace(/\.js$/, '.ts'), base.replace(/\.js$/, '.tsx'), base.replace(/\.js$/, '.jsx'));
|
|
11
|
+
}
|
|
12
|
+
else if (!extname(base)) {
|
|
13
|
+
candidates.push(`${base}.ts`, `${base}.tsx`, `${base}.js`, join(base, 'index.ts'), join(base, 'index.tsx'));
|
|
14
|
+
}
|
|
15
|
+
for (const candidate of candidates) {
|
|
16
|
+
if (await isFile(candidate))
|
|
17
|
+
return candidate;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
registerDoctorCheck({
|
|
22
|
+
id: 'imports',
|
|
23
|
+
async run(context) {
|
|
24
|
+
let resolved = 0;
|
|
25
|
+
const problems = [];
|
|
26
|
+
for (const file of context.sourceFiles) {
|
|
27
|
+
const content = await readFile(file, 'utf8');
|
|
28
|
+
for (const match of content.matchAll(/from\s+['"](\.{1,2}\/[^'"]+)['"]/g)) {
|
|
29
|
+
if (await resolveImportTarget(match[1], file)) {
|
|
30
|
+
resolved += 1;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
problems.push({
|
|
34
|
+
level: 'error',
|
|
35
|
+
message: `${toDisplayPath(context.cwd, file)} → ${match[1]} (missing)`
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
summary: `${resolved} resolved${problems.length > 0 ? `, ${problems.length} broken` : ''}`,
|
|
42
|
+
problems
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { CLI_NAME } from '../../constants/index.js';
|
|
3
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
4
|
+
const MOTION_CLASS = /\b(?:motion-(?:color|fade|fade-slow|transform|press|lift|focus|icon-swap|ripple)|reveal-up|stagger-(?:children|words)|stagger-word|surface-enter|popup-enter|backdrop-enter|toast-enter|progress-life|tabs-indicator|sidebar-shell|sidebar-drawer|sidebar-label|sidebar-chevron|sidebar-highlight|shimmer|shake|check-draw)\b/;
|
|
5
|
+
registerDoctorCheck({
|
|
6
|
+
id: 'motion',
|
|
7
|
+
async run(context) {
|
|
8
|
+
const hasMotionStyles = context.files.some(file => /[\\/]styles[\\/]motion\.css$/.test(file));
|
|
9
|
+
if (hasMotionStyles)
|
|
10
|
+
return null;
|
|
11
|
+
const matches = await Promise.all(context.sourceFiles.map(async (file) => {
|
|
12
|
+
try {
|
|
13
|
+
return MOTION_CLASS.test(await readFile(file, 'utf8'));
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
if (!matches.some(Boolean))
|
|
20
|
+
return null;
|
|
21
|
+
const problems = [
|
|
22
|
+
{
|
|
23
|
+
level: 'warn',
|
|
24
|
+
message: `Motion utilities are in use but ${context.displayDir}/styles/motion.css is missing. Run "${CLI_NAME} add styles-motion".`,
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
return { summary: 'motion styles missing, 1 issue', problems };
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const FORBIDDEN_IMPORTS = /from\s+['"]((?:motion|framer-motion|motion\/react|@animate-ui\/react(?:\/[^'"]*)?|@base-ui\/react(?:\/[^'"]*)?|radix-ui(?:[^'"]*)?))['"]/;
|
|
31
|
+
const FORBIDDEN_HOOKS = /\b(useInView|useParallax|useReducedMotion|useScrolled)\s*\(/;
|
|
32
|
+
registerDoctorCheck({
|
|
33
|
+
id: 'motion-policy',
|
|
34
|
+
async run(context) {
|
|
35
|
+
const problems = [];
|
|
36
|
+
await Promise.all(context.sourceFiles.map(async (file) => {
|
|
37
|
+
let content;
|
|
38
|
+
try {
|
|
39
|
+
content = await readFile(file, 'utf8');
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const importMatch = content.match(FORBIDDEN_IMPORTS);
|
|
45
|
+
if (importMatch) {
|
|
46
|
+
problems.push({
|
|
47
|
+
level: 'error',
|
|
48
|
+
message: `${file} imports ${importMatch[1]}; animation libraries are not allowed. Use styles-motion utilities instead.`,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const hookMatch = content.match(FORBIDDEN_HOOKS);
|
|
52
|
+
if (hookMatch) {
|
|
53
|
+
problems.push({
|
|
54
|
+
level: 'error',
|
|
55
|
+
message: `${file} calls ${hookMatch[1]}; motion hooks are not allowed. Publish semantic state and animate with CSS.`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
if (problems.length === 0)
|
|
60
|
+
return null;
|
|
61
|
+
return {
|
|
62
|
+
summary: `motion policy violations, ${problems.length} issue${problems.length === 1 ? '' : 's'}`,
|
|
63
|
+
problems: problems.sort((a, b) => a.message.localeCompare(b.message)),
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { getInstalledItems, readJsonFile } from '../doctor.helpers.js';
|
|
3
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
4
|
+
function parsePeerSpec(spec) {
|
|
5
|
+
const at = spec.startsWith('@') ? spec.indexOf('@', 1) : spec.indexOf('@');
|
|
6
|
+
if (at === -1)
|
|
7
|
+
return { name: spec };
|
|
8
|
+
return { name: spec.slice(0, at), version: spec.slice(at + 1) };
|
|
9
|
+
}
|
|
10
|
+
function normalizeVersion(version) {
|
|
11
|
+
return version.trim().replace(/^[~^]/, '');
|
|
12
|
+
}
|
|
13
|
+
registerDoctorCheck({
|
|
14
|
+
id: 'peers',
|
|
15
|
+
async run(context) {
|
|
16
|
+
const items = await getInstalledItems(context);
|
|
17
|
+
const specs = Array.from(new Set(items.flatMap(item => item.peers))).map(parsePeerSpec);
|
|
18
|
+
let project = {};
|
|
19
|
+
try {
|
|
20
|
+
project = await readJsonFile(join(context.cwd, 'package.json'));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
project = {};
|
|
24
|
+
}
|
|
25
|
+
const installed = {
|
|
26
|
+
...project.dependencies,
|
|
27
|
+
...project.devDependencies
|
|
28
|
+
};
|
|
29
|
+
const problems = [];
|
|
30
|
+
let satisfied = 0;
|
|
31
|
+
for (const { name, version } of specs) {
|
|
32
|
+
const declared = installed[name];
|
|
33
|
+
const install = `${name}${version ? `@${version}` : ''}`;
|
|
34
|
+
if (typeof declared !== 'string') {
|
|
35
|
+
problems.push({
|
|
36
|
+
level: 'warn',
|
|
37
|
+
message: `${name} is not listed in package.json. Install it with: pnpm add ${install}`
|
|
38
|
+
});
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (version && normalizeVersion(declared) !== version) {
|
|
42
|
+
problems.push({
|
|
43
|
+
level: 'warn',
|
|
44
|
+
message: `${install} is required, but package.json declares ${declared}. Install it with: pnpm add ${install}`
|
|
45
|
+
});
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
satisfied += 1;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
summary: `${satisfied}/${specs.length} satisfied${problems.length > 0 ? ` (${problems.length} pending)` : ''}`,
|
|
52
|
+
problems
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|