Skip to content

Commit 5c2e597

Browse files
Add publish types script (#2273)
* add publish types script * use postpublish script * 5.24.0-test.0 * 5.24.0-test.1 * uncomment * 5.24.0-test.2 * simplify automation * 5.24.0-test.3 * fix script * 5.24.0-test.4 * fix script * 5.24.0-test.5 * [email protected] * restore versions * delete generated file * Update update-undici-types-version.js Co-authored-by: Superchupu <[email protected]> * fix contributor list and fix types export * this should fix types * one more adjustment * 5.24.0-test.6 * [email protected] * revert versions and add README for undici-types --------- Co-authored-by: Superchupu <[email protected]>
1 parent 985b381 commit 5c2e597

6 files changed

Lines changed: 169 additions & 57 deletions

File tree

index.d.ts

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,3 @@
1-
import Dispatcher from'./types/dispatcher'
2-
import { setGlobalDispatcher, getGlobalDispatcher } from './types/global-dispatcher'
3-
import { setGlobalOrigin, getGlobalOrigin } from './types/global-origin'
4-
import Pool from'./types/pool'
5-
import { RedirectHandler, DecoratorHandler } from './types/handlers'
6-
7-
import BalancedPool from './types/balanced-pool'
8-
import Client from'./types/client'
9-
import buildConnector from'./types/connector'
10-
import errors from'./types/errors'
11-
import Agent from'./types/agent'
12-
import MockClient from'./types/mock-client'
13-
import MockPool from'./types/mock-pool'
14-
import MockAgent from'./types/mock-agent'
15-
import mockErrors from'./types/mock-errors'
16-
import ProxyAgent from'./types/proxy-agent'
17-
import { request, pipeline, stream, connect, upgrade } from './types/api'
18-
19-
export * from './types/cookies'
20-
export * from './types/fetch'
21-
export * from './types/file'
22-
export * from './types/filereader'
23-
export * from './types/formdata'
24-
export * from './types/diagnostics-channel'
25-
export * from './types/websocket'
26-
export * from './types/content-type'
27-
export * from './types/cache'
28-
export { Interceptable } from './types/mock-interceptor'
29-
30-
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
1+
export * from './types/index'
2+
import Undici from './types/index'
313
export default Undici
32-
33-
declare namespace Undici {
34-
var Dispatcher: typeof import('./types/dispatcher').default
35-
var Pool: typeof import('./types/pool').default;
36-
var RedirectHandler: typeof import ('./types/handlers').RedirectHandler
37-
var DecoratorHandler: typeof import ('./types/handlers').DecoratorHandler
38-
var createRedirectInterceptor: typeof import ('./types/interceptors').createRedirectInterceptor
39-
var BalancedPool: typeof import('./types/balanced-pool').default;
40-
var Client: typeof import('./types/client').default;
41-
var buildConnector: typeof import('./types/connector').default;
42-
var errors: typeof import('./types/errors').default;
43-
var Agent: typeof import('./types/agent').default;
44-
var setGlobalDispatcher: typeof import('./types/global-dispatcher').setGlobalDispatcher;
45-
var getGlobalDispatcher: typeof import('./types/global-dispatcher').getGlobalDispatcher;
46-
var request: typeof import('./types/api').request;
47-
var stream: typeof import('./types/api').stream;
48-
var pipeline: typeof import('./types/api').pipeline;
49-
var connect: typeof import('./types/api').connect;
50-
var upgrade: typeof import('./types/api').upgrade;
51-
var MockClient: typeof import('./types/mock-client').default;
52-
var MockPool: typeof import('./types/mock-pool').default;
53-
var MockAgent: typeof import('./types/mock-agent').default;
54-
var mockErrors: typeof import('./types/mock-errors').default;
55-
var fetch: typeof import('./types/fetch').fetch;
56-
var caches: typeof import('./types/cache').caches;
57-
}

package.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,41 @@
1111
"url": "git+https://github.com/nodejs/undici.git"
1212
},
1313
"license": "MIT",
14-
"author": "Matteo Collina <[email protected]>",
1514
"contributors": [
15+
{
16+
"name": "Daniele Belardi",
17+
"url": "https://github.com/dnlup",
18+
"author": true
19+
},
20+
{
21+
"name": "Ethan Arrowood",
22+
"url": "https://github.com/ethan-arrowood",
23+
"author": true
24+
},
25+
{
26+
"name": "Matteo Collina",
27+
"url": "https://github.com/mcollina",
28+
"author": true
29+
},
30+
{
31+
"name": "Matthew Aitken",
32+
"url": "https://github.com/KhafraDev",
33+
"author": true
34+
},
1635
{
1736
"name": "Robert Nagy",
1837
"url": "https://github.com/ronag",
1938
"author": true
39+
},
40+
{
41+
"name": "Szymon Marczak",
42+
"url": "https://github.com/szmarczak",
43+
"author": true
44+
},
45+
{
46+
"name": "Tomas Della Vedova",
47+
"url": "https://github.com/delvedor",
48+
"author": true
2049
}
2150
],
2251
"keywords": [
@@ -64,6 +93,7 @@
6493
"bench:run": "CONNECTIONS=1 node benchmarks/benchmark.js; CONNECTIONS=50 node benchmarks/benchmark.js",
6594
"serve:website": "docsify serve .",
6695
"prepare": "husky install",
96+
"postpublish": "node scripts/update-undici-types-version.js && cd types && npm publish",
6797
"fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
6898
},
6999
"devDependencies": {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fs = require('node:fs')
2+
const path = require('node:path')
3+
const childProcess = require('node:child_process')
4+
5+
const packageJSONPath = path.join(__dirname, '..', 'package.json')
6+
const packageJSONRaw = fs.readFileSync(packageJSONPath, 'utf-8')
7+
const packageJSON = JSON.parse(packageJSONRaw)
8+
const version = packageJSON.version
9+
10+
const packageTypesJSONPath = path.join(__dirname, '..', 'types', 'package.json')
11+
const packageTypesJSONRaw = fs.readFileSync(packageTypesJSONPath, 'utf-8')
12+
const packageTypesJSON = JSON.parse(packageTypesJSONRaw)
13+
packageTypesJSON.version = version
14+
15+
fs.writeFileSync(packageTypesJSONPath, JSON.stringify(packageTypesJSON, null, 2))
16+
17+
childProcess.execSync('git add types/package.json', { cwd: path.join(__dirname, '..') })
18+
childProcess.execSync(`git commit -n -m 'undici-types@${version}'`, { cwd: path.join(__dirname, '..') })

types/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# undici-types
2+
3+
This package is a dual-publish of the [undici](https://www.npmjs.com/package/undici) library types. The `undici` package **still contains types**. This package is for users who _only_ need undici types (such as for `@types/node`). It is published alongside every release of `undici`, so you can always use the same version.
4+
5+
- [GitHub nodejs/undici](https://github.com/nodejs/undici)
6+
- [Undici Documentation](https://undici.nodejs.org/#/)

types/index.d.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import Dispatcher from'./dispatcher'
2+
import { setGlobalDispatcher, getGlobalDispatcher } from './global-dispatcher'
3+
import { setGlobalOrigin, getGlobalOrigin } from './global-origin'
4+
import Pool from'./pool'
5+
import { RedirectHandler, DecoratorHandler } from './handlers'
6+
7+
import BalancedPool from './balanced-pool'
8+
import Client from'./client'
9+
import buildConnector from'./connector'
10+
import errors from'./errors'
11+
import Agent from'./agent'
12+
import MockClient from'./mock-client'
13+
import MockPool from'./mock-pool'
14+
import MockAgent from'./mock-agent'
15+
import mockErrors from'./mock-errors'
16+
import ProxyAgent from'./proxy-agent'
17+
import { request, pipeline, stream, connect, upgrade } from './api'
18+
19+
export * from './cookies'
20+
export * from './fetch'
21+
export * from './file'
22+
export * from './filereader'
23+
export * from './formdata'
24+
export * from './diagnostics-channel'
25+
export * from './websocket'
26+
export * from './content-type'
27+
export * from './cache'
28+
export { Interceptable } from './mock-interceptor'
29+
30+
export { Dispatcher, BalancedPool, Pool, Client, buildConnector, errors, Agent, request, stream, pipeline, connect, upgrade, setGlobalDispatcher, getGlobalDispatcher, setGlobalOrigin, getGlobalOrigin, MockClient, MockPool, MockAgent, mockErrors, ProxyAgent, RedirectHandler, DecoratorHandler }
31+
export default Undici
32+
33+
declare namespace Undici {
34+
var Dispatcher: typeof import('./dispatcher').default
35+
var Pool: typeof import('./pool').default;
36+
var RedirectHandler: typeof import ('./handlers').RedirectHandler
37+
var DecoratorHandler: typeof import ('./handlers').DecoratorHandler
38+
var createRedirectInterceptor: typeof import ('./interceptors').createRedirectInterceptor
39+
var BalancedPool: typeof import('./balanced-pool').default;
40+
var Client: typeof import('./client').default;
41+
var buildConnector: typeof import('./connector').default;
42+
var errors: typeof import('./errors').default;
43+
var Agent: typeof import('./agent').default;
44+
var setGlobalDispatcher: typeof import('./global-dispatcher').setGlobalDispatcher;
45+
var getGlobalDispatcher: typeof import('./global-dispatcher').getGlobalDispatcher;
46+
var request: typeof import('./api').request;
47+
var stream: typeof import('./api').stream;
48+
var pipeline: typeof import('./api').pipeline;
49+
var connect: typeof import('./api').connect;
50+
var upgrade: typeof import('./api').upgrade;
51+
var MockClient: typeof import('./mock-client').default;
52+
var MockPool: typeof import('./mock-pool').default;
53+
var MockAgent: typeof import('./mock-agent').default;
54+
var mockErrors: typeof import('./mock-errors').default;
55+
var fetch: typeof import('./fetch').fetch;
56+
var caches: typeof import('./cache').caches;
57+
}

types/package.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "undici-types",
3+
"version": "5.24.0",
4+
"description": "A stand-alone types package for Undici",
5+
"homepage": "https://undici.nodejs.org",
6+
"bugs": {
7+
"url": "https://github.com/nodejs/undici/issues"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/nodejs/undici.git"
12+
},
13+
"license": "MIT",
14+
"types": "index.d.ts",
15+
"files": [
16+
"*.d.ts"
17+
],
18+
"contributors": [
19+
{
20+
"name": "Daniele Belardi",
21+
"url": "https://github.com/dnlup",
22+
"author": true
23+
},
24+
{
25+
"name": "Ethan Arrowood",
26+
"url": "https://github.com/ethan-arrowood",
27+
"author": true
28+
},
29+
{
30+
"name": "Matteo Collina",
31+
"url": "https://github.com/mcollina",
32+
"author": true
33+
},
34+
{
35+
"name": "Matthew Aitken",
36+
"url": "https://github.com/KhafraDev",
37+
"author": true
38+
},
39+
{
40+
"name": "Robert Nagy",
41+
"url": "https://github.com/ronag",
42+
"author": true
43+
},
44+
{
45+
"name": "Szymon Marczak",
46+
"url": "https://github.com/szmarczak",
47+
"author": true
48+
},
49+
{
50+
"name": "Tomas Della Vedova",
51+
"url": "https://github.com/delvedor",
52+
"author": true
53+
}
54+
]
55+
}

0 commit comments

Comments
 (0)