@nx/react-native 0.0.0-pr-22179-271588f

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 (276) hide show
  1. package/.eslintrc.json +48 -0
  2. package/LICENSE +22 -0
  3. package/README.md +68 -0
  4. package/executors.json +59 -0
  5. package/generators.json +58 -0
  6. package/index.d.ts +5 -0
  7. package/index.js +13 -0
  8. package/migrations.json +632 -0
  9. package/package.json +57 -0
  10. package/plugin.d.ts +1 -0
  11. package/plugin.js +6 -0
  12. package/plugins/jest/svg-mock.d.ts +0 -0
  13. package/plugins/jest/svg-mock.js +3 -0
  14. package/plugins/metro-resolver.d.ts +1 -0
  15. package/plugins/metro-resolver.js +136 -0
  16. package/plugins/plugin.d.ts +14 -0
  17. package/plugins/plugin.js +162 -0
  18. package/plugins/with-nx-metro.d.ts +8 -0
  19. package/plugins/with-nx-metro.js +31 -0
  20. package/project.json +54 -0
  21. package/src/executors/build-android/build-android.impl.d.ts +6 -0
  22. package/src/executors/build-android/build-android.impl.js +48 -0
  23. package/src/executors/build-android/build-android.impl.ts +69 -0
  24. package/src/executors/build-android/schema.d.ts +14 -0
  25. package/src/executors/build-android/schema.json +81 -0
  26. package/src/executors/build-ios/build-ios.impl.d.ts +6 -0
  27. package/src/executors/build-ios/build-ios.impl.js +55 -0
  28. package/src/executors/build-ios/build-ios.impl.ts +77 -0
  29. package/src/executors/build-ios/schema.d.ts +17 -0
  30. package/src/executors/build-ios/schema.json +91 -0
  31. package/src/executors/bundle/bundle.impl.d.ts +6 -0
  32. package/src/executors/bundle/bundle.impl.js +56 -0
  33. package/src/executors/bundle/bundle.impl.ts +77 -0
  34. package/src/executors/bundle/schema.d.ts +16 -0
  35. package/src/executors/bundle/schema.json +92 -0
  36. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +9 -0
  37. package/src/executors/ensure-symlink/ensure-symlink.impl.js +13 -0
  38. package/src/executors/ensure-symlink/ensure-symlink.impl.ts +22 -0
  39. package/src/executors/ensure-symlink/schema.json +11 -0
  40. package/src/executors/pod-install/pod-install.impl.d.ts +6 -0
  41. package/src/executors/pod-install/pod-install.impl.js +11 -0
  42. package/src/executors/pod-install/pod-install.impl.ts +21 -0
  43. package/src/executors/pod-install/schema.d.ts +6 -0
  44. package/src/executors/pod-install/schema.json +33 -0
  45. package/src/executors/run-android/run-android.impl.d.ts +6 -0
  46. package/src/executors/run-android/run-android.impl.js +66 -0
  47. package/src/executors/run-android/run-android.impl.ts +94 -0
  48. package/src/executors/run-android/schema.d.ts +13 -0
  49. package/src/executors/run-android/schema.json +100 -0
  50. package/src/executors/run-ios/run-ios.impl.d.ts +6 -0
  51. package/src/executors/run-ios/run-ios.impl.js +65 -0
  52. package/src/executors/run-ios/run-ios.impl.ts +92 -0
  53. package/src/executors/run-ios/schema.d.ts +7 -0
  54. package/src/executors/run-ios/schema.json +96 -0
  55. package/src/executors/start/lib/is-packager-running.d.ts +1 -0
  56. package/src/executors/start/lib/is-packager-running.js +15 -0
  57. package/src/executors/start/schema.d.ts +7 -0
  58. package/src/executors/start/schema.json +28 -0
  59. package/src/executors/start/start.impl.d.ts +10 -0
  60. package/src/executors/start/start.impl.js +87 -0
  61. package/src/executors/start/start.impl.ts +111 -0
  62. package/src/executors/storybook/schema.d.ts +5 -0
  63. package/src/executors/storybook/schema.json +29 -0
  64. package/src/executors/storybook/storybook.impl.d.ts +10 -0
  65. package/src/executors/storybook/storybook.impl.js +51 -0
  66. package/src/executors/storybook/storybook.impl.ts +85 -0
  67. package/src/executors/sync-deps/schema.d.ts +5 -0
  68. package/src/executors/sync-deps/schema.json +33 -0
  69. package/src/executors/sync-deps/sync-deps.impl.d.ts +9 -0
  70. package/src/executors/sync-deps/sync-deps.impl.js +78 -0
  71. package/src/executors/sync-deps/sync-deps.impl.ts +140 -0
  72. package/src/executors/upgrade/schema.d.ts +1 -0
  73. package/src/executors/upgrade/schema.json +11 -0
  74. package/src/executors/upgrade/upgrade.impl.d.ts +13 -0
  75. package/src/executors/upgrade/upgrade.impl.js +47 -0
  76. package/src/executors/upgrade/upgrade.impl.ts +64 -0
  77. package/src/generators/application/application.d.ts +5 -0
  78. package/src/generators/application/application.js +87 -0
  79. package/src/generators/application/application.spec.ts +258 -0
  80. package/src/generators/application/files/app/.babelrc.js.template +23 -0
  81. package/src/generators/application/files/app/Gemfile.template +7 -0
  82. package/src/generators/application/files/app/android/app/build.gradle.template +119 -0
  83. package/src/generators/application/files/app/android/app/debug.keystore +0 -0
  84. package/src/generators/application/files/app/android/app/proguard-rules.pro +10 -0
  85. package/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +30 -0
  86. package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +10 -0
  87. package/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +26 -0
  88. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +22 -0
  89. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +45 -0
  90. package/src/generators/application/files/app/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
  91. package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  92. package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  93. package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  94. package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  95. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  96. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  97. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  98. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  99. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  100. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  101. package/src/generators/application/files/app/android/app/src/main/res/values/strings.xml.template +3 -0
  102. package/src/generators/application/files/app/android/app/src/main/res/values/styles.xml +9 -0
  103. package/src/generators/application/files/app/android/app/src/main/res/xml/network_security_config.xml +7 -0
  104. package/src/generators/application/files/app/android/build.gradle.template +21 -0
  105. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  106. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  107. package/src/generators/application/files/app/android/gradle.properties +41 -0
  108. package/src/generators/application/files/app/android/gradlew.bat +92 -0
  109. package/src/generators/application/files/app/android/gradlew.template +249 -0
  110. package/src/generators/application/files/app/android/settings.gradle.template +4 -0
  111. package/src/generators/application/files/app/app.json.template +4 -0
  112. package/src/generators/application/files/app/ios/.xcode.env.template +12 -0
  113. package/src/generators/application/files/app/ios/Podfile.template +55 -0
  114. package/src/generators/application/files/app/ios/__className__/AppDelegate.h +6 -0
  115. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +31 -0
  116. package/src/generators/application/files/app/ios/__className__/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  117. package/src/generators/application/files/app/ios/__className__/Images.xcassets/Contents.json +6 -0
  118. package/src/generators/application/files/app/ios/__className__/Info.plist.template +52 -0
  119. package/src/generators/application/files/app/ios/__className__/LaunchScreen.storyboard.template +47 -0
  120. package/src/generators/application/files/app/ios/__className__/main.m +10 -0
  121. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +684 -0
  122. package/src/generators/application/files/app/ios/__className__.xcodeproj/xcshareddata/xcschemes/__className__.xcscheme.template +88 -0
  123. package/src/generators/application/files/app/ios/__className__.xcworkspace/contents.xcworkspacedata +10 -0
  124. package/src/generators/application/files/app/ios/__className__Tests/Info.plist +24 -0
  125. package/src/generators/application/files/app/ios/__className__Tests/__className__Tests.m +66 -0
  126. package/src/generators/application/files/app/metro.config.js.template +31 -0
  127. package/src/generators/application/files/app/package.json.template +14 -0
  128. package/src/generators/application/files/app/src/app/App.spec.tsx.template +9 -0
  129. package/src/generators/application/files/app/src/app/App.tsx.template +731 -0
  130. package/src/generators/application/files/app/src/main.tsx.template +4 -0
  131. package/src/generators/application/files/app/test-setup.ts.template +1 -0
  132. package/src/generators/application/files/app/tsconfig.app.json.template +10 -0
  133. package/src/generators/application/files/app/tsconfig.json.template +19 -0
  134. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  135. package/src/generators/application/lib/add-e2e.js +46 -0
  136. package/src/generators/application/lib/add-project.d.ts +3 -0
  137. package/src/generators/application/lib/add-project.js +91 -0
  138. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  139. package/src/generators/application/lib/create-application-files.js +24 -0
  140. package/src/generators/application/lib/normalize-options.d.ts +17 -0
  141. package/src/generators/application/lib/normalize-options.js +47 -0
  142. package/src/generators/application/lib/normalize-options.spec.ts +196 -0
  143. package/src/generators/application/schema.d.ts +23 -0
  144. package/src/generators/application/schema.json +103 -0
  145. package/src/generators/component/component.d.ts +5 -0
  146. package/src/generators/component/component.js +64 -0
  147. package/src/generators/component/component.spec.ts +127 -0
  148. package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +11 -0
  149. package/src/generators/component/files/__fileName__.tsx__tmpl__ +32 -0
  150. package/src/generators/component/lib/add-import.d.ts +3 -0
  151. package/src/generators/component/lib/add-import.js +33 -0
  152. package/src/generators/component/lib/normalize-options.d.ts +10 -0
  153. package/src/generators/component/lib/normalize-options.js +50 -0
  154. package/src/generators/component/schema.d.ts +24 -0
  155. package/src/generators/component/schema.json +85 -0
  156. package/src/generators/component-story/component-story.d.ts +8 -0
  157. package/src/generators/component-story/component-story.js +15 -0
  158. package/src/generators/component-story/schema.d.ts +6 -0
  159. package/src/generators/component-story/schema.json +42 -0
  160. package/src/generators/init/init.d.ts +6 -0
  161. package/src/generators/init/init.js +78 -0
  162. package/src/generators/init/init.spec.ts +38 -0
  163. package/src/generators/init/lib/add-git-ignore-entry.d.ts +2 -0
  164. package/src/generators/init/lib/add-git-ignore-entry.js +24 -0
  165. package/src/generators/init/lib/gitignore-entries.d.ts +1 -0
  166. package/src/generators/init/lib/gitignore-entries.js +74 -0
  167. package/src/generators/init/schema.d.ts +7 -0
  168. package/src/generators/init/schema.json +35 -0
  169. package/src/generators/library/files/lib/.babelrc.js.template +21 -0
  170. package/src/generators/library/files/lib/README.md +7 -0
  171. package/src/generators/library/files/lib/package.json.template +4 -0
  172. package/src/generators/library/files/lib/src/index.ts.template +0 -0
  173. package/src/generators/library/files/lib/test-setup.ts.template +1 -0
  174. package/src/generators/library/files/lib/tsconfig.json.template +16 -0
  175. package/src/generators/library/files/lib/tsconfig.lib.json.template +9 -0
  176. package/src/generators/library/lib/normalize-options.d.ts +12 -0
  177. package/src/generators/library/lib/normalize-options.js +33 -0
  178. package/src/generators/library/library.d.ts +5 -0
  179. package/src/generators/library/library.js +154 -0
  180. package/src/generators/library/library.spec.ts +420 -0
  181. package/src/generators/library/schema.d.ts +25 -0
  182. package/src/generators/library/schema.json +107 -0
  183. package/src/generators/stories/schema.d.ts +7 -0
  184. package/src/generators/stories/schema.json +58 -0
  185. package/src/generators/stories/stories.d.ts +8 -0
  186. package/src/generators/stories/stories.js +13 -0
  187. package/src/generators/storybook-configuration/configuration.d.ts +9 -0
  188. package/src/generators/storybook-configuration/configuration.js +26 -0
  189. package/src/generators/storybook-configuration/schema.d.ts +13 -0
  190. package/src/generators/storybook-configuration/schema.json +79 -0
  191. package/src/generators/upgrade-native/lib/create-native-files.d.ts +3 -0
  192. package/src/generators/upgrade-native/lib/create-native-files.js +14 -0
  193. package/src/generators/upgrade-native/lib/normalize-options.d.ts +12 -0
  194. package/src/generators/upgrade-native/lib/normalize-options.js +27 -0
  195. package/src/generators/upgrade-native/schema.d.ts +9 -0
  196. package/src/generators/upgrade-native/schema.json +41 -0
  197. package/src/generators/upgrade-native/upgrade-native.d.ts +10 -0
  198. package/src/generators/upgrade-native/upgrade-native.js +31 -0
  199. package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +23 -0
  200. package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +15 -0
  201. package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
  202. package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
  203. package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +9 -0
  204. package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +82 -0
  205. package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +23 -0
  206. package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
  207. package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
  208. package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +14 -0
  209. package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +9 -0
  210. package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +77 -0
  211. package/src/generators/web-configuration/lib/normalize-schema.d.ts +17 -0
  212. package/src/generators/web-configuration/lib/normalize-schema.js +16 -0
  213. package/src/generators/web-configuration/lib/webpack-targets.d.ts +7 -0
  214. package/src/generators/web-configuration/lib/webpack-targets.js +75 -0
  215. package/src/generators/web-configuration/schema.d.ts +6 -0
  216. package/src/generators/web-configuration/schema.json +42 -0
  217. package/src/generators/web-configuration/web-configuration.d.ts +12 -0
  218. package/src/generators/web-configuration/web-configuration.js +87 -0
  219. package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +2 -0
  220. package/src/migrations/update-15-0-0/add-babel-inputs.js +9 -0
  221. package/src/migrations/update-15-0-0/add-babel-inputs.spec.ts +73 -0
  222. package/src/migrations/update-15-9-1/add-build-ios-target.d.ts +5 -0
  223. package/src/migrations/update-15-9-1/add-build-ios-target.js +29 -0
  224. package/src/migrations/update-15-9-1/add-build-ios-target.spec.ts +36 -0
  225. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  226. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  227. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +37 -0
  228. package/src/migrations/update-16-1-0/upgrade-storybook-6-5.d.ts +6 -0
  229. package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +21 -0
  230. package/src/migrations/update-16-6-0/add-depends-on.d.ts +6 -0
  231. package/src/migrations/update-16-6-0/add-depends-on.js +63 -0
  232. package/src/migrations/update-16-6-0/update-metro-config.d.ts +6 -0
  233. package/src/migrations/update-16-6-0/update-metro-config.js +63 -0
  234. package/src/migrations/update-16-9-0/remove-types-react-native.d.ts +7 -0
  235. package/src/migrations/update-16-9-0/remove-types-react-native.js +13 -0
  236. package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +6 -0
  237. package/src/migrations/update-18-0-0/add-upgrade-target.js +33 -0
  238. package/src/migrations/update-18-0-0/add-web-configuration.d.ts +8 -0
  239. package/src/migrations/update-18-0-0/add-web-configuration.js +33 -0
  240. package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +39 -0
  241. package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +5 -0
  242. package/src/migrations/update-18-0-0/change-storybook-targets.js +57 -0
  243. package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
  244. package/src/migrations/update-18-0-0/remove-block-list.js +28 -0
  245. package/src/migrations/update-18-0-0/remove-block-list.spec.ts +68 -0
  246. package/src/migrations/update-18-0-0/remove-metro.d.ts +14 -0
  247. package/src/migrations/update-18-0-0/remove-metro.js +29 -0
  248. package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
  249. package/src/migrations/update-18-0-0/remove-symlink-target.js +30 -0
  250. package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +40 -0
  251. package/src/utils/add-jest.d.ts +2 -0
  252. package/src/utils/add-jest.js +48 -0
  253. package/src/utils/add-linting.d.ts +13 -0
  254. package/src/utils/add-linting.js +36 -0
  255. package/src/utils/add-linting.spec.ts +40 -0
  256. package/src/utils/chmod-android-gradle-files.d.ts +3 -0
  257. package/src/utils/chmod-android-gradle-files.js +27 -0
  258. package/src/utils/ensure-dependencies.d.ts +2 -0
  259. package/src/utils/ensure-dependencies.js +30 -0
  260. package/src/utils/ensure-node-modules-symlink.d.ts +9 -0
  261. package/src/utils/ensure-node-modules-symlink.js +28 -0
  262. package/src/utils/ensure-node-modules-symlink.spec.ts +108 -0
  263. package/src/utils/find-all-npm-dependencies.d.ts +2 -0
  264. package/src/utils/find-all-npm-dependencies.js +27 -0
  265. package/src/utils/find-all-npm-dependencies.spec.ts +103 -0
  266. package/src/utils/format-file.d.ts +1 -0
  267. package/src/utils/format-file.js +16 -0
  268. package/src/utils/get-cli-options.d.ts +8 -0
  269. package/src/utils/get-cli-options.js +33 -0
  270. package/src/utils/pod-install-task.d.ts +18 -0
  271. package/src/utils/pod-install-task.js +73 -0
  272. package/src/utils/testing-generators.d.ts +3 -0
  273. package/src/utils/testing-generators.js +32 -0
  274. package/src/utils/versions.d.ts +17 -0
  275. package/src/utils/versions.js +20 -0
  276. package/typings/svg.d.ts +7 -0
