@vttforge/cli 0.6.0 → 0.7.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 +33 -0
- package/README.md +1 -1
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +1 -6
- package/dist/index.mjs +1 -1
- package/dist/{src-CHdyBA95.mjs → src-4Yg6Ycyo.mjs} +72 -2
- package/dist/src-4Yg6Ycyo.mjs.map +1 -0
- package/package.json +1 -1
- package/templates/module-js/package.json +2 -2
- package/templates/module-ts/package.json +2 -2
- package/templates/system-js/README.md +0 -1
- package/templates/system-js/package.json +3 -3
- package/templates/system-ts/README.md +0 -1
- package/templates/system-ts/package.json +3 -3
- package/dist/src-CHdyBA95.mjs.map +0 -1
- package/templates/system-js/template.json +0 -8
- package/templates/system-ts/template.json +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @vttforge/cli
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7169a30: Stop scaffolding `template.json`, and add an audit rule for the damage it does.
|
|
8
|
+
|
|
9
|
+
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:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
"documentTypes": { "Actor": { "character": { "htmlFields": ["biography"] } } }
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
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.
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
`vttforge audit` reports the collision as `VTTF-AUDIT-010` (HIGH), naming the keys that get dropped. Run it on an existing project:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx vttforge audit
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If you have a `template.json` and no type in it declares one of those three keys in `documentTypes`, nothing changes for you.
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 4f81bfd: Follow the `@vttforge/core` minor in the scaffold's pin, so a new project gets the `onI18nInit` and `onSetup` hooks.
|
|
30
|
+
|
|
31
|
+
On a `0.x` version a caret pins the minor, so `^0.11.0` would have kept new projects on the release before them.
|
|
32
|
+
- e9c184d: Follow the `@vttforge/styles` minor in the scaffold's pin.
|
|
33
|
+
|
|
34
|
+
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.
|
|
35
|
+
|
|
3
36
|
## 0.6.0
|
|
4
37
|
|
|
5
38
|
### 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
|
|
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-
|
|
2
|
+
import { M as runAuditCommand, c as runDev, n as ScaffoldError, r as runInit, t as VTTFORGE_CLI_VERSION, x as runBuild } from "./src-4Yg6Ycyo.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
|
|
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
|
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-
|
|
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-4Yg6Ycyo.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 };
|
|
@@ -10,7 +10,7 @@ import { createServer } from "node:http";
|
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
11
|
import { promisify } from "node:util";
|
|
12
12
|
//#region package.json
|
|
13
|
-
var version = "0.
|
|
13
|
+
var version = "0.7.0";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/audit/manifest-rules.ts
|
|
16
16
|
/**
|
|
@@ -24,6 +24,7 @@ var version = "0.6.0";
|
|
|
24
24
|
* VTTF-AUDIT-002 (MEDIUM): deprecated gridDistance/gridUnits
|
|
25
25
|
* VTTF-AUDIT-003 (LOW) : styles array of strings (v12 shape)
|
|
26
26
|
* VTTF-AUDIT-009 (MEDIUM): a documentTypes subtype with no TYPES label
|
|
27
|
+
* VTTF-AUDIT-010 (HIGH) : template.json erasing documentTypes metadata
|
|
27
28
|
*
|
|
28
29
|
* Each rule emits zero or more `RuleResult`s. Line numbers are looked up
|
|
29
30
|
* cheaply by scanning the raw JSON for the offending key. Accurate
|
|
@@ -257,6 +258,74 @@ function nestedExample(dotted) {
|
|
|
257
258
|
* Entry point: run every manifest rule against every manifest at the
|
|
258
259
|
* project root.
|
|
259
260
|
*/
|
|
261
|
+
/**
|
|
262
|
+
* VTTF-AUDIT-010 (HIGH) — `template.json` erases the metadata that
|
|
263
|
+
* `system.json` declares for the same type.
|
|
264
|
+
*
|
|
265
|
+
* On load, Foundry reads `template.json` and, for every type it lists,
|
|
266
|
+
* replaces that type's entry in `documentTypes` with a fresh object. Into the
|
|
267
|
+
* new object it copies only `htmlFields`, `filePathFields` and `gmOnlyFields`,
|
|
268
|
+
* and it reads them from the document level of `template.json`, not from the
|
|
269
|
+
* type. So this in `system.json`:
|
|
270
|
+
*
|
|
271
|
+
* ```json
|
|
272
|
+
* "documentTypes": { "Actor": { "character": { "htmlFields": ["biography"] } } }
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* is thrown away the moment `template.json` lists `character` under `Actor`.
|
|
276
|
+
*
|
|
277
|
+
* Nothing errors, and the type still works. What is lost is every behaviour
|
|
278
|
+
* that keys off those lists: HTML sanitization, ProseMirror enrichment, asset
|
|
279
|
+
* path migration and search indexing. The field goes on saving and loading,
|
|
280
|
+
* so the loss is invisible until a value comes back stripped or a path fails
|
|
281
|
+
* to migrate.
|
|
282
|
+
*
|
|
283
|
+
* A system whose schemas come from `TypeDataModel` does not need
|
|
284
|
+
* `template.json` at all: `documentTypes` declares the types and the data
|
|
285
|
+
* model owns the shape.
|
|
286
|
+
*/
|
|
287
|
+
function ruleTemplateJsonShadowing(cwd, manifest) {
|
|
288
|
+
if (!manifest.path.endsWith("system.json")) return [];
|
|
289
|
+
const templatePath = join(cwd, "template.json");
|
|
290
|
+
if (!existsSync(templatePath)) return [];
|
|
291
|
+
const documentTypes = manifest.parsed.documentTypes;
|
|
292
|
+
if (documentTypes === null || typeof documentTypes !== "object") return [];
|
|
293
|
+
let template;
|
|
294
|
+
try {
|
|
295
|
+
template = JSON.parse(readFileSync(templatePath, "utf8"));
|
|
296
|
+
} catch {
|
|
297
|
+
return [];
|
|
298
|
+
}
|
|
299
|
+
const CARRIED = [
|
|
300
|
+
"htmlFields",
|
|
301
|
+
"filePathFields",
|
|
302
|
+
"gmOnlyFields"
|
|
303
|
+
];
|
|
304
|
+
const results = [];
|
|
305
|
+
for (const [documentName, declared] of Object.entries(documentTypes)) {
|
|
306
|
+
if (declared === null || typeof declared !== "object") continue;
|
|
307
|
+
const templateDoc = template[documentName];
|
|
308
|
+
if (templateDoc === null || typeof templateDoc !== "object") continue;
|
|
309
|
+
const listed = templateDoc.types;
|
|
310
|
+
if (!Array.isArray(listed)) continue;
|
|
311
|
+
for (const [type, meta] of Object.entries(declared)) {
|
|
312
|
+
if (!listed.includes(type)) continue;
|
|
313
|
+
if (meta === null || typeof meta !== "object") continue;
|
|
314
|
+
const lost = CARRIED.filter((key) => key in meta && !(key in templateDoc));
|
|
315
|
+
if (lost.length === 0) continue;
|
|
316
|
+
results.push({
|
|
317
|
+
ruleId: "VTTF-AUDIT-010",
|
|
318
|
+
title: "template.json erases documentTypes metadata",
|
|
319
|
+
severity: "HIGH",
|
|
320
|
+
filePath: "template.json",
|
|
321
|
+
line: findKeyLine(readFileSync(templatePath, "utf8"), documentName),
|
|
322
|
+
message: `template.json lists ${documentName} type "${type}", so Foundry replaces that type's documentTypes entry and drops ${lost.join(", ")} declared in system.json. Sanitization, enrichment and asset migration stop applying to those fields, silently.`,
|
|
323
|
+
remediation: "Delete template.json. Your types are declared in system.json under `documentTypes`, and the schema comes from the TypeDataModel registered on `CONFIG.<Document>.dataModels`. If you still need it, move the lost keys up to the document level of template.json instead of the type."
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return results;
|
|
328
|
+
}
|
|
260
329
|
async function runManifestRules(cwd) {
|
|
261
330
|
const manifests = await loadManifests(cwd);
|
|
262
331
|
const results = [];
|
|
@@ -265,6 +334,7 @@ async function runManifestRules(cwd) {
|
|
|
265
334
|
results.push(...ruleGridShape(manifest));
|
|
266
335
|
results.push(...ruleStylesShape(manifest));
|
|
267
336
|
results.push(...await ruleTypeLabels(cwd, manifest));
|
|
337
|
+
results.push(...ruleTemplateJsonShadowing(cwd, manifest));
|
|
268
338
|
}
|
|
269
339
|
return results;
|
|
270
340
|
}
|
|
@@ -2731,4 +2801,4 @@ const VTTFORGE_CLI_VERSION = version;
|
|
|
2731
2801
|
//#endregion
|
|
2732
2802
|
export { installCommand as A, ViteNotInstalledError as C, detectPackageManager as D, spawnViteWatch as E, SEVERITY_RANK as F, runSourceRules as I, runManifestRules as L, runAuditCommand as M, formatReport as N, detectProjectPackageManager as O, runAudit as P, emitZip as S, runViteBuildOnce as T, createLink as _, substitute as a, emitReleaseZip as b, runDev as c, configPath as d, foundryPackagesDir as f, saveConfig as g, resolveFoundryDataDir as h, scaffold as i, readManifest as j, execInvocation as k, setupDevSymlink as l, looksLikeFoundryDataDir as m, ScaffoldError as n, templatesRoot as o, loadConfig as p, runInit as r, cleanupDevSymlink as s, VTTFORGE_CLI_VERSION as t, autoDetectFoundryDataDir as u, readLinkTarget as v, resolveViteInvocation as w, runBuild as x, removeLink as y };
|
|
2733
2803
|
|
|
2734
|
-
//# sourceMappingURL=src-
|
|
2804
|
+
//# sourceMappingURL=src-4Yg6Ycyo.mjs.map
|