Skip to content

Commit 1fae937

Browse files
authored
[rush] Remove node-fetch. (#5031)
* Remove node-fetch. * fixup! Remove node-fetch. * Make the next release of Rush a minor bump. * Convert inline snapshots to normal snapshots. * Memoize parsed and stringified response. * Support compression. * fixup! Support compression. * fixup! Support compression. * Improve content decoding. * fixup! Memoize parsed and stringified response. * fixup! Support compression. * Drop the Accept-Encoding header.
1 parent 6c66b58 commit 1fae937

File tree

16 files changed

+422
-478
lines changed

16 files changed

+422
-478
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/rush",
5+
"comment": "Remove the dependency on node-fetch.",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@microsoft/rush"
10+
}

common/config/rush/version-policies.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"policyName": "rush",
104104
"definitionName": "lockStepVersion",
105105
"version": "5.144.1",
106-
"nextBump": "patch",
106+
"nextBump": "minor",
107107
"mainProject": "@microsoft/rush"
108108
}
109109
]

common/config/subspaces/build-tests-subspace/pnpm-lock.yaml

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
22
{
3-
"pnpmShrinkwrapHash": "be8fa6aee16239aa65766063b1b600566fe13d2b",
3+
"pnpmShrinkwrapHash": "91719dffed0a42aec00fee22b00e6c236b96fc7e",
44
"preferredVersionsHash": "ce857ea0536b894ec8f346aaea08cfd85a5af648",
5-
"packageJsonInjectedDependenciesHash": "3e941f94bf991fc5ad180bc33d43dec969990e74"
5+
"packageJsonInjectedDependenciesHash": "7bb5b296a95ab3932d6ffa5b97edd5ea79613f33"
66
}

common/config/subspaces/default/pnpm-lock.yaml

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libraries/rush-lib/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"@rushstack/stream-collator": "workspace:*",
4141
"@rushstack/terminal": "workspace:*",
4242
"@rushstack/ts-command-line": "workspace:*",
43-
"@types/node-fetch": "2.6.2",
4443
"@yarnpkg/lockfile": "~1.0.2",
4544
"builtin-modules": "~3.1.0",
4645
"cli-table": "~0.3.1",
@@ -53,7 +52,6 @@
5352
"ignore": "~5.1.6",
5453
"inquirer": "~7.3.3",
5554
"js-yaml": "~3.13.1",
56-
"node-fetch": "2.6.7",
5755
"npm-check": "~6.0.1",
5856
"npm-package-arg": "~6.1.0",
5957
"read-package-tree": "~5.1.5",

libraries/rush-lib/src/logic/base/BaseInstallManager.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import type * as fetch from 'node-fetch';
54
import * as os from 'os';
65
import * as path from 'path';
76
import * as crypto from 'crypto';
@@ -48,7 +47,7 @@ import { ShrinkwrapFileFactory } from '../ShrinkwrapFileFactory';
4847
import { Utilities } from '../../utilities/Utilities';
4948
import { InstallHelpers } from '../installManager/InstallHelpers';
5049
import * as PolicyValidator from '../policy/PolicyValidator';
51-
import type { WebClient as WebClientType, WebClientResponse } from '../../utilities/WebClient';
50+
import type { WebClient as WebClientType, IWebClientResponse } from '../../utilities/WebClient';
5251
import { SetupPackageRegistry } from '../setup/SetupPackageRegistry';
5352
import { PnpmfileConfiguration } from '../pnpm/PnpmfileConfiguration';
5453
import type { IInstallManagerOptions } from './BaseInstallManagerTypes';
@@ -1066,12 +1065,13 @@ ${gitLfsHookHandling}
10661065
webClient.userAgent = `pnpm/? npm/? node/${process.version} ${os.platform()} ${os.arch()}`;
10671066
webClient.accept = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*';
10681067

1069-
const response: WebClientResponse = await webClient.fetchAsync(queryUrl);
1068+
const response: IWebClientResponse = await webClient.fetchAsync(queryUrl);
10701069
if (!response.ok) {
10711070
throw new Error('Failed to query');
10721071
}
10731072

1074-
const data: { versions: { [version: string]: { dist: { tarball: string } } } } = await response.json();
1073+
const data: { versions: { [version: string]: { dist: { tarball: string } } } } =
1074+
await response.getJsonAsync();
10751075
let url: string;
10761076
try {
10771077
if (!data.versions[Rush.version]) {
@@ -1090,7 +1090,7 @@ ${gitLfsHookHandling}
10901090
// Make sure the tarball wasn't deleted from the CDN
10911091
webClient.accept = '*/*';
10921092

1093-
const response2: fetch.Response = await webClient.fetchAsync(url);
1093+
const response2: IWebClientResponse = await webClient.fetchAsync(url);
10941094

10951095
if (!response2.ok) {
10961096
if (response2.status === 404) {

libraries/rush-lib/src/logic/setup/SetupPackageRegistry.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { PrintUtilities, Colorize, ConsoleTerminalProvider, Terminal } from '@ru
1717
import type { RushConfiguration } from '../../api/RushConfiguration';
1818
import { Utilities } from '../../utilities/Utilities';
1919
import { type IArtifactoryPackageRegistryJson, ArtifactoryConfiguration } from './ArtifactoryConfiguration';
20-
import type { WebClient as WebClientType, WebClientResponse } from '../../utilities/WebClient';
20+
import type { WebClient as WebClientType, IWebClientResponse } from '../../utilities/WebClient';
2121
import { TerminalInput } from './TerminalInput';
2222

2323
interface IArtifactoryCustomizableMessages {
@@ -300,7 +300,7 @@ export class SetupPackageRegistry {
300300
// our token.
301301
queryUrl += `auth/.npm`;
302302

303-
let response: WebClientResponse;
303+
let response: IWebClientResponse;
304304
try {
305305
response = await webClient.fetchAsync(queryUrl);
306306
} catch (e) {
@@ -324,7 +324,7 @@ export class SetupPackageRegistry {
324324
// //your-company.jfrog.io/your-artifacts/api/npm/npm-private/:[email protected]
325325
// //your-company.jfrog.io/your-artifacts/api/npm/npm-private/:[email protected]
326326
// //your-company.jfrog.io/your-artifacts/api/npm/npm-private/:always-auth=true
327-
const responseText: string = await response.text();
327+
const responseText: string = await response.getTextAsync();
328328
const responseLines: string[] = Text.convertToLf(responseText).trim().split('\n');
329329
if (responseLines.length < 2 || !responseLines[0].startsWith('@.npm:')) {
330330
throw new Error('Unexpected response from Artifactory');

0 commit comments

Comments
 (0)