@milesroxas/create-design-hub 0.1.3 → 0.3.0
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/index.mjs +17 -6
- package/lib.mjs +54 -4
- package/package.json +3 -2
- package/setup/app.html +79 -1
- package/setup/lib.mjs +12 -0
- package/setup/lib.test.mjs +20 -2
- package/setup/server.mjs +13 -6
- package/template/.design-hub/project.json +3 -0
- package/template/.env.example +12 -2
- package/template/AGENTS.md +17 -9
- package/template/DESIGN.md +13 -3
- package/template/README.md +5 -3
- package/template/_gitignore +7 -2
- package/template/docs/sprints/sample-brand/guide.md +63 -0
- package/template/docs/sprints/sample-site/guide.md +69 -0
- package/template/kit/shell.ts +1 -0
- package/template/package.json +2 -0
- package/template/prototypes/sample-list/README.md +1 -0
- package/template/prototypes/sample-page/README.md +52 -0
- package/template/prototypes/sample-page/fixtures.json +78 -0
- package/template/prototypes/sample-page/index.tsx +115 -0
- package/template/prototypes/sample-page/styles.css +27 -0
- package/template/prototypes/sample-social/README.md +56 -0
- package/template/prototypes/sample-social/fixtures.json +46 -0
- package/template/prototypes/sample-social/index.tsx +95 -0
- package/template/prototypes/sample-social/styles.css +20 -0
- package/template/.claude/launch.json +0 -18
package/index.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// npm create @milesroxas/design-hub -- --path <absolute path> [--owner <gh account>] [--visibility private|public|none]
|
|
3
|
+
// [--track product|website|brand ...] [--platform webflow|payload|wordpress|emdash] [--frontend astro|next]
|
|
3
4
|
//
|
|
4
5
|
// Copies the template into the folder, names the project after it, pins the
|
|
5
6
|
// design-hub version, starts a git repo, installs, and puts the miles-*
|
|
6
|
-
// skills in place. With --
|
|
7
|
+
// skills in place. With --track it records the project's tracks and keeps
|
|
8
|
+
// only their samples. With --visibility private or public it also creates the
|
|
7
9
|
// GitHub repo and pushes. Flags only, never a prompt, one JSON object on
|
|
8
10
|
// stdout, `--help` prints the schema, a second run finds the project and
|
|
9
11
|
// changes nothing.
|
|
10
12
|
import { spawnSync } from 'node:child_process';
|
|
11
|
-
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync,
|
|
13
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
14
|
import { basename, dirname, join } from 'node:path';
|
|
13
15
|
import { fileURLToPath } from 'node:url';
|
|
14
16
|
import { parseArgs } from 'node:util';
|
|
15
|
-
import { projectManifest, RENAMES, SKIP, SKIP_DIRS, SPEC, validate } from './lib.mjs';
|
|
17
|
+
import { projectManifest, RENAMES, SKIP, SKIP_DIRS, SPEC, tracksArgs, validate } from './lib.mjs';
|
|
16
18
|
|
|
17
19
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
18
20
|
const TEMPLATE = join(HERE, 'template');
|
|
@@ -37,6 +39,7 @@ function run(cmd, args, cwd) {
|
|
|
37
39
|
fail(`${cmd} ${args[0]} failed.`, {
|
|
38
40
|
command: [cmd, ...args].join(' '),
|
|
39
41
|
stderr: out.stderr.trim().slice(-600),
|
|
42
|
+
stdout: out.stdout.trim().slice(-600),
|
|
40
43
|
});
|
|
41
44
|
return out.stdout.trim();
|
|
42
45
|
}
|
|
@@ -54,6 +57,9 @@ try {
|
|
|
54
57
|
owner: { type: 'string' },
|
|
55
58
|
visibility: { type: 'string' },
|
|
56
59
|
link: { type: 'string' },
|
|
60
|
+
track: { type: 'string', multiple: true },
|
|
61
|
+
platform: { type: 'string' },
|
|
62
|
+
frontend: { type: 'string' },
|
|
57
63
|
'no-install': { type: 'boolean' },
|
|
58
64
|
},
|
|
59
65
|
strict: true,
|
|
@@ -71,9 +77,13 @@ if (major < 22 || (major === 22 && minor < 18))
|
|
|
71
77
|
|
|
72
78
|
const errors = validate(values);
|
|
73
79
|
if (Object.keys(errors).length) fail(Object.values(errors).join(' '), { errors });
|
|
74
|
-
const { path, visibility = 'none', link } = values;
|
|
80
|
+
const { path, visibility = 'none', link, track = [] } = values;
|
|
75
81
|
const name = basename(path);
|
|
76
|
-
|
|
82
|
+
// dev claims the folder's port on its first start; bootstrap is only for its flags (TypeSafe, Vercel, Conductor).
|
|
83
|
+
const next =
|
|
84
|
+
values['no-install'] && track.length
|
|
85
|
+
? `pnpm --dir "${path}" install, then pnpm --dir "${path}" exec design-hub ${tracksArgs(values).join(' ')}`
|
|
86
|
+
: `pnpm --dir "${path}" ${values['no-install'] ? 'install' : 'dev'}`;
|
|
77
87
|
|
|
78
88
|
// A second run finds the project already there and changes nothing.
|
|
79
89
|
if (existsSync(join(path, 'package.json')) && existsSync(join(path, '.git'))) {
|
|
@@ -113,6 +123,7 @@ run('git', ['init', '-b', 'main'], path);
|
|
|
113
123
|
if (!values['no-install']) {
|
|
114
124
|
run('pnpm', ['install'], path);
|
|
115
125
|
run(join(path, 'node_modules', '.bin', 'design-hub'), ['skills'], path);
|
|
126
|
+
if (track.length) run(join(path, 'node_modules', '.bin', 'design-hub'), tracksArgs(values), path);
|
|
116
127
|
}
|
|
117
128
|
run('git', ['add', '-A'], path);
|
|
118
129
|
run(
|
|
@@ -151,4 +162,4 @@ if (visibility !== 'none') {
|
|
|
151
162
|
);
|
|
152
163
|
repo = `https://github.com/${owner}/${name}`;
|
|
153
164
|
}
|
|
154
|
-
print({ ok: true, path, repo, created: true, next });
|
|
165
|
+
print({ ok: true, path, repo, created: true, ...(track.length ? { tracks: track } : {}), next });
|
package/lib.mjs
CHANGED
|
@@ -27,9 +27,25 @@ export const SPEC = {
|
|
|
27
27
|
description:
|
|
28
28
|
'Developing Design Hub itself: a local path to packages/design-hub, installed with the link: protocol.',
|
|
29
29
|
},
|
|
30
|
+
'--track': {
|
|
31
|
+
type: 'list',
|
|
32
|
+
choices: ['product', 'website', 'brand'],
|
|
33
|
+
description:
|
|
34
|
+
'A track the project has, repeated for several. Keeps only their samples. Default: every sample, tracks unset.',
|
|
35
|
+
},
|
|
36
|
+
'--platform': {
|
|
37
|
+
type: 'string',
|
|
38
|
+
choices: ['webflow', 'payload', 'wordpress', 'emdash'],
|
|
39
|
+
description: 'With --track website: where the site is built.',
|
|
40
|
+
},
|
|
41
|
+
'--frontend': {
|
|
42
|
+
type: 'string',
|
|
43
|
+
choices: ['astro', 'next'],
|
|
44
|
+
description: 'With Payload or WordPress: the front end. Webflow takes none; EmDash is always Astro.',
|
|
45
|
+
},
|
|
30
46
|
'--no-install': { type: 'boolean', description: 'Copy the template and stop before pnpm install.' },
|
|
31
47
|
},
|
|
32
|
-
output: '{ ok, path, repo, created, next }',
|
|
48
|
+
output: '{ ok, path, repo, created, tracks?, next }',
|
|
33
49
|
};
|
|
34
50
|
|
|
35
51
|
/** Files the template stores under another name, because npm drops dotfiles of these names from a package. */
|
|
@@ -38,12 +54,44 @@ export const RENAMES = { _gitignore: '.gitignore', _gitattributes: '.gitattribut
|
|
|
38
54
|
/** What is copied from the template: everything but what a project makes for itself. */
|
|
39
55
|
export const SKIP = new Set(['node_modules', 'dist', '.env', 'pnpm-lock.yaml']);
|
|
40
56
|
export const SKIP_DIRS = {
|
|
41
|
-
'.design-hub': new Set(['checks.json']),
|
|
42
|
-
'.claude': new Set(['settings.json'
|
|
57
|
+
'.design-hub': new Set(['checks.json', 'project.json']),
|
|
58
|
+
'.claude': new Set(['settings.json']),
|
|
43
59
|
};
|
|
44
60
|
|
|
61
|
+
const TRACKS = ['product', 'website', 'brand'];
|
|
62
|
+
// The platform rules of design-hub's core/project.ts, checked here before
|
|
63
|
+
// anything is copied, because the package that owns them is not installed
|
|
64
|
+
// yet. `design-hub tracks set` applies them again after the install.
|
|
65
|
+
const PLATFORM_FRONTEND = { webflow: null, emdash: 'astro', payload: 'choose', wordpress: 'choose' };
|
|
66
|
+
|
|
67
|
+
/** The problem with a set of tracks and a website platform, or null. */
|
|
68
|
+
export function tracksProblem({ track = [], platform, frontend }) {
|
|
69
|
+
const unknown = track.filter((t) => !TRACKS.includes(t));
|
|
70
|
+
if (unknown.length) return `--track takes ${TRACKS.join(', ')}; got ${unknown.join(', ')}.`;
|
|
71
|
+
if ((platform || frontend) && !track.includes('website'))
|
|
72
|
+
return '--platform and --frontend need --track website.';
|
|
73
|
+
if (frontend && !platform) return '--frontend needs --platform.';
|
|
74
|
+
if (!platform) return null;
|
|
75
|
+
if (!(platform in PLATFORM_FRONTEND))
|
|
76
|
+
return `--platform takes ${Object.keys(PLATFORM_FRONTEND).join(', ')}.`;
|
|
77
|
+
const rule = PLATFORM_FRONTEND[platform];
|
|
78
|
+
if (rule === 'choose' && !['astro', 'next'].includes(frontend ?? ''))
|
|
79
|
+
return `${platform} needs --frontend astro or next.`;
|
|
80
|
+
if (rule !== 'choose' && frontend && frontend !== rule)
|
|
81
|
+
return rule ? `${platform} always uses ${rule}.` : `${platform} renders its own pages; drop --frontend.`;
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Flags for `design-hub tracks set`, which records the tracks and drops the other tracks' samples. */
|
|
86
|
+
export function tracksArgs({ track = [], platform, frontend }) {
|
|
87
|
+
const args = ['tracks', 'set', ...track.flatMap((t) => ['--track', t]), '--remove-samples'];
|
|
88
|
+
if (platform) args.push('--platform', platform);
|
|
89
|
+
if (frontend) args.push('--frontend', frontend);
|
|
90
|
+
return args;
|
|
91
|
+
}
|
|
92
|
+
|
|
45
93
|
/** The problems with a create request, by flag; empty when it is valid. */
|
|
46
|
-
export function validate({ path, visibility = 'none', template, link }) {
|
|
94
|
+
export function validate({ path, visibility = 'none', template, link, track, platform, frontend }) {
|
|
47
95
|
const errors = {};
|
|
48
96
|
if (!path || !isAbsolute(path)) errors.path = '--path takes an absolute folder.';
|
|
49
97
|
else if (!/^[\w.-]+$/.test(basename(path)))
|
|
@@ -53,6 +101,8 @@ export function validate({ path, visibility = 'none', template, link }) {
|
|
|
53
101
|
if (template !== undefined && !/^[\w.-]+\/[\w.-]+$/.test(template))
|
|
54
102
|
errors.template = '--template takes owner/repo.';
|
|
55
103
|
if (link !== undefined && !isAbsolute(link)) errors.link = '--link takes an absolute path.';
|
|
104
|
+
const tracks = tracksProblem({ track, platform, frontend });
|
|
105
|
+
if (tracks) errors.track = tracks;
|
|
56
106
|
return errors;
|
|
57
107
|
}
|
|
58
108
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milesroxas/create-design-hub",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Create a Design Hub project: the thin folder of prototypes, kit materials and docs that installs the @milesroxas/design-hub package. Runs as `npm create @milesroxas/design-hub`.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"!template/node_modules",
|
|
24
24
|
"!template/.design-hub/*",
|
|
25
25
|
"template/.design-hub/checks.json",
|
|
26
|
+
"template/.design-hub/project.json",
|
|
26
27
|
"!template/.claude/skills",
|
|
27
28
|
"!template/dist",
|
|
28
29
|
"!template/.env",
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
],
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@biomejs/biome": "2.6.3",
|
|
34
|
-
"@milesroxas/design-hub": "0.
|
|
35
|
+
"@milesroxas/design-hub": "0.3.0"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"check": "biome check --config-path ../design-hub/configs/biome .",
|
package/setup/app.html
CHANGED
|
@@ -204,6 +204,13 @@
|
|
|
204
204
|
.choice input:checked { border: 1.5px solid var(--text); }
|
|
205
205
|
.choice input:checked::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--text); }
|
|
206
206
|
.choice input:focus-visible { outline: none; }
|
|
207
|
+
.choice input[type=checkbox] { border-radius: 4px; }
|
|
208
|
+
.choice input[type=checkbox]:checked { background: var(--text); border-color: var(--text); }
|
|
209
|
+
.choice input[type=checkbox]:checked::after { width: 8px; height: 4px; border-radius: 0; background: none; border-left: 1.5px solid var(--surface); border-bottom: 1.5px solid var(--surface); transform: translateY(-1px) rotate(-45deg); }
|
|
210
|
+
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--s2); }
|
|
211
|
+
legend { padding: 0; margin-bottom: var(--s2); font-size: var(--text-sm); font-weight: 500; }
|
|
212
|
+
.inline-choices { display: flex; flex-wrap: wrap; gap: var(--s2); }
|
|
213
|
+
.inline-choices .choice { padding: var(--s3) var(--s4); }
|
|
207
214
|
.choice-body { display: grid; gap: 2px; }
|
|
208
215
|
.choice-title { font-weight: 500; }
|
|
209
216
|
.choice:has(input:disabled) .choice-title { color: var(--disabled-text); }
|
|
@@ -374,6 +381,50 @@
|
|
|
374
381
|
<button type="button" class="small quiet" id="pick-folder" aria-label="Change where the project is saved">Change…</button>
|
|
375
382
|
</div>
|
|
376
383
|
</div>
|
|
384
|
+
<fieldset>
|
|
385
|
+
<legend>What is this project? <span class="optional">Pick every one that applies</span></legend>
|
|
386
|
+
<div class="choices">
|
|
387
|
+
<label class="choice">
|
|
388
|
+
<input type="checkbox" name="track" value="product">
|
|
389
|
+
<div class="choice-body">
|
|
390
|
+
<div class="choice-title">Product</div>
|
|
391
|
+
<div class="choice-desc">App screens in a sidebar and top bar, handed to the client's engineers as a spec.</div>
|
|
392
|
+
</div>
|
|
393
|
+
</label>
|
|
394
|
+
<label class="choice">
|
|
395
|
+
<input type="checkbox" name="track" value="website">
|
|
396
|
+
<div class="choice-body">
|
|
397
|
+
<div class="choice-title">Website</div>
|
|
398
|
+
<div class="choice-desc">Pages with a header and footer, built on a CMS.</div>
|
|
399
|
+
</div>
|
|
400
|
+
</label>
|
|
401
|
+
<label class="choice">
|
|
402
|
+
<input type="checkbox" name="track" value="brand">
|
|
403
|
+
<div class="choice-body">
|
|
404
|
+
<div class="choice-title">Brand collateral</div>
|
|
405
|
+
<div class="choice-desc">Social posts, slides and print, from the brand's design system.</div>
|
|
406
|
+
</div>
|
|
407
|
+
</label>
|
|
408
|
+
</div>
|
|
409
|
+
<p class="error-text" data-error="track" role="alert"></p>
|
|
410
|
+
</fieldset>
|
|
411
|
+
<fieldset id="platform-field" hidden>
|
|
412
|
+
<legend>Where is the website built?</legend>
|
|
413
|
+
<div class="inline-choices">
|
|
414
|
+
<label class="choice"><input type="radio" name="platform" value="webflow"><div class="choice-body"><div class="choice-title">Webflow</div></div></label>
|
|
415
|
+
<label class="choice"><input type="radio" name="platform" value="payload"><div class="choice-body"><div class="choice-title">Payload</div></div></label>
|
|
416
|
+
<label class="choice"><input type="radio" name="platform" value="wordpress"><div class="choice-body"><div class="choice-title">WordPress</div></div></label>
|
|
417
|
+
<label class="choice"><input type="radio" name="platform" value="emdash"><div class="choice-body"><div class="choice-title">EmDash</div></div></label>
|
|
418
|
+
</div>
|
|
419
|
+
<p class="hint" id="platform-hint">Not decided yet? Leave it; you can set it later.</p>
|
|
420
|
+
</fieldset>
|
|
421
|
+
<fieldset id="frontend-field" hidden>
|
|
422
|
+
<legend>Which front end?</legend>
|
|
423
|
+
<div class="inline-choices">
|
|
424
|
+
<label class="choice"><input type="radio" name="frontend" value="astro"><div class="choice-body"><div class="choice-title">Astro</div></div></label>
|
|
425
|
+
<label class="choice"><input type="radio" name="frontend" value="next"><div class="choice-body"><div class="choice-title">Next.js</div></div></label>
|
|
426
|
+
</div>
|
|
427
|
+
</fieldset>
|
|
377
428
|
<div class="actions"><button class="primary" type="submit">Continue</button></div>
|
|
378
429
|
</form>
|
|
379
430
|
</section>
|
|
@@ -623,7 +674,7 @@
|
|
|
623
674
|
}),
|
|
624
675
|
card({
|
|
625
676
|
icon: 'folder', title: 'Come back later',
|
|
626
|
-
desc: 'Design Hub.command in the project folder
|
|
677
|
+
desc: 'Design Hub.command in the project folder starts the hub and opens it in your browser.',
|
|
627
678
|
run: async () => {
|
|
628
679
|
const res = await api('/api/reveal', { path: project.path });
|
|
629
680
|
return res.ok ? 'Shown in Finder.' : null;
|
|
@@ -703,8 +754,33 @@
|
|
|
703
754
|
if (res.path) { form.parent = res.path; form.parentDisplay = res.display; renderWhere(); }
|
|
704
755
|
};
|
|
705
756
|
|
|
757
|
+
const checked = (name) => $$(`input[name=${name}]:checked`).map((i) => i.value);
|
|
758
|
+
const PLATFORM_HINT = {
|
|
759
|
+
webflow: 'Webflow renders its own pages.',
|
|
760
|
+
emdash: 'EmDash sites are built with Astro and deployed on Cloudflare.',
|
|
761
|
+
};
|
|
762
|
+
function syncTracks() {
|
|
763
|
+
const website = checked('track').includes('website');
|
|
764
|
+
const [platform] = checked('platform');
|
|
765
|
+
$('#platform-field').hidden = !website;
|
|
766
|
+
$('#frontend-field').hidden = !website || !['payload', 'wordpress'].includes(platform);
|
|
767
|
+
$('#platform-hint').textContent = PLATFORM_HINT[platform] ?? 'Not decided yet? Leave it; you can set it later.';
|
|
768
|
+
$('[data-error=track]').textContent = '';
|
|
769
|
+
}
|
|
770
|
+
for (const i of $$('input[name=track], input[name=platform]')) i.addEventListener('change', syncTracks);
|
|
771
|
+
function tracks() {
|
|
772
|
+
const track = checked('track');
|
|
773
|
+
const [platform = ''] = track.includes('website') ? checked('platform') : [];
|
|
774
|
+
const [frontend = ''] = ['payload', 'wordpress'].includes(platform) ? checked('frontend') : [];
|
|
775
|
+
return { track, platform, frontend };
|
|
776
|
+
}
|
|
777
|
+
|
|
706
778
|
$('#name-form').addEventListener('submit', async (e) => {
|
|
707
779
|
e.preventDefault();
|
|
780
|
+
if (!checked('track').length) {
|
|
781
|
+
$('[data-error=track]').textContent = 'Pick at least one.';
|
|
782
|
+
return $('input[name=track]').focus();
|
|
783
|
+
}
|
|
708
784
|
const name = $('#project-name').value;
|
|
709
785
|
const res = await api('/api/path', { name, parent: form.parent });
|
|
710
786
|
if (!res.ok) {
|
|
@@ -786,6 +862,7 @@
|
|
|
786
862
|
owner: $('#owner').value,
|
|
787
863
|
typesafeKey: $('#typesafe-key').value,
|
|
788
864
|
conductorBranch: $('#conductor-branch').value,
|
|
865
|
+
...tracks(),
|
|
789
866
|
};
|
|
790
867
|
}
|
|
791
868
|
|
|
@@ -815,6 +892,7 @@
|
|
|
815
892
|
const n = $(`[data-error=${field}]`);
|
|
816
893
|
if (n) n.textContent = msg;
|
|
817
894
|
}
|
|
895
|
+
if (event.errors.track) return show('name');
|
|
818
896
|
if (event.errors.name || event.errors.parent) {
|
|
819
897
|
$('#name-error').textContent = event.errors.name ?? event.errors.parent;
|
|
820
898
|
return show('name');
|
package/setup/lib.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// create-design-hub and bootstrap, and the plain-language version of their errors.
|
|
3
3
|
// No I/O here, so every rule is tested without a server or a disk.
|
|
4
4
|
import { isAbsolute, join } from 'node:path';
|
|
5
|
+
import { tracksProblem } from '../lib.mjs';
|
|
5
6
|
import { slugify } from './slug.mjs';
|
|
6
7
|
|
|
7
8
|
/** What to do when nothing more specific is known. */
|
|
@@ -61,9 +62,20 @@ export function validateCreate(body, { home }) {
|
|
|
61
62
|
const target = projectPath(b, home);
|
|
62
63
|
Object.assign(errors, target.errors);
|
|
63
64
|
value.path = target.path;
|
|
65
|
+
Object.assign(value, trackValue(b, errors));
|
|
64
66
|
return Object.keys(errors).length ? { ok: false, errors } : { ok: true, value };
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
/** The tracks and website platform from the page, recording the problem under `track`. */
|
|
70
|
+
function trackValue(b, errors) {
|
|
71
|
+
const track = Array.isArray(b.track) ? b.track.map(String) : [];
|
|
72
|
+
const platform = String(b.platform ?? '').trim() || undefined;
|
|
73
|
+
const frontend = String(b.frontend ?? '').trim() || undefined;
|
|
74
|
+
const problem = track.length ? tracksProblem({ track, platform, frontend }) : 'Pick at least one.';
|
|
75
|
+
if (problem) errors.track = problem;
|
|
76
|
+
return { track, platform, frontend };
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
/** Flags for create-design-hub: the copy only; the install is its own step. `link` is a local design-hub checkout. */
|
|
68
80
|
export function createArgs({ path, visibility, owner, link }) {
|
|
69
81
|
const args = ['--path', path, '--visibility', visibility === 'local' ? 'none' : visibility, '--no-install'];
|
package/setup/lib.test.mjs
CHANGED
|
@@ -33,9 +33,20 @@ test('readPort reads the PORT line', () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
test('validateCreate builds the path and rejects bad fields', () => {
|
|
36
|
-
const ok = validateCreate({ name: 'Acme', visibility: 'local' }, { home: HOME });
|
|
36
|
+
const ok = validateCreate({ name: 'Acme', visibility: 'local', track: ['product'] }, { home: HOME });
|
|
37
37
|
assert.equal(ok.ok, true);
|
|
38
38
|
assert.equal(ok.value.path, '/Users/sam/Design/acme');
|
|
39
|
+
assert.deepEqual(ok.value.track, ['product']);
|
|
40
|
+
const site = validateCreate(
|
|
41
|
+
{ name: 'Acme', track: ['website'], platform: 'payload', frontend: 'next' },
|
|
42
|
+
{ home: HOME },
|
|
43
|
+
);
|
|
44
|
+
assert.deepEqual([site.value.platform, site.value.frontend], ['payload', 'next']);
|
|
45
|
+
assert.match(validateCreate({ name: 'Acme' }, { home: HOME }).errors.track, /at least one/);
|
|
46
|
+
assert.match(
|
|
47
|
+
validateCreate({ name: 'Acme', track: ['website'], platform: 'wordpress' }, { home: HOME }).errors.track,
|
|
48
|
+
/needs --frontend/,
|
|
49
|
+
);
|
|
39
50
|
const bad = validateCreate(
|
|
40
51
|
{
|
|
41
52
|
name: '!!',
|
|
@@ -46,7 +57,14 @@ test('validateCreate builds the path and rejects bad fields', () => {
|
|
|
46
57
|
},
|
|
47
58
|
{ home: HOME },
|
|
48
59
|
);
|
|
49
|
-
assert.deepEqual(Object.keys(bad.errors).sort(), [
|
|
60
|
+
assert.deepEqual(Object.keys(bad.errors).sort(), [
|
|
61
|
+
'name',
|
|
62
|
+
'owner',
|
|
63
|
+
'parent',
|
|
64
|
+
'track',
|
|
65
|
+
'typesafeKey',
|
|
66
|
+
'visibility',
|
|
67
|
+
]);
|
|
50
68
|
});
|
|
51
69
|
|
|
52
70
|
test('createArgs maps local to none, drops the owner there, never installs, and links a local hub', () => {
|
package/setup/server.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { createServer } from 'node:http';
|
|
|
23
23
|
import { homedir, platform } from 'node:os';
|
|
24
24
|
import { basename, delimiter, dirname, join } from 'node:path';
|
|
25
25
|
import { fileURLToPath } from 'node:url';
|
|
26
|
+
import { tracksArgs } from '../lib.mjs';
|
|
26
27
|
import {
|
|
27
28
|
bootstrapArgs,
|
|
28
29
|
createArgs,
|
|
@@ -42,9 +43,12 @@ const HOME = homedir();
|
|
|
42
43
|
const MAC = platform() === 'darwin';
|
|
43
44
|
const TOKEN = randomBytes(16).toString('hex');
|
|
44
45
|
const CREATE = join(HERE, '..', 'index.mjs');
|
|
45
|
-
// Inside the Design Hub repo
|
|
46
|
+
// Inside a developer's checkout of the Design Hub repo, new projects link the
|
|
47
|
+
// local package instead of the published one. A downloaded ZIP of the repo has
|
|
48
|
+
// the same folders but no build, so it must install from npm like anyone else:
|
|
49
|
+
// the link needs the built CLI, not just the package.json.
|
|
46
50
|
const LOCAL_HUB = join(HERE, '..', '..', 'design-hub');
|
|
47
|
-
const LINK = existsSync(join(LOCAL_HUB, '
|
|
51
|
+
const LINK = existsSync(join(LOCAL_HUB, 'dist', 'scripts', 'cli.js')) ? LOCAL_HUB : undefined;
|
|
48
52
|
// The pnpm major projects are installed with.
|
|
49
53
|
const PNPM = 'pnpm@12';
|
|
50
54
|
|
|
@@ -179,8 +183,8 @@ async function prepare(body, send) {
|
|
|
179
183
|
return path && { path, value: checked.value };
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
/** pnpm install, then the miles-* skills from the installed package. */
|
|
183
|
-
function install(path) {
|
|
186
|
+
/** pnpm install, then the miles-* skills from the installed package, then the tracks (which drop the other samples). */
|
|
187
|
+
function install(path, value) {
|
|
184
188
|
return new Promise((resolve) => {
|
|
185
189
|
const child = spawn('pnpm', ['install'], { cwd: path, env: process.env });
|
|
186
190
|
let err = '';
|
|
@@ -188,7 +192,10 @@ function install(path) {
|
|
|
188
192
|
child.on('error', (e) => resolve({ ok: false, error: 'pnpm is not installed.', stderr: e.message }));
|
|
189
193
|
child.on('close', (code) => {
|
|
190
194
|
if (code !== 0) return resolve({ ok: false, error: 'pnpm install failed.', stderr: err.slice(-1200) });
|
|
191
|
-
|
|
195
|
+
const hub = join(path, 'node_modules', '.bin', 'design-hub');
|
|
196
|
+
runJson(hub, ['skills'], path).then((skills) =>
|
|
197
|
+
resolve(skills.ok ? runJson(hub, tracksArgs(value), path) : skills),
|
|
198
|
+
);
|
|
192
199
|
});
|
|
193
200
|
});
|
|
194
201
|
}
|
|
@@ -196,7 +203,7 @@ function install(path) {
|
|
|
196
203
|
async function create(body, send) {
|
|
197
204
|
const ready = await prepare(body, send);
|
|
198
205
|
if (!ready) return;
|
|
199
|
-
const installed = await step(send, 'install', () => install(ready.path));
|
|
206
|
+
const installed = await step(send, 'install', () => install(ready.path, ready.value));
|
|
200
207
|
if (!installed) return;
|
|
201
208
|
const hub = join(ready.path, 'node_modules', '.bin', 'design-hub');
|
|
202
209
|
const ported = await step(send, 'port', () =>
|
package/template/.env.example
CHANGED
|
@@ -23,6 +23,16 @@ TYPESAFE_API_KEY=
|
|
|
23
23
|
KV_REST_API_URL=
|
|
24
24
|
KV_REST_API_TOKEN=
|
|
25
25
|
|
|
26
|
-
# Optional: `pnpm fixtures-pull` reads
|
|
27
|
-
#
|
|
26
|
+
# Optional: `pnpm fixtures-pull` reads real content from the website's CMS.
|
|
27
|
+
# Fill only the platform's lines. Read-only access is enough.
|
|
28
|
+
# Webflow: a site token with the cms:read scope.
|
|
28
29
|
WEBFLOW_TOKEN=
|
|
30
|
+
# Payload: the site's origin and an API key from a user in an auth collection
|
|
31
|
+
# with useAPIKey on (PAYLOAD_AUTH_COLLECTION when that collection is not users).
|
|
32
|
+
PAYLOAD_URL=
|
|
33
|
+
PAYLOAD_API_KEY=
|
|
34
|
+
PAYLOAD_AUTH_COLLECTION=
|
|
35
|
+
# WordPress: the site's origin. Drafts need a user and an application password.
|
|
36
|
+
WORDPRESS_URL=
|
|
37
|
+
WORDPRESS_USER=
|
|
38
|
+
WORDPRESS_APP_PASSWORD=
|
package/template/AGENTS.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
The contract for every coding agent in this project (Claude, Codex, Cursor, others). `CLAUDE.md` points here.
|
|
4
4
|
|
|
5
|
-
This project holds prototypes, the materials they are drawn with, and the documents around them. The hub that lists and serves them, the review panel, the password gate and the `design-hub` command are the `@milesroxas/design-hub` package in `node_modules`: never edit it, never read it to do prototype work. Everything an agent touches is in this folder.
|
|
5
|
+
This project holds prototypes, the materials they are drawn with, and the documents around them. Its tracks, in `.design-hub/project.json`, say what kind of engagement it is: **product** (app screens, handed to the client's engineers as a spec), **website** (pages on a CMS: Webflow, Payload, WordPress or EmDash), **brand** (collateral: social posts, slides, print), or any mix. Read it before starting work; `pnpm tracks` prints it. The hub that lists and serves them, the review panel, the password gate and the `design-hub` command are the `@milesroxas/design-hub` package in `node_modules`: never edit it, never read it to do prototype work. Everything an agent touches is in this folder.
|
|
6
6
|
|
|
7
7
|
## Why it works this way
|
|
8
8
|
|
|
9
9
|
Code here is for sketching, not shipping. Following Karri Saarinen's [Design is more than code](https://linear.app/now/design-is-more-than-code), a prototype answers a question that was written down first, in words. Speed comes from removing production constraints, never from skipping the problem.
|
|
10
10
|
|
|
11
11
|
1. **Problem first.** `README.md` states the problem and the one question before any code exists. Restate it when you present the prototype.
|
|
12
|
-
2. **
|
|
12
|
+
2. **Where it stands.** Pick one per prototype: the shell of its track (`AppShell` for product, `SiteShell` for website), the project's chrome from `kit/shell.ts` and `DESIGN.md`, Shell; or the low-gravity space (`Space`), one thing alone on a quiet canvas with the picker and live dials. Brand collateral always stands on a `Board` of `Artboard`s, each at its real pixel size.
|
|
13
13
|
3. **Low gravity.** A prototype imports only `@kit/*` and its own folder. Never another prototype. No tests, no stories, no abstractions for later. The fidelity ceiling is in the `miles-prototype` skill, and the fidelity guard hook says so when a write goes over it.
|
|
14
14
|
4. **Fork, don't flex.** If a kit piece needs to behave differently, copy it into the prototype folder and change the copy. Never add a prop or a variant to `kit/` for one prototype.
|
|
15
15
|
5. **Promote on second use.** When a second prototype copies the same thing, move it into `kit/` and point both at it.
|
|
@@ -37,19 +37,23 @@ Run from the project root. Every command prints one JSON object; `--help` prints
|
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
39
|
pnpm dev # http://localhost:<PORT>, review panel and all
|
|
40
|
+
pnpm tracks # the project's tracks and website platform
|
|
40
41
|
pnpm new <slug> --feature <feature> # a space prototype with the picker and dials
|
|
41
|
-
pnpm new <slug> --app --sprint --feature <feature> # the feature's one primary prototype, in
|
|
42
|
+
pnpm new <slug> --app --sprint --feature <feature> # the feature's one primary prototype, in its track's shell
|
|
42
43
|
pnpm new <slug> --app --alternate --feature <feature> # another take on the primary
|
|
44
|
+
pnpm new <slug> --app --track website ... # with several tracks, name the one it belongs to
|
|
45
|
+
pnpm new <slug> --track brand --feature <feature> # brand collateral: a Board of artboards
|
|
43
46
|
pnpm guide <feature> # the feature's walkthrough, docs/sprints/<feature>/guide.md
|
|
47
|
+
pnpm export <slug> # brand artboards to exports/<slug>/: PNG for posts, PDF for slides and print (miles-brand)
|
|
44
48
|
pnpm check # TypeScript and Biome; must pass before you report done
|
|
45
49
|
pnpm fix # Biome format and safe fixes
|
|
46
50
|
pnpm preflight # every check a share link needs (miles-deploy)
|
|
47
51
|
pnpm comments pull # review comments into docs/sprints/<feature>/comments.md (miles-review)
|
|
48
|
-
pnpm fixtures-pull <slug> --collection <id> --map key=
|
|
52
|
+
pnpm fixtures-pull <slug> --collection <id> --map key=path # real fixtures from the CMS: Webflow, Payload, WordPress, or --from a JSON file (miles-get-hostile)
|
|
49
53
|
pnpm commands # every command, with its flags, as JSON
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
Each checkout (the main clone, a git worktree, a harness workspace) runs on its own port. A new one needs only `pnpm install && pnpm dev`: the first start claims a free port for the folder and writes it to `.env`. A harness that assigns ports sets `$DESIGN_HUB_PORT` (Conductor's `$CONDUCTOR_PORT` also works), and that wins. A taken port is refused. Never pass another port: a second port silently serves the wrong project.
|
|
53
57
|
|
|
54
58
|
## Layout
|
|
55
59
|
|
|
@@ -57,16 +61,18 @@ The port is Conductor's `$CONDUCTOR_PORT` in a workspace, else the `PORT` in `.e
|
|
|
57
61
|
prototypes/<slug>/ one prototype: README.md, index.tsx, styles.css, fixtures.json
|
|
58
62
|
kit/ the project's materials: tokens.css, shell.ts (brand, nav), icons.ts, AppShell, SiteShell
|
|
59
63
|
docs/sprints/<feature>/ design-doc.md, guide.md, comments.md (generated), port.md, assets/
|
|
60
|
-
DESIGN.md PRODUCT.md the design system's named rules; who the product is for
|
|
64
|
+
DESIGN.md PRODUCT.md the design system's named rules (Brand for collateral); who the product is for
|
|
65
|
+
exports/ exported collateral, gitignored; rebuilt from the prototype any time
|
|
66
|
+
.design-hub/project.json the tracks and website platform (pnpm tracks set rewrites it)
|
|
61
67
|
.design-hub/checks.json the Jev thresholds (design-hub calibrate --write rewrites it)
|
|
62
68
|
api/review.ts proxy.ts vercel.json the deploy entries; one line each, never edited
|
|
63
69
|
```
|
|
64
70
|
|
|
65
|
-
`prototypes/sample-list/`
|
|
71
|
+
Each track's sample is the reference for its conventions: `prototypes/sample-list/` for product, `prototypes/sample-page/` for website, `prototypes/sample-social/` for brand. Setup keeps only the samples of the project's tracks; delete one, with its `docs/sprints/` folder, once its track has a feature of its own.
|
|
66
72
|
|
|
67
73
|
## A prototype
|
|
68
74
|
|
|
69
|
-
README frontmatter, all fields required (`feature` may be empty for a one-off): `title`, `summary`, `context` (space | app), `status` (exploring | decided | archived), `kind` (sprint | alternate | exploration), `feature`, `created`. `pnpm new` writes it.
|
|
75
|
+
README frontmatter, all fields required (`feature` may be empty for a one-off): `title`, `summary`, `context` (space | app | board), `track` (product | website | brand), `status` (exploring | decided | archived), `kind` (sprint | alternate | exploration), `feature`, `created`. `pnpm new` writes it.
|
|
70
76
|
|
|
71
77
|
The README's `## States` table lists every state the prototype holds and how to reach it. The fidelity guard asks whether a write adds a state that is not there, and `miles-port` refuses a folder without the table.
|
|
72
78
|
|
|
@@ -87,6 +93,7 @@ One slug in two places: `docs/sprints/<feature>/` and the `feature:` line of eve
|
|
|
87
93
|
| `@kit/shell` | `BRAND`, `PRODUCT` (nav, workspace, user), `SITE` (nav, footer): the one place the chrome is written. |
|
|
88
94
|
| `@kit/AppShell`, `@kit/SiteShell` | The disposable shells. Mount the dialog, sheet and toast hosts and the View dials. `PageHead({ title, desc, back, actions })`. |
|
|
89
95
|
| `@kit/Space` | `<Space title lede width>`: the low-gravity canvas. |
|
|
96
|
+
| `@kit/Artboard` | `<Board title lede>` holding `<Artboard format name>`s: collateral at real pixel size, scaled to fit on screen, written to files by `pnpm export`. `FORMATS` lists the sizes. |
|
|
90
97
|
| `@kit/ui` | `Button`, `Chevron`, `Segmented`, `Badge`, `Checkbox`, `useMenu`, `Select`, `openDialog`, `confirmDialog`, `openSheet`, `toast()`, `notInPrototype(what)`. Card, table and empty-state classes in `ui.css`. |
|
|
91
98
|
| `@kit/fixtures` | `fixtureSets({ real, missing }, { max, text })` returns `{ real, longest, empty, max, missing }`; `SET_NAMES` for the dial. |
|
|
92
99
|
| `@kit/Variants` | `<Variants options={{ Quiet, Editorial }}>`: the picker. Keys 1-N, arrows, R; `?v=N`. |
|
|
@@ -128,6 +135,7 @@ The `miles-*` skills in `.claude/skills/` come from the `@milesroxas/design-hub`
|
|
|
128
135
|
| `miles-deploy` | Deploying, sharing a link, the password, checking the work before either. |
|
|
129
136
|
| `miles-review` | Comments from the deployed prototypes, and who may comment. |
|
|
130
137
|
| `miles-port` | Turning an approved prototype into production. |
|
|
131
|
-
| `miles-
|
|
138
|
+
| `miles-brand` | Brand collateral: social posts, slides, print; artboards, formats and export. |
|
|
139
|
+
| `miles-worktrees` | Worktrees, parallel agents, Conductor or any harness, and port collisions. |
|
|
132
140
|
|
|
133
141
|
Existing skills these lean on: `emil-prototype`, `emil-animations`, `emil-touch-and-accessibility`, `emil-performance`, `emil-writing-skills` for every Markdown file, `impeccable` for a design pass. If a skill disagrees with this file, this file wins.
|
package/template/DESIGN.md
CHANGED
|
@@ -69,12 +69,22 @@ One paragraph on what the product is for and how the interface serves that. Name
|
|
|
69
69
|
|
|
70
70
|
## Shell
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
The shell follows the tracks in `.design-hub/project.json`: a product draws `AppShell` (sidebar, top bar, content), a website draws `SiteShell` (header and footer, with a pre-footer when the design treats one as a global), and brand collateral has no shell. Record, per track the project has, what `miles-design-hub` collected so it is built once and never asked again:
|
|
73
73
|
|
|
74
|
-
- **
|
|
75
|
-
- **
|
|
74
|
+
- **Product:** the link to each Paper frame that holds the sidebar and top bar, or "from the sample".
|
|
75
|
+
- **Website:** the link to each Paper frame that holds the header, footer and pre-footer, or "from the sample".
|
|
76
76
|
- **Where it is built:** `kit/shell.ts` (brand, navigation, people) and `AppShell.tsx` or `SiteShell.tsx`. A prototype never rebuilds the shell inside its own folder.
|
|
77
77
|
|
|
78
|
+
## Brand
|
|
79
|
+
|
|
80
|
+
For a project with the brand track. Collateral is drawn from the same tokens as everything else; this section holds what tokens cannot say. `miles-brand` reads it before any artboard. Leave it out when the project has no brand track.
|
|
81
|
+
|
|
82
|
+
- **Logo:** each lockup, its file in `kit/icons.ts` or `public/`, its clear space (in units of the mark's height) and its minimum size in pixels. When it goes on the brand colour and when on the page colour.
|
|
83
|
+
- **Imagery:** the photo or illustration style in two sentences, the crops each format uses, and what never appears.
|
|
84
|
+
- **Collateral type:** the headline, subhead and body sizes at 1080 wide, and the shortest headline that still reads at feed size.
|
|
85
|
+
- **Formats:** the formats the brand runs (`post-square`, `post-portrait`, `story`, `link-preview`, `banner`, `slide`, `a4`, `letter`) and where each goes. A story keeps type and the logo out of its top and bottom 250px.
|
|
86
|
+
- **Voice:** the rule for headlines and calls to action, with one right and one wrong example.
|
|
87
|
+
|
|
78
88
|
## Colors
|
|
79
89
|
|
|
80
90
|
Group by role: primary, neutral, status, any utility family. For each colour, its name, hex, token, what it is for and its dark value. Then the named rules, each a bold name and a paragraph that says the rule and why it holds.
|
package/template/README.md
CHANGED
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
Prototypes for one product or website, built on [Design Hub](https://github.com/milesroxas/design-hub). One repo holds the prototypes, the design rules, the walkthroughs reviewers read, and their comments.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
pnpm
|
|
7
|
-
pnpm dev # http://localhost:<PORT
|
|
6
|
+
pnpm install
|
|
7
|
+
pnpm dev # http://localhost:<PORT>; the first start claims a free port for this folder
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
Or double-click `Design Hub.command`.
|
|
11
11
|
|
|
12
|
+
Not a developer? The [guide](https://github.com/milesroxas/design-hub/tree/main/docs/guide) covers setup, working with Claude, sharing a link and comments.
|
|
13
|
+
|
|
12
14
|
| Path | What goes there |
|
|
13
15
|
| --- | --- |
|
|
14
|
-
| `prototypes/<slug>/` | One prototype: its README, code, styles and fixtures. `sample-list/`
|
|
16
|
+
| `prototypes/<slug>/` | One prototype: its README, code, styles and fixtures. Each track keeps its sample as the reference (`sample-list/` for product, `sample-page/` for website); delete one once its track has a feature. |
|
|
15
17
|
| `kit/` | The project's materials: `tokens.css`, `shell.ts` (brand and navigation), `icons.ts`, the disposable `AppShell` and `SiteShell`. |
|
|
16
18
|
| `docs/sprints/<feature>/` | A feature's design doc, walkthrough, pulled comments and port report. |
|
|
17
19
|
| `DESIGN.md`, `PRODUCT.md` | The recorded design system and who the product is for. |
|
package/template/_gitignore
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
# Dependencies and builds
|
|
10
10
|
node_modules/
|
|
11
11
|
dist/
|
|
12
|
+
|
|
13
|
+
# Exported collateral: files to hand over, rebuilt from the prototype any time
|
|
14
|
+
exports/
|
|
12
15
|
.vercel/
|
|
13
16
|
|
|
14
17
|
# Environment and secrets
|
|
@@ -19,9 +22,10 @@ dist/
|
|
|
19
22
|
# Logs
|
|
20
23
|
*.log
|
|
21
24
|
|
|
22
|
-
# Local state: the Jev log and its labels, the dev review store. checks.json
|
|
25
|
+
# Local state: the Jev log and its labels, the dev review store. checks.json (the thresholds) and project.json (the tracks) stay.
|
|
23
26
|
.design-hub/*
|
|
24
27
|
!.design-hub/checks.json
|
|
28
|
+
!.design-hub/project.json
|
|
25
29
|
|
|
26
30
|
# Obsidian per-machine state (docs/ is an Obsidian vault)
|
|
27
31
|
docs/.obsidian/workspace*.json
|
|
@@ -31,8 +35,9 @@ docs/.obsidian/workspace*.json
|
|
|
31
35
|
.impeccable/live/
|
|
32
36
|
.impeccable/hook.cache.json
|
|
33
37
|
|
|
34
|
-
# Claude Code worktrees
|
|
38
|
+
# Claude Code worktrees, and the preview config: it holds this folder's port, like .env
|
|
35
39
|
.claude/worktrees/
|
|
40
|
+
.claude/launch.json
|
|
36
41
|
|
|
37
42
|
# Conductor per-developer settings
|
|
38
43
|
.conductor/settings.local.toml
|