From bc820e840db5800f2d194811c7b604405bc8add3 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 7 Feb 2025 17:50:28 -0800 Subject: [PATCH 01/22] chore!: upgrade to Node 18 --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/continuous/node14/common.cfg | 24 --------------- .kokoro/continuous/node14/lint.cfg | 4 --- .kokoro/continuous/node14/samples-test.cfg | 12 -------- .kokoro/continuous/node14/system-test.cfg | 12 -------- .kokoro/continuous/node14/test.cfg | 0 .kokoro/presubmit/node14/common.cfg | 24 --------------- .kokoro/presubmit/node14/samples-test.cfg | 12 -------- .kokoro/presubmit/node14/system-test.cfg | 12 -------- .kokoro/presubmit/node14/test.cfg | 0 package.json | 36 +++++++++++----------- 11 files changed, 19 insertions(+), 119 deletions(-) delete mode 100644 .kokoro/continuous/node14/common.cfg delete mode 100644 .kokoro/continuous/node14/lint.cfg delete mode 100644 .kokoro/continuous/node14/samples-test.cfg delete mode 100644 .kokoro/continuous/node14/system-test.cfg delete mode 100644 .kokoro/continuous/node14/test.cfg delete mode 100644 .kokoro/presubmit/node14/common.cfg delete mode 100644 .kokoro/presubmit/node14/samples-test.cfg delete mode 100644 .kokoro/presubmit/node14/system-test.cfg delete mode 100644 .kokoro/presubmit/node14/test.cfg diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 24943e1..ca36f56 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:609822e3c09b7a1bd90b99655904609f162cc15acb4704f1edf778284c36f429 + digest: gcr.io/repo-automation-bots/owlbot-nodejs@sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8 # created: 2024-10-01T19:34:30.797530443Z diff --git a/.kokoro/continuous/node14/common.cfg b/.kokoro/continuous/node14/common.cfg deleted file mode 100644 index 67dd805..0000000 --- a/.kokoro/continuous/node14/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "teeny-request/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/test.sh" -} diff --git a/.kokoro/continuous/node14/lint.cfg b/.kokoro/continuous/node14/lint.cfg deleted file mode 100644 index c657bd9..0000000 --- a/.kokoro/continuous/node14/lint.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/lint.sh" -} diff --git a/.kokoro/continuous/node14/samples-test.cfg b/.kokoro/continuous/node14/samples-test.cfg deleted file mode 100644 index 85675a0..0000000 --- a/.kokoro/continuous/node14/samples-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/samples-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/continuous/node14/system-test.cfg b/.kokoro/continuous/node14/system-test.cfg deleted file mode 100644 index 2fbc001..0000000 --- a/.kokoro/continuous/node14/system-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/system-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/continuous/node14/test.cfg b/.kokoro/continuous/node14/test.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/.kokoro/presubmit/node14/common.cfg b/.kokoro/presubmit/node14/common.cfg deleted file mode 100644 index 67dd805..0000000 --- a/.kokoro/presubmit/node14/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "teeny-request/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/test.sh" -} diff --git a/.kokoro/presubmit/node14/samples-test.cfg b/.kokoro/presubmit/node14/samples-test.cfg deleted file mode 100644 index 85675a0..0000000 --- a/.kokoro/presubmit/node14/samples-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/samples-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/presubmit/node14/system-test.cfg b/.kokoro/presubmit/node14/system-test.cfg deleted file mode 100644 index 2fbc001..0000000 --- a/.kokoro/presubmit/node14/system-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/system-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/presubmit/node14/test.cfg b/.kokoro/presubmit/node14/test.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/package.json b/package.json index 994c9a1..ec06967 100644 --- a/package.json +++ b/package.json @@ -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", @@ -38,29 +38,29 @@ }, "homepage": "https://github.com/googleapis/teeny-request#readme", "dependencies": { - "http-proxy-agent": "^5.0.0", - "https-proxy-agent": "^5.0.0", - "node-fetch": "^2.6.9", + "http-proxy-agent": "^7.0.2", + "https-proxy-agent": "^7.0.6", + "node-fetch": "^2.7.0", "stream-events": "^1.0.5", - "uuid": "^9.0.0" + "uuid": "^11.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": [ From fe67febafb38c001b3062a4fa66ea47d84ad44c6 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Tue, 11 Feb 2025 19:42:30 -0800 Subject: [PATCH 02/22] Update owlbot.py --- owlbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/owlbot.py b/owlbot.py index f184210..6bfddf7 100644 --- a/owlbot.py +++ b/owlbot.py @@ -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"]) From 6dae755bcca25d76b6e4c8f04266028447c5f62a Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 11 Feb 2025 21:46:04 -0800 Subject: [PATCH 03/22] run post processor From 9bd0c61287f352b0b03bd905f081ec96926ba12c Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Tue, 11 Feb 2025 21:46:41 -0800 Subject: [PATCH 04/22] update post processor --- .github/.OwlBot.lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index ca36f56..2bce36b 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: gcr.io/repo-automation-bots/owlbot-nodejs@sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8 + digest: gcr.io/repo-automation-bots/owlbot-nodejs@sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8m # created: 2024-10-01T19:34:30.797530443Z From 12455e2f18e4762fcf00c9cac030ff9d3952dcfd Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Tue, 11 Feb 2025 21:52:53 -0800 Subject: [PATCH 05/22] Update .OwlBot.lock.yaml --- .github/.OwlBot.lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 2bce36b..bd233cd 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: gcr.io/repo-automation-bots/owlbot-nodejs@sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8m + digest: sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8 # created: 2024-10-01T19:34:30.797530443Z From cb01f88a7c45d5eae048242eb639c22e2398bd36 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 12 Feb 2025 05:54:29 +0000 Subject: [PATCH 06/22] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .eslintignore | 1 - .github/CODEOWNERS | 7 +++++-- .github/auto-approve.yml | 3 ++- .github/sync-repo-settings.yaml | 5 +++-- .github/workflows/ci.yaml | 6 +++--- .kokoro/common.cfg | 2 +- .kokoro/continuous/node12/common.cfg | 24 ++++++++++++++++++++++ .kokoro/continuous/node12/lint.cfg | 4 ++++ .kokoro/continuous/node12/samples-test.cfg | 12 +++++++++++ .kokoro/continuous/node12/system-test.cfg | 12 +++++++++++ .kokoro/continuous/node12/test.cfg | 0 .kokoro/presubmit/node12/common.cfg | 24 ++++++++++++++++++++++ .kokoro/presubmit/node12/samples-test.cfg | 12 +++++++++++ .kokoro/presubmit/node12/system-test.cfg | 12 +++++++++++ .kokoro/presubmit/node12/test.cfg | 0 .kokoro/publish.sh | 14 +------------ .kokoro/release/docs-devsite.sh | 5 ++--- .kokoro/release/docs.cfg | 2 +- .kokoro/release/publish.cfg | 14 +------------ .kokoro/samples-test.sh | 2 +- .kokoro/system-test.sh | 2 +- .kokoro/test.bat | 2 +- .kokoro/test.sh | 2 +- renovate.json | 1 - 24 files changed, 123 insertions(+), 45 deletions(-) create mode 100644 .kokoro/continuous/node12/common.cfg create mode 100644 .kokoro/continuous/node12/lint.cfg create mode 100644 .kokoro/continuous/node12/samples-test.cfg create mode 100644 .kokoro/continuous/node12/system-test.cfg create mode 100644 .kokoro/continuous/node12/test.cfg create mode 100644 .kokoro/presubmit/node12/common.cfg create mode 100644 .kokoro/presubmit/node12/samples-test.cfg create mode 100644 .kokoro/presubmit/node12/system-test.cfg create mode 100644 .kokoro/presubmit/node12/test.cfg diff --git a/.eslintignore b/.eslintignore index c4a0963..ea5b04a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,4 +5,3 @@ build/ docs/ protos/ samples/generated/ -system-test/**/fixtures diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f7a9dcc..d260229 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,5 +5,8 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax -# Unless specified, the jsteam is the default owner for nodejs repositories. -* @googleapis/jsteam-handwritten-libraries @googleapis/jsteam \ No newline at end of file +# The yoshi-nodejs team is the default owner for nodejs repositories. +* @googleapis/yoshi-nodejs @googleapis/jsteam-handwritten-libraries + +# The github automation team is the default owner for the auto-approve file. +.github/auto-approve.yml @googleapis/github-automation diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml index 7cba0af..4cd91cc 100644 --- a/.github/auto-approve.yml +++ b/.github/auto-approve.yml @@ -1,2 +1,3 @@ processes: - - "NodeDependency" \ No newline at end of file + - "NodeDependency" + - "OwlBotTemplateChanges" diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index b46e4c4..a356273 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -7,10 +7,11 @@ branchProtectionRules: requiredStatusCheckContexts: - "ci/kokoro: Samples test" - "ci/kokoro: System test" + - docs - lint - - test (14) - - test (16) - test (18) + - test (20) + - test (22) - cla/google - windows - OwlBot Post Processor diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4892eb2..85f8b84 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ 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 @@ -22,7 +22,7 @@ jobs: - run: npm install --production --engine-strict --ignore-scripts --no-package-lock # Clean up the production install, before installing dev/production: - run: rm -rf node_modules - - run: npm install --engine-strict + - run: npm install - run: npm test env: MOCHA_THROW_DEPRECATION: false @@ -33,7 +33,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 14 - - run: npm install --engine-strict + - run: npm install - run: npm test env: MOCHA_THROW_DEPRECATION: false diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 67dd805..699709b 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -16,7 +16,7 @@ build_file: "teeny-request/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/continuous/node12/common.cfg b/.kokoro/continuous/node12/common.cfg new file mode 100644 index 0000000..699709b --- /dev/null +++ b/.kokoro/continuous/node12/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "teeny-request/.kokoro/trampoline_v2.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node12/lint.cfg b/.kokoro/continuous/node12/lint.cfg new file mode 100644 index 0000000..c657bd9 --- /dev/null +++ b/.kokoro/continuous/node12/lint.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/lint.sh" +} diff --git a/.kokoro/continuous/node12/samples-test.cfg b/.kokoro/continuous/node12/samples-test.cfg new file mode 100644 index 0000000..85675a0 --- /dev/null +++ b/.kokoro/continuous/node12/samples-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/samples-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/continuous/node12/system-test.cfg b/.kokoro/continuous/node12/system-test.cfg new file mode 100644 index 0000000..2fbc001 --- /dev/null +++ b/.kokoro/continuous/node12/system-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/system-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/continuous/node12/test.cfg b/.kokoro/continuous/node12/test.cfg new file mode 100644 index 0000000..e69de29 diff --git a/.kokoro/presubmit/node12/common.cfg b/.kokoro/presubmit/node12/common.cfg new file mode 100644 index 0000000..699709b --- /dev/null +++ b/.kokoro/presubmit/node12/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "teeny-request/.kokoro/trampoline_v2.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node12/samples-test.cfg b/.kokoro/presubmit/node12/samples-test.cfg new file mode 100644 index 0000000..85675a0 --- /dev/null +++ b/.kokoro/presubmit/node12/samples-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/samples-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/presubmit/node12/system-test.cfg b/.kokoro/presubmit/node12/system-test.cfg new file mode 100644 index 0000000..2fbc001 --- /dev/null +++ b/.kokoro/presubmit/node12/system-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/system-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/presubmit/node12/test.cfg b/.kokoro/presubmit/node12/test.cfg new file mode 100644 index 0000000..e69de29 diff --git a/.kokoro/publish.sh b/.kokoro/publish.sh index ca1d47a..949e3e1 100755 --- a/.kokoro/publish.sh +++ b/.kokoro/publish.sh @@ -27,16 +27,4 @@ NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_google-cloud-npm-token-1) echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc npm install -npm pack . -# npm provides no way to specify, observe, or predict the name of the tarball -# file it generates. We have to look in the current directory for the freshest -# .tgz file. -TARBALL=$(ls -1 -t *.tgz | head -1) - -npm publish --access=public --registry=https://wombat-dressing-room.appspot.com "$TARBALL" - -# Kokoro collects *.tgz and package-lock.json files and stores them in Placer -# so we can generate SBOMs and attestations. -# However, we *don't* want Kokoro to collect package-lock.json and *.tgz files -# that happened to be installed with dependencies. -find node_modules -name package-lock.json -o -name "*.tgz" | xargs rm -f \ No newline at end of file +npm publish --access=public --registry=https://wombat-dressing-room.appspot.com diff --git a/.kokoro/release/docs-devsite.sh b/.kokoro/release/docs-devsite.sh index 81a89f6..2198e67 100755 --- a/.kokoro/release/docs-devsite.sh +++ b/.kokoro/release/docs-devsite.sh @@ -25,6 +25,5 @@ if [[ -z "$CREDENTIALS" ]]; then fi npm install -npm install --no-save @google-cloud/cloud-rad@^0.4.0 -# publish docs to devsite -npx @google-cloud/cloud-rad . cloud-rad +npm install --no-save @google-cloud/cloud-rad@^0.2.5 +npx @google-cloud/cloud-rad \ No newline at end of file diff --git a/.kokoro/release/docs.cfg b/.kokoro/release/docs.cfg index 6bf2aab..d3d8094 100644 --- a/.kokoro/release/docs.cfg +++ b/.kokoro/release/docs.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" } # Download trampoline resources. diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index 3d21b18..a1f58da 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -30,22 +30,10 @@ build_file: "teeny-request/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/teeny-request/.kokoro/publish.sh" } - -# Store the packages we uploaded to npmjs.org and their corresponding -# package-lock.jsons in Placer. That way, we have a record of exactly -# what we published, and which version of which tools we used to publish -# it, which we can use to generate SBOMs and attestations. -action { - define_artifacts { - regex: "github/**/*.tgz" - regex: "github/**/package-lock.json" - strip_prefix: "github" - } -} diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index 8c5d108..806c008 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -56,7 +56,7 @@ fi # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=12 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 0b3043d..0201e9d 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -49,7 +49,7 @@ npm run system-test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=12 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/test.bat b/.kokoro/test.bat index 0bb1240..ae59e59 100644 --- a/.kokoro/test.bat +++ b/.kokoro/test.bat @@ -21,7 +21,7 @@ cd .. @rem we upgrade Node.js in the image: SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm -call nvm use v14.17.3 +call nvm use v12.14.1 call which node call npm install || goto :error diff --git a/.kokoro/test.sh b/.kokoro/test.sh index 862d478..a5c7ac0 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -39,7 +39,7 @@ npm test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=14 +COVERAGE_NODE=12 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/renovate.json b/renovate.json index c5c702c..26428fc 100644 --- a/renovate.json +++ b/renovate.json @@ -4,7 +4,6 @@ "docker:disable", ":disableDependencyDashboard" ], - "constraintsFiltering": "strict", "pinVersions": false, "rebaseStalePrs": true, "schedule": [ From 30b1f76d8869857dd086c24acfbb9523b27d3a9d Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Tue, 11 Feb 2025 22:26:03 -0800 Subject: [PATCH 07/22] Update .OwlBot.lock.yaml --- .github/.OwlBot.lock.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index bd233cd..2290457 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest - digest: sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8 + digest: sha256:0d39e59663287ae929c1d4ccf8ebf7cef9946826c9b86eda7e85d8d752dbb584 # created: 2024-10-01T19:34:30.797530443Z From 20797ced5da2cb4860d31939de3bdb4f28c0463e Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Wed, 12 Feb 2025 06:27:53 +0000 Subject: [PATCH 08/22] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- .eslintignore | 1 + .github/CODEOWNERS | 7 ++---- .github/auto-approve.yml | 3 +-- .github/release-trigger.yml | 1 + .github/sync-repo-settings.yaml | 1 - .github/workflows/ci.yaml | 26 +++++++++++----------- .kokoro/common.cfg | 2 +- .kokoro/continuous/node18/common.cfg | 24 ++++++++++++++++++++ .kokoro/continuous/node18/lint.cfg | 4 ++++ .kokoro/continuous/node18/samples-test.cfg | 12 ++++++++++ .kokoro/continuous/node18/system-test.cfg | 12 ++++++++++ .kokoro/continuous/node18/test.cfg | 0 .kokoro/presubmit/node18/common.cfg | 24 ++++++++++++++++++++ .kokoro/presubmit/node18/samples-test.cfg | 12 ++++++++++ .kokoro/presubmit/node18/system-test.cfg | 12 ++++++++++ .kokoro/presubmit/node18/test.cfg | 0 .kokoro/publish.sh | 14 +++++++++++- .kokoro/release/docs-devsite.cfg | 2 +- .kokoro/release/docs-devsite.sh | 5 +++-- .kokoro/release/docs.cfg | 2 +- .kokoro/release/docs.sh | 2 +- .kokoro/release/publish.cfg | 14 +++++++++++- .kokoro/samples-test.sh | 6 +++-- .kokoro/system-test.sh | 2 +- .kokoro/test.bat | 2 +- .kokoro/test.sh | 2 +- .kokoro/trampoline_v2.sh | 2 +- renovate.json | 1 + 28 files changed, 160 insertions(+), 35 deletions(-) create mode 100644 .kokoro/continuous/node18/common.cfg create mode 100644 .kokoro/continuous/node18/lint.cfg create mode 100644 .kokoro/continuous/node18/samples-test.cfg create mode 100644 .kokoro/continuous/node18/system-test.cfg create mode 100644 .kokoro/continuous/node18/test.cfg create mode 100644 .kokoro/presubmit/node18/common.cfg create mode 100644 .kokoro/presubmit/node18/samples-test.cfg create mode 100644 .kokoro/presubmit/node18/system-test.cfg create mode 100644 .kokoro/presubmit/node18/test.cfg diff --git a/.eslintignore b/.eslintignore index ea5b04a..c4a0963 100644 --- a/.eslintignore +++ b/.eslintignore @@ -5,3 +5,4 @@ build/ docs/ protos/ samples/generated/ +system-test/**/fixtures diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d260229..f7a9dcc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,8 +5,5 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax -# The yoshi-nodejs team is the default owner for nodejs repositories. -* @googleapis/yoshi-nodejs @googleapis/jsteam-handwritten-libraries - -# The github automation team is the default owner for the auto-approve file. -.github/auto-approve.yml @googleapis/github-automation +# Unless specified, the jsteam is the default owner for nodejs repositories. +* @googleapis/jsteam-handwritten-libraries @googleapis/jsteam \ No newline at end of file diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml index 4cd91cc..7cba0af 100644 --- a/.github/auto-approve.yml +++ b/.github/auto-approve.yml @@ -1,3 +1,2 @@ processes: - - "NodeDependency" - - "OwlBotTemplateChanges" + - "NodeDependency" \ No newline at end of file diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml index d4ca941..038fba6 100644 --- a/.github/release-trigger.yml +++ b/.github/release-trigger.yml @@ -1 +1,2 @@ enabled: true +multiScmName: teeny-request \ No newline at end of file diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index a356273..a013376 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -7,7 +7,6 @@ branchProtectionRules: requiredStatusCheckContexts: - "ci/kokoro: Samples test" - "ci/kokoro: System test" - - docs - lint - test (18) - test (20) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 85f8b84..791891a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,8 +11,8 @@ jobs: matrix: 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 @@ -22,37 +22,37 @@ jobs: - run: npm install --production --engine-strict --ignore-scripts --no-package-lock # Clean up the production install, before installing dev/production: - run: rm -rf node_modules - - run: npm install + - run: npm install --engine-strict - run: npm test env: MOCHA_THROW_DEPRECATION: false 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 - - run: npm install + 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 diff --git a/.kokoro/common.cfg b/.kokoro/common.cfg index 699709b..3fe2d24 100644 --- a/.kokoro/common.cfg +++ b/.kokoro/common.cfg @@ -16,7 +16,7 @@ build_file: "teeny-request/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" diff --git a/.kokoro/continuous/node18/common.cfg b/.kokoro/continuous/node18/common.cfg new file mode 100644 index 0000000..3fe2d24 --- /dev/null +++ b/.kokoro/continuous/node18/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "teeny-request/.kokoro/trampoline_v2.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/test.sh" +} diff --git a/.kokoro/continuous/node18/lint.cfg b/.kokoro/continuous/node18/lint.cfg new file mode 100644 index 0000000..c657bd9 --- /dev/null +++ b/.kokoro/continuous/node18/lint.cfg @@ -0,0 +1,4 @@ +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/lint.sh" +} diff --git a/.kokoro/continuous/node18/samples-test.cfg b/.kokoro/continuous/node18/samples-test.cfg new file mode 100644 index 0000000..85675a0 --- /dev/null +++ b/.kokoro/continuous/node18/samples-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/samples-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/continuous/node18/system-test.cfg b/.kokoro/continuous/node18/system-test.cfg new file mode 100644 index 0000000..2fbc001 --- /dev/null +++ b/.kokoro/continuous/node18/system-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/system-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/continuous/node18/test.cfg b/.kokoro/continuous/node18/test.cfg new file mode 100644 index 0000000..e69de29 diff --git a/.kokoro/presubmit/node18/common.cfg b/.kokoro/presubmit/node18/common.cfg new file mode 100644 index 0000000..3fe2d24 --- /dev/null +++ b/.kokoro/presubmit/node18/common.cfg @@ -0,0 +1,24 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "teeny-request/.kokoro/trampoline_v2.sh" + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" +} +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/test.sh" +} diff --git a/.kokoro/presubmit/node18/samples-test.cfg b/.kokoro/presubmit/node18/samples-test.cfg new file mode 100644 index 0000000..85675a0 --- /dev/null +++ b/.kokoro/presubmit/node18/samples-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/samples-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/presubmit/node18/system-test.cfg b/.kokoro/presubmit/node18/system-test.cfg new file mode 100644 index 0000000..2fbc001 --- /dev/null +++ b/.kokoro/presubmit/node18/system-test.cfg @@ -0,0 +1,12 @@ +# Download resources for system tests (service account key, etc.) +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/teeny-request/.kokoro/system-test.sh" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "long-door-651-kokoro-system-test-service-account" +} \ No newline at end of file diff --git a/.kokoro/presubmit/node18/test.cfg b/.kokoro/presubmit/node18/test.cfg new file mode 100644 index 0000000..e69de29 diff --git a/.kokoro/publish.sh b/.kokoro/publish.sh index 949e3e1..ca1d47a 100755 --- a/.kokoro/publish.sh +++ b/.kokoro/publish.sh @@ -27,4 +27,16 @@ NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_google-cloud-npm-token-1) echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc npm install -npm publish --access=public --registry=https://wombat-dressing-room.appspot.com +npm pack . +# npm provides no way to specify, observe, or predict the name of the tarball +# file it generates. We have to look in the current directory for the freshest +# .tgz file. +TARBALL=$(ls -1 -t *.tgz | head -1) + +npm publish --access=public --registry=https://wombat-dressing-room.appspot.com "$TARBALL" + +# Kokoro collects *.tgz and package-lock.json files and stores them in Placer +# so we can generate SBOMs and attestations. +# However, we *don't* want Kokoro to collect package-lock.json and *.tgz files +# that happened to be installed with dependencies. +find node_modules -name package-lock.json -o -name "*.tgz" | xargs rm -f \ No newline at end of file diff --git a/.kokoro/release/docs-devsite.cfg b/.kokoro/release/docs-devsite.cfg index 3e9f8b9..c04d2b9 100644 --- a/.kokoro/release/docs-devsite.cfg +++ b/.kokoro/release/docs-devsite.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } # Download trampoline resources. diff --git a/.kokoro/release/docs-devsite.sh b/.kokoro/release/docs-devsite.sh index 2198e67..81a89f6 100755 --- a/.kokoro/release/docs-devsite.sh +++ b/.kokoro/release/docs-devsite.sh @@ -25,5 +25,6 @@ if [[ -z "$CREDENTIALS" ]]; then fi npm install -npm install --no-save @google-cloud/cloud-rad@^0.2.5 -npx @google-cloud/cloud-rad \ No newline at end of file +npm install --no-save @google-cloud/cloud-rad@^0.4.0 +# publish docs to devsite +npx @google-cloud/cloud-rad . cloud-rad diff --git a/.kokoro/release/docs.cfg b/.kokoro/release/docs.cfg index d3d8094..3b724fa 100644 --- a/.kokoro/release/docs.cfg +++ b/.kokoro/release/docs.cfg @@ -11,7 +11,7 @@ before_action { # doc publications use a Python image. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } # Download trampoline resources. diff --git a/.kokoro/release/docs.sh b/.kokoro/release/docs.sh index 1d8f3f4..e9079a6 100755 --- a/.kokoro/release/docs.sh +++ b/.kokoro/release/docs.sh @@ -16,7 +16,7 @@ set -eo pipefail -# build jsdocs (Python is installed on the Node 10 docker image). +# build jsdocs (Python is installed on the Node 18 docker image). if [[ -z "$CREDENTIALS" ]]; then # if CREDENTIALS are explicitly set, assume we're testing locally # and don't set NPM_CONFIG_PREFIX. diff --git a/.kokoro/release/publish.cfg b/.kokoro/release/publish.cfg index a1f58da..a4e27c7 100644 --- a/.kokoro/release/publish.cfg +++ b/.kokoro/release/publish.cfg @@ -30,10 +30,22 @@ build_file: "teeny-request/.kokoro/trampoline_v2.sh" # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" + value: "gcr.io/cloud-devrel-kokoro-resources/node:18-user" } env_vars: { key: "TRAMPOLINE_BUILD_FILE" value: "github/teeny-request/.kokoro/publish.sh" } + +# Store the packages we uploaded to npmjs.org and their corresponding +# package-lock.jsons in Placer. That way, we have a record of exactly +# what we published, and which version of which tools we used to publish +# it, which we can use to generate SBOMs and attestations. +action { + define_artifacts { + regex: "github/**/*.tgz" + regex: "github/**/package-lock.json" + strip_prefix: "github" + } +} diff --git a/.kokoro/samples-test.sh b/.kokoro/samples-test.sh index 806c008..5287753 100755 --- a/.kokoro/samples-test.sh +++ b/.kokoro/samples-test.sh @@ -16,7 +16,9 @@ set -eo pipefail -export NPM_CONFIG_PREFIX=${HOME}/.npm-global +# Ensure the npm global directory is writable, otherwise rebuild `npm` +mkdir -p $NPM_CONFIG_PREFIX +npm config -g ls || npm i -g npm@`npm --version` # Setup service account credentials. export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account @@ -56,7 +58,7 @@ fi # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=12 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/system-test.sh b/.kokoro/system-test.sh index 0201e9d..a90d5cf 100755 --- a/.kokoro/system-test.sh +++ b/.kokoro/system-test.sh @@ -49,7 +49,7 @@ npm run system-test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=12 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/test.bat b/.kokoro/test.bat index ae59e59..caf8256 100644 --- a/.kokoro/test.bat +++ b/.kokoro/test.bat @@ -21,7 +21,7 @@ cd .. @rem we upgrade Node.js in the image: SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm -call nvm use v12.14.1 +call nvm use 18 call which node call npm install || goto :error diff --git a/.kokoro/test.sh b/.kokoro/test.sh index a5c7ac0..0d9f639 100755 --- a/.kokoro/test.sh +++ b/.kokoro/test.sh @@ -39,7 +39,7 @@ npm test # codecov combines coverage across integration and unit tests. Include # the logic below for any environment you wish to collect coverage for: -COVERAGE_NODE=12 +COVERAGE_NODE=18 if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then NYC_BIN=./node_modules/nyc/bin/nyc.js if [ -f "$NYC_BIN" ]; then diff --git a/.kokoro/trampoline_v2.sh b/.kokoro/trampoline_v2.sh index 4d03112..5d6cfcc 100755 --- a/.kokoro/trampoline_v2.sh +++ b/.kokoro/trampoline_v2.sh @@ -44,7 +44,7 @@ # the project root. # # Here is an example for running this script. -# TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/node:10-user \ +# TRAMPOLINE_IMAGE=gcr.io/cloud-devrel-kokoro-resources/node:18-user \ # TRAMPOLINE_BUILD_FILE=.kokoro/system-test.sh \ # .kokoro/trampoline_v2.sh diff --git a/renovate.json b/renovate.json index 26428fc..c5c702c 100644 --- a/renovate.json +++ b/renovate.json @@ -4,6 +4,7 @@ "docker:disable", ":disableDependencyDashboard" ], + "constraintsFiltering": "strict", "pinVersions": false, "rebaseStalePrs": true, "schedule": [ From 659d01d84ce065576867a39907fc8f83dc556889 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Tue, 11 Feb 2025 23:46:36 -0800 Subject: [PATCH 09/22] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec06967..a4203a9 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,8 @@ }, "homepage": "https://github.com/googleapis/teeny-request#readme", "dependencies": { - "http-proxy-agent": "^7.0.2", - "https-proxy-agent": "^7.0.6", + "http-proxy-agent": "^6.0.0", + "https-proxy-agent": "^6.0.0", "node-fetch": "^2.7.0", "stream-events": "^1.0.5", "uuid": "^11.0.5" From 29edb4d1637454417d71fe43acf5a187f15a4797 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Wed, 12 Feb 2025 00:02:48 -0800 Subject: [PATCH 10/22] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4203a9..c4d8895 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "homepage": "https://github.com/googleapis/teeny-request#readme", "dependencies": { - "http-proxy-agent": "^6.0.0", + "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^6.0.0", "node-fetch": "^2.7.0", "stream-events": "^1.0.5", From 7af4c2aac29e9dbfe0b6b8557af6ef026ed09d25 Mon Sep 17 00:00:00 2001 From: sofisl <55454395+sofisl@users.noreply.github.com> Date: Wed, 12 Feb 2025 00:09:04 -0800 Subject: [PATCH 11/22] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c4d8895..7ff537e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "homepage": "https://github.com/googleapis/teeny-request#readme", "dependencies": { "http-proxy-agent": "^5.0.0", - "https-proxy-agent": "^6.0.0", + "https-proxy-agent": "^5.0.0", "node-fetch": "^2.7.0", "stream-events": "^1.0.5", "uuid": "^11.0.5" From 0657fc10a9fd9fe0ce983c933301a454fea3e7c7 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Thu, 13 Feb 2025 00:19:01 -0800 Subject: [PATCH 12/22] chore: remove node 12 folders --- .kokoro/continuous/node12/common.cfg | 24 ---------------------- .kokoro/continuous/node12/lint.cfg | 4 ---- .kokoro/continuous/node12/samples-test.cfg | 12 ----------- .kokoro/continuous/node12/system-test.cfg | 12 ----------- .kokoro/continuous/node12/test.cfg | 0 .kokoro/presubmit/node12/common.cfg | 24 ---------------------- .kokoro/presubmit/node12/samples-test.cfg | 12 ----------- .kokoro/presubmit/node12/system-test.cfg | 12 ----------- .kokoro/presubmit/node12/test.cfg | 0 9 files changed, 100 deletions(-) delete mode 100644 .kokoro/continuous/node12/common.cfg delete mode 100644 .kokoro/continuous/node12/lint.cfg delete mode 100644 .kokoro/continuous/node12/samples-test.cfg delete mode 100644 .kokoro/continuous/node12/system-test.cfg delete mode 100644 .kokoro/continuous/node12/test.cfg delete mode 100644 .kokoro/presubmit/node12/common.cfg delete mode 100644 .kokoro/presubmit/node12/samples-test.cfg delete mode 100644 .kokoro/presubmit/node12/system-test.cfg delete mode 100644 .kokoro/presubmit/node12/test.cfg diff --git a/.kokoro/continuous/node12/common.cfg b/.kokoro/continuous/node12/common.cfg deleted file mode 100644 index 699709b..0000000 --- a/.kokoro/continuous/node12/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "teeny-request/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/test.sh" -} diff --git a/.kokoro/continuous/node12/lint.cfg b/.kokoro/continuous/node12/lint.cfg deleted file mode 100644 index c657bd9..0000000 --- a/.kokoro/continuous/node12/lint.cfg +++ /dev/null @@ -1,4 +0,0 @@ -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/lint.sh" -} diff --git a/.kokoro/continuous/node12/samples-test.cfg b/.kokoro/continuous/node12/samples-test.cfg deleted file mode 100644 index 85675a0..0000000 --- a/.kokoro/continuous/node12/samples-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/samples-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/continuous/node12/system-test.cfg b/.kokoro/continuous/node12/system-test.cfg deleted file mode 100644 index 2fbc001..0000000 --- a/.kokoro/continuous/node12/system-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/system-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/continuous/node12/test.cfg b/.kokoro/continuous/node12/test.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/.kokoro/presubmit/node12/common.cfg b/.kokoro/presubmit/node12/common.cfg deleted file mode 100644 index 699709b..0000000 --- a/.kokoro/presubmit/node12/common.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Build logs will be here -action { - define_artifacts { - regex: "**/*sponge_log.xml" - } -} - -# Download trampoline resources. -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" - -# Use the trampoline script to run in docker. -build_file: "teeny-request/.kokoro/trampoline_v2.sh" - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user" -} -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/test.sh" -} diff --git a/.kokoro/presubmit/node12/samples-test.cfg b/.kokoro/presubmit/node12/samples-test.cfg deleted file mode 100644 index 85675a0..0000000 --- a/.kokoro/presubmit/node12/samples-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/samples-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/presubmit/node12/system-test.cfg b/.kokoro/presubmit/node12/system-test.cfg deleted file mode 100644 index 2fbc001..0000000 --- a/.kokoro/presubmit/node12/system-test.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Download resources for system tests (service account key, etc.) -gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/teeny-request/.kokoro/system-test.sh" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "long-door-651-kokoro-system-test-service-account" -} \ No newline at end of file diff --git a/.kokoro/presubmit/node12/test.cfg b/.kokoro/presubmit/node12/test.cfg deleted file mode 100644 index e69de29..0000000 From 2387b66e2d5677ad0580d6b90d6b2690cc10d995 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Thu, 13 Feb 2025 00:23:46 -0800 Subject: [PATCH 13/22] run lint --- src/TeenyStatistics.ts | 4 ++-- src/agents.ts | 2 +- src/index.ts | 16 ++++++++-------- test/TeenyStatistics.ts | 22 +++++++++++----------- test/agents.ts | 8 ++++---- test/index.ts | 12 ++++++------ 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/TeenyStatistics.ts b/src/TeenyStatistics.ts index 0e3a77d..2182237 100644 --- a/src/TeenyStatistics.ts +++ b/src/TeenyStatistics.ts @@ -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; @@ -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; diff --git a/src/agents.ts b/src/agents.ts index 2ae9e74..3369dcf 100644 --- a/src/agents.ts +++ b/src/agents.ts @@ -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 = diff --git a/src/index.ts b/src/index.ts index 31d87df..1a854c9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -198,7 +198,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); @@ -232,7 +232,7 @@ function teenyRequest( }, (err: Error) => { callback(err, response, body); - } + }, ); return; } @@ -244,13 +244,13 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - } + }, ); return; } @@ -287,7 +287,7 @@ function teenyRequest( err => { teenyRequest.stats.requestFinished(); requestStream.emit('error', err); - } + }, ); // fetch doesn't supply the raw HTTP stream, instead it @@ -320,7 +320,7 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); return; } @@ -333,13 +333,13 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - } + }, ); return; } diff --git a/test/TeenyStatistics.ts b/test/TeenyStatistics.ts index 90653d2..d8f39b8 100644 --- a/test/TeenyStatistics.ts +++ b/test/TeenyStatistics.ts @@ -65,7 +65,7 @@ describe('TeenyStatistics', () => { it('should have default concurrent requests', () => { assert.strictEqual( TeenyStatistics.DEFAULT_WARN_CONCURRENT_REQUESTS, - 5000 + 5000, ); }); @@ -231,8 +231,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning) - ) + sinon.match.instanceOf(TeenyStatisticsWarning), + ), ); }); @@ -246,8 +246,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning) - ) + sinon.match.instanceOf(TeenyStatisticsWarning), + ), ); // shouldn't emit on the next call (i.e. still greater than threshold) @@ -271,8 +271,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning) - ) + sinon.match.instanceOf(TeenyStatisticsWarning), + ), ); // let's bring the counter back down @@ -298,7 +298,7 @@ describe('TeenyStatistics', () => { assert.strictEqual(warning.value, 5e3); assert.strictEqual( warning.type, - TeenyStatisticsWarning.CONCURRENT_REQUESTS + TeenyStatisticsWarning.CONCURRENT_REQUESTS, ); }); @@ -311,15 +311,15 @@ describe('TeenyStatistics', () => { const errStr: string = emitWarnStub.firstCall.args[0].toString(); assert( errStr.includes('Possible excessive concurrent requests detected.'), - 'describes the nature of the warning' + 'describes the nature of the warning', ); assert( errStr.includes('TEENY_REQUEST_WARN_CONCURRENT_REQUESTS'), - 'mentions env var' + 'mentions env var', ); assert( errStr.includes('concurrentRequests'), - 'mentions concurrentRequests option' + 'mentions concurrentRequests option', ); assert(errStr.search(/\b0\b/) !== -1, 'mentions 0'); }); diff --git a/test/agents.ts b/test/agents.ts index 7b28068..891895c 100644 --- a/test/agents.ts +++ b/test/agents.ts @@ -211,7 +211,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent!.maxSockets, 1000); @@ -224,7 +224,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent, undefined); @@ -243,7 +243,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent!.maxSockets, 1000); @@ -256,7 +256,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent, undefined); diff --git a/test/index.ts b/test/index.ts index ab398ff..7b0c024 100644 --- a/test/index.ts +++ b/test/index.ts @@ -367,7 +367,7 @@ describe('teeny', () => { assert.strictEqual(body, '🌍'); scope.done(); done(); - } + }, ); }); @@ -381,7 +381,7 @@ describe('teeny', () => { assert.strictEqual(body, '🌍'); scope.done(); done(); - } + }, ); }); @@ -413,7 +413,7 @@ describe('teeny', () => { assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); done(); - } + }, ); }); @@ -432,7 +432,7 @@ describe('teeny', () => { assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); done(); - } + }, ); }); @@ -442,7 +442,7 @@ describe('teeny', () => { teenyRequest({uri: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message' + 'Did not throw with expected message', ); done(); }); @@ -453,7 +453,7 @@ describe('teeny', () => { teenyRequest({url: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message' + 'Did not throw with expected message', ); done(); }); From d8e79bbaa1465b201d7f4e25c40e90a3921cfc4b Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 15:38:19 -0800 Subject: [PATCH 14/22] WIP of upgrading fetch to v3 --- package.json | 2 +- src/index.ts | 6 ++- test/TeenyStatistics.ts | 2 +- test/agents.ts | 2 +- test/index.ts | 105 ++++++++++++++++++---------------------- tsconfig.json | 4 +- 6 files changed, 57 insertions(+), 64 deletions(-) diff --git a/package.json b/package.json index 7ff537e..c54c048 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "dependencies": { "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0", - "node-fetch": "^2.7.0", + "node-fetch": "^3.3.2", "stream-events": "^1.0.5", "uuid": "^11.0.5" }, diff --git a/src/index.ts b/src/index.ts index 1a854c9..7e7c407 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,13 +17,15 @@ 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'; // eslint-disable-next-line @typescript-eslint/no-var-requires const streamEvents = require('stream-events'); +const fetch = (...args: any[]) => + import('node-fetch').then(({default: fetch}) => fetch([...args] as any)); export interface CoreOptions { method?: string; @@ -152,7 +154,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 any, { statusCode: res.status, statusMessage: res.statusText, request, diff --git a/test/TeenyStatistics.ts b/test/TeenyStatistics.ts index d8f39b8..a554547 100644 --- a/test/TeenyStatistics.ts +++ b/test/TeenyStatistics.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import * as assert from 'assert'; +import assert from 'assert'; import {afterEach, before, beforeEach, describe, it} from 'mocha'; import * as sinon from 'sinon'; import { diff --git a/test/agents.ts b/test/agents.ts index 891895c..6ea3f8d 100644 --- a/test/agents.ts +++ b/test/agents.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import * as assert from 'assert'; +import assert from 'assert'; import {describe, it, afterEach} from 'mocha'; import * as http from 'http'; import * as https from 'https'; diff --git a/test/index.ts b/test/index.ts index 7b0c024..e77ebb3 100644 --- a/test/index.ts +++ b/test/index.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -import * as assert from 'assert'; +import assert from 'assert'; import {describe, it, afterEach, beforeEach} from 'mocha'; -import * as nock from 'nock'; +import nock from 'nock'; import {Readable, PassThrough} from 'stream'; import * as sinon from 'sinon'; import {teenyRequest} from '../src'; @@ -65,18 +65,18 @@ describe('teeny', () => { nock.cleanAll(); }); - it('should get JSON', done => { + it('should get JSON', async () => { const scope = mockJson(); teenyRequest({uri}, (error, response, body) => { assert.ifError(error); assert.strictEqual(response.statusCode, 200); assert.ok(body.hello); scope.done(); - done(); + // done(); }); }); - it('should set defaults', done => { + it('should set defaults', async () => { const scope = mockJson(); const defaultRequest = teenyRequest.defaults({timeout: 60000}); defaultRequest({uri}, (error, response, body) => { @@ -84,11 +84,10 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.ok(body.hello); scope.done(); - done(); }); }); - it('response event emits object compatible with request module', done => { + it('response event emits object compatible with request module', async () => { const reqHeaders = {fruit: 'banana'}; const resHeaders = {veggies: 'carrots'}; const scope = nock(uri).get('/').reply(202, 'ok', resHeaders); @@ -103,12 +102,13 @@ describe('teeny', () => { }); assert(res instanceof Readable); scope.done(); - done(); }) - .on('error', done); + .on('error', err => { + throw err; + }); }); - it('should include the request in the response', done => { + it('should include the request in the response', async () => { const path = '/?dessert=pie'; const scope = nock(uri).get(path).reply(202); const headers = {dinner: 'tacos'}; @@ -119,11 +119,10 @@ describe('teeny', () => { assert.deepStrictEqual(req.headers, headers); assert.strictEqual(req.href, url); scope.done(); - done(); }); }); - it('should not wrap the error', done => { + it('should not wrap the error', async () => { const scope = nock(uri) .get('/') .reply(200, '🚨', {'content-type': 'application/json'}); @@ -131,11 +130,10 @@ describe('teeny', () => { assert.ok(err); assert.ok(err!.message.match(/^invalid json response body/)); scope.done(); - done(); }); }); - it('should include headers in the response', done => { + it('should include headers in the response', async () => { const headers = {dinner: 'tacos'}; const body = {hello: '🌍'}; const scope = nock(uri).get('/').reply(200, body, headers); @@ -143,22 +141,20 @@ describe('teeny', () => { assert.ifError(err); assert.strictEqual(headers['dinner'], res.headers['dinner']); scope.done(); - done(); }); }); - it('should accept the forever option', done => { + it('should accept the forever option', async () => { const scope = nock(uri).get('/').reply(200); teenyRequest({uri, forever: true}, (err, res) => { assert.ifError(err); // eslint-disable-next-line @typescript-eslint/no-explicit-any assert.strictEqual((res.request.agent as any).keepAlive, true); scope.done(); - done(); }); }); - it('should allow setting compress/gzip to true', done => { + it('should allow setting compress/gzip to true', async () => { const reqheaders = { 'Accept-Encoding': 'gzip,deflate', }; @@ -168,11 +164,10 @@ describe('teeny', () => { teenyRequest({uri, gzip: true}, err => { assert.ifError(err); scope.done(); - done(); }); }); - it('should allow setting compress/gzip to false', done => { + it('should allow setting compress/gzip to false', async () => { const badheaders = ['Accept-Encoding']; const scope = nock(uri, {badheaders}).get('/').reply(200); @@ -180,13 +175,12 @@ describe('teeny', () => { teenyRequest({uri, gzip: false}, err => { assert.ifError(err); scope.done(); - done(); }); }); const envVars = ['http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY']; for (const v of envVars) { - it(`should respect ${v} environment variable for proxy config`, done => { + it(`should respect ${v} environment variable for proxy config`, () => { sandbox.stub(process, 'env').value({[v]: 'https://fake.proxy'}); const expectedBody = {hello: '🌎'}; const scope = nock(uri).get('/').reply(200, expectedBody); @@ -195,12 +189,12 @@ describe('teeny', () => { assert.ifError(err); assert.deepStrictEqual(expectedBody, body); assert.ok(res.request.agent instanceof HttpsProxyAgent); - return done(); + return; }); }); } - it('should create http proxy if upstream scheme is http', done => { + it('should create http proxy if upstream scheme is http', async () => { sandbox.stub(process, 'env').value({http_proxy: 'https://fake.proxy'}); const expectedBody = {hello: '🌎'}; const scope = nock('http://example.com').get('/').reply(200, expectedBody); @@ -209,11 +203,11 @@ describe('teeny', () => { assert.ifError(err); assert.deepStrictEqual(expectedBody, body); assert.ok(res.request.agent instanceof HttpProxyAgent); - return done(); + return; }); }); - it('should use proxy if set in request options', done => { + it('should use proxy if set in request options', async () => { const expectedBody = {hello: '🌎'}; const scope = nock(uri).get('/').reply(200, expectedBody); teenyRequest({uri, proxy: 'https://fake.proxy'}, (err, res, body) => { @@ -221,44 +215,51 @@ describe('teeny', () => { assert.ifError(err); assert.deepStrictEqual(expectedBody, body); assert.ok(res.request.agent instanceof HttpsProxyAgent); - return done(); + return; }); }); // see: https://github.com/googleapis/nodejs-storage/issues/798 - it('should not throw exception when piped through pumpify', async () => { + it.only('should not throw exception when piped through pumpify', async () => { const scope = mockJson(); + console.log('A'); const stream = teenyRequest({uri}).pipe(new PassThrough()); + console.log(stream); let content = ''; for await (const data of stream) { + console.log(data); content += data; } + console.log(content); assert.deepStrictEqual(JSON.parse(content), {hello: '🌍'}); scope.done(); }); - it('should emit response event when called without callback', done => { + it('should emit response event when called without callback', async () => { const scope = mockJson(); teenyRequest({uri}).on('response', res => { assert.ok(res); scope.done(); - return done(); + return; }); }); - it('should pipe response stream to user', done => { + it('should pipe response stream to user', () => { const scope = mockJson(); teenyRequest({uri}) - .on('error', done) + .on('error', err => { + throw err; + }) .on('data', () => { scope.done(); - done(); }); }); - it('should not pipe response stream to user unless they ask for it', done => { + it('should not pipe response stream to user unless they ask for it', async () => { const scope = mockJson(); - const stream = teenyRequest({uri}).on('error', done); + const stream = teenyRequest({uri}).on('error', err => { + throw err; + }); stream.on('response', responseStream => { // We are using an internal property of Readable to get the number of // active readers. The property changed from `pipesCount: number` in @@ -273,7 +274,6 @@ describe('teeny', () => { responseStream.body._readableState.pipes?.length; assert.strictEqual(numPipes, 1); scope.done(); - done(); }); }); }); @@ -298,7 +298,7 @@ describe('teeny', () => { assert.deepStrictEqual(newOptions, {concurrentRequests: 42}); }); - it('should emit warning on too many concurrent requests', done => { + it('should emit warning on too many concurrent requests', () => { statsStub.setOptions.restore(); statsStub.requestStarting.restore(); teenyRequest.stats.setOptions({concurrentRequests: 1}); @@ -307,32 +307,29 @@ describe('teeny', () => { teenyRequest({uri}, () => { assert.ok(emitWarnStub.calledOnce); scope.done(); - done(); }); }); - it('should track stats, callback mode, success', done => { + it('should track stats, callback mode, success', () => { const scope = mockJson(); teenyRequest({uri}, () => { assert.ok(statsStub.requestStarting.calledOnceWithExactly()); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - done(); }); }); - it('should track stats, callback mode, failure', done => { + it('should track stats, callback mode, failure', () => { const scope = mockError(); teenyRequest({uri}, err => { assert.ok(err); assert.ok(statsStub.requestStarting.calledOnceWithExactly()); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - done(); }); }); - it('should track stats, stream mode, success', done => { + it('should track stats, stream mode, success', () => { const scope = mockJson(); const readable = teenyRequest({uri}); assert.ok(statsStub.requestStarting.calledOnceWithExactly()); @@ -340,11 +337,10 @@ describe('teeny', () => { readable.once('response', () => { assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - done(); }); }); - it('should track stats, stream mode, failure', done => { + it('should track stats, stream mode, failure', () => { const scope = mockError(); const readable = teenyRequest({uri}); assert.ok(statsStub.requestStarting.calledOnceWithExactly()); @@ -353,11 +349,10 @@ describe('teeny', () => { assert.ok(err); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - done(); }); }); - it('should accept a Buffer as the body of a request', done => { + it('should accept a Buffer as the body of a request', () => { const scope = nock(uri).post('/', 'hello').reply(200, '🌍'); teenyRequest( {uri, method: 'POST', body: Buffer.from('hello')}, @@ -366,12 +361,11 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - done(); }, ); }); - it('should accept a plain string as the body of a request', done => { + it('should accept a plain string as the body of a request', () => { const scope = nock(uri).post('/', 'hello').reply(200, '🌍'); teenyRequest( {uri, method: 'POST', body: 'hello'}, @@ -380,12 +374,11 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - done(); }, ); }); - it('should accept json as the body of a request', done => { + it('should accept json as the body of a request', () => { const body = {hello: '🌍'}; const scope = nock(uri).post('/', JSON.stringify(body)).reply(200, '👋'); teenyRequest({uri, method: 'POST', json: body}, (error, response, body) => { @@ -393,7 +386,6 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '👋'); scope.done(); - done(); }); }); @@ -417,7 +409,7 @@ describe('teeny', () => { ); }); - it.skip('should track stats, multipart mode, failure', done => { + it.skip('should track stats, multipart mode, failure', () => { const scope = mockError(); teenyRequest( { @@ -431,12 +423,11 @@ describe('teeny', () => { assert.ok(statsStub.requestStarting.calledOnceWithExactly()); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - done(); }, ); }); - it('should throw an exception if uri is an empty string', done => { + it('should throw an exception if uri is an empty string', () => { assert.throws( () => { teenyRequest({uri: ''}); @@ -444,10 +435,9 @@ describe('teeny', () => { /Missing uri or url in reqOpts/, 'Did not throw with expected message', ); - done(); }); - it('should throw an exception if url is an empty string', done => { + it('should throw an exception if url is an empty string', () => { assert.throws( () => { teenyRequest({url: ''}); @@ -455,6 +445,5 @@ describe('teeny', () => { /Missing uri or url in reqOpts/, 'Did not throw with expected message', ); - done(); }); }); diff --git a/tsconfig.json b/tsconfig.json index 26f33cd..7e87ff7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,9 @@ "extends": "./node_modules/gts/tsconfig-google.json", "compilerOptions": { "rootDir": ".", - "outDir": "build" + "outDir": "build", + "moduleResolution": "nodenext", + "module": "nodenext" }, "include": [ "src/*.ts", From 8db269437e269f18d34a09b79cae1ecd623112a1 Mon Sep 17 00:00:00 2001 From: Daniel Bankhead Date: Fri, 14 Feb 2025 16:14:30 -0800 Subject: [PATCH 15/22] fix: `fetch` arg passing --- src/index.ts | 9 ++++++--- test/index.ts | 33 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7e7c407..6b1d3c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,8 +24,11 @@ import {getAgent} from './agents'; import {TeenyStatistics} from './TeenyStatistics'; // eslint-disable-next-line @typescript-eslint/no-var-requires const streamEvents = require('stream-events'); -const fetch = (...args: any[]) => - import('node-fetch').then(({default: fetch}) => fetch([...args] as any)); + +import type nodeFetch from 'node-fetch' with {'resolution-mode': 'import'}; + +const fetch = (...args: Parameters) => + import('node-fetch').then(({default: fetch}) => fetch(...args)); export interface CoreOptions { method?: string; @@ -154,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 as any, { + const response = Object.assign(res.body as {}, { statusCode: res.status, statusMessage: res.statusText, request, diff --git a/test/index.ts b/test/index.ts index e77ebb3..4dcd4df 100644 --- a/test/index.ts +++ b/test/index.ts @@ -18,7 +18,7 @@ import assert from 'assert'; import {describe, it, afterEach, beforeEach} from 'mocha'; import nock from 'nock'; -import {Readable, PassThrough} from 'stream'; +import {Readable} from 'stream'; import * as sinon from 'sinon'; import {teenyRequest} from '../src'; import {TeenyStatistics, TeenyStatisticsWarning} from '../src/TeenyStatistics'; @@ -220,18 +220,19 @@ describe('teeny', () => { }); // see: https://github.com/googleapis/nodejs-storage/issues/798 - it.only('should not throw exception when piped through pumpify', async () => { + it('should not throw exception when piped through pumpify', async () => { const scope = mockJson(); - console.log('A'); - const stream = teenyRequest({uri}).pipe(new PassThrough()); - console.log(stream); - let content = ''; + const stream = teenyRequest({uri}); + // set the encoding for the returned stream + stream.setEncoding('utf8'); + + // collect the buffers, then concat later for performance + const content: string[] = []; for await (const data of stream) { - console.log(data); - content += data; + content.push(data); } - console.log(content); - assert.deepStrictEqual(JSON.parse(content), {hello: '🌍'}); + + assert.deepStrictEqual(JSON.parse(content.join('')), {hello: '🌍'}); scope.done(); }); @@ -361,7 +362,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - }, + } ); }); @@ -374,7 +375,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - }, + } ); }); @@ -405,7 +406,7 @@ describe('teeny', () => { assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); done(); - }, + } ); }); @@ -423,7 +424,7 @@ describe('teeny', () => { assert.ok(statsStub.requestStarting.calledOnceWithExactly()); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - }, + } ); }); @@ -433,7 +434,7 @@ describe('teeny', () => { teenyRequest({uri: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message', + 'Did not throw with expected message' ); }); @@ -443,7 +444,7 @@ describe('teeny', () => { teenyRequest({url: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message', + 'Did not throw with expected message' ); }); }); From 6f06e53e9b90670088b9ce35165a6df0ec5ad9a7 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 17:07:31 -0800 Subject: [PATCH 16/22] upgrade node-fetch v3 and remove uuid --- src/TeenyStatistics.ts | 4 ++-- src/agents.ts | 2 +- src/index.ts | 3 +-- test/TeenyStatistics.ts | 22 +++++++++++----------- test/agents.ts | 8 ++++---- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/TeenyStatistics.ts b/src/TeenyStatistics.ts index 2182237..0e3a77d 100644 --- a/src/TeenyStatistics.ts +++ b/src/TeenyStatistics.ts @@ -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; @@ -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; diff --git a/src/agents.ts b/src/agents.ts index 3369dcf..2ae9e74 100644 --- a/src/agents.ts +++ b/src/agents.ts @@ -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 = diff --git a/src/index.ts b/src/index.ts index 6b1d3c1..73a9f01 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,7 +19,6 @@ import {Agent, AgentOptions as HttpsAgentOptions} from 'https'; import {AgentOptions as HttpAgentOptions} from 'http'; 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'; // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -213,7 +212,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 = globalThis.crypto?.randomUUID(); (options.headers as Headers)['Content-Type'] = `multipart/related; boundary=${boundary}`; options.body = createMultipartStream(boundary, multipart); diff --git a/test/TeenyStatistics.ts b/test/TeenyStatistics.ts index a554547..85fd45f 100644 --- a/test/TeenyStatistics.ts +++ b/test/TeenyStatistics.ts @@ -65,7 +65,7 @@ describe('TeenyStatistics', () => { it('should have default concurrent requests', () => { assert.strictEqual( TeenyStatistics.DEFAULT_WARN_CONCURRENT_REQUESTS, - 5000, + 5000 ); }); @@ -231,8 +231,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning), - ), + sinon.match.instanceOf(TeenyStatisticsWarning) + ) ); }); @@ -246,8 +246,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning), - ), + sinon.match.instanceOf(TeenyStatisticsWarning) + ) ); // shouldn't emit on the next call (i.e. still greater than threshold) @@ -271,8 +271,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning), - ), + sinon.match.instanceOf(TeenyStatisticsWarning) + ) ); // let's bring the counter back down @@ -298,7 +298,7 @@ describe('TeenyStatistics', () => { assert.strictEqual(warning.value, 5e3); assert.strictEqual( warning.type, - TeenyStatisticsWarning.CONCURRENT_REQUESTS, + TeenyStatisticsWarning.CONCURRENT_REQUESTS ); }); @@ -311,15 +311,15 @@ describe('TeenyStatistics', () => { const errStr: string = emitWarnStub.firstCall.args[0].toString(); assert( errStr.includes('Possible excessive concurrent requests detected.'), - 'describes the nature of the warning', + 'describes the nature of the warning' ); assert( errStr.includes('TEENY_REQUEST_WARN_CONCURRENT_REQUESTS'), - 'mentions env var', + 'mentions env var' ); assert( errStr.includes('concurrentRequests'), - 'mentions concurrentRequests option', + 'mentions concurrentRequests option' ); assert(errStr.search(/\b0\b/) !== -1, 'mentions 0'); }); diff --git a/test/agents.ts b/test/agents.ts index 6ea3f8d..46e5d6c 100644 --- a/test/agents.ts +++ b/test/agents.ts @@ -211,7 +211,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions, + defaultOptions ); const agent = getAgent(uri, options); assert.strictEqual(agent!.maxSockets, 1000); @@ -224,7 +224,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions, + defaultOptions ); const agent = getAgent(uri, options); assert.strictEqual(agent, undefined); @@ -243,7 +243,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions, + defaultOptions ); const agent = getAgent(uri, options); assert.strictEqual(agent!.maxSockets, 1000); @@ -256,7 +256,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions, + defaultOptions ); const agent = getAgent(uri, options); assert.strictEqual(agent, undefined); From e8c08107d3b67f2f0de835880d07bbc7b2942f54 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 17:08:06 -0800 Subject: [PATCH 17/22] remove uuid --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index c54c048..8ba4a31 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,7 @@ "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0", "node-fetch": "^3.3.2", - "stream-events": "^1.0.5", - "uuid": "^11.0.5" + "stream-events": "^1.0.5" }, "devDependencies": { "@babel/plugin-proposal-private-methods": "^7.18.6", From b152c9511ecd53ea702f21c473307290d9c67766 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 17:10:45 -0800 Subject: [PATCH 18/22] run lint --- src/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/index.ts b/src/index.ts index 73a9f01..92501ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -202,7 +202,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); @@ -236,7 +236,7 @@ function teenyRequest( }, (err: Error) => { callback(err, response, body); - }, + } ); return; } @@ -248,13 +248,13 @@ function teenyRequest( }, err => { callback(err, response, body); - }, + } ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - }, + } ); return; } @@ -291,7 +291,7 @@ function teenyRequest( err => { teenyRequest.stats.requestFinished(); requestStream.emit('error', err); - }, + } ); // fetch doesn't supply the raw HTTP stream, instead it @@ -324,7 +324,7 @@ function teenyRequest( }, err => { callback(err, response, body); - }, + } ); return; } @@ -337,13 +337,13 @@ function teenyRequest( }, err => { callback(err, response, body); - }, + } ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - }, + } ); return; } From 887b16de0b38e31597b3d828e2b2ca9661fb908b Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 17:13:29 -0800 Subject: [PATCH 19/22] fix how we ingest uuid; --- src/index.ts | 19 ++++++++++--------- test/index.ts | 12 ++++++------ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/index.ts b/src/index.ts index 92501ed..737560a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,6 +21,7 @@ import type * as f from 'node-fetch' with {'resolution-mode': 'import'}; import {PassThrough, Readable, pipeline} from 'stream'; 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'); @@ -202,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); @@ -212,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 = globalThis.crypto?.randomUUID(); + const boundary: string = randomUUID(); (options.headers as Headers)['Content-Type'] = `multipart/related; boundary=${boundary}`; options.body = createMultipartStream(boundary, multipart); @@ -236,7 +237,7 @@ function teenyRequest( }, (err: Error) => { callback(err, response, body); - } + }, ); return; } @@ -248,13 +249,13 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - } + }, ); return; } @@ -291,7 +292,7 @@ function teenyRequest( err => { teenyRequest.stats.requestFinished(); requestStream.emit('error', err); - } + }, ); // fetch doesn't supply the raw HTTP stream, instead it @@ -324,7 +325,7 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); return; } @@ -337,13 +338,13 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - } + }, ); return; } diff --git a/test/index.ts b/test/index.ts index 4dcd4df..1dcd69e 100644 --- a/test/index.ts +++ b/test/index.ts @@ -362,7 +362,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - } + }, ); }); @@ -375,7 +375,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - } + }, ); }); @@ -406,7 +406,7 @@ describe('teeny', () => { assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); done(); - } + }, ); }); @@ -424,7 +424,7 @@ describe('teeny', () => { assert.ok(statsStub.requestStarting.calledOnceWithExactly()); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - } + }, ); }); @@ -434,7 +434,7 @@ describe('teeny', () => { teenyRequest({uri: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message' + 'Did not throw with expected message', ); }); @@ -444,7 +444,7 @@ describe('teeny', () => { teenyRequest({url: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message' + 'Did not throw with expected message', ); }); }); From e15b70f98b987bbfb30739b8f3a4c6352ee91b29 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 17:17:13 -0800 Subject: [PATCH 20/22] run lint --- src/index.ts | 16 ++++++++-------- test/index.ts | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index 737560a..006e034 100644 --- a/src/index.ts +++ b/src/index.ts @@ -203,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); @@ -237,7 +237,7 @@ function teenyRequest( }, (err: Error) => { callback(err, response, body); - }, + } ); return; } @@ -249,13 +249,13 @@ function teenyRequest( }, err => { callback(err, response, body); - }, + } ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - }, + } ); return; } @@ -292,7 +292,7 @@ function teenyRequest( err => { teenyRequest.stats.requestFinished(); requestStream.emit('error', err); - }, + } ); // fetch doesn't supply the raw HTTP stream, instead it @@ -325,7 +325,7 @@ function teenyRequest( }, err => { callback(err, response, body); - }, + } ); return; } @@ -338,13 +338,13 @@ function teenyRequest( }, err => { callback(err, response, body); - }, + } ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - }, + } ); return; } diff --git a/test/index.ts b/test/index.ts index 1dcd69e..4dcd4df 100644 --- a/test/index.ts +++ b/test/index.ts @@ -362,7 +362,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - }, + } ); }); @@ -375,7 +375,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - }, + } ); }); @@ -406,7 +406,7 @@ describe('teeny', () => { assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); done(); - }, + } ); }); @@ -424,7 +424,7 @@ describe('teeny', () => { assert.ok(statsStub.requestStarting.calledOnceWithExactly()); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - }, + } ); }); @@ -434,7 +434,7 @@ describe('teeny', () => { teenyRequest({uri: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message', + 'Did not throw with expected message' ); }); @@ -444,7 +444,7 @@ describe('teeny', () => { teenyRequest({url: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message', + 'Did not throw with expected message' ); }); }); From b7505ff48089d9a2f5fd9b59231a08bc7a5807af Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 18:18:01 -0800 Subject: [PATCH 21/22] rerun lint --- src/index.ts | 16 ++++++++-------- test/index.ts | 12 ++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index 006e034..737560a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -203,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); @@ -237,7 +237,7 @@ function teenyRequest( }, (err: Error) => { callback(err, response, body); - } + }, ); return; } @@ -249,13 +249,13 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - } + }, ); return; } @@ -292,7 +292,7 @@ function teenyRequest( err => { teenyRequest.stats.requestFinished(); requestStream.emit('error', err); - } + }, ); // fetch doesn't supply the raw HTTP stream, instead it @@ -325,7 +325,7 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); return; } @@ -338,13 +338,13 @@ function teenyRequest( }, err => { callback(err, response, body); - } + }, ); }, err => { teenyRequest.stats.requestFinished(); callback(err, null!, null); - } + }, ); return; } diff --git a/test/index.ts b/test/index.ts index 4dcd4df..1dcd69e 100644 --- a/test/index.ts +++ b/test/index.ts @@ -362,7 +362,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - } + }, ); }); @@ -375,7 +375,7 @@ describe('teeny', () => { assert.strictEqual(response.statusCode, 200); assert.strictEqual(body, '🌍'); scope.done(); - } + }, ); }); @@ -406,7 +406,7 @@ describe('teeny', () => { assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); done(); - } + }, ); }); @@ -424,7 +424,7 @@ describe('teeny', () => { assert.ok(statsStub.requestStarting.calledOnceWithExactly()); assert.ok(statsStub.requestFinished.calledOnceWithExactly()); scope.done(); - } + }, ); }); @@ -434,7 +434,7 @@ describe('teeny', () => { teenyRequest({uri: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message' + 'Did not throw with expected message', ); }); @@ -444,7 +444,7 @@ describe('teeny', () => { teenyRequest({url: ''}); }, /Missing uri or url in reqOpts/, - 'Did not throw with expected message' + 'Did not throw with expected message', ); }); }); From 67d0aa80e7190d04a773261338f551b6f8343a22 Mon Sep 17 00:00:00 2001 From: Sofia Leon Date: Fri, 14 Feb 2025 18:19:40 -0800 Subject: [PATCH 22/22] rerun lint --- src/TeenyStatistics.ts | 4 ++-- src/agents.ts | 2 +- test/TeenyStatistics.ts | 22 +++++++++++----------- test/agents.ts | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/TeenyStatistics.ts b/src/TeenyStatistics.ts index 0e3a77d..2182237 100644 --- a/src/TeenyStatistics.ts +++ b/src/TeenyStatistics.ts @@ -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; @@ -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; diff --git a/src/agents.ts b/src/agents.ts index 2ae9e74..3369dcf 100644 --- a/src/agents.ts +++ b/src/agents.ts @@ -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 = diff --git a/test/TeenyStatistics.ts b/test/TeenyStatistics.ts index 85fd45f..a554547 100644 --- a/test/TeenyStatistics.ts +++ b/test/TeenyStatistics.ts @@ -65,7 +65,7 @@ describe('TeenyStatistics', () => { it('should have default concurrent requests', () => { assert.strictEqual( TeenyStatistics.DEFAULT_WARN_CONCURRENT_REQUESTS, - 5000 + 5000, ); }); @@ -231,8 +231,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning) - ) + sinon.match.instanceOf(TeenyStatisticsWarning), + ), ); }); @@ -246,8 +246,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning) - ) + sinon.match.instanceOf(TeenyStatisticsWarning), + ), ); // shouldn't emit on the next call (i.e. still greater than threshold) @@ -271,8 +271,8 @@ describe('TeenyStatistics', () => { t.requestStarting(); assert( emitWarnStub.calledOnceWith( - sinon.match.instanceOf(TeenyStatisticsWarning) - ) + sinon.match.instanceOf(TeenyStatisticsWarning), + ), ); // let's bring the counter back down @@ -298,7 +298,7 @@ describe('TeenyStatistics', () => { assert.strictEqual(warning.value, 5e3); assert.strictEqual( warning.type, - TeenyStatisticsWarning.CONCURRENT_REQUESTS + TeenyStatisticsWarning.CONCURRENT_REQUESTS, ); }); @@ -311,15 +311,15 @@ describe('TeenyStatistics', () => { const errStr: string = emitWarnStub.firstCall.args[0].toString(); assert( errStr.includes('Possible excessive concurrent requests detected.'), - 'describes the nature of the warning' + 'describes the nature of the warning', ); assert( errStr.includes('TEENY_REQUEST_WARN_CONCURRENT_REQUESTS'), - 'mentions env var' + 'mentions env var', ); assert( errStr.includes('concurrentRequests'), - 'mentions concurrentRequests option' + 'mentions concurrentRequests option', ); assert(errStr.search(/\b0\b/) !== -1, 'mentions 0'); }); diff --git a/test/agents.ts b/test/agents.ts index 46e5d6c..6ea3f8d 100644 --- a/test/agents.ts +++ b/test/agents.ts @@ -211,7 +211,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent!.maxSockets, 1000); @@ -224,7 +224,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent, undefined); @@ -243,7 +243,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent!.maxSockets, 1000); @@ -256,7 +256,7 @@ describe('agents', () => { maxSockets: 1000, }, }, - defaultOptions + defaultOptions, ); const agent = getAgent(uri, options); assert.strictEqual(agent, undefined);