@nuasite/cli 0.52.0 → 0.54.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 CHANGED
@@ -63,9 +63,11 @@ config, and run `nua dev`.
63
63
  Validates the content collections without building the site:
64
64
 
65
65
  ```bash
66
- nua check # exit 1 on errors
67
- nua check --json # machine-readable report
68
- nua check --strict # warnings fail too
66
+ nua check # exit 1 on errors
67
+ nua check --json # machine-readable report
68
+ nua check --strict # warnings fail too
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
69
71
  ```
70
72
 
71
73
  Run it anywhere in the project: with no `astro.config.*` in the current directory
@@ -77,12 +79,68 @@ frontmatter that does not parse, values that do not match a declared field type
77
79
  (`order: ""` where the schema wants a number), missing required fields, and
78
80
  `reference()` values pointing at no entry.
79
81
 
82
+ It then parses the project's own `.astro`, `.ts` and `.tsx` — each `.astro` through
83
+ `@astrojs/compiler` and then the emitted TypeScript, which is the same two steps a
84
+ build takes before it renders anything. That catches the syntax error that kills a
85
+ build in `Building static entrypoints`, and reports it at its line in the `.astro`
86
+ source rather than in generated code. It is a syntax check, not a type check: a
87
+ wrong prop type still needs `astro check` or a build.
88
+
80
89
  Use it instead of a full build when you only need to know whether the content is
81
90
  still valid: `astro build` validates the same things but costs the whole render
82
91
  and stops at the first bad entry, while this reports every problem in one pass —
83
92
  under a second on a 1500-entry site. A dangling reference is a warning, because
84
93
  it builds green and then renders nothing.
85
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
+
86
144
  `check` is new in 0.51.0. Most projects do not depend on `@nuasite/cli` directly
87
145
  — it arrives through `@nuasite/nua`, which pins it exactly — so a project on an
88
146
  older `@nuasite/nua` has an older `nua` and answers `Unknown command: check`