Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!: upgrade to Node 18 #353

Merged
merged 22 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest
digest: sha256:609822e3c09b7a1bd90b99655904609f162cc15acb4704f1edf778284c36f429
digest: sha256:0d39e59663287ae929c1d4ccf8ebf7cef9946826c9b86eda7e85d8d752dbb584
# created: 2024-10-01T19:34:30.797530443Z
1 change: 1 addition & 0 deletions .github/release-trigger.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
enabled: true
multiScmName: teeny-request
4 changes: 2 additions & 2 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ branchProtectionRules:
- "ci/kokoro: Samples test"
- "ci/kokoro: System test"
- lint
- test (14)
- test (16)
- test (18)
- test (20)
- test (22)
- cla/google
- windows
- OwlBot Post Processor
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16, 18, 20]
node: [18, 20, 22]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: node --version
Expand All @@ -29,30 +29,30 @@ jobs:
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- run: npm install --engine-strict
- run: npm test
env:
MOCHA_THROW_DEPRECATION: false
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- run: npm install
- run: npm run lint
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 14
node-version: 18
- run: npm install
- run: npm run docs
- uses: JustinBeckwith/linkinator-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/common.cfg

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

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

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

File renamed without changes.
2 changes: 1 addition & 1 deletion .kokoro/release/docs-devsite.cfg

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

2 changes: 1 addition & 1 deletion .kokoro/release/docs.cfg

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

2 changes: 1 addition & 1 deletion .kokoro/release/docs.sh

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

2 changes: 1 addition & 1 deletion .kokoro/release/publish.cfg

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

6 changes: 4 additions & 2 deletions .kokoro/samples-test.sh

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

2 changes: 1 addition & 1 deletion .kokoro/system-test.sh

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

2 changes: 1 addition & 1 deletion .kokoro/test.bat

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

2 changes: 1 addition & 1 deletion .kokoro/test.sh

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

2 changes: 1 addition & 1 deletion .kokoro/trampoline_v2.sh

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

2 changes: 1 addition & 1 deletion owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

import synthtool.languages.node as node

