@sbuilder/cli 0.11.0 → 0.12.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 +57 -2
- package/README.vi.md +57 -2
- package/dist/bin/sb.js +52 -3
- package/dist/bin/sb.js.map +1 -1
- package/dist/src/components.js +574 -0
- package/dist/src/components.js.map +1 -0
- package/dist/src/doctor.js +4 -0
- package/dist/src/doctor.js.map +1 -1
- package/dist/src/envtypes.gen.js +13 -0
- package/dist/src/envtypes.gen.js.map +1 -1
- package/dist/src/login.js +1 -1
- package/dist/src/route.js +2 -0
- package/dist/src/route.js.map +1 -1
- package/dist/src/site.js +6 -0
- package/dist/src/site.js.map +1 -1
- package/dist/src/starter.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { lstat, mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { sbJsonSite } from './code.js';
|
|
6
|
+
import { DevError } from './dev.js';
|
|
7
|
+
import { errorOf, linkOn, open, put, refusal, send } from './site.js';
|
|
8
|
+
import { parseFile, printFile } from './source/meta.js';
|
|
9
|
+
import { parseSource } from './source/parse.js';
|
|
10
|
+
/**
|
|
11
|
+
* `sb site components` — code components: React (Preact) components a developer writes in a site
|
|
12
|
+
* repo's `components/` folder, bundled HERE with the repo's own esbuild and uploaded as IMMUTABLE
|
|
13
|
+
* versions (POST /api/v1/code-components). The CLI has no runtime dependency, so esbuild, preact and
|
|
14
|
+
* preact-render-to-string are the SITE REPO's devDependencies (`sb site components init` adds them).
|
|
15
|
+
*
|
|
16
|
+
* # What is built (the bundle contract, server/internal/codecomponents/codecomponents.go)
|
|
17
|
+
*
|
|
18
|
+
* SSR an IIFE that assigns `globalThis.__sbComponent = { render(props) -> string }`, react and
|
|
19
|
+
* react-dom aliased to preact/compat (the C0 spike's exact flags). The platform only ever
|
|
20
|
+
* EXECUTES this one, inside its sandbox: the platform renders every upload once with the
|
|
21
|
+
* schema's defaults before storing it and refuses (422 bundle_rejected) one that throws.
|
|
22
|
+
* The CLI never runs the bundle — it reads the props from the SOURCE (`schemaOf`).
|
|
23
|
+
* client an IIFE with `globalName: '__sbClient'` whose export is `{ hydrate(el, props) }`. It names
|
|
24
|
+
* no component and no version: the platform's serving route wraps the stored bytes and
|
|
25
|
+
* assigns `__sbClient` to `__sbComponentClient["<name>@<version>"]` (what
|
|
26
|
+
* runtime/src/nodes/code-component.ts reads), because only the platform knows the version.
|
|
27
|
+
* Version-agnostic bytes are also what lets identical sources dedupe by sha.
|
|
28
|
+
*
|
|
29
|
+
* The author never writes either contract: the entry stubs below are generated.
|
|
30
|
+
*
|
|
31
|
+
* Both are deterministic for the same source, so "same sha means no new version" holds.
|
|
32
|
+
*
|
|
33
|
+
* # What push does
|
|
34
|
+
*
|
|
35
|
+
* Every component is uploaded BEFORE any page, so a page pin always names a version that exists.
|
|
36
|
+
* The platform answers 201 for a new version and 200 (the existing one) for identical content; the
|
|
37
|
+
* version it assigned is printed. Nothing on any page moves: `sb site components upgrade` is the
|
|
38
|
+
* deliberate, local edit that does.
|
|
39
|
+
*/
|
|
40
|
+
/** Pinned exactly (no ranges): the C0 spike measured these, and a bundle's sha depends on them. */
|
|
41
|
+
export const ESBUILD_VERSION = '0.28.2';
|
|
42
|
+
export const PREACT_VERSION = '11.2.0';
|
|
43
|
+
export const RENDER_TO_STRING_VERSION = '6.8.3';
|
|
44
|
+
/**
|
|
45
|
+
* `@sbuilder/sdk/component` landed in 0.2.0. Not imported from starter.ts: that file reaches next.ts,
|
|
46
|
+
* and this one is loaded by host.ts (through site.ts), which must never load next's files.
|
|
47
|
+
*/
|
|
48
|
+
export const SDK_RANGE = '^0.2.0';
|
|
49
|
+
export const DEV_DEPENDENCIES = {
|
|
50
|
+
'@sbuilder/sdk': SDK_RANGE,
|
|
51
|
+
esbuild: ESBUILD_VERSION,
|
|
52
|
+
preact: PREACT_VERSION,
|
|
53
|
+
'preact-render-to-string': RENDER_TO_STRING_VERSION,
|
|
54
|
+
};
|
|
55
|
+
/** The platform's caps (codecomponents.MaxSSRBytes / MaxClientBytes): refused here, by name. */
|
|
56
|
+
export const MAX_SSR_BYTES = 512 << 10;
|
|
57
|
+
export const MAX_CLIENT_BYTES = 256 << 10;
|
|
58
|
+
export const COMPONENTS_DIR = 'components';
|
|
59
|
+
const NAME = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
60
|
+
export class ComponentRefused extends DevError {
|
|
61
|
+
}
|
|
62
|
+
const HERO = `import { defineProps, type Props } from '@sbuilder/sdk/component';
|
|
63
|
+
|
|
64
|
+
// The props the editor shows for this component. A length or a colour is a \`css\` prop: the
|
|
65
|
+
// page sets it per breakpoint as the custom property --<name>, and the markup reads it with
|
|
66
|
+
// var(--<name>, <default>). Its name must be lowercase kebab-case.
|
|
67
|
+
export const schema = defineProps({
|
|
68
|
+
title: { kind: 'text', default: 'Welcome' },
|
|
69
|
+
subtitle: { kind: 'text', default: 'Made with a code component' },
|
|
70
|
+
cta: { kind: 'link', default: '/' },
|
|
71
|
+
tone: { kind: 'enum', options: ['light', 'dark'], default: 'light' },
|
|
72
|
+
'gap-size': { kind: 'css', default: '16px' },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export default function Hero({ title, subtitle, cta, tone }: Props<typeof schema>) {
|
|
76
|
+
return (
|
|
77
|
+
<section class={\`hero hero-\${tone}\`} style="display: grid; gap: var(--gap-size, 16px)">
|
|
78
|
+
<h1>{title}</h1>
|
|
79
|
+
<p>{subtitle}</p>
|
|
80
|
+
<a href={cta}>Learn more</a>
|
|
81
|
+
</section>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
const TSCONFIG = `{
|
|
86
|
+
"compilerOptions": {
|
|
87
|
+
"target": "ES2020",
|
|
88
|
+
"module": "ESNext",
|
|
89
|
+
"moduleResolution": "Bundler",
|
|
90
|
+
"lib": ["ES2020", "DOM"],
|
|
91
|
+
"jsx": "react-jsx",
|
|
92
|
+
"jsxImportSource": "preact",
|
|
93
|
+
"strict": true,
|
|
94
|
+
"noEmit": true,
|
|
95
|
+
"skipLibCheck": true,
|
|
96
|
+
"baseUrl": ".",
|
|
97
|
+
"paths": {
|
|
98
|
+
"react": ["../node_modules/preact/compat"],
|
|
99
|
+
"react-dom": ["../node_modules/preact/compat"]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"include": ["./**/*"]
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
const refuseLink = async (dir, file) => {
|
|
106
|
+
const l = await linkOn(dir, file);
|
|
107
|
+
if (l)
|
|
108
|
+
throw new ComponentRefused(`${l} is a symbolic link — nothing was read or written. Replace it with the real file.`);
|
|
109
|
+
};
|
|
110
|
+
/** `sb site components init`: devDependencies, components/Hero.tsx, components/tsconfig.json. */
|
|
111
|
+
export async function componentsInit(dir, log) {
|
|
112
|
+
const out = { wrote: [], kept: [] };
|
|
113
|
+
for (const f of ['package.json', COMPONENTS_DIR, `${COMPONENTS_DIR}/Hero.tsx`])
|
|
114
|
+
await refuseLink(dir, f);
|
|
115
|
+
const pkgPath = join(dir, 'package.json');
|
|
116
|
+
const text = await readFile(pkgPath, 'utf8').catch(() => undefined);
|
|
117
|
+
let pkg = { name: 'site', private: true };
|
|
118
|
+
if (text !== undefined) {
|
|
119
|
+
try {
|
|
120
|
+
const parsed = JSON.parse(text);
|
|
121
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
122
|
+
throw new Error();
|
|
123
|
+
pkg = parsed;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
throw new ComponentRefused('package.json is not a JSON object — fix it, then run sb site components init again.');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const dev = (typeof pkg.devDependencies === 'object' && pkg.devDependencies !== null
|
|
130
|
+
? { ...pkg.devDependencies }
|
|
131
|
+
: {});
|
|
132
|
+
const added = [];
|
|
133
|
+
for (const [n, v] of Object.entries(DEV_DEPENDENCIES)) {
|
|
134
|
+
if (dev[n] === undefined) {
|
|
135
|
+
dev[n] = v;
|
|
136
|
+
added.push(`${n}@${v}`);
|
|
137
|
+
}
|
|
138
|
+
else if (dev[n] !== v)
|
|
139
|
+
log(` · ${n} stays at ${dev[n]} (this CLI was measured with ${v}; a different build changes every bundle's sha)`);
|
|
140
|
+
}
|
|
141
|
+
if (added.length) {
|
|
142
|
+
pkg.devDependencies = Object.fromEntries(Object.entries(dev).sort(([a], [b]) => a.localeCompare(b)));
|
|
143
|
+
await put(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
144
|
+
out.wrote.push('package.json');
|
|
145
|
+
log(` + package.json devDependencies: ${added.join(', ')}`);
|
|
146
|
+
}
|
|
147
|
+
else
|
|
148
|
+
out.kept.push('package.json');
|
|
149
|
+
await mkdir(join(dir, COMPONENTS_DIR), { recursive: true });
|
|
150
|
+
for (const [file, body] of [
|
|
151
|
+
[`${COMPONENTS_DIR}/Hero.tsx`, HERO],
|
|
152
|
+
[`${COMPONENTS_DIR}/tsconfig.json`, TSCONFIG],
|
|
153
|
+
]) {
|
|
154
|
+
await refuseLink(dir, file);
|
|
155
|
+
try {
|
|
156
|
+
await writeFile(join(dir, file), body, { encoding: 'utf8', flag: 'wx' });
|
|
157
|
+
out.wrote.push(file);
|
|
158
|
+
log(` + ${file}`);
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
if (err.code !== 'EEXIST')
|
|
162
|
+
throw err;
|
|
163
|
+
out.kept.push(file);
|
|
164
|
+
log(` · ${file} exists — kept`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
log('Next: npm install, then edit components/Hero.tsx and run sb site push — it bundles and uploads each\n' +
|
|
168
|
+
'component before the pages. Then drop it on a page from the editor (Code component).');
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
function loadEsbuild(dir) {
|
|
172
|
+
try {
|
|
173
|
+
return createRequire(join(dir, 'package.json'))('esbuild');
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
throw new ComponentRefused('esbuild is not installed in this repo. Run sb site components init, then npm install ' +
|
|
177
|
+
`(the CLI bundles with the repo's own esbuild ${ESBUILD_VERSION}).`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** The shared flags: the C0 spike's, so the bundle runs in the platform's sandbox as measured. */
|
|
181
|
+
const COMMON = {
|
|
182
|
+
bundle: true,
|
|
183
|
+
format: 'iife',
|
|
184
|
+
minify: true,
|
|
185
|
+
jsx: 'automatic',
|
|
186
|
+
legalComments: 'none',
|
|
187
|
+
write: false,
|
|
188
|
+
logLevel: 'silent',
|
|
189
|
+
target: 'es2020',
|
|
190
|
+
define: { 'process.env.NODE_ENV': '"production"' },
|
|
191
|
+
mainFields: ['module', 'main'],
|
|
192
|
+
conditions: ['browser'],
|
|
193
|
+
alias: {
|
|
194
|
+
react: 'preact/compat',
|
|
195
|
+
'react-dom': 'preact/compat',
|
|
196
|
+
'react/jsx-runtime': 'preact/jsx-runtime',
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
const ssrEntry = (file) => `import * as M from ${JSON.stringify(`./${COMPONENTS_DIR}/${file}`)};
|
|
200
|
+
import { h } from 'preact';
|
|
201
|
+
import { renderToString } from 'preact-render-to-string';
|
|
202
|
+
globalThis.__sbComponent = { render: (p) => renderToString(h(M.default, p)), schema: M.schema };
|
|
203
|
+
`;
|
|
204
|
+
const clientEntry = (file) => `import * as M from ${JSON.stringify(`./${COMPONENTS_DIR}/${file}`)};
|
|
205
|
+
import { h, hydrate as mount } from 'preact';
|
|
206
|
+
export const hydrate = (el, props) => mount(h(M.default, props), el);
|
|
207
|
+
`;
|
|
208
|
+
/**
|
|
209
|
+
* The props schema, read from the source WITHOUT running anything: the literal inside
|
|
210
|
+
* `export const schema = defineProps({ … })` (or a bare `{ … }`). A schema built by code is
|
|
211
|
+
* refused with the fix — the platform re-validates what is sent, and the bundle's own defineProps
|
|
212
|
+
* re-checks it where the platform renders the component.
|
|
213
|
+
*/
|
|
214
|
+
export function schemaOf(src) {
|
|
215
|
+
const m = /export\s+const\s+schema\b[^=]*=\s*(?:defineProps\s*(?:<[^>]*>)?\s*\(\s*)?/.exec(src);
|
|
216
|
+
const start = m ? m.index + m[0].length : -1;
|
|
217
|
+
let end = -1;
|
|
218
|
+
if (start >= 0 && src[start] === '{') {
|
|
219
|
+
let depth = 0;
|
|
220
|
+
for (let i = start, q = ''; i < src.length; i++) {
|
|
221
|
+
const c = src[i];
|
|
222
|
+
if (q) {
|
|
223
|
+
if (c === '\\')
|
|
224
|
+
i++;
|
|
225
|
+
else if (c === q)
|
|
226
|
+
q = '';
|
|
227
|
+
}
|
|
228
|
+
else if (c === '"' || c === "'" || c === '`')
|
|
229
|
+
q = c;
|
|
230
|
+
else if (c === '/' && src[i + 1] === '/')
|
|
231
|
+
i = src.indexOf('\n', i) < 0 ? src.length : src.indexOf('\n', i);
|
|
232
|
+
else if (c === '/' && src[i + 1] === '*')
|
|
233
|
+
i = src.indexOf('*/', i) < 0 ? src.length : src.indexOf('*/', i) + 1;
|
|
234
|
+
else if (c === '{')
|
|
235
|
+
depth++;
|
|
236
|
+
else if (c === '}' && --depth === 0) {
|
|
237
|
+
end = i + 1;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const fail = (why) => {
|
|
243
|
+
throw new ComponentRefused(`\`schema\` ${why}. Write it as a literal: export const schema = defineProps({ title: { kind: 'text' } });`);
|
|
244
|
+
};
|
|
245
|
+
if (end < 0)
|
|
246
|
+
return fail('is not a literal object');
|
|
247
|
+
try {
|
|
248
|
+
const v = parseSource(`export default (<Page id="p" />);\nexport const page = ${src.slice(start, end)};`).exports.page?.value;
|
|
249
|
+
if (typeof v !== 'object' || v === null || Array.isArray(v))
|
|
250
|
+
return fail('is not an object');
|
|
251
|
+
return v;
|
|
252
|
+
}
|
|
253
|
+
catch (err) {
|
|
254
|
+
return fail(`could not be read (${err instanceof Error ? err.message : String(err)})`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** Bundles one component with the repo's esbuild. Runs the repo's build tooling, never the bundle. */
|
|
258
|
+
export async function buildComponent(dir, file) {
|
|
259
|
+
const name = file.replace(/\.tsx$/, '');
|
|
260
|
+
const esbuild = loadEsbuild(dir);
|
|
261
|
+
const run = async (contents, extra) => {
|
|
262
|
+
try {
|
|
263
|
+
const r = await esbuild.build({
|
|
264
|
+
...COMMON,
|
|
265
|
+
...extra,
|
|
266
|
+
absWorkingDir: dir,
|
|
267
|
+
stdin: {
|
|
268
|
+
contents,
|
|
269
|
+
resolveDir: dir,
|
|
270
|
+
sourcefile: `${COMPONENTS_DIR}/${name}.entry.tsx`,
|
|
271
|
+
loader: 'tsx',
|
|
272
|
+
},
|
|
273
|
+
});
|
|
274
|
+
return r.outputFiles[0]?.text ?? '';
|
|
275
|
+
}
|
|
276
|
+
catch (err) {
|
|
277
|
+
const errors = err.errors;
|
|
278
|
+
throw new ComponentRefused(`${name}: the build failed — ` +
|
|
279
|
+
(errors?.length
|
|
280
|
+
? errors
|
|
281
|
+
.slice(0, 5)
|
|
282
|
+
.map((e) => `${e.location ? `${e.location.file}:${e.location.line}:${e.location.column} ` : ''}${e.text}`)
|
|
283
|
+
.join('; ')
|
|
284
|
+
: err instanceof Error
|
|
285
|
+
? err.message
|
|
286
|
+
: String(err)));
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
const ssr = await run(ssrEntry(file), { platform: 'neutral' });
|
|
290
|
+
const client = await run(clientEntry(file), { platform: 'browser', globalName: '__sbClient' });
|
|
291
|
+
let schema;
|
|
292
|
+
try {
|
|
293
|
+
schema = schemaOf(await readFile(join(dir, COMPONENTS_DIR, file), 'utf8'));
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
throw new ComponentRefused(`${name}: ${err instanceof Error ? err.message : String(err)}`);
|
|
297
|
+
}
|
|
298
|
+
const kib = (n) => `${(n / 1024).toFixed(1)} KiB`;
|
|
299
|
+
if (Buffer.byteLength(ssr) > MAX_SSR_BYTES)
|
|
300
|
+
throw new ComponentRefused(`${name}: the SSR bundle is ${kib(Buffer.byteLength(ssr))}, over the ${MAX_SSR_BYTES >> 10} KiB cap — import less (a large library does not fit; the platform's sandbox runs this bundle).`);
|
|
301
|
+
if (Buffer.byteLength(client) > MAX_CLIENT_BYTES)
|
|
302
|
+
throw new ComponentRefused(`${name}: the client bundle is ${kib(Buffer.byteLength(client))}, over the ${MAX_CLIENT_BYTES >> 10} KiB cap — import less.`);
|
|
303
|
+
return { name, file, schema, ssr, client };
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The components in the repo: `components/<Name>.tsx` that export a `schema`. Anything else is
|
|
307
|
+
* named and left alone — `components/` is also the folder a Next.js app puts its own components in,
|
|
308
|
+
* and uploading `Header.tsx` as a code component would be a surprise nobody asked for.
|
|
309
|
+
*/
|
|
310
|
+
export async function listComponents(dir, note) {
|
|
311
|
+
const st = await lstat(join(dir, COMPONENTS_DIR)).catch(() => undefined);
|
|
312
|
+
if (!st)
|
|
313
|
+
return [];
|
|
314
|
+
await refuseLink(dir, COMPONENTS_DIR);
|
|
315
|
+
const out = [];
|
|
316
|
+
for (const f of (await readdir(join(dir, COMPONENTS_DIR))).sort()) {
|
|
317
|
+
if (!f.endsWith('.tsx') || f.endsWith('.d.tsx'))
|
|
318
|
+
continue;
|
|
319
|
+
const file = `${COMPONENTS_DIR}/${f}`;
|
|
320
|
+
await refuseLink(dir, file);
|
|
321
|
+
if (!NAME.test(f.slice(0, -4))) {
|
|
322
|
+
note(` · ${file}: not a component name (letters, digits, _; starts with a letter) — skipped`);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
const src = await readFile(join(dir, file), 'utf8');
|
|
326
|
+
if (!/export\s+const\s+schema\b/.test(src)) {
|
|
327
|
+
note(` · ${file}: exports no \`schema\` (defineProps) — not a code component, skipped`);
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
out.push(f);
|
|
331
|
+
}
|
|
332
|
+
return out;
|
|
333
|
+
}
|
|
334
|
+
/** Builds and uploads each component; the version the platform assigned is printed. */
|
|
335
|
+
export async function pushComponents(ctx, o) {
|
|
336
|
+
const out = { sent: 0, failed: 0 };
|
|
337
|
+
let files;
|
|
338
|
+
try {
|
|
339
|
+
files = await listComponents(ctx.dir, ctx.warn);
|
|
340
|
+
}
|
|
341
|
+
catch (err) {
|
|
342
|
+
if (!(err instanceof ComponentRefused))
|
|
343
|
+
throw err;
|
|
344
|
+
ctx.warn(` ! ${err.message}`);
|
|
345
|
+
return { sent: 0, failed: 1 };
|
|
346
|
+
}
|
|
347
|
+
if (!files.length)
|
|
348
|
+
return out;
|
|
349
|
+
if (!ctx.v1 && !o.dryRun) {
|
|
350
|
+
ctx.warn(` ! components/: uploading code components needs an API key (wbk_… with pages.write) in SB_TOKEN or .env — a browser sign-in cannot. ${files.length} component(s) not uploaded; pages were still pushed.`);
|
|
351
|
+
return { sent: 0, failed: files.length };
|
|
352
|
+
}
|
|
353
|
+
for (const f of files) {
|
|
354
|
+
const file = `${COMPONENTS_DIR}/${f}`;
|
|
355
|
+
let built;
|
|
356
|
+
try {
|
|
357
|
+
built = await buildComponent(ctx.dir, f);
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
if (!(err instanceof ComponentRefused))
|
|
361
|
+
throw err;
|
|
362
|
+
ctx.warn(` ! ${file}: ${err.message}`);
|
|
363
|
+
out.failed++;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
const sizes = `${(Buffer.byteLength(built.ssr) / 1024).toFixed(1)} KiB SSR, ${(Buffer.byteLength(built.client) / 1024).toFixed(1)} KiB client`;
|
|
367
|
+
if (o.dryRun) {
|
|
368
|
+
ctx.log(` ↑ ${file} (dry run, ${sizes})`);
|
|
369
|
+
out.sent++;
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
const res = await send(ctx, `${ctx.base}/code-components`, 'POST', {
|
|
373
|
+
name: built.name,
|
|
374
|
+
propsSchema: built.schema,
|
|
375
|
+
ssrBundle: built.ssr,
|
|
376
|
+
clientBundle: built.client,
|
|
377
|
+
});
|
|
378
|
+
if (!res.ok) {
|
|
379
|
+
const err = await errorOf(res);
|
|
380
|
+
const wait = res.headers.get('retry-after');
|
|
381
|
+
ctx.warn(` ! ${file}: refused (${refusal(err)})${res.status === 429 && wait ? ` — try again in ${wait}s` : ''}`);
|
|
382
|
+
out.failed++;
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const v = (await res.json()).codeComponent.version;
|
|
386
|
+
ctx.log(` ↑ ${file} → ${built.name} version ${v} (${res.status === 201 ? 'new' : 'unchanged'}, ${sizes})`);
|
|
387
|
+
out.sent++;
|
|
388
|
+
}
|
|
389
|
+
ctx.log(`${out.sent} code component(s) ${o.dryRun ? 'would be ' : ''}uploaded${out.failed ? `, ${out.failed} refused` : ''}.`);
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
// ── pins ──────────────────────────────────────────────────────────────────────────────────────
|
|
393
|
+
const KINDS = [
|
|
394
|
+
['design/pages', 'page'],
|
|
395
|
+
['design/globals', 'global'],
|
|
396
|
+
['design/overlays', 'overlay'],
|
|
397
|
+
];
|
|
398
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
399
|
+
/** Every code-component node of a document: its pinned name and version. */
|
|
400
|
+
export function pinsOf(doc) {
|
|
401
|
+
const out = [];
|
|
402
|
+
for (const [id, n] of Object.entries(doc.nodes ?? {})) {
|
|
403
|
+
const data = n.data;
|
|
404
|
+
const sp = n.specials;
|
|
405
|
+
if (!isObj(data) || data.type !== 'code-component' || !isObj(sp))
|
|
406
|
+
continue;
|
|
407
|
+
if (typeof sp.component === 'string' && typeof sp.version === 'number')
|
|
408
|
+
out.push({ id, name: sp.component, version: sp.version });
|
|
409
|
+
}
|
|
410
|
+
return out;
|
|
411
|
+
}
|
|
412
|
+
/** Each design file that parses, with its text; unparseable ones are the doctor's `files` check. */
|
|
413
|
+
async function designFiles(dir) {
|
|
414
|
+
const out = [];
|
|
415
|
+
for (const [d, kind] of KINDS) {
|
|
416
|
+
for (const f of (await readdir(join(dir, d)).catch(() => [])).sort()) {
|
|
417
|
+
if (!f.endsWith('.page.tsx'))
|
|
418
|
+
continue;
|
|
419
|
+
const file = `${d}/${f}`;
|
|
420
|
+
if (await linkOn(dir, file))
|
|
421
|
+
continue;
|
|
422
|
+
try {
|
|
423
|
+
const { document, meta } = parseFile(await readFile(join(dir, file), 'utf8'), kind);
|
|
424
|
+
out.push({ file, kind, doc: document, meta });
|
|
425
|
+
}
|
|
426
|
+
catch {
|
|
427
|
+
// said by the files check; an upgrade must not touch a file it cannot read
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return out;
|
|
432
|
+
}
|
|
433
|
+
export async function pinsInRepo(dir) {
|
|
434
|
+
const pins = [];
|
|
435
|
+
for (const f of await designFiles(dir))
|
|
436
|
+
for (const p of pinsOf(f.doc))
|
|
437
|
+
pins.push({ file: f.file, node: p.id, name: p.name, version: p.version });
|
|
438
|
+
return pins;
|
|
439
|
+
}
|
|
440
|
+
const rowsOf = (body) => {
|
|
441
|
+
const b = body;
|
|
442
|
+
return b.codeComponents ?? b.versions ?? [];
|
|
443
|
+
};
|
|
444
|
+
/** `sb site components upgrade <Name> [--to N]`: rewrites the pins in page files. A local edit only. */
|
|
445
|
+
export async function upgrade(o) {
|
|
446
|
+
if (!NAME.test(o.name))
|
|
447
|
+
throw new ComponentRefused(`"${o.name}" is not a component name.`);
|
|
448
|
+
if (o.to !== undefined && (!Number.isInteger(o.to) || o.to < 1))
|
|
449
|
+
throw new ComponentRefused('--to takes a version number (1, 2, 3 …).');
|
|
450
|
+
const ctx = await open(o);
|
|
451
|
+
const base = `${ctx.base}/code-components/${encodeURIComponent(o.name)}`;
|
|
452
|
+
const res = await send(ctx, o.to === undefined ? `${base}/versions?limit=1` : `${base}/versions/${o.to}`, 'GET');
|
|
453
|
+
if (!res.ok) {
|
|
454
|
+
if (res.status === 404)
|
|
455
|
+
throw new ComponentRefused(o.to === undefined
|
|
456
|
+
? `The platform has no component named ${o.name}. Push it first: sb site push.`
|
|
457
|
+
: `The platform has no ${o.name} version ${o.to}. Without --to the latest is used.`);
|
|
458
|
+
throw new ComponentRefused(`Reading ${o.name} failed: ${refusal(await errorOf(res))}`);
|
|
459
|
+
}
|
|
460
|
+
const body = (await res.json());
|
|
461
|
+
const target = o.to === undefined ? rowsOf(body)[0] : body.codeComponent;
|
|
462
|
+
if (!target)
|
|
463
|
+
throw new ComponentRefused(`The platform has no component named ${o.name}.`);
|
|
464
|
+
const schema = target.propsSchema ?? {};
|
|
465
|
+
let changed = 0;
|
|
466
|
+
let files = 0;
|
|
467
|
+
for (const f of await designFiles(ctx.dir)) {
|
|
468
|
+
const nodes = Object.entries(f.doc.nodes).filter(([id]) => pinsOf(f.doc).some((p) => p.id === id && p.name === o.name && p.version !== target.version));
|
|
469
|
+
if (!nodes.length)
|
|
470
|
+
continue;
|
|
471
|
+
for (const [id, n] of nodes) {
|
|
472
|
+
const sp = n.specials;
|
|
473
|
+
const was = sp.version;
|
|
474
|
+
const dropped = isObj(sp.props)
|
|
475
|
+
? Object.keys(sp.props).filter((k) => !schema[k] || schema[k]?.kind === 'css')
|
|
476
|
+
: [];
|
|
477
|
+
sp.version = target.version;
|
|
478
|
+
changed++;
|
|
479
|
+
ctx.log(` ${f.file}: ${id} ${o.name} version ${String(was)} → ${target.version}`);
|
|
480
|
+
if (dropped.length)
|
|
481
|
+
ctx.warn(` ! ${f.file}: ${id} sets ${dropped.join(', ')}, which version ${target.version} does not take — the platform drops ${dropped.length > 1 ? 'them' : 'it'} on the next save.`);
|
|
482
|
+
}
|
|
483
|
+
files++;
|
|
484
|
+
if (!o.dryRun) {
|
|
485
|
+
await refuseLink(ctx.dir, f.file);
|
|
486
|
+
await put(join(ctx.dir, f.file), printFile(f.kind, f.doc, f.meta));
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
if (!changed) {
|
|
490
|
+
ctx.log(`No page file pins ${o.name} below version ${target.version}: nothing to change.`);
|
|
491
|
+
return 0;
|
|
492
|
+
}
|
|
493
|
+
ctx.log(`${changed} pin(s) in ${files} file(s) ${o.dryRun ? 'would move' : 'moved'} to ${o.name} version ${target.version}. ` +
|
|
494
|
+
'html is derived: the platform re-renders it when you push. Review the diff, then sb site push (a draft).');
|
|
495
|
+
return 0;
|
|
496
|
+
}
|
|
497
|
+
// ── doctor ────────────────────────────────────────────────────────────────────────────────────
|
|
498
|
+
const make = (id, title) => (status, detail, fix = null) => ({
|
|
499
|
+
id,
|
|
500
|
+
title,
|
|
501
|
+
status,
|
|
502
|
+
detail,
|
|
503
|
+
fix,
|
|
504
|
+
});
|
|
505
|
+
/**
|
|
506
|
+
* `components:build` and `components:pins`. Without `build` this is STATIC and read-only: the files
|
|
507
|
+
* exist, each exports a literal `schema`, esbuild is installed (its package.json is looked for,
|
|
508
|
+
* never loaded) and GETs. With `build` (`sb doctor --build`) each component is also bundled, which
|
|
509
|
+
* runs the repo's own esbuild — code from this repo's node_modules, so it is opt-in.
|
|
510
|
+
*/
|
|
511
|
+
export async function doctorChecks(root, api, get, canAsk, key, build = false) {
|
|
512
|
+
const out = [];
|
|
513
|
+
{
|
|
514
|
+
const c = make('components:build', 'components/ is ready to push');
|
|
515
|
+
const notes = [];
|
|
516
|
+
try {
|
|
517
|
+
const files = await listComponents(root, (l) => notes.push(l.trim()));
|
|
518
|
+
if (!files.length)
|
|
519
|
+
out.push(c('skip', 'no components/<Name>.tsx with a schema', 'sb site components init'));
|
|
520
|
+
else {
|
|
521
|
+
const bad = [];
|
|
522
|
+
for (const f of files) {
|
|
523
|
+
const file = `${COMPONENTS_DIR}/${f}`;
|
|
524
|
+
try {
|
|
525
|
+
schemaOf(await readFile(join(root, file), 'utf8'));
|
|
526
|
+
if (build)
|
|
527
|
+
await buildComponent(root, f);
|
|
528
|
+
}
|
|
529
|
+
catch (e) {
|
|
530
|
+
bad.push(`${file}: ${e instanceof Error ? e.message : String(e)}`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const installed = existsSync(join(root, 'node_modules', 'esbuild', 'package.json'));
|
|
534
|
+
out.push(bad.length
|
|
535
|
+
? c('fail', `${bad.length} of ${files.length} cannot be pushed:\n ${bad.join('\n ')}`, 'Fix the line named, then sb site push')
|
|
536
|
+
: !installed
|
|
537
|
+
? c('fail', 'esbuild is not installed in this repo: sb site push cannot bundle', 'sb site components init, then npm install')
|
|
538
|
+
: c('ok', `${files.length} component(s) with a readable schema${build ? ', and they build within the size caps' : ' (sb doctor --build also bundles them, running this repo’s esbuild)'}`));
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
catch (err) {
|
|
542
|
+
out.push(c('fail', err instanceof Error ? err.message : String(err), 'Replace the symbolic link with the real folder'));
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
{
|
|
546
|
+
const c = make('components:pins', 'Pinned component versions exist');
|
|
547
|
+
const pins = await pinsInRepo(root);
|
|
548
|
+
if (!pins.length)
|
|
549
|
+
out.push(c('skip', 'no page file pins a code component'));
|
|
550
|
+
else if (!canAsk)
|
|
551
|
+
out.push(c('skip', 'not tested (not signed in)'));
|
|
552
|
+
else {
|
|
553
|
+
const site = key ? '' : await sbJsonSite(root);
|
|
554
|
+
const base = key ? `${api}/api/v1` : `${api}/api/sites/${encodeURIComponent(site ?? '')}`;
|
|
555
|
+
const seen = new Map();
|
|
556
|
+
const gone = [];
|
|
557
|
+
for (const p of pins) {
|
|
558
|
+
const k = `${p.name}@${p.version}`;
|
|
559
|
+
if (!seen.has(k))
|
|
560
|
+
seen.set(k, (await get(`${base}/code-components/${encodeURIComponent(p.name)}/versions/${p.version}`)).status);
|
|
561
|
+
if (seen.get(k) === 404)
|
|
562
|
+
gone.push(`${p.file}: ${k}`);
|
|
563
|
+
}
|
|
564
|
+
const odd = [...seen.entries()].find(([, s]) => s !== 200 && s !== 404);
|
|
565
|
+
out.push(gone.length
|
|
566
|
+
? c('fail', `a page pins a version the platform does not have:\n ${gone.slice(0, 10).join('\n ')}`, 'sb site push uploads components/ first; or sb site components upgrade <Name> to a version that exists')
|
|
567
|
+
: odd
|
|
568
|
+
? c('skip', `not tested (HTTP ${odd[1]} for ${odd[0]})`)
|
|
569
|
+
: c('ok', `${seen.size} pinned version(s) exist`));
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return out;
|
|
573
|
+
}
|
|
574
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,mGAAmG;AACnG,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C,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;YACxE,GAAG,CAAC,IAAI,CACN,IAAI,CAAC,MAAM;gBACT,CAAC,CAAC,CAAC,CACC,MAAM,EACN,4DAA4D,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,EAChG,uGAAuG,CACxG;gBACH,CAAC,CAAC,GAAG;oBACH,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,oBAAoB,GAAG,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;oBACxD,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,0BAA0B,CAAC,CACtD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/src/doctor.js
CHANGED
|
@@ -2,6 +2,7 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { readdir } from 'node:fs/promises';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { authedFetch, SB_TOKEN_REFUSED } from './auth.js';
|
|
5
|
+
import { doctorChecks as componentChecks } from './components.js';
|
|
5
6
|
import { deployedOrigin, hostMode } from './host.js';
|
|
6
7
|
import { signHost } from './hostlink.js';
|
|
7
8
|
import { whoIs } from './login.js';
|
|
@@ -269,6 +270,9 @@ export async function doctor(o) {
|
|
|
269
270
|
? c('fail', `${bad.length} of ${n} file(s) do not parse:\n ${bad.slice(0, 10).join('\n ')}${bad.length > 10 ? `\n … and ${bad.length - 10} more` : ''}`, 'Edit each file at the line shown (page files hold data, not code), then sb site push')
|
|
270
271
|
: c('ok', `${n} file(s) parse`));
|
|
271
272
|
}
|
|
273
|
+
// code components: components/ builds, and every pinned version exists
|
|
274
|
+
for (const c of await componentChecks(root, o.api, (u) => get(u, o.token), !!o.token && !(typeof o.token === 'string' && o.token.startsWith('sbdk_')), key, o.build === true))
|
|
275
|
+
add(c);
|
|
272
276
|
// ── the Next.js app ─────────────────────────────────────────────────────────
|
|
273
277
|
const pkgPath = join(root, 'package.json');
|
|
274
278
|
let pkg = {};
|