@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
package/README.md
CHANGED
|
@@ -1,132 +1,182 @@
|
|
|
1
1
|
# @blankways/ui
|
|
2
2
|
|
|
3
|
-
CLI
|
|
3
|
+
API build-time y CLI para **componer registries externos** dentro de `ui/`. El paquete no incluye componentes, no trae un runtime propio, no importa React y no tiene registry integrado. Cada proveedor publica sus entradas en su propio paquete y `@blankways/ui` solo las descubre, valida, copia y sincroniza.
|
|
4
4
|
|
|
5
|
-
El
|
|
5
|
+
El resultado en el proyecto consumidor es siempre el mismo:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```text
|
|
8
|
+
ui/
|
|
9
|
+
components/<uiRegistryId>/...
|
|
10
|
+
themes/<uiRegistryId>/...
|
|
11
|
+
runtimes/<uiRegistryId>/...
|
|
12
|
+
themes/index.css # generado
|
|
13
|
+
runtimes/index.ts # generado
|
|
14
|
+
ui.lock.json # commiteado
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`@blankways/ui/styles.css` es la base inmutable: se importa desde `ui/themes/index.css`, nunca se copia a `ui/`. No existen `ui/styles/` ni `ui/internals/` globales.
|
|
18
|
+
|
|
19
|
+
## Instalación
|
|
8
20
|
|
|
9
21
|
```bash
|
|
10
22
|
pnpm add -D @blankways/ui
|
|
11
|
-
|
|
12
|
-
pnpm exec ui
|
|
13
|
-
pnpm exec ui add button input
|
|
14
|
-
pnpm exec ui add theme-provider theme-toggle theme-selector
|
|
15
|
-
pnpm exec ui add icons-toast toast
|
|
16
|
-
pnpm exec ui add styles-tokens styles-base styles-components styles-utilities
|
|
17
|
-
pnpm exec ui styles link
|
|
23
|
+
pnpm exec ui init --framework react --registry @blankways/react-registry
|
|
24
|
+
pnpm exec ui install
|
|
18
25
|
pnpm exec ui doctor
|
|
19
|
-
pnpm exec ui list
|
|
20
26
|
```
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`init` escribe el framework elegido en `components.json`. Las entradas del registro están etiquetadas con ese framework, así que `add`, `list` y `doctor` solo ven las alternativas instalables para el proyecto:
|
|
28
|
+
`init` crea `components.json`, materializa **todo** (`exposure: "full"`) y escribe `ui.lock.json`. `install` repite ese workflow de forma idempotente. `ui/` puede borrarse y regenerarse; el lockfile debe commitearse.
|
|
25
29
|
|
|
26
30
|
```json
|
|
27
31
|
{
|
|
28
32
|
"componentsDir": "ui",
|
|
29
33
|
"framework": "react",
|
|
30
|
-
"overwrite": false
|
|
34
|
+
"overwrite": false,
|
|
35
|
+
"registries": ["@blankways/react-registry"],
|
|
36
|
+
"exposure": "incremental",
|
|
37
|
+
"entries": ["bw:brand-logo", "bw:container", "bw:cursor-glow", "bw:reveal"],
|
|
38
|
+
"themeOrder": ["bw", "acme"]
|
|
31
39
|
}
|
|
32
40
|
```
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
- `exposure: "full"` (por defecto) instala cada entrada visible de cada registry; `entries` se ignora.
|
|
43
|
+
- `exposure: "incremental"` instala solo `entries`, más su clausura de `requires`. Esa lista es la fuente de verdad para `ui install --frozen` en CI.
|
|
44
|
+
- `add` y `ensure()` siguen pudiendo pedir entradas concretas por encima de la config.
|
|
45
|
+
- `themeOrder` fija el orden CSS entre peers; dentro de cada peer el orden es determinista.
|
|
35
46
|
|
|
36
|
-
|
|
47
|
+
## Workflow
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
Toda escritura pasa por la misma secuencia; no se escribe nada antes de validar:
|
|
39
50
|
|
|
40
|
-
|
|
51
|
+
```text
|
|
52
|
+
DISCOVER → RESOLVE → VALIDATE → PLAN → APPLY → SYNC → VERIFY
|
|
53
|
+
```
|
|
41
54
|
|
|
42
|
-
|
|
55
|
+
`planActions` compara la entrada con el lockfile: archivo ausente → `add`, lockfile coincidente → `update`, modificación local → `keep`. La decisión es reproducible y `--dry-run` muestra el plan sin tocar disco.
|
|
43
56
|
|
|
44
|
-
|
|
45
|
-
|---|---|
|
|
46
|
-
| `component` | `button`, `input`, `select`, `tabs`, `toast`, `sidebar` |
|
|
47
|
-
| `icon` | `icons`, `icons-theme`, `icons-form`, `icons-sidebar`, `icons-toast` |
|
|
48
|
-
| `theme` | `theme-core`, `theme-provider`, `theme-light`, `theme-dark`, `theme-system`, `theme-toggle`, `theme-selector` |
|
|
49
|
-
| `style` | `styles-tokens`, `styles-base`, `styles-components`, `styles-utilities` |
|
|
50
|
-
| `utility` | `button-styles`, `field-styles` |
|
|
57
|
+
## API build-time
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
```ts
|
|
60
|
+
import {
|
|
61
|
+
ensure, // entradas concretas + clausura de requires
|
|
62
|
+
ensureAll, // composición completa
|
|
63
|
+
install, // operación general (selectors, exposure, frozen…)
|
|
64
|
+
status, // lockfile actual
|
|
65
|
+
sync, // solo regenera barrels
|
|
66
|
+
validate // solo valida contratos
|
|
67
|
+
} from '@blankways/ui'
|
|
53
68
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<App />
|
|
57
|
-
</ThemeProvider>
|
|
69
|
+
await ensureAll({ cwd: process.cwd() })
|
|
70
|
+
await ensure(['acme:button'], { cwd: process.cwd() })
|
|
58
71
|
```
|
|
59
72
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Lista todo o filtra:
|
|
73
|
+
Ninguna de estas funciones arranca código en el browser. Todas reciben una raíz de proyecto y son seguras en un script de build o en CI:
|
|
63
74
|
|
|
64
75
|
```bash
|
|
65
|
-
pnpm exec ui
|
|
66
|
-
pnpm exec ui list --kind icon
|
|
67
|
-
pnpm exec ui list --kind theme
|
|
76
|
+
pnpm exec ui install --frozen
|
|
68
77
|
```
|
|
69
78
|
|
|
70
|
-
|
|
79
|
+
`--frozen` falla si cambiaron las entradas, las revisiones o `exposure`, sin reescribir el lockfile.
|
|
71
80
|
|
|
72
|
-
|
|
73
|
-
- `--components-dir <path>`: sobrescribe `componentsDir`.
|
|
74
|
-
- `--framework <name>`: alternativa de UI para `init` (ahora mismo `react`; alias: `--variant`).
|
|
75
|
-
- `--global-css <path>`: CSS global donde se conecta `ui/styles/index.css` (se detecta solo si se omite).
|
|
76
|
-
- `--kind <kind>`: filtra `list` o `add` por tipo.
|
|
77
|
-
- `--force`: sobrescribe archivos existentes o `components.json`.
|
|
78
|
-
- `--dry-run`: muestra qué se copiaría sin escribir.
|
|
79
|
-
- `--all`: agrega todas las entradas (combina con `--kind`).
|
|
80
|
-
- `--no-deps`: no copia dependencias del registry.
|
|
81
|
-
- `--no-import`: no conecta los estilos después de `add`.
|
|
81
|
+
## Contrato de un registry
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
`package.json` del proveedor:
|
|
84
84
|
|
|
85
|
-
```
|
|
86
|
-
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"name": "@mi-org/acme-ui",
|
|
88
|
+
"version": "1.0.0",
|
|
89
|
+
"uiRegistry": "ui",
|
|
90
|
+
"uiRegistryId": "acme",
|
|
91
|
+
"uiRequires": ["@blankways/ui@^0.2.0-alpha.1"],
|
|
92
|
+
"uiDevRegistries": ["../mi-state-runtime"],
|
|
93
|
+
"exports": { "./package.json": "./package.json" }
|
|
94
|
+
}
|
|
87
95
|
```
|
|
88
96
|
|
|
89
|
-
|
|
97
|
+
| Campo | Significado |
|
|
98
|
+
|---|---|
|
|
99
|
+
| `uiRegistry` | Directorio de entradas, relativo al root del paquete (`"."` o `true` para el root). |
|
|
100
|
+
| `uiRegistryId` | Slug en minúsculas que namespacea todos los targets. Debe ser único entre los registries configurados. |
|
|
101
|
+
| `uiRequires` | Requisitos de `@blankways/ui`; información, no una dependencia que el CLI imponga. |
|
|
102
|
+
| `uiDevRegistries` | Peers usados **solo al desarrollar** el registry. Nunca se escriben en el proyecto del consumidor. |
|
|
90
103
|
|
|
91
|
-
`
|
|
104
|
+
`component.json` de una entrada:
|
|
92
105
|
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"name": "button",
|
|
109
|
+
"kind": "component",
|
|
110
|
+
"requires": ["acme:cn", "acme:theme", "bw:state-runtime"],
|
|
111
|
+
"themes": ["dawn", "midnight"],
|
|
112
|
+
"revision": 2,
|
|
113
|
+
"peers": ["react"],
|
|
114
|
+
"files": [
|
|
115
|
+
{ "source": "Button.tsx", "target": "components/acme/button/Button.tsx" },
|
|
116
|
+
{ "source": "button.css", "target": "components/acme/button/button.css" },
|
|
117
|
+
{ "source": "runtime.ts", "target": "runtimes/acme/button.ts" }
|
|
118
|
+
]
|
|
119
|
+
}
|
|
99
120
|
```
|
|
100
121
|
|
|
101
|
-
|
|
122
|
+
| Campo | Regla |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `requires` | Entradas calificadas `id:entrada` de **cualquier** registry. Es la única forma segura de interoperar entre paquetes. |
|
|
125
|
+
| `dependencies` | Compatibilidad hacia atrás: entradas del mismo registry. |
|
|
126
|
+
| `themes` | Nombres arbitrarios por peer. No hay `light`, `dark` ni `system` especiales. |
|
|
127
|
+
| `revision` | Cambia cuando el proveedor publica una versión incompatible; `--frozen` lo detecta. |
|
|
128
|
+
| `files[].target` | Debe empezar por `components/<id>/`, `themes/<id>/` o `runtimes/<id>/`. |
|
|
102
129
|
|
|
103
|
-
|
|
104
|
-
@import './ui/styles/index.css';
|
|
105
|
-
```
|
|
130
|
+
Los nombres calificados usan `uiRegistryId` (`acme:button`). El specifier del paquete también funciona (`@mi-org/acme-ui:button`). El nombre simple solo se acepta si es único; si dos peers tienen `button`, el CLI exige el calificado. Las dependencias sin calificar resuelven primero dentro del mismo peer.
|
|
106
131
|
|
|
107
|
-
|
|
132
|
+
Los archivos se copian **tal cual** a la ruta `target`; por eso los imports relativos se escriben para la estructura final, no para la carpeta de origen del paquete (ver [`docs/registry-guide.md`](./docs/registry-guide.md)).
|
|
108
133
|
|
|
109
|
-
##
|
|
134
|
+
## Entorno dev: dependencias de UI
|
|
135
|
+
|
|
136
|
+
Un registry que interopera con otro necesita ese peer para desarrollarse, pero **no debe imponérselo** a quien lo consume. `ui dev` monta una app desechable donde los `uiDevRegistries` hacen de peers locales:
|
|
110
137
|
|
|
111
138
|
```bash
|
|
112
|
-
|
|
139
|
+
# desde la raíz del paquete @mi-org/acme-ui
|
|
140
|
+
pnpm exec ui dev # genera .ui-dev/
|
|
141
|
+
pnpm exec ui dev --app ../playground
|
|
113
142
|
```
|
|
114
143
|
|
|
144
|
+
La app generada declara como registries el propio paquete (`..`) y los `uiDevRegistries` resueltos, con `exposure: "full"`. Después se pueden editar sus archivos, ejecutar `ui doctor` y probar imports reales como si la app fuera un proyecto consumidor. El `package.json` publicado sigue declarando solo `uiDevRegistries`; el consumidor aporta su propio paquete con el mismo `uiRegistryId`.
|
|
145
|
+
|
|
146
|
+
Ejemplo en este repositorio (dogfooding):
|
|
147
|
+
|
|
115
148
|
```text
|
|
116
|
-
ui
|
|
149
|
+
.ignore/workspace/packages/acme-ui # uiDevRegistries: ["../bw-runtime"]
|
|
150
|
+
.ignore/workspace/packages/bw-runtime
|
|
151
|
+
.ignore/workspace/packages/bw-alt # mismo id "bw", otro proveedor
|
|
152
|
+
.ignore/workspace/app # consume bw-runtime
|
|
153
|
+
.ignore/workspace/app-alt # consume bw-alt sin tocar acme-ui
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
`acme:button` importa `runtimes/bw` en ambos casos; en `app` obtiene el runtime propio y en `app-alt` obtiene el del consumidor. Ese es el punto: la interoperabilidad se resuelve por `uiRegistryId` + `requires` en tiempo de build, no por una dependencia publicada.
|
|
117
157
|
|
|
118
|
-
|
|
119
|
-
OK icons: 8 imports checked
|
|
120
|
-
OK themes: 2 found (light, dark)
|
|
121
|
-
OK entries: 12 detected
|
|
122
|
-
OK peers: 6/6 installed
|
|
158
|
+
## Barrels y estilos
|
|
123
159
|
|
|
124
|
-
|
|
160
|
+
`sync` se ejecuta automáticamente después de cada instalación:
|
|
161
|
+
|
|
162
|
+
```css
|
|
163
|
+
/* ui/themes/index.css */
|
|
164
|
+
@import '@blankways/ui/styles.css';
|
|
165
|
+
@import './acme/dawn.css';
|
|
166
|
+
@import './bw/tokens.css';
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Se añade `@import './ui/themes/index.css';` al CSS global detectado, justo después de `@import "tailwindcss";`. También se generan `ui/runtimes/<id>/index.ts` y `ui/runtimes/index.ts`. `ui styles link` queda como alias obsoleto de `sync`.
|
|
170
|
+
|
|
171
|
+
## Doctor
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
pnpm exec ui doctor
|
|
125
175
|
```
|
|
126
176
|
|
|
127
|
-
`
|
|
177
|
+
Checks incluidos: `contracts` (ids únicos, targets por namespace y `requires` conocidos), `namespaces` (imports cruzados declarados), `barrels`, `imports`, `icons`, `themes`, `entries`, `peers` y `motion`. Un `error` termina con exit code 1.
|
|
128
178
|
|
|
129
|
-
Los checks son plug-ins
|
|
179
|
+
Los checks son plug-ins:
|
|
130
180
|
|
|
131
181
|
```ts
|
|
132
182
|
import { registerDoctorCheck } from '@blankways/ui'
|
|
@@ -134,96 +184,64 @@ import { registerDoctorCheck } from '@blankways/ui'
|
|
|
134
184
|
registerDoctorCheck({
|
|
135
185
|
id: 'mi-regla',
|
|
136
186
|
async run({ componentsDir }) {
|
|
137
|
-
return {
|
|
138
|
-
summary: 'checked',
|
|
139
|
-
problems: []
|
|
140
|
-
}
|
|
187
|
+
return { summary: 'checked', problems: [] }
|
|
141
188
|
}
|
|
142
189
|
})
|
|
143
190
|
```
|
|
144
191
|
|
|
145
|
-
|
|
192
|
+
El contexto incluye `cwd`, `componentsDir`, `displayDir`, `files`, `sourceFiles`, `framework`, `registries`, `globalCss`, `items`, `providers` y `lock`.
|
|
146
193
|
|
|
147
|
-
##
|
|
148
|
-
|
|
149
|
-
Los comandos tampoco viven en un `switch`: cada operación se registra con `registerCliCommand` en `source/commands/` y el CLI los descubre. La ayuda y las opciones también se generan desde el registro.
|
|
194
|
+
## Extensión del CLI
|
|
150
195
|
|
|
151
196
|
```ts
|
|
152
|
-
import {
|
|
153
|
-
registerCliCommand,
|
|
154
|
-
registerDoctorCheck,
|
|
155
|
-
listRegistryItems
|
|
156
|
-
} from '@blankways/ui'
|
|
197
|
+
import { registerCliCommand, listRegistryItems } from '@blankways/ui'
|
|
157
198
|
|
|
158
199
|
registerCliCommand({
|
|
159
200
|
name: 'mis-icons',
|
|
160
201
|
description: 'Lista los iconos disponibles',
|
|
161
202
|
order: 60,
|
|
162
|
-
run: async
|
|
163
|
-
const items = await listRegistryItems(
|
|
203
|
+
run: async context => {
|
|
204
|
+
const items = await listRegistryItems({
|
|
205
|
+
cwd: context.cwd,
|
|
206
|
+
registries: context.registries
|
|
207
|
+
})
|
|
164
208
|
console.log(items.filter(item => item.kind === 'icon').map(item => item.name).join('\n'))
|
|
165
209
|
}
|
|
166
210
|
})
|
|
167
|
-
|
|
168
|
-
registerDoctorCheck({
|
|
169
|
-
id: 'mis-icons',
|
|
170
|
-
run: () => ({ summary: 'checked', problems: [] })
|
|
171
|
-
})
|
|
172
211
|
```
|
|
173
212
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
Los datos vienen de dos lados:
|
|
177
|
-
|
|
178
|
-
- **Internos**: los manifiestos `registry/*/component.json` y sus archivos fuente.
|
|
179
|
-
- **Expuestos**: el API público del paquete (`listRegistryItems`, `registerCliCommand`, `registerDoctorCheck`, `getCliOptions`, etc.).
|
|
213
|
+
Importar el paquete root no registra los comandos integrados: el bin lo hace. `listRegistryItems()` sin opciones devuelve `[]` porque no hay registry integrado.
|
|
180
214
|
|
|
181
|
-
|
|
215
|
+
## Opciones
|
|
182
216
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
```
|
|
217
|
+
- `--cwd <path>`: raíz del proyecto.
|
|
218
|
+
- `--components-dir <path>`: sobrescribe `componentsDir`.
|
|
219
|
+
- `--registry <paquete[,paquete...]>`: sobrescribe los registries en una ejecución.
|
|
220
|
+
- `--framework <name>` / `--variant`: framework para `init`.
|
|
221
|
+
- `--global-css <path>`: CSS global donde conectar el barrel.
|
|
222
|
+
- `--exposure <full|incremental>`: modo de materialización.
|
|
223
|
+
- `--frozen`: exige que el lockfile esté al día (`install`).
|
|
224
|
+
- `--app <path>`: directorio de la app de `ui dev`.
|
|
225
|
+
- `--force`, `--dry-run`, `--all`, `--no-deps`, `--install-peers`.
|
|
194
226
|
|
|
195
|
-
##
|
|
227
|
+
## Playground local
|
|
196
228
|
|
|
197
|
-
|
|
229
|
+
`.ignore/workspace/dev-app` es una app Vite + React que consume `@blankways/react-registry` mediante `@blankways/ui` (dependencias `file:`). Sirve para probar la composición real con HMR:
|
|
198
230
|
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
icons/index.ts
|
|
205
|
-
icons/theme.ts
|
|
206
|
-
styles/tokens.css
|
|
207
|
-
styles/button-styles.ts
|
|
208
|
-
styles/field-styles.ts
|
|
209
|
-
themes/theme.ts
|
|
210
|
-
themes/ThemeContext.tsx
|
|
211
|
-
internals/cn.ts
|
|
231
|
+
```bash
|
|
232
|
+
cd .ignore/workspace/dev-app
|
|
233
|
+
pnpm install
|
|
234
|
+
pnpm exec ui install --global-css src/demo.css
|
|
235
|
+
pnpm dev # http://localhost:4173
|
|
212
236
|
```
|
|
213
237
|
|
|
214
|
-
Cada entrada define `target` en su `component.json`, así que las rutas son estables aunque el nombre de entrada sea distinto (por ejemplo `icons-theme` → `ui/icons/theme.ts`). Los imports relativos de los componentes ya apuntan a esta estructura (por ejemplo `../../internals/cn.js` desde `ui/components/button/`).
|
|
215
|
-
|
|
216
|
-
`cn` es una entrada interna (`hidden: true`): no aparece en `list`, no se puede pedir con `add` y se instala automáticamente como dependencia en `ui/internals/cn.ts`. Los helpers `button-styles` y `field-styles` viven en `ui/styles/`.
|
|
217
|
-
|
|
218
238
|
## Desarrollo
|
|
219
239
|
|
|
220
|
-
Este es un proyecto independiente, con su propio `package.json` y toolchain:
|
|
221
|
-
|
|
222
240
|
```bash
|
|
223
241
|
pnpm install
|
|
224
|
-
pnpm typecheck
|
|
225
|
-
pnpm test
|
|
226
|
-
pnpm build
|
|
242
|
+
pnpm typecheck # tsc + validación del registry local (delega en su validador)
|
|
243
|
+
pnpm test # vitest (contrato de API, registry y doctor)
|
|
244
|
+
pnpm build # solo source/ → dist/
|
|
227
245
|
```
|
|
228
246
|
|
|
229
|
-
|
|
247
|
+
El registry ya no vive en la root: `@blankways/react-registry` es un paquete autocontenido cuya copia de desarrollo está en `.ignore/workspace/packages/react-registry` (ignorada por git). Se puede mover entero a otro workspace: se valida con `pnpm validate` dentro del paquete y `pnpm pack` lo valida antes de publicar. `pnpm typecheck` delega en ese validador si el fixture está presente (`BLANKWAYS_REGISTRY_DIR=<ruta>` para otra copia) y lo omite si no existe. `pnpm build` compila solo `source/`; la publicación de `@blankways/ui` contiene `dist/` y `styles.css`. La guía de autoría está en [`docs/registry-guide.md`](./docs/registry-guide.md).
|
package/dist/cli/cli.options.js
CHANGED
|
@@ -19,6 +19,10 @@ const CLI_OPTIONS = [
|
|
|
19
19
|
flag: '--kind <kind>',
|
|
20
20
|
description: 'Filter by: component, icon, theme, style, utility'
|
|
21
21
|
},
|
|
22
|
+
{
|
|
23
|
+
flag: '--registry <package[,package...]>',
|
|
24
|
+
description: 'Registry packages to use (overrides components.json)'
|
|
25
|
+
},
|
|
22
26
|
{
|
|
23
27
|
flag: '--force',
|
|
24
28
|
description: 'Overwrite existing files or components.json'
|
|
@@ -37,7 +41,23 @@ const CLI_OPTIONS = [
|
|
|
37
41
|
},
|
|
38
42
|
{
|
|
39
43
|
flag: '--no-import',
|
|
40
|
-
description: 'Do not link styles after add'
|
|
44
|
+
description: 'Do not link styles after add (deprecated)'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
flag: '--frozen',
|
|
48
|
+
description: 'Fail if ui.lock.json does not match the configured registries'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
flag: '--exposure <full|incremental>',
|
|
52
|
+
description: 'Override the default full materialization'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
flag: '--install-peers',
|
|
56
|
+
description: 'Allow install to add declared peer packages'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
flag: '--app <path>',
|
|
60
|
+
description: 'Dev app directory for "ui dev" (default .ui-dev)'
|
|
41
61
|
},
|
|
42
62
|
{
|
|
43
63
|
flag: '-h, --help',
|
package/dist/cli/cli.types.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import './commands/index.js';
|
|
|
3
3
|
import { resolveCliCommand } from './cli/cli.registry.js';
|
|
4
4
|
import { CLI_NAME } from './constants/index.js';
|
|
5
5
|
import { CliError } from './errors/index.js';
|
|
6
|
-
import { getStringFlag, isFlagEnabled, parseArgs, printHelp } from './helpers/index.js';
|
|
6
|
+
import { getStringFlag, getStringListFlag, isFlagEnabled, parseArgs, printHelp } from './helpers/index.js';
|
|
7
7
|
import { getPackageVersion } from './helpers/package.helpers.js';
|
|
8
8
|
async function main() {
|
|
9
9
|
const args = parseArgs(process.argv.slice(2));
|
|
@@ -30,6 +30,7 @@ async function main() {
|
|
|
30
30
|
kind: getStringFlag(args.flags, 'kind'),
|
|
31
31
|
framework: getStringFlag(args.flags, 'framework'),
|
|
32
32
|
variant: getStringFlag(args.flags, 'variant'),
|
|
33
|
+
registries: getStringListFlag(args.flags, 'registry'),
|
|
33
34
|
names: args.names,
|
|
34
35
|
flags: args.flags,
|
|
35
36
|
force: isFlagEnabled(args.flags, 'force'),
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { AddOptions } from '../types/config.types.js';
|
|
2
|
+
import { type InstallResult } from '../ui-api/index.js';
|
|
3
|
+
export declare function printInstallResult(result: InstallResult, dryRun: boolean): void;
|
|
2
4
|
export declare function addCommand(options: AddOptions): Promise<void>;
|
|
@@ -1,101 +1,49 @@
|
|
|
1
|
-
import { mkdir } from 'node:fs/promises';
|
|
2
|
-
import { basename, resolve } from 'node:path';
|
|
3
1
|
import { registerCliCommand } from '../cli/cli.registry.js';
|
|
4
|
-
import { readConfig, resolveComponentsDir } from '../config/index.js';
|
|
5
2
|
import { CLI_NAME } from '../constants/index.js';
|
|
6
3
|
import { CliError } from '../errors/index.js';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export async function addCommand(options) {
|
|
12
|
-
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
13
|
-
const config = await readConfig(cwd);
|
|
14
|
-
if (!config) {
|
|
15
|
-
throw new CliError(`components.json not found. Run "${CLI_NAME} init" first.`);
|
|
16
|
-
}
|
|
17
|
-
const componentsDir = resolveComponentsDir(cwd, config, options.componentsDir);
|
|
18
|
-
const items = await resolveSelectedComponents(options.names, Boolean(options.all), {
|
|
19
|
-
kind: options.kind,
|
|
20
|
-
framework: config.framework,
|
|
21
|
-
noDeps: options.noDeps
|
|
22
|
-
});
|
|
23
|
-
const force = Boolean(options.force || config.overwrite);
|
|
24
|
-
const dryRun = Boolean(options.dryRun);
|
|
25
|
-
if (!dryRun)
|
|
26
|
-
await mkdir(componentsDir, { recursive: true });
|
|
27
|
-
let copied = 0;
|
|
28
|
-
let skipped = 0;
|
|
29
|
-
let planned = 0;
|
|
30
|
-
for (const item of items) {
|
|
31
|
-
const result = await copyRegistryItem(item, componentsDir, { cwd, force, dryRun });
|
|
32
|
-
copied += result.copied.length;
|
|
33
|
-
skipped += result.skipped.length;
|
|
34
|
-
planned += result.planned.length;
|
|
35
|
-
const label = item.requested
|
|
36
|
-
? dryRun
|
|
37
|
-
? 'Would add'
|
|
38
|
-
: 'Added'
|
|
39
|
-
: dryRun
|
|
40
|
-
? 'Would add dependency'
|
|
41
|
-
: 'Added dependency';
|
|
42
|
-
const files = [...result.copied, ...result.skipped, ...result.planned];
|
|
43
|
-
if (files.length > 0)
|
|
44
|
-
console.log(`${label} ${item.name}: ${files.join(', ')}`);
|
|
45
|
-
}
|
|
46
|
-
const plannedStyles = items
|
|
47
|
-
.filter(item => item.kind === 'style')
|
|
48
|
-
.flatMap(item => item.files.map(file => basename(file.target)));
|
|
49
|
-
const linkStyles = async () => {
|
|
50
|
-
if (options.noImport || plannedStyles.length === 0)
|
|
4
|
+
import { install } from '../ui-api/index.js';
|
|
5
|
+
export function printInstallResult(result, dryRun) {
|
|
6
|
+
const label = (items, verb) => {
|
|
7
|
+
if (items.length === 0)
|
|
51
8
|
return;
|
|
52
|
-
|
|
53
|
-
cwd,
|
|
54
|
-
componentsDir,
|
|
55
|
-
globalCss: options.globalCss,
|
|
56
|
-
dryRun,
|
|
57
|
-
plannedStyles
|
|
58
|
-
});
|
|
59
|
-
printStylesSync(result, cwd, dryRun);
|
|
9
|
+
console.log(`\n${verb}: ${items.join(', ')}`);
|
|
60
10
|
};
|
|
61
11
|
if (dryRun) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
await printEducation(items, config.framework);
|
|
12
|
+
label(result.planned, 'Would add');
|
|
13
|
+
console.log(`\nDry run: ${result.planned.length} file(s) would be copied.`);
|
|
65
14
|
return;
|
|
66
15
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
console.log(`\nDone: ${
|
|
72
|
-
await linkStyles();
|
|
73
|
-
await printEducation(items, config.framework);
|
|
16
|
+
label(result.added, 'Added');
|
|
17
|
+
label(result.updated, 'Updated');
|
|
18
|
+
label(result.kept, 'Kept locally modified');
|
|
19
|
+
label(result.barrels, 'Regenerated');
|
|
20
|
+
console.log(`\nDone: ${result.entries.length} entries installed.`);
|
|
74
21
|
}
|
|
75
|
-
async function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
console.log(`\nPeer packages: ${peers.join(', ')}`);
|
|
79
|
-
console.log(`Install them with: pnpm add ${peers.join(' ')}`);
|
|
80
|
-
}
|
|
81
|
-
const installed = new Set(items.map(item => item.name));
|
|
82
|
-
const available = new Set((await listRegistryItems({ framework }))
|
|
83
|
-
.filter(item => !item.hidden)
|
|
84
|
-
.map(item => item.name));
|
|
85
|
-
const suggestions = Array.from(new Set(items.flatMap(item => item.suggestions))).filter(name => available.has(name) && !installed.has(name));
|
|
86
|
-
if (suggestions.length > 0) {
|
|
87
|
-
console.log(`\nRecommended styles: pnpm exec ${CLI_NAME} add ${suggestions.join(' ')}`);
|
|
22
|
+
export async function addCommand(options) {
|
|
23
|
+
if (!options.names?.length && !options.all) {
|
|
24
|
+
throw new CliError('No entries specified. Use <entry...> or --all.');
|
|
88
25
|
}
|
|
26
|
+
const result = await install({
|
|
27
|
+
cwd: options.cwd,
|
|
28
|
+
componentsDir: options.componentsDir,
|
|
29
|
+
registries: options.registries,
|
|
30
|
+
selectors: options.names,
|
|
31
|
+
exposure: options.all ? 'full' : 'incremental',
|
|
32
|
+
force: options.force,
|
|
33
|
+
dryRun: options.dryRun,
|
|
34
|
+
globalCss: options.globalCss
|
|
35
|
+
});
|
|
36
|
+
printInstallResult(result, Boolean(options.dryRun));
|
|
89
37
|
}
|
|
90
38
|
registerCliCommand({
|
|
91
39
|
name: 'add',
|
|
92
|
-
description: '
|
|
40
|
+
description: 'Install registry entries and their requires, then regenerate barrels',
|
|
93
41
|
usage: 'add <entry...> [options]',
|
|
94
42
|
order: 20,
|
|
95
43
|
examples: [
|
|
96
|
-
`${CLI_NAME} add button
|
|
97
|
-
`${CLI_NAME} add
|
|
98
|
-
`${CLI_NAME} add button --dry-run`
|
|
44
|
+
`${CLI_NAME} add acme:button`,
|
|
45
|
+
`${CLI_NAME} add --all`,
|
|
46
|
+
`${CLI_NAME} add acme:button --dry-run`
|
|
99
47
|
],
|
|
100
48
|
run: context => addCommand(context)
|
|
101
49
|
});
|