@vttforge/cli 0.13.0 → 0.15.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 +25 -0
- package/README.md +5 -5
- package/dist/bin.mjs +428 -103
- package/dist/bin.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-5a2deycw.mjs → src-D3qRQqRr.mjs} +98 -6
- package/dist/src-D3qRQqRr.mjs.map +1 -0
- package/package.json +2 -2
- package/templates/module-js/README.md +10 -10
- package/templates/module-js/package.json +1 -1
- package/templates/module-ts/README.md +12 -13
- package/templates/module-ts/package.json +1 -1
- package/templates/system-js/README.md +12 -12
- package/templates/system-js/package.json +1 -1
- package/templates/system-ts/README.md +11 -12
- package/templates/system-ts/package.json +1 -1
- package/dist/src-5a2deycw.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { S as runManifestRules, a as runDev, b as runSourceRules, c as emitZip, d as formatReport, f as runAudit, i as runInit, l as readManifest, n as runLintCommand, o as emitReleaseZip, r as ScaffoldError, s as runBuild, t as VTTFORGE_CLI_VERSION, u as runAuditCommand, v as SEVERITY_RANK } from "./src-
|
|
1
|
+
import { S as runManifestRules, a as runDev, b as runSourceRules, c as emitZip, d as formatReport, f as runAudit, i as runInit, l as readManifest, n as runLintCommand, o as emitReleaseZip, r as ScaffoldError, s as runBuild, t as VTTFORGE_CLI_VERSION, u as runAuditCommand, v as SEVERITY_RANK } from "./src-D3qRQqRr.mjs";
|
|
2
2
|
export { SEVERITY_RANK, ScaffoldError, VTTFORGE_CLI_VERSION, emitReleaseZip, emitZip, formatReport, readManifest, runAudit, runAuditCommand, runBuild, runDev, runInit, runLintCommand, runManifestRules, runSourceRules };
|
|
@@ -11,7 +11,7 @@ import { createServer } from "node:http";
|
|
|
11
11
|
import { homedir } from "node:os";
|
|
12
12
|
import { promisify } from "node:util";
|
|
13
13
|
//#region package.json
|
|
14
|
-
var version = "0.
|
|
14
|
+
var version = "0.15.1";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/audit/manifest-rules.ts
|
|
17
17
|
/**
|
|
@@ -508,6 +508,14 @@ function isSourceFile(name) {
|
|
|
508
508
|
if (/\.min\.[cm]?js$/.test(name)) return false;
|
|
509
509
|
return SOURCE_EXTENSIONS.some((ext) => name.endsWith(ext));
|
|
510
510
|
}
|
|
511
|
+
/** Every `.hbs` / `.html` in the project, outside the build and dependency folders. */
|
|
512
|
+
async function* walkTemplateFiles(cwd) {
|
|
513
|
+
const entries = await readdir(cwd, { withFileTypes: true });
|
|
514
|
+
for (const entry of entries) if (entry.isDirectory()) {
|
|
515
|
+
if (EXCLUDED_DIRS.has(entry.name)) continue;
|
|
516
|
+
yield* walkTemplateFiles(join(cwd, entry.name));
|
|
517
|
+
} else if (entry.isFile() && /\.(?:hbs|html)$/.test(entry.name)) yield join(cwd, entry.name);
|
|
518
|
+
}
|
|
511
519
|
async function* walkSourceFiles(cwd) {
|
|
512
520
|
const entries = await readdir(cwd, { withFileTypes: true });
|
|
513
521
|
for (const entry of entries) {
|
|
@@ -1018,7 +1026,7 @@ async function sourceHasValueMaxSchemaAtPath(sourceFiles, targetPath, actorClass
|
|
|
1018
1026
|
if (decl.path !== targetPath) continue;
|
|
1019
1027
|
if (actorClasses.size > 0) {
|
|
1020
1028
|
const owner = classes.find((c) => decl.index > c.openIdx && decl.index < c.endIdx);
|
|
1021
|
-
if (
|
|
1029
|
+
if (owner && !actorClasses.has(owner.className)) continue;
|
|
1022
1030
|
}
|
|
1023
1031
|
const topKeys = extractTopLevelKeys(decl.body);
|
|
1024
1032
|
if (topKeys.has("value") && topKeys.has("max")) return true;
|
|
@@ -1185,6 +1193,39 @@ async function collectDeclaredRichFields(cwd) {
|
|
|
1185
1193
|
}
|
|
1186
1194
|
}
|
|
1187
1195
|
}
|
|
1196
|
+
const templatePath = join(cwd, "template.json");
|
|
1197
|
+
if (existsSync(templatePath)) {
|
|
1198
|
+
let template;
|
|
1199
|
+
try {
|
|
1200
|
+
template = JSON.parse(await readFile(templatePath, "utf8"));
|
|
1201
|
+
} catch {
|
|
1202
|
+
template = null;
|
|
1203
|
+
}
|
|
1204
|
+
if (template && typeof template === "object" && !Array.isArray(template)) for (const [docName, doc] of Object.entries(template)) {
|
|
1205
|
+
if (!doc || typeof doc !== "object" || Array.isArray(doc)) continue;
|
|
1206
|
+
const { types, htmlFields, filePathFields } = doc;
|
|
1207
|
+
if (!Array.isArray(types)) continue;
|
|
1208
|
+
const html = Array.isArray(htmlFields) ? htmlFields.filter((e) => typeof e === "string").map(normalizeDeclaredPath) : [];
|
|
1209
|
+
const filePath = declaredFilePathKeys(filePathFields).map(normalizeDeclaredPath);
|
|
1210
|
+
for (const type of types) {
|
|
1211
|
+
if (typeof type !== "string") continue;
|
|
1212
|
+
const key = `${docName}.${type}`;
|
|
1213
|
+
const entry = perSubtype.get(key) ?? {
|
|
1214
|
+
html: /* @__PURE__ */ new Set(),
|
|
1215
|
+
filePath: /* @__PURE__ */ new Set()
|
|
1216
|
+
};
|
|
1217
|
+
for (const path of html) {
|
|
1218
|
+
entry.html.add(path);
|
|
1219
|
+
globalHtml.add(path);
|
|
1220
|
+
}
|
|
1221
|
+
for (const path of filePath) {
|
|
1222
|
+
entry.filePath.add(path);
|
|
1223
|
+
globalFilePath.add(path);
|
|
1224
|
+
}
|
|
1225
|
+
perSubtype.set(key, entry);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1188
1229
|
return {
|
|
1189
1230
|
declared: {
|
|
1190
1231
|
perSubtype,
|
|
@@ -1255,6 +1296,7 @@ async function runSourceRules(cwd) {
|
|
|
1255
1296
|
}
|
|
1256
1297
|
const _internal = {
|
|
1257
1298
|
walkSourceFiles,
|
|
1299
|
+
walkTemplateFiles,
|
|
1258
1300
|
isSourceFile,
|
|
1259
1301
|
lineOf,
|
|
1260
1302
|
lastSegment,
|
|
@@ -1285,6 +1327,10 @@ const TEMPLATE_RE = /template:\s*[`'"]([^`'"]*\.hbs)[`'"]/g;
|
|
|
1285
1327
|
/** A `<form>` start tag, ignoring what a Handlebars comment says about one. */
|
|
1286
1328
|
const FORM_TAG_RE = /<form[\s>]/i;
|
|
1287
1329
|
const HANDLEBARS_COMMENT_RE = /\{\{!--[\s\S]*?--\}\}|\{\{![^}]*\}\}/g;
|
|
1330
|
+
/** Blank out Handlebars comments, keeping their newlines so line numbers still point at the source. */
|
|
1331
|
+
function withoutComments(source) {
|
|
1332
|
+
return source.replace(HANDLEBARS_COMMENT_RE, (m) => m.replace(/[^\n]/g, ""));
|
|
1333
|
+
}
|
|
1288
1334
|
/**
|
|
1289
1335
|
* The templates a form-tagged sheet declares, as paths inside the project.
|
|
1290
1336
|
*
|
|
@@ -1320,7 +1366,53 @@ function templatesOfFormSheets(source) {
|
|
|
1320
1366
|
* HIGH because of how it fails. There is no error and no warning. The sheet
|
|
1321
1367
|
* looks right, accepts what you type, and drops it when the window closes.
|
|
1322
1368
|
*/
|
|
1369
|
+
/**
|
|
1370
|
+
* VTTF-AUDIT-021 (HIGH) — a Handlebars helper v14 removed.
|
|
1371
|
+
*
|
|
1372
|
+
* `{{#select}}` and `{{colorPicker}}` are gone. A template that still calls
|
|
1373
|
+
* one fails to render with "Missing helper", and the sheet, dialog or settings
|
|
1374
|
+
* form it belongs to never opens. Every `.hbs` / `.html` in the project is
|
|
1375
|
+
* read, since the failing template can belong to anything.
|
|
1376
|
+
*/
|
|
1377
|
+
const REMOVED_HELPERS = [{
|
|
1378
|
+
pattern: /\{\{#?select\b/,
|
|
1379
|
+
name: "{{#select}}",
|
|
1380
|
+
fix: "Replace the block with `{{selectOptions choices selected=value}}` (add `localize=true` when the labels are keys), or write the `<option>` list with `{{#each}}` and a `selected` attribute you compute yourself."
|
|
1381
|
+
}, {
|
|
1382
|
+
pattern: /\{\{colorPicker\b/,
|
|
1383
|
+
name: "{{colorPicker}}",
|
|
1384
|
+
fix: "Replace it with the `<color-picker>` element, `<color-picker name=\"...\" value=\"{{value}}\"></color-picker>`."
|
|
1385
|
+
}];
|
|
1386
|
+
async function runRemovedHelperRule(cwd) {
|
|
1387
|
+
const results = [];
|
|
1388
|
+
const files = [];
|
|
1389
|
+
for await (const file of _internal.walkTemplateFiles(cwd)) files.push(file);
|
|
1390
|
+
for (const path of files.sort()) {
|
|
1391
|
+
let source;
|
|
1392
|
+
try {
|
|
1393
|
+
source = await readFile(path, "utf8");
|
|
1394
|
+
} catch {
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
const markup = withoutComments(source);
|
|
1398
|
+
for (const helper of REMOVED_HELPERS) {
|
|
1399
|
+
if (!helper.pattern.test(markup)) continue;
|
|
1400
|
+
const line = markup.split("\n").findIndex((text) => helper.pattern.test(text)) + 1;
|
|
1401
|
+
results.push({
|
|
1402
|
+
ruleId: "VTTF-AUDIT-021",
|
|
1403
|
+
title: "Template calls a Handlebars helper v14 removed",
|
|
1404
|
+
severity: "HIGH",
|
|
1405
|
+
filePath: relative(cwd, path),
|
|
1406
|
+
line: line > 0 ? line : 1,
|
|
1407
|
+
message: `${helper.name} was removed in v14. Rendering this template throws "Missing helper", so whatever renders it never opens.`,
|
|
1408
|
+
remediation: helper.fix
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
return results;
|
|
1413
|
+
}
|
|
1323
1414
|
async function runTemplateRules(cwd) {
|
|
1415
|
+
const removedHelpers = await runRemovedHelperRule(cwd);
|
|
1324
1416
|
const templates = /* @__PURE__ */ new Set();
|
|
1325
1417
|
for await (const file of _internal.walkSourceFiles(cwd)) {
|
|
1326
1418
|
let content;
|
|
@@ -1340,7 +1432,7 @@ async function runTemplateRules(cwd) {
|
|
|
1340
1432
|
} catch {
|
|
1341
1433
|
continue;
|
|
1342
1434
|
}
|
|
1343
|
-
const markup = source
|
|
1435
|
+
const markup = withoutComments(source);
|
|
1344
1436
|
if (!FORM_TAG_RE.test(markup)) continue;
|
|
1345
1437
|
const line = markup.split("\n").findIndex((text) => FORM_TAG_RE.test(text)) + 1;
|
|
1346
1438
|
results.push({
|
|
@@ -1350,10 +1442,10 @@ async function runTemplateRules(cwd) {
|
|
|
1350
1442
|
filePath: relative(cwd, path) || template,
|
|
1351
1443
|
line: line > 0 ? line : 1,
|
|
1352
1444
|
message: "This template is rendered by a sheet built on BaseActorSheet or BaseItemSheet, which set `tag: \"form\"`, so the application element already is a form. A nested form owns the fields inside it, so the submit reads the outer element and finds nothing. Every edit is dropped when the window closes, with no error.",
|
|
1353
|
-
remediation: "Replace the `<form>` wrapper with a `<div
|
|
1445
|
+
remediation: "Replace the `<form>` wrapper with a `<div>`. Keep one root element: a part that renders several top-level elements fails to render. The fields belong to the application element, and `submitOnChange` saves them as they change."
|
|
1354
1446
|
});
|
|
1355
1447
|
}
|
|
1356
|
-
return results;
|
|
1448
|
+
return [...results, ...removedHelpers];
|
|
1357
1449
|
}
|
|
1358
1450
|
//#endregion
|
|
1359
1451
|
//#region src/audit/types.ts
|
|
@@ -3620,4 +3712,4 @@ const VTTFORGE_CLI_VERSION = version;
|
|
|
3620
3712
|
//#endregion
|
|
3621
3713
|
export { runManifestRules as S, definesName as _, runDev as a, runSourceRules as b, emitZip as c, formatReport as d, runAudit as f, bareUsePattern as g, LEGACY_GLOBALS as h, runInit as i, readManifest as l, maskComments 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, SEVERITY_RANK as v, runReleaseRules as x, _internal as y };
|
|
3622
3714
|
|
|
3623
|
-
//# sourceMappingURL=src-
|
|
3715
|
+
//# sourceMappingURL=src-D3qRQqRr.mjs.map
|