@raketa-cloud/design-cli 1.1.3 → 1.1.5
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 +6 -8
- package/build.mjs +3 -2
- package/cli.mjs +1 -1
- package/package.json +1 -1
- package/preset.mjs +65 -33
- package/preview-css.mjs +1 -3
- package/skills/design-system/SKILL.md +16 -9
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npx @raketa-cloud/design-cli new component my-pattern
|
|
|
14
14
|
npx @raketa-cloud/design-cli new layout my-pattern
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Alternatively, install it with `npm install --save-dev @raketa-cloud/design-cli` and run `npx design <command>`. Run `npx @raketa-cloud/design-cli --help` for usage. `serve` listens on `127.0.0.1:4174`; `PORT` changes the port. `SHOWCASE_PRESET` selects a built-in or design-local
|
|
17
|
+
Alternatively, install it with `npm install --save-dev @raketa-cloud/design-cli` and run `npx design <command>`. Run `npx @raketa-cloud/design-cli --help` for usage. `serve` listens on `127.0.0.1:4174`; `PORT` changes the port. `SHOWCASE_PRESET` selects a built-in or design-local showcase theme. New scaffold previews link `/__showcase/preview.css`; their markup and docs remain placeholders, not finished designs.
|
|
18
18
|
`init` creates a starter `.design` directory, installs the design-system skill to `.agents/skills/design-system`, and links it from `.claude/skills/` and `.pi/skills/`. It refuses to overwrite any of those paths. Update `.design/config.json`, tokens, and `DESIGN.md` for your project, then add patterns and wire the generated CSS into your application. The initializer does not change application code or dependencies.
|
|
19
19
|
|
|
20
20
|
|
|
@@ -33,11 +33,11 @@ A design directory has `config.json`:
|
|
|
33
33
|
|
|
34
34
|
`system.name` names the showcase; `system.id` is lowercase kebab-case and forms the output directory. `build.output` is relative to the project directory (or an absolute path). The build writes exactly `[build.output]/[system.id]/theme.css`. `DESIGN_DIR` selects the design directory (default `.design`), whose parent is the project directory. `DESIGN_CONFIG` selects another config path without changing those directories.
|
|
35
35
|
|
|
36
|
-
The builder reads `tokens/tokens.json`,
|
|
36
|
+
The builder reads `tokens/tokens.json`, emits custom properties, and bundles only `components/<pattern>/styles.css` and `layouts/<pattern>/styles.css`. Output is standalone CSS; Tailwind directives and CSS imports are rejected in pattern styles. The CLI never copies preview HTML, JavaScript or runtime assets into the host. Hosts adapt markup and behavior and configure any utility framework themselves.
|
|
37
37
|
|
|
38
38
|
The showcase reads `system.name` from configuration. Its token renderer detects normalized data (`primitive.color` and `semantic.color`) or Raketa CSS-native data (`blocks`). The latter projection reads `tokens/components.json` and a transient Tailwind build for status colors; its typography specimens use Raketa's documented defaults. Unknown or ambiguous token formats are rejected. `DESIGN.md` remains a design reference; configuration supplies the showcase name.
|
|
39
39
|
|
|
40
|
-
`/__showcase/preview.css`
|
|
40
|
+
The showcase's `/__showcase/preview.css` is generated in memory from Tailwind, the design tokens and pattern markup; it is not a source file or a host asset. Preview behavior belongs inline in `preview.html`. Reusable custom CSS belongs in the pattern's `styles.css`; the former `preview.css` configuration is no longer supported. Run `generate` before serving to provide `/__showcase/theme.css`.
|
|
41
41
|
|
|
42
42
|
Configuration, preview HTML and `_theme_preview.html` are trusted local inputs; do not expose the server to untrusted networks. Apart from shared chrome under `/__showcase/` and `/showcase/asset-grid.css`, the server serves files only within the design directory, plus the configured output at `/__showcase/theme.css`. The server watches the output directory for reloads when it exists at startup; restart after changing the output location or creating a previously missing directory. Theme selection and application-specific behavior must still be added to scaffolds.
|
|
43
43
|
|
|
@@ -45,13 +45,11 @@ Run `npm test` here for tooling behavior. Consumers should separately validate i
|
|
|
45
45
|
|
|
46
46
|
## Repository-backed presets
|
|
47
47
|
|
|
48
|
-
Set `"preset": { "repo": "git@github.com:example/admin-ui.git", "ref": "main" }` in `.design/config.json`. The repository contains `.design/`
|
|
48
|
+
Set `"preset": { "repo": "git@github.com:example/admin-ui.git", "ref": "main" }` in `.design/config.json`. The repository contains `.design/` shared design inputs. Run `design preset update` to pin the ref in `.design/preset.lock.json`; commit the lock. On a fresh checkout run `design preset install`. Generate and serve do not fetch; updates are explicit and require Git access.
|
|
49
49
|
|
|
50
|
-
The disposable `.design/.preset/` cache
|
|
50
|
+
The disposable `.design/.preset/` cache keeps one locked checkout and links `.design/.preset/latest` to it. The CLI generates CSS only; it does not install runtime assets or scripts into the host. For live preset development, set `DESIGN_PRESET_DIR` to a local checkout; this is forbidden in CI. Restart the showcase after changing the checkout location.
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
Token JSON objects merge recursively; arrays replace wholesale. Local component and layout pattern directories replace the entire matching preset pattern. Additional local component CSS follows preset CSS. `tokenOverrides` maps `:root` and `.dark` to existing CSS variable names and values; unknown names are rejected. For example: `"tokenOverrides": { ":root": { "--color-action": "#123456" } }`. Not every valid CSS color expression can be rendered in catalog swatches; inspect the actual preview and generated CSS.
|
|
52
|
+
Token JSON objects merge recursively; arrays replace wholesale. Local component and layout pattern directories replace the entire matching preset pattern. Local pattern CSS follows preset CSS. `tokenOverrides` maps `:root` and `.dark` to existing CSS variable names and values; unknown names are rejected. For example: `"tokenOverrides": { ":root": { "--color-action": "#123456" } }`. Not every valid CSS color expression can be rendered in catalog swatches; inspect the actual preview and generated CSS.
|
|
55
53
|
The showcase uses the host's `_theme_preview.html` when present, otherwise the preset's; if neither exists it displays a placeholder.
|
|
56
54
|
|
|
57
55
|
Preset repositories, previews and runtime JavaScript are trusted inputs. The installer does not invoke preset install scripts, but Git uses your configuration and credentials, including any configured checkout filters. Using preset CSS, JavaScript or Tailwind plugins can execute or load untrusted content. Review changes and test framework integration separately.
|
package/build.mjs
CHANGED
|
@@ -157,12 +157,13 @@ export function applyCatalogOverrides(input, overrides = {}) {
|
|
|
157
157
|
}
|
|
158
158
|
export async function renderTheme(context) {
|
|
159
159
|
let css = '/* Generated by design-tooling; edit the design sources instead. */\n' + await tokenCSS(context);
|
|
160
|
-
const files = (await
|
|
160
|
+
const files = (await Promise.all(['components', 'layouts'].map(folder => overlayFiles(context, folder))))
|
|
161
|
+
.flat().filter(file => /^(components|layouts)\/[^/]+\/styles\.css$/.test(file.name));
|
|
161
162
|
const localRoot = await realpath(context.designDir);
|
|
162
163
|
files.sort((a, b) => Number(a.path.startsWith(localRoot + '/')) - Number(b.path.startsWith(localRoot + '/')) || a.name.localeCompare(b.name));
|
|
163
164
|
for (const { name, path } of files) {
|
|
164
165
|
const content = await readFile(path, 'utf8');
|
|
165
|
-
if (/@(?:apply|import|theme|source)\b/.test(content)) throw new Error('
|
|
166
|
+
if (/@(?:apply|import|theme|source|tailwind|utility|custom-variant|variant|reference|plugin|config)\b/.test(content)) throw new Error('Pattern styles must be standalone CSS: ' + name);
|
|
166
167
|
css += `\n/* ${name} */\n` + content.trim() + '\n';
|
|
167
168
|
}
|
|
168
169
|
return css;
|
package/cli.mjs
CHANGED
|
@@ -32,7 +32,7 @@ if (command === '--help' || command === '-h' || !command) {
|
|
|
32
32
|
throw error;
|
|
33
33
|
}
|
|
34
34
|
try {
|
|
35
|
-
await writeFile(resolve(target, 'preview.html'), `<!doctype html>\n<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${name}</title><link rel="stylesheet" href="/__showcase/
|
|
35
|
+
await writeFile(resolve(target, 'preview.html'), `<!doctype html>\n<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${name}</title><link rel="stylesheet" href="/__showcase/preview.css"></head><body><main><h1>${name}</h1><p>Replace this placeholder with the pattern.</p></main></body></html>\n`, { flag: 'wx' });
|
|
36
36
|
await writeFile(resolve(target, 'docs.md'), `# ${name}\n\n## Purpose\nDescribe when to use this ${kind}.\n\n## Properties and states\nDocument content, defaults, variants and states.\n\n## Contract\nDocument accessibility, responsive behavior and integration.\n\n## Verification\nRecord verification and known gaps.\n`, { flag: 'wx' });
|
|
37
37
|
} catch (error) { await rm(target, { recursive: true, force: true }); throw error; }
|
|
38
38
|
console.log(`Created ${kind}: ${target}`);
|
package/package.json
CHANGED
package/preset.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
|
-
import {
|
|
3
|
-
import { lstat, mkdir, mkdtemp, readFile, realpath, rename, rm, symlink, writeFile } from 'node:fs/promises';
|
|
4
|
-
import { isAbsolute, join, resolve
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { lstat, mkdir, mkdtemp, readFile, readdir, readlink, realpath, rename, rm, symlink, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
5
5
|
import { promisify } from 'node:util';
|
|
6
6
|
|
|
7
7
|
const exec = promisify(execFile);
|
|
@@ -21,9 +21,8 @@ function source(repo, context) {
|
|
|
21
21
|
if (isAbsolute(repo) || repo.includes('://') || /^[^/]+@[^:]+:/.test(repo)) return repo;
|
|
22
22
|
return resolve(context.projectDir || process.cwd(), repo);
|
|
23
23
|
}
|
|
24
|
-
function cachePath(context
|
|
25
|
-
|
|
26
|
-
return join(context.designDir, '.preset', key);
|
|
24
|
+
function cachePath(context) {
|
|
25
|
+
return join(context.designDir, '.preset', 'checkout');
|
|
27
26
|
}
|
|
28
27
|
async function readLock(context, preset) {
|
|
29
28
|
let lock;
|
|
@@ -61,25 +60,28 @@ export async function resolvePreset(context) {
|
|
|
61
60
|
return validateCheckout(context, await readLock(context, preset));
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
//
|
|
63
|
+
// The checkout is reference material; no runtime files are copied into the host.
|
|
65
64
|
async function linkRuntime(preset, cache) {
|
|
66
|
-
const
|
|
67
|
-
|
|
65
|
+
const target = await realpath(preset);
|
|
66
|
+
await validateDesign(target);
|
|
67
|
+
const latest = join(cache, 'latest');
|
|
68
68
|
try {
|
|
69
|
-
|
|
70
|
-
if (!target.startsWith(await realpath(preset) + sep) || !(await lstat(target)).isDirectory()) throw new Error('not a directory inside the preset');
|
|
71
|
-
} catch (error) { throw new Error(`Invalid preset runtime directory ${assets}: ${error.message}`); }
|
|
72
|
-
const runtime = join(cache, 'runtime');
|
|
73
|
-
try {
|
|
74
|
-
if (!(await lstat(runtime)).isSymbolicLink()) throw new Error(`Refusing to replace non-symlink runtime path: ${runtime}`);
|
|
69
|
+
if (!(await lstat(latest)).isSymbolicLink()) throw new Error(`Refusing to replace non-symlink latest path: ${latest}`);
|
|
75
70
|
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
76
|
-
const temporary = join(cache, `.
|
|
71
|
+
const temporary = join(cache, `.latest-${randomUUID()}`);
|
|
77
72
|
try {
|
|
78
73
|
await symlink(target, temporary, 'dir');
|
|
79
|
-
await rename(temporary,
|
|
74
|
+
await rename(temporary, latest);
|
|
80
75
|
} finally { await rm(temporary, { force: true }); }
|
|
81
76
|
}
|
|
82
77
|
|
|
78
|
+
async function validateDesign(preset) {
|
|
79
|
+
const design = join(preset, '.design');
|
|
80
|
+
try {
|
|
81
|
+
if (!(await lstat(design)).isDirectory()) throw new Error('not a directory');
|
|
82
|
+
} catch (error) { throw new Error(`Invalid preset design directory ${design}: ${error.message}`); }
|
|
83
|
+
}
|
|
84
|
+
|
|
83
85
|
export async function refreshPresetRuntime(context) {
|
|
84
86
|
const preset = await resolvePreset(context);
|
|
85
87
|
if (!preset) return;
|
|
@@ -114,35 +116,65 @@ async function checkout(context, lock, temp) {
|
|
|
114
116
|
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(lock.commit)) throw new Error('Invalid preset commit');
|
|
115
117
|
await git(['checkout', '--detach', '--force', lock.commit], temp);
|
|
116
118
|
}
|
|
117
|
-
async function install(context, lock, cache) {
|
|
119
|
+
async function install(context, lock, cache, commit) {
|
|
118
120
|
const temp = await mkdtemp(join(cache, '.staging-'));
|
|
119
121
|
try {
|
|
120
122
|
await checkout(context, lock, temp);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
await validateDesign(temp);
|
|
124
|
+
const target = cachePath(context);
|
|
125
|
+
const valid = await validateCheckout(context, lock).then(() => true, () => false);
|
|
126
|
+
if (valid) { await commit(target); return target; }
|
|
124
127
|
const old = join(cache, `.old-${randomUUID()}`);
|
|
125
|
-
|
|
126
|
-
try { await rename(
|
|
127
|
-
|
|
128
|
+
let hadOld = false;
|
|
129
|
+
try { await rename(target, old); hadOld = true; } catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
130
|
+
try {
|
|
131
|
+
await rename(temp, target);
|
|
132
|
+
await commit(target);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
await rm(target, { recursive: true, force: true });
|
|
135
|
+
if (hadOld) await rename(old, target);
|
|
128
136
|
throw error;
|
|
129
137
|
} finally { await rm(old, { recursive: true, force: true }); }
|
|
130
138
|
return target;
|
|
131
139
|
} finally { await rm(temp, { recursive: true, force: true }); }
|
|
132
140
|
}
|
|
141
|
+
|
|
142
|
+
async function commitPreset(cache, path, commitLock = async () => {}) {
|
|
143
|
+
const latest = join(cache, 'latest');
|
|
144
|
+
let previous;
|
|
145
|
+
try { previous = await readlink(latest); } catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
146
|
+
await linkRuntime(path, cache);
|
|
147
|
+
try { await commitLock(); } catch (error) {
|
|
148
|
+
await rm(latest, { force: true });
|
|
149
|
+
if (previous !== undefined) await symlink(previous, latest, 'dir');
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function cleanupLegacy(cache) {
|
|
154
|
+
for (const name of await readdir(cache)) {
|
|
155
|
+
if (/^[0-9a-f]{64}$/.test(name)) await rm(join(cache, name), { recursive: true, force: true });
|
|
156
|
+
}
|
|
157
|
+
const runtime = join(cache, 'runtime');
|
|
158
|
+
try { if ((await lstat(runtime)).isSymbolicLink()) await rm(runtime); }
|
|
159
|
+
catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
160
|
+
}
|
|
161
|
+
|
|
133
162
|
export async function updatePreset(context) {
|
|
134
163
|
forbidCIOverride();
|
|
135
164
|
const preset = presetConfig(context);
|
|
136
165
|
if (!preset) throw new Error('config.preset is required');
|
|
137
166
|
return withOperation(context, async cache => {
|
|
138
167
|
const lock = { ...preset, commit: '' };
|
|
139
|
-
const path = await install(context, lock, cache
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
168
|
+
const path = await install(context, lock, cache, async path => {
|
|
169
|
+
await commitPreset(cache, path, async () => {
|
|
170
|
+
const temporary = join(context.designDir, `.preset-lock-${randomUUID()}`);
|
|
171
|
+
try {
|
|
172
|
+
await writeFile(temporary, JSON.stringify(lock, null, 2) + '\n', { flag: 'wx' });
|
|
173
|
+
await rename(temporary, join(context.designDir, 'preset.lock.json'));
|
|
174
|
+
} finally { await rm(temporary, { force: true }); }
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
await cleanupLegacy(cache);
|
|
146
178
|
return path;
|
|
147
179
|
});
|
|
148
180
|
}
|
|
@@ -151,8 +183,8 @@ export async function installPreset(context) {
|
|
|
151
183
|
const preset = presetConfig(context);
|
|
152
184
|
if (!preset) throw new Error('config.preset is required');
|
|
153
185
|
return withOperation(context, async cache => {
|
|
154
|
-
const path = await install(context, await readLock(context, preset), cache);
|
|
155
|
-
await
|
|
186
|
+
const path = await install(context, await readLock(context, preset), cache, path => commitPreset(cache, path));
|
|
187
|
+
await cleanupLegacy(cache);
|
|
156
188
|
return path;
|
|
157
189
|
});
|
|
158
190
|
}
|
package/preview-css.mjs
CHANGED
|
@@ -17,8 +17,7 @@ export async function previewCss(context) {
|
|
|
17
17
|
const base = await presetDesign(context);
|
|
18
18
|
const dynamic = !!base || !!config?.tokenOverrides;
|
|
19
19
|
const sources = dynamic ? [...await overlayFiles(context, 'components'), ...await overlayFiles(context, 'layouts')] : [];
|
|
20
|
-
|
|
21
|
-
if (extraCss !== undefined && (typeof extraCss !== 'string' || !extraCss.trim())) throw new Error('preview.css must be a non-empty path');
|
|
20
|
+
if (config?.preview?.css !== undefined) throw new Error('preview.css is no longer supported; move reusable styles to pattern styles.css');
|
|
22
21
|
const output = config ? themePath(context) : null;
|
|
23
22
|
let generated = false;
|
|
24
23
|
if (output) {
|
|
@@ -30,7 +29,6 @@ export async function previewCss(context) {
|
|
|
30
29
|
const input = [
|
|
31
30
|
`@import ${JSON.stringify(tailwind)} source(none);`,
|
|
32
31
|
...(dynamic ? [await renderTheme(context)] : generated ? [`@import ${JSON.stringify(output)};`] : []),
|
|
33
|
-
...(extraCss ? [`@import ${JSON.stringify(resolve(projectDir, extraCss))};`] : []),
|
|
34
32
|
...(typeof tokens.variant === 'string' ? [tokens.variant] : []),
|
|
35
33
|
...blocks,
|
|
36
34
|
...(dynamic ? sources.map(file => `@source ${JSON.stringify(file.path)};`) : [`@source ${JSON.stringify(resolve(designDir, 'components'))};`, `@source ${JSON.stringify(resolve(designDir, 'layouts'))};`]),
|
|
@@ -5,23 +5,30 @@ description: Use the project's .design system and its tooling when inspecting, d
|
|
|
5
5
|
|
|
6
6
|
# Design system workflow
|
|
7
7
|
|
|
8
|
-
Before
|
|
8
|
+
Before changing an interface, read `DESIGN.md` where present, relevant rules, and the affected patterns' docs and previews. Install a configured preset first. The design system is authoritative; raise conflicts with host conventions. Accessibility takes precedence.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
## Finding patterns and examples
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- Local sources are in `.design/`. An installed preset's shared sources are in `.design/.preset/latest/.design/`; `latest` points to the locked checkout, not necessarily the newest remote commit. For `DESIGN_PRESET_DIR`, use that checkout instead. Without a preset, use local sources only.
|
|
13
|
+
- Find patterns in `components/<pattern>/` and `layouts/<pattern>/`. Read `docs.md`, `preview.html` and, when present, `styles.css`. See `tokens/`, `assets/` and `rules/` for foundations and constraints.
|
|
14
|
+
- A local pattern directory replaces the whole preset pattern. Check it first; retain all needed files when creating an override. The showcase resolves both layers.
|
|
15
|
+
- Preview HTML and its inline vanilla JavaScript are references: adapt markup and behavior to the host's technology and lifecycle. Do not ship demo handlers. Preserve documented states and accessibility; report gaps.
|
|
16
|
+
|
|
17
|
+
Edit authored local sources and previews, not generated output or cached preset files. Keep previews, styles and docs consistent; document new reusable patterns and gaps.
|
|
13
18
|
|
|
14
19
|
## Tooling and validation
|
|
15
20
|
|
|
16
21
|
Requires Node 22+. Run these commands from the host project root:
|
|
17
22
|
|
|
23
|
+
If `.design/config.json` configures a preset, run `npx @raketa-cloud/design-cli@latest preset install`; repository access may be required. To advance the locked preset, run `npx @raketa-cloud/design-cli@latest preset update` and review the lock and resulting behavior.
|
|
24
|
+
|
|
18
25
|
```bash
|
|
19
|
-
npx @raketa-cloud/design-cli generate
|
|
20
|
-
npx @raketa-cloud/design-cli serve
|
|
21
|
-
npx @raketa-cloud/design-cli new component my-pattern
|
|
22
|
-
npx @raketa-cloud/design-cli new layout my-pattern
|
|
26
|
+
npx @raketa-cloud/design-cli@latest generate
|
|
27
|
+
npx @raketa-cloud/design-cli@latest serve
|
|
28
|
+
npx @raketa-cloud/design-cli@latest new component my-pattern
|
|
29
|
+
npx @raketa-cloud/design-cli@latest new layout my-pattern
|
|
23
30
|
```
|
|
24
31
|
|
|
25
|
-
Generate before serving the showcase at `http://127.0.0.1:4174
|
|
32
|
+
Generate before serving the showcase at `http://127.0.0.1:4174` (or set `PORT`). The theme bundles tokens and pattern `styles.css` as plain CSS; host tooling supplies utility classes. Use `init` only for an uninitialized project; `new` scaffolds patterns without overwriting them.
|
|
26
33
|
|
|
27
|
-
|
|
34
|
+
After relevant changes, generate, run focused tests, and inspect previews at desktop and narrow widths in supported themes. Validate production integration separately; generation does not wire the host application. Report anything unverified.
|