From b3b91ca779ab137b709735d51b8ad2e365438caa Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Fri, 12 Jul 2024 17:32:28 +0300 Subject: [PATCH] resolve: Replace request with fetch Change-type: patch --- lib/resolve/resolvers/nodeResolver.ts | 20 +++++++------------- package.json | 2 -- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/resolve/resolvers/nodeResolver.ts b/lib/resolve/resolvers/nodeResolver.ts index 4a9b684..1f8d001 100644 --- a/lib/resolve/resolvers/nodeResolver.ts +++ b/lib/resolve/resolvers/nodeResolver.ts @@ -17,11 +17,7 @@ import * as memoize from 'memoizee'; import * as _ from 'lodash'; -import * as request from 'request'; import * as semver from 'semver'; -import { promisify } from 'util'; - -const getAsync = promisify(request.get); import type { Bundle, FileInfo, Resolver } from '../resolver'; import type { ParsedPathPlus } from '../utils'; @@ -34,19 +30,17 @@ const getDeviceTypeVersions = memoize( let nextUrl: string | undefined = `https://hub.docker.com/v2/repositories/resin/${deviceType}-node/tags/?page_size=100`; while (nextUrl != null) { - const res = ( - await getAsync({ - url: nextUrl, - json: true, - }) - ).body as { results: Array<{ name: string }>; next?: string }; - - const curr: string[] = res.results + const response = (await fetch(nextUrl).then((res) => res.json())) as { + results: Array<{ name: string }>; + next?: string; + }; + + const curr: string[] = response.results .map(({ name }) => name) .filter(versionTest); tags.push(...curr); - nextUrl = res.next; + nextUrl = response.next; } return tags; diff --git a/package.json b/package.json index 91471aa..55e4c82 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,6 @@ "@types/mz": "^2.7.4", "@types/node": "^18.19.39", "@types/proxyquire": "^1.3.28", - "@types/request": "^2.48.4", "@types/semver": "^7.3.5", "@types/tar-stream": "^2.2.0", "chai": "^4.3.4", @@ -84,7 +83,6 @@ "mz": "^2.7.0", "p-map": "^4.0.0", "pinejs-client-core": "^6.13.0", - "request": "^2.88.2", "semver": "^7.3.5", "stream-to-promise": "^3.0.0", "tar-stream": "^3.1.6",