@rtorcato/repo-tooling 3.7.2 → 3.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.
|
@@ -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(
|
|
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,13 +20,27 @@ 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
|
|
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
|
+
* The thin pointer config — the same shape this repo dogfoods. `fix biome` used
|
|
39
|
+
* to copy the whole preset inline instead, which meant the scaffolded file
|
|
40
|
+
* carried no `@rtorcato/repo-tooling/biome` reference for doctor's Biome check
|
|
41
|
+
* to match, and preset improvements never reached consumers.
|
|
42
|
+
*/
|
|
28
43
|
export async function generateBiomeConfig(targetDir) {
|
|
29
|
-
const biomeConfigPath = path.join(targetDir, 'biome.jsonc');
|
|
30
44
|
// Biome 2.x schema + shape. The base preset (extends) already defines the
|
|
31
45
|
// file globs via `files.includes`; emitting the old 1.x `include`/`ignore`
|
|
32
46
|
// keys here forced consumers to run `biome migrate` before `biome check`
|
|
@@ -35,7 +49,9 @@ export async function generateBiomeConfig(targetDir) {
|
|
|
35
49
|
$schema: 'https://biomejs.dev/schemas/2.5.0/schema.json',
|
|
36
50
|
extends: ['@rtorcato/repo-tooling/biome'],
|
|
37
51
|
};
|
|
38
|
-
await fs.writeJson(
|
|
52
|
+
await fs.writeJson(path.join(targetDir, BIOME_CONFIG), biomeConfig, { spaces: 2 });
|
|
53
|
+
await fs.remove(path.join(targetDir, BIOME_LEGACY_CONFIG));
|
|
54
|
+
return BIOME_CONFIG;
|
|
39
55
|
}
|
|
40
56
|
export async function generateESLintConfig(config, targetDir) {
|
|
41
57
|
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.
|
|
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
|
-
|
|
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:
|
|
125
|
+
description: `Scaffold ${BIOME_CONFIG} extending the @rtorcato/repo-tooling preset, plus the scripts that run it`,
|
|
126
126
|
appliesTo: ['Biome'],
|
|
127
|
-
outputs: [
|
|
127
|
+
outputs: [BIOME_CONFIG, 'package.json (scripts)'],
|
|
128
128
|
canFixDrift: true,
|
|
129
129
|
async run({ targetDir }) {
|
|
130
|
-
|
|
131
|
-
|
|
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