@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,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const child_process_1 = require("child_process");
5
+ const start_impl_1 = require("../start/start.impl");
6
+ const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
7
+ const get_cli_options_1 = require("../../utils/get-cli-options");
8
+ let childProcess;
9
+ async function* runAndroidExecutor(options, context) {
10
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
11
+ (0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(context.root, projectRoot, 'android'));
12
+ const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
13
+ if (options.mode !== 'Release') {
14
+ tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
15
+ port: options.port,
16
+ resetCache: options.resetCache,
17
+ interactive: true,
18
+ }));
19
+ }
20
+ await Promise.all(tasks);
21
+ yield { success: true };
22
+ }
23
+ exports.default = runAndroidExecutor;
24
+ function runCliRunAndroid(workspaceRoot, projectRoot, options) {
25
+ return new Promise((resolve, reject) => {
26
+ /**
27
+ * Call the react native cli with option `--no-packager`
28
+ * Not passing '--packager' due to cli will launch start command from the project root
29
+ */
30
+ childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['run-android', ...createRunAndroidOptions(options), '--no-packager'], {
31
+ stdio: 'inherit',
32
+ cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
33
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
34
+ });
35
+ /**
36
+ * Ensure the child process is killed when the parent exits
37
+ */
38
+ const processExitListener = (signal) => () => {
39
+ childProcess.kill(signal);
40
+ process.exit();
41
+ };
42
+ process.once('exit', (signal) => childProcess.kill(signal));
43
+ process.once('SIGTERM', processExitListener);
44
+ process.once('SIGINT', processExitListener);
45
+ process.once('SIGQUIT', processExitListener);
46
+ childProcess.on('error', (err) => {
47
+ reject(err);
48
+ });
49
+ childProcess.on('exit', (code) => {
50
+ if (code === 0) {
51
+ resolve(childProcess);
52
+ }
53
+ else {
54
+ reject(code);
55
+ }
56
+ });
57
+ });
58
+ }
59
+ const startOptions = ['port', 'resetCache'];
60
+ function createRunAndroidOptions(options) {
61
+ return (0, get_cli_options_1.getCliOptions)(options, startOptions, [
62
+ 'appId',
63
+ 'appIdSuffix',
64
+ 'deviceId',
65
+ ]);
66
+ }
@@ -0,0 +1,94 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { join, resolve as pathResolve } from 'path';
3
+ import { ChildProcess, fork } from 'child_process';
4
+
5
+ import { ReactNativeRunAndroidOptions } from './schema';
6
+ import { runCliStart } from '../start/start.impl';
7
+ import { chmodAndroidGradlewFiles } from '../../utils/chmod-android-gradle-files';
8
+ import { getCliOptions } from '../../utils/get-cli-options';
9
+
10
+ export interface ReactNativeRunAndroidOutput {
11
+ success: boolean;
12
+ }
13
+
14
+ let childProcess: ChildProcess;
15
+
16
+ export default async function* runAndroidExecutor(
17
+ options: ReactNativeRunAndroidOptions,
18
+ context: ExecutorContext
19
+ ): AsyncGenerator<ReactNativeRunAndroidOutput> {
20
+ const projectRoot =
21
+ context.projectsConfigurations.projects[context.projectName].root;
22
+ chmodAndroidGradlewFiles(join(context.root, projectRoot, 'android'));
23
+
24
+ const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
25
+
26
+ if (options.mode !== 'Release') {
27
+ tasks.push(
28
+ runCliStart(context.root, projectRoot, {
29
+ port: options.port,
30
+ resetCache: options.resetCache,
31
+ interactive: true,
32
+ })
33
+ );
34
+ }
35
+
36
+ await Promise.all(tasks);
37
+
38
+ yield { success: true };
39
+ }
40
+
41
+ function runCliRunAndroid(
42
+ workspaceRoot: string,
43
+ projectRoot: string,
44
+ options: ReactNativeRunAndroidOptions
45
+ ): Promise<ChildProcess> {
46
+ return new Promise<ChildProcess>((resolve, reject) => {
47
+ /**
48
+ * Call the react native cli with option `--no-packager`
49
+ * Not passing '--packager' due to cli will launch start command from the project root
50
+ */
51
+ childProcess = fork(
52
+ require.resolve('react-native/cli.js'),
53
+ ['run-android', ...createRunAndroidOptions(options), '--no-packager'],
54
+ {
55
+ stdio: 'inherit',
56
+ cwd: pathResolve(workspaceRoot, projectRoot),
57
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
58
+ }
59
+ );
60
+
61
+ /**
62
+ * Ensure the child process is killed when the parent exits
63
+ */
64
+ const processExitListener = (signal?: number | NodeJS.Signals) => () => {
65
+ childProcess.kill(signal);
66
+ process.exit();
67
+ };
68
+ process.once('exit', (signal) => childProcess.kill(signal));
69
+ process.once('SIGTERM', processExitListener);
70
+ process.once('SIGINT', processExitListener);
71
+ process.once('SIGQUIT', processExitListener);
72
+
73
+ childProcess.on('error', (err) => {
74
+ reject(err);
75
+ });
76
+ childProcess.on('exit', (code) => {
77
+ if (code === 0) {
78
+ resolve(childProcess);
79
+ } else {
80
+ reject(code);
81
+ }
82
+ });
83
+ });
84
+ }
85
+
86
+ const startOptions = ['port', 'resetCache'];
87
+
88
+ function createRunAndroidOptions(options: ReactNativeRunAndroidOptions) {
89
+ return getCliOptions<ReactNativeRunAndroidOptions>(options, startOptions, [
90
+ 'appId',
91
+ 'appIdSuffix',
92
+ 'deviceId',
93
+ ]);
94
+ }
@@ -0,0 +1,13 @@
1
+ import { ReactNativeBuildAndroidOptions } from '../build-android/schema';
2
+ import { ReactNativeStartOptions } from '../start/schema';
3
+
4
+ // part of options from https://github.com/react-native-community/cli/blob/main/packages/cli-platform-android/src/commands/runAndroid/index.ts
5
+ export interface ReactNativeRunAndroidOptions
6
+ extends ReactNativeBuildAndroidOptions {
7
+ appId: string;
8
+ appIdSuffix: string;
9
+ mainActiviy: string;
10
+ deviceId: string;
11
+ listDevices?: boolean;
12
+ binaryPath?: string;
13
+ }
@@ -0,0 +1,100 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "cli": "nx",
5
+ "$id": "NxReactNativeRunAndroid",
6
+ "$schema": "https://json-schema.org/schema",
7
+ "title": "Run Android application",
8
+ "description": "Run Android target options.",
9
+ "type": "object",
10
+ "presets": [
11
+ {
12
+ "name": "Run Android for the current device architecture",
13
+ "keys": ["activeArchOnly"]
14
+ },
15
+ {
16
+ "name": "Lists all available Android devices and simulators",
17
+ "keys": ["listDevices"]
18
+ },
19
+ {
20
+ "name": "Run Android without metro cache",
21
+ "keys": ["resetCache"]
22
+ }
23
+ ],
24
+ "properties": {
25
+ "appId": {
26
+ "type": "string",
27
+ "description": "Specify an `applicationId` to launch after build. If not specified, `package` from `AndroidManifest.xml` will be used."
28
+ },
29
+ "appIdSuffix": {
30
+ "type": "string",
31
+ "description": "Specify an `applicationIdSuffix` to launch after build."
32
+ },
33
+ "mainActivity": {
34
+ "type": "string",
35
+ "description": "Name of the activity to start.",
36
+ "default": "MainActivity"
37
+ },
38
+ "deviceId": {
39
+ "type": "string",
40
+ "description": "Builds your app and starts it on a specific device/simulator with the given device id (listed by running `adb devices` on the command line)."
41
+ },
42
+ "listDevices": {
43
+ "type": "boolean",
44
+ "description": "Lists all available Android devices and simulators and let you choose one to run the app"
45
+ },
46
+ "binaryPath": {
47
+ "type": "string",
48
+ "description": "Path relative to project root where pre-built .apk binary lives."
49
+ },
50
+ "mode": {
51
+ "type": "string",
52
+ "description": "Specify your app's build variant",
53
+ "default": "debug",
54
+ "examples": ["debug", "release"],
55
+ "x-priority": "important"
56
+ },
57
+ "port": {
58
+ "type": "number",
59
+ "description": "The port where the packager server is listening on.",
60
+ "default": 8081
61
+ },
62
+ "tasks": {
63
+ "oneOf": [
64
+ { "type": "array", "items": { "type": "string" } },
65
+ { "type": "string" }
66
+ ],
67
+ "description": "Run custom Gradle tasks. By default it's \"assembleDebug\". Will override passed mode and variant arguments.",
68
+ "examples": [
69
+ "assembleDebug",
70
+ "assembleRelease",
71
+ "bundleDebug",
72
+ "bundleRelease",
73
+ "installDebug",
74
+ "installRelease"
75
+ ]
76
+ },
77
+ "activeArchOnly": {
78
+ "type": "boolean",
79
+ "description": "Build native libraries only for the current device architecture for debug builds.",
80
+ "default": false
81
+ },
82
+ "extraParams": {
83
+ "oneOf": [
84
+ { "type": "array", "items": { "type": "string" } },
85
+ { "type": "string" }
86
+ ],
87
+ "description": "Custom params passed to gradle build command"
88
+ },
89
+ "interactive": {
90
+ "type": "boolean",
91
+ "description": "Explicitly select build type and flavour to use before running a build"
92
+ },
93
+ "resetCache": {
94
+ "type": "boolean",
95
+ "description": "Resets metro cache.",
96
+ "default": false
97
+ }
98
+ },
99
+ "examplesFile": "../../../docs/run-android-examples.md"
100
+ }
@@ -0,0 +1,6 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ import { ReactNativeRunIosOptions } from './schema';
3
+ export interface ReactNativeRunIosOutput {
4
+ success: boolean;
5
+ }
6
+ export default function runIosExecutor(options: ReactNativeRunIosOptions, context: ExecutorContext): AsyncGenerator<ReactNativeRunIosOutput>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const child_process_1 = require("child_process");
5
+ const os_1 = require("os");
6
+ const start_impl_1 = require("../start/start.impl");
7
+ const get_cli_options_1 = require("../../utils/get-cli-options");
8
+ async function* runIosExecutor(options, context) {
9
+ if ((0, os_1.platform)() !== 'darwin') {
10
+ throw new Error(`The run-ios build requires Mac to run`);
11
+ }
12
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
13
+ const tasks = [runCliRunIOS(context.root, projectRoot, options)];
14
+ if (options.mode !== 'Release') {
15
+ tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
16
+ port: options.port,
17
+ resetCache: options.resetCache,
18
+ interactive: true,
19
+ }));
20
+ }
21
+ await Promise.all(tasks);
22
+ yield { success: true };
23
+ }
24
+ exports.default = runIosExecutor;
25
+ function runCliRunIOS(workspaceRoot, projectRoot, options) {
26
+ return new Promise((resolve, reject) => {
27
+ /**
28
+ * Call the react native cli with option `--no-packager`
29
+ * Not passing '--packager' due to cli will launch start command from the project root
30
+ */
31
+ const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['run-ios', ...createRunIOSOptions(options), '--no-packager'], {
32
+ stdio: 'inherit',
33
+ cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
34
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
35
+ });
36
+ /**
37
+ * Ensure the child process is killed when the parent exits
38
+ */
39
+ const processExitListener = (signal) => () => {
40
+ childProcess.kill(signal);
41
+ process.exit();
42
+ };
43
+ process.once('exit', (signal) => childProcess.kill(signal));
44
+ process.once('SIGTERM', processExitListener);
45
+ process.once('SIGINT', processExitListener);
46
+ process.once('SIGQUIT', processExitListener);
47
+ childProcess.on('error', (err) => {
48
+ reject(err);
49
+ });
50
+ childProcess.on('exit', (code) => {
51
+ if (code === 0) {
52
+ resolve(childProcess);
53
+ }
54
+ else {
55
+ reject(code);
56
+ }
57
+ });
58
+ });
59
+ }
60
+ const startOptions = ['port', 'resetCache'];
61
+ function createRunIOSOptions(options) {
62
+ return (0, get_cli_options_1.getCliOptions)(options, startOptions, [
63
+ 'buildFolder',
64
+ ]);
65
+ }
@@ -0,0 +1,92 @@
1
+ import { ExecutorContext, GeneratorCallback, workspaceRoot } from '@nx/devkit';
2
+ import { resolve as pathResolve } from 'path';
3
+ import { ChildProcess, fork } from 'child_process';
4
+ import { platform } from 'os';
5
+
6
+ import { runCliStart } from '../start/start.impl';
7
+ import { getCliOptions } from '../../utils/get-cli-options';
8
+
9
+ import { ReactNativeRunIosOptions } from './schema';
10
+ export interface ReactNativeRunIosOutput {
11
+ success: boolean;
12
+ }
13
+
14
+ export default async function* runIosExecutor(
15
+ options: ReactNativeRunIosOptions,
16
+ context: ExecutorContext
17
+ ): AsyncGenerator<ReactNativeRunIosOutput> {
18
+ if (platform() !== 'darwin') {
19
+ throw new Error(`The run-ios build requires Mac to run`);
20
+ }
21
+ const projectRoot =
22
+ context.projectsConfigurations.projects[context.projectName].root;
23
+
24
+ const tasks = [runCliRunIOS(context.root, projectRoot, options)];
25
+
26
+ if (options.mode !== 'Release') {
27
+ tasks.push(
28
+ runCliStart(context.root, projectRoot, {
29
+ port: options.port,
30
+ resetCache: options.resetCache,
31
+ interactive: true,
32
+ })
33
+ );
34
+ }
35
+
36
+ await Promise.all(tasks);
37
+
38
+ yield { success: true };
39
+ }
40
+
41
+ function runCliRunIOS(
42
+ workspaceRoot: string,
43
+ projectRoot: string,
44
+ options: ReactNativeRunIosOptions
45
+ ): Promise<ChildProcess> {
46
+ return new Promise<ChildProcess>((resolve, reject) => {
47
+ /**
48
+ * Call the react native cli with option `--no-packager`
49
+ * Not passing '--packager' due to cli will launch start command from the project root
50
+ */
51
+ const childProcess = fork(
52
+ require.resolve('react-native/cli.js'),
53
+ ['run-ios', ...createRunIOSOptions(options), '--no-packager'],
54
+ {
55
+ stdio: 'inherit',
56
+ cwd: pathResolve(workspaceRoot, projectRoot),
57
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
58
+ }
59
+ );
60
+
61
+ /**
62
+ * Ensure the child process is killed when the parent exits
63
+ */
64
+ const processExitListener = (signal?: number | NodeJS.Signals) => () => {
65
+ childProcess.kill(signal);
66
+ process.exit();
67
+ };
68
+ process.once('exit', (signal) => childProcess.kill(signal));
69
+ process.once('SIGTERM', processExitListener);
70
+ process.once('SIGINT', processExitListener);
71
+ process.once('SIGQUIT', processExitListener);
72
+
73
+ childProcess.on('error', (err) => {
74
+ reject(err);
75
+ });
76
+ childProcess.on('exit', (code) => {
77
+ if (code === 0) {
78
+ resolve(childProcess);
79
+ } else {
80
+ reject(code);
81
+ }
82
+ });
83
+ });
84
+ }
85
+
86
+ const startOptions = ['port', 'resetCache'];
87
+
88
+ function createRunIOSOptions(options: ReactNativeRunIosOptions) {
89
+ return getCliOptions<ReactNativeRunIosOptions>(options, startOptions, [
90
+ 'buildFolder',
91
+ ]);
92
+ }
@@ -0,0 +1,7 @@
1
+ import { ReactNativeBuildIosOptions } from '../build-ios/schema';
2
+ import { ReactNativeStartOptions } from '../start/schema';
3
+
4
+ // part of options form https://github.com/react-native-community/cli/blob/main/packages/cli-platform-ios/src/commands/runIOS/index.ts
5
+ export interface ReactNativeRunIosOptions extends ReactNativeBuildIosOptions {
6
+ binaryPath?: string;
7
+ }
@@ -0,0 +1,96 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "cli": "nx",
5
+ "$id": "NxReactNativeRunIos",
6
+ "$schema": "https://json-schema.org/schema",
7
+ "title": "Run iOS application",
8
+ "description": "Run iOS target options.",
9
+ "type": "object",
10
+ "presets": [
11
+ {
12
+ "name": "Run iOS on a simulator",
13
+ "keys": ["simulator"]
14
+ },
15
+ {
16
+ "name": "Run iOS on a device",
17
+ "keys": ["device"]
18
+ },
19
+ {
20
+ "name": "Run iOS on a device with udid",
21
+ "keys": ["udid"]
22
+ }
23
+ ],
24
+ "properties": {
25
+ "simulator": {
26
+ "type": "string",
27
+ "description": "Explicitly set simulator to use. Optionally include iOS version between parenthesis at the end to match an exact version: \"iPhone 6 (10.0)\"",
28
+ "examples": [
29
+ "iPhone 14",
30
+ "iPhone 13",
31
+ "iPhone 12",
32
+ "iPhone 11",
33
+ "iPhone X"
34
+ ],
35
+ "x-priority": "important"
36
+ },
37
+ "mode": {
38
+ "type": "string",
39
+ "description": "Explicitly set the scheme configuration to use",
40
+ "default": "Debug",
41
+ "examples": ["Debug", "Release"],
42
+ "x-priority": "important"
43
+ },
44
+ "scheme": {
45
+ "type": "string",
46
+ "description": "Explicitly set Xcode scheme to use"
47
+ },
48
+ "device": {
49
+ "type": "string",
50
+ "description": "Explicitly set device to use by name. The value is not required if you have a single device connected."
51
+ },
52
+ "udid": {
53
+ "type": "string",
54
+ "description": "Explicitly set device to use by udid"
55
+ },
56
+ "verbose": {
57
+ "type": "boolean",
58
+ "description": "Do not use xcbeautify or xcpretty even if installed"
59
+ },
60
+ "port": {
61
+ "type": "number",
62
+ "description": "The port where the packager server is listening on.",
63
+ "default": 8081
64
+ },
65
+ "xcconfig": {
66
+ "type": "string",
67
+ "description": "Explicitly set xcconfig to use"
68
+ },
69
+ "buildFolder": {
70
+ "type": "string",
71
+ "description": "Location for iOS build artifacts. Corresponds to Xcode's \"-derivedDataPath\". Relative to ios directory.",
72
+ "buildFolder": "./build"
73
+ },
74
+ "interactive": {
75
+ "type": "boolean",
76
+ "description": "Explicitly select which scheme and configuration to use before running a build"
77
+ },
78
+ "extraParams": {
79
+ "oneOf": [
80
+ { "type": "array", "items": { "type": "string" } },
81
+ { "type": "string" }
82
+ ],
83
+ "description": "Custom params that will be passed to xcodebuild command."
84
+ },
85
+ "resetCache": {
86
+ "type": "boolean",
87
+ "description": "Resets metro cache.",
88
+ "default": false
89
+ },
90
+ "binaryPath": {
91
+ "type": "string",
92
+ "description": "Path relative to project root where pre-built .app binary lives."
93
+ }
94
+ },
95
+ "examplesFile": "../../../docs/run-ios-examples.md"
96
+ }
@@ -0,0 +1 @@
1
+ export declare function isPackagerRunning(packagerPort: number): Promise<'running' | 'not_running' | 'unrecognized'>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPackagerRunning = void 0;
4
+ const node_fetch_1 = require("node-fetch");
5
+ async function isPackagerRunning(packagerPort) {
6
+ try {
7
+ const resp = await (0, node_fetch_1.default)(`http://localhost:${packagerPort}/status`);
8
+ const data = await resp.text();
9
+ return data === 'packager-status:running' ? 'running' : 'unrecognized';
10
+ }
11
+ catch {
12
+ return 'not_running';
13
+ }
14
+ }
15
+ exports.isPackagerRunning = isPackagerRunning;
@@ -0,0 +1,7 @@
1
+ // options from https://github.com/facebook/react-native/blob/main/packages/community-cli-plugin/src/commands/start/index.js
2
+
3
+ export interface ReactNativeStartOptions {
4
+ port: number;
5
+ resetCache: boolean; // default is false
6
+ interactive: boolean; // default is true
7
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "version": 2,
3
+ "outputCapture": "direct-nodejs",
4
+ "cli": "nx",
5
+ "$id": "NxReactNativeStart",
6
+ "$schema": "https://json-schema.org/schema",
7
+ "title": "Packager Server for React Native",
8
+ "description": "Packager Server target options.",
9
+ "type": "object",
10
+ "properties": {
11
+ "port": {
12
+ "type": "number",
13
+ "description": "The port to listen on.",
14
+ "default": 8081
15
+ },
16
+ "resetCache": {
17
+ "type": "boolean",
18
+ "description": "Resets metro cache.",
19
+ "default": false
20
+ },
21
+ "interactive": {
22
+ "type": "boolean",
23
+ "description": "Run packager server in interactive mode.",
24
+ "default": true
25
+ }
26
+ },
27
+ "examplesFile": "../../../docs/start-examples.md"
28
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ import { ExecutorContext } from '@nx/devkit';
3
+ import { ChildProcess } from 'child_process';
4
+ import { ReactNativeStartOptions } from './schema';
5
+ export interface ReactNativeStartOutput {
6
+ port?: number;
7
+ success: boolean;
8
+ }
9
+ export default function startExecutor(options: ReactNativeStartOptions, context: ExecutorContext): AsyncGenerator<ReactNativeStartOutput>;
10
+ export declare function runCliStart(workspaceRoot: string, projectRoot: string, options: ReactNativeStartOptions): Promise<ChildProcess>;