Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rush] Remove node-fetch. #5031

Merged
merged 12 commits into from
Dec 9, 2024
10 changes: 10 additions & 0 deletions common/changes/@microsoft/rush/main_2024-12-05-18-29.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft/rush",
"comment": "Remove the dependency on node-fetch.",
"type": "none"
}
],
"packageName": "@microsoft/rush"
}
2 changes: 1 addition & 1 deletion common/config/rush/version-policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"policyName": "rush",
"definitionName": "lockStepVersion",
"version": "5.144.1",
"nextBump": "patch",
"nextBump": "minor",
"mainProject": "@microsoft/rush"
}
]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
{
"pnpmShrinkwrapHash": "be8fa6aee16239aa65766063b1b600566fe13d2b",
"pnpmShrinkwrapHash": "91719dffed0a42aec00fee22b00e6c236b96fc7e",
"preferredVersionsHash": "ce857ea0536b894ec8f346aaea08cfd85a5af648",
"packageJsonInjectedDependenciesHash": "3e941f94bf991fc5ad180bc33d43dec969990e74"
"packageJsonInjectedDependenciesHash": "7bb5b296a95ab3932d6ffa5b97edd5ea79613f33"
}
9 changes: 0 additions & 9 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions libraries/rush-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"@rushstack/stream-collator": "workspace:*",
"@rushstack/terminal": "workspace:*",
"@rushstack/ts-command-line": "workspace:*",
"@types/node-fetch": "2.6.2",
"@yarnpkg/lockfile": "~1.0.2",
"builtin-modules": "~3.1.0",
"cli-table": "~0.3.1",
Expand All @@ -53,7 +52,6 @@
"ignore": "~5.1.6",
"inquirer": "~7.3.3",
"js-yaml": "~3.13.1",
"node-fetch": "2.6.7",
"npm-check": "~6.0.1",
"npm-package-arg": "~6.1.0",
"read-package-tree": "~5.1.5",
Expand Down
10 changes: 5 additions & 5 deletions libraries/rush-lib/src/logic/base/BaseInstallManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type * as fetch from 'node-fetch';
import * as os from 'os';
import * as path from 'path';
import * as crypto from 'crypto';
Expand Down Expand Up @@ -48,7 +47,7 @@ import { ShrinkwrapFileFactory } from '../ShrinkwrapFileFactory';
import { Utilities } from '../../utilities/Utilities';
import { InstallHelpers } from '../installManager/InstallHelpers';
import * as PolicyValidator from '../policy/PolicyValidator';
import type { WebClient as WebClientType, WebClientResponse } from '../../utilities/WebClient';
import type { WebClient as WebClientType, IWebClientResponse } from '../../utilities/WebClient';
import { SetupPackageRegistry } from '../setup/SetupPackageRegistry';
import { PnpmfileConfiguration } from '../pnpm/PnpmfileConfiguration';
import type { IInstallManagerOptions } from './BaseInstallManagerTypes';
Expand Down Expand Up @@ -1066,12 +1065,13 @@ ${gitLfsHookHandling}
webClient.userAgent = `pnpm/? npm/? node/${process.version} ${os.platform()} ${os.arch()}`;
webClient.accept = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*';

const response: WebClientResponse = await webClient.fetchAsync(queryUrl);
const response: IWebClientResponse = await webClient.fetchAsync(queryUrl);
if (!response.ok) {
throw new Error('Failed to query');
}

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

const response2: fetch.Response = await webClient.fetchAsync(url);
const response2: IWebClientResponse = await webClient.fetchAsync(url);

if (!response2.ok) {
if (response2.status === 404) {
Expand Down
6 changes: 3 additions & 3 deletions libraries/rush-lib/src/logic/setup/SetupPackageRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PrintUtilities, Colorize, ConsoleTerminalProvider, Terminal } from '@ru
import type { RushConfiguration } from '../../api/RushConfiguration';
import { Utilities } from '../../utilities/Utilities';
import { type IArtifactoryPackageRegistryJson, ArtifactoryConfiguration } from './ArtifactoryConfiguration';
import type { WebClient as WebClientType, WebClientResponse } from '../../utilities/WebClient';
import type { WebClient as WebClientType, IWebClientResponse } from '../../utilities/WebClient';
import { TerminalInput } from './TerminalInput';

interface IArtifactoryCustomizableMessages {
Expand Down Expand Up @@ -300,7 +300,7 @@ export class SetupPackageRegistry {
// our token.
queryUrl += `auth/.npm`;

let response: WebClientResponse;
let response: IWebClientResponse;
try {
response = await webClient.fetchAsync(queryUrl);
} catch (e) {
Expand All @@ -324,7 +324,7 @@ export class SetupPackageRegistry {
// //your-company.jfrog.io/your-artifacts/api/npm/npm-private/:username=your.name@your-company.com
// //your-company.jfrog.io/your-artifacts/api/npm/npm-private/:email=your.name@your-company.com
// //your-company.jfrog.io/your-artifacts/api/npm/npm-private/:always-auth=true
const responseText: string = await response.text();
const responseText: string = await response.getTextAsync();
const responseLines: string[] = Text.convertToLf(responseText).trim().split('\n');
if (responseLines.length < 2 || !responseLines[0].startsWith('@.npm:')) {
throw new Error('Unexpected response from Artifactory');
Expand Down
Loading
Loading