Skip to content

Commit 4a5c834

Browse files
sofislgcf-owl-bot[bot]d-goog
authored
chore!: upgrade to Node 18 (#353)
* chore!: upgrade to Node 18 * Update owlbot.py * run post processor * update post processor * Update .OwlBot.lock.yaml * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update .OwlBot.lock.yaml * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update package.json * Update package.json * Update package.json * chore: remove node 12 folders * run lint * WIP of upgrading fetch to v3 * fix: `fetch` arg passing * upgrade node-fetch v3 and remove uuid * remove uuid * run lint * fix how we ingest uuid; * run lint * rerun lint * rerun lint --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Daniel Bankhead <[email protected]>
1 parent c62efc1 commit 4a5c834

32 files changed

+146
-147
lines changed

.github/.OwlBot.lock.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest
16-
digest: sha256:609822e3c09b7a1bd90b99655904609f162cc15acb4704f1edf778284c36f429
16+
digest: sha256:0d39e59663287ae929c1d4ccf8ebf7cef9946826c9b86eda7e85d8d752dbb584
1717
# created: 2024-10-01T19:34:30.797530443Z

.github/release-trigger.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
enabled: true
2+
multiScmName: teeny-request

.github/sync-repo-settings.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ branchProtectionRules:
88
- "ci/kokoro: Samples test"
99
- "ci/kokoro: System test"
1010
- lint
11-
- test (14)
12-
- test (16)
1311
- test (18)
12+
- test (20)
13+
- test (22)
1414
- cla/google
1515
- windows
1616
- OwlBot Post Processor

.github/workflows/ci.yaml

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
node: [14, 16, 18, 20]
12+
node: [18, 20, 22]
1313
steps:
14-
- uses: actions/checkout@v3
15-
- uses: actions/setup-node@v3
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
1616
with:
1717
node-version: ${{ matrix.node }}
1818
- run: node --version
@@ -29,30 +29,30 @@ jobs:
2929
windows:
3030
runs-on: windows-latest
3131
steps:
32-
- uses: actions/checkout@v3
33-
- uses: actions/setup-node@v3
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-node@v4
3434
with:
35-
node-version: 14
35+
node-version: 18
3636
- run: npm install --engine-strict
3737
- run: npm test
3838
env:
3939
MOCHA_THROW_DEPRECATION: false
4040
lint:
4141
runs-on: ubuntu-latest
4242
steps:
43-
- uses: actions/checkout@v3
44-
- uses: actions/setup-node@v3
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-node@v4
4545
with:
46-
node-version: 14
46+
node-version: 18
4747
- run: npm install
4848
- run: npm run lint
4949
docs:
5050
runs-on: ubuntu-latest
5151
steps:
52-
- uses: actions/checkout@v3
53-
- uses: actions/setup-node@v3
52+
- uses: actions/checkout@v4
53+
- uses: actions/setup-node@v4
5454
with:
55-
node-version: 14
55+
node-version: 18
5656
- run: npm install
5757
- run: npm run docs
5858
- uses: JustinBeckwith/linkinator-action@v1

.kokoro/common.cfg

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

.kokoro/continuous/node14/common.cfg .kokoro/continuous/node18/common.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.

.kokoro/presubmit/node14/common.cfg .kokoro/presubmit/node18/common.cfg

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

.kokoro/release/docs-devsite.cfg

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

.kokoro/release/docs.cfg

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

.kokoro/release/docs.sh

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

.kokoro/release/publish.cfg

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

.kokoro/samples-test.sh

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

.kokoro/system-test.sh

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

.kokoro/test.bat

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

.kokoro/test.sh

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

.kokoro/trampoline_v2.sh

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

owlbot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
import synthtool.languages.node as node
1616

17-
node.owlbot_main(templates_excludes=["README.md", ".github/ISSUE_TEMPLATE", ".github/scripts", ".github/workflows"])
17+
node.owlbot_main(templates_excludes=["README.md", ".github/ISSUE_TEMPLATE", ".github/scripts", ".github/workflows/issues-no-repro.yaml", ".github/workflows/response.yaml"])

package.json

+16-17
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "./build/src/index.js",
66
"types": "./build/src/index.d.ts",
77
"engines": {
8-
"node": ">=14"
8+
"node": ">=18"
99
},
1010
"scripts": {
1111
"test": "c8 mocha build/test",
@@ -40,27 +40,26 @@
4040
"dependencies": {
4141
"http-proxy-agent": "^5.0.0",
4242
"https-proxy-agent": "^5.0.0",
43-
"node-fetch": "^2.6.9",
44-
"stream-events": "^1.0.5",
45-
"uuid": "^9.0.0"
43+
"node-fetch": "^3.3.2",
44+
"stream-events": "^1.0.5"
4645
},
4746
"devDependencies": {
4847
"@babel/plugin-proposal-private-methods": "^7.18.6",
49-
"@types/mocha": "^10.0.0",
50-
"@types/node-fetch": "^2.5.7",
51-
"@types/sinon": "^17.0.0",
52-
"@types/uuid": "^9.0.0",
53-
"c8": "^9.0.0",
54-
"codecov": "^3.1.0",
55-
"gts": "^5.0.0",
56-
"jsdoc": "^4.0.0",
48+
"@types/mocha": "^10.0.10",
49+
"@types/node-fetch": "^2.6.12",
50+
"@types/sinon": "^17.0.3",
51+
"@types/uuid": "^10.0.0",
52+
"c8": "^10.1.3",
53+
"codecov": "^3.8.3",
54+
"gts": "^6.0.2",
55+
"jsdoc": "^4.0.4",
5756
"jsdoc-fresh": "^3.0.0",
5857
"jsdoc-region-tag": "^3.0.0",
59-
"linkinator": "^3.0.0",
60-
"mocha": "^10.0.0",
61-
"nock": "^13.0.0",
62-
"sinon": "^17.0.0",
63-
"typescript": "^5.1.6"
58+
"linkinator": "^6.1.2",
59+
"mocha": "^11.1.0",
60+
"nock": "^14.0.1",
61+
"sinon": "^19.0.2",
62+
"typescript": "^5.7.3"
6463
},
6564
"nyc": {
6665
"exclude": [

src/TeenyStatistics.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class TeenyStatistics {
153153
this._options.concurrentRequests +
154154
'. Use the TEENY_REQUEST_WARN_CONCURRENT_REQUESTS environment ' +
155155
'variable or the concurrentRequests option of teeny-request to ' +
156-
'increase or disable (0) this warning.'
156+
'increase or disable (0) this warning.',
157157
);
158158
warning.type = TeenyStatisticsWarning.CONCURRENT_REQUESTS;
159159
warning.value = this._concurrentRequests;
@@ -187,7 +187,7 @@ export class TeenyStatistics {
187187
let concurrentRequests = this.DEFAULT_WARN_CONCURRENT_REQUESTS;
188188

189189
const envConcurrentRequests = Number(
190-
process.env.TEENY_REQUEST_WARN_CONCURRENT_REQUESTS
190+
process.env.TEENY_REQUEST_WARN_CONCURRENT_REQUESTS,
191191
);
192192
if (diConcurrentRequests !== undefined) {
193193
concurrentRequests = diConcurrentRequests;

src/agents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function shouldUseProxyForURI(uri: string): boolean {
6666
*/
6767
export function getAgent(
6868
uri: string,
69-
reqOpts: Options
69+
reqOpts: Options,
7070
): HttpAnyAgent | undefined {
7171
const isHttp = uri.startsWith('http://');
7272
const proxy =

src/index.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@
1717

1818
import {Agent, AgentOptions as HttpsAgentOptions} from 'https';
1919
import {AgentOptions as HttpAgentOptions} from 'http';
20-
import fetch, * as f from 'node-fetch';
20+
import type * as f from 'node-fetch' with {'resolution-mode': 'import'};
2121
import {PassThrough, Readable, pipeline} from 'stream';
22-
import * as uuid from 'uuid';
2322
import {getAgent} from './agents';
2423
import {TeenyStatistics} from './TeenyStatistics';
24+
import {randomUUID} from 'crypto';
2525
// eslint-disable-next-line @typescript-eslint/no-var-requires
2626
const streamEvents = require('stream-events');
2727

28+
import type nodeFetch from 'node-fetch' with {'resolution-mode': 'import'};
29+
30+
const fetch = (...args: Parameters<typeof nodeFetch>) =>
31+
import('node-fetch').then(({default: fetch}) => fetch(...args));
32+
2833
export interface CoreOptions {
2934
method?: string;
3035
timeout?: number;
@@ -152,7 +157,7 @@ function fetchToRequestResponse(opts: f.RequestInit, res: f.Response) {
152157
const resHeaders = {} as Headers;
153158
res.headers.forEach((value, key) => (resHeaders[key] = value));
154159

155-
const response = Object.assign(res.body, {
160+
const response = Object.assign(res.body as {}, {
156161
statusCode: res.status,
157162
statusMessage: res.statusText,
158163
request,
@@ -198,7 +203,7 @@ function teenyRequest(reqOpts: Options): Request;
198203
function teenyRequest(reqOpts: Options, callback: RequestCallback): void;
199204
function teenyRequest(
200205
reqOpts: Options,
201-
callback?: RequestCallback
206+
callback?: RequestCallback,
202207
): Request | void {
203208
const {uri, options} = requestToFetchOptions(reqOpts);
204209

@@ -208,7 +213,7 @@ function teenyRequest(
208213
// TODO: add support for multipart uploads through streaming
209214
throw new Error('Multipart without callback is not implemented.');
210215
}
211-
const boundary: string = uuid.v4();
216+
const boundary: string = randomUUID();
212217
(options.headers as Headers)['Content-Type'] =
213218
`multipart/related; boundary=${boundary}`;
214219
options.body = createMultipartStream(boundary, multipart);
@@ -232,7 +237,7 @@ function teenyRequest(
232237
},
233238
(err: Error) => {
234239
callback(err, response, body);
235-
}
240+
},
236241
);
237242
return;
238243
}
@@ -244,13 +249,13 @@ function teenyRequest(
244249
},
245250
err => {
246251
callback(err, response, body);
247-
}
252+
},
248253
);
249254
},
250255
err => {
251256
teenyRequest.stats.requestFinished();
252257
callback(err, null!, null);
253-
}
258+
},
254259
);
255260
return;
256261
}
@@ -287,7 +292,7 @@ function teenyRequest(
287292
err => {
288293
teenyRequest.stats.requestFinished();
289294
requestStream.emit('error', err);
290-
}
295+
},
291296
);
292297

293298
// fetch doesn't supply the raw HTTP stream, instead it
@@ -320,7 +325,7 @@ function teenyRequest(
320325
},
321326
err => {
322327
callback(err, response, body);
323-
}
328+
},
324329
);
325330
return;
326331
}
@@ -333,13 +338,13 @@ function teenyRequest(
333338
},
334339
err => {
335340
callback(err, response, body);
336-
}
341+
},
337342
);
338343
},
339344
err => {
340345
teenyRequest.stats.requestFinished();
341346
callback(err, null!, null);
342-
}
347+
},
343348
);
344349
return;
345350
}

0 commit comments

Comments
 (0)