@vttforge/cli 0.15.3 → 0.16.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 +41 -0
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-vwmR9t7H.mjs → src-DK2hXzBk.mjs} +115 -64
- package/dist/src-DK2hXzBk.mjs.map +1 -0
- package/package.json +1 -1
- package/templates/module-js/package.json +2 -2
- package/templates/module-js/scripts/main.mjs +2 -2
- package/templates/module-ts/package.json +2 -2
- package/templates/module-ts/scripts/main.ts +2 -2
- package/templates/system-js/package.json +2 -2
- package/templates/system-js/scripts/main.mjs +2 -2
- package/templates/system-ts/package.json +2 -2
- package/templates/system-ts/scripts/main.ts +2 -2
- package/dist/src-vwmR9t7H.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @vttforge/cli
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3c56de9: `vttforge audit` gains VTTF-AUDIT-022: source that talks on the package socket
|
|
8
|
+
channel while the manifest has no `"socket": true`.
|
|
9
|
+
|
|
10
|
+
Foundry opens the `module.<id>` / `system.<id>` channel only for a package that
|
|
11
|
+
declares the flag. Without it `emit` returns without throwing, the message
|
|
12
|
+
never leaves the client, and nothing is logged. The listener on the other
|
|
13
|
+
machine is bound and correct and never fires, so the search goes to the
|
|
14
|
+
handler, the payload and the user permissions, and the manifest is the last
|
|
15
|
+
place anyone looks.
|
|
16
|
+
|
|
17
|
+
The rule wants the package channel. Core events ride the same socket under
|
|
18
|
+
their own names and need no flag, so `game.socket.on('userActivity', ...)` on
|
|
19
|
+
its own is not a finding. A file that names `module.<id>` or `system.<id>`, or
|
|
20
|
+
that calls `registerSocket`, is. Calls quoted in comments are skipped.
|
|
21
|
+
|
|
22
|
+
The project templates pin `@vttforge/cli` by minor, so they move to the
|
|
23
|
+
release that carries the rule.
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 14b29cc: Point the project templates at the `@vttforge/core` minor that carries
|
|
28
|
+
`inject()`. On a 0.x line a caret pins the minor, so the old pin would have
|
|
29
|
+
scaffolded a project that cannot see it.
|
|
30
|
+
- 86b64fa: Point the project templates at the `@vttforge/core` minor that carries the
|
|
31
|
+
`api` option and the module-api helpers. On a 0.x line a caret pins the minor,
|
|
32
|
+
so the old pin would have scaffolded a project that cannot see them.
|
|
33
|
+
- ac59e0a: Point the project templates at the `@vttforge/core` minor that renames
|
|
34
|
+
`SystemConfig` to `PackageConfig`, and switch the scaffolded code to the new
|
|
35
|
+
name. On a 0.x line a caret pins the minor, so the old pin would have
|
|
36
|
+
scaffolded a project that cannot resolve it.
|
|
37
|
+
- a5623a0: Point the project templates at the `@vttforge/core` minor that carries
|
|
38
|
+
`registerSocket()`. On a 0.x line a caret pins the minor, so the old pin would
|
|
39
|
+
have scaffolded a project that cannot see the new API.
|
|
40
|
+
- 7e77931: Point the project templates at the `@vttforge/core` minor that carries
|
|
41
|
+
`convertSubTypes()`. On a 0.x line a caret pins the minor, so the old pin would
|
|
42
|
+
have scaffolded a project that cannot see it.
|
|
43
|
+
|
|
3
44
|
## 0.15.3
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/dist/bin.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { a as runDev, b as maskComments, g as definesName, h as bareUsePattern, i as runInit, m as LEGACY_GLOBALS, n as runLintCommand, p as REMOVED_UTILS, r as ScaffoldError, s as runBuild, t as VTTFORGE_CLI_VERSION, u as runAuditCommand, v as _internal, x as runReleaseRules } from "./src-DK2hXzBk.mjs";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { dirname, join, relative, resolve } from "node:path";
|
|
5
5
|
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
package/dist/index.d.mts
CHANGED
|
@@ -62,7 +62,6 @@ type ReportFormat = 'json' | 'markdown';
|
|
|
62
62
|
export declare function formatReport(report: AuditReport, format: ReportFormat): string;
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region src/audit/source-rules.d.ts
|
|
65
|
-
/** Entry point: gather everything once, then dispatch to the per-file rules. */
|
|
66
65
|
export declare function runSourceRules(cwd: string): Promise<RuleResult[]>;
|
|
67
66
|
//#endregion
|
|
68
67
|
//#region src/commands/audit.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { S as runManifestRules,
|
|
1
|
+
import { S as runManifestRules, _ as SEVERITY_RANK, a as runDev, 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, y as runSourceRules } from "./src-DK2hXzBk.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.16.0";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/audit/manifest-rules.ts
|
|
17
17
|
/**
|
|
@@ -462,6 +462,66 @@ async function runReleaseRules(cwd) {
|
|
|
462
462
|
}
|
|
463
463
|
return findings;
|
|
464
464
|
}
|
|
465
|
+
function maskComments(source, { strings = false } = {}) {
|
|
466
|
+
const out = source.split("");
|
|
467
|
+
let quote = null;
|
|
468
|
+
let lastCode = "";
|
|
469
|
+
for (let i = 0; i < source.length; i += 1) {
|
|
470
|
+
const ch = source[i] ?? "";
|
|
471
|
+
const next = source[i + 1] ?? "";
|
|
472
|
+
if (quote !== null) {
|
|
473
|
+
if (ch === "\\") {
|
|
474
|
+
if (strings) {
|
|
475
|
+
out[i] = "\0";
|
|
476
|
+
if (source[i + 1] !== "\n") out[i + 1] = "\0";
|
|
477
|
+
}
|
|
478
|
+
i += 1;
|
|
479
|
+
} else if (ch === quote) quote = null;
|
|
480
|
+
else if (strings && ch !== "\n") out[i] = "\0";
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (ch === "\"" || ch === "'" || ch === "`") {
|
|
484
|
+
quote = ch;
|
|
485
|
+
lastCode = ch;
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (ch === "/" && next === "/") {
|
|
489
|
+
const end = source.indexOf("\n", i);
|
|
490
|
+
const stop = end === -1 ? source.length : end;
|
|
491
|
+
for (let j = i; j < stop; j += 1) out[j] = "\0";
|
|
492
|
+
i = stop - 1;
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
if (ch === "/" && next === "*") {
|
|
496
|
+
const close = source.indexOf("*/", i + 2);
|
|
497
|
+
const stop = close === -1 ? source.length : close + 2;
|
|
498
|
+
for (let j = i; j < stop; j += 1) if (source[j] !== "\n") out[j] = "\0";
|
|
499
|
+
i = stop - 1;
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (ch === "/" && startsRegex(lastCode)) {
|
|
503
|
+
let inClass = false;
|
|
504
|
+
let j = i + 1;
|
|
505
|
+
for (; j < source.length; j += 1) {
|
|
506
|
+
const c = source[j] ?? "";
|
|
507
|
+
if (c === "\\") j += 1;
|
|
508
|
+
else if (c === "\n") break;
|
|
509
|
+
else if (inClass) inClass = c !== "]";
|
|
510
|
+
else if (c === "[") inClass = true;
|
|
511
|
+
else if (c === "/") break;
|
|
512
|
+
}
|
|
513
|
+
i = j;
|
|
514
|
+
lastCode = "/";
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
if (!/\s/.test(ch)) lastCode = ch;
|
|
518
|
+
}
|
|
519
|
+
return out.join("");
|
|
520
|
+
}
|
|
521
|
+
/** After one of these a `/` opens a regex literal, not a division. */
|
|
522
|
+
function startsRegex(lastCode) {
|
|
523
|
+
return lastCode === "" || "(,=:[!&|?{};+-*%<>~^".includes(lastCode);
|
|
524
|
+
}
|
|
465
525
|
//#endregion
|
|
466
526
|
//#region src/audit/source-rules.ts
|
|
467
527
|
/**
|
|
@@ -476,12 +536,27 @@ async function runReleaseRules(cwd) {
|
|
|
476
536
|
* VTTF-AUDIT-006 (LOW) : `_addDataFieldMigrations` override (wrong signature)
|
|
477
537
|
* VTTF-AUDIT-007 (MEDIUM): manifest primary/secondaryTokenAttribute not matched
|
|
478
538
|
* by a `value`/`max` SchemaField in source
|
|
539
|
+
* VTTF-AUDIT-022 (HIGH) : source talks over the socket, manifest does not
|
|
540
|
+
* declare `"socket": true`
|
|
479
541
|
*
|
|
480
542
|
* Regex-based on purpose: avoids pulling in a TypeScript AST dependency
|
|
481
543
|
* for what amount to four pattern checks. The trade-off is occasional
|
|
482
544
|
* false negatives on heavily-formatted code; the alternative would be a
|
|
483
545
|
* 30MB+ runtime dep for marginal gains.
|
|
484
546
|
*/
|
|
547
|
+
/**
|
|
548
|
+
* `registerSocket` binds `game.socket.on` on the package channel and emits on
|
|
549
|
+
* it, so it carries the manifest requirement on its own.
|
|
550
|
+
*/
|
|
551
|
+
const REGISTER_SOCKET = /\bregisterSocket\s*\(/;
|
|
552
|
+
/** A raw `game.socket.emit(` or `game.socket.on(`. */
|
|
553
|
+
const RAW_SOCKET_CALL = /\bgame\s*\.\s*socket\s*\.\s*(?:emit|on)\s*\(/;
|
|
554
|
+
/**
|
|
555
|
+
* The package channel, in a string or a template literal. Core events travel
|
|
556
|
+
* the same socket under their own names, and those need no manifest flag, so
|
|
557
|
+
* a raw call only counts when the file also names a package channel.
|
|
558
|
+
*/
|
|
559
|
+
const PACKAGE_CHANNEL = /['"`](?:module|system)\.[^'"`\s]*/;
|
|
485
560
|
/** Directories we never descend into; they are not user source. */
|
|
486
561
|
const EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
487
562
|
"node_modules",
|
|
@@ -1284,6 +1359,41 @@ function lastSegment(path) {
|
|
|
1284
1359
|
return idx < 0 ? path : path.slice(idx + 1);
|
|
1285
1360
|
}
|
|
1286
1361
|
/** Entry point: gather everything once, then dispatch to the per-file rules. */
|
|
1362
|
+
/**
|
|
1363
|
+
* VTTF-AUDIT-022 (HIGH): the source uses the package socket, the manifest
|
|
1364
|
+
* does not declare it.
|
|
1365
|
+
*
|
|
1366
|
+
* Foundry only opens the `module.<id>` / `system.<id>` channel for a package
|
|
1367
|
+
* whose manifest carries `"socket": true`. Without the flag, `emit` returns
|
|
1368
|
+
* without throwing and the message never leaves the client. Nothing is
|
|
1369
|
+
* logged. The listener on the other machine is bound and correct, and it
|
|
1370
|
+
* never fires, so the search goes to the handler and the payload shape and
|
|
1371
|
+
* the user permissions, and the manifest is the last place anyone looks.
|
|
1372
|
+
*/
|
|
1373
|
+
function rule022(manifestPath, manifestRaw, manifestParsed, contents) {
|
|
1374
|
+
if (!manifestPath || !manifestRaw || !manifestParsed) return [];
|
|
1375
|
+
if (manifestParsed.socket === true) return [];
|
|
1376
|
+
const manifestName = basename(manifestPath);
|
|
1377
|
+
const out = [];
|
|
1378
|
+
for (const [file, content] of contents) {
|
|
1379
|
+
const code = maskComments(content);
|
|
1380
|
+
const registered = REGISTER_SOCKET.exec(code);
|
|
1381
|
+
const raw = PACKAGE_CHANNEL.test(code) ? RAW_SOCKET_CALL.exec(code) : null;
|
|
1382
|
+
const match = registered ?? raw;
|
|
1383
|
+
if (match?.index === void 0) continue;
|
|
1384
|
+
const call = match[0].replace(/\s*\($/, "").replaceAll(/\s+/g, "");
|
|
1385
|
+
out.push({
|
|
1386
|
+
ruleId: "VTTF-AUDIT-022",
|
|
1387
|
+
title: "Socket use with no \"socket\": true in the manifest",
|
|
1388
|
+
severity: "HIGH",
|
|
1389
|
+
filePath: file,
|
|
1390
|
+
line: content.slice(0, match.index).split("\n").length,
|
|
1391
|
+
message: `This file calls \`${call}\`, and ${manifestName} has no \`"socket": true\`. Foundry never opens the package channel, so every emit is dropped without an error and no listener on any other client fires.`,
|
|
1392
|
+
remediation: "Add `\"socket\": true` to the manifest, then restart the world. Foundry reads the flag when the package loads, so a running world keeps the old answer."
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
return out;
|
|
1396
|
+
}
|
|
1287
1397
|
async function runSourceRules(cwd) {
|
|
1288
1398
|
if (!existsSync(cwd)) return [];
|
|
1289
1399
|
if (!(await stat(cwd)).isDirectory()) return [];
|
|
@@ -1302,6 +1412,7 @@ async function runSourceRules(cwd) {
|
|
|
1302
1412
|
results.push(...rule004(file, content, declared, classToSubtypes));
|
|
1303
1413
|
}
|
|
1304
1414
|
results.push(...await rule007(manifestPath, manifestRaw, manifestParsed, sourceFiles, classToSubtypes));
|
|
1415
|
+
results.push(...rule022(manifestPath, manifestRaw, manifestParsed, contents));
|
|
1305
1416
|
return results;
|
|
1306
1417
|
}
|
|
1307
1418
|
const _internal = {
|
|
@@ -1591,66 +1702,6 @@ function definesName(source, name) {
|
|
|
1591
1702
|
function bareUsePattern(name) {
|
|
1592
1703
|
return new RegExp(`(?<![\\w$.])${name}\\b(?!\\s*:(?!:))(?=[\\s.(,;)\\]}]|$)`, "gm");
|
|
1593
1704
|
}
|
|
1594
|
-
function maskComments(source, { strings = false } = {}) {
|
|
1595
|
-
const out = source.split("");
|
|
1596
|
-
let quote = null;
|
|
1597
|
-
let lastCode = "";
|
|
1598
|
-
for (let i = 0; i < source.length; i += 1) {
|
|
1599
|
-
const ch = source[i] ?? "";
|
|
1600
|
-
const next = source[i + 1] ?? "";
|
|
1601
|
-
if (quote !== null) {
|
|
1602
|
-
if (ch === "\\") {
|
|
1603
|
-
if (strings) {
|
|
1604
|
-
out[i] = "\0";
|
|
1605
|
-
if (source[i + 1] !== "\n") out[i + 1] = "\0";
|
|
1606
|
-
}
|
|
1607
|
-
i += 1;
|
|
1608
|
-
} else if (ch === quote) quote = null;
|
|
1609
|
-
else if (strings && ch !== "\n") out[i] = "\0";
|
|
1610
|
-
continue;
|
|
1611
|
-
}
|
|
1612
|
-
if (ch === "\"" || ch === "'" || ch === "`") {
|
|
1613
|
-
quote = ch;
|
|
1614
|
-
lastCode = ch;
|
|
1615
|
-
continue;
|
|
1616
|
-
}
|
|
1617
|
-
if (ch === "/" && next === "/") {
|
|
1618
|
-
const end = source.indexOf("\n", i);
|
|
1619
|
-
const stop = end === -1 ? source.length : end;
|
|
1620
|
-
for (let j = i; j < stop; j += 1) out[j] = "\0";
|
|
1621
|
-
i = stop - 1;
|
|
1622
|
-
continue;
|
|
1623
|
-
}
|
|
1624
|
-
if (ch === "/" && next === "*") {
|
|
1625
|
-
const close = source.indexOf("*/", i + 2);
|
|
1626
|
-
const stop = close === -1 ? source.length : close + 2;
|
|
1627
|
-
for (let j = i; j < stop; j += 1) if (source[j] !== "\n") out[j] = "\0";
|
|
1628
|
-
i = stop - 1;
|
|
1629
|
-
continue;
|
|
1630
|
-
}
|
|
1631
|
-
if (ch === "/" && startsRegex(lastCode)) {
|
|
1632
|
-
let inClass = false;
|
|
1633
|
-
let j = i + 1;
|
|
1634
|
-
for (; j < source.length; j += 1) {
|
|
1635
|
-
const c = source[j] ?? "";
|
|
1636
|
-
if (c === "\\") j += 1;
|
|
1637
|
-
else if (c === "\n") break;
|
|
1638
|
-
else if (inClass) inClass = c !== "]";
|
|
1639
|
-
else if (c === "[") inClass = true;
|
|
1640
|
-
else if (c === "/") break;
|
|
1641
|
-
}
|
|
1642
|
-
i = j;
|
|
1643
|
-
lastCode = "/";
|
|
1644
|
-
continue;
|
|
1645
|
-
}
|
|
1646
|
-
if (!/\s/.test(ch)) lastCode = ch;
|
|
1647
|
-
}
|
|
1648
|
-
return out.join("");
|
|
1649
|
-
}
|
|
1650
|
-
/** After one of these a `/` opens a regex literal, not a division. */
|
|
1651
|
-
function startsRegex(lastCode) {
|
|
1652
|
-
return lastCode === "" || "(,=:[!&|?{};+-*%<>~^".includes(lastCode);
|
|
1653
|
-
}
|
|
1654
1705
|
//#endregion
|
|
1655
1706
|
//#region src/audit/v14-rules.ts
|
|
1656
1707
|
/**
|
|
@@ -1942,7 +1993,7 @@ async function runV14Rules(cwd) {
|
|
|
1942
1993
|
*
|
|
1943
1994
|
* Rule organisation:
|
|
1944
1995
|
* - manifest-rules.ts → VTTF-AUDIT-001, 002, 003 (manifest-only)
|
|
1945
|
-
* - source-rules.ts → VTTF-AUDIT-004, 005, 006, 007 (source walker
|
|
1996
|
+
* - source-rules.ts → VTTF-AUDIT-004, 005, 006, 007, 022 (source walker
|
|
1946
1997
|
* + cross-check with manifest where needed)
|
|
1947
1998
|
* - template-rules.ts → VTTF-AUDIT-008 (the Handlebars, cross-checked
|
|
1948
1999
|
* against which base each sheet is built on)
|
|
@@ -3720,6 +3771,6 @@ async function runLintCommand(options = {}) {
|
|
|
3720
3771
|
*/
|
|
3721
3772
|
const VTTFORGE_CLI_VERSION = version;
|
|
3722
3773
|
//#endregion
|
|
3723
|
-
export { runManifestRules as S,
|
|
3774
|
+
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 };
|
|
3724
3775
|
|
|
3725
|
-
//# sourceMappingURL=src-
|
|
3776
|
+
//# sourceMappingURL=src-DK2hXzBk.mjs.map
|