@niscorp/cli 0.7.0 → 0.8.1
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/CHANGELOG.md +62 -0
- package/README.md +1 -1
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# @niscorp/cli
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8eaea60: The docs say where `server.checkFunctions()` goes: after every route of the app's own, before it listens.
|
|
8
|
+
|
|
9
|
+
Nobody's shell makes its reads in-process, and the server takes no route once it has answered one: a route mounted after the check throws `Can not add a route since the matcher is already built.` moss's DOCS, nisc's AGENTS and the cli README say so.
|
|
10
|
+
|
|
11
|
+
- 1a67306: `nisc start` checks the app's functions after the project's `routes` and the site are mounted.
|
|
12
|
+
|
|
13
|
+
Checking the functions answers requests in-process, and the server takes no route once it has answered one. An app with functions whose first screen reads as it mounts failed to start: `Can not add a route since the matcher is already built.`
|
|
14
|
+
|
|
15
|
+
## 0.8.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 2076f80: `session.draft.add` is what `session.draft.put` was. **Breaking.**
|
|
20
|
+
|
|
21
|
+
BREAKING — approved by moccadroid, 2026-10-18: rename `session.draft.put(...)` to `session.draft.add(...)`. Nothing else about it changes: it takes what `save` takes, what is added is in that one shell when the add answers, and `save`, `discard`, `show`, `remove` and `list` are as they were.
|
|
22
|
+
|
|
23
|
+
- cdc89cc: `server.checkFunctions()` reads the app's functions and refuses what is wrong with them before anyone is served. **Breaking.**
|
|
24
|
+
|
|
25
|
+
BREAKING — approved by moccadroid, 2026-10-18: `serve` of `@niscorp/moss/node`, and `nisc dev`, `nisc build`, `nisc check` and `nisc start`, refuse to come up on an action that calls a function the app has no function of, a charter `functions` deny that matches nothing, or two functions under one id. An app that hands a function only to signed-in sessions, with a shipped action calling it, hands it to every session (the function refuses whom it must), or is refused.
|
|
26
|
+
|
|
27
|
+
An app's functions are known only once a session is: `functions(session)` is called for each shell, and a session hook may reach for the server object, which the app holds only once `createServer` has answered. So the check is the app's to call, once it holds the server and before it listens; `serve` of `@niscorp/moss/node` calls it, and so do `nisc dev`, `nisc build`, `nisc check` and `nisc start` after the project's `boot`; each closes what it built where it refuses. It builds nobody's shell once, after everything is in force, and drops it. What that call returned is checked, and it refuses on:
|
|
28
|
+
- **an action, or a fragment a shell ships, that calls a function the app does not have**: `"home" calls "auth.leave", which the app has no function of`. Before, the call failed when a person pressed the button. An app with no `functions` has none. A set of actions handed over while the app runs is held to the same at that refresh.
|
|
29
|
+
- **a charter `functions` deny that matches nothing**: `Charter is incoherent over the app’s functions — refusing to serve:`.
|
|
30
|
+
- **two functions under one id**: `moss: functions(session) returned "auth.leave" twice.`
|
|
31
|
+
|
|
32
|
+
What the charter only warns of (a grant that names no function, a function no role grants), the functions with no description, and a map of handlers are said at that point, once.
|
|
33
|
+
|
|
34
|
+
The cost is one anonymous shell built, as any visitor who is not signed in causes. Every check reads nobody's functions: an app that hands a function only to signed-in sessions is refused where an action calls it.
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- edd3271: `session.answerIntent(writers, asked)` also replays a query that exists: `asked` may be `{ fingerprint, context }`.
|
|
39
|
+
|
|
40
|
+
It is answered as the caller, as an intent is, with what vex knows of the query: the context keys it binds, the ones the call left out (`meta.missingContext`), its warnings. The wire answers a replay with the rows alone. A model that proves a query before it builds on it learns from this why a replay came back empty.
|
|
41
|
+
|
|
42
|
+
- f461b98: What a person generated and nobody has used for long enough is deleted, with `runtime.artifactsUnusedMs`.
|
|
43
|
+
- A version of an artifact a person saved is stamped as used (`artifacts.last_used_at`, migration `nisc.moss/6`) when a shell is built for them, once an hour at most, through the same vex entries and row rule as the save itself.
|
|
44
|
+
- A sweep runs as the server comes up and then every hour: every artifact of a person whose newest version was neither saved nor used within `artifactsUnusedMs` is deleted, every version of it, and the saves left empty with them. What is published for everybody (`*`) never ages; what the build ships is not a row.
|
|
45
|
+
- Without the setting nothing is deleted. `0` or less refuses the boot.
|
|
46
|
+
- The sweep is one raw statement in moss (`data/aging.ts`), entered in the raw-SQL ledger: vex keeps every statement of its own to one principal's rows, and the sweep crosses them all.
|
|
47
|
+
|
|
48
|
+
- 37422bf: `server.defaults(publisher)` publishes every kind a person saves: an action, a fragment and a read, beside a layout.
|
|
49
|
+
- **An action or a fragment is given its id by whoever publishes it**, as a shipped one has one: `server.defaults(who).save([{ kind: 'action', id: 'promo', body }])`. One without an id is refused (`moss: a published action is given its id by whoever publishes it: name it.`), and so is one under `generated.`. The charter grants it by that id: a new id needs a grant, and one that is a shipped action's or fragment's replaces the build's for everybody until it is reset.
|
|
50
|
+
- **A read vex wrote is published under its fingerprint**, `save([{ kind: 'read', id: '<fingerprint>' }])`, and is answered to everybody, nobody signed in included, after what the caller saved themselves. One under the fingerprint of a shipped entry is refused. A generated action anybody saves may replay it.
|
|
51
|
+
- **Checked as a person's save is, as the publisher, and then as a manifest.** An action's `fn:` calls are ones the publisher's roles grant and its reads ones they may replay; then the whole set in force is verified as a set handed over is, and a holder whose roles do not grant a call refuses the publish: `Publish refused — actions call functions the app does not have, or that their holders’ charter does not grant:`.
|
|
52
|
+
- **A default that no longer passes under a new build is left out, and the build's copies stand**, with a line said once per read of the rows: `[moss] what is published for everybody is left out, and the build’s copies stand: …`.
|
|
53
|
+
- `publishedArtifacts(saved, publisher)` of the running manifest takes who publishes, for the roles and reads a publish is held to; `server.defaults` resolves them from the publisher's principal.
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [edd3271]
|
|
56
|
+
- Updated dependencies [f461b98]
|
|
57
|
+
- Updated dependencies [2076f80]
|
|
58
|
+
- Updated dependencies [cdc89cc]
|
|
59
|
+
- Updated dependencies [37422bf]
|
|
60
|
+
- Updated dependencies [63b9ab5]
|
|
61
|
+
- Updated dependencies [6a62604]
|
|
62
|
+
- @niscorp/moss@0.8.0
|
|
63
|
+
- @niscorp/nova@0.5.0
|
|
64
|
+
|
|
3
65
|
## 0.7.0
|
|
4
66
|
|
|
5
67
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ page in the manifest), and what each one needs once it has been drawn.
|
|
|
55
55
|
|
|
56
56
|
| Field | |
|
|
57
57
|
|---|---|
|
|
58
|
-
| `boot` | stand the app up: `{ server, close? }` |
|
|
58
|
+
| `boot` | stand the app up: `{ server, close? }`; `nisc` then calls `server.checkFunctions()` (`nisc start` once `routes` and the site are mounted), which refuses an action calling a function the app does not have before anything is drawn or served |
|
|
59
59
|
| `draw` | a terminal that draws a screen to a string (moss's `terminal/react/server`, `/vue/server`, `/dom/server`) |
|
|
60
60
|
| `htmlAttributes?` | what the kit would put on `<html>` from an effect (a palette, a scheme) |
|
|
61
61
|
| `site?` | the address the site is served at (`"https://example.com"`). With it, every path's document says its own canonical address — see "The head of each page" |
|
package/dist/cli.js
CHANGED
|
@@ -38,6 +38,12 @@ var mossPlugin = async (configFile, dev2) => {
|
|
|
38
38
|
const project = Reflect.get(loaded, "project");
|
|
39
39
|
if (!isProject(project) || isShellProject(project)) throw new Error(`nisc: ${configFile} no longer describes an app behind moss.`);
|
|
40
40
|
const booted = await project.boot();
|
|
41
|
+
try {
|
|
42
|
+
await booted.server.checkFunctions();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
await booted.close?.();
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
41
47
|
const signIn = project.dev?.signIn;
|
|
42
48
|
return {
|
|
43
49
|
server: booted.server,
|
|
@@ -500,6 +506,7 @@ var survey = async (options, project) => {
|
|
|
500
506
|
const { exportDocuments } = await import('@niscorp/moss');
|
|
501
507
|
const booted = await project.boot();
|
|
502
508
|
try {
|
|
509
|
+
await booted.server.checkFunctions();
|
|
503
510
|
const paths = project.paths === void 0 ? defaultPaths(booted.server.pages) : await project.paths(booted.server);
|
|
504
511
|
return await exportDocuments({
|
|
505
512
|
server: booted.server,
|
|
@@ -596,6 +603,12 @@ var start = async (options) => {
|
|
|
596
603
|
...project.site !== void 0 ? { site: project.site } : {},
|
|
597
604
|
...project.tokenKey !== void 0 ? { tokenKey: project.tokenKey } : {}
|
|
598
605
|
});
|
|
606
|
+
try {
|
|
607
|
+
await booted.server.checkFunctions();
|
|
608
|
+
} catch (error) {
|
|
609
|
+
await booted.close?.();
|
|
610
|
+
throw error;
|
|
611
|
+
}
|
|
599
612
|
const httpServer = serve({ fetch: siteHandler(booted.server.fetch, { except: MOSS_PATHS }), port });
|
|
600
613
|
attachSocket(httpServer, booted.server.socket);
|
|
601
614
|
const url = await listening(httpServer, options);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/routes.ts","../src/shell-site.ts","../src/site.ts","../src/stylesheet.ts","../src/commands.ts","../src/cli.ts"],"names":["dev","join","pad","why","existsSync","resolve","sep","statSync","readFileSync","writeFileSync","require","createRequire","dirname","spawnSync","rmSync","httpServer","url"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,SAAA,GAAY,CAAC,KAAA,KACjB,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,cAAc,CAAA,KAAM,UAAA;AAE/F,IAAM,MAAA,GAAS,OAAO,IAAA,KAAmC;AACvD,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,cAAc,IAAA,CAAK,IAAA,EAAM,cAAc,CAAC,CAAA,CAAE,QAAQ,MAAM,CAAA;AAAA,EAClE,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,IAAI,CAAA,EAAA,CAAI,CAAA;AAAA,EAC/E;AACA,EAAA,M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E,EAAA,OAAA,CAAQ,IAAI,KAAK,CAAA;AACjB,EAAA,OAAO,YAAY,MAAA,IAAa,OAAA,KAAY,MAAA,IAAU,OAAA,KAAY,WAAW,CAAA,GAAI,CAAA;AACnF,CAAA;AAEA,IAAA,EAAK,CAAE,IAAA;AAAA;AAAA;AAAA,EAGL,CAAC,IAAA,KAAS,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA;AAAA,EAC3B,CAAC,KAAA,KAAmB;AAClB,IAAA,OAAA,CAAQ,KAAA,CAAM,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,UAAU,KAAK,CAAA;AAC5D,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAA","file":"cli.js","sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { configFileOf, isProject, isShellProject, loadProject } from './project';\nimport type { NiscMossProject } from './project';\n\n// Declared here rather than imported: vite is the app's dependency, and so are\n// its types.\ntype DevServer = {\n listen: () => Promise<unknown>;\n printUrls: () => void;\n resolvedUrls: { local: string[] } | null;\n close: () => Promise<void>;\n};\ntype ViteApi = { createServer: (config: { root: string; server?: { port: number }; plugins: unknown[] }) => Promise<DevServer> };\n\nconst isViteApi = (value: unknown): value is ViteApi =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createServer') === 'function';\n\nconst viteOf = async (root: string): Promise<ViteApi> => {\n let entry: string;\n try {\n entry = createRequire(join(root, 'package.json')).resolve('vite');\n } catch {\n throw new Error(`nisc: this app has no vite installed (looked from ${root}).`);\n }\n const loaded: unknown = await import(pathToFileURL(entry).href);\n if (!isViteApi(loaded)) throw new Error(`nisc: ${entry} is not vite.`);\n return loaded;\n};\n\n// Read once, when the command starts: a change to one takes a restart of\n// `nisc dev`, unlike the rest of the config, which vite reloads.\nexport const devPluginOptionsOf = (dev: NiscMossProject['dev']): { watch?: RegExp; owned?: RegExp; signInFromNetwork?: boolean } => ({\n ...(dev?.watch !== undefined ? { watch: dev.watch } : {}),\n ...(dev?.owned !== undefined ? { owned: dev.owned } : {}),\n ...(dev?.signInFromNetwork !== undefined ? { signInFromNetwork: dev.signInFromNetwork } : {}),\n});\n\nconst mossPlugin = async (configFile: string, dev: NiscMossProject['dev']): Promise<unknown> => {\n const { mossDev } = await import('@niscorp/moss/vite');\n return mossDev({\n label: 'nisc',\n ...devPluginOptionsOf(dev),\n app: async (load) => {\n const loaded = await load(`/${configFile}`);\n const project: unknown = Reflect.get(loaded, 'project');\n if (!isProject(project) || isShellProject(project)) throw new Error(`nisc: ${configFile} no longer describes an app behind moss.`);\n const booted = await project.boot();\n const signIn = project.dev?.signIn;\n return {\n server: booted.server,\n ...(booted.close !== undefined ? { close: booted.close } : {}),\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n ...(signIn !== undefined ? { signIn: (who: string) => signIn(booted.server, who) } : {}),\n };\n },\n });\n};\n\nexport const devServer = async (options: { root: string; port?: number }): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const configFile = configFileOf(options.root);\n const vite = await viteOf(options.root);\n const server = await vite.createServer({\n root: options.root,\n ...(options.port !== undefined ? { server: { port: options.port } } : {}),\n plugins: isShellProject(project) || configFile === undefined ? [] : [await mossPlugin(configFile, project.dev)],\n });\n await server.listen();\n server.printUrls();\n const url = server.resolvedUrls?.local[0] ?? `http://localhost:${options.port ?? 5173}/`;\n return { url, close: () => server.close() };\n};\n","export type RouteReport = {\n path: string;\n page?: string;\n drawn: boolean;\n live: boolean;\n why: readonly string[];\n drawnWith: readonly string[];\n settled: boolean;\n head?: { elements: readonly unknown[]; actions: readonly string[] };\n};\n\nexport const defaultPaths = (pages: readonly { name: string; path: string }[]): string[] => [\n '/',\n ...pages\n .map((page) => page.path)\n .filter((path) => !path.split('/').some((segment) => segment.startsWith(':')))\n .sort(),\n];\n\nexport const fileOf = (path: string): string => {\n const segments = path.split('?')[0]?.split('/').filter((segment) => segment !== '') ?? [];\n if (segments.some((segment) => segment === '..' || segment === '.')) throw new Error(`nisc: \"${path}\" is not a path a file can be written for.`);\n return [...segments, 'index.html'].join('/');\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\nexport const routeTable = (routes: readonly RouteReport[]): string => {\n const says = (route: RouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const rows = routes.map((route) => {\n const mark = !route.drawn ? '✗' : route.live ? '●' : '○';\n const what = route.page === undefined ? 'the app' : `page ${route.page}`;\n const served = !route.drawn ? 'not drawn' : route.live ? 'server' : 'file';\n const notes = [\n ...(route.drawn ? route.why : ['it could not be drawn — it goes out as the undrawn template']),\n ...(route.drawn && !route.settled ? ['it was still loading when the wait ran out — drawn with what it had'] : []),\n ...(route.drawnWith.length > 0 ? [`drawn with ${route.drawnWith.join(', ')} — as it answered at build`] : []),\n ];\n const head = headed && route.drawn ? [says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own'] : [];\n return { mark, path: route.path, what, served, notes, head };\n });\n const widths = {\n path: Math.max(5, ...rows.map((row) => row.path.length)),\n what: Math.max(4, ...rows.map((row) => row.what.length)),\n served: Math.max(9, ...rows.map((row) => row.served.length)),\n };\n const lines = [` ${pad('Route', widths.path + 2)}${pad('What', widths.what + 2)}${pad('Served as', widths.served + 2)}Because`];\n for (const row of rows) {\n const head = `${row.mark} ${pad(row.path, widths.path + 2)}${pad(row.what, widths.what + 2)}${pad(row.served, widths.served + 2)}`;\n const [first, ...rest] = [...(row.notes.length > 0 ? row.notes : ['nothing on it can still happen']), ...row.head];\n lines.push(`${head}${first ?? ''}`);\n for (const note of rest) lines.push(`${' '.repeat(head.length)}${note}`);\n }\n lines.push('');\n lines.push('○ file drawn once, for nobody in particular; nothing on it can still happen');\n lines.push('● server something on it can still happen; it wants moss behind it');\n return lines.join('\\n');\n};\n","import { spawnSync } from 'node:child_process';\nimport { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, extname, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { shellSettled, shellView } from '@niscorp/nova';\nimport type { Shell } from '@niscorp/nova';\nimport { headOf, placeHead } from '@niscorp/nova/document';\nimport type { ScreenHead } from '@niscorp/nova/document';\nimport { livenessOf } from '@niscorp/nova/reflect';\nimport type { NiscShellProject } from './project';\n\nconst DEFAULT_BUILD_WAIT_MS = 5000;\nexport const DEFAULT_ROOT = '<div id=\"root\"></div>';\n\nexport type ShellRouteReport = {\n path: string;\n html: string;\n problems: readonly string[];\n actions: readonly string[];\n opensWith: readonly string[];\n callsLater: readonly string[];\n listens: readonly string[];\n head?: ScreenHead;\n};\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<');\n\nexport const placeScreen = (template: string, screen: string, attributes: Record<string, string> = {}, root = DEFAULT_ROOT): string => {\n const written = Object.entries(attributes)\n .map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n .join('');\n return (\n template\n // functions, both, so nothing in the screen is read as a replacement pattern\n .replace(root, () => root.replace('></div>', () => `>${screen}</div>`))\n .replace(/<html([^>]*)>/, (whole, existing: string) => (written === '' ? whole : `<html${existing}${written}>`))\n );\n};\n\nconst factsOf = (shell: Shell): Pick<ShellRouteReport, 'actions' | 'opensWith' | 'callsLater' | 'listens'> => {\n const [actions, opensWith, callsLater, listens] = [new Set<string>(), new Set<string>(), new Set<string>(), new Set<string>()];\n for (const canvas of Object.values(shell.getState().canvases)) {\n for (const instance of canvas.stack) {\n const definition = shell.getRuntime(instance.id)?.definition;\n if (definition === undefined) continue;\n actions.add(definition.id);\n const liveness = livenessOf(definition);\n for (const channel of liveness.listens) listens.add(channel);\n for (const endpoint of liveness.endpoints) {\n const label = `${definition.id}.${endpoint.name}${endpoint.kind === 'fn' ? ' (a function)' : endpoint.url !== undefined ? ` (${endpoint.url})` : ''}`;\n if (endpoint.onOpen) opensWith.add(label);\n if (endpoint.later) callsLater.add(label);\n }\n }\n }\n const sorted = (set: Set<string>): string[] => [...set].sort();\n return { actions: sorted(actions), opensWith: sorted(opensWith), callsLater: sorted(callsLater), listens: sorted(listens) };\n};\n\ntype Drawn = { screen: string; whole: boolean; attributes: Record<string, string>; head: ScreenHead | undefined; facts: ReturnType<typeof factsOf> };\n\nconst documentOf = (project: NiscShellProject, template: string, path: string, drawn: Drawn): string =>\n placeHead(placeScreen(template, drawn.screen, drawn.attributes), drawn.head?.elements, { ...(project.site !== undefined ? { site: project.site } : {}), path });\n\nconst drawOnce = async (project: NiscShellProject, path: string): Promise<Drawn> => {\n const booted = await project.shell({ path });\n try {\n const whole = await shellSettled(booted.shell, { waitMs: project.waitMs ?? DEFAULT_BUILD_WAIT_MS });\n const screen = await project.draw(booted.shell);\n return { screen, whole, attributes: project.htmlAttributes?.(booted.shell) ?? {}, head: headOf(shellView(booted.shell).api), facts: factsOf(booted.shell) };\n } finally {\n await booted.close?.();\n }\n};\n\nconst said = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n// The adoption check runs in a process of its own (./adopt): a DOM has to exist\n// before the app's modules load, because an adapter decides what it is running\n// in when it is imported.\ntype Adoption = { path: string; complaints: string[] };\n\nconst isAdoption = (value: unknown): value is Adoption =>\n value !== null &&\n typeof value === 'object' &&\n typeof Reflect.get(value, 'path') === 'string' &&\n Array.isArray(Reflect.get(value, 'complaints'));\n\nconst adoptAll = (root: string, pages: readonly { path: string; screen: string }[]): Adoption[] => {\n if (pages.length === 0) return [];\n const here = dirname(fileURLToPath(import.meta.url));\n // built: beside this file. From source (the package's own tests): in dist.\n const entry = [join(here, 'adopt.js'), join(here, '..', 'dist', 'adopt.js')].find((candidate) => existsSync(candidate));\n if (entry === undefined) throw new Error('nisc: the adoption check is not built (packages/cli/dist/adopt.js).');\n const scratch = mkdtempSync(join(tmpdir(), 'nisc-adopt-'));\n try {\n const [asked, answered] = [join(scratch, 'pages.json'), join(scratch, 'adopted.json')];\n writeFileSync(asked, JSON.stringify(pages));\n const result = spawnSync(process.execPath, [entry, root, asked, answered], { cwd: root, stdio: ['ignore', 'ignore', 'pipe'], encoding: 'utf8' });\n if (!existsSync(answered)) {\n const why = result.stderr.trim().split('\\n').slice(-6).join('\\n');\n return pages.map((page) => ({ path: page.path, complaints: [`the adoption check could not run${why === '' ? '' : ` — ${why}`}`] }));\n }\n const parsed: unknown = JSON.parse(readFileSync(answered, 'utf8'));\n return Array.isArray(parsed) ? parsed.filter(isAdoption) : [];\n } finally {\n rmSync(scratch, { recursive: true, force: true });\n }\n};\n\nexport const surveyShell = async (root: string, project: NiscShellProject, template: string): Promise<ShellRouteReport[]> => {\n if (!template.includes(DEFAULT_ROOT)) {\n throw new Error(`nisc: the built index.html has no empty root (${DEFAULT_ROOT}) — that is where a screen goes.`);\n }\n const paths = project.paths === undefined ? ['/'] : await project.paths();\n const none = { actions: [], opensWith: [], callsLater: [], listens: [] };\n\n const first: { path: string; drawn?: Drawn; problems: string[] }[] = [];\n for (const path of paths) {\n const problems: string[] = [];\n let drawn: Drawn | undefined;\n try {\n drawn = await drawOnce(project, path);\n if (drawn.screen.trim() === '') problems.push('drawn: it drew to nothing');\n if (!drawn.whole) problems.push(`whole: it was still loading after ${project.waitMs ?? DEFAULT_BUILD_WAIT_MS}ms`);\n for (const why of drawn.head?.refused ?? []) problems.push(`head: ${why}`);\n const again = await drawOnce(project, path);\n if (again.screen !== drawn.screen) problems.push(`same twice: a second boot drew different markup${differenceOf(drawn.screen, again.screen)}`);\n const [head, headAgain] = [JSON.stringify(drawn.head ?? null), JSON.stringify(again.head ?? null)];\n if (headAgain !== head) problems.push(`same twice: a second boot said a different head${differenceOf(head, headAgain)}`);\n } catch (error) {\n problems.push(`drawn: ${said(error)}`);\n }\n first.push({ path, ...(drawn !== undefined ? { drawn } : {}), problems });\n }\n\n const adoptable = first.flatMap((route) => (route.drawn !== undefined && route.drawn.whole && route.drawn.screen.trim() !== '' ? [{ path: route.path, screen: route.drawn.screen }] : []));\n const adoptions = new Map(adoptAll(root, adoptable).map((adoption) => [adoption.path, adoption.complaints]));\n\n return first.map((route) => {\n const asked = adoptable.some((page) => page.path === route.path);\n const complaints = asked ? (adoptions.get(route.path) ?? ['the adoption check said nothing about it']) : [];\n const problems = [...route.problems, ...complaints.map((complaint) => `adopted: ${complaint}`)];\n return {\n path: route.path,\n html: route.drawn === undefined ? template : documentOf(project, template, route.path, route.drawn),\n problems,\n ...(route.drawn?.facts ?? none),\n ...(route.drawn?.head !== undefined ? { head: route.drawn.head } : {}),\n };\n });\n};\n\nconst differenceOf = (a: string, b: string): string => {\n let at = 0;\n while (at < a.length && at < b.length && a[at] === b[at]) at += 1;\n const around = (text: string): string => JSON.stringify(text.slice(Math.max(0, at - 30), at + 50));\n return ` — at character ${at}: ${around(a)} then ${around(b)}`;\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\nexport const shellRouteTable = (routes: readonly ShellRouteReport[]): string => {\n const width = Math.max(5, ...routes.map((route) => route.path.length)) + 2;\n const lines = [` ${pad('Route', width)}First screen`];\n const indent = ' '.repeat(width + 2);\n const says = (route: ShellRouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const headNote = (route: ShellRouteReport): string =>\n says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own';\n for (const route of routes) {\n const ok = route.problems.length === 0;\n const notes = ok\n ? [\n `drawn · whole · same twice · adopted${route.actions.length > 0 ? ` (${route.actions.join(', ')})` : ''}`,\n ...(route.opensWith.length > 0 ? [`opened with ${route.opensWith.join(', ')} — in the file as answered at build`] : []),\n ...(route.callsLater.length > 0 ? [`can still call ${route.callsLater.join(', ')}`] : []),\n ...(route.listens.length > 0 ? [`waits on ${route.listens.join(', ')}`] : []),\n ...(headed ? [headNote(route)] : []),\n ]\n : route.problems;\n const [head, ...rest] = notes;\n lines.push(`${ok ? '○' : '✗'} ${pad(route.path, width)}${head ?? ''}`);\n for (const note of rest) lines.push(`${indent}${note}`);\n }\n lines.push('');\n lines.push('○ a file: the first screen, drawn for nobody in particular; the page’s own shell picks it up');\n lines.push('✗ not written: a check did not hold');\n return lines.join('\\n');\n};\n\nconst TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.mjs': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.webp': 'image/webp',\n '.ico': 'image/x-icon',\n '.woff2': 'font/woff2',\n '.woff': 'font/woff',\n '.wasm': 'application/wasm',\n '.data': 'application/octet-stream',\n '.map': 'application/json; charset=utf-8',\n '.txt': 'text/plain; charset=utf-8',\n};\n\nexport const shellSite = (project: NiscShellProject, dist: string): ((request: Request) => Promise<Response>) => {\n const base = resolve(dist);\n return async (request) => {\n const path = decodeURIComponent(new URL(request.url).pathname);\n if (path !== '/' && path !== '/index.html') {\n const file = resolve(base, `.${path}`);\n const stats = file === base || file.startsWith(base + sep) ? statSync(file, { throwIfNoEntry: false }) : undefined;\n if (stats?.isFile() === true) {\n return new Response(readFileSync(file), {\n headers: { 'content-type': TYPES[extname(file)] ?? 'application/octet-stream', 'content-length': String(stats.size), 'last-modified': stats.mtime.toUTCString() },\n });\n }\n if (extname(path) !== '') return new Response('not found', { status: 404 });\n }\n const template = readFileSync(join(base, 'index.html'), 'utf8');\n const headers = { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' };\n try {\n const at = path === '/index.html' ? '/' : path;\n return new Response(documentOf(project, template, at, await drawOnce(project, at)), { headers });\n } catch (error) {\n console.error(`[nisc] \"${path}\" could not be drawn — serving it undrawn:`, error);\n return new Response(template, { headers });\n }\n };\n};\n","import { constants, createBrotliCompress, createGzip } from 'node:zlib';\nimport type { BrotliCompress, Gzip } from 'node:zlib';\n\nexport type SiteHandler<Rest extends readonly unknown[] = []> = (request: Request, ...rest: Rest) => Response | Promise<Response>;\n\nexport type SiteOptions = {\n except?: RegExp;\n};\n\nconst KEPT_PATHS = /^\\/assets\\//;\nconst KEPT_FOREVER = 'public, max-age=31536000, immutable';\n\nexport const withCaching =\n <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if ((request.method !== 'GET' && request.method !== 'HEAD') || response.status !== 200) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (response.headers.has('cache-control')) return response;\n\n const headers = new Headers(response.headers);\n if (KEPT_PATHS.test(path)) {\n headers.set('cache-control', KEPT_FOREVER);\n return new Response(response.body, { status: 200, headers });\n }\n headers.set('cache-control', 'no-cache');\n const [since, modified] = [request.headers.get('if-modified-since'), headers.get('last-modified')];\n if (since !== null && modified !== null && Date.parse(since) >= Date.parse(modified)) {\n await response.body?.cancel();\n headers.delete('content-length');\n return new Response(null, { status: 304, headers });\n }\n return new Response(response.body, { status: 200, headers });\n };\n\nconst COMPRESSIBLE = /^(text\\/(?!event-stream)|application\\/(json|javascript|xml|manifest\\+json|wasm)|image\\/svg\\+xml)/i;\nconst SMALL_BYTES = 1024;\n// fast enough to do per answer, and already smaller than gzip's best\nconst BROTLI_QUALITY = 5;\n\ntype Encoding = 'br' | 'gzip';\n\nconst encodingFor = (header: string | null): Encoding | undefined => {\n const offered = new Map<string, number>();\n for (const part of (header ?? '').toLowerCase().split(',')) {\n const [name = '', ...parameters] = part.split(';').map((piece) => piece.trim());\n const weight = parameters.find((parameter) => parameter.startsWith('q='));\n if (name !== '') offered.set(name, weight === undefined ? 1 : Number(weight.slice(2)));\n }\n if ((offered.get('br') ?? 0) > 0) return 'br';\n if ((offered.get('gzip') ?? 0) > 0) return 'gzip';\n return undefined;\n};\n\n// Flushed after every piece written: that is what keeps a streamed answer streaming.\nconst compressorFor = (encoding: Encoding): BrotliCompress | Gzip =>\n encoding === 'br'\n ? createBrotliCompress({ flush: constants.BROTLI_OPERATION_FLUSH, params: { [constants.BROTLI_PARAM_QUALITY]: BROTLI_QUALITY } })\n : createGzip({ flush: constants.Z_SYNC_FLUSH });\n\nconst compressedBody = (source: ReadableStream<Uint8Array>, encoding: Encoding, whole?: (bytes: Buffer<ArrayBuffer>) => void): ReadableStream<Uint8Array> => {\n const reader = source.getReader();\n const compressor = compressorFor(encoding);\n const pieces: Buffer[] = [];\n let isLetGo = false;\n let finished: () => void = () => undefined;\n const ended = new Promise<void>((done) => {\n finished = done;\n });\n return new ReadableStream<Uint8Array>({\n start: (controller) => {\n compressor.on('data', (piece: Buffer) => {\n if (isLetGo) return;\n if (whole !== undefined) pieces.push(piece);\n controller.enqueue(piece);\n });\n compressor.on('end', () => {\n if (!isLetGo) {\n whole?.(Buffer.concat(pieces));\n controller.close();\n }\n finished();\n });\n compressor.on('error', (error) => {\n if (!isLetGo) controller.error(error);\n finished();\n });\n },\n pull: async () => {\n const { done, value } = await reader.read().catch((error: unknown) => {\n compressor.destroy();\n throw error;\n });\n if (done) {\n compressor.end();\n return ended;\n }\n return new Promise<void>((taken) => {\n compressor.write(value, () => taken());\n });\n },\n cancel: async (reason) => {\n isLetGo = true;\n compressor.destroy();\n await reader.cancel(reason);\n },\n });\n};\n\nexport const withCompression = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> => {\n // No eviction: only an answer that says it will never change is remembered,\n // which is bounded by what the built folder holds under assets/.\n const remembered = new Map<string, Buffer<ArrayBuffer>>();\n return async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if (request.method !== 'GET' || response.status !== 200 || response.body === null) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (!COMPRESSIBLE.test(response.headers.get('content-type') ?? '')) return response;\n if (response.headers.has('content-encoding') || /no-transform/i.test(response.headers.get('cache-control') ?? '')) return response;\n\n // From here the answer depends on what was asked for, compressed or not: a\n // cache has to be told.\n const headers = new Headers(response.headers);\n const varies = (headers.get('vary') ?? '').toLowerCase().split(',').map((name) => name.trim());\n if (!varies.includes('accept-encoding')) headers.append('vary', 'Accept-Encoding');\n\n const encoding = encodingFor(request.headers.get('accept-encoding'));\n const length = headers.get('content-length');\n if (encoding === undefined || (length !== null && Number(length) < SMALL_BYTES)) return new Response(response.body, { status: 200, headers });\n\n headers.set('content-encoding', encoding);\n headers.delete('content-length');\n // A strong etag promises the exact bytes, and compression changes them.\n const etag = headers.get('etag');\n if (etag !== null && !etag.startsWith('W/')) headers.set('etag', `W/${etag}`);\n\n if (!/\\bimmutable\\b/i.test(headers.get('cache-control') ?? '')) return new Response(compressedBody(response.body, encoding), { status: 200, headers });\n const key = `${encoding} ${path} ${headers.get('last-modified') ?? ''}`;\n const known = remembered.get(key);\n if (known === undefined) return new Response(compressedBody(response.body, encoding, (bytes) => remembered.set(key, bytes)), { status: 200, headers });\n await response.body.cancel();\n headers.set('content-length', String(known.length));\n return new Response(known, { status: 200, headers });\n };\n};\n\nexport const siteHandler = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n withCompression(withCaching(handler, options), options);\n","import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { join, resolve, sep } from 'node:path';\n\nexport type StylesheetReport = {\n inPage: readonly { href: string; bytes: number }[];\n left: readonly { href: string; why: string }[];\n};\n\nexport type StylesheetRewrite = StylesheetReport & { html: string };\n\nconst attributesOf = (tag: string): Record<string, string> => {\n const found: Record<string, string> = {};\n for (const match of tag.slice(5).matchAll(/([^\\s\"'<>/=]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g)) {\n const name = match[1];\n if (name !== undefined) found[name.toLowerCase()] = match[2] ?? match[3] ?? match[4] ?? '';\n }\n return found;\n};\n\nconst PLAIN = new Set(['rel', 'href', 'crossorigin']);\n\nconst isPortableUrl = (url: string): boolean => url === '' || /^(\\/|data:|blob:|https?:|#)/i.test(url);\n\nconst whyStylesheetStays = (css: string): string | undefined => {\n if (/@import\\b/i.test(css)) return 'it imports another stylesheet';\n for (const match of css.matchAll(/url\\(\\s*(?:\"([^\"]*)\"|'([^']*)'|([^)]*?))\\s*\\)/gi)) {\n const url = (match[1] ?? match[2] ?? match[3] ?? '').trim();\n if (!isPortableUrl(url)) return `it names a file relative to itself (${url})`;\n }\n return undefined;\n};\n\nexport const stylesheetInPage = (html: string, read: (href: string) => string | undefined): StylesheetRewrite => {\n const inPage: { href: string; bytes: number }[] = [];\n const left: { href: string; why: string }[] = [];\n const rewritten = html.replace(/<link\\b[^>]*>/gi, (tag) => {\n const attributes = attributesOf(tag);\n if ((attributes['rel'] ?? '').toLowerCase() !== 'stylesheet') return tag;\n const href = attributes['href'] ?? '';\n const stays = (why: string): string => {\n left.push({ href, why });\n return tag;\n };\n const extra = Object.keys(attributes).filter((name) => !PLAIN.has(name));\n if (extra.length > 0) return stays(`its link says more than where it is (${extra.join(', ')})`);\n if (!href.startsWith('/') || href.startsWith('//') || /[?#]/.test(href)) return stays('it is not a path into the built folder');\n const css = read(href);\n if (css === undefined) return stays('it is not in the built folder');\n const why = whyStylesheetStays(css);\n if (why !== undefined) return stays(why);\n inPage.push({ href, bytes: Buffer.byteLength(css) });\n // A <style> ends at the first `</style`, whatever CSS thinks it is inside.\n // `\\/` is the same character to CSS, and not that to the HTML parser.\n return `<style>${css.replace(/<\\/(style)/gi, '<\\\\/$1')}</style>`;\n });\n return { html: rewritten, inPage, left };\n};\n\nexport const writeStylesheetIntoPage = (dist: string): StylesheetReport => {\n const page = join(dist, 'index.html');\n if (!existsSync(page)) return { inPage: [], left: [] };\n const base = resolve(dist);\n const read = (href: string): string | undefined => {\n const file = resolve(base, `.${href}`);\n return file.startsWith(base + sep) && existsSync(file) && statSync(file).isFile() ? readFileSync(file, 'utf8') : undefined;\n };\n const html = readFileSync(page, 'utf8');\n const rewrite = stylesheetInPage(html, read);\n if (rewrite.html !== html) writeFileSync(page, rewrite.html);\n return { inPage: rewrite.inPage, left: rewrite.left };\n};\n","import { spawn, spawnSync } from 'node:child_process';\nimport { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport type { AddressInfo } from 'node:net';\nimport { dirname, join, resolve } from 'node:path';\nimport { serve } from '@hono/node-server';\nimport type { ExportedDocument } from '@niscorp/moss';\nimport { devServer } from './dev';\nimport { isShellProject, loadProject } from './project';\nimport type { NiscMossProject, NiscProject, NiscShellProject } from './project';\nimport { defaultPaths, fileOf, routeTable } from './routes';\nimport { shellRouteTable, shellSite, surveyShell } from './shell-site';\nimport type { ShellRouteReport } from './shell-site';\nimport { siteHandler } from './site';\nimport { writeStylesheetIntoPage } from './stylesheet';\n\n// Moss is loaded by a dynamic import, and only for an app behind it: an app\n// with its own shell does not have it installed.\n\nexport type CommandOptions = {\n root: string;\n out?: string;\n allowLive?: boolean;\n port?: number;\n skipBundle?: boolean;\n dryRun?: boolean;\n print?: (line: string) => void;\n};\n\nconst say = (options: CommandOptions): ((line: string) => void) => options.print ?? ((line) => console.log(line));\n\nconst toolOf = (root: string, name: string, bin: string): string => {\n const require = createRequire(join(root, 'package.json'));\n let manifestPath: string;\n try {\n manifestPath = require.resolve(`${name}/package.json`);\n } catch {\n throw new Error(`nisc: this app has no ${name} installed (looked from ${root}).`);\n }\n const manifest: unknown = JSON.parse(readFileSync(manifestPath, 'utf8'));\n const bins: unknown = manifest !== null && typeof manifest === 'object' ? Reflect.get(manifest, 'bin') : undefined;\n const relative: unknown = typeof bins === 'string' ? bins : bins !== null && typeof bins === 'object' ? Reflect.get(bins, bin) : undefined;\n if (typeof relative !== 'string') throw new Error(`nisc: ${name} ships no \"${bin}\" command.`);\n return join(dirname(manifestPath), relative);\n};\n\nconst distOf = (root: string, project: NiscProject): string => resolve(root, project.dist ?? 'dist');\n\nconst bundle = (options: CommandOptions, project: NiscProject): void => {\n const result = spawnSync(process.execPath, [toolOf(options.root, 'vite', 'vite'), 'build'], { cwd: options.root, stdio: 'inherit' });\n if (result.status !== 0) throw new Error('nisc: the bundler failed — nothing was drawn.');\n if (project.stylesheet === 'file') return;\n const print = say(options);\n const { inPage, left } = writeStylesheetIntoPage(distOf(options.root, project));\n if (inPage.length + left.length > 0) print('');\n for (const sheet of inPage) print(`nisc: ${sheet.href} is in the page (${(sheet.bytes / 1024).toFixed(1)} kB) — one response paints it`);\n for (const sheet of left) print(`nisc: ${sheet.href} stays a file — ${sheet.why}`);\n if (inPage.length > 0) print(\" A Content-Security-Policy that forbids inline styles would refuse it: `stylesheet: 'file'` in nisc.config.ts keeps it a file.\");\n};\n\nconst warnOfOwnAssets = (options: CommandOptions): void => {\n if (!existsSync(join(options.root, 'public', 'assets'))) return;\n say(options)('nisc: public/assets/ holds files of your own. `nisc start` has browsers keep everything under /assets/ for a year, so a change to one of them will not be seen under the same name — keep them elsewhere in public/.');\n};\n\nconst warnOfOneAddress = (options: CommandOptions, project: NiscProject, template: string, paths: number): void => {\n if (project.site !== undefined || paths < 2 || !/<link\\b[^>]*\\brel\\s*=\\s*[\"']?canonical\\b/i.test(template)) return;\n say(options)('');\n say(options)(`nisc: index.html names one canonical address and this app has ${paths} paths — every file would say it lives there.`);\n say(options)(' `site: \"https://…\"` in nisc.config.ts gives each path its own.');\n};\n\nconst templateOf =(options: CommandOptions, project: NiscProject): string => {\n const template = join(distOf(options.root, project), 'index.html');\n if (!existsSync(template)) throw new Error(`nisc: no built terminal at ${template} — run \\`nisc build\\`.`);\n return readFileSync(template, 'utf8');\n};\n\nconst survey = async (options: CommandOptions, project: NiscMossProject): Promise<ExportedDocument[]> => {\n const template = templateOf(options, project);\n const { exportDocuments } = await import('@niscorp/moss');\n const booted = await project.boot();\n try {\n const paths = project.paths === undefined ? defaultPaths(booted.server.pages) : await project.paths(booted.server);\n return await exportDocuments({\n server: booted.server,\n template,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n paths,\n });\n } finally {\n await booted.close?.();\n }\n};\n\nexport type BuildResult =\n | { kind: 'moss'; ok: boolean; routes: ExportedDocument[] }\n | { kind: 'shell'; ok: boolean; routes: ShellRouteReport[] };\n\nconst buildShell = async (options: CommandOptions, project: NiscShellProject): Promise<BuildResult> => {\n const template = templateOf(options, project);\n const routes = await surveyShell(options.root, project, template);\n say(options)('');\n say(options)(shellRouteTable(routes));\n warnOfOneAddress(options, project, template, routes.length);\n return { kind: 'shell', ok: routes.every((route) => route.problems.length === 0), routes };\n};\n\nexport const build = async (options: CommandOptions): Promise<BuildResult> => {\n const project = await loadProject(options.root);\n if (options.skipBundle !== true) bundle(options, project);\n warnOfOwnAssets(options);\n if (isShellProject(project)) return buildShell(options, project);\n const routes = await survey(options, project);\n say(options)('');\n say(options)(routeTable(routes));\n warnOfOneAddress(options, project, templateOf(options, project), routes.length);\n return { kind: 'moss', ok: routes.every((route) => route.drawn), routes };\n};\n\nconst write = (options: CommandOptions, project: NiscProject, out: string, routes: readonly { path: string; html: string }[]): void => {\n rmSync(out, { recursive: true, force: true });\n cpSync(distOf(options.root, project), out, { recursive: true });\n for (const route of routes) {\n const file = join(out, fileOf(route.path));\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, route.html);\n }\n say(options)('');\n say(options)(`nisc: ${routes.length} paths written to ${out}`);\n};\n\nexport const exportSite = async (options: CommandOptions): Promise<{ written: boolean; result: BuildResult; out: string }> => {\n const project = await loadProject(options.root);\n const result = await build(options);\n const out = resolve(options.root, options.out ?? 'out');\n if (result.kind === 'shell') {\n if (!result.ok) {\n const failed = result.routes.filter((route) => route.problems.length > 0);\n say(options)('');\n say(options)(`nisc: ${failed.length} of ${result.routes.length} paths did not hold (${failed.map((route) => route.path).join(', ')}). Nothing was written.`);\n return { written: false, result, out };\n }\n write(options, project, out, result.routes);\n return { written: true, result, out };\n }\n const routes = result.routes;\n const live = routes.filter((route) => route.live || !route.drawn);\n if (live.length > 0 && options.allowLive !== true) {\n say(options)('');\n say(options)(`nisc: ${live.length} of ${routes.length} paths cannot be a file alone (${live.map((route) => route.path).join(', ')}).`);\n say(options)(' Nothing was written. With a server beside the files they still work: `nisc export --allow-live`.');\n return { written: false, result, out };\n }\n write(options, project, out, routes);\n return { written: true, result, out };\n};\n\nconst listening = async (httpServer: ReturnType<typeof serve>, options: CommandOptions): Promise<string> => {\n await new Promise<void>((up) => httpServer.once('listening', () => up()));\n const address = httpServer.address();\n const port = address !== null && typeof address === 'object' ? (address satisfies AddressInfo).port : options.port;\n return `http://localhost:${port}`;\n};\n\nexport const start = async (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const dist = distOf(options.root, project);\n if (!existsSync(join(dist, 'index.html'))) throw new Error(`nisc: no built terminal in ${dist} — run \\`nisc build\\`.`);\n const port = options.port ?? Number(process.env['PORT'] ?? 8787);\n if (isShellProject(project)) {\n const httpServer = serve({ fetch: siteHandler(shellSite(project, dist)), port });\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built app, each path’s first screen drawn; the shell is the page’s own`);\n return { url, close: async () => void httpServer.close() };\n }\n const { attachSocket, mountSite, MOSS_PATHS } = await import('@niscorp/moss/node');\n const booted = await project.boot();\n await project.routes?.(booted.server);\n mountSite(booted.server, {\n dist,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n });\n const httpServer = serve({ fetch: siteHandler(booted.server.fetch, { except: MOSS_PATHS }), port });\n attachSocket(httpServer, booted.server.socket);\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built terminal, its pages drawn; the socket at /socket`);\n return {\n url,\n close: async () => {\n httpServer.close();\n await booted.close?.();\n },\n };\n};\n\nexport const migrate = async (options: CommandOptions): Promise<void> => {\n const project = await loadProject(options.root);\n if (isShellProject(project) || project.app === undefined || project.runtime === undefined) {\n throw new Error('nisc: `nisc migrate` needs `app` and `runtime` in nisc.config.ts — the manifest, and the environment it runs on.');\n }\n const { migrateTables } = await import('@niscorp/moss');\n const print = say(options);\n const isDryRun = options.dryRun === true;\n const runtime = await project.runtime();\n try {\n const report = await migrateTables(runtime, project.app, isDryRun ? { dryRun: true } : {});\n if (report.applied.length === 0) print('nisc: nothing to migrate');\n else print(isDryRun ? `nisc: would apply ${report.applied.length} — rolled back, nothing changed` : `nisc: applied ${report.applied.length}`);\n for (const migration of report.applied) print(` ${migration.ref} ${migration.description}`);\n if (report.removed.length > 0) print(`nisc: this run removes ${report.removed.join(', ')}`);\n if (report.retyped.length > 0) print(`nisc: this run changes the type of ${report.retyped.join(', ')}`);\n if (report.alreadyBroken.length > 0) print('nisc: not fitting before this run either, and seeded as they are — said, not refused:');\n for (const entry of report.alreadyBroken) print(` ${entry}`);\n } finally {\n await runtime.close?.();\n }\n};\n\nconst handOver = (options: CommandOptions, tool: string, args: readonly string[]): Promise<number> =>\n new Promise((done) => {\n const child = spawn(process.execPath, [tool, ...args], { cwd: options.root, stdio: 'inherit' });\n child.once('exit', (code) => done(code ?? 1));\n });\n\nexport const dev = (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> =>\n devServer({ root: options.root, ...(options.port !== undefined ? { port: options.port } : {}) });\n\nexport const check = async (options: CommandOptions): Promise<number> => {\n const project = await loadProject(options.root);\n return handOver(options, toolOf(options.root, 'tsx', 'tsx'), [project.checks ?? 'src/dev/all-checks.ts']);\n};\n","import { resolve } from 'node:path';\nimport { build, check, dev, exportSite, migrate, start } from './commands';\nimport type { CommandOptions } from './commands';\n\nconst USAGE = `nisc — the command for a nisc application\n\n nisc dev the app's dev server — its vite, with the app server inside\n nisc build bundle the app, draw every path, and check what was drawn\n nisc export build, then write every path as a file (the site as a folder)\n nisc start serve the built app, each path's first screen drawn\n nisc check the app's check suite\n nisc migrate apply the tables' pending migrations, if the app's entries fit the result\n\n --root <dir> the app's root (default: here) — where nisc.config.ts is\n --out <dir> export: where the files go (default: out)\n --allow-live export: write even though some path wants a server behind it\n --port <n> dev, start: the port (start: $PORT, then 8787)\n --skip-bundle build, export: the terminal is already built\n --check migrate: do all of it, then roll it back\n\nAn app says in nisc.config.ts how it boots and how one of its screens is drawn.\nBehind moss (boot + draw): which paths exist and what each needs is read off the\nserver. With its own shell (shell + draw + adopt): every path is drawn from the\napp's own boot, and a file is written only if the page's boot picks it up clean.`;\n\nconst valueAfter = (args: readonly string[], flag: string): string | undefined => {\n const at = args.indexOf(flag);\n return at < 0 ? undefined : args[at + 1];\n};\n\nconst main = async (): Promise<number> => {\n const [command, ...args] = process.argv.slice(2);\n const port = valueAfter(args, '--port');\n const out = valueAfter(args, '--out');\n const options: CommandOptions = {\n root: resolve(valueAfter(args, '--root') ?? process.cwd()),\n ...(out !== undefined ? { out } : {}),\n ...(port !== undefined ? { port: Number(port) } : {}),\n allowLive: args.includes('--allow-live'),\n skipBundle: args.includes('--skip-bundle'),\n };\n\n if (command === 'dev' || command === 'start') {\n const served = command === 'dev' ? await dev(options) : await start(options);\n const stop = (): void => {\n void served.close().finally(() => process.exit(0));\n };\n process.on('SIGINT', stop);\n process.on('SIGTERM', stop);\n return new Promise<number>(() => undefined);\n }\n if (command === 'check') return check(options);\n if (command === 'migrate') {\n await migrate({ ...options, dryRun: args.includes('--check') });\n return 0;\n }\n if (command === 'build') {\n return (await build(options)).ok ? 0 : 1;\n }\n if (command === 'export') return (await exportSite(options)).written ? 0 : 1;\n console.log(USAGE);\n return command === undefined || command === 'help' || command === '--help' ? 0 : 1;\n};\n\nmain().then(\n // An explicit exit: an app's own handles (a database, a timer) would keep a\n // finished command open.\n (code) => process.exit(code),\n (error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n },\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/routes.ts","../src/shell-site.ts","../src/site.ts","../src/stylesheet.ts","../src/commands.ts","../src/cli.ts"],"names":["dev","join","pad","why","existsSync","resolve","sep","statSync","readFileSync","writeFileSync","require","createRequire","dirname","spawnSync","rmSync","httpServer","url"],"mappings":";;;;;;;;;;;;;AAgBA,IAAM,SAAA,GAAY,CAAC,KAAA,KACjB,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,IAAY,OAAO,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,cAAc,CAAA,KAAM,UAAA;AAE/F,IAAM,MAAA,GAAS,OAAO,IAAA,KAAmC;AACvD,EAAA,IAAI,KAAA;AACJ,EAAA,IAAI;AACF,IAAA,KAAA,GAAQ,cAAc,IAAA,CAAK,IAAA,EAAM,cAAc,CAAC,CAAA,CAAE,QAAQ,MAAM,CAAA;AAAA,EAClE,CAAA,CAAA,MAAQ;AACN,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kDAAA,EAAqD,IAAI,CAAA,EAAA,CAAI,CAAA;AAAA,EAC/E;AACA,EAAA,MAAM,MAAA,GAAkB,MAAM,OAAO,aAAA,CAAc,KAAK,CAAA,CAAE,IAAA,CAAA;AAC1D,EAAA,IAAI,CAAC,UAAU,MAAM,CAAA,QAAS,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,KAAK,CAAA,aAAA,CAAe,CAAA;AACrE,EAAA,OAAO,MAAA;AACT,CAAA;AAIO,IAAM,kBAAA,GAAqB,CAACA,IAAAA,MAAkG;AAAA,EACnI,GAAIA,MAAK,KAAA,KAAU,MAAA,GAAY,EAAE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,WAAW,OAAO,CAAA,EAAG,UAAU,CAAA,GAAI,CAAA;AAC3E,EAAA,OAAA,CAAQ,IAAI,KAAK,CAAA;AACjB,EAAA,OAAO,YAAY,MAAA,IAAa,OAAA,KAAY,MAAA,IAAU,OAAA,KAAY,WAAW,CAAA,GAAI,CAAA;AACnF,CAAA;AAEA,IAAA,EAAK,CAAE,IAAA;AAAA;AAAA;AAAA,EAGL,CAAC,IAAA,KAAS,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAA;AAAA,EAC3B,CAAC,KAAA,KAAmB;AAClB,IAAA,OAAA,CAAQ,KAAA,CAAM,KAAA,YAAiB,KAAA,GAAQ,KAAA,CAAM,UAAU,KAAK,CAAA;AAC5D,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAA","file":"cli.js","sourcesContent":["import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { configFileOf, isProject, isShellProject, loadProject } from './project';\nimport type { NiscMossProject } from './project';\n\n// Declared here rather than imported: vite is the app's dependency, and so are\n// its types.\ntype DevServer = {\n listen: () => Promise<unknown>;\n printUrls: () => void;\n resolvedUrls: { local: string[] } | null;\n close: () => Promise<void>;\n};\ntype ViteApi = { createServer: (config: { root: string; server?: { port: number }; plugins: unknown[] }) => Promise<DevServer> };\n\nconst isViteApi = (value: unknown): value is ViteApi =>\n value !== null && typeof value === 'object' && typeof Reflect.get(value, 'createServer') === 'function';\n\nconst viteOf = async (root: string): Promise<ViteApi> => {\n let entry: string;\n try {\n entry = createRequire(join(root, 'package.json')).resolve('vite');\n } catch {\n throw new Error(`nisc: this app has no vite installed (looked from ${root}).`);\n }\n const loaded: unknown = await import(pathToFileURL(entry).href);\n if (!isViteApi(loaded)) throw new Error(`nisc: ${entry} is not vite.`);\n return loaded;\n};\n\n// Read once, when the command starts: a change to one takes a restart of\n// `nisc dev`, unlike the rest of the config, which vite reloads.\nexport const devPluginOptionsOf = (dev: NiscMossProject['dev']): { watch?: RegExp; owned?: RegExp; signInFromNetwork?: boolean } => ({\n ...(dev?.watch !== undefined ? { watch: dev.watch } : {}),\n ...(dev?.owned !== undefined ? { owned: dev.owned } : {}),\n ...(dev?.signInFromNetwork !== undefined ? { signInFromNetwork: dev.signInFromNetwork } : {}),\n});\n\nconst mossPlugin = async (configFile: string, dev: NiscMossProject['dev']): Promise<unknown> => {\n const { mossDev } = await import('@niscorp/moss/vite');\n return mossDev({\n label: 'nisc',\n ...devPluginOptionsOf(dev),\n app: async (load) => {\n const loaded = await load(`/${configFile}`);\n const project: unknown = Reflect.get(loaded, 'project');\n if (!isProject(project) || isShellProject(project)) throw new Error(`nisc: ${configFile} no longer describes an app behind moss.`);\n const booted = await project.boot();\n try {\n await booted.server.checkFunctions();\n } catch (error) {\n await booted.close?.();\n throw error;\n }\n const signIn = project.dev?.signIn;\n return {\n server: booted.server,\n ...(booted.close !== undefined ? { close: booted.close } : {}),\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n ...(signIn !== undefined ? { signIn: (who: string) => signIn(booted.server, who) } : {}),\n };\n },\n });\n};\n\nexport const devServer = async (options: { root: string; port?: number }): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const configFile = configFileOf(options.root);\n const vite = await viteOf(options.root);\n const server = await vite.createServer({\n root: options.root,\n ...(options.port !== undefined ? { server: { port: options.port } } : {}),\n plugins: isShellProject(project) || configFile === undefined ? [] : [await mossPlugin(configFile, project.dev)],\n });\n await server.listen();\n server.printUrls();\n const url = server.resolvedUrls?.local[0] ?? `http://localhost:${options.port ?? 5173}/`;\n return { url, close: () => server.close() };\n};\n","export type RouteReport = {\n path: string;\n page?: string;\n drawn: boolean;\n live: boolean;\n why: readonly string[];\n drawnWith: readonly string[];\n settled: boolean;\n head?: { elements: readonly unknown[]; actions: readonly string[] };\n};\n\nexport const defaultPaths = (pages: readonly { name: string; path: string }[]): string[] => [\n '/',\n ...pages\n .map((page) => page.path)\n .filter((path) => !path.split('/').some((segment) => segment.startsWith(':')))\n .sort(),\n];\n\nexport const fileOf = (path: string): string => {\n const segments = path.split('?')[0]?.split('/').filter((segment) => segment !== '') ?? [];\n if (segments.some((segment) => segment === '..' || segment === '.')) throw new Error(`nisc: \"${path}\" is not a path a file can be written for.`);\n return [...segments, 'index.html'].join('/');\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\nexport const routeTable = (routes: readonly RouteReport[]): string => {\n const says = (route: RouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const rows = routes.map((route) => {\n const mark = !route.drawn ? '✗' : route.live ? '●' : '○';\n const what = route.page === undefined ? 'the app' : `page ${route.page}`;\n const served = !route.drawn ? 'not drawn' : route.live ? 'server' : 'file';\n const notes = [\n ...(route.drawn ? route.why : ['it could not be drawn — it goes out as the undrawn template']),\n ...(route.drawn && !route.settled ? ['it was still loading when the wait ran out — drawn with what it had'] : []),\n ...(route.drawnWith.length > 0 ? [`drawn with ${route.drawnWith.join(', ')} — as it answered at build`] : []),\n ];\n const head = headed && route.drawn ? [says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own'] : [];\n return { mark, path: route.path, what, served, notes, head };\n });\n const widths = {\n path: Math.max(5, ...rows.map((row) => row.path.length)),\n what: Math.max(4, ...rows.map((row) => row.what.length)),\n served: Math.max(9, ...rows.map((row) => row.served.length)),\n };\n const lines = [` ${pad('Route', widths.path + 2)}${pad('What', widths.what + 2)}${pad('Served as', widths.served + 2)}Because`];\n for (const row of rows) {\n const head = `${row.mark} ${pad(row.path, widths.path + 2)}${pad(row.what, widths.what + 2)}${pad(row.served, widths.served + 2)}`;\n const [first, ...rest] = [...(row.notes.length > 0 ? row.notes : ['nothing on it can still happen']), ...row.head];\n lines.push(`${head}${first ?? ''}`);\n for (const note of rest) lines.push(`${' '.repeat(head.length)}${note}`);\n }\n lines.push('');\n lines.push('○ file drawn once, for nobody in particular; nothing on it can still happen');\n lines.push('● server something on it can still happen; it wants moss behind it');\n return lines.join('\\n');\n};\n","import { spawnSync } from 'node:child_process';\nimport { existsSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { dirname, extname, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { shellSettled, shellView } from '@niscorp/nova';\nimport type { Shell } from '@niscorp/nova';\nimport { headOf, placeHead } from '@niscorp/nova/document';\nimport type { ScreenHead } from '@niscorp/nova/document';\nimport { livenessOf } from '@niscorp/nova/reflect';\nimport type { NiscShellProject } from './project';\n\nconst DEFAULT_BUILD_WAIT_MS = 5000;\nexport const DEFAULT_ROOT = '<div id=\"root\"></div>';\n\nexport type ShellRouteReport = {\n path: string;\n html: string;\n problems: readonly string[];\n actions: readonly string[];\n opensWith: readonly string[];\n callsLater: readonly string[];\n listens: readonly string[];\n head?: ScreenHead;\n};\n\nconst escapeAttribute = (value: string): string => value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<');\n\nexport const placeScreen = (template: string, screen: string, attributes: Record<string, string> = {}, root = DEFAULT_ROOT): string => {\n const written = Object.entries(attributes)\n .map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n .join('');\n return (\n template\n // functions, both, so nothing in the screen is read as a replacement pattern\n .replace(root, () => root.replace('></div>', () => `>${screen}</div>`))\n .replace(/<html([^>]*)>/, (whole, existing: string) => (written === '' ? whole : `<html${existing}${written}>`))\n );\n};\n\nconst factsOf = (shell: Shell): Pick<ShellRouteReport, 'actions' | 'opensWith' | 'callsLater' | 'listens'> => {\n const [actions, opensWith, callsLater, listens] = [new Set<string>(), new Set<string>(), new Set<string>(), new Set<string>()];\n for (const canvas of Object.values(shell.getState().canvases)) {\n for (const instance of canvas.stack) {\n const definition = shell.getRuntime(instance.id)?.definition;\n if (definition === undefined) continue;\n actions.add(definition.id);\n const liveness = livenessOf(definition);\n for (const channel of liveness.listens) listens.add(channel);\n for (const endpoint of liveness.endpoints) {\n const label = `${definition.id}.${endpoint.name}${endpoint.kind === 'fn' ? ' (a function)' : endpoint.url !== undefined ? ` (${endpoint.url})` : ''}`;\n if (endpoint.onOpen) opensWith.add(label);\n if (endpoint.later) callsLater.add(label);\n }\n }\n }\n const sorted = (set: Set<string>): string[] => [...set].sort();\n return { actions: sorted(actions), opensWith: sorted(opensWith), callsLater: sorted(callsLater), listens: sorted(listens) };\n};\n\ntype Drawn = { screen: string; whole: boolean; attributes: Record<string, string>; head: ScreenHead | undefined; facts: ReturnType<typeof factsOf> };\n\nconst documentOf = (project: NiscShellProject, template: string, path: string, drawn: Drawn): string =>\n placeHead(placeScreen(template, drawn.screen, drawn.attributes), drawn.head?.elements, { ...(project.site !== undefined ? { site: project.site } : {}), path });\n\nconst drawOnce = async (project: NiscShellProject, path: string): Promise<Drawn> => {\n const booted = await project.shell({ path });\n try {\n const whole = await shellSettled(booted.shell, { waitMs: project.waitMs ?? DEFAULT_BUILD_WAIT_MS });\n const screen = await project.draw(booted.shell);\n return { screen, whole, attributes: project.htmlAttributes?.(booted.shell) ?? {}, head: headOf(shellView(booted.shell).api), facts: factsOf(booted.shell) };\n } finally {\n await booted.close?.();\n }\n};\n\nconst said = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n// The adoption check runs in a process of its own (./adopt): a DOM has to exist\n// before the app's modules load, because an adapter decides what it is running\n// in when it is imported.\ntype Adoption = { path: string; complaints: string[] };\n\nconst isAdoption = (value: unknown): value is Adoption =>\n value !== null &&\n typeof value === 'object' &&\n typeof Reflect.get(value, 'path') === 'string' &&\n Array.isArray(Reflect.get(value, 'complaints'));\n\nconst adoptAll = (root: string, pages: readonly { path: string; screen: string }[]): Adoption[] => {\n if (pages.length === 0) return [];\n const here = dirname(fileURLToPath(import.meta.url));\n // built: beside this file. From source (the package's own tests): in dist.\n const entry = [join(here, 'adopt.js'), join(here, '..', 'dist', 'adopt.js')].find((candidate) => existsSync(candidate));\n if (entry === undefined) throw new Error('nisc: the adoption check is not built (packages/cli/dist/adopt.js).');\n const scratch = mkdtempSync(join(tmpdir(), 'nisc-adopt-'));\n try {\n const [asked, answered] = [join(scratch, 'pages.json'), join(scratch, 'adopted.json')];\n writeFileSync(asked, JSON.stringify(pages));\n const result = spawnSync(process.execPath, [entry, root, asked, answered], { cwd: root, stdio: ['ignore', 'ignore', 'pipe'], encoding: 'utf8' });\n if (!existsSync(answered)) {\n const why = result.stderr.trim().split('\\n').slice(-6).join('\\n');\n return pages.map((page) => ({ path: page.path, complaints: [`the adoption check could not run${why === '' ? '' : ` — ${why}`}`] }));\n }\n const parsed: unknown = JSON.parse(readFileSync(answered, 'utf8'));\n return Array.isArray(parsed) ? parsed.filter(isAdoption) : [];\n } finally {\n rmSync(scratch, { recursive: true, force: true });\n }\n};\n\nexport const surveyShell = async (root: string, project: NiscShellProject, template: string): Promise<ShellRouteReport[]> => {\n if (!template.includes(DEFAULT_ROOT)) {\n throw new Error(`nisc: the built index.html has no empty root (${DEFAULT_ROOT}) — that is where a screen goes.`);\n }\n const paths = project.paths === undefined ? ['/'] : await project.paths();\n const none = { actions: [], opensWith: [], callsLater: [], listens: [] };\n\n const first: { path: string; drawn?: Drawn; problems: string[] }[] = [];\n for (const path of paths) {\n const problems: string[] = [];\n let drawn: Drawn | undefined;\n try {\n drawn = await drawOnce(project, path);\n if (drawn.screen.trim() === '') problems.push('drawn: it drew to nothing');\n if (!drawn.whole) problems.push(`whole: it was still loading after ${project.waitMs ?? DEFAULT_BUILD_WAIT_MS}ms`);\n for (const why of drawn.head?.refused ?? []) problems.push(`head: ${why}`);\n const again = await drawOnce(project, path);\n if (again.screen !== drawn.screen) problems.push(`same twice: a second boot drew different markup${differenceOf(drawn.screen, again.screen)}`);\n const [head, headAgain] = [JSON.stringify(drawn.head ?? null), JSON.stringify(again.head ?? null)];\n if (headAgain !== head) problems.push(`same twice: a second boot said a different head${differenceOf(head, headAgain)}`);\n } catch (error) {\n problems.push(`drawn: ${said(error)}`);\n }\n first.push({ path, ...(drawn !== undefined ? { drawn } : {}), problems });\n }\n\n const adoptable = first.flatMap((route) => (route.drawn !== undefined && route.drawn.whole && route.drawn.screen.trim() !== '' ? [{ path: route.path, screen: route.drawn.screen }] : []));\n const adoptions = new Map(adoptAll(root, adoptable).map((adoption) => [adoption.path, adoption.complaints]));\n\n return first.map((route) => {\n const asked = adoptable.some((page) => page.path === route.path);\n const complaints = asked ? (adoptions.get(route.path) ?? ['the adoption check said nothing about it']) : [];\n const problems = [...route.problems, ...complaints.map((complaint) => `adopted: ${complaint}`)];\n return {\n path: route.path,\n html: route.drawn === undefined ? template : documentOf(project, template, route.path, route.drawn),\n problems,\n ...(route.drawn?.facts ?? none),\n ...(route.drawn?.head !== undefined ? { head: route.drawn.head } : {}),\n };\n });\n};\n\nconst differenceOf = (a: string, b: string): string => {\n let at = 0;\n while (at < a.length && at < b.length && a[at] === b[at]) at += 1;\n const around = (text: string): string => JSON.stringify(text.slice(Math.max(0, at - 30), at + 50));\n return ` — at character ${at}: ${around(a)} then ${around(b)}`;\n};\n\nconst pad = (text: string, width: number): string => text + ' '.repeat(Math.max(0, width - text.length));\n\nexport const shellRouteTable = (routes: readonly ShellRouteReport[]): string => {\n const width = Math.max(5, ...routes.map((route) => route.path.length)) + 2;\n const lines = [` ${pad('Route', width)}First screen`];\n const indent = ' '.repeat(width + 2);\n const says = (route: ShellRouteReport): boolean => (route.head?.elements.length ?? 0) > 0;\n const headed = routes.some(says);\n const headNote = (route: ShellRouteReport): string =>\n says(route) ? `head: its own, said by ${route.head?.actions.join(', ') || 'the shell’s chrome'}` : 'head: the template’s own';\n for (const route of routes) {\n const ok = route.problems.length === 0;\n const notes = ok\n ? [\n `drawn · whole · same twice · adopted${route.actions.length > 0 ? ` (${route.actions.join(', ')})` : ''}`,\n ...(route.opensWith.length > 0 ? [`opened with ${route.opensWith.join(', ')} — in the file as answered at build`] : []),\n ...(route.callsLater.length > 0 ? [`can still call ${route.callsLater.join(', ')}`] : []),\n ...(route.listens.length > 0 ? [`waits on ${route.listens.join(', ')}`] : []),\n ...(headed ? [headNote(route)] : []),\n ]\n : route.problems;\n const [head, ...rest] = notes;\n lines.push(`${ok ? '○' : '✗'} ${pad(route.path, width)}${head ?? ''}`);\n for (const note of rest) lines.push(`${indent}${note}`);\n }\n lines.push('');\n lines.push('○ a file: the first screen, drawn for nobody in particular; the page’s own shell picks it up');\n lines.push('✗ not written: a check did not hold');\n return lines.join('\\n');\n};\n\nconst TYPES: Record<string, string> = {\n '.html': 'text/html; charset=utf-8',\n '.js': 'text/javascript; charset=utf-8',\n '.mjs': 'text/javascript; charset=utf-8',\n '.css': 'text/css; charset=utf-8',\n '.json': 'application/json; charset=utf-8',\n '.svg': 'image/svg+xml',\n '.png': 'image/png',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.webp': 'image/webp',\n '.ico': 'image/x-icon',\n '.woff2': 'font/woff2',\n '.woff': 'font/woff',\n '.wasm': 'application/wasm',\n '.data': 'application/octet-stream',\n '.map': 'application/json; charset=utf-8',\n '.txt': 'text/plain; charset=utf-8',\n};\n\nexport const shellSite = (project: NiscShellProject, dist: string): ((request: Request) => Promise<Response>) => {\n const base = resolve(dist);\n return async (request) => {\n const path = decodeURIComponent(new URL(request.url).pathname);\n if (path !== '/' && path !== '/index.html') {\n const file = resolve(base, `.${path}`);\n const stats = file === base || file.startsWith(base + sep) ? statSync(file, { throwIfNoEntry: false }) : undefined;\n if (stats?.isFile() === true) {\n return new Response(readFileSync(file), {\n headers: { 'content-type': TYPES[extname(file)] ?? 'application/octet-stream', 'content-length': String(stats.size), 'last-modified': stats.mtime.toUTCString() },\n });\n }\n if (extname(path) !== '') return new Response('not found', { status: 404 });\n }\n const template = readFileSync(join(base, 'index.html'), 'utf8');\n const headers = { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-cache' };\n try {\n const at = path === '/index.html' ? '/' : path;\n return new Response(documentOf(project, template, at, await drawOnce(project, at)), { headers });\n } catch (error) {\n console.error(`[nisc] \"${path}\" could not be drawn — serving it undrawn:`, error);\n return new Response(template, { headers });\n }\n };\n};\n","import { constants, createBrotliCompress, createGzip } from 'node:zlib';\nimport type { BrotliCompress, Gzip } from 'node:zlib';\n\nexport type SiteHandler<Rest extends readonly unknown[] = []> = (request: Request, ...rest: Rest) => Response | Promise<Response>;\n\nexport type SiteOptions = {\n except?: RegExp;\n};\n\nconst KEPT_PATHS = /^\\/assets\\//;\nconst KEPT_FOREVER = 'public, max-age=31536000, immutable';\n\nexport const withCaching =\n <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if ((request.method !== 'GET' && request.method !== 'HEAD') || response.status !== 200) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (response.headers.has('cache-control')) return response;\n\n const headers = new Headers(response.headers);\n if (KEPT_PATHS.test(path)) {\n headers.set('cache-control', KEPT_FOREVER);\n return new Response(response.body, { status: 200, headers });\n }\n headers.set('cache-control', 'no-cache');\n const [since, modified] = [request.headers.get('if-modified-since'), headers.get('last-modified')];\n if (since !== null && modified !== null && Date.parse(since) >= Date.parse(modified)) {\n await response.body?.cancel();\n headers.delete('content-length');\n return new Response(null, { status: 304, headers });\n }\n return new Response(response.body, { status: 200, headers });\n };\n\nconst COMPRESSIBLE = /^(text\\/(?!event-stream)|application\\/(json|javascript|xml|manifest\\+json|wasm)|image\\/svg\\+xml)/i;\nconst SMALL_BYTES = 1024;\n// fast enough to do per answer, and already smaller than gzip's best\nconst BROTLI_QUALITY = 5;\n\ntype Encoding = 'br' | 'gzip';\n\nconst encodingFor = (header: string | null): Encoding | undefined => {\n const offered = new Map<string, number>();\n for (const part of (header ?? '').toLowerCase().split(',')) {\n const [name = '', ...parameters] = part.split(';').map((piece) => piece.trim());\n const weight = parameters.find((parameter) => parameter.startsWith('q='));\n if (name !== '') offered.set(name, weight === undefined ? 1 : Number(weight.slice(2)));\n }\n if ((offered.get('br') ?? 0) > 0) return 'br';\n if ((offered.get('gzip') ?? 0) > 0) return 'gzip';\n return undefined;\n};\n\n// Flushed after every piece written: that is what keeps a streamed answer streaming.\nconst compressorFor = (encoding: Encoding): BrotliCompress | Gzip =>\n encoding === 'br'\n ? createBrotliCompress({ flush: constants.BROTLI_OPERATION_FLUSH, params: { [constants.BROTLI_PARAM_QUALITY]: BROTLI_QUALITY } })\n : createGzip({ flush: constants.Z_SYNC_FLUSH });\n\nconst compressedBody = (source: ReadableStream<Uint8Array>, encoding: Encoding, whole?: (bytes: Buffer<ArrayBuffer>) => void): ReadableStream<Uint8Array> => {\n const reader = source.getReader();\n const compressor = compressorFor(encoding);\n const pieces: Buffer[] = [];\n let isLetGo = false;\n let finished: () => void = () => undefined;\n const ended = new Promise<void>((done) => {\n finished = done;\n });\n return new ReadableStream<Uint8Array>({\n start: (controller) => {\n compressor.on('data', (piece: Buffer) => {\n if (isLetGo) return;\n if (whole !== undefined) pieces.push(piece);\n controller.enqueue(piece);\n });\n compressor.on('end', () => {\n if (!isLetGo) {\n whole?.(Buffer.concat(pieces));\n controller.close();\n }\n finished();\n });\n compressor.on('error', (error) => {\n if (!isLetGo) controller.error(error);\n finished();\n });\n },\n pull: async () => {\n const { done, value } = await reader.read().catch((error: unknown) => {\n compressor.destroy();\n throw error;\n });\n if (done) {\n compressor.end();\n return ended;\n }\n return new Promise<void>((taken) => {\n compressor.write(value, () => taken());\n });\n },\n cancel: async (reason) => {\n isLetGo = true;\n compressor.destroy();\n await reader.cancel(reason);\n },\n });\n};\n\nexport const withCompression = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> => {\n // No eviction: only an answer that says it will never change is remembered,\n // which is bounded by what the built folder holds under assets/.\n const remembered = new Map<string, Buffer<ArrayBuffer>>();\n return async (request, ...rest) => {\n const response = await handler(request, ...rest);\n if (request.method !== 'GET' || response.status !== 200 || response.body === null) return response;\n const path = new URL(request.url).pathname;\n if (options.except?.test(path) === true) return response;\n if (!COMPRESSIBLE.test(response.headers.get('content-type') ?? '')) return response;\n if (response.headers.has('content-encoding') || /no-transform/i.test(response.headers.get('cache-control') ?? '')) return response;\n\n // From here the answer depends on what was asked for, compressed or not: a\n // cache has to be told.\n const headers = new Headers(response.headers);\n const varies = (headers.get('vary') ?? '').toLowerCase().split(',').map((name) => name.trim());\n if (!varies.includes('accept-encoding')) headers.append('vary', 'Accept-Encoding');\n\n const encoding = encodingFor(request.headers.get('accept-encoding'));\n const length = headers.get('content-length');\n if (encoding === undefined || (length !== null && Number(length) < SMALL_BYTES)) return new Response(response.body, { status: 200, headers });\n\n headers.set('content-encoding', encoding);\n headers.delete('content-length');\n // A strong etag promises the exact bytes, and compression changes them.\n const etag = headers.get('etag');\n if (etag !== null && !etag.startsWith('W/')) headers.set('etag', `W/${etag}`);\n\n if (!/\\bimmutable\\b/i.test(headers.get('cache-control') ?? '')) return new Response(compressedBody(response.body, encoding), { status: 200, headers });\n const key = `${encoding} ${path} ${headers.get('last-modified') ?? ''}`;\n const known = remembered.get(key);\n if (known === undefined) return new Response(compressedBody(response.body, encoding, (bytes) => remembered.set(key, bytes)), { status: 200, headers });\n await response.body.cancel();\n headers.set('content-length', String(known.length));\n return new Response(known, { status: 200, headers });\n };\n};\n\nexport const siteHandler = <Rest extends readonly unknown[]>(handler: SiteHandler<Rest>, options: SiteOptions = {}): SiteHandler<Rest> =>\n withCompression(withCaching(handler, options), options);\n","import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { join, resolve, sep } from 'node:path';\n\nexport type StylesheetReport = {\n inPage: readonly { href: string; bytes: number }[];\n left: readonly { href: string; why: string }[];\n};\n\nexport type StylesheetRewrite = StylesheetReport & { html: string };\n\nconst attributesOf = (tag: string): Record<string, string> => {\n const found: Record<string, string> = {};\n for (const match of tag.slice(5).matchAll(/([^\\s\"'<>/=]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g)) {\n const name = match[1];\n if (name !== undefined) found[name.toLowerCase()] = match[2] ?? match[3] ?? match[4] ?? '';\n }\n return found;\n};\n\nconst PLAIN = new Set(['rel', 'href', 'crossorigin']);\n\nconst isPortableUrl = (url: string): boolean => url === '' || /^(\\/|data:|blob:|https?:|#)/i.test(url);\n\nconst whyStylesheetStays = (css: string): string | undefined => {\n if (/@import\\b/i.test(css)) return 'it imports another stylesheet';\n for (const match of css.matchAll(/url\\(\\s*(?:\"([^\"]*)\"|'([^']*)'|([^)]*?))\\s*\\)/gi)) {\n const url = (match[1] ?? match[2] ?? match[3] ?? '').trim();\n if (!isPortableUrl(url)) return `it names a file relative to itself (${url})`;\n }\n return undefined;\n};\n\nexport const stylesheetInPage = (html: string, read: (href: string) => string | undefined): StylesheetRewrite => {\n const inPage: { href: string; bytes: number }[] = [];\n const left: { href: string; why: string }[] = [];\n const rewritten = html.replace(/<link\\b[^>]*>/gi, (tag) => {\n const attributes = attributesOf(tag);\n if ((attributes['rel'] ?? '').toLowerCase() !== 'stylesheet') return tag;\n const href = attributes['href'] ?? '';\n const stays = (why: string): string => {\n left.push({ href, why });\n return tag;\n };\n const extra = Object.keys(attributes).filter((name) => !PLAIN.has(name));\n if (extra.length > 0) return stays(`its link says more than where it is (${extra.join(', ')})`);\n if (!href.startsWith('/') || href.startsWith('//') || /[?#]/.test(href)) return stays('it is not a path into the built folder');\n const css = read(href);\n if (css === undefined) return stays('it is not in the built folder');\n const why = whyStylesheetStays(css);\n if (why !== undefined) return stays(why);\n inPage.push({ href, bytes: Buffer.byteLength(css) });\n // A <style> ends at the first `</style`, whatever CSS thinks it is inside.\n // `\\/` is the same character to CSS, and not that to the HTML parser.\n return `<style>${css.replace(/<\\/(style)/gi, '<\\\\/$1')}</style>`;\n });\n return { html: rewritten, inPage, left };\n};\n\nexport const writeStylesheetIntoPage = (dist: string): StylesheetReport => {\n const page = join(dist, 'index.html');\n if (!existsSync(page)) return { inPage: [], left: [] };\n const base = resolve(dist);\n const read = (href: string): string | undefined => {\n const file = resolve(base, `.${href}`);\n return file.startsWith(base + sep) && existsSync(file) && statSync(file).isFile() ? readFileSync(file, 'utf8') : undefined;\n };\n const html = readFileSync(page, 'utf8');\n const rewrite = stylesheetInPage(html, read);\n if (rewrite.html !== html) writeFileSync(page, rewrite.html);\n return { inPage: rewrite.inPage, left: rewrite.left };\n};\n","import { spawn, spawnSync } from 'node:child_process';\nimport { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport type { AddressInfo } from 'node:net';\nimport { dirname, join, resolve } from 'node:path';\nimport { serve } from '@hono/node-server';\nimport type { ExportedDocument } from '@niscorp/moss';\nimport { devServer } from './dev';\nimport { isShellProject, loadProject } from './project';\nimport type { NiscMossProject, NiscProject, NiscShellProject } from './project';\nimport { defaultPaths, fileOf, routeTable } from './routes';\nimport { shellRouteTable, shellSite, surveyShell } from './shell-site';\nimport type { ShellRouteReport } from './shell-site';\nimport { siteHandler } from './site';\nimport { writeStylesheetIntoPage } from './stylesheet';\n\n// Moss is loaded by a dynamic import, and only for an app behind it: an app\n// with its own shell does not have it installed.\n\nexport type CommandOptions = {\n root: string;\n out?: string;\n allowLive?: boolean;\n port?: number;\n skipBundle?: boolean;\n dryRun?: boolean;\n print?: (line: string) => void;\n};\n\nconst say = (options: CommandOptions): ((line: string) => void) => options.print ?? ((line) => console.log(line));\n\nconst toolOf = (root: string, name: string, bin: string): string => {\n const require = createRequire(join(root, 'package.json'));\n let manifestPath: string;\n try {\n manifestPath = require.resolve(`${name}/package.json`);\n } catch {\n throw new Error(`nisc: this app has no ${name} installed (looked from ${root}).`);\n }\n const manifest: unknown = JSON.parse(readFileSync(manifestPath, 'utf8'));\n const bins: unknown = manifest !== null && typeof manifest === 'object' ? Reflect.get(manifest, 'bin') : undefined;\n const relative: unknown = typeof bins === 'string' ? bins : bins !== null && typeof bins === 'object' ? Reflect.get(bins, bin) : undefined;\n if (typeof relative !== 'string') throw new Error(`nisc: ${name} ships no \"${bin}\" command.`);\n return join(dirname(manifestPath), relative);\n};\n\nconst distOf = (root: string, project: NiscProject): string => resolve(root, project.dist ?? 'dist');\n\nconst bundle = (options: CommandOptions, project: NiscProject): void => {\n const result = spawnSync(process.execPath, [toolOf(options.root, 'vite', 'vite'), 'build'], { cwd: options.root, stdio: 'inherit' });\n if (result.status !== 0) throw new Error('nisc: the bundler failed — nothing was drawn.');\n if (project.stylesheet === 'file') return;\n const print = say(options);\n const { inPage, left } = writeStylesheetIntoPage(distOf(options.root, project));\n if (inPage.length + left.length > 0) print('');\n for (const sheet of inPage) print(`nisc: ${sheet.href} is in the page (${(sheet.bytes / 1024).toFixed(1)} kB) — one response paints it`);\n for (const sheet of left) print(`nisc: ${sheet.href} stays a file — ${sheet.why}`);\n if (inPage.length > 0) print(\" A Content-Security-Policy that forbids inline styles would refuse it: `stylesheet: 'file'` in nisc.config.ts keeps it a file.\");\n};\n\nconst warnOfOwnAssets = (options: CommandOptions): void => {\n if (!existsSync(join(options.root, 'public', 'assets'))) return;\n say(options)('nisc: public/assets/ holds files of your own. `nisc start` has browsers keep everything under /assets/ for a year, so a change to one of them will not be seen under the same name — keep them elsewhere in public/.');\n};\n\nconst warnOfOneAddress = (options: CommandOptions, project: NiscProject, template: string, paths: number): void => {\n if (project.site !== undefined || paths < 2 || !/<link\\b[^>]*\\brel\\s*=\\s*[\"']?canonical\\b/i.test(template)) return;\n say(options)('');\n say(options)(`nisc: index.html names one canonical address and this app has ${paths} paths — every file would say it lives there.`);\n say(options)(' `site: \"https://…\"` in nisc.config.ts gives each path its own.');\n};\n\nconst templateOf =(options: CommandOptions, project: NiscProject): string => {\n const template = join(distOf(options.root, project), 'index.html');\n if (!existsSync(template)) throw new Error(`nisc: no built terminal at ${template} — run \\`nisc build\\`.`);\n return readFileSync(template, 'utf8');\n};\n\nconst survey = async (options: CommandOptions, project: NiscMossProject): Promise<ExportedDocument[]> => {\n const template = templateOf(options, project);\n const { exportDocuments } = await import('@niscorp/moss');\n const booted = await project.boot();\n try {\n await booted.server.checkFunctions();\n const paths = project.paths === undefined ? defaultPaths(booted.server.pages) : await project.paths(booted.server);\n return await exportDocuments({\n server: booted.server,\n template,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n paths,\n });\n } finally {\n await booted.close?.();\n }\n};\n\nexport type BuildResult =\n | { kind: 'moss'; ok: boolean; routes: ExportedDocument[] }\n | { kind: 'shell'; ok: boolean; routes: ShellRouteReport[] };\n\nconst buildShell = async (options: CommandOptions, project: NiscShellProject): Promise<BuildResult> => {\n const template = templateOf(options, project);\n const routes = await surveyShell(options.root, project, template);\n say(options)('');\n say(options)(shellRouteTable(routes));\n warnOfOneAddress(options, project, template, routes.length);\n return { kind: 'shell', ok: routes.every((route) => route.problems.length === 0), routes };\n};\n\nexport const build = async (options: CommandOptions): Promise<BuildResult> => {\n const project = await loadProject(options.root);\n if (options.skipBundle !== true) bundle(options, project);\n warnOfOwnAssets(options);\n if (isShellProject(project)) return buildShell(options, project);\n const routes = await survey(options, project);\n say(options)('');\n say(options)(routeTable(routes));\n warnOfOneAddress(options, project, templateOf(options, project), routes.length);\n return { kind: 'moss', ok: routes.every((route) => route.drawn), routes };\n};\n\nconst write = (options: CommandOptions, project: NiscProject, out: string, routes: readonly { path: string; html: string }[]): void => {\n rmSync(out, { recursive: true, force: true });\n cpSync(distOf(options.root, project), out, { recursive: true });\n for (const route of routes) {\n const file = join(out, fileOf(route.path));\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, route.html);\n }\n say(options)('');\n say(options)(`nisc: ${routes.length} paths written to ${out}`);\n};\n\nexport const exportSite = async (options: CommandOptions): Promise<{ written: boolean; result: BuildResult; out: string }> => {\n const project = await loadProject(options.root);\n const result = await build(options);\n const out = resolve(options.root, options.out ?? 'out');\n if (result.kind === 'shell') {\n if (!result.ok) {\n const failed = result.routes.filter((route) => route.problems.length > 0);\n say(options)('');\n say(options)(`nisc: ${failed.length} of ${result.routes.length} paths did not hold (${failed.map((route) => route.path).join(', ')}). Nothing was written.`);\n return { written: false, result, out };\n }\n write(options, project, out, result.routes);\n return { written: true, result, out };\n }\n const routes = result.routes;\n const live = routes.filter((route) => route.live || !route.drawn);\n if (live.length > 0 && options.allowLive !== true) {\n say(options)('');\n say(options)(`nisc: ${live.length} of ${routes.length} paths cannot be a file alone (${live.map((route) => route.path).join(', ')}).`);\n say(options)(' Nothing was written. With a server beside the files they still work: `nisc export --allow-live`.');\n return { written: false, result, out };\n }\n write(options, project, out, routes);\n return { written: true, result, out };\n};\n\nconst listening = async (httpServer: ReturnType<typeof serve>, options: CommandOptions): Promise<string> => {\n await new Promise<void>((up) => httpServer.once('listening', () => up()));\n const address = httpServer.address();\n const port = address !== null && typeof address === 'object' ? (address satisfies AddressInfo).port : options.port;\n return `http://localhost:${port}`;\n};\n\nexport const start = async (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> => {\n const project = await loadProject(options.root);\n const dist = distOf(options.root, project);\n if (!existsSync(join(dist, 'index.html'))) throw new Error(`nisc: no built terminal in ${dist} — run \\`nisc build\\`.`);\n const port = options.port ?? Number(process.env['PORT'] ?? 8787);\n if (isShellProject(project)) {\n const httpServer = serve({ fetch: siteHandler(shellSite(project, dist)), port });\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built app, each path’s first screen drawn; the shell is the page’s own`);\n return { url, close: async () => void httpServer.close() };\n }\n const { attachSocket, mountSite, MOSS_PATHS } = await import('@niscorp/moss/node');\n const booted = await project.boot();\n await project.routes?.(booted.server);\n mountSite(booted.server, {\n dist,\n draw: project.draw,\n ...(project.htmlAttributes !== undefined ? { htmlAttributes: project.htmlAttributes } : {}),\n ...(project.site !== undefined ? { site: project.site } : {}),\n ...(project.tokenKey !== undefined ? { tokenKey: project.tokenKey } : {}),\n });\n // After every route: the check answers requests in-process, and Hono takes no route once it has answered one.\n try {\n await booted.server.checkFunctions();\n } catch (error) {\n await booted.close?.();\n throw error;\n }\n const httpServer = serve({ fetch: siteHandler(booted.server.fetch, { except: MOSS_PATHS }), port });\n attachSocket(httpServer, booted.server.socket);\n const url = await listening(httpServer, options);\n say(options)(`nisc: serving ${url} — the built terminal, its pages drawn; the socket at /socket`);\n return {\n url,\n close: async () => {\n httpServer.close();\n await booted.close?.();\n },\n };\n};\n\nexport const migrate = async (options: CommandOptions): Promise<void> => {\n const project = await loadProject(options.root);\n if (isShellProject(project) || project.app === undefined || project.runtime === undefined) {\n throw new Error('nisc: `nisc migrate` needs `app` and `runtime` in nisc.config.ts — the manifest, and the environment it runs on.');\n }\n const { migrateTables } = await import('@niscorp/moss');\n const print = say(options);\n const isDryRun = options.dryRun === true;\n const runtime = await project.runtime();\n try {\n const report = await migrateTables(runtime, project.app, isDryRun ? { dryRun: true } : {});\n if (report.applied.length === 0) print('nisc: nothing to migrate');\n else print(isDryRun ? `nisc: would apply ${report.applied.length} — rolled back, nothing changed` : `nisc: applied ${report.applied.length}`);\n for (const migration of report.applied) print(` ${migration.ref} ${migration.description}`);\n if (report.removed.length > 0) print(`nisc: this run removes ${report.removed.join(', ')}`);\n if (report.retyped.length > 0) print(`nisc: this run changes the type of ${report.retyped.join(', ')}`);\n if (report.alreadyBroken.length > 0) print('nisc: not fitting before this run either, and seeded as they are — said, not refused:');\n for (const entry of report.alreadyBroken) print(` ${entry}`);\n } finally {\n await runtime.close?.();\n }\n};\n\nconst handOver = (options: CommandOptions, tool: string, args: readonly string[]): Promise<number> =>\n new Promise((done) => {\n const child = spawn(process.execPath, [tool, ...args], { cwd: options.root, stdio: 'inherit' });\n child.once('exit', (code) => done(code ?? 1));\n });\n\nexport const dev = (options: CommandOptions): Promise<{ url: string; close: () => Promise<void> }> =>\n devServer({ root: options.root, ...(options.port !== undefined ? { port: options.port } : {}) });\n\nexport const check = async (options: CommandOptions): Promise<number> => {\n const project = await loadProject(options.root);\n return handOver(options, toolOf(options.root, 'tsx', 'tsx'), [project.checks ?? 'src/dev/all-checks.ts']);\n};\n","import { resolve } from 'node:path';\nimport { build, check, dev, exportSite, migrate, start } from './commands';\nimport type { CommandOptions } from './commands';\n\nconst USAGE = `nisc — the command for a nisc application\n\n nisc dev the app's dev server — its vite, with the app server inside\n nisc build bundle the app, draw every path, and check what was drawn\n nisc export build, then write every path as a file (the site as a folder)\n nisc start serve the built app, each path's first screen drawn\n nisc check the app's check suite\n nisc migrate apply the tables' pending migrations, if the app's entries fit the result\n\n --root <dir> the app's root (default: here) — where nisc.config.ts is\n --out <dir> export: where the files go (default: out)\n --allow-live export: write even though some path wants a server behind it\n --port <n> dev, start: the port (start: $PORT, then 8787)\n --skip-bundle build, export: the terminal is already built\n --check migrate: do all of it, then roll it back\n\nAn app says in nisc.config.ts how it boots and how one of its screens is drawn.\nBehind moss (boot + draw): which paths exist and what each needs is read off the\nserver. With its own shell (shell + draw + adopt): every path is drawn from the\napp's own boot, and a file is written only if the page's boot picks it up clean.`;\n\nconst valueAfter = (args: readonly string[], flag: string): string | undefined => {\n const at = args.indexOf(flag);\n return at < 0 ? undefined : args[at + 1];\n};\n\nconst main = async (): Promise<number> => {\n const [command, ...args] = process.argv.slice(2);\n const port = valueAfter(args, '--port');\n const out = valueAfter(args, '--out');\n const options: CommandOptions = {\n root: resolve(valueAfter(args, '--root') ?? process.cwd()),\n ...(out !== undefined ? { out } : {}),\n ...(port !== undefined ? { port: Number(port) } : {}),\n allowLive: args.includes('--allow-live'),\n skipBundle: args.includes('--skip-bundle'),\n };\n\n if (command === 'dev' || command === 'start') {\n const served = command === 'dev' ? await dev(options) : await start(options);\n const stop = (): void => {\n void served.close().finally(() => process.exit(0));\n };\n process.on('SIGINT', stop);\n process.on('SIGTERM', stop);\n return new Promise<number>(() => undefined);\n }\n if (command === 'check') return check(options);\n if (command === 'migrate') {\n await migrate({ ...options, dryRun: args.includes('--check') });\n return 0;\n }\n if (command === 'build') {\n return (await build(options)).ok ? 0 : 1;\n }\n if (command === 'export') return (await exportSite(options)).written ? 0 : 1;\n console.log(USAGE);\n return command === undefined || command === 'help' || command === '--help' ? 0 : 1;\n};\n\nmain().then(\n // An explicit exit: an app's own handles (a database, a timer) would keep a\n // finished command open.\n (code) => process.exit(code),\n (error: unknown) => {\n console.error(error instanceof Error ? error.message : error);\n process.exit(1);\n },\n);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niscorp/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "nisc — the command for a nisc application: dev, build, export, start. One config file says how the app boots and how its pages are drawn; the command does the rest.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"node": ">=22.12"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@niscorp/
|
|
43
|
-
"@niscorp/
|
|
42
|
+
"@niscorp/nova": "^0.5.0",
|
|
43
|
+
"@niscorp/moss": "^0.8.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"@niscorp/moss": {
|
|
@@ -52,14 +52,16 @@
|
|
|
52
52
|
"tsx": "^4.23.15"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
+
"@electric-sql/pglite": "^0.5.1",
|
|
55
56
|
"@types/jsdom": "^30.0.0",
|
|
56
57
|
"@types/node": "^26.6.4",
|
|
57
58
|
"jsdom": "^25.0.1",
|
|
58
59
|
"tsup": "^8.5.1",
|
|
59
60
|
"typescript": "^6.0.2",
|
|
60
61
|
"vitest": "^4.1.2",
|
|
61
|
-
"@niscorp/moss": "^0.
|
|
62
|
-
"@niscorp/
|
|
62
|
+
"@niscorp/moss": "^0.8.1",
|
|
63
|
+
"@niscorp/vex": "^0.4.1",
|
|
64
|
+
"@niscorp/nova": "^0.5.0"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"build": "tsup",
|