@nx/react-native 0.0.0-pr-29464-ce11848 → 0.0.0-pr-30111-5026d75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "0.0.0-pr-29464-ce11848",
3
+ "version": "0.0.0-pr-30111-5026d75",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
6
6
  "keywords": [
@@ -35,12 +35,12 @@
35
35
  "picocolors": "^1.1.0",
36
36
  "tsconfig-paths": "^4.1.2",
37
37
  "tslib": "^2.3.0",
38
- "@nx/devkit": "0.0.0-pr-29464-ce11848",
39
- "@nx/jest": "0.0.0-pr-29464-ce11848",
40
- "@nx/js": "0.0.0-pr-29464-ce11848",
41
- "@nx/eslint": "0.0.0-pr-29464-ce11848",
42
- "@nx/react": "0.0.0-pr-29464-ce11848",
43
- "@nx/workspace": "0.0.0-pr-29464-ce11848"
38
+ "@nx/devkit": "0.0.0-pr-30111-5026d75",
39
+ "@nx/jest": "0.0.0-pr-30111-5026d75",
40
+ "@nx/js": "0.0.0-pr-30111-5026d75",
41
+ "@nx/eslint": "0.0.0-pr-30111-5026d75",
42
+ "@nx/react": "0.0.0-pr-30111-5026d75",
43
+ "@nx/workspace": "0.0.0-pr-30111-5026d75"
44
44
  },
45
45
  "executors": "./executors.json",
46
46
  "ng-update": {
@@ -43,6 +43,11 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
43
43
  }
44
44
  await (0, create_application_files_1.createApplicationFiles)(host, options);
45
45
  (0, add_project_1.addProject)(host, options);
46
+ // If we are using the new TS solution
47
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
48
+ if (options.isTsSolutionSetup) {
49
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
50
+ }
46
51
  const lintTask = await (0, add_linting_1.addLinting)(host, {
47
52
  ...options,
48
53
  projectRoot: options.appProjectRoot,
@@ -88,11 +93,6 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
88
93
  }, options.linter === 'eslint'
89
94
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
90
95
  : undefined);
