@nx/react-native 17.0.4 → 17.0.6

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 (181) hide show
  1. package/.eslintrc.json +1 -7
  2. package/LICENSE +1 -1
  3. package/README.md +4 -9
  4. package/executors.json +0 -5
  5. package/generators.json +11 -12
  6. package/migrations.json +0 -126
  7. package/package.json +15 -11
  8. package/plugins/metro-resolver.js +1 -4
  9. package/plugins/with-nx-metro.js +2 -6
  10. package/src/executors/build-android/build-android.impl.js +6 -2
  11. package/src/executors/build-android/build-android.impl.ts +6 -2
  12. package/src/executors/build-android/schema.json +1 -1
  13. package/src/executors/build-ios/schema.json +1 -1
  14. package/src/executors/bundle/schema.d.ts +1 -1
  15. package/src/executors/bundle/schema.json +1 -1
  16. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +0 -4
  17. package/src/executors/ensure-symlink/ensure-symlink.impl.js +0 -4
  18. package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -4
  19. package/src/executors/ensure-symlink/schema.json +1 -1
  20. package/src/executors/pod-install/schema.json +1 -1
  21. package/src/executors/run-android/run-android.impl.js +17 -5
  22. package/src/executors/run-android/run-android.impl.ts +18 -9
  23. package/src/executors/run-android/schema.json +1 -1
  24. package/src/executors/run-ios/run-ios.impl.js +16 -4
  25. package/src/executors/run-ios/run-ios.impl.ts +18 -9
  26. package/src/executors/run-ios/schema.json +1 -1
  27. package/src/executors/start/schema.d.ts +1 -1
  28. package/src/executors/start/schema.json +1 -1
  29. package/src/executors/start/start.impl.js +26 -11
  30. package/src/executors/start/start.impl.ts +28 -14
  31. package/src/executors/storybook/storybook.impl.d.ts +0 -4
  32. package/src/executors/storybook/storybook.impl.js +2 -15
  33. package/src/executors/storybook/storybook.impl.ts +7 -26
  34. package/src/executors/sync-deps/schema.d.ts +0 -1
  35. package/src/executors/sync-deps/schema.json +1 -6
  36. package/src/executors/sync-deps/sync-deps.impl.d.ts +1 -2
  37. package/src/executors/sync-deps/sync-deps.impl.js +11 -33
  38. package/src/executors/sync-deps/sync-deps.impl.ts +18 -57
  39. package/src/generators/application/application.js +8 -52
  40. package/src/generators/application/application.spec.ts +2 -29
  41. package/src/generators/application/files/app/Gemfile.template +1 -2
  42. package/src/generators/application/files/app/android/app/build.gradle.template +28 -12
  43. package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +6 -2
  44. package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +75 -0
  45. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +32 -0
  46. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +62 -0
  47. package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +20 -0
  48. package/src/generators/application/files/app/android/build.gradle.template +20 -7
  49. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +1 -2
  50. package/src/generators/application/files/app/android/gradle.properties +3 -0
  51. package/src/generators/application/files/app/android/gradlew.template +7 -12
  52. package/src/generators/application/files/app/android/settings.gradle.template +2 -2
  53. package/src/generators/application/files/app/babel.config.json.template +3 -0
  54. package/src/generators/application/files/app/ios/Podfile.template +7 -0
  55. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +0 -5
  56. package/src/generators/application/files/app/ios/__className__/Info.plist.template +8 -5
  57. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +33 -11
  58. package/src/generators/application/files/app/metro.config.js.template +5 -1
  59. package/src/generators/application/files/app/src/app/App.tsx.template +13 -50
  60. package/src/generators/application/lib/add-detox.d.ts +3 -0
  61. package/src/generators/application/lib/add-detox.js +23 -0
  62. package/src/generators/application/lib/add-project.js +18 -18
  63. package/src/generators/application/lib/normalize-options.d.ts +0 -7
  64. package/src/generators/application/lib/normalize-options.js +3 -35
  65. package/src/generators/application/lib/normalize-options.spec.ts +7 -70
  66. package/src/generators/application/schema.d.ts +3 -5
  67. package/src/generators/application/schema.json +6 -14
  68. package/src/generators/component/files/__fileName__.tsx__tmpl__ +1 -1
  69. package/src/generators/component/schema.d.ts +3 -3
  70. package/src/generators/component/schema.json +4 -4
  71. package/src/generators/component-story/component-story.d.ts +8 -5
  72. package/src/generators/component-story/component-story.js +69 -8
  73. package/src/generators/component-story/component-story.spec.ts +428 -0
  74. package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +32 -0
  75. package/src/generators/component-story/schema.d.ts +0 -1
  76. package/src/generators/component-story/schema.json +3 -11
  77. package/src/generators/init/init.d.ts +1 -2
  78. package/src/generators/init/init.js +56 -55
  79. package/src/generators/init/init.spec.ts +6 -7
  80. package/src/generators/init/schema.d.ts +3 -3
  81. package/src/generators/init/schema.json +18 -13
  82. package/src/generators/library/files/lib/babel.config.json.template +17 -0
  83. package/src/generators/library/lib/normalize-options.js +0 -5
  84. package/src/generators/library/library.js +38 -48
  85. package/src/generators/library/library.spec.ts +60 -12
  86. package/src/generators/library/schema.d.ts +0 -1
  87. package/src/generators/library/schema.json +2 -2
  88. package/src/generators/stories/schema.d.ts +0 -2
  89. package/src/generators/stories/schema.json +2 -15
  90. package/src/generators/stories/stories-app.spec.ts +128 -0
  91. package/src/generators/stories/stories-lib.spec.ts +105 -0
  92. package/src/generators/stories/stories.d.ts +2 -5
  93. package/src/generators/stories/stories.js +50 -7
  94. package/src/generators/storybook-configuration/configuration.d.ts +2 -7
  95. package/src/generators/storybook-configuration/configuration.js +48 -18
  96. package/src/generators/storybook-configuration/configuration.spec.ts +135 -0
  97. package/src/generators/storybook-configuration/files/app/storybook.ts.template +9 -0
  98. package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +74 -0
  99. package/src/generators/storybook-configuration/files/root/story-loader.ts.template +5 -0
  100. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +6 -0
  101. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +25 -0
  102. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +161 -0
  103. package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +6 -0
  104. package/src/generators/storybook-configuration/lib/create-storybook-files.js +42 -0
  105. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +7 -0
  106. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +29 -0
  107. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +65 -0
  108. package/src/generators/storybook-configuration/schema.d.ts +2 -4
  109. package/src/generators/storybook-configuration/schema.json +12 -22
  110. package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
  111. package/src/generators/upgrade-native/schema.d.ts +1 -1
  112. package/src/generators/upgrade-native/schema.json +3 -3
  113. package/src/generators/upgrade-native/upgrade-native.d.ts +0 -2
  114. package/src/generators/upgrade-native/upgrade-native.js +0 -3
  115. package/src/migrations/update-16-6-0/update-metro-config.js +5 -1
  116. package/src/migrations/update-16-9-0/remove-types-react-native.js +9 -2
  117. package/src/utils/add-jest.d.ts +1 -1
  118. package/src/utils/add-jest.js +1 -13
  119. package/src/utils/add-linting.d.ts +0 -1
  120. package/src/utils/add-linting.js +1 -1
  121. package/src/utils/add-linting.spec.ts +6 -4
  122. package/src/utils/chmod-android-gradle-files.js +2 -6
  123. package/src/utils/find-all-npm-dependencies.js +3 -5
  124. package/src/utils/find-all-npm-dependencies.spec.ts +9 -17
  125. package/src/utils/symlink-task.d.ts +2 -0
  126. package/src/utils/symlink-task.js +18 -0
  127. package/src/utils/testing-generators.js +0 -1
  128. package/src/utils/versions.d.ts +13 -10
  129. package/src/utils/versions.js +14 -11
  130. package/plugin.d.ts +0 -1
  131. package/plugin.js +0 -6
  132. package/plugins/plugin.d.ts +0 -14
  133. package/plugins/plugin.js +0 -162
  134. package/src/executors/upgrade/schema.d.ts +0 -1
  135. package/src/executors/upgrade/schema.json +0 -11
  136. package/src/executors/upgrade/upgrade.impl.d.ts +0 -13
  137. package/src/executors/upgrade/upgrade.impl.js +0 -47
  138. package/src/executors/upgrade/upgrade.impl.ts +0 -64
  139. package/src/generators/application/files/app/.babelrc.js.template +0 -23
  140. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +0 -22
  141. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +0 -45
  142. package/src/generators/application/lib/add-e2e.d.ts +0 -3
  143. package/src/generators/application/lib/add-e2e.js +0 -46
  144. package/src/generators/library/files/lib/.babelrc.js.template +0 -21
  145. package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +0 -23
  146. package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +0 -15
  147. package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
  148. package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
  149. package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +0 -9
  150. package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +0 -82
  151. package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +0 -23
  152. package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
  153. package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
  154. package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +0 -14
  155. package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +0 -9
  156. package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +0 -77
  157. package/src/generators/web-configuration/lib/normalize-schema.d.ts +0 -17
  158. package/src/generators/web-configuration/lib/normalize-schema.js +0 -16
  159. package/src/generators/web-configuration/lib/webpack-targets.d.ts +0 -7
  160. package/src/generators/web-configuration/lib/webpack-targets.js +0 -75
  161. package/src/generators/web-configuration/schema.d.ts +0 -6
  162. package/src/generators/web-configuration/schema.json +0 -42
  163. package/src/generators/web-configuration/web-configuration.d.ts +0 -12
  164. package/src/generators/web-configuration/web-configuration.js +0 -87
  165. package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +0 -6
  166. package/src/migrations/update-18-0-0/add-upgrade-target.js +0 -33
  167. package/src/migrations/update-18-0-0/add-web-configuration.d.ts +0 -8
  168. package/src/migrations/update-18-0-0/add-web-configuration.js +0 -33
  169. package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
  170. package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +0 -5
  171. package/src/migrations/update-18-0-0/change-storybook-targets.js +0 -57
  172. package/src/migrations/update-18-0-0/remove-block-list.d.ts +0 -6
  173. package/src/migrations/update-18-0-0/remove-block-list.js +0 -28
  174. package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
  175. package/src/migrations/update-18-0-0/remove-metro.d.ts +0 -14
  176. package/src/migrations/update-18-0-0/remove-metro.js +0 -29
  177. package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +0 -6
  178. package/src/migrations/update-18-0-0/remove-symlink-target.js +0 -30
  179. package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
  180. package/src/utils/ensure-dependencies.d.ts +0 -2
  181. package/src/utils/ensure-dependencies.js +0 -30
