@vttforge/cli 0.17.1 → 0.18.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 CHANGED
@@ -1,5 +1,86 @@
1
1
  # @vttforge/cli
2
2
 
3
+ ## 0.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 9ae404a: Five fixes found by building a module on the SDK from scratch, outside this
8
+ repo.
9
+
10
+ **The TypeScript templates type the Foundry globals.** `foundry-globals.ts`
11
+ declared `game`, `CONFIG`, `Hooks`, `ui` and `foundry` as `any`, and its
12
+ comment said `@vttforge/types` was still to come. It shipped. The file is now
13
+ `foundry-globals.d.ts`, where an ambient declaration belongs, and it imports
14
+ from `@vttforge/types`. `foundry.*` is narrowed to the members the template
15
+ reaches for rather than widened to `any`, because a typo in a namespaced path
16
+ is the kind of mistake that only shows up at runtime. The entry point no
17
+ longer imports the file: a `.d.ts` is picked up by `include`.
18
+
19
+ **Breaking for a scaffolded project you have already edited.** Typed globals
20
+ report mistakes the `any` declarations accepted. Delete
21
+ `scripts/foundry-globals.ts`, take the new `.d.ts`, and drop the
22
+ `import './foundry-globals.js';` line from your entry point.
23
+
24
+ **`create-vttforge` forwards every flag `vttforge init` takes.** It carried
25
+ four, so `--id`, `--title`, `--description`, `--author`, `--license` and
26
+ `--yes` were unreachable through `npm create vttforge`, which is the entry
27
+ point most people use. A scaffold came out holding the template's placeholder
28
+ description.
29
+
30
+ **`vttforge lint` stops reporting `noThisInStatic`.** ApplicationV2 calls an
31
+ action handler with `this` bound to the instance even though the handler is
32
+ declared static, which is how Foundry's own documentation writes it. The
33
+ rule's suggested fix compiles and then fails at runtime.
34
+
35
+ **`vttforge audit` no longer reads a TypeScript member signature as a bare v13
36
+ global.** `renderTemplate(path: string, context: unknown): Promise<string>`
37
+ inside an `interface` declares the namespaced member; rule 019 called it a use
38
+ of the removed alias. A call in a ternary is still flagged.
39
+
40
+ **The release workflow the templates ship matches the Node and pnpm the
41
+ templates require.** It ran Node 22 and pnpm 10 against an `engines.node` of
42
+ `>=26`.
43
+
44
+ The scaffold templates pin `@vttforge/cli` at `^0.18.0` and add
45
+ `@vttforge/types` at `^0.5.0`, the versions this release publishes. A caret
46
+ pins the minor on a 0.x line.
47
+
48
+ ### Patch Changes
49
+
50
+ - fef514a: The plugin writes the `manifest` and `download` URLs into the built manifest.
51
+
52
+ `vttforge build` emits `dist/` and zips it in one step, so a release workflow
53
+ that patched `dist/module.json` afterwards shipped a zip holding the unpatched
54
+ manifest. The templates worked around it by calling `vite build` directly,
55
+ patching the JSON with an inline `node -e`, and zipping by hand.
56
+
57
+ Two options, `manifestUrl` and `downloadUrl`, each falling back to
58
+ `VTTFORGE_MANIFEST_URL` and `VTTFORGE_DOWNLOAD_URL` so a workflow sets them
59
+ without editing the Vite config. `{version}` in the download URL is replaced
60
+ with the version being built. Neither given, the source manifest is left
61
+ alone.
62
+
63
+ The release workflow the templates ship now runs `pnpm build` with those two
64
+ variables set, and the three-step dance is gone.
65
+
66
+ `vttforge audit` rule 020 knows that `vttforge build` writes the zip itself,
67
+ from `dist/`, so a workflow naming that zip is not shipping the checkout. A
68
+ workflow that runs a plain `vite build` and then zips the source tree is still
69
+ a HIGH finding.
70
+ - c34b8ca: The scaffold templates pin `@vttforge/core` at `^0.20.0`, the version the
71
+ pending release publishes. On a 0.x line a caret pins the minor, so the old
72
+ `^0.19.0` would scaffold a project that cannot resolve the core it is written
73
+ against.
74
+
75
+ ## 0.17.2
76
+
77
+ ### Patch Changes
78
+
79
+ - 712edb3: Point the scaffold templates at `@vttforge/core` 0.19, and use the document
80
+ types it ships. The TypeScript templates no longer hand-write an interface for
81
+ their own actor or item: they pass the schema to the sheet factory
82
+ (`BaseActorSheet<CharacterActor>()`) and read `this.document` straight.
83
+
3
84
  ## 0.17.1
