@vttforge/cli 0.6.0 → 0.7.1

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 CHANGED
@@ -1,5 +1,56 @@
1
1
  # @vttforge/cli
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7920fa2: Say which exports are supported, which are experimental, and which are internal.
8
+
9
+ This package's product is the `vttforge` binary, and its index had grown to re-export the pieces the commands are built from. 60 exports, of which 33 were reachable only by importing them directly. Nothing outside the package imports them.
10
+
11
+ They are now tagged where they are defined, so the tag reaches the published types and your editor shows it:
12
+
13
+ - **Supported**, under the deprecation policy: `runInit` and the audit surface (`runAudit`, `runManifestRules`, `runSourceRules`, `formatReport`, and the `RuleFn` / `RuleResult` / `Severity` types). `create-vttforge` calls `runInit`, and the audit rules are a deliberate extension point.
14
+ - **`@experimental`**: plausibly useful to a tool author, but nobody has asked, so the shape is a guess. Can change in a minor.
15
+ - **`@internal`**: implementation detail (`substitute`, `templatesRoot`, `configPath`, the symlink and Vite-spawning helpers, and the rest). They keep working until the next major, and importing one is not supported today.
16
+
17
+ Nothing is removed and no signature changed. If you are importing something tagged `@internal` and it is the only way to do what you need, open an issue.
18
+
19
+ The other four packages came out clean: every export in `core`, `testing`, `vite-plugin` and `types` is reachable through the documented API.
20
+
21
+ ## 0.7.0
22
+
23
+ ### Minor Changes
24
+
25
+ - 7169a30: Stop scaffolding `template.json`, and add an audit rule for the damage it does.
26
+
27
+ Foundry reads `template.json` on load and, for every type it lists, replaces that type's entry in `documentTypes` with a fresh object. Into the new object it copies only `htmlFields`, `filePathFields` and `gmOnlyFields`, and it reads them from the document level of `template.json` rather than from the type. So a system that declares this:
28
+
29
+ ```json
30
+ "documentTypes": { "Actor": { "character": { "htmlFields": ["biography"] } } }
31
+ ```
32
+
33
+ loses it the moment `template.json` lists `character` under `Actor`. The scaffolds did both, so every system created from them shipped with its `htmlFields` quietly discarded, taking HTML sanitization, ProseMirror enrichment, asset path migration and search indexing with it. Nothing errors, and the field goes on saving and loading, so the loss shows up much later as a stripped value or a path that never migrated.
34
+
35
+ The types are declared in `system.json` under `documentTypes` and the shape comes from the `TypeDataModel`, so nothing needed the second file. New scaffolds do not ship one.
36
+
37
+ `vttforge audit` reports the collision as `VTTF-AUDIT-010` (HIGH), naming the keys that get dropped. Run it on an existing project:
38
+
39
+ ```bash
40
+ npx vttforge audit
41
+ ```
42
+
43
+ If you have a `template.json` and no type in it declares one of those three keys in `documentTypes`, nothing changes for you.
44
+
45
+ ### Patch Changes
46
+
47
+ - 4f81bfd: Follow the `@vttforge/core` minor in the scaffold's pin, so a new project gets the `onI18nInit` and `onSetup` hooks.
48
+
49
+ On a `0.x` version a caret pins the minor, so `^0.11.0` would have kept new projects on the release before them.
50
+ - e9c184d: Follow the `@vttforge/styles` minor in the scaffold's pin.
51
+
52
+ On a `0.x` version a caret pins the minor, so `^0.3.0` would have kept new projects on the old styles. The templates ship inside this package, so the corrected pin only reaches anyone when the CLI is published too.
53
+
3
54
  ## 0.6.0
4
55
 
5
56
  ### Minor Changes
package/README.md CHANGED
@@ -22,7 +22,7 @@ vttforge audit [dir] [--json] [--strict]
22
22
 