@@ -2,23 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reactNativeApplicationGeneratorInternal = exports.reactNativeApplicationGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const js_1 = require("@nx/js");
6
- const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
5
+ const symlink_task_1 = require("../../utils/symlink-task");
7
6
  const add_linting_1 = require("../../utils/add-linting");
8
7
  const add_jest_1 = require("../../utils/add-jest");
9
8
  const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
10
- const pod_install_task_1 = require("../../utils/pod-install-task");
11
- const web_configuration_1 = require("../web-configuration/web-configuration");
12
9
  const normalize_options_1 = require("./lib/normalize-options");
13
10
  const init_1 = require("../init/init");
14
11
  const add_project_1 = require("./lib/add-project");
15
12
  const create_application_files_1 = require("./lib/create-application-files");
16
- const add_e2e_1 = require("./lib/add-e2e");
17
- const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
18
- const sync_deps_impl_1 = require("../../executors/sync-deps/sync-deps.impl");
13
+ const add_detox_1 = require("./lib/add-detox");
19
14
  async function reactNativeApplicationGenerator(host, schema) {
20
15
  return await reactNativeApplicationGeneratorInternal(host, {
21
- addPlugin: false,
22
16
  projectNameAndRootFormat: 'derived',
23
17
  ...schema,
24
18
  });
@@ -26,19 +20,9 @@ async function reactNativeApplicationGenerator(host, schema) {
26
20
  exports.reactNativeApplicationGenerator = reactNativeApplicationGenerator;
27
21
  async function reactNativeApplicationGeneratorInternal(host, schema) {
28
22
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
29
- const tasks = [];
30
- const jsInitTask = await (0, js_1.initGenerator)(host, {
31
- ...schema,
32
- skipFormat: true,
33
- });
34
- tasks.push(jsInitTask);
35
- const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
36
- tasks.push(initTask);
37
- if (!options.skipPackageJson) {
38
- tasks.push((0, ensure_dependencies_1.ensureDependencies)(host));
39
- }
40
23
  (0, create_application_files_1.createApplicationFiles)(host, options);
41
24
  (0, add_project_1.addProject)(host, options);
25
+ const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
42
26
  const lintTask = await (0, add_linting_1.addLinting)(host, {
43
27
  ...options,
44
28
  projectRoot: options.appProjectRoot,
@@ -46,42 +30,14 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
46
30
  (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'tsconfig.app.json'),
47
31
  ],
48
32
  });
49
- tasks.push(lintTask);
50
- const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, options.addPlugin);
51
- tasks.push(jestTask);
52
- const webTask = await (0, web_configuration_1.webConfigurationGenerator)(host, {
53
- ...options,
54
- project: options.name,
55
- skipFormat: true,
56
- });
57
- tasks.push(webTask);
58
- const e2eTask = await (0, add_e2e_1.addE2e)(host, options);
59
- tasks.push(e2eTask);
60
- const chmodTaskGradlewTask = (0, chmod_android_gradle_files_1.chmodAndroidGradlewFilesTask)((0, devkit_1.joinPathFragments)(host.root, options.androidProjectRoot));
61
- tasks.push(chmodTaskGradlewTask);
62
- const podInstallTask = (0, pod_install_task_1.runPodInstall)((0, devkit_1.joinPathFragments)(host.root, options.iosProjectRoot));
63
- if (options.install) {
64
- const projectPackageJsonPath = (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json');
65
- const workspacePackageJson = (0, devkit_1.readJson)(host, 'package.json');
66
- const projectPackageJson = (0, devkit_1.readJson)(host, projectPackageJsonPath);
67
- await (0, sync_deps_impl_1.syncDeps)(options.name, projectPackageJson, projectPackageJsonPath, workspacePackageJson);
68
- tasks.push(podInstallTask);
69
- }
70
- else {
71
- devkit_1.output.log({
72
- title: 'Skip `pod install`',
73
- bodyLines: [
74
- `run 'nx run ${options.name}:pod-install' to install native modules before running iOS app`,
75
- ],
76
- });
77
- }
33
+ const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson);
34
+ const detoxTask = await (0, add_detox_1.addDetox)(host, options);
35
+ const symlinkTask = (0, symlink_task_1.runSymlink)(host.root, options.appProjectRoot);
36
+ const chmodTaskGradlew = (0, chmod_android_gradle_files_1.chmodAndroidGradlewFilesTask)((0, devkit_1.joinPathFragments)(host.root, options.androidProjectRoot));
78
37
  if (!options.skipFormat) {
79
38
  await (0, devkit_1.formatFiles)(host);
80
39
  }
81
- tasks.push(() => {
82
- (0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
83
- });
84
- return (0, devkit_1.runTasksInSerial)(...tasks);
40
+ return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask, chmodTaskGradlew);
85
41
  }
