@nx/react-native 21.0.0-beta.0 → 21.0.0-beta.10

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.
Files changed (36) hide show
  1. package/migrations.json +0 -126
  2. package/package.json +7 -7
  3. package/project.json +2 -5
  4. package/src/generators/application/application.js +6 -5
  5. package/src/generators/application/files/app/android/gradlew.bat +94 -94
  6. package/src/generators/application/lib/add-e2e.js +2 -0
  7. package/src/generators/application/lib/add-project.js +20 -11
  8. package/src/generators/application/lib/normalize-options.d.ts +2 -1
  9. package/src/generators/application/lib/normalize-options.js +8 -8
  10. package/src/generators/application/schema.d.ts +1 -0
  11. package/src/generators/application/schema.json +4 -0
  12. package/src/generators/component/component.js +6 -2
  13. package/src/generators/component/lib/normalize-options.d.ts +1 -0
  14. package/src/generators/component/lib/normalize-options.js +1 -0
  15. package/src/generators/component/schema.d.ts +1 -0
  16. package/src/generators/component/schema.json +6 -0
  17. package/src/generators/library/lib/normalize-options.d.ts +1 -0
  18. package/src/generators/library/lib/normalize-options.js +3 -5
  19. package/src/generators/library/library.js +73 -75
  20. package/src/generators/library/schema.d.ts +1 -0
  21. package/src/generators/library/schema.json +4 -0
  22. package/src/generators/library/files/lib/package.json.template +0 -4
  23. package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +0 -6
  24. package/src/migrations/update-18-0-0/add-upgrade-target.js +0 -31
  25. package/src/migrations/update-18-0-0/add-web-configuration.d.ts +0 -8
  26. package/src/migrations/update-18-0-0/add-web-configuration.js +0 -33
  27. package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +0 -5
  28. package/src/migrations/update-18-0-0/change-storybook-targets.js +0 -57
  29. package/src/migrations/update-18-0-0/remove-block-list.d.ts +0 -6
  30. package/src/migrations/update-18-0-0/remove-block-list.js +0 -28
  31. package/src/migrations/update-18-0-0/remove-metro.d.ts +0 -14
  32. package/src/migrations/update-18-0-0/remove-metro.js +0 -29
  33. package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +0 -6
  34. package/src/migrations/update-18-0-0/remove-symlink-target.js +0 -30
  35. package/src/utils/format-file.d.ts +0 -1
  36. package/src/utils/format-file.js +0 -15
package/migrations.json CHANGED
@@ -1,41 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "update-18-0-0-add-web-configuration": {
4
- "cli": "nx",
5
- "version": "18.0.0-beta.0",
6
- "description": "Add web configuration to react native projects",
7
- "implementation": "./src/migrations/update-18-0-0/add-web-configuration"
8
- },
9
- "update-18-0-0-change-storybook-targets": {
10
- "cli": "nx",
11
- "version": "18.0.0-beta.0",
12
- "description": "Upgrade react native storybook target to use web",
13
- "implementation": "./src/migrations/update-18-0-0/change-storybook-targets"
14
- },
15
- "update-18-0-0-remove-block-list": {
16
- "cli": "nx",
17
- "version": "18.0.0-beta.0",
18
- "description": "Remove blockList in metro.config.js.",
19
- "implementation": "./src/migrations/update-18-0-0/remove-block-list"
20
- },
21
- "update-18-0-0-remove-metro": {
22
- "cli": "nx",
23
- "version": "18.0.0-beta.0",
24
- "description": "Remove metro-* and @react-native-community/cli-* from package.json devDependencies",
25
- "implementation": "./src/migrations/update-18-0-0/remove-metro"
26
- },
27
- "update-18-0-0-remove-symlink-target": {
28
- "cli": "nx",
29
- "version": "18.0.0-beta.0",
30
- "description": "Remove ensure-symlink target",
31
- "implementation": "./src/migrations/update-18-0-0/remove-symlink-target"
32
- },
33
- "update-18-0-0-add-upgrade-target": {
34
- "cli": "nx",
35
- "version": "18.0.0-beta.0",
36
- "description": "Add upgrade target to react native projects",
37
- "implementation": "./src/migrations/update-18-0-0/add-upgrade-target"
38
- },
39
3
  "update-19-6-0-rename-upgrade-target-name": {
40
4
  "cli": "nx",
41
5
  "version": "19.6.0-beta.1",
@@ -44,96 +8,6 @@
44
8
  }
