@sbuilder/cli 0.9.1 → 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 +247 -6
- package/README.vi.md +241 -7
- package/dist/bin/sb.js +141 -6
- package/dist/bin/sb.js.map +1 -1
- package/dist/src/agentdocs.js +12 -3
- package/dist/src/agentdocs.js.map +1 -1
- package/dist/src/doctor.js +516 -0
- package/dist/src/doctor.js.map +1 -0
- package/dist/src/envtypes.gen.js +1748 -0
- package/dist/src/envtypes.gen.js.map +1 -0
- package/dist/src/host.js +414 -22
- package/dist/src/host.js.map +1 -1
- package/dist/src/hostlink.js +161 -0
- package/dist/src/hostlink.js.map +1 -0
- package/dist/src/login.js +1 -1
- package/dist/src/login.js.map +1 -1
- package/dist/src/next.js +82 -6
- package/dist/src/next.js.map +1 -1
- package/dist/src/repo.js +24 -2
- package/dist/src/repo.js.map +1 -1
- package/dist/src/roottsconfig.js +154 -0
- package/dist/src/roottsconfig.js.map +1 -0
- package/dist/src/route.js +16 -1
- package/dist/src/route.js.map +1 -1
- package/dist/src/site.js +615 -71
- package/dist/src/site.js.map +1 -1
- package/dist/src/sitedev.js +99 -0
- package/dist/src/sitedev.js.map +1 -0
- package/dist/src/siteinit.js +76 -0
- package/dist/src/siteinit.js.map +1 -1
- package/dist/src/sitekinds.js +1048 -0
- package/dist/src/sitekinds.js.map +1 -0
- package/dist/src/sitepaths.js +12 -0
- package/dist/src/sitepaths.js.map +1 -0
- package/dist/src/sitestatus.js +104 -0
- package/dist/src/sitestatus.js.map +1 -0
- package/dist/src/source/meta.js +118 -0
- package/dist/src/source/meta.js.map +1 -0
- package/dist/src/source/parse.js +21 -2
- package/dist/src/source/parse.js.map +1 -1
- package/dist/src/starter.js +61 -0
- package/dist/src/starter.js.map +1 -0
- package/dist/src/vercel.js +379 -0
- package/dist/src/vercel.js.map +1 -0
- package/package.json +9 -1
- package/dist/src/export.js +0 -167
- package/dist/src/export.js.map +0 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createHmac, randomBytes } from 'node:crypto';
|
|
2
|
+
import { lstat, readFile, rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { isIP } from 'node:net';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { authedFetch } from './auth.js';
|
|
6
|
+
import { DevError, messageOf } from './dev.js';
|
|
7
|
+
/** The X-SB-Host value for one request. `now` is injectable so skew is testable. */
|
|
8
|
+
export function signHost(secret, siteId, method, requestUri, clientIp, now = Date.now()) {
|
|
9
|
+
const unix = String(Math.floor(now / 1000));
|
|
10
|
+
const mac = createHmac('sha256', secret)
|
|
11
|
+
.update(`${unix}|${method.toUpperCase()}|${requestUri}|${clientIp}`)
|
|
12
|
+
.digest('hex');
|
|
13
|
+
return `${siteId}.${unix}.${mac}`;
|
|
14
|
+
}
|
|
15
|
+
/** A visitor address worth signing: a plain IPv4 or IPv6 literal, nothing else. */
|
|
16
|
+
export function validIp(ip) {
|
|
17
|
+
return !!ip && !ip.includes('%') && isIP(ip) !== 0;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The visitor's address, or undefined when there is no source this host may trust.
|
|
21
|
+
*
|
|
22
|
+
* TRUST ASSUMPTION, stated because a forged address buys a forged rate bucket:
|
|
23
|
+
*
|
|
24
|
+
* - On VERCEL (`VERCEL=1`) the platform OVERWRITES `x-forwarded-for` with what it saw, so the
|
|
25
|
+
* FIRST hop is the visitor — nothing the client sent survives.
|
|
26
|
+
* - Anywhere else the header is whatever the client sent, and a proxy that APPENDS puts the
|
|
27
|
+
* address it saw on the RIGHT: the leftmost hop is visitor-controlled. So with
|
|
28
|
+
* `SB_TRUST_PROXY=N` (N proxies YOU control sit in front of this host; `1` is the usual case)
|
|
29
|
+
* the visitor is the Nth hop from the RIGHT. Fewer hops than that means the chain is not what
|
|
30
|
+
* was declared, and nothing is signed.
|
|
31
|
+
* - Without either there is no trustworthy address, and the request is forwarded unsigned (the
|
|
32
|
+
* store then sees the host, as it always did).
|
|
33
|
+
*/
|
|
34
|
+
export function clientIpOf(request, env = process.env) {
|
|
35
|
+
const hops = (request.headers.get('x-forwarded-for') ?? '')
|
|
36
|
+
.split(',')
|
|
37
|
+
.map((h) => h.trim())
|
|
38
|
+
.filter(Boolean);
|
|
39
|
+
if (env.VERCEL === '1')
|
|
40
|
+
return hops[0];
|
|
41
|
+
const n = Number(env.SB_TRUST_PROXY);
|
|
42
|
+
if (!Number.isInteger(n) || n < 1)
|
|
43
|
+
return undefined;
|
|
44
|
+
// Fewer hops than declared: the index falls off the left end (undefined) — the chain is not what was said.
|
|
45
|
+
return hops[hops.length - n];
|
|
46
|
+
}
|
|
47
|
+
/** The two headers to add to a forwarded request, or undefined when it cannot be signed. */
|
|
48
|
+
export function hostHeaders(request, method, requestUri, env = process.env, now) {
|
|
49
|
+
const secret = env.SB_HOST_SECRET;
|
|
50
|
+
const site = env.SB_SITE_ID;
|
|
51
|
+
if (!secret || !site)
|
|
52
|
+
return undefined;
|
|
53
|
+
const ip = clientIpOf(request, env);
|
|
54
|
+
if (!validIp(ip))
|
|
55
|
+
return undefined;
|
|
56
|
+
return {
|
|
57
|
+
'x-sb-host': signHost(secret, site, method, requestUri, ip, now),
|
|
58
|
+
'x-sb-client-ip': ip,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Sets KEY=value lines in an env file's text, keeping every other line as it was. */
|
|
62
|
+
export function setEnv(text, values) {
|
|
63
|
+
const lines = text.split('\n');
|
|
64
|
+
const done = new Set();
|
|
65
|
+
const out = lines.map((l) => {
|
|
66
|
+
const m = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(l);
|
|
67
|
+
if (m && m[1] in values) {
|
|
68
|
+
done.add(m[1]);
|
|
69
|
+
return `${m[1]}=${values[m[1]]}`;
|
|
70
|
+
}
|
|
71
|
+
return l;
|
|
72
|
+
});
|
|
73
|
+
while (out.length && out[out.length - 1] === '')
|
|
74
|
+
out.pop();
|
|
75
|
+
for (const k of Object.keys(values))
|
|
76
|
+
if (!done.has(k))
|
|
77
|
+
out.push(`${k}=${values[k]}`);
|
|
78
|
+
return out.join('\n') + '\n';
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Mints (or rotates) this site's host secret and writes it, with the site id, into the repo's
|
|
82
|
+
* `.env` (0600, git-ignored). The secret is shown by the platform ONCE, here, and is not printed:
|
|
83
|
+
* it goes to the file, and from there into the host's environment (README: "Deploy on Vercel").
|
|
84
|
+
*/
|
|
85
|
+
export async function linkHost(o) {
|
|
86
|
+
const log = o.log ?? console.log;
|
|
87
|
+
if (!o.token || typeof o.token !== 'string' || !o.token.startsWith('wbk_'))
|
|
88
|
+
throw new DevError('The host link is minted with the repo’s API key (wbk_…, pages.write): run this inside a repo made by `sb site init`, or set SB_TOKEN to such a key.');
|
|
89
|
+
const envPath = join(o.dir, '.env');
|
|
90
|
+
// .env is read, then rewritten with its contents: through a link planted in a cloned repo
|
|
91
|
+
// (.env -> ~/.aws/credentials) that would copy a foreign file into the real one.
|
|
92
|
+
if ((await lstat(envPath).catch(() => undefined))?.isSymbolicLink())
|
|
93
|
+
throw new DevError('.env is a symbolic link: refusing to read or replace it (a cloned repo could point it at another file). Remove the link and run again.');
|
|
94
|
+
const have = await readFile(envPath, 'utf8').catch(() => '');
|
|
95
|
+
const url = `${o.api}/api/v1/host-link`;
|
|
96
|
+
const call = async (method) => {
|
|
97
|
+
try {
|
|
98
|
+
return await authedFetch(url, { method }, o.token);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
throw new DevError(`Could not reach ${new URL(o.api).origin}: ${messageOf(err)}. Check SB_API.`);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
// A secret already in .env — or a link on the platform that another machine or CI made: minting
|
|
105
|
+
// replaces it at once, and the deployed host holding the current one stops being believed. That is
|
|
106
|
+
// a decision, not a side effect, so it is asked before anything is written.
|
|
107
|
+
const inEnv = /^\s*(?:export\s+)?SB_HOST_SECRET\s*=\s*\S/m.test(have);
|
|
108
|
+
let onPlatform = false;
|
|
109
|
+
if (!inEnv && !o.yes) {
|
|
110
|
+
// Only 404 means "no link": a 403 or a 5xx says nothing, and rotating on a guess is the harm.
|
|
111
|
+
const { status } = await call('GET');
|
|
112
|
+
if (status !== 404 && status !== 200)
|
|
113
|
+
throw new DevError(`Could not tell whether this site already has a host link (HTTP ${status}), so nothing was minted. Check the key (pages.read) and the platform, or run again with ${o.flag ?? '--yes'} to mint regardless.`);
|
|
114
|
+
onPlatform = status === 200;
|
|
115
|
+
}
|
|
116
|
+
if ((inEnv || onPlatform) && !o.yes) {
|
|
117
|
+
const what = inEnv
|
|
118
|
+
? 'This repo already has a host secret in .env'
|
|
119
|
+
: 'This site already has a host link (made elsewhere: another machine, CI or Manage)';
|
|
120
|
+
const go = o.confirm
|
|
121
|
+
? await o.confirm(`${what}. Rotating it stops the deployed host's CURRENT secret working at once, until you give the host the new one. Rotate? [y/N] `)
|
|
122
|
+
: false;
|
|
123
|
+
if (!go)
|
|
124
|
+
throw new DevError(`${what}. Rotating it stops the deployed host's current secret working at once, so the host must be updated too — run again with ${o.flag ?? '--yes'} to rotate.`);
|
|
125
|
+
}
|
|
126
|
+
// With --yes nothing was asked, so whether a link existed is unknown: assume it did.
|
|
127
|
+
const replaced = inEnv || onPlatform || !!o.yes;
|
|
128
|
+
const res = await call('PUT');
|
|
129
|
+
if (res.status === 401 || res.status === 403)
|
|
130
|
+
throw new DevError('The platform refused the key (the host link needs pages.write). Settings → API keys: add pages.write, or mint a new key with `sb site init`.');
|
|
131
|
+
if (res.status === 404 || res.status === 501)
|
|
132
|
+
throw new DevError('This platform has no host link yet — it is older than this CLI.');
|
|
133
|
+
if (!res.ok)
|
|
134
|
+
throw new DevError(`The host link was refused (HTTP ${res.status}).`);
|
|
135
|
+
const link = (await res.json()).hostLink;
|
|
136
|
+
if (!link?.secret?.startsWith('sbh_') || !link.siteId)
|
|
137
|
+
throw new DevError('The platform answered without a host secret.');
|
|
138
|
+
// 'wx': a file that is already there (a leftover, or a link planted in a cloned repo) is never
|
|
139
|
+
// written through. The platform has ALREADY rotated: whatever fails from here, the old secret is dead.
|
|
140
|
+
const tmp = `${envPath}.${process.pid}.${randomBytes(4).toString('hex')}.tmp`;
|
|
141
|
+
try {
|
|
142
|
+
await writeFile(tmp, setEnv(have, { SB_HOST_SECRET: link.secret, SB_SITE_ID: link.siteId }), {
|
|
143
|
+
mode: 0o600,
|
|
144
|
+
flag: 'wx',
|
|
145
|
+
});
|
|
146
|
+
await rename(tmp, envPath);
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
await rm(tmp, { force: true }).catch(() => undefined);
|
|
150
|
+
throw new DevError(`The platform minted a new host secret, but writing .env failed (${messageOf(err)}). The OLD secret is already dead and the new one was not saved — fix the problem and run again with --yes to mint another.`);
|
|
151
|
+
}
|
|
152
|
+
const ignored = /^\/?\.env$/m.test(await readFile(join(o.dir, '.gitignore'), 'utf8').catch(() => ''));
|
|
153
|
+
log('Host link ready: SB_HOST_SECRET and SB_SITE_ID are in .env (mode 0600) — the secret is not printed.');
|
|
154
|
+
if (!ignored)
|
|
155
|
+
log(' ! .env is not in .gitignore — add it before you commit: this file now holds a secret.');
|
|
156
|
+
log('A deployed host needs both in ITS environment (Vercel: Project → Settings → Environment Variables), plus');
|
|
157
|
+
log('SB_PUBLIC_URL (your primary domain) and SB_STOREFRONT (the store’s built-in address). Copy the values from .env.');
|
|
158
|
+
log('With the link the store no longer redirects the built-in address for this host: no setting to change.');
|
|
159
|
+
return { replaced };
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=hostlink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostlink.js","sourceRoot":"","sources":["../../src/hostlink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,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ED
|
@@ -15,7 +15,7 @@ import { DevError, explain } from './dev.js';
|
|
|
15
15
|
* in POST bodies and is never printed, and neither are the tokens it buys.
|
|
16
16
|
*/
|
|
17
17
|
/** Sent as `clientVersion`; a test holds it equal to package.json. */
|
|
18
|
-
export const VERSION = '0.
|
|
18
|
+
export const VERSION = '0.11.0';
|
|
19
19
|
/**
|
|
20
20
|
* The platform's API, when SB_API is not set. PRODUCTION, because this CLI is
|
|
21
21
|
* published: `npx @sbuilder/cli agent` on an author's machine must reach the
|
package/dist/src/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG7E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;;;;;;;;GAYG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG7E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAG7C;;;;;;;;;;;;GAYG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,4BAA4B,CAAC;AAExD,gEAAgE;AAChE,MAAM,UAAU,OAAO;IACrB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,WAA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CAAC,CAAC;QAChD,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,QAAQ,CAAC,GAAG,GAAG,kBAAkB,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG;YACjB,GAAG,CAAC,4BAA4B,CAAC,CAAC,MAAM,sCAAsC,CAAC,CAAC;IACpF,CAAC;IAAC,MAAM,CAAC;QACP,GAAG,CAAC,gEAAgE,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACrC,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/src/next.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import { describeRoot, excludeDesign } from './roottsconfig.js';
|
|
3
4
|
import { SiteRefused } from './site.js';
|
|
5
|
+
import { blockEnvUpload, envUploadBlocked } from './vercel.js';
|
|
4
6
|
/**
|
|
5
7
|
* `sb site next` — make a site repo a Next.js app that serves its
|
|
6
8
|
* `design/pages/*.page.tsx` pages, rendered by the platform's own renderer
|
|
@@ -17,20 +19,32 @@ import { SiteRefused } from './site.js';
|
|
|
17
19
|
* A route the developer adds under `app/` wins over the catch-all, which is how
|
|
18
20
|
* hand-written React pages live beside the builder's.
|
|
19
21
|
*/
|
|
20
|
-
|
|
22
|
+
/**
|
|
23
|
+
* The Next.js range a generated app asks for, and the one the CLI supports (peerDependencies):
|
|
24
|
+
* 15.0 is the first release with top-level `serverExternalPackages` and
|
|
25
|
+
* `outputFileTracingIncludes` and a stable `instrumentation.js`; a new major joins the range only after the
|
|
26
|
+
* compatibility matrix (.github/workflows/next-compat.yml) passes on it.
|
|
27
|
+
*/
|
|
28
|
+
export const NEXT_RANGE = '>=15.0.0 <17';
|
|
21
29
|
export const REACT_RANGE = '^19.0.0';
|
|
22
30
|
export const ROUTE_JS = `// Serves design/pages/*.page.tsx through @sbuilder/cli/host — rendered by the
|
|
23
31
|
// platform's own renderer, so a page looks here exactly as it does on the store.
|
|
24
32
|
// A route you add under app/ wins over this one. Written by \`sb site next\`.
|
|
25
|
-
import { renderRequest, errorPage, forwardToStore } from '@sbuilder/cli/host';
|
|
33
|
+
import { renderRequest, crawlRequest, errorPage, forwardToStore } from '@sbuilder/cli/host';
|
|
34
|
+
import crawl from '../sb-crawl.js';
|
|
26
35
|
|
|
27
36
|
export const runtime = 'nodejs';
|
|
28
37
|
export const dynamic = 'force-dynamic';
|
|
29
38
|
|
|
30
39
|
export async function GET(request) {
|
|
31
40
|
try {
|
|
32
|
-
//
|
|
33
|
-
|
|
41
|
+
// sitemap.xml, robots.txt, llms.txt: the STORE's, plus what app/sb-crawl.js adds; any other path with
|
|
42
|
+
// no page file: the live storefront answers (search, account, …).
|
|
43
|
+
return (
|
|
44
|
+
(await renderRequest(request)) ??
|
|
45
|
+
(await crawlRequest(request, { crawl })) ??
|
|
46
|
+
(await forwardToStore(request, process.env.SB_STOREFRONT))
|
|
47
|
+
);
|
|
34
48
|
} catch (err) {
|
|
35
49
|
return errorPage(err);
|
|
36
50
|
}
|
|
@@ -40,14 +54,41 @@ export async function GET(request) {
|
|
|
40
54
|
export const PROXY_JS = `// /_wb/* — cart, checkout, forms, the islands runtime — belongs to the live
|
|
41
55
|
// storefront. next.config.mjs routes it here so that only the store's own cookies
|
|
42
56
|
// (wb_*) are forwarded, never this app's. Written by \`sb site next\`.
|
|
43
|
-
import { forwardToStore } from '@sbuilder/cli/host';
|
|
57
|
+
import { forwardToStore, errorPage } from '@sbuilder/cli/host';
|
|
44
58
|
|
|
45
59
|
export const runtime = 'nodejs';
|
|
46
60
|
export const dynamic = 'force-dynamic';
|
|
47
61
|
|
|
48
|
-
|
|
62
|
+
// A store that redirects back onto this host would loop: that is named, not passed on.
|
|
63
|
+
const forward = async (request) => {
|
|
64
|
+
try {
|
|
65
|
+
return await forwardToStore(request, process.env.SB_STOREFRONT);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
return errorPage(err);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
49
70
|
export { forward as GET, forward as POST, forward as PUT, forward as PATCH, forward as DELETE };
|
|
50
71
|
`;
|
|
72
|
+
export const CRAWL_JS = `// Your own URLs for the crawl files. The store's sitemap.xml, robots.txt and llms.txt are the
|
|
73
|
+
// platform's — fetched, never regenerated here — and what you list below is MERGED into them,
|
|
74
|
+
// each once, on the site's one origin. Do not add app/sitemap.* or app/robots.*: they would
|
|
75
|
+
// replace the store's part instead of merging with it. Written by \`sb site next\`.
|
|
76
|
+
export default {
|
|
77
|
+
// sitemap: [{ url: '/pricing', lastModified: new Date() }], // your own pages (Next's Sitemap shape)
|
|
78
|
+
// robots: ['Disallow: /account'], // extra robots.txt lines
|
|
79
|
+
// llms: ['- [API docs](/docs): the developer reference'], // extra llms.txt lines
|
|
80
|
+
};
|
|
81
|
+
`;
|
|
82
|
+
export const INSTRUMENTATION_JS = `// Runs once when the server starts. A DEPLOYED host refuses to start unless its public address
|
|
83
|
+
// (SB_PUBLIC_URL, or VERCEL_PROJECT_PRODUCTION_URL) is the site's primary domain — otherwise every
|
|
84
|
+
// canonical, hreflang and sitemap URL would point elsewhere. Preview and dev hosts skip the check.
|
|
85
|
+
// Written by \`sb site next\`.
|
|
86
|
+
export async function register() {
|
|
87
|
+
if (process.env.NEXT_RUNTIME !== 'nodejs') return;
|
|
88
|
+
const { assertDeployedOrigin } = await import('@sbuilder/cli/host');
|
|
89
|
+
await assertDeployedOrigin();
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
51
92
|
export const NEXT_CONFIG = `// Written by \`sb site next\`. Pages come from design/pages/*.page.tsx (see
|
|
52
93
|
// app/[[...slug]]/route.js). Everything under /_wb/ — cart, checkout, forms,
|
|
53
94
|
// the islands runtime — belongs to the live storefront, so it is forwarded there.
|
|
@@ -56,6 +97,25 @@ export default {
|
|
|
56
97
|
// Loaded from node_modules at run time: the renderer is a 17 MB .wasm it reads
|
|
57
98
|
// from its own folder, which a bundler would break.
|
|
58
99
|
serverExternalPackages: ['@sbuilder/render', '@sbuilder/cli'],
|
|
100
|
+
// The wasm is loaded by a name held in a variable, which file tracing cannot follow — so the
|
|
101
|
+
// deployed function would not contain it and every render would 500. Name it, and the files the
|
|
102
|
+
// host reads at run time (the page files and the manifest), for every route.
|
|
103
|
+
outputFileTracingIncludes: {
|
|
104
|
+
'/**': [
|
|
105
|
+
'./node_modules/@sbuilder/render/renderpage.wasm',
|
|
106
|
+
'./design/**/*',
|
|
107
|
+
'./.sb-site.json',
|
|
108
|
+
'./sb.json',
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
// A preview (SB_MODE=preview, or any Vercel preview deployment) is never indexed — including the
|
|
112
|
+
// routes you wrote under app/, 404s and static files, which the host's own responses do not cover.
|
|
113
|
+
// Read when Next BUILDS, so set SB_MODE=preview for the build too (Vercel sets VERCEL_ENV itself).
|
|
114
|
+
async headers() {
|
|
115
|
+
return process.env.VERCEL_ENV === 'preview' || process.env.SB_MODE === 'preview'
|
|
116
|
+
? [{ source: '/:path*', headers: [{ key: 'X-Robots-Tag', value: 'noindex' }] }]
|
|
117
|
+
: [];
|
|
118
|
+
},
|
|
59
119
|
async rewrites() {
|
|
60
120
|
// Through a route handler, not straight to the store: it forwards only the
|
|
61
121
|
// store's wb_* cookies (app/sb-proxy/[...path]/route.js).
|
|
@@ -69,7 +129,10 @@ export function packageJson(name, cliRange, renderRange) {
|
|
|
69
129
|
private: true,
|
|
70
130
|
type: 'module',
|
|
71
131
|
scripts: {
|
|
132
|
+
// The page types and the root tsconfig's `design` exclusion, before Next type-checks anything.
|
|
133
|
+
predev: 'sb site types --quiet',
|
|
72
134
|
dev: 'next dev',
|
|
135
|
+
prebuild: 'sb site types --quiet',
|
|
73
136
|
build: 'next build',
|
|
74
137
|
start: 'next start',
|
|
75
138
|
pull: 'sb site pull',
|
|
@@ -92,10 +155,14 @@ export async function initNext(o) {
|
|
|
92
155
|
const files = {
|
|
93
156
|
'app/[[...slug]]/route.js': ROUTE_JS,
|
|
94
157
|
'app/sb-proxy/[...path]/route.js': PROXY_JS,
|
|
158
|
+
'app/sb-crawl.js': CRAWL_JS,
|
|
159
|
+
'instrumentation.js': INSTRUMENTATION_JS,
|
|
95
160
|
'next.config.mjs': NEXT_CONFIG,
|
|
96
161
|
'package.json': packageJson((o.dir.split(/[\\/]/).pop() || 'site').toLowerCase().replace(/[^a-z0-9-]+/g, '-'), o.cliRange, o.renderRange),
|
|
97
162
|
};
|
|
98
163
|
const exists = async (f) => readFile(join(o.dir, f)).then(() => true, () => false);
|
|
164
|
+
// A linked .vercelignore is refused HERE, before any file is written (blockEnvUpload below would be too late).
|
|
165
|
+
await envUploadBlocked(o.dir);
|
|
99
166
|
const clash = [];
|
|
100
167
|
for (const f of Object.keys(files))
|
|
101
168
|
if (await exists(f))
|
|
@@ -106,6 +173,15 @@ export async function initNext(o) {
|
|
|
106
173
|
await mkdir(dirname(join(o.dir, f)), { recursive: true });
|
|
107
174
|
await writeFile(join(o.dir, f), text, 'utf8');
|
|
108
175
|
}
|
|
176
|
+
// The page types are their own project (design/tsconfig.json); an app tsconfig that already
|
|
177
|
+
// exists must leave `design` out, or `next build` type-checks the page files with the DOM's names.
|
|
178
|
+
const root = describeRoot(await excludeDesign(o.dir));
|
|
179
|
+
if (root.say)
|
|
180
|
+
log(root.say);
|
|
181
|
+
if (root.warn)
|
|
182
|
+
log(`! ${root.warn}`);
|
|
183
|
+
// `vercel deploy` uploads .env (it reads .vercelignore, never .gitignore's contents) — and .env holds the repo's key.
|
|
184
|
+
await blockEnvUpload(o.dir);
|
|
109
185
|
// Next and its build output never belong in git.
|
|
110
186
|
const gi = (await readFile(join(o.dir, '.gitignore'), 'utf8').catch(() => '')).split('\n');
|
|
111
187
|
const add = ['node_modules', '.next'].filter((l) => !gi.includes(l));
|
package/dist/src/next.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../src/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../src/next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC;AACzC,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AAErC,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBvB,CAAC;AAEF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;CAiBvB,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;CASvB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;CASjC,CAAC;AAEF,MAAM,C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AAC,IAAI,CAAC,GAAG,CAAC;QAC/B,GAAG,CAAC,0FAA0F,CAAC,CAAC;IAClG,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/src/repo.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, join, resolve } from 'node:path';
|
|
4
4
|
/**
|
|
5
5
|
* A SITE REPO's own settings: `sb.json` marks its root, and `.env` beside it
|
|
@@ -9,6 +9,23 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
9
9
|
* commands and `sb site mcp` find the key without anyone exporting it. A variable
|
|
10
10
|
* already in the environment always wins — the repo fills only what is unset.
|
|
11
11
|
*/
|
|
12
|
+
/**
|
|
13
|
+
* On Windows cmd.exe looks for a bare command name in the CURRENT DIRECTORY before PATH, so a cloned
|
|
14
|
+
* repo carrying `vercel.cmd` / `npx.bat` would run with the secrets we hand the child. The env var
|
|
15
|
+
* (`noCwdExec`) is the real protection; this refuses outright, for the default PATHEXT. Checked on every
|
|
16
|
+
* platform (a plain file listing), so it is testable and a repo cannot rely on the OS.
|
|
17
|
+
*/
|
|
18
|
+
export function strayExecutable(dir, command) {
|
|
19
|
+
const bad = new Set(['cmd', 'bat', 'exe', 'com', 'ps1', 'vbs', 'vbe', 'js', 'jse', 'wsf', 'wsh', 'msc'].map((e) => `${command}.${e}`));
|
|
20
|
+
try {
|
|
21
|
+
return readdirSync(dir).find((f) => bad.has(f.toLowerCase()));
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The child's env on Windows: never resolve a command from the current directory. */
|
|
28
|
+
export const noCwdExec = (env) => process.platform === 'win32' ? { ...env, NoDefaultCurrentDirectoryInExePath: '1' } : env;
|
|
12
29
|
/** The nearest folder at or above `from` that holds sb.json. */
|
|
13
30
|
export function repoRoot(from = process.cwd()) {
|
|
14
31
|
for (let dir = resolve(from);; dir = dirname(dir)) {
|
|
@@ -99,11 +116,16 @@ export function mcp(from) {
|
|
|
99
116
|
console.error(MCP_NO_KEY);
|
|
100
117
|
return Promise.resolve(1);
|
|
101
118
|
}
|
|
119
|
+
const stray = strayExecutable(process.cwd(), 'npx');
|
|
120
|
+
if (stray) {
|
|
121
|
+
console.error(`sb site mcp: ${stray} is in this folder, and Windows would run it instead of npx with your key in its environment. Delete it, then run again.`);
|
|
122
|
+
return Promise.resolve(1);
|
|
123
|
+
}
|
|
102
124
|
return new Promise((done) => {
|
|
103
125
|
const child = spawn('npx', ['-y', MCP_PACKAGE], {
|
|
104
126
|
stdio: 'inherit',
|
|
105
127
|
// Only the four allow-listed names reach the child — never a repo's NODE_OPTIONS or PATH.
|
|
106
|
-
env: { ...process.env, ...env },
|
|
128
|
+
env: noCwdExec({ ...process.env, ...env }),
|
|
107
129
|
shell: process.platform === 'win32',
|
|
108
130
|
});
|
|
109
131
|
child.on('error', (err) => {
|
package/dist/src/repo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../src/repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD;;;;;;;GAOG;AAEH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,154 @@
|
|
|
1
|
+
import { readdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { linkOn } from './site.js';
|
|
4
|
+
/** Does this parsed tsconfig exclude the design folder? (`design`, `./design`, `design/**` …) */
|
|
5
|
+
export function excludesDesign(cfg) {
|
|
6
|
+
return (Array.isArray(cfg.exclude) &&
|
|
7
|
+
cfg.exclude.some((e) => typeof e === 'string' && /^(\.\/)?design(\/(\*\*\/?\*?)?)?$/.test(e)));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Makes sure a root tsconfig.json, if there is one, excludes `design`. No tsconfig and a JS-only
|
|
11
|
+
* app → nothing is written (a tsconfig would make Next demand TypeScript). No tsconfig but the app
|
|
12
|
+
* already has TypeScript files — Next is about to write its own, which would pull `design` in and
|
|
13
|
+
* fail `next build` — → ours, with Next's defaults and the exclude ('created'); Next accepts an
|
|
14
|
+
* existing tsconfig and only fills gaps.
|
|
15
|
+
* A file that is not plain JSON (comments), is a symbolic link, or is not an object is KEPT —
|
|
16
|
+
* the caller says what to add. A parse is the only edit: the rest of the config is untouched.
|
|
17
|
+
*/
|
|
18
|
+
export async function excludeDesign(dir) {
|
|
19
|
+
const file = 'tsconfig.json';
|
|
20
|
+
const text = await readFile(join(dir, file), 'utf8').catch(() => undefined);
|
|
21
|
+
if (text === undefined) {
|
|
22
|
+
if (!(await hasAppTypeScript(dir)) || (await linkOn(dir, file)))
|
|
23
|
+
return 'absent';
|
|
24
|
+
await writeFile(join(dir, file), NEXT_TSCONFIG, { encoding: 'utf8', flag: 'wx' });
|
|
25
|
+
return 'created';
|
|
26
|
+
}
|
|
27
|
+
if (await linkOn(dir, file))
|
|
28
|
+
return 'kept';
|
|
29
|
+
let cfg;
|
|
30
|
+
try {
|
|
31
|
+
cfg = JSON.parse(text);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Comments or trailing commas (tsconfig allows both): cannot be edited, but may already say it.
|
|
35
|
+
// A commented-out exclude must not count, so the comments go first.
|
|
36
|
+
return /"exclude"\s*:\s*\[[^\]]*"(\.\/)?design(\/\*\*(\/\*)?)?"/.test(stripComments(text))
|
|
37
|
+
? 'ok'
|
|
38
|
+
: 'kept';
|
|
39
|
+
}
|
|
40
|
+
if (typeof cfg !== 'object' || cfg === null || Array.isArray(cfg))
|
|
41
|
+
return 'kept';
|
|
42
|
+
if (excludesDesign(cfg))
|
|
43
|
+
return 'ok';
|
|
44
|
+
if (cfg.exclude !== undefined && !Array.isArray(cfg.exclude))
|
|
45
|
+
return 'kept';
|
|
46
|
+
// `extends` without its own exclude inherits the base's; naming one here would REPLACE it.
|
|
47
|
+
if (cfg.exclude === undefined && cfg.extends !== undefined)
|
|
48
|
+
return 'inherits';
|
|
49
|
+
// TypeScript's own default exclude is node_modules; naming `exclude` replaces it, so keep that.
|
|
50
|
+
cfg.exclude = [...(cfg.exclude ?? ['node_modules']), 'design'];
|
|
51
|
+
await writeFile(join(dir, file), JSON.stringify(cfg, null, 2) + '\n', 'utf8');
|
|
52
|
+
return 'edited';
|
|
53
|
+
}
|
|
54
|
+
/** `//` and `/* *\/` comments removed, string contents left alone. */
|
|
55
|
+
export function stripComments(text) {
|
|
56
|
+
let out = '';
|
|
57
|
+
for (let i = 0; i < text.length; i++) {
|
|
58
|
+
const c = text[i];
|
|
59
|
+
if (c === '"') {
|
|
60
|
+
let j = i + 1;
|
|
61
|
+
while (j < text.length && text[j] !== '"')
|
|
62
|
+
j += text[j] === '\\' ? 2 : 1;
|
|
63
|
+
out += text.slice(i, j + 1);
|
|
64
|
+
i = j;
|
|
65
|
+
}
|
|
66
|
+
else if (c === '/' && text[i + 1] === '/') {
|
|
67
|
+
while (i < text.length && text[i] !== '\n')
|
|
68
|
+
i++;
|
|
69
|
+
out += '\n';
|
|
70
|
+
}
|
|
71
|
+
else if (c === '/' && text[i + 1] === '*') {
|
|
72
|
+
const end = text.indexOf('*/', i + 2);
|
|
73
|
+
i = end < 0 ? text.length : end + 1;
|
|
74
|
+
}
|
|
75
|
+
else
|
|
76
|
+
out += c;
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/** What to tell the developer when the root tsconfig could not be edited. */
|
|
81
|
+
export const ROOT_HINT = 'add "design" to "exclude" in the root tsconfig.json (the page types are their own project)';
|
|
82
|
+
/** What Next 15 writes for a new app, plus the exclude. Next 16 adjusts `jsx` and `include` itself. */
|
|
83
|
+
export const NEXT_TSCONFIG = JSON.stringify({
|
|
84
|
+
compilerOptions: {
|
|
85
|
+
target: 'ES2017',
|
|
86
|
+
lib: ['dom', 'dom.iterable', 'esnext'],
|
|
87
|
+
allowJs: true,
|
|
88
|
+
skipLibCheck: true,
|
|
89
|
+
strict: true,
|
|
90
|
+
noEmit: true,
|
|
91
|
+
esModuleInterop: true,
|
|
92
|
+
module: 'esnext',
|
|
93
|
+
moduleResolution: 'bundler',
|
|
94
|
+
resolveJsonModule: true,
|
|
95
|
+
isolatedModules: true,
|
|
96
|
+
jsx: 'preserve',
|
|
97
|
+
incremental: true,
|
|
98
|
+
plugins: [{ name: 'next' }],
|
|
99
|
+
},
|
|
100
|
+
include: ['next-env.d.ts', '.next/types/**/*.ts', '**/*.ts', '**/*.tsx'],
|
|
101
|
+
exclude: ['node_modules', 'design', 'code'],
|
|
102
|
+
}, null, 2) + '\n';
|
|
103
|
+
/**
|
|
104
|
+
* Does the app have TypeScript Next itself would notice — what makes Next write a tsconfig? Next
|
|
105
|
+
* looks in root app/ and pages/ (only when neither exists, in src/app and src/pages), and treats
|
|
106
|
+
* middleware / proxy / instrumentation at the root or in src/ as app code. A root config file
|
|
107
|
+
* (vitest.config.ts, tailwind.config.ts…), `.d.ts` files, `design/`, `code/` and a lone src/lib
|
|
108
|
+
* do NOT count.
|
|
109
|
+
*/
|
|
110
|
+
export async function hasAppTypeScript(dir) {
|
|
111
|
+
const isTs = (n) => /\.tsx?$/.test(n) && !n.endsWith('.d.ts');
|
|
112
|
+
const walk = async (d) => {
|
|
113
|
+
for (const e of await readdir(d, { withFileTypes: true }).catch(() => [])) {
|
|
114
|
+
if (e.isSymbolicLink())
|
|
115
|
+
continue;
|
|
116
|
+
if (e.isDirectory() ? await walk(join(d, e.name)) : isTs(e.name))
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
};
|
|
121
|
+
const isDir = (p) => stat(p).then((x) => x.isDirectory(), () => false);
|
|
122
|
+
const roots = (await isDir(join(dir, 'app'))) || (await isDir(join(dir, 'pages'))) ? [''] : ['src'];
|
|
123
|
+
for (const r of roots)
|
|
124
|
+
for (const sub of ['app', 'pages'])
|
|
125
|
+
if (await walk(join(dir, r, sub)))
|
|
126
|
+
return true;
|
|
127
|
+
for (const where of ['', 'src'])
|
|
128
|
+
for (const f of ['middleware', 'proxy', 'instrumentation'])
|
|
129
|
+
if (await stat(join(dir, where, `${f}.ts`)).then((x) => x.isFile(), () => false))
|
|
130
|
+
return true;
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* How a caller reports an outcome: `say` is news; `warn` is a problem; `fail` says the file's own
|
|
135
|
+
* content shows design is NOT excluded (a build would fail), so `sb site types` must exit 1.
|
|
136
|
+
*/
|
|
137
|
+
export function describeRoot(r) {
|
|
138
|
+
if (r === 'edited')
|
|
139
|
+
return {
|
|
140
|
+
say: 'Added "design" to the root tsconfig.json exclude (the page types are their own project).',
|
|
141
|
+
};
|
|
142
|
+
if (r === 'created')
|
|
143
|
+
return {
|
|
144
|
+
say: 'Wrote tsconfig.json (Next’s defaults, excluding design and code: the app has TypeScript files).',
|
|
145
|
+
};
|
|
146
|
+
if (r === 'kept')
|
|
147
|
+
return { warn: `tsconfig.json: kept as it is — ${ROOT_HINT}`, fail: true };
|
|
148
|
+
if (r === 'inherits')
|
|
149
|
+
return {
|
|
150
|
+
warn: 'tsconfig.json extends another and has no exclude of its own — make sure the base (or this file) excludes "design"',
|
|
151
|
+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