@raketa-cloud/design-cli 1.1.4 → 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 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 preset. New scaffold previews link `/__showcase/theme.css`, so existing component classes work when opened through the showcase. Scaffolded markup and docs remain placeholders, not finished designs.
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`, detects normalized or CSS-native data, emits custom properties and appends CSS files recursively from `components/`. `preview.css` is excluded because it contains specimen-only presentation. For CSS-native sources, `tokens/palettes.json` supplies optional `:root`/`.dark` custom properties, and `tokens/components.json` supplies optional component aliases and dark overrides. Normalized sources include their token groups and themes in `tokens.json`. Token references become CSS variable references. Component CSS must be standalone: Tailwind `@apply`, `@theme`, `@source`, and CSS `@import` are rejected. Relative asset URLs remain the component author's responsibility. Preview HTML, scripts, host runtime assets and application builds are not generated or updated.
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` uses the CLI's bundled Tailwind compiler, design tokens and component/layout previews, independent of the host framework. It includes the generated theme when present. If previews also depend on a Tailwind-compatible stylesheet, set `"preview": { "css": "raketa/index.css" }` in `config.json` (path relative to the project). This is preview-only and does not alter production CSS. The stylesheet and its imports must be compatible with the CLI's Tailwind version; host plugins must be resolvable by the host. Run `generate` before serving to include the theme. Missing output returns 404 at `/__showcase/theme.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/` for shared design inputs and `raketa/` for runtime assets. Run `design preset update` to resolve the ref and write `.design/preset.lock.json`; commit the lock. On a fresh checkout run `design preset install` before building. Generate and serve do not fetch; updates are explicit and reviewable. Git access must be available without an interactive prompt.
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 is ignored by its own ignore file. Install and update keep one locked checkout and link `.design/.preset/latest` to it; shared sources are in `latest/.design/` and runtime assets in `latest/raketa/`. Successful installation removes old hashed caches and the former `runtime` link. Run generate or serve after changing the selected preset. Production builds must install first and include the generated theme and runtime assets using the host's framework-specific wiring.
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
- For live preset development, set `DESIGN_PRESET_DIR` to a local checkout and run generate or serve. Changes to that checkout are visible through the runtime link and showcase. This override is forbidden when `CI` is set. Restart the showcase after changing the checkout location.
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 overlayFiles(context, 'components')).filter(file => file.name.endsWith('.css') && !file.name.endsWith('/preview.css'));
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('Component styles must be standalone CSS: ' + name);
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/theme.css"></head><body><main><h1>${name}</h1><p>Replace this placeholder with the pattern.</p></main></body></html>\n`, { flag: 'wx' });
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-cloud/design-cli",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "CLI for building and previewing local design systems",
5
5
  "repository": {
6
6
  "type": "git",
package/preset.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { lstat, mkdir, mkdtemp, readFile, readdir, readlink, realpath, rename, rm, symlink, writeFile } from 'node:fs/promises';
4
- import { isAbsolute, join, resolve, sep } from 'node:path';
4
+ import { isAbsolute, join, resolve } from 'node:path';
5
5
  import { promisify } from 'node:util';
6
6
 
7
7
  const exec = promisify(execFile);
@@ -60,10 +60,10 @@ export async function resolvePreset(context) {
60
60
  return validateCheckout(context, await readLock(context, preset));
61
61
  }
62
62
 
63
- // Link the selected checkout so both its design sources and runtime are accessible.
63
+ // The checkout is reference material; no runtime files are copied into the host.
64
64
  async function linkRuntime(preset, cache) {
65
65
  const target = await realpath(preset);
66
- await validateRuntime(target);
66
+ await validateDesign(target);
67
67
  const latest = join(cache, 'latest');
68
68
  try {
69
69
  if (!(await lstat(latest)).isSymbolicLink()) throw new Error(`Refusing to replace non-symlink latest path: ${latest}`);
@@ -75,12 +75,11 @@ async function linkRuntime(preset, cache) {
75
75
  } finally { await rm(temporary, { force: true }); }
76
76
  }
77
77
 
78
- async function validateRuntime(preset) {
79
- const assets = join(preset, 'raketa');
78
+ async function validateDesign(preset) {
79
+ const design = join(preset, '.design');
80
80
  try {
81
- const target = await realpath(assets);
82
- if (!target.startsWith(await realpath(preset) + sep) || !(await lstat(target)).isDirectory()) throw new Error('not a directory inside the preset');
83
- } catch (error) { throw new Error(`Invalid preset runtime directory ${assets}: ${error.message}`); }
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}`); }
84
83
  }
85
84
 
86
85
  export async function refreshPresetRuntime(context) {
@@ -121,7 +120,7 @@ async function install(context, lock, cache, commit) {
121
120
  const temp = await mkdtemp(join(cache, '.staging-'));
122
121
  try {
123
122
  await checkout(context, lock, temp);
124
- await validateRuntime(temp);
123
+ await validateDesign(temp);
125
124
  const target = cachePath(context);
126
125
  const valid = await validateCheckout(context, lock).then(() => true, () => false);
127
126
  if (valid) { await commit(target); return target; }
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
- const extraCss = config?.preview?.css;
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'))};`]),
@@ -10,9 +10,9 @@ Before changing an interface, read `DESIGN.md` where present, relevant rules, an
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 examples in `components/<pattern>/` and `layouts/<pattern>/`: `docs.md` explains usage, `preview.html` contains example markup, and `styles.css` may contain reusable styles. See `tokens/`, `assets/` and `rules/` for foundations and constraints.
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
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
- - Adapt examples to the application; preserve documented structure, states and accessibility. Report missing patterns or assets and unresolved design decisions.
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
16
 
17
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.
18
18
 
@@ -29,6 +29,6 @@ npx @raketa-cloud/design-cli@latest new component my-pattern
29
29
  npx @raketa-cloud/design-cli@latest new layout my-pattern
30
30
  ```
31
31
 
32
- Generate before serving the showcase at `http://127.0.0.1:4174` (or set `PORT`). If needed, set `preview.css` in `.design/config.json` to a project-relative Tailwind-compatible CSS file. Use `init` only for an uninitialized project; `new` scaffolds patterns without overwriting them.
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.
33
33
 
34
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.