@nx/react-native 17.0.3 → 17.0.4
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 +7 -1
- package/LICENSE +1 -1
- package/README.md +9 -4
- package/executors.json +5 -0
- package/generators.json +12 -11
- package/migrations.json +126 -0
- package/package.json +11 -15
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +162 -0
- package/plugins/with-nx-metro.js +6 -2
- package/src/executors/build-android/build-android.impl.js +2 -6
- package/src/executors/build-android/build-android.impl.ts +2 -6
- 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 +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/ensure-symlink/schema.json +1 -1
- package/src/executors/pod-install/schema.json +1 -1
- package/src/executors/run-android/run-android.impl.js +5 -17
- package/src/executors/run-android/run-android.impl.ts +9 -18
- package/src/executors/run-android/schema.json +1 -1
- 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/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 +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 +15 -2
- package/src/executors/storybook/storybook.impl.ts +26 -7
- package/src/executors/sync-deps/schema.d.ts +1 -0
- package/src/executors/sync-deps/schema.json +6 -1
- package/src/executors/sync-deps/sync-deps.impl.d.ts +2 -1
- package/src/executors/sync-deps/sync-deps.impl.js +33 -11
- package/src/executors/sync-deps/sync-deps.impl.ts +57 -18
- 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 +52 -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/Gemfile.template +2 -1
- 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 +1 -5
- package/src/generators/application/files/app/src/app/App.tsx.template +50 -13
- 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.js +18 -18
- package/src/generators/application/lib/normalize-options.d.ts +7 -0
- package/src/generators/application/lib/normalize-options.js +35 -3
- package/src/generators/application/lib/normalize-options.spec.ts +70 -7
- package/src/generators/application/schema.d.ts +5 -3
- package/src/generators/application/schema.json +14 -6
- 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 +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 +11 -3
- package/src/generators/init/init.d.ts +2 -1
- package/src/generators/init/init.js +55 -56
- package/src/generators/init/init.spec.ts +7 -6
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +13 -18
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +5 -0
- package/src/generators/library/library.js +48 -38
- package/src/generators/library/library.spec.ts +12 -60
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +2 -2
- package/src/generators/stories/schema.d.ts +2 -0
- package/src/generators/stories/schema.json +15 -2
- 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 +18 -48
- package/src/generators/storybook-configuration/schema.d.ts +4 -2
- package/src/generators/storybook-configuration/schema.json +22 -12
- 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 +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 +87 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +1 -5
- 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 +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 +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 -1
- package/src/utils/add-linting.spec.ts +4 -6
- package/src/utils/chmod-android-gradle-files.js +6 -2
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +30 -0
- package/src/utils/find-all-npm-dependencies.js +5 -3
- package/src/utils/find-all-npm-dependencies.spec.ts +17 -9
- package/src/utils/testing-generators.js +1 -0
- package/src/utils/versions.d.ts +10 -13
- package/src/utils/versions.js +11 -14
- 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 -3
- 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 -428
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +0 -32
- package/src/generators/library/files/lib/babel.config.json.template +0 -17
- 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/symlink-task.d.ts +0 -2
- package/src/utils/symlink-task.js +0 -18
|
@@ -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,11 @@ 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;
|
|
16
|
+
e2eWebServerAddress: string;
|
|
17
|
+
e2eWebServerTarget: string;
|
|
18
|
+
e2ePort: number;
|
|
12
19
|
}
|
|
13
20
|
export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
|
|
@@ -12,19 +12,45 @@ async function normalizeOptions(host, options) {
|
|
|
12
12
|
callingGenerator: '@nx/react-native:application',
|
|
13
13
|
});
|
|
14
14
|
options.projectNameAndRootFormat = projectNameAndRootFormat;
|
|
15
|
-
const
|
|
15
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
16
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
17
|
+
nxJson.useInferencePlugins !== false;
|
|
18
|
+
options.addPlugin ??= addPluginDefault;
|
|
19
|
+
const { className, fileName } = (0, devkit_1.names)(options.name);
|
|
16
20
|
const iosProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'ios');
|
|
17
21
|
const androidProjectRoot = (0, devkit_1.joinPathFragments)(appProjectRoot, 'android');
|
|
22
|
+
const rootProject = appProjectRoot === '.';
|
|
23
|
+
let e2eWebServerTarget = 'start';
|
|
24
|
+
if (options.addPlugin) {
|
|
25
|
+
if (nxJson.plugins) {
|
|
26
|
+
for (const plugin of nxJson.plugins) {
|
|
27
|
+
if (options.bundler === 'vite' &&
|
|
28
|
+
typeof plugin === 'object' &&
|
|
29
|
+
plugin.plugin === '@nx/react-native/plugin' &&
|
|
30
|
+
plugin.options.startTargetName) {
|
|
31
|
+
e2eWebServerTarget = plugin.options
|
|
32
|
+
.startTargetName;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
let e2ePort = 4200;
|
|
38
|
+
if (nxJson.targetDefaults?.[e2eWebServerTarget] &&
|
|
39
|
+
nxJson.targetDefaults?.[e2eWebServerTarget].options?.port) {
|
|
40
|
+
e2ePort = nxJson.targetDefaults?.[e2eWebServerTarget].options?.port;
|
|
41
|
+
}
|
|
42
|
+
const e2eProjectName = rootProject ? 'e2e' : `${fileName}-e2e`;
|
|
43
|
+
const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
|
|
44
|
+
const e2eWebServerAddress = `http://localhost:${e2ePort}`;
|
|
18
45
|
const parsedTags = options.tags
|
|
19
46
|
? options.tags.split(',').map((s) => s.trim())
|
|
20
47
|
: [];
|
|
21
48
|
const entryFile = options.js ? 'src/main.js' : 'src/main.tsx';
|
|
22
49
|
return {
|
|
23
50
|
...options,
|
|
24
|
-
unitTestRunner: options.unitTestRunner || 'jest',
|
|
25
|
-
e2eTestRunner: options.e2eTestRunner || 'detox',
|
|
26
51
|
name: projectNames.projectSimpleName,
|
|
27
52
|
className,
|
|
53
|
+
fileName,
|
|
28
54
|
lowerCaseName: className.toLowerCase(),
|
|
29
55
|
displayName: options.displayName || className,
|
|
30
56
|
projectName: appProjectName,
|
|
@@ -33,6 +59,12 @@ async function normalizeOptions(host, options) {
|
|
|
33
59
|
androidProjectRoot,
|
|
34
60
|
parsedTags,
|
|
35
61
|
entryFile,
|
|
62
|
+
rootProject,
|
|
63
|
+
e2eProjectName,
|
|
64
|
+
e2eProjectRoot,
|
|
65
|
+
e2eWebServerAddress,
|
|
66
|
+
e2eWebServerTarget,
|
|
67
|
+
e2ePort,
|
|
36
68
|
};
|
|
37
69
|
}
|
|
38
70
|
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,15 @@ 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',
|
|
47
|
+
e2ePort: 4200,
|
|
48
|
+
e2eWebServerAddress: 'http://localhost:4200',
|
|
49
|
+
e2eWebServerTarget: 'start',
|
|
39
50
|
});
|
|
40
51
|
});
|
|
41
52
|
|
|
@@ -45,12 +56,17 @@ describe('Normalize Options', () => {
|
|
|
45
56
|
e2eTestRunner: 'none',
|
|
46
57
|
install: false,
|
|
47
58
|
projectNameAndRootFormat: 'as-provided',
|
|
59
|
+
linter: Linter.None,
|
|
60
|
+
unitTestRunner: 'none',
|
|
61
|
+
bundler: 'vite',
|
|
48
62
|
};
|
|
49
63
|
const options = await normalizeOptions(appTree, schema);
|
|
50
64
|
expect(options).toEqual({
|
|
65
|
+
addPlugin: true,
|
|
51
66
|
androidProjectRoot: 'myApp/android',
|
|
52
67
|
appProjectRoot: 'myApp',
|
|
53
68
|
className: 'MyApp',
|
|
69
|
+
fileName: 'my-app',
|
|
54
70
|
displayName: 'MyApp',
|
|
55
71
|
iosProjectRoot: 'myApp/ios',
|
|
56
72
|
lowerCaseName: 'myapp',
|
|
@@ -60,8 +76,16 @@ describe('Normalize Options', () => {
|
|
|
60
76
|
projectNameAndRootFormat: 'as-provided',
|
|
61
77
|
entryFile: 'src/main.tsx',
|
|
62
78
|
e2eTestRunner: 'none',
|
|
63
|
-
unitTestRunner: '
|
|
79
|
+
unitTestRunner: 'none',
|
|
64
80
|
install: false,
|
|
81
|
+
bundler: 'vite',
|
|
82
|
+
linter: Linter.None,
|
|
83
|
+
rootProject: false,
|
|
84
|
+
e2eProjectName: 'my-app-e2e',
|
|
85
|
+
e2eProjectRoot: 'myApp-e2e',
|
|
86
|
+
e2ePort: 4200,
|
|
87
|
+
e2eWebServerAddress: 'http://localhost:4200',
|
|
88
|
+
e2eWebServerTarget: 'start',
|
|
65
89
|
});
|
|
66
90
|
});
|
|
67
91
|
|
|
@@ -72,12 +96,17 @@ describe('Normalize Options', () => {
|
|
|
72
96
|
e2eTestRunner: 'none',
|
|
73
97
|
install: false,
|
|
74
98
|
projectNameAndRootFormat: 'as-provided',
|
|
99
|
+
linter: Linter.None,
|
|
100
|
+
unitTestRunner: 'none',
|
|
101
|
+
bundler: 'vite',
|
|
75
102
|
};
|
|
76
103
|
const options = await normalizeOptions(appTree, schema);
|
|
77
104
|
expect(options).toEqual({
|
|
105
|
+
addPlugin: true,
|
|
78
106
|
androidProjectRoot: 'directory/my-app/android',
|
|
79
107
|
appProjectRoot: 'directory/my-app',
|
|
80
108
|
className: 'MyApp',
|
|
109
|
+
fileName: 'my-app',
|
|
81
110
|
displayName: 'MyApp',
|
|
82
111
|
iosProjectRoot: 'directory/my-app/ios',
|
|
83
112
|
lowerCaseName: 'myapp',
|
|
@@ -88,8 +117,16 @@ describe('Normalize Options', () => {
|
|
|
88
117
|
projectNameAndRootFormat: 'as-provided',
|
|
89
118
|
entryFile: 'src/main.tsx',
|
|
90
119
|
e2eTestRunner: 'none',
|
|
91
|
-
unitTestRunner: '
|
|
120
|
+
unitTestRunner: 'none',
|
|
92
121
|
install: false,
|
|
122
|
+
bundler: 'vite',
|
|
123
|
+
linter: Linter.None,
|
|
124
|
+
rootProject: false,
|
|
125
|
+
e2eProjectName: 'my-app-e2e',
|
|
126
|
+
e2eProjectRoot: 'directory/my-app-e2e',
|
|
127
|
+
e2ePort: 4200,
|
|
128
|
+
e2eWebServerAddress: 'http://localhost:4200',
|
|
129
|
+
e2eWebServerTarget: 'start',
|
|
93
130
|
});
|
|
94
131
|
});
|
|
95
132
|
|
|
@@ -99,23 +136,36 @@ describe('Normalize Options', () => {
|
|
|
99
136
|
e2eTestRunner: 'none',
|
|
100
137
|
install: false,
|
|
101
138
|
projectNameAndRootFormat: 'as-provided',
|
|
139
|
+
linter: Linter.None,
|
|
140
|
+
unitTestRunner: 'none',
|
|
141
|
+
bundler: 'vite',
|
|
102
142
|
};
|
|
103
143
|
const options = await normalizeOptions(appTree, schema);
|
|
104
144
|
expect(options).toEqual({
|
|
145
|
+
addPlugin: true,
|
|
105
146
|
androidProjectRoot: 'directory/my-app/android',
|
|
106
147
|
appProjectRoot: 'directory/my-app',
|
|
107
148
|
className: 'DirectoryMyApp',
|
|
149
|
+
fileName: 'directory/my-app',
|
|
108
150
|
displayName: 'DirectoryMyApp',
|
|
109
151
|
iosProjectRoot: 'directory/my-app/ios',
|
|
110
152
|
lowerCaseName: 'directorymyapp',
|
|
111
|
-
name: '
|
|
153
|
+
name: 'my-app',
|
|
112
154
|
parsedTags: [],
|
|
113
|
-
projectName: '
|
|
155
|
+
projectName: 'my-app',
|
|
114
156
|
projectNameAndRootFormat: 'as-provided',
|
|
115
157
|
entryFile: 'src/main.tsx',
|
|
116
158
|
e2eTestRunner: 'none',
|
|
117
|
-
unitTestRunner: '
|
|
159
|
+
unitTestRunner: 'none',
|
|
118
160
|
install: false,
|
|
161
|
+
bundler: 'vite',
|
|
162
|
+
linter: Linter.None,
|
|
163
|
+
rootProject: false,
|
|
164
|
+
e2eProjectName: 'directory/my-app-e2e',
|
|
165
|
+
e2eProjectRoot: 'directory/my-app-e2e',
|
|
166
|
+
e2ePort: 4200,
|
|
167
|
+
e2eWebServerAddress: 'http://localhost:4200',
|
|
168
|
+
e2eWebServerTarget: 'start',
|
|
119
169
|
});
|
|
120
170
|
});
|
|
121
171
|
|
|
@@ -126,12 +176,17 @@ describe('Normalize Options', () => {
|
|
|
126
176
|
e2eTestRunner: 'none',
|
|
127
177
|
install: false,
|
|
128
178
|
projectNameAndRootFormat: 'as-provided',
|
|
179
|
+
linter: Linter.None,
|
|
180
|
+
unitTestRunner: 'none',
|
|
181
|
+
bundler: 'vite',
|
|
129
182
|
};
|
|
130
183
|
const options = await normalizeOptions(appTree, schema);
|
|
131
184
|
expect(options).toEqual({
|
|
185
|
+
addPlugin: true,
|
|
132
186
|
androidProjectRoot: 'my-app/android',
|
|
133
187
|
appProjectRoot: 'my-app',
|
|
134
188
|
className: 'MyApp',
|
|
189
|
+
fileName: 'my-app',
|
|
135
190
|
displayName: 'My App',
|
|
136
191
|
iosProjectRoot: 'my-app/ios',
|
|
137
192
|
lowerCaseName: 'myapp',
|
|
@@ -141,8 +196,16 @@ describe('Normalize Options', () => {
|
|
|
141
196
|
projectNameAndRootFormat: 'as-provided',
|
|
142
197
|
entryFile: 'src/main.tsx',
|
|
143
198
|
e2eTestRunner: 'none',
|
|
144
|
-
unitTestRunner: '
|
|
199
|
+
unitTestRunner: 'none',
|
|
145
200
|
install: false,
|
|
201
|
+
bundler: 'vite',
|
|
202
|
+
linter: Linter.None,
|
|
203
|
+
rootProject: false,
|
|
204
|
+
e2eProjectName: 'my-app-e2e',
|
|
205
|
+
e2eProjectRoot: 'my-app-e2e',
|
|
206
|
+
e2ePort: 4200,
|
|
207
|
+
e2eWebServerAddress: 'http://localhost:4200',
|
|
208
|
+
e2eWebServerTarget: 'start',
|
|
146
209
|
});
|
|
147
210
|
});
|
|
148
211
|
});
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxReactNativeApplication",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "https://json-schema.org/schema",
|
|
5
5
|
"title": "Create a React Application for Nx",
|
|
6
6
|
"description": "Create a React Application for Nx.",
|
|
7
7
|
"examples": [
|
|
@@ -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": []
|
|
@@ -4,20 +4,20 @@
|
|
|
4
4
|
export interface Schema {
|
|
5
5
|
name: string;
|
|
6
6
|
/**
|
|
7
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
7
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19.
|
|
8
8
|
*/
|
|
9
9
|
project: string;
|
|
10
10
|
skipTests?: boolean;
|
|
11
11
|
directory?: string;
|
|
12
12
|
export?: boolean;
|
|
13
13
|
/**
|
|
14
|
-
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
14
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
|
|
15
15
|
*/
|
|
16
16
|
pascalCaseFiles?: boolean;
|
|
17
17
|
classComponent?: boolean;
|
|
18
18
|
js?: boolean;
|
|
19
19
|
/**
|
|
20
|
-
* @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
20
|
+
* @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
|
|
21
21
|
*/
|
|
22
22
|
flat?: boolean;
|
|
23
23
|
nameAndDirectoryFormat?: 'as-provided' | 'derived';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxReactNativeApplication",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "https://json-schema.org/schema",
|
|
5
5
|
"title": "Create a React Native Component for Nx",
|
|
6
6
|
"description": "Create a React native Component for Nx.",
|
|
7
7
|
"type": "object",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"$default": {
|
|
24
24
|
"$source": "projectName"
|
|
25
25
|
},
|
|
26
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx
|
|
26
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v19."
|
|
27
27
|
},
|
|
28
28
|
"name": {
|
|
29
29
|
"type": "string",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"type": "boolean",
|
|
59
59
|
"description": "Create component at the source root rather than its own directory.",
|
|
60
60
|
"default": false,
|
|
61
|
-
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx
|
|
61
|
+
"x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
|
|
62
62
|
},
|
|
63
63
|
"export": {
|
|
64
64
|
"type": "boolean",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
73
73
|
"alias": "P",
|
|
74
74
|
"default": false,
|
|
75
|
-
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx
|
|
75
|
+
"x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
|
|
76
76
|
},
|
|
77
77
|
"classComponent": {
|
|
78
78
|
"type": "boolean",
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeComponentStory",
|
|
5
5
|
"title": "React native component story",
|
|
@@ -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
|
|
4
|
+
export declare function reactNativeInitGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
5
|
+
export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
|
|
5
6
|
export default reactNativeInitGenerator;
|