Skip to content

Commit c15b908

Browse files
committed
chore: move undici to undici/v6
1 parent 5c5e00f commit c15b908

16 files changed

+61
-29
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { configs as sharedConfigs } from '@3846masa/configs/eslint';
22

33
/** @type {import('eslint').Linter.Config[]} */
44
const configs = [
5-
{ ignores: ['dist/', 'http/index.js', 'undici/index.js'] },
5+
{ ignores: ['dist/', 'http/index.js', 'undici/index.js', 'undici/v6/index.js'] },
66
...sharedConfigs,
77
{
88
files: ['examples/**/*'],

jest.config.js

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
/** @type {import('jest').Config} */
22
const config = {
3-
extensionsToTreatAsEsm: ['.ts'],
4-
injectGlobals: false,
5-
roots: ['./src'],
6-
setupFiles: ['./jest/setup.ts'],
7-
testMatch: ['**/__tests__/*.spec.ts'],
8-
transform: {
9-
'\\.+(ts)$': 'babel-jest',
10-
},
3+
projects: [
4+
{
5+
displayName: 'default',
6+
extensionsToTreatAsEsm: ['.ts'],
7+
injectGlobals: false,
8+
roots: ['./src'],
9+
setupFiles: ['./jest/setup.ts'],
10+
testMatch: ['**/__tests__/*.spec.ts', '!**/undici/v6/__tests__/*.spec.ts'],
11+
transform: {
12+
'\\.+(ts)$': 'babel-jest',
13+
},
14+
},
15+
{
16+
displayName: 'undici@6',
17+
extensionsToTreatAsEsm: ['.ts'],
18+
injectGlobals: false,
19+
moduleNameMapper: {
20+
'^undici$': 'undici@v6',
21+
'^undici/(.*)$': 'undici@v6/$1',
22+
},
23+
roots: ['./src'],
24+
setupFiles: ['./jest/setup.ts'],
25+
testMatch: ['**/undici/v6/__tests__/*.spec.ts'],
26+
transform: {
27+
'\\.+(ts)$': 'babel-jest',
28+
},
29+
},
30+
],
1131
};
1232

1333
module.exports = config;

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"author": "3846masa <[email protected]>",
3333
"exports": {
3434
"./http": "./http/index.js",
35-
"./undici": "./undici/index.js"
35+
"./undici": "./undici/index.js",
36+
"./undici/v6": "./undici/v6/index.js"
3637
},
3738
"files": [
3839
"dist",
@@ -95,6 +96,7 @@
9596
"tough-cookie": "5.1.2",
9697
"typescript": "5.8.3",
9798
"undici": "7.8.0",
99+
"undici@v6": "npm:[email protected]",
98100
"urllib": "4.4.0"
99101
},
100102
"peerDependencies": {

src/undici/__tests__/global_fetch.spec.ts renamed to src/undici/v6/__tests__/global_fetch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { expect, jest, test } from '@jest/globals';
55
import semver from 'semver';
66
import { CookieJar } from 'tough-cookie';
77

8-
import { createTestServer } from '../../__tests__/helpers';
8+
import { createTestServer } from '../../../__tests__/helpers';
99
import { CookieAgent } from '../cookie_agent';
1010

1111
if (semver.lt(process.version, 'v18.2.0')) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect, jest, test } from '@jest/globals';
44
import { CookieJar } from 'tough-cookie';
55
import { request } from 'undici';
66

7-
import { createTestServer } from '../../__tests__/helpers';
7+
import { createTestServer } from '../../../__tests__/helpers';
88
import { CookieAgent } from '../cookie_agent';
99

1010
test('should set cookies to CookieJar from Set-Cookie header', async () => {

src/undici/__tests__/undici_fetch.spec.ts renamed to src/undici/v6/__tests__/undici_fetch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect, jest, test } from '@jest/globals';
44
import { CookieJar } from 'tough-cookie';
55
import { fetch } from 'undici';
66

7-
import { createTestServer } from '../../__tests__/helpers';
7+
import { createTestServer } from '../../../__tests__/helpers';
88
import { CookieAgent } from '../cookie_agent';
99

1010
test('should set cookies to CookieJar from Set-Cookie header', async () => {

src/undici/__tests__/undici_proxy.spec.ts renamed to src/undici/v6/__tests__/undici_proxy.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, jest, test } from '@jest/globals';
22
import { CookieJar } from 'tough-cookie';
33
import { ProxyAgent, request } from 'undici';
44

5-
import { createTestServerWithProxy } from '../../__tests__/helpers';
5+
import { createTestServerWithProxy } from '../../../__tests__/helpers';
66
import { CookieClient } from '../cookie_client';
77

88
test('should set cookies to CookieJar from Set-Cookie header', async () => {

src/undici/__tests__/urllib.spec.ts renamed to src/undici/v6/__tests__/urllib.spec.skip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { expect, jest, test } from '@jest/globals';
44
import { CookieJar } from 'tough-cookie';
55
import { request } from 'urllib';
66

7-
import { createTestServer } from '../../__tests__/helpers';
7+
import { createTestServer } from '../../../__tests__/helpers';
88
import { CookieAgent } from '../index';
99

1010
test('should set cookies to CookieJar from Set-Cookie header', async () => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Agent, errors, Pool } from 'undici';
22

3-
import type { CookieOptions } from '../cookie_options';
4-
import { validateCookieOptions } from '../utils/validate_cookie_options';
3+
import type { CookieOptions } from '../../cookie_options';
4+
import { validateCookieOptions } from '../../utils/validate_cookie_options';
55

66
import { CookieClient } from './cookie_client';
77

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import type { Agent, Dispatcher } from 'undici';
22
import { Client, RedirectHandler } from 'undici';
33
import Symbols from 'undici/lib/core/symbols';
44

5-
import type { CookieOptions } from '../cookie_options';
6-
import { createCookieHeaderValue } from '../utils/create_cookie_header_value';
7-
import { validateCookieOptions } from '../utils/validate_cookie_options';
5+
import type { CookieOptions } from '../../cookie_options';
6+
import { convertToHeadersObject } from '../../utils/convert_to_headers_object';
7+
import { createCookieHeaderValue } from '../../utils/create_cookie_header_value';
8+
import { validateCookieOptions } from '../../utils/validate_cookie_options';
89

910
import { CookieHandler } from './cookie_handler';
10-
import { convertToHeadersObject } from './utils/convert_to_headers_object';
1111

1212
const kCookieOptions = Symbol('cookieOptions');
1313

@@ -34,7 +34,7 @@ function createCookieClient<BaseClient extends Client = Client, BaseClientOption
3434
}
3535
}
3636

37-
override [Symbols.kDispatch](opts: Agent.DispatchOptions, handler: Dispatcher.DispatchHandlers) {
37+
override [Symbols.kDispatch](opts: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler) {
3838
const { maxRedirections = this[Symbols.kMaxRedirections] } = opts;
3939

4040
if (maxRedirections) {

0 commit comments

Comments
 (0)