@niscorp/cli 0.9.1 → 0.10.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 +62 -0
- package/README.md +121 -18
- package/dist/adopt.js +2 -2
- package/dist/adopt.js.map +1 -1
- package/dist/{chunk-4EDCXCKZ.js → chunk-VGA7OHHG.js} +23 -6
- package/dist/chunk-VGA7OHHG.js.map +1 -0
- package/dist/cli.js +448 -228
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/project-5TBKATKF.js +3 -0
- package/dist/{project-RA4IMQ4V.js.map → project-5TBKATKF.js.map} +1 -1
- package/dist/shape.cjs +112 -19
- package/dist/shape.cjs.map +1 -1
- package/dist/shape.js +113 -20
- package/dist/shape.js.map +1 -1
- package/package.json +6 -6
- package/dist/chunk-4EDCXCKZ.js.map +0 -1
- package/dist/project-RA4IMQ4V.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# @niscorp/cli
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 16f8bf2: BREAKING — approved by moccadroid (owner), 2026-11-22: nothing, unless an export on Windows relied on a path such as `/a\..\..\x` writing its file outside the export's folder.
|
|
8
|
+
|
|
9
|
+
`nisc export` writes every file into a fresh folder first (`.nisc-export-<process>-<id>`: for `out/`, in `node_modules/.cache/nisc/`, where git does not look; for a folder named with `--out`, inside it), and touches the export's folder only when every file was made. A path whose file the system will not make (on Windows, `/a:b`) or whose file would land outside the export's folder (on Windows, `/a\..\..\x`) is now said — `nisc: the path "/a:b" cannot be written here (ENOENT). Nothing was written.` — with exit code 1 and the folder as it was. Before, `/a:b` emptied `out/`, wrote part of the site and ended on a raw stack; `/a\..\..\x` wrote outside the folder (with the default `out/`, into the app's own folder) and exited 0. A write that fails for another reason, such as a full disk, says `nisc: the export could not be written into <out> (ENOSPC on <file>). Nothing already in it was changed.` The default `out/` is then emptied and copied from the build, with the same files and modes; a `.nisc-export-…` folder a killed export leaves is removed by the next export.
|
|
10
|
+
|
|
11
|
+
- f4341b9: BREAKING — approved by moccadroid (owner), 2026-11-22: a build step that relied on `nisc export --out <dir>` emptying that folder empties it itself before the export; the default `out/` is unchanged.
|
|
12
|
+
|
|
13
|
+
`nisc export --out <dir>` no longer empties the folder it is given. It removes only the files the previous export wrote there, recorded in `node_modules/.cache/nisc/exports.json`, then writes the new export; everything else in the folder (a `.git`, a notes file) stays and is named on one line each run. The default `out/` is emptied and written exactly as before, also when named with `--out out` or, on Windows and macOS, `--out OUT`. For a folder named with `--out`: the export is first written whole into a folder of its own inside it, so a file that cannot be made changes nothing already there; removal goes by real location, so a link in the folder is removed as a link and never written or deleted through; `--out` is also refused when where it points is the app, above it, or the build; if the record cannot be written, the export still finishes and says the next export will remove none of it. What changes for a folder named with `--out`: files an older export left there, before the record or without it (a fresh CI checkout), are named on every run instead of removed; a file another step put in the folder survives the next export; a link named with `--out` is written into, where it used to be replaced by a folder; a file at the `--out` path, or a folder with files of its own where the export writes a file, is said and nothing is written, where both used to be replaced; a kill during an export can leave a `.nisc-export-…` folder in it until the next export removes it.
|
|
14
|
+
|
|
15
|
+
- 6b9b449: BREAKING — approved by moccadroid (owner), 2026-11-22: nothing, unless something relied on a repeated `immutable` answer from `nisc start` being the first answer's bytes, sent with a `content-length`.
|
|
16
|
+
|
|
17
|
+
`nisc start` no longer remembers compressed answers. It used to keep every compressed answer marked `immutable` by path and `last-modified` — not by query — so an app route answering `immutable` by `?user=` gave the second person the first person's body (`/thumb?user=bob` got Alice's thumbnail). Every answer is now compressed as it streams, as every other answer already was: the bytes a browser decodes are the same, a repeated asset answer comes without `content-length`, and it costs the compression again: about 9–11 ms for a 0.5–0.6 MB bundle and 19 ms for 2.3 MB, where answering from the remembered bytes took 0.4–0.7 ms — once per new browser, since `/assets/` files are kept a year.
|
|
18
|
+
|
|
19
|
+
- a8a9684: BREAKING — approved by moccadroid (owner), 2026-11-22: nothing, unless an app's `allow.style` names a file only because of a `<const>` assertion — that allowance now fails as allowing nothing; delete it.
|
|
20
|
+
|
|
21
|
+
The shape check (`@niscorp/cli/shape`) also asks the compiler what each name refers to, and prints an `[info]` line — file, line and rule — for a reach its rules miss because it is spelt another way: `const { roles } = session`, `const { NumberFormat } = Intl`, `new globalThis.Intl.DateTimeFormat()`, `const { pathname } = window.location`, `window['document'].querySelector(…)`, and a function of `src/app/` reached through a namespace import, a re-export or a dynamic import. A name read only as a type (`import type`, `typeof`, `export type`) is not reported. Such a line is left out when a rule already fails the same name in that file, or when `allow` names that file for that rule. The exit code is unchanged: these spellings are reported, not failed, and the README now says which spellings fail. `<const>[...]` passes rule 16, as `as const` does.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 13465d1: `nisc export --out` refuses a folder that is the app's, one above it, or the build, instead of deleting it.
|
|
26
|
+
`nisc start` on a port that is taken, or given a `--port` or `$PORT` that is not a port, says so in a sentence instead of crashing with Node's own error.
|
|
27
|
+
An error thrown by the app's own code (its `boot`, its config) is printed with its stack, so it says where it was thrown; the command's own refusals stay one sentence.
|
|
28
|
+
- 7842b56: The command's source is made of modules (`command`, `project`, `build`, `serve`, `dev`, `migrate`, `shape`); its commands, exports and built files are the same.
|
|
29
|
+
Three printed lines are worded plainly: an own-shell export that writes nothing says `N of M paths failed a check`, the build's legend says `✗ not written: a check failed`, and the build says `public/assets/ has files of your own`. Exit codes and files are the same.
|
|
30
|
+
`nisc export` on an app behind moss names a path that could not be drawn on a line of its own, and offers `--allow-live` only for the paths that want a server; with `--allow-live` it says which paths were written as the undrawn template. Exit codes and files are the same.
|
|
31
|
+
`nisc migrate` (and `--check`, `--status`) on a runtime that says `migrations: 'apply'` prints first that its database starts empty every time, so what it applies is gone when the command ends. Everything after that line is as before.
|
|
32
|
+
`nisc start` with `PORT` set but empty says that it is read as 0, any free port; the port is the same as before.
|
|
33
|
+
`nisc start` on an app with its own shell answers an address that does not decode to a path (`/%`, `/%E0%A4%A`, one with `%00`) with a 400 `not a path`, where it answered 500.
|
|
34
|
+
`nisc build` on an app behind moss names, after the route table, what its charter does not read as written (a misspelt key such as `denny`), one line each. The exit code is the same.
|
|
35
|
+
The README says to add `@niscorp/cli` as a dependency when `nisc start` serves the app, with what `nisc.config.ts` imports.
|
|
36
|
+
- Updated dependencies [be6cc14]
|
|
37
|
+
- Updated dependencies [d3fadac]
|
|
38
|
+
- Updated dependencies [adba9b1]
|
|
39
|
+
- Updated dependencies [29e51ec]
|
|
40
|
+
- Updated dependencies [23c4613]
|
|
41
|
+
- Updated dependencies [1e228d3]
|
|
42
|
+
- Updated dependencies [4b7d4a4]
|
|
43
|
+
- Updated dependencies [bf72478]
|
|
44
|
+
- Updated dependencies [e1db181]
|
|
45
|
+
- Updated dependencies [241bd4d]
|
|
46
|
+
- Updated dependencies [9f8e4b5]
|
|
47
|
+
- Updated dependencies [1b615d6]
|
|
48
|
+
- Updated dependencies [e7edd95]
|
|
49
|
+
- Updated dependencies [0a46ff6]
|
|
50
|
+
- Updated dependencies [59f314a]
|
|
51
|
+
- Updated dependencies [281108e]
|
|
52
|
+
- Updated dependencies [b233463]
|
|
53
|
+
- Updated dependencies [e2b9595]
|
|
54
|
+
- Updated dependencies [7aef6a7]
|
|
55
|
+
- Updated dependencies [79cf65c]
|
|
56
|
+
- Updated dependencies [e828562]
|
|
57
|
+
- Updated dependencies [6b01a50]
|
|
58
|
+
- Updated dependencies [6eef458]
|
|
59
|
+
- Updated dependencies [b18f9d3]
|
|
60
|
+
- Updated dependencies [8b4d6cd]
|
|
61
|
+
- Updated dependencies [b1e314e]
|
|
62
|
+
- @niscorp/moss@0.10.0
|
|
63
|
+
- @niscorp/nova@0.6.0
|
|
64
|
+
|
|
3
65
|
## 0.9.1
|
|
4
66
|
|
|
5
67
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
`nisc` — the command for a nisc application.
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
pnpm add
|
|
6
|
+
pnpm add @niscorp/cli
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
+
A dependency, not a dev dependency, when `nisc start` serves the app: a host
|
|
10
|
+
that installs the dependencies alone must still have `nisc`. So is what
|
|
11
|
+
`nisc.config.ts` imports.
|
|
12
|
+
|
|
9
13
|
A new app starts with `npm create nisc`, which writes the `nisc.config.ts`
|
|
10
14
|
described below.
|
|
11
15
|
|
|
@@ -98,7 +102,7 @@ The browser entry does the same two things in the page — boot, then adopt:
|
|
|
98
102
|
```tsx
|
|
99
103
|
const app = await getApp();
|
|
100
104
|
if (root.hasChildNodes()) {
|
|
101
|
-
await shellSettled(app.shell); // reach the screen the file
|
|
105
|
+
await shellSettled(app.shell); // reach the screen the file contains
|
|
102
106
|
adopt(root, app.shell); // hydrateRoot(root, <Screen shell={shell} />)
|
|
103
107
|
} else {
|
|
104
108
|
createRoot(root).render(<Screen shell={app.shell} />); // dev: nothing was drawn
|
|
@@ -121,14 +125,14 @@ at all — nova's DOM adapter, `renderToString` from
|
|
|
121
125
|
| `waitMs?` | how long a build waits for a screen to be whole (default 5000) |
|
|
122
126
|
| `dist?`, `stylesheet?`, `checks?` | as above |
|
|
123
127
|
|
|
124
|
-
The built `index.html` must
|
|
128
|
+
The built `index.html` must contain the empty root, `<div id="root"></div>` — that
|
|
125
129
|
is where a screen goes. The adoption check needs a DOM: `jsdom`, installed in
|
|
126
130
|
the app.
|
|
127
131
|
|
|
128
132
|
### The head of each page
|
|
129
133
|
|
|
130
134
|
Either kind. A page's `<head>` is a node in a layout — nova's `nova:head` —
|
|
131
|
-
and its children are the elements a head
|
|
135
|
+
and its children are the elements a head contains, bound to the action's data
|
|
132
136
|
like everything else on the screen:
|
|
133
137
|
|
|
134
138
|
```typescript
|
|
@@ -160,10 +164,10 @@ a tag that gave up its place is kept, inert, in a `<template data-nova-own>`.
|
|
|
160
164
|
When the screen moves on to one that no longer says it, the document's own
|
|
161
165
|
comes back.
|
|
162
166
|
|
|
163
|
-
**What a head may not
|
|
167
|
+
**What a head may not contain fails the build.** A layout is data: a script a
|
|
164
168
|
browser would run, a stylesheet, `http-equiv`, a handler attribute are refused,
|
|
165
169
|
and the path is not written. Those go in `index.html` — the app's own file,
|
|
166
|
-
which
|
|
170
|
+
which may contain anything — or in the kit component that needs them.
|
|
167
171
|
|
|
168
172
|
**Where a page lives.** `site` in the config is the address the site is served
|
|
169
173
|
at. With it, every path's document says its own canonical address
|
|
@@ -221,7 +225,7 @@ draws it, and checks what it drew:
|
|
|
221
225
|
| **same twice** | a second boot drew different markup, or said a different head (it says where they part) — the page's boot would not match the file |
|
|
222
226
|
| **adopted** | inside a DOM, a third boot ran the app's own `adopt` over the markup and the adapter complained: a hydration error, or a rebuilt root that is not what it was handed |
|
|
223
227
|
|
|
224
|
-
And one that
|
|
228
|
+
And one that is true by construction: `shell` is handed a path and nothing else,
|
|
225
229
|
so a file is only ever the screen **as nobody in particular sees it**.
|
|
226
230
|
|
|
227
231
|
What cannot be failed is reported, read off the actions on the first screen:
|
|
@@ -230,7 +234,7 @@ at build — if one answers differently in the page, the page's shell draws that
|
|
|
230
234
|
part again), which it **can still call**, and which channels it **waits on**.
|
|
231
235
|
All of those keep working: the shell is in the page.
|
|
232
236
|
|
|
233
|
-
Exit code 1 if any check
|
|
237
|
+
Exit code 1 if any check failed.
|
|
234
238
|
|
|
235
239
|
**An app behind moss.** Bundles the terminal (the app's own vite), stands the app up, draws every path
|
|
236
240
|
once **for nobody**, and prints how each one is served:
|
|
@@ -254,24 +258,97 @@ build.
|
|
|
254
258
|
|
|
255
259
|
Exit code 1 if a path could not be drawn at all.
|
|
256
260
|
|
|
261
|
+
After the table, the build names what the app's charter does not read as
|
|
262
|
+
written — a misspelt key such as `denny`, which grants what it meant to take
|
|
263
|
+
away — one line each, from the server it booted. The app runs, so the exit code
|
|
264
|
+
does not change; an app that wants its check to fail on them reads them with
|
|
265
|
+
`verifyApp` from `@niscorp/moss`, as the check of an app `npm create nisc`
|
|
266
|
+
makes does.
|
|
267
|
+
|
|
257
268
|
## `nisc export`
|
|
258
269
|
|
|
259
270
|
`nisc build`, then the site as a folder (`out/` by default, `--out <dir>`): the
|
|
260
271
|
bundle, and one `index.html` per path — `/` at the top, `/about` at
|
|
261
272
|
`about/index.html` — which is what any static host serves for that path.
|
|
262
273
|
|
|
274
|
+
Every export is first written whole into a fresh folder of its own,
|
|
275
|
+
`.nisc-export-<process>-<id>`: for `out/`, in `node_modules/.cache/nisc/` under
|
|
276
|
+
the app's folder, where git does not look; for a folder named with `--out`,
|
|
277
|
+
inside that folder. Only when every file was made there is anything
|
|
278
|
+
already in the export's folder touched. A path whose file the system will not
|
|
279
|
+
make (on Windows, `/a:b`), or whose file would land outside the export's folder
|
|
280
|
+
(on Windows, `/a\..\..\x`), is said, and nothing is written (exit code 1):
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
nisc: the path "/a:b" cannot be written here (ENOENT). Nothing was written.
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Which names are refused is the system's own answer: names Windows accepts, such
|
|
287
|
+
as `/about.` or `/con`, export as any other. A `.nisc-export-…` folder that an
|
|
288
|
+
ended export left (a kill, a Ctrl+C) is removed by the next export that makes
|
|
289
|
+
its fresh folder in the same place. It is never part of what is written.
|
|
290
|
+
|
|
291
|
+
**The default folder, `out/`**, is then emptied, and the build and the pages
|
|
292
|
+
are copied into it; the fresh folder only shows that every file can be made,
|
|
293
|
+
and is removed.
|
|
294
|
+
`--out out`, the full path to it, or on Windows and macOS another spelling of
|
|
295
|
+
it such as `--out OUT` is the same folder; a link to it is not.
|
|
296
|
+
|
|
297
|
+
**A folder named with `--out`** loses only the files the previous export wrote
|
|
298
|
+
there. A link named with `--out` is followed: the export goes into the folder
|
|
299
|
+
it points to. If a file cannot be made, nothing already in the folder is
|
|
300
|
+
changed; a folder that did not exist has been made, and is left empty.
|
|
301
|
+
|
|
302
|
+
- What each export writes there is recorded in
|
|
303
|
+
`node_modules/.cache/nisc/exports.json` under the app's root, keyed by the
|
|
304
|
+
folder's real location: outside the folder, so nothing published lists the
|
|
305
|
+
paths. The record is never written through a link. If it cannot be written
|
|
306
|
+
(a read-only `node_modules`, a link on the way), the export still finishes
|
|
307
|
+
and says so on one line: the next export removes none of what this one wrote.
|
|
308
|
+
- The next export removes the recorded files (and any folder that leaves
|
|
309
|
+
empty), then moves its own in. A file or link at a path where it writes is
|
|
310
|
+
replaced; a folder with files of its own where it writes a file is said, and
|
|
311
|
+
nothing is written (exit code 1). If moving the files in fails (a file the
|
|
312
|
+
system will not let go of, another export into the same folder at the same
|
|
313
|
+
time), the command says how many of its files are in place, and exits 1:
|
|
314
|
+
export again to finish.
|
|
315
|
+
- Everything else in the folder stays, and every export names it on one line,
|
|
316
|
+
the first five and how many more:
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
nisc: left as they were in /work/site, not written by this export (2): .git/, notes.txt
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Removal goes by real location. A link where the export writes is removed as a
|
|
323
|
+
link, and nothing is written through it. A recorded file is never removed
|
|
324
|
+
through a link, nor when it lies outside the folder (a record edited by hand):
|
|
325
|
+
it is named `not removed`. So a file the command never recorded — one an older
|
|
326
|
+
export left before the record, or after it was lost (a fresh CI checkout has
|
|
327
|
+
none) — is never removed by it: it is named on every export until someone
|
|
328
|
+
deletes it, and deleting the folder once ends it. A file another step puts in
|
|
329
|
+
the folder survives the next export.
|
|
330
|
+
|
|
331
|
+
`--out` may not be the app's folder, a folder above it, the build, or a folder
|
|
332
|
+
inside the build: each is refused before anything is drawn (exit code 1). For a
|
|
333
|
+
folder named with `--out`, that is checked as written and where it really
|
|
334
|
+
points. A file at a path named with `--out` (other than `out`, which is
|
|
335
|
+
replaced) is said and left as it is, and nothing is written (exit
|
|
336
|
+
code 1).
|
|
337
|
+
|
|
263
338
|
A file is **only ever the page as nobody sees it**. No credential reaches a
|
|
264
339
|
build, so there is nothing to leak into one.
|
|
265
340
|
|
|
266
341
|
For an app with its own shell that is the whole deployment: the folder goes on
|
|
267
342
|
any static host, each path answers with its screen, and the bundle's shell
|
|
268
|
-
picks it up. If a check
|
|
343
|
+
picks it up. If a check failed, **nothing is written**.
|
|
269
344
|
|
|
270
345
|
For an app behind moss: if any path wants a server behind it, **nothing is written** and the command
|
|
271
346
|
says which paths and why (exit code 1). A folder cannot be a server. When one
|
|
272
347
|
will stand beside the files — the socket at `/socket` on the same origin —
|
|
273
348
|
`--allow-live` writes the site anyway: each such file is a true first screen,
|
|
274
|
-
and its terminal connects.
|
|
349
|
+
and its terminal connects. A path that could not be drawn is named on a line of
|
|
350
|
+
its own, and `--allow-live` is not offered for it: written anyway, it is the
|
|
351
|
+
template, empty until its terminal connects, and the command says so.
|
|
275
352
|
|
|
276
353
|
A folder carries no headers, so what a browser may keep of it is the host's to
|
|
277
354
|
say. What `nisc start` says is the rule to give it: everything under `/assets/`
|
|
@@ -288,7 +365,8 @@ as the app answers now, not as it answered at build. No shell is kept.
|
|
|
288
365
|
every page **drawn for whoever is asking** — the app's own screen at `/`, a
|
|
289
366
|
manifest page at its path. A signed-in person gets their screen in the markup
|
|
290
367
|
(`private, no-store`); nobody gets the page as nobody sees it. `--port <n>`, or
|
|
291
|
-
`$PORT`, default 8787
|
|
368
|
+
`$PORT`, default 8787; a port that is taken, or not a port, ends the command
|
|
369
|
+
with a sentence saying so (exit code 1). A name with an extension that is neither a file in
|
|
292
370
|
`dist/` nor a page is a missing file, answered 404 — never a screen.
|
|
293
371
|
|
|
294
372
|
**Either kind**, around the app's handler:
|
|
@@ -339,7 +417,7 @@ and `start` do:
|
|
|
339
417
|
another prefix names moss's and its own. All three are read when the command
|
|
340
418
|
starts.
|
|
341
419
|
|
|
342
|
-
The app's `vite.config.ts`
|
|
420
|
+
The app's `vite.config.ts` has its framework's plugin and nothing about the
|
|
343
421
|
server. An app with its own shell is a vite app and nothing more.
|
|
344
422
|
|
|
345
423
|
## `nisc check`
|
|
@@ -373,11 +451,11 @@ process.exit(
|
|
|
373
451
|
```
|
|
374
452
|
|
|
375
453
|
It prints one `[pass]` or `[fail]` line per rule and answers the exit code, 0
|
|
376
|
-
or 1. It fails
|
|
454
|
+
or 1. It fails on these spellings, and only these:
|
|
377
455
|
|
|
378
456
|
| Rule | It fails on |
|
|
379
457
|
|---|---|
|
|
380
|
-
| `style` (rule 16) | in `src/`: an `as` or `<T>` assertion other than `as const
|
|
458
|
+
| `style` (rule 16) | in `src/`: an `as` or `<T>` assertion other than `as const` or `<const>`, a non-null `!`, a `function` declaration, a class, an enum, `any`, a default export. `.d.ts` files are not read |
|
|
381
459
|
| `formatting` (rule 9) | `Intl.` or a `.toLocale…()` call in `src/`, but `src/dev/` |
|
|
382
460
|
| `roles` (rule 11) | `session.roles` or `principal.roles` in `src/server/` |
|
|
383
461
|
| `files` (rule 9a) | `FileReader` or a `readAs…` call in `src/ui/` |
|
|
@@ -388,6 +466,31 @@ or 1. It fails when:
|
|
|
388
466
|
Each is read off the syntax tree, so a word in a comment or a string is never a
|
|
389
467
|
finding.
|
|
390
468
|
|
|
469
|
+
The same reaches spelt another way are **reported, not failed**. A second
|
|
470
|
+
reading asks the compiler what each name refers to, and prints an `[info]` line
|
|
471
|
+
with the file, the line and the rule for each one the table misses:
|
|
472
|
+
|
|
473
|
+
| Rule | Reported, whatever the spelling |
|
|
474
|
+
|---|---|
|
|
475
|
+
| `formatting` | any use of the global `Intl`: `const { NumberFormat } = Intl`, `new globalThis.Intl.DateTimeFormat()` |
|
|
476
|
+
| `roles` | a `roles` declared in `@niscorp/moss`'s types, read with a dot, `['roles']` or destructuring: `const { roles } = session` |
|
|
477
|
+
| `address` | any value of the browser's `Location` type (`const { pathname } = window.location`), and `pushState`/`replaceState` on a `History` |
|
|
478
|
+
| `dom` | `querySelector` and its kin on a value of type `Document`: `window['document'].querySelector(…)` |
|
|
479
|
+
| `data` | a function of `src/app/` reached through a namespace import (`helpers.wordsOf(1)`), a re-export (`export { wordsOf } from '../app/helpers'`) or a dynamic import |
|
|
480
|
+
|
|
481
|
+
```
|
|
482
|
+
[info] rule 9: src/server/when.ts:1 Intl, the global one — another spelling of what the rule fails on; reported, not failed
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
A name read only as a type (`import type { wordsOf }`, `typeof wordsOf`,
|
|
486
|
+
`export type { wordsOf }`) reaches nothing, and is not reported. Such a line is
|
|
487
|
+
left out when the table already fails the same rule for the same name in that
|
|
488
|
+
file, and when `allow` names that file for that rule (an
|
|
489
|
+
allowance still has to allow something the table fails, or it fails as
|
|
490
|
+
allowing nothing). It never changes the exit code: an app that passes keeps
|
|
491
|
+
passing. If the second reading cannot run, one `[info]` line says so, and the
|
|
492
|
+
exit code is the table's.
|
|
493
|
+
|
|
391
494
|
`allow` names, per rule, the files that may do what the rule refuses, each with
|
|
392
495
|
why: the file that finds the app's day, the identity seam that reads roles, a
|
|
393
496
|
routing adapter, a shim. An allowance fails when it gives no reason, names a
|
|
@@ -403,8 +506,8 @@ against how often they replay vex, how many reads word their rows with a Prism
|
|
|
403
506
|
`mapping`, and the `refresh: 'reactive'` reads no action replays by name.
|
|
404
507
|
|
|
405
508
|
It reads the source with the app's own TypeScript, 6.x, found from `root`, and
|
|
406
|
-
the app as its `tsconfig.json` there says.
|
|
407
|
-
|
|
509
|
+
the app as its `tsconfig.json` there says. The second reading adds a second or
|
|
510
|
+
two on lyceum.
|
|
408
511
|
|
|
409
512
|
## `nisc migrate`
|
|
410
513
|
|
|
@@ -451,7 +554,7 @@ nisc: 1 pending
|
|
|
451
554
|
```
|
|
452
555
|
|
|
453
556
|
A run waits for another one running at the same time, up to an hour, and a
|
|
454
|
-
step that waits more than 10 s for a table another query
|
|
557
|
+
step that waits more than 10 s for a table another query has locked gives up — the
|
|
455
558
|
run is rolled back, and running it again is safe.
|
|
456
559
|
|
|
457
560
|
`runtime` only opens the environment. It migrates nothing and seeds nothing:
|
|
@@ -472,7 +575,7 @@ what a value means.
|
|
|
472
575
|
| | |
|
|
473
576
|
|---|---|
|
|
474
577
|
| `--root <dir>` | the app's root (default: the current directory) |
|
|
475
|
-
| `--out <dir>` | `export`: where the files go (default `out`) |
|
|
578
|
+
| `--out <dir>` | `export`: where the files go (default `out`, which is emptied first); a folder named here loses only what the previous export wrote there (`nisc export`). Never the app's folder or its build |
|
|
476
579
|
| `--allow-live` | `export`: write even though some path wants a server |
|
|
477
580
|
| `--skip-bundle` | `build`, `export`: the terminal is already built — it is neither bundled nor has its stylesheet written into its page |
|
|
478
581
|
| `--check` | `migrate`: do all of it, then roll it back |
|
package/dist/adopt.js
CHANGED
|
@@ -4,7 +4,7 @@ import { join } from 'path';
|
|
|
4
4
|
import { format } from 'util';
|
|
5
5
|
import { shellSettled } from '@niscorp/nova';
|
|
6
6
|
|
|
7
|
-
// src/adopt.ts
|
|
7
|
+
// src/build/adopt.ts
|
|
8
8
|
var QUIET_MS = 60;
|
|
9
9
|
var ADOPT_WAIT_MS = 1e4;
|
|
10
10
|
var pause = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
@@ -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-5TBKATKF.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"));
|
package/dist/adopt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adopt.ts"],"names":["require","window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AK,EAAE,IAAA,EAAM,UAAA,EAAY,MAAM,CAAA;AAAA,EACrC;AACA,EAAA,aAAA,CAAc,QAAA,EAAU,IAAA,CAAK,SAAA,CAAU,GAAG,CAAC,CAAA;AAC7C,CAAA;AAEA,IAAA,EAAK,CAAE,IAAA;AAAA,EACL,MAAM,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA;AAAA,EACpB,CAAC,KAAA,KAAmB;AAClB,IAAA,OAAA,CAAQ,MAAA,CAAO,MAAM,CAAA,EAAG,KAAA,YAAiB,QAAQ,KAAA,CAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC;AAAA,CAAI,CAAA;AAClF,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAA","file":"adopt.js","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { format } from 'node:util';\nimport { shellSettled } from '@niscorp/nova';\n\nconst QUIET_MS = 60;\nconst ADOPT_WAIT_MS = 10_000;\n\nconst pause = (ms: number): Promise<void> => new Promise((done) => setTimeout(done, ms));\n\nconst standDom = (root: string): void => {\n const require = createRequire(join(root, 'package.json'));\n let library: unknown;\n try {\n library = require('jsdom');\n } catch {\n throw new Error(`nisc: the adoption check needs a DOM, and this app has no jsdom installed (looked from ${root}). pnpm add -D jsdom`);\n }\n const constructor: unknown = library !== null && typeof library === 'object' ? Reflect.get(library, 'JSDOM') : undefined;\n if (typeof constructor !== 'function') throw new Error('nisc: jsdom exports no JSDOM.');\n const dom: unknown = Reflect.construct(constructor, ['<!doctype html><html><body></body></html>', { url: 'http://localhost/', pretendToBeVisual: true }]);\n const window: unknown = dom !== null && typeof dom === 'object' ? Reflect.get(dom, 'window') : undefined;\n if (window === null || typeof window !== 'object') throw new Error('nisc: jsdom made no window.');\n for (const name of ['window', 'document', ...Object.getOwnPropertyNames(window)]) {\n if (name in globalThis) continue;\n Object.defineProperty(globalThis, name, { configurable: true, get: () => Reflect.get(window, name) });\n }\n};\n\nconst main = async (): Promise<void> => {\n const [root, asked, answered] = process.argv.slice(2);\n if (root === undefined || asked === undefined || answered === undefined) throw new Error('usage: adopt <root> <pages.json> <answer.json>');\n standDom(root);\n // only now: the app's modules load into a world that has a DOM\n const { isShellProject, loadProject } = await import('../project');\n const project = await loadProject(root);\n if (!isShellProject(project)) throw new Error('nisc: this app has no shell of its own to adopt with.');\n\n const pages: unknown = JSON.parse(readFileSync(asked, 'utf8'));\n if (!Array.isArray(pages)) throw new Error('nisc: no pages to adopt.');\n\n let complaints: string[] = [];\n const short = (text: string): string => (text.length > 600 ? `${text.slice(0, 600)}…` : text);\n console.error = (...args: unknown[]): void => {\n complaints.push(short(format(...args)));\n };\n window.addEventListener('error', (event) => {\n complaints.push(short(event.message));\n event.preventDefault();\n });\n\n const out: { path: string; complaints: string[] }[] = [];\n for (const page of pages) {\n const path: unknown = page !== null && typeof page === 'object' ? Reflect.get(page, 'path') : undefined;\n const screen: unknown = page !== null && typeof page === 'object' ? Reflect.get(page, 'screen') : undefined;\n if (typeof path !== 'string' || typeof screen !== 'string') continue;\n complaints = [];\n const mine = complaints;\n try {\n document.body.innerHTML = '<div id=\"root\"></div>';\n const element = document.getElementById('root');\n if (element === null) throw new Error('no root');\n element.innerHTML = screen;\n const parsed = element.innerHTML;\n const booted = await project.shell({ path });\n if (!(await shellSettled(booted.shell, { waitMs: ADOPT_WAIT_MS }))) mine.push('the page’s own boot was still loading when it came to adopt');\n await project.adopt(element, booted.shell);\n // An adapter that rebuilds its root (the DOM adapter) has done so by now.\n // One that adopts in place (React, Vue) reports a mismatch a moment\n // later, as a logged or raised error: the pause waits for it.\n if (element.innerHTML !== parsed) mine.push('what the page’s boot drew is not the markup it was handed');\n await pause(QUIET_MS);\n await booted.close?.();\n } catch (error) {\n mine.push(error instanceof Error ? error.message : String(error));\n }\n out.push({ path, complaints: mine });\n }\n writeFileSync(answered, JSON.stringify(out));\n};\n\nmain().then(\n () => process.exit(0),\n (error: unknown) => {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`);\n process.exit(1);\n },\n);\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import { join, dirname, resolve } from 'path';
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
|
+
import { createRequire } from 'module';
|
|
4
5
|
|
|
5
|
-
// src/project.ts
|
|
6
|
+
// src/project/project.ts
|
|
6
7
|
var CONFIG_NAMES = ["nisc.config.ts", "nisc.config.mts", "nisc.config.js", "nisc.config.mjs"];
|
|
7
8
|
var has = (value, key) => typeof Reflect.get(value, key) === "function";
|
|
8
9
|
var isShellProject = (project) => "shell" in project;
|
|
@@ -40,7 +41,23 @@ var loadProject = async (root) => {
|
|
|
40
41
|
}
|
|
41
42
|
return project;
|
|
42
43
|
};
|
|
44
|
+
var say = (options) => options.print ?? ((line) => console.log(line));
|
|
45
|
+
var toolOf = (root, name, bin) => {
|
|
46
|
+
const require2 = createRequire(join(root, "package.json"));
|
|
47
|
+
let manifestPath;
|
|
48
|
+
try {
|
|
49
|
+
manifestPath = require2.resolve(`${name}/package.json`);
|
|
50
|
+
} catch {
|
|
51
|
+
throw new Error(`nisc: this app has no ${name} installed (looked from ${root}).`);
|
|
52
|
+
}
|
|
53
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
54
|
+
const bins = manifest !== null && typeof manifest === "object" ? Reflect.get(manifest, "bin") : void 0;
|
|
55
|
+
const relative = typeof bins === "string" ? bins : bins !== null && typeof bins === "object" ? Reflect.get(bins, bin) : void 0;
|
|
56
|
+
if (typeof relative !== "string") throw new Error(`nisc: ${name} ships no "${bin}" command.`);
|
|
57
|
+
return join(dirname(manifestPath), relative);
|
|
58
|
+
};
|
|
59
|
+
var distOf = (root, project) => resolve(root, project.dist ?? "dist");
|
|
43
60
|
|
|
44
|
-
export { configFileOf, isProject, isShellProject, loadProject };
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
46
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
export { configFileOf, distOf, isProject, isShellProject, loadProject, say, toolOf };
|
|
62
|
+
//# sourceMappingURL=chunk-VGA7OHHG.js.map
|
|
63
|
+
//# sourceMappingURL=chunk-VGA7OHHG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/project/project.ts","../src/project/options.ts"],"names":["require","join"],"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,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,IAAI;AACF,IAAA,OAAO,CAAC,SAAS,QAAQ,CAAA,CAAE,SAAS,IAAI,GAAA,CAAI,KAA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AA;AACjI,EAAA,IAAI,OAAO,QAAA,KAAa,QAAA,EAAU,MAAM,IAAI,MAAM,CAAA,MAAA,EAAS,IAAI,CAAA,WAAA,EAAc,GAAG,CAAA,UAAA,CAAY,CAAA;AAC5F,EAAA,OAAOC,IAAAA,CAAK,OAAA,CAAQ,YAAY,CAAA,EAAG,QAAQ,CAAA;AAC7C;AAEO,IAAM,MAAA,GAAS,CAAC,IAAA,EAAc,OAAA,KAAiC,QAAQ,IAAA,EAAM,OAAA,CAAQ,QAAQ,MAAM","file":"chunk-VGA7OHHG.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 contains 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","import { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport type { NiscProject } from './project';\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\nexport const say = (options: CommandOptions): ((line: string) => void) => options.print ?? ((line) => console.log(line));\n\nexport const 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\nexport const distOf = (root: string, project: NiscProject): string => resolve(root, project.dist ?? 'dist');\n"]}
|