@milesroxas/design-hub 0.6.2 → 0.7.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 +16 -6
- package/core/review/model.ts +82 -6
- package/core/review/policy.test.ts +2 -0
- package/core/review/policy.ts +2 -2
- package/core/review/service.test.ts +397 -27
- package/core/review/service.ts +168 -36
- package/core/review/store.ts +22 -4
- package/dist/core/review/model.d.ts +35 -4
- package/dist/core/review/model.js +66 -4
- package/dist/core/review/service.d.ts +24 -6
- package/dist/core/review/service.js +155 -36
- package/dist/core/review/store.d.ts +15 -4
- package/dist/core/review/store.js +19 -3
- package/dist/scripts/bootstrap.d.ts +16 -14
- package/dist/scripts/bootstrap.js +56 -39
- package/dist/scripts/lib/deploy.d.ts +12 -4
- package/dist/scripts/lib/deploy.js +47 -13
- package/dist/scripts/lib/vercel.d.ts +8 -2
- package/dist/scripts/lib/vercel.js +23 -9
- package/dist/scripts/people.d.ts +13 -26
- package/dist/scripts/people.js +68 -35
- package/dist/scripts/preflight.js +2 -2
- package/dist/scripts/share.d.ts +2 -3
- package/dist/scripts/share.js +18 -10
- package/dist/server/api.d.ts +6 -2
- package/dist/server/api.js +53 -22
- package/dist/server/fake-upstash.js +3 -2
- package/dist/server/local.js +2 -0
- package/dist/server/session.d.ts +25 -10
- package/dist/server/session.js +69 -52
- package/dist/server/upstash.js +4 -3
- package/dist/vercel/proxy.d.ts +5 -3
- package/dist/vercel/proxy.js +183 -157
- package/dist/vite/plugin.js +5 -5
- package/package.json +2 -2
- package/shell/review/People.tsx +178 -45
- package/shell/review/Review.tsx +7 -7
- package/shell/review/client.ts +36 -17
- package/shell/review/review.css +2 -0
- package/skills/miles-deploy/SKILL.md +44 -16
- package/skills/miles-design-hub/SKILL.md +5 -5
- package/skills/miles-new-feature/SKILL.md +1 -1
- package/skills/miles-review/SKILL.md +7 -5
- package/skills/miles-worktrees/SKILL.md +1 -1
- package/templates/conductor/settings.toml +1 -1
- package/templates/guide.md +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// What `design-hub signin` and `design-hub share` decide, kept apart from the
|
|
3
3
|
// vercel and git calls that feed them so every branch is tested: the sign-in
|
|
4
4
|
// link in the CLI's log, which way a deploy goes, the production URL, and
|
|
5
|
-
// whether the deployed site answers with the gate.
|
|
5
|
+
// whether the deployed site answers with the gate's sign-in page.
|
|
6
6
|
/** The device sign-in `vercel login` prints and then waits on. */
|
|
7
7
|
export function deviceLink(log) {
|
|
8
8
|
const m = log.match(/https:\/\/vercel\.com\/oauth\/device\?user_code=([A-Z0-9-]+)/);
|
|
@@ -39,38 +39,54 @@ export function plan(repo, forceCli) {
|
|
|
39
39
|
return { via: 'git', branch: repo.productionBranch };
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* How `design-hub share` asks for the home page: as a browser does
|
|
43
|
-
* answers a client that does not accept HTML with a plain-text
|
|
44
|
-
* no
|
|
42
|
+
* How `design-hub share` asks for the home page: as a browser does, signed
|
|
43
|
+
* out. The gate answers a client that does not accept HTML with a plain-text
|
|
44
|
+
* 401, which has no sign-in page to find.
|
|
45
45
|
*/
|
|
46
46
|
export const GATE_REQUEST = {
|
|
47
47
|
redirect: 'manual',
|
|
48
48
|
headers: { accept: 'text/html,application/xhtml+xml' },
|
|
49
49
|
};
|
|
50
|
-
/**
|
|
51
|
-
|
|
50
|
+
/** The hub's sign-in page carries this on its main element (vercel/proxy.ts). */
|
|
51
|
+
const SIGN_IN_MARKER = 'data-gate="sign-in"';
|
|
52
|
+
const quote = (body) => JSON.stringify(body.replace(/\s+/g, ' ').trim().slice(0, 80));
|
|
53
|
+
/** The first problem with the status alone, or null when it is the 401 the gate answers. */
|
|
54
|
+
function statusProblem(answer) {
|
|
52
55
|
if (answer.status >= 300 && answer.status < 400 && /vercel\.com/.test(answer.location ?? ''))
|
|
53
56
|
return {
|
|
54
57
|
ok: false,
|
|
55
|
-
problem: 'Visitors are sent to a Vercel login before the
|
|
56
|
-
fix: 'design-hub bootstrap --vercel <project> turns Vercel Authentication off; run it, then deploy again.',
|
|
58
|
+
problem: 'Visitors are sent to a Vercel login before the sign-in page.',
|
|
59
|
+
fix: 'design-hub bootstrap --vercel <project> --review turns Vercel Authentication off; run it, then deploy again.',
|
|
57
60
|
};
|
|
58
61
|
if (answer.status === 503)
|
|
59
62
|
return {
|
|
60
63
|
ok: false,
|
|
61
|
-
problem: 'The gate answers 503:
|
|
62
|
-
fix: 'design-hub bootstrap --vercel <project
|
|
64
|
+
problem: 'The gate answers 503: GATE_SECRET is missing on the deployment.',
|
|
65
|
+
fix: 'design-hub bootstrap --vercel <project> --review, then deploy again so the env reaches the site.',
|
|
63
66
|
};
|
|
64
67
|
if (answer.status !== 401)
|
|
65
68
|
return {
|
|
66
69
|
ok: false,
|
|
67
|
-
problem: `Expected the
|
|
70
|
+
problem: `Expected the sign-in page (401), got ${answer.status}.`,
|
|
68
71
|
fix: 'Check that proxy.ts and vercel.json are the template’s, then deploy again.',
|
|
69
72
|
};
|
|
70
|
-
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
/** Whether the production URL answers a signed-out visitor with the hub's sign-in page. */
|
|
76
|
+
export function gateVerdict(answer) {
|
|
77
|
+
const status = statusProblem(answer);
|
|
78
|
+
if (status)
|
|
79
|
+
return status;
|
|
80
|
+
if (/name="password"/.test(answer.body))
|
|
81
|
+
return {
|
|
82
|
+
ok: false,
|
|
83
|
+
problem: 'The site still asks for a password: it runs a hub from before one-time links.',
|
|
84
|
+
fix: 'Commit the updated @milesroxas/design-hub (package.json and pnpm-lock.yaml), then deploy again.',
|
|
85
|
+
};
|
|
86
|
+
if (!answer.body.includes(SIGN_IN_MARKER))
|
|
71
87
|
return {
|
|
72
88
|
ok: false,
|
|
73
|
-
problem: `The site answered 401, but the body was not the
|
|
89
|
+
problem: `The site answered 401, but the body was not the sign-in page: ${quote(answer.body)}.`,
|
|
74
90
|
fix: 'Something other than the hub’s gate answered. Check that Vercel’s Password Protection is off and that proxy.ts and vercel.json are the template’s, then deploy again.',
|
|
75
91
|
};
|
|
76
92
|
if (!/noindex/.test(answer.robots ?? ''))
|
|
@@ -81,6 +97,24 @@ export function gateVerdict(answer) {
|
|
|
81
97
|
};
|
|
82
98
|
return { ok: true };
|
|
83
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* A link no store holds, asked for as a browser does once the sign-in page
|
|
102
|
+
* passed: it proves the review store is wired, since people sign in only with
|
|
103
|
+
* links it keeps. 43 characters, the length of a real token.
|
|
104
|
+
*/
|
|
105
|
+
export const PROBE_LINK = `/invite/${'x'.repeat(43)}`;
|
|
106
|
+
/** Whether the probe link's answer shows a review store behind the gate: 404 means it looked and found nothing. */
|
|
107
|
+
export function storeVerdict(status) {
|
|
108
|
+
if (status === 404)
|
|
109
|
+
return { ok: true };
|
|
110
|
+
return {
|
|
111
|
+
ok: false,
|
|
112
|
+
problem: status === 503
|
|
113
|
+
? 'The site has no review store, so nobody can sign in: people sign in with links it keeps.'
|
|
114
|
+
: `A sign-in link answered ${status}, not 404, so the review store could not be checked.`,
|
|
115
|
+
fix: 'pnpm bootstrap --vercel <project> --review, then deploy again so the store reaches the site.',
|
|
116
|
+
};
|
|
117
|
+
}
|
|
84
118
|
const APPEAR_MS = 2 * 60_000;
|
|
85
119
|
const BUILD_MS = 10 * 60_000;
|
|
86
120
|
/** One look at the deployment Vercel started for a pushed commit: done, keep waiting, or stop. */
|
|
@@ -14,8 +14,14 @@ export declare const linkedProject: (cwd: string) => string | null;
|
|
|
14
14
|
export declare const linkedOrg: (cwd: string) => string | null;
|
|
15
15
|
/** The variable names set for a target, read from `vercel env ls`'s table. */
|
|
16
16
|
export declare function envNames(cwd: string, target: Target): Set<string> | null;
|
|
17
|
-
/**
|
|
18
|
-
export declare function setEnv(cwd: string, name: string, target: Target, value: string
|
|
17
|
+
/** Adds one variable for one target that does not have it yet. */
|
|
18
|
+
export declare function setEnv(cwd: string, name: string, target: Target, value: string): Run | null;
|
|
19
|
+
/**
|
|
20
|
+
* What the gate needs that a target lacks, as `NAME:target`: the secret, and
|
|
21
|
+
* the review store, without which nobody can sign in, since it keeps the
|
|
22
|
+
* people and their links. Null when a target's names could not be read.
|
|
23
|
+
*/
|
|
24
|
+
export declare function missingGateEnv(names: Record<(typeof ENVIRONMENTS)[number], Set<string> | null>): string[] | null;
|
|
19
25
|
/** The gate variables missing from production or preview, or null when the CLI cannot say. */
|
|
20
26
|
export declare function gateEnvMissing(cwd: string): string[] | null;
|
|
21
27
|
/** The signed-in account, or null when the CLI is missing or signed out. */
|
|
@@ -6,7 +6,8 @@ import { spawnSync } from 'node:child_process';
|
|
|
6
6
|
import { existsSync, readFileSync } from 'node:fs';
|
|
7
7
|
import { join } from 'node:path';
|
|
8
8
|
export const ENVIRONMENTS = ['production', 'preview'];
|
|
9
|
-
|
|
9
|
+
/** What the gate needs: the secret that signs each person's session. */
|
|
10
|
+
const GATE_ENV = ['GATE_SECRET'];
|
|
10
11
|
/** What the Upstash for Redis integration injects (Vercel Marketplace). */
|
|
11
12
|
export const STORE_ENV = ['KV_REST_API_URL', 'KV_REST_API_TOKEN'];
|
|
12
13
|
export function vercel(cwd, args, input) {
|
|
@@ -36,24 +37,37 @@ export function envNames(cwd, target) {
|
|
|
36
37
|
return null;
|
|
37
38
|
return new Set([...out.stdout.matchAll(/^\s*([A-Z][A-Z0-9_]*)\s/gm)].map((m) => m[1]));
|
|
38
39
|
}
|
|
39
|
-
/**
|
|
40
|
-
export function setEnv(cwd, name, target, value
|
|
40
|
+
/** Adds one variable for one target that does not have it yet. */
|
|
41
|
+
export function setEnv(cwd, name, target, value) {
|
|
41
42
|
// The value goes on stdin, never argv, so it stays out of the process list.
|
|
42
|
-
return vercel(cwd, ['env', 'add', name, target,
|
|
43
|
+
return vercel(cwd, ['env', 'add', name, target, '--yes'], value);
|
|
43
44
|
}
|
|
44
|
-
/** The
|
|
45
|
-
|
|
45
|
+
/** The Upstash console's names for the same store; server/upstash.ts reads either pair. */
|
|
46
|
+
const UPSTASH_ENV = ['UPSTASH_REDIS_REST_URL', 'UPSTASH_REDIS_REST_TOKEN'];
|
|
47
|
+
/**
|
|
48
|
+
* What the gate needs that a target lacks, as `NAME:target`: the secret, and
|
|
49
|
+
* the review store, without which nobody can sign in, since it keeps the
|
|
50
|
+
* people and their links. Null when a target's names could not be read.
|
|
51
|
+
*/
|
|
52
|
+
export function missingGateEnv(names) {
|
|
46
53
|
const missing = [];
|
|
47
54
|
for (const target of ENVIRONMENTS) {
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
55
|
+
const have = names[target];
|
|
56
|
+
if (!have)
|
|
50
57
|
return null;
|
|
51
58
|
for (const name of GATE_ENV)
|
|
52
|
-
if (!
|
|
59
|
+
if (!have.has(name))
|
|
53
60
|
missing.push(`${name}:${target}`);
|
|
61
|
+
const store = [STORE_ENV, UPSTASH_ENV].some((pair) => pair.every((n) => have.has(n)));
|
|
62
|
+
if (!store)
|
|
63
|
+
missing.push(...STORE_ENV.filter((n) => !have.has(n)).map((n) => `${n}:${target}`));
|
|
54
64
|
}
|
|
55
65
|
return missing;
|
|
56
66
|
}
|
|
67
|
+
/** The gate variables missing from production or preview, or null when the CLI cannot say. */
|
|
68
|
+
export function gateEnvMissing(cwd) {
|
|
69
|
+
return missingGateEnv({ production: envNames(cwd, 'production'), preview: envNames(cwd, 'preview') });
|
|
70
|
+
}
|
|
57
71
|
/** The signed-in account, or null when the CLI is missing or signed out. */
|
|
58
72
|
export function whoami(cwd) {
|
|
59
73
|
const out = vercel(cwd, ['whoami']);
|
package/dist/scripts/people.d.ts
CHANGED
|
@@ -2,58 +2,45 @@
|
|
|
2
2
|
import { type Args } from './lib/cli.ts';
|
|
3
3
|
export declare const spec: {
|
|
4
4
|
readonly name: 'people';
|
|
5
|
-
readonly summary: 'List
|
|
5
|
+
readonly summary: 'List or add the people who comment on the deployed prototypes, give them sign-in links, sign them out, revoke them, and set how long they keep access.';
|
|
6
6
|
readonly positionals: [{
|
|
7
7
|
readonly name: 'action';
|
|
8
|
-
readonly description: 'list (default): everyone
|
|
8
|
+
readonly description: 'list (default): everyone. add: a new person and their link. link <id>: another one-time link, for another device. sign-out <id>: ends every session and unused link, and gives one new link. revoke <id>: ends their access everywhere. access [id]: with an id and --access, sets that person’s access from now; without an id, reads the project default, or sets it with --access.';
|
|
9
9
|
}, {
|
|
10
10
|
readonly name: 'id';
|
|
11
|
-
readonly description: 'The person, for
|
|
11
|
+
readonly description: 'The person, for link, sign-out, revoke and access';
|
|
12
12
|
}];
|
|
13
13
|
readonly flags: {
|
|
14
14
|
readonly name: {
|
|
15
15
|
readonly type: 'string';
|
|
16
|
-
readonly description: 'For
|
|
16
|
+
readonly description: 'For add: their name as it shows on comments.';
|
|
17
17
|
};
|
|
18
18
|
readonly team: {
|
|
19
19
|
readonly type: 'string';
|
|
20
|
-
readonly description: "For
|
|
20
|
+
readonly description: "For add: the studio, or the client's company.";
|
|
21
21
|
};
|
|
22
22
|
readonly kind: {
|
|
23
23
|
readonly type: 'string';
|
|
24
24
|
readonly default: 'client';
|
|
25
25
|
readonly choices: readonly ["studio", "client"];
|
|
26
|
-
readonly description: 'client comments, replies and resolves any thread; studio also deletes any comment, sorts and
|
|
26
|
+
readonly description: 'client comments, replies and resolves any thread; studio also deletes any comment, sorts and manages people.';
|
|
27
|
+
};
|
|
28
|
+
readonly access: {
|
|
29
|
+
readonly type: 'string';
|
|
30
|
+
readonly choices: readonly ["3m", "6m", "open"];
|
|
31
|
+
readonly description: 'How long they keep access: 3m, 6m or open. For add, absent means the project default for a client and open for studio.';
|
|
27
32
|
};
|
|
28
33
|
readonly site: {
|
|
29
34
|
readonly type: 'string';
|
|
30
|
-
readonly description: 'The deployed URL, so the
|
|
35
|
+
readonly description: 'The deployed URL, so the link prints whole.';
|
|
31
36
|
};
|
|
32
37
|
readonly local: {
|
|
33
38
|
readonly type: 'boolean';
|
|
34
39
|
readonly description: 'Use the local dev store even when the deployed one is configured.';
|
|
35
40
|
};
|
|
36
41
|
};
|
|
37
|
-
readonly output: '{ ok, store, people } or { ok, store, person, link }';
|
|
42
|
+
readonly output: '{ ok, store, people } or { ok, store, person, link } or { ok, store, person } or { ok, store, access }';
|
|
38
43
|
};
|
|
39
44
|
export declare function main({ positionals: [action, id], flags }: Args<typeof spec>): Promise<{
|
|
40
45
|
store: "deployed" | "local";
|
|
41
|
-
people: Omit<import("../core/review/model.ts").Person, "epoch">[];
|
|
42
|
-
person?: undefined;
|
|
43
|
-
} | {
|
|
44
|
-
link: string;
|
|
45
|
-
next: string;
|
|
46
|
-
people?: undefined;
|
|
47
|
-
store: "deployed" | "local";
|
|
48
|
-
person: Omit<import("../core/review/model.ts").Person, "epoch">;
|
|
49
|
-
} | {
|
|
50
|
-
next?: undefined;
|
|
51
|
-
link: string;
|
|
52
|
-
people?: undefined;
|
|
53
|
-
store: "deployed" | "local";
|
|
54
|
-
person: Omit<import("../core/review/model.ts").Person, "epoch">;
|
|
55
|
-
} | {
|
|
56
|
-
people?: undefined;
|
|
57
|
-
store: "deployed" | "local";
|
|
58
|
-
person: Omit<import("../core/review/model.ts").Person, "epoch">;
|
|
59
46
|
}>;
|
package/dist/scripts/people.js
CHANGED
|
@@ -1,36 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
// The people who comment on the deployed prototypes. The first Studio person
|
|
4
|
-
// is
|
|
5
|
-
|
|
4
|
+
// is added from here; after that, Studio adds people from the People tab.
|
|
5
|
+
// Each person signs in with a one-time link: it signs in one device, then
|
|
6
|
+
// stops working, so a second device needs a new link.
|
|
7
|
+
import { ACCESS, PERSON_KINDS } from '../core/review/model.js';
|
|
6
8
|
import { CliError } from './lib/cli.js';
|
|
7
9
|
import { cliActor, cliReview } from './lib/review.js';
|
|
8
10
|
export const spec = {
|
|
9
11
|
name: 'people',
|
|
10
|
-
summary: 'List
|
|
12
|
+
summary: 'List or add the people who comment on the deployed prototypes, give them sign-in links, sign them out, revoke them, and set how long they keep access.',
|
|
11
13
|
positionals: [
|
|
12
14
|
{
|
|
13
15
|
name: 'action',
|
|
14
|
-
description: 'list (default): everyone
|
|
16
|
+
description: 'list (default): everyone. add: a new person and their link. link <id>: another one-time link, for another device. sign-out <id>: ends every session and unused link, and gives one new link. revoke <id>: ends their access everywhere. access [id]: with an id and --access, sets that person’s access from now; without an id, reads the project default, or sets it with --access.',
|
|
15
17
|
},
|
|
16
|
-
{ name: 'id', description: 'The person, for
|
|
18
|
+
{ name: 'id', description: 'The person, for link, sign-out, revoke and access' },
|
|
17
19
|
],
|
|
18
20
|
flags: {
|
|
19
|
-
name: { type: 'string', description: 'For
|
|
20
|
-
team: { type: 'string', description: "For
|
|
21
|
+
name: { type: 'string', description: 'For add: their name as it shows on comments.' },
|
|
22
|
+
team: { type: 'string', description: "For add: the studio, or the client's company." },
|
|
21
23
|
kind: {
|
|
22
24
|
type: 'string',
|
|
23
25
|
default: 'client',
|
|
24
26
|
choices: PERSON_KINDS,
|
|
25
|
-
description: 'client comments, replies and resolves any thread; studio also deletes any comment, sorts and
|
|
27
|
+
description: 'client comments, replies and resolves any thread; studio also deletes any comment, sorts and manages people.',
|
|
26
28
|
},
|
|
27
|
-
|
|
29
|
+
access: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
choices: ACCESS,
|
|
32
|
+
description: 'How long they keep access: 3m, 6m or open. For add, absent means the project default for a client and open for studio.',
|
|
33
|
+
},
|
|
34
|
+
site: { type: 'string', description: 'The deployed URL, so the link prints whole.' },
|
|
28
35
|
local: {
|
|
29
36
|
type: 'boolean',
|
|
30
37
|
description: 'Use the local dev store even when the deployed one is configured.',
|
|
31
38
|
},
|
|
32
39
|
},
|
|
33
|
-
output: '{ ok, store, people } or { ok, store, person, link }',
|
|
40
|
+
output: '{ ok, store, people } or { ok, store, person, link } or { ok, store, person } or { ok, store, access }',
|
|
34
41
|
};
|
|
35
42
|
const linkFor = (token, site) => {
|
|
36
43
|
const path = `/invite/${token}`;
|
|
@@ -43,31 +50,57 @@ const linkFor = (token, site) => {
|
|
|
43
50
|
throw new CliError('--site takes a URL.', { got: site });
|
|
44
51
|
}
|
|
45
52
|
};
|
|
53
|
+
const strip = ({ epoch: _e, ...rest }) => rest;
|
|
54
|
+
function needId(action, id) {
|
|
55
|
+
if (!id)
|
|
56
|
+
throw new CliError(`Name the person: pnpm people ${action} <id>.`, { fix: 'pnpm people lists ids.' });
|
|
57
|
+
return id;
|
|
58
|
+
}
|
|
59
|
+
const withLink = (r, site) => ({
|
|
60
|
+
person: strip(r.person),
|
|
61
|
+
...linkFor(r.token, site),
|
|
62
|
+
});
|
|
63
|
+
/** One person's access with an id, else the project default: read it, or set it with --access. */
|
|
64
|
+
async function access({ review, actor, flags, id }) {
|
|
65
|
+
if (id) {
|
|
66
|
+
if (!flags.access)
|
|
67
|
+
throw new CliError('Say how long: pnpm people access <id> --access 3m|6m|open.');
|
|
68
|
+
return { person: strip(await review.setAccess(actor, id, flags.access)) };
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
access: flags.access
|
|
72
|
+
? await review.setDefaultAccess(actor, flags.access)
|
|
73
|
+
: await review.defaultAccess(actor),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const ACTIONS = {
|
|
77
|
+
list: async ({ review, actor }) => ({ people: (await review.listPeople(actor)).map(strip) }),
|
|
78
|
+
add: async ({ review, actor, flags }) => withLink(await review.addPerson(actor, {
|
|
79
|
+
name: flags.name,
|
|
80
|
+
team: flags.team,
|
|
81
|
+
kind: flags.kind,
|
|
82
|
+
access: flags.access,
|
|
83
|
+
}), flags.site),
|
|
84
|
+
link: async ({ review, actor, flags, id }) => withLink(await review.newLink(actor, needId('link', id)), flags.site),
|
|
85
|
+
'sign-out': async ({ review, actor, flags, id }) => withLink(await review.signOutEverywhere(actor, needId('sign-out', id)), flags.site),
|
|
86
|
+
revoke: async ({ review, actor, id }) => ({
|
|
87
|
+
person: strip(await review.revoke(actor, needId('revoke', id))),
|
|
88
|
+
}),
|
|
89
|
+
access,
|
|
90
|
+
};
|
|
46
91
|
export async function main({ positionals: [action = 'list', id], flags }) {
|
|
92
|
+
const run = Object.hasOwn(ACTIONS, action) ? ACTIONS[action] : undefined;
|
|
93
|
+
if (!run)
|
|
94
|
+
throw new CliError(`Unknown action ${action}.`, { fix: 'list, add, link, sign-out, revoke or access' });
|
|
95
|
+
if (flags.local && flags.site)
|
|
96
|
+
throw new CliError('--local and --site do not go together: a local link opens nothing on the deployed site.', {
|
|
97
|
+
fix: 'Drop --site for a local link, or drop --local to use the deployed store.',
|
|
98
|
+
});
|
|
47
99
|
const { review, store } = cliReview(flags.local);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const { person, token } = await review.invite(actor, {
|
|
55
|
-
name: flags.name,
|
|
56
|
-
team: flags.team,
|
|
57
|
-
kind: flags.kind,
|
|
58
|
-
});
|
|
59
|
-
return { store, person: strip(person), ...linkFor(token, flags.site) };
|
|
60
|
-
}
|
|
61
|
-
case 'reissue':
|
|
62
|
-
case 'revoke': {
|
|
63
|
-
if (!id)
|
|
64
|
-
throw new CliError(`Name the person: pnpm people ${action} <id>.`, { fix: 'pnpm people lists ids.' });
|
|
65
|
-
if (action === 'revoke')
|
|
66
|
-
return { store, person: strip(await review.revoke(actor, id)) };
|
|
67
|
-
const { person, token } = await review.reissue(actor, id);
|
|
68
|
-
return { store, person: strip(person), ...linkFor(token, flags.site) };
|
|
69
|
-
}
|
|
70
|
-
default:
|
|
71
|
-
throw new CliError(`Unknown action ${action}.`, { fix: 'list, invite, reissue or revoke' });
|
|
72
|
-
}
|
|
100
|
+
// A link made in the local store opens nothing on the deployed site, so never print one under its URL.
|
|
101
|
+
if (flags.site && store === 'local')
|
|
102
|
+
throw new CliError('--site names the deployed site, but its store is not configured here.', {
|
|
103
|
+
fix: 'KV_REST_API_URL and KV_REST_API_TOKEN are missing from .env: pnpm bootstrap --vercel <project> --review puts them there. For a local link, pass --local without --site.',
|
|
104
|
+
});
|
|
105
|
+
return { store, ...(await run({ review, actor: cliActor(), flags, id })) };
|
|
73
106
|
}
|
|
@@ -183,7 +183,7 @@ function gate() {
|
|
|
183
183
|
step: 'gate',
|
|
184
184
|
ok: true,
|
|
185
185
|
skipped: 'not linked to Vercel yet',
|
|
186
|
-
fix: 'design-hub bootstrap --vercel <project>',
|
|
186
|
+
fix: 'design-hub bootstrap --vercel <project> --review',
|
|
187
187
|
};
|
|
188
188
|
const missing = gateEnvMissing(ROOT);
|
|
189
189
|
if (missing === null)
|
|
@@ -193,7 +193,7 @@ function gate() {
|
|
|
193
193
|
step: 'gate',
|
|
194
194
|
ok: false,
|
|
195
195
|
detail: { missing },
|
|
196
|
-
fix: '
|
|
196
|
+
fix: 'pnpm bootstrap --vercel <project> --review sets GATE_SECRET and adds the review store, which keeps the people and their links: without it nobody can sign in.',
|
|
197
197
|
}
|
|
198
198
|
: { step: 'gate', ok: true };
|
|
199
199
|
}
|
package/dist/scripts/share.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { type Args } from './lib/cli.ts';
|
|
3
3
|
export declare const spec: {
|
|
4
4
|
readonly name: 'share';
|
|
5
|
-
readonly summary: 'Pre-flight, deploy to production, wait for the build, and check the live URL shows the
|
|
5
|
+
readonly summary: 'Pre-flight, deploy to production, wait for the build, and check the live URL shows the sign-in page. Returns the share details.';
|
|
6
6
|
readonly flags: {
|
|
7
7
|
readonly skip: {
|
|
8
8
|
readonly type: 'list';
|
|
@@ -13,7 +13,7 @@ export declare const spec: {
|
|
|
13
13
|
readonly description: 'Upload this folder with the Vercel CLI even when the project deploys on push.';
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
readonly output: '{ ok, via, deployment, url, gate, share: { url,
|
|
16
|
+
readonly output: '{ ok, via, deployment, url, gate, share: { url, open: [{ title, path, guide? }] }, review, next } or { ok: false, stage, ... }';
|
|
17
17
|
};
|
|
18
18
|
export declare function main({ flags }: Args<typeof spec>): Promise<{
|
|
19
19
|
ok: boolean;
|
|
@@ -42,7 +42,6 @@ export declare function main({ flags }: Args<typeof spec>): Promise<{
|
|
|
42
42
|
} | {
|
|
43
43
|
share: {
|
|
44
44
|
url: string;
|
|
45
|
-
password: string;
|
|
46
45
|
open: {
|
|
47
46
|
title: string;
|
|
48
47
|
path: string;
|
package/dist/scripts/share.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// One command from a passing project to a link that works: the pre-flight,
|
|
4
4
|
// the deploy (a push when the Vercel project is connected to the repo, an
|
|
5
5
|
// upload otherwise), the wait for the build, and a signed-out request that
|
|
6
|
-
// must come back as the
|
|
6
|
+
// must come back as the sign-in page. It ends with what the handover needs.
|
|
7
7
|
import { spawnSync } from 'node:child_process';
|
|
8
8
|
import { existsSync } from 'node:fs';
|
|
9
9
|
import { join } from 'node:path';
|
|
@@ -12,12 +12,12 @@ import { readEnv } from '../server/env.js';
|
|
|
12
12
|
import { DOCS, ROOT } from '../server/paths.js';
|
|
13
13
|
import { prototypes } from './lib/catalog.js';
|
|
14
14
|
import { CliError } from './lib/cli.js';
|
|
15
|
-
import { GATE_REQUEST, gateVerdict, gitConnected, nextStep, plan, productionUrl, } from './lib/deploy.js';
|
|
15
|
+
import { GATE_REQUEST, gateVerdict, gitConnected, nextStep, PROBE_LINK, plan, productionUrl, storeVerdict, } from './lib/deploy.js';
|
|
16
16
|
import { linkedOrg, linkedProject, projectInfo, STORE_ENV, vercel, whoami } from './lib/vercel.js';
|
|
17
17
|
import * as preflight from './preflight.js';
|
|
18
18
|
export const spec = {
|
|
19
19
|
name: 'share',
|
|
20
|
-
summary: 'Pre-flight, deploy to production, wait for the build, and check the live URL shows the
|
|
20
|
+
summary: 'Pre-flight, deploy to production, wait for the build, and check the live URL shows the sign-in page. Returns the share details.',
|
|
21
21
|
flags: {
|
|
22
22
|
skip: {
|
|
23
23
|
type: 'list',
|
|
@@ -28,7 +28,7 @@ export const spec = {
|
|
|
28
28
|
description: 'Upload this folder with the Vercel CLI even when the project deploys on push.',
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
|
-
output: '{ ok, via, deployment, url, gate, share: { url,
|
|
31
|
+
output: '{ ok, via, deployment, url, gate, share: { url, open: [{ title, path, guide? }] }, review, next } or { ok: false, stage, ... }',
|
|
32
32
|
};
|
|
33
33
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
34
34
|
function git(args) {
|
|
@@ -82,16 +82,23 @@ function viaCli() {
|
|
|
82
82
|
throw new CliError('vercel deploy --prod failed.', { stderr: out.stderr.trim().slice(-600) });
|
|
83
83
|
return url;
|
|
84
84
|
}
|
|
85
|
-
/**
|
|
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
|
+
*/
|
|
86
90
|
async function smoke(url) {
|
|
87
91
|
try {
|
|
88
92
|
const res = await fetch(`${url}/`, GATE_REQUEST);
|
|
89
|
-
|
|
93
|
+
const gate = gateVerdict({
|
|
90
94
|
status: res.status,
|
|
91
95
|
location: res.headers.get('location'),
|
|
92
96
|
robots: res.headers.get('x-robots-tag'),
|
|
93
97
|
body: await res.text(),
|
|
94
98
|
});
|
|
99
|
+
if (!gate.ok)
|
|
100
|
+
return gate;
|
|
101
|
+
return storeVerdict((await fetch(`${url}${PROBE_LINK}`, GATE_REQUEST)).status);
|
|
95
102
|
}
|
|
96
103
|
catch (error) {
|
|
97
104
|
return {
|
|
@@ -122,7 +129,7 @@ function target() {
|
|
|
122
129
|
const project = linkedProject(ROOT);
|
|
123
130
|
if (!project)
|
|
124
131
|
throw new CliError('This folder is not linked to a Vercel project.', {
|
|
125
|
-
fix: 'design-hub bootstrap --vercel <project> --team <team>',
|
|
132
|
+
fix: 'design-hub bootstrap --vercel <project> --team <team> --review',
|
|
126
133
|
});
|
|
127
134
|
return { project, scope: linkedOrg(ROOT) };
|
|
128
135
|
}
|
|
@@ -149,15 +156,16 @@ async function deploy(route, project, scope) {
|
|
|
149
156
|
return { via: 'git', deployment: await viaGit(project, scope, route.branch) };
|
|
150
157
|
return { via: 'cli', deployment: viaCli() };
|
|
151
158
|
}
|
|
159
|
+
/** People sign in with their own one-time links, so the handover carries no secret, only who to add. */
|
|
152
160
|
function handover(url) {
|
|
153
161
|
const env = readEnv(ROOT);
|
|
154
162
|
const review = STORE_ENV.every((n) => env[n]) ? 'on' : 'off';
|
|
155
163
|
return {
|
|
156
|
-
share: { url,
|
|
164
|
+
share: { url, open: opens() },
|
|
157
165
|
review,
|
|
158
166
|
next: review === 'on'
|
|
159
|
-
? `
|
|
160
|
-
: '
|
|
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.',
|
|
161
169
|
};
|
|
162
170
|
}
|
|
163
171
|
export async function main({ flags }) {
|
package/dist/server/api.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ export type Deployed = {
|
|
|
16
16
|
} | {
|
|
17
17
|
error: string;
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The review service as deployed: Upstash for the store, Jev for triage when
|
|
21
|
+
* its key is set and `checks` is given. `now` is the clock, so the gate and
|
|
22
|
+
* the service it asks run on one (the gate's tests move it).
|
|
23
|
+
*/
|
|
24
|
+
export declare function deployedReview(env: Record<string, string | undefined>, checks?: Checks | null, now?: () => Date): Deployed;
|
|
21
25
|
/** The Vercel function's whole body; `checks` is the project's checks.json, bundled by its api/review.ts. */
|
|
22
26
|
export declare function deployedHandler(request: Request, checks: Checks | null): Promise<Response>;
|