@nrwl/react-native 14.0.0-beta.2 → 14.0.0-beta.5

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 (70) hide show
  1. package/.eslintrc.json +5 -0
  2. package/migrations.json +58 -0
  3. package/package.json +8 -8
  4. package/plugins/metro-resolver.js +16 -20
  5. package/plugins/metro-resolver.js.map +1 -1
  6. package/plugins/with-nx-metro.d.ts +2 -0
  7. package/plugins/with-nx-metro.js +16 -3
  8. package/plugins/with-nx-metro.js.map +1 -1
  9. package/src/generators/application/files/app/android/app/build.gradle.template +111 -22
  10. package/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +1 -1
  11. package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +4 -3
  12. package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +4 -3
  13. package/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +26 -46
  14. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +27 -2
  15. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +13 -2
  16. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/MainApplicationReactNativeHost.java.template +116 -0
  17. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/components/MainComponentsRegistry.java.template +36 -0
  18. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java.template +48 -0
  19. package/src/generators/application/files/app/android/app/src/main/jni/Android.mk.template +49 -0
  20. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.cpp +24 -0
  21. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationModuleProvider.h +16 -0
  22. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +45 -0
  23. package/src/generators/application/files/app/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h.template +38 -0
  24. package/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.cpp +61 -0
  25. package/src/generators/application/files/app/android/app/src/main/jni/MainComponentsRegistry.h.template +32 -0
  26. package/src/generators/application/files/app/android/app/src/main/jni/OnLoad.cpp +11 -0
  27. package/src/generators/application/files/app/android/build.gradle.template +22 -9
  28. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  29. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -2
  30. package/src/generators/application/files/app/android/gradle.properties +15 -10
  31. package/src/generators/application/files/app/android/gradlew.bat +234 -89
  32. package/src/generators/application/files/app/android/gradlew.template +154 -105
  33. package/src/generators/application/files/app/android/settings.gradle.template +6 -0
  34. package/src/generators/application/files/app/ios/Podfile.template +9 -2
  35. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +108 -0
  36. package/src/generators/application/files/app/ios/__className__/Images.xcassets/AppIcon.appiconset/Contents.json +29 -14
  37. package/src/generators/application/files/app/ios/__className__/main.m +3 -3
  38. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +48 -37
  39. package/src/generators/application/files/app/metro.config.js.template +5 -1
  40. package/src/generators/application/files/app/src/app/App.spec.tsx.template +1 -1
  41. package/src/generators/application/files/app/src/main.tsx.template +1 -1
  42. package/src/generators/application/files/app/tsconfig.app.json.template +1 -1
  43. package/src/generators/application/lib/add-project.js +2 -2
  44. package/src/generators/application/lib/add-project.js.map +1 -1
  45. package/src/generators/application/lib/create-application-files.js +1 -1
  46. package/src/generators/application/lib/create-application-files.js.map +1 -1
  47. package/src/generators/application/lib/nomalize-options.spec.ts +5 -10
  48. package/src/generators/application/lib/normalize-options.d.ts +0 -1
  49. package/src/generators/application/lib/normalize-options.js +2 -4
  50. package/src/generators/application/lib/normalize-options.js.map +1 -1
  51. package/src/generators/init/init.js +2 -8
  52. package/src/generators/init/init.js.map +1 -1
  53. package/src/generators/init/init.spec.ts +0 -25
  54. package/src/generators/init/lib/gitignore-entries.d.ts +1 -1
  55. package/src/generators/init/lib/gitignore-entries.js +25 -17
  56. package/src/generators/init/lib/gitignore-entries.js.map +1 -1
  57. package/src/generators/library/library.spec.ts +1 -1
  58. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.d.ts +6 -0
  59. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js +35 -0
  60. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js.map +1 -0
  61. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.spec.ts +188 -0
  62. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.d.ts +5 -0
  63. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js +39 -0
  64. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js.map +1 -0
  65. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.spec.ts +84 -0
  66. package/src/utils/add-jest.js +2 -2
  67. package/src/utils/versions.d.ts +7 -8
  68. package/src/utils/versions.js +9 -13
  69. package/src/utils/versions.js.map +1 -1
  70. package/src/generators/application/files/app/ios/__className__/AppDelegate.m.template +0 -62
package/.eslintrc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "../../.eslintrc",
3
+ "rules": {},
4
+ "ignorePatterns": ["!**/*"]
5
+ }
package/migrations.json CHANGED
@@ -23,6 +23,18 @@
23
23
  "cli": "nx",
24
24
  "description": "Add babel.config.json at root for react native workspace if it does not exist",
