@nx/react-native 0.0.0-pr-22179-271588f
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 +48 -0
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/executors.json +59 -0
- package/generators.json +58 -0
- package/index.d.ts +5 -0
- package/index.js +13 -0
- package/migrations.json +632 -0
- package/package.json +57 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/jest/svg-mock.d.ts +0 -0
- package/plugins/jest/svg-mock.js +3 -0
- package/plugins/metro-resolver.d.ts +1 -0
- package/plugins/metro-resolver.js +136 -0
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +162 -0
- package/plugins/with-nx-metro.d.ts +8 -0
- package/plugins/with-nx-metro.js +31 -0
- package/project.json +54 -0
- package/src/executors/build-android/build-android.impl.d.ts +6 -0
- package/src/executors/build-android/build-android.impl.js +48 -0
- package/src/executors/build-android/build-android.impl.ts +69 -0
- package/src/executors/build-android/schema.d.ts +14 -0
- package/src/executors/build-android/schema.json +81 -0
- package/src/executors/build-ios/build-ios.impl.d.ts +6 -0
- package/src/executors/build-ios/build-ios.impl.js +55 -0
- package/src/executors/build-ios/build-ios.impl.ts +77 -0
- package/src/executors/build-ios/schema.d.ts +17 -0
- package/src/executors/build-ios/schema.json +91 -0
- package/src/executors/bundle/bundle.impl.d.ts +6 -0
- package/src/executors/bundle/bundle.impl.js +56 -0
- package/src/executors/bundle/bundle.impl.ts +77 -0
- package/src/executors/bundle/schema.d.ts +16 -0
- package/src/executors/bundle/schema.json +92 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +9 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +13 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +22 -0
- package/src/executors/ensure-symlink/schema.json +11 -0
- package/src/executors/pod-install/pod-install.impl.d.ts +6 -0
- package/src/executors/pod-install/pod-install.impl.js +11 -0
- package/src/executors/pod-install/pod-install.impl.ts +21 -0
- package/src/executors/pod-install/schema.d.ts +6 -0
- package/src/executors/pod-install/schema.json +33 -0
- package/src/executors/run-android/run-android.impl.d.ts +6 -0
- package/src/executors/run-android/run-android.impl.js +66 -0
- package/src/executors/run-android/run-android.impl.ts +94 -0
- package/src/executors/run-android/schema.d.ts +13 -0
- package/src/executors/run-android/schema.json +100 -0
- package/src/executors/run-ios/run-ios.impl.d.ts +6 -0
- package/src/executors/run-ios/run-ios.impl.js +65 -0
- package/src/executors/run-ios/run-ios.impl.ts +92 -0
- package/src/executors/run-ios/schema.d.ts +7 -0
- package/src/executors/run-ios/schema.json +96 -0
- package/src/executors/start/lib/is-packager-running.d.ts +1 -0
- package/src/executors/start/lib/is-packager-running.js +15 -0
- package/src/executors/start/schema.d.ts +7 -0
- package/src/executors/start/schema.json +28 -0
- package/src/executors/start/start.impl.d.ts +10 -0
- package/src/executors/start/start.impl.js +87 -0
- package/src/executors/start/start.impl.ts +111 -0
- package/src/executors/storybook/schema.d.ts +5 -0
- package/src/executors/storybook/schema.json +29 -0
- package/src/executors/storybook/storybook.impl.d.ts +10 -0
- package/src/executors/storybook/storybook.impl.js +51 -0
- package/src/executors/storybook/storybook.impl.ts +85 -0
- package/src/executors/sync-deps/schema.d.ts +5 -0
- package/src/executors/sync-deps/schema.json +33 -0
- package/src/executors/sync-deps/sync-deps.impl.d.ts +9 -0
- package/src/executors/sync-deps/sync-deps.impl.js +78 -0
- package/src/executors/sync-deps/sync-deps.impl.ts +140 -0
- 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.d.ts +5 -0
- package/src/generators/application/application.js +87 -0
- package/src/generators/application/application.spec.ts +258 -0
- package/src/generators/application/files/app/.babelrc.js.template +23 -0
- package/src/generators/application/files/app/Gemfile.template +7 -0
- package/src/generators/application/files/app/android/app/build.gradle.template +119 -0
- package/src/generators/application/files/app/android/app/debug.keystore +0 -0
- package/src/generators/application/files/app/android/app/proguard-rules.pro +10 -0
- package/src/generators/application/files/app/android/app/src/androidTest/java/com/__lowerCaseName__/DetoxTest.java.template +30 -0
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +10 -0
- package/src/generators/application/files/app/android/app/src/main/AndroidManifest.xml.template +26 -0
- 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/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/src/generators/application/files/app/android/app/src/main/res/values/strings.xml.template +3 -0
- package/src/generators/application/files/app/android/app/src/main/res/values/styles.xml +9 -0
- package/src/generators/application/files/app/android/app/src/main/res/xml/network_security_config.xml +7 -0
- package/src/generators/application/files/app/android/build.gradle.template +21 -0
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/src/generators/application/files/app/android/gradle.properties +41 -0
- package/src/generators/application/files/app/android/gradlew.bat +92 -0
- package/src/generators/application/files/app/android/gradlew.template +249 -0
- package/src/generators/application/files/app/android/settings.gradle.template +4 -0
- package/src/generators/application/files/app/app.json.template +4 -0
- package/src/generators/application/files/app/ios/.xcode.env.template +12 -0
- package/src/generators/application/files/app/ios/Podfile.template +55 -0
- package/src/generators/application/files/app/ios/__className__/AppDelegate.h +6 -0
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +31 -0
- package/src/generators/application/files/app/ios/__className__/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/src/generators/application/files/app/ios/__className__/Images.xcassets/Contents.json +6 -0
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +52 -0
- package/src/generators/application/files/app/ios/__className__/LaunchScreen.storyboard.template +47 -0
- package/src/generators/application/files/app/ios/__className__/main.m +10 -0
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +684 -0
- package/src/generators/application/files/app/ios/__className__.xcodeproj/xcshareddata/xcschemes/__className__.xcscheme.template +88 -0
- package/src/generators/application/files/app/ios/__className__.xcworkspace/contents.xcworkspacedata +10 -0
- package/src/generators/application/files/app/ios/__className__Tests/Info.plist +24 -0
- package/src/generators/application/files/app/ios/__className__Tests/__className__Tests.m +66 -0
- package/src/generators/application/files/app/metro.config.js.template +31 -0
- package/src/generators/application/files/app/package.json.template +14 -0
- package/src/generators/application/files/app/src/app/App.spec.tsx.template +9 -0
- package/src/generators/application/files/app/src/app/App.tsx.template +731 -0
- package/src/generators/application/files/app/src/main.tsx.template +4 -0
- package/src/generators/application/files/app/test-setup.ts.template +1 -0
- package/src/generators/application/files/app/tsconfig.app.json.template +10 -0
- package/src/generators/application/files/app/tsconfig.json.template +19 -0
- 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.d.ts +3 -0
- package/src/generators/application/lib/add-project.js +91 -0
- package/src/generators/application/lib/create-application-files.d.ts +3 -0
- package/src/generators/application/lib/create-application-files.js +24 -0
- package/src/generators/application/lib/normalize-options.d.ts +17 -0
- package/src/generators/application/lib/normalize-options.js +47 -0
- package/src/generators/application/lib/normalize-options.spec.ts +196 -0
- package/src/generators/application/schema.d.ts +23 -0
- package/src/generators/application/schema.json +103 -0
- package/src/generators/component/component.d.ts +5 -0
- package/src/generators/component/component.js +64 -0
- package/src/generators/component/component.spec.ts +127 -0
- package/src/generators/component/files/__fileName__.spec.tsx__tmpl__ +11 -0
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +32 -0
- package/src/generators/component/lib/add-import.d.ts +3 -0
- package/src/generators/component/lib/add-import.js +33 -0
- package/src/generators/component/lib/normalize-options.d.ts +10 -0
- package/src/generators/component/lib/normalize-options.js +50 -0
- package/src/generators/component/schema.d.ts +24 -0
- package/src/generators/component/schema.json +85 -0
- package/src/generators/component-story/component-story.d.ts +8 -0
- package/src/generators/component-story/component-story.js +15 -0
- package/src/generators/component-story/schema.d.ts +6 -0
- package/src/generators/component-story/schema.json +42 -0
- package/src/generators/init/init.d.ts +6 -0
- package/src/generators/init/init.js +78 -0
- package/src/generators/init/init.spec.ts +38 -0
- package/src/generators/init/lib/add-git-ignore-entry.d.ts +2 -0
- package/src/generators/init/lib/add-git-ignore-entry.js +24 -0
- package/src/generators/init/lib/gitignore-entries.d.ts +1 -0
- package/src/generators/init/lib/gitignore-entries.js +74 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +35 -0
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/files/lib/README.md +7 -0
- package/src/generators/library/files/lib/package.json.template +4 -0
- package/src/generators/library/files/lib/src/index.ts.template +0 -0
- package/src/generators/library/files/lib/test-setup.ts.template +1 -0
- package/src/generators/library/files/lib/tsconfig.json.template +16 -0
- package/src/generators/library/files/lib/tsconfig.lib.json.template +9 -0
- package/src/generators/library/lib/normalize-options.d.ts +12 -0
- package/src/generators/library/lib/normalize-options.js +33 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +154 -0
- package/src/generators/library/library.spec.ts +420 -0
- package/src/generators/library/schema.d.ts +25 -0
- package/src/generators/library/schema.json +107 -0
- package/src/generators/stories/schema.d.ts +7 -0
- package/src/generators/stories/schema.json +58 -0
- package/src/generators/stories/stories.d.ts +8 -0
- package/src/generators/stories/stories.js +13 -0
- package/src/generators/storybook-configuration/configuration.d.ts +9 -0
- package/src/generators/storybook-configuration/configuration.js +26 -0
- package/src/generators/storybook-configuration/schema.d.ts +13 -0
- package/src/generators/storybook-configuration/schema.json +79 -0
- package/src/generators/upgrade-native/lib/create-native-files.d.ts +3 -0
- package/src/generators/upgrade-native/lib/create-native-files.js +14 -0
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +12 -0
- package/src/generators/upgrade-native/lib/normalize-options.js +27 -0
- package/src/generators/upgrade-native/schema.d.ts +9 -0
- package/src/generators/upgrade-native/schema.json +41 -0
- package/src/generators/upgrade-native/upgrade-native.d.ts +10 -0
- package/src/generators/upgrade-native/upgrade-native.js +31 -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-15-0-0/add-babel-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.js +9 -0
- package/src/migrations/update-15-0-0/add-babel-inputs.spec.ts +73 -0
- package/src/migrations/update-15-9-1/add-build-ios-target.d.ts +5 -0
- package/src/migrations/update-15-9-1/add-build-ios-target.js +29 -0
- package/src/migrations/update-15-9-1/add-build-ios-target.spec.ts +36 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +37 -0
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.d.ts +6 -0
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +21 -0
- package/src/migrations/update-16-6-0/add-depends-on.d.ts +6 -0
- package/src/migrations/update-16-6-0/add-depends-on.js +63 -0
- package/src/migrations/update-16-6-0/update-metro-config.d.ts +6 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +63 -0
- package/src/migrations/update-16-9-0/remove-types-react-native.d.ts +7 -0
- package/src/migrations/update-16-9-0/remove-types-react-native.js +13 -0
- 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 +2 -0
- package/src/utils/add-jest.js +48 -0
- package/src/utils/add-linting.d.ts +13 -0
- package/src/utils/add-linting.js +36 -0
- package/src/utils/add-linting.spec.ts +40 -0
- package/src/utils/chmod-android-gradle-files.d.ts +3 -0
- package/src/utils/chmod-android-gradle-files.js +27 -0
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +30 -0
- package/src/utils/ensure-node-modules-symlink.d.ts +9 -0
- package/src/utils/ensure-node-modules-symlink.js +28 -0
- package/src/utils/ensure-node-modules-symlink.spec.ts +108 -0
- package/src/utils/find-all-npm-dependencies.d.ts +2 -0
- package/src/utils/find-all-npm-dependencies.js +27 -0
- package/src/utils/find-all-npm-dependencies.spec.ts +103 -0
- package/src/utils/format-file.d.ts +1 -0
- package/src/utils/format-file.js +16 -0
- package/src/utils/get-cli-options.d.ts +8 -0
- package/src/utils/get-cli-options.js +33 -0
- package/src/utils/pod-install-task.d.ts +18 -0
- package/src/utils/pod-install-task.js +73 -0
- package/src/utils/testing-generators.d.ts +3 -0
- package/src/utils/testing-generators.js +32 -0
- package/src/utils/versions.d.ts +17 -0
- package/src/utils/versions.js +20 -0
- package/typings/svg.d.ts +7 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readJson,
|
|
3
|
+
readProjectConfiguration,
|
|
4
|
+
Tree,
|
|
5
|
+
updateJson,
|
|
6
|
+
} from '@nx/devkit';
|
|
7
|
+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
8
|
+
import libraryGenerator from './library';
|
|
9
|
+
import { Linter } from '@nx/eslint';
|
|
10
|
+
import { Schema } from './schema';
|
|
11
|
+
|
|
12
|
+
describe('lib', () => {
|
|
13
|
+
let appTree: Tree;
|
|
14
|
+
|
|
15
|
+
const defaultSchema: Schema = {
|
|
16
|
+
name: 'my-lib',
|
|
17
|
+
linter: Linter.EsLint,
|
|
18
|
+
skipFormat: false,
|
|
19
|
+
skipTsConfig: false,
|
|
20
|
+
unitTestRunner: 'jest',
|
|
21
|
+
strict: true,
|
|
22
|
+
projectNameAndRootFormat: 'as-provided',
|
|
23
|
+
addPlugin: true,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
appTree = createTreeWithEmptyWorkspace();
|
|
28
|
+
appTree.write('.gitignore', '');
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('not nested', () => {
|
|
32
|
+
it('should update root tsconfig.base.json', async () => {
|
|
33
|
+
await libraryGenerator(appTree, defaultSchema);
|
|
34
|
+
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
35
|
+
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
36
|
+
'my-lib/src/index.ts',
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should update root tsconfig.json when no tsconfig.base.json', async () => {
|
|
41
|
+
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
42
|
+
|
|
43
|
+
await libraryGenerator(appTree, defaultSchema);
|
|
44
|
+
|
|
45
|
+
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
|
46
|
+
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
47
|
+
'my-lib/src/index.ts',
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should update root tsconfig.base.json (no existing path mappings)', async () => {
|
|
52
|
+
updateJson(appTree, 'tsconfig.base.json', (json) => {
|
|
53
|
+
json.compilerOptions.paths = undefined;
|
|
54
|
+
return json;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
await libraryGenerator(appTree, defaultSchema);
|
|
58
|
+
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
59
|
+
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
60
|
+
'my-lib/src/index.ts',
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should create a local tsconfig.json', async () => {
|
|
65
|
+
await libraryGenerator(appTree, defaultSchema);
|
|
66
|
+
|
|
67
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
68
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
|
69
|
+
expect(tsconfigJson.references).toEqual([
|
|
70
|
+
{
|
|
71
|
+
path: './tsconfig.lib.json',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
path: './tsconfig.spec.json',
|
|
75
|
+
},
|
|
76
|
+
]);
|
|
77
|
+
expect(
|
|
78
|
+
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
|
79
|
+
).toEqual(true);
|
|
80
|
+
expect(tsconfigJson.compilerOptions.strict).toEqual(true);
|
|
81
|
+
expect(tsconfigJson.compilerOptions.noImplicitReturns).toEqual(true);
|
|
82
|
+
expect(tsconfigJson.compilerOptions.noFallthroughCasesInSwitch).toEqual(
|
|
83
|
+
true
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
|
|
88
|
+
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
89
|
+
|
|
90
|
+
await libraryGenerator(appTree, defaultSchema);
|
|
91
|
+
|
|
92
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
93
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should extend the local tsconfig.json with tsconfig.spec.json', async () => {
|
|
97
|
+
await libraryGenerator(appTree, defaultSchema);
|
|
98
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.spec.json');
|
|
99
|
+
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should extend the local tsconfig.json with tsconfig.lib.json', async () => {
|
|
103
|
+
await libraryGenerator(appTree, defaultSchema);
|
|
104
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.lib.json');
|
|
105
|
+
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('nested', () => {
|
|
110
|
+
it('should update nx.json', async () => {
|
|
111
|
+
await libraryGenerator(appTree, {
|
|
112
|
+
...defaultSchema,
|
|
113
|
+
directory: 'my-dir',
|
|
114
|
+
tags: 'one',
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
118
|
+
expect(projectConfiguration).toMatchObject({
|
|
119
|
+
tags: ['one'],
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
await libraryGenerator(appTree, {
|
|
123
|
+
...defaultSchema,
|
|
124
|
+
name: 'my-lib2',
|
|
125
|
+
directory: 'my-dir2',
|
|
126
|
+
tags: 'one,two',
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const lib2ProjectConfiguration = readProjectConfiguration(
|
|
130
|
+
appTree,
|
|
131
|
+
'my-lib2'
|
|
132
|
+
);
|
|
133
|
+
expect(lib2ProjectConfiguration).toMatchObject({
|
|
134
|
+
tags: ['one', 'two'],
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should update root tsconfig.base.json', async () => {
|
|
139
|
+
await libraryGenerator(appTree, {
|
|
140
|
+
...defaultSchema,
|
|
141
|
+
directory: 'my-dir',
|
|
142
|
+
});
|
|
143
|
+
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
144
|
+
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
145
|
+
'my-dir/src/index.ts',
|
|
146
|
+
]);
|
|
147
|
+
expect(
|
|
148
|
+
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
|
149
|
+
).toBeUndefined();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should update root tsconfig.json when no tsconfig.base.json', async () => {
|
|
153
|
+
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
154
|
+
|
|
155
|
+
await libraryGenerator(appTree, {
|
|
156
|
+
...defaultSchema,
|
|
157
|
+
directory: 'my-dir',
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
|
161
|
+
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
162
|
+
'my-dir/src/index.ts',
|
|
163
|
+
]);
|
|
164
|
+
expect(
|
|
165
|
+
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
|
166
|
+
).toBeUndefined();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('should create a local tsconfig.json', async () => {
|
|
170
|
+
await libraryGenerator(appTree, {
|
|
171
|
+
...defaultSchema,
|
|
172
|
+
directory: 'my-dir',
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
176
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
|
177
|
+
expect(tsconfigJson.references).toEqual([
|
|
178
|
+
{
|
|
179
|
+
path: './tsconfig.lib.json',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
path: './tsconfig.spec.json',
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
|
|
188
|
+
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
189
|
+
|
|
190
|
+
await libraryGenerator(appTree, {
|
|
191
|
+
...defaultSchema,
|
|
192
|
+
directory: 'my-dir',
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
196
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('--unit-test-runner none', () => {
|
|
201
|
+
it('should not generate test configuration', async () => {
|
|
202
|
+
await libraryGenerator(appTree, {
|
|
203
|
+
...defaultSchema,
|
|
204
|
+
unitTestRunner: 'none',
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(appTree.exists('my-lib/tsconfig.spec.json')).toBeFalsy();
|
|
208
|
+
expect(appTree.exists('my-lib/jest.config.ts')).toBeFalsy();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('should generate test configuration', async () => {
|
|
212
|
+
await libraryGenerator(appTree, {
|
|
213
|
+
...defaultSchema,
|
|
214
|
+
unitTestRunner: 'jest',
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
expect(appTree.read('my-lib/tsconfig.spec.json', 'utf-8'))
|
|
218
|
+
.toMatchInlineSnapshot(`
|
|
219
|
+
"{
|
|
220
|
+
"extends": "./tsconfig.json",
|
|
221
|
+
"compilerOptions": {
|
|
222
|
+
"outDir": "../dist/out-tsc",
|
|
223
|
+
"module": "commonjs",
|
|
224
|
+
"types": ["jest", "node"]
|
|
225
|
+
},
|
|
226
|
+
"include": [
|
|
227
|
+
"jest.config.ts",
|
|
228
|
+
"src/**/*.test.ts",
|
|
229
|
+
"src/**/*.spec.ts",
|
|
230
|
+
"src/**/*.test.tsx",
|
|
231
|
+
"src/**/*.spec.tsx",
|
|
232
|
+
"src/**/*.test.js",
|
|
233
|
+
"src/**/*.spec.js",
|
|
234
|
+
"src/**/*.test.jsx",
|
|
235
|
+
"src/**/*.spec.jsx",
|
|
236
|
+
"src/**/*.d.ts"
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
"
|
|
240
|
+
`);
|
|
241
|
+
expect(appTree.read('my-lib/jest.config.ts', 'utf-8'))
|
|
242
|
+
.toMatchInlineSnapshot(`
|
|
243
|
+
"module.exports = {
|
|
244
|
+
displayName: 'my-lib',
|
|
245
|
+
preset: 'react-native',
|
|
246
|
+
resolver: '@nx/jest/plugins/resolver',
|
|
247
|
+
moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
|
|
248
|
+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
|
|
249
|
+
moduleNameMapper: {
|
|
250
|
+
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
|
251
|
+
},
|
|
252
|
+
transform: {
|
|
253
|
+
'^.+.(js|ts|tsx)$': [
|
|
254
|
+
'babel-jest',
|
|
255
|
+
{
|
|
256
|
+
configFile: __dirname + '/.babelrc.js',
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
'^.+.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
|
|
260
|
+
'react-native/jest/assetFileTransformer.js'
|
|
261
|
+
),
|
|
262
|
+
},
|
|
263
|
+
coverageDirectory: '../coverage/my-lib',
|
|
264
|
+
};
|
|
265
|
+
"
|
|
266
|
+
`);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe('--buildable', () => {
|
|
271
|
+
it('should have a builder defined', async () => {
|
|
272
|
+
await libraryGenerator(appTree, {
|
|
273
|
+
...defaultSchema,
|
|
274
|
+
buildable: true,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
278
|
+
|
|
279
|
+
expect(projectConfiguration.targets.build).toBeDefined();
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
describe('--publishable', () => {
|
|
284
|
+
it('should add build architect', async () => {
|
|
285
|
+
await libraryGenerator(appTree, {
|
|
286
|
+
...defaultSchema,
|
|
287
|
+
publishable: true,
|
|
288
|
+
importPath: '@proj/my-lib',
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
292
|
+
|
|
293
|
+
expect(projectConfiguration.targets.build).toMatchObject({
|
|
294
|
+
executor: '@nx/rollup:rollup',
|
|
295
|
+
outputs: ['{options.outputPath}'],
|
|
296
|
+
options: {
|
|
297
|
+
external: ['react/jsx-runtime', 'react-native', 'react', 'react-dom'],
|
|
298
|
+
entryFile: 'my-lib/src/index.ts',
|
|
299
|
+
outputPath: 'dist/my-lib',
|
|
300
|
+
project: 'my-lib/package.json',
|
|
301
|
+
tsConfig: 'my-lib/tsconfig.lib.json',
|
|
302
|
+
rollupConfig: '@nx/react/plugins/bundle-rollup',
|
|
303
|
+
},
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('should fail if no importPath is provided with publishable', async () => {
|
|
308
|
+
expect.assertions(1);
|
|
309
|
+
|
|
310
|
+
try {
|
|
311
|
+
await libraryGenerator(appTree, {
|
|
312
|
+
...defaultSchema,
|
|
313
|
+
directory: 'my-dir',
|
|
314
|
+
publishable: true,
|
|
315
|
+
});
|
|
316
|
+
} catch (e) {
|
|
317
|
+
expect(e.message).toContain(
|
|
318
|
+
'For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)'
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it('should add package.json and .babelrc', async () => {
|
|
324
|
+
await libraryGenerator(appTree, {
|
|
325
|
+
...defaultSchema,
|
|
326
|
+
publishable: true,
|
|
327
|
+
importPath: '@proj/my-lib',
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const packageJson = readJson(appTree, 'my-lib/package.json');
|
|
331
|
+
expect(packageJson.name).toEqual('@proj/my-lib');
|
|
332
|
+
expect(appTree.exists('my-lib/.babelrc'));
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
describe('--js', () => {
|
|
337
|
+
it('should generate JS files', async () => {
|
|
338
|
+
await libraryGenerator(appTree, {
|
|
339
|
+
...defaultSchema,
|
|
340
|
+
js: true,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
expect(appTree.exists('my-lib/src/index.js')).toBe(true);
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
describe('--importPath', () => {
|
|
348
|
+
it('should update the package.json & tsconfig with the given import path', async () => {
|
|
349
|
+
await libraryGenerator(appTree, {
|
|
350
|
+
...defaultSchema,
|
|
351
|
+
publishable: true,
|
|
352
|
+
directory: 'my-dir',
|
|
353
|
+
importPath: '@myorg/lib',
|
|
354
|
+
});
|
|
355
|
+
const packageJson = readJson(appTree, 'my-dir/package.json');
|
|
356
|
+
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
357
|
+
|
|
358
|
+
expect(packageJson.name).toBe('@myorg/lib');
|
|
359
|
+
expect(
|
|
360
|
+
tsconfigJson.compilerOptions.paths[packageJson.name]
|
|
361
|
+
).toBeDefined();
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('should fail if the same importPath has already been used', async () => {
|
|
365
|
+
await libraryGenerator(appTree, {
|
|
366
|
+
...defaultSchema,
|
|
367
|
+
name: 'my-lib1',
|
|
368
|
+
publishable: true,
|
|
369
|
+
importPath: '@myorg/lib',
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
try {
|
|
373
|
+
await libraryGenerator(appTree, {
|
|
374
|
+
...defaultSchema,
|
|
375
|
+
name: 'my-lib2',
|
|
376
|
+
publishable: true,
|
|
377
|
+
importPath: '@myorg/lib',
|
|
378
|
+
});
|
|
379
|
+
} catch (e) {
|
|
380
|
+
expect(e.message).toContain(
|
|
381
|
+
'You already have a library using the import path'
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
expect.assertions(1);
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
describe('--no-strict', () => {
|
|
390
|
+
it('should not add options for strict mode', async () => {
|
|
391
|
+
await libraryGenerator(appTree, {
|
|
392
|
+
...defaultSchema,
|
|
393
|
+
strict: false,
|
|
394
|
+
});
|
|
395
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
396
|
+
|
|
397
|
+
expect(
|
|
398
|
+
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
|
399
|
+
).not.toBeDefined();
|
|
400
|
+
expect(tsconfigJson.compilerOptions.strict).not.toBeDefined();
|
|
401
|
+
expect(tsconfigJson.compilerOptions.noImplicitReturns).not.toBeDefined();
|
|
402
|
+
expect(
|
|
403
|
+
tsconfigJson.compilerOptions.noFallthroughCasesInSwitch
|
|
404
|
+
).not.toBeDefined();
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
describe('--skipPackageJson', () => {
|
|
409
|
+
it('should not add or update dependencies when true', async () => {
|
|
410
|
+
const packageJsonBefore = readJson(appTree, 'package.json');
|
|
411
|
+
|
|
412
|
+
await libraryGenerator(appTree, {
|
|
413
|
+
...defaultSchema,
|
|
414
|
+
skipPackageJson: true,
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
|
|
2
|
+
import type { Linter } from '@nx/eslint';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Same as the @nx/react library schema, except it removes keys: style, component, routing, appProject
|
|
6
|
+
*/
|
|
7
|
+
export interface Schema {
|
|
8
|
+
name: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
projectNameAndRootFormat?: ProjectNameAndRootFormat;
|
|
11
|
+
skipTsConfig: boolean;
|
|
12
|
+
skipFormat: boolean;
|
|
13
|
+
tags?: string;
|
|
14
|
+
pascalCaseFiles?: boolean;
|
|
15
|
+
unitTestRunner: 'jest' | 'none';
|
|
16
|
+
linter: Linter;
|
|
17
|
+
publishable?: boolean;
|
|
18
|
+
buildable?: boolean;
|
|
19
|
+
importPath?: string;
|
|
20
|
+
js?: boolean;
|
|
21
|
+
strict?: boolean;
|
|
22
|
+
setParserOptionsProject?: boolean;
|
|
23
|
+
skipPackageJson?: boolean; //default is false
|
|
24
|
+
addPlugin?: boolean;
|
|
25
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cli": "nx",
|
|
3
|
+
"$id": "NxReactNativeLibrary",
|
|
4
|
+
"$schema": "https://json-schema.org/schema",
|
|
5
|
+
"title": "Create a React Native Library for Nx",
|
|
6
|
+
"description": "Create a React Native Library for Nx.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g @nx/react-native:lib mylib --directory=myapp",
|
|
11
|
+
"description": "Generate `libs/myapp/mylib`"
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"properties": {
|
|
15
|
+
"name": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "Library name.",
|
|
18
|
+
"$default": {
|
|
19
|
+
"$source": "argv",
|
|
20
|
+
"index": 0
|
|
21
|
+
},
|
|
22
|
+
"x-prompt": "What name would you like to use for the library?",
|
|
23
|
+
"pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
|
|
24
|
+
},
|
|
25
|
+
"directory": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "A directory where the lib is placed.",
|
|
28
|
+
"alias": "dir",
|
|
29
|
+
"x-priority": "important"
|
|
30
|
+
},
|
|
31
|
+
"projectNameAndRootFormat": {
|
|
32
|
+
"description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
|
|
33
|
+
"type": "string",
|
|
34
|
+
"enum": ["as-provided", "derived"]
|
|
35
|
+
},
|
|
36
|
+
"linter": {
|
|
37
|
+
"description": "The tool to use for running lint checks.",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"enum": ["eslint", "none"],
|
|
40
|
+
"default": "eslint"
|
|
41
|
+
},
|
|
42
|
+
"unitTestRunner": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"enum": ["jest", "none"],
|
|
45
|
+
"description": "Test runner to use for unit tests.",
|
|
46
|
+
"default": "jest"
|
|
47
|
+
},
|
|
48
|
+
"tags": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Add tags to the library (used for linting).",
|
|
51
|
+
"alias": "t"
|
|
52
|
+
},
|
|
53
|
+
"skipFormat": {
|
|
54
|
+
"description": "Skip formatting files.",
|
|
55
|
+
"type": "boolean",
|
|
56
|
+
"default": false,
|
|
57
|
+
"x-priority": "internal"
|
|
58
|
+
},
|
|
59
|
+
"skipTsConfig": {
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"default": false,
|
|
62
|
+
"description": "Do not update `tsconfig.json` for development experience.",
|
|
63
|
+
"x-priority": "internal"
|
|
64
|
+
},
|
|
65
|
+
"pascalCaseFiles": {
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"description": "Use pascal case component file name (e.g. `App.tsx`).",
|
|
68
|
+
"alias": "P",
|
|
69
|
+
"default": false
|
|
70
|
+
},
|
|
71
|
+
"publishable": {
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"description": "Create a publishable library."
|
|
74
|
+
},
|
|
75
|
+
"buildable": {
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"default": false,
|
|
78
|
+
"description": "Generate a buildable library."
|
|
79
|
+
},
|
|
80
|
+
"importPath": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"description": "The library name used to import it, like `@myorg/my-awesome-lib`."
|
|
83
|
+
},
|
|
84
|
+
"js": {
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
87
|
+
"default": false
|
|
88
|
+
},
|
|
89
|
+
"strict": {
|
|
90
|
+
"type": "boolean",
|
|
91
|
+
"description": "Whether to enable tsconfig strict mode or not.",
|
|
92
|
+
"default": true
|
|
93
|
+
},
|
|
94
|
+
"setParserOptionsProject": {
|
|
95
|
+
"type": "boolean",
|
|
96
|
+
"description": "Whether or not to configure the ESLint `parserOptions.project` option. We do not do this by default for lint performance reasons.",
|
|
97
|
+
"default": false
|
|
98
|
+
},
|
|
99
|
+
"skipPackageJson": {
|
|
100
|
+
"description": "Do not add dependencies to `package.json`.",
|
|
101
|
+
"type": "boolean",
|
|
102
|
+
"default": false,
|
|
103
|
+
"x-priority": "internal"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"required": ["name"]
|
|
107
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxReactNativeStorybookStories",
|
|
5
|
+
"title": "Generate React Native Storybook stories",
|
|
6
|
+
"description": "Generate stories/specs for all components declared in a React Native project.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"project": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"aliases": ["name", "projectName"],
|
|
12
|
+
"description": "Project for which to generate stories.",
|
|
13
|
+
"$default": {
|
|
14
|
+
"$source": "projectName",
|
|
15
|
+
"index": 0
|
|
16
|
+
},
|
|
17
|
+
"x-prompt": "For which project do you want to generate stories?",
|
|
18
|
+
"x-priority": "important"
|
|
19
|
+
},
|
|
20
|
+
"interactionTests": {
|
|
21
|
+
"type": "boolean",
|
|
22
|
+
"description": "Set up Storybook interaction tests.",
|
|
23
|
+
"x-prompt": "Do you want to set up Storybook interaction tests?",
|
|
24
|
+
"x-priority": "important",
|
|
25
|
+
"default": true
|
|
26
|
+
},
|
|
27
|
+
"js": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "Generate JavaScript files rather than TypeScript files.",
|
|
30
|
+
"default": false
|
|
31
|
+
},
|
|
32
|
+
"ignorePaths": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"description": "Paths to ignore when looking for components.",
|
|
35
|
+
"items": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Path to ignore."
|
|
38
|
+
},
|
|
39
|
+
"default": [
|
|
40
|
+
"*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"
|
|
41
|
+
],
|
|
42
|
+
"examples": [
|
|
43
|
+
"apps/my-app/src/not-stories/**",
|
|
44
|
+
"**/**/src/**/not-stories/**",
|
|
45
|
+
"libs/my-lib/**/*.something.ts",
|
|
46
|
+
"**/**/src/**/*.other.*",
|
|
47
|
+
"libs/my-lib/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"skipFormat": {
|
|
51
|
+
"description": "Skip formatting files.",
|
|
52
|
+
"type": "boolean",
|
|
53
|
+
"default": false,
|
|
54
|
+
"x-priority": "internal"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": ["project"]
|
|
58
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { StorybookStoriesSchema } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated This would be a direct pass through to @nx/react:stories generator.
|
|
5
|
+
* TODO (@xiongemi): remove this generator for v19
|
|
6
|
+
*/
|
|
7
|
+
export declare function storiesGenerator(host: Tree, schema: StorybookStoriesSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
8
|
+
export default storiesGenerator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storiesGenerator = void 0;
|
|
4
|
+
const react_1 = require("@nx/react");
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated This would be a direct pass through to @nx/react:stories generator.
|
|
7
|
+
* TODO (@xiongemi): remove this generator for v19
|
|
8
|
+
*/
|
|
9
|
+
async function storiesGenerator(host, schema) {
|
|
10
|
+
return (0, react_1.storiesGenerator)(host, schema);
|
|
11
|
+
}
|
|
12
|
+
exports.storiesGenerator = storiesGenerator;
|
|
13
|
+
exports.default = storiesGenerator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { StorybookConfigureSchema } from './schema';
|
|
3
|
+
export declare function storybookConfigurationGenerator(tree: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
4
|
+
/**
|
|
5
|
+
* This would be a direct pass through to @nx/react:storybook-configuration generator.
|
|
6
|
+
* @TODO (@xiongemi): remove this generator for v19
|
|
7
|
+
*/
|
|
8
|
+
export declare function storybookConfigurationGeneratorInternal(host: Tree, schema: StorybookConfigureSchema): Promise<import("@nx/devkit").GeneratorCallback>;
|
|
9
|
+
export default storybookConfigurationGenerator;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storybookConfigurationGeneratorInternal = exports.storybookConfigurationGenerator = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const react_1 = require("@nx/react");
|
|
6
|
+
function storybookConfigurationGenerator(tree, schema) {
|
|
7
|
+
return storybookConfigurationGeneratorInternal(tree, {
|
|
8
|
+
addPlugin: false,
|
|
9
|
+
...schema,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
|
|
13
|
+
/**
|
|
14
|
+
* This would be a direct pass through to @nx/react:storybook-configuration generator.
|
|
15
|
+
* @TODO (@xiongemi): remove this generator for v19
|
|
16
|
+
*/
|
|
17
|
+
async function storybookConfigurationGeneratorInternal(host, schema) {
|
|
18
|
+
devkit_1.logger.warn(`Please run 'nx run @nx/react:storybook-configuration ${schema.project}' instead.`);
|
|
19
|
+
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
20
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
21
|
+
nxJson.useInferencePlugins !== false;
|
|
22
|
+
schema.addPlugin ??= addPluginDefault;
|
|
23
|
+
return (0, react_1.storybookConfigurationGenerator)(host, schema);
|
|
24
|
+
}
|
|
25
|
+
exports.storybookConfigurationGeneratorInternal = storybookConfigurationGeneratorInternal;
|
|
26
|
+
exports.default = storybookConfigurationGenerator;
|