@nx/react-native 18.0.0-beta.0 → 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/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 +4 -16
- package/src/executors/run-android/run-android.impl.ts +8 -17
- 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 +8 -1
- package/src/executors/storybook/storybook.impl.ts +16 -5
- package/src/executors/sync-deps/schema.json +1 -1
- 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 +30 -7
- 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 +14 -6
- 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 +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/init/schema.json +1 -1
- 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 +6 -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 +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 +15 -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 +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 -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 -427
- 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/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
|
@@ -19,7 +19,10 @@ export const App = () => {
|
|
|
19
19
|
return (
|
|
20
20
|
<>
|
|
21
21
|
<StatusBar barStyle="dark-content" />
|
|
22
|
-
<SafeAreaView
|
|
22
|
+
<SafeAreaView
|
|
23
|
+
style={{
|
|
24
|
+
flex: 1,
|
|
25
|
+
}}>
|
|
23
26
|
<ScrollView
|
|
24
27
|
ref={(ref) => {
|
|
25
28
|
scrollViewRef.current = ref;
|
|
@@ -29,7 +32,7 @@ export const App = () => {
|
|
|
29
32
|
>
|
|
30
33
|
<View style={styles.section}>
|
|
31
34
|
<Text style={styles.textLg}>Hello there,</Text>
|
|
32
|
-
<Text style={[styles.textXL, styles.appTitleText]} testID="heading">
|
|
35
|
+
<Text style={[styles.textXL, styles.appTitleText]} testID="heading" role="heading">
|
|
33
36
|
Welcome <%= displayName %> 👋
|
|
34
37
|
</Text>
|
|
35
38
|
</View>
|
|
@@ -475,6 +478,30 @@ export const App = () => {
|
|
|
475
478
|
ui/src/lib/button
|
|
476
479
|
</Text>
|
|
477
480
|
</View>
|
|
481
|
+
<View style={styles.listItem}>
|
|
482
|
+
<Svg
|
|
483
|
+
width={24}
|
|
484
|
+
height={24}
|
|
485
|
+
stroke="#000000"
|
|
486
|
+
fill="none"
|
|
487
|
+
viewBox="0 0 24 24"
|
|
488
|
+
>
|
|
489
|
+
<Path
|
|
490
|
+
strokeLinecap="round"
|
|
491
|
+
strokeLinejoin="round"
|
|
492
|
+
strokeWidth="2"
|
|
493
|
+
d="M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
494
|
+
/>
|
|
495
|
+
</Svg>
|
|
496
|
+
<View style={styles.listItemTextContainer}>
|
|
497
|
+
<Text style={styles.textSm}>
|
|
498
|
+
View project details
|
|
499
|
+
</Text>
|
|
500
|
+
</View>
|
|
501
|
+
</View>
|
|
502
|
+
<View style={[styles.codeBlock, styles.marginBottomLg]}>
|
|
503
|
+
<Text style={[styles.textXS, styles.monospace]}>nx show project <%= displayName %> --web</Text>
|
|
504
|
+
</View>
|
|
478
505
|
<View style={styles.listItem}>
|
|
479
506
|
<Svg
|
|
480
507
|
width={24}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addE2e = void 0;
|
|
4
|
+
const add_e2e_1 = require("@nx/react/src/generators/application/lib/add-e2e");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
async function addE2e(host, options) {
|
|
8
|
+
switch (options.e2eTestRunner) {
|
|
9
|
+
case 'cypress':
|
|
10
|
+
return (0, add_e2e_1.addE2e)(host, {
|
|
11
|
+
...options,
|
|
12
|
+
e2eTestRunner: 'cypress',
|
|
13
|
+
style: 'none',
|
|
14
|
+
styledModule: null,
|
|
15
|
+
hasStyles: false,
|
|
16
|
+
unitTestRunner: 'none',
|
|
17
|
+
});
|
|
18
|
+
case 'playwright':
|
|
19
|
+
return (0, add_e2e_1.addE2e)(host, {
|
|
20
|
+
...options,
|
|
21
|
+
e2eTestRunner: 'playwright',
|
|
22
|
+
style: 'none',
|
|
23
|
+
styledModule: null,
|
|
24
|
+
hasStyles: false,
|
|
25
|
+
unitTestRunner: 'none',
|
|
26
|
+
});
|
|
27
|
+
case 'detox':
|
|
28
|
+
case 'detox':
|
|
29
|
+
const { detoxApplicationGenerator } = (0, devkit_1.ensurePackage)('@nx/detox', versions_1.nxVersion);
|
|
30
|
+
return detoxApplicationGenerator(host, {
|
|
31
|
+
...options,
|
|
32
|
+
e2eName: options.e2eProjectName,
|
|
33
|
+
e2eDirectory: options.e2eProjectRoot,
|
|
34
|
+
projectNameAndRootFormat: 'as-provided',
|
|
35
|
+
appProject: options.projectName,
|
|
36
|
+
appDisplayName: options.displayName,
|
|
37
|
+
appName: options.name,
|
|
38
|
+
framework: 'react-native',
|
|
39
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
40
|
+
skipFormat: true,
|
|
41
|
+
});
|
|
42
|
+
case 'none':
|
|
43
|
+
default:
|
|
44
|
+
return () => { };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.addE2e = addE2e;
|
|
@@ -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
|
}
|
|
@@ -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;
|