diff --git a/flow-typed/npm/node-fetch_v2.x.x.js b/flow-typed/npm/node-fetch_v2.x.x.js deleted file mode 100644 index 83429219078..00000000000 --- a/flow-typed/npm/node-fetch_v2.x.x.js +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict - * @format - */ - -// Modified from flow-typed repo: -// https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/node-fetch_v2.x.x/flow_v0.104.x-/node-fetch_v2.x.x.js - -declare module 'node-fetch' { - import type http from 'http'; - import type https from 'https'; - import type {Readable} from 'stream'; - - declare type AbortSignal = { - readonly aborted: boolean, - readonly onabort: (event?: {...}) => void, - - readonly addEventListener: (name: string, cb: () => unknown) => void, - readonly removeEventListener: (name: string, cb: () => unknown) => void, - readonly dispatchEvent: (event: {...}) => void, - ... - }; - - declare class Request mixins Body { - constructor( - input: string | {href: string, ...} | Request, - init?: RequestInit, - ): this; - context: RequestContext; - headers: Headers; - method: string; - redirect: RequestRedirect; - referrer: string; - url: string; - - // node-fetch extensions - agent: http.Agent | https.Agent; - compress: boolean; - counter: number; - follow: number; - hostname: string; - port: number; - protocol: string; - size: number; - timeout: number; - } - - declare type HeaderObject = {[index: string]: string | number, ...}; - - declare type RequestInit = { - body?: BodyInit, - headers?: HeaderObject | null, - method?: string, - redirect?: RequestRedirect, - signal?: AbortSignal | null, - - // node-fetch extensions - agent?: - ((v: URL) => http.Agent | https.Agent) | http.Agent | https.Agent | null, - compress?: boolean, - follow?: number, - size?: number, - timeout?: number, - }; - - declare interface FetchError extends Error { - // cannot set name due to incompatible extend error - // name: 'FetchError'; - type: string; - code: ?number; - errno: ?number; - } - - declare interface AbortError extends Error { - // cannot set name due to incompatible extend error - // name: 'AbortError'; - type: 'aborted'; - } - - declare type RequestContext = - | 'audio' - | 'beacon' - | 'cspreport' - | 'download' - | 'embed' - | 'eventsource' - | 'favicon' - | 'fetch' - | 'font' - | 'form' - | 'frame' - | 'hyperlink' - | 'iframe' - | 'image' - | 'imageset' - | 'import' - | 'internal' - | 'location' - | 'manifest' - | 'object' - | 'ping' - | 'plugin' - | 'prefetch' - | 'script' - | 'serviceworker' - | 'sharedworker' - | 'subresource' - | 'style' - | 'track' - | 'video' - | 'worker' - | 'xmlhttprequest' - | 'xslt'; - declare type RequestRedirect = 'error' | 'follow' | 'manual'; - - declare class Headers { - append(name: string, value: string): void; - delete(name: string): void; - forEach(callback: (value: string, name: string) => void): void; - get(name: string): string; - getAll(name: string): Array; - has(name: string): boolean; - raw(): {[k: string]: string[], ...}; - set(name: string, value: string): void; - entries(): Iterator<[string, string]>; - keys(): Iterator; - values(): Iterator; - @@iterator(): Iterator<[string, string]>; - } - - declare class Body { - buffer(): Promise; - json(): Promise; - json(): Promise; - text(): Promise; - body: stream$Readable; - bodyUsed: boolean; - } - - declare class Response mixins Body { - constructor(body?: BodyInit, init?: ResponseInit): this; - clone(): Response; - error(): Response; - redirect(url: string, status: number): Response; - headers: Headers; - ok: boolean; - status: number; - statusText: string; - size: number; - timeout: number; - type: ResponseType; - url: string; - } - - declare type ResponseType = - 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect'; - - declare interface ResponseInit { - headers?: HeaderInit; - status: number; - statusText?: string; - } - - declare type HeaderInit = Headers | Array; - declare type BodyInit = - string | null | Buffer | Blob | Readable | URLSearchParams; - - declare function fetch( - url: string | URL | Request, - init?: RequestInit, - ): Promise; - - declare module.exports: typeof fetch; -} diff --git a/package.json b/package.json index 66a38257073..3298ae9b2f0 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,6 @@ "metro-babel-register": "^0.88.0", "metro-transform-plugins": "^0.88.0", "micromatch": "^4.0.4", - "node-fetch": "^2.2.0", "nullthrows": "^1.1.1", "pixelmatch": "5.3.0", "pngjs": "7.0.0", diff --git a/scripts/release-testing/utils/github-actions-utils.js b/scripts/release-testing/utils/github-actions-utils.js index 7a173c102a8..bc2f8ea419a 100644 --- a/scripts/release-testing/utils/github-actions-utils.js +++ b/scripts/release-testing/utils/github-actions-utils.js @@ -11,7 +11,6 @@ 'use strict'; -const fetch = require('node-fetch'); const {execSync: exec} = require('node:child_process'); const {styleText} = require('node:util'); @@ -75,41 +74,33 @@ const reactNativeActionsURL = `${reactNativeRepo}actions/runs`; async function _getActionRunsOnBranch() /*: Promise */ { const url = `${reactNativeActionsURL}?branch=${branch}&per_page=100`; - const options = { + const options /*: RequestInit */ = { method: 'GET', headers: ciHeaders, }; - // $FlowFixMe[prop-missing] Conflicting .flowconfig in Meta's monorepo - // $FlowFixMe[incompatible-type] const response = await fetch(url, options); if (!response.ok) { throw new Error(JSON.stringify(await response.json())); } - const body = await response - .json /*::*/ - (); + const body /*: WorkflowRuns */ = await response.json(); return body; } async function _getArtifacts(run_id /*: number */) /*: Promise */ { const url = `${reactNativeActionsURL}/${run_id}/artifacts?per_page=100`; - const options = { + const options /*: RequestInit */ = { method: 'GET', headers: ciHeaders, }; - // $FlowFixMe[prop-missing] Conflicting .flowconfig in Meta's monorepo - // $FlowFixMe[incompatible-type] const response = await fetch(url, options); if (!response.ok) { throw new Error(JSON.stringify(await response.json())); } - const body = await response - .json /*::*/ - (); + const body /*: Artifacts */ = await response.json(); return body; } diff --git a/yarn.lock b/yarn.lock index 1bd980abff8..f70b67d532e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7386,13 +7386,6 @@ node-exports-info@^1.6.0: object.entries "^1.1.9" semver "^6.3.1" -node-fetch@^2.2.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== - dependencies: - whatwg-url "^5.0.0" - node-int64@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" @@ -9006,11 +8999,6 @@ toidentifier@1.0.1, toidentifier@~1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - traverse@0.6.6: version "0.6.6" resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" @@ -9376,24 +9364,11 @@ wcwidth@^1.0.1: dependencies: defaults "^1.0.3" -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - whatwg-fetch@^3.0.0: version "3.6.20" resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70" integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg== -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"