@nx/react-native 17.0.5 → 17.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +1 -7
- package/LICENSE +1 -1
- package/README.md +4 -9
- package/executors.json +0 -5
- package/generators.json +11 -12
- package/migrations.json +0 -126
- package/package.json +15 -11
- package/plugins/metro-resolver.js +1 -4
- package/plugins/with-nx-metro.js +2 -6
- package/src/executors/build-android/build-android.impl.js +6 -2
- package/src/executors/build-android/build-android.impl.ts +6 -2
- package/src/executors/build-android/schema.json +1 -1
- package/src/executors/build-ios/schema.json +1 -1
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/bundle/schema.json +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +0 -4
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +0 -4
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -4
- package/src/executors/ensure-symlink/schema.json +1 -1
- package/src/executors/pod-install/schema.json +1 -1
- package/src/executors/run-android/run-android.impl.js +17 -5
- package/src/executors/run-android/run-android.impl.ts +18 -9
- package/src/executors/run-android/schema.json +1 -1
- package/src/executors/run-ios/run-ios.impl.js +16 -4
- package/src/executors/run-ios/run-ios.impl.ts +18 -9
- package/src/executors/run-ios/schema.json +1 -1
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/schema.json +1 -1
- package/src/executors/start/start.impl.js +26 -11
- package/src/executors/start/start.impl.ts +28 -14
- package/src/executors/storybook/storybook.impl.d.ts +0 -4
- package/src/executors/storybook/storybook.impl.js +2 -15
- package/src/executors/storybook/storybook.impl.ts +7 -26
- package/src/executors/sync-deps/schema.d.ts +0 -1
- package/src/executors/sync-deps/schema.json +1 -6
- package/src/executors/sync-deps/sync-deps.impl.d.ts +1 -2
- package/src/executors/sync-deps/sync-deps.impl.js +11 -33
- package/src/executors/sync-deps/sync-deps.impl.ts +18 -57
- package/src/generators/application/application.js +8 -52
- package/src/generators/application/application.spec.ts +2 -29
- package/src/generators/application/files/app/Gemfile.template +1 -2
- package/src/generators/application/files/app/android/app/build.gradle.template +28 -12
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +6 -2
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +75 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +32 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +62 -0
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +20 -0
- package/src/generators/application/files/app/android/build.gradle.template +20 -7
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +1 -2
- package/src/generators/application/files/app/android/gradle.properties +3 -0
- package/src/generators/application/files/app/android/gradlew.template +7 -12
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/babel.config.json.template +3 -0
- package/src/generators/application/files/app/ios/Podfile.template +7 -0
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +0 -5
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +8 -5
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +33 -11
- package/src/generators/application/files/app/metro.config.js.template +5 -1
- package/src/generators/application/files/app/src/app/App.tsx.template +13 -50
- package/src/generators/application/lib/add-detox.d.ts +3 -0
- package/src/generators/application/lib/add-detox.js +23 -0
- package/src/generators/application/lib/add-project.js +18 -18
- package/src/generators/application/lib/normalize-options.d.ts +0 -7
- package/src/generators/application/lib/normalize-options.js +3 -35
- package/src/generators/application/lib/normalize-options.spec.ts +7 -70
- package/src/generators/application/schema.d.ts +3 -5
- package/src/generators/application/schema.json +6 -14
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +1 -1
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +4 -4
- package/src/generators/component-story/component-story.d.ts +8 -5
- package/src/generators/component-story/component-story.js +69 -8
- package/src/generators/component-story/component-story.spec.ts +428 -0
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +32 -0
- package/src/generators/component-story/schema.d.ts +0 -1
- package/src/generators/component-story/schema.json +3 -11
- package/src/generators/init/init.d.ts +1 -2
- package/src/generators/init/init.js +56 -55
- package/src/generators/init/init.spec.ts +6 -7
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +18 -13
- package/src/generators/library/files/lib/babel.config.json.template +17 -0
- package/src/generators/library/lib/normalize-options.js +0 -5
- package/src/generators/library/library.js +38 -48
- package/src/generators/library/library.spec.ts +60 -12
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +2 -2
- package/src/generators/stories/schema.d.ts +0 -2
- package/src/generators/stories/schema.json +2 -15
- package/src/generators/stories/stories-app.spec.ts +128 -0
- package/src/generators/stories/stories-lib.spec.ts +105 -0
- package/src/generators/stories/stories.d.ts +2 -5
- package/src/generators/stories/stories.js +50 -7
- package/src/generators/storybook-configuration/configuration.d.ts +2 -7
- package/src/generators/storybook-configuration/configuration.js +48 -18
- package/src/generators/storybook-configuration/configuration.spec.ts +135 -0
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +9 -0
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +74 -0
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +5 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +6 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +25 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +161 -0
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +6 -0
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +42 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +7 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +29 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +65 -0
- package/src/generators/storybook-configuration/schema.d.ts +2 -4
- package/src/generators/storybook-configuration/schema.json +12 -22
- 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 +3 -3
- package/src/generators/upgrade-native/upgrade-native.d.ts +0 -2
- package/src/generators/upgrade-native/upgrade-native.js +0 -3
- package/src/migrations/update-16-6-0/update-metro-config.js +5 -1
- package/src/migrations/update-16-9-0/remove-types-react-native.js +9 -2
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +1 -13
- package/src/utils/add-linting.d.ts +0 -1
- package/src/utils/add-linting.js +1 -1
- package/src/utils/add-linting.spec.ts +6 -4
- package/src/utils/chmod-android-gradle-files.js +2 -6
- package/src/utils/find-all-npm-dependencies.js +3 -5
- package/src/utils/find-all-npm-dependencies.spec.ts +9 -17
- package/src/utils/symlink-task.d.ts +2 -0
- package/src/utils/symlink-task.js +18 -0
- package/src/utils/testing-generators.js +0 -1
- package/src/utils/versions.d.ts +13 -10
- package/src/utils/versions.js +14 -11
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -6
- package/plugins/plugin.d.ts +0 -14
- package/plugins/plugin.js +0 -162
- package/src/executors/upgrade/schema.d.ts +0 -1
- package/src/executors/upgrade/schema.json +0 -11
- package/src/executors/upgrade/upgrade.impl.d.ts +0 -13
- package/src/executors/upgrade/upgrade.impl.js +0 -47
- package/src/executors/upgrade/upgrade.impl.ts +0 -64
- package/src/generators/application/files/app/.babelrc.js.template +0 -23
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +0 -22
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +0 -45
- package/src/generators/application/lib/add-e2e.d.ts +0 -3
- package/src/generators/application/lib/add-e2e.js +0 -46
- package/src/generators/library/files/lib/.babelrc.js.template +0 -21
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +0 -23
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +0 -15
- 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__ +0 -9
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +0 -82
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +0 -23
- 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__ +0 -14
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +0 -9
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +0 -77
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +0 -17
- package/src/generators/web-configuration/lib/normalize-schema.js +0 -16
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +0 -7
- package/src/generators/web-configuration/lib/webpack-targets.js +0 -75
- package/src/generators/web-configuration/schema.d.ts +0 -6
- package/src/generators/web-configuration/schema.json +0 -42
- package/src/generators/web-configuration/web-configuration.d.ts +0 -12
- package/src/generators/web-configuration/web-configuration.js +0 -87
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +0 -6
- package/src/migrations/update-18-0-0/add-upgrade-target.js +0 -33
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +0 -8
- package/src/migrations/update-18-0-0/add-web-configuration.js +0 -33
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +0 -5
- package/src/migrations/update-18-0-0/change-storybook-targets.js +0 -57
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-block-list.js +0 -28
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
- package/src/migrations/update-18-0-0/remove-metro.d.ts +0 -14
- package/src/migrations/update-18-0-0/remove-metro.js +0 -29
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-symlink-target.js +0 -30
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
- package/src/utils/ensure-dependencies.d.ts +0 -2
- package/src/utils/ensure-dependencies.js +0 -30
package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { addProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
+
|
|
4
|
+
import { formatFile } from '../../../utils/format-file';
|
|
5
|
+
|
|
6
|
+
import { replaceAppImportWithStorybookToggle } from './replace-app-import-with-storybook-toggle';
|
|
7
|
+
|
|
8
|
+
describe('replaceAppImportWithStorybookToggle', () => {
|
|
9
|
+
let tree: Tree;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
tree = createTreeWithEmptyWorkspace();
|
|
13
|
+
|
|
14
|
+
addProjectConfiguration(tree, 'products', {
|
|
15
|
+
root: 'products',
|
|
16
|
+
sourceRoot: 'products/src',
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should update the main file with import from storybook', async () => {
|
|
21
|
+
tree.write(
|
|
22
|
+
'products/src/main.tsx',
|
|
23
|
+
formatFile`import { AppRegistry } from 'react-native';
|
|
24
|
+
import App from './app/App';
|
|
25
|
+
|
|
26
|
+
AppRegistry.registerComponent('main', () => App);
|
|
27
|
+
`
|
|
28
|
+
);
|
|
29
|
+
replaceAppImportWithStorybookToggle(tree, {
|
|
30
|
+
name: 'products',
|
|
31
|
+
js: false,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const mainFile = tree.read('products/src/main.tsx', 'utf-8');
|
|
35
|
+
expect(formatFile`${mainFile}`).toEqual(
|
|
36
|
+
formatFile`import { AppRegistry } from 'react-native';
|
|
37
|
+
import App from './storybook/toggle-storybook';
|
|
38
|
+
|
|
39
|
+
AppRegistry.registerComponent('main', () => App);`
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should not update the main file if import is already updated', async () => {
|
|
44
|
+
tree.write(
|
|
45
|
+
'products/src/main.tsx',
|
|
46
|
+
formatFile`import { AppRegistry } from 'react-native';
|
|
47
|
+
import App from './app/App';
|
|
48
|
+
|
|
49
|
+
AppRegistry.registerComponent('main', () => App);
|
|
50
|
+
`
|
|
51
|
+
);
|
|
52
|
+
replaceAppImportWithStorybookToggle(tree, {
|
|
53
|
+
name: 'products',
|
|
54
|
+
js: false,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const mainFile = tree.read('products/src/main.tsx', 'utf-8');
|
|
58
|
+
expect(formatFile`${mainFile}`).toEqual(
|
|
59
|
+
formatFile`import { AppRegistry } from 'react-native';
|
|
60
|
+
import App from './storybook/toggle-storybook';
|
|
61
|
+
|
|
62
|
+
AppRegistry.registerComponent('main', () => App);`
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Linter } from '@nx/eslint';
|
|
2
2
|
|
|
3
3
|
export interface StorybookConfigureSchema {
|
|
4
|
-
|
|
5
|
-
interactionTests?: boolean;
|
|
4
|
+
name: string;
|
|
6
5
|
generateStories?: boolean;
|
|
7
6
|
js?: boolean;
|
|
8
7
|
tsConfiguration?: boolean;
|
|
9
8
|
linter?: Linter;
|
|
9
|
+
standaloneConfig?: boolean;
|
|
10
10
|
ignorePaths?: string[];
|
|
11
|
-
configureStaticServe?: boolean;
|
|
12
|
-
addPlugin?: boolean;
|
|
13
11
|
}
|
|
@@ -1,45 +1,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeStorybookConfigure",
|
|
5
5
|
"title": "React native Storybook configuration",
|
|
6
6
|
"description": "Set up Storybook for a React-Native app or library.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"name": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"aliases": ["
|
|
11
|
+
"aliases": ["project", "projectName"],
|
|
12
12
|
"description": "Project for which to generate Storybook configuration.",
|
|
13
13
|
"$default": {
|
|
14
14
|
"$source": "argv",
|
|
15
15
|
"index": 0
|
|
16
16
|
},
|
|
17
17
|
"x-prompt": "For which project do you want to generate Storybook configuration?",
|
|
18
|
-
"x-dropdown": "projects"
|
|
19
|
-
"x-priority": "important"
|
|
20
|
-
},
|
|
21
|
-
"interactionTests": {
|
|
22
|
-
"type": "boolean",
|
|
23
|
-
"description": "Set up Storybook interaction tests.",
|
|
24
|
-
"x-prompt": "Do you want to set up Storybook interaction tests?",
|
|
25
|
-
"x-priority": "important",
|
|
26
|
-
"alias": ["configureTestRunner"],
|
|
27
|
-
"default": true
|
|
18
|
+
"x-dropdown": "projects"
|
|
28
19
|
},
|
|
29
20
|
"generateStories": {
|
|
30
21
|
"type": "boolean",
|
|
31
|
-
"description": "Automatically generate
|
|
22
|
+
"description": "Automatically generate *.stories.ts files for components declared in this project?",
|
|
32
23
|
"x-prompt": "Automatically generate *.stories.ts files for components declared in this project?",
|
|
33
24
|
"default": true,
|
|
34
25
|
"x-priority": "important"
|
|
35
26
|
},
|
|
36
|
-
"configureStaticServe": {
|
|
37
|
-
"type": "boolean",
|
|
38
|
-
"description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
|
|
39
|
-
"x-prompt": "Configure a static file server for the storybook instance?",
|
|
40
|
-
"default": true,
|
|
41
|
-
"x-priority": "important"
|
|
42
|
-
},
|
|
43
27
|
"js": {
|
|
44
28
|
"type": "boolean",
|
|
45
29
|
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
@@ -56,6 +40,12 @@
|
|
|
56
40
|
"enum": ["eslint"],
|
|
57
41
|
"default": "eslint"
|
|
58
42
|
},
|
|
43
|
+
"standaloneConfig": {
|
|
44
|
+
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"default": true,
|
|
47
|
+
"x-deprecated": "Nx only supports standaloneConfig"
|
|
48
|
+
},
|
|
59
49
|
"ignorePaths": {
|
|
60
50
|
"type": "array",
|
|
61
51
|
"description": "Paths to ignore when looking for components.",
|
|
@@ -75,5 +65,5 @@
|
|
|
75
65
|
]
|
|
76
66
|
}
|
|
77
67
|
},
|
|
78
|
-
"required": ["
|
|
68
|
+
"required": ["name"]
|
|
79
69
|
}
|
|
@@ -6,7 +6,7 @@ export interface NormalizedSchema {
|
|
|
6
6
|
lowerCaseName: string;
|
|
7
7
|
entryFile: string;
|
|
8
8
|
entryFileIos: string;
|
|
9
|
-
e2eTestRunner: '
|
|
9
|
+
e2eTestRunner: 'detox' | 'none';
|
|
10
10
|
offsetFromRoot: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function normalizeOptions(options: UpgradeNativeConfigureSchema, appProjectRoot: string): NormalizedSchema;
|
|
@@ -4,6 +4,6 @@ export interface UpgradeNativeConfigureSchema {
|
|
|
4
4
|
name: string;
|
|
5
5
|
displayName?: string;
|
|
6
6
|
js: boolean; // default is false
|
|
7
|
-
e2eTestRunner: '
|
|
7
|
+
e2eTestRunner: 'detox' | 'none'; // default is detox
|
|
8
8
|
install: boolean; // default is true
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeUpgradeNativeConfigure",
|
|
5
5
|
"title": "React native upgrade native configuration",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"e2eTestRunner": {
|
|
28
28
|
"description": "Adds the specified e2e test runner.",
|
|
29
29
|
"type": "string",
|
|
30
|
-
"enum": ["
|
|
31
|
-
"default": "
|
|
30
|
+
"enum": ["detox", "none"],
|
|
31
|
+
"default": "detox"
|
|
32
32
|
},
|
|
33
33
|
"install": {
|
|
34
34
|
"type": "boolean",
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @deprecated use `nx run @nx/react-native:upgrade` instead.
|
|
3
|
-
* TODO (@xiongemi): remove this generator for nx v19
|
|
4
2
|
* This function is a destructive command that replace React Native iOS and Android code with latest.
|
|
5
3
|
* It would replace the Android and iOS folder entirely.
|
|
6
4
|
*/
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* @deprecated use `nx run @nx/react-native:upgrade` instead.
|
|
4
|
-
* TODO (@xiongemi): remove this generator for nx v19
|
|
5
3
|
* This function is a destructive command that replace React Native iOS and Android code with latest.
|
|
6
4
|
* It would replace the Android and iOS folder entirely.
|
|
7
5
|
*/
|
|
@@ -13,7 +11,6 @@ const pod_install_task_1 = require("../../utils/pod-install-task");
|
|
|
13
11
|
const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
|
|
14
12
|
const create_native_files_1 = require("./lib/create-native-files");
|
|
15
13
|
async function reactNativeUpgradeNativeGenerator(host, schema) {
|
|
16
|
-
devkit_1.logger.warn(`Please run 'nx run @nx/react-native:upgrade ${schema.name}' instead.`);
|
|
17
14
|
const { projectType, root: appProjectRoot } = (0, devkit_1.readProjectConfiguration)(host, schema.name);
|
|
18
15
|
const iosProjectRoot = (0, devkit_1.joinPathFragments)(host.root, appProjectRoot, 'ios');
|
|
19
16
|
const androidProjectRoot = (0, devkit_1.joinPathFragments)(host.root, appProjectRoot, 'android');
|
|
@@ -31,6 +31,7 @@ const oldConfigComment = `/**
|
|
|
31
31
|
const content = `
|
|
32
32
|
const { withNxMetro } = require('@nx/react-native');
|
|
33
33
|
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
|
34
|
+
const exclusionList = require('metro-config/src/defaults/exclusionList');
|
|
34
35
|
|
|
35
36
|
const defaultConfig = getDefaultConfig(__dirname);
|
|
36
37
|
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
@@ -47,7 +48,10 @@ const customConfig = {
|
|
|
47
48
|
},
|
|
48
49
|
resolver: {
|
|
49
50
|
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
50
|
-
sourceExts: [...sourceExts, '
|
|
51
|
+
sourceExts: [...sourceExts, 'svg'],
|
|
52
|
+
blockList: exclusionList([/^(?!.*node_modules).*\\/dist\\/.*/]),
|
|
53
|
+
unstable_enableSymlinks: true,
|
|
54
|
+
unstable_enablePackageExports: true,
|
|
51
55
|
},
|
|
52
56
|
};
|
|
53
57
|
|
|
@@ -7,7 +7,14 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
async function update(tree) {
|
|
10
|
-
(0, devkit_1.
|
|
11
|
-
|
|
10
|
+
const packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
11
|
+
if (!packageJson.devDependencies['@types/react-native'] ||
|
|
12
|
+
!packageJson.dependencies['react-native']) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
16
|
+
delete packageJson.devDependencies['@types/react-native'];
|
|
17
|
+
return packageJson;
|
|
18
|
+
});
|
|
12
19
|
}
|
|
13
20
|
exports.default = update;
|
package/src/utils/add-jest.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean
|
|
2
|
+
export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
|
package/src/utils/add-jest.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.addJest = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const jest_1 = require("@nx/jest");
|
|
6
|
-
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson
|
|
6
|
+
async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
|
|
7
7
|
if (unitTestRunner !== 'jest') {
|
|
8
8
|
return () => { };
|
|
9
9
|
}
|
|
@@ -16,7 +16,6 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
|
|
|
16
16
|
compiler: 'babel',
|
|
17
17
|
skipPackageJson,
|
|
18
18
|
skipFormat: true,
|
|
19
|
-
addPlugin,
|
|
20
19
|
});
|
|
21
20
|
// overwrite the jest.config.ts file because react native needs to have special transform property
|
|
22
21
|
const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
|
|
@@ -29,17 +28,6 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
|
|
|
29
28
|
moduleNameMapper: {
|
|
30
29
|
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock'
|
|
31
30
|
},
|
|
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
31
|
coverageDirectory: '${(0, devkit_1.offsetFromRoot)(appProjectRoot)}coverage/${appProjectRoot}'
|
|
44
32
|
};`;
|
|
45
33
|
host.write(configPath, content);
|
|
@@ -7,7 +7,6 @@ interface NormalizedSchema {
|
|
|
7
7
|
setParserOptionsProject?: boolean;
|
|
8
8
|
tsConfigPaths: string[];
|
|
9
9
|
skipPackageJson?: boolean;
|
|
10
|
-
addPlugin?: boolean;
|
|
11
10
|
}
|
|
12
11
|
export declare function addLinting(host: Tree, options: NormalizedSchema): Promise<GeneratorCallback>;
|
|
13
12
|
export {};
|
package/src/utils/add-linting.js
CHANGED
|
@@ -14,9 +14,9 @@ async function addLinting(host, options) {
|
|
|
14
14
|
linter: options.linter,
|
|
15
15
|
project: options.projectName,
|
|
16
16
|
tsConfigPaths: options.tsConfigPaths,
|
|
17
|
+
eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
|
|
17
18
|
skipFormat: true,
|
|
18
19
|
skipPackageJson: options.skipPackageJson,
|
|
19
|
-
addPlugin: options.addPlugin,
|
|
20
20
|
});
|
|
21
21
|
tasks.push(lintTask);
|
|
22
22
|
if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
|
|
@@ -15,19 +15,21 @@ describe('Add Linting', () => {
|
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
it('should add
|
|
19
|
-
|
|
18
|
+
it('should add update configuration when eslint is passed', () => {
|
|
19
|
+
addLinting(tree, {
|
|
20
20
|
projectName: 'my-lib',
|
|
21
21
|
linter: Linter.EsLint,
|
|
22
22
|
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
|
|
23
23
|
projectRoot: 'libs/my-lib',
|
|
24
24
|
});
|
|
25
|
+
const project = readProjectConfiguration(tree, 'my-lib');
|
|
25
26
|
|
|
26
|
-
expect(
|
|
27
|
+
expect(project.targets.lint).toBeDefined();
|
|
28
|
+
expect(project.targets.lint.executor).toEqual('@nx/eslint:lint');
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
it('should not add lint target when "none" is passed', async () => {
|
|
30
|
-
|
|
32
|
+
addLinting(tree, {
|
|
31
33
|
projectName: 'my-lib',
|
|
32
34
|
linter: Linter.None,
|
|
33
35
|
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
|
|
@@ -5,12 +5,8 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
function chmodAndroidGradlewFiles(androidFolder) {
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
}
|
|
8
|
+
(0, fs_1.chmodSync)((0, path_1.join)(androidFolder, 'gradlew'), 0o775);
|
|
9
|
+
(0, fs_1.chmodSync)((0, path_1.join)(androidFolder, 'gradlew.bat'), 0o775);
|
|
14
10
|
}
|
|
15
11
|
exports.chmodAndroidGradlewFiles = chmodAndroidGradlewFiles;
|
|
16
12
|
function chmodAndroidGradlewFilesTask(androidFolder) {
|
|
@@ -8,13 +8,11 @@ function findAllNpmDependencies(graph, projectName, list = [], seen = new Set())
|
|
|
8
8
|
}
|
|
9
9
|
seen.add(projectName);
|
|
10
10
|
const node = graph.externalNodes[projectName];
|
|
11
|
-
// Don't want to include '@nx/react-native'
|
|
11
|
+
// Don't want to include '@nx/react-native' because React Native
|
|
12
12
|
// autolink will warn that the package has no podspec file for iOS.
|
|
13
13
|
if (node) {
|
|
14
|
-
if (node.name !==
|
|
15
|
-
node.name !==
|
|
16
|
-
node.name !== `npm:@nx/expo` &&
|
|
17
|
-
node.name !== `npm:@nrwl/expo`) {
|
|
14
|
+
if (node.name !== 'npm:@nx/react-native' &&
|
|
15
|
+
node.name !== 'npm:@nrwl/react-native') {
|
|
18
16
|
list.push(node.data.packageName);
|
|
19
17
|
}
|
|
20
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findAllNpmDependencies } from './find-all-npm-dependencies';
|
|
2
|
-
import {
|
|
2
|
+
import { ProjectGraph } from '@nx/devkit';
|
|
3
3
|
|
|
4
4
|
test('findAllNpmDependencies', () => {
|
|
5
5
|
const graph: ProjectGraph = {
|
|
@@ -61,34 +61,26 @@ test('findAllNpmDependencies', () => {
|
|
|
61
61
|
},
|
|
62
62
|
dependencies: {
|
|
63
63
|
myapp: [
|
|
64
|
-
{ type:
|
|
65
|
-
{ type:
|
|
64
|
+
{ type: 'static', source: 'myapp', target: 'lib1' },
|
|
65
|
+
{ type: 'static', source: 'myapp', target: 'lib2' },
|
|
66
66
|
{
|
|
67
|
-
type:
|
|
67
|
+
type: 'static',
|
|
68
68
|
source: 'myapp',
|
|
69
69
|
target: 'npm:react-native-image-picker',
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
type:
|
|
72
|
+
type: 'static',
|
|
73
73
|
source: 'myapp',
|
|
74
74
|
target: 'npm:@nx/react-native',
|
|
75
75
|
},
|
|
76
76
|
],
|
|
77
77
|
lib1: [
|
|
78
|
-
{ type:
|
|
79
|
-
{
|
|
80
|
-
type: DependencyType.static,
|
|
81
|
-
source: 'lib3',
|
|
82
|
-
target: 'npm:react-native-snackbar',
|
|
83
|
-
},
|
|
78
|
+
{ type: 'static', source: 'lib1', target: 'lib2' },
|
|
79
|
+
{ type: 'static', source: 'lib3', target: 'npm:react-native-snackbar' },
|
|
84
80
|
],
|
|
85
|
-
lib2: [{ type:
|
|
81
|
+
lib2: [{ type: 'static', source: 'lib2', target: 'lib3' }],
|
|
86
82
|
lib3: [
|
|
87
|
-
{
|
|
88
|
-
type: DependencyType.static,
|
|
89
|
-
source: 'lib3',
|
|
90
|
-
target: 'npm:react-native-dialog',
|
|
91
|
-
},
|
|
83
|
+
{ type: 'static', source: 'lib3', target: 'npm:react-native-dialog' },
|
|
92
84
|
],
|
|
93
85
|
},
|
|
94
86
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runSymlink = void 0;
|
|
4
|
+
const ensure_node_modules_symlink_1 = require("./ensure-node-modules-symlink");
|
|
5
|
+
const chalk = require("chalk");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
function runSymlink(workspaceRoot, projectRoot) {
|
|
8
|
+
return () => {
|
|
9
|
+
devkit_1.logger.info(`creating symlinks for ${chalk.bold(projectRoot)}`);
|
|
10
|
+
try {
|
|
11
|
+
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(workspaceRoot, projectRoot);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
throw new Error(`Failed to create symlinks for ${chalk.bold(projectRoot)}`);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.runSymlink = runSymlink;
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
|
-
export declare const reactNativeVersion = "0.
|
|
3
|
-
export declare const typesNodeVersion = "18.
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
2
|
+
export declare const reactNativeVersion = "0.72.4";
|
|
3
|
+
export declare const typesNodeVersion = "18.14.4";
|
|
4
|
+
export declare const metroVersion = "0.76.7";
|
|
5
|
+
export declare const reactNativeMetroConfigVersion = "^0.72.11";
|
|
6
|
+
export declare const reactNativeCommunityCli = "11.3.6";
|
|
7
|
+
export declare const reactNativeCommunityCliIos = "11.3.6";
|
|
8
|
+
export declare const reactNativeCommunityCliAndroid = "11.3.6";
|
|
8
9
|
export declare const reactVersion = "18.2.0";
|
|
9
10
|
export declare const reactDomVersion = "18.2.0";
|
|
10
11
|
export declare const reactTestRendererVersion = "18.2.0";
|
|
11
|
-
export declare const typesReactVersion = "
|
|
12
|
-
export declare const testingLibraryReactNativeVersion = "~12.
|
|
12
|
+
export declare const typesReactVersion = "18.0.28";
|
|
13
|
+
export declare const testingLibraryReactNativeVersion = "~12.3.0";
|
|
13
14
|
export declare const testingLibraryJestNativeVersion = "~5.4.3";
|
|
14
15
|
export declare const jestReactNativeVersion = "18.0.0";
|
|
15
|
-
export declare const reactNativeSvgTransformerVersion = "1.
|
|
16
|
-
export declare const reactNativeSvgVersion = "
|
|
16
|
+
export declare const reactNativeSvgTransformerVersion = "1.0.0";
|
|
17
|
+
export declare const reactNativeSvgVersion = "13.9.0";
|
|
17
18
|
export declare const babelRuntimeVersion = "7.22.6";
|
|
19
|
+
export declare const reactNativeAsyncStorageVersion = "~1.19.3";
|
|
20
|
+
export declare const reactNativeSafeAreaContextVersion = "~4.7.2";
|
package/src/utils/versions.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.babelRuntimeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.jestReactNativeVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.
|
|
3
|
+
exports.reactNativeSafeAreaContextVersion = exports.reactNativeAsyncStorageVersion = exports.babelRuntimeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.jestReactNativeVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.reactNativeCommunityCliAndroid = exports.reactNativeCommunityCliIos = exports.reactNativeCommunityCli = exports.reactNativeMetroConfigVersion = exports.metroVersion = exports.typesNodeVersion = exports.reactNativeVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
|
-
exports.reactNativeVersion = '0.
|
|
6
|
-
exports.typesNodeVersion = '18.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
5
|
+
exports.reactNativeVersion = '0.72.4';
|
|
6
|
+
exports.typesNodeVersion = '18.14.4';
|
|
7
|
+
exports.metroVersion = '0.76.7';
|
|
8
|
+
exports.reactNativeMetroConfigVersion = '^0.72.11';
|
|
9
|
+
exports.reactNativeCommunityCli = '11.3.6';
|
|
10
|
+
exports.reactNativeCommunityCliIos = '11.3.6';
|
|
11
|
+
exports.reactNativeCommunityCliAndroid = '11.3.6';
|
|
11
12
|
exports.reactVersion = '18.2.0';
|
|
12
13
|
exports.reactDomVersion = '18.2.0';
|
|
13
14
|
exports.reactTestRendererVersion = '18.2.0';
|
|
14
|
-
exports.typesReactVersion = '
|
|
15
|
-
exports.testingLibraryReactNativeVersion = '~12.
|
|
15
|
+
exports.typesReactVersion = '18.0.28';
|
|
16
|
+
exports.testingLibraryReactNativeVersion = '~12.3.0';
|
|
16
17
|
exports.testingLibraryJestNativeVersion = '~5.4.3';
|
|
17
18
|
exports.jestReactNativeVersion = '18.0.0';
|
|
18
|
-
exports.reactNativeSvgTransformerVersion = '1.
|
|
19
|
-
exports.reactNativeSvgVersion = '
|
|
19
|
+
exports.reactNativeSvgTransformerVersion = '1.0.0';
|
|
20
|
+
exports.reactNativeSvgVersion = '13.9.0';
|
|
20
21
|
exports.babelRuntimeVersion = '7.22.6';
|
|
22
|
+
exports.reactNativeAsyncStorageVersion = '~1.19.3';
|
|
23
|
+
exports.reactNativeSafeAreaContextVersion = '~4.7.2';
|
package/plugin.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createNodes, createDependencies, ReactNativePluginOptions, } from './plugins/plugin';
|
package/plugin.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDependencies = exports.createNodes = void 0;
|
|
4
|
-
var plugin_1 = require("./plugins/plugin");
|
|
5
|
-
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
6
|
-
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
|
package/plugins/plugin.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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>;
|