@niscorp/cli 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +41 -12
- package/dist/adopt.js +1 -1
- package/dist/{chunk-Z2PJ5QB7.js → chunk-4EDCXCKZ.js} +2 -2
- package/dist/chunk-4EDCXCKZ.js.map +1 -0
- package/dist/cli.js +27 -12
- package/dist/cli.js.map +1 -1
- package/dist/project-RA4IMQ4V.js +3 -0
- package/dist/{project-3LJPDFX2.js.map → project-RA4IMQ4V.js.map} +1 -1
- package/package.json +7 -6
- package/dist/chunk-Z2PJ5QB7.js.map +0 -1
- package/dist/project-3LJPDFX2.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @niscorp/cli
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2780c56: A real database's tables change only through `nisc migrate`. `migrations` on the runtime defaults to `'verify'`: `createServer` — and so `nisc dev`, `nisc build` and `nisc start` — checks the tables and refuses to start while a migration is pending, naming each one and the two commands that apply it (`npx nisc migrate --check`, then `npx nisc migrate`). On a database that is up to date the check only reads the ledger, so the app's database role needs `SELECT` on `strata_ledger` and no right to change tables. A runtime whose database starts empty every time (PGlite in memory) writes `migrations: 'apply'` and is migrated at boot as before.
|
|
8
|
+
|
|
9
|
+
The boot and `migrateTables` refuse a database whose ledger records a sequence they do not name (`UNKNOWN_SEQUENCE`): a sequence that has run stays in `runtime.tables`.
|
|
10
|
+
|
|
11
|
+
`migrateTables` and `nisc migrate` refuse a run that removes a table or a column, or changes a column's type, unless `allowRemoval` / `--allow-removal` is given; the refusal names each. A run that applied nothing, because another run had already applied it, is not refused.
|
|
12
|
+
|
|
13
|
+
`tableStatus(runtime, app)` and `nisc migrate --status`: what is applied and what is pending, read and nothing else.
|
|
14
|
+
|
|
15
|
+
BREAKING — approved by moccadroid, 2026-11-07: a runtime on a real database runs `nisc migrate` before the app starts (on Railway, the service's pre-deploy command `pnpm exec nisc migrate`); a runtime on in-memory PGlite writes `migrations: 'apply'`; every sequence that has run on the database is in `runtime.tables` (`TIDE_SEQUENCE` with the store made `migrate: false`), and the runtime migrates nothing itself and calls no `cache.init()`; a database that has not yet run `nisc.moss/4` is migrated once with `--allow-removal`.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [2780c56]
|
|
20
|
+
- @niscorp/moss@0.9.0
|
|
21
|
+
|
|
22
|
+
## 0.8.2
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 2d9219a: `nisc dev` registers the project's `routes` on the app server, as `nisc start` does, before it checks the app's functions.
|
|
27
|
+
|
|
28
|
+
A path that `dev.owned` sent to the app server for one of those routes was answered 404 under `nisc dev` and worked under `nisc start`.
|
|
29
|
+
|
|
3
30
|
## 0.8.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ nisc build # bundle the app, draw every path, and check what was drawn
|
|
|
15
15
|
nisc export # build, then write every path as a file — the site as a folder
|
|
16
16
|
nisc start # serve the built app, each path's first screen drawn
|
|
17
17
|
nisc check # the app's check suite
|
|
18
|
-
nisc migrate # apply the tables' pending migrations, if the app's entries fit the result
|
|
18
|
+
nisc migrate # apply the tables' pending migrations, if the app's entries fit the result — the only command that changes a real database
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
An app is one of two things, and the command runs both. **Behind moss**, the
|
|
@@ -55,12 +55,12 @@ 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? }`; `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 |
|
|
58
|
+
| `boot` | stand the app up: `{ server, close? }`; `nisc` then calls `server.checkFunctions()` (`nisc dev` once `routes` are registered, `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" |
|
|
62
62
|
| `paths?` | the paths to build. Default: `/` and every page whose path has no parameter. A page like `/docs/:slug` has as many paths as there are rows — list them here (`server.executeAs` runs a seeded read as a charter role) |
|
|
63
|
-
| `routes?` | routes of the app's own
|
|
63
|
+
| `routes?` | routes of the app's own (a sign-in handoff, a webhook): `nisc start` registers them before the site, and `nisc dev` registers them too, for the paths `dev.owned` sends to the app server |
|
|
64
64
|
| `dist?` | where the bundler writes the terminal (default `dist`) |
|
|
65
65
|
| `stylesheet?` | where the built page's stylesheet goes: `'page'` (the default — written into `index.html`, see `nisc build`) or `'file'` (left as the bundler linked it) |
|
|
66
66
|
| `checks?` | the check suite `nisc check` runs (default `src/dev/all-checks.ts`) |
|
|
@@ -324,6 +324,8 @@ and `start` do:
|
|
|
324
324
|
still a vite page (its client, the framework's refresh preamble);
|
|
325
325
|
- moss's own paths (`/api`, `/catalog`, the socket, …) go to the app server,
|
|
326
326
|
everything else to vite;
|
|
327
|
+
- the config's `routes` are registered on the app server, as `nisc start`
|
|
328
|
+
registers them — a path reaches them once `dev.owned` sends it there;
|
|
327
329
|
- an edit under `src/app`, `src/server`, `src/db`, `src/ui` or to the config
|
|
328
330
|
re-boots the app (a fresh database, fresh shells) and reloads the page — the
|
|
329
331
|
old server answers until the new one is up;
|
|
@@ -348,8 +350,13 @@ with the app's own `tsx`. Its exit code is the suite's.
|
|
|
348
350
|
## `nisc migrate`
|
|
349
351
|
|
|
350
352
|
For an app behind moss whose config hands over `app` and `runtime`. It is the
|
|
351
|
-
|
|
352
|
-
`
|
|
353
|
+
only command that changes a real database's tables: `nisc dev`, `nisc build`
|
|
354
|
+
and `nisc start` boot the app, and a boot only checks the tables — with a
|
|
355
|
+
migration pending it refuses to start and names it — unless the runtime says
|
|
356
|
+
`migrations: 'apply'`, which a database that starts empty every time (PGlite in
|
|
357
|
+
memory) does. A deployment runs it before the new version starts; on Railway,
|
|
358
|
+
as the service's pre-deploy command (`pnpm exec nisc migrate`): a failure stops
|
|
359
|
+
the deploy, and the running version keeps serving.
|
|
353
360
|
|
|
354
361
|
In one transaction it applies every pending table migration — moss's, and the
|
|
355
362
|
app's own (`runtime.tables`) — then checks that every entry of the manifest
|
|
@@ -364,19 +371,39 @@ nisc: applied 1
|
|
|
364
371
|
nisc: this run removes notes.stars
|
|
365
372
|
```
|
|
366
373
|
|
|
367
|
-
A run that
|
|
368
|
-
|
|
369
|
-
|
|
374
|
+
A run that takes something away — a table or a column removed, a column's
|
|
375
|
+
type changed — is refused, each named, unless `--allow-removal` is given; then
|
|
376
|
+
it lands and says what it took away. It sees tables and columns, not rows a
|
|
377
|
+
step deletes. An entry that already did not fit before the run, and is already
|
|
378
|
+
seeded as it is, is listed and does not refuse the run.
|
|
370
379
|
|
|
371
380
|
`--check` does all of it and rolls it back. It takes the locks the real run
|
|
372
381
|
will take, for as long.
|
|
373
382
|
|
|
383
|
+
`--status` reads and changes nothing: how many migrations of each sequence the
|
|
384
|
+
database records and what is pending (exit 0), and anything that would refuse
|
|
385
|
+
a run — an edited migration, a database migrated by newer code, a sequence
|
|
386
|
+
nobody names (exit 1).
|
|
387
|
+
|
|
388
|
+
```
|
|
389
|
+
nisc: applied nisc.moss 6, nisc.moss.sessions 1, nisc.vex.cache 2, acme.app 2
|
|
390
|
+
nisc: 1 pending
|
|
391
|
+
acme.app/3 notes lose their stars
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
A run waits for another one running at the same time, up to an hour, and a
|
|
395
|
+
step that waits more than 10 s for a table another query holds gives up — the
|
|
396
|
+
run is rolled back, and running it again is safe.
|
|
397
|
+
|
|
374
398
|
`runtime` only opens the environment. It migrates nothing and seeds nothing:
|
|
375
399
|
tables it changes itself are changed before the step can check them, and
|
|
376
|
-
`--check` would then change the database.
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
400
|
+
`--check` would then change the database. So it calls no `cache.init()` (the
|
|
401
|
+
server does, after its check), and a tide store under moss is made
|
|
402
|
+
`migrate: false`. Every table an entry reads or writes comes from a sequence in
|
|
403
|
+
the run — the app's own go in `runtime.tables`, and so does tide's
|
|
404
|
+
(`TIDE_SEQUENCE`, from `@niscorp/tide/postgres`) when the app keeps tide's
|
|
405
|
+
tables. A sequence that has run stays there: the run refuses a database that
|
|
406
|
+
records one nobody names.
|
|
380
407
|
|
|
381
408
|
It checks entries. It does not see SQL written by hand, and it does not know
|
|
382
409
|
what a value means.
|
|
@@ -390,6 +417,8 @@ what a value means.
|
|
|
390
417
|
| `--allow-live` | `export`: write even though some path wants a server |
|
|
391
418
|
| `--skip-bundle` | `build`, `export`: the terminal is already built — it is neither bundled nor has its stylesheet written into its page |
|
|
392
419
|
| `--check` | `migrate`: do all of it, then roll it back |
|
|
420
|
+
| `--status` | `migrate`: what is applied and pending — reads, changes nothing |
|
|
421
|
+
| `--allow-removal` | `migrate`: apply a run that removes a table or column, or changes a column's type |
|
|
393
422
|
| `--port <n>` | `dev`, `start`: the port (`start`: `$PORT`, then 8787) |
|
|
394
423
|
|
|
395
424
|
## License
|
package/dist/adopt.js
CHANGED
|
@@ -30,7 +30,7 @@ var main = async () => {
|
|
|
30
30
|
const [root, asked, answered] = process.argv.slice(2);
|
|
31
31
|
if (root === void 0 || asked === void 0 || answered === void 0) throw new Error("usage: adopt <root> <pages.json> <answer.json>");
|
|
32
32
|
standDom(root);
|
|
33
|
-
const { isShellProject, loadProject } = await import('./project-
|
|
33
|
+
const { isShellProject, loadProject } = await import('./project-RA4IMQ4V.js');
|
|
34
34
|
const project = await loadProject(root);
|
|
35
35
|
if (!isShellProject(project)) throw new Error("nisc: this app has no shell of its own to adopt with.");
|
|
36
36
|
const pages = JSON.parse(readFileSync(asked, "utf8"));
|
|
@@ -42,5 +42,5 @@ var loadProject = async (root) => {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export { configFileOf, isProject, isShellProject, loadProject };
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-4EDCXCKZ.js.map
|
|
46
|
+
//# sourceMappingURL=chunk-4EDCXCKZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/project.ts"],"names":[],"mappings":";;;;;AA2DA,IAAM,YAAA,GAAe,CAAC,gBAAA,EAAkB,iBAAA,EAAmB,kBAAkB,iBAAiB,CAAA;AAE9F,IAAM,GAAA,GAAM,CAAC,KAAA,EAAe,GAAA,KAAyB,OAAO,OAAA,CAAQ,GAAA,CAAI,KAAA,EAAO,GAAG,CAAA,KAAM,UAAA;AAEjF,IAAM,cAAA,GAAiB,CAAC,OAAA,KAAsD,OAAA,IAAW;AAEzF,IAAM,SAAA,GAAY,CAAC,KAAA,KAAyC;AACjE,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,IAAY,CAAC,GAAA,CAAI,KAAA,EAAO,MAAM,CAAA,EAAG,OAAO,KAAA;AAC/E,EAAA,MAAM,CAAC,IAAA,EAAM,GAAG,CAAA,GAAI,CAAC,GAAA,CAAI,KAAA,EAAO,MAAM,CAAA,EAAG,GAAA,CAAI,KAAA,EAAO,OAAO,CAAC,CAAA;AAC5D,EAAA,OAAO,IAAA,KAAS,GAAA,KAAQ,IAAA,IAAQ,GAAA,CAAI,OAAO,OAAO,CAAA,CAAA;AACpD;AAEA,IAAM,MAAA,GAAS,CAAC,KAAA,KAA4B;AAC1C,EAAA,I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AO,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,SAAS,IAAI,CAAA,kLAAA;AAAA,KACf;AAAA,EACF;AACA,EAAA,IAAI,QAAQ,IAAA,KAAS,MAAA,IAAa,CAAC,MAAA,CAAO,OAAA,CAAQ,IAAI,CAAA,EAAG;AACvD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,MAAA,EAAS,IAAI,CAAA,mBAAA,EAAsB,KAAK,SAAA,CAAU,OAAA,CAAQ,IAAI,CAAC,CAAA,8EAAA,CAA2E,CAAA;AAAA,EAC5J;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-4EDCXCKZ.js","sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { DocumentConfig, MossServer, NiscApp, NiscRuntime } from '@niscorp/moss';\nimport type { Shell } from '@niscorp/nova';\n\ntype Common = {\n // Default `dist`, relative to the root.\n dist?: string;\n // Default `page`: a <style> in index.html. `file` is for a Content-Security-Policy that forbids inline styles.\n stylesheet?: 'page' | 'file';\n // Default `src/dev/all-checks.ts`.\n checks?: string;\n site?: string;\n};\n\nexport type NiscMossProject = Common & {\n boot: () => Promise<{ server: MossServer; close?: () => void | Promise<void> }>;\n draw: DocumentConfig['draw'];\n htmlAttributes?: DocumentConfig['htmlAttributes'];\n // Default `nisc.token`.\n tokenKey?: string;\n // Default: `/`, and every page whose path has no parameter.\n paths?: (server: MossServer) => readonly string[] | Promise<readonly string[]>;\n // `nisc start` registers these before the site's catch-all; `nisc dev` registers them too, and sends them the paths `dev.owned` names.\n routes?: (server: MossServer) => void | Promise<void>;\n // For `nisc migrate`. `runtime` opens the environment and nothing else:\n // tables it migrated itself are changed before the step can check them.\n app?: NiscApp;\n runtime?: () => Promise<NiscRuntime & { close?: () => void | Promise<void> }>;\n dev?: {\n // The token `/dev/as/<who>` stores; `null` is nobody of that name.\n signIn?: (server: MossServer, who: string) => string | null | Promise<string | null>;\n // Default: this machine only. With it, anybody who can reach the dev server signs in as anybody.\n signInFromNetwork?: boolean;\n // Default: `src/app`, `src/server`, `src/db`, `src/ui` and the config.\n watch?: RegExp;\n // Paths that go to the app server and not to vite. Default: moss's own\n // prefixes; an app with routes of its own names those and its own.\n owned?: RegExp;\n };\n};\n\nexport type NiscShellProject = Common & {\n // Called more than once per path (a build boots twice to compare, and once\n // more inside a DOM to adopt), so it must not memoize.\n shell: (request: { path: string }) => Promise<{ shell: Shell; close?: () => void | Promise<void> }>;\n draw: (shell: Shell) => string | Promise<string>;\n // `root` already holds the drawn markup: the browser entry's own call (`hydrateRoot`, `createSSRApp().mount`, nova's `mountShell`).\n adopt: (root: HTMLElement, shell: Shell) => void | Promise<void>;\n htmlAttributes?: (shell: Shell) => Record<string, string>;\n // Default: `/`.\n paths?: () => readonly string[] | Promise<readonly string[]>;\n // Default 5000. Past it the build fails.\n waitMs?: number;\n};\n\nexport type NiscProject = NiscMossProject | NiscShellProject;\n\nconst CONFIG_NAMES = ['nisc.config.ts', 'nisc.config.mts', 'nisc.config.js', 'nisc.config.mjs'];\n\nconst has = (value: object, key: string): boolean => typeof Reflect.get(value, key) === 'function';\n\nexport const isShellProject = (project: NiscProject): project is NiscShellProject => 'shell' in project;\n\nexport const isProject = (value: unknown): value is NiscProject => {\n if (value === null || typeof value !== 'object' || !has(value, 'draw')) return false;\n const [moss, own] = [has(value, 'boot'), has(value, 'shell')];\n return moss !== own && (moss || has(value, 'adopt'));\n};\n\nconst isSite = (value: unknown): boolean => {\n if (typeof value !== 'string') return false;\n try {\n return ['http:', 'https:'].includes(new URL(value).protocol);\n } catch {\n return false;\n }\n};\n\nexport const configFileOf = (root: string): string | undefined => CONFIG_NAMES.find((name) => existsSync(join(root, name)));\n\nexport const loadProject = async (root: string): Promise<NiscProject> => {\n const name = configFileOf(root);\n const file = name === undefined ? undefined : join(root, name);\n if (file === undefined) {\n throw new Error(`nisc: no nisc.config.ts in ${root}. It exports \\`project\\`: how the app boots, and how one of its screens is drawn.`);\n }\n const { tsImport } = await import('tsx/esm/api');\n const tsconfig = join(root, 'tsconfig.json');\n const loaded: unknown = await tsImport(pathToFileURL(file).href, { parentURL: import.meta.url, ...(existsSync(tsconfig) ? { tsconfig } : {}) });\n const project: unknown = loaded !== null && typeof loaded === 'object' ? Reflect.get(loaded, 'project') : undefined;\n if (!isProject(project)) {\n throw new Error(\n `nisc: ${file} does not export a \\`project\\` the command can run. It hands over EITHER \\`boot\\` + \\`draw\\` (an app behind moss) OR \\`shell\\` + \\`draw\\` + \\`adopt\\` (an app with its own shell).`,\n );\n }\n if (project.site !== undefined && !isSite(project.site)) {\n throw new Error(`nisc: ${file} gives \\`site\\` as ${JSON.stringify(project.site)} — it is the address the site is served at, whole: \"https://example.com\".`);\n }\n return project;\n};\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadProject, isShellProject, configFileOf, isProject } from './chunk-
|
|
1
|
+
import { loadProject, isShellProject, configFileOf, isProject } from './chunk-4EDCXCKZ.js';
|
|
2
2
|
import { resolve, join, sep, extname, dirname } from 'path';
|
|
3
3
|
import { spawn, spawnSync } from 'child_process';
|
|
4
4
|
import { existsSync, statSync, readFileSync, rmSync, cpSync, mkdirSync, writeFileSync, mkdtempSync } from 'fs';
|
|
@@ -39,6 +39,7 @@ var mossPlugin = async (configFile, dev2) => {
|
|
|
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
41
|
try {
|
|
42
|
+
await project.routes?.(booted.server);
|
|
42
43
|
await booted.server.checkFunctions();
|
|
43
44
|
} catch (error) {
|
|
44
45
|
await booted.close?.();
|
|
@@ -595,15 +596,15 @@ var start = async (options) => {
|
|
|
595
596
|
}
|
|
596
597
|
const { attachSocket, mountSite, MOSS_PATHS } = await import('@niscorp/moss/node');
|
|
597
598
|
const booted = await project.boot();
|
|
598
|
-
await project.routes?.(booted.server);
|
|
599
|
-
mountSite(booted.server, {
|
|
600
|
-
dist,
|
|
601
|
-
draw: project.draw,
|
|
602
|
-
...project.htmlAttributes !== void 0 ? { htmlAttributes: project.htmlAttributes } : {},
|
|
603
|
-
...project.site !== void 0 ? { site: project.site } : {},
|
|
604
|
-
...project.tokenKey !== void 0 ? { tokenKey: project.tokenKey } : {}
|
|
605
|
-
});
|
|
606
599
|
try {
|
|
600
|
+
await project.routes?.(booted.server);
|
|
601
|
+
mountSite(booted.server, {
|
|
602
|
+
dist,
|
|
603
|
+
draw: project.draw,
|
|
604
|
+
...project.htmlAttributes !== void 0 ? { htmlAttributes: project.htmlAttributes } : {},
|
|
605
|
+
...project.site !== void 0 ? { site: project.site } : {},
|
|
606
|
+
...project.tokenKey !== void 0 ? { tokenKey: project.tokenKey } : {}
|
|
607
|
+
});
|
|
607
608
|
await booted.server.checkFunctions();
|
|
608
609
|
} catch (error) {
|
|
609
610
|
await booted.close?.();
|
|
@@ -626,12 +627,23 @@ var migrate = async (options) => {
|
|
|
626
627
|
if (isShellProject(project) || project.app === void 0 || project.runtime === void 0) {
|
|
627
628
|
throw new Error("nisc: `nisc migrate` needs `app` and `runtime` in nisc.config.ts \u2014 the manifest, and the environment it runs on.");
|
|
628
629
|
}
|
|
629
|
-
const { migrateTables } = await import('@niscorp/moss');
|
|
630
|
+
const { migrateTables, tableStatus } = await import('@niscorp/moss');
|
|
630
631
|
const print = say(options);
|
|
631
632
|
const isDryRun = options.dryRun === true;
|
|
632
633
|
const runtime = await project.runtime();
|
|
633
634
|
try {
|
|
634
|
-
|
|
635
|
+
if (options.status === true) {
|
|
636
|
+
const plan = await tableStatus(runtime, project.app);
|
|
637
|
+
print(`nisc: applied ${Object.entries(plan.applied).map(([sequence, n]) => `${sequence} ${n}`).join(", ")}`);
|
|
638
|
+
print(plan.pending.length === 0 ? "nisc: nothing pending" : `nisc: ${plan.pending.length} pending`);
|
|
639
|
+
for (const migration of plan.pending) print(` ${migration.ref} ${migration.description}`);
|
|
640
|
+
if (plan.problems.length > 0) {
|
|
641
|
+
const problems = plan.problems.map((problem) => ` ${problem.code}: ${problem.detail}`);
|
|
642
|
+
throw new Error(["nisc: this database cannot be migrated or booted as it is:", ...problems].join("\n"));
|
|
643
|
+
}
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
const report = await migrateTables(runtime, project.app, { ...isDryRun ? { dryRun: true } : {}, ...options.allowRemoval === true ? { allowRemoval: true } : {} });
|
|
635
647
|
if (report.applied.length === 0) print("nisc: nothing to migrate");
|
|
636
648
|
else print(isDryRun ? `nisc: would apply ${report.applied.length} \u2014 rolled back, nothing changed` : `nisc: applied ${report.applied.length}`);
|
|
637
649
|
for (const migration of report.applied) print(` ${migration.ref} ${migration.description}`);
|
|
@@ -662,6 +674,7 @@ var USAGE = `nisc \u2014 the command for a nisc application
|
|
|
662
674
|
nisc start serve the built app, each path's first screen drawn
|
|
663
675
|
nisc check the app's check suite
|
|
664
676
|
nisc migrate apply the tables' pending migrations, if the app's entries fit the result
|
|
677
|
+
(the only command that changes a real database's tables; boot only checks them)
|
|
665
678
|
|
|
666
679
|
--root <dir> the app's root (default: here) \u2014 where nisc.config.ts is
|
|
667
680
|
--out <dir> export: where the files go (default: out)
|
|
@@ -669,6 +682,8 @@ var USAGE = `nisc \u2014 the command for a nisc application
|
|
|
669
682
|
--port <n> dev, start: the port (start: $PORT, then 8787)
|
|
670
683
|
--skip-bundle build, export: the terminal is already built
|
|
671
684
|
--check migrate: do all of it, then roll it back
|
|
685
|
+
--status migrate: what is applied and what is pending \u2014 reads, changes nothing
|
|
686
|
+
--allow-removal migrate: apply a run that removes a table or column or changes a column's type
|
|
672
687
|
|
|
673
688
|
An app says in nisc.config.ts how it boots and how one of its screens is drawn.
|
|
674
689
|
Behind moss (boot + draw): which paths exist and what each needs is read off the
|
|
@@ -700,7 +715,7 @@ var main = async () => {
|
|
|
700
715
|
}
|
|
701
716
|
if (command === "check") return check(options);
|
|
702
717
|
if (command === "migrate") {
|
|
703
|
-
await migrate({ ...options, dryRun: args.includes("--check") });
|
|
718
|
+
await migrate({ ...options, dryRun: args.includes("--check"), status: args.includes("--status"), allowRemoval: args.includes("--allow-removal") });
|
|
704
719
|
return 0;
|
|
705
720
|
}
|
|
706
721
|
if (command === "build") {
|
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,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,MA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A,KAAY,UAAU,OAAA,CAAQ,MAAM,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"]}
|
|
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,C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,EAAE,GAAG,SAAS,MAAA,EAAQ,IAAA,CAAK,SAAS,SAAS,CAAA,EAAG,QAAQ,IAAA,CAAK,QAAA,CAAS,UAAU,CAAA,EAAG,YAAA,EAAc,KAAK,QAAA,CAAS,iBAAiB,GAAG,CAAA;AACjJ,IAAA,OAAO,CAAA;AAAA,EACT;AACA,EAAA,IAAI,YAAY,OAAA,EAAS;AACvB,IAAA,OAAA,CAAQ,MAAM,KAAA,CAAM,OAAO,CAAA,EAAG,KAAK,CAAA,GAAI,CAAA;AAAA,EACzC;AACA,EAAA,IAAI,OAAA,KAAY,UAAU,OAAA,CAAQ,MAAM,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 // Routes first: the check answers requests in-process, and Hono takes no route once it has answered one.\n try {\n await project.routes?.(booted.server);\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 status?: boolean;\n allowRemoval?: 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 try {\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 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, tableStatus } = await import('@niscorp/moss');\n const print = say(options);\n const isDryRun = options.dryRun === true;\n const runtime = await project.runtime();\n try {\n if (options.status === true) {\n const plan = await tableStatus(runtime, project.app);\n print(`nisc: applied ${Object.entries(plan.applied).map(([sequence, n]) => `${sequence} ${n}`).join(', ')}`);\n print(plan.pending.length === 0 ? 'nisc: nothing pending' : `nisc: ${plan.pending.length} pending`);\n for (const migration of plan.pending) print(` ${migration.ref} ${migration.description}`);\n if (plan.problems.length > 0) {\n const problems = plan.problems.map((problem) => ` ${problem.code}: ${problem.detail}`);\n throw new Error(['nisc: this database cannot be migrated or booted as it is:', ...problems].join('\\n'));\n }\n return;\n }\n const report = await migrateTables(runtime, project.app, { ...(isDryRun ? { dryRun: true } : {}), ...(options.allowRemoval === true ? { allowRemoval: 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 (the only command that changes a real database's tables; boot only checks them)\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 --status migrate: what is applied and what is pending — reads, changes nothing\n --allow-removal migrate: apply a run that removes a table or column or changes a column's type\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'), status: args.includes('--status'), allowRemoval: args.includes('--allow-removal') });\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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"project-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"project-RA4IMQ4V.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niscorp/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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/moss": "^0.9.0",
|
|
43
|
+
"@niscorp/nova": "^0.5.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"@niscorp/moss": {
|
|
@@ -58,10 +58,11 @@
|
|
|
58
58
|
"jsdom": "^25.0.1",
|
|
59
59
|
"tsup": "^8.5.1",
|
|
60
60
|
"typescript": "^6.0.2",
|
|
61
|
+
"vite": "^7.1.12",
|
|
61
62
|
"vitest": "^4.1.2",
|
|
62
|
-
"@niscorp/
|
|
63
|
-
"@niscorp/
|
|
64
|
-
"@niscorp/
|
|
63
|
+
"@niscorp/vex": "^0.4.3",
|
|
64
|
+
"@niscorp/nova": "^0.5.1",
|
|
65
|
+
"@niscorp/moss": "^0.9.0"
|
|
65
66
|
},
|
|
66
67
|
"scripts": {
|
|
67
68
|
"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k-Z2PJ5QB7.js","sourcesContent":["import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { DocumentConfig, MossServer, NiscApp, NiscRuntime } from '@niscorp/moss';\nimport type { Shell } from '@niscorp/nova';\n\ntype Common = {\n // Default `dist`, relative to the root.\n dist?: string;\n // Default `page`: a <style> in index.html. `file` is for a Content-Security-Policy that forbids inline styles.\n stylesheet?: 'page' | 'file';\n // Default `src/dev/all-checks.ts`.\n checks?: string;\n site?: string;\n};\n\nexport type NiscMossProject = Common & {\n boot: () => Promise<{ server: MossServer; close?: () => void | Promise<void> }>;\n draw: DocumentConfig['draw'];\n htmlAttributes?: DocumentConfig['htmlAttributes'];\n // Default `nisc.token`.\n tokenKey?: string;\n // Default: `/`, and every page whose path has no parameter.\n paths?: (server: MossServer) => readonly string[] | Promise<readonly string[]>;\n // `nisc start` registers these before the site's catch-all.\n routes?: (server: MossServer) => void | Promise<void>;\n // For `nisc migrate`. `runtime` opens the environment and nothing else:\n // tables it migrated itself are changed before the step can check them.\n app?: NiscApp;\n runtime?: () => Promise<NiscRuntime & { close?: () => void | Promise<void> }>;\n dev?: {\n // The token `/dev/as/<who>` stores; `null` is nobody of that name.\n signIn?: (server: MossServer, who: string) => string | null | Promise<string | null>;\n // Default: this machine only. With it, anybody who can reach the dev server signs in as anybody.\n signInFromNetwork?: boolean;\n // Default: `src/app`, `src/server`, `src/db`, `src/ui` and the config.\n watch?: RegExp;\n // Paths that go to the app server and not to vite. Default: moss's own\n // prefixes; an app with routes of its own names those and its own.\n owned?: RegExp;\n };\n};\n\nexport type NiscShellProject = Common & {\n // Called more than once per path (a build boots twice to compare, and once\n // more inside a DOM to adopt), so it must not memoize.\n shell: (request: { path: string }) => Promise<{ shell: Shell; close?: () => void | Promise<void> }>;\n draw: (shell: Shell) => string | Promise<string>;\n // `root` already holds the drawn markup: the browser entry's own call (`hydrateRoot`, `createSSRApp().mount`, nova's `mountShell`).\n adopt: (root: HTMLElement, shell: Shell) => void | Promise<void>;\n htmlAttributes?: (shell: Shell) => Record<string, string>;\n // Default: `/`.\n paths?: () => readonly string[] | Promise<readonly string[]>;\n // Default 5000. Past it the build fails.\n waitMs?: number;\n};\n\nexport type NiscProject = NiscMossProject | NiscShellProject;\n\nconst CONFIG_NAMES = ['nisc.config.ts', 'nisc.config.mts', 'nisc.config.js', 'nisc.config.mjs'];\n\nconst has = (value: object, key: string): boolean => typeof Reflect.get(value, key) === 'function';\n\nexport const isShellProject = (project: NiscProject): project is NiscShellProject => 'shell' in project;\n\nexport const isProject = (value: unknown): value is NiscProject => {\n if (value === null || typeof value !== 'object' || !has(value, 'draw')) return false;\n const [moss, own] = [has(value, 'boot'), has(value, 'shell')];\n return moss !== own && (moss || has(value, 'adopt'));\n};\n\nconst isSite = (value: unknown): boolean => {\n if (typeof value !== 'string') return false;\n try {\n return ['http:', 'https:'].includes(new URL(value).protocol);\n } catch {\n return false;\n }\n};\n\nexport const configFileOf = (root: string): string | undefined => CONFIG_NAMES.find((name) => existsSync(join(root, name)));\n\nexport const loadProject = async (root: string): Promise<NiscProject> => {\n const name = configFileOf(root);\n const file = name === undefined ? undefined : join(root, name);\n if (file === undefined) {\n throw new Error(`nisc: no nisc.config.ts in ${root}. It exports \\`project\\`: how the app boots, and how one of its screens is drawn.`);\n }\n const { tsImport } = await import('tsx/esm/api');\n const tsconfig = join(root, 'tsconfig.json');\n const loaded: unknown = await tsImport(pathToFileURL(file).href, { parentURL: import.meta.url, ...(existsSync(tsconfig) ? { tsconfig } : {}) });\n const project: unknown = loaded !== null && typeof loaded === 'object' ? Reflect.get(loaded, 'project') : undefined;\n if (!isProject(project)) {\n throw new Error(\n `nisc: ${file} does not export a \\`project\\` the command can run. It hands over EITHER \\`boot\\` + \\`draw\\` (an app behind moss) OR \\`shell\\` + \\`draw\\` + \\`adopt\\` (an app with its own shell).`,\n );\n }\n if (project.site !== undefined && !isSite(project.site)) {\n throw new Error(`nisc: ${file} gives \\`site\\` as ${JSON.stringify(project.site)} — it is the address the site is served at, whole: \"https://example.com\".`);\n }\n return project;\n};\n"]}
|
package/dist/project-3LJPDFX2.js
DELETED