Skip to content

Commit

Permalink
chore: remove deprecated --npm flag (#2504)
Browse files Browse the repository at this point in the history
  • Loading branch information
TMisiukiewicz committed Sep 16, 2024
1 parent a4e3fc4 commit a414d98
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 62 deletions.
38 changes: 0 additions & 38 deletions __e2e__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,44 +155,6 @@ test('init skips installation of dependencies with --skip-install', () => {
);
});

test('init uses npm as the package manager with --npm', () => {
createCustomTemplateFiles();

const {stdout} = runCLI(DIR, [
'init',
'--template',
templatePath,
PROJECT_NAME,
'--npm',
'--install-pods',
'false',
]);

expect(stdout).toContain('Run instructions');

// make sure we don't leave garbage
expect(fs.readdirSync(DIR)).toContain('custom');

const initDirPath = path.join(DIR, PROJECT_NAME);

// Remove yarn specific files and node_modules
const filteredFiles = customTemplateCopiedFiles.filter(
(file) =>
!['yarn.lock', 'node_modules', '.yarnrc.yml', '.yarn'].includes(file),
);

// Add package-lock.json
const customTemplateCopiedFilesForNpm = [
...filteredFiles,
'package-lock.json',
];

// Assert for existence
customTemplateCopiedFilesForNpm.forEach((file) => {
expect(fs.existsSync(path.join(initDirPath, file))).toBe(true);
});
});

// react-native-macos stopped shipping `template.config.js` for 0.75, so this test is disabled. in future releases we should re-enable once `template.config.js` will be there again.
test.skip('init --platform-name should work for out of tree platform', () => {

Check warning on line 159 in __e2e__/init.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Disabled test
createCustomTemplateFiles();
Expand Down
7 changes: 0 additions & 7 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ Skip dependencies installation

Determine if CocoaPods should be installed when initializing a project. If set to `true` it will install pods, if set to `false`, it will skip the step entirely. If not used, prompt will be displayed

#### `--npm`

> [!WARNING]
> `--npm` is deprecated and will be removed in the future. Please use `--pm npm` instead.
Force use of npm during initialization

#### `--pm <string>`

Use specific package manager to initialize the project. Available options: `yarn`, `npm`, `bun`. Default: `yarn`
Expand Down
2 changes: 1 addition & 1 deletion docs/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npx react-native@${VERSION} init ProjectName
It is possible to initialize a new application with a custom template with
a `--template` option.

It should point to a valid package that can be installed with `yarn` or `npm` (if you're using `--npm` option).
It should point to a valid package that can be installed with `npm` or `yarn` (if you're using `--pm yarn` option).

The most common options are:

Expand Down
6 changes: 1 addition & 5 deletions packages/cli/src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ export default {
{
name: '--template <string>',
description:
'Uses a custom template. Valid arguments are the ones supported by `yarn add [package]` or `npm install [package]`, if you are using `--npm` option',
},
{
name: '--npm',
description: 'Forces using npm for initialization',
'Uses a custom template. Valid arguments are the ones supported by `npm install [package]` or `yarn add [package]`, if you are using `--pm yarn` option',
},
{
name: '--pm <string>',
Expand Down
11 changes: 0 additions & 11 deletions packages/cli/src/commands/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ interface TemplateOptions {
projectName: string;
shouldBumpYarnVersion: boolean;
templateUri: string;
npm?: boolean;
pm?: PackageManager.PackageManager;
directory: string;
projectTitle?: string;
Expand Down Expand Up @@ -186,7 +185,6 @@ async function createFromTemplate({
projectName,
shouldBumpYarnVersion,
templateUri,
npm,
pm,
directory,
projectTitle,
Expand All @@ -213,14 +211,6 @@ async function createFromTemplate({
packageManager = userAgentPM || 'yarn';
}

if (npm) {
logger.warn(
'Flag --npm is deprecated and will be removed soon. In the future, please use --pm npm instead.',
);

packageManager = 'npm';
}

// if the project with the name already has cache, remove the cache to avoid problems with pods installation
cacheManager.removeProjectCache(projectName);

Expand Down Expand Up @@ -425,7 +415,6 @@ async function createProject(
projectName,
shouldBumpYarnVersion,
templateUri,
npm: options.npm,
pm: options.pm,
directory,
projectTitle: options.title,
Expand Down

0 comments on commit a414d98

Please sign in to comment.