@nx/react-native 0.0.0-pr-22179-271588f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +48 -0
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/executors.json +59 -0
- package/generators.json +58 -0
- package/index.d.ts +5 -0
- package/index.js +13 -0
- package/migrations.json +632 -0
- package/package.json +57 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/jest/svg-mock.d.ts +0 -0
- package/plugins/jest/svg-mock.js +3 -0
- package/plugins/metro-resolver.d.ts +1 -0
- package/plugins/metro-resolver.js +136 -0
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +162 -0
- package/plugins/with-nx-metro.d.ts +8 -0
- package/plugins/with-nx-metro.js +31 -0
- package/project.json +54 -0
- package/src/executors/build-android/build-android.impl.d.ts +6 -0
- package/src/executors/build-android/build-android.impl.js +48 -0
- package/src/executors/build-android/build-android.impl.ts +69 -0
- package/src/executors/build-android/schema.d.ts +14 -0
- package/src/executors/build-android/schema.json +81 -0
- package/src/executors/build-ios/build-ios.impl.d.ts +6 -0
- package/src/executors/build-ios/build-ios.impl.js +55 -0
- package/src/executors/build-ios/build-ios.impl.ts +77 -0
- package/src/executors/build-ios/schema.d.ts +17 -0
- package/src/executors/build-ios/schema.json +91 -0
- package/src/executors/bundle/bundle.impl.d.ts +6 -0
- package/src/executors/bundle/bundle.impl.js +56 -0
- package/src/executors/bundle/bundle.impl.ts +77 -0
- package/src/executors/bundle/schema.d.ts +16 -0
- package/src/executors/bundle/schema.json +92 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +9 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +13 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +22 -0
- package/src/executors/ensure-symlink/schema.json +11 -0
- package/src/executors/pod-install/pod-install.impl.d.ts +6 -0
- package/src/executors/pod-install/pod-install.impl.js +11 -0
- package/src/executors/pod-install/pod-install.impl.ts +21 -0
- package/src/executors/pod-install/schema.d.ts +6 -0
- package/src/executors/pod-install/schema.json +33 -0
- package/src/executors/run-android/run-android.impl.d.ts +6 -0
- package/src/executors/run-android/run-android.impl.js +66 -0
- package/src/executors/run-android/run-android.impl.ts +94 -0
- package/src/executors/run-android/schema.d.ts +13 -0
- package/src/executors/run-android/schema.json +100 -0
- package/src/executors/run-ios/run-ios.impl.d.ts +6 -0
- package/src/executors/run-ios/run-ios.impl.js +65 -0
- package/src/executors/run-ios/run-ios.impl.ts +92 -0
- package/src/executors/run-ios/schema.d.ts +7 -0
- package/src/executors/run-ios/schema.json +96 -0
- package/src/executors/start/lib/is-packager-running.d.ts +1 -0
- package/src/executors/start/lib/is-packager-running.js +15 -0
- package/src/executors/start/schema.d.ts +7 -0
- package/src/executors/start/schema.json +28 -0
- package/src/executors/start/start.impl.d.ts +10 -0
- package/src/executors/start/start.impl.js +87 -0
- package/src/executors/start/start.impl.ts +111 -0
- package/src/executors/storybook/schema.d.ts +5 -0
- package/src/executors/storybook/schema.json +29 -0
- package/src/executors/storybook/storybook.impl.d.ts +10 -0
- package/src/executors/storybook/storybook.impl.js +51 -0
- package/src/executors/storybook/storybook.impl.ts +85 -0
- package/src/executors/sync-deps/schema.d.ts +5 -0
- package/src/executors/sync-deps/schema.json +33 -0
- package/src/executors/sync-deps/sync-deps.impl.d.ts +9 -0
- package/src/executors/sync-deps/sync-deps.impl.js +78 -0
- package/src/executors/sync-deps/sync-deps.impl.ts +140 -0
- 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.d.ts +5 -0
- package/src/generators/application/application.js +87 -0
- package/src/generators/application/application.spec.ts +258 -0
- package/src/generators/application/files/app/.babelrc.js.template +23 -0
- package/src/generators/application/files/app/Gemfile.template +7 -0
- package/src/generators/application/files/app/android/app/build.gradle.template +119 -0
- package/src/generators/application/files/app/android/app/debug.keystore +0 -0
- package/src/generators/application/files/app/android/app/proguard-rules.pro +10 -0
- package/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +30 -0
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +10 -0
- package/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +26 -0
- 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/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/values/strings.xml.template +3 -0
- package/src/generators/application/files/app/android/app/src/main/res/values/styles.xml +9 -0
- package/src/generators/application/files/app/android/app/src/main/res/xml/network_security_config.xml +7 -0
- package/src/generators/application/files/app/android/build.gradle.template +21 -0
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/src/generators/application/files/app/android/gradle.properties +41 -0
- package/src/generators/application/files/app/android/gradlew.bat +92 -0
- package/src/generators/application/files/app/android/gradlew.template +249 -0
- package/src/generators/application/files/app/android/settings.gradle.template +4 -0
- package/src/generators/application/files/app/app.json.template +4 -0
- package/src/generators/application/files/app/ios/.xcode.env.template +12 -0
- package/src/generators/application/files/app/ios/Podfile.template +55 -0
- package/src/generators/application/files/app/ios/__className__/AppDelegate.h +6 -0
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +31 -0
- package/src/generators/application/files/app/ios/__className__/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/src/generators/application/files/app/ios/__className__/Images.xcassets/Contents.json +6 -0
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +52 -0
- package/src/generators/application/files/app/ios/__className__/LaunchScreen.storyboard.template +47 -0
- package/src/generators/application/files/app/ios/__className__/main.m +10 -0
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +684 -0
- package/src/generators/application/files/app/ios/__className__.xcodeproj/xcshareddata/xcschemes/__className__.xcscheme.template +88 -0
- package/src/generators/application/files/app/ios/__className__.xcworkspace/contents.xcworkspacedata +10 -0
- package/src/generators/application/files/app/ios/__className__Tests/Info.plist +24 -0
- package/src/generators/application/files/app/ios/__className__Tests/__className__Tests.m +66 -0
- package/src/generators/application/files/app/metro.config.js.template +31 -0
- package/src/generators/application/files/app/package.json.template +14 -0
- package/src/generators/application/files/app/src/app/App.spec.tsx.template +9 -0
- package/src/generators/application/files/app/src/app/App.tsx.template +731 -0
- package/src/generators/application/files/app/src/main.tsx.template +4 -0
- package/src/generators/application/files/app/test-setup.ts.template +1 -0
- package/src/generators/application/files/app/tsconfig.app.json.template +10 -0
- package/src/generators/application/files/app/tsconfig.json.template +19 -0
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +46 -0
- package/src/generators/application/lib/add-project.d.ts +3 -0
- package/src/generators/application/lib/add-project.js +91 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.js +24 -0
- package/src/generators/application/lib/normalize-options.d.ts +17 -0
- package/src/generators/application/lib/normalize-options.js +47 -0
- package/src/generators/application/lib/normalize-options.spec.ts +196 -0
- package/src/generators/application/schema.d.ts +23 -0
- package/src/generators/application/schema.json +103 -0
- package/src/generators/component/component.d.ts +5 -0
- package/src/generators/component/component.js +64 -0
- package/src/generators/component/component.spec.ts +127 -0
- package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +11 -0
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +32 -0
- package/src/generators/component/lib/add-import.d.ts +3 -0
- package/src/generators/component/lib/add-import.js +33 -0
- package/src/generators/component/lib/normalize-options.d.ts +10 -0
- package/src/generators/component/lib/normalize-options.js +50 -0
- package/src/generators/component/schema.d.ts +24 -0
- package/src/generators/component/schema.json +85 -0
- package/src/generators/component-story/component-story.d.ts +8 -0
- package/src/generators/component-story/component-story.js +15 -0
- package/src/generators/component-story/schema.d.ts +6 -0
- package/src/generators/component-story/schema.json +42 -0
- package/src/generators/init/init.d.ts +6 -0
- package/src/generators/init/init.js +78 -0
- package/src/generators/init/init.spec.ts +38 -0
- package/src/generators/init/lib/add-git-ignore-entry.d.ts +2 -0
- package/src/generators/init/lib/add-git-ignore-entry.js +24 -0
- package/src/generators/init/lib/gitignore-entries.d.ts +1 -0
- package/src/generators/init/lib/gitignore-entries.js +74 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +35 -0
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/files/lib/README.md +7 -0
- package/src/generators/library/files/lib/package.json.template +4 -0
- package/src/generators/library/files/lib/src/index.ts.template +0 -0
- package/src/generators/library/files/lib/test-setup.ts.template +1 -0
- package/src/generators/library/files/lib/tsconfig.json.template +16 -0
- package/src/generators/library/files/lib/tsconfig.lib.json.template +9 -0
- package/src/generators/library/lib/normalize-options.d.ts +12 -0
- package/src/generators/library/lib/normalize-options.js +33 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +154 -0
- package/src/generators/library/library.spec.ts +420 -0
- package/src/generators/library/schema.d.ts +25 -0
- package/src/generators/library/schema.json +107 -0
- package/src/generators/stories/schema.d.ts +7 -0
- package/src/generators/stories/schema.json +58 -0
- package/src/generators/stories/stories.d.ts +8 -0
- package/src/generators/stories/stories.js +13 -0
- package/src/generators/storybook-configuration/configuration.d.ts +9 -0
- package/src/generators/storybook-configuration/configuration.js +26 -0
- package/src/generators/storybook-configuration/schema.d.ts +13 -0
- package/src/generators/storybook-configuration/schema.json +79 -0
- package/src/generators/upgrade-native/lib/create-native-files.d.ts +3 -0
- package/src/generators/upgrade-native/lib/create-native-files.js +14 -0
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +12 -0
- package/src/generators/upgrade-native/lib/normalize-options.js +27 -0
- package/src/generators/upgrade-native/schema.d.ts +9 -0
- package/src/generators/upgrade-native/schema.json +41 -0
- package/src/generators/upgrade-native/upgrade-native.d.ts +10 -0
- package/src/generators/upgrade-native/upgrade-native.js +31 -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 +87 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.js +9 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.spec.ts +73 -0
- package/src/migrations/update-15-9-1/add-build-ios-target.d.ts +5 -0
- package/src/migrations/update-15-9-1/add-build-ios-target.js +29 -0
- package/src/migrations/update-15-9-1/add-build-ios-target.spec.ts +36 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +37 -0
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.d.ts +6 -0
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +21 -0
- package/src/migrations/update-16-6-0/add-depends-on.d.ts +6 -0
- package/src/migrations/update-16-6-0/add-depends-on.js +63 -0
- package/src/migrations/update-16-6-0/update-metro-config.d.ts +6 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +63 -0
- package/src/migrations/update-16-9-0/remove-types-react-native.d.ts +7 -0
- package/src/migrations/update-16-9-0/remove-types-react-native.js +13 -0
- 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 +28 -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 +2 -0
- package/src/utils/add-jest.js +48 -0
- package/src/utils/add-linting.d.ts +13 -0
- package/src/utils/add-linting.js +36 -0
- package/src/utils/add-linting.spec.ts +40 -0
- package/src/utils/chmod-android-gradle-files.d.ts +3 -0
- package/src/utils/chmod-android-gradle-files.js +27 -0
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +30 -0
- package/src/utils/ensure-node-modules-symlink.d.ts +9 -0
- package/src/utils/ensure-node-modules-symlink.js +28 -0
- package/src/utils/ensure-node-modules-symlink.spec.ts +108 -0
- package/src/utils/find-all-npm-dependencies.d.ts +2 -0
- package/src/utils/find-all-npm-dependencies.js +27 -0
- package/src/utils/find-all-npm-dependencies.spec.ts +103 -0
- package/src/utils/format-file.d.ts +1 -0
- package/src/utils/format-file.js +16 -0
- package/src/utils/get-cli-options.d.ts +8 -0
- package/src/utils/get-cli-options.js +33 -0
- package/src/utils/pod-install-task.d.ts +18 -0
- package/src/utils/pod-install-task.js +73 -0
- package/src/utils/testing-generators.d.ts +3 -0
- package/src/utils/testing-generators.js +32 -0
- package/src/utils/versions.d.ts +17 -0
- package/src/utils/versions.js +20 -0
- package/typings/svg.d.ts +7 -0
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getResolveRequest(extensions: string[]): (_context: any, realModuleName: string, platform: string | null) => any;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResolveRequest = void 0;
|
|
4
|
+
const metroResolver = require("metro-resolver");
|
|
5
|
+
const tsconfig_paths_1 = require("tsconfig-paths");
|
|
6
|
+
const chalk = require("chalk");
|
|
7
|
+
const enhanced_resolve_1 = require("enhanced-resolve");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
/*
|
|
12
|
+
* Use tsconfig to resolve additional workspace libs.
|
|
13
|
+
*
|
|
14
|
+
* This resolve function requires projectRoot to be set to
|
|
15
|
+
* workspace root in order modules and assets to be registered and watched.
|
|
16
|
+
*/
|
|
17
|
+
function getResolveRequest(extensions) {
|
|
18
|
+
return function (_context, realModuleName, platform) {
|
|
19
|
+
const debug = process.env.NX_REACT_NATIVE_DEBUG === 'true';
|
|
20
|
+
if (debug)
|
|
21
|
+
console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`));
|
|
22
|
+
const { resolveRequest, ...context } = _context;
|
|
23
|
+
const resolvedPath = resolveRequestFromContext(resolveRequest, _context, realModuleName, platform, debug) ||
|
|
24
|
+
defaultMetroResolver(context, realModuleName, platform, debug) ||
|
|
25
|
+
tsconfigPathsResolver(context, extensions, realModuleName, platform, debug) ||
|
|
26
|
+
pnpmResolver(extensions, context, realModuleName, debug);
|
|
27
|
+
if (resolvedPath) {
|
|
28
|
+
return resolvedPath;
|
|
29
|
+
}
|
|
30
|
+
if (debug) {
|
|
31
|
+
console.log(chalk.red(`[Nx] Unable to resolve with any resolver: ${realModuleName}`));
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Cannot resolve ${chalk.bold(realModuleName)}`);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.getResolveRequest = getResolveRequest;
|
|
37
|
+
function resolveRequestFromContext(resolveRequest, context, realModuleName, platform, debug) {
|
|
38
|
+
try {
|
|
39
|
+
return resolveRequest(context, realModuleName, platform);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
if (debug)
|
|
43
|
+
console.log(chalk.cyan(`[Nx] Unable to resolve with default resolveRequest: ${realModuleName}`));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* This function try to resolve path using metro's default resolver
|
|
48
|
+
* @returns path if resolved, else undefined
|
|
49
|
+
*/
|
|
50
|
+
function defaultMetroResolver(context, realModuleName, platform, debug) {
|
|
51
|
+
try {
|
|
52
|
+
return metroResolver.resolve(context, realModuleName, platform);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
if (debug)
|
|
56
|
+
console.log(chalk.cyan(`[Nx] Unable to resolve with default Metro resolver: ${realModuleName}`));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* This resolver try to resolve module for pnpm.
|
|
61
|
+
* @returns path if resolved, else undefined
|
|
62
|
+
* This pnpm resolver is inspired from https://github.com/vjpr/pnpm-react-native-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js
|
|
63
|
+
*/
|
|
64
|
+
function pnpmResolver(extensions, context, realModuleName, debug) {
|
|
65
|
+
try {
|
|
66
|
+
const pnpmResolve = getPnpmResolver(extensions);
|
|
67
|
+
const lookupStartPath = (0, path_1.dirname)(context.originModulePath);
|
|
68
|
+
const filePath = pnpmResolve.resolveSync({}, lookupStartPath, realModuleName);
|
|
69
|
+
if (filePath) {
|
|
70
|
+
return { type: 'sourceFile', filePath };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
if (debug)
|
|
75
|
+
console.log(chalk.cyan(`[Nx] Unable to resolve with default PNPM resolver: ${realModuleName}`));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* This function try to resolve files that are specified in tsconfig's paths
|
|
80
|
+
* @returns path if resolved, else undefined
|
|
81
|
+
*/
|
|
82
|
+
function tsconfigPathsResolver(context, extensions, realModuleName, platform, debug) {
|
|
83
|
+
try {
|
|
84
|
+
const tsConfigPathMatcher = getMatcher(debug);
|
|
85
|
+
const match = tsConfigPathMatcher(realModuleName, undefined, undefined, extensions.map((ext) => `.${ext}`));
|
|
86
|
+
return metroResolver.resolve(context, match, platform);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
if (debug) {
|
|
90
|
+
console.log(chalk.cyan(`[Nx] Failed to resolve ${chalk.bold(realModuleName)}`));
|
|
91
|
+
console.log(chalk.cyan(`[Nx] The following tsconfig paths was used:\n:${chalk.bold(JSON.stringify(paths, null, 2))}`));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
let matcher;
|
|
96
|
+
let absoluteBaseUrl;
|
|
97
|
+
let paths;
|
|
98
|
+
function getMatcher(debug) {
|
|
99
|
+
if (!matcher) {
|
|
100
|
+
const result = (0, tsconfig_paths_1.loadConfig)();
|
|
101
|
+
if (result.resultType === 'success') {
|
|
102
|
+
absoluteBaseUrl = result.absoluteBaseUrl;
|
|
103
|
+
paths = result.paths;
|
|
104
|
+
if (debug) {
|
|
105
|
+
console.log(chalk.cyan(`[Nx] Located tsconfig at ${chalk.bold(absoluteBaseUrl)}`));
|
|
106
|
+
console.log(chalk.cyan(`[Nx] Found the following paths:\n:${chalk.bold(JSON.stringify(paths, null, 2))}`));
|
|
107
|
+
}
|
|
108
|
+
matcher = (0, tsconfig_paths_1.createMatchPath)(absoluteBaseUrl, paths);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
console.log(chalk.cyan(`[Nx] Failed to locate tsconfig}`));
|
|
112
|
+
throw new Error(`Could not load tsconfig for project`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return matcher;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* This function returns resolver for pnpm.
|
|
119
|
+
* It is inspired form https://github.com/vjpr/pnpm-expo-example/blob/main/packages/pnpm-expo-helper/util/make-resolver.js.
|
|
120
|
+
*/
|
|
121
|
+
let resolver;
|
|
122
|
+
function getPnpmResolver(extensions) {
|
|
123
|
+
if (!resolver) {
|
|
124
|
+
const fileSystem = new enhanced_resolve_1.CachedInputFileSystem(fs, 4000);
|
|
125
|
+
resolver = enhanced_resolve_1.ResolverFactory.createResolver({
|
|
126
|
+
fileSystem,
|
|
127
|
+
extensions: extensions.map((extension) => '.' + extension),
|
|
128
|
+
useSyncFileSystemCalls: true,
|
|
129
|
+
modules: [(0, path_1.join)(devkit_1.workspaceRoot, 'node_modules'), 'node_modules'],
|
|
130
|
+
conditionNames: ['native', 'browser', 'require', 'default'],
|
|
131
|
+
mainFields: ['react-native', 'browser', 'main'],
|
|
132
|
+
aliasFields: ['browser'],
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return resolver;
|
|
136
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
2
|
+
export interface ReactNativePluginOptions {
|
|
3
|
+
startTargetName?: string;
|
|
4
|
+
podInstallTargetName?: string;
|
|
5
|
+
runIosTargetName?: string;
|
|
6
|
+
runAndroidTargetName?: string;
|
|
7
|
+
buildIosTargetName?: string;
|
|
8
|
+
buildAndroidTargetName?: string;
|
|
9
|
+
bundleTargetName?: string;
|
|
10
|
+
syncDepsTargetName?: string;
|
|
11
|
+
upgradeTargetname?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const createDependencies: CreateDependencies;
|
|
14
|
+
export declare const createNodes: CreateNodes<ReactNativePluginOptions>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const js_1 = require("@nx/js");
|
|
7
|
+
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
10
|
+
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
11
|
+
const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'react-native.hash');
|
|
12
|
+
const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
|
|
13
|
+
const calculatedTargets = {};
|
|
14
|
+
function readTargetsCache() {
|
|
15
|
+
return (0, devkit_1.readJsonFile)(cachePath);
|
|
16
|
+
}
|
|
17
|
+
function writeTargetsToCache(targets) {
|
|
18
|
+
(0, devkit_1.writeJsonFile)(cachePath, targets);
|
|
19
|
+
}
|
|
20
|
+
const createDependencies = () => {
|
|
21
|
+
writeTargetsToCache(calculatedTargets);
|
|
22
|
+
return [];
|
|
23
|
+
};
|
|
24
|
+
exports.createDependencies = createDependencies;
|
|
25
|
+
exports.createNodes = [
|
|
26
|
+
'**/app.{json,config.js}',
|
|
27
|
+
(configFilePath, options, context) => {
|
|
28
|
+
options = normalizeOptions(options);
|
|
29
|
+
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
30
|
+
// Do not create a project if package.json or project.json or metro.config.js isn't there.
|
|
31
|
+
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
32
|
+
if (!siblingFiles.includes('package.json') ||
|
|
33
|
+
!siblingFiles.includes('metro.config.js')) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
const appConfig = getAppConfig(configFilePath, context);
|
|
37
|
+
if (appConfig.expo) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
|
|
41
|
+
(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
|
|
42
|
+
]);
|
|
43
|
+
const targets = targetsCache[hash]
|
|
44
|
+
? targetsCache[hash]
|
|
45
|
+
: buildReactNativeTargets(projectRoot, options, context);
|
|
46
|
+
calculatedTargets[hash] = targets;
|
|
47
|
+
return {
|
|
48
|
+
projects: {
|
|
49
|
+
[projectRoot]: {
|
|
50
|
+
targets,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
function buildReactNativeTargets(projectRoot, options, context) {
|
|
57
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
58
|
+
const targets = {
|
|
59
|
+
[options.startTargetName]: {
|
|
60
|
+
command: `react-native start`,
|
|
61
|
+
options: { cwd: projectRoot },
|
|
62
|
+
},
|
|
63
|
+
[options.podInstallTargetName]: {
|
|
64
|
+
command: `pod install`,
|
|
65
|
+
options: { cwd: (0, devkit_1.joinPathFragments)(projectRoot, 'ios') },
|
|
66
|
+
dependsOn: [`${options.syncDepsTargetName}`],
|
|
67
|
+
cache: true,
|
|
68
|
+
inputs: getInputs(namedInputs),
|
|
69
|
+
outputs: [
|
|
70
|
+
getOutputs(projectRoot, 'ios/Pods'),
|
|
71
|
+
getOutputs(projectRoot, 'ios/Podfile.lock'),
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
[options.runIosTargetName]: {
|
|
75
|
+
command: `react-native run-ios`,
|
|
76
|
+
options: { cwd: projectRoot },
|
|
77
|
+
},
|
|
78
|
+
[options.runAndroidTargetName]: {
|
|
79
|
+
command: `react-native run-android`,
|
|
80
|
+
options: { cwd: projectRoot },
|
|
81
|
+
},
|
|
82
|
+
[options.buildIosTargetName]: {
|
|
83
|
+
command: `react-native build-ios`,
|
|
84
|
+
options: { cwd: projectRoot },
|
|
85
|
+
cache: true,
|
|
86
|
+
dependsOn: [`^${options.buildIosTargetName}`],
|
|
87
|
+
inputs: getInputs(namedInputs),
|
|
88
|
+
outputs: [getOutputs(projectRoot, 'ios/build/Build/Products')],
|
|
89
|
+
},
|
|
90
|
+
[options.buildAndroidTargetName]: {
|
|
91
|
+
command: `react-native build-android`,
|
|
92
|
+
options: { cwd: projectRoot },
|
|
93
|
+
cache: true,
|
|
94
|
+
dependsOn: [`^${options.buildAndroidTargetName}`],
|
|
95
|
+
inputs: getInputs(namedInputs),
|
|
96
|
+
outputs: [getOutputs(projectRoot, 'android/app/build/outputs')],
|
|
97
|
+
},
|
|
98
|
+
[options.bundleTargetName]: {
|
|
99
|
+
command: `react-native bundle`,
|
|
100
|
+
options: { cwd: projectRoot },
|
|
101
|
+
dependsOn: [`^${options.bundleTargetName}`],
|
|
102
|
+
inputs: getInputs(namedInputs),
|
|
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
|
+
},
|
|
111
|
+
};
|
|
112
|
+
return targets;
|
|
113
|
+
}
|
|
114
|
+
function getAppConfig(configFilePath, context) {
|
|
115
|
+
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
116
|
+
let module = load(resolvedPath);
|
|
117
|
+
return module.default ?? module;
|
|
118
|
+
}
|
|
119
|
+
function getInputs(namedInputs) {
|
|
120
|
+
return [
|
|
121
|
+
...('production' in namedInputs
|
|
122
|
+
? ['default', '^production']
|
|
123
|
+
: ['default', '^default']),
|
|
124
|
+
{
|
|
125
|
+
externalDependencies: ['react-native'],
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
function getOutputs(projectRoot, dir) {
|
|
130
|
+
if (projectRoot === '.') {
|
|
131
|
+
return `{projectRoot}/${dir}`;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return `{workspaceRoot}/${projectRoot}/${dir}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Load the module after ensuring that the require cache is cleared.
|
|
139
|
+
*/
|
|
140
|
+
function load(path) {
|
|
141
|
+
// Clear cache if the path is in the cache
|
|
142
|
+
if (require.cache[path]) {
|
|
143
|
+
for (const k of Object.keys(require.cache)) {
|
|
144
|
+
delete require.cache[k];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Then require
|
|
148
|
+
return require(path);
|
|
149
|
+
}
|
|
150
|
+
function normalizeOptions(options) {
|
|
151
|
+
options ??= {};
|
|
152
|
+
options.startTargetName ??= 'start';
|
|
153
|
+
options.podInstallTargetName ??= 'pod-install';
|
|
154
|
+
options.runIosTargetName ??= 'run-ios';
|
|
155
|
+
options.runAndroidTargetName ??= 'run-android';
|
|
156
|
+
options.buildIosTargetName ??= 'build-ios';
|
|
157
|
+
options.buildAndroidTargetName ??= 'build-android';
|
|
158
|
+
options.bundleTargetName ??= 'bundle';
|
|
159
|
+
options.syncDepsTargetName ??= 'sync-deps';
|
|
160
|
+
options.upgradeTargetname ??= 'upgrade';
|
|
161
|
+
return options;
|
|
162
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MetroConfig } from 'metro-config';
|
|
2
|
+
interface WithNxOptions {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
extensions?: string[];
|
|
5
|
+
watchFolders?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare function withNxMetro(userConfig: MetroConfig, opts?: WithNxOptions): Promise<import("metro-config").ConfigT>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withNxMetro = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const metro_config_1 = require("metro-config");
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
const metro_resolver_1 = require("./metro-resolver");
|
|
8
|
+
async function withNxMetro(userConfig, opts = {}) {
|
|
9
|
+
const extensions = ['', 'ts', 'tsx', 'js', 'jsx', 'json'];
|
|
10
|
+
if (opts.debug)
|
|
11
|
+
process.env.NX_REACT_NATIVE_DEBUG = 'true';
|
|
12
|
+
if (opts.extensions)
|
|
13
|
+
extensions.push(...opts.extensions);
|
|
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());
|
|
18
|
+
if (opts.watchFolders?.length) {
|
|
19
|
+
watchFolders = watchFolders.concat(opts.watchFolders);
|
|
20
|
+
}
|
|
21
|
+
watchFolders = [...new Set(watchFolders)].filter((folder) => (0, fs_extra_1.existsSync)(folder));
|
|
22
|
+
const nxConfig = {
|
|
23
|
+
resolver: {
|
|
24
|
+
resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions),
|
|
25
|
+
nodeModulesPaths: [(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'node_modules')],
|
|
26
|
+
},
|
|
27
|
+
watchFolders,
|
|
28
|
+
};
|
|
29
|
+
return (0, metro_config_1.mergeConfig)(userConfig, nxConfig);
|
|
30
|
+
}
|
|
31
|
+
exports.withNxMetro = withNxMetro;
|
package/project.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/react-native/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"targets": {
|
|
7
|
+
"lint": {},
|
|
8
|
+
"test": {},
|
|
9
|
+
"build-base": {
|
|
10
|
+
"executor": "@nx/js:tsc",
|
|
11
|
+
"options": {
|
|
12
|
+
"assets": [
|
|
13
|
+
"packages/react-native/*.md",
|
|
14
|
+
{
|
|
15
|
+
"input": "packages/react-native",
|
|
16
|
+
"glob": "**/files/**/.babelrc.template",
|
|
17
|
+
"output": "/"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"input": "packages/react-native/src",
|
|
21
|
+
"glob": "**/*.!(ts)",
|
|
22
|
+
"output": "/src"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"input": "packages/react-native",
|
|
26
|
+
"glob": "**/*.json",
|
|
27
|
+
"ignore": ["**/tsconfig*.json"],
|
|
28
|
+
"output": "/"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"input": "packages/react-native",
|
|
32
|
+
"glob": "**/*.d.ts",
|
|
33
|
+
"output": "/"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"input": "",
|
|
37
|
+
"glob": "LICENSE",
|
|
38
|
+
"output": "/"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"build": {
|
|
44
|
+
"executor": "nx:run-commands",
|
|
45
|
+
"outputs": ["{workspaceRoot}/build/packages/react-native"],
|
|
46
|
+
"options": {
|
|
47
|
+
"command": "node ./scripts/copy-readme.js react-native"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"add-extra-dependencies": {
|
|
51
|
+
"command": "node ./scripts/add-dependency-to-build.js react-native @nrwl/react-native"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { ReactNativeBuildAndroidOptions } from './schema';
|
|
3
|
+
export interface ReactNativeBuildOutput {
|
|
4
|
+
success: boolean;
|
|
5
|
+
}
|
|
6
|
+
export default function buildAndroidExecutor(options: ReactNativeBuildAndroidOptions, context: ExecutorContext): AsyncGenerator<ReactNativeBuildOutput>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
|
|
6
|
+
const get_cli_options_1 = require("../../utils/get-cli-options");
|
|
7
|
+
async function* buildAndroidExecutor(options, context) {
|
|
8
|
+
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
9
|
+
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(context.root, projectRoot, 'android'));
|
|
10
|
+
await runCliBuild(context.root, projectRoot, options);
|
|
11
|
+
yield { success: true };
|
|
12
|
+
}
|
|
13
|
+
exports.default = buildAndroidExecutor;
|
|
14
|
+
function runCliBuild(workspaceRoot, projectRoot, options) {
|
|
15
|
+
return new Promise((res, reject) => {
|
|
16
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['build-android', ...createBuildAndroidOptions(options)], {
|
|
17
|
+
stdio: 'inherit',
|
|
18
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
19
|
+
env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Ensure the child process is killed when the parent exits
|
|
23
|
+
*/
|
|
24
|
+
const processExitListener = (signal) => () => {
|
|
25
|
+
childProcess.kill(signal);
|
|
26
|
+
process.exit();
|
|
27
|
+
};
|
|
28
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
29
|
+
process.once('SIGTERM', processExitListener);
|
|
30
|
+
process.once('SIGINT', processExitListener);
|
|
31
|
+
process.once('SIGQUIT', processExitListener);
|
|
32
|
+
childProcess.on('error', (err) => {
|
|
33
|
+
reject(err);
|
|
34
|
+
});
|
|
35
|
+
childProcess.on('exit', (code) => {
|
|
36
|
+
if (code === 0) {
|
|
37
|
+
res(childProcess);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
reject(code);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const startOptions = ['port', 'resetCache'];
|
|
46
|
+
function createBuildAndroidOptions(options) {
|
|
47
|
+
return (0, get_cli_options_1.getCliOptions)(options, startOptions);
|
|
48
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { join, resolve as pathResolve } from 'path';
|
|
3
|
+
import { ChildProcess, fork } from 'child_process';
|
|
4
|
+
import { ReactNativeBuildAndroidOptions } from './schema';
|
|
5
|
+
import { chmodAndroidGradlewFiles } from '../../utils/chmod-android-gradle-files';
|
|
6
|
+
import { getCliOptions } from '../../utils/get-cli-options';
|
|
7
|
+
|
|
8
|
+
export interface ReactNativeBuildOutput {
|
|
9
|
+
success: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default async function* buildAndroidExecutor(
|
|
13
|
+
options: ReactNativeBuildAndroidOptions,
|
|
14
|
+
context: ExecutorContext
|
|
15
|
+
): AsyncGenerator<ReactNativeBuildOutput> {
|
|
16
|
+
const projectRoot =
|
|
17
|
+
context.projectsConfigurations.projects[context.projectName].root;
|
|
18
|
+
chmodAndroidGradlewFiles(join(context.root, projectRoot, 'android'));
|
|
19
|
+
|
|
20
|
+
await runCliBuild(context.root, projectRoot, options);
|
|
21
|
+
yield { success: true };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function runCliBuild(
|
|
25
|
+
workspaceRoot: string,
|
|
26
|
+
projectRoot: string,
|
|
27
|
+
options: ReactNativeBuildAndroidOptions
|
|
28
|
+
) {
|
|
29
|
+
return new Promise<ChildProcess>((res, reject) => {
|
|
30
|
+
const childProcess = fork(
|
|
31
|
+
require.resolve('react-native/cli.js'),
|
|
32
|
+
['build-android', ...createBuildAndroidOptions(options)],
|
|
33
|
+
{
|
|
34
|
+
stdio: 'inherit',
|
|
35
|
+
cwd: pathResolve(workspaceRoot, projectRoot),
|
|
36
|
+
env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Ensure the child process is killed when the parent exits
|
|
42
|
+
*/
|
|
43
|
+
const processExitListener = (signal?: number | NodeJS.Signals) => () => {
|
|
44
|
+
childProcess.kill(signal);
|
|
45
|
+
process.exit();
|
|
46
|
+
};
|
|
47
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
48
|
+
process.once('SIGTERM', processExitListener);
|
|
49
|
+
process.once('SIGINT', processExitListener);
|
|
50
|
+
process.once('SIGQUIT', processExitListener);
|
|
51
|
+
|
|
52
|
+
childProcess.on('error', (err) => {
|
|
53
|
+
reject(err);
|
|
54
|
+
});
|
|
55
|
+
childProcess.on('exit', (code) => {
|
|
56
|
+
if (code === 0) {
|
|
57
|
+
res(childProcess);
|
|
58
|
+
} else {
|
|
59
|
+
reject(code);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const startOptions = ['port', 'resetCache'];
|
|
66
|
+
|
|
67
|
+
function createBuildAndroidOptions(options: ReactNativeBuildAndroidOptions) {
|
|
68
|
+
return getCliOptions<ReactNativeBuildAndroidOptions>(options, startOptions);
|
|
69
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// options taken from https://github.com/react-native-community/cli/blob/main/packages/cli-platform-android/src/commands/buildAndroid/index.ts
|
|
2
|
+
// https://github.com/react-native-community/cli/blob/main/packages/cli-platform-android/README.md#build-android
|
|
3
|
+
|
|
4
|
+
import { ReactNativeStartOptions } from '../start/schema';
|
|
5
|
+
|
|
6
|
+
export interface ReactNativeBuildAndroidOptions
|
|
7
|
+
extends ReactNativeStartOptions {
|
|
8
|
+
// react native options
|
|
9
|
+
mode: string; // default is debug
|
|
10
|
+
activeArchOnly: boolean; // default is false
|
|
11
|
+
tasks?: string | Array<string>;
|
|
12
|
+
extraParams?: Array<string>;
|
|
13
|
+
interactive: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"outputCapture": "direct-nodejs",
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"$id": "NxReactNativeBuildAndroid",
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
|
+
"title": "Release Build for Android",
|
|
8
|
+
"description": "Build target options for Android.",
|
|
9
|
+
"type": "object",
|
|
10
|
+
"presets": [
|
|
11
|
+
{
|
|
12
|
+
"name": "Build Android for current device architecture",
|
|
13
|
+
"keys": ["activeArchOnly"]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "Build Android without metro cache",
|
|
17
|
+
"keys": ["resetCache"]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "Build Android with specific tasks",
|
|
21
|
+
"keys": ["tasks"]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "Build Android with a specific mode",
|
|
25
|
+
"keys": ["mode"]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"properties": {
|
|
29
|
+
"mode": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Specify your app's build variant",
|
|
32
|
+
"default": "debug",
|
|
33
|
+
"examples": ["debug", "release"],
|
|
34
|
+
"x-priority": "important"
|
|
35
|
+
},
|
|
36
|
+
"port": {
|
|
37
|
+
"type": "number",
|
|
38
|
+
"description": "The port where the packager server is listening on.",
|
|
39
|
+
"default": 8081
|
|
40
|
+
},
|
|
41
|
+
"tasks": {
|
|
42
|
+
"oneOf": [
|
|
43
|
+
{ "type": "array", "items": { "type": "string" } },
|
|
44
|
+
{ "type": "string" }
|
|
45
|
+
],
|
|
46
|
+
"description": "Run custom Gradle tasks. By default it's \"assembleDebug\". Will override passed mode and variant arguments.",
|
|
47
|
+
"examples": [
|
|
48
|
+
"assembleDebug",
|
|
49
|
+
"assembleRelease",
|
|
50
|
+
"bundleDebug",
|
|
51
|
+
"bundleRelease",
|
|
52
|
+
"installDebug",
|
|
53
|
+
"installRelease"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"activeArchOnly": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Build native libraries only for the current device architecture for debug builds.",
|
|
59
|
+
"default": false
|
|
60
|
+
},
|
|
61
|
+
"extraParams": {
|
|
62
|
+
"oneOf": [
|
|
63
|
+
{ "type": "array", "items": { "type": "string" } },
|
|
64
|
+
{ "type": "string" }
|
|
65
|
+
],
|
|
66
|
+
"description": "Custom params passed to gradle build command",
|
|
67
|
+
"examples": ["-x lint -x test"]
|
|
68
|
+
},
|
|
69
|
+
"interactive": {
|
|
70
|
+
"type": "boolean",
|
|
71
|
+
"description": "Explicitly select build type and flavour to use before running a build"
|
|
72
|
+
},
|
|
73
|
+
"resetCache": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"description": "Resets metro cache.",
|
|
76
|
+
"default": false
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"required": [],
|
|
80
|
+
"examplesFile": "../../../docs/build-android-examples.md"
|
|
81
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { ReactNativeBuildIosOptions } from './schema';
|
|
3
|
+
export interface ReactNativeBuildIosOutput {
|
|
4
|
+
success: boolean;
|
|
5
|
+
}
|
|
6
|
+
export default function buildIosExecutor(options: ReactNativeBuildIosOptions, context: ExecutorContext): AsyncGenerator<ReactNativeBuildIosOutput>;
|