node.owlbot_main(templates_excludes=["README.md", ".github/ISSUE_TEMPLATE", ".github/scripts", ".github/workflows"])
node.owlbot_main(templates_excludes=["README.md", ".github/ISSUE_TEMPLATE", ".github/scripts", ".github/workflows/issues-no-repro.yaml", ".github/workflows/response.yaml"])
33 changes: 16 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./build/src/index.js",
"types": "./build/src/index.d.ts",
"engines": {
"node": ">=14"
"node": ">=18"
},
"scripts": {
"test": "c8 mocha build/test",
Expand Down Expand Up @@ -40,27 +40,26 @@
"dependencies": {
"http-proxy-agent": "^5.0.0",
"https-proxy-agent": "^5.0.0",
"node-fetch": "^2.6.9",
"stream-events": "^1.0.5",
"uuid": "^9.0.0"
"node-fetch": "^3.3.2",
"stream-events": "^1.0.5"
},
"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@types/mocha": "^10.0.0",
"@types/node-fetch": "^2.5.7",
"@types/sinon": "^17.0.0",
"@types/uuid": "^9.0.0",
"c8": "^9.0.0",
"codecov": "^3.1.0",
"gts": "^5.0.0",
"jsdoc": "^4.0.0",
"@types/mocha": "^10.0.10",
"@types/node-fetch": "^2.6.12",
"@types/sinon": "^17.0.3",
"@types/uuid": "^10.0.0",
"c8": "^10.1.3",
"codecov": "^3.8.3",
"gts": "^6.0.2",
"jsdoc": "^4.0.4",
"jsdoc-fresh": "^3.0.0",
"jsdoc-region-tag": "^3.0.0",
"linkinator": "^3.0.0",
"mocha": "^10.0.0",
"nock": "^13.0.0",
"sinon": "^17.0.0",
"typescript": "^5.1.6"
"linkinator": "^6.1.2",
"mocha": "^11.1.0",
"nock": "^14.0.1",
"sinon": "^19.0.2",
"typescript": "^5.7.3"
},
"nyc": {
"exclude": [
Expand Down
4 changes: 2 additions & 2 deletions src/TeenyStatistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class TeenyStatistics {
this._options.concurrentRequests +
'. Use the TEENY_REQUEST_WARN_CONCURRENT_REQUESTS environment ' +
'variable or the concurrentRequests option of teeny-request to ' +
'increase or disable (0) this warning.'
'increase or disable (0) this warning.',
);
warning.type = TeenyStatisticsWarning.CONCURRENT_REQUESTS;
warning.value = this._concurrentRequests;
Expand Down Expand Up @@ -187,7 +187,7 @@ export class TeenyStatistics {
let concurrentRequests = this.DEFAULT_WARN_CONCURRENT_REQUESTS;

const envConcurrentRequests = Number(
process.env.TEENY_REQUEST_WARN_CONCURRENT_REQUESTS
process.env.TEENY_REQUEST_WARN_CONCURRENT_REQUESTS,
);
if (diConcurrentRequests !== undefined) {
concurrentRequests = diConcurrentRequests;
Expand Down
2 changes: 1 addition & 1 deletion src/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function shouldUseProxyForURI(uri: string): boolean {
*/
export function getAgent(
uri: string,
reqOpts: Options
reqOpts: Options,
): HttpAnyAgent | undefined {
const isHttp = uri.startsWith('http://');
const proxy =
Expand Down
29 changes: 17 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@

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

import type nodeFetch from 'node-fetch' with {'resolution-mode': 'import'};

const fetch = (...args: Parameters<typeof nodeFetch>) =>
import('node-fetch').then(({default: fetch}) => fetch(...args));

export interface CoreOptions {
method?: string;
timeout?: number;
Expand Down Expand Up @@ -152,7 +157,7 @@ function fetchToRequestResponse(opts: f.RequestInit, res: f.Response) {
const resHeaders = {} as Headers;
res.headers.forEach((value, key) => (resHeaders[key] = value));

const response = Object.assign(res.body, {
const response = Object.assign(res.body as {}, {
statusCode: res.status,
statusMessage: res.statusText,
request,
Expand Down Expand Up @@ -198,7 +203,7 @@ function teenyRequest(reqOpts: Options): Request;
function teenyRequest(reqOpts: Options, callback: RequestCallback): void;
function teenyRequest(
reqOpts: Options,
callback?: RequestCallback
callback?: RequestCallback,
): Request | void {
const {uri, options} = requestToFetchOptions(reqOpts);

Expand All @@ -208,7 +213,7 @@ function teenyRequest(
// TODO: add support for multipart uploads through streaming
throw new Error('Multipart without callback is not implemented.');
}
const boundary: string = uuid.v4();
const boundary: string = randomUUID();
(options.headers as Headers)['Content-Type'] =
`multipart/related; boundary=${boundary}`;
options.body = createMultipartStream(boundary, multipart);
Expand All @@ -232,7 +237,7 @@ function teenyRequest(
},
(err: Error) => {
callback(err, response, body);
}
},
);
return;
}
Expand All @@ -244,13 +249,13 @@ function teenyRequest(
},
err => {
callback(err, response, body);
}
},
);
},
err => {
teenyRequest.stats.requestFinished();
callback(err, null!, null);
}
},
);
return;
}
Expand Down Expand Up @@ -287,7 +292,7 @@ function teenyRequest(
err => {
teenyRequest.stats.requestFinished();
requestStream.emit('error', err);
}
},
);

// fetch doesn't supply the raw HTTP stream, instead it
Expand Down Expand Up @@ -320,7 +325,7 @@ function teenyRequest(
},
err => {
callback(err, response, body);
}
},
);
return;
}
Expand All @@ -333,13 +338,13 @@ function teenyRequest(
},
err => {
callback(err, response, body);
}
},
);
},
err => {
teenyRequest.stats.requestFinished();
callback(err, null!, null);
}
},
);
return;
}
Expand Down
Loading
Loading