New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@react-native-community/cli

Package Overview
Dependencies
Maintainers
4
Versions
332
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/cli - npm Package Compare versions

Comparing version
20.1.1
to
20.1.2
+1
-1
build/commands/init/version.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/commands/init/version.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAQrC,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAqDjB"}
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/commands/init/version.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAQrC,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CA2DjB"}

@@ -54,2 +54,5 @@ "use strict";

const templateVersion = await (0, _npm.getTemplateVersion)(version);
if (templateVersion == null) {
throw new Error(`Unable to find a template for react-native version '${version}'. ` + `Please check that the version exists and has a corresponding template published to npm.`);
}
return `${_constants.TEMPLATE_PACKAGE_COMMUNITY}@${templateVersion}`;

@@ -56,0 +59,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"version.js","names":["createTemplateUri","options","version","platformName","logger","debug","template","TEMPLATE_PACKAGE_LEGACY_TYPESCRIPT","warn","TEMPLATE_PACKAGE_LEGACY","simpleVersion","semver","coerce","useLegacyTemplate","lt","TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION","test","TEMPLATE_PACKAGE_COMMUNITY","templateVersion","getTemplateVersion"],"sources":["../../../src/commands/init/version.ts"],"sourcesContent":["import {logger} from '@react-native-community/cli-tools';\nimport {getTemplateVersion} from '../../tools/npm';\nimport semver from 'semver';\n\nimport type {Options} from './types';\nimport {\n TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION,\n TEMPLATE_PACKAGE_COMMUNITY,\n TEMPLATE_PACKAGE_LEGACY,\n TEMPLATE_PACKAGE_LEGACY_TYPESCRIPT,\n} from './constants';\n\nexport async function createTemplateUri(\n options: Options,\n version: string,\n): Promise<string> {\n if (options.platformName && options.platformName !== 'react-native') {\n logger.debug('User has specified an out-of-tree platform, using it');\n return `${options.platformName}@${version}`;\n }\n\n if (options.template === TEMPLATE_PACKAGE_LEGACY_TYPESCRIPT) {\n logger.warn(\n \"Ignoring custom template: 'react-native-template-typescript'. Starting from React Native v0.71 TypeScript is used by default.\",\n );\n return TEMPLATE_PACKAGE_LEGACY;\n }\n\n if (options.template) {\n logger.debug(`Use the user provided --template=${options.template}`);\n return options.template;\n }\n\n // 0.75.0-nightly-20240618-5df5ed1a8' -> 0.75.0\n // 0.75.0-rc.1 -> 0.75.0\n const simpleVersion = semver.coerce(version) ?? version;\n\n // Does the react-native@version package *not* have a template embedded. We know that this applies to\n // all version before 0.75. The 1st release candidate is the minimal version that has no template.\n const useLegacyTemplate = semver.lt(\n simpleVersion,\n TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION,\n );\n\n logger.debug(\n `[template]: is '${version} (${simpleVersion})' < '${TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION}' = ` +\n (useLegacyTemplate\n ? 'yes, look for template in react-native'\n : 'no, look for template in @react-native-community/template'),\n );\n\n if (!useLegacyTemplate) {\n if (/nightly/.test(version)) {\n logger.debug(\n \"[template]: you're using a nightly version of react-native\",\n );\n // Template nightly versions and react-native@nightly versions don't match (template releases at a much\n // lower cadence). We have to assume the user is running against the latest nightly by pointing to the tag.\n return `${TEMPLATE_PACKAGE_COMMUNITY}@nightly`;\n }\n const templateVersion = await getTemplateVersion(version);\n return `${TEMPLATE_PACKAGE_COMMUNITY}@${templateVersion}`;\n }\n\n logger.debug(\n `Using the legacy template because '${TEMPLATE_PACKAGE_LEGACY}' still contains a template folder`,\n );\n return `${TEMPLATE_PACKAGE_LEGACY}@${version}`;\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;AAKqB;AAEd,eAAeA,iBAAiB,CACrCC,OAAgB,EAChBC,OAAe,EACE;EACjB,IAAID,OAAO,CAACE,YAAY,IAAIF,OAAO,CAACE,YAAY,KAAK,cAAc,EAAE;IACnEC,kBAAM,CAACC,KAAK,CAAC,sDAAsD,CAAC;IACpE,OAAQ,GAAEJ,OAAO,CAACE,YAAa,IAAGD,OAAQ,EAAC;EAC7C;EAEA,IAAID,OAAO,CAACK,QAAQ,KAAKC,6CAAkC,EAAE;IAC3DH,kBAAM,CAACI,IAAI,CACT,+HAA+H,CAChI;IACD,OAAOC,kCAAuB;EAChC;EAEA,IAAIR,OAAO,CAACK,QAAQ,EAAE;IACpBF,kBAAM,CAACC,KAAK,CAAE,oCAAmCJ,OAAO,CAACK,QAAS,EAAC,CAAC;IACpE,OAAOL,OAAO,CAACK,QAAQ;EACzB;;EAEA;EACA;EACA,MAAMI,aAAa,GAAGC,iBAAM,CAACC,MAAM,CAACV,OAAO,CAAC,IAAIA,OAAO;;EAEvD;EACA;EACA,MAAMW,iBAAiB,GAAGF,iBAAM,CAACG,EAAE,CACjCJ,aAAa,EACbK,kDAAuC,CACxC;EAEDX,kBAAM,CAACC,KAAK,CACT,mBAAkBH,OAAQ,KAAIQ,aAAc,SAAQK,kDAAwC,MAAK,IAC/FF,iBAAiB,GACd,wCAAwC,GACxC,2DAA2D,CAAC,CACnE;EAED,IAAI,CAACA,iBAAiB,EAAE;IACtB,IAAI,SAAS,CAACG,IAAI,CAACd,OAAO,CAAC,EAAE;MAC3BE,kBAAM,CAACC,KAAK,CACV,4DAA4D,CAC7D;MACD;MACA;MACA,OAAQ,GAAEY,qCAA2B,UAAS;IAChD;IACA,MAAMC,eAAe,GAAG,MAAM,IAAAC,uBAAkB,EAACjB,OAAO,CAAC;IACzD,OAAQ,GAAEe,qCAA2B,IAAGC,eAAgB,EAAC;EAC3D;EAEAd,kBAAM,CAACC,KAAK,CACT,sCAAqCI,kCAAwB,oCAAmC,CAClG;EACD,OAAQ,GAAEA,kCAAwB,IAAGP,OAAQ,EAAC;AAChD"}
{"version":3,"file":"version.js","names":["createTemplateUri","options","version","platformName","logger","debug","template","TEMPLATE_PACKAGE_LEGACY_TYPESCRIPT","warn","TEMPLATE_PACKAGE_LEGACY","simpleVersion","semver","coerce","useLegacyTemplate","lt","TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION","test","TEMPLATE_PACKAGE_COMMUNITY","templateVersion","getTemplateVersion","Error"],"sources":["../../../src/commands/init/version.ts"],"sourcesContent":["import {logger} from '@react-native-community/cli-tools';\nimport {getTemplateVersion} from '../../tools/npm';\nimport semver from 'semver';\n\nimport type {Options} from './types';\nimport {\n TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION,\n TEMPLATE_PACKAGE_COMMUNITY,\n TEMPLATE_PACKAGE_LEGACY,\n TEMPLATE_PACKAGE_LEGACY_TYPESCRIPT,\n} from './constants';\n\nexport async function createTemplateUri(\n options: Options,\n version: string,\n): Promise<string> {\n if (options.platformName && options.platformName !== 'react-native') {\n logger.debug('User has specified an out-of-tree platform, using it');\n return `${options.platformName}@${version}`;\n }\n\n if (options.template === TEMPLATE_PACKAGE_LEGACY_TYPESCRIPT) {\n logger.warn(\n \"Ignoring custom template: 'react-native-template-typescript'. Starting from React Native v0.71 TypeScript is used by default.\",\n );\n return TEMPLATE_PACKAGE_LEGACY;\n }\n\n if (options.template) {\n logger.debug(`Use the user provided --template=${options.template}`);\n return options.template;\n }\n\n // 0.75.0-nightly-20240618-5df5ed1a8' -> 0.75.0\n // 0.75.0-rc.1 -> 0.75.0\n const simpleVersion = semver.coerce(version) ?? version;\n\n // Does the react-native@version package *not* have a template embedded. We know that this applies to\n // all version before 0.75. The 1st release candidate is the minimal version that has no template.\n const useLegacyTemplate = semver.lt(\n simpleVersion,\n TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION,\n );\n\n logger.debug(\n `[template]: is '${version} (${simpleVersion})' < '${TEMPLATE_COMMUNITY_REACT_NATIVE_VERSION}' = ` +\n (useLegacyTemplate\n ? 'yes, look for template in react-native'\n : 'no, look for template in @react-native-community/template'),\n );\n\n if (!useLegacyTemplate) {\n if (/nightly/.test(version)) {\n logger.debug(\n \"[template]: you're using a nightly version of react-native\",\n );\n // Template nightly versions and react-native@nightly versions don't match (template releases at a much\n // lower cadence). We have to assume the user is running against the latest nightly by pointing to the tag.\n return `${TEMPLATE_PACKAGE_COMMUNITY}@nightly`;\n }\n const templateVersion = await getTemplateVersion(version);\n if (templateVersion == null) {\n throw new Error(\n `Unable to find a template for react-native version '${version}'. ` +\n `Please check that the version exists and has a corresponding template published to npm.`,\n );\n }\n return `${TEMPLATE_PACKAGE_COMMUNITY}@${templateVersion}`;\n }\n\n logger.debug(\n `Using the legacy template because '${TEMPLATE_PACKAGE_LEGACY}' still contains a template folder`,\n );\n return `${TEMPLATE_PACKAGE_LEGACY}@${version}`;\n}\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;AAKqB;AAEd,eAAeA,iBAAiB,CACrCC,OAAgB,EAChBC,OAAe,EACE;EACjB,IAAID,OAAO,CAACE,YAAY,IAAIF,OAAO,CAACE,YAAY,KAAK,cAAc,EAAE;IACnEC,kBAAM,CAACC,KAAK,CAAC,sDAAsD,CAAC;IACpE,OAAQ,GAAEJ,OAAO,CAACE,YAAa,IAAGD,OAAQ,EAAC;EAC7C;EAEA,IAAID,OAAO,CAACK,QAAQ,KAAKC,6CAAkC,EAAE;IAC3DH,kBAAM,CAACI,I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,GAAG,EAAE,MAAM,sBAE5C;AAED,eAAO,MAAM,iBAAiB,cAkB1B,CAAC;AAEL;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAGD,KAAK,eAAe,GAAG,MAAM,CAAC;AA6C9B,wBAAsB,kBAAkB,CACtC,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAwDtC"}
{"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../src/tools/npm.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,wBAAgB,wBAAwB,kBAcvC;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,sBAE5C;AAED,eAAO,MAAM,iBAAiB,cAkB1B,CAAC;AAEL;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAGD,KAAK,eAAe,GAAG,MAAM,CAAC;AAwC9B,wBAAsB,kBAAkB,CACtC,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CA6CtC"}

@@ -111,6 +111,2 @@ "use strict";

}
const minorVersion = version => {
const v = _semver().default.parse(version);
return `${v.major}.${v.minor}`;
};
async function getTemplateVersion(reactNativeVersion) {

@@ -127,7 +123,4 @@ const json = await fetch(new URL('@react-native-community/template', getNpmRegistryUrl())).then(resp => resp.json());

// specific fixes for React Native versions.
// - ELSE, is there a match for React Native MINOR.PATCH?
// - Yes: if there are >= 2 versions, pick the one last published. This decouples us from
// React Native releases.
// - No: we don't have a version of the template for a version of React Native. There should
// at a minimum be at last one version cut for each MINOR.PATCH since 0.75. Before this
// at a minimum be at least one version cut for each MAJOR.MINOR.PATCH since 0.75. Before this
// the template was shipped with React Native

@@ -143,7 +136,4 @@ const rnToTemplate = {};

const template = new Template(templateVersion, rnVersion, json.time[templateVersion]);
const rnMinorVersion = minorVersion(rnVersion);
rnToTemplate[rnVersion] = rnToTemplate[rnVersion] ?? [];
rnToTemplate[rnVersion].push(template);
rnToTemplate[rnMinorVersion] = rnToTemplate[rnMinorVersion] ?? [];
rnToTemplate[rnMinorVersion].push(template);
}

