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

chore: remove deprecated --npm flag #2504

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions __e2e__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,46 +155,8 @@
);
});

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();
const outOfTreePlatformName = 'react-native-macos';

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
Loading