45
9
  },
46
10
  "packageJsonUpdates": {
47
- "17.1.0": {
48
- "version": "17.1.0-beta.1",
49
- "packages": {
50
- "react-native": {
51
- "version": "0.72.6",
52
- "alwaysAddToPackageJson": false
53
- },
54
- "metro": {
55
- "version": "0.76.8",
56
- "alwaysAddToPackageJson": false
57
- },
58
- "metro-resolver": {
59
- "version": "0.76.8",
60
- "alwaysAddToPackageJson": false
61
- },
62
- "metro-config": {
63
- "version": "0.76.8",
64
- "alwaysAddToPackageJson": false
65
- },
66
- "metro-react-native-babel-preset": {
67
- "version": "0.76.8",
68
- "alwaysAddToPackageJson": false
69
- },
70
- "metro-babel-register": {
71
- "version": "0.76.8",
72
- "alwaysAddToPackageJson": false
73
- },
74
- "metro-react-native-babel-transformer": {
75
- "version": "0.76.7",
76
- "alwaysAddToPackageJson": false
77
- },
78
- "@react-native-community/cli": {
79
- "version": "11.3.7",
80
- "alwaysAddToPackageJson": false
81
- },
82
- "@react-native-community/cli-platform-android": {
83
- "version": "11.3.7",
84
- "alwaysAddToPackageJson": false
85
- },
86
- "@react-native-community/cli-platform-ios": {
87
- "version": "11.3.7",
88
- "alwaysAddToPackageJson": false
89
- }
90
- }
91
- },
92
- "17.3.0": {
93
- "version": "17.3.0-beta.3",
94
- "packages": {
95
- "@types/node": {
96
- "version": "18.16.9"
97
- }
98
- }
99
- },
100
- "18.0.0": {
101
- "version": "18.0.0-beta.0",
102
- "packages": {
103
- "react-native": {
104
- "version": "0.73.2",
105
- "alwaysAddToPackageJson": false
106
- },
107
- "@react-native/babel-preset": {
108
- "version": "^0.73.18",
109
- "addToPackageJson": "devDependencies"
110
- },
111
- "@react-native/metro-config": {
112
- "version": "^0.73.2",
113
- "addToPackageJson": "devDependencies"
114
- },
115
- "@types/react": {
116
- "version": "~18.2.45",
117
- "alwaysAddToPackageJson": false
118
- },
119
- "@testing-library/react-native": {
120
- "version": "~12.4.2",
121
- "alwaysAddToPackageJson": false
122
- },
123
- "react-native-svg-transformer": {
124
- "version": "1.2.0",
125
- "alwaysAddToPackageJson": false
126
- },
127
- "react-native-svg": {
128
- "version": "14.1.0",
129
- "alwaysAddToPackageJson": false
130
- },
131
- "@react-native-community/cli-platform-android": {
132
- "version": "12.3.0",
133
- "alwaysAddToPackageJson": false
134
- }
135
- }
136
- },
137
11
  "19.0.0": {
138
12
  "version": "19.0.0-beta.7",
139
13
  "packages": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "21.0.0-beta.0",
3
+ "version": "21.0.0-beta.10",
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": "21.0.0-beta.0",
39
- "@nx/jest": "21.0.0-beta.0",
40
- "@nx/js": "21.0.0-beta.0",
41
- "@nx/eslint": "21.0.0-beta.0",
42
- "@nx/react": "21.0.0-beta.0",
43
- "@nx/workspace": "21.0.0-beta.0"
38
+ "@nx/devkit": "21.0.0-beta.10",
39
+ "@nx/jest": "21.0.0-beta.10",
40
+ "@nx/js": "21.0.0-beta.10",
41
+ "@nx/eslint": "21.0.0-beta.10",
42
+ "@nx/react": "21.0.0-beta.10",
43
+ "@nx/workspace": "21.0.0-beta.10"
44
44
  },
45
45
  "executors": "./executors.json",
46
46
  "ng-update": {
package/project.json CHANGED
@@ -39,11 +39,8 @@
39
39
  }
40
40
  },
41
41
  "build": {
42
- "executor": "nx:run-commands",
43
- "outputs": ["{workspaceRoot}/build/packages/react-native"],
44
- "options": {
45
- "command": "node ./scripts/copy-readme.js react-native"
46
- }
42
+ "outputs": ["{workspaceRoot}/build/packages/react-native/README.md"],
43
+ "command": "node ./scripts/copy-readme.js react-native"
47
44
  }
