@bensandee/tooling 0.12.0 → 0.13.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/dist/bin.mjs +51 -51
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -516,8 +516,10 @@ const STANDARD_SCRIPTS_SINGLE = {
|
|
|
516
516
|
test: "vitest run",
|
|
517
517
|
lint: "oxlint",
|
|
518
518
|
knip: "knip",
|
|
519
|
-
check: "pnpm exec tooling
|
|
520
|
-
"
|
|
519
|
+
check: "pnpm exec tooling checks:run",
|
|
520
|
+
"ci:check": "pnpm check",
|
|
521
|
+
"tooling:check": "pnpm exec tooling repo:check",
|
|
522
|
+
"tooling:update": "pnpm exec tooling repo:update"
|
|
521
523
|
};
|
|
522
524
|
const STANDARD_SCRIPTS_MONOREPO = {
|
|
523
525
|
build: "pnpm -r build",
|
|
@@ -525,13 +527,17 @@ const STANDARD_SCRIPTS_MONOREPO = {
|
|
|
525
527
|
typecheck: "pnpm -r --parallel run typecheck",
|
|
526
528
|
lint: "oxlint",
|
|
527
529
|
knip: "knip",
|
|
528
|
-
check: "pnpm exec tooling
|
|
529
|
-
"
|
|
530
|
+
check: "pnpm exec tooling checks:run",
|
|
531
|
+
"ci:check": "pnpm check",
|
|
532
|
+
"tooling:check": "pnpm exec tooling repo:check",
|
|
533
|
+
"tooling:update": "pnpm exec tooling repo:update"
|
|
530
534
|
};
|
|
531
535
|
/** Scripts that tooling owns — map from script name to keyword that must appear in the value. */
|
|
532
536
|
const MANAGED_SCRIPTS = {
|
|
533
|
-
check: "
|
|
534
|
-
"
|
|
537
|
+
check: "checks:run",
|
|
538
|
+
"ci:check": "pnpm check",
|
|
539
|
+
"tooling:check": "repo:check",
|
|
540
|
+
"tooling:update": "repo:update"
|
|
535
541
|
};
|
|
536
542
|
/** DevDeps that belong in every project (single repo) or per-package (monorepo). */
|
|
537
543
|
const PER_PACKAGE_DEV_DEPS = {
|
|
@@ -588,7 +594,7 @@ function getAddedDevDepNames(config) {
|
|
|
588
594
|
const deps = { ...ROOT_DEV_DEPS };
|
|
589
595
|
if (config.structure !== "monorepo") Object.assign(deps, PER_PACKAGE_DEV_DEPS);
|
|
590
596
|
deps["@bensandee/config"] = "0.7.1";
|
|
591
|
-
deps["@bensandee/tooling"] = "0.
|
|
597
|
+
deps["@bensandee/tooling"] = "0.13.0";
|
|
592
598
|
if (config.formatter === "oxfmt") deps["oxfmt"] = "0.35.0";
|
|
593
599
|
if (config.formatter === "prettier") deps["prettier"] = "3.8.1";
|
|
594
600
|
addReleaseDeps(deps, config);
|
|
@@ -609,7 +615,7 @@ async function generatePackageJson(ctx) {
|
|
|
609
615
|
const devDeps = { ...ROOT_DEV_DEPS };
|
|
610
616
|
if (!isMonorepo) Object.assign(devDeps, PER_PACKAGE_DEV_DEPS);
|
|
611
617
|
devDeps["@bensandee/config"] = isWorkspacePackage(ctx, "@bensandee/config") ? "workspace:*" : "0.7.1";
|
|
612
|
-
devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.
|
|
618
|
+
devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.13.0";
|
|
613
619
|
if (ctx.config.useEslintPlugin) devDeps["@bensandee/eslint-plugin"] = isWorkspacePackage(ctx, "@bensandee/eslint-plugin") ? "workspace:*" : "0.9.0";
|
|
614
620
|
if (ctx.config.formatter === "oxfmt") devDeps["oxfmt"] = "0.35.0";
|
|
615
621
|
if (ctx.config.formatter === "prettier") devDeps["prettier"] = "3.8.1";
|
|
@@ -1386,7 +1392,7 @@ jobs:
|
|
|
1386
1392
|
cache: pnpm
|
|
1387
1393
|
- run: pnpm install --frozen-lockfile
|
|
1388
1394
|
- name: Run all checks
|
|
1389
|
-
run: pnpm check
|
|
1395
|
+
run: pnpm ci:check
|
|
1390
1396
|
`;
|
|
1391
1397
|
}
|
|
1392
1398
|
function requiredCheckSteps(nodeVersionYaml) {
|
|
@@ -1417,7 +1423,7 @@ function requiredCheckSteps(nodeVersionYaml) {
|
|
|
1417
1423
|
match: { run: "check" },
|
|
1418
1424
|
step: {
|
|
1419
1425
|
name: "Run all checks",
|
|
1420
|
-
run: "pnpm check"
|
|
1426
|
+
run: "pnpm ci:check"
|
|
1421
1427
|
}
|
|
1422
1428
|
}
|
|
1423
1429
|
];
|
|
@@ -3412,39 +3418,26 @@ function mergeGitHub(dryRun) {
|
|
|
3412
3418
|
//#endregion
|
|
3413
3419
|
//#region src/commands/repo-run-checks.ts
|
|
3414
3420
|
const CHECKS = [
|
|
3415
|
-
{
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
},
|
|
3419
|
-
{
|
|
3420
|
-
name: "typecheck",
|
|
3421
|
-
cmd: "pnpm run --if-present typecheck"
|
|
3422
|
-
},
|
|
3423
|
-
{
|
|
3424
|
-
name: "lint",
|
|
3425
|
-
cmd: "pnpm run --if-present lint"
|
|
3426
|
-
},
|
|
3427
|
-
{
|
|
3428
|
-
name: "test",
|
|
3429
|
-
cmd: "pnpm run --if-present test"
|
|
3430
|
-
},
|
|
3421
|
+
{ name: "build" },
|
|
3422
|
+
{ name: "typecheck" },
|
|
3423
|
+
{ name: "lint" },
|
|
3424
|
+
{ name: "test" },
|
|
3431
3425
|
{
|
|
3432
3426
|
name: "format",
|
|
3433
|
-
|
|
3434
|
-
},
|
|
3435
|
-
{
|
|
3436
|
-
name: "knip",
|
|
3437
|
-
cmd: "pnpm run --if-present knip"
|
|
3427
|
+
args: "--check"
|
|
3438
3428
|
},
|
|
3439
|
-
{
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
},
|
|
3443
|
-
{
|
|
3444
|
-
name: "image:check",
|
|
3445
|
-
cmd: "pnpm run --if-present image:check"
|
|
3446
|
-
}
|
|
3429
|
+
{ name: "knip" },
|
|
3430
|
+
{ name: "tooling:check" },
|
|
3431
|
+
{ name: "image:check" }
|
|
3447
3432
|
];
|
|
3433
|
+
function defaultGetScripts(targetDir) {
|
|
3434
|
+
try {
|
|
3435
|
+
const pkg = parsePackageJson(readFileSync(path.join(targetDir, "package.json"), "utf-8"));
|
|
3436
|
+
return new Set(Object.keys(pkg?.scripts ?? {}));
|
|
3437
|
+
} catch {
|
|
3438
|
+
return /* @__PURE__ */ new Set();
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3448
3441
|
function defaultExecCommand(cmd, cwd) {
|
|
3449
3442
|
try {
|
|
3450
3443
|
execSync(cmd, {
|
|
@@ -3460,21 +3453,27 @@ function defaultExecCommand(cmd, cwd) {
|
|
|
3460
3453
|
const ciLog = (msg) => console.log(msg);
|
|
3461
3454
|
function runRunChecks(targetDir, options = {}) {
|
|
3462
3455
|
const exec = options.execCommand ?? defaultExecCommand;
|
|
3456
|
+
const getScripts = options.getScripts ?? defaultGetScripts;
|
|
3463
3457
|
const skip = options.skip ?? /* @__PURE__ */ new Set();
|
|
3464
3458
|
const add = options.add ?? [];
|
|
3465
3459
|
const isCI = Boolean(process.env["CI"]);
|
|
3466
|
-
const
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
}))];
|
|
3460
|
+
const definedScripts = getScripts(targetDir);
|
|
3461
|
+
const addedNames = new Set(add);
|
|
3462
|
+
const allChecks = [...CHECKS, ...add.map((name) => ({ name }))];
|
|
3470
3463
|
const failures = [];
|
|
3464
|
+
const notDefined = [];
|
|
3471
3465
|
for (const check of allChecks) {
|
|
3472
|
-
if (skip.has(check.name))
|
|
3473
|
-
|
|
3466
|
+
if (skip.has(check.name)) continue;
|
|
3467
|
+
if (!definedScripts.has(check.name)) {
|
|
3468
|
+
if (addedNames.has(check.name)) {
|
|
3469
|
+
p.log.error(`${check.name} not defined in package.json`);
|
|
3470
|
+
failures.push(check.name);
|
|
3471
|
+
} else notDefined.push(check.name);
|
|
3474
3472
|
continue;
|
|
3475
3473
|
}
|
|
3474
|
+
const cmd = check.args ? `pnpm run ${check.name} ${check.args}` : `pnpm run ${check.name}`;
|
|
3476
3475
|
if (isCI) ciLog(`::group::${check.name}`);
|
|
3477
|
-
const exitCode = exec(
|
|
3476
|
+
const exitCode = exec(cmd, targetDir);
|
|
3478
3477
|
if (isCI) ciLog("::endgroup::");
|
|
3479
3478
|
if (exitCode === 0) p.log.success(check.name);
|
|
3480
3479
|
else {
|
|
@@ -3483,6 +3482,7 @@ function runRunChecks(targetDir, options = {}) {
|
|
|
3483
3482
|
failures.push(check.name);
|
|
3484
3483
|
}
|
|
3485
3484
|
}
|
|
3485
|
+
if (notDefined.length > 0) p.log.info(`Skipped (not defined): ${notDefined.join(", ")}`);
|
|
3486
3486
|
if (failures.length > 0) {
|
|
3487
3487
|
p.log.error(`Failed checks: ${failures.join(", ")}`);
|
|
3488
3488
|
return 1;
|
|
@@ -3492,7 +3492,7 @@ function runRunChecks(targetDir, options = {}) {
|
|
|
3492
3492
|
}
|
|
3493
3493
|
const runChecksCommand = defineCommand({
|
|
3494
3494
|
meta: {
|
|
3495
|
-
name: "
|
|
3495
|
+
name: "checks:run",
|
|
3496
3496
|
description: "Run all standard checks (build, typecheck, lint, test, format, knip, tooling:check, image:check)"
|
|
3497
3497
|
},
|
|
3498
3498
|
args: {
|
|
@@ -3508,7 +3508,7 @@ const runChecksCommand = defineCommand({
|
|
|
3508
3508
|
},
|
|
3509
3509
|
add: {
|
|
3510
3510
|
type: "string",
|
|
3511
|
-
description: "Comma-separated list of additional check names to run (uses pnpm run
|
|
3511
|
+
description: "Comma-separated list of additional check names to run (uses pnpm run <name>)",
|
|
3512
3512
|
required: false
|
|
3513
3513
|
}
|
|
3514
3514
|
},
|
|
@@ -3525,21 +3525,21 @@ const runChecksCommand = defineCommand({
|
|
|
3525
3525
|
const main = defineCommand({
|
|
3526
3526
|
meta: {
|
|
3527
3527
|
name: "tooling",
|
|
3528
|
-
version: "0.
|
|
3528
|
+
version: "0.13.0",
|
|
3529
3529
|
description: "Bootstrap and maintain standardized TypeScript project tooling"
|
|
3530
3530
|
},
|
|
3531
3531
|
subCommands: {
|
|
3532
3532
|
"repo:init": initCommand,
|
|
3533
3533
|
"repo:update": updateCommand,
|
|
3534
3534
|
"repo:check": checkCommand,
|
|
3535
|
-
"
|
|
3535
|
+
"checks:run": runChecksCommand,
|
|
3536
3536
|
"release:changesets": releaseForgejoCommand,
|
|
3537
3537
|
"release:trigger": releaseTriggerCommand,
|
|
3538
3538
|
"release:create-forgejo-release": createForgejoReleaseCommand,
|
|
3539
3539
|
"release:merge": releaseMergeCommand
|
|
3540
3540
|
}
|
|
3541
3541
|
});
|
|
3542
|
-
console.log(`@bensandee/tooling v0.
|
|
3542
|
+
console.log(`@bensandee/tooling v0.13.0`);
|
|
3543
3543
|
runMain(main);
|
|
3544
3544
|
//#endregion
|
|
3545
3545
|
export {};
|