@vttforge/cli 0.16.0 → 0.17.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 +30 -0
- package/dist/bin.mjs +75 -6
- package/dist/bin.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-DK2hXzBk.mjs → src-GF89Qav8.mjs} +8 -4
- package/dist/{src-DK2hXzBk.mjs.map → src-GF89Qav8.mjs.map} +1 -1
- package/package.json +1 -1
- package/templates/module-js/package.json +1 -1
- package/templates/module-ts/package.json +1 -1
- package/templates/system-js/package.json +1 -1
- package/templates/system-ts/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @vttforge/cli
|
|
2
2
|
|
|
3
|
+
## 0.17.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- eb61b51: A call that used to succeed now exits 1. `vttforge init` refuses a flag it
|
|
8
|
+
does not know and a value it does not accept, instead of carrying on. A script
|
|
9
|
+
or a CI job passing either one starts failing on upgrade, which is the point:
|
|
10
|
+
it was not doing what it asked for.
|
|
11
|
+
|
|
12
|
+
Two ways to lose. An unknown flag was collected and ignored, so
|
|
13
|
+
`vttforge init app --template module-ts` exited 0 and scaffolded a system: the
|
|
14
|
+
flag does not exist, and nothing said so. A known flag with an unrecognised
|
|
15
|
+
value fell back to the default, so `--type modul` also produced a system, with
|
|
16
|
+
`system.json` and every system template file in it. Both surface much later,
|
|
17
|
+
usually in Foundry.
|
|
18
|
+
|
|
19
|
+
`--type` and `--lang` now list what they take, in the error and in `--help`.
|
|
20
|
+
An unknown flag names itself and the command's real flags. Both exit 1 and
|
|
21
|
+
write nothing. Every command carries the unknown-flag check, not only `init`.
|
|
22
|
+
|
|
23
|
+
`vttforge migrate` had the same fallback on `--style` and `--lang`, where a
|
|
24
|
+
typo wrote the wrong kind of file. Both are checked now too.
|
|
25
|
+
|
|
26
|
+
`create-vttforge` does the same. It used to skip unknown flags on purpose, to
|
|
27
|
+
keep the create flow from crashing; the cost was a scaffold that silently
|
|
28
|
+
ignored what was asked for.
|
|
29
|
+
|
|
30
|
+
The project templates pin `@vttforge/cli` by minor, so they move to the
|
|
31
|
+
release that carries this.
|
|
32
|
+
|
|
3
33
|
## 0.16.0
|
|
4
34
|
|
|
5
35
|
### Minor Changes
|
package/dist/bin.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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-
|
|
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-GF89Qav8.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";
|
|
6
|
-
import { defineCommand, runMain } from "citty";
|
|
6
|
+
import { defineCittyPlugin, defineCommand, runMain } from "citty";
|
|
7
7
|
import { parse } from "@babel/parser";
|
|
8
8
|
//#region src/migrate/data-models.ts
|
|
9
9
|
const RICH_TEXT_KEYS = /^(description|biography|bio|notes|details)$/i;
|
|
@@ -2514,6 +2514,65 @@ async function runMigrateCommand(options = {}) {
|
|
|
2514
2514
|
};
|
|
2515
2515
|
}
|
|
2516
2516
|
//#endregion
|
|
2517
|
+
//#region src/strict-args.ts
|
|
2518
|
+
/**
|
|
2519
|
+
* Refuse a flag the command does not define.
|
|
2520
|
+
*
|
|
2521
|
+
* The argument parser collects anything that looks like a flag, whether or
|
|
2522
|
+
* not the command declared it, and hands the whole lot to `run`. A command
|
|
2523
|
+
* reads the keys it knows and never looks at the rest, so a typo does
|
|
2524
|
+
* nothing and says nothing: `vttforge init app --typ module` scaffolds a
|
|
2525
|
+
* system, exit code 0. The user finds out much later, usually from Foundry.
|
|
2526
|
+
*
|
|
2527
|
+
* This plugin runs before the command and stops on the first unknown flag.
|
|
2528
|
+
*/
|
|
2529
|
+
/**
|
|
2530
|
+
* One spelling of a flag name, for comparison.
|
|
2531
|
+
*
|
|
2532
|
+
* The parser answers to a flag under several keys: the declared name, its
|
|
2533
|
+
* aliases, and the camelCase and kebab-case forms of each. Folding case and
|
|
2534
|
+
* dropping the dashes covers all of them with one rule. It accepts a few
|
|
2535
|
+
* spellings the parser would not produce on its own, which is the safe
|
|
2536
|
+
* direction to be loose in: this check can then never reject a flag the
|
|
2537
|
+
* command really does define.
|
|
2538
|
+
*/
|
|
2539
|
+
function fold(name) {
|
|
2540
|
+
return name.toLowerCase().replaceAll("-", "");
|
|
2541
|
+
}
|
|
2542
|
+
function acceptedNames(argsDef) {
|
|
2543
|
+
const accepted = /* @__PURE__ */ new Set();
|
|
2544
|
+
for (const [name, def] of Object.entries(argsDef)) {
|
|
2545
|
+
accepted.add(fold(name));
|
|
2546
|
+
const alias = def.alias;
|
|
2547
|
+
for (const entry of Array.isArray(alias) ? alias : alias ? [alias] : []) accepted.add(fold(entry));
|
|
2548
|
+
}
|
|
2549
|
+
return accepted;
|
|
2550
|
+
}
|
|
2551
|
+
/** The flags passed that the command does not define, in the order given. */
|
|
2552
|
+
function unknownArgs(args, argsDef) {
|
|
2553
|
+
const accepted = acceptedNames(argsDef);
|
|
2554
|
+
return Object.keys(args).filter((key) => key !== "_" && !accepted.has(fold(key)));
|
|
2555
|
+
}
|
|
2556
|
+
/**
|
|
2557
|
+
* Add to a command's `plugins`. It has to go on each command rather than on
|
|
2558
|
+
* the root: a subcommand runs through its own plugin list, not its parent's.
|
|
2559
|
+
*/
|
|
2560
|
+
const strictArgs = defineCittyPlugin({
|
|
2561
|
+
name: "vttforge:strict-args",
|
|
2562
|
+
setup({ args, cmd }) {
|
|
2563
|
+
const argsDef = typeof cmd.args === "object" && cmd.args !== null ? cmd.args : {};
|
|
2564
|
+
const unknown = unknownArgs(args, argsDef);
|
|
2565
|
+
if (unknown.length === 0) return;
|
|
2566
|
+
const named = unknown.map((flag) => `--${flag}`).join(", ");
|
|
2567
|
+
const known = Object.keys(argsDef).filter((name) => argsDef[name].type !== "positional").map((name) => `--${name}`).join(", ");
|
|
2568
|
+
const meta = cmd.meta;
|
|
2569
|
+
const label = meta?.name ? ` ${meta.name}` : "";
|
|
2570
|
+
console.error(`Unknown ${unknown.length === 1 ? "flag" : "flags"} for \`vttforge${label}\`: ${named}.`);
|
|
2571
|
+
console.error(`This command takes: ${known}.`);
|
|
2572
|
+
process.exit(1);
|
|
2573
|
+
}
|
|
2574
|
+
});
|
|
2575
|
+
//#endregion
|
|
2517
2576
|
//#region src/cli.ts
|
|
2518
2577
|
/**
|
|
2519
2578
|
* vttforge command tree.
|
|
@@ -2525,6 +2584,7 @@ async function runMigrateCommand(options = {}) {
|
|
|
2525
2584
|
* lets the suite parse real argv against the real definitions.
|
|
2526
2585
|
*/
|
|
2527
2586
|
const init = defineCommand({
|
|
2587
|
+
plugins: [strictArgs],
|
|
2528
2588
|
meta: {
|
|
2529
2589
|
name: "init",
|
|
2530
2590
|
description: "Scaffold a new Foundry VTT system or module from a VTTForge template"
|
|
@@ -2536,11 +2596,13 @@ const init = defineCommand({
|
|
|
2536
2596
|
required: false
|
|
2537
2597
|
},
|
|
2538
2598
|
type: {
|
|
2539
|
-
type: "
|
|
2599
|
+
type: "enum",
|
|
2600
|
+
options: ["system", "module"],
|
|
2540
2601
|
description: "Package type: system | module"
|
|
2541
2602
|
},
|
|
2542
2603
|
lang: {
|
|
2543
|
-
type: "
|
|
2604
|
+
type: "enum",
|
|
2605
|
+
options: ["ts", "js"],
|
|
2544
2606
|
description: "Language: ts | js"
|
|
2545
2607
|
},
|
|
2546
2608
|
id: {
|
|
@@ -2602,6 +2664,7 @@ const init = defineCommand({
|
|
|
2602
2664
|
}
|
|
2603
2665
|
});
|
|
2604
2666
|
const dev = defineCommand({
|
|
2667
|
+
plugins: [strictArgs],
|
|
2605
2668
|
meta: {
|
|
2606
2669
|
name: "dev",
|
|
2607
2670
|
description: "Symlink dist/ into Foundry Data and run vite build --watch"
|
|
@@ -2637,6 +2700,7 @@ const dev = defineCommand({
|
|
|
2637
2700
|
}
|
|
2638
2701
|
});
|
|
2639
2702
|
const build = defineCommand({
|
|
2703
|
+
plugins: [strictArgs],
|
|
2640
2704
|
meta: {
|
|
2641
2705
|
name: "build",
|
|
2642
2706
|
description: "Run vite build (production) and emit <id>-<version>.zip for foundryvtt.com"
|
|
@@ -2651,6 +2715,7 @@ const build = defineCommand({
|
|
|
2651
2715
|
}
|
|
2652
2716
|
});
|
|
2653
2717
|
const lint = defineCommand({
|
|
2718
|
+
plugins: [strictArgs],
|
|
2654
2719
|
meta: {
|
|
2655
2720
|
name: "lint",
|
|
2656
2721
|
description: "Run Biome (shipped with the CLI) over the project, then the v14 audit"
|
|
@@ -2693,6 +2758,7 @@ const lint = defineCommand({
|
|
|
2693
2758
|
}
|
|
2694
2759
|
});
|
|
2695
2760
|
const audit = defineCommand({
|
|
2761
|
+
plugins: [strictArgs],
|
|
2696
2762
|
meta: {
|
|
2697
2763
|
name: "audit",
|
|
2698
2764
|
description: "Scan a system/module project for the v14 manifest, source and template breakages that fail quietly"
|
|
@@ -2729,6 +2795,7 @@ const audit = defineCommand({
|
|
|
2729
2795
|
}
|
|
2730
2796
|
});
|
|
2731
2797
|
const migrate = defineCommand({
|
|
2798
|
+
plugins: [strictArgs],
|
|
2732
2799
|
meta: {
|
|
2733
2800
|
name: "migrate",
|
|
2734
2801
|
description: "Rewrite a v13 system or module for Foundry v14 (preview by default); --data-models and --sheets write the v16 replacements"
|
|
@@ -2760,12 +2827,14 @@ const migrate = defineCommand({
|
|
|
2760
2827
|
description: "Also generate a data model per template.json type (template.json is deprecated since v14)"
|
|
2761
2828
|
},
|
|
2762
2829
|
style: {
|
|
2763
|
-
type: "
|
|
2830
|
+
type: "enum",
|
|
2831
|
+
options: ["plain", "sdk"],
|
|
2764
2832
|
default: "plain",
|
|
2765
2833
|
description: "For --data-models: \"plain\" Foundry classes, or \"sdk\" classes on @vttforge/core"
|
|
2766
2834
|
},
|
|
2767
2835
|
lang: {
|
|
2768
|
-
type: "
|
|
2836
|
+
type: "enum",
|
|
2837
|
+
options: ["js", "ts"],
|
|
2769
2838
|
default: "js",
|
|
2770
2839
|
description: "For --data-models and --sheets: \"js\" writes .mjs, \"ts\" writes .ts"
|
|
2771
2840
|
},
|