@nx/react-native 18.0.0-beta.1 → 18.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +6 -1
- package/executors.json +5 -0
- package/generators.json +12 -11
- package/migrations.json +73 -1
- package/package.json +10 -15
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.d.ts +2 -0
- package/plugins/plugin.js +12 -1
- package/plugins/with-nx-metro.js +6 -2
- package/src/executors/build-android/build-android.impl.js +1 -5
- package/src/executors/build-android/build-android.impl.ts +1 -5
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +4 -0
- package/src/executors/run-android/run-android.impl.js +4 -16
- package/src/executors/run-android/run-android.impl.ts +8 -17
- package/src/executors/run-ios/run-ios.impl.js +4 -16
- package/src/executors/run-ios/run-ios.impl.ts +9 -18
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/start.impl.js +11 -26
- package/src/executors/start/start.impl.ts +14 -28
- package/src/executors/storybook/storybook.impl.d.ts +4 -0
- package/src/executors/storybook/storybook.impl.js +8 -1
- package/src/executors/storybook/storybook.impl.ts +16 -5
- package/src/executors/sync-deps/sync-deps.impl.d.ts +3 -2
- package/src/executors/sync-deps/sync-deps.impl.js +28 -11
- package/src/executors/sync-deps/sync-deps.impl.ts +45 -19
- package/src/executors/upgrade/schema.d.ts +1 -0
- package/src/executors/upgrade/schema.json +11 -0
- package/src/executors/upgrade/upgrade.impl.d.ts +13 -0
- package/src/executors/upgrade/upgrade.impl.js +47 -0
- package/src/executors/upgrade/upgrade.impl.ts +64 -0
- package/src/generators/application/application.js +27 -8
- package/src/generators/application/application.spec.ts +29 -2
- package/src/generators/application/files/app/.babelrc.js.template +23 -0
- package/src/generators/application/files/app/android/app/build.gradle.template +12 -28
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +2 -6
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +22 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +45 -0
- package/src/generators/application/files/app/android/build.gradle.template +7 -20
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/src/generators/application/files/app/android/gradle.properties +0 -3
- package/src/generators/application/files/app/android/gradlew.template +12 -7
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/ios/Podfile.template +0 -7
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +5 -0
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +5 -8
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +11 -33
- package/src/generators/application/files/app/metro.config.js.template +0 -4
- package/src/generators/application/files/app/src/app/App.tsx.template +29 -2
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +47 -0
- package/src/generators/application/lib/add-project.js +13 -17
- package/src/generators/application/lib/normalize-options.d.ts +4 -0
- package/src/generators/application/lib/normalize-options.js +9 -3
- package/src/generators/application/lib/normalize-options.spec.ts +53 -5
- package/src/generators/application/schema.d.ts +5 -3
- package/src/generators/application/schema.json +13 -5
- package/src/generators/component-story/component-story.d.ts +5 -8
- package/src/generators/component-story/component-story.js +8 -69
- package/src/generators/component-story/schema.d.ts +1 -0
- package/src/generators/component-story/schema.json +10 -2
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +14 -7
- package/src/generators/init/init.spec.ts +6 -2
- package/src/generators/init/schema.d.ts +1 -0
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +1 -0
- package/src/generators/library/library.js +2 -1
- package/src/generators/library/library.spec.ts +12 -41
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +1 -1
- package/src/generators/stories/schema.d.ts +2 -0
- package/src/generators/stories/schema.json +14 -1
- package/src/generators/stories/stories.d.ts +5 -2
- package/src/generators/stories/stories.js +7 -50
- package/src/generators/storybook-configuration/configuration.d.ts +7 -2
- package/src/generators/storybook-configuration/configuration.js +15 -48
- package/src/generators/storybook-configuration/schema.d.ts +4 -2
- package/src/generators/storybook-configuration/schema.json +21 -11
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
- package/src/generators/upgrade-native/schema.d.ts +1 -1
- package/src/generators/upgrade-native/schema.json +2 -2
- package/src/generators/upgrade-native/upgrade-native.d.ts +2 -0
- package/src/generators/upgrade-native/upgrade-native.js +3 -0
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +15 -0
- package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +82 -0
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +14 -0
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +77 -0
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +17 -0
- package/src/generators/web-configuration/lib/normalize-schema.js +16 -0
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +7 -0
- package/src/generators/web-configuration/lib/webpack-targets.js +75 -0
- package/src/generators/web-configuration/schema.d.ts +6 -0
- package/src/generators/web-configuration/schema.json +42 -0
- package/src/generators/web-configuration/web-configuration.d.ts +12 -0
- package/src/generators/web-configuration/web-configuration.js +85 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +0 -4
- package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/add-upgrade-target.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +8 -0
- package/src/migrations/update-18-0-0/add-web-configuration.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +39 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +5 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.js +57 -0
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-block-list.js +26 -0
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +68 -0
- package/src/migrations/update-18-0-0/remove-metro.d.ts +14 -0
- package/src/migrations/update-18-0-0/remove-metro.js +29 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.js +30 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +40 -0
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +13 -1
- package/src/utils/add-linting.d.ts +1 -0
- package/src/utils/add-linting.js +1 -0
- package/src/utils/add-linting.spec.ts +2 -4
- package/src/utils/ensure-dependencies.js +2 -6
- package/src/utils/testing-generators.js +1 -0
- package/src/utils/versions.d.ts +9 -12
- package/src/utils/versions.js +10 -13
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -75
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +0 -32
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +0 -62
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -20
- package/src/generators/application/files/app/babel.config.json.template +0 -10
- package/src/generators/application/lib/add-detox.d.ts +0 -3
- package/src/generators/application/lib/add-detox.js +0 -23
- package/src/generators/component-story/component-story.spec.ts +0 -427
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +0 -32
- package/src/generators/library/files/lib/babel.config.json.template +0 -19
- package/src/generators/stories/stories-app.spec.ts +0 -128
- package/src/generators/stories/stories-lib.spec.ts +0 -105
- package/src/generators/storybook-configuration/configuration.spec.ts +0 -135
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +0 -9
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +0 -74
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +0 -5
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +0 -25
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +0 -161
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +0 -42
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +0 -7
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +0 -29
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +0 -65
- package/src/utils/find-all-npm-dependencies.d.ts +0 -2
- package/src/utils/find-all-npm-dependencies.js +0 -25
- package/src/utils/find-all-npm-dependencies.spec.ts +0 -95
- package/src/utils/symlink-task.d.ts +0 -2
- package/src/utils/symlink-task.js +0 -18
|
@@ -23,25 +23,19 @@ function getTargets(options) {
|
|
|
23
23
|
const architect = {};
|
|
24
24
|
architect.start = {
|
|
25
25
|
executor: '@nx/react-native:start',
|
|
26
|
-
dependsOn: [
|
|
26
|
+
dependsOn: [],
|
|
27
27
|
options: {
|
|
28
28
|
port: 8081,
|
|
29
29
|
},
|
|
30
30
|
};
|
|
31
|
-
architect.serve = {
|
|
32
|
-
executor: 'nx:run-commands',
|
|
33
|
-
options: {
|
|
34
|
-
command: `nx start ${options.projectName}`,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
31
|
architect['run-ios'] = {
|
|
38
32
|
executor: '@nx/react-native:run-ios',
|
|
39
|
-
dependsOn: [
|
|
33
|
+
dependsOn: [],
|
|
40
34
|
options: {},
|
|
41
35
|
};
|
|
42
36
|
architect['bundle-ios'] = {
|
|
43
37
|
executor: '@nx/react-native:bundle',
|
|
44
|
-
dependsOn: [
|
|
38
|
+
dependsOn: [],
|
|
45
39
|
outputs: ['{options.bundleOutput}'],
|
|
46
40
|
options: {
|
|
47
41
|
entryFile: options.entryFile,
|
|
@@ -51,7 +45,7 @@ function getTargets(options) {
|
|
|
51
45
|
};
|
|
52
46
|
architect['run-android'] = {
|
|
53
47
|
executor: '@nx/react-native:run-android',
|
|
54
|
-
dependsOn: [
|
|
48
|
+
dependsOn: [],
|
|
55
49
|
options: {},
|
|
56
50
|
};
|
|
57
51
|
architect['build-android'] = {
|
|
@@ -60,22 +54,28 @@ function getTargets(options) {
|
|
|
60
54
|
`{projectRoot}/android/app/build/outputs/bundle`,
|
|
61
55
|
`{projectRoot}/android/app/build/outputs/apk`,
|
|
62
56
|
],
|
|
63
|
-
dependsOn: [
|
|
57
|
+
dependsOn: [],
|
|
64
58
|
options: {},
|
|
65
59
|
};
|
|
66
60
|
architect['build-ios'] = {
|
|
67
61
|
executor: '@nx/react-native:build-ios',
|
|
68
62
|
outputs: ['{projectRoot}/ios/build/Build'],
|
|
69
|
-
dependsOn: [
|
|
63
|
+
dependsOn: [],
|
|
70
64
|
options: {},
|
|
71
65
|
};
|
|
72
66
|
architect['pod-install'] = {
|
|
73
67
|
executor: '@nx/react-native:pod-install',
|
|
68
|
+
dependsOn: ['sync-deps'],
|
|
69
|
+
outputs: ['{projectRoot}/ios/Pods', '{projectRoot}/ios/Podfile.lock'],
|
|
70
|
+
options: {},
|
|
71
|
+
};
|
|
72
|
+
architect.upgrade = {
|
|
73
|
+
executor: '@nx/react-native:upgrade',
|
|
74
74
|
options: {},
|
|
75
75
|
};
|
|
76
76
|
architect['bundle-android'] = {
|
|
77
77
|
executor: '@nx/react-native:bundle',
|
|
78
|
-
dependsOn: [
|
|
78
|
+
dependsOn: [],
|
|
79
79
|
outputs: ['{options.bundleOutput}'],
|
|
80
80
|
options: {
|
|
81
81
|
entryFile: options.entryFile,
|
|
@@ -87,9 +87,5 @@ function getTargets(options) {
|
|
|
87
87
|
executor: '@nx/react-native:sync-deps',
|
|
88
88
|
options: {},
|
|
89
89
|
};
|
|
90
|
-
architect['ensure-symlink'] = {
|
|
91
|
-
executor: '@nx/react-native:ensure-symlink',
|
|
92
|
-
options: {},
|
|
93
|
-
};
|
|
94
90
|
return architect;
|
|
95
91
|
}
|
|
@@ -2,6 +2,7 @@ import { Tree } from '@nx/devkit';
|
|
|
2
2
|
import { Schema } from '../schema';
|
|
3
3
|
export interface NormalizedSchema extends Schema {
|
|
4
4
|
className: string;
|
|
5
|
+
fileName: string;
|
|
5
6
|
projectName: string;
|
|
6
7
|
appProjectRoot: string;
|
|
7
8
|
lowerCaseName: string;
|
|
@@ -9,5 +10,8 @@ export interface NormalizedSchema extends Schema {
|
|
|
9
10
|
androidProjectRoot: string;
|
|
10
11
|
parsedTags: string[];
|
|
11
12
|
entryFile: string;
|
|
13
|
+
rootProject: boolean;
|
|
14
|
+
e2eProjectName: string;
|
|
15
|
+
e2eProjectRoot: string;
|
|
12
16
|
}
|
|
13
17
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -12,19 +12,22 @@ async function normalizeOptions(host, options) {
|
|
|
12
12
|
callingGenerator: '@nx/react-native:application',
|
|
13
13
|
});
|
|
14
14
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
|
-
|
|
15
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
16
|
+
const { className, fileName } = (0, devkit_1.names)(options.name);
|
|
16
17
|
const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
|
|
17
18
|
const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
|
|
19
|
+
const rootProject = appProjectRoot === '.';
|
|
20
|
+
const e2eProjectName = rootProject ? 'e2e' : `${fileName}-e2e`;
|
|
21
|
+
const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
18
22
|
const parsedTags = options.tags
|
|
19
23
|
? options.tags.split(',').map((s) => s.trim())
|
|
20
24
|
: [];
|
|
21
25
|
const entryFile = options.js ? 'src/main.js' : 'src/main.tsx';
|
|
22
26
|
return {
|
|
23
27
|
...options,
|
|
24
|
-
unitTestRunner: options.unitTestRunner || 'jest',
|
|
25
|
-
e2eTestRunner: options.e2eTestRunner || 'detox',
|
|
26
28
|
name: projectNames.projectSimpleName,
|
|
27
29
|
className,
|
|
30
|
+
fileName,
|
|
28
31
|
lowerCaseName: className.toLowerCase(),
|
|
29
32
|
displayName: options.displayName || className,
|
|
30
33
|
projectName: appProjectName,
|
|
@@ -33,6 +36,9 @@ async function normalizeOptions(host, options) {
|
|
|
33
36
|
androidProjectRoot,
|
|
34
37
|
parsedTags,
|
|
35
38
|
entryFile,
|
|
39
|
+
rootProject,
|
|
40
|
+
e2eProjectName,
|
|
41
|
+
e2eProjectRoot,
|
|
36
42
|
};
|
|
37
43
|
}
|
|
38
44
|
exports.normalizeOptions = normalizeOptions;
|
|
@@ -18,11 +18,15 @@ describe('Normalize Options', () => {
|
|
|
18
18
|
e2eTestRunner: 'none',
|
|
19
19
|
install: false,
|
|
20
20
|
projectNameAndRootFormat: 'as-provided',
|
|
21
|
+
unitTestRunner: 'none',
|
|
22
|
+
bundler: 'vite',
|
|
21
23
|
};
|
|
22
24
|
const options = await normalizeOptions(appTree, schema);
|
|
23
25
|
expect(options).toEqual({
|
|
26
|
+
addPlugin: true,
|
|
24
27
|
androidProjectRoot: 'my-app/android',
|
|
25
28
|
appProjectRoot: 'my-app',
|
|
29
|
+
fileName: 'my-app',
|
|
26
30
|
className: 'MyApp',
|
|
27
31
|
displayName: 'MyApp',
|
|
28
32
|
iosProjectRoot: 'my-app/ios',
|
|
@@ -34,8 +38,12 @@ describe('Normalize Options', () => {
|
|
|
34
38
|
linter: Linter.EsLint,
|
|
35
39
|
entryFile: 'src/main.tsx',
|
|
36
40
|
e2eTestRunner: 'none',
|
|
37
|
-
unitTestRunner: '
|
|
41
|
+
unitTestRunner: 'none',
|
|
38
42
|
install: false,
|
|
43
|
+
bundler: 'vite',
|
|
44
|
+
rootProject: false,
|
|
45
|
+
e2eProjectName: 'my-app-e2e',
|
|
46
|
+
e2eProjectRoot: 'my-app-e2e',
|
|
39
47
|
});
|
|
40
48
|
});
|
|
41
49
|
|
|
@@ -45,12 +53,17 @@ describe('Normalize Options', () => {
|
|
|
45
53
|
e2eTestRunner: 'none',
|
|
46
54
|
install: false,
|
|
47
55
|
projectNameAndRootFormat: 'as-provided',
|
|
56
|
+
linter: Linter.None,
|
|
57
|
+
unitTestRunner: 'none',
|
|
58
|
+
bundler: 'vite',
|
|
48
59
|
};
|
|
49
60
|
const options = await normalizeOptions(appTree, schema);
|
|
50
61
|
expect(options).toEqual({
|
|
62
|
+
addPlugin: true,
|
|
51
63
|
androidProjectRoot: 'myApp/android',
|
|
52
64
|
appProjectRoot: 'myApp',
|
|
53
65
|
className: 'MyApp',
|
|
66
|
+
fileName: 'my-app',
|
|
54
67
|
displayName: 'MyApp',
|
|
55
68
|
iosProjectRoot: 'myApp/ios',
|
|
56
69
|
lowerCaseName: 'myapp',
|
|
@@ -60,8 +73,13 @@ describe('Normalize Options', () => {
|
|
|
60
73
|
projectNameAndRootFormat: 'as-provided',
|
|
61
74
|
entryFile: 'src/main.tsx',
|
|
62
75
|
e2eTestRunner: 'none',
|
|
63
|
-
unitTestRunner: '
|
|
76
|
+
unitTestRunner: 'none',
|
|
64
77
|
install: false,
|
|
78
|
+
bundler: 'vite',
|
|
79
|
+
linter: Linter.None,
|
|
80
|
+
rootProject: false,
|
|
81
|
+
e2eProjectName: 'my-app-e2e',
|
|
82
|
+
e2eProjectRoot: 'myApp-e2e',
|
|
65
83
|
});
|
|
66
84
|
});
|
|
67
85
|
|
|
@@ -72,12 +90,17 @@ describe('Normalize Options', () => {
|
|
|
72
90
|
e2eTestRunner: 'none',
|
|
73
91
|
install: false,
|
|
74
92
|
projectNameAndRootFormat: 'as-provided',
|
|
93
|
+
linter: Linter.None,
|
|
94
|
+
unitTestRunner: 'none',
|
|
95
|
+
bundler: 'vite',
|
|
75
96
|
};
|
|
76
97
|
const options = await normalizeOptions(appTree, schema);
|
|
77
98
|
expect(options).toEqual({
|
|
99
|
+
addPlugin: true,
|
|
78
100
|
androidProjectRoot: 'directory/my-app/android',
|
|
79
101
|
appProjectRoot: 'directory/my-app',
|
|
80
102
|
className: 'MyApp',
|
|
103
|
+
fileName: 'my-app',
|
|
81
104
|
displayName: 'MyApp',
|
|
82
105
|
iosProjectRoot: 'directory/my-app/ios',
|
|
83
106
|
lowerCaseName: 'myapp',
|
|
@@ -88,8 +111,13 @@ describe('Normalize Options', () => {
|
|
|
88
111
|
projectNameAndRootFormat: 'as-provided',
|
|
89
112
|
entryFile: 'src/main.tsx',
|
|
90
113
|
e2eTestRunner: 'none',
|
|
91
|
-
unitTestRunner: '
|
|
114
|
+
unitTestRunner: 'none',
|
|
92
115
|
install: false,
|
|
116
|
+
bundler: 'vite',
|
|
117
|
+
linter: Linter.None,
|
|
118
|
+
rootProject: false,
|
|
119
|
+
e2eProjectName: 'my-app-e2e',
|
|
120
|
+
e2eProjectRoot: 'directory/my-app-e2e',
|
|
93
121
|
});
|
|
94
122
|
});
|
|
95
123
|
|
|
@@ -99,12 +127,17 @@ describe('Normalize Options', () => {
|
|
|
99
127
|
e2eTestRunner: 'none',
|
|
100
128
|
install: false,
|
|
101
129
|
projectNameAndRootFormat: 'as-provided',
|
|
130
|
+
linter: Linter.None,
|
|
131
|
+
unitTestRunner: 'none',
|
|
132
|
+
bundler: 'vite',
|
|
102
133
|
};
|
|
103
134
|
const options = await normalizeOptions(appTree, schema);
|
|
104
135
|
expect(options).toEqual({
|
|
136
|
+
addPlugin: true,
|
|
105
137
|
androidProjectRoot: 'directory/my-app/android',
|
|
106
138
|
appProjectRoot: 'directory/my-app',
|
|
107
139
|
className: 'DirectoryMyApp',
|
|
140
|
+
fileName: 'directory/my-app',
|
|
108
141
|
displayName: 'DirectoryMyApp',
|
|
109
142
|
iosProjectRoot: 'directory/my-app/ios',
|
|
110
143
|
lowerCaseName: 'directorymyapp',
|
|
@@ -114,8 +147,13 @@ describe('Normalize Options', () => {
|
|
|
114
147
|
projectNameAndRootFormat: 'as-provided',
|
|
115
148
|
entryFile: 'src/main.tsx',
|
|
116
149
|
e2eTestRunner: 'none',
|
|
117
|
-
unitTestRunner: '
|
|
150
|
+
unitTestRunner: 'none',
|
|
118
151
|
install: false,
|
|
152
|
+
bundler: 'vite',
|
|
153
|
+
linter: Linter.None,
|
|
154
|
+
rootProject: false,
|
|
155
|
+
e2eProjectName: 'directory/my-app-e2e',
|
|
156
|
+
e2eProjectRoot: 'directory/my-app-e2e',
|
|
119
157
|
});
|
|
120
158
|
});
|
|
121
159
|
|
|
@@ -126,12 +164,17 @@ describe('Normalize Options', () => {
|
|
|
126
164
|
e2eTestRunner: 'none',
|
|
127
165
|
install: false,
|
|
128
166
|
projectNameAndRootFormat: 'as-provided',
|
|
167
|
+
linter: Linter.None,
|
|
168
|
+
unitTestRunner: 'none',
|
|
169
|
+
bundler: 'vite',
|
|
129
170
|
};
|
|
130
171
|
const options = await normalizeOptions(appTree, schema);
|
|
131
172
|
expect(options).toEqual({
|
|
173
|
+
addPlugin: true,
|
|
132
174
|
androidProjectRoot: 'my-app/android',
|
|
133
175
|
appProjectRoot: 'my-app',
|
|
134
176
|
className: 'MyApp',
|
|
177
|
+
fileName: 'my-app',
|
|
135
178
|
displayName: 'My App',
|
|
136
179
|
iosProjectRoot: 'my-app/ios',
|
|
137
180
|
lowerCaseName: 'myapp',
|
|
@@ -141,8 +184,13 @@ describe('Normalize Options', () => {
|
|
|
141
184
|
projectNameAndRootFormat: 'as-provided',
|
|
142
185
|
entryFile: 'src/main.tsx',
|
|
143
186
|
e2eTestRunner: 'none',
|
|
144
|
-
unitTestRunner: '
|
|
187
|
+
unitTestRunner: 'none',
|
|
145
188
|
install: false,
|
|
189
|
+
bundler: 'vite',
|
|
190
|
+
linter: Linter.None,
|
|
191
|
+
rootProject: false,
|
|
192
|
+
e2eProjectName: 'my-app-e2e',
|
|
193
|
+
e2eProjectRoot: 'my-app-e2e',
|
|
146
194
|
});
|
|
147
195
|
});
|
|
148
196
|
});
|
|
@@ -9,13 +9,15 @@ export interface Schema {
|
|
|
9
9
|
directory?: string;
|
|
10
10
|
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
11
|
tags?: string;
|
|
12
|
-
unitTestRunner
|
|
12
|
+
unitTestRunner: 'jest' | 'none'; // default is jest
|
|
13
13
|
pascalCaseFiles?: boolean;
|
|
14
14
|
classComponent?: boolean;
|
|
15
15
|
js?: boolean;
|
|
16
|
-
linter
|
|
16
|
+
linter: Linter;
|
|
17
17
|
setParserOptionsProject?: boolean;
|
|
18
|
-
e2eTestRunner
|
|
18
|
+
e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none'; // default is cypress
|
|
19
|
+
bundler: 'webpack' | 'vite'; // default is webpack
|
|
19
20
|
install: boolean; // default is true
|
|
20
21
|
skipPackageJson?: boolean; //default is false
|
|
22
|
+
addPlugin?: boolean;
|
|
21
23
|
}
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"linter": {
|
|
49
49
|
"description": "The tool to use for running lint checks.",
|
|
50
50
|
"type": "string",
|
|
51
|
-
"enum": ["eslint"],
|
|
51
|
+
"enum": ["eslint", "none"],
|
|
52
52
|
"default": "eslint"
|
|
53
53
|
},
|
|
54
54
|
"unitTestRunner": {
|
|
@@ -75,20 +75,28 @@
|
|
|
75
75
|
"e2eTestRunner": {
|
|
76
76
|
"description": "Adds the specified e2e test runner.",
|
|
77
77
|
"type": "string",
|
|
78
|
-
"enum": ["detox", "none"],
|
|
79
|
-
"default": "
|
|
78
|
+
"enum": ["cypress", "playwright", "detox", "none"],
|
|
79
|
+
"default": "cypress"
|
|
80
80
|
},
|
|
81
81
|
"install": {
|
|
82
82
|
"type": "boolean",
|
|
83
83
|
"description": "Runs `pod install` for native modules before building iOS app.",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
84
|
+
"x-prompt": "Run 'pod install' for native modules?",
|
|
85
|
+
"default": true
|
|
86
86
|
},
|
|
87
87
|
"skipPackageJson": {
|
|
88
88
|
"description": "Do not add dependencies to `package.json`.",
|
|
89
89
|
"type": "boolean",
|
|
90
90
|
"default": false,
|
|
91
91
|
"x-priority": "internal"
|
|
92
|
+
},
|
|
93
|
+
"bundler": {
|
|
94
|
+
"description": "The bundler to use.",
|
|
95
|
+
"type": "string",
|
|
96
|
+
"enum": ["vite", "webpack"],
|
|
97
|
+
"x-prompt": "Which bundler do you want to use to build the application?",
|
|
98
|
+
"default": "webpack",
|
|
99
|
+
"x-priority": "important"
|
|
92
100
|
}
|
|
93
101
|
},
|
|
94
102
|
"required": []
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export declare function createComponentStoriesFile(host: Tree, { project, componentPath }: CreateComponentStoriesFileSchema): void;
|
|
9
|
-
export declare function findPropsAndGenerateFile(host: Tree, sourceFile: ts.SourceFile, cmpDeclaration: ts.Node, componentDirectory: string, name: string, isPlainJs: boolean, fileExt: string, fromNodeArray?: boolean): void;
|
|
2
|
+
import { CreateComponentStoriesFileSchema } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated This would be a direct pass through to @nx/react:component-story generator.
|
|
5
|
+
* TODO (@xiongemi): remove this generator for v19
|
|
6
|
+
*/
|
|
10
7
|
export declare function componentStoryGenerator(host: Tree, schema: CreateComponentStoriesFileSchema): Promise<void>;
|
|
11
8
|
export default componentStoryGenerator;
|
|
@@ -1,76 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.componentStoryGenerator =
|
|
3
|
+
exports.componentStoryGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!tsModule) {
|
|
11
|
-
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
12
|
-
}
|
|
13
|
-
const proj = (0, devkit_1.getProjects)(host).get(project);
|
|
14
|
-
const sourceRoot = proj.sourceRoot;
|
|
15
|
-
const componentFilePath = (0, devkit_1.joinPathFragments)(sourceRoot, componentPath);
|
|
16
|
-
const componentDirectory = componentFilePath.replace(componentFilePath.slice(componentFilePath.lastIndexOf('/')), '');
|
|
17
|
-
const isPlainJs = componentFilePath.endsWith('.jsx') || componentFilePath.endsWith('.js');
|
|
18
|
-
let fileExt = 'tsx';
|
|
19
|
-
if (componentFilePath.endsWith('.jsx')) {
|
|
20
|
-
fileExt = 'jsx';
|
|
21
|
-
}
|
|
22
|
-
else if (componentFilePath.endsWith('.js')) {
|
|
23
|
-
fileExt = 'js';
|
|
24
|
-
}
|
|
25
|
-
const componentFileName = componentFilePath
|
|
26
|
-
.slice(componentFilePath.lastIndexOf('/') + 1)
|
|
27
|
-
.replace('.tsx', '')
|
|
28
|
-
.replace('.jsx', '')
|
|
29
|
-
.replace('.js', '');
|
|
30
|
-
const name = componentFileName;
|
|
31
|
-
const contents = host.read(componentFilePath, 'utf-8');
|
|
32
|
-
if (contents === null) {
|
|
33
|
-
throw new Error(`Failed to read ${componentFilePath}`);
|
|
34
|
-
}
|
|
35
|
-
const sourceFile = tsModule.createSourceFile(componentFilePath, contents, tsModule.ScriptTarget.Latest, true);
|
|
36
|
-
const cmpDeclaration = (0, ast_utils_1.getComponentNode)(sourceFile);
|
|
37
|
-
if (!cmpDeclaration) {
|
|
38
|
-
const componentNodes = (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile);
|
|
39
|
-
if (componentNodes?.length) {
|
|
40
|
-
componentNodes.forEach((declaration) => {
|
|
41
|
-
findPropsAndGenerateFile(host, sourceFile, declaration, componentDirectory, name, isPlainJs, fileExt, componentNodes.length > 1);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
throw new Error(`Could not find any React Native component in file ${componentFilePath}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
findPropsAndGenerateFile(host, sourceFile, cmpDeclaration, componentDirectory, name, isPlainJs, fileExt);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.createComponentStoriesFile = createComponentStoriesFile;
|
|
53
|
-
function findPropsAndGenerateFile(host, sourceFile, cmpDeclaration, componentDirectory, name, isPlainJs, fileExt, fromNodeArray) {
|
|
54
|
-
const { propsTypeName, props, argTypes } = (0, component_props_1.getDefaultsForComponent)(sourceFile, cmpDeclaration);
|
|
55
|
-
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), (0, devkit_1.normalizePath)(componentDirectory), {
|
|
56
|
-
componentFileName: fromNodeArray
|
|
57
|
-
? `${name}--${cmpDeclaration.name.text}`
|
|
58
|
-
: name,
|
|
59
|
-
componentImportFileName: name,
|
|
60
|
-
propsTypeName,
|
|
61
|
-
props,
|
|
62
|
-
argTypes,
|
|
63
|
-
componentName: cmpDeclaration.name.text,
|
|
64
|
-
isPlainJs,
|
|
65
|
-
fileExt,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
exports.findPropsAndGenerateFile = findPropsAndGenerateFile;
|
|
5
|
+
const react_1 = require("@nx/react");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated This would be a direct pass through to @nx/react:component-story generator.
|
|
8
|
+
* TODO (@xiongemi): remove this generator for v19
|
|
9
|
+
*/
|
|
69
10
|
async function componentStoryGenerator(host, schema) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
await (0, devkit_1.formatFiles)(host);
|
|
73
|
-
}
|
|
11
|
+
devkit_1.logger.warn(`Please run 'nx run @nx/react:component-story ${schema.project}' instead.`);
|
|
12
|
+
return (0, react_1.componentStoryGenerator)(host, schema);
|
|
74
13
|
}
|
|
75
14
|
exports.componentStoryGenerator = componentStoryGenerator;
|
|
76
15
|
exports.default = componentStoryGenerator;
|
|
@@ -15,19 +15,27 @@
|
|
|
15
15
|
"$source": "projectName",
|
|
16
16
|
"index": 0
|
|
17
17
|
},
|
|
18
|
-
"x-prompt": "What's
|
|
18
|
+
"x-prompt": "What's name of the project where the component lives?",
|
|
19
|
+
"x-priority": "important"
|
|
19
20
|
},
|
|
20
21
|
"componentPath": {
|
|
21
22
|
"type": "string",
|
|
22
23
|
"description": "Relative path to the component file from the library root.",
|
|
23
24
|
"examples": ["lib/components"],
|
|
24
|
-
"x-prompt": "What's path of the component relative to the project's lib root?"
|
|
25
|
+
"x-prompt": "What's path of the component relative to the project's lib root?",
|
|
26
|
+
"x-priority": "important"
|
|
25
27
|
},
|
|
26
28
|
"skipFormat": {
|
|
27
29
|
"description": "Skip formatting files.",
|
|
28
30
|
"type": "boolean",
|
|
29
31
|
"default": false,
|
|
30
32
|
"x-priority": "internal"
|
|
33
|
+
},
|
|
34
|
+
"interactionTests": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Set up Storybook interaction tests.",
|
|
37
|
+
"default": true,
|
|
38
|
+
"x-priority": "important"
|
|
31
39
|
}
|
|
32
40
|
},
|
|
33
41
|
"required": ["project", "componentPath"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function reactNativeInitGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function reactNativeInitGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
|
|
5
6
|
export default reactNativeInitGenerator;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDependencies = exports.reactNativeInitGenerator = void 0;
|
|
3
|
+
exports.updateDependencies = exports.reactNativeInitGeneratorInternal = exports.reactNativeInitGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
6
|
const plugin_1 = require("../../../plugins/plugin");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
8
|
const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
|
|
9
|
-
|
|
9
|
+
function reactNativeInitGenerator(host, schema) {
|
|
10
|
+
return reactNativeInitGeneratorInternal(host, {
|
|
11
|
+
addPlugin: false,
|
|
12
|
+
...schema,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.reactNativeInitGenerator = reactNativeInitGenerator;
|
|
16
|
+
async function reactNativeInitGeneratorInternal(host, schema) {
|
|
10
17
|
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
|
|
11
|
-
|
|
18
|
+
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
19
|
+
if (schema.addPlugin) {
|
|
12
20
|
addPlugin(host);
|
|
13
21
|
}
|
|
14
22
|
const tasks = [];
|
|
@@ -24,7 +32,7 @@ async function reactNativeInitGenerator(host, schema) {
|
|
|
24
32
|
}
|
|
25
33
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
26
34
|
}
|
|
27
|
-
exports.
|
|
35
|
+
exports.reactNativeInitGeneratorInternal = reactNativeInitGeneratorInternal;
|
|
28
36
|
function updateDependencies(host, schema) {
|
|
29
37
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
30
38
|
react: versions_1.reactVersion,
|
|
@@ -32,9 +40,6 @@ function updateDependencies(host, schema) {
|
|
|
32
40
|
'react-native': versions_1.reactNativeVersion,
|
|
33
41
|
}, {
|
|
34
42
|
'@nx/react-native': versions_1.nxVersion,
|
|
35
|
-
'@react-native-community/cli': versions_1.reactNativeCommunityCli,
|
|
36
|
-
'@react-native-community/cli-platform-android': versions_1.reactNativeCommunityCliAndroid,
|
|
37
|
-
'@react-native-community/cli-platform-ios': versions_1.reactNativeCommunityCliIos,
|
|
38
43
|
}, undefined, schema.keepExistingVersions);
|
|
39
44
|
}
|
|
40
45
|
exports.updateDependencies = updateDependencies;
|
|
@@ -61,6 +66,8 @@ function addPlugin(host) {
|
|
|
61
66
|
runAndroidTargetName: 'run-android',
|
|
62
67
|
buildIosTargetName: 'build-ios',
|
|
63
68
|
buildAndroidTargetName: 'build-android',
|
|
69
|
+
syncDepsTargetName: 'sync-deps',
|
|
70
|
+
upgradeTargetname: 'upgrade',
|
|
64
71
|
},
|
|
65
72
|
});
|
|
66
73
|
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
@@ -11,7 +11,9 @@ describe('init', () => {
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it('should add react native dependencies', async () => {
|
|
14
|
-
await reactNativeInitGenerator(tree, {
|
|
14
|
+
await reactNativeInitGenerator(tree, {
|
|
15
|
+
addPlugin: true,
|
|
16
|
+
});
|
|
15
17
|
const packageJson = readJson(tree, 'package.json');
|
|
16
18
|
expect(packageJson.dependencies['react']).toBeDefined();
|
|
17
19
|
expect(packageJson.dependencies['react-native']).toBeDefined();
|
|
@@ -24,7 +26,9 @@ describe('init', () => {
|
|
|
24
26
|
/node_modules
|
|
25
27
|
`
|
|
26
28
|
);
|
|
27
|
-
await reactNativeInitGenerator(tree, {
|
|
29
|
+
await reactNativeInitGenerator(tree, {
|
|
30
|
+
addPlugin: true,
|
|
31
|
+
});
|
|
28
32
|
|
|
29
33
|
const content = tree.read('/.gitignore').toString();
|
|
30
34
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = function (api) {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
presets: [
|
|
6
|
+
[
|
|
7
|
+
'@nx/react/babel',
|
|
8
|
+
{
|
|
9
|
+
runtime: 'automatic',
|
|
10
|
+
useBuiltIns: 'usage',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
],
|
|
14
|
+
plugins: [],
|
|
15
|
+
env: {
|
|
16
|
+
test: {
|
|
17
|
+
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -11,6 +11,7 @@ async function normalizeOptions(host, options) {
|
|
|
11
11
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
12
|
callingGenerator: '@nx/react-native:library',
|
|
13
13
|
});
|
|
14
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
14
15
|
const parsedTags = options.tags
|
|
15
16
|
? options.tags.split(',').map((s) => s.trim())
|
|
16
17
|
: [];
|
|
@@ -12,6 +12,7 @@ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
|
12
12
|
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
13
13
|
async function reactNativeLibraryGenerator(host, schema) {
|
|
14
14
|
return await reactNativeLibraryGeneratorInternal(host, {
|
|
15
|
+
addPlugin: false,
|
|
15
16
|
projectNameAndRootFormat: 'derived',
|
|
16
17
|
...schema,
|
|
17
18
|
});
|
|
@@ -46,7 +47,7 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
46
47
|
],
|
|
47
48
|
});
|
|
48
49
|
tasks.push(lintTask);
|
|
49
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson);
|
|
50
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin);
|
|
50
51
|
tasks.push(jestTask);
|
|
51
52
|
if (options.publishable || options.buildable) {
|
|
52
53
|
updateLibPackageNpmScope(host, options);
|