@@ -158,6 +148,2 @@

}
const rnMinorVersion = minorVersion(reactNativeVersion);
if (rnMinorVersion in rnToTemplate) {
return rnToTemplate[rnMinorVersion][0].version;
}
return;

@@ -164,0 +150,0 @@ }

@@ -1,1 +0,1 @@

{"version":3,"file":"npm.js","names":["getNpmVersionIfAvailable","npmVersion","execSync","stdio","toString","trim","error","isProjectUsingNpm","cwd","findUp","sync","getNpmRegistryUrl","registryUrl","npmResolveConcreteVersion","packageName","tagOrVersion","url","URL","pathname","resp","fetch","indexOf","status","Error","json","version","Template","constructor","reactNativeVersion","published","Date","isPreRelease","includes","minorVersion","v","semver","parse","major","minor","getTemplateVersion","then","rnToTemplate","templateVersion","pkg","Object","entries","versions","rnVersion","scripts","valid","template","time","rnMinorVersion","push","sort","a","b","getTime"],"sources":["../../src/tools/npm.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport {execSync} from 'child_process';\nimport findUp from 'find-up';\nimport semver from 'semver';\n\nexport function getNpmVersionIfAvailable() {\n let npmVersion;\n try {\n // execSync returns a Buffer -> convert to string\n npmVersion = (\n execSync('npm --version', {\n stdio: [0, 'pipe', 'ignore'],\n }).toString() || ''\n ).trim();\n\n return npmVersion;\n } catch (error) {\n return null;\n }\n}\n\nexport function isProjectUsingNpm(cwd: string) {\n return findUp.sync('package-lock.json', {cwd});\n}\n\nexport const getNpmRegistryUrl = (() => {\n // Lazily resolve npm registry url since it is only needed when initializing a\n // new project.\n let registryUrl = '';\n return () => {\n if (!registryUrl) {\n try {\n registryUrl = execSync(\n 'npm config get registry --workspaces=false --include-workspace-root',\n )\n .toString()\n .trim();\n } catch {\n registryUrl = 'https://registry.npmjs.org/';\n }\n }\n return registryUrl;\n };\n})();\n\n/**\n * Convert an npm tag to a concrete version, for example:\n * - next -> 0.75.0-rc.0\n * - nightly -> 0.75.0-nightly-20240618-5df5ed1a8\n */\nexport async function npmResolveConcreteVersion(\n packageName: string,\n tagOrVersion: string,\n): Promise<string> {\n const url = new URL(getNpmRegistryUrl());\n url.pathname = `${packageName}/${tagOrVersion}`;\n const resp = await fetch(url);\n if (\n [\n 200, // OK\n 301, // Moved Permanemently\n 302, // Found\n 304, // Not Modified\n 307, // Temporary Redirect\n 308, // Permanent Redirect\n ].indexOf(resp.status) === -1\n ) {\n throw new Error(`Unknown version ${packageName}@${tagOrVersion}`);\n }\n const json: any = await resp.json();\n return json.version;\n}\n\ntype TimeStampString = string;\ntype TemplateVersion = string;\ntype VersionedTemplates = {\n [rnVersion: string]: Template[];\n};\n\ntype NpmTemplateResponse = {\n versions: {\n // Template version, semver including -rc candidates\n [version: TemplateVersion]: {\n scripts?: {\n // Version of react-native this is built for\n reactNativeVersion?: string;\n // The initial implemntation used this, but moved to reactNativeVersion\n version?: string;\n };\n };\n };\n time: {\n created: string;\n modified: string;\n [version: TemplateVersion]: TimeStampString;\n };\n};\n\nclass Template {\n version: string;\n reactNativeVersion: string;\n published: Date;\n\n constructor(version: string, reactNativeVersion: string, published: string) {\n this.version = version;\n this.reactNativeVersion = reactNativeVersion;\n this.published = new Date(published);\n }\n\n get isPreRelease() {\n return this.version.includes('-rc');\n }\n}\n\nconst minorVersion = (version: string) => {\n const v = semver.parse(version)!;\n return `${v.major}.${v.minor}`;\n};\n\nexport async function getTemplateVersion(\n reactNativeVersion: string,\n): Promise<TemplateVersion | undefined> {\n const json = await fetch(\n new URL('@react-native-community/template', getNpmRegistryUrl()),\n ).then((resp) => resp.json() as Promise<NpmTemplateResponse>);\n\n // We are abusing which npm metadata is publicly available through the registry. Scripts\n // is always captured, and we use this in the Github Action that manages our releases to\n // capture the version of React Native the template is built with.\n //\n // Users are interested in:\n // - IF there a match for React Native MAJOR.MINOR.PATCH?\n // - Yes: if there are >= 2 versions, pick the one last published. This lets us release\n // specific fixes for React Native versions.\n // - ELSE, is there a match for React Native MINOR.PATCH?\n // - Yes: if there are >= 2 versions, pick the one last published. This decouples us from\n // React Native releases.\n // - No: we don't have a version of the template for a version of React Native. There should\n // at a minimum be at last one version cut for each MINOR.PATCH since 0.75. Before this\n // the template was shipped with React Native\n const rnToTemplate: VersionedTemplates = {};\n for (const [templateVersion, pkg] of Object.entries(json.versions)) {\n const rnVersion = pkg?.scripts?.reactNativeVersion ?? pkg?.scripts?.version;\n if (rnVersion == null || !semver.valid(rnVersion)) {\n // This is a very early version that doesn't have the correct metadata embedded\n continue;\n }\n\n const template = new Template(\n templateVersion,\n rnVersion,\n json.time[templateVersion],\n );\n\n const rnMinorVersion = minorVersion(rnVersion);\n\n rnToTemplate[rnVersion] = rnToTemplate[rnVersion] ?? [];\n rnToTemplate[rnVersion].push(template);\n rnToTemplate[rnMinorVersion] = rnToTemplate[rnMinorVersion] ?? [];\n rnToTemplate[rnMinorVersion].push(template);\n }\n\n // Make sure the last published is the first one in each version of React Native\n for (const v in rnToTemplate) {\n rnToTemplate[v].sort(\n (a, b) => b.published.getTime() - a.published.getTime(),\n );\n }\n\n if (reactNativeVersion in rnToTemplate) {\n return rnToTemplate[reactNativeVersion][0].version;\n }\n const rnMinorVersion = minorVersion(reactNativeVersion);\n if (rnMinorVersion in rnToTemplate) {\n return rnToTemplate[rnMinorVersion][0].version;\n }\n return;\n}\n"],"mappings":";;;;;;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA4B;AAV5B;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,SAASA,wBAAwB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npmVersion","execSync","stdio","toString","trim","error","isProjectUsingNpm","cwd","findUp","sync","getNpmRegistryUrl","registryUrl","npmResolveConcreteVersion","packageName","tagOrVersion","url","URL","pathname","resp","fetch","indexOf","status","Error","json","version","Template","constructor","reactNativeVersion","published","Date","isPreRelease","includes","getTemplateVersion","then","rnToTemplate","templateVersion","pkg","Object","entries","versions","rnVersion","scripts","semver","valid","template","time","push","v","sort","a","b","getTime"],"sources":["../../src/tools/npm.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport {execSync} from 'child_process';\nimport findUp from 'find-up';\nimport semver from 'semver';\n\nexport function getNpmVersionIfAvailable() {\n let npmVersion;\n try {\n // execSync returns a Buffer -> convert to string\n npmVersion = (\n execSync('npm --version', {\n stdio: [0, 'pipe', 'ignore'],\n }).toString() || ''\n ).trim();\n\n return npmVersion;\n } catch (error) {\n return null;\n }\n}\n\nexport function isProjectUsingNpm(cwd: string) {\n return findUp.sync('package-lock.json', {cwd});\n}\n\nexport const getNpmRegistryUrl = (() => {\n // Lazily resolve npm registry url since it is only needed when initializing a\n // new project.\n let registryUrl = '';\n return () => {\n if (!registryUrl) {\n try {\n registryUrl = execSync(\n 'npm config get registry --workspaces=false --include-workspace-root',\n )\n .toString()\n .trim();\n } catch {\n registryUrl = 'https://registry.npmjs.org/';\n }\n }\n return registryUrl;\n };\n})();\n\n/**\n * Convert an npm tag to a concrete version, for example:\n * - next -> 0.75.0-rc.0\n * - nightly -> 0.75.0-nightly-20240618-5df5ed1a8\n */\nexport async function npmResolveConcreteVersion(\n packageName: string,\n tagOrVersion: string,\n): Promise<string> {\n const url = new URL(getNpmRegistryUrl());\n url.pathname = `${packageName}/${tagOrVersion}`;\n const resp = await fetch(url);\n if (\n [\n 200, // OK\n 301, // Moved Permanemently\n 302, // Found\n 304, // Not Modified\n 307, // Temporary Redirect\n 308, // Permanent Redirect\n ].indexOf(resp.status) === -1\n ) {\n throw new Error(`Unknown version ${packageName}@${tagOrVersion}`);\n }\n const json: any = await resp.json();\n return json.version;\n}\n\ntype TimeStampString = string;\ntype TemplateVersion = string;\ntype VersionedTemplates = {\n [rnVersion: string]: Template[];\n};\n\ntype NpmTemplateResponse = {\n versions: {\n // Template version, semver including -rc candidates\n [version: TemplateVersion]: {\n scripts?: {\n // Version of react-native this is built for\n reactNativeVersion?: string;\n // The initial implemntation used this, but moved to reactNativeVersion\n version?: string;\n };\n };\n };\n time: {\n created: string;\n modified: string;\n [version: TemplateVersion]: TimeStampString;\n };\n};\n\nclass Template {\n version: string;\n reactNativeVersion: string;\n published: Date;\n\n constructor(version: string, reactNativeVersion: string, published: string) {\n this.version = version;\n this.reactNativeVersion = reactNativeVersion;\n this.published = new Date(published);\n }\n\n get isPreRelease() {\n return this.version.includes('-rc');\n }\n}\n\nexport async function getTemplateVersion(\n reactNativeVersion: string,\n): Promise<TemplateVersion | undefined> {\n const json = await fetch(\n new URL('@react-native-community/template', getNpmRegistryUrl()),\n ).then((resp) => resp.json() as Promise<NpmTemplateResponse>);\n\n // We are abusing which npm metadata is publicly available through the registry. Scripts\n // is always captured, and we use this in the Github Action that manages our releases to\n // capture the version of React Native the template is built with.\n //\n // Users are interested in:\n // - IF there a match for React Native MAJOR.MINOR.PATCH?\n // - Yes: if there are >= 2 versions, pick the one last published. This lets us release\n // specific fixes for React Native versions.\n // - No: we don't have a version of the template for a version of React Native. There should\n // at a minimum be at least one version cut for each MAJOR.MINOR.PATCH since 0.75. Before this\n // the template was shipped with React Native\n const rnToTemplate: VersionedTemplates = {};\n for (const [templateVersion, pkg] of Object.entries(json.versions)) {\n const rnVersion = pkg?.scripts?.reactNativeVersion ?? pkg?.scripts?.version;\n if (rnVersion == null || !semver.valid(rnVersion)) {\n // This is a very early version that doesn't have the correct metadata embedded\n continue;\n }\n\n const template = new Template(\n templateVersion,\n rnVersion,\n json.time[templateVersion],\n );\n\n rnToTemplate[rnVersion] = rnToTemplate[rnVersion] ?? [];\n rnToTemplate[rnVersion].push(template);\n }\n\n // Make sure the last published is the first one in each version of React Native\n for (const v in rnToTemplate) {\n rnToTemplate[v].sort(\n (a, b) => b.published.getTime() - a.published.getTime(),\n );\n }\n\n if (reactNativeVersion in rnToTemplate) {\n return rnToTemplate[reactNativeVersion][0].version;\n }\n return;\n}\n"],"mappings":";;;;;;;;;;AAQA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA4B;AAV5B;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,SAASA,wBAAwB,GAAG;EACzC,IAAIC,UAAU;EACd,IAAI;IACF;IACAA,UAAU,GAAG,CACX,IAAAC,yBAAQ,EAAC,eAAe,EAAE;MACxBC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ;IAC7B,CAAC,CAAC,CAACC,QAAQ,EAAE,IAAI,EAAE,EACnBC,IAAI,EAAE;IAER,OAAOJ,UAAU;EACnB,CAAC,CAAC,OAAOK,KAAK,EAAE;IACd,OAAO,IAAI;EACb;AACF;AAEO,SAASC,iBAAiB,CAACC,GAAW,EAAE;EAC7C,OAAOC,iBAAM,CAACC,IAAI,CAAC,mBAAmB,EAAE;IAACF;EAAG,CAAC,CAAC;AAChD;AAEO,MAAMG,iBAAiB,GAAG,CAAC,MAAM;EACtC;EACA;EACA,IAAIC,WAAW,GAAG,EAAE;EACpB,OAAO,MAAM;IACX,IAAI,CAACA,WAAW,EAAE;MAChB,IAAI;QACFA,WAAW,GAAG,IAAAV,yBAAQ,EACpB,qEAAqE,CACtE,CACEE,QAAQ,EAAE,CACVC,IAAI,EAAE;MACX,CAAC,CAAC,MAAM;QACNO,WAAW,GAAG,6BAA6B;MAC7C;IACF;IACA,OAAOA,WAAW;EACpB,CAAC;AACH,CAAC,GAAG;;AAEJ;AACA;AACA;AAC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,MAAMW,YAAgC,GAAG,CAAC,CAAC;EAC3C,KAAK,MAAM,CAACC,eAAe,EAAEC,GAAG,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACf,IAAI,CAACgB,QAAQ,CAAC,EAAE;IAAA;IAClE,MAAMC,SAAS,GAAG,CAAAJ,GAAG,aAAHA,GAAG,uCAAHA,GAAG,CAAEK,OAAO,iDAAZ,aAAcd,kBAAkB,MAAIS,GAAG,aAAHA,GAAG,wCAAHA,GAAG,CAAEK,OAAO,kDAAZ,cAAcjB,OAAO;IAC3E,IAAIgB,SAAS,IAAI,IAAI,IAAI,CAACE,iBAAM,CAACC,KAAK,CAACH,SAAS,CAAC,EAAE;MACjD;MACA;IACF;IAEA,MAAMI,QAAQ,GAAG,IAAInB,QAAQ,CAC3BU,eAAe,EACfK,SAAS,EACTjB,IAAI,CAACsB,IAAI,CAACV,eAAe,CAAC,CAC3B;IAEDD,YAAY,CAACM,SAAS,CAAC,GAAGN,YAAY,CAACM,SAAS,CAAC,IAAI,EAAE;IACvDN,YAAY,CAACM,SAAS,CAAC,CAACM,IAAI,CAACF,QAAQ,CAAC;EACxC;;EAEA;EACA,KAAK,MAAMG,CAAC,IAAIb,YAAY,EAAE;IAC5BA,YAAY,CAACa,CAAC,CAAC,CAACC,IAAI,CAClB,CAACC,CAAC,EAAEC,CAAC,KAAKA,CAAC,CAACtB,SAAS,CAACuB,OAAO,EAAE,GAAGF,CAAC,CAACrB,SAAS,CAACuB,OAAO,EAAE,CACxD;EACH;EAEA,IAAIxB,kBAAkB,IAAIO,YAAY,EAAE;IACtC,OAAOA,YAAY,CAACP,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAACH,OAAO;EACpD;EACA;AACF"}
{
"name": "@react-native-community/cli",
"version": "20.1.1",
"version": "20.1.2",
"description": "React Native CLI",

@@ -27,8 +27,8 @@ "license": "MIT",

"dependencies": {
"@react-native-community/cli-clean": "20.1.1",
"@react-native-community/cli-config": "20.1.1",
"@react-native-community/cli-doctor": "20.1.1",
"@react-native-community/cli-server-api": "20.1.1",
"@react-native-community/cli-tools": "20.1.1",
"@react-native-community/cli-types": "20.1.1",
"@react-native-community/cli-clean": "20.1.2",
"@react-native-community/cli-config": "20.1.2",
"@react-native-community/cli-doctor": "20.1.2",
"@react-native-community/cli-server-api": "20.1.2",
"@react-native-community/cli-tools": "20.1.2",
"@react-native-community/cli-types": "20.1.2",
"commander": "^9.4.1",

@@ -59,3 +59,3 @@ "deepmerge": "^4.3.0",

},
"gitHead": "2eb9e44ecb11abc01c5dd918b8cf36afa4a88db2"
"gitHead": "f9619307f49272af41c3292536e79865c6310e88"
}