91
- // If we are using the new TS solution
92
- // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
93
- if (options.useTsSolution) {
94
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
95
- }
96
96
  (0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
97
97
  if (!options.skipFormat) {
98
98
  await (0, devkit_1.formatFiles)(host);
@@ -1,94 +1,94 @@
1
- @rem
2
- @rem Copyright 2015 the original author or authors.
3
- @rem
4
- @rem Licensed under the Apache License, Version 2.0 (the "License");
5
- @rem you may not use this file except in compliance with the License.
6
- @rem You may obtain a copy of the License at
7
- @rem
8
- @rem https://www.apache.org/licenses/LICENSE-2.0
9
- @rem
10
- @rem Unless required by applicable law or agreed to in writing, software
11
- @rem distributed under the License is distributed on an "AS IS" BASIS,
12
- @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- @rem See the License for the specific language governing permissions and
14
- @rem limitations under the License.
15
- @rem
16
- @rem SPDX-License-Identifier: Apache-2.0
17
- @rem
18
-
19
- @if "%DEBUG%"=="" @echo off
20
- @rem ##########################################################################
21
- @rem
22
- @rem Gradle startup script for Windows
23
- @rem
24
- @rem ##########################################################################
25
-
26
- @rem Set local scope for the variables with windows NT shell
27
- if "%OS%"=="Windows_NT" setlocal
28
-
29
- set DIRNAME=%~dp0
30
- if "%DIRNAME%"=="" set DIRNAME=.
31
- @rem This is normally unused
32
- set APP_BASE_NAME=%~n0
33
- set APP_HOME=%DIRNAME%
34
-
35
- @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36
- for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37
-
38
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39
- set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40
-
41
- @rem Find java.exe
42
- if defined JAVA_HOME goto findJavaFromJavaHome
43
-
44
- set JAVA_EXE=java.exe
45
- %JAVA_EXE% -version >NUL 2>&1
46
- if %ERRORLEVEL% equ 0 goto execute
47
-
48
- echo. 1>&2
49
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
- echo. 1>&2
51
- echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
- echo location of your Java installation. 1>&2
53
-
54
- goto fail
55
-
56
- :findJavaFromJavaHome
57
- set JAVA_HOME=%JAVA_HOME:"=%
58
- set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59
-
60
- if exist "%JAVA_EXE%" goto execute
61
-
62
- echo. 1>&2
63
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
- echo. 1>&2
65
- echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
- echo location of your Java installation. 1>&2
67
-
68
- goto fail
69
-
70
- :execute
71
- @rem Setup the command line
72
-
73
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74
-
75
-
76
- @rem Execute Gradle
77
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78
-
79
- :end
80
- @rem End local scope for the variables with windows NT shell
81
- if %ERRORLEVEL% equ 0 goto mainEnd
82
-
83
- :fail
84
- rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85
- rem the _cmd.exe /c_ return code!
86
- set EXIT_CODE=%ERRORLEVEL%
87
- if %EXIT_CODE% equ 0 set EXIT_CODE=1
88
- if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89
- exit /b %EXIT_CODE%
90
-
91
- :mainEnd
92
- if "%OS%"=="Windows_NT" endlocal
93
-
94
- :omega
1
+ @rem
2
+ @rem Copyright 2015 the original author or authors.
3
+ @rem
4
+ @rem Licensed under the Apache License, Version 2.0 (the "License");
5
+ @rem you may not use this file except in compliance with the License.
6
+ @rem You may obtain a copy of the License at
7
+ @rem
8
+ @rem https://www.apache.org/licenses/LICENSE-2.0
9
+ @rem
10
+ @rem Unless required by applicable law or agreed to in writing, software
11
+ @rem distributed under the License is distributed on an "AS IS" BASIS,
12
+ @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ @rem See the License for the specific language governing permissions and
14
+ @rem limitations under the License.
15
+ @rem
16
+ @rem SPDX-License-Identifier: Apache-2.0
17
+ @rem
18
+
19
+ @if "%DEBUG%"=="" @echo off
20
+ @rem ##########################################################################
21
+ @rem
22
+ @rem Gradle startup script for Windows
23
+ @rem
24
+ @rem ##########################################################################
25
+
26
+ @rem Set local scope for the variables with windows NT shell
27
+ if "%OS%"=="Windows_NT" setlocal
28
+
29
+ set DIRNAME=%~dp0
30
+ if "%DIRNAME%"=="" set DIRNAME=.
31
+ @rem This is normally unused
32
+ set APP_BASE_NAME=%~n0
33
+ set APP_HOME=%DIRNAME%
34
+
35
+ @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36
+ for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37
+
38
+ @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39
+ set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40
+
41
+ @rem Find java.exe
42
+ if defined JAVA_HOME goto findJavaFromJavaHome
43
+
44
+ set JAVA_EXE=java.exe
45
+ %JAVA_EXE% -version >NUL 2>&1
46
+ if %ERRORLEVEL% equ 0 goto execute
47
+
48
+ echo. 1>&2
49
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
+ echo. 1>&2
51
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
+ echo location of your Java installation. 1>&2
53
+
54
+ goto fail
55
+
56
+ :findJavaFromJavaHome
57
+ set JAVA_HOME=%JAVA_HOME:"=%
58
+ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59
+
60
+ if exist "%JAVA_EXE%" goto execute
61
+
62
+ echo. 1>&2
63
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
+ echo. 1>&2
65
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
+ echo location of your Java installation. 1>&2
67
+
68
+ goto fail
69
+
70
+ :execute
71
+ @rem Setup the command line
72
+
73
+ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
74
+
75
+
76
+ @rem Execute Gradle
77
+ "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
78
+
79
+ :end
80
+ @rem End local scope for the variables with windows NT shell
81
+ if %ERRORLEVEL% equ 0 goto mainEnd
82
+
83
+ :fail
84
+ rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85
+ rem the _cmd.exe /c_ return code!
86
+ set EXIT_CODE=%ERRORLEVEL%
87
+ if %EXIT_CODE% equ 0 set EXIT_CODE=1
88
+ if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89
+ exit /b %EXIT_CODE%
90
+
91
+ :mainEnd
92
+ if "%OS%"=="Windows_NT" endlocal
93
+
94
+ :omega
@@ -14,6 +14,7 @@ async function addE2e(host, options) {
14
14
  styledModule: null,
15
15
  hasStyles: false,
16
16
  unitTestRunner: 'none',
17
+ names: (0, devkit_1.names)(options.name),
17
18
  });
18
19
  case 'playwright':
19
20
  return (0, add_e2e_1.addE2e)(host, {
@@ -23,6 +24,7 @@ async function addE2e(host, options) {
23
24
  styledModule: null,
24
25
  hasStyles: false,
25
26
  unitTestRunner: 'none',
27
+ names: (0, devkit_1.names)(options.name),
26
28
  });
27
29
  case 'detox':
28
30
  const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
@@ -16,15 +16,23 @@ function addProject(host, options) {
16
16
  tags: options.parsedTags,
17
17
  };
18
18
  if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
19
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
20
- name: options.projectName,
19
+ const packageJson = {
20
+ name: options.importPath,
21
21
  version: '0.0.1',
22
22
  private: true,
23
- nx: {
24
- targets: hasPlugin ? {} : getTargets(options),
25
- tags: options.parsedTags?.length ? options.parsedTags : undefined,
26
- },
27
- });
23
+ };
24
+ if (options.projectName !== options.importPath) {
25
+ packageJson.nx = { name: options.projectName };
26
+ }
27
+ if (!hasPlugin) {
28
+ packageJson.nx ??= {};
29
+ packageJson.nx.targets = getTargets(options);
30
+ }
31
+ if (options.parsedTags?.length) {
32
+ packageJson.nx ??= {};
33
+ packageJson.nx.tags = options.parsedTags;
34
+ }
35
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
28
36
  }
