@vttforge/cli 0.8.0 → 0.9.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 +17 -0
- package/README.md +2 -2
- package/dist/bin.mjs +3 -3
- package/dist/bin.mjs.map +1 -1
- package/dist/index.d.mts +16 -16
- package/dist/index.mjs +1 -1
- package/dist/{src-uGulrZd5.mjs → src-BAHJHuJ7.mjs} +239 -31
- package/dist/src-BAHJHuJ7.mjs.map +1 -0
- package/package.json +5 -5
- package/templates/module-js/README.md +3 -3
- package/templates/module-js/module.json +1 -0
- package/templates/module-js/package.json +3 -3
- package/templates/module-ts/README.md +3 -3
- package/templates/module-ts/module.json +1 -0
- package/templates/module-ts/package.json +3 -3
- package/templates/system-js/README.md +3 -3
- package/templates/system-js/package.json +3 -3
- package/templates/system-js/scripts/main.mjs +0 -8
- package/templates/system-js/scripts/migrations.mjs +1 -1
- package/templates/system-js/system.json +1 -0
- package/templates/system-js/templates/actor/character-sheet.hbs +1 -1
- package/templates/system-ts/README.md +3 -3
- package/templates/system-ts/package.json +3 -3
- package/templates/system-ts/scripts/foundry-globals.ts +4 -0
- package/templates/system-ts/scripts/main.ts +0 -8
- package/templates/system-ts/scripts/migrations.ts +1 -1
- package/templates/system-ts/system.json +1 -0
- package/templates/system-ts/templates/actor/character-sheet.hbs +1 -1
- package/dist/src-uGulrZd5.mjs.map +0 -1
|
@@ -10,18 +10,18 @@ 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.9.0";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/audit/manifest-rules.ts
|
|
16
16
|
/**
|
|
17
17
|
* Manifest-scope audit rules.
|
|
18
18
|
*
|
|
19
19
|
* These rules operate on the parsed contents of `system.json` and/or
|
|
20
|
-
* `module.json` at the project root. They cover
|
|
20
|
+
* `module.json` at the project root. They cover the v14 manifest
|
|
21
21
|
* footguns from the VTTForge audit catalog:
|
|
22
22
|
*
|
|
23
23
|
* VTTF-AUDIT-001 (HIGH) : flags.hotReload shape
|
|
24
|
-
* VTTF-AUDIT-002 (
|
|
24
|
+
* VTTF-AUDIT-002 (HIGH) : removed 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
27
|
* VTTF-AUDIT-010 (HIGH) : template.json erasing documentTypes metadata
|
|
@@ -80,7 +80,7 @@ function findKeyLine(raw, key) {
|
|
|
80
80
|
/**
|
|
81
81
|
* VTTF-AUDIT-001 (HIGH): flags.hotReload shape.
|
|
82
82
|
*
|
|
83
|
-
* v12 accepted `"hotReload": ["css", "hbs", ...]` (array). v13 expects
|
|
83
|
+
* v12 accepted `"hotReload": ["css", "hbs", ...]` (array). v13+ expects
|
|
84
84
|
* `"hotReload": { "extensions": [...], "paths": [...] }` (object at the
|
|
85
85
|
* root of `flags`, NOT nested under a package id). With the array shape
|
|
86
86
|
* the server's chokidar watcher reads `.extensions` and gets undefined,
|
|
@@ -98,7 +98,7 @@ function ruleHotReload(manifest) {
|
|
|
98
98
|
severity: "HIGH",
|
|
99
99
|
filePath: manifest.path,
|
|
100
100
|
line,
|
|
101
|
-
message: "flags.hotReload is an array;
|
|
101
|
+
message: "flags.hotReload is an array; Foundry expects an object `{ \"extensions\": [...], \"paths\": [...] }`. With the array shape Foundry silently disables HMR for this package.",
|
|
102
102
|
remediation: "Replace the array with an object: `\"hotReload\": { \"extensions\": [\"css\", \"hbs\", \"json\"], \"paths\": [\"styles\", \"templates\", \"lang\"] }`."
|
|
103
103
|
}];
|
|
104
104
|
if (hr === null || typeof hr !== "object") return [{
|
|
@@ -107,7 +107,7 @@ function ruleHotReload(manifest) {
|
|
|
107
107
|
severity: "HIGH",
|
|
108
108
|
filePath: manifest.path,
|
|
109
109
|
line,
|
|
110
|
-
message: "flags.hotReload must be an object with `extensions` and `paths` arrays
|
|
110
|
+
message: "flags.hotReload must be an object with `extensions` and `paths` arrays.",
|
|
111
111
|
remediation: "Replace with `\"hotReload\": { \"extensions\": [...], \"paths\": [...] }`."
|
|
112
112
|
}];
|
|
113
113
|
const hrObj = hr;
|
|
@@ -123,12 +123,12 @@ function ruleHotReload(manifest) {
|
|
|
123
123
|
return [];
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* VTTF-AUDIT-002 (
|
|
126
|
+
* VTTF-AUDIT-002 (HIGH): removed top-level grid fields.
|
|
127
127
|
*
|
|
128
|
-
* v12 used flat `gridDistance` + `gridUnits`. v13
|
|
129
|
-
* `grid: { type, distance, units, diagonals }
|
|
130
|
-
*
|
|
131
|
-
*
|
|
128
|
+
* v12 used flat `gridDistance` + `gridUnits`. v13 auto-migrated them to
|
|
129
|
+
* `grid: { type, distance, units, diagonals }` with a warning; v14 dropped
|
|
130
|
+
* the shim. The keys are now ignored and the system silently falls back to
|
|
131
|
+
* the default grid.
|
|
132
132
|
*/
|
|
133
133
|
function ruleGridShape(manifest) {
|
|
134
134
|
const hasLegacyDistance = "gridDistance" in manifest.parsed;
|
|
@@ -137,18 +137,18 @@ function ruleGridShape(manifest) {
|
|
|
137
137
|
const offendingKey = hasLegacyDistance ? "gridDistance" : "gridUnits";
|
|
138
138
|
return [{
|
|
139
139
|
ruleId: "VTTF-AUDIT-002",
|
|
140
|
-
title: "Top-level gridDistance / gridUnits are
|
|
141
|
-
severity: "
|
|
140
|
+
title: "Top-level gridDistance / gridUnits are removed v12 fields",
|
|
141
|
+
severity: "HIGH",
|
|
142
142
|
filePath: manifest.path,
|
|
143
143
|
line: findKeyLine(manifest.raw, offendingKey),
|
|
144
|
-
message: "gridDistance and gridUnits at the manifest root are the v12 shape.
|
|
144
|
+
message: "gridDistance and gridUnits at the manifest root are the v12 shape. v14 removed the migration shim: the keys are ignored and the system falls back to the default grid with no warning.",
|
|
145
145
|
remediation: "Replace with `\"grid\": { \"type\": 1, \"distance\": 5, \"units\": \"ft\", \"diagonals\": 0 }` (adjust values to your system)."
|
|
146
146
|
}];
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* VTTF-AUDIT-003 (LOW): styles array of strings.
|
|
150
150
|
*
|
|
151
|
-
* v12 took `styles: ["styles/foo.css"]`. v13 expects `styles: [{ src,
|
|
151
|
+
* v12 took `styles: ["styles/foo.css"]`. v13+ expects `styles: [{ src,
|
|
152
152
|
* layer? }]` so cascade-layer ordering can be declared in the manifest.
|
|
153
153
|
* The string form still works (Foundry auto-migrates) but emits a
|
|
154
154
|
* deprecation warning and loses the ability to control layer placement.
|
|
@@ -163,7 +163,7 @@ function ruleStylesShape(manifest) {
|
|
|
163
163
|
severity: "LOW",
|
|
164
164
|
filePath: manifest.path,
|
|
165
165
|
line: findKeyLine(manifest.raw, "styles"),
|
|
166
|
-
message: "styles entries should be objects of the form `{ \"src\": \"path/to.css\", \"layer\": \"optional-layer\" }`
|
|
166
|
+
message: "styles entries should be objects of the form `{ \"src\": \"path/to.css\", \"layer\": \"optional-layer\" }` since v13. String entries auto-migrate today but the conversion drops your control over cascade-layer placement.",
|
|
167
167
|
remediation: "Replace each string with `{ \"src\": \"<that-path>\" }`. Add a `\"layer\"` field per entry where you want explicit cascade ordering."
|
|
168
168
|
}];
|
|
169
169
|
}
|
|
@@ -345,7 +345,7 @@ async function runManifestRules(cwd) {
|
|
|
345
345
|
*
|
|
346
346
|
* These walk `.ts` / `.tsx` / `.mjs` / `.cjs` / `.js` files under the
|
|
347
347
|
* project root (excluding common build/dependency dirs) and apply regex
|
|
348
|
-
* heuristics to spot four
|
|
348
|
+
* heuristics to spot four footguns from the VTTForge audit catalog:
|
|
349
349
|
*
|
|
350
350
|
* VTTF-AUDIT-004 (MEDIUM): HTMLField/FilePathField missing manifest declaration
|
|
351
351
|
* VTTF-AUDIT-005 (MEDIUM): extends TypeDataModel without prepareBaseData stub
|
|
@@ -464,7 +464,7 @@ function rule006(filePath, content) {
|
|
|
464
464
|
severity: "LOW",
|
|
465
465
|
filePath,
|
|
466
466
|
line: lineOf(content, /_addDataFieldMigrations\s*\(/),
|
|
467
|
-
message: "The plural `_addDataFieldMigrations` is not a real Foundry API. The canonical
|
|
467
|
+
message: "The plural `_addDataFieldMigrations` is not a real Foundry API. The canonical migration hook is a static `migrateData(source)` override that calls singular `super._addDataFieldMigration(source, oldKey, newKey, apply?)` for each rename. Instance overrides named `_addDataFieldMigrations` never run.",
|
|
468
468
|
remediation: "Replace the override with `static migrateData(source) { super._addDataFieldMigration(source, \"oldKey\", \"newKey\"); return super.migrateData(source); }`."
|
|
469
469
|
}];
|
|
470
470
|
}
|
|
@@ -1098,6 +1098,7 @@ async function runSourceRules(cwd) {
|
|
|
1098
1098
|
const _internal = {
|
|
1099
1099
|
walkSourceFiles,
|
|
1100
1100
|
isSourceFile,
|
|
1101
|
+
lineOf,
|
|
1101
1102
|
lastSegment,
|
|
1102
1103
|
findClassRanges,
|
|
1103
1104
|
EXCLUDED_DIRS
|
|
@@ -1205,6 +1206,210 @@ const SEVERITY_RANK = {
|
|
|
1205
1206
|
LOW: 2
|
|
1206
1207
|
};
|
|
1207
1208
|
//#endregion
|
|
1209
|
+
//#region src/audit/v14-rules.ts
|
|
1210
|
+
/**
|
|
1211
|
+
* Source rules for the v13 code that v14 broke or deprecated.
|
|
1212
|
+
*
|
|
1213
|
+
* VTTF-AUDIT-011 (HIGH) : a bare utility global v14 removed (`mergeObject(`, ...)
|
|
1214
|
+
* VTTF-AUDIT-012 (MEDIUM): `-=` / `==` update keys, replaced by data operators
|
|
1215
|
+
* VTTF-AUDIT-013 (MEDIUM): `rollMode`, replaced by `messageMode`
|
|
1216
|
+
* VTTF-AUDIT-014 (MEDIUM): `CONFIG.statusEffects = [...]`, which empties the collection first
|
|
1217
|
+
* VTTF-AUDIT-015 (MEDIUM): `legacyTransferral`, a flag v14 no longer reads
|
|
1218
|
+
* VTTF-AUDIT-016 (MEDIUM): numeric Active Effect modes, replaced by string change types
|
|
1219
|
+
*
|
|
1220
|
+
* Regex heuristics like the rest of the source rules, for the same reason:
|
|
1221
|
+
* the patterns are short and a TypeScript AST would not make them more
|
|
1222
|
+
* precise. Each rule reports the first match per file; one finding is enough
|
|
1223
|
+
* to send the reader to the file, and the fix is a search-and-replace there.
|
|
1224
|
+
*/
|
|
1225
|
+
/**
|
|
1226
|
+
* VTTF-AUDIT-011 (HIGH): a bare utility global v14 removed.
|
|
1227
|
+
*
|
|
1228
|
+
* v13 kept the v12-era globals (`mergeObject`, `getProperty`, ...) as
|
|
1229
|
+
* deprecation shims over `foundry.utils`. v14 removed the shims, so a bare
|
|
1230
|
+
* call throws `ReferenceError` the first time it runs, which for a helper
|
|
1231
|
+
* called from a sheet or a migration means a feature that dies on click.
|
|
1232
|
+
*
|
|
1233
|
+
* Only names with no plausible user-land meaning are listed: `duplicate`
|
|
1234
|
+
* and `debounce` are left out because a project can define its own.
|
|
1235
|
+
*/
|
|
1236
|
+
const REMOVED_UTILS = [
|
|
1237
|
+
"mergeObject",
|
|
1238
|
+
"getProperty",
|
|
1239
|
+
"setProperty",
|
|
1240
|
+
"hasProperty",
|
|
1241
|
+
"deepClone",
|
|
1242
|
+
"expandObject",
|
|
1243
|
+
"flattenObject",
|
|
1244
|
+
"diffObject",
|
|
1245
|
+
"isNewerVersion",
|
|
1246
|
+
"randomID"
|
|
1247
|
+
];
|
|
1248
|
+
const REMOVED_GLOBALS = [
|
|
1249
|
+
...REMOVED_UTILS.map((name) => ({
|
|
1250
|
+
name,
|
|
1251
|
+
pattern: new RegExp(`(?<![\\w$.])${name}\\s*\\(`),
|
|
1252
|
+
replacement: `\`foundry.utils.${name}\``
|
|
1253
|
+
})),
|
|
1254
|
+
{
|
|
1255
|
+
name: "Math.clamped",
|
|
1256
|
+
pattern: /\bMath\.clamped\s*\(/,
|
|
1257
|
+
replacement: "`Math.clamp`"
|
|
1258
|
+
},
|
|
1259
|
+
{
|
|
1260
|
+
name: "game.template",
|
|
1261
|
+
pattern: /\bgame\.template\b/,
|
|
1262
|
+
replacement: "`game.model` or the `documentTypes` on the package"
|
|
1263
|
+
}
|
|
1264
|
+
];
|
|
1265
|
+
/**
|
|
1266
|
+
* A file that declares, imports, or defines the name as a method (a test
|
|
1267
|
+
* mock's `utils: { mergeObject(a, b) {...} }`) is using its own, not
|
|
1268
|
+
* Foundry's. The method-shorthand alternative uses `[^)]*` (no nested
|
|
1269
|
+
* parens) to avoid a false positive on call-sites inside conditional blocks
|
|
1270
|
+
* like `if (hasProperty(obj, 'key')) {`, where a lazy `[\s\S]*?` would
|
|
1271
|
+
* backtrack through the outer `)` and match the block brace.
|
|
1272
|
+
*/
|
|
1273
|
+
function definesItself(content, name) {
|
|
1274
|
+
return new RegExp(`(?:function\\s+${name}\\b|(?:const|let|var)\\s+${name}\\b|import[^;]*\\b${name}\\b|\\b${name}\\s*\\([^)]*\\)\\s*\\{)`).test(content);
|
|
1275
|
+
}
|
|
1276
|
+
function rule011(filePath, content) {
|
|
1277
|
+
const first = REMOVED_GLOBALS.flatMap((global) => {
|
|
1278
|
+
const idx = content.search(global.pattern);
|
|
1279
|
+
if (idx < 0) return [];
|
|
1280
|
+
if (REMOVED_UTILS.includes(global.name) && definesItself(content, global.name)) return [];
|
|
1281
|
+
return [{
|
|
1282
|
+
global,
|
|
1283
|
+
idx
|
|
1284
|
+
}];
|
|
1285
|
+
}).sort((a, b) => a.idx - b.idx)[0];
|
|
1286
|
+
if (first === void 0) return [];
|
|
1287
|
+
return [{
|
|
1288
|
+
ruleId: "VTTF-AUDIT-011",
|
|
1289
|
+
title: "A global v14 removed",
|
|
1290
|
+
severity: "HIGH",
|
|
1291
|
+
filePath,
|
|
1292
|
+
line: _internal.lineOf(content, first.global.pattern),
|
|
1293
|
+
message: `\`${first.global.name}\` was a v12 shim that v13 kept and v14 removed. The call throws ReferenceError the first time it runs.`,
|
|
1294
|
+
remediation: `Use ${first.global.replacement}.`
|
|
1295
|
+
}];
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* VTTF-AUDIT-012 (MEDIUM): `-=` / `==` update keys.
|
|
1299
|
+
*
|
|
1300
|
+
* Deprecated since v14, removed in v16. The replacement is a data operator:
|
|
1301
|
+
* `{ "system.old": _del }` and `{ "system.stats": _replace({...}) }`, or the
|
|
1302
|
+
* classes under `foundry.data.operators`.
|
|
1303
|
+
*/
|
|
1304
|
+
function rule012(filePath, content) {
|
|
1305
|
+
const pattern = /['"`](?:[\w$]+\.)*(?:-=|==)[\w$]/;
|
|
1306
|
+
if (!pattern.test(content)) return [];
|
|
1307
|
+
return [{
|
|
1308
|
+
ruleId: "VTTF-AUDIT-012",
|
|
1309
|
+
title: "Update key uses the -= / == prefix",
|
|
1310
|
+
severity: "MEDIUM",
|
|
1311
|
+
filePath,
|
|
1312
|
+
line: _internal.lineOf(content, pattern),
|
|
1313
|
+
message: "The `-=key` and `==key` update syntax is deprecated since v14 and removed in v16. Foundry warns on every write that uses it.",
|
|
1314
|
+
remediation: "Delete with `{ \"path.to.key\": _del }` and replace with `{ \"path.to.key\": _replace(value) }`, or use `foundry.data.operators.ForcedDeletion` / `ForcedReplacement`. `mergeObject` takes `{ applyOperators: true }` where it took `{ performDeletions: true }`."
|
|
1315
|
+
}];
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* VTTF-AUDIT-013 (MEDIUM): `rollMode`.
|
|
1319
|
+
*
|
|
1320
|
+
* v14 renamed the option to `messageMode`, moved the user default to the
|
|
1321
|
+
* `core.messageMode` setting, and made `CONFIG.Dice.rollModes` and
|
|
1322
|
+
* `CONST.DICE_ROLL_MODES` deprecation proxies over `CONFIG.ChatMessage.modes`.
|
|
1323
|
+
* The old names warn until v16.
|
|
1324
|
+
*/
|
|
1325
|
+
function rule013(filePath, content) {
|
|
1326
|
+
const pattern = /\brollMode\s*:|['"]rollMode['"]|CONFIG\.Dice\.rollModes|DICE_ROLL_MODES/;
|
|
1327
|
+
if (!pattern.test(content)) return [];
|
|
1328
|
+
return [{
|
|
1329
|
+
ruleId: "VTTF-AUDIT-013",
|
|
1330
|
+
title: "rollMode is deprecated in favour of messageMode",
|
|
1331
|
+
severity: "MEDIUM",
|
|
1332
|
+
filePath,
|
|
1333
|
+
line: _internal.lineOf(content, pattern),
|
|
1334
|
+
message: "The `rollMode` option, the `core.rollMode` setting, `CONFIG.Dice.rollModes` and `CONST.DICE_ROLL_MODES` are deprecated since v14 and removed in v16.",
|
|
1335
|
+
remediation: "Pass `{ messageMode }` (a key of `CONFIG.ChatMessage.modes`: public, gm, blind, self, ic) to `Roll#toMessage` and `ChatMessage.create`; read the user default from `game.settings.get(\"core\", \"messageMode\")`; map an old value with `Roll._mapLegacyRollMode`."
|
|
1336
|
+
}];
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* VTTF-AUDIT-014 (MEDIUM): `CONFIG.statusEffects = [...]`.
|
|
1340
|
+
*
|
|
1341
|
+
* v14 keys the collection by id. Assigning a whole array still works, but
|
|
1342
|
+
* the setter empties the collection first, so every condition another
|
|
1343
|
+
* package added earlier in `init` is gone, with no warning.
|
|
1344
|
+
*/
|
|
1345
|
+
function rule014(filePath, content) {
|
|
1346
|
+
const pattern = /CONFIG\.statusEffects\s*=[^=]/;
|
|
1347
|
+
if (!pattern.test(content)) return [];
|
|
1348
|
+
return [{
|
|
1349
|
+
ruleId: "VTTF-AUDIT-014",
|
|
1350
|
+
title: "CONFIG.statusEffects is assigned wholesale",
|
|
1351
|
+
severity: "MEDIUM",
|
|
1352
|
+
filePath,
|
|
1353
|
+
line: _internal.lineOf(content, pattern),
|
|
1354
|
+
message: "Assigning an array to `CONFIG.statusEffects` empties the collection first, which drops the conditions other packages added before this code ran. v14 deprecates the assignment.",
|
|
1355
|
+
remediation: "Add and remove by id: `CONFIG.statusEffects[\"my-id\"] = { id: \"my-id\", name, img }` and `delete CONFIG.statusEffects.dead`. `registerSystem` and `registerModule` do this for the `statusEffects` option."
|
|
1356
|
+
}];
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* VTTF-AUDIT-015 (MEDIUM): `legacyTransferral`.
|
|
1360
|
+
*
|
|
1361
|
+
* v14 removed the flag. Effects on owned Items with `transfer: true` apply
|
|
1362
|
+
* to the Actor in place; nothing is copied. Setting the flag does nothing,
|
|
1363
|
+
* and code that reasons about copied effects reasons about the wrong model.
|
|
1364
|
+
*/
|
|
1365
|
+
function rule015(filePath, content) {
|
|
1366
|
+
const pattern = /\blegacyTransferral\b/;
|
|
1367
|
+
if (!pattern.test(content)) return [];
|
|
1368
|
+
return [{
|
|
1369
|
+
ruleId: "VTTF-AUDIT-015",
|
|
1370
|
+
title: "legacyTransferral no longer exists",
|
|
1371
|
+
severity: "MEDIUM",
|
|
1372
|
+
filePath,
|
|
1373
|
+
line: _internal.lineOf(content, pattern),
|
|
1374
|
+
message: "`CONFIG.ActiveEffect.legacyTransferral` was removed in v14. Item effects with `transfer: true` apply to the Actor in place through `allApplicableEffects()`; the flag is ignored.",
|
|
1375
|
+
remediation: "Delete the assignment. If the code relied on effects being copied onto the Actor, iterate `actor.allApplicableEffects()` instead of `actor.effects`."
|
|
1376
|
+
}];
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* VTTF-AUDIT-016 (MEDIUM): numeric Active Effect modes.
|
|
1380
|
+
*
|
|
1381
|
+
* v14 moved `changes` to `system.changes` and replaced the numeric `mode`
|
|
1382
|
+
* with a string `type` (`add`, `multiply`, `override`, `upgrade`,
|
|
1383
|
+
* `downgrade`, `subtract`, `custom`). The old shape loads through a
|
|
1384
|
+
* migration shim that warns until v16.
|
|
1385
|
+
*/
|
|
1386
|
+
function rule016(filePath, content) {
|
|
1387
|
+
const pattern = /\bACTIVE_EFFECT_MODES\b/;
|
|
1388
|
+
if (!pattern.test(content)) return [];
|
|
1389
|
+
return [{
|
|
1390
|
+
ruleId: "VTTF-AUDIT-016",
|
|
1391
|
+
title: "Active Effect changes use numeric modes",
|
|
1392
|
+
severity: "MEDIUM",
|
|
1393
|
+
filePath,
|
|
1394
|
+
line: _internal.lineOf(content, pattern),
|
|
1395
|
+
message: "`CONST.ACTIVE_EFFECT_MODES` and a numeric `mode` on a change are deprecated since v14 and removed in v16. Changes live in `system.changes` with a string `type`.",
|
|
1396
|
+
remediation: "Write `{ key, type: \"add\", value }` under `system.changes`; register extra types in `CONFIG.ActiveEffect.changeTypes`."
|
|
1397
|
+
}];
|
|
1398
|
+
}
|
|
1399
|
+
async function runV14Rules(cwd) {
|
|
1400
|
+
const results = [];
|
|
1401
|
+
for await (const file of _internal.walkSourceFiles(cwd)) {
|
|
1402
|
+
let content;
|
|
1403
|
+
try {
|
|
1404
|
+
content = await readFile(file, "utf8");
|
|
1405
|
+
} catch {
|
|
1406
|
+
continue;
|
|
1407
|
+
}
|
|
1408
|
+
results.push(...rule011(file, content), ...rule012(file, content), ...rule013(file, content), ...rule014(file, content), ...rule015(file, content), ...rule016(file, content));
|
|
1409
|
+
}
|
|
1410
|
+
return results;
|
|
1411
|
+
}
|
|
1412
|
+
//#endregion
|
|
1208
1413
|
//#region src/audit/index.ts
|
|
1209
1414
|
/**
|
|
1210
1415
|
* Audit orchestrator: runs every rule against a project root and
|
|
@@ -1216,6 +1421,8 @@ const SEVERITY_RANK = {
|
|
|
1216
1421
|
* + cross-check with manifest where needed)
|
|
1217
1422
|
* - template-rules.ts → VTTF-AUDIT-008 (the Handlebars, cross-checked
|
|
1218
1423
|
* against which base each sheet is built on)
|
|
1424
|
+
* - v14-rules.ts → VTTF-AUDIT-011 to 016 (v13 code that v14 broke
|
|
1425
|
+
* or deprecated)
|
|
1219
1426
|
*
|
|
1220
1427
|
* The orchestrator stays minimal. It knows which rule sets exist, but
|
|
1221
1428
|
* the rules themselves are responsible for their own file IO. This keeps
|
|
@@ -1232,15 +1439,17 @@ async function runAudit(options) {
|
|
|
1232
1439
|
if (!existsSync(cwd)) throw new AuditTargetError(`Audit target does not exist: ${cwd}`);
|
|
1233
1440
|
if (!statSync(cwd).isDirectory()) throw new AuditTargetError(`Audit target is not a directory: ${cwd}`);
|
|
1234
1441
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1235
|
-
const [manifestFindings, sourceFindings, templateFindings] = await Promise.all([
|
|
1442
|
+
const [manifestFindings, sourceFindings, templateFindings, v14Findings] = await Promise.all([
|
|
1236
1443
|
runManifestRules(cwd),
|
|
1237
1444
|
runSourceRules(cwd),
|
|
1238
|
-
runTemplateRules(cwd)
|
|
1445
|
+
runTemplateRules(cwd),
|
|
1446
|
+
runV14Rules(cwd)
|
|
1239
1447
|
]);
|
|
1240
1448
|
const findings = [
|
|
1241
1449
|
...manifestFindings,
|
|
1242
1450
|
...sourceFindings,
|
|
1243
|
-
...templateFindings
|
|
1451
|
+
...templateFindings,
|
|
1452
|
+
...v14Findings
|
|
1244
1453
|
].sort(compareFindings);
|
|
1245
1454
|
return {
|
|
1246
1455
|
cwd,
|
|
@@ -1292,7 +1501,7 @@ function formatMarkdown(report) {
|
|
|
1292
1501
|
lines.push(`- findings: ${findings.length} (${counts.HIGH} HIGH · ${counts.MEDIUM} MEDIUM · ${counts.LOW} LOW)`);
|
|
1293
1502
|
lines.push("");
|
|
1294
1503
|
if (findings.length === 0) {
|
|
1295
|
-
lines.push("No issues found. The system / module looks healthy against the
|
|
1504
|
+
lines.push("No issues found. The system / module looks healthy against the v14 catalog.");
|
|
1296
1505
|
lines.push("");
|
|
1297
1506
|
return lines.join("\n");
|
|
1298
1507
|
}
|
|
@@ -1340,11 +1549,10 @@ function relativizeIfBelow(filePath, cwd) {
|
|
|
1340
1549
|
//#region src/commands/audit.ts
|
|
1341
1550
|
/**
|
|
1342
1551
|
* `vttforge audit`: scan a system/module project against the VTTForge
|
|
1343
|
-
* audit catalog (
|
|
1552
|
+
* audit catalog (the v14 manifest, source and template breakages that fail quietly).
|
|
1344
1553
|
*
|
|
1345
|
-
* The
|
|
1346
|
-
*
|
|
1347
|
-
* CLI surface that orchestrates them and prints the report.
|
|
1554
|
+
* The rules live under `audit/` (manifest, source, template and v14 sets);
|
|
1555
|
+
* this file is the CLI surface that orchestrates them and prints the report.
|
|
1348
1556
|
*
|
|
1349
1557
|
* Exit codes:
|
|
1350
1558
|
* 0: clean run, or only MEDIUM/LOW findings (informational)
|
|
@@ -2657,7 +2865,7 @@ function templateVariantFor(type, lang) {
|
|
|
2657
2865
|
async function runInit(options = {}) {
|
|
2658
2866
|
const cwd = options.cwd ?? process.cwd();
|
|
2659
2867
|
const interactive = canPrompt(options.yes);
|
|
2660
|
-
p.intro("🜲 vttforge init: scaffold a Foundry
|
|
2868
|
+
p.intro("🜲 vttforge init: scaffold a Foundry v14+ system or module");
|
|
2661
2869
|
let name = options.name?.trim();
|
|
2662
2870
|
if (!name && !interactive) bail("A directory name is required when running without prompts. Pass it as the first argument: `vttforge init my-module --yes`.");
|
|
2663
2871
|
if (!name) {
|
|
@@ -2737,7 +2945,7 @@ async function runInit(options = {}) {
|
|
|
2737
2945
|
initialValue: titleCase(id),
|
|
2738
2946
|
validate: validateRequiredMetadata
|
|
2739
2947
|
}), validateRequiredMetadata);
|
|
2740
|
-
const defaultDescription = `A Foundry
|
|
2948
|
+
const defaultDescription = `A Foundry v14+ ${type} built with VTTForge`;
|
|
2741
2949
|
const description = await resolveField(options.description, defaultDescription, () => p.text({
|
|
2742
2950
|
message: "One-line description",
|
|
2743
2951
|
placeholder: defaultDescription,
|
|
@@ -2774,8 +2982,8 @@ async function runInit(options = {}) {
|
|
|
2774
2982
|
],
|
|
2775
2983
|
initialValue: "MIT"
|
|
2776
2984
|
}), validateRequiredMetadata);
|
|
2777
|
-
const foundryMinVersion = "
|
|
2778
|
-
const foundryVerifiedVersion = "
|
|
2985
|
+
const foundryMinVersion = "14";
|
|
2986
|
+
const foundryVerifiedVersion = "14";
|
|
2779
2987
|
const templateVariant = templateVariantFor(type, lang);
|
|
2780
2988
|
const templateDir = resolve(templatesRoot(), templateVariant);
|
|
2781
2989
|
if (!existsSync(templateDir)) bail(`Template "${templateVariant}" not found at ${templateDir}`);
|
|
@@ -2881,4 +3089,4 @@ const VTTFORGE_CLI_VERSION = version;
|
|
|
2881
3089
|
//#endregion
|
|
2882
3090
|
export { emitReleaseZip as a, readManifest as c, runAudit as d, SEVERITY_RANK as f, runDev as i, runAuditCommand as l, runManifestRules as m, ScaffoldError as n, runBuild as o, runSourceRules as p, runInit as r, emitZip as s, VTTFORGE_CLI_VERSION as t, formatReport as u };
|
|
2883
3091
|
|
|
2884
|
-
//# sourceMappingURL=src-
|
|
3092
|
+
//# sourceMappingURL=src-BAHJHuJ7.mjs.map
|