@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # @vttforge/cli
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 89b7ffa: **Breaking.** Removes 23 internal exports from the package index.
8
+
9
+ Every package here is below `1.0.0`, where a minor may break you. This one does.
10
+
11
+ The product here is the `vttforge` binary. Its index had grown to re-export the pieces the commands are built from, and 33 of 60 exports were reachable only by importing them by name. The previous release tagged them `@internal`; this one removes them.
12
+
13
+ Gone: `scaffold`, `substitute`, `templatesRoot`, `createLink`, `readLinkTarget`, `removeLink`, `setupDevSymlink`, `cleanupDevSymlink`, `resolveViteInvocation`, `runViteBuildOnce`, `spawnViteWatch`, `ViteNotInstalledError`, `detectPackageManager`, `detectProjectPackageManager`, `execInvocation`, `installCommand`, `autoDetectFoundryDataDir`, `configPath`, `foundryPackagesDir`, `looksLikeFoundryDataDir`, `resolveFoundryDataDir`, `loadConfig`, `saveConfig`, and the types that existed only for them (`ScaffoldOptions`, `ScaffoldVars`, `CreateLinkOptions`, `PackageManager`, `ResolveDataDirOptions`, `VTTForgeConfig`).
14
+
15
+ What remains is what the package is for:
16
+
17
+ - `runInit` and `ScaffoldError`, which is what `create-vttforge` calls.
18
+ - The audit surface: `runAudit`, `runManifestRules`, `runSourceRules`, `formatReport`, `SEVERITY_RANK`, and the `RuleFn` / `RuleResult` / `Severity` / `AuditReport` types. Write your own rule and hand it to the same reporter the CLI uses.
19
+ - `runDev`, `runBuild`, `emitReleaseZip`, `emitZip` and `readManifest`, still `@experimental`.
20
+
21
+ Every removed export was checked: nothing outside this package imported any of them. If one of these was your only way to do something, open an issue and it comes back as a supported export rather than a leak.
22
+
23
+ Use the `vttforge` command for everything else.
24
+
25
+ ## 0.7.1
26
+
27
+ ### Patch Changes
28
+
29
+ - 7920fa2: Say which exports are supported, which are experimental, and which are internal.
30
+
31
+ This package's product is the `vttforge` binary, and its index had grown to re-export the pieces the commands are built from. 60 exports, of which 33 were reachable only by importing them directly. Nothing outside the package imports them.
32
+
33
+ They are now tagged where they are defined, so the tag reaches the published types and your editor shows it:
34
+
35
+ - **Supported**, under the deprecation policy: `runInit` and the audit surface (`runAudit`, `runManifestRules`, `runSourceRules`, `formatReport`, and the `RuleFn` / `RuleResult` / `Severity` types). `create-vttforge` calls `runInit`, and the audit rules are a deliberate extension point.
36
+ - **`@experimental`**: plausibly useful to a tool author, but nobody has asked, so the shape is a guess. Can change in a minor.
37
+ - **`@internal`**: implementation detail (`substitute`, `templatesRoot`, `configPath`, the symlink and Vite-spawning helpers, and the rest). They keep working until the next major, and importing one is not supported today.
38
+
39
+ Nothing is removed and no signature changed. If you are importing something tagged `@internal` and it is the only way to do what you need, open an issue.
40
+
41
+ The other four packages came out clean: every export in `core`, `testing`, `vite-plugin` and `types` is reachable through the documented API.
42
+
3
43
  ## 0.7.0
4
44
 
5
45
  ### Minor Changes
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { M as runAuditCommand, c as runDev, n as ScaffoldError, r as runInit, t as VTTFORGE_CLI_VERSION, x as runBuild } from "./src-4Yg6Ycyo.mjs";
2
+ import { i as runDev, l as runAuditCommand, n as ScaffoldError, o as runBuild, r as runInit, t as VTTFORGE_CLI_VERSION } from "./src-uGulrZd5.mjs";
3
3
  import { defineCommand, runMain } from "citty";
4
4
  //#region src/cli.ts
