@nx/react-native 18.0.0-beta.1 → 18.0.0-beta.2
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.
- package/.eslintrc.json +6 -1
- package/executors.json +5 -0
- package/generators.json +12 -11
- package/migrations.json +73 -1
- package/package.json +10 -15
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.d.ts +2 -0
- package/plugins/plugin.js +12 -1
- package/plugins/with-nx-metro.js +6 -2
- package/src/executors/build-android/build-android.impl.js +1 -5
- package/src/executors/build-android/build-android.impl.ts +1 -5
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +4 -0
- package/src/executors/run-android/run-android.impl.js +4 -16
- package/src/executors/run-android/run-android.impl.ts +8 -17
- package/src/executors/run-ios/run-ios.impl.js +4 -16
- package/src/executors/run-ios/run-ios.impl.ts +9 -18
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/start.impl.js +11 -26
- package/src/executors/start/start.impl.ts +14 -28
- package/src/executors/storybook/storybook.impl.d.ts +4 -0
- package/src/executors/storybook/storybook.impl.js +8 -1
- package/src/executors/storybook/storybook.impl.ts +16 -5
- package/src/executors/sync-deps/sync-deps.impl.d.ts +3 -2
- package/src/executors/sync-deps/sync-deps.impl.js +28 -11
- package/src/executors/sync-deps/sync-deps.impl.ts +45 -19
- package/src/executors/upgrade/schema.d.ts +1 -0
- package/src/executors/upgrade/schema.json +11 -0
- package/src/executors/upgrade/upgrade.impl.d.ts +13 -0
- package/src/executors/upgrade/upgrade.impl.js +47 -0
- package/src/executors/upgrade/upgrade.impl.ts +64 -0
- package/src/generators/application/application.js +27 -8
- package/src/generators/application/application.spec.ts +29 -2
- package/src/generators/application/files/app/.babelrc.js.template +23 -0
- package/src/generators/application/files/app/android/app/build.gradle.template +12 -28
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +2 -6
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +22 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +45 -0
- package/src/generators/application/files/app/android/build.gradle.template +7 -20
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/src/generators/application/files/app/android/gradle.properties +0 -3
- package/src/generators/application/files/app/android/gradlew.template +12 -7
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/ios/Podfile.template +0 -7
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +5 -0
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +5 -8
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +11 -33
- package/src/generators/application/files/app/metro.config.js.template +0 -4
- package/src/generators/application/files/app/src/app/App.tsx.template +29 -2
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +47 -0
- package/src/generators/application/lib/add-project.js +13 -17
- package/src/generators/application/lib/normalize-options.d.ts +4 -0
- package/src/generators/application/lib/normalize-options.js +9 -3
- package/src/generators/application/lib/normalize-options.spec.ts +53 -5
- package/src/generators/application/schema.d.ts +5 -3
- package/src/generators/application/schema.json +13 -5
- package/src/generators/component-story/component-story.d.ts +5 -8
- package/src/generators/component-story/component-story.js +8 -69
- package/src/generators/component-story/schema.d.ts +1 -0
- package/src/generators/component-story/schema.json +10 -2
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +14 -7
- package/src/generators/init/init.spec.ts +6 -2
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +1 -0
- package/src/generators/library/library.js +2 -1
- package/src/generators/library/library.spec.ts +12 -41
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +1 -1
- package/src/generators/stories/schema.d.ts +2 -0
- package/src/generators/stories/schema.json +14 -1
- package/src/generators/stories/stories.d.ts +5 -2
- package/src/generators/stories/stories.js +7 -50
- package/src/generators/storybook-configuration/configuration.d.ts +7 -2
- package/src/generators/storybook-configuration/configuration.js +15 -48
- package/src/generators/storybook-configuration/schema.d.ts +4 -2
- package/src/generators/storybook-configuration/schema.json +21 -11
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
- package/src/generators/upgrade-native/schema.d.ts +1 -1
- package/src/generators/upgrade-native/schema.json +2 -2
- package/src/generators/upgrade-native/upgrade-native.d.ts +2 -0
- package/src/generators/upgrade-native/upgrade-native.js +3 -0
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +15 -0
- package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +82 -0
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +14 -0
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +77 -0
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +17 -0
- package/src/generators/web-configuration/lib/normalize-schema.js +16 -0
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +7 -0
- package/src/generators/web-configuration/lib/webpack-targets.js +75 -0
- package/src/generators/web-configuration/schema.d.ts +6 -0
- package/src/generators/web-configuration/schema.json +42 -0
- package/src/generators/web-configuration/web-configuration.d.ts +12 -0
- package/src/generators/web-configuration/web-configuration.js +85 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +0 -4
- package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/add-upgrade-target.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +8 -0
- package/src/migrations/update-18-0-0/add-web-configuration.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +39 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +5 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.js +57 -0
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-block-list.js +26 -0
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +68 -0
- package/src/migrations/update-18-0-0/remove-metro.d.ts +14 -0
- package/src/migrations/update-18-0-0/remove-metro.js +29 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.js +30 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +40 -0
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +13 -1
- package/src/utils/add-linting.d.ts +1 -0
- package/src/utils/add-linting.js +1 -0
- package/src/utils/add-linting.spec.ts +2 -4
- package/src/utils/ensure-dependencies.js +2 -6
- package/src/utils/testing-generators.js +1 -0
- package/src/utils/versions.d.ts +9 -12
- package/src/utils/versions.js +10 -13
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -75
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +0 -32
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +0 -62
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -20
- package/src/generators/application/files/app/babel.config.json.template +0 -10
- package/src/generators/application/lib/add-detox.d.ts +0 -3
- package/src/generators/application/lib/add-detox.js +0 -23
- package/src/generators/component-story/component-story.spec.ts +0 -427
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +0 -32
- package/src/generators/library/files/lib/babel.config.json.template +0 -19
- package/src/generators/stories/stories-app.spec.ts +0 -128
- package/src/generators/stories/stories-lib.spec.ts +0 -105
- package/src/generators/storybook-configuration/configuration.spec.ts +0 -135
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +0 -9
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +0 -74
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +0 -5
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +0 -25
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +0 -161
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +0 -42
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +0 -7
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +0 -29
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +0 -65
- package/src/utils/find-all-npm-dependencies.d.ts +0 -2
- package/src/utils/find-all-npm-dependencies.js +0 -25
- package/src/utils/find-all-npm-dependencies.spec.ts +0 -95
- package/src/utils/symlink-task.d.ts +0 -2
- package/src/utils/symlink-task.js +0 -18
package/.eslintrc.json
CHANGED
package/executors.json
CHANGED
|
@@ -49,6 +49,11 @@
|
|
|
49
49
|
"implementation": "./src/executors/pod-install/pod-install.impl",
|
|
50
50
|
"schema": "./src/executors/pod-install/schema.json",
|
|
51
51
|
"description": "Run `pod install` in the `ios` directory."
|
|
52
|
+
},
|
|
53
|
+
"upgrade": {
|
|
54
|
+
"implementation": "./src/executors/upgrade/upgrade.impl",
|
|
55
|
+
"schema": "./src/executors/upgrade/schema.json",
|
|
56
|
+
"description": "upgrade executor"
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
}
|
package/generators.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"extends": ["@nx/workspace"],
|
|
5
5
|
"generators": {
|
|
6
6
|
"init": {
|
|
7
|
-
"factory": "./src/generators/init/init#
|
|
7
|
+
"factory": "./src/generators/init/init#reactNativeInitGeneratorInternal",
|
|
8
8
|
"schema": "./src/generators/init/schema.json",
|
|
9
|
-
"description": "Initialize the `@
|
|
9
|
+
"description": "Initialize the `@nx/react-native` plugin.",
|
|
10
10
|
"hidden": true
|
|
11
11
|
},
|
|
12
12
|
"application": {
|
|
@@ -30,28 +30,29 @@
|
|
|
30
30
|
"aliases": ["c"]
|
|
31
31
|
},
|
|
32
32
|
"storybook-configuration": {
|
|
33
|
-
"factory": "./src/generators/storybook-configuration/configuration#
|
|
33
|
+
"factory": "./src/generators/storybook-configuration/configuration#storybookConfigurationGeneratorInternal",
|
|
34
34
|
"schema": "./src/generators/storybook-configuration/schema.json",
|
|
35
|
-
"description": "Set up Storybook for a React
|
|
36
|
-
"hidden": false
|
|
35
|
+
"description": "Set up Storybook for a React Native application or library."
|
|
37
36
|
},
|
|
38
37
|
"component-story": {
|
|
39
38
|
"factory": "./src/generators/component-story/component-story#componentStoryGenerator",
|
|
40
39
|
"schema": "./src/generators/component-story/schema.json",
|
|
41
|
-
"description": "Generate Storybook story for a React
|
|
42
|
-
"hidden": false
|
|
40
|
+
"description": "Generate Storybook story for a React Native component."
|
|
43
41
|
},
|
|
44
42
|
"stories": {
|
|
45
43
|
"factory": "./src/generators/stories/stories#storiesGenerator",
|
|
46
44
|
"schema": "./src/generators/stories/schema.json",
|
|
47
|
-
"description": "Create stories
|
|
48
|
-
"hidden": false
|
|
45
|
+
"description": "Create stories for all components declared in an application or library."
|
|
49
46
|
},
|
|
50
47
|
"upgrade-native": {
|
|
51
48
|
"factory": "./src/generators/upgrade-native/upgrade-native#reactNativeUpgradeNativeGenerator",
|
|
52
49
|
"schema": "./src/generators/upgrade-native/schema.json",
|
|
53
|
-
"description": "Destructive command to upgrade native iOS and Android code to latest."
|
|
54
|
-
|
|
50
|
+
"description": "Destructive command to upgrade native iOS and Android code to latest."
|
|
51
|
+
},
|
|
52
|
+
"web-configuration": {
|
|
53
|
+
"factory": "./src/generators/web-configuration/web-configuration#webConfigurationGenerator",
|
|
54
|
+
"schema": "./src/generators/web-configuration/schema.json",
|
|
55
|
+
"description": "Set up web configuration for a React Native app"
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
}
|
package/migrations.json
CHANGED
|
@@ -41,6 +41,42 @@
|
|
|
41
41
|
"version": "16.9.0-beta.1",
|
|
42
42
|
"description": "Remove @types/react-native from package.json",
|
|
43
43
|
"implementation": "./src/migrations/update-16-9-0/remove-types-react-native"
|
|
44
|
+
},
|
|
45
|
+
"update-18-0-0-add-web-configuration": {
|
|
46
|
+
"cli": "nx",
|
|
47
|
+
"version": "18.0.0-beta.0",
|
|
48
|
+
"description": "Add web configuration to react native projects",
|
|
49
|
+
"implementation": "./src/migrations/update-18-0-0/add-web-configuration"
|
|
50
|
+
},
|
|
51
|
+
"update-18-0-0-change-storybook-targets": {
|
|
52
|
+
"cli": "nx",
|
|
53
|
+
"version": "18.0.0-beta.0",
|
|
54
|
+
"description": "Upgrade react native storybook target to use web",
|
|
55
|
+
"implementation": "./src/migrations/update-18-0-0/change-storybook-targets"
|
|
56
|
+
},
|
|
57
|
+
"update-18-0-0-remove-block-list": {
|
|
58
|
+
"cli": "nx",
|
|
59
|
+
"version": "18.0.0-beta.0",
|
|
60
|
+
"description": "Remove blockList in metro.config.js.",
|
|
61
|
+
"implementation": "./src/migrations/update-18-0-0/remove-block-list"
|
|
62
|
+
},
|
|
63
|
+
"update-18-0-0-remove-metro": {
|
|
64
|
+
"cli": "nx",
|
|
65
|
+
"version": "18.0.0-beta.0",
|
|
66
|
+
"description": "Remove metro-* and @react-native-community/cli-* from package.json devDependencies",
|
|
67
|
+
"implementation": "./src/migrations/update-18-0-0/remove-metro"
|
|
68
|
+
},
|
|
69
|
+
"update-18-0-0-remove-symlink-target": {
|
|
70
|
+
"cli": "nx",
|
|
71
|
+
"version": "18.0.0-beta.0",
|
|
72
|
+
"description": "Remove ensure-symlink target",
|
|
73
|
+
"implementation": "./src/migrations/update-18-0-0/remove-symlink-target"
|
|
74
|
+
},
|
|
75
|
+
"update-18-0-0-add-upgrade-target": {
|
|
76
|
+
"cli": "nx",
|
|
77
|
+
"version": "18.0.0-beta.0",
|
|
78
|
+
"description": "Add upgrade target to react native projects",
|
|
79
|
+
"implementation": "./src/migrations/update-18-0-0/add-upgrade-target"
|
|
44
80
|
}
|
|
45
81
|
},
|
|
46
82
|
"packageJsonUpdates": {
|
|
@@ -551,7 +587,43 @@
|
|
|
551
587
|
"version": "17.3.0-beta.3",
|
|
552
588
|
"packages": {
|
|
553
589
|
"@types/node": {
|
|
554
|
-
"version": "18.16.9"
|
|
590
|
+
"version": "18.16.9"
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
},
|
|
594
|
+
"18.0.0": {
|
|
595
|
+
"version": "18.0.0-beta.0",
|
|
596
|
+
"packages": {
|
|
597
|
+
"react-native": {
|
|
598
|
+
"version": "0.73.2",
|
|
599
|
+
"alwaysAddToPackageJson": false
|
|
600
|
+
},
|
|
601
|
+
"@react-native/babel-preset": {
|
|
602
|
+
"version": "^0.73.18",
|
|
603
|
+
"addToPackageJson": "devDependencies"
|
|
604
|
+
},
|
|
605
|
+
"@react-native/metro-config": {
|
|
606
|
+
"version": "^0.73.2",
|
|
607
|
+
"addToPackageJson": "devDependencies"
|
|
608
|
+
},
|
|
609
|
+
"@types/react": {
|
|
610
|
+
"version": "~18.2.45",
|
|
611
|
+
"alwaysAddToPackageJson": false
|
|
612
|
+
},
|
|
613
|
+
"@testing-library/react-native": {
|
|
614
|
+
"version": "~12.4.2",
|
|
615
|
+
"alwaysAddToPackageJson": false
|
|
616
|
+
},
|
|
617
|
+
"react-native-svg-transformer": {
|
|
618
|
+
"version": "1.2.0",
|
|
619
|
+
"alwaysAddToPackageJson": false
|
|
620
|
+
},
|
|
621
|
+
"react-native-svg": {
|
|
622
|
+
"version": "14.1.0",
|
|
623
|
+
"alwaysAddToPackageJson": false
|
|
624
|
+
},
|
|
625
|
+
"@react-native-community/cli-platform-android": {
|
|
626
|
+
"version": "12.3.0",
|
|
555
627
|
"alwaysAddToPackageJson": false
|
|
556
628
|
}
|
|
557
629
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "18.0.0-beta.
|
|
3
|
+
"version": "18.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
|
|
6
6
|
"keywords": [
|
|
@@ -30,23 +30,18 @@
|
|
|
30
30
|
"fs-extra": "^11.1.0",
|
|
31
31
|
"glob": "7.1.4",
|
|
32
32
|
"ignore": "^5.0.4",
|
|
33
|
-
"metro-config": "~0.
|
|
34
|
-
"metro-resolver": "~0.
|
|
35
|
-
"minimatch": "9.0.3",
|
|
33
|
+
"metro-config": "~0.80.4",
|
|
34
|
+
"metro-resolver": "~0.80.4",
|
|
36
35
|
"node-fetch": "^2.6.7",
|
|
37
36
|
"tsconfig-paths": "^4.1.2",
|
|
38
37
|
"tslib": "^2.3.0",
|
|
39
|
-
"@nx/
|
|
40
|
-
"@nx/
|
|
41
|
-
"@nx/
|
|
42
|
-
"@nx/
|
|
43
|
-
"@nx/
|
|
44
|
-
"@nx/
|
|
45
|
-
"@
|
|
46
|
-
"@nrwl/react-native": "18.0.0-beta.1"
|
|
47
|
-
},
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"react-native": ">= 0.72.0 < 0.73.0"
|
|
38
|
+
"@nx/devkit": "18.0.0-beta.2",
|
|
39
|
+
"@nx/jest": "18.0.0-beta.2",
|
|
40
|
+
"@nx/js": "18.0.0-beta.2",
|
|
41
|
+
"@nx/eslint": "18.0.0-beta.2",
|
|
42
|
+
"@nx/react": "18.0.0-beta.2",
|
|
43
|
+
"@nx/workspace": "18.0.0-beta.2",
|
|
44
|
+
"@nrwl/react-native": "18.0.0-beta.2"
|
|
50
45
|
},
|
|
51
46
|
"executors": "./executors.json",
|
|
52
47
|
"ng-update": {
|
|
@@ -27,6 +27,9 @@ function getResolveRequest(extensions) {
|
|
|
27
27
|
if (resolvedPath) {
|
|
28
28
|
return resolvedPath;
|
|
29
29
|
}
|
|
30
|
+
if (debug) {
|
|
31
|
+
console.log(chalk.red(`[Nx] Unable to resolve with any resolver: ${realModuleName}`));
|
|
32
|
+
}
|
|
30
33
|
throw new Error(`Cannot resolve ${chalk.bold(realModuleName)}`);
|
|
31
34
|
};
|
|
32
35
|
}
|
|
@@ -84,7 +87,7 @@ function tsconfigPathsResolver(context, extensions, realModuleName, platform, de
|
|
|
84
87
|
}
|
|
85
88
|
catch {
|
|
86
89
|
if (debug) {
|
|
87
|
-
console.log(chalk.
|
|
90
|
+
console.log(chalk.cyan(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`));
|
|
88
91
|
console.log(chalk.cyan(`[Nx] The following tsconfig paths was used:\n:${chalk.bold(JSON.stringify(paths, null, 2))}`));
|
|
89
92
|
}
|
|
90
93
|
}
|
package/plugins/plugin.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface ReactNativePluginOptions {
|
|
|
7
7
|
buildIosTargetName?: string;
|
|
8
8
|
buildAndroidTargetName?: string;
|
|
9
9
|
bundleTargetName?: string;
|
|
10
|
+
syncDepsTargetName?: string;
|
|
11
|
+
upgradeTargetname?: string;
|
|
10
12
|
}
|
|
11
13
|
export declare const createDependencies: CreateDependencies;
|
|
12
14
|
export declare const createNodes: CreateNodes<ReactNativePluginOptions>;
|
package/plugins/plugin.js
CHANGED
|
@@ -57,11 +57,13 @@ function buildReactNativeTargets(projectRoot, options, context) {
|
|
|
57
57
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
58
58
|
const targets = {
|
|
59
59
|
[options.startTargetName]: {
|
|
60
|
-
|
|
60
|
+
command: `react-native start`,
|
|
61
|
+
options: { cwd: projectRoot },
|
|
61
62
|
},
|
|
62
63
|
[options.podInstallTargetName]: {
|
|
63
64
|
command: `pod install`,
|
|
64
65
|
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot, 'ios') },
|
|
66
|
+
dependsOn: [`${options.syncDepsTargetName}`],
|
|
65
67
|
cache: true,
|
|
66
68
|
inputs: getInputs(namedInputs),
|
|
67
69
|
outputs: [
|
|
@@ -99,6 +101,13 @@ function buildReactNativeTargets(projectRoot, options, context) {
|
|
|
99
101
|
dependsOn: [`^${options.bundleTargetName}`],
|
|
100
102
|
inputs: getInputs(namedInputs),
|
|
101
103
|
},
|
|
104
|
+
[options.syncDepsTargetName]: {
|
|
105
|
+
executor: '@nx/react-native:sync-deps',
|
|
106
|
+
},
|
|
107
|
+
[options.upgradeTargetname]: {
|
|
108
|
+
command: `react-native upgrade`,
|
|
109
|
+
options: { cwd: projectRoot },
|
|
110
|
+
},
|
|
102
111
|
};
|
|
103
112
|
return targets;
|
|
104
113
|
}
|
|
@@ -147,5 +156,7 @@ function normalizeOptions(options) {
|
|
|
147
156
|
options.buildIosTargetName ??= 'build-ios';
|
|
148
157
|
options.buildAndroidTargetName ??= 'build-android';
|
|
149
158
|
options.bundleTargetName ??= 'bundle';
|
|
159
|
+
options.syncDepsTargetName ??= 'sync-deps';
|
|
160
|
+
options.upgradeTargetname ??= 'upgrade';
|
|
150
161
|
return options;
|
|
151
162
|
}
|
package/plugins/with-nx-metro.js
CHANGED
|
@@ -11,14 +11,18 @@ async function withNxMetro(userConfig, opts = {}) {
|
|
|
11
11
|
process.env.NX_REACT_NATIVE_DEBUG = 'true';
|
|
12
12
|
if (opts.extensions)
|
|
13
13
|
extensions.push(...opts.extensions);
|
|
14
|
-
let watchFolders =
|
|
14
|
+
let watchFolders = (0, fs_extra_1.readdirSync)(devkit_1.workspaceRoot)
|
|
15
|
+
.filter((fileName) => !['dist', 'e2e'].includes(fileName) && !fileName.startsWith('.'))
|
|
16
|
+
.map((fileName) => (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, fileName))
|
|
17
|
+
.filter((filePath) => (0, fs_extra_1.statSync)(filePath).isDirectory());
|
|
15
18
|
if (opts.watchFolders?.length) {
|
|
16
19
|
watchFolders = watchFolders.concat(opts.watchFolders);
|
|
17
20
|
}
|
|
18
|
-
watchFolders = watchFolders.filter((folder) => (0, fs_extra_1.existsSync)(folder));
|
|
21
|
+
watchFolders = [...new Set(watchFolders)].filter((folder) => (0, fs_extra_1.existsSync)(folder));
|
|
19
22
|
const nxConfig = {
|
|
20
23
|
resolver: {
|
|
21
24
|
resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions),
|
|
25
|
+
nodeModulesPaths: [(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'node_modules')],
|
|
22
26
|
},
|
|
23
27
|
watchFolders,
|
|
24
28
|
};
|
|
@@ -13,11 +13,7 @@ async function* buildAndroidExecutor(options, context) {
|
|
|
13
13
|
exports.default = buildAndroidExecutor;
|
|
14
14
|
function runCliBuild(workspaceRoot, projectRoot, options) {
|
|
15
15
|
return new Promise((res, reject) => {
|
|
16
|
-
|
|
17
|
-
* Call the react native cli with option `--no-packager`
|
|
18
|
-
* Not passing '--packager' due to cli will launch start command from the project root
|
|
19
|
-
*/
|
|
20
|
-
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['build-android', ...createBuildAndroidOptions(options), '--no-packager'], {
|
|
16
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['build-android', ...createBuildAndroidOptions(options)], {
|
|
21
17
|
stdio: 'inherit',
|
|
22
18
|
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
23
19
|
env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
|
|
@@ -27,13 +27,9 @@ function runCliBuild(
|
|
|
27
27
|
options: ReactNativeBuildAndroidOptions
|
|
28
28
|
) {
|
|
29
29
|
return new Promise<ChildProcess>((res, reject) => {
|
|
30
|
-
/**
|
|
31
|
-
* Call the react native cli with option `--no-packager`
|
|
32
|
-
* Not passing '--packager' due to cli will launch start command from the project root
|
|
33
|
-
*/
|
|
34
30
|
const childProcess = fork(
|
|
35
31
|
require.resolve('react-native/cli.js'),
|
|
36
|
-
['build-android', ...createBuildAndroidOptions(options)
|
|
32
|
+
['build-android', ...createBuildAndroidOptions(options)],
|
|
37
33
|
{
|
|
38
34
|
stdio: 'inherit',
|
|
39
35
|
cwd: pathResolve(workspaceRoot, projectRoot),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// options form https://github.com/react-native
|
|
1
|
+
// options form https://github.com/facebook/react-native/tree/main/packages/community-cli-plugin#bundle
|
|
2
2
|
export interface ReactNativeBundleOptions {
|
|
3
3
|
entryFile: string;
|
|
4
4
|
platform: string;
|
|
@@ -2,4 +2,8 @@ import { ExecutorContext } from '@nx/devkit';
|
|
|
2
2
|
export interface ReactNativeEnsureSymlinkOutput {
|
|
3
3
|
success: boolean;
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
7
|
+
* @deprecated It is no longer needed for react native 73.
|
|
8
|
+
*/
|
|
5
9
|
export default function ensureSymlinkExecutor(_: any, context: ExecutorContext): AsyncGenerator<ReactNativeEnsureSymlinkOutput>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
|
|
4
|
+
/**
|
|
5
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
6
|
+
* @deprecated It is no longer needed for react native 73.
|
|
7
|
+
*/
|
|
4
8
|
async function* ensureSymlinkExecutor(_, context) {
|
|
5
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
6
10
|
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
|
|
@@ -5,6 +5,10 @@ export interface ReactNativeEnsureSymlinkOutput {
|
|
|
5
5
|
success: boolean;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
10
|
+
* @deprecated It is no longer needed for react native 73.
|
|
11
|
+
*/
|
|
8
12
|
export default async function* ensureSymlinkExecutor(
|
|
9
13
|
_,
|
|
10
14
|
context: ExecutorContext
|
|
@@ -9,27 +9,15 @@ let childProcess;
|
|
|
9
9
|
async function* runAndroidExecutor(options, context) {
|
|
10
10
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
11
11
|
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
|
|
12
|
+
const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
|
|
12
13
|
if (options.mode !== 'Release') {
|
|
13
|
-
|
|
14
|
+
tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
|
|
14
15
|
port: options.port,
|
|
15
16
|
resetCache: options.resetCache,
|
|
16
17
|
interactive: true,
|
|
17
|
-
}
|
|
18
|
-
for await (const result of startResults) {
|
|
19
|
-
if (result.success) {
|
|
20
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
21
|
-
yield {
|
|
22
|
-
success: true,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
18
|
+
}));
|
|
32
19
|
}
|
|
20
|
+
await Promise.all(tasks);
|
|
33
21
|
yield { success: true };
|
|
34
22
|
}
|
|
35
23
|
exports.default = runAndroidExecutor;
|
|
@@ -3,7 +3,7 @@ import { join, resolve as pathResolve } from 'path';
|
|
|
3
3
|
import { ChildProcess, fork } from 'child_process';
|
|
4
4
|
|
|
5
5
|
import { ReactNativeRunAndroidOptions } from './schema';
|
|
6
|
-
import
|
|
6
|
+
import { runCliStart } from '../start/start.impl';
|
|
7
7
|
import { chmodAndroidGradlewFiles } from '../../utils/chmod-android-gradle-files';
|
|
8
8
|
import { getCliOptions } from '../../utils/get-cli-options';
|
|
9
9
|
|
|
@@ -21,29 +21,20 @@ export default async function* runAndroidExecutor(
|
|
|
21
21
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
22
22
|
chmodAndroidGradlewFiles(join(projectRoot, 'android'));
|
|
23
23
|
|
|
24
|
+
const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
|
|
25
|
+
|
|
24
26
|
if (options.mode !== 'Release') {
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
+
tasks.push(
|
|
28
|
+
runCliStart(context.root, projectRoot, {
|
|
27
29
|
port: options.port,
|
|
28
30
|
resetCache: options.resetCache,
|
|
29
31
|
interactive: true,
|
|
30
|
-
}
|
|
31
|
-
context
|
|
32
|
+
})
|
|
32
33
|
);
|
|
33
|
-
for await (const result of startResults) {
|
|
34
|
-
if (result.success) {
|
|
35
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
36
|
-
yield {
|
|
37
|
-
success: true,
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
45
34
|
}
|
|
46
35
|
|
|
36
|
+
await Promise.all(tasks);
|
|
37
|
+
|
|
47
38
|
yield { success: true };
|
|
48
39
|
}
|
|
49
40
|
|
|
@@ -10,27 +10,15 @@ async function* runIosExecutor(options, context) {
|
|
|
10
10
|
throw new Error(`The run-ios build requires Mac to run`);
|
|
11
11
|
}
|
|
12
12
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
13
|
+
const tasks = [runCliRunIOS(context.root, projectRoot, options)];
|
|
13
14
|
if (options.mode !== 'Release') {
|
|
14
|
-
|
|
15
|
+
tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
|
|
15
16
|
port: options.port,
|
|
16
17
|
resetCache: options.resetCache,
|
|
17
18
|
interactive: true,
|
|
18
|
-
}
|
|
19
|
-
for await (const result of startResults) {
|
|
20
|
-
if (result.success) {
|
|
21
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
22
|
-
yield {
|
|
23
|
-
success: true,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
19
|
+
}));
|
|
33
20
|
}
|
|
21
|
+
await Promise.all(tasks);
|
|
34
22
|
yield { success: true };
|
|
35
23
|
}
|
|
36
24
|
exports.default = runIosExecutor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
1
|
+
import { ExecutorContext, GeneratorCallback, workspaceRoot } from '@nx/devkit';
|
|
2
2
|
import { resolve as pathResolve } from 'path';
|
|
3
3
|
import { ChildProcess, fork } from 'child_process';
|
|
4
4
|
import { platform } from 'os';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import { runCliStart } from '../start/start.impl';
|
|
7
7
|
import { getCliOptions } from '../../utils/get-cli-options';
|
|
8
8
|
|
|
9
9
|
import { ReactNativeRunIosOptions } from './schema';
|
|
@@ -21,29 +21,20 @@ export default async function* runIosExecutor(
|
|
|
21
21
|
const projectRoot =
|
|
22
22
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
23
23
|
|
|
24
|
+
const tasks = [runCliRunIOS(context.root, projectRoot, options)];
|
|
25
|
+
|
|
24
26
|
if (options.mode !== 'Release') {
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
+
tasks.push(
|
|
28
|
+
runCliStart(context.root, projectRoot, {
|
|
27
29
|
port: options.port,
|
|
28
30
|
resetCache: options.resetCache,
|
|
29
31
|
interactive: true,
|
|
30
|
-
}
|
|
31
|
-
context
|
|
32
|
+
})
|
|
32
33
|
);
|
|
33
|
-
for await (const result of startResults) {
|
|
34
|
-
if (result.success) {
|
|
35
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
36
|
-
yield {
|
|
37
|
-
success: true,
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
45
34
|
}
|
|
46
35
|
|
|
36
|
+
await Promise.all(tasks);
|
|
37
|
+
|
|
47
38
|
yield { success: true };
|
|
48
39
|
}
|
|
49
40
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// options from https://github.com/react-native
|
|
1
|
+
// options from https://github.com/facebook/react-native/blob/main/packages/community-cli-plugin/src/commands/start/index.js
|
|
2
2
|
|
|
3
3
|
export interface ReactNativeStartOptions {
|
|
4
4
|
port: number;
|
|
@@ -7,25 +7,11 @@ const path_1 = require("path");
|
|
|
7
7
|
const is_packager_running_1 = require("./lib/is-packager-running");
|
|
8
8
|
async function* startExecutor(options, context) {
|
|
9
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
10
|
-
|
|
10
|
+
await runCliStart(context.root, projectRoot, options);
|
|
11
11
|
yield {
|
|
12
12
|
port: options.port,
|
|
13
13
|
success: true,
|
|
14
14
|
};
|
|
15
|
-
if (!startProcess) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
await new Promise((resolve) => {
|
|
19
|
-
const processExitListener = (signal) => () => {
|
|
20
|
-
startProcess.kill(signal);
|
|
21
|
-
resolve();
|
|
22
|
-
process.exit();
|
|
23
|
-
};
|
|
24
|
-
process.once('exit', (signal) => startProcess.kill(signal));
|
|
25
|
-
process.once('SIGTERM', processExitListener);
|
|
26
|
-
process.once('SIGINT', processExitListener);
|
|
27
|
-
process.once('SIGQUIT', processExitListener);
|
|
28
|
-
});
|
|
29
15
|
}
|
|
30
16
|
exports.default = startExecutor;
|
|
31
17
|
/*
|
|
@@ -47,7 +33,7 @@ async function runCliStart(workspaceRoot, projectRoot, options) {
|
|
|
47
33
|
return await startAsync(workspaceRoot, projectRoot, options);
|
|
48
34
|
}
|
|
49
35
|
catch (error) {
|
|
50
|
-
devkit_1.logger.error(`Failed to start the packager server. Error details: ${error.message}`);
|
|
36
|
+
devkit_1.logger.error(`Failed to start the packager server. Error details: ${error.message ?? error}`);
|
|
51
37
|
throw error;
|
|
52
38
|
}
|
|
53
39
|
}
|
|
@@ -58,16 +44,7 @@ function startAsync(workspaceRoot, projectRoot, options) {
|
|
|
58
44
|
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['start', ...createStartOptions(options)], {
|
|
59
45
|
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
60
46
|
env: process.env,
|
|
61
|
-
stdio:
|
|
62
|
-
});
|
|
63
|
-
childProcess.stdout.on('data', (data) => {
|
|
64
|
-
process.stdout.write(data);
|
|
65
|
-
if (data.toString().includes('reload the app')) {
|
|
66
|
-
resolve(childProcess);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
childProcess.stderr.on('data', (data) => {
|
|
70
|
-
process.stderr.write(data);
|
|
47
|
+
stdio: 'inherit',
|
|
71
48
|
});
|
|
72
49
|
childProcess.on('error', (err) => {
|
|
73
50
|
reject(err);
|
|
@@ -80,6 +57,14 @@ function startAsync(workspaceRoot, projectRoot, options) {
|
|
|
80
57
|
reject(code);
|
|
81
58
|
}
|
|
82
59
|
});
|
|
60
|
+
const processExitListener = (signal) => () => {
|
|
61
|
+
childProcess.kill(signal);
|
|
62
|
+
process.exit();
|
|
63
|
+
};
|
|
64
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
65
|
+
process.once('SIGTERM', processExitListener);
|
|
66
|
+
process.once('SIGINT', processExitListener);
|
|
67
|
+
process.once('SIGQUIT', processExitListener);
|
|
83
68
|
});
|
|
84
69
|
}
|
|
85
70
|
function createStartOptions(options) {
|