@bensandee/tooling 0.5.1 → 0.6.1
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 +25 -27
- package/package.json +3 -2
package/dist/bin.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import * as p from "@clack/prompts";
|
|
|
4
4
|
import { execSync } from "node:child_process";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
7
|
+
import JSON5 from "json5";
|
|
7
8
|
import { parse } from "jsonc-parser";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
|
|
@@ -53,10 +54,14 @@ function parseTsconfig(raw) {
|
|
|
53
54
|
const result = TsconfigSchema.safeParse(parse(raw));
|
|
54
55
|
return result.success ? result.data : {};
|
|
55
56
|
}
|
|
56
|
-
/** Parse a JSON string as a renovate.
|
|
57
|
+
/** Parse a JSON/JSON5/JSONC string as a renovate config. Returns a typed object with `{}` fallback on failure. */
|
|
57
58
|
function parseRenovateJson(raw) {
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
try {
|
|
60
|
+
const result = RenovateSchema.safeParse(JSON5.parse(raw));
|
|
61
|
+
return result.success ? result.data : {};
|
|
62
|
+
} catch {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
/** Parse a JSON string as a package.json. Returns `undefined` on failure. */
|
|
62
67
|
function parsePackageJson(raw) {
|
|
@@ -436,8 +441,7 @@ const STANDARD_SCRIPTS_SINGLE = {
|
|
|
436
441
|
test: "vitest run",
|
|
437
442
|
lint: "oxlint",
|
|
438
443
|
knip: "knip",
|
|
439
|
-
check: "pnpm typecheck && pnpm build && pnpm lint && pnpm knip"
|
|
440
|
-
prepare: "lefthook install"
|
|
444
|
+
check: "pnpm typecheck && pnpm build && pnpm lint && pnpm knip"
|
|
441
445
|
};
|
|
442
446
|
const STANDARD_SCRIPTS_MONOREPO = {
|
|
443
447
|
build: "pnpm -r build",
|
|
@@ -445,8 +449,7 @@ const STANDARD_SCRIPTS_MONOREPO = {
|
|
|
445
449
|
typecheck: "pnpm -r --parallel run typecheck",
|
|
446
450
|
lint: "oxlint",
|
|
447
451
|
knip: "knip",
|
|
448
|
-
check: "pnpm typecheck && pnpm build && pnpm lint && pnpm knip"
|
|
449
|
-
prepare: "lefthook install"
|
|
452
|
+
check: "pnpm typecheck && pnpm build && pnpm lint && pnpm knip"
|
|
450
453
|
};
|
|
451
454
|
/** DevDeps that belong in every project (single repo) or per-package (monorepo). */
|
|
452
455
|
const PER_PACKAGE_DEV_DEPS = {
|
|
@@ -1237,15 +1240,15 @@ const RENOVATE_CONFIG_PATHS = [
|
|
|
1237
1240
|
".github/renovate.json5"
|
|
1238
1241
|
];
|
|
1239
1242
|
async function generateRenovate(ctx) {
|
|
1240
|
-
const
|
|
1243
|
+
const defaultPath = "renovate.json";
|
|
1241
1244
|
if (!ctx.config.setupRenovate) return {
|
|
1242
|
-
filePath,
|
|
1245
|
+
filePath: defaultPath,
|
|
1243
1246
|
action: "skipped",
|
|
1244
1247
|
description: "Renovate not requested"
|
|
1245
1248
|
};
|
|
1246
1249
|
const existingPath = RENOVATE_CONFIG_PATHS.find((p) => ctx.exists(p));
|
|
1247
|
-
if (existingPath
|
|
1248
|
-
const existing = ctx.read(
|
|
1250
|
+
if (existingPath) {
|
|
1251
|
+
const existing = ctx.read(existingPath);
|
|
1249
1252
|
if (existing) {
|
|
1250
1253
|
const parsed = parseRenovateJson(existing);
|
|
1251
1254
|
const existingExtends = parsed.extends ?? [];
|
|
@@ -1253,9 +1256,9 @@ async function generateRenovate(ctx) {
|
|
|
1253
1256
|
if (legacyIndex !== -1) {
|
|
1254
1257
|
existingExtends[legacyIndex] = SHARED_PRESET;
|
|
1255
1258
|
parsed.extends = existingExtends;
|
|
1256
|
-
ctx.write(
|
|
1259
|
+
ctx.write(existingPath, JSON.stringify(parsed, null, 2) + "\n");
|
|
1257
1260
|
return {
|
|
1258
|
-
filePath,
|
|
1261
|
+
filePath: existingPath,
|
|
1259
1262
|
action: "updated",
|
|
1260
1263
|
description: `Migrated extends: ${LEGACY_PRESET} → ${SHARED_PRESET}`
|
|
1261
1264
|
};
|
|
@@ -1263,32 +1266,27 @@ async function generateRenovate(ctx) {
|
|
|
1263
1266
|
if (!existingExtends.includes(SHARED_PRESET)) {
|
|
1264
1267
|
existingExtends.unshift(SHARED_PRESET);
|
|
1265
1268
|
parsed.extends = existingExtends;
|
|
1266
|
-
ctx.write(
|
|
1269
|
+
ctx.write(existingPath, JSON.stringify(parsed, null, 2) + "\n");
|
|
1267
1270
|
return {
|
|
1268
|
-
filePath,
|
|
1271
|
+
filePath: existingPath,
|
|
1269
1272
|
action: "updated",
|
|
1270
1273
|
description: `Added extends: ${SHARED_PRESET}`
|
|
1271
1274
|
};
|
|
1272
1275
|
}
|
|
1273
1276
|
return {
|
|
1274
|
-
filePath,
|
|
1277
|
+
filePath: existingPath,
|
|
1275
1278
|
action: "skipped",
|
|
1276
1279
|
description: "Already extends shared config"
|
|
1277
1280
|
};
|
|
1278
1281
|
}
|
|
1279
1282
|
}
|
|
1280
|
-
if (existingPath) return {
|
|
1281
|
-
filePath: existingPath,
|
|
1282
|
-
action: "skipped",
|
|
1283
|
-
description: `Existing config found at ${existingPath}`
|
|
1284
|
-
};
|
|
1285
1283
|
const config = {
|
|
1286
1284
|
$schema: "https://docs.renovatebot.com/renovate-schema.json",
|
|
1287
1285
|
extends: [SHARED_PRESET]
|
|
1288
1286
|
};
|
|
1289
|
-
ctx.write(
|
|
1287
|
+
ctx.write(defaultPath, JSON.stringify(config, null, 2) + "\n");
|
|
1290
1288
|
return {
|
|
1291
|
-
filePath,
|
|
1289
|
+
filePath: defaultPath,
|
|
1292
1290
|
action: "created",
|
|
1293
1291
|
description: "Generated renovate.json extending shared config"
|
|
1294
1292
|
};
|
|
@@ -1816,8 +1814,8 @@ function cleanPackageJson(ctx, results) {
|
|
|
1816
1814
|
}
|
|
1817
1815
|
}
|
|
1818
1816
|
if (pkg.scripts?.["prepare"] && /\bhusky\b/.test(pkg.scripts["prepare"])) {
|
|
1819
|
-
pkg.scripts["prepare"]
|
|
1820
|
-
changes.push("
|
|
1817
|
+
delete pkg.scripts["prepare"];
|
|
1818
|
+
changes.push("removed husky prepare script");
|
|
1821
1819
|
}
|
|
1822
1820
|
if (changes.length === 0) return;
|
|
1823
1821
|
ctx.write("package.json", JSON.stringify(pkg, null, 2) + "\n");
|
|
@@ -2701,7 +2699,7 @@ function mergeGitHub(dryRun) {
|
|
|
2701
2699
|
const main = defineCommand({
|
|
2702
2700
|
meta: {
|
|
2703
2701
|
name: "tooling",
|
|
2704
|
-
version: "0.
|
|
2702
|
+
version: "0.6.1",
|
|
2705
2703
|
description: "Bootstrap and maintain standardized TypeScript project tooling"
|
|
2706
2704
|
},
|
|
2707
2705
|
subCommands: {
|
|
@@ -2713,7 +2711,7 @@ const main = defineCommand({
|
|
|
2713
2711
|
"release:merge": releaseMergeCommand
|
|
2714
2712
|
}
|
|
2715
2713
|
});
|
|
2716
|
-
console.log(`@bensandee/tooling v0.
|
|
2714
|
+
console.log(`@bensandee/tooling v0.6.1`);
|
|
2717
2715
|
runMain(main);
|
|
2718
2716
|
|
|
2719
2717
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bensandee/tooling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tooling": "./dist/bin.mjs"
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@clack/prompts": "^1.0.1",
|
|
25
25
|
"citty": "^0.2.1",
|
|
26
|
+
"json5": "^2.2.3",
|
|
26
27
|
"jsonc-parser": "^3.3.1",
|
|
27
28
|
"zod": "^4.3.6"
|
|
28
29
|
},
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
"tsdown": "0.20.3",
|
|
32
33
|
"typescript": "5.9.3",
|
|
33
34
|
"vitest": "4.0.18",
|
|
34
|
-
"@bensandee/config": "0.
|
|
35
|
+
"@bensandee/config": "0.6.1"
|
|
35
36
|
},
|
|
36
37
|
"scripts": {
|
|
37
38
|
"build": "tsdown",
|