Skip to content

Commit 769fcd0

Browse files
committed
Add documentation links to README and include 'docs' directory in package.json
1 parent 2d2336d commit 769fcd0

19 files changed

Lines changed: 1747 additions & 0 deletions

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ Universal **shadcn-style** registry service: `init` / `add` / `list` / `diff` /
44

55
Contract version: **2.0.0**
66

7+
**Full documentation (English):** [docs/README.md](./docs/README.md)
8+
9+
| Start here | |
10+
|------------|--|
11+
| [Getting started](./docs/getting-started.md) | Install + first init/add |
12+
| [Commands](./docs/commands.md) | Complete CLI reference |
13+
| [Scenarios](./docs/scenarios/) | React, Svelte, Templ, private CDN, publish, CI |
14+
| [Registry format](./docs/registry-format.md) | Item / index JSON contract |
15+
716
## Idea
817

918
```text
@@ -174,6 +183,8 @@ npm run pack:check # dry-run tarball contents
174183

175184
Maintainer scripts (local fixtures, CDN probe): see [scripts/README.md](scripts/README.md).
176185

186+
User & author guides: see [docs/README.md](docs/README.md).
187+
177188
## License
178189

179190
MIT

docs/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# ui8kit CLI documentation
2+
3+
Contract **2.0.0** · Node.js `>=20`
4+
5+
`ui8kit` is a **file-based registry CLI** (shadcn-style): it fetches registry items from a CDN (or local server) and **writes source files into your app**. It does not treat `node_modules` as the kit source of truth, so Tailwind and bundlers see real classes and files.
6+
7+
This docs set covers concepts, configuration, every command, the registry JSON contract, CDN/cache behavior, publishing, end-to-end scenarios, troubleshooting, and migration from v1.
8+
9+
## Guides
10+
11+
| Doc | Contents |
12+
|-----|----------|
13+
| [Getting started](./getting-started.md) | Install, first `init` / `add`, verification |
14+
| [Concepts](./concepts.md) | Mental model, folders, types, runtimes, path remap |
15+
| [Configuration](./configuration.md) | Full `ui8kit.config.json` reference |
16+
| [Commands](./commands.md) | Every command, flag, and example |
17+
| [Registry format](./registry-format.md) | Item / index JSON contract |
18+
| [CDN and cache](./cdn-and-cache.md) | URL resolution, pinning, offline cache |
19+
| [Publishing a registry](./publishing.md) | `scan``build` → host `/r` |
20+
| [Troubleshooting](./troubleshooting.md) | Common failures and fixes |
21+
| [Migration v1 → v2](./migration-v2.md) | Breaking changes checklist |
22+
23+
## Scenarios
24+
25+
| Scenario | Audience |
26+
|----------|----------|
27+
| [Consumer app (React)](./scenarios/consumer-react.md) | App teams installing primitives |
28+
| [Svelte / Solid / Vue](./scenarios/multi-runtime.md) | Multi-runtime digests |
29+
| [Go Templ / PHP](./scenarios/non-js.md) | Kit on disk without a JS framework |
30+
| [Private / strict CDN](./scenarios/private-cdn.md) | Locked registry URL + version pin |
31+
| [Maintain & publish registry](./scenarios/maintain-registry.md) | Authors assembling `packages/registry/r` |
32+
| [CI dry-run & upgrades](./scenarios/ci-and-upgrades.md) | Automation, `diff`, force updates |
33+
34+
## Quick mental model
35+
36+
```text
37+
┌─────────────────────┐
38+
│ Registry CDN `/r` │
39+
│ index.json + items │
40+
└──────────┬──────────┘
41+
│ fetch
42+
43+
┌──────────────┐ ui8kit add ┌────────────────────────┐
44+
│ App project │ ◄──────────────── │ files under {dir}/… │
45+
│ ui8kit.config│ │ components/ui, utils… │
46+
└──────────────┘ └────────────────────────┘
47+
```
48+
49+
Authors use the reverse path:
50+
51+
```text
52+
source kit → ui8kit scan → registry.json → ui8kit build → packages/registry/r
53+
```
54+
55+
## Related
56+
57+
- Package README: [../README.md](../README.md)
58+
- Maintainer scripts: [../scripts/README.md](../scripts/README.md)
59+
- Changelog: [../CHANGELOG.md](../CHANGELOG.md)

docs/cdn-and-cache.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# CDN and cache
2+
3+
## Registry base URL
4+
5+
A **base** is a URL that already points at the `/r` tree (no trailing slash required):
6+
7+
```text
8+
https://cdn.example.com/ui8kit/r
9+
https://unpkg.com/@ui8kit/registry@latest/r
10+
http://127.0.0.1:4173/r
11+
```
12+
13+
From that base the CLI requests:
14+
15+
```text
16+
{base}/index.json
17+
{base}/components/ui/button.json
18+
{base}/utils/cn.json
19+
20+
```
21+
22+
## Resolution order
23+
24+
`getCdnUrls` builds an ordered unique list:
25+
26+
1. Explicit `--registry-url` / `config.registryUrl` (after version rewrite)
27+
2. If **not** (`strictCdn` **and** explicit URL): append
28+
- `config.cdnBaseUrls` when set, else
29+
- built-in defaults:
30+
31+
```text
32+
https://unpkg.com/@ui8kit/registry@latest/r
33+
https://cdn.jsdelivr.net/npm/@ui8kit/registry@latest/r
34+
https://raw.githubusercontent.com/ui8kit/core/refs/heads/main/packages/registry/r
35+
```
36+
37+
### Strict mode
38+
39+
```bash
40+
ui8kit add button --registry-url https://cdn.example.com/r --strict-cdn
41+
```
42+
43+
Only that URL is tried. Failures do **not** fall back to public CDNs. Prefer this for private registries and CI.
44+
45+
### Version pinning
46+
47+
`--registry-version 0.1.0` / `registryVersion` rewrites `@latest` in URL templates:
48+
49+
```text
50+
…/@ui8kit/registry@latest/r → …/@ui8kit/registry@0.1.0/r
51+
```
52+
53+
Custom hosts without `@latest` are left unchanged; pin by changing the path yourself or hosting immutable digests.
54+
55+
## Inspect resolution
56+
57+
```bash
58+
ui8kit info --cdn
59+
ui8kit info --json
60+
```
61+
62+
Maintainer probe (repo scripts, not shipped in tarball logic):
63+
64+
```bash
65+
npm run get-cdn
66+
node scripts/get-cdn.js --url https://cdn.example.com/r --path index.json --json
67+
```
68+
69+
## Local cache
70+
71+
Successful JSON responses are cached under:
72+
73+
```text
74+
~/.ui8kit/cache/
75+
```
76+
77+
- Default TTL: **1 hour**
78+
- Bypass: `ui8kit --no-cache …` or clear with `ui8kit cache clear`
79+
- `reset --with-cache` also clears the cache
80+
81+
Cache keys are derived from request paths; safe to delete anytime.
82+
83+
## Offline / air-gapped
84+
85+
1. Host `packages/registry/r` on an internal static server
86+
2. Set `registryUrl` + `strictCdn: true`
87+
3. Optionally pre-warm: run `list` / `add` once on a builder image and ship the cache (usually unnecessary if the internal CDN is fast)
88+
89+
## Retry
90+
91+
`ui8kit add … --retry` increases fetch retries for flaky CDNs. Prefer fixing CDN reliability for production CI.

0 commit comments

Comments
 (0)