86
42
  exports.reactNativeApplicationGeneratorInternal = reactNativeApplicationGeneratorInternal;
87
43
  exports.default = reactNativeApplicationGenerator;
@@ -24,8 +24,6 @@ describe('app', () => {
24
24
  e2eTestRunner: 'none',
25
25
  install: false,
26
26
  projectNameAndRootFormat: 'as-provided',
27
- unitTestRunner: 'none',
28
- bundler: 'vite',
29
27
  });
30
28
  const projects = getProjects(appTree);
31
29
 
@@ -41,8 +39,6 @@ describe('app', () => {
41
39
  e2eTestRunner: 'none',
42
40
  install: false,
43
41
  projectNameAndRootFormat: 'as-provided',
44
- unitTestRunner: 'none',
45
- bundler: 'vite',
46
42
  });
47
43
 
48
44
  const projectConfiguration = readProjectConfiguration(appTree, 'my-app');
@@ -59,8 +55,6 @@ describe('app', () => {
59
55
  e2eTestRunner: 'none',
60
56
  install: false,
61
57
  projectNameAndRootFormat: 'as-provided',
62
- unitTestRunner: 'jest',
63
- bundler: 'vite',
64
58
  });
65
59
  expect(appTree.exists('my-app/src/app/App.tsx')).toBeTruthy();
