Skip to content

Commit 024e347

Browse files
feat: use remove-dependencies in blockTSup and blockVitest (#1892)
## PR Checklist - [x] Addresses an existing open issue: fixes #1889 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview 💖
1 parent d0ff0fc commit 024e347

7 files changed

+48
-1
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"parse-package-name": "^1.0.0",
6767
"populate-all-contributors-for-repository": "^0.1.2",
6868
"prettier": "^3.4.2",
69+
"remove-dependencies": "^0.1.0",
6970
"remove-undefined-objects": "^5.0.0",
7071
"replace-in-file": "^8.3.0",
7172
"rimraf": "^6.0.1",

pnpm-lock.yaml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/next/blocks/blockTSup.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ describe("blockTSup", () => {
176176
",
177177
},
178178
"scripts": [
179+
{
180+
"commands": [
181+
"node path/to/remove-dependencies/bin/index.js @babel/core babel",
182+
],
183+
"phase": 3,
184+
},
179185
{
180186
"commands": [
181187
"rm -rf .babelrc* babel.config.* dist lib",

src/next/blocks/blockTSup.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
import { vi } from "vitest";
12
import { z } from "zod";
23

34
import { base } from "../base.js";
5+
import { resolveBin } from "../utils/resolveBin.js";
46
import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js";
57
import { blockESLint } from "./blockESLint.js";
68
import { blockGitHubActionsCI } from "./blockGitHubActionsCI.js";
79
import { blockPackageJson } from "./blockPackageJson.js";
810
import { getPackageDependencies } from "./packageData.js";
911
import { CommandPhase } from "./phases.js";
1012

13+
vi.mock("../utils/resolveBin.js", () => ({
14+
resolveBin: (bin: string) => `path/to/${bin}`,
15+
}));
16+
1117
export const blockTSup = base.createBlock({
1218
about: {
1319
name: "tsup",
@@ -19,6 +25,12 @@ export const blockTSup = base.createBlock({
1925
migrate() {
2026
return {
2127
scripts: [
28+
{
29+
commands: [
30+
`node ${resolveBin("remove-dependencies/bin/index.js")} @babel/core babel`,
31+
],
32+
phase: CommandPhase.Process,
33+
},
2234
{
2335
commands: ["rm -rf .babelrc* babel.config.* dist lib"],
2436
phase: CommandPhase.Migrations,

src/next/blocks/blockVitest.test.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { testBlock } from "create-testers";
2-
import { describe, expect, test } from "vitest";
2+
import { describe, expect, test, vi } from "vitest";
33

44
import { blockVitest } from "./blockVitest.js";
55
import { optionsBase } from "./options.fakes.js";
66

7+
vi.mock("../utils/resolveBin.js", () => ({
8+
resolveBin: (bin: string) => `path/to/${bin}`,
9+
}));
10+
711
describe("blockVitest", () => {
812
test("without addons or mode", () => {
913
const creation = testBlock(blockVitest, {
@@ -467,6 +471,12 @@ describe("blockVitest", () => {
467471
",
468472
},
469473
"scripts": [
474+
{
475+
"commands": [
476+
"node path/to/remove-dependencies/bin/index.js eslint-plugin-jest eslint-plugin-mocha eslint-plugin-vitest jest mocha",
477+
],
478+
"phase": 3,
479+
},
470480
{
471481
"commands": [
472482
"rm .mocha* jest.config.* vitest.config.*",

src/next/blocks/blockVitest.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { z } from "zod";
22

33
import { base } from "../base.js";
4+
import { resolveBin } from "../utils/resolveBin.js";
45
import { blockCSpell } from "./blockCSpell.js";
56
import { blockDevelopmentDocs } from "./blockDevelopmentDocs.js";
67
import { blockESLint } from "./blockESLint.js";
@@ -32,6 +33,12 @@ export const blockVitest = base.createBlock({
3233
migrate() {
3334
return {
3435
scripts: [
36+
{
37+
commands: [
38+
`node ${resolveBin("remove-dependencies/bin/index.js")} eslint-plugin-jest eslint-plugin-mocha eslint-plugin-vitest jest mocha`,
39+
],
40+
phase: CommandPhase.Process,
41+
},
3542
{
3643
commands: ["rm .mocha* jest.config.* vitest.config.*"],
3744
phase: CommandPhase.Migrations,

src/steps/uninstallPackages.ts

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export async function uninstallPackages(offline: boolean | undefined) {
3131
"parse-package-name",
3232
"populate-all-contributors-for-repository",
3333
"prettier",
34+
"remove-dependencies",
3435
"remove-undefined-objects",
3536
"replace-in-file",
3637
"rimraf",

0 commit comments

Comments
 (0)