From e087269252825cd2c08fabcd10bc3be45c8ea738 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Tue, 21 Jan 2025 15:02:21 -0800 Subject: [PATCH] hmmmm --- .eslintrc.json | 7 +++- package.json | 4 +- src/Cache.ts | 1 + src/GotDownloader.ts | 6 ++- test/utils.spec.ts | 1 + tsconfig.esm.json | 5 ++- tsconfig.json | 6 +-- yarn.lock | 96 ++++++++++++++++++-------------------------- 8 files changed, 59 insertions(+), 67 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index dbeda04a9..0e83d94c0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,11 +3,14 @@ "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", - "plugin:jest/recommended", "plugin:import/errors", "plugin:import/warnings", "plugin:import/typescript", "prettier", "prettier/@typescript-eslint" - ] + ], + "rules": { + "@typescript-eslint/prefer-ts-expect-error": 0, + "@typescript-eslint/ban-ts-comment": 0 + } } diff --git a/package.json b/package.json index 61eea0c0c..04d24347b 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "prettier:write": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "prepublishOnly": "npm run build", "test": "vitest run --coverage", - "test:nonetwork": "npm run lint && npm run jest -- --testPathIgnorePatterns network.spec" + "test:nonetwork": "npm run lint && vitest run --coverage --testPathIgnorePatterns network.spec" }, "files": [ "dist/", @@ -32,7 +32,7 @@ "dependencies": { "debug": "^4.1.1", "env-paths": "^3.0.0", - "got": "^14.4.5", + "got": "^12.6.1", "progress": "^2.0.3", "semver": "^7.6.3", "sumchecker": "^3.0.1" diff --git a/src/Cache.ts b/src/Cache.ts index e1e46ea9a..219b5e76c 100644 --- a/src/Cache.ts +++ b/src/Cache.ts @@ -1,4 +1,5 @@ import debug from 'debug'; +// @ts-ignore - require(esm) supported in Node 22.12 import envPaths from 'env-paths'; import crypto from 'node:crypto'; diff --git a/src/GotDownloader.ts b/src/GotDownloader.ts index 0df650058..5d3c87202 100644 --- a/src/GotDownloader.ts +++ b/src/GotDownloader.ts @@ -1,4 +1,8 @@ +/* eslint-disable */ +// @ts-ignore - require(esm) supported in Node 22.12 import got, { HTTPError, Progress as GotProgress, Options as GotOptions } from 'got'; +/* eslint-enable */ + import fs from 'node:fs'; import path from 'node:path'; import ProgressBar from 'progress'; @@ -34,7 +38,7 @@ export class GotDownloader implements Downloader { async download( url: string, targetFilePath: string, - options?: GotDownloaderOptions, + options?: Partial, ): Promise { if (!options) { options = {}; diff --git a/test/utils.spec.ts b/test/utils.spec.ts index 1297de649..30cec1545 100644 --- a/test/utils.spec.ts +++ b/test/utils.spec.ts @@ -95,6 +95,7 @@ describe('utils', () => { vi.spyOn(process, 'arch', 'get').mockReturnValue('arm'); vi.spyOn(process, 'config', 'get').mockReturnValue({ ...process.config, + // eslint-disable-next-line @typescript-eslint/no-explicit-any variables: {} as any, }); expect(getHostArch()).toEqual('armv7l'); diff --git a/tsconfig.esm.json b/tsconfig.esm.json index 53692fe96..f084f0968 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -1,7 +1,8 @@ { "extends": "./tsconfig.json", "compilerOptions": { - "module": "esnext", + "module": "ESNext", + "moduleResolution": "node", "outDir": "dist/esm" } -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index a2663a7cd..44e87392a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,11 @@ { "extends": "@tsconfig/node22/tsconfig.json", "compilerOptions": { - "module": "CommonJS", - "moduleResolution": "node", + "module": "Node16", + "moduleResolution": "Node16", "sourceMap": true, "outDir": "dist/cjs", - "types": ["node", "jest"], + "types": ["node"], "allowSyntheticDefaultImports": true, "declaration": true, "skipLibCheck": false diff --git a/yarn.lock b/yarn.lock index ac728cecd..0716bd13f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -391,15 +391,10 @@ resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8" integrity sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g== -"@sec-ant/readable-stream@^0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz#60de891bb126abfdc5410fdc6166aca065f10a0c" - integrity sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg== - -"@sindresorhus/is@^7.0.1": - version "7.0.1" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-7.0.1.tgz#693cd0bfa7fdc71a3386b72088b660fb70851927" - integrity sha512-QWLl2P+rsCJeofkDNIT3WFmb6NrRud1SUYW8dIhXK/46XFV8Q/g7Bsvib0Askb0reRLe+WYPeeE+l5cH7SlkuQ== +"@sindresorhus/is@^5.2.0": + version "5.6.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-5.6.0.tgz#41dd6093d34652cddb5d5bdeee04eafc33826668" + integrity sha512-TV7t8GKYaJWsn00tFDqBw8+Uqmr8A0fRU1tvTQhyZzGv0sJCGRQL3JGMI3ucuKo3XIZdUP+Lx7/gh2t3lewy7g== "@szmarczak/http-timer@^5.0.1": version "5.0.1" @@ -423,7 +418,7 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== -"@types/http-cache-semantics@^4.0.4": +"@types/http-cache-semantics@^4.0.2": version "4.0.4" resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4" integrity sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA== @@ -798,17 +793,17 @@ cacheable-lookup@^7.0.0: resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz#3476a8215d046e5a3202a9209dd13fec1f933a27" integrity sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w== -cacheable-request@^12.0.1: - version "12.0.1" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-12.0.1.tgz#e6f473b5b76c02e72a0ec2cd44c7cfb7c751d7c5" - integrity sha512-Yo9wGIQUaAfIbk+qY0X4cDQgCosecfBe3V9NSyeY4qPC2SAkbCS4Xj79VP8WOzitpJUZKc/wsRCYF5ariDIwkg== +cacheable-request@^10.2.8: + version "10.2.14" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-10.2.14.tgz#eb915b665fda41b79652782df3f553449c406b9d" + integrity sha512-zkDT5WAF4hSSoUgyfg5tFIxz8XQK+25W/TLVojJTMKBaxevLBBtLxgqguAuVQB8PVW79FVjHcU+GJ9tVbDZ9mQ== dependencies: - "@types/http-cache-semantics" "^4.0.4" - get-stream "^9.0.1" + "@types/http-cache-semantics" "^4.0.2" + get-stream "^6.0.1" http-cache-semantics "^4.1.1" - keyv "^4.5.4" + keyv "^4.5.3" mimic-response "^4.0.0" - normalize-url "^8.0.1" + normalize-url "^8.0.0" responselike "^3.0.0" call-bind-apply-helpers@^1.0.0, call-bind-apply-helpers@^1.0.1: @@ -1480,10 +1475,10 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" -form-data-encoder@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-4.0.2.tgz#dd286fd5f9049e8ded1d44ce427f5e29185c7c12" - integrity sha512-KQVhvhK8ZkWzxKxOr56CPulAhH3dobtuQ4+hNQ+HekH/Wp5gSOafqRAeTphQUJAIk0GBvHZgJ2ZGRWd5kphMuw== +form-data-encoder@^2.1.2: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-2.1.4.tgz#261ea35d2a70d48d30ec7a9603130fa5515e9cd5" + integrity sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw== fs.realpath@^1.0.0: version "1.0.0" @@ -1551,19 +1546,16 @@ get-stdin@^6.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== +get-stream@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== + get-stream@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-8.0.1.tgz#def9dfd71742cd7754a7761ed43749a27d02eca2" integrity sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA== -get-stream@^9.0.1: - version "9.0.1" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-9.0.1.tgz#95157d21df8eb90d1647102b63039b1df60ebd27" - integrity sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA== - dependencies: - "@sec-ant/readable-stream" "^0.4.1" - is-stream "^4.0.1" - get-symbol-description@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/get-symbol-description/-/get-symbol-description-1.1.0.tgz#7bdd54e0befe8ffc9f3b4e203220d9f1e881b6ee" @@ -1650,22 +1642,22 @@ gopd@^1.0.1, gopd@^1.2.0: resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.2.0.tgz#89f56b8217bdbc8802bd299df6d7f1081d7e51a1" integrity sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg== -got@^14.4.5: - version "14.4.5" - resolved "https://registry.yarnpkg.com/got/-/got-14.4.5.tgz#49a8b49a49a851d658b19e2d1b97e50ef8903f17" - integrity sha512-sq+uET8TnNKRNnjEOPJzMcxeI0irT8BBNmf+GtZcJpmhYsQM1DSKmCROUjPWKsXZ5HzwD5Cf5/RV+QD9BSTxJg== +got@^12.6.1: + version "12.6.1" + resolved "https://registry.yarnpkg.com/got/-/got-12.6.1.tgz#8869560d1383353204b5a9435f782df9c091f549" + integrity sha512-mThBblvlAF1d4O5oqyvN+ZxLAYwIJK7bpMxgYqPD9okW0C3qm5FFn7k811QrcuEBwaogR3ngOFoCfs6mRv7teQ== dependencies: - "@sindresorhus/is" "^7.0.1" + "@sindresorhus/is" "^5.2.0" "@szmarczak/http-timer" "^5.0.1" cacheable-lookup "^7.0.0" - cacheable-request "^12.0.1" + cacheable-request "^10.2.8" decompress-response "^6.0.0" - form-data-encoder "^4.0.2" - http2-wrapper "^2.2.1" + form-data-encoder "^2.1.2" + get-stream "^6.0.1" + http2-wrapper "^2.1.10" lowercase-keys "^3.0.0" - p-cancelable "^4.0.1" + p-cancelable "^3.0.0" responselike "^3.0.0" - type-fest "^4.26.1" graphemer@^1.4.0: version "1.4.0" @@ -1725,7 +1717,7 @@ http-cache-semantics@^4.1.1: resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== -http2-wrapper@^2.2.1: +http2-wrapper@^2.1.10: version "2.2.1" resolved "https://registry.yarnpkg.com/http2-wrapper/-/http2-wrapper-2.2.1.tgz#310968153dcdedb160d8b72114363ef5fce1f64a" integrity sha512-V5nVw1PAOgfI3Lmeaj2Exmeg7fenjhRUgz1lPSezy1CuhPYbgQtbQj4jZfEAEMlaL+vupsvhjqCyjzob0yxsmQ== @@ -1949,11 +1941,6 @@ is-stream@^3.0.0: resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-3.0.0.tgz#e6bfd7aa6bef69f4f472ce9bb681e3e57b4319ac" integrity sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA== -is-stream@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-4.0.1.tgz#375cf891e16d2e4baec250b85926cffc14720d9b" - integrity sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A== - is-string@^1.0.7, is-string@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.1.1.tgz#92ea3f3d5c5b6e039ca8677e5ac8d07ea773cbb9" @@ -2087,7 +2074,7 @@ jsonc-parser@^3.2.0: resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.1.tgz#031904571ccf929d7670ee8c547545081cb37f1a" integrity sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA== -keyv@^4.5.3, keyv@^4.5.4: +keyv@^4.5.3: version "4.5.4" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.4.tgz#a879a99e29452f942439f2a405e3af8b31d4de93" integrity sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw== @@ -2305,7 +2292,7 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -normalize-url@^8.0.1: +normalize-url@^8.0.0: version "8.0.1" resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-8.0.1.tgz#9b7d96af9836577c58f5883e939365fa15623a4a" integrity sha512-IO9QvjUMWxPQQhs60oOu10CRkWCiZzSUkzbXGGV9pviYl1fXYcvkzQ5jV9z8Y6un8ARoVRl4EtC6v6jNqbaJ/w== @@ -2410,10 +2397,10 @@ own-keys@^1.0.1: object-keys "^1.1.1" safe-push-apply "^1.0.0" -p-cancelable@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-4.0.1.tgz#2d1edf1ab8616b72c73db41c4bc9ecdd10af640e" - integrity sha512-wBowNApzd45EIKdO1LaU+LrMBwAcjfPaYtVzV3lmfM3gf8Z4CHZsiIqlM8TZZ8okYvh5A1cP6gTfCRQtwUpaUg== +p-cancelable@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-3.0.0.tgz#63826694b54d61ca1c20ebcb6d3ecf5e14cd8050" + integrity sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw== p-limit@^3.0.2: version "3.1.0" @@ -3062,11 +3049,6 @@ type-fest@^0.20.2: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4" integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ== -type-fest@^4.26.1: - version "4.33.0" - resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.33.0.tgz#2da0c135b9afa76cf8b18ecfd4f260ecd414a432" - integrity sha512-s6zVrxuyKbbAsSAD5ZPTB77q4YIdRctkTbJ2/Dqlinwz+8ooH2gd+YA7VA6Pa93KML9GockVvoxjZ2vHP+mu8g== - typed-array-buffer@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536"