Skip to content

Commit

Permalink
feat: use remove-dependencies in blockTSup and blockVitest (#1892)
Browse files Browse the repository at this point in the history
## 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

💖
  • Loading branch information
JoshuaKGoldberg authored Jan 16, 2025
1 parent d0ff0fc commit 024e347
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/next/blocks/blockTSup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions src/next/blocks/blockTSup.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
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";
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",
Expand All @@ -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,
Expand Down
12 changes: 11 additions & 1 deletion src/next/blocks/blockVitest.test.ts
Original file line number Diff line number Diff line change
@@ -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, {
Expand Down Expand Up @@ -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.*",
Expand Down
7 changes: 7 additions & 0 deletions src/next/blocks/blockVitest.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/steps/uninstallPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 024e347

Please sign in to comment.