@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeComponentStory",
|
|
5
5
|
"title": "React native component story",
|
|
@@ -15,19 +15,27 @@
|
|
|
15
15
|
"$source": "projectName",
|
|
16
16
|
"index": 0
|
|
17
17
|
},
|
|
18
|
-
"x-prompt": "What's
|
|
18
|
+
"x-prompt": "What's name of the project where the component lives?",
|
|
19
|
+
"x-priority": "important"
|
|
19
20
|
},
|
|
20
21
|
"componentPath": {
|
|
21
22
|
"type": "string",
|
|
22
23
|
"description": "Relative path to the component file from the library root.",
|
|
23
24
|
"examples": ["lib/components"],
|
|
24
|
-
"x-prompt": "What's path of the component relative to the project's lib root?"
|
|
25
|
+
"x-prompt": "What's path of the component relative to the project's lib root?",
|
|
26
|
+
"x-priority": "important"
|
|
25
27
|
},
|
|
26
28
|
"skipFormat": {
|
|
27
29
|
"description": "Skip formatting files.",
|
|
28
30
|
"type": "boolean",
|
|
29
31
|
"default": false,
|
|
30
32
|
"x-priority": "internal"
|
|
33
|
+
},
|
|
34
|
+
"interactionTests": {
|
|
35
|
+
"type": "boolean",
|
|
36
|
+
"description": "Set up Storybook interaction tests.",
|
|
37
|
+
"default": true,
|
|
38
|
+
"x-priority": "important"
|
|
31
39
|
}
|
|
32
40
|
},
|
|
33
41
|
"required": ["project", "componentPath"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function reactNativeInitGenerator(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function reactNativeInitGeneratorInternal(host: Tree, schema: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export declare function updateDependencies(host: Tree, schema: Schema): GeneratorCallback;
|
|
5
6
|
export default reactNativeInitGenerator;
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDependencies = exports.reactNativeInitGenerator = void 0;
|
|
3
|
+
exports.updateDependencies = exports.reactNativeInitGeneratorInternal = exports.reactNativeInitGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
6
|
const plugin_1 = require("../../../plugins/plugin");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
8
|
const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
|
|
9
|
-
|
|
9
|
+
function reactNativeInitGenerator(host, schema) {
|
|
10
|
+
return reactNativeInitGeneratorInternal(host, {
|
|
11
|
+
addPlugin: false,
|
|
12
|
+
...schema,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.reactNativeInitGenerator = reactNativeInitGenerator;
|
|
16
|
+
async function reactNativeInitGeneratorInternal(host, schema) {
|
|
10
17
|
(0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
|
|
11
|
-
|
|
18
|
+
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
19
|
+
if (schema.addPlugin) {
|
|
12
20
|
addPlugin(host);
|
|
13
21
|
}
|
|
14
22
|
const tasks = [];
|
|
@@ -24,7 +32,7 @@ async function reactNativeInitGenerator(host, schema) {
|
|
|
24
32
|
}
|
|
25
33
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
26
34
|
}
|
|
27
|
-
exports.
|
|
35
|
+
exports.reactNativeInitGeneratorInternal = reactNativeInitGeneratorInternal;
|
|
28
36
|
function updateDependencies(host, schema) {
|
|
29
37
|
return (0, devkit_1.addDependenciesToPackageJson)(host, {
|
|
30
38
|
react: versions_1.reactVersion,
|
|
@@ -32,9 +40,6 @@ function updateDependencies(host, schema) {
|
|
|
32
40
|
'react-native': versions_1.reactNativeVersion,
|
|
33
41
|
}, {
|
|
34
42
|
'@nx/react-native': versions_1.nxVersion,
|
|
35
|
-
'@react-native-community/cli': versions_1.reactNativeCommunityCli,
|
|
36
|
-
'@react-native-community/cli-platform-android': versions_1.reactNativeCommunityCliAndroid,
|
|
37
|
-
'@react-native-community/cli-platform-ios': versions_1.reactNativeCommunityCliIos,
|
|
38
43
|
}, undefined, schema.keepExistingVersions);
|
|
39
44
|
}
|
|
40
45
|
exports.updateDependencies = updateDependencies;
|
|
@@ -61,6 +66,8 @@ function addPlugin(host) {
|
|
|
61
66
|
runAndroidTargetName: 'run-android',
|
|
62
67
|
buildIosTargetName: 'build-ios',
|
|
63
68
|
buildAndroidTargetName: 'build-android',
|
|
69
|
+
syncDepsTargetName: 'sync-deps',
|
|
70
|
+
upgradeTargetname: 'upgrade',
|
|
64
71
|
},
|
|
65
72
|
});
|
|
66
73
|
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
@@ -11,7 +11,9 @@ describe('init', () => {
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it('should add react native dependencies', async () => {
|
|
14
|
-
await reactNativeInitGenerator(tree, {
|
|
14
|
+
await reactNativeInitGenerator(tree, {
|
|
15
|
+
addPlugin: true,
|
|
16
|
+
});
|
|
15
17
|
const packageJson = readJson(tree, 'package.json');
|
|
16
18
|
expect(packageJson.dependencies['react']).toBeDefined();
|
|
17
19
|
expect(packageJson.dependencies['react-native']).toBeDefined();
|
|
@@ -24,7 +26,9 @@ describe('init', () => {
|
|
|
24
26
|
/node_modules
|
|
25
27
|
`
|
|
26
28
|
);
|
|
27
|
-
await reactNativeInitGenerator(tree, {
|
|
29
|
+
await reactNativeInitGenerator(tree, {
|
|
30
|
+
addPlugin: true,
|
|
31
|
+
});
|
|
28
32
|
|
|
29
33
|
const content = tree.read('/.gitignore').toString();
|
|
30
34
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = function (api) {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
presets: [
|
|
6
|
+
[
|
|
7
|
+
'@nx/react/babel',
|
|
8
|
+
{
|
|
9
|
+
runtime: 'automatic',
|
|
10
|
+
useBuiltIns: 'usage',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
],
|
|
14
|
+
plugins: [],
|
|
15
|
+
env: {
|
|
16
|
+
test: {
|
|
17
|
+
presets: [['module:@react-native/babel-preset', { "useTransformReactJSX": true }]],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -11,6 +11,7 @@ async function normalizeOptions(host, options) {
|
|
|
11
11
|
projectNameAndRootFormat: options.projectNameAndRootFormat,
|
|
12
12
|
callingGenerator: '@nx/react-native:library',
|
|
13
13
|
});
|
|
14
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
14
15
|
const parsedTags = options.tags
|
|
15
16
|
? options.tags.split(',').map((s) => s.trim())
|
|
16
17
|
: [];
|
|
@@ -9,8 +9,10 @@ const add_jest_1 = require("../../utils/add-jest");
|
|
|
9
9
|
const versions_1 = require("../../utils/versions");
|
|
10
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
11
11
|
const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
|
|
12
|
+
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
12
13
|
async function reactNativeLibraryGenerator(host, schema) {
|
|
13
14
|
return await reactNativeLibraryGeneratorInternal(host, {
|
|
15
|
+
addPlugin: false,
|
|
14
16
|
projectNameAndRootFormat: 'derived',
|
|
15
17
|
...schema,
|
|
16
18
|
});
|
|
@@ -45,7 +47,7 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
45
47
|
],
|
|
46
48
|
});
|
|
47
49
|
tasks.push(lintTask);
|
|
48
|
-
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson);
|
|
50
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin);
|
|
49
51
|
tasks.push(jestTask);
|
|
50
52
|
if (options.publishable || options.buildable) {
|
|
51
53
|
updateLibPackageNpmScope(host, options);
|
|
@@ -58,6 +60,9 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
|
58
60
|
if (!options.skipFormat) {
|
|
59
61
|
await (0, devkit_1.formatFiles)(host);
|
|
60
62
|
}
|
|
63
|
+
tasks.push(() => {
|
|
64
|
+
(0, log_show_project_command_1.logShowProjectCommand)(options.name);
|
|
65
|
+
});
|
|
61
66
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
62
67
|
}
|
|
63
68
|
exports.reactNativeLibraryGeneratorInternal = reactNativeLibraryGeneratorInternal;
|
|
@@ -20,6 +20,7 @@ describe('lib', () => {
|
|
|
20
20
|
unitTestRunner: 'jest',
|
|
21
21
|
strict: true,
|
|
22
22
|
projectNameAndRootFormat: 'as-provided',
|
|
23
|
+
addPlugin: true,
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
beforeEach(() => {
|
|
@@ -28,17 +29,6 @@ describe('lib', () => {
|
|
|
28
29
|
});
|
|
29
30
|
|
|
30
31
|
describe('not nested', () => {
|
|
31
|
-
it('should update project.json', async () => {
|
|
32
|
-
await libraryGenerator(appTree, { ...defaultSchema, tags: 'one,two' });
|
|
33
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
34
|
-
expect(projectConfiguration.root).toEqual('my-lib');
|
|
35
|
-
expect(projectConfiguration.targets.build).toBeUndefined();
|
|
36
|
-
expect(projectConfiguration.targets.lint).toEqual({
|
|
37
|
-
executor: '@nx/eslint:lint',
|
|
38
|
-
});
|
|
39
|
-
expect(projectConfiguration.tags).toEqual(['one', 'two']);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
32
|
it('should update root tsconfig.base.json', async () => {
|
|
43
33
|
await libraryGenerator(appTree, defaultSchema);
|
|
44
34
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
@@ -145,19 +135,6 @@ describe('lib', () => {
|
|
|
145
135
|
});
|
|
146
136
|
});
|
|
147
137
|
|
|
148
|
-
it('should update project.json', async () => {
|
|
149
|
-
await libraryGenerator(appTree, {
|
|
150
|
-
...defaultSchema,
|
|
151
|
-
directory: 'my-dir',
|
|
152
|
-
});
|
|
153
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
154
|
-
|
|
155
|
-
expect(projectConfiguration.root).toEqual('my-dir');
|
|
156
|
-
expect(projectConfiguration.targets.lint).toEqual({
|
|
157
|
-
executor: '@nx/eslint:lint',
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
|
|
161
138
|
it('should update root tsconfig.base.json', async () => {
|
|
162
139
|
await libraryGenerator(appTree, {
|
|
163
140
|
...defaultSchema,
|
|
@@ -229,11 +206,6 @@ describe('lib', () => {
|
|
|
229
206
|
|
|
230
207
|
expect(appTree.exists('my-lib/tsconfig.spec.json')).toBeFalsy();
|
|
231
208
|
expect(appTree.exists('my-lib/jest.config.ts')).toBeFalsy();
|
|
232
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
233
|
-
expect(projectConfiguration.targets.test).toBeUndefined();
|
|
234
|
-
expect(projectConfiguration.targets.lint).toMatchObject({
|
|
235
|
-
executor: '@nx/eslint:lint',
|
|
236
|
-
});
|
|
237
209
|
});
|
|
238
210
|
|
|
239
211
|
it('should generate test configuration', async () => {
|
|
@@ -277,22 +249,21 @@ describe('lib', () => {
|
|
|
277
249
|
moduleNameMapper: {
|
|
278
250
|
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
|
279
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
|
+
},
|
|
280
263
|
coverageDirectory: '../coverage/my-lib',
|
|
281
264
|
};
|
|
282
265
|
"
|
|
283
266
|
`);
|
|
284
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
285
|
-
expect(projectConfiguration.targets.test).toMatchInlineSnapshot(`
|
|
286
|
-
{
|
|
287
|
-
"executor": "@nx/jest:jest",
|
|
288
|
-
"options": {
|
|
289
|
-
"jestConfig": "my-lib/jest.config.ts",
|
|
290
|
-
},
|
|
291
|
-
"outputs": [
|
|
292
|
-
"{workspaceRoot}/coverage/{projectRoot}",
|
|
293
|
-
],
|
|
294
|
-
}
|
|
295
|
-
`);
|
|
296
267
|
});
|
|
297
268
|
});
|
|
298
269
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": "nx",
|
|
3
3
|
"$id": "NxReactNativeLibrary",
|
|
4
|
-
"$schema": "
|
|
4
|
+
"$schema": "https://json-schema.org/schema",
|
|
5
5
|
"title": "Create a React Native Library for Nx",
|
|
6
6
|
"description": "Create a React Native Library for Nx.",
|
|
7
7
|
"type": "object",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"linter": {
|
|
37
37
|
"description": "The tool to use for running lint checks.",
|
|
38
38
|
"type": "string",
|
|
39
|
-
"enum": ["eslint"],
|
|
39
|
+
"enum": ["eslint", "none"],
|
|
40
40
|
"default": "eslint"
|
|
41
41
|
},
|
|
42
42
|
"unitTestRunner": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeStorybookStories",
|
|
5
5
|
"title": "Generate React Native Storybook stories",
|
|
@@ -14,7 +14,20 @@
|
|
|
14
14
|
"$source": "projectName",
|
|
15
15
|
"index": 0
|
|
16
16
|
},
|
|
17
|
-
"x-prompt": "For which project do you want to generate stories?"
|
|
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
|
|
18
31
|
},
|
|
19
32
|
"ignorePaths": {
|
|
20
33
|
"type": "array",
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { StorybookStoriesSchema } from './schema';
|
|
3
|
-
|
|
4
|
-
|
|
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>;
|
|
5
8
|
export default storiesGenerator;
|
|
@@ -1,56 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storiesGenerator =
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const versions_1 = require("../../utils/versions");
|
|
10
|
-
async function createAllStories(tree, projectName, ignorePaths) {
|
|
11
|
-
(0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
|
|
12
|
-
const { isTheFileAStory } = await Promise.resolve().then(() => require('@nx/storybook/src/utils/utilities'));
|
|
13
|
-
const projects = (0, devkit_1.getProjects)(tree);
|
|
14
|
-
const projectConfiguration = projects.get(projectName);
|
|
15
|
-
const { sourceRoot } = projectConfiguration;
|
|
16
|
-
const projectPath = await (0, stories_1.projectRootPath)(tree, projectConfiguration);
|
|
17
|
-
let componentPaths = [];
|
|
18
|
-
(0, devkit_1.visitNotIgnoredFiles)(tree, projectPath, (path) => {
|
|
19
|
-
if (ignorePaths?.some((pattern) => (0, minimatch_1.minimatch)(path, pattern)))
|
|
20
|
-
return;
|
|
21
|
-
if ((path.endsWith('.tsx') && !path.endsWith('.spec.tsx')) ||
|
|
22
|
-
(path.endsWith('.js') && !path.endsWith('.spec.js')) ||
|
|
23
|
-
(path.endsWith('.jsx') && !path.endsWith('.spec.jsx'))) {
|
|
24
|
-
// Check if file is NOT a story (either ts/tsx or js/jsx)
|
|
25
|
-
if (!isTheFileAStory(tree, path)) {
|
|
26
|
-
// Since the file is not a story
|
|
27
|
-
// Let's see if the .stories.* file exists
|
|
28
|
-
const ext = path.slice(path.lastIndexOf('.'));
|
|
29
|
-
const storyPath = `${path.split(ext)[0]}.stories${ext}`;
|
|
30
|
-
if (!tree.exists(storyPath)) {
|
|
31
|
-
componentPaths.push(path);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
await Promise.all(componentPaths.map(async (componentPath) => {
|
|
37
|
-
const relativeCmpDir = componentPath.replace((0, path_1.join)(sourceRoot, '/'), '');
|
|
38
|
-
if (!(0, stories_1.containsComponentDeclaration)(tree, componentPath)) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
await (0, component_story_1.default)(tree, {
|
|
42
|
-
componentPath: relativeCmpDir,
|
|
43
|
-
project: projectName,
|
|
44
|
-
skipFormat: true,
|
|
45
|
-
});
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
exports.createAllStories = createAllStories;
|
|
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
|
+
*/
|
|
49
9
|
async function storiesGenerator(host, schema) {
|
|
50
|
-
|
|
51
|
-
if (!schema.skipFormat) {
|
|
52
|
-
await (0, devkit_1.formatFiles)(host);
|
|
53
|
-
}
|
|
10
|
+
return (0, react_1.storiesGenerator)(host, schema);
|
|
54
11
|
}
|
|
55
12
|
exports.storiesGenerator = storiesGenerator;
|
|
56
13
|
exports.default = storiesGenerator;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
2
|
import { StorybookConfigureSchema } from './schema';
|
|
3
|
-
export declare function storybookConfigurationGenerator(
|
|
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>;
|
|
4
9
|
export default storybookConfigurationGenerator;
|
|
@@ -1,56 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.storybookConfigurationGenerator = void 0;
|
|
3
|
+
exports.storybookConfigurationGeneratorInternal = exports.storybookConfigurationGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
async function generateStories(host, schema) {
|
|
11
|
-
await (0, stories_1.default)(host, {
|
|
12
|
-
project: schema.name,
|
|
13
|
-
ignorePaths: schema.ignorePaths,
|
|
14
|
-
skipFormat: true,
|
|
5
|
+
const react_1 = require("@nx/react");
|
|
6
|
+
function storybookConfigurationGenerator(tree, schema) {
|
|
7
|
+
return storybookConfigurationGeneratorInternal(tree, {
|
|
8
|
+
addPlugin: false,
|
|
9
|
+
...schema,
|
|
15
10
|
});
|
|
16
11
|
}
|
|
17
|
-
async function storybookConfigurationGenerator(host, schema) {
|
|
18
|
-
const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
|
|
19
|
-
const installTask = await configurationGenerator(host, {
|
|
20
|
-
project: schema.name,
|
|
21
|
-
uiFramework: '@storybook/react-native',
|
|
22
|
-
configureCypress: false,
|
|
23
|
-
js: false,
|
|
24
|
-
linter: schema.linter,
|
|
25
|
-
standaloneConfig: schema.standaloneConfig,
|
|
26
|
-
tsConfiguration: schema.tsConfiguration,
|
|
27
|
-
skipFormat: true,
|
|
28
|
-
});
|
|
29
|
-
const installRequiredPackagesTask = await (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
30
|
-
'@react-native-async-storage/async-storage': versions_1.reactNativeAsyncStorageVersion,
|
|
31
|
-
'react-native-safe-area-context': versions_1.reactNativeSafeAreaContextVersion,
|
|
32
|
-
});
|
|
33
|
-
addStorybookTask(host, schema.name);
|
|
34
|
-
(0, create_storybook_files_1.createStorybookFiles)(host, schema);
|
|
35
|
-
(0, replace_app_import_with_storybook_toggle_1.replaceAppImportWithStorybookToggle)(host, schema);
|
|
36
|
-
(0, add_resolver_main_fields_to_metro_config_1.addResolverMainFieldsToMetroConfig)(host, schema);
|
|
37
|
-
if (schema.generateStories) {
|
|
38
|
-
await generateStories(host, schema);
|
|
39
|
-
}
|
|
40
|
-
await (0, devkit_1.formatFiles)(host);
|
|
41
|
-
return (0, devkit_1.runTasksInSerial)(installTask, installRequiredPackagesTask);
|
|
42
|
-
}
|
|
43
12
|
exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
(0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfig);
|
|
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
|
+
schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
20
|
+
return (0, react_1.storybookConfigurationGenerator)(host, schema);
|
|
55
21
|
}
|
|
22
|
+
exports.storybookConfigurationGeneratorInternal = storybookConfigurationGeneratorInternal;
|
|
56
23
|
exports.default = storybookConfigurationGenerator;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Linter } from '@nx/eslint';
|
|
2
2
|
|
|
3
3
|
export interface StorybookConfigureSchema {
|
|
4
|
-
|
|
4
|
+
project: string;
|
|
5
|
+
interactionTests?: boolean;
|
|
5
6
|
generateStories?: boolean;
|
|
6
7
|
js?: boolean;
|
|
7
8
|
tsConfiguration?: boolean;
|
|
8
9
|
linter?: Linter;
|
|
9
|
-
standaloneConfig?: boolean;
|
|
10
10
|
ignorePaths?: string[];
|
|
11
|
+
configureStaticServe?: boolean;
|
|
12
|
+
addPlugin?: boolean;
|
|
11
13
|
}
|
|
@@ -1,29 +1,45 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeStorybookConfigure",
|
|
5
5
|
"title": "React native Storybook configuration",
|
|
6
6
|
"description": "Set up Storybook for a React-Native app or library.",
|
|
7
7
|
"type": "object",
|
|
8
8
|
"properties": {
|
|
9
|
-
"
|
|
9
|
+
"project": {
|
|
10
10
|
"type": "string",
|
|
11
|
-
"aliases": ["
|
|
11
|
+
"aliases": ["name", "projectName"],
|
|
12
12
|
"description": "Project for which to generate Storybook configuration.",
|
|
13
13
|
"$default": {
|
|
14
14
|
"$source": "argv",
|
|
15
15
|
"index": 0
|
|
16
16
|
},
|
|
17
17
|
"x-prompt": "For which project do you want to generate Storybook configuration?",
|
|
18
|
-
"x-dropdown": "projects"
|
|
18
|
+
"x-dropdown": "projects",
|
|
19
|
+
"x-priority": "important"
|
|
20
|
+
},
|
|
21
|
+
"interactionTests": {
|
|
22
|
+
"type": "boolean",
|
|
23
|
+
"description": "Set up Storybook interaction tests.",
|
|
24
|
+
"x-prompt": "Do you want to set up Storybook interaction tests?",
|
|
25
|
+
"x-priority": "important",
|
|
26
|
+
"alias": ["configureTestRunner"],
|
|
27
|
+
"default": true
|
|
19
28
|
},
|
|
20
29
|
"generateStories": {
|
|
21
30
|
"type": "boolean",
|
|
22
|
-
"description": "Automatically generate
|
|
31
|
+
"description": "Automatically generate `*.stories.ts` files for components declared in this project?",
|
|
23
32
|
"x-prompt": "Automatically generate *.stories.ts files for components declared in this project?",
|
|
24
33
|
"default": true,
|
|
25
34
|
"x-priority": "important"
|
|
26
35
|
},
|
|
36
|
+
"configureStaticServe": {
|
|
37
|
+
"type": "boolean",
|
|
38
|
+
"description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
|
|
39
|
+
"x-prompt": "Configure a static file server for the storybook instance?",
|
|
40
|
+
"default": true,
|
|
41
|
+
"x-priority": "important"
|
|
42
|
+
},
|
|
27
43
|
"js": {
|
|
28
44
|
"type": "boolean",
|
|
29
45
|
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
@@ -40,12 +56,6 @@
|
|
|
40
56
|
"enum": ["eslint"],
|
|
41
57
|
"default": "eslint"
|
|
42
58
|
},
|
|
43
|
-
"standaloneConfig": {
|
|
44
|
-
"description": "Split the project configuration into `<projectRoot>/project.json` rather than including it inside `workspace.json`.",
|
|
45
|
-
"type": "boolean",
|
|
46
|
-
"default": true,
|
|
47
|
-
"x-deprecated": "Nx only supports standaloneConfig"
|
|
48
|
-
},
|
|
49
59
|
"ignorePaths": {
|
|
50
60
|
"type": "array",
|
|
51
61
|
"description": "Paths to ignore when looking for components.",
|
|
@@ -65,5 +75,5 @@
|
|
|
65
75
|
]
|
|
66
76
|
}
|
|
67
77
|
},
|
|
68
|
-
"required": ["
|
|
78
|
+
"required": ["project"]
|
|
69
79
|
}
|
|
@@ -6,7 +6,7 @@ export interface NormalizedSchema {
|
|
|
6
6
|
lowerCaseName: string;
|
|
7
7
|
entryFile: string;
|
|
8
8
|
entryFileIos: string;
|
|
9
|
-
e2eTestRunner: 'detox' | 'none';
|
|
9
|
+
e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none';
|
|
10
10
|
offsetFromRoot: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function normalizeOptions(options: UpgradeNativeConfigureSchema, appProjectRoot: string): NormalizedSchema;
|
|
@@ -4,6 +4,6 @@ export interface UpgradeNativeConfigureSchema {
|
|
|
4
4
|
name: string;
|
|
5
5
|
displayName?: string;
|
|
6
6
|
js: boolean; // default is false
|
|
7
|
-
e2eTestRunner: 'detox' | 'none'; // default is
|
|
7
|
+
e2eTestRunner: 'cypress' | 'playwright' | 'detox' | 'none'; // default is cypress
|
|
8
8
|
install: boolean; // default is true
|
|
9
9
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$schema": "
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
3
|
"cli": "nx",
|
|
4
4
|
"$id": "NxReactNativeUpgradeNativeConfigure",
|
|
5
5
|
"title": "React native upgrade native configuration",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"e2eTestRunner": {
|
|
28
28
|
"description": "Adds the specified e2e test runner.",
|
|
29
29
|
"type": "string",
|
|
30
|
-
"enum": ["detox", "none"],
|
|
31
|
-
"default": "
|
|
30
|
+
"enum": ["cypress", "playwright", "detox", "none"],
|
|
31
|
+
"default": "cypress"
|
|
32
32
|
},
|
|
33
33
|
"install": {
|
|
34
34
|
"type": "boolean",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @deprecated use `nx run @nx/react-native:upgrade` instead.
|
|
3
|
+
* TODO (@xiongemi): remove this generator for nx v19
|
|
2
4
|
* This function is a destructive command that replace React Native iOS and Android code with latest.
|
|
3
5
|
* It would replace the Android and iOS folder entirely.
|
|
4
6
|
*/
|