4
85
 
5
86
  ### Patch Changes
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
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-wuBV0ItE.mjs";
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-DZoPlpQk.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.mjs CHANGED
@@ -1,2 +1,2 @@
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-wuBV0ItE.mjs";
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-DZoPlpQk.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.17.1";
14
+ var version = "0.18.0";
15
15
  //#endregion
16
16
  //#region src/audit/manifest-rules.ts
17
17
  /**
@@ -364,26 +364,48 @@ const VITE_CONFIGS = [
364
364
  ];
365
365
  /** A line that runs the build. */
366
366
  const BUILD_STEP = /\b(?:vttforge\s+build|vite\s+build|(?:pnpm|npm|yarn|bun)\s+(?:run\s+)?build)\b/;
367
+ /**
368
+ * A line that runs `vttforge build`, directly or through the `build` script.
369
+ *
370
+ * That command writes the zip itself, from `dist/`, so the artifact it leaves
371
+ * in the project root is already the right one. A workflow naming that zip is
372
+ * not shipping the checkout.
373
+ */
374
+ const VTTFORGE_BUILD = /\bvttforge\s+build\b/;
375
+ const SCRIPT_BUILD = /\b(?:pnpm|npm|yarn|bun)\s+(?:run\s+)?build(?=\s|$)/;
367
376
  /** A line that makes or names the artifact. */
368
377
  const ZIP_COMMAND = /\bzip\s+(?:-\S+\s+)*\S+\.zip\b|\bzip\s+-r\b/;
369
378
  const ARTIFACT_LIST = /^\s*(?:artifacts|files|asset_path|path)\s*:/;
370
379
  const MANIFEST = /\b(?:system|module)\.json\b/;
371
380
  const RELEASE_ACTION = /(?:release-action|action-gh-release|upload-release-asset)/;
