@raketa-cloud/design-cli 1.0.0 → 1.0.3
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 +11 -4
- package/catalog/css-native.mjs +4 -7
- package/cli.mjs +6 -2
- package/config.mjs +5 -8
- package/init.mjs +31 -0
- package/package.json +34 -7
- package/preview-css.mjs +31 -8
- package/skills/design-system/SKILL.md +27 -0
package/README.md
CHANGED
|
@@ -4,9 +4,10 @@ Shared Node 22+ tooling for local design systems. It serves the showcase and bui
|
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Initialize a host project, then generate and preview its design system:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
+
npx @raketa-cloud/design-cli init
|
|
10
11
|
npx @raketa-cloud/design-cli generate
|
|
11
12
|
npx @raketa-cloud/design-cli serve
|
|
12
13
|
npx @raketa-cloud/design-cli new component my-pattern
|
|
@@ -14,6 +15,8 @@ npx @raketa-cloud/design-cli new layout my-pattern
|
|
|
14
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.
|
|
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
|
+
|
|
17
20
|
|
|
18
21
|
Pattern previews are hand-maintained `preview.html` files, optionally accompanied by `docs.md` and reusable `styles.css`. Generation does not produce or overwrite previews.
|
|
19
22
|
|
|
@@ -32,13 +35,17 @@ A design directory has `config.json`:
|
|
|
32
35
|
|
|
33
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.
|
|
34
37
|
|
|
35
|
-
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
|
|
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
|
+
|
|
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`.
|
|
36
41
|
|
|
37
|
-
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`.
|
|
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.
|
|
38
43
|
|
|
39
44
|
Run `npm test` here for tooling behavior. Consumers should separately validate integration and preview appearance; the build does not change their production wiring.
|
|
40
45
|
|
|
41
46
|
## Publishing
|
|
42
47
|
|
|
43
|
-
The package is public on npm even though this repository is private.
|
|
48
|
+
The package is public on npm even though this repository is private. In npm package settings, add a GitHub Actions trusted publisher for organization `studioraketa`, repository `design-system-tools`, workflow filename `publish.yml`, with direct `npm publish` allowed and no environment name. The workflow uses GitHub OIDC rather than an npm token; Node 24 supplies the required npm 11.5.1 or later. Complete the first publish within two days of creating the trusted publisher. Private repositories do not generate npm provenance.
|
|
49
|
+
|
|
50
|
+
Update the package version and lockfile, then publish a GitHub release tagged with the exact version (for example, `1.0.2`); the workflow checks the tag, runs tests, and publishes to npm. Prereleases are not published. After a successful trusted publish, revoke the old npm publishing token and remove the `NPM_TOKEN` GitHub secret.
|
|
44
51
|
|
package/catalog/css-native.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Read-only projection for CSS-native Raketa token packages.
|
|
2
|
-
export function showcaseData(input,
|
|
2
|
+
export function showcaseData(input, status, componentTokens) {
|
|
3
3
|
if (!input.blocks) return input;
|
|
4
4
|
const declarations = selector => {
|
|
5
5
|
const block = input.blocks.find(block => block.selector === selector);
|
|
@@ -67,13 +67,10 @@ export function showcaseData(input, componentCSS, status, componentTokens) {
|
|
|
67
67
|
const type = (size, lineHeight, weight = 400) => ({ $type: 'typography', $value: { fontFamily: '{foundation.font.ui}', fontSize: { value: size, unit: 'px' }, lineHeight: Number(lineHeight.toFixed(2)), fontWeight: weight, letterSpacing: { value: 0, unit: 'em' } } });
|
|
68
68
|
const scale = { 'text-4xl': [36, 40 / 36], 'text-xl': [20, 28 / 20], 'text-sm': [14, 20 / 14], 'text-xs': [12, 16 / 12] };
|
|
69
69
|
const typography = {};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (!rule) throw new Error('Missing authored typography rule: ' + name);
|
|
73
|
-
const utility = rule.match(/@apply (text-[\w-]+)/)?.[1];
|
|
74
|
-
if (!scale[utility]) throw new Error('Unknown authored typography size: ' + utility);
|
|
70
|
+
// Raketa's documented default typography specimens; host CSS is not a design input.
|
|
71
|
+
for (const [name, utility, weight] of [['title-page', 'text-4xl', 700], ['title-header', 'text-xl', 700], ['title-section', 'text-xl', 600], ['title-subsection', 'text-sm', 600]]) {
|
|
75
72
|
const [size, lineHeight] = scale[utility];
|
|
76
|
-
typography[name] = type(size, lineHeight,
|
|
73
|
+
typography[name] = type(size, lineHeight, weight);
|
|
77
74
|
}
|
|
78
75
|
typography['body-1'] = type(14, 20 / 14);
|
|
79
76
|
typography['text-sm'] = type(14, 20 / 14);
|
package/cli.mjs
CHANGED
|
@@ -6,10 +6,14 @@ import { build } from './build.mjs';
|
|
|
6
6
|
|
|
7
7
|
const [command, ...args] = process.argv.slice(2);
|
|
8
8
|
if (command === '--help' || command === '-h' || !command) {
|
|
9
|
-
console.log('Usage: design <generate|serve|new>\n\n generate Build the design system CSS\n serve Start the local showcase\n new <component|layout> <name> Scaffold a pattern');
|
|
9
|
+
console.log('Usage: design <init|generate|serve|new>\n\n init Set up a design system and agent skill\n generate Build the design system CSS\n serve Start the local showcase\n new <component|layout> <name> Scaffold a pattern');
|
|
10
10
|
} else if (command === '--version' || command === '-v') {
|
|
11
11
|
const { readFile } = await import('node:fs/promises');
|
|
12
12
|
console.log(JSON.parse(await readFile(new URL('./package.json', import.meta.url), 'utf8')).version);
|
|
13
|
+
} else if (command === 'init') {
|
|
14
|
+
if (args.length) throw new Error('Unexpected arguments');
|
|
15
|
+
const { init } = await import('./init.mjs');
|
|
16
|
+
await init();
|
|
13
17
|
} else if (command === 'new') {
|
|
14
18
|
const [kind, name, ...extra] = args;
|
|
15
19
|
if (!['component', 'layout'].includes(kind) || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(name || '') || extra.length) throw new Error('Usage: design new <component|layout> <kebab-case-name>');
|
|
@@ -34,4 +38,4 @@ if (command === '--help' || command === '-h' || !command) {
|
|
|
34
38
|
} else if (command === 'serve') {
|
|
35
39
|
if (args.length) throw new Error('Unexpected arguments');
|
|
36
40
|
await import('./showcase/serve.mjs');
|
|
37
|
-
} else throw new Error('Usage: design <generate|serve|new>');
|
|
41
|
+
} else throw new Error('Usage: design <init|generate|serve|new>');
|
package/config.mjs
CHANGED
|
@@ -25,18 +25,15 @@ export async function tokenSource(designDir) {
|
|
|
25
25
|
return { input, type: cssNative ? 'raketa-css' : 'tokens' };
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export async function raketaInputs({ designDir
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
readFile(resolve(projectDir, 'raketa/components.css'), 'utf8')
|
|
32
|
-
]);
|
|
33
|
-
return { input, componentTokens, css };
|
|
28
|
+
export async function raketaInputs({ designDir }, input) {
|
|
29
|
+
const componentTokens = JSON.parse(await readFile(resolve(designDir, 'tokens/components.json'), 'utf8'));
|
|
30
|
+
return { input, componentTokens };
|
|
34
31
|
}
|
|
35
32
|
|
|
36
33
|
export async function catalog(context) {
|
|
37
34
|
const { input, type } = await tokenSource(context.designDir);
|
|
38
35
|
if (type === 'tokens') return input;
|
|
39
|
-
const { componentTokens
|
|
36
|
+
const { componentTokens } = await raketaInputs(context, input);
|
|
40
37
|
const status = statusColors(await previewCss(context));
|
|
41
|
-
return showcaseData(input,
|
|
38
|
+
return showcaseData(input, status, componentTokens);
|
|
42
39
|
}
|
package/init.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { lstat, mkdir, readFile, symlink, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export async function init() {
|
|
5
|
+
const root = process.cwd();
|
|
6
|
+
const paths = ['.design', '.agents/skills/design-system', '.claude/skills/design-system', '.pi/skills/design-system'];
|
|
7
|
+
for (const path of paths) {
|
|
8
|
+
try {
|
|
9
|
+
await lstat(resolve(root, path));
|
|
10
|
+
throw new Error(`Refusing to overwrite existing path: ${path}`);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (error.code !== 'ENOENT') throw error;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// Create the design directory exclusively; existing projects are never merged or overwritten.
|
|
16
|
+
await mkdir(resolve(root, '.design'));
|
|
17
|
+
for (const dir of ['tokens', 'components', 'layouts', 'rules', 'assets']) {
|
|
18
|
+
await mkdir(resolve(root, '.design', dir));
|
|
19
|
+
}
|
|
20
|
+
await writeFile(resolve(root, '.design/config.json'), JSON.stringify({ system: { name: 'My design system', id: 'my-design-system' }, build: { output: 'public/design' } }, null, 2) + '\n', { flag: 'wx' });
|
|
21
|
+
const tokens = { primitive: { color: { neutral: { white: { $type: 'color', $value: '#ffffff' }, black: { $type: 'color', $value: '#000000' } } } }, semantic: { color: { background: { $type: 'color', $value: '{primitive.color.neutral.white}' }, foreground: { $type: 'color', $value: '{primitive.color.neutral.black}' } } } };
|
|
22
|
+
await writeFile(resolve(root, '.design/tokens/tokens.json'), JSON.stringify(tokens, null, 2) + '\n', { flag: 'wx' });
|
|
23
|
+
await writeFile(resolve(root, '.design/DESIGN.md'), '# Design system\n\nReplace this starter with your design principles, conventions, and references.\n', { flag: 'wx' });
|
|
24
|
+
await mkdir(resolve(root, '.agents/skills/design-system'), { recursive: true });
|
|
25
|
+
await writeFile(resolve(root, '.agents/skills/design-system/SKILL.md'), await readFile(new URL('./skills/design-system/SKILL.md', import.meta.url)), { flag: 'wx' });
|
|
26
|
+
for (const agent of ['.claude', '.pi']) {
|
|
27
|
+
await mkdir(resolve(root, agent, 'skills'), { recursive: true });
|
|
28
|
+
await symlink('../../.agents/skills/design-system', resolve(root, agent, 'skills/design-system'), 'dir');
|
|
29
|
+
}
|
|
30
|
+
console.log('Initialized .design and installed the design-system skill.\n\nNext steps:\n 1. Update .design/config.json (system name, id, and output path).\n 2. Replace the starter tokens and document your system in .design/DESIGN.md and rules/.\n 3. Add patterns, run design generate and design serve, and wire the CSS into your app.');
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raketa-cloud/design-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "CLI for building and previewing local design systems",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/studioraketa/design-system-tools.git"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"design": "cli.mjs"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"*.mjs",
|
|
14
|
+
"catalog/",
|
|
15
|
+
"showcase/",
|
|
16
|
+
"tokens/",
|
|
17
|
+
"skills/"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
8
22
|
"type": "module",
|
|
9
|
-
"engines": {
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=22"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
"./showcase/serve.mjs": "./showcase/serve.mjs",
|
|
28
|
+
"./showcase/assets.mjs": "./showcase/assets.mjs",
|
|
29
|
+
"./showcase/asset-grid.mjs": "./showcase/asset-grid.mjs",
|
|
30
|
+
"./cli.mjs": "./cli.mjs"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "node --test tests/*.test.mjs"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@tailwindcss/cli": "^4.3.5",
|
|
37
|
+
"tailwindcss": "^4.3.5"
|
|
38
|
+
}
|
|
12
39
|
}
|
package/preview-css.mjs
CHANGED
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import {
|
|
2
|
+
import { readFile, access } from 'node:fs/promises';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { dirname, resolve } from 'node:path';
|
|
5
|
+
import { themePath } from './config.mjs';
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const cli = resolve(dirname(require.resolve('@tailwindcss/cli/package.json')), 'dist/index.mjs');
|
|
9
|
+
const tailwind = require.resolve('tailwindcss/index.css');
|
|
10
|
+
|
|
11
|
+
// Preview compilation is independent of the host application's toolchain.
|
|
12
|
+
export async function previewCss(context) {
|
|
13
|
+
const { projectDir, designDir, config } = context;
|
|
14
|
+
const tokens = JSON.parse(await readFile(resolve(designDir, 'tokens/tokens.json'), 'utf8'));
|
|
15
|
+
const extraCss = config?.preview?.css;
|
|
16
|
+
if (extraCss !== undefined && (typeof extraCss !== 'string' || !extraCss.trim())) throw new Error('preview.css must be a non-empty path');
|
|
17
|
+
const output = config ? themePath(context) : null;
|
|
18
|
+
let generated = false;
|
|
19
|
+
if (output) {
|
|
20
|
+
try { await access(output); generated = true; } catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
21
|
+
}
|
|
22
|
+
const blocks = (tokens.blocks || []).filter(block => block.selector === '@theme' || block.selector === '@theme inline').map(block =>
|
|
23
|
+
`${block.selector} {\n${Object.entries(block.tokens).map(([name, token]) => ` ${name}: ${token.$value};`).join('\n')}\n}`
|
|
24
|
+
);
|
|
6
25
|
const input = [
|
|
7
|
-
`@import ${JSON.stringify(
|
|
26
|
+
`@import ${JSON.stringify(tailwind)} source(none);`,
|
|
27
|
+
...(generated ? [`@import ${JSON.stringify(output)};`] : []),
|
|
28
|
+
...(extraCss ? [`@import ${JSON.stringify(resolve(projectDir, extraCss))};`] : []),
|
|
29
|
+
...(typeof tokens.variant === 'string' ? [tokens.variant] : []),
|
|
30
|
+
...blocks,
|
|
8
31
|
`@source ${JSON.stringify(resolve(designDir, 'components'))};`,
|
|
9
32
|
`@source ${JSON.stringify(resolve(designDir, 'layouts'))};`,
|
|
10
33
|
'@source inline("bg-{red,green,orange,yellow}-{50,{100..900..100},950}");'
|
|
11
34
|
].join('\n');
|
|
12
35
|
return new Promise((resolvePromise, reject) => {
|
|
13
|
-
const child = spawn(
|
|
14
|
-
let
|
|
15
|
-
child.stdout.setEncoding('utf8').on('data', chunk => {
|
|
36
|
+
const child = spawn(process.execPath, [cli, '-i', '-'], { cwd: projectDir, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
37
|
+
let outputCss = '', errors = '';
|
|
38
|
+
child.stdout.setEncoding('utf8').on('data', chunk => { outputCss += chunk; });
|
|
16
39
|
child.stderr.setEncoding('utf8').on('data', chunk => { errors += chunk; });
|
|
17
40
|
child.on('error', reject);
|
|
18
41
|
child.stdin.on('error', error => { if (error.code !== 'EPIPE') reject(error); });
|
|
19
|
-
child.on('close', code => code === 0 ? resolvePromise(
|
|
42
|
+
child.on('close', code => code === 0 ? resolvePromise(outputCss) : reject(new Error(`Preview CSS compilation failed (${code}): ${errors}`)));
|
|
20
43
|
child.stdin.end(input);
|
|
21
44
|
});
|
|
22
45
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: design-system
|
|
3
|
+
description: Use the project's .design system and its tooling when inspecting, designing, building, or changing interfaces, design tokens, components, layouts, or previews.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Design system workflow
|
|
7
|
+
|
|
8
|
+
Before designing or changing an interface, read `.design/DESIGN.md`, the relevant rules under `.design/rules/`, and the documentation and previews for the patterns involved. The design system is authoritative; flag conflicts with host conventions and ask. Accessibility takes precedence.
|
|
9
|
+
|
|
10
|
+
Use the project's tokens, assets and documented patterns. Preserve semantic structure, reading order, responsive behavior, keyboard access and visible focus. Report missing patterns or assets; do not invent imagery. Document new reusable patterns and known gaps, and ask when a necessary design decision is unresolved.
|
|
11
|
+
|
|
12
|
+
For design-system work, edit previews directly and keep them consistent with reusable styles and documentation. Follow the project's styling conventions.
|
|
13
|
+
|
|
14
|
+
## Tooling and validation
|
|
15
|
+
|
|
16
|
+
Requires Node 22+. Run these commands from the host project root:
|
|
17
|
+
|
|
18
|
+
```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
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Generate before serving the showcase at `http://127.0.0.1:4174`; set `PORT` to use another port. The CLI bundles the Tailwind compiler for previews and does not require Rails or a host Tailwind installation. If previews depend on additional Tailwind-compatible CSS, set `preview.css` in `.design/config.json` to its project-relative path; validate that the preview matches the host. The `new` commands scaffold placeholders without overwriting existing patterns. If the project has not been initialized, run `npx @raketa-cloud/design-cli init`; it refuses to overwrite existing design or skill paths.
|
|
26
|
+
|
|
27
|
+
Edit tokens and component CSS, not generated CSS. The build does not regenerate previews or wire the host application. After relevant changes, generate, run focused tests, and inspect previews at desktop and narrow widths and in supported themes. Validate production integration separately and report gaps or anything unverified.
|