48
45
  }
49
46
  }
@@ -22,6 +22,7 @@ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
22
22
  async function reactNativeApplicationGenerator(host, schema) {
23
23
  return await reactNativeApplicationGeneratorInternal(host, {
24
24
  addPlugin: false,
25
+ useProjectJson: true,
25
26
  ...schema,
26
27
  });
27
28
  }
@@ -43,6 +44,11 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
43
44
  }
44
45
  await (0, create_application_files_1.createApplicationFiles)(host, options);
45
46
  (0, add_project_1.addProject)(host, options);
47
+ // If we are using the new TS solution
48
+ // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
49
+ if (options.isTsSolutionSetup) {
50
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
51
+ }
46
52
  const lintTask = await (0, add_linting_1.addLinting)(host, {
47
53
  ...options,
48
54
  projectRoot: options.appProjectRoot,
@@ -88,11 +94,6 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
88
94
  }, options.linter === 'eslint'
89
95
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
90
96
  : 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
97
  (0, sort_fields_1.sortPackageJsonFields)(host, options.appProjectRoot);
97
98
  if (!options.skipFormat) {
98
99
  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);
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProject = addProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
5
  function addProject(host, options) {
7
6
  const nxJson = (0, devkit_1.readNxJson)(host);
8
7
  const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
@@ -15,22 +14,32 @@ function addProject(host, options) {
15
14
  targets: hasPlugin ? {} : getTargets(options),
16
15
  tags: options.parsedTags,
17
16
  };
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,
21
- version: '0.0.1',
22
- private: true,
23
- nx: {
24
- targets: hasPlugin ? {} : getTargets(options),
25
- tags: options.parsedTags?.length ? options.parsedTags : undefined,
26
- },
27
- });
17
+ const packageJson = {
18
+ name: options.importPath,
19
+ version: '0.0.1',
20
+ private: true,
21
+ };
22
+ if (!options.useProjectJson) {
23
+ if (options.projectName !== options.importPath) {
24
+ packageJson.nx = { name: options.projectName };
25
+ }
26
+ if (!hasPlugin) {
27
+ packageJson.nx ??= {};
28
+ packageJson.nx.targets = getTargets(options);
29
+ }
30
+ if (options.parsedTags?.length) {
31
+ packageJson.nx ??= {};
32
+ packageJson.nx.tags = options.parsedTags;
33
+ }
28
34
  }
29
35
  else {
30
36
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
31
37
  ...project,
32
38
  });
33
39
  }
40
+ if (!options.useProjectJson || options.isTsSolutionSetup) {
41
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
42
+ }
34
43
  }
35
44
  function getTargets(options) {
36
45
  const architect = {};
@@ -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,
@@ -46,5 +45,6 @@ async function normalizeOptions(host, options) {
46
45
  e2eProjectName,
47
46
  e2eProjectRoot,
48
47
  isTsSolutionSetup,
48
+ useProjectJson: options.useProjectJson ?? !isTsSolutionSetup,
49
49
  };
50
50
  }
@@ -21,4 +21,5 @@ export interface Schema {
21
21
  nxCloudToken?: string;
22
22
  useTsSolution?: boolean;
23
23
  formatter?: 'prettier' | 'none';
24
+ useProjectJson?: boolean;
24
25
  }
@@ -95,6 +95,10 @@
95
95
  "x-prompt": "Which bundler do you want to use to build the application?",
96
96
  "default": "vite",
97
97
  "x-priority": "important"
98
+ },
99
+ "useProjectJson": {
100
+ "type": "boolean",
101
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
98
102
  }
99
103
  },
100
104
  "required": ["directory"]
@@ -11,7 +11,9 @@ async function reactNativeComponentGenerator(host, schema) {
11
11
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
12
12
  createComponentFiles(host, options);
13
13
  addExportsToBarrel(host, options);
14
- await (0, devkit_1.formatFiles)(host);
14
+ if (!options.skipFormat) {
15
+ await (0, devkit_1.formatFiles)(host);
16
+ }
15
17
  }
