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

fix/ios xcworkspace with extra files #3

Closed
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
48 changes: 4 additions & 44 deletions __e2e__/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@

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(() => {
Expand Down Expand Up @@ -150,50 +147,13 @@

expect(dirFiles).toEqual(
customTemplateCopiedFiles.filter(
(file) => !['node_modules', 'yarn.lock'].includes(file),
(file) => !['node_modules', 'package-lock.json'].includes(file),
),
);
});

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);
});
});

test('init --platform-name should work for out of tree platform', () => {
// 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 156 in __e2e__/init.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Disabled test

Check warning on line 156 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
8 changes: 4 additions & 4 deletions docs/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <https://github.com/yarnpkg/berry/pull/40> so we'll be able to use it in a similar fashion.

Expand All @@ -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 All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "14.0.1",
"version": "15.0.0-alpha.2",
"npmClient": "yarn",
"exact": true,
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"eslint-plugin-import": "^2.25.3",
"execa": "^5.0.0",
"fast-glob": "^3.3.2",
"glob": "^7.1.3",
"husky": "^8.0.2",
"jest": "^26.6.2",
"jest-circus": "^26.6.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-clean/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@react-native-community/cli-clean",
"version": "14.0.1",
"version": "15.0.0-alpha.2",
"license": "MIT",
"main": "build/index.js",
"publishConfig": {
"access": "public"
},
"types": "build/index.d.ts",
"dependencies": {
"@react-native-community/cli-tools": "14.0.1",
"@react-native-community/cli-tools": "15.0.0-alpha.2",
"chalk": "^4.1.2",
"execa": "^5.0.0",
"fast-glob": "^3.3.2"
Expand All @@ -19,7 +19,7 @@
"!*.map"
],
"devDependencies": {
"@react-native-community/cli-types": "14.0.1",
"@react-native-community/cli-types": "15.0.0-alpha.2",
"@types/prompts": "^2.4.4"
},
"homepage": "https://github.com/react-native-community/cli/tree/main/packages/cli-clean",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-config/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@react-native-community/cli-config",
"version": "14.0.1",
"version": "15.0.0-alpha.2",
"license": "MIT",
"main": "build/index.js",
"publishConfig": {
"access": "public"
},
"types": "build/index.d.ts",
"dependencies": {
"@react-native-community/cli-tools": "14.0.1",
"@react-native-community/cli-tools": "15.0.0-alpha.2",
"chalk": "^4.1.2",
"cosmiconfig": "^9.0.0",
"deepmerge": "^4.3.0",
Expand All @@ -21,7 +21,7 @@
"!*.map"
],
"devDependencies": {
"@react-native-community/cli-types": "14.0.1",
"@react-native-community/cli-types": "15.0.0-alpha.2",
"@types/cosmiconfig": "^5.0.3"
},
"homepage": "https://github.com/react-native-community/cli/tree/main/packages/cli-config",
Expand Down
42 changes: 27 additions & 15 deletions packages/cli-config/src/__tests__/findDependencies-test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
import findDependencies from '../findDependencies';
import {cleanup, writeFiles, getTempDirectory} from '../../../../jest/helpers';

beforeEach(async () => {
cleanup(DIR);
jest.resetModules();
});
describe('findDependencies', () => {
const DIR = getTempDirectory('find_dependencies_test');

beforeEach(() => {
cleanup(DIR);
jest.resetModules();
});

afterEach(() => cleanup(DIR));
afterEach(() => cleanup(DIR));

const DIR = getTempDirectory('find_dependencies_test');
test('returns packages from dependencies, peer and dev dependencies', () => {
writeFiles(DIR, {
'package.json': JSON.stringify({
dependencies: {'rnpm-plugin-test': '*'},
peerDependencies: {'rnpm-plugin-test-2': '*'},
devDependencies: {'rnpm-plugin-test-3': '*'},
}),
});
expect(findDependencies(DIR)).toHaveLength(3);
});

test('returns plugins from both dependencies and dev dependencies', () => {
writeFiles(DIR, {
'package.json': `
{
"dependencies": {"rnpm-plugin-test": "*"},
"devDependencies": {"rnpm-plugin-test-2": "*"}
}
`,
test('dedupes dependencies', () => {
writeFiles(DIR, {
'package.json': JSON.stringify({
dependencies: {'rnpm-plugin-test': '*'},
peerDependencies: {'rnpm-plugin-test-2': '*'},
devDependencies: {'rnpm-plugin-test-2': '*'},
}),
});
expect(findDependencies(DIR)).toHaveLength(2);
});
expect(findDependencies(DIR)).toHaveLength(2);
});
12 changes: 6 additions & 6 deletions packages/cli-config/src/findDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ export default function findDependencies(root: string): Array<string> {
let pjson;

try {
pjson = JSON.parse(
fs.readFileSync(path.join(root, 'package.json'), 'utf8'),
);
const content = fs.readFileSync(path.join(root, 'package.json'), 'utf8');
pjson = JSON.parse(content);
} catch (e) {
return [];
}

const deps = [
const deps = new Set([
...Object.keys(pjson.dependencies || {}),
...Object.keys(pjson.peerDependencies || {}),
...Object.keys(pjson.devDependencies || {}),
];
]);

return deps;
return Array.from(deps);
}
2 changes: 1 addition & 1 deletion packages/cli-debugger-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-community/cli-debugger-ui",
"version": "14.0.1",
"version": "15.0.0-alpha.2",
"license": "MIT",
"main": "build/middleware/index.js",
"targets": {
Expand Down
14 changes: 7 additions & 7 deletions packages/cli-doctor/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "@react-native-community/cli-doctor",
"version": "14.0.1",
"version": "15.0.0-alpha.2",
"license": "MIT",
"main": "build/index.js",
"publishConfig": {
"access": "public"
},
"types": "build/index.d.ts",
"dependencies": {
"@react-native-community/cli-config": "14.0.1",
"@react-native-community/cli-platform-android": "14.0.1",
"@react-native-community/cli-platform-apple": "14.0.1",
"@react-native-community/cli-platform-ios": "14.0.1",
"@react-native-community/cli-tools": "14.0.1",
"@react-native-community/cli-config": "15.0.0-alpha.2",
"@react-native-community/cli-platform-android": "15.0.0-alpha.2",
"@react-native-community/cli-platform-apple": "15.0.0-alpha.2",
"@react-native-community/cli-platform-ios": "15.0.0-alpha.2",
"@react-native-community/cli-tools": "15.0.0-alpha.2",
"chalk": "^4.1.2",
"command-exists": "^1.2.8",
"deepmerge": "^4.3.0",
Expand All @@ -31,7 +31,7 @@
"!*.map"
],
"devDependencies": {
"@react-native-community/cli-types": "14.0.1",
"@react-native-community/cli-types": "15.0.0-alpha.2",
"@types/command-exists": "^1.2.0",
"@types/envinfo": "^7.8.4",
"@types/ip": "^1.1.0",
Expand Down
15 changes: 8 additions & 7 deletions packages/cli-link-assets/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"name": "@react-native-community/cli-link-assets",
"version": "14.0.1",
"version": "15.0.0-alpha.2",
"license": "MIT",
"main": "build/index.js",
"publishConfig": {
"access": "public"
},
"types": "build/index.d.ts",
"dependencies": {
"@react-native-community/cli-config": "14.0.1",
"@react-native-community/cli-platform-android": "14.0.1",
"@react-native-community/cli-platform-apple": "14.0.1",
"@react-native-community/cli-platform-ios": "14.0.1",
"@react-native-community/cli-tools": "14.0.1",
"@react-native-community/cli-config": "15.0.0-alpha.2",
"@react-native-community/cli-platform-android": "15.0.0-alpha.2",
"@react-native-community/cli-platform-apple": "15.0.0-alpha.2",
"@react-native-community/cli-platform-ios": "15.0.0-alpha.2",
"@react-native-community/cli-tools": "15.0.0-alpha.2",
"chalk": "^4.1.2",
"fast-glob": "^3.3.2",
"fast-xml-parser": "^4.4.1",
"opentype.js": "^1.3.4",
"plist": "^3.1.0",
Expand All @@ -25,7 +26,7 @@
"!*.map"
],
"devDependencies": {
"@react-native-community/cli-types": "14.0.1",
"@react-native-community/cli-types": "15.0.0-alpha.2",
"@types/plist": "^3.0.5",
"type-fest": "^4.10.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {isProjectUsingKotlin} from '@react-native-community/cli-platform-android
import {CLIError, logger} from '@react-native-community/cli-tools';
import {XMLBuilder, XMLParser} from 'fast-xml-parser';
import fs from 'fs-extra';
import {sync as globSync} from 'glob';
import glob from 'fast-glob';
import OpenType from 'opentype.js';
import path from 'path';

Expand Down Expand Up @@ -77,7 +77,7 @@ function convertToAndroidResourceName(str: string) {
function getProjectFilePath(rootPath: string, name: string) {
const isUsingKotlin = isProjectUsingKotlin(rootPath);
const ext = isUsingKotlin ? 'kt' : 'java';
const filePath = globSync(
const filePath = glob.sync(
path.join(rootPath, `app/src/main/java/**/${name}.${ext}`),
)[0];
return filePath;
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-platform-android/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@react-native-community/cli-platform-android",
"version": "14.0.1",
"version": "15.0.0-alpha.2",
"license": "MIT",
"main": "build/index.js",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@react-native-community/cli-tools": "14.0.1",
"@react-native-community/cli-tools": "15.0.0-alpha.2",
"chalk": "^4.1.2",
"execa": "^5.0.0",
"fast-glob": "^3.3.2",
Expand All @@ -21,7 +21,7 @@
"native_modules.gradle"
],
"devDependencies": {
"@react-native-community/cli-types": "14.0.1",
"@react-native-community/cli-types": "15.0.0-alpha.2",
"@types/fs-extra": "^8.1.0"
},
"homepage": "https://github.com/react-native-community/cli/tree/main/packages/cli-platform-android",
Expand Down
Loading
Loading