@milesroxas/design-hub 0.4.0 → 0.4.1

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.
@@ -2,12 +2,19 @@
2
2
  import type { Args } from './lib/cli.ts';
3
3
  export declare const spec: {
4
4
  readonly name: 'skills';
5
- readonly summary: "Install or update the project's miles-* skills from this package into .claude/skills/.";
5
+ readonly summary: "Install or update the project's miles-* skills from this package into .claude/skills/, and add any package.json script they call that the project lacks.";
6
6
  readonly flags: {};
7
- readonly output: '{ ok, installed: [name], into }';
7
+ readonly output: '{ ok, installed: [name], into, scripts: { added: [name] } }';
8
8
  };
9
9
  export declare function installSkills(from?: string, into?: string): string[];
10
+ /** The scripts a project's package.json carries, as the template writes them. The skills call them by these names. */
11
+ export declare const SCRIPTS: Record<string, string>;
12
+ /** Adds each missing script to the project's package.json; a script the project already has is never changed. */
13
+ export declare function addScripts(file?: string): string[];
10
14
  export declare function main(_args: Args<typeof spec>): {
11
15
  installed: string[];
12
16
  into: string;
17
+ scripts: {
18
+ added: string[];
19
+ };
13
20
  };
@@ -4,15 +4,17 @@
4
4
  // into the project's .claude/skills/, replacing what is there. The skills
5
5
  // ship with the package so a version bump updates them; a project never
6
6
  // edits its copies. `miles-design-hub` stays out: it starts a project from
7
- // outside one and is installed globally.
8
- import { cpSync, existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
7
+ // outside one and is installed globally. It also adds the package.json
8
+ // scripts a newer version's skills call, since an upgrade never touches the
9
+ // project's own files and a skill that runs `pnpm share` needs the script.
10
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
9
11
  import { join } from 'node:path';
10
- import { PACKAGE_SKILLS, SKILLS } from '../server/paths.js';
12
+ import { PACKAGE_SKILLS, ROOT, SKILLS } from '../server/paths.js';
11
13
  export const spec = {
12
14
  name: 'skills',
13
- summary: "Install or update the project's miles-* skills from this package into .claude/skills/.",
15
+ summary: "Install or update the project's miles-* skills from this package into .claude/skills/, and add any package.json script they call that the project lacks.",
14
16
  flags: {},
15
- output: '{ ok, installed: [name], into }',
17
+ output: '{ ok, installed: [name], into, scripts: { added: [name] } }',
16
18
  };
17
19
  const GLOBAL_ONLY = new Set(['miles-design-hub']);
18
20
  /** Skills the package no longer ships, removed from a project on update. miles-conductor became miles-worktrees in 0.2.0. */
@@ -33,6 +35,46 @@ export function installSkills(from = PACKAGE_SKILLS, into = SKILLS) {
33
35
  }
34
36
  return names;
35
37
  }
38
+ /** The scripts a project's package.json carries, as the template writes them. The skills call them by these names. */
39
+ export const SCRIPTS = {
40
+ dev: 'design-hub dev',
41
+ build: 'design-hub build',
42
+ preview: 'design-hub preview',
43
+ export: 'design-hub export',
44
+ bootstrap: 'design-hub bootstrap',
45
+ new: 'design-hub new',
46
+ tracks: 'design-hub tracks',
47
+ guide: 'design-hub guide',
48
+ check: 'design-hub check',
49
+ fix: 'design-hub check --fix',
50
+ guard: 'design-hub guard',
51
+ preflight: 'design-hub preflight',
52
+ signin: 'design-hub signin',
53
+ share: 'design-hub share',
54
+ comments: 'design-hub comments',
55
+ people: 'design-hub people',
56
+ calibrate: 'design-hub calibrate',
57
+ 'fixtures-pull': 'design-hub fixtures-pull',
58
+ 'visual-match': 'design-hub visual-match',
59
+ elyx: 'design-hub elyx',
60
+ skills: 'design-hub skills',
61
+ commands: 'design-hub commands',
62
+ };
63
+ /** Adds each missing script to the project's package.json; a script the project already has is never changed. */
64
+ export function addScripts(file = join(ROOT, 'package.json')) {
65
+ if (!existsSync(file))
66
+ return [];
67
+ const pkg = JSON.parse(readFileSync(file, 'utf8'));
68
+ const scripts = pkg.scripts ?? {};
69
+ const added = Object.keys(SCRIPTS).filter((name) => !(name in scripts));
70
+ if (!added.length)
71
+ return [];
72
+ for (const name of added)
73
+ scripts[name] = SCRIPTS[name];
74
+ pkg.scripts = scripts;
75
+ writeFileSync(file, `${JSON.stringify(pkg, null, 2)}\n`);
76
+ return added;
77
+ }
36
78
  export function main(_args) {
37
- return { installed: installSkills(), into: SKILLS };
79
+ return { installed: installSkills(), into: SKILLS, scripts: { added: addScripts() } };
38
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@milesroxas/design-hub",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "The Design Hub product: the hub that lists and serves prototypes, the review panel and its API, the password gate, the kit, and the design-hub CLI. A project installs it and keeps only its prototypes, kit materials and docs.",
5
5
  "license": "MIT",
6
6
  "repository": {