66
60
  expect(appTree.exists('my-app/src/main.tsx')).toBeTruthy();
@@ -80,17 +74,6 @@ describe('app', () => {
80
74
  moduleNameMapper: {
81
75
  '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
82
76
  },
83
- transform: {
84
- '^.+.(js|ts|tsx)$': [
85
- 'babel-jest',
86
- {
87
- configFile: __dirname + '/.babelrc.js',
88
- },
89
- ],
90
- '^.+.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
91
- 'react-native/jest/assetFileTransformer.js'
92
- ),
93
- },
94
77
  coverageDirectory: '../coverage/my-app',
95
78
  };
96
79
  "
@@ -105,11 +88,9 @@ describe('app', () => {
105
88
  e2eTestRunner: 'none',
106
89
  install: false,
107
90
  projectNameAndRootFormat: 'as-provided',
108
- unitTestRunner: 'jest',
109
- bundler: 'vite',
110
91
  });
111
-
112
- expect(appTree.exists('my-app/jest.config.ts')).toBeTruthy();
92
+ const targets = readProjectConfiguration(appTree, 'my-app').targets;
93
+ expect(targets.test).toBeDefined();
113
94
  });
114
95
 
115
96
  it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
@@ -122,8 +103,6 @@ describe('app', () => {
122
103
  e2eTestRunner: 'none',
123
104
  install: false,
124
105
  projectNameAndRootFormat: 'as-provided',
125
- unitTestRunner: 'none',
126
- bundler: 'vite',
127
106
  });
