@bensandee/tooling 0.10.0 → 0.10.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.
Files changed (2) hide show
  1. package/dist/bin.mjs +25 -55
  2. package/package.json +1 -1
package/dist/bin.mjs CHANGED
@@ -581,7 +581,7 @@ function getAddedDevDepNames(config) {
581
581
  const deps = { ...ROOT_DEV_DEPS };
582
582
  if (config.structure !== "monorepo") Object.assign(deps, PER_PACKAGE_DEV_DEPS);
583
583
  deps["@bensandee/config"] = "0.7.1";
584
- deps["@bensandee/tooling"] = "0.10.0";
584
+ deps["@bensandee/tooling"] = "0.10.1";
585
585
  if (config.formatter === "oxfmt") deps["oxfmt"] = "0.35.0";
586
586
  if (config.formatter === "prettier") deps["prettier"] = "3.8.1";
587
587
  addReleaseDeps(deps, config);
@@ -602,7 +602,7 @@ async function generatePackageJson(ctx) {
602
602
  const devDeps = { ...ROOT_DEV_DEPS };
603
603
  if (!isMonorepo) Object.assign(devDeps, PER_PACKAGE_DEV_DEPS);
604
604
  devDeps["@bensandee/config"] = isWorkspacePackage(ctx, "@bensandee/config") ? "workspace:*" : "0.7.1";
605
- devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.10.0";
605
+ devDeps["@bensandee/tooling"] = isWorkspacePackage(ctx, "@bensandee/tooling") ? "workspace:*" : "0.10.1";
606
606
  if (ctx.config.useEslintPlugin) devDeps["@bensandee/eslint-plugin"] = isWorkspacePackage(ctx, "@bensandee/eslint-plugin") ? "workspace:*" : "0.9.0";
607
607
  if (ctx.config.formatter === "oxfmt") devDeps["oxfmt"] = "0.35.0";
608
608
  if (ctx.config.formatter === "prettier") devDeps["prettier"] = "3.8.1";
@@ -1244,6 +1244,11 @@ async function generateGitignore(ctx) {
1244
1244
  //#endregion
1245
1245
  //#region src/utils/yaml-merge.ts
1246
1246
  const IGNORE_PATTERN = "@bensandee/tooling:ignore";
1247
+ const FORGEJO_SCHEMA_COMMENT = "# yaml-language-server: $schema=../../.vscode/forgejo-workflow.schema.json\n";
1248
+ /** Returns a yaml-language-server schema comment for Forgejo workflows, empty string otherwise. */
1249
+ function workflowSchemaComment(ci) {
1250
+ return ci === "forgejo" ? FORGEJO_SCHEMA_COMMENT : "";
1251
+ }
1247
1252
  /** Check if a YAML file has an opt-out comment in the first 10 lines. */
1248
1253
  function isToolingIgnored(content) {
1249
1254
  return content.split("\n", 10).some((line) => line.includes(IGNORE_PATTERN));
@@ -1344,8 +1349,12 @@ function hasEnginesNode$1(ctx) {
1344
1349
  return typeof parsePackageJson(raw)?.engines?.["node"] === "string";
1345
1350
  }
1346
1351
  function ciWorkflow(isMonorepo, nodeVersionYaml, isForgejo) {
1347
- return `name: CI
1348
- ${isForgejo ? "\nenable-email-notifications: true\n" : ""}on:
1352
+ const buildCmd = isMonorepo ? "pnpm -r build" : "pnpm build";
1353
+ const testCmd = isMonorepo ? "pnpm -r test" : "pnpm test";
1354
+ const typecheckCmd = isMonorepo ? "pnpm -r --parallel run typecheck" : "pnpm typecheck";
1355
+ const emailNotifications = isForgejo ? "\nenable-email-notifications: true\n" : "";
1356
+ return `${workflowSchemaComment(isForgejo ? "forgejo" : "github")}name: CI
1357
+ ${emailNotifications}on:
1349
1358
  push:
1350
1359
  branches: [main]
1351
1360
  pull_request:
@@ -1362,10 +1371,10 @@ jobs:
1362
1371
  ${nodeVersionYaml}
1363
1372
  cache: pnpm
1364
1373
  - run: pnpm install --frozen-lockfile
1365
- - run: ${isMonorepo ? "pnpm -r --parallel run typecheck" : "pnpm typecheck"}
1374
+ - run: ${typecheckCmd}
1366
1375
  - run: pnpm lint
1367
- - run: ${isMonorepo ? "pnpm -r build" : "pnpm build"}
1368
- - run: ${isMonorepo ? "pnpm -r test" : "pnpm test"}
1376
+ - run: ${buildCmd}
1377
+ - run: ${testCmd}
1369
1378
  - run: pnpm format --check
1370
1379
  - run: pnpm knip
1371
1380
  - run: pnpm exec tooling repo:check
@@ -1637,6 +1646,7 @@ function buildSettings(ctx) {
1637
1646
  `Bash(${pm} add *)`,
1638
1647
  `Bash(${pm} update *)`,
1639
1648
  `Bash(${pm} view *)`,
1649
+ `Bash(${pm} why *)`,
1640
1650
  `Bash(${pm} list)`,
1641
1651
  `Bash(${pm} list *)`,
1642
1652
  `Bash(${pm} ls)`,
@@ -1933,7 +1943,7 @@ permissions:
1933
1943
  contents: write
1934
1944
  ` : "";
1935
1945
  const tokenEnv = isGitHub ? `GITHUB_TOKEN: \${{ github.token }}` : `FORGEJO_TOKEN: \${{ secrets.FORGEJO_TOKEN }}`;
1936
- return `name: Release
1946
+ return `${workflowSchemaComment(ci)}name: Release
1937
1947
  on:
1938
1948
  workflow_dispatch:
1939
1949
  ${permissions}
@@ -1982,7 +1992,7 @@ permissions:
1982
1992
  TAG=$(git describe --tags --abbrev=0)
1983
1993
  pnpm publish --no-git-checks
1984
1994
  pnpm exec tooling release:create-forgejo-release --tag "$TAG"`;
1985
- return `name: Release
1995
+ return `${workflowSchemaComment(ci)}name: Release
1986
1996
  on:
1987
1997
  workflow_dispatch:
1988
1998
  ${permissions}
@@ -1994,7 +2004,7 @@ ${commonSteps(nodeVersionYaml)}${gitConfigStep}${releaseStep}
1994
2004
  `;
1995
2005
  }
1996
2006
  function changesetsWorkflow(ci, nodeVersionYaml) {
1997
- if (ci === "github") return `name: Release
2007
+ if (ci === "github") return `${workflowSchemaComment(ci)}name: Release
1998
2008
  on:
1999
2009
  push:
2000
2010
  branches:
@@ -2017,7 +2027,7 @@ ${commonSteps(nodeVersionYaml)}
2017
2027
  GITHUB_TOKEN: \${{ github.token }}
2018
2028
  NPM_TOKEN: \${{ secrets.NPM_TOKEN }}
2019
2029
  `;
2020
- return `name: Release
2030
+ return `${workflowSchemaComment(ci)}name: Release
2021
2031
  on:
2022
2032
  push:
2023
2033
  branches:
@@ -2304,22 +2314,13 @@ async function generateLefthook(ctx) {
2304
2314
  const SCHEMA_NPM_PATH = "@bensandee/config/schemas/forgejo-workflow.schema.json";
2305
2315
  const SCHEMA_LOCAL_PATH = ".vscode/forgejo-workflow.schema.json";
2306
2316
  const SETTINGS_PATH = ".vscode/settings.json";
2307
- const SCHEMA_GLOB = ".forgejo/workflows/*.yml";
2317
+ const SCHEMA_GLOB = ".forgejo/workflows/*.{yml,yaml}";
2308
2318
  const VscodeSettingsSchema = z.object({ "yaml.schemas": z.record(z.string(), z.unknown()).default({}) }).passthrough();
2309
- const FullWorkspaceFileSchema = z.object({ settings: z.record(z.string(), z.unknown()).default({}) }).passthrough();
2310
2319
  function readSchemaFromNodeModules(targetDir) {
2311
2320
  const candidate = path.join(targetDir, "node_modules", SCHEMA_NPM_PATH);
2312
2321
  if (!existsSync(candidate)) return void 0;
2313
2322
  return readFileSync(candidate, "utf-8");
2314
2323
  }
2315
- /** Find a *.code-workspace file in the target directory. */
2316
- function findWorkspaceFile(targetDir) {
2317
- try {
2318
- return readdirSync(targetDir).find((e) => e.endsWith(".code-workspace"));
2319
- } catch {
2320
- return;
2321
- }
2322
- }
2323
2324
  function serializeSettings(settings) {
2324
2325
  return JSON.stringify(settings, null, 2) + "\n";
2325
2326
  }
@@ -2341,36 +2342,6 @@ function mergeYamlSchemas(settings) {
2341
2342
  changed: true
2342
2343
  };
2343
2344
  }
2344
- function writeSchemaToWorkspaceFile(ctx, wsFileName) {
2345
- const raw = ctx.read(wsFileName);
2346
- if (!raw) return {
2347
- filePath: wsFileName,
2348
- action: "skipped",
2349
- description: "Could not read workspace file"
2350
- };
2351
- const fullParsed = FullWorkspaceFileSchema.safeParse(parse(raw));
2352
- if (!fullParsed.success) return {
2353
- filePath: wsFileName,
2354
- action: "skipped",
2355
- description: "Could not parse workspace file"
2356
- };
2357
- const { merged, changed } = mergeYamlSchemas(fullParsed.data.settings);
2358
- if (!changed) return {
2359
- filePath: wsFileName,
2360
- action: "skipped",
2361
- description: "Already has Forgejo schema mapping"
2362
- };
2363
- const updated = {
2364
- ...fullParsed.data,
2365
- settings: merged
2366
- };
2367
- ctx.write(wsFileName, JSON.stringify(updated, null, 2) + "\n");
2368
- return {
2369
- filePath: wsFileName,
2370
- action: "updated",
2371
- description: "Added Forgejo workflow schema mapping to workspace settings"
2372
- };
2373
- }
2374
2345
  function writeSchemaToSettings(ctx) {
2375
2346
  if (ctx.exists(SETTINGS_PATH)) {
2376
2347
  const raw = ctx.read(SETTINGS_PATH);
@@ -2438,8 +2409,7 @@ async function generateVscodeSettings(ctx) {
2438
2409
  description: "Copied Forgejo workflow schema from @bensandee/config"
2439
2410
  });
2440
2411
  }
2441
- const wsFile = findWorkspaceFile(ctx.targetDir);
2442
- results.push(wsFile ? writeSchemaToWorkspaceFile(ctx, wsFile) : writeSchemaToSettings(ctx));
2412
+ results.push(writeSchemaToSettings(ctx));
2443
2413
  return results;
2444
2414
  }
2445
2415
  //#endregion
@@ -3458,7 +3428,7 @@ function mergeGitHub(dryRun) {
3458
3428
  const main = defineCommand({
3459
3429
  meta: {
3460
3430
  name: "tooling",
3461
- version: "0.10.0",
3431
+ version: "0.10.1",
3462
3432
  description: "Bootstrap and maintain standardized TypeScript project tooling"
3463
3433
  },
3464
3434
  subCommands: {
@@ -3471,7 +3441,7 @@ const main = defineCommand({
3471
3441
  "release:merge": releaseMergeCommand
3472
3442
  }
3473
3443
  });
3474
- console.log(`@bensandee/tooling v0.10.0`);
3444
+ console.log(`@bensandee/tooling v0.10.1`);
3475
3445
  runMain(main);
3476
3446
  //#endregion
3477
3447
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bensandee/tooling",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "CLI tool to bootstrap and maintain standardized TypeScript project tooling",
5
5
  "bin": {
6
6
  "tooling": "./dist/bin.mjs"