@nx/react-native 17.0.5 → 17.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +1 -7
- package/LICENSE +1 -1
- package/README.md +4 -9
- package/executors.json +0 -5
- package/generators.json +11 -12
- package/migrations.json +0 -126
- package/package.json +15 -11
- package/plugins/metro-resolver.js +1 -4
- package/plugins/with-nx-metro.js +2 -6
- package/src/executors/build-android/build-android.impl.js +6 -2
- package/src/executors/build-android/build-android.impl.ts +6 -2
- package/src/executors/build-android/schema.json +1 -1
- package/src/executors/build-ios/schema.json +1 -1
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/bundle/schema.json +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +0 -4
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +0 -4
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -4
- package/src/executors/ensure-symlink/schema.json +1 -1
- package/src/executors/pod-install/schema.json +1 -1
- package/src/executors/run-android/run-android.impl.js +17 -5
- package/src/executors/run-android/run-android.impl.ts +18 -9
- package/src/executors/run-android/schema.json +1 -1
- package/src/executors/run-ios/run-ios.impl.js +16 -4
- package/src/executors/run-ios/run-ios.impl.ts +18 -9
- package/src/executors/run-ios/schema.json +1 -1
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/schema.json +1 -1
- package/src/executors/start/start.impl.js +26 -11
- package/src/executors/start/start.impl.ts +28 -14
- package/src/executors/storybook/storybook.impl.d.ts +0 -4
- package/src/executors/storybook/storybook.impl.js +2 -15
- package/src/executors/storybook/storybook.impl.ts +7 -26
- package/src/executors/sync-deps/schema.d.ts +0 -1
- package/src/executors/sync-deps/schema.json +1 -6
- package/src/executors/sync-deps/sync-deps.impl.d.ts +1 -2
- package/src/executors/sync-deps/sync-deps.impl.js +11 -33
- package/src/executors/sync-deps/sync-deps.impl.ts +18 -57
- package/src/generators/application/application.js +8 -52
- package/src/generators/application/application.spec.ts +2 -29
- package/src/generators/application/files/app/Gemfile.template +1 -2
- package/src/generators/application/files/app/android/app/build.gradle.template +28 -12
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +6 -2
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +75 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +32 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +62 -0
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +20 -0
- package/src/generators/application/files/app/android/build.gradle.template +20 -7
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +1 -2
- package/src/generators/application/files/app/android/gradle.properties +3 -0
- package/src/generators/application/files/app/android/gradlew.template +7 -12
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/babel.config.json.template +3 -0
- package/src/generators/application/files/app/ios/Podfile.template +7 -0
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +0 -5
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +8 -5
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +33 -11
- package/src/generators/application/files/app/metro.config.js.template +5 -1
- package/src/generators/application/files/app/src/app/App.tsx.template +13 -50
- package/src/generators/application/lib/add-detox.d.ts +3 -0
- package/src/generators/application/lib/add-detox.js +23 -0
- package/src/generators/application/lib/add-project.js +18 -18
- package/src/generators/application/lib/normalize-options.d.ts +0 -7
- package/src/generators/application/lib/normalize-options.js +3 -35
- package/src/generators/application/lib/normalize-options.spec.ts +7 -70
- package/src/generators/application/schema.d.ts +3 -5
- package/src/generators/application/schema.json +6 -14
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +1 -1
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +4 -4
- package/src/generators/component-story/component-story.d.ts +8 -5
- package/src/generators/component-story/component-story.js +69 -8
- package/src/generators/component-story/component-story.spec.ts +428 -0
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +32 -0
- package/src/generators/component-story/schema.d.ts +0 -1
- package/src/generators/component-story/schema.json +3 -11
- package/src/generators/init/init.d.ts +1 -2
- package/src/generators/init/init.js +56 -55
- package/src/generators/init/init.spec.ts +6 -7
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +18 -13
- package/src/generators/library/files/lib/babel.config.json.template +17 -0
- package/src/generators/library/lib/normalize-options.js +0 -5
- package/src/generators/library/library.js +38 -48
- package/src/generators/library/library.spec.ts +60 -12
- package/src/generators/library/schema.d.ts +0 -1
- package/src/generators/library/schema.json +2 -2
- package/src/generators/stories/schema.d.ts +0 -2
- package/src/generators/stories/schema.json +2 -15
- package/src/generators/stories/stories-app.spec.ts +128 -0
- package/src/generators/stories/stories-lib.spec.ts +105 -0
- package/src/generators/stories/stories.d.ts +2 -5
- package/src/generators/stories/stories.js +50 -7
- package/src/generators/storybook-configuration/configuration.d.ts +2 -7
- package/src/generators/storybook-configuration/configuration.js +48 -18
- package/src/generators/storybook-configuration/configuration.spec.ts +135 -0
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +9 -0
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +74 -0
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +5 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +6 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +25 -0
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +161 -0
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +6 -0
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +42 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +7 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +29 -0
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +65 -0
- package/src/generators/storybook-configuration/schema.d.ts +2 -4
- package/src/generators/storybook-configuration/schema.json +12 -22
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
- package/src/generators/upgrade-native/schema.d.ts +1 -1
- package/src/generators/upgrade-native/schema.json +3 -3
- package/src/generators/upgrade-native/upgrade-native.d.ts +0 -2
- package/src/generators/upgrade-native/upgrade-native.js +0 -3
- package/src/migrations/update-16-6-0/update-metro-config.js +5 -1
- package/src/migrations/update-16-9-0/remove-types-react-native.js +9 -2
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +1 -13
- package/src/utils/add-linting.d.ts +0 -1
- package/src/utils/add-linting.js +1 -1
- package/src/utils/add-linting.spec.ts +6 -4
- package/src/utils/chmod-android-gradle-files.js +2 -6
- package/src/utils/find-all-npm-dependencies.js +3 -5
- package/src/utils/find-all-npm-dependencies.spec.ts +9 -17
- package/src/utils/symlink-task.d.ts +2 -0
- package/src/utils/symlink-task.js +18 -0
- package/src/utils/testing-generators.js +0 -1
- package/src/utils/versions.d.ts +13 -10
- package/src/utils/versions.js +14 -11
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -6
- package/plugins/plugin.d.ts +0 -14
- package/plugins/plugin.js +0 -162
- package/src/executors/upgrade/schema.d.ts +0 -1
- package/src/executors/upgrade/schema.json +0 -11
- package/src/executors/upgrade/upgrade.impl.d.ts +0 -13
- package/src/executors/upgrade/upgrade.impl.js +0 -47
- package/src/executors/upgrade/upgrade.impl.ts +0 -64
- package/src/generators/application/files/app/.babelrc.js.template +0 -23
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +0 -22
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +0 -45
- package/src/generators/application/lib/add-e2e.d.ts +0 -3
- package/src/generators/application/lib/add-e2e.js +0 -46
- package/src/generators/library/files/lib/.babelrc.js.template +0 -21
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +0 -23
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +0 -15
- package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +0 -9
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +0 -82
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +0 -23
- package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +0 -14
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +0 -9
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +0 -77
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +0 -17
- package/src/generators/web-configuration/lib/normalize-schema.js +0 -16
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +0 -7
- package/src/generators/web-configuration/lib/webpack-targets.js +0 -75
- package/src/generators/web-configuration/schema.d.ts +0 -6
- package/src/generators/web-configuration/schema.json +0 -42
- package/src/generators/web-configuration/web-configuration.d.ts +0 -12
- package/src/generators/web-configuration/web-configuration.js +0 -87
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +0 -6
- package/src/migrations/update-18-0-0/add-upgrade-target.js +0 -33
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +0 -8
- package/src/migrations/update-18-0-0/add-web-configuration.js +0 -33
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +0 -5
- package/src/migrations/update-18-0-0/change-storybook-targets.js +0 -57
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-block-list.js +0 -28
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
- package/src/migrations/update-18-0-0/remove-metro.d.ts +0 -14
- package/src/migrations/update-18-0-0/remove-metro.js +0 -29
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +0 -6
- package/src/migrations/update-18-0-0/remove-symlink-target.js +0 -30
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
- package/src/utils/ensure-dependencies.d.ts +0 -2
- package/src/utils/ensure-dependencies.js +0 -30
|
@@ -18,15 +18,11 @@ describe('Normalize Options', () => {
|
|
|
18
18
|
e2eTestRunner: 'none',
|
|
19
19
|
install: false,
|
|
20
20
|
projectNameAndRootFormat: 'as-provided',
|
|
21
|
-
unitTestRunner: 'none',
|
|
22
|
-
bundler: 'vite',
|
|
23
21
|
};
|
|
24
22
|
const options = await normalizeOptions(appTree, schema);
|
|
25
23
|
expect(options).toEqual({
|
|
26
|
-
addPlugin: true,
|
|
27
24
|
androidProjectRoot: 'my-app/android',
|
|
28
25
|
appProjectRoot: 'my-app',
|
|
29
|
-
fileName: 'my-app',
|
|
30
26
|
className: 'MyApp',
|
|
31
27
|
displayName: 'MyApp',
|
|
32
28
|
iosProjectRoot: 'my-app/ios',
|
|
@@ -38,15 +34,8 @@ describe('Normalize Options', () => {
|
|
|
38
34
|
linter: Linter.EsLint,
|
|
39
35
|
entryFile: 'src/main.tsx',
|
|
40
36
|
e2eTestRunner: 'none',
|
|
41
|
-
unitTestRunner: '
|
|
37
|
+
unitTestRunner: 'jest',
|
|
42
38
|
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',
|
|
50
39
|
});
|
|
51
40
|
});
|
|
52
41
|
|
|
@@ -56,17 +45,12 @@ describe('Normalize Options', () => {
|
|
|
56
45
|
e2eTestRunner: 'none',
|
|
57
46
|
install: false,
|
|
58
47
|
projectNameAndRootFormat: 'as-provided',
|
|
59
|
-
linter: Linter.None,
|
|
60
|
-
unitTestRunner: 'none',
|
|
61
|
-
bundler: 'vite',
|
|
62
48
|
};
|
|
63
49
|
const options = await normalizeOptions(appTree, schema);
|
|
64
50
|
expect(options).toEqual({
|
|
65
|
-
addPlugin: true,
|
|
66
51
|
androidProjectRoot: 'myApp/android',
|
|
67
52
|
appProjectRoot: 'myApp',
|
|
68
53
|
className: 'MyApp',
|
|
69
|
-
fileName: 'my-app',
|
|
70
54
|
displayName: 'MyApp',
|
|
71
55
|
iosProjectRoot: 'myApp/ios',
|
|
72
56
|
lowerCaseName: 'myapp',
|
|
@@ -76,16 +60,8 @@ describe('Normalize Options', () => {
|
|
|
76
60
|
projectNameAndRootFormat: 'as-provided',
|
|
77
61
|
entryFile: 'src/main.tsx',
|
|
78
62
|
e2eTestRunner: 'none',
|
|
79
|
-
unitTestRunner: '
|
|
63
|
+
unitTestRunner: 'jest',
|
|
80
64
|
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',
|
|
89
65
|
});
|
|
90
66
|
});
|
|
91
67
|
|
|
@@ -96,17 +72,12 @@ describe('Normalize Options', () => {
|
|
|
96
72
|
e2eTestRunner: 'none',
|
|
97
73
|
install: false,
|
|
98
74
|
projectNameAndRootFormat: 'as-provided',
|
|
99
|
-
linter: Linter.None,
|
|
100
|
-
unitTestRunner: 'none',
|
|
101
|
-
bundler: 'vite',
|
|
102
75
|
};
|
|
103
76
|
const options = await normalizeOptions(appTree, schema);
|
|
104
77
|
expect(options).toEqual({
|
|
105
|
-
addPlugin: true,
|
|
106
78
|
androidProjectRoot: 'directory/my-app/android',
|
|
107
79
|
appProjectRoot: 'directory/my-app',
|
|
108
80
|
className: 'MyApp',
|
|
109
|
-
fileName: 'my-app',
|
|
110
81
|
displayName: 'MyApp',
|
|
111
82
|
iosProjectRoot: 'directory/my-app/ios',
|
|
112
83
|
lowerCaseName: 'myapp',
|
|
@@ -117,16 +88,8 @@ describe('Normalize Options', () => {
|
|
|
117
88
|
projectNameAndRootFormat: 'as-provided',
|
|
118
89
|
entryFile: 'src/main.tsx',
|
|
119
90
|
e2eTestRunner: 'none',
|
|
120
|
-
unitTestRunner: '
|
|
91
|
+
unitTestRunner: 'jest',
|
|
121
92
|
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',
|
|
130
93
|
});
|
|
131
94
|
});
|
|
132
95
|
|
|
@@ -136,36 +99,23 @@ describe('Normalize Options', () => {
|
|
|
136
99
|
e2eTestRunner: 'none',
|
|
137
100
|
install: false,
|
|
138
101
|
projectNameAndRootFormat: 'as-provided',
|
|
139
|
-
linter: Linter.None,
|
|
140
|
-
unitTestRunner: 'none',
|
|
141
|
-
bundler: 'vite',
|
|
142
102
|
};
|
|
143
103
|
const options = await normalizeOptions(appTree, schema);
|
|
144
104
|
expect(options).toEqual({
|
|
145
|
-
addPlugin: true,
|
|
146
105
|
androidProjectRoot: 'directory/my-app/android',
|
|
147
106
|
appProjectRoot: 'directory/my-app',
|
|
148
107
|
className: 'DirectoryMyApp',
|
|
149
|
-
fileName: 'directory/my-app',
|
|
150
108
|
displayName: 'DirectoryMyApp',
|
|
151
109
|
iosProjectRoot: 'directory/my-app/ios',
|
|
152
110
|
lowerCaseName: 'directorymyapp',
|
|
153
|
-
name: 'my-app',
|
|
111
|
+
name: 'directory/my-app',
|
|
154
112
|
parsedTags: [],
|
|
155
|
-
projectName: 'my-app',
|
|
113
|
+
projectName: 'directory/my-app',
|
|
156
114
|
projectNameAndRootFormat: 'as-provided',
|
|
157
115
|
entryFile: 'src/main.tsx',
|
|
158
116
|
e2eTestRunner: 'none',
|
|
159
|
-
unitTestRunner: '
|
|
117
|
+
unitTestRunner: 'jest',
|
|
160
118
|
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',
|
|
169
119
|
});
|
|
170
120
|
});
|
|
171
121
|
|
|
@@ -176,17 +126,12 @@ describe('Normalize Options', () => {
|
|
|
176
126
|
e2eTestRunner: 'none',
|
|
177
127
|
install: false,
|
|
178
128
|
projectNameAndRootFormat: 'as-provided',
|
|
179
|
-
linter: Linter.None,
|
|
180
|
-
unitTestRunner: 'none',
|
|
181
|
-
bundler: 'vite',
|
|
182
129
|
};
|
|
183
130
|
const options = await normalizeOptions(appTree, schema);
|
|
184
131
|
expect(options).toEqual({
|
|
185
|
-
addPlugin: true,
|
|
186
132
|
androidProjectRoot: 'my-app/android',
|
|
187
133
|
appProjectRoot: 'my-app',
|
|
188
134
|
className: 'MyApp',
|
|
189
|
-
fileName: 'my-app',
|
|
190
135
|
displayName: 'My App',
|
|
191
136
|
iosProjectRoot: 'my-app/ios',
|
|
192
137
|
lowerCaseName: 'myapp',
|
|
@@ -196,16 +141,8 @@ describe('Normalize Options', () => {
|
|
|
196
141
|
projectNameAndRootFormat: 'as-provided',
|
|
197
142
|
entryFile: 'src/main.tsx',
|
|
198
143
|
e2eTestRunner: 'none',
|
|
199
|
-
unitTestRunner: '
|
|
144
|
+
unitTestRunner: 'jest',
|
|
200
145
|
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',
|
|
209
146
|
});
|
|
210
147
|
});
|
|
211
148
|
});
|
|
@@ -9,15 +9,13 @@ export interface Schema {
|
|
|
9
9
|
directory?: string;
|
|
10
10
|
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
11
|
tags?: string;
|
|
12
|
-
unitTestRunner
|
|
12
|
+
unitTestRunner?: 'jest' | 'none';
|
|
13
13
|
pascalCaseFiles?: boolean;
|
|
14
14
|
classComponent?: boolean;
|
|
15
15
|
js?: boolean;
|
|
16
|
-
linter
|
|
16
|
+
linter?: Linter;
|
|
17
17
|
setParserOptionsProject?: boolean;
|
|
18
|
-
e2eTestRunner
|
|
19
|
-
bundler: 'webpack' | 'vite'; // default is webpack
|
|
18
|
+
e2eTestRunner?: 'detox' | 'none';
|
|
20
19
|
install: boolean; // default is true
|
|
21
20
|
skipPackageJson?: boolean; //default is false
|
|
22
|
-
addPlugin?: boolean;
|
|
23
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxReactNativeApplication",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "http://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"],
|
|
52
52
|
"default": "eslint"
|
|
53
53
|
},
|
|
54
54
|
"unitTestRunner": {
|
|
@@ -75,28 +75,20 @@
|
|
|
75
75
|
"e2eTestRunner": {
|
|
76
76
|
"description": "Adds the specified e2e test runner.",
|
|
77
77
|
"type": "string",
|
|
78
|
-
"enum": ["
|
|
79
|
-
"default": "
|
|
78
|
+
"enum": ["detox", "none"],
|
|
79
|
+
"default": "detox"
|
|
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
|
+
"default": true,
|
|
85
|
+
"x-priority": "internal"
|
|
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"
|
|
100
92
|
}
|
|
101
93
|
},
|
|
102
94
|
"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 v18.
|
|
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 v18.
|
|
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 v18.
|
|
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": "http://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 v18."
|
|
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 v18."
|
|
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 v18."
|
|
76
76
|
},
|
|
77
77
|
"classComponent": {
|
|
78
78
|
"type": "boolean",
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
export interface CreateComponentStoriesFileSchema {
|
|
4
|
+
project: string;
|
|
5
|
+
componentPath: string;
|
|
6
|
+
skipFormat?: boolean;
|
|
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;
|
|
7
10
|
export declare function componentStoryGenerator(host: Tree, schema: CreateComponentStoriesFileSchema): Promise<void>;
|
|
8
11
|
export default componentStoryGenerator;
|
|
@@ -1,15 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.componentStoryGenerator = void 0;
|
|
3
|
+
exports.componentStoryGenerator = exports.findPropsAndGenerateFile = exports.createComponentStoriesFile = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const ast_utils_1 = require("@nx/react/src/utils/ast-utils");
|
|
6
|
+
const component_props_1 = require("@nx/react/src/utils/component-props");
|
|
7
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
8
|
+
let tsModule;
|
|
9
|
+
function createComponentStoriesFile(host, { project, componentPath }) {
|
|
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;
|
|
10
69
|
async function componentStoryGenerator(host, schema) {
|
|
11
|
-
|
|
12
|
-
|
|
70
|
+
createComponentStoriesFile(host, schema);
|
|
71
|
+
if (!schema.skipFormat) {
|
|
72
|
+
await (0, devkit_1.formatFiles)(host);
|
|
73
|
+
}
|
|
13
74
|
}
|
|
14
75
|
exports.componentStoryGenerator = componentStoryGenerator;
|
|
15
76
|
exports.default = componentStoryGenerator;
|