25
25
  "factory": "./src/migrations/update-13-5-0/add-babel-config-root-13-5-0"
26
+ },
27
+ "update-entry-file-bundle-14-0-0": {
28
+ "version": "14.0.0-beta.0",
29
+ "cli": "nx",
30
+ "description": "Udpate the entry file option under bundle target",
31
+ "factory": "./src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0"
32
+ },
33
+ "add-project-root-metro-config-14-0-0": {
34
+ "version": "14.0.0-beta.0",
35
+ "cli": "nx",
36
+ "description": "Add projectRoot option in metro.config.js",
37
+ "factory": "./src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0"
26
38
  }
27
39
  },
28
40
  "packageJsonUpdates": {
@@ -469,6 +481,52 @@
469
481
  "alwaysAddToPackageJson": false
470
482
  }
471
483
  }
484
+ },
485
+ "14.0.0-beta.0": {
486
+ "version": "14.0.0-beta.0",
487
+ "packages": {
488
+ "react-native": {
489
+ "version": "0.68.1",
490
+ "alwaysAddToPackageJson": false
491
+ },
492
+ "@types/react-native": {
493
+ "version": "0.67.4",
494
+ "alwaysAddToPackageJson": false
495
+ },
496
+ "metro": {
497
+ "version": "0.70.1",
498
+ "alwaysAddToPackageJson": false
499
+ },
500
+ "metro-resolver": {
501
+ "version": "0.70.1",
502
+ "alwaysAddToPackageJson": false
503
+ },
504
+ "metro-babel-register": {
505
+ "version": "0.70.1",
506
+ "alwaysAddToPackageJson": false,
507
+ "addToPackageJson": "devDependencies"
508
+ },
509
+ "metro-config": {
510
+ "version": "0.70.1",
511
+ "alwaysAddToPackageJson": false
512
+ },
513
+ "@react-native-community/cli": {
514
+ "version": "7.0.3",
515
+ "alwaysAddToPackageJson": false
516
+ },
517
+ "metro-react-native-babel-preset": {
518
+ "version": "0.70.1",
519
+ "alwaysAddToPackageJson": false
520
+ },
521
+ "react-test-renderer": {
522
+ "version": "18.0.0",
523
+ "alwaysAddToPackageJson": false
524
+ },
525
+ "@babel/runtime": {
526
+ "version": "7.17.9",
527
+ "alwaysAddToPackageJson": false
528
+ }
529
+ }
472
530
  }
473
531
  }
474
532
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrwl/react-native",
3
- "version": "14.0.0-beta.2",
3
+ "version": "14.0.0-beta.5",
4
4
  "description": "React Native brings React's declarative UI framework to iOS and Android. With React Native, you use native UI controls and have full access to the native platform.\n\nThe Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Detox, and Storybook.\n\n- Scaffolding for creating buildable libraries that can be published to npm.\n\n- Utilities for automatic workspace refactoring.",
