@milesroxas/design-hub 0.4.2 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,6 +56,12 @@ export declare function ensurePort(): {
|
|
|
56
56
|
claimed: boolean;
|
|
57
57
|
warnings: string[];
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Runs `steps` and then puts .gitignore back as `restoreGitignore` says, even
|
|
61
|
+
* when a step throws: `vercel link` appends to it, and a later failure (the
|
|
62
|
+
* Upstash terms, most often) would otherwise leave the tree dirty.
|
|
63
|
+
*/
|
|
64
|
+
export declare function keepingGitignore<T>(dir: string, steps: () => T): T;
|
|
59
65
|
/** The gate's values: the password given, kept, or made, and the secret kept or made. */
|
|
60
66
|
export declare function gateValues(given: string | undefined, env: Record<string, string>): {
|
|
61
67
|
password: string;
|
|
@@ -178,14 +178,27 @@ function link(project, team, warnings) {
|
|
|
178
178
|
warnings.push(`.vercel/project.json pointed at ${current}; relinked to ${project}.`);
|
|
179
179
|
// A new project is created in the scope given; without one the CLI's current team wins, which
|
|
180
180
|
// is whichever team the user last switched to, not necessarily where this project belongs.
|
|
181
|
-
const gitignore = join(ROOT, '.gitignore');
|
|
182
|
-
const before = existsSync(gitignore) ? readFileSync(gitignore, 'utf8') : '';
|
|
183
181
|
cli(['link', '--yes', '--project', project, ...(team ? ['--scope', team] : [])]);
|
|
184
|
-
const kept = restoreGitignore(before, existsSync(gitignore) ? readFileSync(gitignore, 'utf8') : '');
|
|
185
|
-
if (kept !== null)
|
|
186
|
-
writeFileSync(gitignore, kept);
|
|
187
182
|
return 'ran';
|
|
188
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Runs `steps` and then puts .gitignore back as `restoreGitignore` says, even
|
|
186
|
+
* when a step throws: `vercel link` appends to it, and a later failure (the
|
|
187
|
+
* Upstash terms, most often) would otherwise leave the tree dirty.
|
|
188
|
+
*/
|
|
189
|
+
export function keepingGitignore(dir, steps) {
|
|
190
|
+
const file = join(dir, '.gitignore');
|
|
191
|
+
const read = () => (existsSync(file) ? readFileSync(file, 'utf8') : '');
|
|
192
|
+
const before = read();
|
|
193
|
+
try {
|
|
194
|
+
return steps();
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
const kept = restoreGitignore(before, read());
|
|
198
|
+
if (kept !== null)
|
|
199
|
+
writeFileSync(file, kept);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
189
202
|
/** The `origin` remote, or null when the project has none. */
|
|
190
203
|
function origin() {
|
|
191
204
|
const out = spawnSync('git', ['-C', ROOT, 'remote', 'get-url', 'origin'], { encoding: 'utf8' });
|
|
@@ -387,8 +400,9 @@ export function main({ flags }) {
|
|
|
387
400
|
};
|
|
388
401
|
if (flags.conductor)
|
|
389
402
|
result.conductor = writeConductor(flags.branch, warnings);
|
|
390
|
-
|
|
391
|
-
|
|
403
|
+
const project = flags.vercel;
|
|
404
|
+
if (project)
|
|
405
|
+
Object.assign(result, keepingGitignore(ROOT, () => setUpVercel(project, flags, env, typesafeKey, warnings)));
|
|
392
406
|
envIgnored(warnings);
|
|
393
407
|
return { ...result, warnings };
|
|
394
408
|
}
|
|
@@ -44,6 +44,17 @@ export type Plan = {
|
|
|
44
44
|
* neither would deploy what is on disk.
|
|
45
45
|
*/
|
|
46
46
|
export declare function plan(repo: Repo, forceCli: boolean): Plan;
|
|
47
|
+
/**
|
|
48
|
+
* How `design-hub share` asks for the home page: as a browser does. The gate
|
|
49
|
+
* answers a client that does not accept HTML with a plain-text 401, which has
|
|
50
|
+
* no password form to find.
|
|
51
|
+
*/
|
|
52
|
+
export declare const GATE_REQUEST: {
|
|
53
|
+
readonly redirect: 'manual';
|
|
54
|
+
readonly headers: {
|
|
55
|
+
readonly accept: 'text/html,application/xhtml+xml';
|
|
56
|
+
};
|
|
57
|
+
};
|
|
47
58
|
export type Answer = {
|
|
48
59
|
status: number;
|
|
49
60
|
location: string | null;
|
|
@@ -38,6 +38,15 @@ export function plan(repo, forceCli) {
|
|
|
38
38
|
};
|
|
39
39
|
return { via: 'git', branch: repo.productionBranch };
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* How `design-hub share` asks for the home page: as a browser does. The gate
|
|
43
|
+
* answers a client that does not accept HTML with a plain-text 401, which has
|
|
44
|
+
* no password form to find.
|
|
45
|
+
*/
|
|
46
|
+
export const GATE_REQUEST = {
|
|
47
|
+
redirect: 'manual',
|
|
48
|
+
headers: { accept: 'text/html,application/xhtml+xml' },
|
|
49
|
+
};
|
|
41
50
|
/** Whether the production URL answers a signed-out visitor with the hub's password page. */
|
|
42
51
|
export function gateVerdict(answer) {
|
|
43
52
|
if (answer.status >= 300 && answer.status < 400 && /vercel\.com/.test(answer.location ?? ''))
|
|
@@ -52,12 +61,18 @@ export function gateVerdict(answer) {
|
|
|
52
61
|
problem: 'The gate answers 503: GATE_PASSWORD or GATE_SECRET is missing on the deployment.',
|
|
53
62
|
fix: 'design-hub bootstrap --vercel <project>, then deploy again so the env reaches the site.',
|
|
54
63
|
};
|
|
55
|
-
if (answer.status !== 401
|
|
64
|
+
if (answer.status !== 401)
|
|
56
65
|
return {
|
|
57
66
|
ok: false,
|
|
58
67
|
problem: `Expected the password page (401), got ${answer.status}.`,
|
|
59
68
|
fix: 'Check that proxy.ts and vercel.json are the template’s, then deploy again.',
|
|
60
69
|
};
|
|
70
|
+
if (!/name="password"/.test(answer.body))
|
|
71
|
+
return {
|
|
72
|
+
ok: false,
|
|
73
|
+
problem: `The site answered 401, but the body was not the password page: ${JSON.stringify(answer.body.replace(/\s+/g, ' ').trim().slice(0, 80))}.`,
|
|
74
|
+
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
|
+
};
|
|
61
76
|
if (!/noindex/.test(answer.robots ?? ''))
|
|
62
77
|
return {
|
|
63
78
|
ok: false,
|
package/dist/scripts/share.js
CHANGED
|
@@ -12,7 +12,7 @@ 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 { gateVerdict, gitConnected, nextStep, plan, productionUrl, } from './lib/deploy.js';
|
|
15
|
+
import { GATE_REQUEST, gateVerdict, gitConnected, nextStep, plan, productionUrl, } 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 = {
|
|
@@ -85,7 +85,7 @@ function viaCli() {
|
|
|
85
85
|
/** A signed-out request for the home page, the way a reviewer first meets the link. */
|
|
86
86
|
async function smoke(url) {
|
|
87
87
|
try {
|
|
88
|
-
const res = await fetch(`${url}/`,
|
|
88
|
+
const res = await fetch(`${url}/`, GATE_REQUEST);
|
|
89
89
|
return gateVerdict({
|
|
90
90
|
status: res.status,
|
|
91
91
|
location: res.headers.get('location'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milesroxas/design-hub",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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": {
|