@milesroxas/design-hub 0.9.0 → 0.11.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/README.md +13 -11
- package/core/controls.test.ts +176 -0
- package/core/controls.ts +195 -0
- package/core/files.test.ts +76 -0
- package/core/files.ts +131 -0
- package/core/prototype.test.ts +124 -7
- package/core/prototype.ts +133 -24
- package/core/review/model.ts +144 -2
- package/core/review/policy.test.ts +79 -22
- package/core/review/policy.ts +36 -8
- package/core/review/service.test.ts +1525 -322
- package/core/review/service.ts +810 -183
- package/core/review/store.test.ts +91 -0
- package/core/review/store.ts +143 -26
- package/dist/core/controls.d.ts +55 -0
- package/dist/core/controls.js +174 -0
- package/dist/core/files.d.ts +39 -0
- package/dist/core/files.js +107 -0
- package/dist/core/prototype.d.ts +61 -12
- package/dist/core/prototype.js +105 -26
- package/dist/core/review/model.d.ts +87 -2
- package/dist/core/review/model.js +97 -1
- package/dist/core/review/policy.d.ts +11 -4
- package/dist/core/review/policy.js +14 -2
- package/dist/core/review/service.d.ts +222 -43
- package/dist/core/review/service.js +727 -182
- package/dist/core/review/store.d.ts +84 -24
- package/dist/core/review/store.js +66 -26
- package/dist/scripts/bootstrap.d.ts +4 -34
- package/dist/scripts/bootstrap.js +9 -244
- package/dist/scripts/cli.js +6 -0
- package/dist/scripts/client.d.ts +45 -0
- package/dist/scripts/client.js +320 -0
- package/dist/scripts/commands.js +6 -0
- package/dist/scripts/comments.d.ts +8 -26
- package/dist/scripts/comments.js +27 -14
- package/dist/scripts/guard.d.ts +11 -0
- package/dist/scripts/guard.js +44 -0
- package/dist/scripts/lib/builds.d.ts +40 -0
- package/dist/scripts/lib/builds.js +198 -0
- package/dist/scripts/lib/cli.js +3 -1
- package/dist/scripts/lib/deploy.d.ts +6 -90
- package/dist/scripts/lib/deploy.js +24 -137
- package/dist/scripts/lib/dns.d.ts +49 -0
- package/dist/scripts/lib/dns.js +141 -0
- package/dist/scripts/lib/fake-host.d.ts +168 -0
- package/dist/scripts/lib/fake-host.js +244 -0
- package/dist/scripts/lib/host.d.ts +87 -0
- package/dist/scripts/lib/host.js +362 -0
- package/dist/scripts/lib/linked.d.ts +51 -0
- package/dist/scripts/lib/linked.js +124 -0
- package/dist/scripts/lib/names.d.ts +35 -0
- package/dist/scripts/lib/names.js +77 -0
- package/dist/scripts/lib/review.d.ts +23 -2
- package/dist/scripts/lib/review.js +32 -15
- package/dist/scripts/lib/rules.d.ts +1 -0
- package/dist/scripts/lib/rules.js +1 -0
- package/dist/scripts/lib/studio-deps.d.ts +35 -0
- package/dist/scripts/lib/studio-deps.js +79 -0
- package/dist/scripts/lib/studios.d.ts +70 -0
- package/dist/scripts/lib/studios.js +187 -0
- package/dist/scripts/lib/update.d.ts +33 -0
- package/dist/scripts/lib/update.js +40 -0
- package/dist/scripts/lib/vercel.d.ts +1 -23
- package/dist/scripts/lib/vercel.js +6 -81
- package/dist/scripts/people.d.ts +7 -11
- package/dist/scripts/people.js +51 -46
- package/dist/scripts/preflight.d.ts +8 -1
- package/dist/scripts/preflight.js +36 -19
- package/dist/scripts/project.d.ts +86 -0
- package/dist/scripts/project.js +141 -0
- package/dist/scripts/share.d.ts +105 -30
- package/dist/scripts/share.js +82 -154
- package/dist/scripts/skills.d.ts +18 -2
- package/dist/scripts/skills.js +22 -3
- package/dist/scripts/studio.d.ts +75 -0
- package/dist/scripts/studio.js +401 -0
- package/dist/scripts/upgrade.d.ts +10 -2
- package/dist/scripts/upgrade.js +44 -14
- package/dist/server/api.d.ts +22 -11
- package/dist/server/api.js +125 -44
- package/dist/server/blob.d.ts +10 -0
- package/dist/server/blob.js +53 -0
- package/dist/server/checks.js +2 -2
- package/dist/server/dev.js +4 -4
- package/dist/server/env.d.ts +2 -0
- package/dist/server/env.js +9 -0
- package/dist/server/fake-upstash.js +52 -3
- package/dist/server/hosts.d.ts +11 -0
- package/dist/server/hosts.js +31 -0
- package/dist/server/local.d.ts +7 -1
- package/dist/server/local.js +10 -1
- package/dist/server/mark.d.ts +41 -0
- package/dist/server/mark.js +111 -0
- package/dist/server/session.d.ts +17 -9
- package/dist/server/session.js +22 -45
- package/dist/server/upstash.js +20 -0
- package/dist/vercel/files.d.ts +11 -0
- package/dist/vercel/files.js +68 -0
- package/dist/vercel/index.d.ts +4 -3
- package/dist/vercel/index.js +12 -8
- package/dist/vercel/proxy.d.ts +69 -4
- package/dist/vercel/proxy.js +171 -107
- package/dist/vite/plugin.d.ts +24 -1
- package/dist/vite/plugin.js +46 -2
- package/kit/Artboard.tsx +21 -8
- package/kit/Space.tsx +4 -3
- package/kit/Variants.tsx +193 -65
- package/kit/ViewTools.tsx +77 -11
- package/kit/audience.ts +85 -0
- package/kit/dials.css +59 -0
- package/kit/dials.tsx +272 -35
- package/kit/harness.css +34 -0
- package/kit/prefs.ts +23 -1
- package/package.json +3 -2
- package/shell/ClientViewNote.tsx +31 -3
- package/shell/Guide.tsx +11 -5
- package/shell/Index.tsx +32 -10
- package/shell/Notice.tsx +1 -1
- package/shell/controls.ts +26 -0
- package/shell/hub.ts +5 -1
- package/shell/main.tsx +33 -6
- package/shell/review/Review.tsx +2 -2
- package/shell/review/ThreadCard.tsx +5 -5
- package/shell/review/client.ts +28 -11
- package/shell/review/view.test.ts +19 -0
- package/shell/review/view.ts +25 -0
- package/shell/shell.css +8 -0
- package/shell/studio/ClientHub.tsx +98 -0
- package/shell/studio/hub.css +48 -0
- package/shell/studio/index.html +14 -0
- package/shell/studio/main.tsx +17 -0
- package/skills/miles-brand/SKILL.md +11 -1
- package/skills/miles-deploy/SKILL.md +121 -64
- package/skills/miles-design-hub/SKILL.md +11 -9
- package/skills/miles-prototype/SKILL.md +34 -1
- package/skills/miles-review/SKILL.md +5 -7
- package/skills/miles-worktrees/SKILL.md +3 -3
- package/templates/conductor/settings.toml +1 -1
- package/templates/studio/.env.example +9 -0
- package/templates/studio/.vercelignore +5 -0
- package/templates/studio/README.md +84 -0
- package/templates/studio/_gitignore +7 -0
- package/templates/studio/api/files.ts +4 -0
- package/templates/studio/api/review.ts +4 -0
- package/templates/studio/build.mjs +4 -0
- package/templates/studio/package.json +16 -0
- package/templates/studio/proxy.ts +4 -0
- package/templates/studio/studio.json +9 -0
- package/templates/studio/vercel.json +27 -0
package/dist/scripts/share.d.ts
CHANGED
|
@@ -1,62 +1,137 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type Args } from './lib/cli.ts';
|
|
3
|
+
import { type ProjectDeps } from './lib/linked.ts';
|
|
3
4
|
export declare const spec: {
|
|
4
5
|
readonly name: 'share';
|
|
5
|
-
readonly summary:
|
|
6
|
+
readonly summary: "Pre-flight, build the project for its studio, upload the build to the studio and point the project at it, keeping the last 3 builds. Returns the address to send. Needs .design-hub/studio.json (design-hub project link).";
|
|
6
7
|
readonly flags: {
|
|
7
8
|
readonly skip: {
|
|
8
9
|
readonly type: 'list';
|
|
9
10
|
readonly description: 'A pre-flight step to skip, only with the user’s word (design-hub preflight --help lists them).';
|
|
10
11
|
};
|
|
11
|
-
readonly cli: {
|
|
12
|
-
readonly type: 'boolean';
|
|
13
|
-
readonly description: 'Upload this folder with the Vercel CLI even when the project deploys on push.';
|
|
14
|
-
};
|
|
15
12
|
};
|
|
16
|
-
readonly output: '{ ok,
|
|
13
|
+
readonly output: '{ ok, studio, client, project, build, files, address, open: [{ title, url, guide? }], removed, next } or { ok: false, stage, ... }';
|
|
14
|
+
};
|
|
15
|
+
/** A prototype a reviewer is sent to open, by its path below the project. */
|
|
16
|
+
type Open = {
|
|
17
|
+
title: string;
|
|
18
|
+
path: string;
|
|
19
|
+
guide?: string;
|
|
20
|
+
};
|
|
21
|
+
export type ShareDeps = ProjectDeps & {
|
|
22
|
+
/** Builds the project with this base into `outDir`. */
|
|
23
|
+
build(base: string, outDir: string): Promise<void>;
|
|
24
|
+
preflight(skip: string[]): Promise<{
|
|
25
|
+
ok: boolean;
|
|
26
|
+
steps: {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
/** What a reviewer is sent to open. */
|
|
31
|
+
opens(): Open[];
|
|
17
32
|
};
|
|
18
|
-
export declare function
|
|
33
|
+
export declare function run({ flags }: Args<typeof spec>, deps: ShareDeps): Promise<{
|
|
19
34
|
ok: boolean;
|
|
20
35
|
stage: string;
|
|
21
36
|
error: string;
|
|
22
37
|
steps: {
|
|
23
|
-
step: "build" | "checks" | "contacts" | "elyx" | "gate" | "guides" | "lint" | "secrets" | "states" | "types";
|
|
24
38
|
ok: boolean;
|
|
25
|
-
skipped?: string;
|
|
26
|
-
detail?: unknown;
|
|
27
|
-
fix?: string;
|
|
28
39
|
}[];
|
|
29
40
|
fix: string;
|
|
30
|
-
via?: undefined;
|
|
31
|
-
deployment?: undefined;
|
|
32
|
-
url?: undefined;
|
|
33
41
|
} | {
|
|
42
|
+
build: string;
|
|
43
|
+
files: number;
|
|
44
|
+
removed: string[];
|
|
45
|
+
old?: undefined;
|
|
46
|
+
ok?: undefined;
|
|
47
|
+
stage?: undefined;
|
|
48
|
+
error?: undefined;
|
|
34
49
|
steps?: undefined;
|
|
50
|
+
fix?: undefined;
|
|
51
|
+
studio: string;
|
|
52
|
+
client: string;
|
|
53
|
+
project: string;
|
|
54
|
+
address: string;
|
|
55
|
+
open: {
|
|
56
|
+
title: string;
|
|
57
|
+
url: string;
|
|
58
|
+
guide?: string | undefined;
|
|
59
|
+
}[];
|
|
60
|
+
next: string;
|
|
61
|
+
} | {
|
|
62
|
+
build: string;
|
|
63
|
+
files: number;
|
|
64
|
+
removed: never[];
|
|
65
|
+
old: {
|
|
66
|
+
error: string;
|
|
67
|
+
fix: string;
|
|
68
|
+
};
|
|
69
|
+
ok?: undefined;
|
|
70
|
+
stage?: undefined;
|
|
71
|
+
error?: undefined;
|
|
72
|
+
steps?: undefined;
|
|
73
|
+
fix?: undefined;
|
|
74
|
+
studio: string;
|
|
75
|
+
client: string;
|
|
76
|
+
project: string;
|
|
77
|
+
address: string;
|
|
78
|
+
open: {
|
|
79
|
+
title: string;
|
|
80
|
+
url: string;
|
|
81
|
+
guide?: string | undefined;
|
|
82
|
+
}[];
|
|
83
|
+
next: string;
|
|
84
|
+
}>;
|
|
85
|
+
export declare const main: (args: Args<typeof spec>) => Promise<{
|
|
35
86
|
ok: boolean;
|
|
36
87
|
stage: string;
|
|
37
|
-
via: "cli" | "git";
|
|
38
|
-
deployment: string;
|
|
39
|
-
url: string;
|
|
40
88
|
error: string;
|
|
89
|
+
steps: {
|
|
90
|
+
ok: boolean;
|
|
91
|
+
}[];
|
|
41
92
|
fix: string;
|
|
42
93
|
} | {
|
|
94
|
+
build: string;
|
|
95
|
+
files: number;
|
|
96
|
+
removed: string[];
|
|
97
|
+
old?: undefined;
|
|
43
98
|
ok?: undefined;
|
|
99
|
+
stage?: undefined;
|
|
44
100
|
error?: undefined;
|
|
45
|
-
|
|
101
|
+
steps?: undefined;
|
|
102
|
+
fix?: undefined;
|
|
103
|
+
studio: string;
|
|
104
|
+
client: string;
|
|
105
|
+
project: string;
|
|
106
|
+
address: string;
|
|
107
|
+
open: {
|
|
108
|
+
title: string;
|
|
46
109
|
url: string;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
path: string;
|
|
50
|
-
guide?: string | undefined;
|
|
51
|
-
}[];
|
|
52
|
-
};
|
|
53
|
-
review: string;
|
|
110
|
+
guide?: string | undefined;
|
|
111
|
+
}[];
|
|
54
112
|
next: string;
|
|
55
|
-
|
|
113
|
+
} | {
|
|
114
|
+
build: string;
|
|
115
|
+
files: number;
|
|
116
|
+
removed: never[];
|
|
117
|
+
old: {
|
|
118
|
+
error: string;
|
|
119
|
+
fix: string;
|
|
120
|
+
};
|
|
121
|
+
ok?: undefined;
|
|
56
122
|
stage?: undefined;
|
|
123
|
+
error?: undefined;
|
|
124
|
+
steps?: undefined;
|
|
57
125
|
fix?: undefined;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
126
|
+
studio: string;
|
|
127
|
+
client: string;
|
|
128
|
+
project: string;
|
|
129
|
+
address: string;
|
|
130
|
+
open: {
|
|
131
|
+
title: string;
|
|
132
|
+
url: string;
|
|
133
|
+
guide?: string | undefined;
|
|
134
|
+
}[];
|
|
135
|
+
next: string;
|
|
62
136
|
}>;
|
|
137
|
+
export {};
|
package/dist/scripts/share.js
CHANGED
|
@@ -1,189 +1,117 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
// One command from a passing project to
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
// One command from a passing project to the address to send: the studio
|
|
4
|
+
// checked against the project's link, the pre-flight, a build at the
|
|
5
|
+
// project's base (`/<project>/`), and the upload into the studio's file store
|
|
6
|
+
// (scripts/lib/builds.ts), which points the project at the new build only
|
|
7
|
+
// once every file is up. The address is the client's own host and the
|
|
8
|
+
// project's path: a project has no deployment of its own.
|
|
9
|
+
import { existsSync, mkdtempSync, rmSync } from 'node:fs';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
9
11
|
import { join } from 'node:path';
|
|
10
12
|
import { isLive } from '../core/catalog.js';
|
|
11
|
-
import { readEnv } from '../server/env.js';
|
|
12
13
|
import { DOCS, ROOT } from '../server/paths.js';
|
|
14
|
+
import { buildHub } from '../vite/plugin.js';
|
|
15
|
+
import { KEEP_BUILDS, pruneBuilds, publishBuild } from './lib/builds.js';
|
|
13
16
|
import { prototypes } from './lib/catalog.js';
|
|
14
17
|
import { CliError } from './lib/cli.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
18
|
+
import { addressOf, LINK_FILE, openLinked, readLink, realProjectDeps, } from './lib/linked.js';
|
|
19
|
+
import { cliActor } from './lib/review.js';
|
|
17
20
|
import * as preflight from './preflight.js';
|
|
18
21
|
export const spec = {
|
|
19
22
|
name: 'share',
|
|
20
|
-
summary:
|
|
23
|
+
summary: `Pre-flight, build the project for its studio, upload the build to the studio and point the project at it, keeping the last ${KEEP_BUILDS} builds. Returns the address to send. Needs ${LINK_FILE} (design-hub project link).`,
|
|
21
24
|
flags: {
|
|
22
25
|
skip: {
|
|
23
26
|
type: 'list',
|
|
24
27
|
description: 'A pre-flight step to skip, only with the user’s word (design-hub preflight --help lists them).',
|
|
25
28
|
},
|
|
26
|
-
cli: {
|
|
27
|
-
type: 'boolean',
|
|
28
|
-
description: 'Upload this folder with the Vercel CLI even when the project deploys on push.',
|
|
29
|
-
},
|
|
30
29
|
},
|
|
31
|
-
output: '{ ok,
|
|
30
|
+
output: '{ ok, studio, client, project, build, files, address, open: [{ title, url, guide? }], removed, next } or { ok: false, stage, ... }',
|
|
32
31
|
};
|
|
33
|
-
|
|
34
|
-
function git(args) {
|
|
35
|
-
const r = spawnSync('git', ['-C', ROOT, ...args], { encoding: 'utf8' });
|
|
36
|
-
return { ok: r.status === 0, out: (r.stdout ?? '').trim(), err: (r.stderr ?? '').trim() };
|
|
37
|
-
}
|
|
38
|
-
function deploymentFor(project, scope, sha) {
|
|
39
|
-
const out = vercel(ROOT, [
|
|
40
|
-
'list',
|
|
41
|
-
project,
|
|
42
|
-
'--json',
|
|
43
|
-
'--limit',
|
|
44
|
-
'1',
|
|
45
|
-
'--environment',
|
|
46
|
-
'production',
|
|
47
|
-
'-m',
|
|
48
|
-
`githubCommitSha=${sha}`,
|
|
49
|
-
...(scope ? ['--scope', scope] : []),
|
|
50
|
-
]);
|
|
51
|
-
if (out?.status !== 0)
|
|
52
|
-
return null;
|
|
53
|
-
try {
|
|
54
|
-
return JSON.parse(out.stdout).deployments[0] ?? null;
|
|
55
|
-
}
|
|
56
|
-
catch {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/** Pushes the branch and follows the deployment Vercel starts for that commit. */
|
|
61
|
-
async function viaGit(project, scope, branch) {
|
|
62
|
-
const sha = git(['rev-parse', 'HEAD']).out;
|
|
63
|
-
const push = git(['push', 'origin', branch]);
|
|
64
|
-
if (!push.ok)
|
|
65
|
-
throw new CliError(`git push origin ${branch} failed.`, { stderr: push.err.slice(-600) });
|
|
66
|
-
const start = Date.now();
|
|
67
|
-
for (;;) {
|
|
68
|
-
const step = nextStep(deploymentFor(project, scope, sha), sha, Date.now() - start);
|
|
69
|
-
if ('done' in step)
|
|
70
|
-
return step.done;
|
|
71
|
-
if ('error' in step)
|
|
72
|
-
throw new CliError(step.error, { fix: step.fix, deployment: step.deployment });
|
|
73
|
-
await sleep(5000);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function viaCli() {
|
|
77
|
-
const out = vercel(ROOT, ['deploy', '--prod', '--yes']);
|
|
78
|
-
if (!out)
|
|
79
|
-
throw new CliError('The Vercel CLI is not installed.', { fix: 'npm i -g vercel' });
|
|
80
|
-
const url = `${out.stdout}\n${out.stderr}`.match(/https:\/\/[\w.-]+\.vercel\.app/)?.[0];
|
|
81
|
-
if (out.status !== 0 || !url)
|
|
82
|
-
throw new CliError('vercel deploy --prod failed.', { stderr: out.stderr.trim().slice(-600) });
|
|
83
|
-
return url;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Signed-out requests as a browser makes them: the home page must answer with
|
|
87
|
-
* the sign-in page, and a link no store holds with 404, which proves the store
|
|
88
|
-
* that keeps people's links is wired.
|
|
89
|
-
*/
|
|
90
|
-
async function smoke(url) {
|
|
91
|
-
try {
|
|
92
|
-
const res = await fetch(`${url}/`, GATE_REQUEST);
|
|
93
|
-
const gate = gateVerdict({
|
|
94
|
-
status: res.status,
|
|
95
|
-
location: res.headers.get('location'),
|
|
96
|
-
robots: res.headers.get('x-robots-tag'),
|
|
97
|
-
body: await res.text(),
|
|
98
|
-
});
|
|
99
|
-
if (!gate.ok)
|
|
100
|
-
return gate;
|
|
101
|
-
return storeVerdict((await fetch(`${url}${PROBE_LINK}`, GATE_REQUEST)).status);
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
return {
|
|
105
|
-
ok: false,
|
|
106
|
-
problem: `Could not reach ${url}: ${error instanceof Error ? error.message : error}`,
|
|
107
|
-
fix: 'Open the URL in a private window; a new domain can take a minute to resolve.',
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/** What a reviewer is sent to open: each live sprint and its walkthrough. */
|
|
32
|
+
/** Each live sprint and its walkthrough, by its path below the project. */
|
|
112
33
|
function opens() {
|
|
113
34
|
return prototypes()
|
|
114
35
|
.filter((p) => isLive(p) && p.kind === 'sprint')
|
|
115
36
|
.map((p) => ({
|
|
116
37
|
title: p.title,
|
|
117
|
-
path:
|
|
38
|
+
path: `${p.slug}/`,
|
|
118
39
|
...(p.feature && existsSync(join(DOCS, 'sprints', p.feature, 'guide.md'))
|
|
119
|
-
? { guide:
|
|
40
|
+
? { guide: `guide/${p.feature}/` }
|
|
120
41
|
: {}),
|
|
121
42
|
}));
|
|
122
43
|
}
|
|
123
|
-
/** The
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const branch = git(['rev-parse', '--abbrev-ref', 'HEAD']).out;
|
|
138
|
-
const status = git(['status', '--porcelain']).out;
|
|
139
|
-
return {
|
|
140
|
-
connected: gitConnected(info) && git(['remote', 'get-url', 'origin']).ok,
|
|
141
|
-
branch: branch && branch !== 'HEAD' ? branch : null,
|
|
142
|
-
productionBranch: info?.link?.productionBranch ?? 'main',
|
|
143
|
-
dirty: status ? status.split('\n') : [],
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Deploys by the route the plan chose. A push the remote already has starts no
|
|
148
|
-
* build, but a deploy after an env change still needs one, so that uploads.
|
|
149
|
-
*/
|
|
150
|
-
async function deploy(route, project, scope) {
|
|
151
|
-
if ('error' in route)
|
|
152
|
-
throw new CliError(route.error, { stage: 'deploy', fix: route.fix, ...(route.detail ?? {}) });
|
|
153
|
-
const head = git(['rev-parse', 'HEAD']).out;
|
|
154
|
-
const remote = route.via === 'git' ? git(['ls-remote', 'origin', `refs/heads/${route.branch}`]).out.split(/\s/)[0] : '';
|
|
155
|
-
if (route.via === 'git' && remote !== head)
|
|
156
|
-
return { via: 'git', deployment: await viaGit(project, scope, route.branch) };
|
|
157
|
-
return { via: 'cli', deployment: viaCli() };
|
|
158
|
-
}
|
|
159
|
-
/** People sign in with their own one-time links, so the handover carries no secret, only who to add. */
|
|
160
|
-
function handover(url) {
|
|
161
|
-
const env = readEnv(ROOT);
|
|
162
|
-
const review = STORE_ENV.every((n) => env[n]) ? 'on' : 'off';
|
|
163
|
-
return {
|
|
164
|
-
share: { url, open: opens() },
|
|
165
|
-
review,
|
|
166
|
-
next: review === 'on'
|
|
167
|
-
? `Add each person with pnpm people add --name "<name>" --team "<team>" --site ${url} (--kind studio for the studio), and send each person their own link with the handover (miles-deploy). A link signs in one device, then stops working. Never send GATE_SECRET.`
|
|
168
|
-
: 'Nobody can sign in without the review store: run design-hub bootstrap --vercel <project> --review, then share again. Never send GATE_SECRET.',
|
|
169
|
-
};
|
|
44
|
+
/** The studio's other builds of the project, down to the last few; a failure leaves them for the next share. */
|
|
45
|
+
async function prune(...[deps, scope]) {
|
|
46
|
+
try {
|
|
47
|
+
return { removed: await pruneBuilds(deps, scope) };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
removed: [],
|
|
52
|
+
old: {
|
|
53
|
+
error: `Older builds were not removed: ${error instanceof Error ? error.message : String(error)}`,
|
|
54
|
+
fix: 'Nothing is wrong with this share. The next share removes them.',
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
170
58
|
}
|
|
171
|
-
export async function
|
|
172
|
-
const
|
|
173
|
-
|
|
59
|
+
export async function run({ flags }, deps) {
|
|
60
|
+
const link = readLink(deps.root);
|
|
61
|
+
if (!link)
|
|
62
|
+
throw new CliError('This project is not linked to a studio, so a share has nowhere to go.', {
|
|
63
|
+
code: 'not_linked',
|
|
64
|
+
fix: 'design-hub project link --studio <slug> --client <slug> --project <slug>, then share again.',
|
|
65
|
+
});
|
|
66
|
+
// The studio must agree with the link before anything is built, and its file store's token is the studio folder's.
|
|
67
|
+
const { review, scope, client, studio } = await openLinked(deps, link);
|
|
68
|
+
const files = deps.files(studio);
|
|
69
|
+
const checked = await deps.preflight(flags.skip);
|
|
174
70
|
if (!checked.ok)
|
|
175
71
|
return {
|
|
176
72
|
ok: false,
|
|
177
73
|
stage: 'preflight',
|
|
178
|
-
error: 'The pre-flight failed; nothing was
|
|
74
|
+
error: 'The pre-flight failed; nothing was uploaded.',
|
|
179
75
|
steps: checked.steps.filter((s) => !s.ok),
|
|
180
76
|
fix: 'Fix each step (miles-deploy says how), then run this again.',
|
|
181
77
|
};
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
78
|
+
const out = mkdtempSync(join(tmpdir(), 'design-hub-share-'));
|
|
79
|
+
try {
|
|
80
|
+
try {
|
|
81
|
+
await deps.build(`/${link.project}/`, out);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
throw new CliError('The build failed; nothing was uploaded.', {
|
|
85
|
+
stage: 'build',
|
|
86
|
+
cause: error instanceof Error ? error.message : String(error),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const store = { review, files, actor: cliActor() };
|
|
90
|
+
const published = await publishBuild(store, scope, out);
|
|
91
|
+
const address = addressOf(client, link.project);
|
|
92
|
+
return {
|
|
93
|
+
studio: link.studio,
|
|
94
|
+
client: client.slug,
|
|
95
|
+
project: link.project,
|
|
96
|
+
...published,
|
|
97
|
+
address,
|
|
98
|
+
open: deps.opens().map(({ title, path, guide }) => ({
|
|
99
|
+
title,
|
|
100
|
+
url: `${address}${path}`,
|
|
101
|
+
...(guide ? { guide: `${address}${guide}` } : {}),
|
|
102
|
+
})),
|
|
103
|
+
...(await prune(store, scope)),
|
|
104
|
+
next: `Send ${address} with each person’s own sign-in link: pnpm people add --name "<name>" --team "<team>" prints one on ${client.host}. Someone already signed in there sees the project at once. A link signs in one device, then stops working.`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
rmSync(out, { recursive: true, force: true });
|
|
109
|
+
}
|
|
189
110
|
}
|
|
111
|
+
const realShareDeps = () => ({
|
|
112
|
+
...realProjectDeps(),
|
|
113
|
+
build: (base, outDir) => buildHub({ root: ROOT, base, outDir }),
|
|
114
|
+
preflight: (skip) => preflight.main({ flags: { skip, 'allow-contact': [] }, positionals: [] }),
|
|
115
|
+
opens,
|
|
116
|
+
});
|
|
117
|
+
export const main = (args) => run(args, realShareDeps());
|
package/dist/scripts/skills.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import type
|
|
2
|
+
import { type Args } from './lib/cli.ts';
|
|
3
3
|
export declare const spec: {
|
|
4
4
|
readonly name: 'skills';
|
|
5
5
|
readonly summary: "Install or update the project's miles-* skills from this package into .claude/skills/, add any package.json script they call that the project lacks, and the session-start upgrade hook.";
|
|
6
6
|
readonly flags: {};
|
|
7
|
-
readonly output: '{ ok, installed: [name], into, scripts: { added: [name] }, hooks: { sessionStart: added | kept } }';
|
|
7
|
+
readonly output: '{ ok, installed: [name], into, scripts: { added: [name] }, hooks: { sessionStart: added | kept }, error?, fix? }; ok is false while the project still has its own deployment files, after everything else is installed. In a studio folder: { ok: false, code: studio_folder, error, fix }, with nothing changed.';
|
|
8
8
|
};
|
|
9
9
|
export declare function installSkills(from?: string, into?: string): string[];
|
|
10
10
|
/** The scripts a project's package.json carries, as the template writes them. The skills call them by these names. */
|
|
@@ -13,6 +13,10 @@ export declare const SCRIPTS: Record<string, string>;
|
|
|
13
13
|
export declare function addScripts(file?: string): string[];
|
|
14
14
|
/** Adds the SessionStart upgrade hook to .claude/settings.json when it is missing; other hooks are never changed. */
|
|
15
15
|
export declare function addSessionHook(file?: string): 'added' | 'kept';
|
|
16
|
+
/** The files of a project's own deployment it still has (OWN_DEPLOYMENT); none in a studio folder, whose site they are. */
|
|
17
|
+
export declare const ownDeploymentIn: (root?: string) => string[];
|
|
18
|
+
/** Stops `skills` and `upgrade` in a studio folder before either changes anything there. */
|
|
19
|
+
export declare function notInStudioFolder(root?: string): void;
|
|
16
20
|
export declare function main(_args: Args<typeof spec>): {
|
|
17
21
|
installed: string[];
|
|
18
22
|
into: string;
|
|
@@ -22,4 +26,16 @@ export declare function main(_args: Args<typeof spec>): {
|
|
|
22
26
|
hooks: {
|
|
23
27
|
sessionStart: "added" | "kept";
|
|
24
28
|
};
|
|
29
|
+
} | {
|
|
30
|
+
installed: string[];
|
|
31
|
+
into: string;
|
|
32
|
+
scripts: {
|
|
33
|
+
added: string[];
|
|
34
|
+
};
|
|
35
|
+
hooks: {
|
|
36
|
+
sessionStart: "added" | "kept";
|
|
37
|
+
};
|
|
38
|
+
ok: boolean;
|
|
39
|
+
error: string;
|
|
40
|
+
fix: string;
|
|
25
41
|
};
|
package/dist/scripts/skills.js
CHANGED
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
11
11
|
import { join } from 'node:path';
|
|
12
12
|
import { PACKAGE_SKILLS, ROOT, SKILLS } from '../server/paths.js';
|
|
13
|
-
import {
|
|
13
|
+
import { CliError } from './lib/cli.js';
|
|
14
|
+
import { isStudioFolder } from './lib/studios.js';
|
|
15
|
+
import { OWN_DEPLOYMENT, ownDeployment, STUDIO_FOLDER, withSessionHook } from './lib/update.js';
|
|
14
16
|
export const spec = {
|
|
15
17
|
name: 'skills',
|
|
16
18
|
summary: "Install or update the project's miles-* skills from this package into .claude/skills/, add any package.json script they call that the project lacks, and the session-start upgrade hook.",
|
|
17
19
|
flags: {},
|
|
18
|
-
output: '{ ok, installed: [name], into, scripts: { added: [name] }, hooks: { sessionStart: added | kept } }',
|
|
20
|
+
output: '{ ok, installed: [name], into, scripts: { added: [name] }, hooks: { sessionStart: added | kept }, error?, fix? }; ok is false while the project still has its own deployment files, after everything else is installed. In a studio folder: { ok: false, code: studio_folder, error, fix }, with nothing changed.',
|
|
19
21
|
};
|
|
20
22
|
const GLOBAL_ONLY = new Set(['miles-design-hub']);
|
|
21
23
|
/** Skills the package no longer ships, removed from a project on update. miles-conductor became miles-worktrees in 0.2.0. */
|
|
@@ -52,6 +54,9 @@ export const SCRIPTS = {
|
|
|
52
54
|
preflight: 'design-hub preflight',
|
|
53
55
|
signin: 'design-hub signin',
|
|
54
56
|
share: 'design-hub share',
|
|
57
|
+
project: 'design-hub project',
|
|
58
|
+
studio: 'design-hub studio',
|
|
59
|
+
client: 'design-hub client',
|
|
55
60
|
comments: 'design-hub comments',
|
|
56
61
|
people: 'design-hub people',
|
|
57
62
|
calibrate: 'design-hub calibrate',
|
|
@@ -86,11 +91,25 @@ export function addSessionHook(file = join(ROOT, '.claude', 'settings.json')) {
|
|
|
86
91
|
writeFileSync(file, `${JSON.stringify(next, null, 2)}\n`);
|
|
87
92
|
return 'added';
|
|
88
93
|
}
|
|
94
|
+
/** The files of a project's own deployment it still has (OWN_DEPLOYMENT); none in a studio folder, whose site they are. */
|
|
95
|
+
export const ownDeploymentIn = (root = ROOT) => isStudioFolder(root) ? [] : OWN_DEPLOYMENT.filter((f) => existsSync(join(root, f)));
|
|
96
|
+
/** Stops `skills` and `upgrade` in a studio folder before either changes anything there. */
|
|
97
|
+
export function notInStudioFolder(root = ROOT) {
|
|
98
|
+
const { error, ...detail } = STUDIO_FOLDER;
|
|
99
|
+
if (isStudioFolder(root))
|
|
100
|
+
throw new CliError(error, detail);
|
|
101
|
+
}
|
|
89
102
|
export function main(_args) {
|
|
90
|
-
|
|
103
|
+
notInStudioFolder();
|
|
104
|
+
const done = {
|
|
91
105
|
installed: installSkills(),
|
|
92
106
|
into: SKILLS,
|
|
93
107
|
scripts: { added: addScripts() },
|
|
94
108
|
hooks: { sessionStart: addSessionHook() },
|
|
95
109
|
};
|
|
110
|
+
const left = ownDeploymentIn();
|
|
111
|
+
if (!left.length)
|
|
112
|
+
return done;
|
|
113
|
+
const { error, fix } = ownDeployment(left);
|
|
114
|
+
return { ok: false, ...done, error, fix };
|
|
96
115
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type Args } from './lib/cli.ts';
|
|
3
|
+
import { type StudioDeps } from './lib/studio-deps.ts';
|
|
4
|
+
export declare const spec: {
|
|
5
|
+
readonly name: 'studio';
|
|
6
|
+
readonly summary: 'Create a studio (its folder, its site on a Vercel team, its stores), deploy it again, or list an existing studio folder on this machine.';
|
|
7
|
+
readonly positionals: [{
|
|
8
|
+
readonly name: 'action';
|
|
9
|
+
readonly required: true;
|
|
10
|
+
readonly description: 'create: scaffold --dir, install and build it here, set it up on --team, deploy, and list it. deploy: install and build the studio folder here, so the site installs the package its package.json names, deploy it again and remove every older deployment. link: list an existing studio folder (--dir) on this machine and link it to the studio’s project.';
|
|
11
|
+
}];
|
|
12
|
+
readonly flags: {
|
|
13
|
+
readonly dir: {
|
|
14
|
+
readonly type: 'string';
|
|
15
|
+
readonly description: 'For create and link: the studio folder.';
|
|
16
|
+
};
|
|
17
|
+
readonly slug: {
|
|
18
|
+
readonly type: 'string';
|
|
19
|
+
readonly description: 'For create: the studio’s slug, kebab-case.';
|
|
20
|
+
};
|
|
21
|
+
readonly apex: {
|
|
22
|
+
readonly type: 'string';
|
|
23
|
+
readonly description: 'For create: the apex domain clients are hosted under, such as example.com.';
|
|
24
|
+
};
|
|
25
|
+
readonly name: {
|
|
26
|
+
readonly type: 'string';
|
|
27
|
+
readonly description: 'For create: the studio’s name, shown beside its people on comments.';
|
|
28
|
+
};
|
|
29
|
+
readonly owner: {
|
|
30
|
+
readonly type: 'string';
|
|
31
|
+
readonly description: 'For create: your name. You are the studio’s first Studio person and get a link on each new client’s host.';
|
|
32
|
+
};
|
|
33
|
+
readonly team: {
|
|
34
|
+
readonly type: 'string';
|
|
35
|
+
readonly description: 'For create: the Vercel team (its slug) the studio lives in. Required: the CLI’s current team is never used.';
|
|
36
|
+
};
|
|
37
|
+
readonly project: {
|
|
38
|
+
readonly type: 'string';
|
|
39
|
+
readonly description: 'For create: the Vercel project name. Absent, the slug.';
|
|
40
|
+
};
|
|
41
|
+
readonly dns: {
|
|
42
|
+
readonly type: 'string';
|
|
43
|
+
readonly choices: readonly ["vercel", "cloudflare", "manual"];
|
|
44
|
+
readonly description: 'For create: who serves DNS for the apex. vercel: one wildcard for every client (only *.<apex> reaches certificate logs). cloudflare: a record per client by its API (each host is public in certificate logs). manual: a record per client, printed for you to add.';
|
|
45
|
+
};
|
|
46
|
+
readonly zone: {
|
|
47
|
+
readonly type: 'string';
|
|
48
|
+
readonly description: 'For create with --dns cloudflare: the zone id. Absent, it is found from the apex.';
|
|
49
|
+
};
|
|
50
|
+
readonly 'cloudflare-token-file': {
|
|
51
|
+
readonly type: 'string';
|
|
52
|
+
readonly description: 'For create and link with Cloudflare DNS: a file holding an API token with DNS edit on the apex’s zone. It is copied into the studio’s .env; never pass a token itself.';
|
|
53
|
+
};
|
|
54
|
+
readonly region: {
|
|
55
|
+
readonly type: 'string';
|
|
56
|
+
readonly default: 'iad1';
|
|
57
|
+
readonly description: 'For create: the file store’s region, the site’s function region.';
|
|
58
|
+
};
|
|
59
|
+
readonly database: {
|
|
60
|
+
readonly type: 'string';
|
|
61
|
+
readonly description: 'For create: the name of a database (Upstash for Redis) the team already has and no studio uses, connected to the studio in place of a new one. A database serves one studio only: create marks it as this studio’s, and refuses one that is another studio’s or already holds a studio’s data, before writing to it, disconnecting it again and keeping none of its credentials. Absent, a new one is made, only ever on the free plan; a team refused the free plan stops here with nothing bought.';
|
|
62
|
+
};
|
|
63
|
+
readonly package: {
|
|
64
|
+
readonly type: 'string';
|
|
65
|
+
readonly description: 'For create and deploy: a .tgz of @milesroxas/design-hub (pnpm pack in a checkout), copied into the studio folder and installed in place of the package it named, even one packed again at the same version. Without it, deploy installs what the folder’s package.json names: to move to a newer published version, pnpm add @milesroxas/design-hub@<version> in the folder first.';
|
|
66
|
+
};
|
|
67
|
+
readonly studio: {
|
|
68
|
+
readonly type: 'string';
|
|
69
|
+
readonly description: 'For deploy: the studio’s slug. Absent, the studio folder this runs in.';
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly output: 'create: { ok, studio, dir, folder, list, package, vercel, env: { GATE_SECRET: set | kept, database: created | connected | kept, files: created | kept, pulled }, mark: claimed | kept (the database marked as this studio’s), dns, owner, deployment, removed, next }. deploy: { ok, studio, package, deployment, removed }. package is what the folder’s package.json names for @milesroxas/design-hub. link: { ok, studio, dir, list, env, warnings }';
|
|
73
|
+
};
|
|
74
|
+
export declare function run({ positionals: [action], flags }: Args<typeof spec>, deps: StudioDeps): Promise<Record<string, unknown>>;
|
|
75
|
+
export declare const main: (args: Args<typeof spec>) => Promise<Record<string, unknown>>;
|