@blankways/ui 0.1.0-alpha.1 → 0.2.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 +157 -139
- package/dist/cli/cli.options.js +21 -1
- package/dist/cli/cli.types.d.ts +1 -0
- package/dist/cli.js +2 -1
- package/dist/commands/add.command.d.ts +2 -0
- package/dist/commands/add.command.js +30 -82
- package/dist/commands/dev.command.d.ts +3 -0
- package/dist/commands/dev.command.js +76 -0
- package/dist/commands/doctor.command.js +12 -1
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/init.command.js +15 -10
- package/dist/commands/install.command.d.ts +2 -0
- package/dist/commands/install.command.js +36 -0
- package/dist/commands/list.command.js +10 -5
- package/dist/commands/registry.command.d.ts +2 -0
- package/dist/commands/registry.command.js +69 -0
- package/dist/commands/styles.command.d.ts +1 -2
- package/dist/commands/styles.command.js +15 -39
- package/dist/config/config.helpers.d.ts +4 -1
- package/dist/config/config.helpers.js +61 -8
- package/dist/constants/cli.constants.d.ts +14 -3
- package/dist/constants/cli.constants.js +14 -9
- package/dist/doctor/checks/barrels.check.d.ts +1 -0
- package/dist/doctor/checks/barrels.check.js +60 -0
- package/dist/doctor/checks/contracts.check.d.ts +1 -0
- package/dist/doctor/checks/contracts.check.js +45 -0
- package/dist/doctor/checks/icons.check.js +8 -3
- package/dist/doctor/checks/index.d.ts +3 -0
- package/dist/doctor/checks/index.js +3 -0
- package/dist/doctor/checks/motion.check.js +2 -2
- package/dist/doctor/checks/namespaces.check.d.ts +1 -0
- package/dist/doctor/checks/namespaces.check.js +76 -0
- package/dist/doctor/checks/themes.check.js +18 -40
- package/dist/doctor/doctor.helpers.js +5 -1
- package/dist/doctor/doctor.types.d.ts +4 -0
- package/dist/helpers/args.helpers.d.ts +2 -0
- package/dist/helpers/args.helpers.js +9 -0
- package/dist/helpers/barrels.helpers.d.ts +15 -0
- package/dist/helpers/barrels.helpers.js +157 -0
- package/dist/index.d.ts +12 -9
- package/dist/index.js +11 -9
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.js +2 -0
- package/dist/registry/lockfile.d.ts +18 -0
- package/dist/registry/lockfile.js +32 -0
- package/dist/registry/registry.helpers.d.ts +3 -13
- package/dist/registry/registry.helpers.js +30 -116
- package/dist/registry/registry.providers.d.ts +13 -0
- package/dist/registry/registry.providers.js +159 -0
- package/dist/registry/registry.service.d.ts +14 -0
- package/dist/registry/registry.service.js +126 -0
- package/dist/types/config.types.d.ts +29 -0
- package/dist/types/registry.types.d.ts +31 -0
- package/dist/types/registry.types.js +2 -0
- package/dist/ui-api/index.d.ts +16 -0
- package/dist/ui-api/index.js +30 -0
- package/dist/ui-api/ui-api.d.ts +18 -0
- package/dist/ui-api/ui-api.js +194 -0
- package/package.json +7 -5
- package/styles.css +16 -0
- package/dist/registry-data/README.md +0 -71
- package/dist/registry-data/avatar/Avatar.tsx +0 -64
- package/dist/registry-data/avatar/component.json +0 -30
- package/dist/registry-data/avatar/index.ts +0 -1
- package/dist/registry-data/badge/Badge.tsx +0 -76
- package/dist/registry-data/badge/component.json +0 -30
- package/dist/registry-data/badge/index.ts +0 -1
- package/dist/registry-data/brand-logo/BrandLogo.tsx +0 -24
- package/dist/registry-data/brand-logo/component.json +0 -26
- package/dist/registry-data/brand-logo/index.ts +0 -1
- package/dist/registry-data/button/Button.tsx +0 -76
- package/dist/registry-data/button/component.json +0 -33
- package/dist/registry-data/button/index.ts +0 -1
- package/dist/registry-data/button-link/ButtonLink.tsx +0 -83
- package/dist/registry-data/button-link/component.json +0 -33
- package/dist/registry-data/button-link/index.ts +0 -5
- package/dist/registry-data/button-styles/component.json +0 -19
- package/dist/registry-data/button-styles/index.ts +0 -45
- package/dist/registry-data/cn/cn.ts +0 -6
- package/dist/registry-data/cn/component.json +0 -16
- package/dist/registry-data/confirm-dialog/ConfirmDialog.tsx +0 -134
- package/dist/registry-data/confirm-dialog/component.json +0 -34
- package/dist/registry-data/confirm-dialog/index.ts +0 -1
- package/dist/registry-data/container/Container.tsx +0 -22
- package/dist/registry-data/container/component.json +0 -28
- package/dist/registry-data/container/index.ts +0 -1
- package/dist/registry-data/cursor-glow/CursorGlow.tsx +0 -29
- package/dist/registry-data/cursor-glow/component.json +0 -28
- package/dist/registry-data/cursor-glow/index.ts +0 -1
- package/dist/registry-data/dropdown-menu/DropdownMenu.tsx +0 -157
- package/dist/registry-data/dropdown-menu/component.json +0 -34
- package/dist/registry-data/dropdown-menu/index.ts +0 -5
- package/dist/registry-data/empty-state/EmptyState.tsx +0 -92
- package/dist/registry-data/empty-state/component.json +0 -30
- package/dist/registry-data/empty-state/index.ts +0 -5
- package/dist/registry-data/eyebrow/Eyebrow.tsx +0 -68
- package/dist/registry-data/eyebrow/component.json +0 -30
- package/dist/registry-data/eyebrow/index.ts +0 -1
- package/dist/registry-data/field-styles/component.json +0 -19
- package/dist/registry-data/field-styles/index.ts +0 -42
- package/dist/registry-data/form-dialog/FormDialog.tsx +0 -128
- package/dist/registry-data/form-dialog/component.json +0 -34
- package/dist/registry-data/form-dialog/index.ts +0 -1
- package/dist/registry-data/icons/component.json +0 -22
- package/dist/registry-data/icons/index.ts +0 -21
- package/dist/registry-data/icons-form/component.json +0 -17
- package/dist/registry-data/icons-form/index.ts +0 -1
- package/dist/registry-data/icons-sidebar/component.json +0 -17
- package/dist/registry-data/icons-sidebar/index.ts +0 -1
- package/dist/registry-data/icons-theme/component.json +0 -17
- package/dist/registry-data/icons-theme/index.ts +0 -1
- package/dist/registry-data/icons-toast/component.json +0 -17
- package/dist/registry-data/icons-toast/index.ts +0 -1
- package/dist/registry-data/info-dialog/InfoDialog.tsx +0 -119
- package/dist/registry-data/info-dialog/component.json +0 -36
- package/dist/registry-data/info-dialog/index.ts +0 -1
- package/dist/registry-data/input/Input.tsx +0 -96
- package/dist/registry-data/input/component.json +0 -33
- package/dist/registry-data/input/index.ts +0 -1
- package/dist/registry-data/multi-combobox/MultiCombobox.tsx +0 -205
- package/dist/registry-data/multi-combobox/component.json +0 -35
- package/dist/registry-data/multi-combobox/index.ts +0 -5
- package/dist/registry-data/remote-provider/RemoteProvider.tsx +0 -8
- package/dist/registry-data/remote-provider/component.json +0 -25
- package/dist/registry-data/remote-provider/index.ts +0 -3
- package/dist/registry-data/reveal/Reveal.tsx +0 -22
- package/dist/registry-data/reveal/component.json +0 -30
- package/dist/registry-data/reveal/index.ts +0 -1
- package/dist/registry-data/section/Section.tsx +0 -80
- package/dist/registry-data/section/component.json +0 -30
- package/dist/registry-data/section/index.ts +0 -1
- package/dist/registry-data/section-heading/SectionHeading.tsx +0 -105
- package/dist/registry-data/section-heading/component.json +0 -32
- package/dist/registry-data/section-heading/index.ts +0 -1
- package/dist/registry-data/select/Select.tsx +0 -197
- package/dist/registry-data/select/component.json +0 -34
- package/dist/registry-data/select/index.ts +0 -1
- package/dist/registry-data/sidebar/Sidebar.tsx +0 -432
- package/dist/registry-data/sidebar/SidebarCollapsible.tsx +0 -77
- package/dist/registry-data/sidebar/SidebarParts.tsx +0 -373
- package/dist/registry-data/sidebar/component.json +0 -47
- package/dist/registry-data/sidebar/index.ts +0 -4
- package/dist/registry-data/sidebar/useSidebar.ts +0 -29
- package/dist/registry-data/styles-base/component.json +0 -19
- package/dist/registry-data/styles-base/index.css +0 -67
- package/dist/registry-data/styles-components/component.json +0 -19
- package/dist/registry-data/styles-components/index.css +0 -30
- package/dist/registry-data/styles-motion/component.json +0 -20
- package/dist/registry-data/styles-motion/index.css +0 -381
- package/dist/registry-data/styles-tokens/component.json +0 -17
- package/dist/registry-data/styles-tokens/index.css +0 -77
- package/dist/registry-data/styles-utilities/component.json +0 -19
- package/dist/registry-data/styles-utilities/index.css +0 -29
- package/dist/registry-data/switch/Switch.tsx +0 -91
- package/dist/registry-data/switch/component.json +0 -34
- package/dist/registry-data/switch/index.ts +0 -1
- package/dist/registry-data/tabs/Tabs.tsx +0 -226
- package/dist/registry-data/tabs/component.json +0 -32
- package/dist/registry-data/tabs/index.ts +0 -1
- package/dist/registry-data/textarea/Textarea.tsx +0 -94
- package/dist/registry-data/textarea/component.json +0 -33
- package/dist/registry-data/textarea/index.ts +0 -1
- package/dist/registry-data/theme-core/component.json +0 -17
- package/dist/registry-data/theme-core/theme.ts +0 -84
- package/dist/registry-data/theme-dark/component.json +0 -19
- package/dist/registry-data/theme-dark/index.ts +0 -7
- package/dist/registry-data/theme-light/component.json +0 -19
- package/dist/registry-data/theme-light/index.ts +0 -7
- package/dist/registry-data/theme-provider/ThemeContext.tsx +0 -177
- package/dist/registry-data/theme-provider/component.json +0 -30
- package/dist/registry-data/theme-provider/index.ts +0 -2
- package/dist/registry-data/theme-selector/ThemeSelector.tsx +0 -269
- package/dist/registry-data/theme-selector/component.json +0 -35
- package/dist/registry-data/theme-selector/selector.ts +0 -1
- package/dist/registry-data/theme-system/component.json +0 -19
- package/dist/registry-data/theme-system/index.ts +0 -7
- package/dist/registry-data/theme-toggle/ThemeToggle.tsx +0 -71
- package/dist/registry-data/theme-toggle/component.json +0 -31
- package/dist/registry-data/theme-toggle/toggle.ts +0 -1
- package/dist/registry-data/toast/Toast.tsx +0 -260
- package/dist/registry-data/toast/ToastTypeIcon.tsx +0 -83
- package/dist/registry-data/toast/component.json +0 -43
- package/dist/registry-data/toast/index.ts +0 -3
- package/dist/registry-data/toast/useToast.ts +0 -47
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
3
|
+
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
4
|
+
import { CLI_NAME, UI_DEV_REGISTRIES_FIELD, UI_REGISTRY_FIELD } from '../constants/index.js';
|
|
5
|
+
import { CliError } from '../errors/index.js';
|
|
6
|
+
import { getStringFlag } from '../helpers/index.js';
|
|
7
|
+
import { install } from '../ui-api/index.js';
|
|
8
|
+
async function isFile(path) {
|
|
9
|
+
try {
|
|
10
|
+
return (await stat(path)).isFile();
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function readStringArray(value, field) {
|
|
17
|
+
if (value === undefined)
|
|
18
|
+
return [];
|
|
19
|
+
if (!Array.isArray(value) || value.some(entry => typeof entry !== 'string')) {
|
|
20
|
+
throw new CliError(`package.json: "${field}" must be an array of strings.`);
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
/** Mounts a throwaway app where dev-only registries stand in for peers. */
|
|
25
|
+
export async function devCommand(context) {
|
|
26
|
+
const packageRoot = context.cwd ? resolve(context.cwd) : process.cwd();
|
|
27
|
+
const manifestPath = join(packageRoot, 'package.json');
|
|
28
|
+
if (!(await isFile(manifestPath))) {
|
|
29
|
+
throw new CliError(`package.json not found at ${packageRoot}.`);
|
|
30
|
+
}
|
|
31
|
+
const manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
|
|
32
|
+
if (manifest[UI_REGISTRY_FIELD] === undefined) {
|
|
33
|
+
throw new CliError(`package.json at ${packageRoot} does not declare "${UI_REGISTRY_FIELD}".`);
|
|
34
|
+
}
|
|
35
|
+
const appDir = resolve(packageRoot, getStringFlag(context.flags, 'app') ?? '.ui-dev');
|
|
36
|
+
const devRegistries = readStringArray(manifest[UI_DEV_REGISTRIES_FIELD], UI_DEV_REGISTRIES_FIELD).map(specifier => specifier.startsWith('.') || isAbsolute(specifier)
|
|
37
|
+
? resolve(packageRoot, specifier)
|
|
38
|
+
: specifier);
|
|
39
|
+
const self = relative(appDir, packageRoot) || '.';
|
|
40
|
+
const selfSpecifier = self.startsWith('.') ? self : `./${self}`;
|
|
41
|
+
const registries = Array.from(new Set([selfSpecifier, ...devRegistries]));
|
|
42
|
+
await mkdir(appDir, { recursive: true });
|
|
43
|
+
await writeFile(join(appDir, 'components.json'), `${JSON.stringify({
|
|
44
|
+
componentsDir: 'ui',
|
|
45
|
+
framework: context.framework ?? 'react',
|
|
46
|
+
overwrite: true,
|
|
47
|
+
registries,
|
|
48
|
+
exposure: 'full'
|
|
49
|
+
}, null, 2)}\n`, 'utf8');
|
|
50
|
+
const packagePath = join(appDir, 'package.json');
|
|
51
|
+
if (!(await isFile(packagePath))) {
|
|
52
|
+
await writeFile(packagePath, `${JSON.stringify({
|
|
53
|
+
name: '@blankways/ui-dev-app',
|
|
54
|
+
private: true,
|
|
55
|
+
type: 'module',
|
|
56
|
+
dependencies: { react: '^19.0.0' }
|
|
57
|
+
}, null, 2)}\n`, 'utf8');
|
|
58
|
+
}
|
|
59
|
+
const globalCss = join(appDir, 'src', 'app', 'globals.css');
|
|
60
|
+
await mkdir(join(globalCss, '..'), { recursive: true });
|
|
61
|
+
if (!(await isFile(globalCss))) {
|
|
62
|
+
await writeFile(globalCss, '@import "tailwindcss";\n', 'utf8');
|
|
63
|
+
}
|
|
64
|
+
const result = await install({ cwd: appDir, force: true, globalCss: 'src/app/globals.css' });
|
|
65
|
+
console.log(`${CLI_NAME} dev app: ${appDir}`);
|
|
66
|
+
console.log(`Registries: ${registries.join(', ')}`);
|
|
67
|
+
console.log(`Added ${result.added.length} file(s), ${result.entries.length} entries.`);
|
|
68
|
+
}
|
|
69
|
+
registerCliCommand({
|
|
70
|
+
name: 'dev',
|
|
71
|
+
description: 'Create a local dev app using uiDevRegistries without publishing them',
|
|
72
|
+
usage: 'dev [--app <path>]',
|
|
73
|
+
order: 12,
|
|
74
|
+
examples: [`${CLI_NAME} dev`, `${CLI_NAME} dev --app ../playground`],
|
|
75
|
+
run: context => devCommand(context)
|
|
76
|
+
});
|
|
@@ -7,6 +7,8 @@ import { CliError } from '../errors/index.js';
|
|
|
7
7
|
import { toDisplayPath } from '../helpers/path.helpers.js';
|
|
8
8
|
import '../doctor/index.js';
|
|
9
9
|
import { getDoctorChecks } from '../doctor/doctor.registry.js';
|
|
10
|
+
import { readLockfile } from '../registry/lockfile.js';
|
|
11
|
+
import { loadRegistryProviders } from '../registry/registry.providers.js';
|
|
10
12
|
async function walkFiles(directory) {
|
|
11
13
|
const files = [];
|
|
12
14
|
let entries;
|
|
@@ -45,6 +47,10 @@ export async function doctorCommand(options = {}) {
|
|
|
45
47
|
}
|
|
46
48
|
const componentsDir = resolveComponentsDir(cwd, config, options.componentsDir);
|
|
47
49
|
const files = await walkFiles(componentsDir);
|
|
50
|
+
const registries = options.registries ?? config.registries;
|
|
51
|
+
const providers = await loadRegistryProviders(cwd, registries, config.framework);
|
|
52
|
+
const items = providers.flatMap(provider => provider.items);
|
|
53
|
+
const lock = await readLockfile(cwd);
|
|
48
54
|
const reports = [];
|
|
49
55
|
for (const check of getDoctorChecks()) {
|
|
50
56
|
const result = await check.run({
|
|
@@ -54,7 +60,11 @@ export async function doctorCommand(options = {}) {
|
|
|
54
60
|
files,
|
|
55
61
|
sourceFiles: files.filter(file => /\.tsx?$/.test(file)),
|
|
56
62
|
framework: config.framework,
|
|
57
|
-
|
|
63
|
+
registries,
|
|
64
|
+
globalCss: options.globalCss,
|
|
65
|
+
items,
|
|
66
|
+
providers,
|
|
67
|
+
lock
|
|
58
68
|
});
|
|
59
69
|
if (result)
|
|
60
70
|
reports.push({ id: check.id, result });
|
|
@@ -87,6 +97,7 @@ registerCliCommand({
|
|
|
87
97
|
run: context => doctorCommand({
|
|
88
98
|
cwd: context.cwd,
|
|
89
99
|
componentsDir: context.componentsDir,
|
|
100
|
+
registries: context.registries,
|
|
90
101
|
globalCss: context.globalCss
|
|
91
102
|
})
|
|
92
103
|
});
|
package/dist/commands/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './add.command.js';
|
|
2
|
+
export * from './dev.command.js';
|
|
2
3
|
export * from './doctor.command.js';
|
|
3
4
|
export * from './init.command.js';
|
|
5
|
+
export * from './install.command.js';
|
|
4
6
|
export * from './list.command.js';
|
|
5
7
|
export * from './meta.command.js';
|
|
8
|
+
export * from './registry.command.js';
|
|
6
9
|
export * from './styles.command.js';
|
package/dist/commands/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './add.command.js';
|
|
2
|
+
export * from './dev.command.js';
|
|
2
3
|
export * from './doctor.command.js';
|
|
3
4
|
export * from './init.command.js';
|
|
5
|
+
export * from './install.command.js';
|
|
4
6
|
export * from './list.command.js';
|
|
5
7
|
export * from './meta.command.js';
|
|
8
|
+
export * from './registry.command.js';
|
|
6
9
|
export * from './styles.command.js';
|
|
@@ -2,29 +2,33 @@ import { mkdir } from 'node:fs/promises';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
4
4
|
import { assertFramework, createDefaultConfig, resolveComponentsDir, writeConfig } from '../config/index.js';
|
|
5
|
-
import { CLI_NAME, DEFAULT_COMPONENTS_DIR
|
|
5
|
+
import { CLI_NAME, DEFAULT_COMPONENTS_DIR } from '../constants/index.js';
|
|
6
6
|
import { toDisplayPath } from '../helpers/path.helpers.js';
|
|
7
|
-
import {
|
|
7
|
+
import { install } from '../ui-api/index.js';
|
|
8
|
+
import { printInstallResult } from './add.command.js';
|
|
8
9
|
export async function initCommand(options = {}) {
|
|
9
10
|
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
10
11
|
const framework = assertFramework(options.framework ?? options.variant);
|
|
11
|
-
const
|
|
12
|
+
const registries = Array.from(new Set(options.registries ?? []));
|
|
13
|
+
const config = createDefaultConfig(options.componentsDir ?? DEFAULT_COMPONENTS_DIR, framework, registries);
|
|
12
14
|
const componentsDir = resolveComponentsDir(cwd, config);
|
|
13
15
|
await writeConfig(cwd, config, Boolean(options.force));
|
|
14
16
|
await mkdir(componentsDir, { recursive: true });
|
|
15
17
|
console.log('Created components.json');
|
|
16
18
|
console.log(`Framework: ${framework}`);
|
|
19
|
+
console.log(`Exposure: ${config.exposure}`);
|
|
17
20
|
console.log(`Created ${toDisplayPath(cwd, componentsDir)}/`);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (registries.length === 0) {
|
|
22
|
+
console.log(`No registries configured. Add one with "${CLI_NAME} registry add <package>".`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const result = await install({ cwd, exposure: 'full', force: Boolean(options.force) });
|
|
26
|
+
printInstallResult(result, false);
|
|
27
|
+
console.log(`\nLockfile: ${toDisplayPath(cwd, resolve(cwd, 'ui.lock.json'))}`);
|
|
24
28
|
}
|
|
25
29
|
registerCliCommand({
|
|
26
30
|
name: 'init',
|
|
27
|
-
description: 'Create components.json
|
|
31
|
+
description: 'Create components.json and install the full composition of every registry',
|
|
28
32
|
usage: 'init [options]',
|
|
29
33
|
order: 10,
|
|
30
34
|
examples: [`${CLI_NAME} init --framework react`],
|
|
@@ -33,6 +37,7 @@ registerCliCommand({
|
|
|
33
37
|
componentsDir: context.componentsDir,
|
|
34
38
|
framework: context.framework,
|
|
35
39
|
variant: context.variant,
|
|
40
|
+
registries: context.registries,
|
|
36
41
|
force: context.force
|
|
37
42
|
})
|
|
38
43
|
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
2
|
+
import { CLI_NAME } from '../constants/index.js';
|
|
3
|
+
import { toDisplayPath } from '../helpers/path.helpers.js';
|
|
4
|
+
import { install } from '../ui-api/index.js';
|
|
5
|
+
import { printInstallResult } from './add.command.js';
|
|
6
|
+
export async function installCommand(context) {
|
|
7
|
+
const result = await install({
|
|
8
|
+
cwd: context.cwd,
|
|
9
|
+
componentsDir: context.componentsDir,
|
|
10
|
+
registries: context.registries,
|
|
11
|
+
exposure: context.flags.exposure === 'full' || context.flags.exposure === 'incremental'
|
|
12
|
+
? context.flags.exposure
|
|
13
|
+
: undefined,
|
|
14
|
+
force: context.force,
|
|
15
|
+
dryRun: context.dryRun,
|
|
16
|
+
frozen: context.flags.frozen === true,
|
|
17
|
+
installPeers: context.flags.installPeers === true,
|
|
18
|
+
globalCss: context.globalCss
|
|
19
|
+
});
|
|
20
|
+
printInstallResult(result, context.dryRun);
|
|
21
|
+
console.log(`\nLocked entries: ${result.entries.length}`);
|
|
22
|
+
if (context.cwd)
|
|
23
|
+
console.log(`Project: ${toDisplayPath(process.cwd(), context.cwd)}`);
|
|
24
|
+
}
|
|
25
|
+
registerCliCommand({
|
|
26
|
+
name: 'install',
|
|
27
|
+
description: 'Materialize the configured registries and refresh generated barrels',
|
|
28
|
+
usage: 'install [options]',
|
|
29
|
+
order: 15,
|
|
30
|
+
examples: [
|
|
31
|
+
`${CLI_NAME} install`,
|
|
32
|
+
`${CLI_NAME} install --frozen`,
|
|
33
|
+
`${CLI_NAME} install --dry-run`
|
|
34
|
+
],
|
|
35
|
+
run: context => installCommand(context)
|
|
36
|
+
});
|
|
@@ -16,12 +16,15 @@ export async function listCommand(options = {}) {
|
|
|
16
16
|
const config = await readConfig(cwd);
|
|
17
17
|
const framework = options.framework ?? config?.framework ?? DEFAULT_FRAMEWORK;
|
|
18
18
|
const kind = assertValidRegistryKind(options.kind);
|
|
19
|
-
const
|
|
19
|
+
const registries = options.registries ?? config?.registries ?? [];
|
|
20
|
+
const items = await listRegistryItems({ cwd, framework, registries });
|
|
20
21
|
const visible = items.filter(item => !item.hidden && (kind === undefined || item.kind === kind));
|
|
21
22
|
if (visible.length === 0) {
|
|
22
|
-
console.log(
|
|
23
|
-
? `No
|
|
24
|
-
:
|
|
23
|
+
console.log(registries.length === 0
|
|
24
|
+
? `No registries configured. Add one with "${CLI_NAME} registry add <package>".`
|
|
25
|
+
: kind
|
|
26
|
+
? `No "${kind}" entries available for ${framework} yet.`
|
|
27
|
+
: `No entries available for ${framework} yet.`);
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
27
30
|
console.log(`Available ${framework} registry entries (${visible.length}):`);
|
|
@@ -36,6 +39,7 @@ export async function listCommand(options = {}) {
|
|
|
36
39
|
}
|
|
37
40
|
function printItem(item) {
|
|
38
41
|
console.log(` ${item.name.padEnd(18)} ${item.description}`);
|
|
42
|
+
console.log(`${' '.repeat(21)}registry: ${item.registry}`);
|
|
39
43
|
if (item.dependencies.length > 0) {
|
|
40
44
|
console.log(`${' '.repeat(21)}deps: ${item.dependencies.join(', ')}`);
|
|
41
45
|
}
|
|
@@ -49,6 +53,7 @@ registerCliCommand({
|
|
|
49
53
|
examples: [`${CLI_NAME} list --kind icon`],
|
|
50
54
|
run: context => listCommand({
|
|
51
55
|
cwd: context.cwd,
|
|
52
|
-
kind: context.kind
|
|
56
|
+
kind: context.kind,
|
|
57
|
+
registries: context.registries
|
|
53
58
|
})
|
|
54
59
|
});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
3
|
+
import { readConfig, updateConfig } from '../config/index.js';
|
|
4
|
+
import { CLI_NAME } from '../constants/index.js';
|
|
5
|
+
import { CliError } from '../errors/index.js';
|
|
6
|
+
import { loadRegistryProvider } from '../registry/index.js';
|
|
7
|
+
export async function registryCommand(options = {}) {
|
|
8
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
9
|
+
const config = await readConfig(cwd);
|
|
10
|
+
if (!config) {
|
|
11
|
+
throw new CliError(`components.json not found. Run "${CLI_NAME} init" first.`);
|
|
12
|
+
}
|
|
13
|
+
const names = options.names ?? [];
|
|
14
|
+
const subcommand = names[0] ?? 'list';
|
|
15
|
+
const values = names.slice(1);
|
|
16
|
+
if (subcommand === 'add') {
|
|
17
|
+
if (values.length === 0) {
|
|
18
|
+
throw new CliError('Usage: ui registry add <package...>');
|
|
19
|
+
}
|
|
20
|
+
const next = Array.from(new Set([...config.registries, ...values]));
|
|
21
|
+
const providers = [];
|
|
22
|
+
const ids = new Map();
|
|
23
|
+
for (const specifier of next) {
|
|
24
|
+
const provider = await loadRegistryProvider(cwd, specifier, config.framework);
|
|
25
|
+
const owner = ids.get(provider.id);
|
|
26
|
+
if (owner) {
|
|
27
|
+
throw new CliError(`Duplicate registry id "${provider.id}" declared by "${owner}" and "${specifier}".`);
|
|
28
|
+
}
|
|
29
|
+
ids.set(provider.id, specifier);
|
|
30
|
+
providers.push(provider);
|
|
31
|
+
}
|
|
32
|
+
config.registries = next;
|
|
33
|
+
await updateConfig(cwd, config);
|
|
34
|
+
console.log(`Registries: ${providers.map(provider => `${provider.specifier} (${provider.id})`).join(', ') || 'none'}`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (subcommand === 'remove') {
|
|
38
|
+
if (values.length === 0) {
|
|
39
|
+
throw new CliError('Usage: ui registry remove <package...>');
|
|
40
|
+
}
|
|
41
|
+
const remove = new Set(values);
|
|
42
|
+
config.registries = config.registries.filter(specifier => !remove.has(specifier));
|
|
43
|
+
await updateConfig(cwd, config);
|
|
44
|
+
console.log(`Registries: ${config.registries.join(', ') || 'none'}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (subcommand === 'list') {
|
|
48
|
+
if (config.registries.length === 0) {
|
|
49
|
+
console.log(`No registries configured. Add one with "${CLI_NAME} registry add <package>".`);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
console.log('Configured registries:');
|
|
53
|
+
for (const specifier of config.registries)
|
|
54
|
+
console.log(` ${specifier}`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
throw new CliError(`Unknown registry command "${subcommand}". Use add, remove or list.`);
|
|
58
|
+
}
|
|
59
|
+
registerCliCommand({
|
|
60
|
+
name: 'registry',
|
|
61
|
+
description: 'Manage the external registry packages used by this project',
|
|
62
|
+
usage: 'registry <add|remove|list> [package...]',
|
|
63
|
+
order: 60,
|
|
64
|
+
examples: [
|
|
65
|
+
`${CLI_NAME} registry add @blankways/react-registry`,
|
|
66
|
+
`${CLI_NAME} registry list`
|
|
67
|
+
],
|
|
68
|
+
run: context => registryCommand({ cwd: context.cwd, names: context.names })
|
|
69
|
+
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { CliContext } from '../cli/cli.types.js';
|
|
2
|
-
import { type StylesSyncResult } from '../helpers/styles.helpers.js';
|
|
3
2
|
import type { StylesOptions } from '../types/config.types.js';
|
|
3
|
+
/** Kept as a compatibility alias; barrels are regenerated by every install. */
|
|
4
4
|
export declare function stylesLinkCommand(options?: StylesOptions): Promise<void>;
|
|
5
|
-
export declare function printStylesSync(result: StylesSyncResult, cwd: string, dryRun: boolean): void;
|
|
6
5
|
export declare function stylesCommand(context: CliContext): Promise<void>;
|
|
@@ -1,55 +1,31 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
3
|
-
import { readConfig, resolveComponentsDir } from '../config/index.js';
|
|
4
3
|
import { CLI_NAME } from '../constants/index.js';
|
|
5
|
-
import { CliError } from '../errors/index.js';
|
|
6
4
|
import { toDisplayPath } from '../helpers/path.helpers.js';
|
|
7
|
-
import {
|
|
5
|
+
import { sync } from '../ui-api/index.js';
|
|
6
|
+
/** Kept as a compatibility alias; barrels are regenerated by every install. */
|
|
8
7
|
export async function stylesLinkCommand(options = {}) {
|
|
9
8
|
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
10
|
-
const
|
|
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({
|
|
9
|
+
const result = await sync({
|
|
16
10
|
cwd,
|
|
17
|
-
|
|
18
|
-
globalCss: options.globalCss
|
|
19
|
-
dryRun: options.dryRun
|
|
11
|
+
dryRun: options.dryRun,
|
|
12
|
+
globalCss: options.globalCss
|
|
20
13
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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}`);
|
|
14
|
+
console.log(`${CLI_NAME} styles link is deprecated: install and sync now happen together.`);
|
|
15
|
+
if (result.barrels.length === 0) {
|
|
16
|
+
console.log('No themes or runtimes installed yet.');
|
|
41
17
|
return;
|
|
42
18
|
}
|
|
43
|
-
|
|
44
|
-
console.log(
|
|
45
|
-
return;
|
|
19
|
+
for (const barrel of result.barrels) {
|
|
20
|
+
console.log(`Barrel: ${toDisplayPath(cwd, barrel)}`);
|
|
46
21
|
}
|
|
47
|
-
|
|
22
|
+
if (result.css)
|
|
23
|
+
console.log(`Global CSS: ${toDisplayPath(cwd, result.css)}`);
|
|
48
24
|
}
|
|
49
25
|
export async function stylesCommand(context) {
|
|
50
26
|
const subcommand = context.names[0] ?? 'link';
|
|
51
27
|
if (subcommand !== 'link') {
|
|
52
|
-
throw new
|
|
28
|
+
throw new Error(`Unknown styles command "${subcommand}". Run "${CLI_NAME} --help".`);
|
|
53
29
|
}
|
|
54
30
|
await stylesLinkCommand({
|
|
55
31
|
cwd: context.cwd,
|
|
@@ -60,9 +36,9 @@ export async function stylesCommand(context) {
|
|
|
60
36
|
}
|
|
61
37
|
registerCliCommand({
|
|
62
38
|
name: 'styles',
|
|
63
|
-
description: '
|
|
39
|
+
description: '[deprecated] Regenerate barrels; use install instead',
|
|
64
40
|
usage: 'styles link [options]',
|
|
65
41
|
order: 30,
|
|
66
|
-
examples: [`${CLI_NAME} styles link
|
|
42
|
+
examples: [`${CLI_NAME} styles link`],
|
|
67
43
|
run: context => stylesCommand(context)
|
|
68
44
|
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type SupportedFramework } from '../constants/index.js';
|
|
2
2
|
import type { ComponentsConfig } from '../types/config.types.js';
|
|
3
|
+
import type { ExposureMode } from '../types/registry.types.js';
|
|
3
4
|
export declare function getConfigPath(cwd: string): string;
|
|
4
|
-
export declare function createDefaultConfig(componentsDir?: string, framework?: SupportedFramework): ComponentsConfig;
|
|
5
|
+
export declare function createDefaultConfig(componentsDir?: string, framework?: SupportedFramework, registries?: string[], exposure?: ExposureMode): ComponentsConfig;
|
|
5
6
|
export declare function readConfig(cwd: string): Promise<ComponentsConfig | null>;
|
|
6
7
|
export declare function writeConfig(cwd: string, config: ComponentsConfig, force?: boolean): Promise<void>;
|
|
8
|
+
/** Persists changes to an existing components.json without requiring --force. */
|
|
9
|
+
export declare function updateConfig(cwd: string, config: ComponentsConfig): Promise<void>;
|
|
7
10
|
export declare function resolveComponentsDir(cwd: string, config: ComponentsConfig, override?: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
-
import { CONFIG_FILE_NAME, DEFAULT_COMPONENTS_DIR, DEFAULT_FRAMEWORK } from '../constants/index.js';
|
|
3
|
+
import { CLI_NAME, CONFIG_FILE_NAME, DEFAULT_COMPONENTS_DIR, DEFAULT_EXPOSURE, DEFAULT_FRAMEWORK } from '../constants/index.js';
|
|
4
4
|
import { CliError } from '../errors/index.js';
|
|
5
5
|
import { resolveProjectPath } from '../helpers/path.helpers.js';
|
|
6
6
|
import { assertFramework } from './framework.helpers.js';
|
|
@@ -16,13 +16,47 @@ async function pathExists(path) {
|
|
|
16
16
|
export function getConfigPath(cwd) {
|
|
17
17
|
return join(cwd, CONFIG_FILE_NAME);
|
|
18
18
|
}
|
|
19
|
-
export function createDefaultConfig(componentsDir = DEFAULT_COMPONENTS_DIR, framework = DEFAULT_FRAMEWORK) {
|
|
19
|
+
export function createDefaultConfig(componentsDir = DEFAULT_COMPONENTS_DIR, framework = DEFAULT_FRAMEWORK, registries = [], exposure = DEFAULT_EXPOSURE) {
|
|
20
20
|
return {
|
|
21
21
|
componentsDir,
|
|
22
22
|
framework,
|
|
23
|
-
overwrite: false
|
|
23
|
+
overwrite: false,
|
|
24
|
+
registries: [...registries],
|
|
25
|
+
exposure
|
|
24
26
|
};
|
|
25
27
|
}
|
|
28
|
+
function parseRegistries(value) {
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
return [];
|
|
31
|
+
if (!Array.isArray(value) || value.some(entry => typeof entry !== 'string' || entry.trim() === '')) {
|
|
32
|
+
throw new CliError(`${CONFIG_FILE_NAME}: "registries" must be an array of non-empty strings.`);
|
|
33
|
+
}
|
|
34
|
+
return Array.from(new Set(value.map(entry => entry.trim())));
|
|
35
|
+
}
|
|
36
|
+
function parseExposure(value) {
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
return DEFAULT_EXPOSURE;
|
|
39
|
+
if (value !== 'full' && value !== 'incremental') {
|
|
40
|
+
throw new CliError(`${CONFIG_FILE_NAME}: "exposure" must be "full" or "incremental".`);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
function parseThemeOrder(value) {
|
|
45
|
+
if (value === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
if (!Array.isArray(value) || value.some(entry => typeof entry !== 'string' || entry.trim() === '')) {
|
|
48
|
+
throw new CliError(`${CONFIG_FILE_NAME}: "themeOrder" must be an array of non-empty strings.`);
|
|
49
|
+
}
|
|
50
|
+
return value.map(entry => entry.trim());
|
|
51
|
+
}
|
|
52
|
+
function parseEntries(value) {
|
|
53
|
+
if (value === undefined)
|
|
54
|
+
return undefined;
|
|
55
|
+
if (!Array.isArray(value) || value.some(entry => typeof entry !== 'string' || entry.trim() === '')) {
|
|
56
|
+
throw new CliError(`${CONFIG_FILE_NAME}: "entries" must be an array of non-empty strings.`);
|
|
57
|
+
}
|
|
58
|
+
return Array.from(new Set(value.map(entry => entry.trim())));
|
|
59
|
+
}
|
|
26
60
|
export async function readConfig(cwd) {
|
|
27
61
|
const configPath = getConfigPath(cwd);
|
|
28
62
|
if (!(await pathExists(configPath)))
|
|
@@ -48,15 +82,34 @@ export async function readConfig(cwd) {
|
|
|
48
82
|
if (typeof overwrite !== 'boolean') {
|
|
49
83
|
throw new CliError(`${CONFIG_FILE_NAME}: "overwrite" must be a boolean.`);
|
|
50
84
|
}
|
|
51
|
-
|
|
85
|
+
const entries = parseEntries(record.entries);
|
|
86
|
+
const themeOrder = parseThemeOrder(record.themeOrder);
|
|
87
|
+
return {
|
|
88
|
+
componentsDir,
|
|
89
|
+
framework,
|
|
90
|
+
overwrite,
|
|
91
|
+
registries: parseRegistries(record.registries),
|
|
92
|
+
exposure: parseExposure(record.exposure),
|
|
93
|
+
...(entries ? { entries } : {}),
|
|
94
|
+
...(themeOrder ? { themeOrder } : {})
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
async function saveConfig(cwd, config) {
|
|
98
|
+
await mkdir(cwd, { recursive: true });
|
|
99
|
+
await writeFile(getConfigPath(cwd), `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
|
52
100
|
}
|
|
53
101
|
export async function writeConfig(cwd, config, force = false) {
|
|
54
|
-
|
|
55
|
-
if ((await pathExists(configPath)) && !force) {
|
|
102
|
+
if ((await pathExists(getConfigPath(cwd))) && !force) {
|
|
56
103
|
throw new CliError(`${CONFIG_FILE_NAME} already exists. Use --force to overwrite.`);
|
|
57
104
|
}
|
|
58
|
-
await
|
|
59
|
-
|
|
105
|
+
await saveConfig(cwd, config);
|
|
106
|
+
}
|
|
107
|
+
/** Persists changes to an existing components.json without requiring --force. */
|
|
108
|
+
export async function updateConfig(cwd, config) {
|
|
109
|
+
if (!(await pathExists(getConfigPath(cwd)))) {
|
|
110
|
+
throw new CliError(`${CONFIG_FILE_NAME} not found. Run "${CLI_NAME} init" first.`);
|
|
111
|
+
}
|
|
112
|
+
await saveConfig(cwd, config);
|
|
60
113
|
}
|
|
61
114
|
export function resolveComponentsDir(cwd, config, override) {
|
|
62
115
|
return resolveProjectPath(cwd, override ?? config.componentsDir);
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
export declare const CLI_NAME = "ui";
|
|
2
2
|
export declare const CONFIG_FILE_NAME = "components.json";
|
|
3
3
|
export declare const DEFAULT_COMPONENTS_DIR = "ui";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const DEFAULT_EXPOSURE: 'full';
|
|
5
|
+
export declare const LOCK_FILE_NAME = "ui.lock.json";
|
|
5
6
|
export declare const COMPONENTS_SUBDIR = "components";
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const THEMES_SUBDIR = "themes";
|
|
8
|
+
export declare const RUNTIMES_SUBDIR = "runtimes";
|
|
8
9
|
export declare const MANIFEST_FILE_NAME = "component.json";
|
|
9
10
|
export declare const COMPONENT_NAME_PATTERN: RegExp;
|
|
11
|
+
/** Namespace slug used to scope every target of a registry package. */
|
|
12
|
+
export declare const UI_REGISTRY_ID_FIELD = "uiRegistryId";
|
|
13
|
+
/** Minimum @blankways/ui version required by a registry package. */
|
|
14
|
+
export declare const UI_REQUIRES_FIELD = "uiRequires";
|
|
15
|
+
/** Dev-only registry packages used while authoring this registry. */
|
|
16
|
+
export declare const UI_DEV_REGISTRIES_FIELD = "uiDevRegistries";
|
|
17
|
+
/** Base stylesheet owned by @blankways/ui; imported, never copied. */
|
|
18
|
+
export declare const BASE_STYLE_IMPORT = "@blankways/ui/styles.css";
|
|
19
|
+
/** package.json field that points to a registry directory inside a package. */
|
|
20
|
+
export declare const UI_REGISTRY_FIELD = "uiRegistry";
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
export const CLI_NAME = 'ui';
|
|
2
2
|
export const CONFIG_FILE_NAME = 'components.json';
|
|
3
3
|
export const DEFAULT_COMPONENTS_DIR = 'ui';
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
'styles-base',
|
|
7
|
-
'styles-components',
|
|
8
|
-
'styles-utilities',
|
|
9
|
-
'styles-motion'
|
|
10
|
-
];
|
|
4
|
+
export const DEFAULT_EXPOSURE = 'full';
|
|
5
|
+
export const LOCK_FILE_NAME = 'ui.lock.json';
|
|
11
6
|
export const COMPONENTS_SUBDIR = 'components';
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
7
|
+
export const THEMES_SUBDIR = 'themes';
|
|
8
|
+
export const RUNTIMES_SUBDIR = 'runtimes';
|
|
14
9
|
export const MANIFEST_FILE_NAME = 'component.json';
|
|
15
10
|
export const COMPONENT_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
11
|
+
/** Namespace slug used to scope every target of a registry package. */
|
|
12
|
+
export const UI_REGISTRY_ID_FIELD = 'uiRegistryId';
|
|
13
|
+
/** Minimum @blankways/ui version required by a registry package. */
|
|
14
|
+
export const UI_REQUIRES_FIELD = 'uiRequires';
|
|
15
|
+
/** Dev-only registry packages used while authoring this registry. */
|
|
16
|
+
export const UI_DEV_REGISTRIES_FIELD = 'uiDevRegistries';
|
|
17
|
+
/** Base stylesheet owned by @blankways/ui; imported, never copied. */
|
|
18
|
+
export const BASE_STYLE_IMPORT = '@blankways/ui/styles.css';
|
|
19
|
+
/** package.json field that points to a registry directory inside a package. */
|
|
20
|
+
export const UI_REGISTRY_FIELD = 'uiRegistry';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|