@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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
import update from './add-web-configuration';
|
|
4
|
+
|
|
5
|
+
describe('add-web-configuration', () => {
|
|
6
|
+
let tree: Tree;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
+
addProjectConfiguration(tree, 'product', {
|
|
11
|
+
root: 'apps/product',
|
|
12
|
+
sourceRoot: 'apps/product/src',
|
|
13
|
+
targets: {
|
|
14
|
+
start: {
|
|
15
|
+
executor: '@nx/react-native:start',
|
|
16
|
+
options: {},
|
|
17
|
+
},
|
|
18
|
+
serve: {
|
|
19
|
+
executor: 'nx:run-commands',
|
|
20
|
+
options: {
|
|
21
|
+
command: 'nx start product',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it(`should add web configuration`, async () => {
|
|
29
|
+
await update(tree);
|
|
30
|
+
|
|
31
|
+
tree.exists('apps/product/webpack.config.js');
|
|
32
|
+
getProjects(tree).forEach((project) => {
|
|
33
|
+
expect(project.targets['build'].executor).toEqual('@nx/webpack:webpack');
|
|
34
|
+
expect(project.targets['serve'].executor).toEqual(
|
|
35
|
+
'@nx/webpack:dev-server'
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const output_1 = require("nx/src/utils/output");
|
|
5
|
+
const migrate_7_1 = require("@nx/storybook/src/generators/migrate-7/migrate-7");
|
|
6
|
+
const utilities_1 = require("@nx/storybook/src/utils/utilities");
|
|
7
|
+
const configuration_1 = require("@nx/react/src/generators/storybook-configuration/configuration");
|
|
8
|
+
/**
|
|
9
|
+
* Upgrade react native storybook target to use web
|
|
10
|
+
*/
|
|
11
|
+
async function changeStorybookTargets(tree) {
|
|
12
|
+
const tasks = [];
|
|
13
|
+
// update the storybook target
|
|
14
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
15
|
+
let hasStorybookTarget = false;
|
|
16
|
+
for (const [projectName, config] of projects.entries()) {
|
|
17
|
+
if (config.targets?.['storybook']?.executor === '@nx/react-native:storybook') {
|
|
18
|
+
hasStorybookTarget = true;
|
|
19
|
+
delete config.targets['storybook'];
|
|
20
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
|
|
21
|
+
tasks.push(await (0, configuration_1.default)(tree, {
|
|
22
|
+
project: projectName,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* This just checks if Storybook is installed in the workspace.
|
|
28
|
+
* The thing here is that during the previous step of the migration,
|
|
29
|
+
* during packageJsonUpdates, Nx has already set Storybook
|
|
30
|
+
* to version 7, if Storybook exists in the workspace.
|
|
31
|
+
* So, it makes no sense here to check if the version is
|
|
32
|
+
* 7, because it will always be.
|
|
33
|
+
*/
|
|
34
|
+
const storybookVersion = (0, utilities_1.storybookMajorVersion)();
|
|
35
|
+
if (!hasStorybookTarget || !storybookVersion) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
output_1.output.log({
|
|
39
|
+
title: 'Migrating Storybook to v7',
|
|
40
|
+
bodyLines: [
|
|
41
|
+
`🚀 This migration will update your Storybook configuration to v7.`,
|
|
42
|
+
`It will call the @nx/storybook:migrate-7 generator for you.`,
|
|
43
|
+
`You can read more about the migration and how this generator works here:`,
|
|
44
|
+
`https://nx.dev/packages/storybook/generators/migrate-7`,
|
|
45
|
+
],
|
|
46
|
+
});
|
|
47
|
+
tasks.push(await (0, migrate_7_1.default)(tree, { autoAcceptAllPrompts: true }));
|
|
48
|
+
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(tree, [], [
|
|
49
|
+
'@storybook/react-native',
|
|
50
|
+
'@storybook/addon-ondevice-actions',
|
|
51
|
+
'@storybook/addon-ondevice-backgrounds',
|
|
52
|
+
'@storybook/addon-ondevice-controls',
|
|
53
|
+
'@storybook/addon-ondevice-notes',
|
|
54
|
+
]));
|
|
55
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
56
|
+
}
|
|
57
|
+
exports.default = changeStorybookTargets;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
/**
|
|
5
|
+
* This migration removes blockList in metro.config.js.
|
|
6
|
+
* It is now excluding dist folder in watchFolders in withNxMetro.
|
|
7
|
+
*/
|
|
8
|
+
async function update(tree) {
|
|
9
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
10
|
+
for (const [_, config] of projects.entries()) {
|
|
11
|
+
if (config.targets?.['start']?.executor === '@nx/react-native:start') {
|
|
12
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(config.root, 'metro.config.js'))) {
|
|
13
|
+
let content = tree
|
|
14
|
+
.read((0, devkit_1.joinPathFragments)(config.root, 'metro.config.js'))
|
|
15
|
+
.toString();
|
|
16
|
+
content = content.replace(/blockList: exclusionList(.+?(?=\n))/, '');
|
|
17
|
+
content = content.replace('// unstable_enableSymlinks: true,', '');
|
|
18
|
+
content = content.replace('// unstable_enablePackageExports: true,', '');
|
|
19
|
+
content = content.replace('unstable_enableSymlinks: true,', '');
|
|
20
|
+
content = content.replace('unstable_enablePackageExports: true,', '');
|
|
21
|
+
content = content.replace(`const exclusionList = require('metro-config/src/defaults/exclusionList');`, '');
|
|
22
|
+
tree.write((0, devkit_1.joinPathFragments)(config.root, 'metro.config.js'), content);
|
|
23
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = update;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
2
|
+
import { Tree, addProjectConfiguration } from '@nx/devkit';
|
|
3
|
+
import update from './remove-block-list';
|
|
4
|
+
|
|
5
|
+
describe('remove-block-list', () => {
|
|
6
|
+
let tree: Tree;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
+
addProjectConfiguration(tree, 'product', {
|
|
11
|
+
root: 'apps/product',
|
|
12
|
+
targets: {
|
|
13
|
+
start: {
|
|
14
|
+
executor: '@nx/react-native:start',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
tree.write(
|
|
19
|
+
'apps/product/metro.config.js',
|
|
20
|
+
`
|
|
21
|
+
const { withNxMetro } = require('@nx/expo');
|
|
22
|
+
const { getDefaultConfig } = require('@expo/metro-config');
|
|
23
|
+
const { mergeConfig } = require('metro-config');
|
|
24
|
+
const exclusionList = require('metro-config/src/defaults/exclusionList');
|
|
25
|
+
|
|
26
|
+
const defaultConfig = getDefaultConfig(__dirname);
|
|
27
|
+
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Metro configuration
|
|
31
|
+
* https://facebook.github.io/metro/docs/configuration
|
|
32
|
+
*
|
|
33
|
+
* @type {import('metro-config').MetroConfig}
|
|
34
|
+
*/
|
|
35
|
+
const customConfig = {
|
|
36
|
+
transformer: {
|
|
37
|
+
babelTransformerPath: require.resolve('react-native-svg-transformer'),
|
|
38
|
+
},
|
|
39
|
+
resolver: {
|
|
40
|
+
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
41
|
+
sourceExts: [...sourceExts, 'svg'],
|
|
42
|
+
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
|
|
43
|
+
unstable_enableSymlinks: true,
|
|
44
|
+
unstable_enablePackageExports: true,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
|
|
50
|
+
// Change this to true to see debugging info.
|
|
51
|
+
// Useful if you have issues resolving modules
|
|
52
|
+
debug: false,
|
|
53
|
+
// all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
|
|
54
|
+
extensions: [],
|
|
55
|
+
// Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
|
|
56
|
+
watchFolders: [],
|
|
57
|
+
});`
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('should remove blockList', async () => {
|
|
62
|
+
await update(tree);
|
|
63
|
+
const metroConfig = tree.read(`apps/product/metro.config.js`).toString();
|
|
64
|
+
expect(metroConfig).not.toContain('blockList');
|
|
65
|
+
expect(metroConfig).not.toContain('unstable_enableSymlinks');
|
|
66
|
+
expect(metroConfig).not.toContain('unstable_enablePackageExports');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Remove metro-* package since it is no longer explicity required in package.json.
|
|
4
|
+
* react-native has dependency of @react-native/community-cli-plugin
|
|
5
|
+
* @react-native/community-cli-plugin has dependency of metro
|
|
6
|
+
*
|
|
7
|
+
* Also remove @react-native-community/cli-* since it is a dependency of react-native.
|
|
8
|
+
* (excpet reactNativeCommunityCliPlatformAndroidVersion because android files refer it by path)
|
|
9
|
+
*
|
|
10
|
+
* https://react-native-community.github.io/upgrade-helper/?from=0.72.6&to=0.73.1#RnDiffApp-package.json
|
|
11
|
+
* @param tree
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export default function update(tree: Tree): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
/**
|
|
5
|
+
* Remove metro-* package since it is no longer explicity required in package.json.
|
|
6
|
+
* react-native has dependency of @react-native/community-cli-plugin
|
|
7
|
+
* @react-native/community-cli-plugin has dependency of metro
|
|
8
|
+
*
|
|
9
|
+
* Also remove @react-native-community/cli-* since it is a dependency of react-native.
|
|
10
|
+
* (excpet reactNativeCommunityCliPlatformAndroidVersion because android files refer it by path)
|
|
11
|
+
*
|
|
12
|
+
* https://react-native-community.github.io/upgrade-helper/?from=0.72.6&to=0.73.1#RnDiffApp-package.json
|
|
13
|
+
* @param tree
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
async function update(tree) {
|
|
17
|
+
(0, devkit_1.removeDependenciesFromPackageJson)(tree, [], [
|
|
18
|
+
'metro',
|
|
19
|
+
'metro-resolver',
|
|
20
|
+
'metro-config',
|
|
21
|
+
'metro-react-native-babel-preset',
|
|
22
|
+
'metro-babel-register',
|
|
23
|
+
'metro-react-native-babel-transformer',
|
|
24
|
+
'@react-native-community/cli',
|
|
25
|
+
'@react-native-community/cli-platform-ios',
|
|
26
|
+
]);
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
29
|
+
exports.default = update;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
/**
|
|
6
|
+
* Remove ensure-symlink target.
|
|
7
|
+
* It is going to be supported by react-native version 0.73 by default.
|
|
8
|
+
*/
|
|
9
|
+
async function update(tree) {
|
|
10
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
11
|
+
for (const [projectName, config] of projects.entries()) {
|
|
12
|
+
if (config.targets?.['ensure-symlink']?.executor ===
|
|
13
|
+
'@nx/react-native:ensure-symlink') {
|
|
14
|
+
removeTargets(config.targets, 'ensure-symlink');
|
|
15
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
|
|
16
|
+
(0, fs_extra_1.removeSync)(`${config.root}/node_modules`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = update;
|
|
21
|
+
function removeTargets(targets, targetNameToRemove) {
|
|
22
|
+
for (const targetName in targets) {
|
|
23
|
+
if (targetName === targetNameToRemove) {
|
|
24
|
+
delete targets[targetName];
|
|
25
|
+
}
|
|
26
|
+
if (targets[targetName]?.dependsOn?.length) {
|
|
27
|
+
targets[targetName].dependsOn = targets[targetName].dependsOn.filter((dependsOn) => dependsOn !== targetNameToRemove);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
import update from './remove-symlink-target';
|
|
4
|
+
|
|
5
|
+
describe('remove-symlink-target', () => {
|
|
6
|
+
let tree: Tree;
|
|
7
|
+
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
+
addProjectConfiguration(tree, 'product', {
|
|
11
|
+
root: 'apps/product',
|
|
12
|
+
sourceRoot: 'apps/product/src',
|
|
13
|
+
targets: {
|
|
14
|
+
'ensure-symlink': {
|
|
15
|
+
executor: '@nx/react-native:ensure-symlink',
|
|
16
|
+
options: {},
|
|
17
|
+
},
|
|
18
|
+
'bundle-android': {
|
|
19
|
+
executor: '@nx/react-native:bundle',
|
|
20
|
+
dependsOn: ['ensure-symlink'],
|
|
21
|
+
outputs: ['{options.bundleOutput}'],
|
|
22
|
+
options: {
|
|
23
|
+
entryFile: 'src/main.tsx',
|
|
24
|
+
platform: 'android',
|
|
25
|
+
bundleOutput: 'dist/apps/techy-jokes/android/main.jsbundle',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it(`should remove ensure-symlink target from project.json`, async () => {
|
|
33
|
+
await update(tree);
|
|
34
|
+
|
|
35
|
+
getProjects(tree).forEach((project) => {
|
|
36
|
+
expect(project.targets['ensure-symlink']).toBeUndefined();
|
|
37
|
+
expect(project.targets['bundle-android'].dependsOn).toEqual([]);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addJest = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const jest_1 = require("@nx/jest");
|
|
6
|
+
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin) {
|
|
7
|
+
if (unitTestRunner !== 'jest') {
|
|
8
|
+
return () => { };
|
|
9
|
+
}
|
|
10
|
+
const jestTask = await (0, jest_1.configurationGenerator)(host, {
|
|
11
|
+
js,
|
|
12
|
+
project: projectName,
|
|
13
|
+
supportTsx: true,
|
|
14
|
+
skipSerializers: true,
|
|
15
|
+
setupFile: 'none',
|
|
16
|
+
compiler: 'babel',
|
|
17
|
+
skipPackageJson,
|
|
18
|
+
skipFormat: true,
|
|
19
|
+
addPlugin,
|
|
20
|
+
});
|
|
21
|
+
// overwrite the jest.config.ts file because react native needs to have special transform property
|
|
22
|
+
const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
|
|
23
|
+
const content = `module.exports = {
|
|
24
|
+
displayName: '${projectName}',
|
|
25
|
+
preset: 'react-native',
|
|
26
|
+
resolver: '@nx/jest/plugins/resolver',
|
|
27
|
+
moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
|
|
28
|
+
setupFilesAfterEnv: ['<rootDir>/test-setup.${js ? 'js' : 'ts'}'],
|
|
29
|
+
moduleNameMapper: {
|
|
30
|
+
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock'
|
|
31
|
+
},
|
|
32
|
+
transform: {
|
|
33
|
+
'^.+\\.(js|ts|tsx)$': [
|
|
34
|
+
'babel-jest',
|
|
35
|
+
{
|
|
36
|
+
configFile: __dirname + '/.babelrc.js',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
'^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
|
|
40
|
+
'react-native/jest/assetFileTransformer.js'
|
|
41
|
+
),
|
|
42
|
+
},
|
|
43
|
+
coverageDirectory: '${(0, devkit_1.offsetFromRoot)(appProjectRoot)}coverage/${appProjectRoot}'
|
|
44
|
+
};`;
|
|
45
|
+
host.write(configPath, content);
|
|
46
|
+
return jestTask;
|
|
47
|
+
}
|
|
48
|
+
exports.addJest = addJest;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Linter } from '@nx/eslint';
|
|
2
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
3
|
+
interface NormalizedSchema {
|
|
4
|
+
linter?: Linter;
|
|
5
|
+
projectName: string;
|
|
6
|
+
projectRoot: string;
|
|
7
|
+
setParserOptionsProject?: boolean;
|
|
8
|
+
tsConfigPaths: string[];
|
|
9
|
+
skipPackageJson?: boolean;
|
|
10
|
+
addPlugin?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addLinting = void 0;
|
|
4
|
+
const eslint_1 = require("@nx/eslint");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const lint_1 = require("@nx/react/src/utils/lint");
|
|
7
|
+
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
8
|
+
async function addLinting(host, options) {
|
|
9
|
+
if (options.linter === eslint_1.Linter.None) {
|
|
10
|
+
return () => { };
|
|
11
|
+
}
|
|
12
|
+
const tasks = [];
|
|
13
|
+
const lintTask = await (0, eslint_1.lintProjectGenerator)(host, {
|
|
14
|
+
linter: options.linter,
|
|
15
|
+
project: options.projectName,
|
|
16
|
+
tsConfigPaths: options.tsConfigPaths,
|
|
17
|
+
skipFormat: true,
|
|
18
|
+
skipPackageJson: options.skipPackageJson,
|
|
19
|
+
addPlugin: options.addPlugin,
|
|
20
|
+
});
|
|
21
|
+
tasks.push(lintTask);
|
|
22
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
23
|
+
(0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
|
|
24
|
+
(0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
|
|
25
|
+
'public',
|
|
26
|
+
'.cache',
|
|
27
|
+
'node_modules',
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
if (!options.skipPackageJson) {
|
|
31
|
+
const installTask = await (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
|
|
32
|
+
tasks.push(installTask);
|
|
33
|
+
}
|
|
34
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
35
|
+
}
|
|
36
|
+
exports.addLinting = addLinting;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
import { Linter } from '@nx/eslint';
|
|
4
|
+
import { libraryGenerator } from '@nx/js';
|
|
5
|
+
import { addLinting } from './add-linting';
|
|
6
|
+
|
|
7
|
+
describe('Add Linting', () => {
|
|
8
|
+
let tree: Tree;
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
12
|
+
await libraryGenerator(tree, {
|
|
13
|
+
name: 'my-lib',
|
|
14
|
+
linter: Linter.None,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should add a .eslintrc.json when is passed', async () => {
|
|
19
|
+
await addLinting(tree, {
|
|
20
|
+
projectName: 'my-lib',
|
|
21
|
+
linter: Linter.EsLint,
|
|
22
|
+
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
|
|
23
|
+
projectRoot: 'libs/my-lib',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
expect(tree.exists('libs/my-lib/.eslintrc.json')).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should not add lint target when "none" is passed', async () => {
|
|
30
|
+
await addLinting(tree, {
|
|
31
|
+
projectName: 'my-lib',
|
|
32
|
+
linter: Linter.None,
|
|
33
|
+
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
|
|
34
|
+
projectRoot: 'libs/my-lib',
|
|
35
|
+
});
|
|
36
|
+
const project = readProjectConfiguration(tree, 'my-lib');
|
|
37
|
+
|
|
38
|
+
expect(project.targets.lint).toBeUndefined();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chmodAndroidGradlewFilesTask = exports.chmodAndroidGradlewFiles = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
function chmodAndroidGradlewFiles(androidFolder) {
|
|
8
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(androidFolder, 'gradlew'))) {
|
|
9
|
+
(0, fs_1.chmodSync)((0, path_1.join)(androidFolder, 'gradlew'), 0o775);
|
|
10
|
+
}
|
|
11
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(androidFolder, 'gradlew.bat'))) {
|
|
12
|
+
(0, fs_1.chmodSync)((0, path_1.join)(androidFolder, 'gradlew.bat'), 0o775);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.chmodAndroidGradlewFiles = chmodAndroidGradlewFiles;
|
|
16
|
+
function chmodAndroidGradlewFilesTask(androidFolder) {
|
|
17
|
+
return () => {
|
|
18
|
+
devkit_1.logger.info(`chmod android gradlew files under ${androidFolder}`);
|
|
19
|
+
try {
|
|
20
|
+
chmodAndroidGradlewFiles(androidFolder);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new Error(`chmod failed gradlew file under ${androidFolder}`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.chmodAndroidGradlewFilesTask = chmodAndroidGradlewFilesTask;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureDependencies = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const versions_1 = require("@nx/react/src/utils/versions");
|
|
6
|
+
const versions_2 = require("./versions");
|
|
7
|
+
function ensureDependencies(tree) {
|
|
8
|
+
const isPnpm = (0, devkit_1.detectPackageManager)(tree.root) === 'pnpm';
|
|
9
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
10
|
+
'@types/node': versions_2.typesNodeVersion,
|
|
11
|
+
'@types/react': versions_2.typesReactVersion,
|
|
12
|
+
'@react-native/babel-preset': versions_2.reactNativeBabelPresetVersion,
|
|
13
|
+
'@react-native/metro-config': versions_2.reactNativeMetroConfigVersion,
|
|
14
|
+
'@testing-library/react-native': versions_2.testingLibraryReactNativeVersion,
|
|
15
|
+
'@testing-library/jest-native': versions_2.testingLibraryJestNativeVersion,
|
|
16
|
+
'@react-native-community/cli-platform-android': versions_2.reactNativeCommunityCliPlatformAndroidVersion,
|
|
17
|
+
'jest-react-native': versions_2.jestReactNativeVersion,
|
|
18
|
+
'react-test-renderer': versions_2.reactTestRendererVersion,
|
|
19
|
+
'react-native-svg-transformer': versions_2.reactNativeSvgTransformerVersion,
|
|
20
|
+
'react-native-svg': versions_2.reactNativeSvgVersion,
|
|
21
|
+
'@babel/preset-react': versions_1.babelPresetReactVersion,
|
|
22
|
+
'@babel/core': versions_1.babelCoreVersion,
|
|
23
|
+
...(isPnpm
|
|
24
|
+
? {
|
|
25
|
+
'@babel/runtime': versions_2.babelRuntimeVersion, // @babel/runtime is used by react-native-svg
|
|
26
|
+
}
|
|
27
|
+
: {}),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.ensureDependencies = ensureDependencies;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function symlink workspace node_modules folder with app project's node_mdules folder.
|
|
3
|
+
* For yarn and npm, it will symlink the entire node_modules folder.
|
|
4
|
+
* If app project's node_modules already exist, it will remove it first then symlink it.
|
|
5
|
+
* For pnpm, it will go through the package.json' dependencies and devDependencies, and also the required packages listed above.
|
|
6
|
+
* @param workspaceRoot path of the workspace root
|
|
7
|
+
* @param projectRoot path of app project root
|
|
8
|
+
*/
|
|
9
|
+
export declare function ensureNodeModulesSymlink(workspaceRoot: string, projectRoot: string): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureNodeModulesSymlink = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const os_1 = require("os");
|
|
6
|
+
const fs_extra_1 = require("fs-extra");
|
|
7
|
+
/**
|
|
8
|
+
* This function symlink workspace node_modules folder with app project's node_mdules folder.
|
|
9
|
+
* For yarn and npm, it will symlink the entire node_modules folder.
|
|
10
|
+
* If app project's node_modules already exist, it will remove it first then symlink it.
|
|
11
|
+
* For pnpm, it will go through the package.json' dependencies and devDependencies, and also the required packages listed above.
|
|
12
|
+
* @param workspaceRoot path of the workspace root
|
|
13
|
+
* @param projectRoot path of app project root
|
|
14
|
+
*/
|
|
15
|
+
function ensureNodeModulesSymlink(workspaceRoot, projectRoot) {
|
|
16
|
+
const worksapceNodeModulesPath = (0, path_1.join)(workspaceRoot, 'node_modules');
|
|
17
|
+
if (!(0, fs_extra_1.existsSync)(worksapceNodeModulesPath)) {
|
|
18
|
+
throw new Error(`Cannot find ${worksapceNodeModulesPath}`);
|
|
19
|
+
}
|
|
20
|
+
const appNodeModulesPath = (0, path_1.join)(workspaceRoot, projectRoot, 'node_modules');
|
|
21
|
+
// `mklink /D` requires admin privilege in Windows so we need to use junction
|
|
22
|
+
const symlinkType = (0, os_1.platform)() === 'win32' ? 'junction' : 'dir';
|
|
23
|
+
if ((0, fs_extra_1.existsSync)(appNodeModulesPath)) {
|
|
24
|
+
(0, fs_extra_1.removeSync)(appNodeModulesPath);
|
|
25
|
+
}
|
|
26
|
+
(0, fs_extra_1.symlinkSync)(worksapceNodeModulesPath, appNodeModulesPath, symlinkType);
|
|
27
|
+
}
|
|
28
|
+
exports.ensureNodeModulesSymlink = ensureNodeModulesSymlink;
|