@vttforge/cli 0.13.0 → 0.15.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 +19 -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-BK9BmFiZ.mjs} +65 -6
- package/dist/src-BK9BmFiZ.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-BK9BmFiZ.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.0";
|
|
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;
|
|
@@ -1255,6 +1263,7 @@ async function runSourceRules(cwd) {
|
|
|
1255
1263
|
}
|
|
1256
1264
|
const _internal = {
|
|
1257
1265
|
walkSourceFiles,
|
|
1266
|
+
walkTemplateFiles,
|
|
1258
1267
|
isSourceFile,
|
|
1259
1268
|
lineOf,
|
|
1260
1269
|
lastSegment,
|
|
@@ -1285,6 +1294,10 @@ const TEMPLATE_RE = /template:\s*[`'"]([^`'"]*\.hbs)[`'"]/g;
|
|
|
1285
1294
|
/** A `<form>` start tag, ignoring what a Handlebars comment says about one. */
|
|
1286
1295
|
const FORM_TAG_RE = /<form[\s>]/i;
|
|
1287
1296
|
const HANDLEBARS_COMMENT_RE = /\{\{!--[\s\S]*?--\}\}|\{\{![^}]*\}\}/g;
|
|
1297
|
+
/** Blank out Handlebars comments, keeping their newlines so line numbers still point at the source. */
|
|
1298
|
+
function withoutComments(source) {
|
|
1299
|
+
return source.replace(HANDLEBARS_COMMENT_RE, (m) => m.replace(/[^\n]/g, ""));
|
|
1300
|
+
}
|
|
1288
1301
|
/**
|
|
1289
1302
|
* The templates a form-tagged sheet declares, as paths inside the project.
|
|
1290
1303
|
*
|
|
@@ -1320,7 +1333,53 @@ function templatesOfFormSheets(source) {
|
|
|
1320
1333
|
* HIGH because of how it fails. There is no error and no warning. The sheet
|
|
1321
1334
|
* looks right, accepts what you type, and drops it when the window closes.
|
|
1322
1335
|
*/
|
|
1336
|
+
/**
|
|
1337
|
+
* VTTF-AUDIT-021 (HIGH) — a Handlebars helper v14 removed.
|
|
1338
|
+
*
|
|
1339
|
+
* `{{#select}}` and `{{colorPicker}}` are gone. A template that still calls
|
|
1340
|
+
* one fails to render with "Missing helper", and the sheet, dialog or settings
|
|
1341
|
+
* form it belongs to never opens. Every `.hbs` / `.html` in the project is
|
|
1342
|
+
* read, since the failing template can belong to anything.
|
|
1343
|
+
*/
|
|
1344
|
+
const REMOVED_HELPERS = [{
|
|
1345
|
+
pattern: /\{\{#?select\b/,
|
|
1346
|
+
name: "{{#select}}",
|
|
1347
|
+
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."
|
|
1348
|
+
}, {
|
|
1349
|
+
pattern: /\{\{colorPicker\b/,
|
|
1350
|
+
name: "{{colorPicker}}",
|
|
1351
|
+
fix: "Replace it with the `<color-picker>` element, `<color-picker name=\"...\" value=\"{{value}}\"></color-picker>`."
|
|
1352
|
+
}];
|
|
1353
|
+
async function runRemovedHelperRule(cwd) {
|
|
1354
|
+
const results = [];
|
|
1355
|
+
const files = [];
|
|
1356
|
+
for await (const file of _internal.walkTemplateFiles(cwd)) files.push(file);
|
|
1357
|
+
for (const path of files.sort()) {
|
|
1358
|
+
let source;
|
|
1359
|
+
try {
|
|
1360
|
+
source = await readFile(path, "utf8");
|
|
1361
|
+
} catch {
|
|
1362
|
+
continue;
|
|
1363
|
+
}
|
|
1364
|
+
const markup = withoutComments(source);
|
|
1365
|
+
for (const helper of REMOVED_HELPERS) {
|
|
1366
|
+
if (!helper.pattern.test(markup)) continue;
|
|
1367
|
+
const line = markup.split("\n").findIndex((text) => helper.pattern.test(text)) + 1;
|
|
1368
|
+
results.push({
|
|
1369
|
+
ruleId: "VTTF-AUDIT-021",
|
|
1370
|
+
title: "Template calls a Handlebars helper v14 removed",
|
|
1371
|
+
severity: "HIGH",
|
|
1372
|
+
filePath: relative(cwd, path),
|
|
1373
|
+
line: line > 0 ? line : 1,
|
|
1374
|
+
message: `${helper.name} was removed in v14. Rendering this template throws "Missing helper", so whatever renders it never opens.`,
|
|
1375
|
+
remediation: helper.fix
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
return results;
|
|
1380
|
+
}
|
|
1323
1381
|
async function runTemplateRules(cwd) {
|
|
1382
|
+
const removedHelpers = await runRemovedHelperRule(cwd);
|
|
1324
1383
|
const templates = /* @__PURE__ */ new Set();
|
|
1325
1384
|
for await (const file of _internal.walkSourceFiles(cwd)) {
|
|
1326
1385
|
let content;
|
|
@@ -1340,7 +1399,7 @@ async function runTemplateRules(cwd) {
|
|
|
1340
1399
|
} catch {
|
|
1341
1400
|
continue;
|
|
1342
1401
|
}
|
|
1343
|
-
const markup = source
|
|
1402
|
+
const markup = withoutComments(source);
|
|
1344
1403
|
if (!FORM_TAG_RE.test(markup)) continue;
|
|
1345
1404
|
const line = markup.split("\n").findIndex((text) => FORM_TAG_RE.test(text)) + 1;
|
|
1346
1405
|
results.push({
|
|
@@ -1350,10 +1409,10 @@ async function runTemplateRules(cwd) {
|
|
|
1350
1409
|
filePath: relative(cwd, path) || template,
|
|
1351
1410
|
line: line > 0 ? line : 1,
|
|
1352
1411
|
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
|
|
1412
|
+
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
1413
|
});
|
|
1355
1414
|
}
|
|
1356
|
-
return results;
|
|
1415
|
+
return [...results, ...removedHelpers];
|
|
1357
1416
|
}
|
|
1358
1417
|
//#endregion
|
|
1359
1418
|
//#region src/audit/types.ts
|
|
@@ -3620,4 +3679,4 @@ const VTTFORGE_CLI_VERSION = version;
|
|
|
3620
3679
|
//#endregion
|
|
3621
3680
|
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
3681
|
|
|
3623
|
-
//# sourceMappingURL=src-
|
|
3682
|
+
//# sourceMappingURL=src-BK9BmFiZ.mjs.map
|