@blankways/ui 0.0.0-stage → 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 +246 -2
- package/dist/cli/cli.options.d.ts +5 -0
- package/dist/cli/cli.options.js +73 -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 +33 -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 +48 -0
- package/dist/commands/add.command.d.ts +4 -0
- package/dist/commands/add.command.js +49 -0
- package/dist/commands/dev.command.d.ts +3 -0
- package/dist/commands/dev.command.js +76 -0
- package/dist/commands/doctor.command.d.ts +3 -0
- package/dist/commands/doctor.command.js +103 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/init.command.d.ts +2 -0
- package/dist/commands/init.command.js +43 -0
- package/dist/commands/install.command.d.ts +2 -0
- package/dist/commands/install.command.js +36 -0
- package/dist/commands/list.command.d.ts +2 -0
- package/dist/commands/list.command.js +59 -0
- package/dist/commands/meta.command.d.ts +1 -0
- package/dist/commands/meta.command.js +19 -0
- package/dist/commands/registry.command.d.ts +2 -0
- package/dist/commands/registry.command.js +69 -0
- package/dist/commands/styles.command.d.ts +5 -0
- package/dist/commands/styles.command.js +44 -0
- package/dist/config/config.helpers.d.ts +10 -0
- package/dist/config/config.helpers.js +116 -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 +20 -0
- package/dist/constants/cli.constants.js +20 -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/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/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 +60 -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 +10 -0
- package/dist/doctor/checks/index.js +10 -0
- package/dist/doctor/checks/motion.check.d.ts +1 -0
- package/dist/doctor/checks/motion.check.js +66 -0
- package/dist/doctor/checks/namespaces.check.d.ts +1 -0
- package/dist/doctor/checks/namespaces.check.js +76 -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 +42 -0
- package/dist/doctor/doctor.helpers.d.ts +6 -0
- package/dist/doctor/doctor.helpers.js +43 -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 +31 -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 +6 -0
- package/dist/helpers/args.helpers.js +84 -0
- package/dist/helpers/barrels.helpers.d.ts +15 -0
- package/dist/helpers/barrels.helpers.js +157 -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 +12 -0
- package/dist/index.js +11 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +3 -0
- package/dist/registry/lockfile.d.ts +18 -0
- package/dist/registry/lockfile.js +32 -0
- package/dist/registry/registry.helpers.d.ts +12 -0
- package/dist/registry/registry.helpers.js +242 -0
- 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/cli.types.d.ts +6 -0
- package/dist/types/cli.types.js +1 -0
- package/dist/types/config.types.d.ts +70 -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 +68 -0
- package/dist/types/registry.types.js +3 -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 +37 -3
- package/styles.css +16 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { SupportedFramework } from '../constants/index.js';
|
|
2
|
+
export declare const REGISTRY_KINDS: readonly ['component', 'icon', 'theme', 'style', 'utility'];
|
|
3
|
+
export type RegistryKind = (typeof REGISTRY_KINDS)[number];
|
|
4
|
+
/** Destination roots owned by the new namespaced layout. */
|
|
5
|
+
export declare const REGISTRY_ROOTS: readonly ['components', 'themes', 'runtimes'];
|
|
6
|
+
export type RegistryRoot = (typeof REGISTRY_ROOTS)[number];
|
|
7
|
+
export type ExposureMode = 'full' | 'incremental';
|
|
8
|
+
export type RegistryFile = {
|
|
9
|
+
source: string;
|
|
10
|
+
target: string;
|
|
11
|
+
};
|
|
12
|
+
export type RegistryManifest = {
|
|
13
|
+
name?: string;
|
|
14
|
+
kind?: RegistryKind;
|
|
15
|
+
framework?: SupportedFramework;
|
|
16
|
+
description?: string;
|
|
17
|
+
hidden?: boolean;
|
|
18
|
+
/** Same-registry entries, kept for backwards compatibility. */
|
|
19
|
+
dependencies?: string[];
|
|
20
|
+
/** Qualified `registry:entry` requests; the safe inter-package contract. */
|
|
21
|
+
requires?: string[];
|
|
22
|
+
/** Arbitrary theme names declared by this peer. No special light/dark. */
|
|
23
|
+
themes?: string[];
|
|
24
|
+
/** Revision of this entry, used to tell local drift from registry updates. */
|
|
25
|
+
revision?: number;
|
|
26
|
+
peers?: string[];
|
|
27
|
+
suggestions?: string[];
|
|
28
|
+
files?: RegistryFile[];
|
|
29
|
+
};
|
|
30
|
+
export type RegistryItem = {
|
|
31
|
+
/** Specifier of the package that provides this entry, as written in components.json. */
|
|
32
|
+
registry: string;
|
|
33
|
+
/** Namespace slug declared by `uiRegistryId`; used for qualified names. */
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
kind: RegistryKind;
|
|
37
|
+
framework: SupportedFramework;
|
|
38
|
+
description: string;
|
|
39
|
+
hidden: boolean;
|
|
40
|
+
dependencies: string[];
|
|
41
|
+
requires: string[];
|
|
42
|
+
themes: string[];
|
|
43
|
+
revision: number;
|
|
44
|
+
peers: string[];
|
|
45
|
+
suggestions: string[];
|
|
46
|
+
files: RegistryFile[];
|
|
47
|
+
};
|
|
48
|
+
export type ResolvedRegistryItem = RegistryItem & {
|
|
49
|
+
requested: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** A loaded external registry package and the root directory of its entries. */
|
|
52
|
+
export type RegistryProvider = {
|
|
53
|
+
specifier: string;
|
|
54
|
+
packageRoot: string;
|
|
55
|
+
root: string;
|
|
56
|
+
/** Stable namespace declared via `uiRegistryId` in package.json. */
|
|
57
|
+
id: string;
|
|
58
|
+
version: string;
|
|
59
|
+
uiRequires: string[];
|
|
60
|
+
/** Dev-only peers; never written to the consumer's components.json. */
|
|
61
|
+
devRegistries: string[];
|
|
62
|
+
items: RegistryItem[];
|
|
63
|
+
};
|
|
64
|
+
export type CopyResult = {
|
|
65
|
+
copied: string[];
|
|
66
|
+
skipped: string[];
|
|
67
|
+
planned: string[];
|
|
68
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { install, status, validate } from './ui-api.js';
|
|
2
|
+
export type { InstallResult } from './ui-api.js';
|
|
3
|
+
export type { Lockfile, LockEntry } from '../registry/lockfile.js';
|
|
4
|
+
export type { InstallOptions } from '../types/config.types.js';
|
|
5
|
+
export type { ExposureMode } from '../types/registry.types.js';
|
|
6
|
+
export { install, status, validate };
|
|
7
|
+
/** Materializes specific entries plus their `requires` closure. Build-time only. */
|
|
8
|
+
export declare function ensure(selectors: string[], options?: Parameters<typeof install>[0]): Promise<import("./ui-api.js").InstallResult>;
|
|
9
|
+
/** Materializes every visible entry of every configured registry. Build-time only. */
|
|
10
|
+
export declare function ensureAll(options?: Parameters<typeof install>[0]): Promise<import("./ui-api.js").InstallResult>;
|
|
11
|
+
/** Regenerates the generated barrels without copying any registry files. */
|
|
12
|
+
export declare function sync(options?: {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
dryRun?: boolean;
|
|
15
|
+
globalCss?: string;
|
|
16
|
+
}): Promise<import("../helpers/barrels.helpers.js").BarrelsSyncResult>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { readConfig, resolveComponentsDir } from '../config/index.js';
|
|
3
|
+
import { CLI_NAME } from '../constants/index.js';
|
|
4
|
+
import { CliError } from '../errors/index.js';
|
|
5
|
+
import { syncBarrels } from '../helpers/barrels.helpers.js';
|
|
6
|
+
import { install, status, validate } from './ui-api.js';
|
|
7
|
+
export { install, status, validate };
|
|
8
|
+
/** Materializes specific entries plus their `requires` closure. Build-time only. */
|
|
9
|
+
export async function ensure(selectors, options = {}) {
|
|
10
|
+
return install({ ...options, selectors, exposure: options.exposure ?? 'incremental' });
|
|
11
|
+
}
|
|
12
|
+
/** Materializes every visible entry of every configured registry. Build-time only. */
|
|
13
|
+
export async function ensureAll(options = {}) {
|
|
14
|
+
return install({ ...options, exposure: options.exposure ?? 'full' });
|
|
15
|
+
}
|
|
16
|
+
/** Regenerates the generated barrels without copying any registry files. */
|
|
17
|
+
export async function sync(options = {}) {
|
|
18
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
19
|
+
const config = await readConfig(cwd);
|
|
20
|
+
if (!config) {
|
|
21
|
+
throw new CliError(`components.json not found. Run "${CLI_NAME} init" first.`);
|
|
22
|
+
}
|
|
23
|
+
return syncBarrels({
|
|
24
|
+
cwd,
|
|
25
|
+
componentsDir: resolveComponentsDir(cwd, config),
|
|
26
|
+
globalCss: options.globalCss,
|
|
27
|
+
themeOrder: config.themeOrder,
|
|
28
|
+
dryRun: options.dryRun
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Lockfile } from '../registry/lockfile.js';
|
|
2
|
+
import type { InstallOptions } from '../types/config.types.js';
|
|
3
|
+
export type InstallResult = {
|
|
4
|
+
added: string[];
|
|
5
|
+
updated: string[];
|
|
6
|
+
kept: string[];
|
|
7
|
+
planned: string[];
|
|
8
|
+
barrels: string[];
|
|
9
|
+
entries: string[];
|
|
10
|
+
};
|
|
11
|
+
/** Single write path: resolve, validate, plan, apply, sync, lock. */
|
|
12
|
+
export declare function install(options?: InstallOptions): Promise<InstallResult>;
|
|
13
|
+
export declare function status(options?: {
|
|
14
|
+
cwd?: string;
|
|
15
|
+
}): Promise<Lockfile>;
|
|
16
|
+
export declare function validate(options?: {
|
|
17
|
+
cwd?: string;
|
|
18
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { copyFile, mkdir, stat } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { readConfig, resolveComponentsDir } from '../config/index.js';
|
|
4
|
+
import { CLI_NAME, DEFAULT_EXPOSURE } from '../constants/index.js';
|
|
5
|
+
import { CliError } from '../errors/index.js';
|
|
6
|
+
import { syncBarrels } from '../helpers/barrels.helpers.js';
|
|
7
|
+
import { toDisplayPath } from '../helpers/path.helpers.js';
|
|
8
|
+
import { hashFile, readLockfile, writeLockfile } from '../registry/lockfile.js';
|
|
9
|
+
import { loadRegistryProviders } from '../registry/registry.providers.js';
|
|
10
|
+
import { resolveSelectedComponents } from '../registry/registry.service.js';
|
|
11
|
+
const ALLOWED_ROOTS = ['components', 'themes', 'runtimes'];
|
|
12
|
+
function qualifiedName(item) {
|
|
13
|
+
return `${item.id}:${item.name}`;
|
|
14
|
+
}
|
|
15
|
+
function validateLayout(items) {
|
|
16
|
+
const problems = [];
|
|
17
|
+
for (const item of items) {
|
|
18
|
+
const allowed = ALLOWED_ROOTS.map(root => `${root}/${item.id}/`);
|
|
19
|
+
for (const file of item.files) {
|
|
20
|
+
if (!allowed.some(prefix => file.target.startsWith(prefix))) {
|
|
21
|
+
problems.push(`${qualifiedName(item)} → ${file.target} must start with ${allowed.join(', ')}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return problems;
|
|
26
|
+
}
|
|
27
|
+
async function pathExists(path) {
|
|
28
|
+
try {
|
|
29
|
+
await stat(path);
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function planActions(items, componentsDir, lock, force) {
|
|
37
|
+
const actions = [];
|
|
38
|
+
for (const item of items) {
|
|
39
|
+
const key = qualifiedName(item);
|
|
40
|
+
const locked = lock.entries[key];
|
|
41
|
+
for (const file of item.files) {
|
|
42
|
+
const target = join(componentsDir, file.target);
|
|
43
|
+
const sourceHash = await hashFile(file.source);
|
|
44
|
+
const lockedHash = locked?.files[file.target];
|
|
45
|
+
if (!(await pathExists(target))) {
|
|
46
|
+
actions.push({ target, source: file.source, status: 'add' });
|
|
47
|
+
}
|
|
48
|
+
else if (lockedHash === sourceHash) {
|
|
49
|
+
actions.push({ target, source: file.source, status: 'unchanged' });
|
|
50
|
+
}
|
|
51
|
+
else if (force || (lockedHash && (await hashFile(target)) === lockedHash)) {
|
|
52
|
+
actions.push({ target, source: file.source, status: 'update' });
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
actions.push({ target, source: file.source, status: 'keep' });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return actions;
|
|
60
|
+
}
|
|
61
|
+
function buildLock(items, exposure, registries, providers) {
|
|
62
|
+
const entries = {};
|
|
63
|
+
for (const item of items) {
|
|
64
|
+
entries[qualifiedName(item)] = {
|
|
65
|
+
revision: item.revision,
|
|
66
|
+
files: {}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
version: 1,
|
|
71
|
+
exposure,
|
|
72
|
+
registries: Object.fromEntries(providers
|
|
73
|
+
.filter(provider => registries.includes(provider.specifier))
|
|
74
|
+
.map(provider => [provider.specifier, { id: provider.id, version: provider.version }])),
|
|
75
|
+
entries
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function assertFrozen(lock, desired) {
|
|
79
|
+
if (lock.exposure !== desired.exposure) {
|
|
80
|
+
throw new CliError('ui.lock.json is out of date (exposure changed). Run "ui install".');
|
|
81
|
+
}
|
|
82
|
+
const keys = Object.keys(desired.entries).sort().join(',');
|
|
83
|
+
if (Object.keys(lock.entries).sort().join(',') !== keys) {
|
|
84
|
+
throw new CliError('ui.lock.json is out of date (entries changed). Run "ui install".');
|
|
85
|
+
}
|
|
86
|
+
for (const [key, entry] of Object.entries(desired.entries)) {
|
|
87
|
+
const locked = lock.entries[key];
|
|
88
|
+
if (locked?.revision !== entry.revision) {
|
|
89
|
+
throw new CliError(`ui.lock.json is out of date (${key}). Run "ui install".`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Single write path: resolve, validate, plan, apply, sync, lock. */
|
|
94
|
+
export async function install(options = {}) {
|
|
95
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
96
|
+
const config = await readConfig(cwd);
|
|
97
|
+
if (!config) {
|
|
98
|
+
throw new CliError(`components.json not found. Run "${CLI_NAME} init" first.`);
|
|
99
|
+
}
|
|
100
|
+
const componentsDir = resolveComponentsDir(cwd, config, options.componentsDir);
|
|
101
|
+
const registries = options.registries ?? config.registries;
|
|
102
|
+
const exposure = options.exposure ?? config.exposure ?? DEFAULT_EXPOSURE;
|
|
103
|
+
const providers = await loadRegistryProviders(cwd, registries, config.framework);
|
|
104
|
+
const items = providers.flatMap(provider => provider.items);
|
|
105
|
+
const selectors = options.selectors?.length
|
|
106
|
+
? options.selectors
|
|
107
|
+
: exposure === 'full'
|
|
108
|
+
? items.filter(item => !item.hidden).map(qualifiedName)
|
|
109
|
+
: (config.entries ?? []);
|
|
110
|
+
if (selectors.length === 0) {
|
|
111
|
+
throw new CliError(exposure === 'incremental'
|
|
112
|
+
? 'No entries requested. Add "entries" to components.json, use "ui add <entry>", or switch exposure to "full".'
|
|
113
|
+
: 'No entries available in the configured registries.');
|
|
114
|
+
}
|
|
115
|
+
const ordered = await resolveSelectedComponents(selectors, false, {
|
|
116
|
+
cwd,
|
|
117
|
+
registries,
|
|
118
|
+
framework: config.framework
|
|
119
|
+
});
|
|
120
|
+
const problems = validateLayout(ordered);
|
|
121
|
+
if (problems.length > 0) {
|
|
122
|
+
throw new CliError(`Registry layout is invalid:\n - ${problems.join('\n - ')}`);
|
|
123
|
+
}
|
|
124
|
+
const lock = await readLockfile(cwd);
|
|
125
|
+
const desired = buildLock(ordered, exposure, registries, providers);
|
|
126
|
+
for (const item of ordered) {
|
|
127
|
+
desired.entries[qualifiedName(item)].files = Object.fromEntries(await Promise.all(item.files.map(async (file) => [file.target, await hashFile(file.source)])));
|
|
128
|
+
}
|
|
129
|
+
if (options.frozen)
|
|
130
|
+
assertFrozen(lock, desired);
|
|
131
|
+
const actions = await planActions(ordered, componentsDir, lock, Boolean(options.force));
|
|
132
|
+
const result = {
|
|
133
|
+
added: [],
|
|
134
|
+
updated: [],
|
|
135
|
+
kept: [],
|
|
136
|
+
planned: [],
|
|
137
|
+
barrels: [],
|
|
138
|
+
entries: ordered.map(qualifiedName)
|
|
139
|
+
};
|
|
140
|
+
for (const action of actions) {
|
|
141
|
+
const display = toDisplayPath(cwd, action.target);
|
|
142
|
+
if (action.status === 'unchanged')
|
|
143
|
+
continue;
|
|
144
|
+
if (action.status === 'keep') {
|
|
145
|
+
result.kept.push(display);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (options.dryRun) {
|
|
149
|
+
result.planned.push(display);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
await mkdir(dirname(action.target), { recursive: true });
|
|
153
|
+
await copyFile(action.source, action.target);
|
|
154
|
+
if (action.status === 'add')
|
|
155
|
+
result.added.push(display);
|
|
156
|
+
else
|
|
157
|
+
result.updated.push(display);
|
|
158
|
+
}
|
|
159
|
+
if (!options.dryRun) {
|
|
160
|
+
const barrels = await syncBarrels({
|
|
161
|
+
cwd,
|
|
162
|
+
componentsDir,
|
|
163
|
+
globalCss: options.globalCss,
|
|
164
|
+
themeOrder: config.themeOrder
|
|
165
|
+
});
|
|
166
|
+
result.barrels = barrels.barrels.map(path => toDisplayPath(cwd, path));
|
|
167
|
+
await writeLockfile(cwd, desired);
|
|
168
|
+
}
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
export async function status(options = {}) {
|
|
172
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
173
|
+
const lock = await readLockfile(cwd);
|
|
174
|
+
return lock;
|
|
175
|
+
}
|
|
176
|
+
export async function validate(options = {}) {
|
|
177
|
+
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
178
|
+
const config = await readConfig(cwd);
|
|
179
|
+
if (!config) {
|
|
180
|
+
throw new CliError(`components.json not found. Run "${CLI_NAME} init" first.`);
|
|
181
|
+
}
|
|
182
|
+
const providers = await loadRegistryProviders(cwd, config.registries, config.framework);
|
|
183
|
+
const items = providers.flatMap(provider => provider.items);
|
|
184
|
+
const problems = [];
|
|
185
|
+
for (const item of items) {
|
|
186
|
+
const allowed = ALLOWED_ROOTS.map(root => `${root}/${item.id}/`);
|
|
187
|
+
for (const file of item.files) {
|
|
188
|
+
if (!allowed.some(prefix => file.target.startsWith(prefix))) {
|
|
189
|
+
problems.push(`${qualifiedName(item)} → ${file.target}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return problems;
|
|
194
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blankways/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.2.0-alpha.1",
|
|
4
|
+
"description": "Build-time API and CLI for composing external UI registries into a project.",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ui": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./cli": "./dist/cli.js",
|
|
16
|
+
"./styles.css": "./styles.css"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"styles.css"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "ISC",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"tag": "alpha"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^24.0.0",
|
|
31
|
+
"tsc-alias": "^1.9.9",
|
|
32
|
+
"typescript": "^7.0.2",
|
|
33
|
+
"vitest": "^5.0.5"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "node scripts/clean-dist.mjs && tsc && tsc-alias",
|
|
37
|
+
"typecheck": "tsc --noEmit && node scripts/validate-registry.mjs",
|
|
38
|
+
"test": "vitest run --passWithNoTests"
|
|
39
|
+
}
|
|
6
40
|
}
|
package/styles.css
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* @blankways/ui base stylesheet. Immutable: import it, never copy it into ui/. */
|
|
2
|
+
:where(*, *::before, *::after) {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:where(html) {
|
|
7
|
+
-webkit-text-size-adjust: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:where(body) {
|
|
11
|
+
margin: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:where(button, input, textarea, select) {
|
|
15
|
+
font: inherit;
|
|
16
|
+
}
|