@nuasite/cli 0.50.1 → 0.51.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuasite/cli",
3
- "version": "0.50.1",
3
+ "version": "0.51.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "files": [
@@ -23,7 +23,8 @@
23
23
  "prepack": "bun run ../../scripts/workspace-deps/resolve-deps.ts"
24
24
  },
25
25
  "dependencies": {
26
- "@nuasite/cms": "0.50.1"
26
+ "@nuasite/cms": "0.51.0",
27
+ "@nuasite/cms-core": "0.51.0"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@types/bun": "1.3.11"
package/src/check.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { checkContent, createNodeFs, formatCheckReport } from '@nuasite/cms-core'
2
+
3
+ export interface CheckOptions {
4
+ cwd: string
5
+ json: boolean
6
+ /** Treat warnings as failures too. Off by default: a dangling reference builds fine. */
7
+ strict: boolean
8
+ }
9
+
10
+ /** Validate the content collections and return the process exit code. */
11
+ export async function check(options: CheckOptions): Promise<number> {
12
+ const report = await checkContent(createNodeFs(options.cwd))
13
+
14
+ if (options.json) {
15
+ console.log(JSON.stringify(report, null, 2))
16
+ } else {
17
+ const formatted = formatCheckReport(report)
18
+ if (formatted) console.log(formatted + '\n')
19
+ }
20
+
21
+ const errors = report.findings.filter(finding => finding.severity === 'error').length
22
+ const warnings = report.findings.length - errors
23
+
24
+ if (!options.json) {
25
+ const counts = `${report.collections} collection(s), ${report.entries} entries`
26
+ console.log(errors === 0 && warnings === 0 ? `${counts} — no problems found` : `${counts} — ${errors} error(s), ${warnings} warning(s)`)
27
+ }
28
+
29
+ return errors > 0 || (options.strict && warnings > 0) ? 1 : 0
30
+ }
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ function printUsage() {
25
25
  console.log(' build Run astro build with the Nua defaults')
26
26
  console.log(' dev Run astro dev with the Nua defaults')
27
27
  console.log(' preview Run astro preview with the Nua defaults')
28
+ console.log(' check Validate the content collections (no build). --json, --strict')
28
29
  console.log(' init Convert a standard Astro project to use Nua')
29
30
  console.log(' clean Eject to a standard Astro project (remove @nuasite/* deps)')
30
31
  console.log(' migrate <target> Run a content migration. Targets: astro-image')
@@ -36,6 +37,17 @@ if (command && ['build', 'dev', 'preview'].includes(command)) {
36
37
  proxyToAstroCLI(command, args)
37
38
  } else {
38
39
  switch (command) {
40
+ case 'check': {
41
+ const { check } = await import('./check')
42
+ process.exit(
43
+ await check({
44
+ cwd: process.cwd(),
45
+ json: args.includes('--json'),
46
+ strict: args.includes('--strict'),
47
+ }),
48
+ )
49
+ break
50
+ }
39
51
  case 'init': {
40
52
  const { init } = await import('./init')
41
53
  await init({
package/src/tsconfig.json CHANGED
@@ -3,5 +3,5 @@
3
3
  "compilerOptions": {
4
4
  "outDir": "../dist/types"
5
5
  },
6
- "references": [{ "path": "../../cms/src" }]
6
+ "references": [{ "path": "../../cms/src" }, { "path": "../../cms-core/src" }]
7
7
  }