@rtorcato/repo-tooling 3.7.2 → 3.7.4

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/README.md CHANGED
@@ -53,6 +53,20 @@ npx @rtorcato/repo-tooling copy oxlint # → .oxlintrc.json
53
53
  npx @rtorcato/repo-tooling copy claude-skill # → .claude/skills/repo-tooling.md
54
54
  ```
55
55
 
56
+ The Biome preset honours your `.gitignore`, so build output stays unlinted. One
57
+ known gap: Biome cannot parse Tailwind CSS v4 stylesheets (`@theme`, `@source`,
58
+ `@custom-variant`, `@apply`) and reports a parse error on them. If you use
59
+ Tailwind v4, exclude your stylesheet in `biome.json`:
60
+
61
+ ```jsonc
62
+ {
63
+ "extends": ["@rtorcato/repo-tooling/biome"],
64
+ // `includes` replaces the preset's list rather than extending it — restate
65
+ // the exclusions you still want alongside the CSS one.
66
+ "files": { "includes": ["**", "!**/node_modules", "!**/dist", "!**/*.css"] }
67
+ }
68
+ ```
69
+
56
70
  **Already have a project?** Don't rerun `setup` — use `doctor` + `fix`:
57
71
 
58
72
  ```bash
@@ -1,4 +1,5 @@
1
1
  import { swiftFileList } from '../../languages/swift/scaffold.js';