5
5
  /**
package/dist/index.d.mts CHANGED
@@ -1,4 +1,3 @@
1
- import { ChildProcess } from "node:child_process";
2
1
  //#region src/audit/types.d.ts
3
2
  /**
4
3
  * Shared types for the `vttforge audit` rule engine.
@@ -85,6 +84,10 @@ interface AuditResult {
85
84
  /** Suggested exit code under the current strictness setting. */
86
85
  exitCode: 0 | 1;
87
86
  }
87
+ /**
88
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
89
+ * change in a minor.
90
+ */
88
91
  declare function runAuditCommand(options?: AuditOptions): Promise<AuditResult>;
89
92
  //#endregion
90
93
  //#region src/manifest.d.ts
@@ -116,6 +119,9 @@ interface FoundryManifest {
116
119
  * Throws if neither file exists, required fields are missing/non-string,
117
120
  * or the id/version contain characters that would let downstream `join()`
118
121
  * calls escape their intended directory.
122
+ *
123
+ * @experimental Shape is unproven: no consumer has asked for this yet.
124
+ * It can change in a minor.
119
125
  */
120
126
  declare function readManifest(distDir: string): Promise<FoundryManifest>;
121
127
  //#endregion
@@ -127,6 +133,9 @@ interface BuildOptions {
127
133
  /**
128
134
  * Internal building block exposed for tests: assumes dist/ is already
129
135
  * populated (vite has run, manifest is present) and just emits the zip.
136
+ *
137
+ * @experimental Shape is unproven: no consumer has asked for this yet.
138
+ * It can change in a minor.
130
139
  */
131
140
  declare function emitReleaseZip(opts: {
132
141
  cwd: string;
@@ -135,6 +144,10 @@ declare function emitReleaseZip(opts: {
135
144
  byteSize: number;
136
145
  manifest: FoundryManifest;
137
146
  }>;
147
+ /**
148
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
149
+ * change in a minor.
150
+ */
138
151
  declare function runBuild(options?: BuildOptions): Promise<void>;
139
152
  //#endregion
140
153
  //#region src/commands/dev.d.ts
@@ -146,32 +159,11 @@ interface DevOptions {
146
159
  /** Port for the hot reload bridge. */
147
160
  hmrPort?: number;
148
161
  }
149
- declare function runDev(options?: DevOptions): Promise<void>;
150
162
  /**
151
- * Internal building block exposed for tests: given an already-built `dist/`
152
- * (vite has run, manifest is present) and a resolved Foundry data dir,
153
- * create the symlink and return the target path + manifest. Skips the
154
- * vite spawn and the signal-loop, so tests can drive the orchestration
155
- * deterministically.
163
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
164
+ * change in a minor.
156
165
  */
157
- declare function setupDevSymlink(opts: {
158
- cwd: string;
159
- dataRoot: string;
160
- }): Promise<{
161
- target: string;
162
- manifest: Awaited<ReturnType<typeof readManifest>>;
163
- childProcess?: ChildProcess;
164
- }>;
165
- /**
166
- * Tear down a dev symlink iff it still points at the expected source.
167
- * Refuses to remove a symlink that another `vttforge dev` session (or a
168
- * manual `ln -s`) has since redirected. That link doesn't belong to us
169
- * and removing it would silently disconnect their setup.
170
- */
171
- declare function cleanupDevSymlink(opts: {
172
- target: string;
173
- expectedSource: string;
174
- }): Promise<void>;
166
+ declare function runDev(options?: DevOptions): Promise<void>;
175
167
  //#endregion
176
168
  //#region src/commands/init.d.ts
177
169
  /**
@@ -232,229 +224,6 @@ declare class ScaffoldError extends Error {
232
224
  }
233
225
  declare function runInit(options?: InitOptions): Promise<void>;
234
226
  //#endregion
235
- //#region src/foundry-data-dir.d.ts
236
- /**
237
- * Foundry user-data directory discovery + persistence.
238
- *
239
- * Foundry stores worlds, systems, and modules under a single user-data
240
- * directory (`Data/` lives at its root). `vttforge dev` needs to know where
241
- * that is so it can symlink the built `dist/` into `Data/systems/<id>/` or
242
- * `Data/modules/<id>/` and let Foundry pick it up.
243
- *
244
- * Precedence (top wins):
245
- * 1. Explicit `--data-dir` flag passed to the command
246
- * 2. `FOUNDRY_DATA_DIR` env var (useful in Docker/CI)
247
- * 3. `<project>/.vttforge/config.json :: foundryDataDir`
248
- * 4. OS default + interactive prompt that saves to (3) for next time
249
- *
250
- * The OS-default detection treats `XDG_DATA_HOME` (Linux) and `%LOCALAPPDATA%`
251
- * (Windows) as part of the OS convention, not as Foundry-specific overrides.
252
- *
253
- * Everything here is pure: `platform`, `env`, and `home` flow through
254
- * options so tests can drive every branch without monkey-patching globals.
255
- */
256
- /** Shape persisted to `<project>/.vttforge/config.json`. */
257
- interface VTTForgeConfig {
258
- foundryDataDir?: string;
259
- }
260
- /**
261
- * Return the OS-default Foundry user-data directory, or `null` on unknown
262
- * platforms / missing platform-specific env vars. Does NOT check existence;
263
- * callers prompt the user when the suggested path doesn't resolve.
264
- */
265
- declare function autoDetectFoundryDataDir(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv, home?: string): string | null;
266
- /**
267
- * Heuristic: a path looks like a Foundry user-data root if it contains a
268
- * `Data/` subdirectory (canonical Foundry layout) OR if it already contains
269
- * `systems/` or `modules/` (the path is already the Data folder itself).
270
- */
271
- declare function looksLikeFoundryDataDir(path: string): boolean;
272
- /** Absolute path to the project-local config file (whether or not it exists). */
273
- declare function configPath(cwd: string): string;
274
- /** Load `<cwd>/.vttforge/config.json` if it exists and is valid JSON. */
275
- declare function loadConfig(cwd: string): Promise<VTTForgeConfig | null>;
276
- /** Persist `<cwd>/.vttforge/config.json`. Creates the `.vttforge/` dir as needed. */
277
- declare function saveConfig(cwd: string, config: VTTForgeConfig): Promise<void>;
278
- /**
279
- * Resolve the packages directory (`Data/systems/` or `Data/modules/`) under
280
- * the given Foundry user-data root. Accepts the path Foundry itself runs
281
- * with (the user-data folder, which contains `Data/`) OR the `Data/` folder
282
- * directly; both are common in muscle memory.
283
- *
284
- * The returned path is not guaranteed to exist yet; callers `mkdir -p` it
285
- * before creating the symlink.
286
- */
287
- declare function foundryPackagesDir(dataRoot: string, type: 'system' | 'module'): string;
288
- interface ResolveDataDirOptions {
289
- /** Project root: also where `.vttforge/config.json` is read/written. */
290
- cwd: string;
291
- /** `--data-dir` flag value. Skips persistence and prompting when present. */
292
- override?: string;
293
- /**
294
- * Interactive prompt for the first run. Receives the OS-default path
295
- * (may be `null` on unknown platforms) and resolves with the chosen path,
296
- * or `null` if the user cancelled. When undefined, the function refuses
297
- * to ask and throws, appropriate for non-TTY contexts (CI, scripts).
298
- */
299
- prompt?: (autoDetected: string | null) => Promise<string | null>;
300
- /** Override `process.platform` (tests). */
301
- platform?: NodeJS.Platform;
302
- /** Override `process.env` (tests). */
303
- env?: NodeJS.ProcessEnv;
304
- /** Override `os.homedir()` (tests). */
305
- home?: string;
306
- }
307
- /**
308
- * Walk the precedence chain and return the chosen Foundry user-data path.
309
- * Saves the user's choice to the project config on first interactive run so
310
- * subsequent invocations skip the prompt.
311
- */
312
- declare function resolveFoundryDataDir(opts: ResolveDataDirOptions): Promise<string>;
313
- //#endregion
314
- //#region src/package-manager.d.ts
315
- /**
316
- * Detect which package manager invoked the CLI so we can run the right
317
- * `install` command after scaffolding.
318
- *
319
- * Strategy: read `npm_config_user_agent`, which pnpm/npm/bun/yarn all set when
320
- * they spawn a child process (including `pnpm dlx`, `pnpm create`, etc.).
321
- * Falls back to `pnpm` because that's the VTTForge house default and the
322
- * most common Foundry-developer choice, but any concrete signal in the
323
- * environment wins over the default.
324
- */
325
- type PackageManager = 'pnpm' | 'npm' | 'bun' | 'yarn';
326
- declare function detectPackageManager(env?: NodeJS.ProcessEnv): PackageManager;
327
- declare function installCommand(pm: PackageManager): string;
328
- /**
329
- * Detect a project's package manager by looking at which lockfile it
330
- * ships. `dev` and `build` need this: by the time the user runs
331
- * `vttforge dev`, npm_config_user_agent reflects whatever shell launched
332
- * the binary (often nothing in a global install), not how the project
333
- * was bootstrapped. The lockfile is the project's own contract.
334
- *
335
- * Falls back to {@link detectPackageManager} for fresh checkouts that
336
- * haven't been installed yet.
337
- */
338
- declare function detectProjectPackageManager(cwd: string, env?: NodeJS.ProcessEnv): PackageManager;
339
- /**
340
- * Argument vector to invoke `vite` (or any other locally-installed CLI)
341
- * via the project's package manager. We always shell out through `<pm>
342
- * exec` so the call works regardless of the linker's choices. Yarn 4
343
- * Plug'n'Play, pnpm's symlinked layout, npm's flattened node_modules,
344
- * Bun's symlinked node_modules. Each manager exposes a uniform "run a
345
- * locally-resolved binary in the project's dependency graph" command.
346
- */
347
- declare function execInvocation(pm: PackageManager, bin: string): [string, string[]];
348
- //#endregion
349
- //#region src/scaffold.d.ts
350
- /**
351
- * Template copy with `{{var}}` placeholder substitution.
352
- *
353
- * Templates live under `packages/cli/templates/<variant>/` and are shipped
354
- * inside the published tarball (see the `files` array in package.json).
355
- * Each file is read, substituted, and written to the destination directory
356
- * preserving the relative path. Directories are created lazily on first
357
- * write.
358
- *
359
- * We intentionally avoid Handlebars or any other template engine. The
360
- * substitution surface is small (a flat string-to-string map), and bundling
361
- * a dependency for ten lines of regex would be wasteful in a tool whose
362
- * value is being fast to invoke.
363
- */
364
- interface ScaffoldVars {
365
- ID: string;
366
- TITLE: string;
367
- DESCRIPTION: string;
368
- AUTHOR: string;
369
- LICENSE: string;
370
- FOUNDRY_MIN_VERSION: string;
371
- FOUNDRY_VERIFIED_VERSION: string;
372
- LOCALE_PREFIX: string;
373
- YEAR: string;
374
- }
375
- interface ScaffoldOptions {
376
- /** Absolute path to the template root (e.g. `<cli-pkg>/templates/system-ts`). */
377
- templateDir: string;
378
- /** Absolute path to the destination directory. Created if it doesn't exist. */
379
- destDir: string;
380
- /** Variables to substitute into `{{NAME}}` placeholders inside template files. */
381
- vars: ScaffoldVars;
382
- }
383
- /**
384
- * Replace `{{NAME}}` placeholders in `content` using the `vars` map.
385
- * Unknown placeholders are passed through unchanged so partially-templated
386
- * files (e.g. a snippet that contains `{{handlebarsLikeSyntax}}` as literal
387
- * content) still scaffold without surprises.
388
- */
389
- declare function substitute(content: string, vars: ScaffoldVars): string;
390
- declare function scaffold({ templateDir, destDir, vars }: ScaffoldOptions): Promise<void>;
391
- /**
392
- * Resolve the templates directory relative to this module's file URL. tsdown
393
- * emits `dist/scaffold.mjs`, so `import.meta.url` points there at runtime;
394
- * we walk up two segments to land at the package root, then descend into
395
- * `templates/`.
396
- */
397
- declare function templatesRoot(): string;
398
- //#endregion
399
- //#region src/symlink.d.ts
400
- /**
401
- * Cross-platform symlink helpers for `vttforge dev`.
402
- *
403
- * The dev loop drops a symlink from Foundry's `Data/<systems|modules>/<id>/`
404
- * back to the project's `dist/` so Foundry serves freshly-built files as
405
- * vite writes them. The win32 path matters: with `type: 'junction'` the
406
- * operation works on standard Windows shells without Developer Mode, while
407
- * `type: 'dir'` requires admin. We never silently fall back to copying;
408
- * Foundry's HMR relies on live file mutation, and a copy snapshot defeats
409
- * the loop. If the symlink fails, we surface the platform-specific fix.
410
- */
411
- interface CreateLinkOptions {
412
- /**
413
- * Overwrite an existing symlink that points elsewhere. Real files and
414
- * directories are never overwritten; that path needs explicit user
415
- * action outside the tool.
416
- */
417
- overwrite?: boolean;
418
- }
419
- /**
420
- * Read a symlink target. Returns the absolute path the link points at, or
421
- * `null` if `path` doesn't exist or isn't a symlink. Relative symlink
422
- * targets are resolved against the link's own directory (matches the
423
- * semantics callers expect when comparing to a known absolute source).
424
- */
425
- declare function readLinkTarget(path: string): Promise<string | null>;
426
- /**
427
- * Create a symlink at `target` pointing to `source`. Win32 uses `'junction'`
428
- * so the call succeeds without elevation; everywhere else uses `'dir'`.
429
- *
430
- * Idempotency:
431
- * - target already points to source → no-op
432
- * - target points elsewhere → throws unless `options.overwrite`
433
- * - target is a real file/dir → throws unconditionally
434
- */
435
- declare function createLink(target: string, source: string, options?: CreateLinkOptions): Promise<void>;
436
- /**
437
- * Remove a symlink at `path`. No-ops when the path doesn't exist. Throws
438
- * when the path exists but isn't a symlink; we never unlink real files
439
- * or directories.
440
- */
441
- declare function removeLink(path: string): Promise<void>;
442
- //#endregion
443
- //#region src/vite-runner.d.ts
444
- declare class ViteNotInstalledError extends Error {
445
- constructor(message: string);
446
- }
447
- /** Spawn args for invoking the user's vite (e.g. `["pnpm", ["exec", "vite"]]`). */
448
- declare function resolveViteInvocation(cwd: string): [string, string[]];
449
- /** Run `vite build` once and wait for it to exit. Throws on non-zero exit. */
450
- declare function runViteBuildOnce(cwd: string): Promise<void>;
451
- /**
452
- * Spawn `vite build --watch` and return the child process. The caller is
453
- * responsible for waiting on it and tearing it down (the dev command kills
454
- * it on SIGINT).
455
- */
456
- declare function spawnViteWatch(cwd: string): ChildProcess;
457
- //#endregion
458
227
  //#region src/zip.d.ts
459
228
  /**
460
229
  * Emit a foundryvtt.com-compatible release zip.
@@ -482,10 +251,14 @@ interface EmitZipResult {
482
251
  outFile: string;
483
252
  byteSize: number;
484
253
  }
254
+ /**
255
+ * @experimental Shape is unproven: no consumer has asked for this yet. It can
256
+ * change in a minor.
257
+ */
485
258
  declare function emitZip(opts: EmitZipOptions): Promise<EmitZipResult>;
486
259
  //#endregion
487
260
  //#region src/index.d.ts
488
261
  declare const VTTFORGE_CLI_VERSION: string;
489
262
  //#endregion
490
- export { type AuditOptions, type AuditReport, type AuditResult, type BuildOptions, type CreateLinkOptions, type DevOptions, type EmitZipOptions, type EmitZipResult, type FoundryManifest, type InitOptions, type PackageManager, type PackageType, type ReportFormat, type ResolveDataDirOptions, type ResolvedInitOptions, type RuleFn, type RuleResult, type RunAuditOptions, SEVERITY_RANK, ScaffoldError, type ScaffoldOptions, type ScaffoldVars, type Severity, type TemplateVariant, VTTFORGE_CLI_VERSION, type VTTForgeConfig, ViteNotInstalledError, autoDetectFoundryDataDir, cleanupDevSymlink, configPath, createLink, detectPackageManager, detectProjectPackageManager, emitReleaseZip, emitZip, execInvocation, formatReport, foundryPackagesDir, installCommand, loadConfig, looksLikeFoundryDataDir, readLinkTarget, readManifest, removeLink, resolveFoundryDataDir, resolveViteInvocation, runAudit, runAuditCommand, runBuild, runDev, runInit, runManifestRules, runSourceRules, runViteBuildOnce, saveConfig, scaffold, setupDevSymlink, spawnViteWatch, substitute, templatesRoot };
263
+ export { type AuditOptions, type AuditReport, type AuditResult, type BuildOptions, type DevOptions, type EmitZipOptions, type EmitZipResult, type FoundryManifest, type InitOptions, type PackageType, type ReportFormat, type ResolvedInitOptions, type RuleFn, type RuleResult, type RunAuditOptions, SEVERITY_RANK, ScaffoldError, type Severity, type TemplateVariant, VTTFORGE_CLI_VERSION, emitReleaseZip, emitZip, formatReport, readManifest, runAudit, runAuditCommand, runBuild, runDev, runInit, runManifestRules, runSourceRules };
491
264
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { A as installCommand, C as ViteNotInstalledError, D as detectPackageManager, E as spawnViteWatch, F as SEVERITY_RANK, I as runSourceRules, L as runManifestRules, M as runAuditCommand, N as formatReport, O as detectProjectPackageManager, P as runAudit, S as emitZip, T as runViteBuildOnce, _ as createLink, a as substitute, b as emitReleaseZip, c as runDev, d as configPath, f as foundryPackagesDir, g as saveConfig, h as resolveFoundryDataDir, i as scaffold, j as readManifest, k as execInvocation, l as setupDevSymlink, m as looksLikeFoundryDataDir, n as ScaffoldError, o as templatesRoot, p as loadConfig, r as runInit, s as cleanupDevSymlink, t as VTTFORGE_CLI_VERSION, u as autoDetectFoundryDataDir, v as readLinkTarget, w as resolveViteInvocation, x as runBuild, y as removeLink } from "./src-4Yg6Ycyo.mjs";
2
- export { SEVERITY_RANK, ScaffoldError, VTTFORGE_CLI_VERSION, ViteNotInstalledError, autoDetectFoundryDataDir, cleanupDevSymlink, configPath, createLink, detectPackageManager, detectProjectPackageManager, emitReleaseZip, emitZip, execInvocation, formatReport, foundryPackagesDir, installCommand, loadConfig, looksLikeFoundryDataDir, readLinkTarget, readManifest, removeLink, resolveFoundryDataDir, resolveViteInvocation, runAudit, runAuditCommand, runBuild, runDev, runInit, runManifestRules, runSourceRules, runViteBuildOnce, saveConfig, scaffold, setupDevSymlink, spawnViteWatch, substitute, templatesRoot };
1
+ import { a as emitReleaseZip, c as readManifest, d as runAudit, f as SEVERITY_RANK, i as runDev, l as runAuditCommand, m as runManifestRules, n as ScaffoldError, o as runBuild, p as runSourceRules, r as runInit, s as emitZip, t as VTTFORGE_CLI_VERSION, u as formatReport } from "./src-uGulrZd5.mjs";
2
+ export { SEVERITY_RANK, ScaffoldError, VTTFORGE_CLI_VERSION, emitReleaseZip, emitZip, formatReport, readManifest, runAudit, runAuditCommand, runBuild, runDev, runInit, runManifestRules, runSourceRules };