372
- /** Whether this project builds through the vite plugin (or a `build` script that runs vite). */
373
- async function buildsToDist(cwd) {
381
+ /** Whether this project builds through the vite plugin, and whether its build script zips. */
382
+ async function buildShape(cwd) {
383
+ let toDist = false;
374
384
  for (const name of VITE_CONFIGS) {
375
385
  const path = join(cwd, name);
376
386
  if (!existsSync(path)) continue;
377
387
  const text = await readFile(path, "utf8");
378
- if (/@vttforge\/vite-plugin|vttforge\s*\(/.test(text)) return true;
388
+ if (/@vttforge\/vite-plugin|vttforge\s*\(/.test(text)) {
389
+ toDist = true;
390
+ break;
391
+ }
379
392
  }
380
393
  const pkg = join(cwd, "package.json");
381
- if (!existsSync(pkg)) return false;
394
+ if (!existsSync(pkg)) return {
395
+ toDist,
396
+ scriptZips: false
397
+ };
382
398
  try {
383
399
  const build = JSON.parse(await readFile(pkg, "utf8")).scripts?.build ?? "";
384
- return /vttforge\s+build|vite\s+build/.test(build);
400
+ return {
401
+ toDist: toDist || /vttforge\s+build|vite\s+build/.test(build),
402
+ scriptZips: VTTFORGE_BUILD.test(build)
403
+ };
385
404
  } catch {
386
- return false;
405
+ return {
406
+ toDist,
407
+ scriptZips: false
408
+ };
387
409
  }
388
410
  }
389
411
  async function workflowFiles(cwd) {
@@ -392,15 +414,17 @@ async function workflowFiles(cwd) {
392
414
  return (await readdir(dir, { withFileTypes: true })).filter((e) => e.isFile() && /\.ya?ml$/.test(e.name)).map((e) => join(dir, e.name)).sort();
393
415
  }
394
416
  /** The first step that ships a package, or null when the workflow ships nothing. */
395
- function shippingStep(text) {
417
+ function shippingStep(text, scriptZips) {
396
418
  const lines = text.split("\n");
397
419
  let builtBefore = false;
420
+ let zipCameFromBuild = false;
398
421
  let inArtifactList = false;
399
422
  for (let i = 0; i < lines.length; i += 1) {
400
423
  const line = lines[i] ?? "";
401
424
  if (BUILD_STEP.test(line)) builtBefore = true;
425
+ if (VTTFORGE_BUILD.test(line) || scriptZips && SCRIPT_BUILD.test(line)) zipCameFromBuild = true;
402
426
  if (ZIP_COMMAND.test(line)) {
403
- const fromDist = /\bdist\b/.test(line) || /\bcd\s+dist\b/.test(lines.slice(Math.max(0, i - 3), i).join("\n"));
427
+ const fromDist = zipCameFromBuild || /\bdist\b/.test(line) || /\bcd\s+dist\b/.test(lines.slice(Math.max(0, i - 3), i).join("\n"));
404
428
  return {
405
429
  line: i + 1,
406
430
  fromDist,
@@ -412,7 +436,7 @@ function shippingStep(text) {
412
436
  const inline = line.slice(line.indexOf(":") + 1);
413
437
  if (MANIFEST.test(inline) || /\.zip\b/.test(inline)) return {
414
438
  line: i + 1,
415
- fromDist: /\bdist\//.test(inline),
439
+ fromDist: zipCameFromBuild || /\bdist\//.test(inline),
416
440
  builtBefore
417
441
  };
418
442
  continue;
@@ -421,7 +445,7 @@ function shippingStep(text) {
421
445
  if (/^\s*-?\s*\S/.test(line) && !/^\s*-\s/.test(line) && !/^\s{4,}\S/.test(line)) inArtifactList = false;
422
446
  else if (MANIFEST.test(line) || /\.zip\b/.test(line)) return {
423
447
  line: i + 1,
424
- fromDist: /\bdist\//.test(line),
448
+ fromDist: zipCameFromBuild || /\bdist\//.test(line),
425
449
  builtBefore
426
450
  };
427
451
  }
@@ -433,12 +457,13 @@ function shippingStep(text) {
433
457
  * and ship `dist/`.
434
458
  */
435
459
  async function runReleaseRules(cwd) {
436
- if (!await buildsToDist(cwd)) return [];
460
+ const shape = await buildShape(cwd);
461
+ if (!shape.toDist) return [];
437
462
  const findings = [];
438
463
  for (const file of await workflowFiles(cwd)) {
439
464
  const text = await readFile(file, "utf8");
440
465
  if (!(RELEASE_ACTION.test(text) || /\brelease\s*:/.test(text) || /\btags\s*:/.test(text))) continue;
441
- const ship = shippingStep(text);
466
+ const ship = shippingStep(text, shape.scriptZips);
442
467
  if (!ship) continue;
443
468
  const relPath = relative(cwd, file);
444
469
  if (!ship.builtBefore) findings.push({
@@ -1691,9 +1716,22 @@ const LEGACY_GLOBALS = Object.freeze({
1691
1716
  *
1692
1717
  * A module that defines its own `Token` class or imports `Tabs` from a
1693
1718
  * library is using that, not Foundry's global.
1719
+ *
1720
+ * The last alternative covers a TypeScript member signature:
1721
+ *
1722
+ * ```ts
1723
+ * interface FoundryHandlebars {
1724
+ * renderTemplate(path: string, context: unknown): Promise<string>;
1725
+ * }
1726
+ * ```
1727
+ *
1728
+ * That is a declaration of the namespaced member, the opposite of a bare
1729
+ * global, and reading it as a use was a false finding. It is anchored to the
1730
+ * start of a line so a ternary's `cond ? renderTemplate(x) : y` still counts
1731
+ * as a use: there the name follows a `?` rather than opening the line.
1694
1732
  */
1695
1733
  function definesName(source, name) {
1696
- return new RegExp(`(?:\\b(?:class|function|const|let|var)\\s+${name}\\b|import[^;]*\\b${name}\\b|\\b${name}\\s*\\([^)]*\\)\\s*\\{)`).test(source);
1734
+ return new RegExp(`(?:\\b(?:class|function|const|let|var)\\s+${name}\\b|import[^;]*\\b${name}\\b|\\b${name}\\s*\\([^)]*\\)\\s*\\{|^[ \\t]*(?:readonly[ \\t]+)?${name}\\s*\\((?:[^)(]|\\([^)]*\\))*\\)\\s*:)`, "m").test(source);
1697
1735
  }
1698
1736
  /**
1699
1737
  * A bare use of `name`: not a property (`x.Token`), not an object key
@@ -3777,4 +3815,4 @@ const VTTFORGE_CLI_VERSION = version;
3777
3815
  //#endregion
3778
3816
  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 };
3779
3817
 
3780
- //# sourceMappingURL=src-wuBV0ItE.mjs.map
3818
+ //# sourceMappingURL=src-DZoPlpQk.mjs.map