@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,32 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { LOCK_FILE_NAME } from '../constants/index.js';
|
|
5
|
+
export function createEmptyLock(exposure = 'full') {
|
|
6
|
+
return { version: 1, exposure, registries: {}, entries: {} };
|
|
7
|
+
}
|
|
8
|
+
export async function readLockfile(cwd) {
|
|
9
|
+
try {
|
|
10
|
+
const content = await readFile(join(cwd, LOCK_FILE_NAME), 'utf8');
|
|
11
|
+
const parsed = JSON.parse(content);
|
|
12
|
+
if (parsed.version !== 1 || typeof parsed.entries !== 'object') {
|
|
13
|
+
throw new Error('unsupported version');
|
|
14
|
+
}
|
|
15
|
+
return parsed;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error.code === 'ENOENT')
|
|
19
|
+
return createEmptyLock();
|
|
20
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
21
|
+
throw new Error(`Invalid ${LOCK_FILE_NAME}: ${message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function writeLockfile(cwd, lock) {
|
|
25
|
+
await writeFile(join(cwd, LOCK_FILE_NAME), `${JSON.stringify(lock, null, 2)}\n`, 'utf8');
|
|
26
|
+
}
|
|
27
|
+
export function hashContent(content) {
|
|
28
|
+
return `sha256:${createHash('sha256').update(content).digest('hex').slice(0, 16)}`;
|
|
29
|
+
}
|
|
30
|
+
export async function hashFile(path) {
|
|
31
|
+
return hashContent(await readFile(path, 'utf8'));
|
|
32
|
+
}
|
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import { type SupportedFramework } from '../constants/index.js';
|
|
2
|
-
import { type CopyResult, type RegistryItem, type RegistryKind
|
|
3
|
-
export declare function getRegistryRoot(): string;
|
|
2
|
+
import { type CopyResult, type RegistryItem, type RegistryKind } from '../types/registry.types.js';
|
|
4
3
|
export declare function isValidComponentName(name: string): boolean;
|
|
5
4
|
export declare function assertValidComponentName(name: string): void;
|
|
6
5
|
export declare function assertValidRegistryKind(value: string | undefined): RegistryKind | undefined;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export declare function listRegistryItems(options?: ListRegistryOptions): Promise<RegistryItem[]>;
|
|
11
|
-
export declare function resolveRegistryItem(name: string, frameworkOption?: SupportedFramework): Promise<RegistryItem | null>;
|
|
12
|
-
export type ResolveOptions = {
|
|
13
|
-
kind?: string;
|
|
14
|
-
framework?: SupportedFramework;
|
|
15
|
-
noDeps?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export declare function resolveSelectedComponents(names: readonly string[], all: boolean, options?: ResolveOptions): Promise<ResolvedRegistryItem[]>;
|
|
6
|
+
/** Reads every entry of a registry directory, independent of where it lives. */
|
|
7
|
+
export declare function listItemsFromDirectory(root: string, framework: SupportedFramework, providerId: string, registryId?: string): Promise<RegistryItem[]>;
|
|
18
8
|
export declare function copyRegistryItem(item: RegistryItem, componentsDir: string, options: {
|
|
19
9
|
cwd: string;
|
|
20
10
|
force?: boolean;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
1
|
import { copyFile, mkdir, readFile, readdir, stat } from 'node:fs/promises';
|
|
3
|
-
import { basename, dirname, isAbsolute, join, normalize, relative
|
|
4
|
-
import {
|
|
5
|
-
import { BUNDLED_REGISTRY_DIR_NAME, COMPONENT_NAME_PATTERN, COMPONENTS_SUBDIR, DEFAULT_FRAMEWORK, MANIFEST_FILE_NAME, REGISTRY_DIR_NAME } from '../constants/index.js';
|
|
2
|
+
import { basename, dirname, isAbsolute, join, normalize, relative } from 'node:path';
|
|
3
|
+
import { COMPONENT_NAME_PATTERN, COMPONENTS_SUBDIR, MANIFEST_FILE_NAME } from '../constants/index.js';
|
|
6
4
|
import { assertFramework } from '../config/framework.helpers.js';
|
|
7
5
|
import { CliError } from '../errors/index.js';
|
|
8
|
-
import { getPackageRoot } from '../helpers/package.helpers.js';
|
|
9
6
|
import { assertSafeRelativePath, toDisplayPath } from '../helpers/path.helpers.js';
|
|
10
|
-
import { REGISTRY_KINDS } from '../types/registry.types.js';
|
|
7
|
+
import { REGISTRY_KINDS, REGISTRY_ROOTS } from '../types/registry.types.js';
|
|
11
8
|
const COMPONENT_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'];
|
|
12
9
|
const IGNORED_DIRECTORIES = new Set(['node_modules']);
|
|
13
10
|
const IGNORED_FILE_NAMES = new Set([MANIFEST_FILE_NAME, 'README.md']);
|
|
@@ -36,13 +33,6 @@ async function isFile(path) {
|
|
|
36
33
|
return false;
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
export function getRegistryRoot() {
|
|
40
|
-
const sourceRegistry = join(getPackageRoot(), REGISTRY_DIR_NAME);
|
|
41
|
-
if (existsSync(sourceRegistry))
|
|
42
|
-
return sourceRegistry;
|
|
43
|
-
// Published packages ship registry data inside dist/ so `files: ["dist"]` is enough.
|
|
44
|
-
return resolve(dirname(fileURLToPath(import.meta.url)), '..', BUNDLED_REGISTRY_DIR_NAME);
|
|
45
|
-
}
|
|
46
36
|
export function isValidComponentName(name) {
|
|
47
37
|
return COMPONENT_NAME_PATTERN.test(name) && name !== '.' && name !== '..';
|
|
48
38
|
}
|
|
@@ -105,18 +95,18 @@ function toStringArray(value, field) {
|
|
|
105
95
|
function normalizeTarget(target, kind) {
|
|
106
96
|
assertSafeRelativePath(target);
|
|
107
97
|
const normalized = normalize(target).replace(/\\/g, '/');
|
|
108
|
-
const
|
|
109
|
-
if (kind !== 'component' ||
|
|
98
|
+
const isKnownRoot = REGISTRY_ROOTS.some(root => normalized.startsWith(`${root}/`));
|
|
99
|
+
if (kind !== 'component' || isKnownRoot)
|
|
110
100
|
return normalized;
|
|
111
|
-
return `${
|
|
101
|
+
return `${COMPONENTS_SUBDIR}/${normalized}`;
|
|
112
102
|
}
|
|
113
|
-
function resolveSource(name, source) {
|
|
103
|
+
function resolveSource(root, name, source) {
|
|
114
104
|
if (isAbsolute(source))
|
|
115
105
|
return source;
|
|
116
106
|
assertSafeRelativePath(source);
|
|
117
|
-
return join(
|
|
107
|
+
return join(root, name, normalize(source));
|
|
118
108
|
}
|
|
119
|
-
function normalizeFiles(name, files, kind) {
|
|
109
|
+
function normalizeFiles(root, name, files, kind) {
|
|
120
110
|
if (files === undefined)
|
|
121
111
|
return [];
|
|
122
112
|
if (!Array.isArray(files)) {
|
|
@@ -131,7 +121,7 @@ function normalizeFiles(name, files, kind) {
|
|
|
131
121
|
throw new CliError(`${MANIFEST_FILE_NAME}: files[${index}] needs string "source" and "target".`);
|
|
132
122
|
}
|
|
133
123
|
return {
|
|
134
|
-
source: resolveSource(name, record.source),
|
|
124
|
+
source: resolveSource(root, name, record.source),
|
|
135
125
|
target: normalizeTarget(record.target, kind)
|
|
136
126
|
};
|
|
137
127
|
});
|
|
@@ -150,7 +140,7 @@ async function readManifest(path) {
|
|
|
150
140
|
}
|
|
151
141
|
return parsed;
|
|
152
142
|
}
|
|
153
|
-
async function createItem(name, manifest, fallbackFiles, framework =
|
|
143
|
+
async function createItem(root, providerId, registryId, name, manifest, fallbackFiles, framework = 'react') {
|
|
154
144
|
assertValidComponentName(name);
|
|
155
145
|
if (manifest?.name !== undefined && manifest.name !== name) {
|
|
156
146
|
throw new CliError(`${MANIFEST_FILE_NAME} in "${name}" declares name "${manifest.name}".`);
|
|
@@ -162,9 +152,9 @@ async function createItem(name, manifest, fallbackFiles, framework = DEFAULT_FRA
|
|
|
162
152
|
}
|
|
163
153
|
const kind = declaredKind ?? inferKind(name);
|
|
164
154
|
const files = manifest?.files !== undefined
|
|
165
|
-
? normalizeFiles(name, manifest.files, kind)
|
|
155
|
+
? normalizeFiles(root, name, manifest.files, kind)
|
|
166
156
|
: fallbackFiles.map(file => {
|
|
167
|
-
const directoryRoot = join(
|
|
157
|
+
const directoryRoot = join(root, name);
|
|
168
158
|
const target = isAbsolute(file) && file.startsWith(directoryRoot)
|
|
169
159
|
? join(name, relative(directoryRoot, file))
|
|
170
160
|
: basename(file);
|
|
@@ -173,26 +163,33 @@ async function createItem(name, manifest, fallbackFiles, framework = DEFAULT_FRA
|
|
|
173
163
|
if (files.length === 0)
|
|
174
164
|
return null;
|
|
175
165
|
return {
|
|
166
|
+
registry: providerId,
|
|
167
|
+
id: registryId,
|
|
176
168
|
name,
|
|
177
169
|
kind,
|
|
178
170
|
framework: assertFramework(manifest?.framework ?? framework),
|
|
179
|
-
description: manifest?.description ?? `
|
|
171
|
+
description: manifest?.description ?? `Registry entry "${name}".`,
|
|
180
172
|
dependencies: toStringArray(manifest?.dependencies, 'dependencies'),
|
|
173
|
+
requires: toStringArray(manifest?.requires, 'requires'),
|
|
174
|
+
themes: toStringArray(manifest?.themes, 'themes'),
|
|
175
|
+
revision: typeof manifest?.revision === 'number' ? manifest.revision : 1,
|
|
181
176
|
peers: toStringArray(manifest?.peers, 'peers'),
|
|
182
177
|
suggestions: toStringArray(manifest?.suggestions, 'suggestions'),
|
|
183
178
|
files,
|
|
184
179
|
hidden: manifest?.hidden === true
|
|
185
180
|
};
|
|
186
181
|
}
|
|
187
|
-
async function loadDirectoryItem(name, directory, framework) {
|
|
182
|
+
async function loadDirectoryItem(root, providerId, registryId, name, directory, framework) {
|
|
188
183
|
const manifestPath = join(directory, MANIFEST_FILE_NAME);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
184
|
+
// A directory is an entry only when it declares a manifest; helpers such as
|
|
185
|
+
// scripts/ or docs/ are package infrastructure, not registry entries.
|
|
186
|
+
if (!(await isFile(manifestPath)))
|
|
187
|
+
return null;
|
|
188
|
+
const manifest = await readManifest(manifestPath);
|
|
189
|
+
return createItem(root, providerId, registryId, name, manifest, [], framework);
|
|
192
190
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const root = getRegistryRoot();
|
|
191
|
+
/** Reads every entry of a registry directory, independent of where it lives. */
|
|
192
|
+
export async function listItemsFromDirectory(root, framework, providerId, registryId = providerId) {
|
|
196
193
|
if (!(await isDirectory(root)))
|
|
197
194
|
return [];
|
|
198
195
|
const entries = await readdir(root, { withFileTypes: true });
|
|
@@ -201,7 +198,7 @@ export async function listRegistryItems(options = {}) {
|
|
|
201
198
|
if (entry.name.startsWith('.') || IGNORED_DIRECTORIES.has(entry.name))
|
|
202
199
|
continue;
|
|
203
200
|
if (entry.isDirectory() && isValidComponentName(entry.name)) {
|
|
204
|
-
const item = await loadDirectoryItem(entry.name, join(root, entry.name), framework);
|
|
201
|
+
const item = await loadDirectoryItem(root, providerId, registryId, entry.name, join(root, entry.name), framework);
|
|
205
202
|
if (item?.framework === framework)
|
|
206
203
|
items.push(item);
|
|
207
204
|
continue;
|
|
@@ -209,7 +206,7 @@ export async function listRegistryItems(options = {}) {
|
|
|
209
206
|
if (entry.isFile() && !IGNORED_FILE_NAMES.has(entry.name)) {
|
|
210
207
|
const name = getFileComponentName(entry.name);
|
|
211
208
|
if (name !== undefined && isValidComponentName(name)) {
|
|
212
|
-
const item = await createItem(name, null, [join(root, entry.name)], framework);
|
|
209
|
+
const item = await createItem(root, providerId, registryId, name, null, [join(root, entry.name)], framework);
|
|
213
210
|
if (item?.framework === framework)
|
|
214
211
|
items.push(item);
|
|
215
212
|
}
|
|
@@ -217,89 +214,6 @@ export async function listRegistryItems(options = {}) {
|
|
|
217
214
|
}
|
|
218
215
|
return items.sort((a, b) => a.name.localeCompare(b.name));
|
|
219
216
|
}
|
|
220
|
-
export async function resolveRegistryItem(name, frameworkOption) {
|
|
221
|
-
assertValidComponentName(name);
|
|
222
|
-
const framework = assertFramework(frameworkOption);
|
|
223
|
-
const root = getRegistryRoot();
|
|
224
|
-
const directory = join(root, name);
|
|
225
|
-
if (await isDirectory(directory)) {
|
|
226
|
-
const item = await loadDirectoryItem(name, directory, framework);
|
|
227
|
-
return item?.framework === framework ? item : null;
|
|
228
|
-
}
|
|
229
|
-
for (const extension of COMPONENT_EXTENSIONS) {
|
|
230
|
-
const file = join(root, `${name}${extension}`);
|
|
231
|
-
const item = await createItem(name, null, [file], framework);
|
|
232
|
-
if (item?.framework === framework)
|
|
233
|
-
return item;
|
|
234
|
-
}
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
|
-
export async function resolveSelectedComponents(names, all, options = {}) {
|
|
238
|
-
const kind = assertValidRegistryKind(options.kind);
|
|
239
|
-
const framework = assertFramework(options.framework);
|
|
240
|
-
const items = await listRegistryItems({ framework });
|
|
241
|
-
const byName = new Map(items.map(item => [item.name, item]));
|
|
242
|
-
const requestedNames = all
|
|
243
|
-
? items
|
|
244
|
-
.filter(item => !item.hidden && (kind === undefined || item.kind === kind))
|
|
245
|
-
.map(item => item.name)
|
|
246
|
-
: Array.from(new Set(names));
|
|
247
|
-
if (requestedNames.length === 0) {
|
|
248
|
-
throw new CliError('No entries specified. Use <name...>, --all or --kind.');
|
|
249
|
-
}
|
|
250
|
-
for (const name of requestedNames)
|
|
251
|
-
assertValidComponentName(name);
|
|
252
|
-
const missing = requestedNames.filter(name => !byName.has(name));
|
|
253
|
-
if (missing.length > 0) {
|
|
254
|
-
const available = items
|
|
255
|
-
.filter(item => !item.hidden)
|
|
256
|
-
.map(item => item.name)
|
|
257
|
-
.join(', ') || 'none';
|
|
258
|
-
throw new CliError(`Unknown registry entry/entries: ${missing.join(', ')}. Available: ${available}.`);
|
|
259
|
-
}
|
|
260
|
-
const hidden = requestedNames.filter(name => byName.get(name)?.hidden);
|
|
261
|
-
if (hidden.length > 0) {
|
|
262
|
-
throw new CliError(`Internal registry entries cannot be added directly: ${hidden.join(', ')}. They are installed automatically as dependencies.`);
|
|
263
|
-
}
|
|
264
|
-
if (kind !== undefined) {
|
|
265
|
-
const wrongKind = requestedNames.filter(name => byName.get(name)?.kind !== kind);
|
|
266
|
-
if (wrongKind.length > 0) {
|
|
267
|
-
throw new CliError(`Expected kind "${kind}" but got: ${wrongKind.join(', ')}.`);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
const orderedNames = [];
|
|
271
|
-
const requested = new Set();
|
|
272
|
-
const resolved = new Set();
|
|
273
|
-
const visiting = [];
|
|
274
|
-
const visit = async (name, isRequested) => {
|
|
275
|
-
if (isRequested)
|
|
276
|
-
requested.add(name);
|
|
277
|
-
if (resolved.has(name))
|
|
278
|
-
return;
|
|
279
|
-
const item = byName.get(name);
|
|
280
|
-
if (!item) {
|
|
281
|
-
throw new CliError(`Unknown registry dependency "${name}".`);
|
|
282
|
-
}
|
|
283
|
-
const cycleIndex = visiting.indexOf(name);
|
|
284
|
-
if (cycleIndex !== -1) {
|
|
285
|
-
throw new CliError(`Registry dependency cycle: ${[...visiting.slice(cycleIndex), name].join(' -> ')}`);
|
|
286
|
-
}
|
|
287
|
-
visiting.push(name);
|
|
288
|
-
if (!options.noDeps) {
|
|
289
|
-
for (const dependency of item.dependencies)
|
|
290
|
-
await visit(dependency, false);
|
|
291
|
-
}
|
|
292
|
-
visiting.pop();
|
|
293
|
-
resolved.add(name);
|
|
294
|
-
orderedNames.push(name);
|
|
295
|
-
};
|
|
296
|
-
for (const name of requestedNames)
|
|
297
|
-
await visit(name, true);
|
|
298
|
-
return orderedNames.map(name => ({
|
|
299
|
-
...byName.get(name),
|
|
300
|
-
requested: requested.has(name)
|
|
301
|
-
}));
|
|
302
|
-
}
|
|
303
217
|
export async function copyRegistryItem(item, componentsDir, options) {
|
|
304
218
|
const result = { copied: [], skipped: [], planned: [] };
|
|
305
219
|
for (const entry of item.files) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SupportedFramework } from '../constants/index.js';
|
|
2
|
+
import type { RegistryProvider } from '../types/registry.types.js';
|
|
3
|
+
/** Resolves the entries directory declared by an external registry package. */
|
|
4
|
+
export declare function resolveRegistryDirectory(cwd: string, specifier: string): Promise<{
|
|
5
|
+
packageRoot: string;
|
|
6
|
+
root: string;
|
|
7
|
+
id: string;
|
|
8
|
+
version: string;
|
|
9
|
+
uiRequires: string[];
|
|
10
|
+
devRegistries: string[];
|
|
11
|
+
}>;
|
|
12
|
+
export declare function loadRegistryProvider(cwd: string, specifier: string, framework: SupportedFramework): Promise<RegistryProvider>;
|
|
13
|
+
export declare function loadRegistryProviders(cwd: string, specifiers: readonly string[], framework: SupportedFramework): Promise<RegistryProvider[]>;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
|
+
import { UI_REGISTRY_FIELD, UI_DEV_REGISTRIES_FIELD, UI_REGISTRY_ID_FIELD, UI_REQUIRES_FIELD } from '../constants/index.js';
|
|
5
|
+
import { CliError } from '../errors/index.js';
|
|
6
|
+
import { assertSafeRelativePath, resolveProjectPath } from '../helpers/path.helpers.js';
|
|
7
|
+
import { listItemsFromDirectory } from './registry.helpers.js';
|
|
8
|
+
const PACKAGE_JSON = 'package.json';
|
|
9
|
+
const REGISTRY_ID_PATTERN = /^[a-z0-9][a-z0-9._-]*$/;
|
|
10
|
+
function readStringArray(value, field) {
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
return [];
|
|
13
|
+
if (!Array.isArray(value) || value.some(entry => typeof entry !== 'string')) {
|
|
14
|
+
throw new CliError(`${PACKAGE_JSON}: "${field}" must be an array of strings.`);
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
async function isDirectory(path) {
|
|
19
|
+
try {
|
|
20
|
+
return (await stat(path)).isDirectory();
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function isFile(path) {
|
|
27
|
+
try {
|
|
28
|
+
return (await stat(path)).isFile();
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function readPackageJson(path) {
|
|
35
|
+
let parsed;
|
|
36
|
+
try {
|
|
37
|
+
parsed = JSON.parse((await readFile(path, 'utf8')).replace(/^\uFEFF/, ''));
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
41
|
+
throw new CliError(`Invalid ${PACKAGE_JSON} at ${path}: ${message}`);
|
|
42
|
+
}
|
|
43
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
44
|
+
throw new CliError(`${PACKAGE_JSON} at ${path} must contain an object.`);
|
|
45
|
+
}
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
async function findPackageRoot(entry, specifier, entryIsManifest) {
|
|
49
|
+
if (entryIsManifest) {
|
|
50
|
+
const manifest = await readPackageJson(entry);
|
|
51
|
+
return { directory: dirname(entry), manifest };
|
|
52
|
+
}
|
|
53
|
+
let directory = dirname(entry);
|
|
54
|
+
while (true) {
|
|
55
|
+
const manifestPath = join(directory, PACKAGE_JSON);
|
|
56
|
+
if (await isFile(manifestPath)) {
|
|
57
|
+
try {
|
|
58
|
+
const manifest = await readPackageJson(manifestPath);
|
|
59
|
+
if (manifest.name === specifier || manifest[UI_REGISTRY_FIELD] !== undefined) {
|
|
60
|
+
return { directory, manifest };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Keep walking: a nested, malformed manifest is not the package root.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const parent = dirname(directory);
|
|
68
|
+
if (parent === directory)
|
|
69
|
+
break;
|
|
70
|
+
directory = parent;
|
|
71
|
+
}
|
|
72
|
+
throw new CliError(`Could not find the root of registry package "${specifier}" from ${entry}.`);
|
|
73
|
+
}
|
|
74
|
+
async function resolvePackageRoot(cwd, specifier) {
|
|
75
|
+
if (specifier.startsWith('.') || isAbsolute(specifier)) {
|
|
76
|
+
const directory = resolveProjectPath(cwd, specifier);
|
|
77
|
+
if (!(await isDirectory(directory))) {
|
|
78
|
+
throw new CliError(`Registry package directory not found: ${specifier}`);
|
|
79
|
+
}
|
|
80
|
+
return directory;
|
|
81
|
+
}
|
|
82
|
+
const requireFromCwd = createRequire(join(cwd, '__ui_registry__.js'));
|
|
83
|
+
let entry;
|
|
84
|
+
let entryIsManifest = false;
|
|
85
|
+
try {
|
|
86
|
+
entry = requireFromCwd.resolve(`${specifier}/${PACKAGE_JSON}`);
|
|
87
|
+
entryIsManifest = true;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
try {
|
|
91
|
+
entry = requireFromCwd.resolve(specifier);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
throw new CliError(`Registry package "${specifier}" could not be resolved from ${cwd}. Install it or use a relative path.`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return (await findPackageRoot(entry, specifier, entryIsManifest)).directory;
|
|
98
|
+
}
|
|
99
|
+
/** Resolves the entries directory declared by an external registry package. */
|
|
100
|
+
export async function resolveRegistryDirectory(cwd, specifier) {
|
|
101
|
+
if (typeof specifier !== 'string' || specifier.trim() === '') {
|
|
102
|
+
throw new CliError('Registry specifiers must be non-empty strings.');
|
|
103
|
+
}
|
|
104
|
+
const packageRoot = await resolvePackageRoot(cwd, specifier);
|
|
105
|
+
const manifest = await readPackageJson(join(packageRoot, PACKAGE_JSON));
|
|
106
|
+
const declared = manifest[UI_REGISTRY_FIELD];
|
|
107
|
+
if (declared === undefined) {
|
|
108
|
+
throw new CliError(`Package "${specifier}" does not declare "${UI_REGISTRY_FIELD}" in its ${PACKAGE_JSON}.`);
|
|
109
|
+
}
|
|
110
|
+
const directoryValue = declared === true ? '.' : declared;
|
|
111
|
+
if (typeof directoryValue !== 'string' || directoryValue.trim() === '') {
|
|
112
|
+
throw new CliError(`${PACKAGE_JSON} of "${specifier}" must declare "${UI_REGISTRY_FIELD}" as a directory path.`);
|
|
113
|
+
}
|
|
114
|
+
const id = manifest[UI_REGISTRY_ID_FIELD];
|
|
115
|
+
if (typeof id !== 'string' || !REGISTRY_ID_PATTERN.test(id)) {
|
|
116
|
+
throw new CliError(`${PACKAGE_JSON} of "${specifier}" must declare "${UI_REGISTRY_ID_FIELD}" as a lowercase slug.`);
|
|
117
|
+
}
|
|
118
|
+
if (directoryValue !== '.')
|
|
119
|
+
assertSafeRelativePath(directoryValue);
|
|
120
|
+
const root = resolve(packageRoot, directoryValue);
|
|
121
|
+
if (!(await isDirectory(root))) {
|
|
122
|
+
throw new CliError(`Registry directory "${directoryValue}" declared by "${specifier}" does not exist.`);
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
packageRoot,
|
|
126
|
+
root,
|
|
127
|
+
id,
|
|
128
|
+
version: typeof manifest.version === 'string' ? manifest.version : '0.0.0',
|
|
129
|
+
uiRequires: readStringArray(manifest[UI_REQUIRES_FIELD], UI_REQUIRES_FIELD),
|
|
130
|
+
devRegistries: readStringArray(manifest[UI_DEV_REGISTRIES_FIELD], UI_DEV_REGISTRIES_FIELD)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export async function loadRegistryProvider(cwd, specifier, framework) {
|
|
134
|
+
const { packageRoot, root, id, version, uiRequires, devRegistries } = await resolveRegistryDirectory(cwd, specifier);
|
|
135
|
+
return {
|
|
136
|
+
specifier,
|
|
137
|
+
packageRoot,
|
|
138
|
+
root,
|
|
139
|
+
id,
|
|
140
|
+
version,
|
|
141
|
+
uiRequires,
|
|
142
|
+
devRegistries,
|
|
143
|
+
items: await listItemsFromDirectory(root, framework, specifier, id)
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
export async function loadRegistryProviders(cwd, specifiers, framework) {
|
|
147
|
+
const providers = [];
|
|
148
|
+
const ids = new Map();
|
|
149
|
+
for (const specifier of Array.from(new Set(specifiers))) {
|
|
150
|
+
const provider = await loadRegistryProvider(cwd, specifier, framework);
|
|
151
|
+
const owner = ids.get(provider.id);
|
|
152
|
+
if (owner) {
|
|
153
|
+
throw new CliError(`Duplicate registry id "${provider.id}" declared by "${owner}" and "${specifier}".`);
|
|
154
|
+
}
|
|
155
|
+
ids.set(provider.id, specifier);
|
|
156
|
+
providers.push(provider);
|
|
157
|
+
}
|
|
158
|
+
return providers;
|
|
159
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type SupportedFramework } from '../constants/index.js';
|
|
2
|
+
import type { RegistryItem, ResolvedRegistryItem } from '../types/registry.types.js';
|
|
3
|
+
export type ListRegistryOptions = {
|
|
4
|
+
cwd?: string;
|
|
5
|
+
framework?: SupportedFramework;
|
|
6
|
+
registries?: readonly string[];
|
|
7
|
+
};
|
|
8
|
+
export type ResolveOptions = ListRegistryOptions & {
|
|
9
|
+
kind?: string;
|
|
10
|
+
noDeps?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/** Lists entries from every registry configured for the project. */
|
|
13
|
+
export declare function listRegistryItems(options?: ListRegistryOptions): Promise<RegistryItem[]>;
|
|
14
|
+
export declare function resolveSelectedComponents(names: readonly string[], all: boolean, options?: ResolveOptions): Promise<ResolvedRegistryItem[]>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { assertFramework } from '../config/framework.helpers.js';
|
|
3
|
+
import { DEFAULT_FRAMEWORK } from '../constants/index.js';
|
|
4
|
+
import { CliError } from '../errors/index.js';
|
|
5
|
+
import { assertValidComponentName, assertValidRegistryKind } from './registry.helpers.js';
|
|
6
|
+
import { loadRegistryProviders } from './registry.providers.js';
|
|
7
|
+
function getContext(options) {
|
|
8
|
+
return {
|
|
9
|
+
cwd: options.cwd ? resolve(options.cwd) : process.cwd(),
|
|
10
|
+
framework: assertFramework(options.framework ?? DEFAULT_FRAMEWORK),
|
|
11
|
+
registries: options.registries ?? []
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function qualifiedName(item) {
|
|
15
|
+
return `${item.id}:${item.name}`;
|
|
16
|
+
}
|
|
17
|
+
function specifierName(item) {
|
|
18
|
+
return `${item.registry}:${item.name}`;
|
|
19
|
+
}
|
|
20
|
+
/** Lists entries from every registry configured for the project. */
|
|
21
|
+
export async function listRegistryItems(options = {}) {
|
|
22
|
+
const { cwd, framework, registries } = getContext(options);
|
|
23
|
+
if (registries.length === 0)
|
|
24
|
+
return [];
|
|
25
|
+
const providers = await loadRegistryProviders(cwd, registries, framework);
|
|
26
|
+
return providers.flatMap(provider => provider.items);
|
|
27
|
+
}
|
|
28
|
+
export async function resolveSelectedComponents(names, all, options = {}) {
|
|
29
|
+
const kind = assertValidRegistryKind(options.kind);
|
|
30
|
+
const { cwd, framework, registries } = getContext(options);
|
|
31
|
+
const items = await listRegistryItems({ cwd, framework, registries });
|
|
32
|
+
if (items.length === 0) {
|
|
33
|
+
throw new CliError('No registries configured. Add one with "ui registry add <package>" or pass --registry.');
|
|
34
|
+
}
|
|
35
|
+
const byQualified = new Map();
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
byQualified.set(qualifiedName(item), item);
|
|
38
|
+
byQualified.set(specifierName(item), item);
|
|
39
|
+
}
|
|
40
|
+
const byPlain = new Map();
|
|
41
|
+
for (const item of items) {
|
|
42
|
+
const existing = byPlain.get(item.name) ?? [];
|
|
43
|
+
existing.push(item);
|
|
44
|
+
byPlain.set(item.name, existing);
|
|
45
|
+
}
|
|
46
|
+
const describe = (item) => qualifiedName(item);
|
|
47
|
+
const resolveName = (name) => {
|
|
48
|
+
const exact = byQualified.get(name);
|
|
49
|
+
if (exact)
|
|
50
|
+
return exact;
|
|
51
|
+
const candidates = byPlain.get(name) ?? [];
|
|
52
|
+
if (candidates.length === 1)
|
|
53
|
+
return candidates[0];
|
|
54
|
+
if (candidates.length > 1) {
|
|
55
|
+
throw new CliError(`Ambiguous entry "${name}". Use one of: ${candidates.map(describe).join(', ')}.`);
|
|
56
|
+
}
|
|
57
|
+
if (name.includes(':')) {
|
|
58
|
+
const id = name.slice(0, name.indexOf(':'));
|
|
59
|
+
const ids = Array.from(new Set(items.map(item => item.id))).sort();
|
|
60
|
+
throw new CliError(`Unknown registry entry "${name}". No configured registry declares id "${id}". Available ids: ${ids.join(', ') || 'none'}.`);
|
|
61
|
+
}
|
|
62
|
+
const available = items
|
|
63
|
+
.filter(item => !item.hidden)
|
|
64
|
+
.map(describe)
|
|
65
|
+
.join(', ') || 'none';
|
|
66
|
+
throw new CliError(`Unknown registry entry/entries: ${name}. Available: ${available}.`);
|
|
67
|
+
};
|
|
68
|
+
const requestedNames = all
|
|
69
|
+
? items
|
|
70
|
+
.filter(item => !item.hidden && (kind === undefined || item.kind === kind))
|
|
71
|
+
.map(qualifiedName)
|
|
72
|
+
: Array.from(new Set(names));
|
|
73
|
+
if (requestedNames.length === 0) {
|
|
74
|
+
throw new CliError('No entries specified. Use <name...>, --all or --kind.');
|
|
75
|
+
}
|
|
76
|
+
for (const name of requestedNames) {
|
|
77
|
+
if (!name.includes(':') && !byPlain.has(name))
|
|
78
|
+
assertValidComponentName(name);
|
|
79
|
+
}
|
|
80
|
+
const selected = requestedNames.map(resolveName);
|
|
81
|
+
const hidden = selected.filter(item => item.hidden);
|
|
82
|
+
if (hidden.length > 0) {
|
|
83
|
+
throw new CliError(`Internal registry entries cannot be added directly: ${hidden.map(describe).join(', ')}. They are installed automatically as dependencies.`);
|
|
84
|
+
}
|
|
85
|
+
if (kind !== undefined) {
|
|
86
|
+
const wrongKind = selected.filter(item => item.kind !== kind);
|
|
87
|
+
if (wrongKind.length > 0) {
|
|
88
|
+
throw new CliError(`Expected kind "${kind}" but got: ${wrongKind.map(describe).join(', ')}.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const resolveDependency = (owner, dependency) => {
|
|
92
|
+
if (dependency.includes(':'))
|
|
93
|
+
return resolveName(dependency);
|
|
94
|
+
const local = items.find(item => item.id === owner.id && item.name === dependency);
|
|
95
|
+
if (local)
|
|
96
|
+
return local;
|
|
97
|
+
return resolveName(dependency);
|
|
98
|
+
};
|
|
99
|
+
const ordered = [];
|
|
100
|
+
const requested = new Set();
|
|
101
|
+
const resolved = new Set();
|
|
102
|
+
const visiting = [];
|
|
103
|
+
const visit = (item, isRequested) => {
|
|
104
|
+
const key = qualifiedName(item);
|
|
105
|
+
if (isRequested)
|
|
106
|
+
requested.add(key);
|
|
107
|
+
if (resolved.has(key))
|
|
108
|
+
return;
|
|
109
|
+
const cycleIndex = visiting.indexOf(key);
|
|
110
|
+
if (cycleIndex !== -1) {
|
|
111
|
+
throw new CliError(`Registry dependency cycle: ${[...visiting.slice(cycleIndex), key].join(' -> ')}`);
|
|
112
|
+
}
|
|
113
|
+
visiting.push(key);
|
|
114
|
+
if (!options.noDeps) {
|
|
115
|
+
for (const dependency of [...item.dependencies, ...item.requires]) {
|
|
116
|
+
visit(resolveDependency(item, dependency), false);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
visiting.pop();
|
|
120
|
+
resolved.add(key);
|
|
121
|
+
ordered.push({ ...item, requested: requested.has(key) });
|
|
122
|
+
};
|
|
123
|
+
for (const item of selected)
|
|
124
|
+
visit(item, true);
|
|
125
|
+
return ordered;
|
|
126
|
+
}
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import type { SupportedFramework } from '../constants/index.js';
|
|
2
|
+
import type { ExposureMode } from './registry.types.js';
|
|
2
3
|
export type ComponentsConfig = {
|
|
3
4
|
componentsDir: string;
|
|
4
5
|
framework: SupportedFramework;
|
|
5
6
|
overwrite: boolean;
|
|
7
|
+
/** Package specifiers that provide registry entries. */
|
|
8
|
+
registries: string[];
|
|
9
|
+
/** `full` installs every visible entry; `incremental` installs on demand. */
|
|
10
|
+
exposure: ExposureMode;
|
|
11
|
+
/** Entries owned by an incremental project; the reproducible source for CI. */
|
|
12
|
+
entries?: string[];
|
|
13
|
+
/** Optional deterministic CSS order across peers. */
|
|
14
|
+
themeOrder?: string[];
|
|
6
15
|
};
|
|
7
16
|
export type InitOptions = {
|
|
8
17
|
cwd?: string;
|
|
9
18
|
componentsDir?: string;
|
|
10
19
|
framework?: string;
|
|
11
20
|
variant?: string;
|
|
21
|
+
registries?: string[];
|
|
12
22
|
force?: boolean;
|
|
13
23
|
};
|
|
14
24
|
export type AddOptions = {
|
|
15
25
|
cwd?: string;
|
|
16
26
|
componentsDir?: string;
|
|
17
27
|
names: string[];
|
|
28
|
+
registries?: string[];
|
|
18
29
|
force?: boolean;
|
|
19
30
|
dryRun?: boolean;
|
|
20
31
|
all?: boolean;
|
|
@@ -27,6 +38,11 @@ export type ListOptions = {
|
|
|
27
38
|
cwd?: string;
|
|
28
39
|
kind?: string;
|
|
29
40
|
framework?: SupportedFramework;
|
|
41
|
+
registries?: string[];
|
|
42
|
+
};
|
|
43
|
+
export type RegistryOptions = {
|
|
44
|
+
cwd?: string;
|
|
45
|
+
names?: string[];
|
|
30
46
|
};
|
|
31
47
|
export type StylesOptions = {
|
|
32
48
|
cwd?: string;
|
|
@@ -37,5 +53,18 @@ export type StylesOptions = {
|
|
|
37
53
|
export type DoctorOptions = {
|
|
38
54
|
cwd?: string;
|
|
39
55
|
componentsDir?: string;
|
|
56
|
+
registries?: string[];
|
|
57
|
+
globalCss?: string;
|
|
58
|
+
};
|
|
59
|
+
export type InstallOptions = {
|
|
60
|
+
cwd?: string;
|
|
61
|
+
componentsDir?: string;
|
|
62
|
+
registries?: string[];
|
|
63
|
+
selectors?: string[];
|
|
64
|
+
exposure?: ExposureMode;
|
|
65
|
+
force?: boolean;
|
|
66
|
+
dryRun?: boolean;
|
|
67
|
+
frozen?: boolean;
|
|
68
|
+
installPeers?: boolean;
|
|
40
69
|
globalCss?: string;
|
|
41
70
|
};
|