2
+ import { BIOME_CONFIG } from '../generators/linting.js';
2
3
  export const PRESET_NAMES = [
3
4
  'library',
4
5
  'web-app',
@@ -212,7 +213,7 @@ export function computeFileList(config) {
212
213
  files.push('tsconfig.json', 'reset.d.ts');
213
214
  }
214
215
  if (config.linting.tool === 'biome' || config.linting.tool === 'both') {
215
- files.push('biome.jsonc');
216
+ files.push(BIOME_CONFIG);
216
217
  }
217
218
  if (config.linting.tool === 'eslint' || config.linting.tool === 'both') {
218
219
  files.push('eslint.config.mjs');
@@ -20,22 +20,79 @@ export async function generateLintingConfigs(config, targetDir) {
20
20
  }
21
21
  export async function generateOxlintConfig(targetDir) {
22
22
  // Oxlint's `extends` resolution from npm packages isn't reliably supported,
23
- // so we copy the full preset rather than write a thin pointer file (same
24
- // pattern as biome.jsonc — the user owns the file once it's in their repo).
23
+ // so we copy the full preset rather than write a thin pointer file.
25
24
  const { copyPreset } = await import('../utils/copy-preset.js');
26
25
  await copyPreset('oxlint', targetDir);
27
26
  }
27
+ /** The one Biome config filename every code path writes. See BIOME_LEGACY_CONFIG. */
28
+ export const BIOME_CONFIG = 'biome.json';
29
+ /**
30
+ * The name this generator used to write. Biome resolves `biome.json` first and
31
+ * says nothing about a `biome.jsonc` sitting next to it, so a repo that had run
32
+ * both `fix biome` (biome.json) and `fix --resync` (biome.jsonc) ended up with
33
+ * two configs, one of them silently dead (#365). Both paths now write
34
+ * BIOME_CONFIG and delete this on the way past, so the ambiguity can't persist.
35
+ */
36
+ export const BIOME_LEGACY_CONFIG = 'biome.jsonc';
37
+ /**
38
+ * Used when nothing in the target repo says which Biome will read the config —
39
+ * a bare directory mid-`setup`, before `pnpm install` has run. Matches the
40
+ * `$schema` the shipped preset carries.
41
+ */
42
+ const BIOME_SCHEMA_FALLBACK = '2.5.0';
43
+ async function readJsonOrNull(filepath) {
44
+ try {
45
+ return (await fs.readJson(filepath));
46
+ }
47
+ catch {
48
+ return null;
49
+ }
50
+ }
51
+ /**
52
+ * The Biome version the scaffolded `$schema` URL should name (#363).
53
+ *
54
+ * A hardcoded version drifts the moment the consumer's Biome moves, and Biome
55
+ * reports the mismatch on *every* invocation ("The configuration schema version
56
+ * does not match the CLI version 2.5.7") — noise on a file the consumer never
57
+ * wrote. The installed package wins because it is literally the binary that
58
+ * will parse the file and emit that warning; the declared range is the next
59
+ * best statement of intent when node_modules isn't populated yet.
60
+ */
61
+ export async function resolveBiomeSchemaVersion(targetDir) {
62
+ const installed = await readJsonOrNull(path.join(targetDir, 'node_modules', '@biomejs', 'biome', 'package.json'));
63
+ const pkg = await readJsonOrNull(path.join(targetDir, 'package.json'));
64
+ const deps = {
65
+ ...(pkg?.dependencies ?? {}),
66
+ ...(pkg?.devDependencies ?? {}),
67
+ };
68
+ // Both an exact version ("2.5.7") and a range ("^2.5.0") carry the x.y.z we
69
+ // need, so one pattern covers every source.
70
+ for (const candidate of [installed?.version, deps['@biomejs/biome']]) {
71
+ const match = typeof candidate === 'string' ? /(\d+\.\d+\.\d+)/.exec(candidate) : null;
72
+ if (match?.[1])
73
+ return match[1];
74
+ }
75
+ return BIOME_SCHEMA_FALLBACK;
76
+ }
77
+ /**
78
+ * The thin pointer config — the same shape this repo dogfoods. `fix biome` used
79
+ * to copy the whole preset inline instead, which meant the scaffolded file
80
+ * carried no `@rtorcato/repo-tooling/biome` reference for doctor's Biome check
81
+ * to match, and preset improvements never reached consumers.
82
+ */
28
83
  export async function generateBiomeConfig(targetDir) {
29
- const biomeConfigPath = path.join(targetDir, 'biome.jsonc');
30
84
  // Biome 2.x schema + shape. The base preset (extends) already defines the
31
85
  // file globs via `files.includes`; emitting the old 1.x `include`/`ignore`
32
86
  // keys here forced consumers to run `biome migrate` before `biome check`
33
87
  // would run at all.
88
+ const version = await resolveBiomeSchemaVersion(targetDir);
34
89
  const biomeConfig = {
35
- $schema: 'https://biomejs.dev/schemas/2.5.0/schema.json',
90
+ $schema: `https://biomejs.dev/schemas/${version}/schema.json`,
36
91
  extends: ['@rtorcato/repo-tooling/biome'],
37
92
  };
38
- await fs.writeJson(biomeConfigPath, biomeConfig, { spaces: 2 });
93
+ await fs.writeJson(path.join(targetDir, BIOME_CONFIG), biomeConfig, { spaces: 2 });
94
+ await fs.remove(path.join(targetDir, BIOME_LEGACY_CONFIG));
95
+ return BIOME_CONFIG;
39
96
  }
40
97
  export async function generateESLintConfig(config, targetDir) {
41
98
  const eslintConfigPath = path.join(targetDir, 'eslint.config.mjs');
@@ -51,7 +51,7 @@ ${config.testing.framework !== 'none' ? '├── tests/ # Test fi
51
51
  ├── dist/ # Build output${config.projectType === 'library' ? ' (library)' : ''}
52
52
  ├── package.json
53
53
  ${config.typescript.enabled ? '├── tsconfig.json # TypeScript configuration' : ''}
54
- ${config.linting.tool === 'biome' || config.linting.tool === 'both' ? '├── biome.jsonc # Biome configuration' : ''}
54
+ ${config.linting.tool === 'biome' || config.linting.tool === 'both' ? '├── biome.json # Biome configuration' : ''}
55
55
  ${config.linting.tool === 'eslint' || config.linting.tool === 'both' ? '├── eslint.config.mjs # ESLint configuration' : ''}
56
56
  ${config.linting.tool === 'eslint' ? '├── prettier.config.mjs # Prettier configuration' : ''}
57
57
  ${config.testing.framework === 'vitest' ? '├── vitest.config.ts # Vitest configuration' : ''}
@@ -56,7 +56,9 @@ export const FILE_CHECKS = [
56
56
  expected: `extends "${PACKAGE}/biome"`,
57
57
  matcher: /@rtorcato\/(?:js|repo)-tooling\/biome/,
58
58
  optional: true,
59
- hint: 'Run `npx @rtorcato/repo-tooling copy biome` to scaffold',
59
+ // `fix biome`, not `copy biome`: copy drops the whole preset inline, which
60
+ // carries no `extends` for the matcher above to find (#365).
61
+ hint: 'Run `npx @rtorcato/repo-tooling fix biome` to scaffold',
60
62
  },
61
63
  {
62
64
  check: 'ESLint',
@@ -7,7 +7,7 @@ import { generateHuskyConfig, generatePrePushHook } from '../../cli/generators/g
7
7
  import { CI_WORKFLOW, generateGitHubActions } from '../../cli/generators/github-actions.js';
8
8
  import { generateGitLabCI } from '../../cli/generators/gitlab-ci.js';
9
9
  import { GH_WORKFLOWS, generateGhWorkflow } from '../../cli/generators/github-workflows.js';
10
- import { generateESLintConfig, generatePrettierConfig } from '../../cli/generators/linting.js';
10
+ import { BIOME_CONFIG, generateBiomeConfig, generateESLintConfig, generatePrettierConfig, } from '../../cli/generators/linting.js';
11
11
  import { alignNodeVersion, ensureEnginesNode, ensurePackageManager, generateKnipConfig, generateNvmrc, generateSizeLimitConfig, generateVscodeExtensions, } from '../../cli/generators/misc.js';
12
12
  import { scriptsOf } from './ci.js';
13
13
  import { composeVerifyScriptFromPkg, ensureScripts } from '../../cli/generators/package-json.js';
@@ -122,13 +122,15 @@ const GH_WORKFLOW_FIXERS = GH_WORKFLOWS.map((name) => ({
122
122
  export const FIXERS = [
123
123
  {
124
124
  target: 'biome',
125
- description: 'Scaffold biome.json extending the @rtorcato/repo-tooling preset, plus the scripts that run it',
125
+ description: `Scaffold ${BIOME_CONFIG} extending the @rtorcato/repo-tooling preset, plus the scripts that run it`,
126
126
  appliesTo: ['Biome'],
127
- outputs: ['biome.json', 'package.json (scripts)'],
127
+ outputs: [BIOME_CONFIG, 'package.json (scripts)'],
128
128
  canFixDrift: true,
129
129
  async run({ targetDir }) {
130
- const result = await copyPreset('biome', targetDir);
131
- const filesWritten = [result.target];
130
+ // Shares generateBiomeConfig with the setup/resync path — the two used to
131
+ // scaffold different filenames with different contents (#365).
132
+ const written = await generateBiomeConfig(targetDir);
133
+ const filesWritten = [written];
132
134
  // A config with no way to run it left `pnpm check` undefined, which the
133
135
  // generated CI called and `fix verify` needed to compose a chain (#364).
134
136
  if (await ensureScripts(targetDir, BIOME_SCRIPTS))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtorcato/repo-tooling",
3
- "version": "3.7.2",
3
+ "version": "3.7.4",
4
4
  "description": "One CLI to scaffold, audit and fix your repo's whole toolchain — linting, tests, commits, releases & CI.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://biomejs.dev/schemas/2.5.0/schema.json",
3
3
  "vcs": {
4
- "enabled": false,
4
+ "enabled": true,
5
5
  "clientKind": "git",
6
6
  "useIgnoreFile": true
7
7
  },