5
5
  "keywords": [
6
6
  "Monorepo",
@@ -24,13 +24,13 @@
24
24
  "main": "index.js",
25
25
  "types": "index.d.ts",
26
26
  "dependencies": {
27
- "@nrwl/detox": "14.0.0-beta.2",
28
- "@nrwl/devkit": "14.0.0-beta.2",
29
- "@nrwl/jest": "14.0.0-beta.2",
30
- "@nrwl/linter": "14.0.0-beta.2",
31
- "@nrwl/storybook": "14.0.0-beta.2",
32
- "@nrwl/react": "14.0.0-beta.2",
33
- "@nrwl/workspace": "14.0.0-beta.2",
27
+ "@nrwl/detox": "14.0.0-beta.5",
28
+ "@nrwl/devkit": "14.0.0-beta.5",
29
+ "@nrwl/jest": "14.0.0-beta.5",
30
+ "@nrwl/linter": "14.0.0-beta.5",
31
+ "@nrwl/storybook": "14.0.0-beta.5",
32
+ "@nrwl/react": "14.0.0-beta.5",
33
+ "@nrwl/workspace": "14.0.0-beta.5",
34
34
  "chalk": "^4.1.0",
35
35
  "enhanced-resolve": "^5.8.3",
36
36
  "fs-extra": "^9.1.0",
@@ -21,9 +21,9 @@ function getResolveRequest(extensions) {
21
21
  if (DEBUG)
22
22
  console.log(chalk.cyan(`[Nx] Resolving: ${moduleName}`));
23
23
  const { resolveRequest } = _context, context = tslib_1.__rest(_context, ["resolveRequest"]);
24
- const resolvedPath = defaultMetroResolver(context, moduleName, platform) ||
25
- tsconfigPathsResolver(context, extensions, realModuleName, moduleName, platform) ||
26
- pnpmResolver(extensions, context, realModuleName, moduleName);
24
+ const resolvedPath = defaultMetroResolver(context, moduleName, platform, DEBUG) ||
25
+ tsconfigPathsResolver(context, extensions, realModuleName, moduleName, platform, DEBUG) ||
26
+ pnpmResolver(extensions, context, realModuleName, moduleName, DEBUG);
27
27
  if (resolvedPath) {
28
28
  return resolvedPath;
29
29
  }
@@ -35,13 +35,12 @@ exports.getResolveRequest = getResolveRequest;
35
35
  * This function try to resolve path using metro's default resolver
36
36
  * @returns path if resolved, else undefined
37
37
  */
38
- function defaultMetroResolver(context, moduleName, platform) {
39
- const DEBUG = process.env.NX_REACT_NATIVE_DEBUG === 'true';
38
+ function defaultMetroResolver(context, moduleName, platform, debug) {
40
39
  try {
41
40
  return metroResolver.resolve(context, moduleName, platform);
42
41
  }
43
42
  catch (_a) {
44
- if (DEBUG)
43
+ if (debug)
45
44
  console.log(chalk.cyan(`[Nx] Unable to resolve with default Metro resolver: ${moduleName}`));
46
45
  }
47
46
  }
@@ -50,18 +49,17 @@ function defaultMetroResolver(context, moduleName, platform) {
50
49
  * @returns path if resolved, else undefined
51
50
  * This pnpm resolver is inspired from https://github.com/vjpr/pnpm-react-native-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js
52
51
  */
53
- function pnpmResolver(extensions, context, realModuleName, moduleName) {
54
- const DEBUG = process.env.NX_REACT_NATIVE_DEBUG === 'true';
52
+ function pnpmResolver(extensions, context, realModuleName, moduleName, debug) {
55
53
  try {
56
- const pnpmResolver = getPnpmResolver(devkit_1.workspaceRoot, extensions);
54
+ const pnpmResolve = getPnpmResolver(extensions);
57
55
  const lookupStartPath = (0, path_1.dirname)(context.originModulePath);
58
- const filePath = pnpmResolver.resolveSync({}, lookupStartPath, realModuleName);
56
+ const filePath = pnpmResolve.resolveSync({}, lookupStartPath, realModuleName);
59
57
  if (filePath) {
60
58
  return { type: 'sourceFile', filePath };
61
59
  }
62
60
  }
63
61
  catch (_a) {
64
- if (DEBUG)
62
+ if (debug)
65
63
  console.log(chalk.cyan(`[Nx] Unable to resolve with default PNPM resolver: ${moduleName}`));
66
64
  }
67
65
  }
@@ -69,15 +67,14 @@ function pnpmResolver(extensions, context, realModuleName, moduleName) {
69
67
  * This function try to resolve files that are specified in tsconfig's paths
70
68
  * @returns path if resolved, else undefined
71
69
  */
72
- function tsconfigPathsResolver(context, extensions, realModuleName, moduleName, platform) {
73
- const DEBUG = process.env.NX_REACT_NATIVE_DEBUG === 'true';
74
- const matcher = getMatcher();
75
- const match = matcher(realModuleName, undefined, undefined, extensions.map((ext) => `.${ext}`));
70
+ function tsconfigPathsResolver(context, extensions, realModuleName, moduleName, platform, debug) {
71
+ const tsConfigPathMatcher = getMatcher(debug);
72
+ const match = tsConfigPathMatcher(realModuleName, undefined, undefined, extensions.map((ext) => `.${ext}`));
76
73
  if (match) {
77
74
  return metroResolver.resolve(context, match, platform);
78
75
  }
79
76
  else {
80
- if (DEBUG) {
77
+ if (debug) {
81
78
  console.log(chalk.red(`[Nx] Failed to resolve ${chalk.bold(moduleName)}`));
82
79
  console.log(chalk.cyan(`[Nx] The following tsconfig paths was used:\n:${chalk.bold(JSON.stringify(paths, null, 2))}`));
83
80
  }
@@ -86,8 +83,7 @@ function tsconfigPathsResolver(context, extensions, realModuleName, moduleName,
86
83
  let matcher;
87
84
  let absoluteBaseUrl;
88
85
  let paths;
89
- function getMatcher() {
90
- const DEBUG = process.env.NX_REACT_NATIVE_DEBUG === 'true';
86
+ function getMatcher(DEBUG) {
91
87
  if (!matcher) {
92
88
  const result = (0, tsconfig_paths_1.loadConfig)();
93
89
  if (result.resultType === 'success') {
@@ -111,14 +107,14 @@ function getMatcher() {
111
107
  * It is inspired form https://github.com/vjpr/pnpm-expo-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js.
112
108
  */
113
109
  let resolver;
114
- function getPnpmResolver(workspaceRoot, extensions) {
110
+ function getPnpmResolver(extensions) {
115
111
  if (!resolver) {
116
112
  const fileSystem = new enhanced_resolve_1.CachedInputFileSystem(fs, 4000);
117
113
  resolver = enhanced_resolve_1.ResolverFactory.createResolver({
118
114
  fileSystem,
119
115
  extensions: extensions.map((extension) => '.' + extension),
120
116
  useSyncFileSystemCalls: true,
121
- modules: [(0, path_1.join)(workspaceRoot, 'node_modules'), 'node_modules'],
117
+ modules: [(0, path_1.join)(devkit_1.workspaceRoot, 'node_modules'), 'node_modules'],
122
118
  });
123
119
  }
124
120
  return resolver;
@@ -1 +1 @@
1
- {"version":3,"file":"metro-resolver.js","sourceRoot":"","sources":["../../../../packages/react-native/plugins/metro-resolver.ts"],"names":[],"mappings":";;;;AAAA,gDAAgD;AAEhD,mDAA6D;AAC7D,+BAA+B;AAC/B,uDAA0E;AAC1E,+BAAqC;AACrC,yBAAyB;AACzB,yCAA6C;AAE7C;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,UAAoB;IACpD,OAAO,UACL,QAAa,EACb,cAAsB,EACtB,QAAuB,EACvB,UAAkB;QAElB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,CAAC;QAE3D,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC,CAAC;QAEpE,MAAM,EAAE,cAAc,KAAiB,QAAQ,EAApB,OAAO,kBAAK,QAAQ,EAAzC,kBAA8B,CAAW,CAAC;QAEhD,MAAM,YAAY,GAChB,oBAAoB,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;YACnD,qBAAqB,CACnB,OAAO,EACP,UAAU,EACV,cAAc,EACd,UAAU,EACV,QAAQ,CACT;YACD,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;QAEhE,IAAI,YAAY,EAAE;YAChB,OAAO,YAAY,CAAC;SACrB;QACD,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC;AA7BD,8CA6BC;AAED;;;GAGG;AACH,SAAS,oBAAoB,CAC3B,OAAY,EACZ,UAAkB,EAClB,QAAgB;IAEhB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,CAAC;IAC3D,IAAI;QACF,OAAO,aAAa,CAAC,OAAO,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AK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACxD;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,IAAI,QAAQ,CAAC;AACb,SAAS,eAAe,CAAC,aAAqB,EAAE,UAAoB;IAClE,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,UAAU,GAAG,IAAI,wCAAqB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACvD,QAAQ,GAAG,kCAAe,CAAC,cAAc,CAAC;YACxC,UAAU;YACV,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,GAAG,SAAS,CAAC;YAC1D,sBAAsB,EAAE,IAAI;YAC5B,OAAO,EAAE,CAAC,IAAA,WAAI,EAAC,aAAa,EAAE,cAAc,CAAC,EAAE,cAAc,CAAC;SAC/D,CAAC,CAAC;KACJ;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"metro-resolver.js","sourceRoot":"","sources":["../../../../packages/react-native/plugins/metro-resolver.ts"],"names":[],"mappings":";;;;AAAA,gDAAgD;AAEhD,mDAA6D;AAC7D,+BAA+B;AAC/B,uDAA0E;AAC1E,+BAAqC;AACrC,yBAAyB;AACzB,yCAA6C;AAE7C;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,UAAoB;IACpD,OAAO,UACL,QAAa,EACb,cAAsB,EACtB,QAAuB,EACvB,UAAkB;QAElB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,CAAC;QAE3D,IAAI,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC,CAAC;QAEpE,MAAM,EAAE,cAAc,KAAiB,QAAQ,EAApB,OAAO,kBAAK,QAAQ,EAAzC,kB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gBACT,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CAAC,4BAA4B,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CACtE,CAAC;gBACF,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CACR,qCAAqC,KAAK,CAAC,IAAI,CAC7C,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAC/B,EAAE,CACJ,CACF,CAAC;aACH;YACD,OAAO,GAAG,IAAA,gCAAe,EAAC,eAAe,EAAE,KAAK,CAAC,CAAC;SACnD;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACxD;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,IAAI,QAAQ,CAAC;AACb,SAAS,eAAe,CAAC,UAAoB;IAC3C,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,UAAU,GAAG,IAAI,wCAAqB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACvD,QAAQ,GAAG,kCAAe,CAAC,cAAc,CAAC;YACxC,UAAU;YACV,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,GAAG,SAAS,CAAC;YAC1D,sBAAsB,EAAE,IAAI;YAC5B,OAAO,EAAE,CAAC,IAAA,WAAI,EAAC,sBAAa,EAAE,cAAc,CAAC,EAAE,cAAc,CAAC;SAC/D,CAAC,CAAC;KACJ;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,6 +1,8 @@
1
1
  interface WithNxOptions {
2
2
  debug?: boolean;
3
3
  extensions?: string[];
4
+ projectRoot?: string;
5
+ watchFolders?: string[];
4
6
  }
5
7
  export declare function withNxMetro(config: any, opts?: WithNxOptions): any;
6
8
  export {};
@@ -1,18 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNxMetro = void 0;
4
- const app_root_1 = require("@nrwl/workspace/src/utils/app-root");
4
+ const devkit_1 = require("@nrwl/devkit");
5
+ const path_1 = require("path");
6
+ const fs_extra_1 = require("fs-extra");
5
7
  const metro_resolver_1 = require("./metro-resolver");
6
8
  function withNxMetro(config, opts = {}) {
9
+ var _a;
7
10
  const extensions = ['', 'ts', 'tsx', 'js', 'jsx', 'json'];
8
11
  if (opts.debug)
9
12
  process.env.NX_REACT_NATIVE_DEBUG = 'true';
10
13
  if (opts.extensions)
11
14
  extensions.push(...opts.extensions);
12
- // Set the root to workspace root so we can resolve modules and assets
13
- config.projectRoot = app_root_1.workspaceRoot;
15
+ config.projectRoot = opts.projectRoot || devkit_1.workspaceRoot;
14
16
  // Add support for paths specified by tsconfig
15
17
  config.resolver = Object.assign(Object.assign({}, config.resolver), { resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions) });
18
+ let watchFolders = config.watchFolders || [];
19
+ watchFolders = watchFolders.concat([
20
+ (0, path_1.join)(devkit_1.workspaceRoot, 'node_modules'),
21
+ (0, path_1.join)(devkit_1.workspaceRoot, (0, devkit_1.workspaceLayout)().libsDir),
22
+ (0, path_1.join)(devkit_1.workspaceRoot, '.storybook'),
23
+ ]);
24
+ if ((_a = opts.watchFolders) === null || _a === void 0 ? void 0 : _a.length) {
25
+ watchFolders = watchFolders.concat(opts.watchFolders);
26
+ }
27
+ watchFolders = watchFolders.filter((folder) => (0, fs_extra_1.existsSync)(folder));
28
+ config.watchFolders = watchFolders;
16
29
  return config;
17
30
  }
18
31
  exports.withNxMetro = withNxMetro;
@@ -1 +1 @@
1
- {"version":3,"file":"with-nx-metro.js","sourceRoot":"","sources":["../../../../packages/react-native/plugins/with-nx-metro.ts"],"names":[],"mappings":";;;AAAA,iEAAmE;AACnE,qDAAqD;AAOrD,SAAgB,WAAW,CAAC,MAAW,EAAE,O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AC,GAC9C,CAAC;IAEF,IAAI,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC;QACjC,IAAA,WAAI,EAAC,sBAAa,EAAE,cAAc,CAAC;QACnC,IAAA,WAAI,EAAC,sBAAa,EAAE,IAAA,wBAAe,GAAE,CAAC,OAAO,CAAC;QAC9C,IAAA,WAAI,EAAC,sBAAa,EAAE,YAAY,CAAC;KAClC,CAAC,CAAC;IACH,IAAI,MAAA,IAAI,CAAC,YAAY,0CAAE,MAAM,EAAE;QAC7B,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACvD;IAED,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAC,CAAC;IACnE,MAAM,CAAC,YAAY,GAAG,YAAY,CAAC;IAEnC,OAAO,MAAM,CAAC;AAChB,CAAC;AA3BD,kCA2BC"}
@@ -2,6 +2,7 @@ apply plugin: "com.android.application"
2
2
  apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
3
3
 
4
4
  import com.android.build.OutputFile
5
+ import org.apache.tools.ant.taskdefs.condition.Os
5
6
 
6
7
  /**
7
8
  * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -79,7 +80,8 @@ import com.android.build.OutputFile
79
80
  */
80
81
 
81
82
  project.ext.react = [
82
- entryFile: "<%= entryFileRelativeToRoot %>",
83
+ // the entry file for bundle generation
84
+ entryFile: "<%= entryFile %>",
83
85
  enableHermes: false, // clean and rebuild if changing
84
86
  ]
85
87
 
@@ -123,9 +125,12 @@ def jscFlavor = 'org.webkit:android-jsc:+'
123
125
  def enableHermes = project.ext.react.get("enableHermes", false);
124
126
 
125
127
  /**
126
- * Architectures to build native code for in debug.
128
+ * Architectures to build native code for.
127
129
  */
128
- def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures")
130
+ def reactNativeArchitectures() {
131
+ def value = project.getProperties().get("reactNativeArchitectures")
132
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
133
+ }
129
134
 
130
135
  android {
131
136
  ndkVersion rootProject.ext.ndkVersion
@@ -138,17 +143,91 @@ android {
138
143
  targetSdkVersion rootProject.ext.targetSdkVersion
139
144
  versionCode 1
140
145
  versionName "1.0"
146
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
141
147
  <% if (e2eTestRunner === 'detox') { %>
142
148
  testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
143
149
  testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
144
150
  <% } %>
151
+
152
+ if (isNewArchitectureEnabled()) {
153
+ // We configure the NDK build only if you decide to opt-in for the New Architecture.
154
+ externalNativeBuild {
155
+ ndkBuild {
156
+ arguments "APP_PLATFORM=android-21",
157
+ "APP_STL=c++_shared",
158
+ "NDK_TOOLCHAIN_VERSION=clang",
159
+ "GENERATED_SRC_DIR=$buildDir/generated/source",
160
+ "PROJECT_BUILD_DIR=$buildDir",
161
+ "REACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
162
+ "REACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build"
163
+ cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
164
+ cppFlags "-std=c++17"
165
+ // Make sure this target name is the same you specify inside the
166
+ // src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
167
+ targets "<%= lowerCaseName %>_appmodules"
168
+
169
+ // Fix for windows limit on number of character in file paths and in command lines
170
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
171
+ arguments "NDK_OUT=${rootProject.projectDir.getParent()}\\.cxx",
172
+ "NDK_APP_SHORT_COMMANDS=true"
173
+ }
174
+ }
175
+ }
176
+ if (!enableSeparateBuildPerCPUArchitecture) {
177
+ ndk {
178
+ abiFilters (*reactNativeArchitectures())
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ if (isNewArchitectureEnabled()) {
185
+ // We configure the NDK build only if you decide to opt-in for the New Architecture.
186
+ externalNativeBuild {
187
+ ndkBuild {
188
+ path "$projectDir/src/main/jni/Android.mk"
189
+ }
190
+ }
191
+ def reactAndroidProjectDir = project(':ReactAndroid').projectDir
192
+ def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
193
+ dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
194
+ from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
195
+ into("$buildDir/react-ndk/exported")
196
+ }
197
+ def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
198
+ dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
199
+ from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
200
+ into("$buildDir/react-ndk/exported")
201
+ }
202
+ afterEvaluate {
203
+ // If you wish to add a custom TurboModule or component locally,
204
+ // you should uncomment this line.
205
+ // preBuild.dependsOn("generateCodegenArtifactsFromSchema")
206
+ preDebugBuild.dependsOn(packageReactNdkDebugLibs)
207
+ preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
208
+
209
+ // Due to a bug inside AGP, we have to explicitly set a dependency
210
+ // between configureNdkBuild* tasks and the preBuild tasks.
211
+ // This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
212
+ configureNdkBuildRelease.dependsOn(preReleaseBuild)
213
+ configureNdkBuildDebug.dependsOn(preDebugBuild)
214
+ reactNativeArchitectures().each { architecture ->
215
+ tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
216
+ dependsOn("preDebugBuild")
217
+ }
218
+ tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
219
+ dependsOn("preReleaseBuild")
220
+ }
221
+ }
222
+ }
145
223
  }
224
+
146
225
  splits {
147
226
  abi {
148
227
  reset()
149
228
  enable enableSeparateBuildPerCPUArchitecture
150
229
  universalApk false // If true, also generate a universal APK
151
- include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
230
+ include (*reactNativeArchitectures())
152
231
  }
153
232
  }
154
233
  signingConfigs {
@@ -158,33 +237,22 @@ android {
158
237
  keyAlias 'androiddebugkey'
159
238
  keyPassword 'android'
160
239
  }
161
- // In production, you need to generate your own keystore file.
162
- // See: https://reactnative.dev/docs/signed-apk-android
163
- // release {
164
- // if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
165
- // storeFile file(MYAPP_UPLOAD_STORE_FILE)
166
- // storePassword MYAPP_UPLOAD_STORE_PASSWORD
167
- // keyAlias MYAPP_UPLOAD_KEY_ALIAS
168
- // keyPassword MYAPP_UPLOAD_KEY_PASSWORD
169
- // }
170
- // }
171
240
  }
172
241
  buildTypes {
173
242
  debug {
174
243
  signingConfig signingConfigs.debug
175
- if (nativeArchitectures) {
176
- ndk {
177
- abiFilters nativeArchitectures.split(',')
178
- }
179
- }
180
244
  }
181
245
  release {
182
246
  // Caution! In production, you need to generate your own keystore file.
183
247
  // see https://reactnative.dev/docs/signed-apk-android.
184
248
  signingConfig signingConfigs.debug
185
- // signingConfig signingConfigs.release
186
249
  minifyEnabled enableProguardInReleaseBuilds
187
- proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
250
+ // Typical pro-guard definitions
251
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
252
+ <% if (e2eTestRunner === 'detox') { %>
253
+ // Detox-specific additions to pro-guard
254
+ proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
255
+ <% } %>
188
256
  }
189
257
  }
190
258
 
@@ -207,6 +275,7 @@ android {
207
275
 
208
276
  dependencies {
209
277
  implementation fileTree(dir: "libs", include: ["*.jar"])
278
+
210
279
  //noinspection GradleDynamicVersion
211
280
  implementation "com.facebook.react:react-native:+" // From node_modules
212
281
  implementation project(':react-native-config')
@@ -239,6 +308,18 @@ dependencies {
239
308
  <% } %>
240
309
  }
241
310
 
311
+ if (isNewArchitectureEnabled()) {
312
+ // If new architecture is enabled, we let you build RN from source
313
+ // Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
314
+ // This will be applied to all the imported transtitive dependency.
315
+ configurations.all {
316
+ resolutionStrategy.dependencySubstitution {
317
+ substitute(module("com.facebook.react:react-native"))
318
+ .using(project(":ReactAndroid")).because("On New Architecture we're building React Native from source")
319
+ }
320
+ }
321
+ }
322
+
242
323
  // Run this once to be able to run the application with BUCK
243
324
  // puts all compile dependencies into folder libs for BUCK to use
244
325
  task copyDownloadableDepsToLibs(type: Copy) {
@@ -246,4 +327,12 @@ task copyDownloadableDepsToLibs(type: Copy) {
246
327
  into 'libs'
247
328
  }
248
329
 
249
- apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
330
+ apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
331
+
332
+ def isNewArchitectureEnabled() {
333
+ // To opt-in for the New Architecture, you can either:
334
+ // - Set `newArchEnabled` to true inside the `gradle.properties` file
335
+ // - Invoke gradle with `-newArchEnabled=true`
336
+ // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
337
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
338
+ }
@@ -1,4 +1,4 @@
1
- // Replace "com.example" here and below with your app's package name from the top of MainActivity.java
1
+ // Replace "com.<%= lowerCaseName %>" here and below with your app's package name from the top of MainActivity.java
2
2
  package com.<%= lowerCaseName %>;
3
3
 
4
4
  import com.wix.detox.Detox;
@@ -7,7 +7,8 @@
7
7
  <application
8
8
  android:usesCleartextTraffic="true"
9
9
  tools:targetApi="28"
10
- tools:ignore="GoogleAppIndexingWarning">
11
- <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
10
+ tools:ignore="GoogleAppIndexingWarning"
11
+ android:networkSecurityConfig="@xml/network_security_config">
12
+ <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false" />
12
13
  </application>
13
- </manifest>
14
+ </manifest>
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
5
  * directory of this source tree.
@@ -19,6 +19,7 @@ import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19
19
  import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20
20
  import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21
21
  import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22
+ import com.facebook.react.ReactInstanceEventListener;
22
23
  import com.facebook.react.ReactInstanceManager;
23
24
  import com.facebook.react.bridge.ReactContext;
24
25
  import com.facebook.react.modules.network.NetworkingModule;
@@ -51,7 +52,7 @@ public class ReactNativeFlipper {
51
52
  ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52
53
  if (reactContext == null) {
53
54
  reactInstanceManager.addReactInstanceEventListener(
54
- new ReactInstanceManager.ReactInstanceEventListener() {
55
+ new ReactInstanceEventListener() {
55
56
  @Override
56
57
  public void onReactContextInitialized(ReactContext reactContext) {
57
58
  reactInstanceManager.removeReactInstanceEventListener(this);
@@ -69,4 +70,4 @@ public class ReactNativeFlipper {
69
70
  }
70
71
  }
71
72
  }
72
- }
73
+ }
@@ -1,47 +1,27 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.<%= lowerCaseName %>">
2
- <uses-permission android:name="android.permission.INTERNET"/>
3
- <!-- OPTIONAL PERMISSIONS, REMOVE WHATEVER YOU DO NOT NEED -->
4
- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
5
- <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
6
- <uses-permission android:name="android.permission.USE_FINGERPRINT"/>
7
- <uses-permission android:name="android.permission.USE_BIOMETRIC"/>
8
- <uses-permission android:name="android.permission.VIBRATE"/>
9
- <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
10
- <!-- These require runtime permissions on M -->
11
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
12
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
13
- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
14
- <uses-permission android:name="android.permission.CAMERA"/>
15
- <uses-permission android:name="android.permission.RECORD_AUDIO"/>
16
- <uses-permission android:name="android.permission.READ_CONTACTS"/>
17
- <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
18
- <uses-permission android:name="android.permission.READ_CALENDAR"/>
19
- <uses-permission android:name="android.permission.WRITE_CALENDAR"/>
20
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
21
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
22
- <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
23
- <!-- END OPTIONAL PERMISSIONS -->
24
- <application
25
- android:name=".MainApplication"
26
- android:label="@string/app_name"
27
- android:icon="@mipmap/ic_launcher"
28
- android:roundIcon="@mipmap/ic_launcher_round"
29
- android:allowBackup="false"
30
- android:theme="@style/AppTheme"
31
- android:networkSecurityConfig="@xml/network_security_config"
32
- >
33
- <activity
34
- android:name=".MainActivity"
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.<%= lowerCaseName %>">
3
+
4
+ <uses-permission android:name="android.permission.INTERNET" />
5
+
6
+ <application
7
+ android:name=".MainApplication"
35
8
  android:label="@string/app_name"
36
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
37
- android:launchMode="singleTask"
38
- android:windowSoftInputMode="adjustResize"
39
- android:theme="@style/Theme.App.SplashScreen"
40
- >
41
- <intent-filter>
42
- <action android:name="android.intent.action.MAIN"/>
43
- <category android:name="android.intent.category.LAUNCHER"/>
44
- </intent-filter>
45
- </activity>
46
- </application>
47
- </manifest>
9
+ android:icon="@mipmap/ic_launcher"
10
+ android:roundIcon="@mipmap/ic_launcher_round"
11
+ android:allowBackup="false"
12
+ android:theme="@style/AppTheme"
13
+ android:networkSecurityConfig="@xml/network_security_config">
14
+ <activity
15
+ android:name=".MainActivity"
16
+ android:label="@string/app_name"
17
+ android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
18
+ android:launchMode="singleTask"
19
+ android:windowSoftInputMode="adjustResize"
20
+ android:exported="true">
21
+ <intent-filter>
22
+ <action android:name="android.intent.action.MAIN" />
23
+ <category android:name="android.intent.category.LAUNCHER" />
24
+ </intent-filter>
25
+ </activity>
26
+ </application>
27
+ </manifest>
@@ -1,6 +1,8 @@
1
1
  package com.<%= lowerCaseName %>;
2
2
 
3
3
  import com.facebook.react.ReactActivity;
4
+ import com.facebook.react.ReactActivityDelegate;
5
+ import com.facebook.react.ReactRootView;
4
6
 
5
7
  public class MainActivity extends ReactActivity {
6
8
 
@@ -10,6 +12,29 @@ public class MainActivity extends ReactActivity {
10
12
  */
11
13
  @Override
12
14
  protected String getMainComponentName() {
13
- return "main";
15
+ return "<%= className %>";
14
16
  }
15
- }
17
+
18
+ /**
19
+ * Returns the instance of the {@link ReactActivityDelegate}. There the RootView is created and
20
+ * you can specify the rendered you wish to use (Fabric or the older renderer).
21
+ */
22
+ @Override
23
+ protected ReactActivityDelegate createReactActivityDelegate() {
24
+ return new MainActivityDelegate(this, getMainComponentName());
25
+ }
26
+
27
+ public static class MainActivityDelegate extends ReactActivityDelegate {
28
+ public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
29
+ super(activity, mainComponentName);
30
+ }
31
+
32
+ @Override
33
+ protected ReactRootView createRootView() {
34
+ ReactRootView reactRootView = new ReactRootView(getContext());
35
+ // If you opted-in for the New Architecture, we enable the Fabric Renderer.
36
+ reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
37
+ return reactRootView;
38
+ }
39
+ }
40
+ }