@milesroxas/design-hub 0.2.0 → 0.4.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 +1 -1
- package/core/catalog.test.ts +10 -1
- package/core/catalog.ts +11 -0
- package/core/cms.test.ts +103 -0
- package/core/cms.ts +178 -0
- package/core/export.test.ts +127 -0
- package/core/export.ts +120 -0
- package/core/formats.ts +60 -0
- package/core/project.test.ts +71 -0
- package/core/project.ts +147 -0
- package/dist/core/catalog.d.ts +5 -0
- package/dist/core/catalog.js +10 -0
- package/dist/core/cms.d.ts +40 -0
- package/dist/core/cms.js +141 -0
- package/dist/core/export.d.ts +52 -0
- package/dist/core/export.js +84 -0
- package/dist/core/formats.d.ts +90 -0
- package/dist/core/formats.js +39 -0
- package/dist/core/project.d.ts +56 -0
- package/dist/core/project.js +121 -0
- package/dist/scripts/bootstrap.d.ts +1 -1
- package/dist/scripts/bootstrap.js +38 -6
- package/dist/scripts/cli.js +8 -0
- package/dist/scripts/commands.js +8 -0
- package/dist/scripts/export.d.ts +42 -0
- package/dist/scripts/export.js +192 -0
- package/dist/scripts/fixtures-pull.d.ts +31 -19
- package/dist/scripts/fixtures-pull.js +102 -62
- package/dist/scripts/lib/cdp.d.ts +11 -0
- package/dist/scripts/lib/cdp.js +110 -0
- package/dist/scripts/lib/deploy.d.ts +76 -0
- package/dist/scripts/lib/deploy.js +94 -0
- package/dist/scripts/lib/vercel.d.ts +5 -0
- package/dist/scripts/lib/vercel.js +24 -0
- package/dist/scripts/new.d.ts +13 -1
- package/dist/scripts/new.js +43 -4
- package/dist/scripts/share.d.ts +63 -0
- package/dist/scripts/share.js +181 -0
- package/dist/scripts/signin.d.ts +31 -0
- package/dist/scripts/signin.js +119 -0
- package/dist/scripts/tracks.d.ts +40 -0
- package/dist/scripts/tracks.js +93 -0
- package/dist/server/paths.d.ts +2 -0
- package/dist/server/paths.js +2 -0
- package/dist/server/project.d.ts +7 -0
- package/dist/server/project.js +29 -0
- package/kit/Artboard.tsx +160 -0
- package/kit/artboard.css +47 -0
- package/kit/dials.tsx +2 -1
- package/package.json +1 -1
- package/shell/Index.tsx +49 -4
- package/shell/main.tsx +6 -2
- package/shell/shell.css +7 -3
- package/skills/miles-brand/SKILL.md +52 -0
- package/skills/miles-deploy/SKILL.md +26 -19
- package/skills/miles-design-hub/SKILL.md +77 -25
- package/skills/miles-get-hostile/SKILL.md +7 -5
- package/skills/miles-new-feature/SKILL.md +8 -7
- package/skills/miles-port/SKILL.md +14 -2
- package/skills/miles-port/references/emdash.md +43 -0
- package/skills/miles-port/references/payload.md +31 -0
- package/skills/miles-port/references/wordpress.md +31 -0
- package/skills/miles-prototype/SKILL.md +2 -2
- package/templates/app/README.md +1 -0
- package/templates/brand/README.md +48 -0
- package/templates/brand/index.tsx +16 -0
- package/templates/brand/styles.css +5 -0
- package/templates/site/README.md +42 -0
- package/templates/site/index.tsx +22 -0
- package/templates/site/styles.css +6 -0
- package/templates/space/README.md +1 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export type Output = 'png' | 'pdf';
|
|
2
|
+
export type Format = {
|
|
3
|
+
label: string;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
output: Output;
|
|
7
|
+
/** The CSS page size for PDF; pixel formats print at their pixel size. */
|
|
8
|
+
page?: string;
|
|
9
|
+
/** Bands a platform's own interface covers; type and logos stay out of them. */
|
|
10
|
+
safe?: {
|
|
11
|
+
top: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare const FORMATS: {
|
|
16
|
+
readonly 'post-square': {
|
|
17
|
+
readonly label: 'Post, square';
|
|
18
|
+
readonly width: 1080;
|
|
19
|
+
readonly height: 1080;
|
|
20
|
+
readonly output: 'png';
|
|
21
|
+
};
|
|
22
|
+
readonly 'post-portrait': {
|
|
23
|
+
readonly label: 'Post, portrait';
|
|
24
|
+
readonly width: 1080;
|
|
25
|
+
readonly height: 1350;
|
|
26
|
+
readonly output: 'png';
|
|
27
|
+
};
|
|
28
|
+
readonly story: {
|
|
29
|
+
readonly label: 'Story';
|
|
30
|
+
readonly width: 1080;
|
|
31
|
+
readonly height: 1920;
|
|
32
|
+
readonly output: 'png';
|
|
33
|
+
readonly safe: {
|
|
34
|
+
readonly top: 250;
|
|
35
|
+
readonly bottom: 250;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly 'link-preview': {
|
|
39
|
+
readonly label: 'Link preview';
|
|
40
|
+
readonly width: 1200;
|
|
41
|
+
readonly height: 630;
|
|
42
|
+
readonly output: 'png';
|
|
43
|
+
};
|
|
44
|
+
readonly banner: {
|
|
45
|
+
readonly label: 'Banner';
|
|
46
|
+
readonly width: 1584;
|
|
47
|
+
readonly height: 396;
|
|
48
|
+
readonly output: 'png';
|
|
49
|
+
};
|
|
50
|
+
readonly slide: {
|
|
51
|
+
readonly label: 'Slide';
|
|
52
|
+
readonly width: 1920;
|
|
53
|
+
readonly height: 1080;
|
|
54
|
+
readonly output: 'pdf';
|
|
55
|
+
};
|
|
56
|
+
readonly a4: {
|
|
57
|
+
readonly label: 'A4';
|
|
58
|
+
readonly width: 794;
|
|
59
|
+
readonly height: 1123;
|
|
60
|
+
readonly output: 'pdf';
|
|
61
|
+
readonly page: '210mm 297mm';
|
|
62
|
+
};
|
|
63
|
+
readonly letter: {
|
|
64
|
+
readonly label: 'Letter';
|
|
65
|
+
readonly width: 816;
|
|
66
|
+
readonly height: 1056;
|
|
67
|
+
readonly output: 'pdf';
|
|
68
|
+
readonly page: '8.5in 11in';
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export type FormatName = keyof typeof FORMATS;
|
|
72
|
+
export declare const FORMAT_NAMES: FormatName[];
|
|
73
|
+
export declare const isFormat: (v: unknown) => v is FormatName;
|
|
74
|
+
/** `1080 × 1350`, as a label under an artboard. */
|
|
75
|
+
export declare const sizeLabel: (name: FormatName) => string;
|
|
76
|
+
/** The CSS `@page` size a format prints at: its paper size, or its pixel size. */
|
|
77
|
+
export declare const pageSize: (name: FormatName) => string;
|
|
78
|
+
/** The screen scale for the Board's zoom dial: `fit`, or a percentage. */
|
|
79
|
+
export declare function zoomFor(zoom: string, name: FormatName, room: {
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
}): number;
|
|
83
|
+
/**
|
|
84
|
+
* How large an artboard draws on screen: its real size at most, else what
|
|
85
|
+
* fits the board's width and a comfortable height. Export always draws at 1.
|
|
86
|
+
*/
|
|
87
|
+
export declare function fitZoom(name: FormatName, room: {
|
|
88
|
+
width: number;
|
|
89
|
+
height: number;
|
|
90
|
+
}): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// The fixed sizes brand collateral is made in. An artboard is designed at its
|
|
2
|
+
// real pixel size, so type and spacing are the values that ship, and
|
|
3
|
+
// `design-hub export` writes it at that size: PNG for anything posted, PDF for
|
|
4
|
+
// anything presented or printed. One list for the kit (the browser) and the
|
|
5
|
+
// export command (Node).
|
|
6
|
+
export const FORMATS = {
|
|
7
|
+
'post-square': { label: 'Post, square', width: 1080, height: 1080, output: 'png' },
|
|
8
|
+
'post-portrait': { label: 'Post, portrait', width: 1080, height: 1350, output: 'png' },
|
|
9
|
+
story: { label: 'Story', width: 1080, height: 1920, output: 'png', safe: { top: 250, bottom: 250 } },
|
|
10
|
+
'link-preview': { label: 'Link preview', width: 1200, height: 630, output: 'png' },
|
|
11
|
+
banner: { label: 'Banner', width: 1584, height: 396, output: 'png' },
|
|
12
|
+
slide: { label: 'Slide', width: 1920, height: 1080, output: 'pdf' },
|
|
13
|
+
a4: { label: 'A4', width: 794, height: 1123, output: 'pdf', page: '210mm 297mm' },
|
|
14
|
+
letter: { label: 'Letter', width: 816, height: 1056, output: 'pdf', page: '8.5in 11in' },
|
|
15
|
+
};
|
|
16
|
+
export const FORMAT_NAMES = Object.keys(FORMATS);
|
|
17
|
+
export const isFormat = (v) => typeof v === 'string' && v in FORMATS;
|
|
18
|
+
/** `1080 × 1350`, as a label under an artboard. */
|
|
19
|
+
export const sizeLabel = (name) => `${FORMATS[name].width} × ${FORMATS[name].height}`;
|
|
20
|
+
/** The CSS `@page` size a format prints at: its paper size, or its pixel size. */
|
|
21
|
+
export const pageSize = (name) => {
|
|
22
|
+
const f = FORMATS[name];
|
|
23
|
+
return f.page ?? `${f.width}px ${f.height}px`;
|
|
24
|
+
};
|
|
25
|
+
/** The screen scale for the Board's zoom dial: `fit`, or a percentage. */
|
|
26
|
+
export function zoomFor(zoom, name, room) {
|
|
27
|
+
if (zoom === 'fit')
|
|
28
|
+
return fitZoom(name, room);
|
|
29
|
+
const percent = Number.parseFloat(zoom);
|
|
30
|
+
return Number.isFinite(percent) && percent > 0 ? percent / 100 : 1;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* How large an artboard draws on screen: its real size at most, else what
|
|
34
|
+
* fits the board's width and a comfortable height. Export always draws at 1.
|
|
35
|
+
*/
|
|
36
|
+
export function fitZoom(name, room) {
|
|
37
|
+
const { width, height } = FORMATS[name];
|
|
38
|
+
return Math.min(1, room.width / width, room.height / height);
|
|
39
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare const TRACKS: readonly ['product', 'website', 'brand'];
|
|
2
|
+
export type Track = (typeof TRACKS)[number];
|
|
3
|
+
export declare const PLATFORMS: readonly ['webflow', 'payload', 'wordpress', 'emdash'];
|
|
4
|
+
export type Platform = (typeof PLATFORMS)[number];
|
|
5
|
+
export declare const FRONTENDS: readonly ['astro', 'next'];
|
|
6
|
+
export type Frontend = (typeof FRONTENDS)[number];
|
|
7
|
+
export type Website = {
|
|
8
|
+
platform: Platform;
|
|
9
|
+
/** The code that renders the site. Absent for Webflow, which renders its own pages. */
|
|
10
|
+
frontend?: Frontend;
|
|
11
|
+
/** Where the site is deployed, when the platform decides it. */
|
|
12
|
+
host?: string;
|
|
13
|
+
};
|
|
14
|
+
export type Project = {
|
|
15
|
+
tracks: Track[];
|
|
16
|
+
website?: Website;
|
|
17
|
+
};
|
|
18
|
+
export declare const TRACK_LABEL: Record<Track, string>;
|
|
19
|
+
/** The website settings a platform and an optional front end make, or the problem with them. */
|
|
20
|
+
export declare function websiteFor(platform: string, frontend?: string): {
|
|
21
|
+
website: Website;
|
|
22
|
+
} | {
|
|
23
|
+
problem: string;
|
|
24
|
+
};
|
|
25
|
+
/** A project from flags or a file: the tracks, and the website when the website track is on. */
|
|
26
|
+
export declare function makeProject(tracks: readonly string[], website?: {
|
|
27
|
+
platform?: string;
|
|
28
|
+
frontend?: string;
|
|
29
|
+
}): {
|
|
30
|
+
project: Project;
|
|
31
|
+
} | {
|
|
32
|
+
problems: string[];
|
|
33
|
+
};
|
|
34
|
+
/** project.json's contents, or the problems with them. A missing file is the caller's case, not this one's. */
|
|
35
|
+
export declare function parseProject(raw: unknown): {
|
|
36
|
+
project: Project;
|
|
37
|
+
} | {
|
|
38
|
+
problems: string[];
|
|
39
|
+
};
|
|
40
|
+
/** Whether the website track still needs its platform. Setup asks for it; the port refuses to start without it. */
|
|
41
|
+
export declare const needsPlatform: (p: Project) => boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The track a new prototype belongs to: the one asked for, else the
|
|
44
|
+
* project's only track. A project with no tracks recorded (made before
|
|
45
|
+
* tracks existed) takes any.
|
|
46
|
+
*/
|
|
47
|
+
export declare function trackFor(project: Project | null, asked?: string): {
|
|
48
|
+
track: Track | '';
|
|
49
|
+
} | {
|
|
50
|
+
problem: string;
|
|
51
|
+
};
|
|
52
|
+
/** The samples to remove when a project keeps only these tracks. */
|
|
53
|
+
export declare const samplesOutside: (tracks: readonly Track[]) => {
|
|
54
|
+
slug: string;
|
|
55
|
+
feature: string;
|
|
56
|
+
}[];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// What kind of engagement a project is: its tracks, and for a website the
|
|
2
|
+
// platform it ships on. A studio works three ways, often at once: a product
|
|
3
|
+
// (designed here, handed to the client's engineers as a spec), a website
|
|
4
|
+
// (built on a CMS and a front end), and brand collateral (fixed-size
|
|
5
|
+
// templates: social posts, slides, print). The answer lives in
|
|
6
|
+
// .design-hub/project.json, so `new`, the hub, the port and every agent read
|
|
7
|
+
// one file instead of guessing from prose. Pure: callers read and write it.
|
|
8
|
+
export const TRACKS = ['product', 'website', 'brand'];
|
|
9
|
+
export const PLATFORMS = ['webflow', 'payload', 'wordpress', 'emdash'];
|
|
10
|
+
export const FRONTENDS = ['astro', 'next'];
|
|
11
|
+
export const TRACK_LABEL = {
|
|
12
|
+
product: 'Product',
|
|
13
|
+
website: 'Website',
|
|
14
|
+
brand: 'Brand',
|
|
15
|
+
};
|
|
16
|
+
const PLATFORM_LABEL = {
|
|
17
|
+
webflow: 'Webflow',
|
|
18
|
+
payload: 'Payload CMS',
|
|
19
|
+
wordpress: 'WordPress',
|
|
20
|
+
emdash: 'EmDash',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* What each platform fixes. Webflow renders its own pages; EmDash is built
|
|
24
|
+
* on Astro and deployed to Cloudflare; Payload and WordPress are headless
|
|
25
|
+
* here, so the front end is a choice.
|
|
26
|
+
*/
|
|
27
|
+
const PLATFORM_RULES = {
|
|
28
|
+
webflow: { frontend: null, host: 'webflow' },
|
|
29
|
+
emdash: { frontend: 'astro', host: 'cloudflare' },
|
|
30
|
+
payload: { frontend: 'choose' },
|
|
31
|
+
wordpress: { frontend: 'choose' },
|
|
32
|
+
};
|
|
33
|
+
/** The sample prototype and walkthrough feature each track ships with, so setup can drop the ones a project does not use. */
|
|
34
|
+
const SAMPLES = {
|
|
35
|
+
product: { slug: 'sample-list', feature: 'sample' },
|
|
36
|
+
website: { slug: 'sample-page', feature: 'sample-site' },
|
|
37
|
+
brand: { slug: 'sample-social', feature: 'sample-brand' },
|
|
38
|
+
};
|
|
39
|
+
const isTrack = (v) => TRACKS.includes(v);
|
|
40
|
+
const isPlatform = (v) => PLATFORMS.includes(v);
|
|
41
|
+
const isFrontend = (v) => FRONTENDS.includes(v);
|
|
42
|
+
/** Tracks in their canonical order, without repeats. */
|
|
43
|
+
const ordered = (tracks) => TRACKS.filter((t) => tracks.includes(t));
|
|
44
|
+
/** The website settings a platform and an optional front end make, or the problem with them. */
|
|
45
|
+
export function websiteFor(platform, frontend) {
|
|
46
|
+
if (!isPlatform(platform))
|
|
47
|
+
return { problem: `The platform is one of: ${PLATFORMS.join(', ')}.` };
|
|
48
|
+
const rule = PLATFORM_RULES[platform];
|
|
49
|
+
const host = rule.host ? { host: rule.host } : {};
|
|
50
|
+
if (rule.frontend === 'choose') {
|
|
51
|
+
if (!frontend)
|
|
52
|
+
return { problem: `${PLATFORM_LABEL[platform]} needs a front end: ${FRONTENDS.join(' or ')}.` };
|
|
53
|
+
if (!isFrontend(frontend))
|
|
54
|
+
return { problem: `The front end is one of: ${FRONTENDS.join(', ')}.` };
|
|
55
|
+
return { website: { platform, frontend, ...host } };
|
|
56
|
+
}
|
|
57
|
+
if (frontend && frontend !== rule.frontend)
|
|
58
|
+
return {
|
|
59
|
+
problem: rule.frontend
|
|
60
|
+
? `${PLATFORM_LABEL[platform]} always uses ${rule.frontend}.`
|
|
61
|
+
: `${PLATFORM_LABEL[platform]} renders its own pages; it takes no front end.`,
|
|
62
|
+
};
|
|
63
|
+
return { website: { platform, ...(rule.frontend ? { frontend: rule.frontend } : {}), ...host } };
|
|
64
|
+
}
|
|
65
|
+
/** A project from flags or a file: the tracks, and the website when the website track is on. */
|
|
66
|
+
export function makeProject(tracks, website) {
|
|
67
|
+
const problems = [];
|
|
68
|
+
const unknown = tracks.filter((t) => !isTrack(t));
|
|
69
|
+
if (unknown.length)
|
|
70
|
+
problems.push(`Unknown track: ${unknown.join(', ')}. Tracks: ${TRACKS.join(', ')}.`);
|
|
71
|
+
const chosen = ordered(tracks.filter(isTrack));
|
|
72
|
+
if (!chosen.length && !unknown.length)
|
|
73
|
+
problems.push(`Pick at least one track: ${TRACKS.join(', ')}.`);
|
|
74
|
+
const project = { tracks: chosen };
|
|
75
|
+
if (chosen.includes('website') && website?.platform) {
|
|
76
|
+
const made = websiteFor(website.platform, website.frontend);
|
|
77
|
+
if ('problem' in made)
|
|
78
|
+
problems.push(made.problem);
|
|
79
|
+
else
|
|
80
|
+
project.website = made.website;
|
|
81
|
+
}
|
|
82
|
+
else if (!chosen.includes('website') && (website?.platform || website?.frontend)) {
|
|
83
|
+
problems.push('A platform or front end needs the website track.');
|
|
84
|
+
}
|
|
85
|
+
return problems.length ? { problems } : { project };
|
|
86
|
+
}
|
|
87
|
+
/** project.json's contents, or the problems with them. A missing file is the caller's case, not this one's. */
|
|
88
|
+
export function parseProject(raw) {
|
|
89
|
+
if (!raw || typeof raw !== 'object')
|
|
90
|
+
return { problems: ['project.json is not an object.'] };
|
|
91
|
+
const { tracks, website } = raw;
|
|
92
|
+
if (!Array.isArray(tracks))
|
|
93
|
+
return { problems: ['project.json has no tracks list.'] };
|
|
94
|
+
return makeProject(tracks.map(String), {
|
|
95
|
+
platform: website?.platform ? String(website.platform) : undefined,
|
|
96
|
+
frontend: website?.frontend ? String(website.frontend) : undefined,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** Whether the website track still needs its platform. Setup asks for it; the port refuses to start without it. */
|
|
100
|
+
export const needsPlatform = (p) => p.tracks.includes('website') && !p.website;
|
|
101
|
+
/**
|
|
102
|
+
* The track a new prototype belongs to: the one asked for, else the
|
|
103
|
+
* project's only track. A project with no tracks recorded (made before
|
|
104
|
+
* tracks existed) takes any.
|
|
105
|
+
*/
|
|
106
|
+
export function trackFor(project, asked) {
|
|
107
|
+
if (asked && !isTrack(asked))
|
|
108
|
+
return { problem: `--track is one of: ${TRACKS.join(', ')}.` };
|
|
109
|
+
if (!project)
|
|
110
|
+
return { track: asked ?? '' };
|
|
111
|
+
if (asked) {
|
|
112
|
+
return project.tracks.includes(asked)
|
|
113
|
+
? { track: asked }
|
|
114
|
+
: { problem: `This project has no ${asked} track. It has: ${project.tracks.join(', ')}.` };
|
|
115
|
+
}
|
|
116
|
+
if (project.tracks.length === 1)
|
|
117
|
+
return { track: project.tracks[0] };
|
|
118
|
+
return { problem: `This project has several tracks; name one with --track ${project.tracks.join('|')}.` };
|
|
119
|
+
}
|
|
120
|
+
/** The samples to remove when a project keeps only these tracks. */
|
|
121
|
+
export const samplesOutside = (tracks) => TRACKS.filter((t) => !tracks.includes(t)).map((t) => SAMPLES[t]);
|
|
@@ -42,7 +42,7 @@ export declare const spec: {
|
|
|
42
42
|
readonly description: 'Provision the review store (Upstash Redis) on the Vercel project.';
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
|
-
readonly output: '{ ok, node, port, install, typesafe, conductor?, vercel?, share?, review?, warnings }';
|
|
45
|
+
readonly output: '{ ok, node, port, install, typesafe, conductor?, vercel: { project, linked, git, protection, env }?, share?, review?, warnings }';
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
48
|
* What `design-hub dev`, `open` and `preview` run first, so a fresh clone or
|
|
@@ -11,8 +11,9 @@ import { join } from 'node:path';
|
|
|
11
11
|
import { harnessPort, readEnv, writeEnv } from '../server/env.js';
|
|
12
12
|
import { ROOT, TEMPLATES } from '../server/paths.js';
|
|
13
13
|
import { CliError } from './lib/cli.js';
|
|
14
|
+
import { gitConnected } from './lib/deploy.js';
|
|
14
15
|
import { holderOf, pickPort, readClaims, writeClaim } from './lib/ports.js';
|
|
15
|
-
import { ENVIRONMENTS, envNames, linkedOrg, linkedProject, STORE_ENV, setEnv, vercel, } from './lib/vercel.js';
|
|
16
|
+
import { ENVIRONMENTS, envNames, linkedOrg, linkedProject, projectInfo, STORE_ENV, setEnv, vercel, whoami, } from './lib/vercel.js';
|
|
16
17
|
export const spec = {
|
|
17
18
|
name: 'bootstrap',
|
|
18
19
|
summary: 'Set the project up on this machine, and optionally on Vercel. Safe to run again.',
|
|
@@ -39,7 +40,7 @@ export const spec = {
|
|
|
39
40
|
description: 'Provision the review store (Upstash Redis) on the Vercel project.',
|
|
40
41
|
},
|
|
41
42
|
},
|
|
42
|
-
output: '{ ok, node, port, install, typesafe, conductor?, vercel?, share?, review?, warnings }',
|
|
43
|
+
output: '{ ok, node, port, install, typesafe, conductor?, vercel: { project, linked, git, protection, env }?, share?, review?, warnings }',
|
|
43
44
|
};
|
|
44
45
|
const MIN_NODE = [22, 18];
|
|
45
46
|
const UPSTASH = 'upstash/upstash-kv';
|
|
@@ -164,7 +165,7 @@ function cli(args, input) {
|
|
|
164
165
|
throw new CliError(`vercel ${args.slice(0, 2).join(' ')} failed.`, {
|
|
165
166
|
stderr: out.stderr.trim().slice(-600),
|
|
166
167
|
fix: /log ?in|credentials|token/i.test(out.stderr)
|
|
167
|
-
? '
|
|
168
|
+
? 'design-hub signin, send the user its url, then run this again.'
|
|
168
169
|
: undefined,
|
|
169
170
|
});
|
|
170
171
|
return out.stdout;
|
|
@@ -180,13 +181,39 @@ function link(project, team, warnings) {
|
|
|
180
181
|
cli(['link', '--yes', '--project', project, ...(team ? ['--scope', team] : [])]);
|
|
181
182
|
return 'ran';
|
|
182
183
|
}
|
|
184
|
+
/** The `origin` remote, or null when the project has none. */
|
|
185
|
+
function origin() {
|
|
186
|
+
const out = spawnSync('git', ['-C', ROOT, 'remote', 'get-url', 'origin'], { encoding: 'utf8' });
|
|
187
|
+
return out.status === 0 ? out.stdout.trim() || null : null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Connects the Vercel project to the repo, so pushing the production branch
|
|
191
|
+
* deploys it. Without a remote, or when Vercel cannot reach the repo, it stays
|
|
192
|
+
* unconnected and `design-hub share` uploads the folder instead.
|
|
193
|
+
*/
|
|
194
|
+
function connectGit(project, team, warnings) {
|
|
195
|
+
const remote = origin();
|
|
196
|
+
if (!remote)
|
|
197
|
+
return 'none';
|
|
198
|
+
if (gitConnected(projectInfo(ROOT, project, team ?? linkedOrg(ROOT))))
|
|
199
|
+
return 'kept';
|
|
200
|
+
const out = vercel(ROOT, ['git', 'connect', remote, '--yes']);
|
|
201
|
+
if (out?.status === 0)
|
|
202
|
+
return 'connected';
|
|
203
|
+
warnings.push(`Could not connect ${remote} to the Vercel project, so design-hub share will upload the folder instead of deploying on push. ` +
|
|
204
|
+
'To deploy on push, the user gives Vercel access to the repo at https://github.com/apps/vercel/installations/new, then run this again. ' +
|
|
205
|
+
(out?.stderr.trim().split('\n').pop() ?? ''));
|
|
206
|
+
return 'none';
|
|
207
|
+
}
|
|
183
208
|
/** Sets each value where it is missing; `rotate` names the ones given again, which replace what is there. */
|
|
184
209
|
function ensureEnv(values, rotate) {
|
|
185
210
|
const state = {};
|
|
186
211
|
for (const target of ENVIRONMENTS) {
|
|
187
212
|
const names = envNames(ROOT, target);
|
|
188
213
|
if (!names)
|
|
189
|
-
throw new CliError(`vercel env ls ${target} failed.`, {
|
|
214
|
+
throw new CliError(`vercel env ls ${target} failed.`, {
|
|
215
|
+
fix: 'design-hub signin, then run this again.',
|
|
216
|
+
});
|
|
190
217
|
for (const [name, value] of Object.entries(values)) {
|
|
191
218
|
const key = `${name}:${target}`;
|
|
192
219
|
const exists = names.has(name);
|
|
@@ -257,7 +284,7 @@ function provisionReview(project, team, warnings) {
|
|
|
257
284
|
if (out?.status !== 0)
|
|
258
285
|
throw new CliError('Could not add the Upstash for Redis store.', {
|
|
259
286
|
stderr: out?.stderr.trim().slice(-600),
|
|
260
|
-
fix: `
|
|
287
|
+
fix: `The Marketplace terms need accepting once per team: send the user https://vercel.com/marketplace/upstash to choose Install and accept for this team, then run this again.`,
|
|
261
288
|
});
|
|
262
289
|
store = 'created';
|
|
263
290
|
}
|
|
@@ -293,6 +320,10 @@ export function gateValues(given, env) {
|
|
|
293
320
|
return { password, secret, rotated: given !== undefined && given !== env.GATE_PASSWORD };
|
|
294
321
|
}
|
|
295
322
|
function setUpVercel(project, flags, env, typesafeKey, warnings) {
|
|
323
|
+
if (!whoami(ROOT))
|
|
324
|
+
throw new CliError('The Vercel CLI is not installed or not signed in.', {
|
|
325
|
+
fix: 'design-hub signin, send the user its url, then run this again.',
|
|
326
|
+
});
|
|
296
327
|
const linked = link(project, flags.team, warnings);
|
|
297
328
|
const { password, secret, rotated } = gateValues(flags['gate-password'], env);
|
|
298
329
|
writeEnv(ROOT, { GATE_PASSWORD: password, GATE_SECRET: secret });
|
|
@@ -306,6 +337,7 @@ function setUpVercel(project, flags, env, typesafeKey, warnings) {
|
|
|
306
337
|
vercel: {
|
|
307
338
|
project,
|
|
308
339
|
linked,
|
|
340
|
+
git: connectGit(project, flags.team, warnings),
|
|
309
341
|
protection: protection(project, flags.team),
|
|
310
342
|
env: ensureEnv(values, new Set(rotated ? ['GATE_PASSWORD'] : [])),
|
|
311
343
|
},
|
|
@@ -313,7 +345,7 @@ function setUpVercel(project, flags, env, typesafeKey, warnings) {
|
|
|
313
345
|
};
|
|
314
346
|
if (!flags.review)
|
|
315
347
|
return result;
|
|
316
|
-
warnings.push('
|
|
348
|
+
warnings.push('Run design-hub share so the new env reaches the site; then design-hub people invite --name "<you>" --role editor --site <url>.');
|
|
317
349
|
return { ...result, review: provisionReview(project, flags.team, warnings) };
|
|
318
350
|
}
|
|
319
351
|
function envIgnored(warnings) {
|
package/dist/scripts/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ import * as commands from './commands.js';
|
|
|
13
13
|
import * as comments from './comments.js';
|
|
14
14
|
import * as dev from './dev.js';
|
|
15
15
|
import * as elyx from './elyx.js';
|
|
16
|
+
import * as exportCmd from './export.js';
|
|
16
17
|
import * as fixturesPull from './fixtures-pull.js';
|
|
17
18
|
import * as guard from './guard.js';
|
|
18
19
|
import { HOOKS, runHook } from './hook.js';
|
|
@@ -21,8 +22,11 @@ import * as create from './new.js';
|
|
|
21
22
|
import * as people from './people.js';
|
|
22
23
|
import * as preflight from './preflight.js';
|
|
23
24
|
import * as releaseCheck from './release-check.js';
|
|
25
|
+
import * as share from './share.js';
|
|
26
|
+
import * as signin from './signin.js';
|
|
24
27
|
import * as skillHint from './skill-hint.js';
|
|
25
28
|
import * as skills from './skills.js';
|
|
29
|
+
import * as tracks from './tracks.js';
|
|
26
30
|
import * as visualMatch from './visual-match.js';
|
|
27
31
|
// `guide` is `new --guide`; `open` is `dev` with the browser.
|
|
28
32
|
const COMMANDS = {
|
|
@@ -39,13 +43,17 @@ const COMMANDS = {
|
|
|
39
43
|
check,
|
|
40
44
|
guard,
|
|
41
45
|
preflight,
|
|
46
|
+
signin,
|
|
47
|
+
share,
|
|
42
48
|
people,
|
|
43
49
|
comments,
|
|
44
50
|
calibrate,
|
|
45
51
|
'fixtures-pull': fixturesPull,
|
|
46
52
|
'visual-match': visualMatch,
|
|
47
53
|
elyx,
|
|
54
|
+
export: exportCmd,
|
|
48
55
|
skills,
|
|
56
|
+
tracks,
|
|
49
57
|
'skill-hint': skillHint,
|
|
50
58
|
'release-check': releaseCheck,
|
|
51
59
|
commands,
|
package/dist/scripts/commands.js
CHANGED
|
@@ -9,6 +9,7 @@ import * as check from './check.js';
|
|
|
9
9
|
import * as comments from './comments.js';
|
|
10
10
|
import * as dev from './dev.js';
|
|
11
11
|
import * as elyx from './elyx.js';
|
|
12
|
+
import * as exportCmd from './export.js';
|
|
12
13
|
import * as fixturesPull from './fixtures-pull.js';
|
|
13
14
|
import * as guard from './guard.js';
|
|
14
15
|
import { schema } from './lib/cli.js';
|
|
@@ -16,8 +17,11 @@ import * as create from './new.js';
|
|
|
16
17
|
import * as people from './people.js';
|
|
17
18
|
import * as preflight from './preflight.js';
|
|
18
19
|
import * as releaseCheck from './release-check.js';
|
|
20
|
+
import * as share from './share.js';
|
|
21
|
+
import * as signin from './signin.js';
|
|
19
22
|
import * as skillHint from './skill-hint.js';
|
|
20
23
|
import * as skills from './skills.js';
|
|
24
|
+
import * as tracks from './tracks.js';
|
|
21
25
|
import * as visualMatch from './visual-match.js';
|
|
22
26
|
export const spec = {
|
|
23
27
|
name: 'commands',
|
|
@@ -35,13 +39,17 @@ export const COMMANDS = [
|
|
|
35
39
|
check.spec,
|
|
36
40
|
guard.spec,
|
|
37
41
|
preflight.spec,
|
|
42
|
+
signin.spec,
|
|
43
|
+
share.spec,
|
|
38
44
|
people.spec,
|
|
39
45
|
comments.spec,
|
|
40
46
|
calibrate.spec,
|
|
41
47
|
fixturesPull.spec,
|
|
42
48
|
visualMatch.spec,
|
|
43
49
|
elyx.spec,
|
|
50
|
+
exportCmd.spec,
|
|
44
51
|
skills.spec,
|
|
52
|
+
tracks.spec,
|
|
45
53
|
skillHint.spec,
|
|
46
54
|
releaseCheck.spec,
|
|
47
55
|
spec,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type Args } from './lib/cli.ts';
|
|
3
|
+
export declare const spec: {
|
|
4
|
+
readonly name: 'export';
|
|
5
|
+
readonly summary: "Write a prototype's artboards to files: PNG for posts, PDF for slides and print.";
|
|
6
|
+
readonly positionals: [{
|
|
7
|
+
readonly name: 'prototype';
|
|
8
|
+
readonly description: 'The prototype folder, e.g. sample-social';
|
|
9
|
+
readonly required: true;
|
|
10
|
+
}];
|
|
11
|
+
readonly flags: {
|
|
12
|
+
readonly as: {
|
|
13
|
+
readonly type: 'string';
|
|
14
|
+
readonly choices: readonly ["auto", "png", "pdf"];
|
|
15
|
+
readonly default: 'auto';
|
|
16
|
+
readonly description: "auto: each artboard's format decides. png: every artboard a PNG. pdf: every artboard into one PDF.";
|
|
17
|
+
};
|
|
18
|
+
readonly scale: {
|
|
19
|
+
readonly type: 'number';
|
|
20
|
+
readonly default: 1;
|
|
21
|
+
readonly description: 'PNG pixel density: 1 for the exact size platforms ask for, 2 for retina.';
|
|
22
|
+
};
|
|
23
|
+
readonly dials: {
|
|
24
|
+
readonly type: 'string';
|
|
25
|
+
readonly description: 'The dial state to export, as JSON by panel: {"Review":{"fixtures":"longest"}}. Default: the committed defaults.';
|
|
26
|
+
};
|
|
27
|
+
readonly theme: {
|
|
28
|
+
readonly type: 'string';
|
|
29
|
+
readonly choices: readonly ["light", "dark"];
|
|
30
|
+
readonly description: 'The theme, when the artboards follow it.';
|
|
31
|
+
};
|
|
32
|
+
readonly out: {
|
|
33
|
+
readonly type: 'string';
|
|
34
|
+
readonly description: 'Folder for the files. Default: exports/<prototype>/.';
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
readonly output: '{ ok, files: [path], artboards }';
|
|
38
|
+
};
|
|
39
|
+
export declare function main({ positionals: [slug], flags }: Args<typeof spec>): Promise<{
|
|
40
|
+
files: string[];
|
|
41
|
+
artboards: number;
|
|
42
|
+
}>;
|