Skip to content

Commit ac44d4d

Browse files
chore(deps): refactor (#4604)
1 parent 9e985e7 commit ac44d4d

File tree

28 files changed

+2030
-1957
lines changed

28 files changed

+2030
-1957
lines changed

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = {
1010
testRegex: ["/test/.*\\.(test.js|test.ts)$"],
1111
moduleFileExtensions: ["ts", "js", "json"],
1212
snapshotResolver: "<rootDir>/scripts/snapshot-resolver.js",
13-
watchPlugins: ["jest-watch-typeahead/filename", "jest-watch-typeahead/testname"],
1413
setupFilesAfterEnv: ["<rootDir>/scripts/setup-test.js"],
1514
globalTeardown: "<rootDir>/scripts/cleanup-test.js",
1615
globalSetup: "<rootDir>/scripts/global-setup.js",

package.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"test:cli": "jest test --reporters=default",
4545
"test:packages": "jest packages/ --reporters=default",
4646
"test:ci": "yarn test:cli && yarn test:packages",
47-
"test:watch": "jest test/ packages/ --watch",
4847
"publish:monorepo": "yarn build && lerna version && lerna publish from-git",
4948
"update:docs": "node ./scripts/update-docs",
5049
"prepare": "husky"
@@ -55,10 +54,10 @@
5554
"@babel/register": "^7.15.8",
5655
"@eslint/js": "^9.28.0",
5756
"@eslint/markdown": "^7.1.0",
58-
"@commitlint/cli": "^19.4.0",
59-
"@commitlint/config-conventional": "^19.2.2",
57+
"@commitlint/cli": "^20.2.0",
58+
"@commitlint/config-conventional": "^20.2.0",
6059
"@stylistic/eslint-plugin": "^5.0.0",
61-
"@types/jest": "^29.5.13",
60+
"@types/jest": "^30.0.0",
6261
"@types/node": "^22.5.5",
6362
"@types/rechoir": "^0.6.1",
6463
"coffeescript": "^2.7.0",
@@ -72,16 +71,15 @@
7271
"eslint-config-prettier": "^10.1.5",
7372
"eslint-plugin-import": "^2.32.0",
7473
"eslint-plugin-jest": "^29.0.1",
75-
"eslint-plugin-jsdoc": "^51.2.3",
74+
"eslint-plugin-jsdoc": "^61.5.0",
7675
"eslint-plugin-n": "^17.19.0",
7776
"eslint-plugin-prettier": "^5.4.1",
78-
"eslint-plugin-unicorn": "^60.0.0",
77+
"eslint-plugin-unicorn": "^62.0.0",
7978
"execa": "^5.0.0",
8079
"get-port": "^5.1.1",
8180
"globals": "^16.2.0",
8281
"husky": "^9.1.4",
83-
"jest": "^29.4.1",
84-
"jest-watch-typeahead": "^2.2.2",
82+
"jest": "^30.2.0",
8583
"lerna": "^8.1.8",
8684
"lint-staged": "^15.2.9",
8785
"mini-css-extract-plugin": "^2.6.1",
@@ -90,15 +88,14 @@
9088
"readable-stream": "^4.5.2",
9189
"sass": "^1.54.9",
9290
"sass-loader": "^16.0.2",
93-
"strip-ansi": "^6.0.1",
9491
"style-loader": "^4.0.0",
9592
"ts-jest": "^29.0.1",
9693
"ts-loader": "^9.3.1",
9794
"ts-node": "^10.9.1",
9895
"typescript": "^5.0.4",
9996
"typescript-eslint": "^8.35.0",
10097
"webpack": "^5.103.0",
101-
"webpack-bundle-analyzer": "^4.5.0",
98+
"webpack-bundle-analyzer": "^5.1.0",
10299
"webpack-dev-server": "^5.1.0"
103100
},
104101
"peerDependencies": {

smoketests/helpers.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const fs = require("node:fs");
22
const path = require("node:path");
3+
const { stripVTControlCharacters } = require("node:util");
34
const execa = require("execa");
4-
const stripAnsi = require("strip-ansi");
55

66
const ROOT_PATH = process.env.GITHUB_WORKSPACE || path.resolve(__dirname, "..");
77

@@ -48,7 +48,7 @@ const runTest = (pkg, cliArgs = [], logMessage = undefined, isSubPackage = false
4848
let hasPassed = false;
4949

5050
proc.stderr.on("data", (chunk) => {
51-
const data = stripAnsi(chunk.toString());
51+
const data = stripVTControlCharacters(chunk.toString());
5252

5353
console.log(` stderr: ${data}`);
5454

@@ -99,7 +99,7 @@ const runTestStdout = ({ packageName, cliArgs, logMessage, isSubPackage } = {})
9999
let hasPassed = false;
100100

101101
proc.stdout.on("data", (chunk) => {
102-
const data = stripAnsi(chunk.toString());
102+
const data = stripVTControlCharacters(chunk.toString());
103103

104104
console.log(` stdout: ${data}`);
105105

@@ -110,7 +110,7 @@ const runTestStdout = ({ packageName, cliArgs, logMessage, isSubPackage } = {})
110110
});
111111

112112
proc.stderr.on("data", (chunk) => {
113-
const data = stripAnsi(chunk.toString());
113+
const data = stripVTControlCharacters(chunk.toString());
114114
console.log(` stderr: ${data}`);
115115
});
116116

@@ -153,7 +153,7 @@ const runTestStdoutWithInput = ({
153153
let hasPassed = false;
154154

155155
proc.stdout.on("data", (chunk) => {
156-
const data = stripAnsi(chunk.toString());
156+
const data = stripVTControlCharacters(chunk.toString());
157157
console.log(` stdout: ${data}`);
158158

159159
if (data.includes(logMessage)) {
@@ -169,7 +169,7 @@ const runTestStdoutWithInput = ({
169169
});
170170

171171
proc.stderr.on("data", (chunk) => {
172-
const data = stripAnsi(chunk.toString());
172+
const data = stripVTControlCharacters(chunk.toString());
173173
console.log(` stderr: ${data}`);
174174
});
175175

@@ -214,7 +214,7 @@ const runTestWithHelp = (pkg, cliArgs = [], logMessage = undefined, isSubPackage
214214
let hasPassed = false;
215215

216216
proc.stderr.on("data", (chunk) => {
217-
const data = stripAnsi(chunk.toString());
217+
const data = stripVTControlCharacters(chunk.toString());
218218

219219
console.log(` stderr: ${data}`);
220220

test/api/__snapshots__/CLI.test.js.snap.webpack5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`CLI API custom help output should display help information 1`] = `
44
[

test/api/do-install.test.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22

3-
const stripAnsi = require("strip-ansi");
3+
const { stripVTControlCharacters } = require("node:util");
44
const CLI = require("../../packages/webpack-cli/lib/webpack-cli");
55

66
const readlineQuestionMock = jest.fn();
@@ -39,9 +39,9 @@ describe("doInstall", () => {
3939
const installResult = await cli.doInstall("test-package");
4040

4141
expect(installResult).toBe("test-package");
42-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
43-
expect(spawnMock.mock.calls).toHaveLength(1);
44-
expect(stripAnsi(readlineQuestionMock.mock.calls[0][0])).toContain(
42+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
43+
expect(spawnMock).toHaveBeenCalledTimes(1);
44+
expect(stripVTControlCharacters(readlineQuestionMock.mock.calls[0][0])).toContain(
4545
"Would you like to install 'test-package' package? (That will run 'npm install -D test-package')",
4646
);
4747

@@ -57,9 +57,9 @@ describe("doInstall", () => {
5757
const installResult = await cli.doInstall("test-package");
5858

5959
expect(installResult).toBe("test-package");
60-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
61-
expect(spawnMock.mock.calls).toHaveLength(1);
62-
expect(stripAnsi(readlineQuestionMock.mock.calls[0][0])).toContain(
60+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
61+
expect(spawnMock).toHaveBeenCalledTimes(1);
62+
expect(stripVTControlCharacters(readlineQuestionMock.mock.calls[0][0])).toContain(
6363
"Would you like to install 'test-package' package? (That will run 'yarn add -D test-package')",
6464
);
6565

@@ -75,9 +75,9 @@ describe("doInstall", () => {
7575
const installResult = await cli.doInstall("test-package");
7676

7777
expect(installResult).toBe("test-package");
78-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
79-
expect(spawnMock.mock.calls).toHaveLength(1);
80-
expect(stripAnsi(readlineQuestionMock.mock.calls[0][0])).toContain(
78+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
79+
expect(spawnMock).toHaveBeenCalledTimes(1);
80+
expect(stripVTControlCharacters(readlineQuestionMock.mock.calls[0][0])).toContain(
8181
"Would you like to install 'test-package' package? (That will run 'pnpm install -D test-package')",
8282
);
8383

@@ -94,10 +94,10 @@ describe("doInstall", () => {
9494
const installResult = await cli.doInstall("test-package", { preMessage });
9595

9696
expect(installResult).toBe("test-package");
97-
expect(preMessage.mock.calls).toHaveLength(1);
98-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
99-
expect(spawnMock.mock.calls).toHaveLength(1);
100-
expect(stripAnsi(readlineQuestionMock.mock.calls[0][0])).toContain(
97+
expect(preMessage).toHaveBeenCalledTimes(1);
98+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
99+
expect(spawnMock).toHaveBeenCalledTimes(1);
100+
expect(stripVTControlCharacters(readlineQuestionMock.mock.calls[0][0])).toContain(
101101
"Would you like to install 'test-package' package? (That will run 'npm install -D test-package')",
102102
);
103103

@@ -113,9 +113,9 @@ describe("doInstall", () => {
113113
const installResult = await cli.doInstall("test-package");
114114

115115
expect(installResult).toBe("test-package");
116-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
117-
expect(spawnMock.mock.calls).toHaveLength(1);
118-
expect(stripAnsi(readlineQuestionMock.mock.calls[0][0])).toContain(
116+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
117+
expect(spawnMock).toHaveBeenCalledTimes(1);
118+
expect(stripVTControlCharacters(readlineQuestionMock.mock.calls[0][0])).toContain(
119119
"Would you like to install 'test-package' package? (That will run 'npm install -D test-package')",
120120
);
121121

@@ -131,9 +131,9 @@ describe("doInstall", () => {
131131
const installResult = await cli.doInstall("test-package");
132132

133133
expect(installResult).toBe("test-package");
134-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
135-
expect(spawnMock.mock.calls).toHaveLength(1);
136-
expect(stripAnsi(readlineQuestionMock.mock.calls[0][0])).toContain(
134+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
135+
expect(spawnMock).toHaveBeenCalledTimes(1);
136+
expect(stripVTControlCharacters(readlineQuestionMock.mock.calls[0][0])).toContain(
137137
"Would you like to install 'test-package' package? (That will run 'npm install -D test-package')",
138138
);
139139

@@ -149,9 +149,9 @@ describe("doInstall", () => {
149149
const installResult = await cli.doInstall("test-package");
150150

151151
expect(installResult).toBe("test-package");
152-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
153-
expect(spawnMock.mock.calls).toHaveLength(1);
154-
expect(stripAnsi(readlineQuestionMock.mock.calls[0][0])).toContain(
152+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
153+
expect(spawnMock).toHaveBeenCalledTimes(1);
154+
expect(stripVTControlCharacters(readlineQuestionMock.mock.calls[0][0])).toContain(
155155
"Would you like to install 'test-package' package? (That will run 'npm install -D test-package')",
156156
);
157157

@@ -167,9 +167,9 @@ describe("doInstall", () => {
167167
const installResult = await cli.doInstall("test-package");
168168

169169
expect(installResult).toBeUndefined();
170-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
170+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
171171
// runCommand should not be called, because the installation is not confirmed
172-
expect(spawnMock.mock.calls).toHaveLength(0);
172+
expect(spawnMock).not.toHaveBeenCalled();
173173
expect(mockExit.mock.calls[0][0]).toBe(2);
174174

175175
mockExit.mockRestore();
@@ -182,9 +182,9 @@ describe("doInstall", () => {
182182
const installResult = await cli.doInstall("test-package");
183183

184184
expect(installResult).toBeUndefined();
185-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
185+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
186186
// runCommand should not be called, because the installation is not confirmed
187-
expect(spawnMock.mock.calls).toHaveLength(0);
187+
expect(spawnMock).not.toHaveBeenCalled();
188188
expect(mockExit.mock.calls[0][0]).toBe(2);
189189

190190
mockExit.mockRestore();
@@ -197,9 +197,9 @@ describe("doInstall", () => {
197197
const installResult = await cli.doInstall("test-package");
198198

199199
expect(installResult).toBeUndefined();
200-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
200+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
201201
// runCommand should not be called, because the installation is not confirmed
202-
expect(spawnMock.mock.calls).toHaveLength(0);
202+
expect(spawnMock).not.toHaveBeenCalled();
203203
expect(mockExit.mock.calls[0][0]).toBe(2);
204204

205205
mockExit.mockRestore();
@@ -212,9 +212,9 @@ describe("doInstall", () => {
212212
const installResult = await cli.doInstall("test-package");
213213

214214
expect(installResult).toBeUndefined();
215-
expect(readlineQuestionMock.mock.calls).toHaveLength(1);
215+
expect(readlineQuestionMock).toHaveBeenCalledTimes(1);
216216
// runCommand should not be called, because the installation is not confirmed
217-
expect(spawnMock.mock.calls).toHaveLength(0);
217+
expect(spawnMock).not.toHaveBeenCalled();
218218
expect(mockExit.mock.calls[0][0]).toBe(2);
219219

220220
mockExit.mockRestore();

test/api/get-default-package-manager.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,56 +46,56 @@ describe("getPackageManager", () => {
4646
cwdSpy.mockReturnValue(testYarnLockPath);
4747

4848
expect(cli.getDefaultPackageManager()).toBe("yarn");
49-
expect(syncMock.mock.calls).toHaveLength(0);
49+
expect(syncMock).not.toHaveBeenCalled();
5050
});
5151

5252
it("should find package-lock.json", () => {
5353
cwdSpy.mockReturnValue(testNpmLockPath);
5454

5555
expect(cli.getDefaultPackageManager()).toBe("npm");
56-
expect(syncMock.mock.calls).toHaveLength(0);
56+
expect(syncMock).not.toHaveBeenCalled();
5757
});
5858

5959
it("should find pnpm-lock.yaml", () => {
6060
cwdSpy.mockReturnValue(testPnpmLockPath);
6161

6262
expect(cli.getDefaultPackageManager()).toBe("pnpm");
63-
expect(syncMock.mock.calls).toHaveLength(0);
63+
expect(syncMock).not.toHaveBeenCalled();
6464
});
6565

6666
it("should prioritize npm over pnpm", () => {
6767
cwdSpy.mockReturnValue(testNpmAndPnpmPath);
6868

6969
expect(cli.getDefaultPackageManager()).toBe("npm");
70-
expect(syncMock.mock.calls).toHaveLength(0);
70+
expect(syncMock).not.toHaveBeenCalled();
7171
});
7272

7373
it("should prioritize npm over yarn", () => {
7474
cwdSpy.mockReturnValue(testNpmAndYarnPath);
7575

7676
expect(cli.getDefaultPackageManager()).toBe("npm");
77-
expect(syncMock.mock.calls).toHaveLength(0);
77+
expect(syncMock).not.toHaveBeenCalled();
7878
});
7979

8080
it("should prioritize yarn over pnpm", () => {
8181
cwdSpy.mockReturnValue(testYarnAndPnpmPath);
8282

8383
expect(cli.getDefaultPackageManager()).toBe("yarn");
84-
expect(syncMock.mock.calls).toHaveLength(0);
84+
expect(syncMock).not.toHaveBeenCalled();
8585
});
8686

8787
it("should prioritize npm with many lock files", () => {
8888
cwdSpy.mockReturnValue(testAllPath);
8989

9090
expect(cli.getDefaultPackageManager()).toBe("npm");
91-
expect(syncMock.mock.calls).toHaveLength(0);
91+
expect(syncMock).not.toHaveBeenCalled();
9292
});
9393

9494
it("should prioritize global npm over other package managers", () => {
9595
cwdSpy.mockReturnValue(noLockPath);
9696

9797
expect(cli.getDefaultPackageManager()).toBe("npm");
98-
expect(syncMock.mock.calls).toHaveLength(1);
98+
expect(syncMock).toHaveBeenCalledTimes(1);
9999
});
100100

101101
it("should throw error if no package manager is found", () => {
@@ -110,6 +110,6 @@ describe("getPackageManager", () => {
110110
expect(cli.getDefaultPackageManager()).toBeFalsy();
111111
expect(mockExit).toHaveBeenCalledWith(2);
112112
expect(consoleMock).toHaveBeenCalledTimes(1);
113-
expect(syncMock.mock.calls).toHaveLength(3); // 3 calls for npm, yarn and pnpm
113+
expect(syncMock).toHaveBeenCalledTimes(3); // 3 calls for npm, yarn and pnpm
114114
});
115115
});

test/build/import-local/import-local.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe("import local", () => {
1414
const { exitCode, stderr, stdout } = await run(__dirname, [], {
1515
env: { WEBPACK_CLI_SKIP_IMPORT_LOCAL: true },
1616
});
17-
expect(importLocalMock).toHaveBeenCalledTimes(0);
17+
expect(importLocalMock).not.toHaveBeenCalled();
1818
expect(exitCode).toBe(0);
1919
expect(stderr).toBeFalsy();
2020
expect(stdout).toBeTruthy();

test/build/output/__snapshots__/output-named-bundles.test.js.snap.webpack4

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/build/output/__snapshots__/output-named-bundles.test.js.snap.webpack5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`output flag named bundles should output file in bin directory using default webpack config with warning for empty output value: stderr 1`] = `
44
"[webpack-cli] Error: Option '-o, --output-path <value>' argument missing

test/build/stats/flags/__snapshots__/stats.test.js.snap.webpack5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`stats flag should log error when an unknown flag stats value is passed: stderr 1`] = `
44
"[webpack-cli] Invalid value 'foo' for the '--stats' option

0 commit comments

Comments
 (0)