16
18
  function createComponentFiles(host, options) {
17
19
  (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, 'files', options.fileExtensionType), options.directory, {
@@ -31,7 +33,9 @@ function addExportsToBarrel(host, options) {
31
33
  const proj = workspace.get(options.projectName);
32
34
  const isApp = (0, ts_solution_setup_1.getProjectType)(host, proj.root, proj.projectType) === 'application';
33
35
  if (options.export && !isApp) {
34
- const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
36
+ const indexFilePath = (0, devkit_1.joinPathFragments)(...(options.projectSourceRoot
37
+ ? [options.projectSourceRoot]
38
+ : [options.projectRoot, 'src']), options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
35
39
  if (!host.exists(indexFilePath)) {
36
40
  return;
37
41
  }
@@ -10,5 +10,6 @@ export interface NormalizedSchema extends Omit<Schema, 'js'> {
10
10
  fileExtension: string;
11
11
  fileExtensionType: FileExtensionType;
12
12
  projectName: string;
13
+ projectRoot: string;
13
14
  }
14
15
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -31,5 +31,6 @@ async function normalizeOptions(host, options) {
31
31
  fileExtensionType,
32
32
  projectSourceRoot,
33
33
  projectName,
34
+ projectRoot: root,
34
35
  };
35
36
  }
@@ -7,6 +7,7 @@ export interface Schema {
7
7
  skipTests?: boolean;
8
8
  export?: boolean;
9
9
  classComponent?: boolean;
10
+ skipFormat?: boolean;
10
11
 
11
12
  /**
12
13
  * @deprecated Provide the full file path including the file extension in the `path` option. This option will be removed in Nx v21.
@@ -59,6 +59,12 @@
59
59
  "alias": "C",
60
60
  "description": "Use class components instead of functional component.",
61
61
  "default": false
62
+ },
63
+ "skipFormat": {
64
+ "description": "Skip formatting files.",
65
+ "type": "boolean",
66
+ "default": false,
67
+ "x-priority": "internal"
62
68
  }
63
69
  },
64
70
  "required": ["path"]
@@ -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,13 +24,12 @@ async function normalizeOptions(host, options) {
25
24
  ...options,
26
25
  fileName: projectName,
27
26
  routePath: `/${projectNames.projectSimpleName}`,
28
- name: isUsingTsSolutionConfig
29
- ? (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,
34
31
  isUsingTsSolutionConfig,
32
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionConfig,
35
33
  };
36
34
  return normalized;
37
35
  }
@@ -7,15 +7,20 @@ const js_1 = require("@nx/js");
7
7
  const init_1 = require("../init/init");
8
8
  const add_linting_1 = require("../../utils/add-linting");
9
9
  const add_jest_1 = require("../../utils/add-jest");
10
- const versions_1 = require("../../utils/versions");
10
+ const component_1 = require("../component/component");
11
11
  const normalize_options_1 = require("./lib/normalize-options");
12
12
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
13
13
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
14
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
15
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
16
+ const add_rollup_build_target_1 = require("@nx/react/src/generators/library/lib/add-rollup-build-target");
17
+ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
18
+ const path_1 = require("path");
19
+ const versions_1 = require("../../utils/versions");
16
20
  async function reactNativeLibraryGenerator(host, schema) {
17
21
  return await reactNativeLibraryGeneratorInternal(host, {
18
22
  addPlugin: false,
23
+ useProjectJson: true,
19
24
  ...schema,
20
25
  });
21
26
  }
@@ -36,6 +41,9 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
36
41
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(host));
37
42
  }
38
43
  createFiles(host, options);
44
+ if (options.isUsingTsSolutionConfig) {
45
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
46
+ }
39
47
  const addProjectTask = await addProject(host, options);
40
48
  if (addProjectTask) {
41
49
  tasks.push(addProjectTask);
@@ -50,9 +58,16 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
50
58
  tasks.push(lintTask);
51
59
  const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin, 'tsconfig.lib.json');
52
60
  tasks.push(jestTask);
53
- if (options.publishable || options.buildable) {
54
- updateLibPackageNpmScope(host, options);
55
- }
61
+ const relativeCwd = (0, artifact_name_and_directory_utils_1.getRelativeCwd)();
62
+ const path = (0, devkit_1.joinPathFragments)(options.projectRoot, 'src/lib', options.fileName);
63
+ const componentTask = await (0, component_1.default)(host, {
64
+ path: relativeCwd ? (0, path_1.relative)(relativeCwd, path) : path,
65
+ skipTests: options.unitTestRunner === 'none',
66
+ export: true,
67
+ skipFormat: true,
68
+ js: options.js,
69
+ });
70
+ tasks.push(() => componentTask);
56
71
  if (!options.skipTsConfig && !options.isUsingTsSolutionConfig) {
57
72
  (0, js_1.addTsConfigPath)(host, options.importPath, [
58
73
  (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
@@ -65,9 +80,6 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
65
80
  }, options.linter === 'eslint'
66
81
  ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
67
82
  : undefined);
68
- if (options.isUsingTsSolutionConfig) {
69
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
70
- }
71
83
  (0, sort_fields_1.sortPackageJsonFields)(host, options.projectRoot);
72
84
  if (!options.skipFormat) {
73
85
  await (0, devkit_1.formatFiles)(host);
@@ -89,61 +101,62 @@ async function addProject(host, options) {
89
101
  tags: options.parsedTags,
90
102
  targets: {},
91
103
  };
92
- const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
93
- if (options.isUsingTsSolutionConfig) {
94
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
95
- name: options.name,
96
- version: '0.0.1',
104
+ let packageJson = {
105
+ name: options.importPath,
106
+ version: '0.0.1',
107
+ };
108
+ if (!options.useProjectJson) {
109
+ packageJson = {
110
+ ...packageJson,
97
111
  ...determineEntryFields(options),
98
- nx: {
99
- tags: options.parsedTags?.length ? options.parsedTags : undefined,
112
+ files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
113
+ peerDependencies: {
114
+ react: versions_1.reactVersion,
115
+ 'react-native': versions_1.reactNativeVersion,
100
116
  },
101
- });
117
+ };
118
+ if (options.name !== options.importPath) {
119
+ packageJson.nx = { name: options.name };
120
+ }
121
+ if (options.parsedTags?.length) {
122
+ packageJson.nx ??= {};
123
+ packageJson.nx.tags = options.parsedTags;
124
+ }
102
125
  }
103
126
  else {
104
127
  (0, devkit_1.addProjectConfiguration)(host, options.name, project);
105
128
  }
106
- if (!options.publishable && !options.buildable) {
107
- return () => { };
129
+ if (!options.useProjectJson ||
130
+ options.isUsingTsSolutionConfig ||
131
+ options.publishable ||
132
+ options.buildable) {
133
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), packageJson);
108
134
  }
109
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
110
- const rollupConfigTask = await configurationGenerator(host, {
111
- ...options,
112
- project: options.name,
113
- skipFormat: true,
114
- });
115
- (0, devkit_1.updateJson)(host, packageJsonPath, (json) => {
116
- if (json.type === 'module') {
117
- // The @nx/rollup:configuration generator can set the type to 'module' which would
118
- // potentially break this library.
119
- delete json.type;
120
- }
121
- return json;
122
- });
123
- const external = ['react/jsx-runtime', 'react-native', 'react', 'react-dom'];
124
- project.targets.build = {
125
- executor: '@nx/rollup:rollup',
126
- outputs: ['{options.outputPath}'],
127
- options: {
128
- outputPath: options.isUsingTsSolutionConfig
129
- ? `${options.projectRoot}/dist`
130
- : `dist/${options.projectRoot}`,
131
- tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
132
- project: `${options.projectRoot}/package.json`,
133
- entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
134
- external,
135
- rollupConfig: `@nx/react/plugins/bundle-rollup`,
136
- assets: [
137
- {
138
- glob: `${options.projectRoot}/README.md`,
139
- input: '.',
140
- output: '.',
141
- },
142
- ],
143
- },
144
- };
145
- (0, devkit_1.updateProjectConfiguration)(host, options.name, project);
146
- return rollupConfigTask;
135
+ if (options.publishable || options.buildable) {
136
+ const external = new Set([
137
+ 'react/jsx-runtime',
138
+ 'react-native',
139
+ 'react',
140
+ 'react-dom',
141
+ ]);
142
+ const rollupTask = await (0, add_rollup_build_target_1.addRollupBuildTarget)(host, {
143
+ ...options,
144
+ format: ['cjs', 'esm'],
145
+ style: 'none',
146
+ js: options.js,
147
+ skipFormat: true,
148
+ }, external);
149
+ (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
150
+ json.peerDependencies = {
151
+ ...json.peerDependencies,
152
+ react: versions_1.reactVersion,
153
+ 'react-native': versions_1.reactNativeVersion,
154
+ };
155
+ return json;
156
+ });
157
+ return rollupTask;
158
+ }
159
+ return () => { };
147
160
  }
148
161
  function updateTsConfig(tree, options) {
149
162
  if (options.isUsingTsSolutionConfig) {
@@ -169,32 +182,17 @@ function createFiles(host, options) {
169
182
  offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
170
183
  rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot),
171
184
  });
172
- if (!options.publishable && !options.buildable) {
173
- host.delete(`${options.projectRoot}/package.json`);
174
- }
175
185
  if (options.js) {
176
186
  (0, devkit_1.toJS)(host);
177
187
  }
178
188
  updateTsConfig(host, options);
179
189
  }
180
- function updateLibPackageNpmScope(host, options) {
181
- return (0, devkit_1.updateJson)(host, `${options.projectRoot}/package.json`, (json) => {
182
- json.name = options.importPath;
183
- json.peerDependencies = {
184
- react: versions_1.reactVersion,
185
- 'react-native': versions_1.reactNativeVersion,
186
- };
187
- return json;
188
- });
189
- }
190
- function maybeJs(options, path) {
191
- return options.js && (path.endsWith('.ts') || path.endsWith('.tsx'))
192
- ? path.replace(/\.tsx?$/, '.js')
193
- : path;
194
- }
195
190
  function determineEntryFields(options) {
196
- if (options.buildable) {
197
- return {};
191
+ if (options.buildable ||
192
+ options.publishable ||
193
+ !options.isUsingTsSolutionConfig) {
194
+ // For buildable libraries, the entries are configured by the bundler (i.e. Rollup).
195
+ return undefined;
198
196
  }
199
197
  return {
200
198
  main: options.js ? './src/index.js' : './src/index.ts',
@@ -19,4 +19,5 @@ export interface Schema {
19
19
  setParserOptionsProject?: boolean;
20
20
  skipPackageJson?: boolean; //default is false
21
21
  addPlugin?: boolean;
22
+ useProjectJson?: boolean;
22
23
  }
@@ -93,6 +93,10 @@
93
93
  "type": "boolean",
94
94
  "default": false,
95
95
  "x-priority": "internal"
96
+ },
97
+ "useProjectJson": {
98
+ "type": "boolean",
99
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
96
100
  }
97
101
  },
98
102
  "required": ["directory"]
@@ -1,4 +0,0 @@
1
- {
2
- "name": "<%= name %>",
3
- "version": "0.0.1"
4
- }
@@ -1,6 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * Add target upgrade for react native apps
4
- * Remove pod-install from dependsOn for all targets, it does pod-install when creating the app
5
- */
6
- export default function update(tree: Tree): Promise<void>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- /**
6
- * Add target upgrade for react native apps
7
- * Remove pod-install from dependsOn for all targets, it does pod-install when creating the app
8
- */
9
- async function update(tree) {
10
- const projects = (0, devkit_1.getProjects)(tree);
11
- for (const [name, config] of projects.entries()) {
12
- if (config.targets?.['start']?.executor === '@nx/react-native:start') {
13
- if (!config.targets['upgrade']) {
14
- config.targets.upgrade = {
15
- executor: '@nx/react-native:upgrade',
16
- options: {},
17
- };
18
- }
19
- if (config.targets?.['pod-install']?.executor ===
20
- '@nx/react-native:pod-install') {
21
- for (const targetName in config.targets) {
22
- if (config.targets[targetName]?.dependsOn?.length) {
23
- config.targets[targetName].dependsOn = config.targets[targetName].dependsOn.filter((dependsOn) => dependsOn !== 'pod-install');
24
- }
25
- }
26
- }
27
- (0, devkit_1.updateProjectConfiguration)(tree, name, config);
28
- }
29
- }
30
- await (0, devkit_1.formatFiles)(tree);
31
- }
@@ -1,8 +0,0 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
2
- /**
3
- * Add web configuration to react native projects
4
- * - delete the current serve target which is just a pass-through to start target
5
- * - rename the babel.config.json to to babel-v72.config.json
6
- * - add web confiugration, it will add .babelrc.js
7
- */
8
- export default function update(tree: Tree): Promise<GeneratorCallback>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- const web_configuration_1 = require("../../generators/web-configuration/web-configuration");
6
- /**
7
- * Add web configuration to react native projects
8
- * - delete the current serve target which is just a pass-through to start target
9
- * - rename the babel.config.json to to babel-v72.config.json
10
- * - add web confiugration, it will add .babelrc.js
11
- */
12
- async function update(tree) {
13
- const projects = (0, devkit_1.getProjects)(tree);
14
- const tasks = [];
15
- for (const [projectName, config] of projects.entries()) {
16
- if (config.targets?.['start']?.executor === '@nx/react-native:start') {
17
- if (config.targets['serve'] &&
18
- config.targets['serve'].executor === 'nx:run-commands' &&
19
- config.targets['serve'].options?.command?.startsWith('nx start')) {
20
- delete config.targets['serve'];
21
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
22
- }
23
- if (tree.exists((0, devkit_1.joinPathFragments)(config.root, 'babel.config.json'))) {
24
- tree.rename((0, devkit_1.joinPathFragments)(config.root, 'babel.config.json'), (0, devkit_1.joinPathFragments)(config.root, 'babel-v72.config.json'));
25
- }
26
- tasks.push(await (0, web_configuration_1.default)(tree, {
27
- project: config.name,
28
- bundler: 'webpack',
29
- }));
30
- }
31
- }
32
- return (0, devkit_1.runTasksInSerial)(...tasks);
33
- }
@@ -1,5 +0,0 @@
1
- import { GeneratorCallback, Tree } from '@nx/devkit';
2
- /**
3
- * Upgrade react native storybook target to use web
4
- */
5
- export default function changeStorybookTargets(tree: Tree): Promise<GeneratorCallback>;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = changeStorybookTargets;
4
- const devkit_1 = require("@nx/devkit");
5
- const output_1 = require("nx/src/utils/output");
6
- const migrate_7_1 = require("@nx/storybook/src/generators/migrate-7/migrate-7");
7
- const utilities_1 = require("@nx/storybook/src/utils/utilities");
8
- const configuration_1 = require("@nx/react/src/generators/storybook-configuration/configuration");
9
- /**
10
- * Upgrade react native storybook target to use web
11
- */
12
- async function changeStorybookTargets(tree) {
13
- const tasks = [];
14
- // update the storybook target
15
- const projects = (0, devkit_1.getProjects)(tree);
16
- let hasStorybookTarget = false;
17
- for (const [projectName, config] of projects.entries()) {
18
- if (config.targets?.['storybook']?.executor === '@nx/react-native:storybook') {
19
- hasStorybookTarget = true;
20
- delete config.targets['storybook'];
21
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
22
- tasks.push(await (0, configuration_1.default)(tree, {
23
- project: projectName,
24
- }));
25
- }
26
- }
27
- /**
28
- * This just checks if Storybook is installed in the workspace.
29
- * The thing here is that during the previous step of the migration,
30
- * during packageJsonUpdates, Nx has already set Storybook
31
- * to version 7, if Storybook exists in the workspace.
32
- * So, it makes no sense here to check if the version is
33
- * 7, because it will always be.
34
- */
35
- const storybookVersion = (0, utilities_1.storybookMajorVersion)();
36
- if (!hasStorybookTarget || !storybookVersion) {
37
- return;
38
- }
39
- output_1.output.log({
40
- title: 'Migrating Storybook to v7',
41
- bodyLines: [
42
- `🚀 This migration will update your Storybook configuration to v7.`,
43
- `It will call the @nx/storybook:migrate-7 generator for you.`,
44
- `You can read more about the migration and how this generator works here:`,
45
- `https://nx.dev/nx-api/storybook/generators/migrate-7`,
46
- ],
47
- });
48
- tasks.push(await (0, migrate_7_1.default)(tree, { autoAcceptAllPrompts: true }));
49
- tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(tree, [], [
50
- '@storybook/react-native',
51
- '@storybook/addon-ondevice-actions',
52
- '@storybook/addon-ondevice-backgrounds',
53
- '@storybook/addon-ondevice-controls',
54
- '@storybook/addon-ondevice-notes',
55
- ]));
56
- return (0, devkit_1.runTasksInSerial)(...tasks);
57
- }
@@ -1,6 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * This migration removes blockList in metro.config.js.
4
- * It is now excluding dist folder in watchFolders in withNxMetro.
5
- */
6
- export default function update(tree: Tree): Promise<void>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- /**
6
- * This migration removes blockList in metro.config.js.
7
- * It is now excluding dist folder in watchFolders in withNxMetro.
8
- */
9
- async function update(tree) {
10
- const projects = (0, devkit_1.getProjects)(tree);
11
- for (const [_, config] of projects.entries()) {
12
- if (config.targets?.['start']?.executor === '@nx/react-native:start') {
13
- if (tree.exists((0, devkit_1.joinPathFragments)(config.root, 'metro.config.js'))) {
14
- let content = tree
15
- .read((0, devkit_1.joinPathFragments)(config.root, 'metro.config.js'))
16
- .toString();
17
- content = content.replace(/blockList: exclusionList(.+?(?=\n))/, '');
18
- content = content.replace('// unstable_enableSymlinks: true,', '');
19
- content = content.replace('// unstable_enablePackageExports: true,', '');
20
- content = content.replace('unstable_enableSymlinks: true,', '');
21
- content = content.replace('unstable_enablePackageExports: true,', '');
22
- content = content.replace(`const exclusionList = require('metro-config/src/defaults/exclusionList');`, '');
23
- tree.write((0, devkit_1.joinPathFragments)(config.root, 'metro.config.js'), content);
24
- await (0, devkit_1.formatFiles)(tree);
25
- }
26
- }
27
- }
28
- }
@@ -1,14 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * Remove metro-* package since it is no longer explicity required in package.json.
4
- * react-native has dependency of @react-native/community-cli-plugin
5
- * @react-native/community-cli-plugin has dependency of metro
6
- *
7
- * Also remove @react-native-community/cli-* since it is a dependency of react-native.
8
- * (excpet reactNativeCommunityCliPlatformAndroidVersion because android files refer it by path)
9
- *
10
- * https://react-native-community.github.io/upgrade-helper/?from=0.72.6&to=0.73.1#RnDiffApp-package.json
11
- * @param tree
12
- * @returns
13
- */
14
- export default function update(tree: Tree): Promise<void>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- /**
6
- * Remove metro-* package since it is no longer explicity required in package.json.
7
- * react-native has dependency of @react-native/community-cli-plugin
8
- * @react-native/community-cli-plugin has dependency of metro
9
- *
10
- * Also remove @react-native-community/cli-* since it is a dependency of react-native.
11
- * (excpet reactNativeCommunityCliPlatformAndroidVersion because android files refer it by path)
12
- *
13
- * https://react-native-community.github.io/upgrade-helper/?from=0.72.6&to=0.73.1#RnDiffApp-package.json
14
- * @param tree
15
- * @returns
16
- */
17
- async function update(tree) {
18
- (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], [
19
- 'metro',
20
- 'metro-resolver',
21
- 'metro-config',
22
- 'metro-react-native-babel-preset',
23
- 'metro-babel-register',
24
- 'metro-react-native-babel-transformer',
25
- '@react-native-community/cli',
26
- '@react-native-community/cli-platform-ios',
27
- ]);
28
- await (0, devkit_1.formatFiles)(tree);
29
- }
@@ -1,6 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * Remove ensure-symlink target.
4
- * It is going to be supported by react-native version 0.73 by default.
5
- */
6
- export default function update(tree: Tree): Promise<void>;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = update;
4
- const devkit_1 = require("@nx/devkit");
5
- const node_fs_1 = require("node:fs");
6
- /**
7
- * Remove ensure-symlink target.
8
- * It is going to be supported by react-native version 0.73 by default.
9
- */
10
- async function update(tree) {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- for (const [projectName, config] of projects.entries()) {
13
- if (config.targets?.['ensure-symlink']?.executor ===
14
- '@nx/react-native:ensure-symlink') {
15
- removeTargets(config.targets, 'ensure-symlink');
16
- (0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
17
- (0, node_fs_1.rmSync)(`${config.root}/node_modules`, { recursive: true, force: true });
18
- }
19
- }
20
- }
21
- function removeTargets(targets, targetNameToRemove) {
22
- for (const targetName in targets) {
23
- if (targetName === targetNameToRemove) {
24
- delete targets[targetName];
25
- }
26
- if (targets[targetName]?.dependsOn?.length) {
27
- targets[targetName].dependsOn = targets[targetName].dependsOn.filter((dependsOn) => dependsOn !== targetNameToRemove);
28
- }
29
- }
30
- }
@@ -1 +0,0 @@
1
- export declare function formatFile(content: any, ...values: any[]): string;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatFile = formatFile;
4
- const devkit_1 = require("@nx/devkit");
5
- const prettier_1 = require("prettier");
6
- function formatFile(content, ...values) {
7
- return (0, prettier_1.format)((0, devkit_1.stripIndents)(content, values)
8
- .split('\n')
9
- .map((line) => line.trim())
10
- .join('')
11
- .trim(), {
12
- singleQuote: true,
13
- parser: 'typescript',
14
- });
15
- }