@nuasite/cli 0.53.0 → 0.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -1
- package/dist/index.js +1263 -228
- package/dist/types/check.d.ts +9 -0
- package/dist/types/check.d.ts.map +1 -1
- package/dist/types/live-schema.d.ts +20 -0
- package/dist/types/live-schema.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/check.ts +49 -3
- package/src/index.ts +3 -10
- package/src/live-schema.ts +0 -0
package/README.md
CHANGED
|
@@ -66,7 +66,8 @@ Validates the content collections without building the site:
|
|
|
66
66
|
nua check # exit 1 on errors
|
|
67
67
|
nua check --json # machine-readable report
|
|
68
68
|
nua check --strict # warnings fail too
|
|
69
|
-
nua check --content-only # skip the source parse
|
|
69
|
+
nua check --content-only # skip the source parse (and the live schema rules)
|
|
70
|
+
nua check --no-live # skip the live schema rules only
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
Run it anywhere in the project: with no `astro.config.*` in the current directory
|
|
@@ -91,6 +92,55 @@ and stops at the first bad entry, while this reports every problem in one pass
|
|
|
91
92
|
under a second on a 1500-entry site. A dangling reference is a warning, because
|
|
92
93
|
it builds green and then renders nothing.
|
|
93
94
|
|
|
95
|
+
#### Live schema rules
|
|
96
|
+
|
|
97
|
+
Unless you pass `--no-live` or `--content-only`, `check` also imports your
|
|
98
|
+
`src/content.config.ts` and validates against the **real** Zod schemas, using the
|
|
99
|
+
project's own `astro/zod`. That adds two things the static rules cannot give you:
|
|
100
|
+
|
|
101
|
+
- `entry/schema-rejected` — every entry the build would reject, including what a
|
|
102
|
+
plain `z.string().min(3)`, a union, a coercion or a refinement says. This is the
|
|
103
|
+
verdict `astro sync` gives, without the build.
|
|
104
|
+
- `cms/empty-write` — the writes the CMS editor is about to make, parsed before
|
|
105
|
+
anyone makes them: creating a new entry in a collection, and clicking "+ Add" in
|
|
106
|
+
a repeater. A required field the editor cannot fill is a schema that breaks the
|
|
107
|
+
build the first time an editor touches it. Where the simulation cannot run,
|
|
108
|
+
`cms/empty-write-unchecked` says so rather than passing silently. What is left
|
|
109
|
+
after `newRepeaterItem` seeds the item is a required key the config does not
|
|
110
|
+
declare, or one whose type has no blank the schema takes (a required enum).
|
|
111
|
+
- `cms/required-drift` and `cms/field-degraded` — the two places the editor's
|
|
112
|
+
picture of a field and the build's picture come apart. The editor is built from
|
|
113
|
+
what the config parser could read, so a field schema behind an import loses its
|
|
114
|
+
`.optional()` (the editor then refuses to save it blank) and loses its type (the
|
|
115
|
+
editor then renders a text input the schema will not accept). Both are proved by
|
|
116
|
+
asking the schema, never by assuming the parser's silence means something.
|
|
117
|
+
|
|
118
|
+
Having the real schema also makes `entry/missing-required` stand down for that
|
|
119
|
+
collection: `required` is only what the parser could see, and `entry/schema-rejected`
|
|
120
|
+
knows what the build actually insists on.
|
|
121
|
+
|
|
122
|
+
These findings carry a `hint` — a `→` line under the finding in human output, a
|
|
123
|
+
`hint` field in `--json` — saying what to change. It is derived from the write
|
|
124
|
+
itself, not guessed from the error: a key the editor omits is fixed by
|
|
125
|
+
`.optional()` or `.default(…)` (and _not_ by `.nullable()`, which accepts `null`
|
|
126
|
+
but still wants the key), while a key the editor fills with a rejected value
|
|
127
|
+
cannot be, and gets the other remedy. A run of findings sharing one hint prints it
|
|
128
|
+
once.
|
|
129
|
+
|
|
130
|
+
Two limits are worth knowing:
|
|
131
|
+
|
|
132
|
+
- The `astro:content` stub used to import the config accepts the same shapes
|
|
133
|
+
`reference()` does, but not the lookup that follows it, and `image()` accepts
|
|
134
|
+
anything — a build resolves those, an import cannot. So the live schema never
|
|
135
|
+
reports a dangling reference or a missing image; the static rules
|
|
136
|
+
(`entry/dangling-reference`, `entry/missing-asset`) are what cover those.
|
|
137
|
+
- Live rules run only when the command resolves to **one** Astro project. The
|
|
138
|
+
`astro:content` stub is process-global, so in a multi-root run one project's
|
|
139
|
+
schemas would judge the others. Run the check inside each project to get them.
|
|
140
|
+
|
|
141
|
+
Whenever the live rules do not run, the report says why — one line in the human
|
|
142
|
+
output, and a `liveSchemas` field (`"ran"` or the reason) in `--json`.
|
|
143
|
+
|
|
94
144
|
`check` is new in 0.51.0. Most projects do not depend on `@nuasite/cli` directly
|
|
95
145
|
— it arrives through `@nuasite/nua`, which pins it exactly — so a project on an
|
|
96
146
|
older `@nuasite/nua` has an older `nua` and answers `Unknown command: check`
|