diff --git a/package.json b/package.json index 5453ff16..eef99317 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "parse-package-name": "^1.0.0", "populate-all-contributors-for-repository": "^0.1.2", "prettier": "^3.4.2", + "remove-dependencies": "^0.1.0", "remove-undefined-objects": "^5.0.0", "replace-in-file": "^8.3.0", "rimraf": "^6.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 936d0a13..132e89f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -83,6 +83,9 @@ importers: prettier: specifier: ^3.4.2 version: 3.4.2 + remove-dependencies: + specifier: ^0.1.0 + version: 0.1.0 remove-undefined-objects: specifier: ^5.0.0 version: 5.0.0 @@ -3754,6 +3757,11 @@ packages: engines: {node: ^18.18.0 || ^20.9.0 || ^22.0.0} hasBin: true + remove-dependencies@0.1.0: + resolution: {integrity: sha512-K9PXkqGYkuQbRVf57SI/t3xBhw87pLbvd94zir6v4+ptJQ0TSjLWtd0ZlebtQEOfnxSchz+wgzTvG7KNpLMAbg==} + engines: {node: '>=18.3.0'} + hasBin: true + remove-undefined-objects@5.0.0: resolution: {integrity: sha512-DE8C17uIWeHaY4SqIkpQpHXm0MIdYHtIqjieWuh0I2PG8YcZRxFE6pqeEhnRetsrQ7Lu9uvSNQkDbg95NLpvnQ==} engines: {node: '>=18'} @@ -8194,6 +8202,8 @@ snapshots: - supports-color - typescript + remove-dependencies@0.1.0: {} + remove-undefined-objects@5.0.0: {} repeat-string@1.6.1: {} diff --git a/src/next/blocks/blockTSup.test.ts b/src/next/blocks/blockTSup.test.ts index fd7a1022..36010267 100644 --- a/src/next/blocks/blockTSup.test.ts +++ b/src/next/blocks/blockTSup.test.ts @@ -176,6 +176,12 @@ describe("blockTSup", () => { ", }, "scripts": [ + { + "commands": [ + "node path/to/remove-dependencies/bin/index.js @babel/core babel", + ], + "phase": 3, + }, { "commands": [ "rm -rf .babelrc* babel.config.* dist lib", diff --git a/src/next/blocks/blockTSup.ts b/src/next/blocks/blockTSup.ts index dfb82d60..30b8e650 100644 --- a/src/next/blocks/blockTSup.ts +++ b/src/next/blocks/blockTSup.ts @@ -1,6 +1,8 @@ +import { vi } from "vitest"; import { z } from "zod"; import { base } from "../base.js"; +import { resolveBin } from "../utils/resolveBin.js"; import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js"; import { blockESLint } from "./blockESLint.js"; import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js"; @@ -8,6 +10,10 @@ import { blockPackageJson } from "./blockPackageJson.js"; import { getPackageDependencies } from "./packageData.js"; import { CommandPhase } from "./phases.js"; +vi.mock("../utils/resolveBin.js", () => ({ + resolveBin: (bin: string) => `path/to/${bin}`, +})); + export const blockTSup = base.createBlock({ about: { name: "tsup", @@ -19,6 +25,12 @@ export const blockTSup = base.createBlock({ migrate() { return { scripts: [ + { + commands: [ + `node ${resolveBin("remove-dependencies/bin/index.js")} @babel/core babel`, + ], + phase: CommandPhase.Process, + }, { commands: ["rm -rf .babelrc* babel.config.* dist lib"], phase: CommandPhase.Migrations, diff --git a/src/next/blocks/blockVitest.test.ts b/src/next/blocks/blockVitest.test.ts index 2323f5ef..bd1217f1 100644 --- a/src/next/blocks/blockVitest.test.ts +++ b/src/next/blocks/blockVitest.test.ts @@ -1,9 +1,13 @@ import { testBlock } from "create-testers"; -import { describe, expect, test } from "vitest"; +import { describe, expect, test, vi } from "vitest"; import { blockVitest } from "./blockVitest.js"; import { optionsBase } from "./options.fakes.js"; +vi.mock("../utils/resolveBin.js", () => ({ + resolveBin: (bin: string) => `path/to/${bin}`, +})); + describe("blockVitest", () => { test("without addons or mode", () => { const creation = testBlock(blockVitest, { @@ -467,6 +471,12 @@ describe("blockVitest", () => { ", }, "scripts": [ + { + "commands": [ + "node path/to/remove-dependencies/bin/index.js eslint-plugin-jest eslint-plugin-mocha eslint-plugin-vitest jest mocha", + ], + "phase": 3, + }, { "commands": [ "rm .mocha* jest.config.* vitest.config.*", diff --git a/src/next/blocks/blockVitest.ts b/src/next/blocks/blockVitest.ts index 9ba0c531..192739f1 100644 --- a/src/next/blocks/blockVitest.ts +++ b/src/next/blocks/blockVitest.ts @@ -1,6 +1,7 @@ import { z } from "zod"; import { base } from "../base.js"; +import { resolveBin } from "../utils/resolveBin.js"; import { blockCSpell } from "./blockCSpell.js"; import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js"; import { blockESLint } from "./blockESLint.js"; @@ -32,6 +33,12 @@ export const blockVitest = base.createBlock({ migrate() { return { scripts: [ + { + commands: [ + `node ${resolveBin("remove-dependencies/bin/index.js")} eslint-plugin-jest eslint-plugin-mocha eslint-plugin-vitest jest mocha`, + ], + phase: CommandPhase.Process, + }, { commands: ["rm .mocha* jest.config.* vitest.config.*"], phase: CommandPhase.Migrations, diff --git a/src/steps/uninstallPackages.ts b/src/steps/uninstallPackages.ts index 6dee5893..6eab6589 100644 --- a/src/steps/uninstallPackages.ts +++ b/src/steps/uninstallPackages.ts @@ -31,6 +31,7 @@ export async function uninstallPackages(offline: boolean | undefined) { "parse-package-name", "populate-all-contributors-for-repository", "prettier", + "remove-dependencies", "remove-undefined-objects", "replace-in-file", "rimraf",