@bensandee/tooling 0.7.2 → 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.
Files changed (2) hide show
  1. package/dist/bin.mjs +49 -35
  2. 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
- const existingInclude = parsed.include ?? [];
867
- if (!existingInclude.includes("src")) {
868
- existingInclude.push("src");
869
- changes.push("added \"src\" to include");
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",
@@ -944,12 +948,10 @@ function generateMonorepoPackageTsconfigs(ctx) {
944
948
  parsed.extends = extendsValue;
945
949
  changes.push(prev ? `changed extends: ${String(prev)} → ${extendsValue}` : `added extends: ${extendsValue}`);
946
950
  }
947
- const existingInclude = parsed.include ?? [];
948
- if (!existingInclude.includes("src")) {
949
- existingInclude.push("src");
950
- 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\"]");
951
954
  }
952
- parsed.include = existingInclude;
953
955
  if (changes.length === 0) {
954
956
  results.push({
955
957
  filePath,
@@ -967,7 +969,7 @@ function generateMonorepoPackageTsconfigs(ctx) {
967
969
  } else {
968
970
  const config = {
969
971
  extends: extendsValue,
970
- include: ["src"],
972
+ ...ctx.exists(path.join(relDir, "src")) ? { include: ["src"] } : {},
971
973
  exclude: ["node_modules", "dist"]
972
974
  };
973
975
  ctx.write(filePath, JSON.stringify(config, null, 2) + "\n");
@@ -1107,23 +1109,15 @@ async function generateFormatter(ctx) {
1107
1109
  }
1108
1110
  async function generateOxfmt(ctx) {
1109
1111
  const filePath = ".oxfmtrc.json";
1110
- const existing = ctx.read(filePath);
1111
- if (existing) {
1112
- if (existing === OXFMT_CONFIG) return {
1113
- filePath,
1114
- action: "skipped",
1115
- description: "Already configured"
1116
- };
1117
- if (await ctx.confirmOverwrite(filePath) === "skip") return {
1118
- filePath,
1119
- action: "skipped",
1120
- description: "Existing oxfmt config preserved"
1121
- };
1122
- }
1112
+ if (ctx.exists(filePath)) return {
1113
+ filePath,
1114
+ action: "skipped",
1115
+ description: "Existing oxfmt config preserved"
1116
+ };
1123
1117
  ctx.write(filePath, OXFMT_CONFIG);
1124
1118
  return {
1125
1119
  filePath,
1126
- action: existing ? "updated" : "created",
1120
+ action: "created",
1127
1121
  description: "Generated .oxfmtrc.json"
1128
1122
  };
1129
1123
  }
@@ -1267,6 +1261,24 @@ jobs:
1267
1261
  - run: pnpm exec tooling repo:check
1268
1262
  `;
1269
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
+ }
1270
1282
  async function generateCi(ctx) {
1271
1283
  if (ctx.config.ci === "none") return {
1272
1284
  filePath: "ci",
@@ -1281,13 +1293,15 @@ async function generateCi(ctx) {
1281
1293
  if (ctx.exists(filePath)) {
1282
1294
  const existing = ctx.read(filePath);
1283
1295
  if (existing && !existing.includes("repo:check")) {
1284
- const patched = existing.trimEnd() + "\n - run: pnpm exec tooling repo:check\n";
1285
- ctx.write(filePath, patched);
1286
- return {
1287
- filePath,
1288
- action: "updated",
1289
- description: "Added `pnpm exec tooling repo:check` step to CI workflow"
1290
- };
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
+ }
1291
1305
  }
1292
1306
  return {
1293
1307
  filePath,
@@ -2971,7 +2985,7 @@ function mergeGitHub(dryRun) {
2971
2985
  const main = defineCommand({
2972
2986
  meta: {
2973
2987
  name: "tooling",
2974
- version: "0.7.2",
2988
+ version: "0.7.3",
2975
2989
  description: "Bootstrap and maintain standardized TypeScript project tooling"
2976
2990
  },
2977
2991
  subCommands: {
@@ -2984,7 +2998,7 @@ const main = defineCommand({
2984
2998
  "release:merge": releaseMergeCommand
2985
2999
  }
2986
3000
  });
2987
- console.log(`@bensandee/tooling v0.7.2`);
3001
+ console.log(`@bensandee/tooling v0.7.3`);
2988
3002
  runMain(main);
2989
3003
 
2990
3004
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bensandee/tooling",
3
- "version": "0.7.2",
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.3"
36
+ "@bensandee/config": "0.6.4"
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsdown",