@vttforge/cli 0.18.8 → 0.18.10
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 +19 -0
- package/dist/bin.mjs +125 -36
- package/dist/bin.mjs.map +1 -1
- package/dist/index.d.mts +23 -28
- package/dist/index.mjs +1 -2
- package/dist/{src-CezN6cK3.mjs → src-kJwlrLLX.mjs} +122 -112
- package/dist/src-kJwlrLLX.mjs.map +1 -0
- package/package.json +5 -6
- package/templates/module-ts/package.json +1 -1
- package/templates/system-js/scripts/main.mjs +1 -1
- package/templates/system-js/templates/actor/character-sheet.hbs +1 -1
- package/templates/system-ts/package.json +1 -1
- package/templates/system-ts/scripts/main.ts +1 -1
- package/templates/system-ts/templates/actor/character-sheet.hbs +1 -1
- package/dist/src-CezN6cK3.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @vttforge/cli: public library exports.
|
|
3
|
+
*
|
|
4
|
+
* The product here is the `vttforge` binary. These exports exist so another
|
|
5
|
+
* tool can drive the same work without shelling out, and they fall into three
|
|
6
|
+
* groups, marked per export below.
|
|
7
|
+
*
|
|
8
|
+
* **Supported.** `runInit` and the audit surface. `create-vttforge` calls
|
|
9
|
+
* `runInit`, and the audit rules are a documented extension point: a project
|
|
10
|
+
* can write its own `RuleFn` and hand it to the same reporter the CLI uses.
|
|
11
|
+
* These follow the deprecation policy.
|
|
12
|
+
*
|
|
13
|
+
* **`@experimental`.** Plausibly useful to a tool author, but no consumer has
|
|
14
|
+
* ever asked for them, so the shape is a guess. They can change in a minor.
|
|
15
|
+
*
|
|
16
|
+
* **`@internal`.** Implementation detail of the binary that reached the index
|
|
17
|
+
* by accident. Nothing outside this package imports them. They are staying
|
|
18
|
+
* only until the next major, and importing one is not supported today.
|
|
19
|
+
*
|
|
20
|
+
* See apps/docs/stability.md for what each tag promises.
|
|
21
|
+
*/
|
|
22
|
+
/** Supported: run every audit rule over a project root. */
|
|
2
23
|
/**
|
|
3
24
|
* Shared types for the `vttforge audit` rule engine.
|
|
4
25
|
*
|
|
@@ -47,24 +68,14 @@ export declare const SEVERITY_RANK: Record<Severity, number>;
|
|
|
47
68
|
* together. Pure functions over the filesystem so tests inject tmp dirs.
|
|
48
69
|
*/
|
|
49
70
|
type RuleFn = (cwd: string) => Promise<RuleResult[]> | RuleResult[];
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/audit/index.d.ts
|
|
52
71
|
interface RunAuditOptions {
|
|
53
72
|
cwd: string;
|
|
54
73
|
}
|
|
55
74
|
export declare function runAudit(options: RunAuditOptions): Promise<AuditReport>;
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/audit/manifest-rules.d.ts
|
|
58
75
|
export declare function runManifestRules(cwd: string): Promise<RuleResult[]>;
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/audit/reporter.d.ts
|
|
61
76
|
type ReportFormat = 'json' | 'markdown';
|
|
62
77
|
export declare function formatReport(report: AuditReport, format: ReportFormat): string;
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/audit/source-rules.d.ts
|
|
65
78
|
export declare function runSourceRules(cwd: string): Promise<RuleResult[]>;
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/commands/audit.d.ts
|
|
68
79
|
interface AuditOptions {
|
|
69
80
|
/** Project root to scan. Defaults to `process.cwd()`. */
|
|
70
81
|
cwd?: string;
|
|
@@ -88,8 +99,6 @@ interface AuditResult {
|
|
|
88
99
|
* change in a minor.
|
|
89
100
|
*/
|
|
90
101
|
export declare function runAuditCommand(options?: AuditOptions): Promise<AuditResult>;
|
|
91
|
-
//#endregion
|
|
92
|
-
//#region src/manifest.d.ts
|
|
93
102
|
/**
|
|
94
103
|
* Read a built manifest (`dist/system.json` or `dist/module.json`).
|
|
95
104
|
*
|
|
@@ -123,8 +132,6 @@ interface FoundryManifest {
|
|
|
123
132
|
* It can change in a minor.
|
|
124
133
|
*/
|
|
125
134
|
export declare function readManifest(distDir: string): Promise<FoundryManifest>;
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/commands/build.d.ts
|
|
128
135
|
interface BuildOptions {
|
|
129
136
|
/** Override the project root. Defaults to `process.cwd()`. */
|
|
130
137
|
cwd?: string;
|
|
@@ -148,8 +155,6 @@ export declare function emitReleaseZip(opts: {
|
|
|
148
155
|
* change in a minor.
|
|
149
156
|
*/
|
|
150
157
|
export declare function runBuild(options?: BuildOptions): Promise<void>;
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/commands/dev.d.ts
|
|
153
158
|
interface DevOptions {
|
|
154
159
|
/** Override the project root. Defaults to `process.cwd()`. */
|
|
155
160
|
cwd?: string;
|
|
@@ -163,8 +168,6 @@ interface DevOptions {
|
|
|
163
168
|
* change in a minor.
|
|
164
169
|
*/
|
|
165
170
|
export declare function runDev(options?: DevOptions): Promise<void>;
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region src/commands/init.d.ts
|
|
168
171
|
/**
|
|
169
172
|
* `vttforge init`: interactive scaffolder.
|
|
170
173
|
*
|
|
@@ -222,8 +225,6 @@ export declare class ScaffoldError extends Error {
|
|
|
222
225
|
constructor(message: string);
|
|
223
226
|
}
|
|
224
227
|
export declare function runInit(options?: InitOptions): Promise<void>;
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region src/commands/lint.d.ts
|
|
227
228
|
/**
|
|
228
229
|
* `vttforge lint`: Biome over the project, then the v14 audit.
|
|
229
230
|
*
|
|
@@ -265,8 +266,6 @@ interface LintResult {
|
|
|
265
266
|
* change in a minor.
|
|
266
267
|
*/
|
|
267
268
|
export declare function runLintCommand(options?: LintOptions): Promise<LintResult>;
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/zip.d.ts
|
|
270
269
|
/**
|
|
271
270
|
* Emit a foundryvtt.com-compatible release zip.
|
|
272
271
|
*
|
|
@@ -298,9 +297,5 @@ interface EmitZipResult {
|
|
|
298
297
|
* change in a minor.
|
|
299
298
|
*/
|
|
300
299
|
export declare function emitZip(opts: EmitZipOptions): Promise<EmitZipResult>;
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/index.d.ts
|
|
303
300
|
export declare const VTTFORGE_CLI_VERSION: string;
|
|
304
|
-
|
|
305
|
-
export type { AuditOptions, AuditReport, AuditResult, BuildOptions, DevOptions, EmitZipOptions, EmitZipResult, FoundryManifest, InitOptions, LintOptions, LintResult, PackageType, ReportFormat, ResolvedInitOptions, RuleFn, RuleResult, RunAuditOptions, Severity, TemplateVariant };
|
|
306
|
-
//# sourceMappingURL=index.d.mts.map
|
|
301
|
+
export type { AuditOptions, AuditReport, AuditResult, BuildOptions, DevOptions, EmitZipOptions, EmitZipResult, FoundryManifest, InitOptions, LintOptions, LintResult, PackageType, ReportFormat, ResolvedInitOptions, RuleFn, RuleResult, RunAuditOptions, Severity, TemplateVariant };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { SEVERITY_RANK, ScaffoldError, VTTFORGE_CLI_VERSION, emitReleaseZip, emitZip, formatReport, readManifest, runAudit, runAuditCommand, runBuild, runDev, runInit, runLintCommand, runManifestRules, runSourceRules };
|
|
1
|
+
export { _ as SEVERITY_RANK, r as ScaffoldError, t as VTTFORGE_CLI_VERSION, o as emitReleaseZip, c as emitZip, d as formatReport, l as readManifest, f as runAudit, u as runAuditCommand, s as runBuild, a as runDev, i as runInit, n as runLintCommand, S as runManifestRules, y as runSourceRules } from "./src-kJwlrLLX.mjs";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
1
|
import { createWriteStream, existsSync, readFileSync, readdirSync, statSync, watch } from "node:fs";
|
|
3
2
|
import { basename, dirname, extname, join, posix, relative, resolve, sep } from "node:path";
|
|
4
3
|
import { lstat, mkdir, readFile, readdir, readlink, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
@@ -10,10 +9,10 @@ import { createHash } from "node:crypto";
|
|
|
10
9
|
import { createServer } from "node:http";
|
|
11
10
|
import { homedir } from "node:os";
|
|
12
11
|
import { promisify } from "node:util";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
import { createRequire } from "node:module";
|
|
13
|
+
// package.json
|
|
14
|
+
var version = "0.18.10";
|
|
15
|
+
// src/audit/manifest-rules.ts
|
|
17
16
|
/**
|
|
18
17
|
* Manifest-scope audit rules.
|
|
19
18
|
*
|
|
@@ -339,8 +338,7 @@ async function runManifestRules(cwd) {
|
|
|
339
338
|
}
|
|
340
339
|
return results;
|
|
341
340
|
}
|
|
342
|
-
|
|
343
|
-
//#region src/audit/release-rules.ts
|
|
341
|
+
// src/audit/release-rules.ts
|
|
344
342
|
/**
|
|
345
343
|
* VTTF-AUDIT-020 (HIGH): the release workflow ships the checkout, but the
|
|
346
344
|
* project builds to `dist/`.
|
|
@@ -547,8 +545,7 @@ function maskComments(source, { strings = false } = {}) {
|
|
|
547
545
|
function startsRegex(lastCode) {
|
|
548
546
|
return lastCode === "" || "(,=:[!&|?{};+-*%<>~^".includes(lastCode);
|
|
549
547
|
}
|
|
550
|
-
|
|
551
|
-
//#region src/audit/source-rules.ts
|
|
548
|
+
// src/audit/source-rules.ts
|
|
552
549
|
/**
|
|
553
550
|
* Source-tree audit rules.
|
|
554
551
|
*
|
|
@@ -647,7 +644,7 @@ function rule005(filePath, content) {
|
|
|
647
644
|
severity: "MEDIUM",
|
|
648
645
|
filePath,
|
|
649
646
|
line: cls.startLine,
|
|
650
|
-
message: `Class \`${cls.className}\` extends TypeDataModel directly but does not define prepareBaseData(). Active Effects apply between prepareBaseData and prepareDerivedData
|
|
647
|
+
message: `Class \`${cls.className}\` extends TypeDataModel directly but does not define prepareBaseData(). Active Effects apply in two phases. The \`initial\` phase runs between prepareBaseData and prepareDerivedData, and the \`final\` phase runs after prepareDerivedData. Without the hook, effects in the \`initial\` phase see uninitialised fields.`,
|
|
651
648
|
remediation: "Add a no-op `prepareBaseData()` method (or extend `BaseTypeDataModel()` from `@vttforge/core`, which provides the stub)."
|
|
652
649
|
});
|
|
653
650
|
}
|
|
@@ -697,8 +694,8 @@ function rule006(filePath, content) {
|
|
|
697
694
|
severity: "LOW",
|
|
698
695
|
filePath,
|
|
699
696
|
line: lineOf(content, /_addDataFieldMigrations\s*\(/),
|
|
700
|
-
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.",
|
|
701
|
-
remediation: "Replace the override with `static migrateData(source) { super._addDataFieldMigration(source, \"oldKey\", \"newKey\"); return super.migrateData(source); }`."
|
|
697
|
+
message: "The plural `_addDataFieldMigrations` is not a real Foundry API. The canonical migration hook is a static `migrateData(source, options)` override that calls singular `super._addDataFieldMigration(source, oldKey, newKey, apply?)` for each rename. Instance overrides named `_addDataFieldMigrations` never run.",
|
|
698
|
+
remediation: "Replace the override with `static migrateData(source, options) { super._addDataFieldMigration(source, \"oldKey\", \"newKey\"); return super.migrateData(source, options); }`. It must end with `return super.migrateData(source, options)`."
|
|
702
699
|
}];
|
|
703
700
|
}
|
|
704
701
|
function findClassRanges(content) {
|
|
@@ -946,14 +943,12 @@ function buildSchemaPath(content, idx, fieldName) {
|
|
|
946
943
|
if (!parentName) return fieldName;
|
|
947
944
|
return `${buildSchemaPath(content, lookbackStart + (m.index ?? 0), parentName)}.${fieldName}`;
|
|
948
945
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
function normalizeDeclaredPath(path) {
|
|
956
|
-
return path.startsWith("system.") ? path.slice(7) : path;
|
|
946
|
+
function emptyDeclaration() {
|
|
947
|
+
return {
|
|
948
|
+
html: /* @__PURE__ */ new Set(),
|
|
949
|
+
filePath: /* @__PURE__ */ new Set(),
|
|
950
|
+
prefixed: /* @__PURE__ */ new Map()
|
|
951
|
+
};
|
|
957
952
|
}
|
|
958
953
|
/**
|
|
959
954
|
* Find one subtype's declarations, accounting for the module prefix.
|
|
@@ -975,6 +970,19 @@ function lookupSubtype(declared, doc, subtype) {
|
|
|
975
970
|
if (!prefix || !subtype.startsWith(prefix)) return void 0;
|
|
976
971
|
return declared.perSubtype.get(`${doc}.${subtype.slice(prefix.length)}`);
|
|
977
972
|
}
|
|
973
|
+
/** An entry written as `system.<path>`: the server prefixes it again. */
|
|
974
|
+
function prefixedFinding(filePath, line, sourcePath, type, where) {
|
|
975
|
+
const effect = type === "HTMLField" ? `the HTML in \`${sourcePath}\` is stored unsanitized` : `the file path in \`${sourcePath}\` is stored unchecked`;
|
|
976
|
+
return {
|
|
977
|
+
ruleId: "VTTF-AUDIT-004",
|
|
978
|
+
title: `${type} declared with a \`system.\` prefix is not sanitized`,
|
|
979
|
+
severity: "HIGH",
|
|
980
|
+
filePath,
|
|
981
|
+
line,
|
|
982
|
+
message: `${where} lists \`system.${sourcePath}\`. The server adds \`system.\` itself and reads \`system.system.${sourcePath}\`, which matches nothing, so ${effect}.`,
|
|
983
|
+
remediation: `Change \`system.${sourcePath}\` to \`${sourcePath}\` in ${where}.`
|
|
984
|
+
};
|
|
985
|
+
}
|
|
978
986
|
/**
|
|
979
987
|
* VTTF-AUDIT-004: cross-check source HTMLField/FilePathField usages
|
|
980
988
|
* against the manifest's documentTypes declarations.
|
|
@@ -1000,19 +1008,25 @@ function rule004(filePath, content, declared, classToSubtypes) {
|
|
|
1000
1008
|
});
|
|
1001
1009
|
if (missing.length > 0) {
|
|
1002
1010
|
const locations = missing.map((mapping) => `${mapping.doc}.${mapping.subtype}`).join(", ");
|
|
1003
|
-
|
|
1011
|
+
const wrong = missing.flatMap((mapping) => lookupSubtype(declared, mapping.doc, mapping.subtype)?.prefixed.get(`${declaredBucketName}:${sourcePath}`) ?? []);
|
|
1012
|
+
out.push(wrong.length > 0 ? prefixedFinding(filePath, usage.line, sourcePath, usage.type, [...new Set(wrong)].join(" and ")) : {
|
|
1004
1013
|
ruleId: "VTTF-AUDIT-004",
|
|
1005
1014
|
title: `${usage.type} not declared in manifest documentTypes`,
|
|
1006
1015
|
severity: "MEDIUM",
|
|
1007
1016
|
filePath,
|
|
1008
1017
|
line: usage.line,
|
|
1009
1018
|
message: `\`${usage.enclosingClass}\` declares \`${sourcePath}\` as ${usage.type}, but documentTypes.${locations}.${declaredBucketName} does not list this path. The Foundry server only sanitises declared paths.`,
|
|
1010
|
-
remediation: `Add \`${sourcePath}\`
|
|
1019
|
+
remediation: `Add \`${sourcePath}\` to documentTypes.${missing[0]?.doc}.${missing[0]?.subtype}.${declaredBucketName} in your manifest. Write it relative to \`system\`.`
|
|
1011
1020
|
});
|
|
1012
1021
|
}
|
|
1013
1022
|
continue;
|
|
1014
1023
|
}
|
|
1015
1024
|
if ((usage.type === "HTMLField" ? declared.globalHtml : declared.globalFilePath).has(sourcePath)) continue;
|
|
1025
|
+
const wrong = declared.globalPrefixed.get(`${declaredBucketName}:${sourcePath}`);
|
|
1026
|
+
if (wrong) {
|
|
1027
|
+
out.push(prefixedFinding(filePath, usage.line, sourcePath, usage.type, wrong));
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1016
1030
|
out.push({
|
|
1017
1031
|
ruleId: "VTTF-AUDIT-004",
|
|
1018
1032
|
title: `${usage.type} not declared in manifest documentTypes`,
|
|
@@ -1020,7 +1034,7 @@ function rule004(filePath, content, declared, classToSubtypes) {
|
|
|
1020
1034
|
filePath,
|
|
1021
1035
|
line: usage.line,
|
|
1022
1036
|
message: `Schema declares \`${sourcePath}\` as ${usage.type}, but no documentTypes.<Doc>.<subtype>.${declaredBucketName} entry lists this path. The Foundry server only sanitises declared paths.`,
|
|
1023
|
-
remediation: `Add \`${sourcePath}\`
|
|
1037
|
+
remediation: `Add \`${sourcePath}\` to documentTypes.<Doc>.<subtype>.${declaredBucketName} in your manifest. Write it relative to \`system\`.`
|
|
1024
1038
|
});
|
|
1025
1039
|
}
|
|
1026
1040
|
return out;
|
|
@@ -1248,6 +1262,28 @@ async function collectDeclaredRichFields(cwd) {
|
|
|
1248
1262
|
const perSubtype = /* @__PURE__ */ new Map();
|
|
1249
1263
|
const globalHtml = /* @__PURE__ */ new Set();
|
|
1250
1264
|
const globalFilePath = /* @__PURE__ */ new Set();
|
|
1265
|
+
const globalPrefixed = /* @__PURE__ */ new Map();
|
|
1266
|
+
const declarePaths = (entry, source, where) => {
|
|
1267
|
+
const lists = [[
|
|
1268
|
+
"htmlFields",
|
|
1269
|
+
declaredPaths(source.htmlFields),
|
|
1270
|
+
entry.html,
|
|
1271
|
+
globalHtml
|
|
1272
|
+
], [
|
|
1273
|
+
"filePathFields",
|
|
1274
|
+
declaredPaths(source.filePathFields),
|
|
1275
|
+
entry.filePath,
|
|
1276
|
+
globalFilePath
|
|
1277
|
+
]];
|
|
1278
|
+
for (const [bucket, paths, own, all] of lists) for (const path of paths) if (path.startsWith("system.")) {
|
|
1279
|
+
const key = `${bucket}:${path.slice(7)}`;
|
|
1280
|
+
entry.prefixed.set(key, `${where}.${bucket}`);
|
|
1281
|
+
globalPrefixed.set(key, `${where}.${bucket}`);
|
|
1282
|
+
} else {
|
|
1283
|
+
own.add(path);
|
|
1284
|
+
all.add(path);
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1251
1287
|
let manifestPath = null;
|
|
1252
1288
|
let manifestRaw = null;
|
|
1253
1289
|
let manifestParsed = null;
|
|
@@ -1283,22 +1319,8 @@ async function collectDeclaredRichFields(cwd) {
|
|
|
1283
1319
|
if (!subtype || typeof subtype !== "object" || Array.isArray(subtype)) continue;
|
|
1284
1320
|
const sub = subtype;
|
|
1285
1321
|
const key = `${docName}.${subName}`;
|
|
1286
|
-
const entry = perSubtype.get(key) ??
|
|
1287
|
-
|
|
1288
|
-
filePath: /* @__PURE__ */ new Set()
|
|
1289
|
-
};
|
|
1290
|
-
if (Array.isArray(sub.htmlFields)) {
|
|
1291
|
-
for (const e of sub.htmlFields) if (typeof e === "string") {
|
|
1292
|
-
const normalized = normalizeDeclaredPath(e);
|
|
1293
|
-
entry.html.add(normalized);
|
|
1294
|
-
globalHtml.add(normalized);
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
for (const declaredPath of declaredFilePathKeys(sub.filePathFields)) {
|
|
1298
|
-
const normalized = normalizeDeclaredPath(declaredPath);
|
|
1299
|
-
entry.filePath.add(normalized);
|
|
1300
|
-
globalFilePath.add(normalized);
|
|
1301
|
-
}
|
|
1322
|
+
const entry = perSubtype.get(key) ?? emptyDeclaration();
|
|
1323
|
+
declarePaths(entry, sub, `documentTypes.${key}`);
|
|
1302
1324
|
perSubtype.set(key, entry);
|
|
1303
1325
|
}
|
|
1304
1326
|
}
|
|
@@ -1313,25 +1335,13 @@ async function collectDeclaredRichFields(cwd) {
|
|
|
1313
1335
|
}
|
|
1314
1336
|
if (template && typeof template === "object" && !Array.isArray(template)) for (const [docName, doc] of Object.entries(template)) {
|
|
1315
1337
|
if (!doc || typeof doc !== "object" || Array.isArray(doc)) continue;
|
|
1316
|
-
const { types
|
|
1338
|
+
const { types } = doc;
|
|
1317
1339
|
if (!Array.isArray(types)) continue;
|
|
1318
|
-
const html = Array.isArray(htmlFields) ? htmlFields.filter((e) => typeof e === "string").map(normalizeDeclaredPath) : [];
|
|
1319
|
-
const filePath = declaredFilePathKeys(filePathFields).map(normalizeDeclaredPath);
|
|
1320
1340
|
for (const type of types) {
|
|
1321
1341
|
if (typeof type !== "string") continue;
|
|
1322
1342
|
const key = `${docName}.${type}`;
|
|
1323
|
-
const entry = perSubtype.get(key) ??
|
|
1324
|
-
|
|
1325
|
-
filePath: /* @__PURE__ */ new Set()
|
|
1326
|
-
};
|
|
1327
|
-
for (const path of html) {
|
|
1328
|
-
entry.html.add(path);
|
|
1329
|
-
globalHtml.add(path);
|
|
1330
|
-
}
|
|
1331
|
-
for (const path of filePath) {
|
|
1332
|
-
entry.filePath.add(path);
|
|
1333
|
-
globalFilePath.add(path);
|
|
1334
|
-
}
|
|
1343
|
+
const entry = perSubtype.get(key) ?? emptyDeclaration();
|
|
1344
|
+
declarePaths(entry, doc, `template.json ${docName}`);
|
|
1335
1345
|
perSubtype.set(key, entry);
|
|
1336
1346
|
}
|
|
1337
1347
|
}
|
|
@@ -1341,7 +1351,8 @@ async function collectDeclaredRichFields(cwd) {
|
|
|
1341
1351
|
perSubtype,
|
|
1342
1352
|
packageId,
|
|
1343
1353
|
globalHtml,
|
|
1344
|
-
globalFilePath
|
|
1354
|
+
globalFilePath,
|
|
1355
|
+
globalPrefixed
|
|
1345
1356
|
},
|
|
1346
1357
|
manifestPath,
|
|
1347
1358
|
manifestRaw,
|
|
@@ -1349,15 +1360,12 @@ async function collectDeclaredRichFields(cwd) {
|
|
|
1349
1360
|
};
|
|
1350
1361
|
}
|
|
1351
1362
|
/**
|
|
1352
|
-
*
|
|
1353
|
-
*
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1356
|
-
* carry a bare array instead; that shape does not validate, but reading it
|
|
1357
|
-
* costs nothing and avoids reporting a field as undeclared when the author
|
|
1358
|
-
* plainly declared it.
|
|
1363
|
+
* The paths one list declares. `htmlFields` is an array. `filePathFields` is an
|
|
1364
|
+
* object keyed by path, whose values name the allowed file categories; some
|
|
1365
|
+
* hand-written manifests carry an array there, and reading it avoids reporting
|
|
1366
|
+
* a field its author declared.
|
|
1359
1367
|
*/
|
|
1360
|
-
function
|
|
1368
|
+
function declaredPaths(value) {
|
|
1361
1369
|
if (Array.isArray(value)) return value.filter((e) => typeof e === "string");
|
|
1362
1370
|
if (value && typeof value === "object") return Object.keys(value);
|
|
1363
1371
|
return [];
|
|
@@ -1449,8 +1457,7 @@ const _internal = {
|
|
|
1449
1457
|
findClassRanges,
|
|
1450
1458
|
EXCLUDED_DIRS
|
|
1451
1459
|
};
|
|
1452
|
-
|
|
1453
|
-
//#region src/audit/template-rules.ts
|
|
1460
|
+
// src/audit/template-rules.ts
|
|
1454
1461
|
/**
|
|
1455
1462
|
* Template-scope audit rules.
|
|
1456
1463
|
*
|
|
@@ -1593,16 +1600,14 @@ async function runTemplateRules(cwd) {
|
|
|
1593
1600
|
}
|
|
1594
1601
|
return [...results, ...removedHelpers];
|
|
1595
1602
|
}
|
|
1596
|
-
|
|
1597
|
-
//#region src/audit/types.ts
|
|
1603
|
+
// src/audit/types.ts
|
|
1598
1604
|
/** Severity rank for sorting (HIGH first). */
|
|
1599
1605
|
const SEVERITY_RANK = {
|
|
1600
1606
|
HIGH: 0,
|
|
1601
1607
|
MEDIUM: 1,
|
|
1602
1608
|
LOW: 2
|
|
1603
1609
|
};
|
|
1604
|
-
|
|
1605
|
-
//#region src/audit/legacy-globals.ts
|
|
1610
|
+
// src/audit/legacy-globals.ts
|
|
1606
1611
|
/**
|
|
1607
1612
|
* The bare globals v13 turned into aliases of a `foundry.*` path.
|
|
1608
1613
|
*
|
|
@@ -1740,8 +1745,7 @@ function definesName(source, name) {
|
|
|
1740
1745
|
function bareUsePattern(name) {
|
|
1741
1746
|
return new RegExp(`(?<![\\w$.])${name}\\b(?!\\s*:(?!:))(?=[\\s.(,;)\\]}]|$)`, "gm");
|
|
1742
1747
|
}
|
|
1743
|
-
|
|
1744
|
-
//#region src/audit/v14-rules.ts
|
|
1748
|
+
// src/audit/v14-rules.ts
|
|
1745
1749
|
/**
|
|
1746
1750
|
* Source rules for the v13 code that v14 broke or deprecated.
|
|
1747
1751
|
*
|
|
@@ -1754,6 +1758,7 @@ function bareUsePattern(name) {
|
|
|
1754
1758
|
* VTTF-AUDIT-017 (MEDIUM): the jQuery `renderChatMessage` hook, removed in v15
|
|
1755
1759
|
* VTTF-AUDIT-018 (LOW) : an Application v1 base class, removed in v16
|
|
1756
1760
|
* VTTF-AUDIT-019 (MEDIUM): a bare v13 global alias (`renderTemplate`, `ActorSheet`, ...), removed in v15
|
|
1761
|
+
* VTTF-AUDIT-023 (LOW) : a call on the legacy `Dialog` class (`new Dialog(`, `Dialog.confirm(`), removed in v16
|
|
1757
1762
|
*
|
|
1758
1763
|
* Regex heuristics like the rest of the source rules, for the same reason:
|
|
1759
1764
|
* the patterns are short and a TypeScript AST would not make them more
|
|
@@ -1891,7 +1896,7 @@ function rule014(filePath, content) {
|
|
|
1891
1896
|
severity: "MEDIUM",
|
|
1892
1897
|
filePath,
|
|
1893
1898
|
line: _internal.lineOf(content, pattern),
|
|
1894
|
-
message: "Assigning an array to `CONFIG.statusEffects`
|
|
1899
|
+
message: "Assigning an array to `CONFIG.statusEffects` replaces the whole palette, including the core conditions and the entries other packages added before this code ran. v14 deprecates the assignment.",
|
|
1895
1900
|
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."
|
|
1896
1901
|
}];
|
|
1897
1902
|
}
|
|
@@ -2009,6 +2014,30 @@ function rule019(filePath, content) {
|
|
|
2009
2014
|
remediation: `Use \`${path}\`. \`vttforge migrate\` renames every alias in this list.`
|
|
2010
2015
|
}];
|
|
2011
2016
|
}
|
|
2017
|
+
/**
|
|
2018
|
+
* VTTF-AUDIT-023 (LOW): a call on the legacy `Dialog` class.
|
|
2019
|
+
*
|
|
2020
|
+
* Rule 018 catches `class X extends Dialog`. This one catches the callers:
|
|
2021
|
+
* `new Dialog(...)` and the static `Dialog.confirm`, `Dialog.prompt` and
|
|
2022
|
+
* `Dialog.wait`. `DialogV2` is a different name, so `\\b` after the word is
|
|
2023
|
+
* enough to leave it alone. A file that defines or imports its own `Dialog`
|
|
2024
|
+
* is not talking about the Foundry class.
|
|
2025
|
+
*/
|
|
2026
|
+
function rule023(filePath, content) {
|
|
2027
|
+
const code = maskComments(content, { strings: true });
|
|
2028
|
+
if (definesName(code, "Dialog")) return [];
|
|
2029
|
+
const pattern = /(?<![\w$.])(?:new\s+(?:foundry\.appv1\.api\.)?Dialog\s*\(|(?:foundry\.appv1\.api\.)?Dialog\s*\.\s*(?:confirm|prompt|wait)\s*\()/;
|
|
2030
|
+
if (!pattern.test(code)) return [];
|
|
2031
|
+
return [{
|
|
2032
|
+
ruleId: "VTTF-AUDIT-023",
|
|
2033
|
+
title: "A call on the legacy Dialog class",
|
|
2034
|
+
severity: "LOW",
|
|
2035
|
+
filePath,
|
|
2036
|
+
line: _internal.lineOf(content, pattern),
|
|
2037
|
+
message: "This code opens a dialog with the Application v1 `Dialog` class, deprecated since v13 and removed in v16. It still works on v14.",
|
|
2038
|
+
remediation: "Use `foundry.applications.api.DialogV2`: `DialogV2.confirm({ window, content })`, `DialogV2.prompt({ ... })`, `DialogV2.wait({ ... })`, or `new DialogV2({ buttons })` for a custom one."
|
|
2039
|
+
}];
|
|
2040
|
+
}
|
|
2012
2041
|
async function runV14Rules(cwd) {
|
|
2013
2042
|
const results = [];
|
|
2014
2043
|
for await (const file of _internal.walkSourceFiles(cwd)) {
|
|
@@ -2019,12 +2048,11 @@ async function runV14Rules(cwd) {
|
|
|
2019
2048
|
continue;
|
|
2020
2049
|
}
|
|
2021
2050
|
content = maskComments(content);
|
|
2022
|
-
results.push(...rule011(file, content), ...rule012(file, content), ...rule013(file, content), ...rule014(file, content), ...rule015(file, content), ...rule016(file, content), ...rule017(file, content), ...rule018(file, content), ...rule019(file, content));
|
|
2051
|
+
results.push(...rule011(file, content), ...rule012(file, content), ...rule013(file, content), ...rule014(file, content), ...rule015(file, content), ...rule016(file, content), ...rule017(file, content), ...rule018(file, content), ...rule019(file, content), ...rule023(file, content));
|
|
2023
2052
|
}
|
|
2024
2053
|
return results;
|
|
2025
2054
|
}
|
|
2026
|
-
|
|
2027
|
-
//#region src/audit/index.ts
|
|
2055
|
+
// src/audit/index.ts
|
|
2028
2056
|
/**
|
|
2029
2057
|
* Audit orchestrator: runs every rule against a project root and
|
|
2030
2058
|
* aggregates the findings into an `AuditReport`.
|
|
@@ -2035,7 +2063,7 @@ async function runV14Rules(cwd) {
|
|
|
2035
2063
|
* + cross-check with manifest where needed)
|
|
2036
2064
|
* - template-rules.ts → VTTF-AUDIT-008 (the Handlebars, cross-checked
|
|
2037
2065
|
* against which base each sheet is built on)
|
|
2038
|
-
* - v14-rules.ts → VTTF-AUDIT-011 to 019 (v13 code that v14 broke
|
|
2066
|
+
* - v14-rules.ts → VTTF-AUDIT-011 to 019 and 023 (v13 code that v14 broke
|
|
2039
2067
|
* or deprecated)
|
|
2040
2068
|
* - release-rules.ts → VTTF-AUDIT-020 (a release workflow that ships the
|
|
2041
2069
|
* checkout of a project that builds to dist/)
|
|
@@ -2092,8 +2120,7 @@ function countBySeverity(findings) {
|
|
|
2092
2120
|
for (const f of findings) counts[f.severity] += 1;
|
|
2093
2121
|
return counts;
|
|
2094
2122
|
}
|
|
2095
|
-
|
|
2096
|
-
//#region src/audit/reporter.ts
|
|
2123
|
+
// src/audit/reporter.ts
|
|
2097
2124
|
/**
|
|
2098
2125
|
* Render an `AuditReport` as JSON (machine-readable, stable schema) or
|
|
2099
2126
|
* markdown (terminal-friendly, sectioned by severity).
|
|
@@ -2163,8 +2190,7 @@ function relativizeIfBelow(filePath, cwd) {
|
|
|
2163
2190
|
if (rel === "" || rel.startsWith("..") || rel.startsWith("/")) return filePath;
|
|
2164
2191
|
return rel;
|
|
2165
2192
|
}
|
|
2166
|
-
|
|
2167
|
-
//#region src/commands/audit.ts
|
|
2193
|
+
// src/commands/audit.ts
|
|
2168
2194
|
/**
|
|
2169
2195
|
* `vttforge audit`: scan a system/module project against the VTTForge
|
|
2170
2196
|
* audit catalog (the v14 manifest, source and template breakages that fail quietly).
|
|
@@ -2194,8 +2220,7 @@ async function runAuditCommand(options = {}) {
|
|
|
2194
2220
|
exitCode: report.counts.HIGH > 0 || strict && (report.counts.MEDIUM > 0 || report.counts.LOW > 0) ? 1 : 0
|
|
2195
2221
|
};
|
|
2196
2222
|
}
|
|
2197
|
-
|
|
2198
|
-
//#region src/manifest.ts
|
|
2223
|
+
// src/manifest.ts
|
|
2199
2224
|
/**
|
|
2200
2225
|
* Read a built manifest (`dist/system.json` or `dist/module.json`).
|
|
2201
2226
|
*
|
|
@@ -2253,8 +2278,7 @@ async function readManifest(distDir) {
|
|
|
2253
2278
|
}
|
|
2254
2279
|
throw new Error(`No Foundry manifest found in ${distDir}. Expected system.json or module.json. Did you run \`vite build\` first?`);
|
|
2255
2280
|
}
|
|
2256
|
-
|
|
2257
|
-
//#region src/package-manager.ts
|
|
2281
|
+
// src/package-manager.ts
|
|
2258
2282
|
/**
|
|
2259
2283
|
* Detect which package manager invoked the CLI so we can run the right
|
|
2260
2284
|
* `install` command after scaffolding.
|
|
@@ -2330,8 +2354,7 @@ function execInvocation(pm, bin) {
|
|
|
2330
2354
|
case "npm": return ["npx", ["--no-install", bin]];
|
|
2331
2355
|
}
|
|
2332
2356
|
}
|
|
2333
|
-
|
|
2334
|
-
//#region src/vite-runner.ts
|
|
2357
|
+
// src/vite-runner.ts
|
|
2335
2358
|
/**
|
|
2336
2359
|
* Spawn the user's project-local `vite` through their package manager.
|
|
2337
2360
|
*
|
|
@@ -2406,8 +2429,7 @@ function spawnViteWatch(cwd) {
|
|
|
2406
2429
|
shell: false
|
|
2407
2430
|
});
|
|
2408
2431
|
}
|
|
2409
|
-
|
|
2410
|
-
//#region src/zip.ts
|
|
2432
|
+
// src/zip.ts
|
|
2411
2433
|
/**
|
|
2412
2434
|
* Emit a foundryvtt.com-compatible release zip.
|
|
2413
2435
|
*
|
|
@@ -2453,8 +2475,7 @@ async function emitZip(opts) {
|
|
|
2453
2475
|
byteSize: (await stat(outFile)).size
|
|
2454
2476
|
};
|
|
2455
2477
|
}
|
|
2456
|
-
|
|
2457
|
-
//#region src/commands/build.ts
|
|
2478
|
+
// src/commands/build.ts
|
|
2458
2479
|
/**
|
|
2459
2480
|
* `vttforge build`: emit a foundryvtt.com-ready release zip.
|
|
2460
2481
|
*
|
|
@@ -2541,8 +2562,7 @@ async function runBuild(options = {}) {
|
|
|
2541
2562
|
p.note(`${zipFile}\n${formatBytes(byteSize)}`, "Release artifact");
|
|
2542
2563
|
p.outro(`Upload this zip to your release. The release workflow shipped with the template handles tag→GitHub Release → foundryvtt.com manifest update.`);
|
|
2543
2564
|
}
|
|
2544
|
-
|
|
2545
|
-
//#region src/symlink.ts
|
|
2565
|
+
// src/symlink.ts
|
|
2546
2566
|
/**
|
|
2547
2567
|
* Cross-platform symlink helpers for `vttforge dev`.
|
|
2548
2568
|
*
|
|
@@ -2634,8 +2654,7 @@ async function removeLink(path) {
|
|
|
2634
2654
|
}
|
|
2635
2655
|
await unlink(path);
|
|
2636
2656
|
}
|
|
2637
|
-
|
|
2638
|
-
//#region src/dev-module-install.ts
|
|
2657
|
+
// src/dev-module-install.ts
|
|
2639
2658
|
/**
|
|
2640
2659
|
* Put `@vttforge/dev-module` where Foundry will find it.
|
|
2641
2660
|
*
|
|
@@ -2679,8 +2698,7 @@ async function installDevModule(modulesDir, packageDir) {
|
|
|
2679
2698
|
function composeMountLine(packageDir) {
|
|
2680
2699
|
return `- ${packageDir}:/data/Data/modules/${DEV_MODULE_ID}:ro`;
|
|
2681
2700
|
}
|
|
2682
|
-
|
|
2683
|
-
//#region src/dev-server.ts
|
|
2701
|
+
// src/dev-server.ts
|
|
2684
2702
|
/**
|
|
2685
2703
|
* A one-way WebSocket server: `vttforge dev` pushes, the dev module listens.
|
|
2686
2704
|
*
|
|
@@ -2793,8 +2811,7 @@ async function startDevServer(options) {
|
|
|
2793
2811
|
port: typeof address === "object" && address ? address.port : options.port
|
|
2794
2812
|
};
|
|
2795
2813
|
}
|
|
2796
|
-
|
|
2797
|
-
//#region src/dev-watcher.ts
|
|
2814
|
+
// src/dev-watcher.ts
|
|
2798
2815
|
/**
|
|
2799
2816
|
* Watch the build output and turn each change into a reload payload.
|
|
2800
2817
|
*
|
|
@@ -2928,8 +2945,7 @@ function watchDist(options) {
|
|
|
2928
2945
|
watcher.close();
|
|
2929
2946
|
} };
|
|
2930
2947
|
}
|
|
2931
|
-
|
|
2932
|
-
//#region src/foundry-data-dir.ts
|
|
2948
|
+
// src/foundry-data-dir.ts
|
|
2933
2949
|
/**
|
|
2934
2950
|
* Foundry user-data directory discovery + persistence.
|
|
2935
2951
|
*
|
|
@@ -3256,8 +3272,7 @@ async function runDev(options = {}) {
|
|
|
3256
3272
|
async function cleanupDevSymlink(opts) {
|
|
3257
3273
|
if (await readLinkTarget(opts.target) === opts.expectedSource) await removeLink(opts.target);
|
|
3258
3274
|
}
|
|
3259
|
-
|
|
3260
|
-
//#region src/git.ts
|
|
3275
|
+
// src/git.ts
|
|
3261
3276
|
/**
|
|
3262
3277
|
* Git helpers for the init scaffolder. Optional: every step degrades to a
|
|
3263
3278
|
* warning, never throws. The scaffold completes even if git is missing or
|
|
@@ -3304,8 +3319,7 @@ async function initGitRepo(cwd) {
|
|
|
3304
3319
|
};
|
|
3305
3320
|
}
|
|
3306
3321
|
}
|
|
3307
|
-
|
|
3308
|
-
//#region src/scaffold.ts
|
|
3322
|
+
// src/scaffold.ts
|
|
3309
3323
|
/**
|
|
3310
3324
|
* Template copy with `{{var}}` placeholder substitution.
|
|
3311
3325
|
*
|
|
@@ -3416,8 +3430,7 @@ function templatesRoot() {
|
|
|
3416
3430
|
const here = fileURLToPath(import.meta.url);
|
|
3417
3431
|
return resolve(here, "..", "..", "templates");
|
|
3418
3432
|
}
|
|
3419
|
-
|
|
3420
|
-
//#region src/commands/init.ts
|
|
3433
|
+
// src/commands/init.ts
|
|
3421
3434
|
/**
|
|
3422
3435
|
* `vttforge init`: interactive scaffolder.
|
|
3423
3436
|
*
|
|
@@ -3685,8 +3698,7 @@ function runInstall(pm, cwd) {
|
|
|
3685
3698
|
});
|
|
3686
3699
|
});
|
|
3687
3700
|
}
|
|
3688
|
-
|
|
3689
|
-
//#region src/commands/lint.ts
|
|
3701
|
+
// src/commands/lint.ts
|
|
3690
3702
|
/**
|
|
3691
3703
|
* `vttforge lint`: Biome over the project, then the v14 audit.
|
|
3692
3704
|
*
|
|
@@ -3789,8 +3801,7 @@ async function runLintCommand(options = {}) {
|
|
|
3789
3801
|
configPath
|
|
3790
3802
|
};
|
|
3791
3803
|
}
|
|
3792
|
-
|
|
3793
|
-
//#region src/index.ts
|
|
3804
|
+
// src/index.ts
|
|
3794
3805
|
/**
|
|
3795
3806
|
* @vttforge/cli: public library exports.
|
|
3796
3807
|
*
|
|
@@ -3813,7 +3824,6 @@ async function runLintCommand(options = {}) {
|
|
|
3813
3824
|
* See apps/docs/stability.md for what each tag promises.
|
|
3814
3825
|
*/
|
|
3815
3826
|
const VTTFORGE_CLI_VERSION = version;
|
|
3816
|
-
//#endregion
|
|
3817
3827
|
export { runManifestRules as S, SEVERITY_RANK as _, runDev as a, maskComments as b, emitZip as c, formatReport as d, runAudit as f, definesName as g, bareUsePattern as h, runInit as i, readManifest as l, LEGACY_GLOBALS as m, runLintCommand as n, emitReleaseZip as o, REMOVED_UTILS as p, ScaffoldError as r, runBuild as s, VTTFORGE_CLI_VERSION as t, runAuditCommand as u, _internal as v, runReleaseRules as x, runSourceRules as y };
|
|
3818
3828
|
|
|
3819
|
-
//# sourceMappingURL=src-
|
|
3829
|
+
//# sourceMappingURL=src-kJwlrLLX.mjs.map
|