@nx/react-native 16.0.0-beta.1

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 (368) hide show
  1. package/.eslintrc.json +19 -0
  2. package/CHANGELOG.md +8 -0
  3. package/LICENSE +22 -0
  4. package/README.md +63 -0
  5. package/executors.json +106 -0
  6. package/generators.json +109 -0
  7. package/index.d.ts +5 -0
  8. package/index.js +14 -0
  9. package/index.js.map +1 -0
  10. package/migrations.json +1291 -0
  11. package/package.json +58 -0
  12. package/plugins/jest/svg-mock.d.ts +0 -0
  13. package/plugins/jest/svg-mock.js +4 -0
  14. package/plugins/jest/svg-mock.js.map +1 -0
  15. package/plugins/metro-resolver.d.ts +1 -0
  16. package/plugins/metro-resolver.js +135 -0
  17. package/plugins/metro-resolver.js.map +1 -0
  18. package/plugins/with-nx-metro.d.ts +8 -0
  19. package/plugins/with-nx-metro.js +32 -0
  20. package/plugins/with-nx-metro.js.map +1 -0
  21. package/project.json +64 -0
  22. package/src/executors/build-android/build-android.impl.d.ts +6 -0
  23. package/src/executors/build-android/build-android.impl.js +76 -0
  24. package/src/executors/build-android/build-android.impl.js.map +1 -0
  25. package/src/executors/build-android/build-android.impl.ts +108 -0
  26. package/src/executors/build-android/compat.d.ts +2 -0
  27. package/src/executors/build-android/compat.js +6 -0
  28. package/src/executors/build-android/compat.js.map +1 -0
  29. package/src/executors/build-android/schema.d.ts +31 -0
  30. package/src/executors/build-android/schema.json +102 -0
  31. package/src/executors/build-ios/build-ios.impl.d.ts +6 -0
  32. package/src/executors/build-ios/build-ios.impl.js +77 -0
  33. package/src/executors/build-ios/build-ios.impl.js.map +1 -0
  34. package/src/executors/build-ios/build-ios.impl.ts +118 -0
  35. package/src/executors/build-ios/compat.d.ts +2 -0
  36. package/src/executors/build-ios/compat.js +6 -0
  37. package/src/executors/build-ios/compat.js.map +1 -0
  38. package/src/executors/build-ios/schema.d.ts +22 -0
  39. package/src/executors/build-ios/schema.json +106 -0
  40. package/src/executors/bundle/bundle.impl.d.ts +6 -0
  41. package/src/executors/bundle/bundle.impl.js +58 -0
  42. package/src/executors/bundle/bundle.impl.js.map +1 -0
  43. package/src/executors/bundle/bundle.impl.ts +76 -0
  44. package/src/executors/bundle/compat.d.ts +2 -0
  45. package/src/executors/bundle/compat.js +6 -0
  46. package/src/executors/bundle/compat.js.map +1 -0
  47. package/src/executors/bundle/schema.d.ts +16 -0
  48. package/src/executors/bundle/schema.json +92 -0
  49. package/src/executors/ensure-symlink/compat.d.ts +2 -0
  50. package/src/executors/ensure-symlink/compat.js +6 -0
  51. package/src/executors/ensure-symlink/compat.js.map +1 -0
  52. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +5 -0
  53. package/src/executors/ensure-symlink/ensure-symlink.impl.js +13 -0
  54. package/src/executors/ensure-symlink/ensure-symlink.impl.js.map +1 -0
  55. package/src/executors/ensure-symlink/ensure-symlink.impl.ts +18 -0
  56. package/src/executors/ensure-symlink/schema.json +11 -0
  57. package/src/executors/pod-install/compat.d.ts +2 -0
  58. package/src/executors/pod-install/compat.js +6 -0
  59. package/src/executors/pod-install/compat.js.map +1 -0
  60. package/src/executors/pod-install/pod-install.impl.d.ts +6 -0
  61. package/src/executors/pod-install/pod-install.impl.js +15 -0
  62. package/src/executors/pod-install/pod-install.impl.js.map +1 -0
  63. package/src/executors/pod-install/pod-install.impl.ts +21 -0
  64. package/src/executors/pod-install/schema.d.ts +3 -0
  65. package/src/executors/pod-install/schema.json +18 -0
  66. package/src/executors/run-android/compat.d.ts +2 -0
  67. package/src/executors/run-android/compat.js +6 -0
  68. package/src/executors/run-android/compat.js.map +1 -0
  69. package/src/executors/run-android/run-android.impl.d.ts +6 -0
  70. package/src/executors/run-android/run-android.impl.js +72 -0
  71. package/src/executors/run-android/run-android.impl.js.map +1 -0
  72. package/src/executors/run-android/run-android.impl.ts +110 -0
  73. package/src/executors/run-android/schema.d.ts +24 -0
  74. package/src/executors/run-android/schema.json +121 -0
  75. package/src/executors/run-ios/compat.d.ts +2 -0
  76. package/src/executors/run-ios/compat.js +6 -0
  77. package/src/executors/run-ios/compat.js.map +1 -0
  78. package/src/executors/run-ios/run-ios.impl.d.ts +6 -0
  79. package/src/executors/run-ios/run-ios.impl.js +78 -0
  80. package/src/executors/run-ios/run-ios.impl.js.map +1 -0
  81. package/src/executors/run-ios/run-ios.impl.ts +120 -0
  82. package/src/executors/run-ios/schema.d.ts +12 -0
  83. package/src/executors/run-ios/schema.json +119 -0
  84. package/src/executors/start/compat.d.ts +2 -0
  85. package/src/executors/start/compat.js +6 -0
  86. package/src/executors/start/compat.js.map +1 -0
  87. package/src/executors/start/lib/is-packager-running.d.ts +1 -0
  88. package/src/executors/start/lib/is-packager-running.js +19 -0
  89. package/src/executors/start/lib/is-packager-running.js.map +1 -0
  90. package/src/executors/start/schema.d.ts +7 -0
  91. package/src/executors/start/schema.json +28 -0
  92. package/src/executors/start/start.impl.d.ts +8 -0
  93. package/src/executors/start/start.impl.js +99 -0
  94. package/src/executors/start/start.impl.js.map +1 -0
  95. package/src/executors/start/start.impl.ts +120 -0
  96. package/src/executors/storybook/compat.d.ts +2 -0
  97. package/src/executors/storybook/compat.js +6 -0
  98. package/src/executors/storybook/compat.js.map +1 -0
  99. package/src/executors/storybook/schema.d.ts +7 -0
  100. package/src/executors/storybook/schema.json +34 -0
  101. package/src/executors/storybook/storybook.impl.d.ts +5 -0
  102. package/src/executors/storybook/storybook.impl.js +76 -0
  103. package/src/executors/storybook/storybook.impl.js.map +1 -0
  104. package/src/executors/storybook/storybook.impl.ts +105 -0
  105. package/src/executors/sync-deps/compat.d.ts +2 -0
  106. package/src/executors/sync-deps/compat.js +6 -0
  107. package/src/executors/sync-deps/compat.js.map +1 -0
  108. package/src/executors/sync-deps/schema.d.ts +4 -0
  109. package/src/executors/sync-deps/schema.json +28 -0
  110. package/src/executors/sync-deps/sync-deps.impl.d.ts +8 -0
  111. package/src/executors/sync-deps/sync-deps.impl.js +62 -0
  112. package/src/executors/sync-deps/sync-deps.impl.js.map +1 -0
  113. package/src/executors/sync-deps/sync-deps.impl.ts +101 -0
  114. package/src/generators/application/application.d.ts +5 -0
  115. package/src/generators/application/application.js +40 -0
  116. package/src/generators/application/application.js.map +1 -0
  117. package/src/generators/application/application.spec.ts +214 -0
  118. package/src/generators/application/files/app/.ruby-version +1 -0
  119. package/src/generators/application/files/app/Gemfile.template +6 -0
  120. package/src/generators/application/files/app/android/app/build.gradle.template +184 -0
  121. package/src/generators/application/files/app/android/app/debug.keystore +0 -0
  122. package/src/generators/application/files/app/android/app/proguard-rules.pro +10 -0
  123. package/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +30 -0
  124. package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +14 -0
  125. package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +75 -0
  126. package/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +26 -0
  127. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +35 -0
  128. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +63 -0
  129. package/src/generators/application/files/app/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
  130. package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  131. package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  132. package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  133. package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  134. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  135. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  136. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  137. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  138. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  139. package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  140. package/src/generators/application/files/app/android/app/src/main/res/values/strings.xml.template +3 -0
  141. package/src/generators/application/files/app/android/app/src/main/res/values/styles.xml +9 -0
  142. package/src/generators/application/files/app/android/app/src/main/res/xml/network_security_config.xml +7 -0
  143. package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +20 -0
  144. package/src/generators/application/files/app/android/build.gradle.template +34 -0
  145. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  146. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  147. package/src/generators/application/files/app/android/gradle.properties +44 -0
  148. package/src/generators/application/files/app/android/gradlew.bat +89 -0
  149. package/src/generators/application/files/app/android/gradlew.template +234 -0
  150. package/src/generators/application/files/app/android/settings.gradle.template +7 -0
  151. package/src/generators/application/files/app/app.json.template +4 -0
  152. package/src/generators/application/files/app/babel.config.json.template +3 -0
  153. package/src/generators/application/files/app/ios/.xcode.env.template +12 -0
  154. package/src/generators/application/files/app/ios/Podfile.template +60 -0
  155. package/src/generators/application/files/app/ios/__className__/AppDelegate.h +6 -0
  156. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +36 -0
  157. package/src/generators/application/files/app/ios/__className__/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  158. package/src/generators/application/files/app/ios/__className__/Images.xcassets/Contents.json +6 -0
  159. package/src/generators/application/files/app/ios/__className__/Info.plist.template +55 -0
  160. package/src/generators/application/files/app/ios/__className__/LaunchScreen.storyboard.template +47 -0
  161. package/src/generators/application/files/app/ios/__className__/main.m +10 -0
  162. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +702 -0
  163. package/src/generators/application/files/app/ios/__className__.xcodeproj/xcshareddata/xcschemes/__className__.xcscheme.template +88 -0
  164. package/src/generators/application/files/app/ios/__className__.xcworkspace/contents.xcworkspacedata +10 -0
  165. package/src/generators/application/files/app/ios/__className__Tests/Info.plist +24 -0
  166. package/src/generators/application/files/app/ios/__className__Tests/__className__Tests.m +66 -0
  167. package/src/generators/application/files/app/metro.config.js.template +38 -0
  168. package/src/generators/application/files/app/package.json.template +15 -0
  169. package/src/generators/application/files/app/src/app/App.spec.tsx.template +9 -0
  170. package/src/generators/application/files/app/src/app/App.tsx.template +694 -0
  171. package/src/generators/application/files/app/src/main.tsx.template +4 -0
  172. package/src/generators/application/files/app/test-setup.ts.template +1 -0
  173. package/src/generators/application/files/app/tsconfig.app.json.template +9 -0
  174. package/src/generators/application/files/app/tsconfig.json.template +25 -0
  175. package/src/generators/application/lib/add-detox.d.ts +3 -0
  176. package/src/generators/application/lib/add-detox.js +16 -0
  177. package/src/generators/application/lib/add-detox.js.map +1 -0
  178. package/src/generators/application/lib/add-project.d.ts +3 -0
  179. package/src/generators/application/lib/add-project.js +83 -0
  180. package/src/generators/application/lib/add-project.js.map +1 -0
  181. package/src/generators/application/lib/create-application-files.d.ts +3 -0
  182. package/src/generators/application/lib/create-application-files.js +20 -0
  183. package/src/generators/application/lib/create-application-files.js.map +1 -0
  184. package/src/generators/application/lib/nomalize-options.spec.ts +138 -0
  185. package/src/generators/application/lib/normalize-options.d.ts +13 -0
  186. package/src/generators/application/lib/normalize-options.js +36 -0
  187. package/src/generators/application/lib/normalize-options.js.map +1 -0
  188. package/src/generators/application/schema.d.ts +19 -0
  189. package/src/generators/application/schema.json +89 -0
  190. package/src/generators/component/component.d.ts +5 -0
  191. package/src/generators/component/component.js +53 -0
  192. package/src/generators/component/component.js.map +1 -0
  193. package/src/generators/component/component.spec.ts +135 -0
  194. package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +11 -0
  195. package/src/generators/component/files/__fileName__.tsx__tmpl__ +32 -0
  196. package/src/generators/component/lib/add-import.d.ts +3 -0
  197. package/src/generators/component/lib/add-import.js +34 -0
  198. package/src/generators/component/lib/add-import.js.map +1 -0
  199. package/src/generators/component/lib/normalize-options.d.ts +8 -0
  200. package/src/generators/component/lib/normalize-options.js +58 -0
  201. package/src/generators/component/lib/normalize-options.js.map +1 -0
  202. package/src/generators/component/schema.d.ts +14 -0
  203. package/src/generators/component/schema.json +78 -0
  204. package/src/generators/component-story/component-story.d.ts +8 -0
  205. package/src/generators/component-story/component-story.js +113 -0
  206. package/src/generators/component-story/component-story.js.map +1 -0
  207. package/src/generators/component-story/component-story.spec.ts +433 -0
  208. package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +24 -0
  209. package/src/generators/component-story/schema.d.ts +5 -0
  210. package/src/generators/component-story/schema.json +34 -0
  211. package/src/generators/init/init.d.ts +6 -0
  212. package/src/generators/init/init.js +58 -0
  213. package/src/generators/init/init.js.map +1 -0
  214. package/src/generators/init/init.spec.ts +81 -0
  215. package/src/generators/init/lib/add-git-ignore-entry.d.ts +2 -0
  216. package/src/generators/init/lib/add-git-ignore-entry.js +25 -0
  217. package/src/generators/init/lib/add-git-ignore-entry.js.map +1 -0
  218. package/src/generators/init/lib/gitignore-entries.d.ts +1 -0
  219. package/src/generators/init/lib/gitignore-entries.js +75 -0
  220. package/src/generators/init/lib/gitignore-entries.js.map +1 -0
  221. package/src/generators/init/schema.d.ts +7 -0
  222. package/src/generators/init/schema.json +40 -0
  223. package/src/generators/library/files/lib/README.md +7 -0
  224. package/src/generators/library/files/lib/babel.config.json.template +17 -0
  225. package/src/generators/library/files/lib/package.json__tmpl__ +4 -0
  226. package/src/generators/library/files/lib/src/index.ts__tmpl__ +0 -0
  227. package/src/generators/library/files/lib/test-setup.ts.template +1 -0
  228. package/src/generators/library/files/lib/tsconfig.json__tmpl__ +16 -0
  229. package/src/generators/library/files/lib/tsconfig.lib.json__tmpl__ +9 -0
  230. package/src/generators/library/lib/normalize-options.d.ts +13 -0
  231. package/src/generators/library/lib/normalize-options.js +26 -0
  232. package/src/generators/library/lib/normalize-options.js.map +1 -0
  233. package/src/generators/library/library.d.ts +5 -0
  234. package/src/generators/library/library.js +103 -0
  235. package/src/generators/library/library.js.map +1 -0
  236. package/src/generators/library/library.spec.ts +397 -0
  237. package/src/generators/library/schema.d.ts +22 -0
  238. package/src/generators/library/schema.json +102 -0
  239. package/src/generators/stories/schema.d.ts +5 -0
  240. package/src/generators/stories/schema.json +42 -0
  241. package/src/generators/stories/stories-app.spec.ts +145 -0
  242. package/src/generators/stories/stories-lib.spec.ts +113 -0
  243. package/src/generators/stories/stories.d.ts +6 -0
  244. package/src/generators/stories/stories.js +63 -0
  245. package/src/generators/stories/stories.js.map +1 -0
  246. package/src/generators/storybook-configuration/configuration.d.ts +5 -0
  247. package/src/generators/storybook-configuration/configuration.js +60 -0
  248. package/src/generators/storybook-configuration/configuration.js.map +1 -0
  249. package/src/generators/storybook-configuration/configuration.spec.ts +146 -0
  250. package/src/generators/storybook-configuration/files/app/storybook.ts.template +9 -0
  251. package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +114 -0
  252. package/src/generators/storybook-configuration/files/root/story-loader.js.template +13 -0
  253. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +6 -0
  254. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +26 -0
  255. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js.map +1 -0
  256. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +161 -0
  257. package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +6 -0
  258. package/src/generators/storybook-configuration/lib/create-storybook-files.js +45 -0
  259. package/src/generators/storybook-configuration/lib/create-storybook-files.js.map +1 -0
  260. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +7 -0
  261. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +30 -0
  262. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js.map +1 -0
  263. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +65 -0
  264. package/src/generators/storybook-configuration/schema.d.ts +11 -0
  265. package/src/generators/storybook-configuration/schema.json +66 -0
  266. package/src/generators/upgrade-native/lib/create-native-files.d.ts +3 -0
  267. package/src/generators/upgrade-native/lib/create-native-files.js +15 -0
  268. package/src/generators/upgrade-native/lib/create-native-files.js.map +1 -0
  269. package/src/generators/upgrade-native/lib/normalize-options.d.ts +12 -0
  270. package/src/generators/upgrade-native/lib/normalize-options.js +28 -0
  271. package/src/generators/upgrade-native/lib/normalize-options.js.map +1 -0
  272. package/src/generators/upgrade-native/schema.d.ts +9 -0
  273. package/src/generators/upgrade-native/schema.json +41 -0
  274. package/src/generators/upgrade-native/upgrade-native.d.ts +9 -0
  275. package/src/generators/upgrade-native/upgrade-native.js +33 -0
  276. package/src/generators/upgrade-native/upgrade-native.js.map +1 -0
  277. package/src/migrations/update-12-10-0/add-react-native-svg-12-10-0.d.ts +8 -0
  278. package/src/migrations/update-12-10-0/add-react-native-svg-12-10-0.js +63 -0
  279. package/src/migrations/update-12-10-0/add-react-native-svg-12-10-0.js.map +1 -0
  280. package/src/migrations/update-12-10-0/add-react-native-svg-12-10-0.spec.ts +79 -0
  281. package/src/migrations/update-12-5-0/update-jest-for-react-native.d.ts +2 -0
  282. package/src/migrations/update-12-5-0/update-jest-for-react-native.js +62 -0
  283. package/src/migrations/update-12-5-0/update-jest-for-react-native.js.map +1 -0
  284. package/src/migrations/update-13-5-0/add-babel-config-root-13-5-0.d.ts +2 -0
  285. package/src/migrations/update-13-5-0/add-babel-config-root-13-5-0.js +22 -0
  286. package/src/migrations/update-13-5-0/add-babel-config-root-13-5-0.js.map +1 -0
  287. package/src/migrations/update-13-5-0/add-babel-config-root-13-5-0.spec.ts +48 -0
  288. package/src/migrations/update-13-5-0/update-react-native-typing-svg-13-5-0.d.ts +6 -0
  289. package/src/migrations/update-13-5-0/update-react-native-typing-svg-13-5-0.js +41 -0
  290. package/src/migrations/update-13-5-0/update-react-native-typing-svg-13-5-0.js.map +1 -0
  291. package/src/migrations/update-13-5-0/update-react-native-typing-svg-13-5-0.spec.ts +61 -0
  292. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.d.ts +6 -0
  293. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js +33 -0
  294. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js.map +1 -0
  295. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.spec.ts +192 -0
  296. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.d.ts +5 -0
  297. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js +39 -0
  298. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js.map +1 -0
  299. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.spec.ts +84 -0
  300. package/src/migrations/update-14-0-2/change-main-to-class-name-14-0-2.d.ts +5 -0
  301. package/src/migrations/update-14-0-2/change-main-to-class-name-14-0-2.js +42 -0
  302. package/src/migrations/update-14-0-2/change-main-to-class-name-14-0-2.js.map +1 -0
  303. package/src/migrations/update-14-0-2/change-main-to-class-name-14-0-2.spec.ts +48 -0
  304. package/src/migrations/update-14-2-1/rename-blockList-metro-config.d.ts +6 -0
  305. package/src/migrations/update-14-2-1/rename-blockList-metro-config.js +33 -0
  306. package/src/migrations/update-14-2-1/rename-blockList-metro-config.js.map +1 -0
  307. package/src/migrations/update-14-2-1/rename-blockList-metro-config.spec.ts +190 -0
  308. package/src/migrations/update-14-5-5/add-exclude-sync-deps.d.ts +5 -0
  309. package/src/migrations/update-14-5-5/add-exclude-sync-deps.js +26 -0
  310. package/src/migrations/update-14-5-5/add-exclude-sync-deps.js.map +1 -0
  311. package/src/migrations/update-14-5-5/add-exclude-sync-deps.spec.ts +39 -0
  312. package/src/migrations/update-14-5-8/change-searchDir-storybook.d.ts +5 -0
  313. package/src/migrations/update-14-5-8/change-searchDir-storybook.js +26 -0
  314. package/src/migrations/update-14-5-8/change-searchDir-storybook.js.map +1 -0
  315. package/src/migrations/update-14-5-8/change-searchDir-storybook.spec.ts +39 -0
  316. package/src/migrations/update-14-6-0/remove-jest-transform.d.ts +5 -0
  317. package/src/migrations/update-14-6-0/remove-jest-transform.js +58 -0
  318. package/src/migrations/update-14-6-0/remove-jest-transform.js.map +1 -0
  319. package/src/migrations/update-14-6-0/remove-jest-transform.spec.ts +109 -0
  320. package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +2 -0
  321. package/src/migrations/update-15-0-0/add-babel-inputs.js +13 -0
  322. package/src/migrations/update-15-0-0/add-babel-inputs.js.map +1 -0
  323. package/src/migrations/update-15-0-0/add-babel-inputs.spec.ts +73 -0
  324. package/src/migrations/update-15-9-1/add-build-ios-target.d.ts +5 -0
  325. package/src/migrations/update-15-9-1/add-build-ios-target.js +34 -0
  326. package/src/migrations/update-15-9-1/add-build-ios-target.js.map +1 -0
  327. package/src/migrations/update-15-9-1/add-build-ios-target.spec.ts +36 -0
  328. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  329. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +13 -0
  330. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js.map +1 -0
  331. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +37 -0
  332. package/src/utils/add-jest.d.ts +2 -0
  333. package/src/utils/add-jest.js +38 -0
  334. package/src/utils/add-jest.js.map +1 -0
  335. package/src/utils/add-linting.d.ts +12 -0
  336. package/src/utils/add-linting.js +41 -0
  337. package/src/utils/add-linting.js.map +1 -0
  338. package/src/utils/add-linting.spec.ts +42 -0
  339. package/src/utils/chmod-android-gradle-files.d.ts +3 -0
  340. package/src/utils/chmod-android-gradle-files.js +24 -0
  341. package/src/utils/chmod-android-gradle-files.js.map +1 -0
  342. package/src/utils/ensure-node-modules-symlink.d.ts +9 -0
  343. package/src/utils/ensure-node-modules-symlink.js +29 -0
  344. package/src/utils/ensure-node-modules-symlink.js.map +1 -0
  345. package/src/utils/ensure-node-modules-symlink.spec.ts +108 -0
  346. package/src/utils/find-all-npm-dependencies.d.ts +2 -0
  347. package/src/utils/find-all-npm-dependencies.js +26 -0
  348. package/src/utils/find-all-npm-dependencies.js.map +1 -0
  349. package/src/utils/find-all-npm-dependencies.spec.ts +95 -0
  350. package/src/utils/format-file.d.ts +1 -0
  351. package/src/utils/format-file.js +17 -0
  352. package/src/utils/format-file.js.map +1 -0
  353. package/src/utils/get-cli-options.d.ts +8 -0
  354. package/src/utils/get-cli-options.js +31 -0
  355. package/src/utils/get-cli-options.js.map +1 -0
  356. package/src/utils/pod-install-task.d.ts +8 -0
  357. package/src/utils/pod-install-task.js +62 -0
  358. package/src/utils/pod-install-task.js.map +1 -0
  359. package/src/utils/symlink-task.d.ts +2 -0
  360. package/src/utils/symlink-task.js +19 -0
  361. package/src/utils/symlink-task.js.map +1 -0
  362. package/src/utils/testing-generators.d.ts +3 -0
  363. package/src/utils/testing-generators.js +36 -0
  364. package/src/utils/testing-generators.js.map +1 -0
  365. package/src/utils/versions.d.ts +20 -0
  366. package/src/utils/versions.js +24 -0
  367. package/src/utils/versions.js.map +1 -0
  368. package/typings/svg.d.ts +7 -0
