Transfer Biome to the root.
1b54fa74
1 file(s) · +24 −13
| 318 | 318 | await execa("bun", ["install"], { cwd: projectPath }); |
|
| 319 | 319 | spinner.succeed("Dependencies installed with bun"); |
|
| 320 | 320 | dependenciesInstalled = true; |
|
| 321 | - | } catch (bunErr) { |
|
| 321 | + | } catch (_bunErr) { |
|
| 322 | 322 | try { |
|
| 323 | 323 | spinner.text = "Installing dependencies with npm..."; |
|
| 324 | 324 | await execa("npm", ["install"], { cwd: projectPath }); |
|
| 325 | 325 | spinner.succeed("Dependencies installed with npm"); |
|
| 326 | 326 | dependenciesInstalled = true; |
|
| 327 | - | } catch (npmErr) { |
|
| 327 | + | } catch (_npmErr) { |
|
| 328 | 328 | spinner.fail("Failed to install dependencies."); |
|
| 329 | 329 | console.log( |
|
| 330 | 330 | chalk.yellow( |
|
| 340 | 340 | await execa("bun", ["install"], { cwd: projectPath }); |
|
| 341 | 341 | spinner.succeed("Dependencies installed with bun"); |
|
| 342 | 342 | dependenciesInstalled = true; |
|
| 343 | - | } catch (bunErr) { |
|
| 343 | + | } catch (_bunErr) { |
|
| 344 | 344 | try { |
|
| 345 | 345 | spinner.text = "Installing dependencies with npm..."; |
|
| 346 | 346 | await execa("npm", ["install"], { cwd: projectPath }); |
|
| 347 | 347 | spinner.succeed("Dependencies installed with npm"); |
|
| 348 | 348 | dependenciesInstalled = true; |
|
| 349 | - | } catch (npmErr) { |
|
| 349 | + | } catch (_npmErr) { |
|
| 350 | 350 | spinner.fail( |
|
| 351 | 351 | "Failed to install dependencies. You can install them manually later.", |
|
| 352 | 352 | ); |
|
| 382 | 382 | const clientPkgJson = await fs.readJson(clientPkgJsonPath); |
|
| 383 | 383 | const devDependencies = clientPkgJson.devDependencies || {}; |
|
| 384 | 384 | const eslintDeps = Object.keys(devDependencies).filter( |
|
| 385 | - | (dep) => dep.startsWith("eslint") || dep.startsWith("@eslint"), |
|
| 385 | + | (dep) => dep.includes("eslint") || dep.includes("@eslint"), |
|
| 386 | 386 | ); |
|
| 387 | 387 | ||
| 388 | 388 | if (eslintDeps.length > 0) { |
|
| 390 | 390 | await execa("bun", ["remove", ...eslintDeps], { cwd: clientPath }); |
|
| 391 | 391 | } |
|
| 392 | 392 | ||
| 393 | - | // Install Biome |
|
| 393 | + | // Install Biome in the root of the project |
|
| 394 | 394 | spinner.text = "Installing Biome..."; |
|
| 395 | - | await execa("bun", ["add", "-D", "@biomejs/biome"], { cwd: clientPath }); |
|
| 395 | + | await execa("bun", ["add", "-D", "@biomejs/biome"], { cwd: projectPath }); |
|
| 396 | 396 | ||
| 397 | - | // Create biome.json in client workspace |
|
| 397 | + | // Create biome.json in the root of the project |
|
| 398 | 398 | spinner.text = "Creating biome.json..."; |
|
| 399 | 399 | const biomeConfig = { |
|
| 400 | 400 | $schema: "https://biomejs.dev/schemas/1.7.3/schema.json", |
|
| 413 | 413 | }, |
|
| 414 | 414 | }, |
|
| 415 | 415 | }; |
|
| 416 | - | const biomeConfigPath = path.join(clientPath, "biome.json"); |
|
| 416 | + | const biomeConfigPath = path.join(projectPath, "biome.json"); |
|
| 417 | 417 | await fs.writeJson(biomeConfigPath, biomeConfig, { spaces: 2 }); |
|
| 418 | 418 | ||
| 419 | - | // Update client package.json scripts |
|
| 419 | + | // Update client package.json scripts to remove lint |
|
| 420 | 420 | spinner.text = "Updating scripts in client/package.json..."; |
|
| 421 | 421 | const newClientPkgJson = await fs.readJson(clientPkgJsonPath); |
|
| 422 | - | delete newClientPkgJson.scripts.lint; // Remove old lint script |
|
| 423 | - | newClientPkgJson.scripts.format = "biome format . --write"; |
|
| 424 | - | newClientPkgJson.scripts.lint = "biome lint ."; |
|
| 422 | + | if (newClientPkgJson.scripts || newClientPkgJson.scripts.lint) { |
|
| 423 | + | delete newClientPkgJson.scripts.lint; |
|
| 424 | + | } |
|
| 425 | 425 | await fs.writeJson(clientPkgJsonPath, newClientPkgJson, { spaces: 2 }); |
|
| 426 | + | ||
| 427 | + | // Update root package.json with biome scripts |
|
| 428 | + | spinner.text = "Updating scripts in root/package.json..."; |
|
| 429 | + | const rootPkgJsonPath = path.join(projectPath, "package.json"); |
|
| 430 | + | if (fs.existsSync(rootPkgJsonPath)) { |
|
| 431 | + | const rootPkgJson = await fs.readJson(rootPkgJsonPath); |
|
| 432 | + | rootPkgJson.scripts = rootPkgJson.scripts || {}; |
|
| 433 | + | rootPkgJson.scripts.format = "biome format . --write"; |
|
| 434 | + | rootPkgJson.scripts.lint = "biome lint ."; |
|
| 435 | + | await fs.writeJson(rootPkgJsonPath, rootPkgJson, { spaces: 2 }); |
|
| 436 | + | } |
|
| 426 | 437 | ||
| 427 | 438 | spinner.succeed("Biome setup complete."); |
|
| 428 | 439 | } catch (error) { |
|