@vttforge/cli 0.7.0 → 0.8.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.
@@ -10,7 +10,7 @@ import { createServer } from "node:http";
10
10
  import { homedir } from "node:os";
11
11
  import { promisify } from "node:util";
12
12
  //#region package.json
13
- var version = "0.7.0";
13
+ var version = "0.8.0";
14
14
  //#endregion
15
15
  //#region src/audit/manifest-rules.ts
16
16
  /**
@@ -1350,6 +1350,10 @@ function relativizeIfBelow(filePath, cwd) {
1350
1350
  * 0: clean run, or only MEDIUM/LOW findings (informational)
1351
1351
  * 1: at least one HIGH finding (or any finding in `--strict` mode)
1352
1352
  */
1353
+ /**
1354
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
1355
+ * change in a minor.
1356
+ */
1353
1357
  async function runAuditCommand(options = {}) {
1354
1358
  const cwd = resolve(options.cwd ?? process.cwd());
1355
1359
  const format = options.format ?? "markdown";
@@ -1392,6 +1396,9 @@ const MANIFEST_VERSION_RE = /^[0-9A-Za-z._+-]+$/;
1392
1396
  * Throws if neither file exists, required fields are missing/non-string,
1393
1397
  * or the id/version contain characters that would let downstream `join()`
1394
1398
  * calls escape their intended directory.
1399
+ *
1400
+ * @experimental Shape is unproven: no consumer has asked for this yet.
1401
+ * It can change in a minor.
1395
1402
  */
1396
1403
  async function readManifest(distDir) {
1397
1404
  for (const { file, type } of MANIFEST_FILES) {
@@ -1432,6 +1439,10 @@ async function readManifest(distDir) {
1432
1439
  * most common Foundry-developer choice, but any concrete signal in the
1433
1440
  * environment wins over the default.
1434
1441
  */
1442
+ /**
1443
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
1444
+ * outside use, and going away in the next major.
1445
+ */
1435
1446
  function detectPackageManager(env = process.env) {
1436
1447
  const ua = env.npm_config_user_agent;
1437
1448
  if (typeof ua === "string" && ua.length > 0) {
@@ -1442,6 +1453,10 @@ function detectPackageManager(env = process.env) {
1442
1453
  }
1443
1454
  return "pnpm";
1444
1455
  }
1456
+ /**
1457
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
1458
+ * outside use, and going away in the next major.
1459
+ */
1445
1460
  function installCommand(pm) {
1446
1461
  return `${pm} install`;
1447
1462
  }
@@ -1454,6 +1469,9 @@ function installCommand(pm) {
1454
1469
  *
1455
1470
  * Falls back to {@link detectPackageManager} for fresh checkouts that
1456
1471
  * haven't been installed yet.
1472
+ *
1473
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1474
+ * for outside use, and going away in the next major.
1457
1475
  */
1458
1476
  function detectProjectPackageManager(cwd, env = process.env) {
1459
1477
  if (existsSync(join(cwd, "pnpm-lock.yaml"))) return "pnpm";
@@ -1469,6 +1487,9 @@ function detectProjectPackageManager(cwd, env = process.env) {
1469
1487
  * Plug'n'Play, pnpm's symlinked layout, npm's flattened node_modules,
1470
1488
  * Bun's symlinked node_modules. Each manager exposes a uniform "run a
1471
1489
  * locally-resolved binary in the project's dependency graph" command.
1490
+ *
1491
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1492
+ * for outside use, and going away in the next major.
1472
1493
  */
1473
1494
  function execInvocation(pm, bin) {
1474
1495
  switch (pm) {
@@ -1494,18 +1515,30 @@ function execInvocation(pm, bin) {
1494
1515
  * binary on disk. The package-manager command always resolves the
1495
1516
  * locally-installed vite correctly regardless of linker.
1496
1517
  */
1518
+ /**
1519
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
1520
+ * outside use, and going away in the next major.
1521
+ */
1497
1522
  var ViteNotInstalledError = class extends Error {
1498
1523
  constructor(message) {
1499
1524
  super(message);
1500
1525
  this.name = "ViteNotInstalledError";
1501
1526
  }
1502
1527
  };
1503
- /** Spawn args for invoking the user's vite (e.g. `["pnpm", ["exec", "vite"]]`). */
1528
+ /** Spawn args for invoking the user's vite (e.g. `["pnpm", ["exec", "vite"]]`).
1529
+ *
1530
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1531
+ * for outside use, and going away in the next major.
1532
+ */
1504
1533
  function resolveViteInvocation(cwd) {
1505
1534
  if (!existsSync(join(cwd, "package.json"))) throw new ViteNotInstalledError(`No package.json found at ${cwd}. Run \`vttforge dev\` / \`vttforge build\` from inside a scaffolded project.`);
1506
1535
  return execInvocation(detectProjectPackageManager(cwd), "vite");
1507
1536
  }
1508
- /** Run `vite build` once and wait for it to exit. Throws on non-zero exit. */
1537
+ /** Run `vite build` once and wait for it to exit. Throws on non-zero exit.
1538
+ *
1539
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1540
+ * for outside use, and going away in the next major.
1541
+ */
1509
1542
  async function runViteBuildOnce(cwd) {
1510
1543
  const [bin, baseArgs] = resolveViteInvocation(cwd);
1511
1544
  await new Promise((resolveBuild, rejectBuild) => {
@@ -1529,6 +1562,9 @@ async function runViteBuildOnce(cwd) {
1529
1562
  * Spawn `vite build --watch` and return the child process. The caller is
1530
1563
  * responsible for waiting on it and tearing it down (the dev command kills
1531
1564
  * it on SIGINT).
1565
+ *
1566
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1567
+ * for outside use, and going away in the next major.
1532
1568
  */
1533
1569
  function spawnViteWatch(cwd) {
1534
1570
  const [bin, baseArgs] = resolveViteInvocation(cwd);
@@ -1557,6 +1593,10 @@ function spawnViteWatch(cwd) {
1557
1593
  * Optional extras (LICENSE / README / CHANGELOG) ride along when present at
1558
1594
  * the project root and not already inside `dist/`. We never duplicate.
1559
1595
  */
1596
+ /**
1597
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
1598
+ * change in a minor.
1599
+ */
1560
1600
  async function emitZip(opts) {
1561
1601
  const { sourceDir, outFile, extras = [], extrasFrom } = opts;
1562
1602
  if (!existsSync(sourceDir)) throw new Error(`emitZip: sourceDir does not exist: ${sourceDir}`);
@@ -1627,6 +1667,9 @@ function formatBytes(n) {
1627
1667
  /**
1628
1668
  * Internal building block exposed for tests: assumes dist/ is already
1629
1669
  * populated (vite has run, manifest is present) and just emits the zip.
1670
+ *
1671
+ * @experimental Shape is unproven: no consumer has asked for this yet.
1672
+ * It can change in a minor.
1630
1673
  */
1631
1674
  async function emitReleaseZip(opts) {
1632
1675
  const cwd = resolve(opts.cwd);
@@ -1646,6 +1689,10 @@ async function emitReleaseZip(opts) {
1646
1689
  manifest
1647
1690
  };
1648
1691
  }
1692
+ /**
1693
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
1694
+ * change in a minor.
1695
+ */
1649
1696
  async function runBuild(options = {}) {
1650
1697
  const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
1651
1698
  p.intro("🜲 vttforge build: release zip");
@@ -1685,6 +1732,9 @@ async function runBuild(options = {}) {
1685
1732
  * `null` if `path` doesn't exist or isn't a symlink. Relative symlink
1686
1733
  * targets are resolved against the link's own directory (matches the
1687
1734
  * semantics callers expect when comparing to a known absolute source).
1735
+ *
1736
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1737
+ * for outside use, and going away in the next major.
1688
1738
  */
1689
1739
  async function readLinkTarget(path) {
1690
1740
  try {
@@ -1703,6 +1753,9 @@ async function readLinkTarget(path) {
1703
1753
  * - target already points to source → no-op
1704
1754
  * - target points elsewhere → throws unless `options.overwrite`
1705
1755
  * - target is a real file/dir → throws unconditionally
1756
+ *
1757
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1758
+ * for outside use, and going away in the next major.
1706
1759
  */
1707
1760
  async function createLink(target, source, options = {}) {
1708
1761
  const absSource = resolve(source);
@@ -1736,6 +1789,9 @@ async function createLink(target, source, options = {}) {
1736
1789
  * Remove a symlink at `path`. No-ops when the path doesn't exist. Throws
1737
1790
  * when the path exists but isn't a symlink; we never unlink real files
1738
1791
  * or directories.
1792
+ *
1793
+ * @internal Implementation detail of the `vttforge` binary. Not supported
1794
+ * for outside use, and going away in the next major.
1739
1795
  */
1740
1796
  async function removeLink(path) {
1741
1797
  let info;
@@ -2071,6 +2127,9 @@ function watchDist(options) {
2071
2127
  * Return the OS-default Foundry user-data directory, or `null` on unknown
2072
2128
  * platforms / missing platform-specific env vars. Does NOT check existence;
2073
2129
  * callers prompt the user when the suggested path doesn't resolve.
2130
+ *
2131
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2132
+ * for outside use, and going away in the next major.
2074
2133
  */
2075
2134
  function autoDetectFoundryDataDir(platform = process.platform, env = process.env, home = homedir()) {
2076
2135
  switch (platform) {
@@ -2088,22 +2147,21 @@ function autoDetectFoundryDataDir(platform = process.platform, env = process.env
2088
2147
  default: return null;
2089
2148
  }
2090
2149
  }
2091
- /**
2092
- * Heuristic: a path looks like a Foundry user-data root if it contains a
2093
- * `Data/` subdirectory (canonical Foundry layout) OR if it already contains
2094
- * `systems/` or `modules/` (the path is already the Data folder itself).
2095
- */
2096
- function looksLikeFoundryDataDir(path) {
2097
- if (!existsSync(path)) return false;
2098
- return existsSync(join(path, "Data")) || existsSync(join(path, "systems")) || existsSync(join(path, "modules"));
2099
- }
2100
2150
  const CONFIG_DIR = ".vttforge";
2101
2151
  const CONFIG_FILE = "config.json";
2102
- /** Absolute path to the project-local config file (whether or not it exists). */
2152
+ /** Absolute path to the project-local config file (whether or not it exists).
2153
+ *
2154
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2155
+ * for outside use, and going away in the next major.
2156
+ */
2103
2157
  function configPath(cwd) {
2104
2158
  return join(resolve(cwd), CONFIG_DIR, CONFIG_FILE);
2105
2159
  }
2106
- /** Load `<cwd>/.vttforge/config.json` if it exists and is valid JSON. */
2160
+ /** Load `<cwd>/.vttforge/config.json` if it exists and is valid JSON.
2161
+ *
2162
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2163
+ * for outside use, and going away in the next major.
2164
+ */
2107
2165
  async function loadConfig(cwd) {
2108
2166
  const path = configPath(cwd);
2109
2167
  if (!existsSync(path)) return null;
@@ -2116,7 +2174,11 @@ async function loadConfig(cwd) {
2116
2174
  return null;
2117
2175
  }
2118
2176
  }
2119
- /** Persist `<cwd>/.vttforge/config.json`. Creates the `.vttforge/` dir as needed. */
2177
+ /** Persist `<cwd>/.vttforge/config.json`. Creates the `.vttforge/` dir as needed.
2178
+ *
2179
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2180
+ * for outside use, and going away in the next major.
2181
+ */
2120
2182
  async function saveConfig(cwd, config) {
2121
2183
  const path = configPath(cwd);
2122
2184
  await mkdir(dirname(path), { recursive: true });
@@ -2145,6 +2207,9 @@ function isFoundryDataFolder(path) {
2145
2207
  *
2146
2208
  * The returned path is not guaranteed to exist yet; callers `mkdir -p` it
2147
2209
  * before creating the symlink.
2210
+ *
2211
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2212
+ * for outside use, and going away in the next major.
2148
2213
  */
2149
2214
  function foundryPackagesDir(dataRoot, type) {
2150
2215
  const subFolder = type === "system" ? "systems" : "modules";
@@ -2166,6 +2231,9 @@ function expandTilde(p, home) {
2166
2231
  * Walk the precedence chain and return the chosen Foundry user-data path.
2167
2232
  * Saves the user's choice to the project config on first interactive run so
2168
2233
  * subsequent invocations skip the prompt.
2234
+ *
2235
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2236
+ * for outside use, and going away in the next major.
2169
2237
  */
2170
2238
  async function resolveFoundryDataDir(opts) {
2171
2239
  const { cwd, override, prompt } = opts;
@@ -2286,6 +2354,10 @@ function installSignalHandlers(cleanup) {
2286
2354
  process.removeListener("SIGTERM", handler);
2287
2355
  };
2288
2356
  }
2357
+ /**
2358
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
2359
+ * change in a minor.
2360
+ */
2289
2361
  async function runDev(options = {}) {
2290
2362
  const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
2291
2363
  p.intro("🜲 vttforge dev: symlink + watch");
@@ -2346,29 +2418,13 @@ async function runDev(options = {}) {
2346
2418
  p.outro("Stopped. Symlink cleaned up.");
2347
2419
  }
2348
2420
  /**
2349
- * Internal building block exposed for tests: given an already-built `dist/`
2350
- * (vite has run, manifest is present) and a resolved Foundry data dir,
2351
- * create the symlink and return the target path + manifest. Skips the
2352
- * vite spawn and the signal-loop, so tests can drive the orchestration
2353
- * deterministically.
2354
- */
2355
- async function setupDevSymlink(opts) {
2356
- const cwd = resolve(opts.cwd);
2357
- const distDir = join(cwd, "dist");
2358
- const manifest = await readManifest(distDir);
2359
- const packagesDir = foundryPackagesDir(opts.dataRoot, manifest.type);
2360
- const target = join(packagesDir, manifest.id);
2361
- await createLink(target, distDir, { overwrite: true });
2362
- return {
2363
- target,
2364
- manifest
2365
- };
2366
- }
2367
- /**
2368
2421
  * Tear down a dev symlink iff it still points at the expected source.
2369
2422
  * Refuses to remove a symlink that another `vttforge dev` session (or a
2370
2423
  * manual `ln -s`) has since redirected. That link doesn't belong to us
2371
2424
  * and removing it would silently disconnect their setup.
2425
+ *
2426
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2427
+ * for outside use, and going away in the next major.
2372
2428
  */
2373
2429
  async function cleanupDevSymlink(opts) {
2374
2430
  if (await readLinkTarget(opts.target) === opts.expectedSource) await removeLink(opts.target);
@@ -2443,6 +2499,9 @@ const PLACEHOLDER_RE = /\{\{(\w+)\}\}/g;
2443
2499
  * Unknown placeholders are passed through unchanged so partially-templated
2444
2500
  * files (e.g. a snippet that contains `{{handlebarsLikeSyntax}}` as literal
2445
2501
  * content) still scaffold without surprises.
2502
+ *
2503
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2504
+ * for outside use, and going away in the next major.
2446
2505
  */
2447
2506
  function substitute(content, vars) {
2448
2507
  const lookup = vars;
@@ -2495,6 +2554,10 @@ function rewriteDestRelPath(relPath) {
2495
2554
  if (replacement === void 0) return relPath;
2496
2555
  return relPath.slice(0, relPath.length - base.length) + replacement;
2497
2556
  }
2557
+ /**
2558
+ * @internal Implementation detail of the `vttforge` binary. Not supported for
2559
+ * outside use, and going away in the next major.
2560
+ */
2498
2561
  async function scaffold({ templateDir, destDir, vars }) {
2499
2562
  if (!existsSync(templateDir)) throw new Error(`[vttforge] template directory does not exist: ${templateDir}`);
2500
2563
  if (!(await stat(templateDir)).isDirectory()) throw new Error(`[vttforge] template path is not a directory: ${templateDir}`);
@@ -2518,6 +2581,9 @@ async function scaffold({ templateDir, destDir, vars }) {
2518
2581
  * emits `dist/scaffold.mjs`, so `import.meta.url` points there at runtime;
2519
2582
  * we walk up two segments to land at the package root, then descend into
2520
2583
  * `templates/`.
2584
+ *
2585
+ * @internal Implementation detail of the `vttforge` binary. Not supported
2586
+ * for outside use, and going away in the next major.
2521
2587
  */
2522
2588
  function templatesRoot() {
2523
2589
  const here = fileURLToPath(import.meta.url);
@@ -2793,12 +2859,26 @@ function runInstall(pm, cwd) {
2793
2859
  /**
2794
2860
  * @vttforge/cli: public library exports.
2795
2861
  *
2796
- * The CLI is intended to be used as a bin (`vttforge` command). These
2797
- * exports exist for consumers who want to programmatically invoke the
2798
- * scaffolder (e.g. from another CLI, a test harness, or a custom tool).
2862
+ * The product here is the `vttforge` binary. These exports exist so another
2863
+ * tool can drive the same work without shelling out, and they fall into three
2864
+ * groups, marked per export below.
2865
+ *
2866
+ * **Supported.** `runInit` and the audit surface. `create-vttforge` calls
2867
+ * `runInit`, and the audit rules are a documented extension point: a project
2868
+ * can write its own `RuleFn` and hand it to the same reporter the CLI uses.
2869
+ * These follow the deprecation policy.
2870
+ *
2871
+ * **`@experimental`.** Plausibly useful to a tool author, but no consumer has
2872
+ * ever asked for them, so the shape is a guess. They can change in a minor.
2873
+ *
2874
+ * **`@internal`.** Implementation detail of the binary that reached the index
2875
+ * by accident. Nothing outside this package imports them. They are staying
2876
+ * only until the next major, and importing one is not supported today.
2877
+ *
2878
+ * See apps/docs/stability.md for what each tag promises.
2799
2879
  */
2800
2880
  const VTTFORGE_CLI_VERSION = version;
2801
2881
  //#endregion
2802
- export { installCommand as A, ViteNotInstalledError as C, detectPackageManager as D, spawnViteWatch as E, SEVERITY_RANK as F, runSourceRules as I, runManifestRules as L, runAuditCommand as M, formatReport as N, detectProjectPackageManager as O, runAudit as P, emitZip as S, runViteBuildOnce as T, createLink as _, substitute as a, emitReleaseZip as b, runDev as c, configPath as d, foundryPackagesDir as f, saveConfig as g, resolveFoundryDataDir as h, scaffold as i, readManifest as j, execInvocation as k, setupDevSymlink as l, looksLikeFoundryDataDir as m, ScaffoldError as n, templatesRoot as o, loadConfig as p, runInit as r, cleanupDevSymlink as s, VTTFORGE_CLI_VERSION as t, autoDetectFoundryDataDir as u, readLinkTarget as v, resolveViteInvocation as w, runBuild as x, removeLink as y };
2882
+ export { emitReleaseZip as a, readManifest as c, runAudit as d, SEVERITY_RANK as f, runDev as i, runAuditCommand as l, runManifestRules as m, ScaffoldError as n, runBuild as o, runSourceRules as p, runInit as r, emitZip as s, VTTFORGE_CLI_VERSION as t, formatReport as u };
2803
2883
 
2804
- //# sourceMappingURL=src-4Yg6Ycyo.mjs.map
2884
+ //# sourceMappingURL=src-uGulrZd5.mjs.map