@bensandee/tooling 0.7.1 → 0.7.3
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 +63 -41
- package/package.json +2 -2
package/dist/bin.mjs
CHANGED
|
@@ -772,6 +772,8 @@ function generateMigratePrompt(results, config, detected) {
|
|
|
772
772
|
}
|
|
773
773
|
sections.push("## Ground rules");
|
|
774
774
|
sections.push("");
|
|
775
|
+
sections.push("It is OK to add new packages (e.g. `zod`, `@bensandee/common`) if they are needed to resolve errors.");
|
|
776
|
+
sections.push("");
|
|
775
777
|
sections.push("When resolving errors from the checklist below, prefer fixing the root cause over suppressing the issue. For example:");
|
|
776
778
|
sections.push("");
|
|
777
779
|
sections.push("- **Lint errors**: fix the code rather than adding disable comments or rule exceptions");
|
|
@@ -808,7 +810,7 @@ async function generateTsconfig(ctx) {
|
|
|
808
810
|
if (!existing) {
|
|
809
811
|
const config = {
|
|
810
812
|
extends: extendsValue,
|
|
811
|
-
include: ["src"],
|
|
813
|
+
...ctx.exists("src") ? { include: ["src"] } : {},
|
|
812
814
|
exclude: ["node_modules", "dist"]
|
|
813
815
|
};
|
|
814
816
|
ctx.write(filePath, JSON.stringify(config, null, 2) + "\n");
|
|
@@ -863,12 +865,14 @@ function mergeSingleTsconfig(ctx, filePath, extendsValue) {
|
|
|
863
865
|
parsed.extends = extendsValue;
|
|
864
866
|
changes.push(`added extends: ${extendsValue}`);
|
|
865
867
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
868
|
+
if (!parsed.include) {
|
|
869
|
+
const tsconfigDir = path.dirname(filePath);
|
|
870
|
+
const srcDir = tsconfigDir === "." ? "src" : path.join(tsconfigDir, "src");
|
|
871
|
+
if (ctx.exists(srcDir)) {
|
|
872
|
+
parsed.include = ["src"];
|
|
873
|
+
changes.push("added include: [\"src\"]");
|
|
874
|
+
}
|
|
870
875
|
}
|
|
871
|
-
parsed.include = existingInclude;
|
|
872
876
|
if (changes.length === 0) return {
|
|
873
877
|
filePath,
|
|
874
878
|
action: "skipped",
|
|
@@ -901,14 +905,10 @@ function generateMonorepoRootTsconfig(ctx, existing) {
|
|
|
901
905
|
description: "Already has project references"
|
|
902
906
|
};
|
|
903
907
|
}
|
|
904
|
-
ctx.write(filePath, JSON.stringify({
|
|
905
|
-
files: [],
|
|
906
|
-
references: []
|
|
907
|
-
}, null, 2) + "\n");
|
|
908
908
|
return {
|
|
909
909
|
filePath,
|
|
910
|
-
action: "
|
|
911
|
-
description: "
|
|
910
|
+
action: "skipped",
|
|
911
|
+
description: "No tsconfig.json found"
|
|
912
912
|
};
|
|
913
913
|
}
|
|
914
914
|
function generateMonorepoPackageTsconfigs(ctx) {
|
|
@@ -930,18 +930,28 @@ function generateMonorepoPackageTsconfigs(ctx) {
|
|
|
930
930
|
continue;
|
|
931
931
|
}
|
|
932
932
|
const parsed = parseTsconfig(existing);
|
|
933
|
+
if (isSolutionStyle(parsed)) {
|
|
934
|
+
results.push({
|
|
935
|
+
filePath,
|
|
936
|
+
action: "skipped",
|
|
937
|
+
description: "Solution-style tsconfig — traversing references"
|
|
938
|
+
});
|
|
939
|
+
for (const ref of parsed.references ?? []) {
|
|
940
|
+
const refPath = path.join(relDir, resolveReferencePath(ref.path));
|
|
941
|
+
results.push(mergeSingleTsconfig(ctx, refPath, extendsValue));
|
|
942
|
+
}
|
|
943
|
+
continue;
|
|
944
|
+
}
|
|
933
945
|
const changes = [];
|
|
934
946
|
if (parsed.extends !== extendsValue) {
|
|
935
947
|
const prev = parsed.extends;
|
|
936
948
|
parsed.extends = extendsValue;
|
|
937
949
|
changes.push(prev ? `changed extends: ${String(prev)} → ${extendsValue}` : `added extends: ${extendsValue}`);
|
|
938
950
|
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
changes.push("added \"src\" to include");
|
|
951
|
+
if (!parsed.include && ctx.exists(path.join(relDir, "src"))) {
|
|
952
|
+
parsed.include = ["src"];
|
|
953
|
+
changes.push("added include: [\"src\"]");
|
|
943
954
|
}
|
|
944
|
-
parsed.include = existingInclude;
|
|
945
955
|
if (changes.length === 0) {
|
|
946
956
|
results.push({
|
|
947
957
|
filePath,
|
|
@@ -959,7 +969,7 @@ function generateMonorepoPackageTsconfigs(ctx) {
|
|
|
959
969
|
} else {
|
|
960
970
|
const config = {
|
|
961
971
|
extends: extendsValue,
|
|
962
|
-
include: ["src"],
|
|
972
|
+
...ctx.exists(path.join(relDir, "src")) ? { include: ["src"] } : {},
|
|
963
973
|
exclude: ["node_modules", "dist"]
|
|
964
974
|
};
|
|
965
975
|
ctx.write(filePath, JSON.stringify(config, null, 2) + "\n");
|
|
@@ -1099,23 +1109,15 @@ async function generateFormatter(ctx) {
|
|
|
1099
1109
|
}
|
|
1100
1110
|
async function generateOxfmt(ctx) {
|
|
1101
1111
|
const filePath = ".oxfmtrc.json";
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
description: "Already configured"
|
|
1108
|
-
};
|
|
1109
|
-
if (await ctx.confirmOverwrite(filePath) === "skip") return {
|
|
1110
|
-
filePath,
|
|
1111
|
-
action: "skipped",
|
|
1112
|
-
description: "Existing oxfmt config preserved"
|
|
1113
|
-
};
|
|
1114
|
-
}
|
|
1112
|
+
if (ctx.exists(filePath)) return {
|
|
1113
|
+
filePath,
|
|
1114
|
+
action: "skipped",
|
|
1115
|
+
description: "Existing oxfmt config preserved"
|
|
1116
|
+
};
|
|
1115
1117
|
ctx.write(filePath, OXFMT_CONFIG);
|
|
1116
1118
|
return {
|
|
1117
1119
|
filePath,
|
|
1118
|
-
action:
|
|
1120
|
+
action: "created",
|
|
1119
1121
|
description: "Generated .oxfmtrc.json"
|
|
1120
1122
|
};
|
|
1121
1123
|
}
|
|
@@ -1259,6 +1261,24 @@ jobs:
|
|
|
1259
1261
|
- run: pnpm exec tooling repo:check
|
|
1260
1262
|
`;
|
|
1261
1263
|
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Insert a step at the end of the `check` job's steps, even if other jobs
|
|
1266
|
+
* follow. Returns null if we can't find the right insertion point.
|
|
1267
|
+
*/
|
|
1268
|
+
function insertStepIntoCheckJob(yaml, step) {
|
|
1269
|
+
const lines = yaml.split("\n");
|
|
1270
|
+
const checkJobIdx = lines.findIndex((l) => /^ {2}check:\s*$/.test(l));
|
|
1271
|
+
if (checkJobIdx === -1) return null;
|
|
1272
|
+
let lastStepIdx = -1;
|
|
1273
|
+
for (const [i, line] of lines.entries()) {
|
|
1274
|
+
if (i <= checkJobIdx) continue;
|
|
1275
|
+
if (/^ {2}\S/.test(line)) break;
|
|
1276
|
+
if (/^ {6}/.test(line)) lastStepIdx = i;
|
|
1277
|
+
}
|
|
1278
|
+
if (lastStepIdx === -1) return null;
|
|
1279
|
+
lines.splice(lastStepIdx + 1, 0, step.trimEnd());
|
|
1280
|
+
return lines.join("\n");
|
|
1281
|
+
}
|
|
1262
1282
|
async function generateCi(ctx) {
|
|
1263
1283
|
if (ctx.config.ci === "none") return {
|
|
1264
1284
|
filePath: "ci",
|
|
@@ -1273,13 +1293,15 @@ async function generateCi(ctx) {
|
|
|
1273
1293
|
if (ctx.exists(filePath)) {
|
|
1274
1294
|
const existing = ctx.read(filePath);
|
|
1275
1295
|
if (existing && !existing.includes("repo:check")) {
|
|
1276
|
-
const patched = existing
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1296
|
+
const patched = insertStepIntoCheckJob(existing, " - run: pnpm exec tooling repo:check\n");
|
|
1297
|
+
if (patched) {
|
|
1298
|
+
ctx.write(filePath, patched);
|
|
1299
|
+
return {
|
|
1300
|
+
filePath,
|
|
1301
|
+
action: "updated",
|
|
1302
|
+
description: "Added `pnpm exec tooling repo:check` step to CI workflow"
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1283
1305
|
}
|
|
1284
1306
|
return {
|
|
1285
1307
|
filePath,
|
|
@@ -2963,7 +2985,7 @@ function mergeGitHub(dryRun) {
|
|
|
2963
2985
|
const main = defineCommand({
|
|
2964
2986
|
meta: {
|
|
2965
2987
|
name: "tooling",
|
|
2966
|
-
version: "0.7.
|
|
2988
|
+
version: "0.7.3",
|
|
2967
2989
|
description: "Bootstrap and maintain standardized TypeScript project tooling"
|
|
2968
2990
|
},
|
|
2969
2991
|
subCommands: {
|
|
@@ -2976,7 +2998,7 @@ const main = defineCommand({
|
|
|
2976
2998
|
"release:merge": releaseMergeCommand
|
|
2977
2999
|
}
|
|
2978
3000
|
});
|
|
2979
|
-
console.log(`@bensandee/tooling v0.7.
|
|
3001
|
+
console.log(`@bensandee/tooling v0.7.3`);
|
|
2980
3002
|
runMain(main);
|
|
2981
3003
|
|
|
2982
3004
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bensandee/tooling",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tooling": "./dist/bin.mjs"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"tsdown": "0.20.3",
|
|
34
34
|
"typescript": "5.9.3",
|
|
35
35
|
"vitest": "4.0.18",
|
|
36
|
-
"@bensandee/config": "0.6.
|
|
36
|
+
"@bensandee/config": "0.6.4"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsdown",
|