@@ -0,0 +1,433 @@
1
+ import { getProjects, Tree, updateProjectConfiguration } from '@nx/devkit';
2
+ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
+ import componentStoryGenerator from './component-story';
4
+ import { Linter } from '@nx/linter';
5
+
6
+ import { formatFile } from '../../utils/format-file';
7
+ import libraryGenerator from '../library/library';
8
+ import componentGenerator from '../component/component';
9
+
10
+ describe('react-native:component-story', () => {
11
+ let appTree: Tree;
12
+ let cmpPath = 'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.tsx';
13
+ let storyFilePath =
14
+ 'libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.stories.tsx';
15
+
16
+ describe('default setup', () => {
17
+ beforeEach(async () => {
18
+ appTree = await createTestUILib('test-ui-lib');
19
+ });
20
+
21
+ describe('when file does not contain a component', () => {
22
+ beforeEach(() => {
23
+ appTree.write(
24
+ cmpPath,
25
+ `export const add = (a: number, b: number) => a + b;`
26
+ );
27
+ });
28
+
29
+ it('should fail with a descriptive error message', async () => {
30
+ try {
31
+ await componentStoryGenerator(appTree, {
32
+ componentPath: 'lib/test-ui-lib/test-ui-lib.tsx',
33
+ project: 'test-ui-lib',
34
+ });
35
+ } catch (e) {
36
+ expect(e.message).toContain(
37
+ 'Could not find any React Native component in file libs/test-ui-lib/src/lib/test-ui-lib/test-ui-lib.tsx'
38
+ );
39
+ }
40
+ });
41
+ });
42
+
43
+ describe('default component setup', () => {
44
+ beforeEach(async () => {
45
+ await componentStoryGenerator(appTree, {
46
+ componentPath: 'lib/test-ui-lib/test-ui-lib.tsx',
47
+ project: 'test-ui-lib',
48
+ });
49
+ });
50
+
51
+ it('should create the story file', () => {
52
+ expect(appTree.exists(storyFilePath)).toBeTruthy();
53
+ });
54
+
55
+ it('should properly set up the story', () => {
56
+ expect(
57
+ formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
58
+ ).toContain(formatFile`
59
+ import { storiesOf } from '@storybook/react-native';
60
+ import React from 'react';
61
+ import { TestUiLib, TestUiLibProps } from './test-ui-lib';
62
+ const props: TestUiLibProps = {};
63
+ storiesOf('TestUiLib', module)
64
+ .add('Primary', () => <TestUiLib {...props} />);
65
+ `);
66
+ });
67
+ });
68
+
69
+ describe('when using plain JS components', () => {
70
+ let storyFilePathPlain =
71
+ 'libs/test-ui-lib/src/lib/test-ui-libplain.stories.jsx';
72
+
73
+ beforeEach(async () => {
74
+ appTree.write(
75
+ 'libs/test-ui-lib/src/lib/test-ui-libplain.jsx',
76
+ `import React from 'react';
77
+
78
+ import './test.scss';
79
+
80
+ export const Test = () => {
81
+ return (
82
+ <div>
83
+ <h1>Welcome to test component</h1>
84
+ </div>
85
+ );
86
+ };
87
+
88
+ export default Test;
89
+ `
90
+ );
91
+
92
+ await componentStoryGenerator(appTree, {
93
+ componentPath: 'lib/test-ui-libplain.jsx',
94
+ project: 'test-ui-lib',
95
+ });
96
+ });
97
+
98
+ it('should create the story file', () => {
99
+ expect(appTree.exists(storyFilePathPlain)).toBeTruthy();
100
+ });
101
+
102
+ it('should properly set up the story', () => {
103
+ expect(formatFile`${appTree.read(storyFilePathPlain, 'utf-8')}`)
104
+ .toContain(formatFile`
105
+ import { storiesOf } from '@storybook/react-native';
106
+ import React from 'react';
107
+ import { Test } from './test-ui-libplain';
108
+
109
+ const props = {};
110
+
111
+ storiesOf('Test', module)
112
+ .add('Primary', () => <Test {...props} />);
113
+ `);
114
+ });
115
+ });
116
+
117
+ describe('component without any props defined', () => {
118
+ beforeEach(async () => {
119
+ appTree.write(
120
+ cmpPath,
121
+ `import React from 'react';
122
+
123
+ import { View, Text } from 'react-native';
124
+
125
+ export function Test() {
126
+ return (
127
+ <View>
128
+ <Text>Welcome to test!</Text>
129
+ </View>
130
+ );
131
+ }
132
+
133
+ export default Test;
134
+ `
135
+ );
136
+ await componentStoryGenerator(appTree, {
137
+ componentPath: 'lib/test-ui-lib/test-ui-lib.tsx',
138
+ project: 'test-ui-lib',
139
+ });
140
+ });
141
+
142
+ it('should create a story without controls', () => {
143
+ expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
144
+ .toContain(formatFile`
145
+ import { storiesOf } from '@storybook/react-native';
146
+ import React from 'react';
147
+ import { Test } from './test-ui-lib';
148
+ const props = {};
149
+ storiesOf('Test', module)
150
+ .add('Primary', () => <Test {...props} />);
151
+ `);
152
+ });
153
+ });
154
+
155
+ describe('component with props', () => {
156
+ beforeEach(async () => {
157
+ await componentStoryGenerator(appTree, {
158
+ componentPath: 'lib/test-ui-lib/test-ui-lib.tsx',
159
+ project: 'test-ui-lib',
160
+ });
161
+ });
162
+
163
+ it('should setup controls based on the component props', () => {
164
+ expect(
165
+ formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
166
+ ).toContain(formatFile`
167
+ import { storiesOf } from '@storybook/react-native';
168
+ import React from 'react';
169
+ import { TestUiLib, TestUiLibProps } from './test-ui-lib';
170
+ const props: TestUiLibProps = {};
171
+ storiesOf('TestUiLib', module)
172
+ .add('Primary', () => <TestUiLib {...props} />);
173
+ `);
174
+ });
175
+ });
176
+
177
+ describe('component with props and actions', () => {
178
+ beforeEach(async () => {
179
+ appTree.write(
180
+ cmpPath,
181
+ `import React from 'react';
182
+
183
+ export type ButtonStyle = 'default' | 'primary' | 'warning';
184
+
185
+ export interface TestProps {
186
+ name: string;
187
+ displayAge: boolean;
188
+ someAction: (e: unknown) => void;
189
+ style: ButtonStyle;
190
+ }
191
+
192
+ export const Test = (props: TestProps) => {
193
+ return (
194
+ <div>
195
+ <h1>Welcome to test component, {props.name}</h1>
196
+ <button onClick={props.someAction}>Click me!</button>
197
+ </div>
198
+ );
199
+ };
200
+
201
+ export default Test;
202
+ `
203
+ );
204
+
205
+ await componentStoryGenerator(appTree, {
206
+ componentPath: 'lib/test-ui-lib/test-ui-lib.tsx',
207
+ project: 'test-ui-lib',
208
+ });
209
+ });
210
+
211
+ it('should setup controls based on the component props', () => {
212
+ expect(
213
+ formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
214
+ ).toContain(formatFile`
215
+ import { action } from '@storybook/addon-actions';
216
+ import { storiesOf } from '@storybook/react-native';
217
+ import React from 'react';
218
+ import { Test, TestProps } from './test-ui-lib';
219
+ const actions = { someAction: action('someAction executed!') };
220
+ const props: TestProps = { name: '', displayAge: false };
221
+ storiesOf('Test', module)
222
+ .add('Primary', () => <Test {...props} {...actions} />);
223
+ `);
224
+ });
225
+ });
226
+
227
+ [
228
+ {
229
+ name: 'default export function',
230
+ src: `export default function Test(props: TestProps) {
231
+ return (
232
+ <div>
233
+ <h1>Welcome to test component, {props.name}</h1>
234
+ </div>
235
+ );
236
+ };
237
+ `,
238
+ },
239
+ {
240
+ name: 'function and then export',
241
+ src: `
242
+ function Test(props: TestProps) {
243
+ return (
244
+ <div>
245
+ <h1>Welcome to test component, {props.name}</h1>
246
+ </div>
247
+ );
248
+ };
249
+ export default Test;
250
+ `,
251
+ },
252
+ {
253
+ name: 'arrow function',
254
+ src: `
255
+ const Test = (props: TestProps) => {
256
+ return (
257
+ <div>
258
+ <h1>Welcome to test component, {props.name}</h1>
259
+ </div>
260
+ );
261
+ };
262
+ export default Test;
263
+ `,
264
+ },
265
+ {
266
+ name: 'arrow function without {..}',
267
+ src: `
268
+ const Test = (props: TestProps) => <div><h1>Welcome to test component, {props.name}</h1></div>;
269
+ export default Test
270
+ `,
271
+ },
272
+ {
273
+ name: 'direct export of component class',
274
+ src: `
275
+ export default class Test extends React.Component<TestProps> {
276
+ render() {
277
+ return <div><h1>Welcome to test component, {this.props.name}</h1></div>;
278
+ }
279
+ }
280
+ `,
281
+ },
282
+ {
283
+ name: 'component class & then default export',
284
+ src: `
285
+ class Test extends React.Component<TestProps> {
286
+ render() {
287
+ return <div><h1>Welcome to test component, {this.props.name}</h1></div>;
288
+ }
289
+ }
290
+ export default Test
291
+ `,
292
+ },
293
+ {
294
+ name: 'PureComponent class & then default export',
295
+ src: `
296
+ class Test extends React.PureComponent<TestProps> {
297
+ render() {
298
+ return <div><h1>Welcome to test component, {this.props.name}</h1></div>;
299
+ }
300
+ }
301
+ export default Test
302
+ `,
303
+ },
304
+ {
305
+ name: 'direct export of component class new JSX transform',
306
+ src: `
307
+ export default class Test extends Component<TestProps> {
308
+ render() {
309
+ return <div><h1>Welcome to test component, {this.props.name}</h1></div>;
310
+ }
311
+ }
312
+ `,
313
+ },
314
+ {
315
+ name: 'component class & then default export new JSX transform',
316
+ src: `
317
+ class Test extends Component<TestProps> {
318
+ render() {
319
+ return <div><h1>Welcome to test component, {this.props.name}</h1></div>;
320
+ }
321
+ }
322
+ export default Test
323
+ `,
324
+ },
325
+ {
326
+ name: 'PureComponent class & then default export new JSX transform',
327
+ src: `
328
+ class Test extends PureComponent<TestProps> {
329
+ render() {
330
+ return <div><h1>Welcome to test component, {this.props.name}</h1></div>;
331
+ }
332
+ }
333
+ export default Test
334
+ `,
335
+ },
336
+ ].forEach((config) => {
337
+ describe(`React Native component defined as:${config.name}`, () => {
338
+ beforeEach(async () => {
339
+ appTree.write(
340
+ cmpPath,
341
+ `import React from 'react';
342
+
343
+ export interface TestProps {
344
+ name: string;
345
+ displayAge: boolean;
346
+ }
347
+
348
+ ${config.src}
349
+ `
350
+ );
351
+
352
+ await componentStoryGenerator(appTree, {
353
+ componentPath: 'lib/test-ui-lib/test-ui-lib.tsx',
354
+ project: 'test-ui-lib',
355
+ });
356
+ });
357
+
358
+ it('should properly setup the controls based on the component props', () => {
359
+ expect(
360
+ formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
361
+ ).toContain(formatFile`
362
+ import { storiesOf } from '@storybook/react-native';
363
+ import React from 'react';
364
+ import { Test, TestProps } from './test-ui-lib';
365
+ const props: TestProps = {
366
+ name: '',
367
+ displayAge: false,
368
+ };
369
+ storiesOf('Test', module)
370
+ .add('Primary', () => <Test {...props} />);
371
+ `);
372
+ });
373
+ });
374
+ });
375
+ });
376
+
377
+ describe('using eslint', () => {
378
+ beforeEach(async () => {
379
+ appTree = await createTestUILib('test-ui-lib');
380
+ await componentGenerator(appTree, {
381
+ name: 'test-ui-lib',
382
+ project: 'test-ui-lib',
383
+ export: true,
384
+ });
385
+ await componentStoryGenerator(appTree, {
386
+ componentPath: 'lib/test-ui-lib/test-ui-lib.tsx',
387
+ project: 'test-ui-lib',
388
+ });
389
+ });
390
+
391
+ it('should properly set up the story', () => {
392
+ expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
393
+ .toContain(formatFile`
394
+ import { storiesOf } from '@storybook/react-native';
395
+ import React from 'react';
396
+ import { TestUiLib, TestUiLibProps } from './test-ui-lib';
397
+
398
+ const props: TestUiLibProps = {};
399
+
400
+ storiesOf('TestUiLib', module)
401
+ .add('Primary', () => <TestUiLib {...props} />);
402
+ `);
403
+ });
404
+ });
405
+ });
406
+
407
+ export async function createTestUILib(libName: string): Promise<Tree> {
408
+ let appTree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
409
+ appTree.write('.gitignore', '');
410
+
411
+ await libraryGenerator(appTree, {
412
+ name: libName,
413
+ linter: Linter.EsLint,
414
+ skipFormat: true,
415
+ skipTsConfig: false,
416
+ unitTestRunner: 'jest',
417
+ });
418
+
419
+ await componentGenerator(appTree, {
420
+ name: libName,
421
+ project: libName,
422
+ export: true,
423
+ });
424
+
425
+ const currentWorkspaceJson = getProjects(appTree);
426
+
427
+ const projectConfig = currentWorkspaceJson.get(libName);
428
+ projectConfig.targets.lint.options.linter = 'eslint';
429
+
430
+ updateProjectConfiguration(appTree, libName, projectConfig);
431
+
432
+ return appTree;
433
+ }
@@ -0,0 +1,24 @@
1
+ <% if (hasActions) { %>
2
+ import { action } from '@storybook/addon-actions';
3
+ <% } %>
4
+ import { storiesOf } from '@storybook/react-native';
5
+ import React from 'react';
6
+ import {
7
+ <%= componentName %>
8
+ <% if ( propsTypeName ) { %>, <%= propsTypeName %> <% } %>
9
+ } from './<%= componentImportFileName %>';
10
+
11
+ <% if (hasActions) { %>
12
+ const actions = {<% for (let argType of argTypes) { %>
13
+ <%= argType.name %>: action('<%- argType.actionText %>'),
14
+ <% } %>};
15
+ <% } %>
16
+
17
+ const props <% if ( propsTypeName ) { %>:<%= propsTypeName %><% } %> = {<% for (let prop of props) { %>
18
+ <%= prop.name %>: <%- prop.defaultValue %>,
19
+ <% } %>};
20
+
21
+ storiesOf('<%= componentName %>', module)
22
+ .add('Primary', () => (
23
+ <<%= componentName %> {...props} <% if (hasActions) { %> {...actions} <% } %>/>
24
+ ));
@@ -0,0 +1,5 @@
1
+ export interface CreateComponentStoriesFileSchema {
2
+ project: string;
3
+ componentPath: string;
4
+ skipFormat?: boolean;
5
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "NxReactNativeComponentStory",
5
+ "title": "React native component story",
6
+ "description": "Generate storybook story for a react-native component.",
7
+ "type": "object",
8
+ "properties": {
9
+ "project": {
10
+ "type": "string",
11
+ "aliases": ["name", "projectName"],
12
+ "description": "The project where to add the components.",
13
+ "examples": ["shared-ui-component"],
14
+ "$default": {
15
+ "$source": "projectName",
16
+ "index": 0
17
+ },
18
+ "x-prompt": "What's the name of the project where the component lives?"
19
+ },
20
+ "componentPath": {
21
+ "type": "string",
22
+ "description": "Relative path to the component file from the library root.",
23
+ "examples": ["lib/components"],
24
+ "x-prompt": "What's path of the component relative to the project's lib root?"
25
+ },
26
+ "skipFormat": {
27
+ "description": "Skip formatting files.",
28
+ "type": "boolean",
29
+ "default": false,
30
+ "x-priority": "internal"
31
+ }
32
+ },
33
+ "required": ["project", "componentPath"]
34
+ }
@@ -0,0 +1,6 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { Schema } from './schema';
3
+ export declare function reactNativeInitGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
4
+ export declare function updateDependencies(host: Tree): GeneratorCallback;
5
+ export default reactNativeInitGenerator;
6
+ export declare const reactNativeInitSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reactNativeInitSchematic = exports.updateDependencies = exports.reactNativeInitGenerator = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const devkit_1 = require("@nx/devkit");
6
+ const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
7
+ const jest_1 = require("@nx/jest");
8
+ const detox_1 = require("@nx/detox");
9
+ const versions_1 = require("@nx/react/src/utils/versions");
10
+ const js_1 = require("@nx/js");
11
+ const versions_2 = require("../../utils/versions");
12
+ const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
13
+ function reactNativeInitGenerator(host, schema) {
14
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
+ (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
16
+ yield (0, add_babel_inputs_1.addBabelInputs)(host);
17
+ const tasks = [];
18
+ tasks.push(yield (0, js_1.initGenerator)(host, Object.assign(Object.assign({}, schema), { skipFormat: true })));
19
+ if (!schema.skipPackageJson) {
20
+ const installTask = updateDependencies(host);
21
+ tasks.push(moveDependency(host));
22
+ tasks.push(installTask);
23
+ }
24
+ if (!schema.unitTestRunner || schema.unitTestRunner === 'jest') {
25
+ const jestTask = yield (0, jest_1.jestInitGenerator)(host, schema);
26
+ tasks.push(jestTask);
27
+ }
28
+ if (!schema.e2eTestRunner || schema.e2eTestRunner === 'detox') {
29
+ const detoxTask = yield (0, detox_1.detoxInitGenerator)(host, Object.assign(Object.assign({}, schema), { skipFormat: true }));
30
+ tasks.push(detoxTask);
31
+ }
32
+ if (!schema.skipFormat) {
33
+ yield (0, devkit_1.formatFiles)(host);
34
+ }
35
+ return (0, devkit_1.runTasksInSerial)(...tasks);
36
+ });
37
+ }
38
+ exports.reactNativeInitGenerator = reactNativeInitGenerator;
39
+ function updateDependencies(host) {
40
+ const isPnpm = (0, devkit_1.detectPackageManager)(host.root) === 'pnpm';
41
+ return (0, devkit_1.addDependenciesToPackageJson)(host, {
42
+ react: versions_2.reactVersion,
43
+ 'react-dom': versions_2.reactDomVersion,
44
+ 'react-native': versions_2.reactNativeVersion,
45
+ }, Object.assign({ '@nrwl/react-native': versions_2.nxVersion, '@types/node': versions_2.typesNodeVersion, '@types/react': versions_2.typesReactVersion, '@types/react-native': versions_2.typesReactNativeVersion, '@react-native-community/cli': versions_2.reactNativeCommunityCli, '@react-native-community/cli-platform-android': versions_2.reactNativeCommunityCliAndroid, '@react-native-community/cli-platform-ios': versions_2.reactNativeCommunityCliIos, '@testing-library/react-native': versions_2.testingLibraryReactNativeVersion, '@testing-library/jest-native': versions_2.testingLibraryJestNativeVersion, 'jest-react-native': versions_2.jestReactNativeVersion, metro: versions_2.metroVersion, 'metro-resolver': versions_2.metroVersion, 'metro-babel-register': versions_2.metroVersion, 'metro-react-native-babel-preset': versions_2.metroVersion, 'metro-react-native-babel-transformer': versions_2.metroVersion, 'react-test-renderer': versions_2.reactTestRendererVersion, 'react-native-svg-transformer': versions_2.reactNativeSvgTransformerVersion, 'react-native-svg': versions_2.reactNativeSvgVersion, 'react-native-config': versions_2.reactNativeConfigVersion, '@react-native-async-storage/async-storage': versions_2.reactNativeAsyncStorageAsyncStorageVersion, '@babel/preset-react': versions_1.babelPresetReactVersion }, (isPnpm
46
+ ? {
47
+ 'metro-config': versions_2.metroVersion,
48
+ '@babel/runtime': versions_2.babelRuntimeVersion, // @babel/runtime is used by react-native-svg
49
+ }
50
+ : {})));
51
+ }
52
+ exports.updateDependencies = updateDependencies;
53
+ function moveDependency(host) {
54
+ return (0, devkit_1.removeDependenciesFromPackageJson)(host, ['@nrwl/react-native'], []);
55
+ }
56
+ exports.default = reactNativeInitGenerator;
57
+ exports.reactNativeInitSchematic = (0, devkit_1.convertNxGenerator)(reactNativeInitGenerator);
58
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/generators/init/init.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,81 @@
1
+ import { NxJsonConfiguration } from '@nx/devkit';
2
+ import { Tree, readJson, updateJson } from '@nx/devkit';
3
+ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
4
+ import { reactNativeInitGenerator } from './init';
5
+
6
+ describe('init', () => {
7
+ let tree: Tree;
8
+
9
+ beforeEach(() => {
10
+ tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
11
+ tree.write('.gitignore', '');
12
+ });
13
+
14
+ it('should add react native dependencies', async () => {
15
+ await reactNativeInitGenerator(tree, { e2eTestRunner: 'none' });
16
+ const packageJson = readJson(tree, 'package.json');
17
+ expect(packageJson.dependencies['react']).toBeDefined();
18
+ expect(packageJson.dependencies['react-native']).toBeDefined();
19
+ expect(packageJson.devDependencies['@types/node']).toBeDefined();
20
+ expect(packageJson.devDependencies['@types/react']).toBeDefined();
21
+ expect(packageJson.devDependencies['@types/react-native']).toBeDefined();
22
+ });
23
+
24
+ it('should add .gitignore entries for React native files and directories', async () => {
25
+ tree.write(
26
+ '/.gitignore',
27
+ `
28
+ /node_modules
29
+ `
30
+ );
31
+ await reactNativeInitGenerator(tree, { e2eTestRunner: 'none' });
32
+
33
+ const content = tree.read('/.gitignore').toString();
34
+
35
+ expect(content).toMatch(/# React Native/);
36
+ expect(content).toMatch(/# Nested node_modules/);
37
+ });
38
+
39
+ describe('babel config', () => {
40
+ it('should create babel config if not present', async () => {
41
+ updateJson<NxJsonConfiguration>(tree, 'nx.json', (json) => {
42
+ json.namedInputs = {
43
+ sharedGlobals: ['{workspaceRoot}/exiting-file.json'],
44
+ };
45
+ return json;
46
+ });
47
+
48
+ await reactNativeInitGenerator(tree, {
49
+ unitTestRunner: 'none',
50
+ e2eTestRunner: 'none',
51
+ });
52
+
53
+ expect(tree.exists('babel.config.json')).toBe(true);
54
+ const sharedGloabls = readJson<NxJsonConfiguration>(tree, 'nx.json')
55
+ .namedInputs.sharedGlobals;
56
+ expect(sharedGloabls).toContain('{workspaceRoot}/exiting-file.json');
57
+ expect(sharedGloabls).toContain('{workspaceRoot}/babel.config.json');
58
+ });
59
+
60
+ it('should not overwrite existing babel config', async () => {
61
+ tree.write('babel.config.json', '{ "preset": ["preset-awesome"] }');
62
+
63
+ await reactNativeInitGenerator(tree, {
64
+ unitTestRunner: 'none',
65
+ e2eTestRunner: 'none',
66
+ });
67
+
68
+ const existing = readJson(tree, 'babel.config.json');
69
+ expect(existing).toEqual({ preset: ['preset-awesome'] });
70
+ });
71
+
72
+ it('should not overwrite existing babel config (.js)', async () => {
73
+ tree.write('/babel.config.js', 'module.exports = () => {};');
74
+ await reactNativeInitGenerator(tree, {
75
+ unitTestRunner: 'none',
76
+ e2eTestRunner: 'none',
77
+ });
78
+ expect(tree.exists('babel.config.json')).toBe(false);
79
+ });
80
+ });
81
+ });
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export declare function addGitIgnoreEntry(host: Tree): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addGitIgnoreEntry = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const ignore_1 = require("ignore");
6
+ const gitignore_entries_1 = require("./gitignore-entries");
7
+ function addGitIgnoreEntry(host) {
8
+ if (!host.exists('.gitignore')) {
9
+ devkit_1.logger.warn(`Couldn't find .gitignore file to update`);
10
+ return;
11
+ }
12
+ let content = host.read('.gitignore', 'utf-8').trimEnd();
13
+ const ig = (0, ignore_1.default)();
14
+ ig.add(host.read('.gitignore', 'utf-8'));
15
+ if (!ig.ignores('apps/example/ios/Pods/Folly')) {
16
+ content = `${content}\n${gitignore_entries_1.gitIgnoreEntriesForReactNative}\n`;
17
+ }
18
+ // also ignore nested node_modules folders due to symlink for React Native
19
+ if (!ig.ignores('apps/example/node_modules')) {
20
+ content = `${content}\n## Nested node_modules\n\nnode_modules/\n`;
21
+ }
22
+ host.write('.gitignore', content);
23
+ }
24
+ exports.addGitIgnoreEntry = addGitIgnoreEntry;
25
+ //# sourceMappingURL=add-git-ignore-entry.js.map