23
23
  **`build`** runs the production build and writes `<id>-<version>.zip` at the project root with the manifest at the top level, which is what foundryvtt.com expects. `LICENSE`, `README.md` and `CHANGELOG.md` go in when present.
24
24
 
25
- **`audit`** checks the manifest, the source and the templates against nine v13 breakages that fail quietly: the `flags.hotReload` shape, deprecated grid fields, the v12 `styles` shape, `HTMLField`/`FilePathField` paths missing from `documentTypes`, `TypeDataModel` without `prepareBaseData`, a bad `_addDataFieldMigrations` override, token attributes that do not point at a `{ value, max }` field, a sheet template that opens a `<form>` the sheet already is, and a declared subtype with no name in any language file. `--json` for machines; `--strict` exits non-zero on any finding rather than only on HIGH.
25
+ **`audit`** checks the manifest, the source and the templates against ten v13 breakages that fail quietly: the `flags.hotReload` shape, deprecated grid fields, the v12 `styles` shape, `HTMLField`/`FilePathField` paths missing from `documentTypes`, `TypeDataModel` without `prepareBaseData`, a bad `_addDataFieldMigrations` override, token attributes that do not point at a `{ value, max }` field, a sheet template that opens a `<form>` the sheet already is, a declared subtype with no name in any language file, and a `template.json` that erases the metadata `system.json` declares for the same type. `--json` for machines; `--strict` exits non-zero on any finding rather than only on HIGH.
26
26
 
27
27
  ## As a library
28
28
 
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { M as runAuditCommand, c as runDev, n as ScaffoldError, r as runInit, t as VTTFORGE_CLI_VERSION, x as runBuild } from "./src-CHdyBA95.mjs";
2
+ import { M as runAuditCommand, c as runDev, n as ScaffoldError, r as runInit, t as VTTFORGE_CLI_VERSION, x as runBuild } from "./src-C2VIeKmf.mjs";
3
3
  import { defineCommand, runMain } from "citty";
4
4
  //#region src/cli.ts
5
5
  /**
package/dist/index.d.mts CHANGED
@@ -3,8 +3,7 @@ import { ChildProcess } from "node:child_process";
3
3
  /**
4
4
  * Shared types for the `vttforge audit` rule engine.
5
5
  *
6
- * The audit catalog covers seven v13 footguns from the VTTForge audit
7
- * spec. Each rule produces zero or more `RuleResult` entries; the
6
+ * The audit catalog covers ten v13 footguns. Each rule produces zero or more `RuleResult` entries; the
8
7
  * orchestrator aggregates them into an `AuditReport` which the reporter
9
8
  * renders as JSON or markdown.
10
9
  *
@@ -57,10 +56,6 @@ interface RunAuditOptions {
57
56
  declare function runAudit(options: RunAuditOptions): Promise<AuditReport>;
58
57
  //#endregion
59
58
  //#region src/audit/manifest-rules.d.ts
60
- /**
61
- * Entry point: run every manifest rule against every manifest at the
62
- * project root.
63
- */
64
59
  declare function runManifestRules(cwd: string): Promise<RuleResult[]>;
65
60
  //#endregion
66
61
  //#region src/audit/reporter.d.ts
@@ -90,6 +85,10 @@ interface AuditResult {
90
85
  /** Suggested exit code under the current strictness setting. */
91
86
  exitCode: 0 | 1;
92
87
  }
88
+ /**
89
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
90
+ * change in a minor.
91
+ */
93
92
  declare function runAuditCommand(options?: AuditOptions): Promise<AuditResult>;
94
93
  //#endregion
95
94
  //#region src/manifest.d.ts
