From 38015f562e114ee8fba423f51393a0dfc136472a Mon Sep 17 00:00:00 2001 From: jilingy Date: Sun, 6 Oct 2024 17:09:42 +0800 Subject: [PATCH 1/3] Remove hardcoded npm registry url --- packages/cli/src/tools/npm.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/tools/npm.ts b/packages/cli/src/tools/npm.ts index c090571f1..2491fbf56 100644 --- a/packages/cli/src/tools/npm.ts +++ b/packages/cli/src/tools/npm.ts @@ -9,6 +9,7 @@ import {execSync} from 'child_process'; import findUp from 'find-up'; import semver from 'semver'; +import { TEMPLATE_PACKAGE_COMMUNITY } from '../' export function getNpmVersionIfAvailable() { let npmVersion; @@ -119,8 +120,6 @@ class Template { } } -const TEMPLATE_VERSIONS_URL = - 'https://registry.npmjs.org/@react-native-community/template'; const minorVersion = (version: string) => { const v = semver.parse(version)!; return `${v.major}.${v.minor}`; @@ -129,7 +128,7 @@ const minorVersion = (version: string) => { export async function getTemplateVersion( reactNativeVersion: string, ): Promise { - const json = await fetch(TEMPLATE_VERSIONS_URL).then( + const json = await fetch(getNpmRegistryUrl() + '@react-native-community/template').then( (resp) => resp.json() as Promise, ); From 2e46a0dfa964996da9aebcf71b7f6131f86a3925 Mon Sep 17 00:00:00 2001 From: jilingy Date: Sun, 6 Oct 2024 18:56:18 +0800 Subject: [PATCH 2/3] Remove hardcoded npm registry url --- packages/cli/src/tools/npm.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/cli/src/tools/npm.ts b/packages/cli/src/tools/npm.ts index 2491fbf56..04e700975 100644 --- a/packages/cli/src/tools/npm.ts +++ b/packages/cli/src/tools/npm.ts @@ -9,7 +9,6 @@ import {execSync} from 'child_process'; import findUp from 'find-up'; import semver from 'semver'; -import { TEMPLATE_PACKAGE_COMMUNITY } from '../' export function getNpmVersionIfAvailable() { let npmVersion; From 47b4cc0456de3c0fee1ef8aa69095b654609d76f Mon Sep 17 00:00:00 2001 From: jilingy Date: Thu, 10 Oct 2024 13:38:31 +0800 Subject: [PATCH 3/3] fix: Remove hardcoded npm registry url --- packages/cli/src/tools/npm.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/tools/npm.ts b/packages/cli/src/tools/npm.ts index 04e700975..3ad234a80 100644 --- a/packages/cli/src/tools/npm.ts +++ b/packages/cli/src/tools/npm.ts @@ -127,9 +127,9 @@ const minorVersion = (version: string) => { export async function getTemplateVersion( reactNativeVersion: string, ): Promise { - const json = await fetch(getNpmRegistryUrl() + '@react-native-community/template').then( - (resp) => resp.json() as Promise, - ); + const json = await fetch( + new URL('@react-native-community/template', getNpmRegistryUrl()), + ).then((resp) => resp.json() as Promise); // We are abusing which npm metadata is publicly available through the registry. Scripts // is always captured, and we use this in the Github Action that manages our releases to