@vttforge/cli 0.11.0 → 0.12.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 +6 -0
- package/README.md +4 -1
- package/dist/bin.mjs +45 -2
- package/dist/bin.mjs.map +1 -1
- package/dist/index.d.mts +44 -1
- package/dist/index.mjs +2 -2
- package/dist/{src-CgS7GUiL.mjs → src-CzzrhCN-.mjs} +108 -3
- package/dist/src-CzzrhCN-.mjs.map +1 -0
- package/lint/vttforge-biome.json +85 -0
- package/package.json +4 -2
- package/templates/module-js/README.md +3 -1
- package/templates/module-js/package.json +4 -2
- package/templates/module-ts/README.md +3 -1
- package/templates/module-ts/package.json +3 -1
- package/templates/module-ts/scripts/enricher.ts +3 -1
- package/templates/module-ts/tsconfig.json +2 -7
- package/templates/system-js/README.md +3 -1
- package/templates/system-js/package.json +4 -2
- package/templates/system-js/scripts/data/character-data.mjs +28 -4
- package/templates/system-js/scripts/sheets/character-sheet.mjs +3 -1
- package/templates/system-js/scripts/sheets/gear-sheet.mjs +5 -4
- package/templates/system-ts/README.md +3 -1
- package/templates/system-ts/package.json +3 -1
- package/templates/system-ts/scripts/data/character-data.ts +28 -4
- package/templates/system-ts/scripts/sheets/character-sheet.ts +13 -3
- package/templates/system-ts/scripts/sheets/gear-sheet.ts +5 -4
- package/dist/src-CgS7GUiL.mjs.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
import { createWriteStream, existsSync, readFileSync, readdirSync, statSync, watch } from "node:fs";
|
|
2
3
|
import { basename, dirname, extname, join, posix, relative, resolve, sep } from "node:path";
|
|
3
4
|
import { lstat, mkdir, readFile, readdir, readlink, rm, stat, symlink, unlink, writeFile } from "node:fs/promises";
|
|
@@ -10,7 +11,7 @@ import { createServer } from "node:http";
|
|
|
10
11
|
import { homedir } from "node:os";
|
|
11
12
|
import { promisify } from "node:util";
|
|
12
13
|
//#region package.json
|
|
13
|
-
var version = "0.
|
|
14
|
+
var version = "0.12.0";
|
|
14
15
|
//#endregion
|
|
15
16
|
//#region src/audit/manifest-rules.ts
|
|
16
17
|
/**
|
|
@@ -3362,6 +3363,110 @@ function runInstall(pm, cwd) {
|
|
|
3362
3363
|
});
|
|
3363
3364
|
}
|
|
3364
3365
|
//#endregion
|
|
3366
|
+
//#region src/commands/lint.ts
|
|
3367
|
+
/**
|
|
3368
|
+
* `vttforge lint`: Biome over the project, then the v14 audit.
|
|
3369
|
+
*
|
|
3370
|
+
* Biome ships as a dependency of this package, so a scaffolded project has
|
|
3371
|
+
* a linter and a formatter without installing or configuring one. The
|
|
3372
|
+
* config it runs with is `<cli-pkg>/lint/vttforge-biome.json` unless the project
|
|
3373
|
+
* has its own `biome.json` / `biome.jsonc` at its root, in which case that
|
|
3374
|
+
* one wins and the shipped config is not read at all. A project that wants
|
|
3375
|
+
* to tweak a rule copies the shipped file and edits it.
|
|
3376
|
+
*
|
|
3377
|
+
* `--fix` writes the safe fixes and formats the files; without it the run
|
|
3378
|
+
* only reports. The audit runs after Biome either way (`--no-audit` skips
|
|
3379
|
+
* it), and the exit code is non-zero when either half fails.
|
|
3380
|
+
*/
|
|
3381
|
+
var BiomeNotFoundError = class extends Error {
|
|
3382
|
+
constructor(message) {
|
|
3383
|
+
super(message);
|
|
3384
|
+
this.name = "BiomeNotFoundError";
|
|
3385
|
+
}
|
|
3386
|
+
};
|
|
3387
|
+
/**
|
|
3388
|
+
* The Biome config shipped with the CLI, resolved from the built module.
|
|
3389
|
+
*
|
|
3390
|
+
* The file is not named `biome.json` on purpose: Biome treats a file with
|
|
3391
|
+
* that name as a nested root config and refuses to run, which would break
|
|
3392
|
+
* a project (or this monorepo) that holds the CLI inside another
|
|
3393
|
+
* Biome-rooted tree. `--config-path` accepts any file path.
|
|
3394
|
+
*/
|
|
3395
|
+
const SHIPPED_CONFIG_NAME = "vttforge-biome.json";
|
|
3396
|
+
function shippedConfig() {
|
|
3397
|
+
const here = fileURLToPath(import.meta.url);
|
|
3398
|
+
const fromDist = resolve(here, "..", "..", "lint", SHIPPED_CONFIG_NAME);
|
|
3399
|
+
if (existsSync(fromDist)) return fromDist;
|
|
3400
|
+
return resolve(here, "..", "..", "..", "lint", SHIPPED_CONFIG_NAME);
|
|
3401
|
+
}
|
|
3402
|
+
/** The project's own config wins when it has one. */
|
|
3403
|
+
function projectConfig(cwd) {
|
|
3404
|
+
for (const name of ["biome.json", "biome.jsonc"]) {
|
|
3405
|
+
const file = join(cwd, name);
|
|
3406
|
+
if (existsSync(file)) return file;
|
|
3407
|
+
}
|
|
3408
|
+
return null;
|
|
3409
|
+
}
|
|
3410
|
+
/** The Biome bin shim, resolved from this package's own dependency graph. */
|
|
3411
|
+
function biomeBin() {
|
|
3412
|
+
const require = createRequire(import.meta.url);
|
|
3413
|
+
try {
|
|
3414
|
+
return require.resolve("@biomejs/biome/bin/biome");
|
|
3415
|
+
} catch {
|
|
3416
|
+
throw new BiomeNotFoundError("Could not resolve @biomejs/biome from @vttforge/cli. Reinstall the CLI (it ships Biome as a dependency).");
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
/** The argv for Biome: `ci .` to report, `check --write .` to fix. */
|
|
3420
|
+
function biomeArgs(opts) {
|
|
3421
|
+
const args = opts.fix ? [
|
|
3422
|
+
"check",
|
|
3423
|
+
"--write",
|
|
3424
|
+
"."
|
|
3425
|
+
] : ["ci", "."];
|
|
3426
|
+
if (opts.configPath) args.push(`--config-path=${opts.configPath}`);
|
|
3427
|
+
return args;
|
|
3428
|
+
}
|
|
3429
|
+
function runBiome(cwd, args) {
|
|
3430
|
+
const bin = biomeBin();
|
|
3431
|
+
return new Promise((resolveRun, rejectRun) => {
|
|
3432
|
+
const child = spawn(process.execPath, [bin, ...args], {
|
|
3433
|
+
cwd,
|
|
3434
|
+
stdio: "inherit",
|
|
3435
|
+
env: process.env,
|
|
3436
|
+
shell: false
|
|
3437
|
+
});
|
|
3438
|
+
child.on("error", rejectRun);
|
|
3439
|
+
child.on("exit", (code) => resolveRun(code ?? 1));
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
/**
|
|
3443
|
+
* @experimental Shape is unproven: no consumer has asked for this yet. It can
|
|
3444
|
+
* change in a minor.
|
|
3445
|
+
*/
|
|
3446
|
+
async function runLintCommand(options = {}) {
|
|
3447
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
3448
|
+
const fix = options.fix === true;
|
|
3449
|
+
const audit = options.audit !== false;
|
|
3450
|
+
if (!existsSync(join(cwd, "package.json"))) throw new Error(`No package.json found at ${cwd}. Run \`vttforge lint\` from inside a scaffolded project.`);
|
|
3451
|
+
const configPath = projectConfig(cwd) === null ? shippedConfig() : null;
|
|
3452
|
+
const biomeExitCode = await runBiome(cwd, biomeArgs({
|
|
3453
|
+
fix,
|
|
3454
|
+
configPath
|
|
3455
|
+
}));
|
|
3456
|
+
let auditExitCode = null;
|
|
3457
|
+
if (audit) auditExitCode = (await runAuditCommand({
|
|
3458
|
+
cwd,
|
|
3459
|
+
strict: options.strict === true,
|
|
3460
|
+
write: options.write
|
|
3461
|
+
})).exitCode;
|
|
3462
|
+
return {
|
|
3463
|
+
biomeExitCode,
|
|
3464
|
+
auditExitCode,
|
|
3465
|
+
exitCode: biomeExitCode !== 0 ? biomeExitCode : auditExitCode ?? 0,
|
|
3466
|
+
configPath
|
|
3467
|
+
};
|
|
3468
|
+
}
|
|
3469
|
+
//#endregion
|
|
3365
3470
|
//#region src/index.ts
|
|
3366
3471
|
/**
|
|
3367
3472
|
* @vttforge/cli: public library exports.
|
|
@@ -3386,6 +3491,6 @@ function runInstall(pm, cwd) {
|
|
|
3386
3491
|
*/
|
|
3387
3492
|
const VTTFORGE_CLI_VERSION = version;
|
|
3388
3493
|
//#endregion
|
|
3389
|
-
export {
|
|
3494
|
+
export { definesName as _, runDev as a, runSourceRules as b, emitZip as c, formatReport as d, runAudit as f, bareUsePattern as g, LEGACY_GLOBALS as h, runInit as i, readManifest as l, maskComments 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, SEVERITY_RANK as v, runManifestRules as x, _internal as y };
|
|
3390
3495
|
|
|
3391
|
-
//# sourceMappingURL=src-
|
|
3496
|
+
//# sourceMappingURL=src-CzzrhCN-.mjs.map
|