128
107
 
129
108
  const tsconfig = readJson(appTree, 'my-app/tsconfig.json');
@@ -139,8 +118,6 @@ describe('app', () => {
139
118
  e2eTestRunner: 'detox',
140
119
  install: false,
141
120
  projectNameAndRootFormat: 'as-provided',
142
- bundler: 'vite',
143
- unitTestRunner: 'none',
144
121
  });
145
122
 
146
123
  const projects = getProjects(appTree);
@@ -191,8 +168,6 @@ describe('app', () => {
191
168
  e2eTestRunner: 'detox',
192
169
  install: false,
193
170
  projectNameAndRootFormat: 'as-provided',
194
- bundler: 'vite',
195
- unitTestRunner: 'none',
196
171
  });
197
172
 
198
173
  const projects = getProjects(appTree);
@@ -248,8 +223,6 @@ describe('app', () => {
248
223
  install: false,
249
224
  skipPackageJson: true,
250
225
  projectNameAndRootFormat: 'as-provided',
251
- unitTestRunner: 'none',
252
- bundler: 'webpack',
253
226
  });
254
227
 
255
228
  expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
@@ -3,5 +3,4 @@ source 'https://rubygems.org'
3
3
  # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
4
4
  ruby ">= 2.6.10"
5
5
 
6
- gem 'cocoapods', '~> 1.13'
7
- gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
6
+ gem 'cocoapods', '~> 1.12'
@@ -1,5 +1,4 @@
1
1
  apply plugin: "com.android.application"
2
- apply plugin: "org.jetbrains.kotlin.android"
3
2
  apply plugin: "com.facebook.react"
4
3
 
5
4
  /**
@@ -10,12 +9,12 @@ react {
10
9
  /* Folders */
11
10
  // The root of your project, i.e. where "package.json" lives. Default is '..'
12
11
  // root = file("../")
13
- // The folder where the react-native NPM package is. Default is <%= offsetFromRoot %>../../node_modules/react-native
14
- reactNativeDir = file("<%= offsetFromRoot %>../../node_modules/react-native")
15
- // The folder where the react-native Codegen package is. Default is <%= offsetFromRoot %>../../node_modules/@react-native/codegen
16
- codegenDir = file("<%= offsetFromRoot %>../../node_modules/@react-native/codegen")
17
- // The cli.js file which is the React Native CLI entrypoint. Default is <%= offsetFromRoot %>../../node_modules/react-native/cli.js
18
- cliFile = file("<%= offsetFromRoot %>../../node_modules/react-native/cli.js")
12
+ // The folder where the react-native NPM package is. Default is ../node_modules/react-native
13
+ // reactNativeDir = file("../node_modules/react-native")
14
+ // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
15
+ // codegenDir = file("../node_modules/@react-native/codegen")
16
+ // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
17
+ // cliFile = file("../node_modules/react-native/cli.js")
19
18
 
20
19
  /* Variants */
21
20
  // The list of variants to that are debuggable. For those we're going to
