@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,60 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { BASE_STYLE_IMPORT } from '../../constants/index.js';
|
|
4
|
+
import { toDisplayPath } from '../../helpers/path.helpers.js';
|
|
5
|
+
import { getInstalledItems, isFile } from '../doctor.helpers.js';
|
|
6
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
7
|
+
registerDoctorCheck({
|
|
8
|
+
id: 'barrels',
|
|
9
|
+
async run(context) {
|
|
10
|
+
const problems = [];
|
|
11
|
+
const themesBarrel = join(context.componentsDir, 'themes', 'index.css');
|
|
12
|
+
const runtimesBarrel = join(context.componentsDir, 'runtimes', 'index.ts');
|
|
13
|
+
const installed = await getInstalledItems(context);
|
|
14
|
+
if (!(await isFile(themesBarrel))) {
|
|
15
|
+
problems.push({
|
|
16
|
+
level: 'error',
|
|
17
|
+
message: `${context.displayDir}/themes/index.css is missing. Run "ui install".`
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const content = await readFile(themesBarrel, 'utf8');
|
|
22
|
+
if (!content.includes(`@import '${BASE_STYLE_IMPORT}';`)) {
|
|
23
|
+
problems.push({
|
|
24
|
+
level: 'error',
|
|
25
|
+
message: `${context.displayDir}/themes/index.css does not import ${BASE_STYLE_IMPORT}`
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
for (const item of installed) {
|
|
29
|
+
for (const file of item.files) {
|
|
30
|
+
if (!file.target.startsWith('themes/') || file.target.endsWith('index.css'))
|
|
31
|
+
continue;
|
|
32
|
+
const name = file.target.slice('themes/'.length);
|
|
33
|
+
if (!content.includes(`@import './${name}';`)) {
|
|
34
|
+
problems.push({
|
|
35
|
+
level: 'warn',
|
|
36
|
+
message: `${context.displayDir}/themes/index.css is missing ${name}`
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const hasRuntimes = installed.some(item => item.files.some(file => file.target.startsWith('runtimes/') && !file.target.endsWith('/index.ts')));
|
|
43
|
+
if (hasRuntimes && !(await isFile(runtimesBarrel))) {
|
|
44
|
+
problems.push({
|
|
45
|
+
level: 'error',
|
|
46
|
+
message: `${context.displayDir}/runtimes/index.ts is missing. Run "ui install".`
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (context.globalCss && (await isFile(context.globalCss))) {
|
|
50
|
+
const css = await readFile(context.globalCss, 'utf8');
|
|
51
|
+
if (!css.includes('themes/index.css')) {
|
|
52
|
+
problems.push({
|
|
53
|
+
level: 'warn',
|
|
54
|
+
message: `${toDisplayPath(context.cwd, context.globalCss)} does not import the themes barrel`
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { summary: 'generated entry points', problems };
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
2
|
+
const ROOTS = ['components', 'themes', 'runtimes'];
|
|
3
|
+
registerDoctorCheck({
|
|
4
|
+
id: 'contracts',
|
|
5
|
+
async run(context) {
|
|
6
|
+
const problems = [];
|
|
7
|
+
const items = context.items ?? [];
|
|
8
|
+
const providers = context.providers ?? [];
|
|
9
|
+
const ids = new Map();
|
|
10
|
+
for (const provider of providers) {
|
|
11
|
+
const owner = ids.get(provider.id);
|
|
12
|
+
if (owner) {
|
|
13
|
+
problems.push({
|
|
14
|
+
level: 'error',
|
|
15
|
+
message: `Duplicate registry id "${provider.id}" (${owner}, ${provider.specifier})`
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
ids.set(provider.id, provider.specifier);
|
|
19
|
+
}
|
|
20
|
+
const available = new Set(items.map(item => `${item.id}:${item.name}`));
|
|
21
|
+
for (const item of items) {
|
|
22
|
+
const allowed = ROOTS.map(root => `${root}/${item.id}/`);
|
|
23
|
+
for (const file of item.files) {
|
|
24
|
+
if (!allowed.some(prefix => file.target.startsWith(prefix))) {
|
|
25
|
+
problems.push({
|
|
26
|
+
level: 'error',
|
|
27
|
+
message: `${item.id}:${item.name} → ${file.target} escapes its namespace`
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const request of item.requires) {
|
|
32
|
+
if (!available.has(request)) {
|
|
33
|
+
problems.push({
|
|
34
|
+
level: 'error',
|
|
35
|
+
message: `${item.id}:${item.name} requires "${request}" which is not configured`
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
summary: `${items.length} entries, ${providers.length} registries`,
|
|
42
|
+
problems
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
@@ -4,11 +4,14 @@ import { localNames } from '../doctor.helpers.js';
|
|
|
4
4
|
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
5
5
|
function parseIconExports(content) {
|
|
6
6
|
const names = new Set();
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const reexport = /export\s*\{([^}]*)\}\s*from\s*['"][^'"]+['"]/g;
|
|
8
|
+
const declaration = /export\s+(?:function|const|class)\s+(\w+)/g;
|
|
9
|
+
for (const match of content.matchAll(reexport)) {
|
|
9
10
|
for (const name of localNames(match[1]))
|
|
10
11
|
names.add(name);
|
|
11
12
|
}
|
|
13
|
+
for (const match of content.matchAll(declaration))
|
|
14
|
+
names.add(match[1]);
|
|
12
15
|
return names;
|
|
13
16
|
}
|
|
14
17
|
function parseIconImports(content) {
|
|
@@ -24,6 +27,8 @@ registerDoctorCheck({
|
|
|
24
27
|
id: 'icons',
|
|
25
28
|
async run(context) {
|
|
26
29
|
const iconFiles = context.files.filter(file => /[\\/]icons[\\/].*\.tsx?$/.test(file));
|
|
30
|
+
if (iconFiles.length === 0)
|
|
31
|
+
return null;
|
|
27
32
|
const iconFileSet = new Set(iconFiles);
|
|
28
33
|
const exported = new Set();
|
|
29
34
|
for (const file of iconFiles) {
|
|
@@ -42,7 +47,7 @@ registerDoctorCheck({
|
|
|
42
47
|
if (!exported.has(name)) {
|
|
43
48
|
problems.push({
|
|
44
49
|
level: 'error',
|
|
45
|
-
message: `${toDisplayPath(context.cwd, file)} imports "${name}" not exported from
|
|
50
|
+
message: `${toDisplayPath(context.cwd, file)} imports "${name}" not exported from any icons module`
|
|
46
51
|
});
|
|
47
52
|
}
|
|
48
53
|
}
|
|
@@ -5,7 +5,7 @@ const MOTION_CLASS = /\b(?:motion-(?:color|fade|fade-slow|transform|press|lift|f
|
|
|
5
5
|
registerDoctorCheck({
|
|
6
6
|
id: 'motion',
|
|
7
7
|
async run(context) {
|
|
8
|
-
const hasMotionStyles = context.files.some(file => /[\\/]
|
|
8
|
+
const hasMotionStyles = context.files.some(file => /[\\/]themes[\\/].*motion\.css$/.test(file));
|
|
9
9
|
if (hasMotionStyles)
|
|
10
10
|
return null;
|
|
11
11
|
const matches = await Promise.all(context.sourceFiles.map(async (file) => {
|
|
@@ -21,7 +21,7 @@ registerDoctorCheck({
|
|
|
21
21
|
const problems = [
|
|
22
22
|
{
|
|
23
23
|
level: 'warn',
|
|
24
|
-
message: `Motion utilities are in use but ${context.displayDir}/
|
|
24
|
+
message: `Motion utilities are in use but ${context.displayDir}/themes/<id>/motion.css is missing. Run "${CLI_NAME} add styles-motion".`,
|
|
25
25
|
},
|
|
26
26
|
];
|
|
27
27
|
return { summary: 'motion styles missing, 1 issue', problems };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { join, sep } from 'node:path';
|
|
3
|
+
import { posix } from 'node:path';
|
|
4
|
+
import { toDisplayPath } from '../../helpers/path.helpers.js';
|
|
5
|
+
import { isFile } from '../doctor.helpers.js';
|
|
6
|
+
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
7
|
+
const RELATIVE_IMPORT = /(?:from\s*|import\s*\(\s*|import\s*)['"](\.{1,2}\/[^'"]+)['"]/g;
|
|
8
|
+
function toPosix(path) {
|
|
9
|
+
return path.split(sep).join('/');
|
|
10
|
+
}
|
|
11
|
+
function peerOf(target) {
|
|
12
|
+
return target.split('/')[1] ?? '';
|
|
13
|
+
}
|
|
14
|
+
function ownerOf(items, target) {
|
|
15
|
+
return items.find(item => item.files.some(file => file.target === target));
|
|
16
|
+
}
|
|
17
|
+
async function resolveTarget(specifier, fromTarget, root) {
|
|
18
|
+
const base = posix.normalize(posix.join(posix.dirname(fromTarget), specifier));
|
|
19
|
+
const extension = posix.extname(base);
|
|
20
|
+
const candidates = [base];
|
|
21
|
+
if (extension === '.js' || extension === '.jsx' || extension === '.mjs') {
|
|
22
|
+
const stem = base.slice(0, -extension.length);
|
|
23
|
+
candidates.push(`${stem}.ts`, `${stem}.tsx`, `${stem}.js`, `${stem}.jsx`);
|
|
24
|
+
}
|
|
25
|
+
else if (extension === '') {
|
|
26
|
+
candidates.push(`${base}.ts`, `${base}.tsx`, `${base}.js`, `${base}.jsx`, posix.join(base, 'index.ts'), posix.join(base, 'index.tsx'));
|
|
27
|
+
}
|
|
28
|
+
for (const candidate of candidates) {
|
|
29
|
+
if (await isFile(join(root, ...candidate.split('/'))))
|
|
30
|
+
return candidate;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
registerDoctorCheck({
|
|
35
|
+
id: 'namespaces',
|
|
36
|
+
async run(context) {
|
|
37
|
+
const problems = [];
|
|
38
|
+
const items = context.items ?? [];
|
|
39
|
+
let checked = 0;
|
|
40
|
+
let crossed = 0;
|
|
41
|
+
for (const file of context.sourceFiles) {
|
|
42
|
+
const target = toPosix(file.slice(context.componentsDir.length + 1));
|
|
43
|
+
if (target.endsWith('/index.ts'))
|
|
44
|
+
continue;
|
|
45
|
+
const owner = ownerOf(items, target);
|
|
46
|
+
if (!owner)
|
|
47
|
+
continue;
|
|
48
|
+
const content = await readFile(file, 'utf8');
|
|
49
|
+
for (const match of content.matchAll(RELATIVE_IMPORT)) {
|
|
50
|
+
const resolved = await resolveTarget(match[1], target, context.componentsDir);
|
|
51
|
+
if (!resolved)
|
|
52
|
+
continue;
|
|
53
|
+
checked += 1;
|
|
54
|
+
const dependency = ownerOf(items, resolved);
|
|
55
|
+
const targetPeer = peerOf(resolved);
|
|
56
|
+
if (!targetPeer || targetPeer === owner.id)
|
|
57
|
+
continue;
|
|
58
|
+
crossed += 1;
|
|
59
|
+
const declared = dependency
|
|
60
|
+
? owner.requires.includes(`${dependency.id}:${dependency.name}`)
|
|
61
|
+
: owner.requires.some(request => request.startsWith(`${targetPeer}:`));
|
|
62
|
+
if (!declared) {
|
|
63
|
+
const expected = dependency ? `${dependency.id}:${dependency.name}` : `${targetPeer}:*`;
|
|
64
|
+
problems.push({
|
|
65
|
+
level: 'error',
|
|
66
|
+
message: `${toDisplayPath(context.cwd, file)} crosses ${targetPeer} without requires "${expected}"`
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
summary: `${checked} imports checked, ${crossed} cross-peer${problems.length > 0 ? `, ${problems.length} undeclared` : ''}`,
|
|
73
|
+
problems
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
});
|
|
@@ -1,63 +1,41 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import {
|
|
3
|
-
import { isFile } from '../doctor.helpers.js';
|
|
2
|
+
import { getInstalledItems } from '../doctor.helpers.js';
|
|
4
3
|
import { registerDoctorCheck } from '../doctor.registry.js';
|
|
5
|
-
|
|
6
|
-
const names = new Set();
|
|
7
|
-
const pattern = /export\s+const\s+\w+\s*:\s*(?:Theme|ThemePreference)\s*=\s*['"]([^'"]+)['"]/g;
|
|
8
|
-
for (const match of content.matchAll(pattern)) {
|
|
9
|
-
if (match[1] !== 'system')
|
|
10
|
-
names.add(match[1]);
|
|
11
|
-
}
|
|
12
|
-
return names;
|
|
13
|
-
}
|
|
14
|
-
function parseCssThemes(content) {
|
|
15
|
-
const names = new Set();
|
|
16
|
-
for (const match of content.matchAll(/\[data-theme\s*=\s*['"]([^'"]+)['"]\]/g)) {
|
|
17
|
-
names.add(match[1]);
|
|
18
|
-
}
|
|
19
|
-
// `:root` is the default theme, so it covers `light` without an explicit block.
|
|
20
|
-
if (/\B:root\s*\{/.test(content))
|
|
21
|
-
names.add('light');
|
|
22
|
-
return names;
|
|
23
|
-
}
|
|
4
|
+
const DECLARED_THEME = /\[data-(?:[\w-]+-)?theme\s*=\s*['"]([^'"]+)['"]\]/g;
|
|
24
5
|
registerDoctorCheck({
|
|
25
6
|
id: 'themes',
|
|
26
7
|
async run(context) {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
for (const file of themeFiles) {
|
|
30
|
-
const content = await readFile(file, 'utf8');
|
|
31
|
-
for (const name of parseThemeConstants(content))
|
|
32
|
-
constants.add(name);
|
|
33
|
-
}
|
|
34
|
-
const tokensPath = join(context.componentsDir, 'styles', 'tokens.css');
|
|
8
|
+
const problems = [];
|
|
9
|
+
const declared = new Set((await getInstalledItems(context)).flatMap(item => item.themes));
|
|
35
10
|
const cssThemes = new Set();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
11
|
+
let cssFiles = 0;
|
|
12
|
+
for (const file of context.files) {
|
|
13
|
+
if (!/[\\/]themes[\\/].*\.css$/.test(file) || file.endsWith('index.css'))
|
|
14
|
+
continue;
|
|
15
|
+
cssFiles += 1;
|
|
16
|
+
const content = await readFile(file, 'utf8');
|
|
17
|
+
for (const match of content.matchAll(DECLARED_THEME))
|
|
18
|
+
cssThemes.add(match[1]);
|
|
40
19
|
}
|
|
41
|
-
const
|
|
42
|
-
for (const name of constants) {
|
|
20
|
+
for (const name of declared) {
|
|
43
21
|
if (!cssThemes.has(name)) {
|
|
44
22
|
problems.push({
|
|
45
23
|
level: 'warn',
|
|
46
|
-
message: `"${name}" is
|
|
24
|
+
message: `Theme "${name}" is declared but has no CSS block.`
|
|
47
25
|
});
|
|
48
26
|
}
|
|
49
27
|
}
|
|
50
28
|
for (const name of cssThemes) {
|
|
51
|
-
if (!
|
|
29
|
+
if (!declared.has(name)) {
|
|
52
30
|
problems.push({
|
|
53
31
|
level: 'warn',
|
|
54
|
-
message: `CSS theme "${name}"
|
|
32
|
+
message: `CSS theme "${name}" is not declared by any registry entry.`
|
|
55
33
|
});
|
|
56
34
|
}
|
|
57
35
|
}
|
|
58
|
-
const names = Array.from(new Set([...
|
|
36
|
+
const names = Array.from(new Set([...declared, ...cssThemes])).sort();
|
|
59
37
|
return {
|
|
60
|
-
summary: `${names.length}
|
|
38
|
+
summary: `${names.length} themes in ${cssFiles} files (${names.join(', ') || 'none'})${problems.length > 0 ? `, ${problems.length} mismatches` : ''}`,
|
|
61
39
|
problems
|
|
62
40
|
};
|
|
63
41
|
}
|
|
@@ -22,7 +22,11 @@ export function localNames(block) {
|
|
|
22
22
|
}
|
|
23
23
|
export async function getInstalledItems(context) {
|
|
24
24
|
const installed = [];
|
|
25
|
-
for (const item of await listRegistryItems({
|
|
25
|
+
for (const item of await listRegistryItems({
|
|
26
|
+
cwd: context.cwd,
|
|
27
|
+
framework: context.framework,
|
|
28
|
+
registries: context.registries ?? []
|
|
29
|
+
})) {
|
|
26
30
|
if (item.hidden || item.files.length === 0)
|
|
27
31
|
continue;
|
|
28
32
|
let present = true;
|
|
@@ -11,7 +11,11 @@ export type DoctorContext = {
|
|
|
11
11
|
files: string[];
|
|
12
12
|
sourceFiles: string[];
|
|
13
13
|
framework?: SupportedFramework;
|
|
14
|
+
registries?: readonly string[];
|
|
14
15
|
globalCss?: string;
|
|
16
|
+
items?: import('../types/registry.types.js').RegistryItem[];
|
|
17
|
+
providers?: import('../types/registry.types.js').RegistryProvider[];
|
|
18
|
+
lock?: import('../registry/lockfile.js').Lockfile;
|
|
15
19
|
};
|
|
16
20
|
export type DoctorCheckResult = {
|
|
17
21
|
summary?: string;
|
|
@@ -2,3 +2,5 @@ import type { CliArgs, FlagValue } from '../types/cli.types.js';
|
|
|
2
2
|
export declare function parseArgs(argv: readonly string[]): CliArgs;
|
|
3
3
|
export declare function getStringFlag(flags: Record<string, FlagValue>, key: string): string | undefined;
|
|
4
4
|
export declare function isFlagEnabled(flags: Record<string, FlagValue>, key: string): boolean;
|
|
5
|
+
/** Reads a comma-separated string flag as a deduplicated list. */
|
|
6
|
+
export declare function getStringListFlag(flags: Record<string, FlagValue>, key: string): string[] | undefined;
|
|
@@ -11,6 +11,8 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
11
11
|
'all',
|
|
12
12
|
'noDeps',
|
|
13
13
|
'noImport',
|
|
14
|
+
'frozen',
|
|
15
|
+
'installPeers',
|
|
14
16
|
'yes'
|
|
15
17
|
]);
|
|
16
18
|
function normalizeFlag(raw) {
|
|
@@ -73,3 +75,10 @@ export function isFlagEnabled(flags, key) {
|
|
|
73
75
|
const value = flags[key];
|
|
74
76
|
return value === true || value === 'true';
|
|
75
77
|
}
|
|
78
|
+
/** Reads a comma-separated string flag as a deduplicated list. */
|
|
79
|
+
export function getStringListFlag(flags, key) {
|
|
80
|
+
const value = getStringFlag(flags, key);
|
|
81
|
+
if (value === undefined)
|
|
82
|
+
return undefined;
|
|
83
|
+
return Array.from(new Set(value.split(',').map(entry => entry.trim()).filter(Boolean)));
|
|
84
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type BarrelsSyncOptions = {
|
|
2
|
+
cwd: string;
|
|
3
|
+
componentsDir: string;
|
|
4
|
+
globalCss?: string;
|
|
5
|
+
themeOrder?: readonly string[];
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type BarrelsSyncResult = {
|
|
9
|
+
barrels: string[];
|
|
10
|
+
css?: string;
|
|
11
|
+
importLine?: string;
|
|
12
|
+
changed: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Regenerates the generated entry points of the namespaced layout. */
|
|
15
|
+
export declare function syncBarrels(options: BarrelsSyncOptions): Promise<BarrelsSyncResult>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { BASE_STYLE_IMPORT, RUNTIMES_SUBDIR, THEMES_SUBDIR } from '../constants/index.js';
|
|
4
|
+
import { findGlobalStylesheet, toCssImport } from './styles.helpers.js';
|
|
5
|
+
async function isFile(path) {
|
|
6
|
+
try {
|
|
7
|
+
return (await stat(path)).isFile();
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
async function walk(directory, prefix = '') {
|
|
14
|
+
const output = [];
|
|
15
|
+
let entries;
|
|
16
|
+
try {
|
|
17
|
+
entries = await readdir(directory, { withFileTypes: true });
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return output;
|
|
21
|
+
}
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
24
|
+
const fullPath = join(directory, entry.name);
|
|
25
|
+
if (entry.isDirectory()) {
|
|
26
|
+
output.push(...(await walk(fullPath, relativePath)));
|
|
27
|
+
}
|
|
28
|
+
else if (entry.isFile()) {
|
|
29
|
+
output.push(relativePath);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return output;
|
|
33
|
+
}
|
|
34
|
+
function peerOf(relativePath) {
|
|
35
|
+
return relativePath.split('/')[0] ?? '';
|
|
36
|
+
}
|
|
37
|
+
function orderedPeers(peers, themeOrder) {
|
|
38
|
+
const rank = (peer) => {
|
|
39
|
+
const index = themeOrder.indexOf(peer);
|
|
40
|
+
return index === -1 ? themeOrder.length : index;
|
|
41
|
+
};
|
|
42
|
+
return [...peers].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b));
|
|
43
|
+
}
|
|
44
|
+
const CSS_ORDER = ['tokens', 'base', 'components', 'utilities', 'motion'];
|
|
45
|
+
function compareCss(left, right) {
|
|
46
|
+
const rank = (file) => {
|
|
47
|
+
const name = basename(file).replace(/\.css$/, '');
|
|
48
|
+
const index = CSS_ORDER.indexOf(name);
|
|
49
|
+
return index === -1 ? CSS_ORDER.length : index;
|
|
50
|
+
};
|
|
51
|
+
return rank(left) - rank(right) || left.localeCompare(right);
|
|
52
|
+
}
|
|
53
|
+
function buildThemesBarrel(files, themeOrder) {
|
|
54
|
+
const css = files.filter(file => file.endsWith('.css') && !file.endsWith('/index.css'));
|
|
55
|
+
const peers = orderedPeers(Array.from(new Set(css.map(peerOf))), themeOrder);
|
|
56
|
+
const lines = [`@import '${BASE_STYLE_IMPORT}';`];
|
|
57
|
+
for (const peer of peers) {
|
|
58
|
+
for (const file of css.filter(item => peerOf(item) === peer).sort(compareCss)) {
|
|
59
|
+
lines.push(`@import './${file}';`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return `${lines.join('\n')}\n`;
|
|
63
|
+
}
|
|
64
|
+
function buildPeerRuntimeBarrel(files) {
|
|
65
|
+
const names = files
|
|
66
|
+
.filter(file => /\.tsx?$/.test(file) && !file.endsWith('/index.ts'))
|
|
67
|
+
.map(file => basename(file).replace(/\.tsx?$/, ''))
|
|
68
|
+
.sort();
|
|
69
|
+
if (names.length === 0)
|
|
70
|
+
return null;
|
|
71
|
+
return `${names.map(name => `export * from './${name}.js'`).join('\n')}\n`;
|
|
72
|
+
}
|
|
73
|
+
function buildRuntimeBarrel(peers) {
|
|
74
|
+
if (peers.length === 0)
|
|
75
|
+
return null;
|
|
76
|
+
return `${peers.map(peer => `export * from './${peer}/index.js'`).join('\n')}\n`;
|
|
77
|
+
}
|
|
78
|
+
function withBarrelImport(content, importLine) {
|
|
79
|
+
const withoutLegacy = content
|
|
80
|
+
.split(/\r?\n/)
|
|
81
|
+
.filter(line => !/styles\/index\.css/.test(line))
|
|
82
|
+
.join('\n');
|
|
83
|
+
if (withoutLegacy.includes(importLine))
|
|
84
|
+
return withoutLegacy;
|
|
85
|
+
const tailwind = withoutLegacy.match(/@import\s+['"]tailwindcss['"]\s*;?\s*\r?\n?/);
|
|
86
|
+
if (tailwind?.index !== undefined) {
|
|
87
|
+
const index = tailwind.index + tailwind[0].length;
|
|
88
|
+
return `${withoutLegacy.slice(0, index)}${importLine}\n${withoutLegacy.slice(index)}`;
|
|
89
|
+
}
|
|
90
|
+
return `${importLine}\n${withoutLegacy.replace(/^\r?\n/, '')}`;
|
|
91
|
+
}
|
|
92
|
+
async function writeIfChanged(path, next, dryRun) {
|
|
93
|
+
let changed = true;
|
|
94
|
+
try {
|
|
95
|
+
changed = (await readFile(path, 'utf8')) !== next;
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
changed = true;
|
|
99
|
+
}
|
|
100
|
+
if (changed && !dryRun) {
|
|
101
|
+
await mkdir(dirname(path), { recursive: true });
|
|
102
|
+
await writeFile(path, next, 'utf8');
|
|
103
|
+
}
|
|
104
|
+
return changed;
|
|
105
|
+
}
|
|
106
|
+
/** Regenerates the generated entry points of the namespaced layout. */
|
|
107
|
+
export async function syncBarrels(options) {
|
|
108
|
+
const root = resolve(options.cwd, options.componentsDir);
|
|
109
|
+
const themeDir = join(root, THEMES_SUBDIR);
|
|
110
|
+
const runtimeDir = join(root, RUNTIMES_SUBDIR);
|
|
111
|
+
const themeOrder = options.themeOrder ?? [];
|
|
112
|
+
const themeFiles = (await walk(themeDir)).filter(file => file !== 'index.css');
|
|
113
|
+
const runtimeFiles = (await walk(runtimeDir)).filter(file => file !== 'index.ts' && !file.endsWith('/index.ts'));
|
|
114
|
+
const result = { barrels: [], changed: false };
|
|
115
|
+
if (themeFiles.length > 0) {
|
|
116
|
+
const barrelPath = join(themeDir, 'index.css');
|
|
117
|
+
if (await writeIfChanged(barrelPath, buildThemesBarrel(themeFiles, themeOrder), Boolean(options.dryRun))) {
|
|
118
|
+
result.changed = true;
|
|
119
|
+
result.barrels.push(barrelPath);
|
|
120
|
+
}
|
|
121
|
+
const globalCss = await findGlobalStylesheet(options.cwd, barrelPath, options.globalCss);
|
|
122
|
+
if (globalCss) {
|
|
123
|
+
const importLine = toCssImport(globalCss, barrelPath);
|
|
124
|
+
const content = await readFile(globalCss, 'utf8');
|
|
125
|
+
const next = withBarrelImport(content, importLine);
|
|
126
|
+
const cssChanged = next !== content;
|
|
127
|
+
if (cssChanged && !options.dryRun)
|
|
128
|
+
await writeFile(globalCss, next, 'utf8');
|
|
129
|
+
result.css = globalCss;
|
|
130
|
+
result.importLine = importLine;
|
|
131
|
+
result.changed = result.changed || cssChanged;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (runtimeFiles.length > 0) {
|
|
135
|
+
const peers = orderedPeers(Array.from(new Set(runtimeFiles.map(peerOf))), themeOrder);
|
|
136
|
+
for (const peer of peers) {
|
|
137
|
+
const files = runtimeFiles.filter(file => peerOf(file) === peer);
|
|
138
|
+
const content = buildPeerRuntimeBarrel(files);
|
|
139
|
+
if (!content)
|
|
140
|
+
continue;
|
|
141
|
+
const path = join(runtimeDir, peer, 'index.ts');
|
|
142
|
+
if (await writeIfChanged(path, content, Boolean(options.dryRun))) {
|
|
143
|
+
result.changed = true;
|
|
144
|
+
result.barrels.push(path);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const rootBarrel = buildRuntimeBarrel(peers);
|
|
148
|
+
if (rootBarrel) {
|
|
149
|
+
const path = join(runtimeDir, 'index.ts');
|
|
150
|
+
if (await writeIfChanged(path, rootBarrel, Boolean(options.dryRun))) {
|
|
151
|
+
result.changed = true;
|
|
152
|
+
result.barrels.push(path);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return result;
|
|
157
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export
|
|
1
|
+
/**
|
|
2
|
+
* Public, curated build-time API of @blankways/ui.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here starts a runtime in the browser: every export performs work at
|
|
5
|
+
* build time against a project root and is safe to call from a script/CI job.
|
|
6
|
+
*/
|
|
7
|
+
export { ensure, ensureAll, install, status, sync, validate } from './ui-api/index.js';
|
|
8
|
+
/** Extension points. Importing the package root never registers built-in commands. */
|
|
9
|
+
export { registerCliCommand } from './cli/cli.registry.js';
|
|
10
|
+
export { registerDoctorCheck } from './doctor/doctor.registry.js';
|
|
11
|
+
export { listRegistryItems } from './registry/registry.service.js';
|
|
12
|
+
export type { ExposureMode, InstallOptions, InstallResult, LockEntry, Lockfile } from './ui-api/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export
|
|
1
|
+
/**
|
|
2
|
+
* Public, curated build-time API of @blankways/ui.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here starts a runtime in the browser: every export performs work at
|
|
5
|
+
* build time against a project root and is safe to call from a script/CI job.
|
|
6
|
+
*/
|
|
7
|
+
export { ensure, ensureAll, install, status, sync, validate } from './ui-api/index.js';
|
|
8
|
+
/** Extension points. Importing the package root never registers built-in commands. */
|
|
9
|
+
export { registerCliCommand } from './cli/cli.registry.js';
|
|
10
|
+
export { registerDoctorCheck } from './doctor/doctor.registry.js';
|
|
11
|
+
export { listRegistryItems } from './registry/registry.service.js';
|
package/dist/registry/index.d.ts
CHANGED
package/dist/registry/index.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type LockEntry = {
|
|
2
|
+
revision: number;
|
|
3
|
+
files: Record<string, string>;
|
|
4
|
+
};
|
|
5
|
+
export type Lockfile = {
|
|
6
|
+
version: 1;
|
|
7
|
+
exposure: string;
|
|
8
|
+
registries: Record<string, {
|
|
9
|
+
id: string;
|
|
10
|
+
version: string;
|
|
11
|
+
}>;
|
|
12
|
+
entries: Record<string, LockEntry>;
|
|
13
|
+
};
|
|
14
|
+
export declare function createEmptyLock(exposure?: string): Lockfile;
|
|
15
|
+
export declare function readLockfile(cwd: string): Promise<Lockfile>;
|
|
16
|
+
export declare function writeLockfile(cwd: string, lock: Lockfile): Promise<void>;
|
|
17
|
+
export declare function hashContent(content: string): string;
|
|
18
|
+
export declare function hashFile(path: string): Promise<string>;
|