29
37
  else {
30
38
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
@@ -1,6 +1,6 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from '../schema';
3
- export interface NormalizedSchema extends Schema {
3
+ export interface NormalizedSchema extends Omit<Schema, 'useTsSolution'> {
4
4
  className: string;
5
5
  fileName: string;
6
6
  projectName: string;
@@ -13,6 +13,7 @@ export interface NormalizedSchema extends Schema {
13
13
  rootProject: boolean;
14
14
  e2eProjectName: string;
15
15
  e2eProjectRoot: string;
16
+ importPath: string;
16
17
  isTsSolutionSetup: boolean;
17
18
  }
18
19
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -4,10 +4,9 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
8
7
  async function normalizeOptions(host, options) {
9
- await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
10
- const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
8
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
9
+ const { projectName, names: projectNames, projectRoot: appProjectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
11
10
  name: options.name,
12
11
  projectType: 'application',
13
12
  directory: options.directory,
@@ -16,17 +15,18 @@ async function normalizeOptions(host, options) {
16
15
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
16
  nxJson.useInferencePlugins !== false;
18
17
  options.addPlugin ??= addPluginDefault;
19
- const { className, fileName } = (0, devkit_1.names)(options.name);
18
+ const { className, fileName } = (0, devkit_1.names)(projectNames.projectSimpleName);
20
19
  const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
21
20
  const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
22
21
  const rootProject = appProjectRoot === '.';
22
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
23
+ const appProjectName = !isTsSolutionSetup || options.name ? projectName : importPath;
23
24
  const e2eProjectName = rootProject ? 'e2e' : `${appProjectName}-e2e`;
24
25
  const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
25
26
  const parsedTags = options.tags
26
27
  ? options.tags.split(',').map((s) => s.trim())
27
28
  : [];
28
29
  const entryFile = options.js ? 'src/main.js' : 'src/main.tsx';
29
- const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
30
30
  return {
31
31
  ...options,
32
32
  name: projectNames.projectSimpleName,
@@ -34,10 +34,9 @@ async function normalizeOptions(host, options) {
34
34
  fileName,
35
35
  lowerCaseName: className.toLowerCase(),
36
36
  displayName: options.displayName || className,
37
- projectName: isTsSolutionSetup
38
- ? (0, get_import_path_1.getImportPath)(host, appProjectName)
39
- : appProjectName,
37
+ projectName: appProjectName,
40
38
  appProjectRoot,
39
+ importPath,
41
40
  iosProjectRoot,
42
41
  androidProjectRoot,
43
42
  parsedTags,
@@ -4,6 +4,7 @@ export interface NormalizedSchema extends Schema {
4
4
  name: string;
5
5
  fileName: string;
6
6
  projectRoot: string;
7
+ importPath: string;
7
8
  routePath: string;
8
9
  parsedTags: string[];
9
10
  appMain?: string;
@@ -4,9 +4,8 @@ exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
8
7
  async function normalizeOptions(host, options) {
9
- await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
8
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
10
9
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
11
10
  name: options.name,
12
11
  projectType: 'library',
@@ -25,9 +24,7 @@ async function normalizeOptions(host, options) {
25
24
  ...options,
26
25
  fileName: projectName,
27
26
  routePath: `/${projectNames.projectSimpleName}`,
28
- name: isUsingTsSolutionConfig
29
- ? options.importPath ?? (0, get_import_path_1.getImportPath)(host, projectName)
30
- : projectName,
27
+ name: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
31
28
  projectRoot,
32
29
  parsedTags,
33
30
  importPath,
@@ -44,6 +44,9 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
44
44
  if (addProjectTask) {
45
45
  tasks.push(addProjectTask);
46
46
  }
47
+ if (options.isUsingTsSolutionConfig) {
48
+ (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
49
+ }
47
50
  const lintTask = await (0, add_linting_1.addLinting)(host, {
48
51
  ...options,
49
52
  projectName: options.name,
@@ -76,9 +79,6 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
76
79
  }, options.linter === 'eslint'
77
80
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
78
81
  : undefined);
79
- if (options.isUsingTsSolutionConfig) {
80
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
81
- }
82
82
  (0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
83
83
  if (!options.skipFormat) {
84
84
  await (0, devkit_1.formatFiles)(host);
@@ -101,19 +101,24 @@ async function addProject(host, options) {
101
101
  targets: {},
102
102
  };
103
103
  if (options.isUsingTsSolutionConfig) {
104
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
105
- name: options.name,
104
+ const packageJson = {
105
+ name: options.importPath,
106
106
  version: '0.0.1',
107
107
  ...determineEntryFields(options),
108
- nx: {
109
- tags: options.parsedTags?.length ? options.parsedTags : undefined,
110
- },
111
108
  files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
112
109
  peerDependencies: {
113
110
  react: versions_1.reactVersion,
114
111
  'react-native': versions_1.reactNativeVersion,
115
112
  },
116
- });
113
+ };
114
+ if (options.name !== options.importPath) {
115
+ packageJson.nx = { name: options.name };
116
+ }
117
+ if (options.parsedTags?.length) {
118
+ packageJson.nx ??= {};
119
+ packageJson.nx.tags = options.parsedTags;
120
+ }
121
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), packageJson);
117
122
  }
118
123
  else {
119
124
  (0, devkit_1.addProjectConfiguration)(host, options.name, project);