@@ -37,7 +36,7 @@ react {
37
36
  // bundleAssetName = "MyApplication.android.bundle"
38
37
  //
39
38
  // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
40
- entryFile = file("../../<%= entryFile %>")
39
+ // entryFile = file("../js/MyApplication.android.js")
41
40
  //
42
41
  // A list of extra flags to pass to the 'bundle' commands.
43
42
  // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
@@ -49,6 +48,7 @@ react {
49
48
  //
50
49
  // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
51
50
  // hermesFlags = ["-O", "-output-source-map"]
51
+ entryFile = file("../../<%= entryFile %>")
52
52
  }
53
53
 
54
54
  /**
@@ -71,8 +71,8 @@ def jscFlavor = 'org.webkit:android-jsc:+'
71
71
 
72
72
  android {
73
73
  ndkVersion rootProject.ext.ndkVersion
74
- buildToolsVersion rootProject.ext.buildToolsVersion
75
- compileSdk rootProject.ext.compileSdkVersion
74
+
75
+ compileSdkVersion rootProject.ext.compileSdkVersion
76
76
 
77
77
  namespace "com.<%= lowerCaseName %>"
78
78
  defaultConfig {
@@ -81,6 +81,10 @@ android {
81
81
  targetSdkVersion rootProject.ext.targetSdkVersion
82
82
  versionCode 1
83
83
  versionName "1.0"
84
+ <% if (e2eTestRunner === 'detox') { %>
85
+ testBuildType System.getProperty('testBuildType', 'debug')
86
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
87
+ <% } %>
84
88
  }
85
89
  signingConfigs {
86
90
  debug {
@@ -100,15 +104,27 @@ android {
100
104
  signingConfig signingConfigs.debug
101
105
  minifyEnabled enableProguardInReleaseBuilds
102
106
  proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
107
+ <% if (e2eTestRunner === 'detox') { %>
108
+ proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
109
+ <% } %>
103
110
  }
104
111
  }
105
112
  }
106
113
 
107
114
  dependencies {
115
+ <% if (e2eTestRunner === 'detox') { %>
116
+ androidTestImplementation('com.wix:detox:+')
117
+ implementation 'androidx.appcompat:appcompat:1.1.0'
118
+ <% } %>
108
119
  // The version of react-native is set by the React Native Gradle Plugin
109
120
  implementation("com.facebook.react:react-android")
110
- implementation("com.facebook.react:flipper-integration")
111
121
 
122
+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
123
+ debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
124
+ exclude group:'com.squareup.okhttp3', module:'okhttp'
125
+ }
126
+
127
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
112
128
  if (hermesEnabled.toBoolean()) {
113
129
  implementation("com.facebook.react:hermes-android")
114
130
  } else {
@@ -116,4 +132,4 @@ dependencies {
116
132
  }
117
133
  }
118
134
 
119
- apply from: file("<%= offsetFromRoot %>../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
135
+ apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
@@ -2,9 +2,13 @@
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  xmlns:tools="http://schemas.android.com/tools">
4
4
 
5
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6
+
5
7
  <application
6
8
  android:usesCleartextTraffic="true"
7
9
  tools:targetApi="28"
8
- android:networkSecurityConfig="@xml/network_security_config"
9
- tools:ignore="GoogleAppIndexingWarning"/>
10
+ tools:ignore="GoogleAppIndexingWarning"
11
+ android:networkSecurityConfig="@xml/network_security_config">
12
+ <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
13
+ </application>
10
14
  </manifest>
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
+ * directory of this source tree.
6
+ */
7
+ package com.<%= lowerCaseName %>;
8
+
9
+ import android.content.Context;
10
+ import com.facebook.flipper.android.AndroidFlipperClient;
11
+ import com.facebook.flipper.android.utils.FlipperUtils;
12
+ import com.facebook.flipper.core.FlipperClient;
13
+ import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14
+ import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15
+ import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16
+ import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17
+ import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18
+ import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19
+ import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20
+ import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
21
+ import com.facebook.react.ReactInstanceEventListener;
22
+ import com.facebook.react.ReactInstanceManager;
23
+ import com.facebook.react.bridge.ReactContext;
24
+ import com.facebook.react.modules.network.NetworkingModule;
25
+ import okhttp3.OkHttpClient;
26
+
27
+ /**
28
+ * Class responsible of loading Flipper inside your React Native application. This is the debug
29
+ * flavor of it. Here you can add your own plugins and customize the Flipper setup.
30
+ */
31
+ public class ReactNativeFlipper {
32
+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
33
+ if (FlipperUtils.shouldEnableFlipper(context)) {
34
+ final FlipperClient client = AndroidFlipperClient.getInstance(context);
35
+
36
+ client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
37
+ client.addPlugin(new DatabasesFlipperPlugin(context));
38
+ client.addPlugin(new SharedPreferencesFlipperPlugin(context));
39
+ client.addPlugin(CrashReporterPlugin.getInstance());
40
+
41
+ NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
42
+ NetworkingModule.setCustomClientBuilder(
43
+ new NetworkingModule.CustomClientBuilder() {
44
+ @Override
45
+ public void apply(OkHttpClient.Builder builder) {
46
+ builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
47
+ }
48
+ });
49
+ client.addPlugin(networkFlipperPlugin);
50
+ client.start();
51
+
52
+ // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
53
+ // Hence we run if after all native modules have been initialized
54
+ ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
55
+ if (reactContext == null) {
56
+ reactInstanceManager.addReactInstanceEventListener(
57
+ new ReactInstanceEventListener() {
58
+ @Override
59
+ public void onReactContextInitialized(ReactContext reactContext) {
60
+ reactInstanceManager.removeReactInstanceEventListener(this);
61
+ reactContext.runOnNativeModulesQueueThread(
62
+ new Runnable() {
63
+ @Override
64
+ public void run() {
65
+ client.addPlugin(new FrescoFlipperPlugin());
66
+ }
67
+ });
68
+ }
69
+ });
70
+ } else {
71
+ client.addPlugin(new FrescoFlipperPlugin());
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,32 @@
1
+ package com.<%= lowerCaseName %>;
2
+
3
+ import com.facebook.react.ReactActivity;
4
+ import com.facebook.react.ReactActivityDelegate;
5
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
6
+ import com.facebook.react.defaults.DefaultReactActivityDelegate;
7
+
8
+ public class MainActivity extends ReactActivity {
9
+
10
+ /**
11
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
12
+ * rendering of the component.
13
+ */
14
+ @Override
15
+ protected String getMainComponentName() {
16
+ return "<%= className %>";
17
+ }
18
+
19
+ /**
20
+ * Returns the instance of the {@link ReactActivityDelegate}. Here we use a util class {@link
21
+ * DefaultReactActivityDelegate} which allows you to easily enable Fabric and Concurrent React
22
+ * (aka React 18) with two boolean flags.
23
+ */
24
+ @Override
25
+ protected ReactActivityDelegate createReactActivityDelegate() {
26
+ return new DefaultReactActivityDelegate(
27
+ this,
28
+ getMainComponentName(),
29
+ // If you opted-in for the New Architecture, we enable the Fabric Renderer.
30
+ DefaultNewArchitectureEntryPoint.getFabricEnabled());
31
+ }
32
+ }
@@ -0,0 +1,62 @@
1
+ package com.<%= lowerCaseName %>;
2
+
3
+ import android.app.Application;
4
+ import com.facebook.react.PackageList;
5
+ import com.facebook.react.ReactApplication;
6
+ import com.facebook.react.ReactNativeHost;
7
+ import com.facebook.react.ReactPackage;
8
+ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
9
+ import com.facebook.react.defaults.DefaultReactNativeHost;
10
+ import com.facebook.soloader.SoLoader;
11
+ import java.util.List;
12
+
13
+ public class MainApplication extends Application implements ReactApplication {
14
+
15
+ private final ReactNativeHost mReactNativeHost =
16
+ new DefaultReactNativeHost(this) {
17
+ @Override
18
+ public boolean getUseDeveloperSupport() {
19
+ return BuildConfig.DEBUG;
20
+ }
21
+
22
+ @Override
23
+ protected List<ReactPackage> getPackages() {
24
+ @SuppressWarnings("UnnecessaryLocalVariable")
25
+ List<ReactPackage> packages = new PackageList(this).getPackages();
26
+ // Packages that cannot be autolinked yet can be added manually here, for example:
27
+ // packages.add(new MyReactNativePackage());
28
+ return packages;
29
+ }
30
+
31
+ @Override
32
+ protected String getJSMainModuleName() {
33
+ return "<%= entryFile %>";
34
+ }
35
+
36
+ @Override
37
+ protected boolean isNewArchEnabled() {
38
+ return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
39
+ }
40
+
41
+ @Override
42
+ protected Boolean isHermesEnabled() {
43
+ return BuildConfig.IS_HERMES_ENABLED;
44
+ }
45
+ };
46
+
47
+ @Override
48
+ public ReactNativeHost getReactNativeHost() {
49
+ return mReactNativeHost;
50
+ }
51
+
52
+ @Override
53
+ public void onCreate() {
54
+ super.onCreate();
55
+ SoLoader.init(this, /* native exopackage */ false);
56
+ if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
57
+ // If you opted-in for the New Architecture, we load the native entry point for this app.
58
+ DefaultNewArchitectureEntryPoint.load();
59
+ }
60
+ ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
61
+ }
62
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
+ * directory of this source tree.
6
+ */
7
+ package com.<%= lowerCaseName %>;
8
+
9
+ import android.content.Context;
10
+ import com.facebook.react.ReactInstanceManager;
11
+
12
+ /**
13
+ * Class responsible of loading Flipper inside your React Native application. This is the release
14
+ * flavor of it so it's empty as we don't want to load Flipper.
15
+ */
16
+ public class ReactNativeFlipper {
17
+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
18
+ // Do nothing as we don't want to initialize Flipper on Release.
19
+ }
20
+ }
@@ -1,11 +1,15 @@
1
+ // Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+
1
3
  buildscript {
2
4
  ext {
3
- buildToolsVersion = "34.0.0"
5
+ buildToolsVersion = "33.0.0"
4
6
  minSdkVersion = 21
5
- compileSdkVersion = 34
6
- targetSdkVersion = 34
7
- ndkVersion = "25.1.8937393"
8
- kotlinVersion = "1.8.0"
7
+ compileSdkVersion = 33
8
+ targetSdkVersion = 33
9
+ kotlinVersion = "1.8.20"
10
+
11
+ // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
12
+ ndkVersion = "23.1.7779620"
9
13
  }
10
14
  repositories {
11
15
  google()
@@ -14,8 +18,17 @@ buildscript {
14
18
  dependencies {
15
19
  classpath("com.android.tools.build:gradle")
16
20
  classpath("com.facebook.react:react-native-gradle-plugin")
17
- classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
21
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
18
22
  }
19
23
  }
20
24
 
21
- apply plugin: "com.facebook.react.rootproject"
25
+ allprojects {
26
+ repositories {
27
+ <% if (e2eTestRunner === 'detox') { %>
28
+ maven {
29
+ // https://wix.github.io/Detox/docs/introduction/project-setup
30
+ url("$rootDir/../node_modules/detox/Detox-android")
31
+ }
32
+ <% } %>
33
+ }
34
+ }
@@ -1,7 +1,6 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
4
4
  networkTimeout=10000
5
- validateDistributionUrl=true
6
5
  zipStoreBase=GRADLE_USER_HOME
7
6
  zipStorePath=wrapper/dists
@@ -24,6 +24,9 @@ android.useAndroidX=true
24
24
  # Automatically convert third-party libraries to use AndroidX
25
25
  android.enableJetifier=true
26
26
 
27
+ # Version of flipper SDK to use with React Native
28
+ FLIPPER_VERSION=0.182.0
29
+
27
30
  # Use this property to specify which architecture you want to build.
28
31
  # You can also override it from the CLI using
29
32
  # ./gradlew <task> -PreactNativeArchitectures=x86_64
@@ -83,8 +83,10 @@ done
83
83
  # This is normally unused
84
84
  # shellcheck disable=SC2034
85
85
  APP_BASE_NAME=${0##*/}
86
- # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87
- APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
86
+ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87
+
88
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
88
90
 
89
91
  # Use the maximum available, or set MAX_FD != -1 to use that value.
90
92
  MAX_FD=maximum
@@ -131,13 +133,10 @@ location of your Java installation."
131
133
  fi
132
134
  else
133
135
  JAVACMD=java
134
- if ! command -v java >/dev/null 2>&1
135
- then
136
- die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
136
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137
137
 
138
138
  Please set the JAVA_HOME variable in your environment to match the
139
139
  location of your Java installation."
140
- fi
141
140
  fi
142
141
 
143
142
  # Increase the maximum file descriptors if we can.
@@ -145,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
145
144
  case $MAX_FD in #(
146
145
  max*)
147
146
  # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148
- # shellcheck disable=SC3045
147
+ # shellcheck disable=SC3045
149
148
  MAX_FD=$( ulimit -H -n ) ||
150
149
  warn "Could not query maximum file descriptor limit"
151
150
  esac
@@ -153,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
153
152
  '' | soft) :;; #(
154
153
  *)
155
154
  # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156
- # shellcheck disable=SC3045
155
+ # shellcheck disable=SC3045
157
156
  ulimit -n "$MAX_FD" ||
158
157
  warn "Could not set maximum file descriptor limit to $MAX_FD"
159
158
  esac
@@ -198,10 +197,6 @@ if "$cygwin" || "$msys" ; then
198
197
  done
199
198
  fi
200
199
 
201
-
202
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203
- DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204
-
205
200
  # Collect all arguments for the java command;
206
201
  # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
207
202
  # shell script including quotes and variable substitutions, so put them in
@@ -1,4 +1,4 @@
1
1
  rootProject.name = '<%= className %>'
2
- apply from: file("<%= offsetFromRoot %>../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
2
+ apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
3
3
  include ':app'
4
- includeBuild('<%= offsetFromRoot %>../node_modules/@react-native/gradle-plugin')
4
+ includeBuild('../node_modules/@react-native/gradle-plugin')
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": ["module:metro-react-native-babel-preset"]
3
+ }
@@ -28,8 +28,14 @@ end
28
28
  target '<%= className %>' do
29
29
  config = use_native_modules!
30
30
 
31
+ # Flags change depending on the env values.
32
+ flags = get_default_flags()
33
+
31
34
  use_react_native!(
32
35
  :path => config[:reactNativePath],
36
+ # Hermes is now enabled by default. Disable by setting this flag to false.
37
+ :hermes_enabled => flags[:hermes_enabled],
38
+ :fabric_enabled => flags[:fabric_enabled],
33
39
  # Enables Flipper.
34
40
  #
35
41
  # Note that if you have use_frameworks! enabled, Flipper will not work and
@@ -51,5 +57,6 @@ target '<%= className %>' do
51
57
  config[:reactNativePath],
52
58
  :mac_catalyst_enabled => false
53
59
  )
60
+ __apply_Xcode_12_5_M1_post_install_workaround(installer)
54
61
  end
55
62
  end