From 09f4a8731afb5f00e9996819651110d11104f723 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Fri, 13 Sep 2024 15:13:54 +0200 Subject: [PATCH 1/2] set npm as default package manager to init --- __e2e__/init.test.ts | 7 ++----- packages/cli/src/commands/init/init.ts | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/__e2e__/init.test.ts b/__e2e__/init.test.ts index 3ce6beff9..6766ab9d1 100644 --- a/__e2e__/init.test.ts +++ b/__e2e__/init.test.ts @@ -22,13 +22,10 @@ function createCustomTemplateFiles() { const customTemplateCopiedFiles = [ '.git', - '.yarn', - '.yarnrc.yml', // .yarnrc.yml for Yarn versions >= 2.0.0 'dir', 'file', - 'node_modules', + 'package-lock.json', 'package.json', - 'yarn.lock', ]; beforeEach(() => { @@ -150,7 +147,7 @@ test('init skips installation of dependencies with --skip-install', () => { expect(dirFiles).toEqual( customTemplateCopiedFiles.filter( - (file) => !['node_modules', 'yarn.lock'].includes(file), + (file) => !['node_modules', 'package-lock.json'].includes(file), ), ); }); diff --git a/packages/cli/src/commands/init/init.ts b/packages/cli/src/commands/init/init.ts index f1bfffd34..df8f61dd0 100644 --- a/packages/cli/src/commands/init/init.ts +++ b/packages/cli/src/commands/init/init.ts @@ -209,8 +209,8 @@ async function createFromTemplate({ packageManager = pm; } else { const userAgentPM = userAgentPackageManager(); - // if possible, use the package manager from the user agent. Otherwise fallback to default (yarn) - packageManager = userAgentPM || 'yarn'; + // if possible, use the package manager from the user agent. Otherwise fallback to default (npm) + packageManager = userAgentPM || 'npm'; } if (npm) { From d2cc2cbac0d97d1e9f6953cf02d2358e6f6af517 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Fri, 13 Sep 2024 15:24:45 +0200 Subject: [PATCH 2/2] update docs --- docs/init.md | 6 +++--- packages/cli/src/commands/init/index.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/init.md b/docs/init.md index 59a936366..31920b0b4 100644 --- a/docs/init.md +++ b/docs/init.md @@ -6,7 +6,7 @@ There are couple of ways to initialize new React Native projects. npx react-native@latest init ProjectName ``` -> Note: If you have both `yarn` and `npm` installed on your machine, React Native CLI will always try to use `yarn`, so even if you use `npx` utility, only `react-native` executable will be installed using `npm` and the rest of the work will be delegated to `yarn`. You can force usage of `npm` adding `--pm npm` flag to the command. +> Note: If you have both `yarn` and `npm` installed on your machine, React Native CLI will always try to use `npm`. You can force usage of `yarn` by adding `--pm yarn` flag to the command. > Note: for Yarn users, `yarn dlx` command similar to `npx` will be featured in Yarn 2.0: so we'll be able to use it in a similar fashion. @@ -49,10 +49,10 @@ npx react-native@latest init ProjectName --template ${TEMPLATE_NAME} npx react-native@${VERSION} init ProjectName --template ${TEMPLATE_NAME} ``` -You can force usage of `npm` if you have both `yarn` and `npm` installed on your machine: +You can force usage of `yarn` if you have both `yarn` and `npm` installed on your machine: ```sh -npx react-native@latest init ProjectName --pm npm +npx react-native@latest init ProjectName --pm yarn ``` ## Creating custom template diff --git a/packages/cli/src/commands/init/index.ts b/packages/cli/src/commands/init/index.ts index 2c36fb0d5..c94bd291a 100644 --- a/packages/cli/src/commands/init/index.ts +++ b/packages/cli/src/commands/init/index.ts @@ -23,7 +23,7 @@ export default { { name: '--pm ', description: - 'Use specific package manager to initialize the project. Available options: `yarn`, `npm`, `bun`. Default: `yarn`', + 'Use specific package manager to initialize the project. Available options: `yarn`, `npm`, `bun`. Default: `npm`', }, { name: '--directory ',