@@ -0,0 +1,42 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NxReactNativeWebConfiguration",
4
+ "description": "Setup web configuration to React Native apps using react-native-web.",
5
+ "title": "Nx React Native Web configuration",
6
+ "type": "object",
7
+ "properties": {
8
+ "project": {
9
+ "type": "string",
10
+ "aliases": ["name", "projectName"],
11
+ "description": "Project for which to generate web configuration.",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "For which project do you want to generate web configuration?",
17
+ "x-dropdown": "projects",
18
+ "x-priority": "important"
19
+ },
20
+ "skipFormat": {
21
+ "description": "Skip formatting files.",
22
+ "type": "boolean",
23
+ "default": false,
24
+ "x-priority": "internal"
25
+ },
26
+ "skipPackageJson": {
27
+ "description": "Do not add dependencies to `package.json`.",
28
+ "type": "boolean",
29
+ "default": false,
30
+ "x-priority": "internal"
31
+ },
32
+ "bundler": {
33
+ "description": "The bundler to use.",
34
+ "type": "string",
35
+ "enum": ["vite", "webpack"],
36
+ "x-prompt": "Which bundler do you want to use to build the application?",
37
+ "default": "webpack",
38
+ "x-priority": "important"
39
+ }
40
+ },
41
+ "required": ["project", "bundler"]
42
+ }
@@ -0,0 +1,12 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { WebConfigurationGeneratorSchema } from './schema';
3
+ /**
4
+ * This function sets web configuration for react native apps with react-native-web.
5
+ * 1. install react-native-web
6
+ * 2. apply webpack or vite init generator
7
+ * 3. create files for webpack or vite config, index.html, assets folder, babel.config.js
8
+ * @param tree
9
+ * @param options
10
+ */
11
+ export declare function webConfigurationGenerator(tree: Tree, options: WebConfigurationGeneratorSchema): Promise<GeneratorCallback>;
12
+ export default webConfigurationGenerator;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webConfigurationGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const has_webpack_plugin_1 = require("@nx/react/src/utils/has-webpack-plugin");
6
+ const versions_1 = require("../../utils/versions");
7
+ const normalize_schema_1 = require("./lib/normalize-schema");
8
+ const webpack_targets_1 = require("./lib/webpack-targets");
9
+ /**
10
+ * This function sets web configuration for react native apps with react-native-web.
11
+ * 1. install react-native-web
12
+ * 2. apply webpack or vite init generator
13
+ * 3. create files for webpack or vite config, index.html, assets folder, babel.config.js
14
+ * @param tree
15
+ * @param options
16
+ */
17
+ async function webConfigurationGenerator(tree, options) {
18
+ const normalizedSchema = (0, normalize_schema_1.normalizeSchema)(tree, options);
19
+ const tasks = [];
20
+ // install react-native-web
21
+ if (!options.skipPackageJson) {
22
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
23
+ 'react-native-web': versions_1.reactNativeWebVersion,
24
+ });
25
+ tasks.push(installTask);
26
+ }
27
+ // apply webpack or vite init generator
28
+ const bundlerTask = await addBundlerConfiguration(tree, normalizedSchema);
29
+ tasks.push(bundlerTask);
30
+ // create files for webpack and vite config, index.html
31
+ if (normalizedSchema.bundler === 'vite') {
32
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/base-vite'), normalizedSchema.projectRoot, { ...normalizedSchema, tmpl: '' });
33
+ }
34
+ else {
35
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, './files/base-webpack'), normalizedSchema.projectRoot, {
36
+ ...normalizedSchema,
37
+ tmpl: '',
38
+ webpackPluginOptions: (0, has_webpack_plugin_1.hasWebpackPlugin)(tree)
39
+ ? (0, webpack_targets_1.createNxWebpackPluginOptions)(normalizedSchema)
40
+ : null,
41
+ });
42
+ }
43
+ if (!options.skipFormat) {
44
+ await (0, devkit_1.formatFiles)(tree);
45
+ }
46
+ return (0, devkit_1.runTasksInSerial)(...tasks);
47
+ }
48
+ exports.webConfigurationGenerator = webConfigurationGenerator;
49
+ /**
50
+ * Add bundler configuration
51
+ * - for vite, viteConfigurationGenerator contains logics to add build and serve target
52
+ * - for webpack, need to explict add the build and serve target
53
+ */
54
+ async function addBundlerConfiguration(tree, normalizedSchema) {
55
+ if (normalizedSchema.bundler === 'vite') {
56
+ const { viteConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', versions_1.nxVersion);
57
+ const viteTask = await viteConfigurationGenerator(tree, {
58
+ ...normalizedSchema,
59
+ uiFramework: 'react',
60
+ project: normalizedSchema.project,
61
+ newProject: true,
62
+ includeVitest: false,
63
+ compiler: 'babel',
64
+ skipFormat: true,
65
+ });
66
+ return viteTask;
67
+ }
68
+ else {
69
+ const { webpackInitGenerator } = (0, devkit_1.ensurePackage)('@nx/webpack', versions_1.nxVersion);
70
+ const webpackInitTask = await webpackInitGenerator(tree, {
71
+ ...normalizedSchema,
72
+ skipFormat: true,
73
+ skipPackageJson: normalizedSchema.skipPackageJson,
74
+ });
75
+ if (!(0, has_webpack_plugin_1.hasWebpackPlugin)(tree)) {
76
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, normalizedSchema.project);
77
+ projectConfiguration.targets = {
78
+ ...projectConfiguration.targets,
79
+ build: (0, webpack_targets_1.createBuildTarget)(normalizedSchema),
80
+ serve: (0, webpack_targets_1.createServeTarget)(normalizedSchema),
81
+ };
82
+ (0, devkit_1.updateProjectConfiguration)(tree, normalizedSchema.project, projectConfiguration);
83
+ }
84
+ return webpackInitTask;
85
+ }
86
+ }
87
+ exports.default = webConfigurationGenerator;
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function (tree: Tree): Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
5
+ async function default_1(tree) {
6
+ (0, add_babel_inputs_1.addBabelInputs)(tree);
7
+ await (0, devkit_1.formatFiles)(tree);
8
+ }
9
+ exports.default = default_1;
@@ -0,0 +1,73 @@
1
+ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
2
+ import { Tree, readNxJson, updateNxJson } from '@nx/devkit';
3
+ import addBabelInputs from './add-babel-inputs';
4
+
5
+ describe('15.0.0 migration (add-babel-inputs)', () => {
6
+ let tree: Tree;
7
+
8
+ beforeEach(() => {
9
+ tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10
+ });
11
+
12
+ it('should add babel.config.json to sharedGlobals', async () => {
13
+ updateNxJson(tree, {
14
+ namedInputs: {
15
+ default: ['{projectRoot}/**/*', 'sharedGlobals'],
16
+ sharedGlobals: [],
17
+ production: ['default'],
18
+ },
19
+ });
20
+ tree.write('babel.config.json', '');
21
+
22
+ await addBabelInputs(tree);
23
+
24
+ const updated = readNxJson(tree);
25
+ expect(updated).toMatchInlineSnapshot(`
26
+ {
27
+ "namedInputs": {
28
+ "default": [
29
+ "{projectRoot}/**/*",
30
+ "sharedGlobals",
31
+ ],
32
+ "production": [
33
+ "default",
34
+ ],
35
+ "sharedGlobals": [
36
+ "{workspaceRoot}/babel.config.json",
37
+ ],
38
+ },
39
+ }
40
+ `);
41
+ });
42
+
43
+ it('should add babel.config.js', async () => {
44
+ updateNxJson(tree, {
45
+ namedInputs: {
46
+ default: ['{projectRoot}/**/*', 'sharedGlobals'],
47
+ sharedGlobals: [],
48
+ production: ['default'],
49
+ },
50
+ });
51
+ tree.write('babel.config.js', '');
52
+
53
+ await addBabelInputs(tree);
54
+
55
+ const updated = readNxJson(tree);
56
+ expect(updated).toMatchInlineSnapshot(`
57
+ {
58
+ "namedInputs": {
59
+ "default": [
60
+ "{projectRoot}/**/*",
61
+ "sharedGlobals",
62
+ ],
63
+ "production": [
64
+ "default",
65
+ ],
66
+ "sharedGlobals": [
67
+ "{workspaceRoot}/babel.config.js",
68
+ ],
69
+ },
70
+ }
71
+ `);
72
+ });
73
+ });
@@ -0,0 +1,5 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Add build-ios target for react-native
4
+ */
5
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ /**
5
+ * Add build-ios target for react-native
6
+ */
7
+ async function update(tree) {
8
+ const projects = (0, devkit_1.getProjects)(tree);
9
+ for (const [name, config] of projects.entries()) {
10
+ if (config.targets?.['start']?.executor === '@nrwl/react-native:start') {
11
+ if (!config.targets['build-ios']) {
12
+ config.targets['build-ios'] = {
13
+ executor: '@nrwl/react-native:build-ios',
14
+ outputs: ['{projectRoot}/ios/build/Build'],
15
+ options: {},
16
+ };
17
+ }
18
+ if (!config.targets['pod-install']) {
19
+ config.targets['pod-install'] = {
20
+ executor: '@nrwl/react-native:pod-install',
21
+ options: {},
22
+ };
23
+ }
24
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
25
+ }
26
+ }
27
+ await (0, devkit_1.formatFiles)(tree);
28
+ }
29
+ exports.default = update;
@@ -0,0 +1,36 @@
1
+ import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
2
+ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
+ import update from './add-build-ios-target';
4
+
5
+ describe('add-build-ios-target', () => {
6
+ let tree: Tree;
7
+
8
+ beforeEach(async () => {
9
+ tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10
+ addProjectConfiguration(tree, 'product', {
11
+ root: 'apps/product',
12
+ sourceRoot: 'apps/product/src',
13
+ targets: {
14
+ start: {
15
+ executor: '@nrwl/react-native:start',
16
+ },
17
+ },
18
+ });
19
+ });
20
+
21
+ it(`should update project.json with target build-ios and pod-install`, async () => {
22
+ await update(tree);
23
+
24
+ getProjects(tree).forEach((project) => {
25
+ expect(project.targets['build-ios']).toEqual({
26
+ executor: '@nrwl/react-native:build-ios',
27
+ outputs: ['{projectRoot}/ios/build/Build'],
28
+ options: {},
29
+ });
30
+ expect(project.targets['pod-install']).toEqual({
31
+ executor: '@nrwl/react-native:pod-install',
32
+ options: {},
33
+ });
34
+ });
35
+ });
36
+ });
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function replacePackage(tree: Tree): Promise<void>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
5
+ async function replacePackage(tree) {
6
+ await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/react-native', '@nx/react-native');
7
+ await (0, devkit_1.formatFiles)(tree);
8
+ }
9
+ exports.default = replacePackage;
@@ -0,0 +1,37 @@
1
+ import { Tree, readJson, updateJson } from '@nx/devkit';
2
+ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
+ import replacePackage from './update-16-0-0-add-nx-packages';
4
+
5
+ describe('update-16-0-0-add-nx-packages', () => {
6
+ let tree: Tree;
7
+ beforeEach(() => {
8
+ tree = createTreeWithEmptyWorkspace();
9
+
10
+ updateJson(tree, 'package.json', (json) => {
11
+ json.devDependencies['@nrwl/react-native'] = '16.0.0';
12
+ return json;
13
+ });
14
+ });
15
+
16
+ it('should remove the dependency on @nrwl/react-native', async () => {
17
+ await replacePackage(tree);
18
+
19
+ expect(
20
+ readJson(tree, 'package.json').dependencies['@nrwl/react-native']
21
+ ).not.toBeDefined();
22
+ expect(
23
+ readJson(tree, 'package.json').devDependencies['@nrwl/react-native']
24
+ ).not.toBeDefined();
25
+ });
26
+
27
+ it('should add a dependency on @nx/react-native', async () => {
28
+ await replacePackage(tree);
29
+
30
+ const packageJson = readJson(tree, 'package.json');
31
+ const newDependencyVersion =
32
+ packageJson.devDependencies['@nx/react-native'] ??
33
+ packageJson.dependencies['@nx/react-native'];
34
+
35
+ expect(newDependencyVersion).toBeDefined();
36
+ });
37
+ });
@@ -0,0 +1,6 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * This migration is to upgrade storybook to 6.5.
4
+ * - remove react-native-storybook-loader
5
+ */
6
+ export default function update(tree: Tree): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ /**
5
+ * This migration is to upgrade storybook to 6.5.
6
+ * - remove react-native-storybook-loader
7
+ */
8
+ function update(tree) {
9
+ if (tree.exists('package.json')) {
10
+ (0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
11
+ if (packageJson.dependencies?.['react-native-storybook-loader']) {
12
+ delete packageJson.dependencies['react-native-storybook-loader'];
13
+ }
14
+ if (packageJson.devDependencies?.['react-native-storybook-loader']) {
15
+ delete packageJson.devDependencies['react-native-storybook-loader'];
16
+ }
17
+ return packageJson;
18
+ });
19
+ }
20
+ }
21
+ exports.default = update;
@@ -0,0 +1,6 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * This migration adds dependsOn to project.json.
4
+ *
5
+ */
6
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ /**
5
+ * This migration adds dependsOn to project.json.
6
+ *
7
+ */
8
+ async function update(tree) {
9
+ const projects = (0, devkit_1.getProjects)(tree);
10
+ for (const [name, config] of projects.entries()) {
11
+ if (config.targets?.['start']?.executor === '@nx/react-native:start') {
12
+ config.targets['start'].dependsOn = [
13
+ 'ensure-symlink',
14
+ 'sync-deps',
15
+ 'pod-install',
16
+ ];
17
+ if (config.targets?.['run-ios']?.executor === '@nx/react-native:run-ios') {
18
+ config.targets['run-ios'].dependsOn = [
19
+ 'ensure-symlink',
20
+ 'sync-deps',
21
+ 'pod-install',
22
+ ];
23
+ }
24
+ if (config.targets?.['bundle-ios']?.executor === '@nx/react-native:bundle') {
25
+ config.targets['bundle-ios'].dependsOn = ['ensure-symlink'];
26
+ }
27
+ if (config.targets?.['run-android']?.executor ===
28
+ '@nx/react-native:run-android') {
29
+ config.targets['run-android'].dependsOn ??= [
30
+ 'ensure-symlink',
31
+ 'sync-deps',
32
+ ];
33
+ }
34
+ if (config.targets?.['build-android']?.executor ===
35
+ '@nx/react-native:build-android') {
36
+ config.targets['build-android'].dependsOn = [
37
+ 'ensure-symlink',
38
+ 'sync-deps',
39
+ ];
40
+ }
41
+ if (config.targets?.['build-ios']?.executor === '@nx/react-native:build-ios') {
42
+ config.targets['build-ios'].dependsOn ??= [
43
+ 'ensure-symlink',
44
+ 'sync-deps',
45
+ 'pod-install',
46
+ ];
47
+ }
48
+ if (config.targets?.['pod-instal']?.executor ===
49
+ '@nx/react-native:pod-install') {
50
+ config.targets['pod-install'].dependsOn ??= [
51
+ 'ensure-symlink',
52
+ 'sync-deps',
53
+ ];
54
+ }
55
+ if (config.targets?.['bundle-android']?.executor ===
56
+ '@nx/react-native:bundle') {
57
+ config.targets['bundle-android'].dependsOn ??= ['ensure-symlink'];
58
+ }
59
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
60
+ }
61
+ }
62
+ }
63
+ exports.default = update;
@@ -0,0 +1,6 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * This migration updates metro.config.js to export config as a default.
4
+ *
5
+ */
6
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const path_1 = require("path");
5
+ /**
6
+ * This migration updates metro.config.js to export config as a default.
7
+ *
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, path_1.join)(config.root, 'metro.config.js'))) {
14
+ const oldConfig = tree
15
+ .read((0, path_1.join)(config.root, 'metro.config.js'))
16
+ .toString();
17
+ tree.write((0, path_1.join)(config.root, 'metro-v71.config.js'), oldConfigComment + oldConfig);
18
+ tree.write((0, path_1.join)(config.root, 'metro.config.js'), content);
19
+ }
20
+ }
21
+ }
22
+ }
23
+ exports.default = update;
24
+ const oldConfigComment = `/**
25
+ * Old custom configuration for React Native v0.71.
26
+ * From @react-native/metro-config 0.72.1, it is no longer necessary to use a config function to access the complete default config.
27
+ * Please port your custom configuration to metro.config.js.
28
+ * Please see https://reactnative.dev/docs/metro to learn about configuration.
29
+ */
30
+ `;
31
+ const content = `
32
+ const { withNxMetro } = require('@nx/react-native');
33
+ const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
34
+
35
+ const defaultConfig = getDefaultConfig(__dirname);
36
+ const { assetExts, sourceExts } = defaultConfig.resolver;
37
+
38
+ /**
39
+ * Metro configuration
40
+ * https://facebook.github.io/metro/docs/configuration
41
+ *
42
+ * @type {import('metro-config').MetroConfig}
43
+ */
44
+ const customConfig = {
45
+ transformer: {
46
+ babelTransformerPath: require.resolve('react-native-svg-transformer'),
47
+ },
48
+ resolver: {
49
+ assetExts: assetExts.filter((ext) => ext !== 'svg'),
50
+ sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg'],
51
+ },
52
+ };
53
+
54
+ module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
55
+ // Change this to true to see debugging info.
56
+ // Useful if you have issues resolving modules
57
+ debug: false,
58
+ // all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
59
+ extensions: [],
60
+ // Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
61
+ watchFolders: [],
62
+ });
63
+ `;
@@ -0,0 +1,7 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Remove @types/react-native package since it is no longer required. It would be a part of react native package.
4
+ * @param tree
5
+ * @returns
6
+ */
7
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ /**
5
+ * Remove @types/react-native package since it is no longer required. It would be a part of react native package.
6
+ * @param tree
7
+ * @returns
8
+ */
9
+ async function update(tree) {
10
+ (0, devkit_1.removeDependenciesFromPackageJson)(tree, [], ['@types/react-native']);
11
+ await (0, devkit_1.formatFiles)(tree);
12
+ }
13
+ exports.default = update;
@@ -0,0 +1,6 @@
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>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const upgrade_impl_1 = require("../../executors/upgrade/upgrade.impl");
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
+ await (0, upgrade_impl_1.runCliUpgrade)(devkit_1.workspaceRoot, config.root);
19
+ }
20
+ if (config.targets?.['pod-install']?.executor ===
21
+ '@nx/react-native:pod-install') {
22
+ for (const targetName in config.targets) {
23
+ if (config.targets[targetName]?.dependsOn?.length) {
24
+ config.targets[targetName].dependsOn = config.targets[targetName].dependsOn.filter((dependsOn) => dependsOn !== 'pod-install');
25
+ }
26
+ }
27
+ }
28
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
29
+ }
30
+ }
31
+ await (0, devkit_1.formatFiles)(tree);
32
+ }
33
+ exports.default = update;
@@ -0,0 +1,8 @@
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>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const web_configuration_1 = require("../../generators/web-configuration/web-configuration");
5
+ /**
6
+ * Add web configuration to react native projects
7
+ * - delete the current serve target which is just a pass-through to start target
8
+ * - rename the babel.config.json to to babel-v72.config.json
9
+ * - add web confiugration, it will add .babelrc.js
10
+ */
11
+ async function update(tree) {
12
+ const projects = (0, devkit_1.getProjects)(tree);
13
+ const tasks = [];
14
+ for (const [projectName, config] of projects.entries()) {
15
+ if (config.targets?.['start']?.executor === '@nx/react-native:start') {
16
+ if (config.targets['serve'] &&
17
+ config.targets['serve'].executor === 'nx:run-commands' &&
18
+ config.targets['serve'].options?.command?.startsWith('nx start')) {
19
+ delete config.targets['serve'];
20
+ (0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
21
+ }
22
+ if (tree.exists((0, devkit_1.joinPathFragments)(config.root, 'babel.config.json'))) {
23
+ tree.rename((0, devkit_1.joinPathFragments)(config.root, 'babel.config.json'), (0, devkit_1.joinPathFragments)(config.root, 'babel-v72.config.json'));
24
+ }
25
+ tasks.push(await (0, web_configuration_1.default)(tree, {
26
+ project: config.name,
27
+ bundler: 'webpack',
28
+ }));
29
+ }
30
+ }
31
+ return (0, devkit_1.runTasksInSerial)(...tasks);
32
+ }
33
+ exports.default = update;