@@ -121,6 +120,9 @@ interface FoundryManifest {
121
120
  * Throws if neither file exists, required fields are missing/non-string,
122
121
  * or the id/version contain characters that would let downstream `join()`
123
122
  * calls escape their intended directory.
123
+ *
124
+ * @experimental Shape is unproven: no consumer has asked for this yet.
125
+ * It can change in a minor.
124
126
  */
125
127
  declare function readManifest(distDir: string): Promise<FoundryManifest>;
126
128
  //#endregion
@@ -132,6 +134,9 @@ interface BuildOptions {
132
134
  /**
133
135
  * Internal building block exposed for tests: assumes dist/ is already
134
136
  * populated (vite has run, manifest is present) and just emits the zip.
137
+ *
138
+ * @experimental Shape is unproven: no consumer has asked for this yet.
139
+ * It can change in a minor.
135
140
  */
136
141
  declare function emitReleaseZip(opts: {
137
142
  cwd: string;
@@ -140,6 +145,10 @@ declare function emitReleaseZip(opts: {
140
145
  byteSize: number;
141
146
  manifest: FoundryManifest;
142
147
  }>;
148
+ /**
149
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
150
+ * change in a minor.
151
+ */
143
152
  declare function runBuild(options?: BuildOptions): Promise<void>;
144
153
  //#endregion
145
154
  //#region src/commands/dev.d.ts
@@ -151,6 +160,10 @@ interface DevOptions {
151
160
  /** Port for the hot reload bridge. */
152
161
  hmrPort?: number;
153
162
  }
163
+ /**
164
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
165
+ * change in a minor.
166
+ */
154
167
  declare function runDev(options?: DevOptions): Promise<void>;
155
168
  /**
156
169
  * Internal building block exposed for tests: given an already-built `dist/`
@@ -158,6 +171,9 @@ declare function runDev(options?: DevOptions): Promise<void>;
158
171
  * create the symlink and return the target path + manifest. Skips the
159
172
  * vite spawn and the signal-loop, so tests can drive the orchestration
160
173
  * deterministically.
174
+ *
175
+ * @internal Implementation detail of the `vttforge` binary. Not supported
176
+ * for outside use, and going away in the next major.
161
177
  */
162
178
  declare function setupDevSymlink(opts: {
163
179
  cwd: string;
@@ -172,6 +188,9 @@ declare function setupDevSymlink(opts: {
172
188
  * Refuses to remove a symlink that another `vttforge dev` session (or a
173
189
  * manual `ln -s`) has since redirected. That link doesn't belong to us
174
190
  * and removing it would silently disconnect their setup.
191
+ *
192
+ * @internal Implementation detail of the `vttforge` binary. Not supported
193
+ * for outside use, and going away in the next major.
175
194
  */
176
195
  declare function cleanupDevSymlink(opts: {
177
196
  target: string;
@@ -266,19 +285,37 @@ interface VTTForgeConfig {
266
285
  * Return the OS-default Foundry user-data directory, or `null` on unknown
267
286
  * platforms / missing platform-specific env vars. Does NOT check existence;
268
287
  * callers prompt the user when the suggested path doesn't resolve.
288
+ *
289
+ * @internal Implementation detail of the `vttforge` binary. Not supported
290
+ * for outside use, and going away in the next major.
269
291
  */
270
292
  declare function autoDetectFoundryDataDir(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv, home?: string): string | null;
271
293
  /**
272
294
  * Heuristic: a path looks like a Foundry user-data root if it contains a
273
295
  * `Data/` subdirectory (canonical Foundry layout) OR if it already contains
274
296
  * `systems/` or `modules/` (the path is already the Data folder itself).
297
+ *
298
+ * @internal Implementation detail of the `vttforge` binary. Not supported
299
+ * for outside use, and going away in the next major.
275
300
  */
276
301
  declare function looksLikeFoundryDataDir(path: string): boolean;
277
- /** Absolute path to the project-local config file (whether or not it exists). */
302
+ /** Absolute path to the project-local config file (whether or not it exists).
303
+ *
304
+ * @internal Implementation detail of the `vttforge` binary. Not supported
305
+ * for outside use, and going away in the next major.
306
+ */
278
307
  declare function configPath(cwd: string): string;
279
- /** Load `<cwd>/.vttforge/config.json` if it exists and is valid JSON. */
308
+ /** Load `<cwd>/.vttforge/config.json` if it exists and is valid JSON.
309
+ *
310
+ * @internal Implementation detail of the `vttforge` binary. Not supported
311
+ * for outside use, and going away in the next major.
312
+ */
280
313
  declare function loadConfig(cwd: string): Promise<VTTForgeConfig | null>;
281
- /** Persist `<cwd>/.vttforge/config.json`. Creates the `.vttforge/` dir as needed. */
314
+ /** Persist `<cwd>/.vttforge/config.json`. Creates the `.vttforge/` dir as needed.
315
+ *
316
+ * @internal Implementation detail of the `vttforge` binary. Not supported
317
+ * for outside use, and going away in the next major.
318
+ */
282
319
  declare function saveConfig(cwd: string, config: VTTForgeConfig): Promise<void>;
283
320
  /**
284
321
  * Resolve the packages directory (`Data/systems/` or `Data/modules/`) under
@@ -288,6 +325,9 @@ declare function saveConfig(cwd: string, config: VTTForgeConfig): Promise<void>;
288
325
  *
289
326
  * The returned path is not guaranteed to exist yet; callers `mkdir -p` it
290
327
  * before creating the symlink.
328
+ *
329
+ * @internal Implementation detail of the `vttforge` binary. Not supported
330
+ * for outside use, and going away in the next major.
291
331
  */
292
332
  declare function foundryPackagesDir(dataRoot: string, type: 'system' | 'module'): string;
293
333
  interface ResolveDataDirOptions {
@@ -313,6 +353,9 @@ interface ResolveDataDirOptions {
313
353
  * Walk the precedence chain and return the chosen Foundry user-data path.
314
354
  * Saves the user's choice to the project config on first interactive run so
315
355
  * subsequent invocations skip the prompt.
356
+ *
357
+ * @internal Implementation detail of the `vttforge` binary. Not supported
358
+ * for outside use, and going away in the next major.
316
359
  */
317
360
  declare function resolveFoundryDataDir(opts: ResolveDataDirOptions): Promise<string>;
318
361
  //#endregion
@@ -328,7 +371,15 @@ declare function resolveFoundryDataDir(opts: ResolveDataDirOptions): Promise<str
328
371
  * environment wins over the default.
329
372
  */
330
373
  type PackageManager = 'pnpm' | 'npm' | 'bun' | 'yarn';
374
+ /**
375
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
376
+ * outside use, and going away in the next major.
377
+ */
331
378
  declare function detectPackageManager(env?: NodeJS.ProcessEnv): PackageManager;
379
+ /**
380
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
381
+ * outside use, and going away in the next major.
382
+ */
332
383
  declare function installCommand(pm: PackageManager): string;
333
384
  /**
334
385
  * Detect a project's package manager by looking at which lockfile it
@@ -339,6 +390,9 @@ declare function installCommand(pm: PackageManager): string;
339
390
  *
340
391
  * Falls back to {@link detectPackageManager} for fresh checkouts that
341
392
  * haven't been installed yet.
393
+ *
394
+ * @internal Implementation detail of the `vttforge` binary. Not supported
395
+ * for outside use, and going away in the next major.
342
396
  */
343
397
  declare function detectProjectPackageManager(cwd: string, env?: NodeJS.ProcessEnv): PackageManager;
344
398
  /**
@@ -348,6 +402,9 @@ declare function detectProjectPackageManager(cwd: string, env?: NodeJS.ProcessEn
348
402
  * Plug'n'Play, pnpm's symlinked layout, npm's flattened node_modules,
349
403
  * Bun's symlinked node_modules. Each manager exposes a uniform "run a
350
404
  * locally-resolved binary in the project's dependency graph" command.
405
+ *
406
+ * @internal Implementation detail of the `vttforge` binary. Not supported
407
+ * for outside use, and going away in the next major.
351
408
  */
352
409
  declare function execInvocation(pm: PackageManager, bin: string): [string, string[]];
353
410
  //#endregion
@@ -390,14 +447,24 @@ interface ScaffoldOptions {
390
447
  * Unknown placeholders are passed through unchanged so partially-templated
391
448
  * files (e.g. a snippet that contains `{{handlebarsLikeSyntax}}` as literal
392
449
  * content) still scaffold without surprises.
450
+ *
451
+ * @internal Implementation detail of the `vttforge` binary. Not supported
452
+ * for outside use, and going away in the next major.
393
453
  */
394
454
  declare function substitute(content: string, vars: ScaffoldVars): string;
455
+ /**
456
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
457
+ * outside use, and going away in the next major.
458
+ */
395
459
  declare function scaffold({ templateDir, destDir, vars }: ScaffoldOptions): Promise<void>;
396
460
  /**
397
461
  * Resolve the templates directory relative to this module's file URL. tsdown
398
462
  * emits `dist/scaffold.mjs`, so `import.meta.url` points there at runtime;
399
463
  * we walk up two segments to land at the package root, then descend into
400
464
  * `templates/`.
465
+ *
466
+ * @internal Implementation detail of the `vttforge` binary. Not supported
467
+ * for outside use, and going away in the next major.
401
468
  */
402
469
  declare function templatesRoot(): string;
403
470
  //#endregion
@@ -426,6 +493,9 @@ interface CreateLinkOptions {
426
493
  * `null` if `path` doesn't exist or isn't a symlink. Relative symlink
427
494
  * targets are resolved against the link's own directory (matches the
428
495
  * semantics callers expect when comparing to a known absolute source).
496
+ *
497
+ * @internal Implementation detail of the `vttforge` binary. Not supported
498
+ * for outside use, and going away in the next major.
429
499
  */
430
500
  declare function readLinkTarget(path: string): Promise<string | null>;
431
501
  /**
@@ -436,27 +506,48 @@ declare function readLinkTarget(path: string): Promise<string | null>;
436
506
  * - target already points to source → no-op
437
507
  * - target points elsewhere → throws unless `options.overwrite`
438
508
  * - target is a real file/dir → throws unconditionally
509
+ *
510
+ * @internal Implementation detail of the `vttforge` binary. Not supported
511
+ * for outside use, and going away in the next major.
439
512
  */
440
513
  declare function createLink(target: string, source: string, options?: CreateLinkOptions): Promise<void>;
441
514
  /**
442
515
  * Remove a symlink at `path`. No-ops when the path doesn't exist. Throws
443
516
  * when the path exists but isn't a symlink; we never unlink real files
444
517
  * or directories.
518
+ *
519
+ * @internal Implementation detail of the `vttforge` binary. Not supported
520
+ * for outside use, and going away in the next major.
445
521
  */
446
522
  declare function removeLink(path: string): Promise<void>;
447
523
  //#endregion
448
524
  //#region src/vite-runner.d.ts
525
+ /**
526
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
527
+ * outside use, and going away in the next major.
528
+ */
449
529
  declare class ViteNotInstalledError extends Error {
450
530
  constructor(message: string);
451
531
  }
452
- /** Spawn args for invoking the user's vite (e.g. `["pnpm", ["exec", "vite"]]`). */
532
+ /** Spawn args for invoking the user's vite (e.g. `["pnpm", ["exec", "vite"]]`).
533
+ *
534
+ * @internal Implementation detail of the `vttforge` binary. Not supported
535
+ * for outside use, and going away in the next major.
536
+ */
453
537
  declare function resolveViteInvocation(cwd: string): [string, string[]];
454
- /** Run `vite build` once and wait for it to exit. Throws on non-zero exit. */
538
+ /** Run `vite build` once and wait for it to exit. Throws on non-zero exit.
539
+ *
540
+ * @internal Implementation detail of the `vttforge` binary. Not supported
541
+ * for outside use, and going away in the next major.
542
+ */
455
543
  declare function runViteBuildOnce(cwd: string): Promise<void>;
456
544
  /**
457
545
  * Spawn `vite build --watch` and return the child process. The caller is
458
546
  * responsible for waiting on it and tearing it down (the dev command kills
459
547
  * it on SIGINT).
548
+ *
549
+ * @internal Implementation detail of the `vttforge` binary. Not supported
550
+ * for outside use, and going away in the next major.
460
551
  */
461
552
  declare function spawnViteWatch(cwd: string): ChildProcess;
462
553
  //#endregion
@@ -487,6 +578,10 @@ interface EmitZipResult {
487
578
  outFile: string;
488
579
  byteSize: number;
489
580
  }
581
+ /**
582
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
583
+ * change in a minor.
584
+ */
490
585
  declare function emitZip(opts: EmitZipOptions): Promise<EmitZipResult>;
491
586
  //#endregion
492
587
  //#region src/index.d.ts
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { A as installCommand, C as ViteNotInstalledError, D as detectPackageManager, E as spawnViteWatch, F as SEVERITY_RANK, I as runSourceRules, L as runManifestRules, M as runAuditCommand, N as formatReport, O as detectProjectPackageManager, P as runAudit, S as emitZip, T as runViteBuildOnce, _ as createLink, a as substitute, b as emitReleaseZip, c as runDev, d as configPath, f as foundryPackagesDir, g as saveConfig, h as resolveFoundryDataDir, i as scaffold, j as readManifest, k as execInvocation, l as setupDevSymlink, m as looksLikeFoundryDataDir, n as ScaffoldError, o as templatesRoot, p as loadConfig, r as runInit, s as cleanupDevSymlink, t as VTTFORGE_CLI_VERSION, u as autoDetectFoundryDataDir, v as readLinkTarget, w as resolveViteInvocation, x as runBuild, y as removeLink } from "./src-CHdyBA95.mjs";
1
+ import { A as installCommand, C as ViteNotInstalledError, D as detectPackageManager, E as spawnViteWatch, F as SEVERITY_RANK, I as runSourceRules, L as runManifestRules, M as runAuditCommand, N as formatReport, O as detectProjectPackageManager, P as runAudit, S as emitZip, T as runViteBuildOnce, _ as createLink, a as substitute, b as emitReleaseZip, c as runDev, d as configPath, f as foundryPackagesDir, g as saveConfig, h as resolveFoundryDataDir, i as scaffold, j as readManifest, k as execInvocation, l as setupDevSymlink, m as looksLikeFoundryDataDir, n as ScaffoldError, o as templatesRoot, p as loadConfig, r as runInit, s as cleanupDevSymlink, t as VTTFORGE_CLI_VERSION, u as autoDetectFoundryDataDir, v as readLinkTarget, w as resolveViteInvocation, x as runBuild, y as removeLink } from "./src-C2VIeKmf.mjs";
2
2
  export { SEVERITY_RANK, ScaffoldError, VTTFORGE_CLI_VERSION, ViteNotInstalledError, autoDetectFoundryDataDir, cleanupDevSymlink, configPath, createLink, detectPackageManager, detectProjectPackageManager, emitReleaseZip, emitZip, execInvocation, formatReport, foundryPackagesDir, installCommand, loadConfig, looksLikeFoundryDataDir, readLinkTarget, readManifest, removeLink, resolveFoundryDataDir, resolveViteInvocation, runAudit, runAuditCommand, runBuild, runDev, runInit, runManifestRules, runSourceRules, runViteBuildOnce, saveConfig, scaffold, setupDevSymlink, spawnViteWatch, substitute, templatesRoot };