@nx/react-native 17.0.2 → 17.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +7 -1
- package/LICENSE +1 -1
- package/README.md +9 -4
- package/executors.json +5 -0
- package/generators.json +12 -11
- package/migrations.json +126 -0
- package/package.json +11 -15
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/metro-resolver.js +4 -1
- package/plugins/plugin.d.ts +14 -0
- package/plugins/plugin.js +162 -0
- package/plugins/with-nx-metro.js +6 -2
- package/src/executors/build-android/build-android.impl.js +2 -6
- package/src/executors/build-android/build-android.impl.ts +2 -6
- package/src/executors/build-android/schema.json +1 -1
- package/src/executors/build-ios/schema.json +1 -1
- package/src/executors/bundle/schema.d.ts +1 -1
- package/src/executors/bundle/schema.json +1 -1
- package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +4 -0
- package/src/executors/ensure-symlink/schema.json +1 -1
- package/src/executors/pod-install/schema.json +1 -1
- package/src/executors/run-android/run-android.impl.js +5 -17
- package/src/executors/run-android/run-android.impl.ts +9 -18
- package/src/executors/run-android/schema.json +1 -1
- package/src/executors/run-ios/run-ios.impl.js +4 -16
- package/src/executors/run-ios/run-ios.impl.ts +9 -18
- package/src/executors/run-ios/schema.json +1 -1
- package/src/executors/start/schema.d.ts +1 -1
- package/src/executors/start/schema.json +1 -1
- package/src/executors/start/start.impl.js +11 -26
- package/src/executors/start/start.impl.ts +14 -28
- package/src/executors/storybook/storybook.impl.d.ts +4 -0
- package/src/executors/storybook/storybook.impl.js +15 -2
- package/src/executors/storybook/storybook.impl.ts +26 -7
- package/src/executors/sync-deps/schema.d.ts +1 -0
- package/src/executors/sync-deps/schema.json +6 -1
- package/src/executors/sync-deps/sync-deps.impl.d.ts +2 -1
- package/src/executors/sync-deps/sync-deps.impl.js +33 -11
- package/src/executors/sync-deps/sync-deps.impl.ts +57 -18
- package/src/executors/upgrade/schema.d.ts +1 -0
- package/src/executors/upgrade/schema.json +11 -0
- package/src/executors/upgrade/upgrade.impl.d.ts +13 -0
- package/src/executors/upgrade/upgrade.impl.js +47 -0
- package/src/executors/upgrade/upgrade.impl.ts +64 -0
- package/src/generators/application/application.js +52 -8
- package/src/generators/application/application.spec.ts +29 -2
- package/src/generators/application/files/app/.babelrc.js.template +23 -0
- package/src/generators/application/files/app/Gemfile.template +2 -1
- package/src/generators/application/files/app/android/app/build.gradle.template +12 -28
- package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +2 -6
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +22 -0
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +45 -0
- package/src/generators/application/files/app/android/build.gradle.template +7 -20
- package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/src/generators/application/files/app/android/gradle.properties +0 -3
- package/src/generators/application/files/app/android/gradlew.template +12 -7
- package/src/generators/application/files/app/android/settings.gradle.template +2 -2
- package/src/generators/application/files/app/ios/Podfile.template +0 -7
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +5 -0
- package/src/generators/application/files/app/ios/__className__/Info.plist.template +5 -8
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +11 -33
- package/src/generators/application/files/app/metro.config.js.template +1 -5
- package/src/generators/application/files/app/src/app/App.tsx.template +50 -13
- package/src/generators/application/lib/add-e2e.d.ts +3 -0
- package/src/generators/application/lib/add-e2e.js +46 -0
- package/src/generators/application/lib/add-project.js +18 -18
- package/src/generators/application/lib/normalize-options.d.ts +7 -0
- package/src/generators/application/lib/normalize-options.js +35 -3
- package/src/generators/application/lib/normalize-options.spec.ts +70 -7
- package/src/generators/application/schema.d.ts +5 -3
- package/src/generators/application/schema.json +14 -6
- package/src/generators/component/files/__fileName__.tsx__tmpl__ +1 -1
- package/src/generators/component/schema.d.ts +3 -3
- package/src/generators/component/schema.json +4 -4
- package/src/generators/component-story/component-story.d.ts +5 -8
- package/src/generators/component-story/component-story.js +8 -69
- package/src/generators/component-story/schema.d.ts +1 -0
- package/src/generators/component-story/schema.json +11 -3
- package/src/generators/init/init.d.ts +2 -1
- package/src/generators/init/init.js +55 -56
- package/src/generators/init/init.spec.ts +7 -6
- package/src/generators/init/schema.d.ts +3 -3
- package/src/generators/init/schema.json +13 -18
- package/src/generators/library/files/lib/.babelrc.js.template +21 -0
- package/src/generators/library/lib/normalize-options.js +5 -0
- package/src/generators/library/library.js +48 -38
- package/src/generators/library/library.spec.ts +12 -60
- package/src/generators/library/schema.d.ts +1 -0
- package/src/generators/library/schema.json +2 -2
- package/src/generators/stories/schema.d.ts +2 -0
- package/src/generators/stories/schema.json +15 -2
- package/src/generators/stories/stories.d.ts +5 -2
- package/src/generators/stories/stories.js +7 -50
- package/src/generators/storybook-configuration/configuration.d.ts +7 -2
- package/src/generators/storybook-configuration/configuration.js +18 -48
- package/src/generators/storybook-configuration/schema.d.ts +4 -2
- package/src/generators/storybook-configuration/schema.json +22 -12
- package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
- package/src/generators/upgrade-native/schema.d.ts +1 -1
- package/src/generators/upgrade-native/schema.json +3 -3
- package/src/generators/upgrade-native/upgrade-native.d.ts +2 -0
- package/src/generators/upgrade-native/upgrade-native.js +3 -0
- package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +15 -0
- package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +82 -0
- package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +23 -0
- package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
- package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +14 -0
- package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +9 -0
- package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +77 -0
- package/src/generators/web-configuration/lib/normalize-schema.d.ts +17 -0
- package/src/generators/web-configuration/lib/normalize-schema.js +16 -0
- package/src/generators/web-configuration/lib/webpack-targets.d.ts +7 -0
- package/src/generators/web-configuration/lib/webpack-targets.js +75 -0
- package/src/generators/web-configuration/schema.d.ts +6 -0
- package/src/generators/web-configuration/schema.json +42 -0
- package/src/generators/web-configuration/web-configuration.d.ts +12 -0
- package/src/generators/web-configuration/web-configuration.js +87 -0
- package/src/migrations/update-16-6-0/update-metro-config.js +1 -5
- package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
- package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/add-upgrade-target.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.d.ts +8 -0
- package/src/migrations/update-18-0-0/add-web-configuration.js +33 -0
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +39 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +5 -0
- package/src/migrations/update-18-0-0/change-storybook-targets.js +57 -0
- package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-block-list.js +28 -0
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +68 -0
- package/src/migrations/update-18-0-0/remove-metro.d.ts +14 -0
- package/src/migrations/update-18-0-0/remove-metro.js +29 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.js +30 -0
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +40 -0
- package/src/utils/add-jest.d.ts +1 -1
- package/src/utils/add-jest.js +13 -1
- package/src/utils/add-linting.d.ts +1 -0
- package/src/utils/add-linting.js +1 -1
- package/src/utils/add-linting.spec.ts +4 -6
- package/src/utils/chmod-android-gradle-files.js +6 -2
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +30 -0
- package/src/utils/find-all-npm-dependencies.js +5 -3
- package/src/utils/find-all-npm-dependencies.spec.ts +17 -9
- package/src/utils/testing-generators.js +1 -0
- package/src/utils/versions.d.ts +10 -13
- package/src/utils/versions.js +11 -14
- package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -75
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +0 -32
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +0 -62
- package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -20
- package/src/generators/application/files/app/babel.config.json.template +0 -3
- package/src/generators/application/lib/add-detox.d.ts +0 -3
- package/src/generators/application/lib/add-detox.js +0 -23
- package/src/generators/component-story/component-story.spec.ts +0 -428
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +0 -32
- package/src/generators/library/files/lib/babel.config.json.template +0 -17
- package/src/generators/stories/stories-app.spec.ts +0 -128
- package/src/generators/stories/stories-lib.spec.ts +0 -105
- package/src/generators/storybook-configuration/configuration.spec.ts +0 -135
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +0 -9
- package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +0 -74
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +0 -5
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +0 -25
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +0 -161
- package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +0 -6
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +0 -42
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +0 -7
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +0 -29
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +0 -65
- package/src/utils/symlink-task.d.ts +0 -2
- package/src/utils/symlink-task.js +0 -18
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxReactNativeEnsureSymlink",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Ensure Symlink for React Native",
|
|
8
8
|
"description": "Ensure workspace node_modules is symlink under app's node_modules folder.",
|
|
9
9
|
"type": "object",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxReactNativePodInstall",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Run Pod Install for React Native iOS Project",
|
|
8
8
|
"description": "Run `pod install` for React Native iOS Project.",
|
|
9
9
|
"type": "object",
|
|
@@ -8,28 +8,16 @@ const get_cli_options_1 = require("../../utils/get-cli-options");
|
|
|
8
8
|
let childProcess;
|
|
9
9
|
async function* runAndroidExecutor(options, context) {
|
|
10
10
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
11
|
-
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
|
|
11
|
+
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(context.root, projectRoot, 'android'));
|
|
12
|
+
const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
|
|
12
13
|
if (options.mode !== 'Release') {
|
|
13
|
-
|
|
14
|
+
tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
|
|
14
15
|
port: options.port,
|
|
15
16
|
resetCache: options.resetCache,
|
|
16
17
|
interactive: true,
|
|
17
|
-
}
|
|
18
|
-
for await (const result of startResults) {
|
|
19
|
-
if (result.success) {
|
|
20
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
21
|
-
yield {
|
|
22
|
-
success: true,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
18
|
+
}));
|
|
32
19
|
}
|
|
20
|
+
await Promise.all(tasks);
|
|
33
21
|
yield { success: true };
|
|
34
22
|
}
|
|
35
23
|
exports.default = runAndroidExecutor;
|
|
@@ -3,7 +3,7 @@ import { join, resolve as pathResolve } from 'path';
|
|
|
3
3
|
import { ChildProcess, fork } from 'child_process';
|
|
4
4
|
|
|
5
5
|
import { ReactNativeRunAndroidOptions } from './schema';
|
|
6
|
-
import
|
|
6
|
+
import { runCliStart } from '../start/start.impl';
|
|
7
7
|
import { chmodAndroidGradlewFiles } from '../../utils/chmod-android-gradle-files';
|
|
8
8
|
import { getCliOptions } from '../../utils/get-cli-options';
|
|
9
9
|
|
|
@@ -19,31 +19,22 @@ export default async function* runAndroidExecutor(
|
|
|
19
19
|
): AsyncGenerator<ReactNativeRunAndroidOutput> {
|
|
20
20
|
const projectRoot =
|
|
21
21
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
22
|
-
chmodAndroidGradlewFiles(join(projectRoot, 'android'));
|
|
22
|
+
chmodAndroidGradlewFiles(join(context.root, projectRoot, 'android'));
|
|
23
|
+
|
|
24
|
+
const tasks = [runCliRunAndroid(context.root, projectRoot, options)];
|
|
23
25
|
|
|
24
26
|
if (options.mode !== 'Release') {
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
+
tasks.push(
|
|
28
|
+
runCliStart(context.root, projectRoot, {
|
|
27
29
|
port: options.port,
|
|
28
30
|
resetCache: options.resetCache,
|
|
29
31
|
interactive: true,
|
|
30
|
-
}
|
|
31
|
-
context
|
|
32
|
+
})
|
|
32
33
|
);
|
|
33
|
-
for await (const result of startResults) {
|
|
34
|
-
if (result.success) {
|
|
35
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
36
|
-
yield {
|
|
37
|
-
success: true,
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
await runCliRunAndroid(context.root, projectRoot, options);
|
|
45
34
|
}
|
|
46
35
|
|
|
36
|
+
await Promise.all(tasks);
|
|
37
|
+
|
|
47
38
|
yield { success: true };
|
|
48
39
|
}
|
|
49
40
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxReactNativeRunAndroid",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Run Android application",
|
|
8
8
|
"description": "Run Android target options.",
|
|
9
9
|
"type": "object",
|
|
@@ -10,27 +10,15 @@ async function* runIosExecutor(options, context) {
|
|
|
10
10
|
throw new Error(`The run-ios build requires Mac to run`);
|
|
11
11
|
}
|
|
12
12
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
13
|
+
const tasks = [runCliRunIOS(context.root, projectRoot, options)];
|
|
13
14
|
if (options.mode !== 'Release') {
|
|
14
|
-
|
|
15
|
+
tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
|
|
15
16
|
port: options.port,
|
|
16
17
|
resetCache: options.resetCache,
|
|
17
18
|
interactive: true,
|
|
18
|
-
}
|
|
19
|
-
for await (const result of startResults) {
|
|
20
|
-
if (result.success) {
|
|
21
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
22
|
-
yield {
|
|
23
|
-
success: true,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
return result;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
19
|
+
}));
|
|
33
20
|
}
|
|
21
|
+
await Promise.all(tasks);
|
|
34
22
|
yield { success: true };
|
|
35
23
|
}
|
|
36
24
|
exports.default = runIosExecutor;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
1
|
+
import { ExecutorContext, GeneratorCallback, workspaceRoot } from '@nx/devkit';
|
|
2
2
|
import { resolve as pathResolve } from 'path';
|
|
3
3
|
import { ChildProcess, fork } from 'child_process';
|
|
4
4
|
import { platform } from 'os';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import { runCliStart } from '../start/start.impl';
|
|
7
7
|
import { getCliOptions } from '../../utils/get-cli-options';
|
|
8
8
|
|
|
9
9
|
import { ReactNativeRunIosOptions } from './schema';
|
|
@@ -21,29 +21,20 @@ export default async function* runIosExecutor(
|
|
|
21
21
|
const projectRoot =
|
|
22
22
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
23
23
|
|
|
24
|
+
const tasks = [runCliRunIOS(context.root, projectRoot, options)];
|
|
25
|
+
|
|
24
26
|
if (options.mode !== 'Release') {
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
+
tasks.push(
|
|
28
|
+
runCliStart(context.root, projectRoot, {
|
|
27
29
|
port: options.port,
|
|
28
30
|
resetCache: options.resetCache,
|
|
29
31
|
interactive: true,
|
|
30
|
-
}
|
|
31
|
-
context
|
|
32
|
+
})
|
|
32
33
|
);
|
|
33
|
-
for await (const result of startResults) {
|
|
34
|
-
if (result.success) {
|
|
35
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
36
|
-
yield {
|
|
37
|
-
success: true,
|
|
38
|
-
};
|
|
39
|
-
} else {
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
await runCliRunIOS(context.root, projectRoot, options);
|
|
45
34
|
}
|
|
46
35
|
|
|
36
|
+
await Promise.all(tasks);
|
|
37
|
+
|
|
47
38
|
yield { success: true };
|
|
48
39
|
}
|
|
49
40
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxReactNativeRunIos",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Run iOS application",
|
|
8
8
|
"description": "Run iOS target options.",
|
|
9
9
|
"type": "object",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// options from https://github.com/react-native
|
|
1
|
+
// options from https://github.com/facebook/react-native/blob/main/packages/community-cli-plugin/src/commands/start/index.js
|
|
2
2
|
|
|
3
3
|
export interface ReactNativeStartOptions {
|
|
4
4
|
port: number;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxReactNativeStart",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Packager Server for React Native",
|
|
8
8
|
"description": "Packager Server target options.",
|
|
9
9
|
"type": "object",
|
|
@@ -7,25 +7,11 @@ const path_1 = require("path");
|
|
|
7
7
|
const is_packager_running_1 = require("./lib/is-packager-running");
|
|
8
8
|
async function* startExecutor(options, context) {
|
|
9
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
10
|
-
|
|
10
|
+
await runCliStart(context.root, projectRoot, options);
|
|
11
11
|
yield {
|
|
12
12
|
port: options.port,
|
|
13
13
|
success: true,
|
|
14
14
|
};
|
|
15
|
-
if (!startProcess) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
await new Promise((resolve) => {
|
|
19
|
-
const processExitListener = (signal) => () => {
|
|
20
|
-
startProcess.kill(signal);
|
|
21
|
-
resolve();
|
|
22
|
-
process.exit();
|
|
23
|
-
};
|
|
24
|
-
process.once('exit', (signal) => startProcess.kill(signal));
|
|
25
|
-
process.once('SIGTERM', processExitListener);
|
|
26
|
-
process.once('SIGINT', processExitListener);
|
|
27
|
-
process.once('SIGQUIT', processExitListener);
|
|
28
|
-
});
|
|
29
15
|
}
|
|
30
16
|
exports.default = startExecutor;
|
|
31
17
|
/*
|
|
@@ -47,7 +33,7 @@ async function runCliStart(workspaceRoot, projectRoot, options) {
|
|
|
47
33
|
return await startAsync(workspaceRoot, projectRoot, options);
|
|
48
34
|
}
|
|
49
35
|
catch (error) {
|
|
50
|
-
devkit_1.logger.error(`Failed to start the packager server. Error details: ${error.message}`);
|
|
36
|
+
devkit_1.logger.error(`Failed to start the packager server. Error details: ${error.message ?? error}`);
|
|
51
37
|
throw error;
|
|
52
38
|
}
|
|
53
39
|
}
|
|
@@ -58,16 +44,7 @@ function startAsync(workspaceRoot, projectRoot, options) {
|
|
|
58
44
|
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['start', ...createStartOptions(options)], {
|
|
59
45
|
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
60
46
|
env: process.env,
|
|
61
|
-
stdio:
|
|
62
|
-
});
|
|
63
|
-
childProcess.stdout.on('data', (data) => {
|
|
64
|
-
process.stdout.write(data);
|
|
65
|
-
if (data.toString().includes('reload the app')) {
|
|
66
|
-
resolve(childProcess);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
childProcess.stderr.on('data', (data) => {
|
|
70
|
-
process.stderr.write(data);
|
|
47
|
+
stdio: 'inherit',
|
|
71
48
|
});
|
|
72
49
|
childProcess.on('error', (err) => {
|
|
73
50
|
reject(err);
|
|
@@ -80,6 +57,14 @@ function startAsync(workspaceRoot, projectRoot, options) {
|
|
|
80
57
|
reject(code);
|
|
81
58
|
}
|
|
82
59
|
});
|
|
60
|
+
const processExitListener = (signal) => () => {
|
|
61
|
+
childProcess.kill(signal);
|
|
62
|
+
process.exit();
|
|
63
|
+
};
|
|
64
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
65
|
+
process.once('SIGTERM', processExitListener);
|
|
66
|
+
process.once('SIGINT', processExitListener);
|
|
67
|
+
process.once('SIGQUIT', processExitListener);
|
|
83
68
|
});
|
|
84
69
|
}
|
|
85
70
|
function createStartOptions(options) {
|
|
@@ -16,27 +16,12 @@ export default async function* startExecutor(
|
|
|
16
16
|
const projectRoot =
|
|
17
17
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
await runCliStart(context.root, projectRoot, options);
|
|
20
20
|
|
|
21
21
|
yield {
|
|
22
22
|
port: options.port,
|
|
23
23
|
success: true,
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
if (!startProcess) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
await new Promise<void>((resolve) => {
|
|
30
|
-
const processExitListener = (signal?: number | NodeJS.Signals) => () => {
|
|
31
|
-
startProcess.kill(signal);
|
|
32
|
-
resolve();
|
|
33
|
-
process.exit();
|
|
34
|
-
};
|
|
35
|
-
process.once('exit', (signal) => startProcess.kill(signal));
|
|
36
|
-
process.once('SIGTERM', processExitListener);
|
|
37
|
-
process.once('SIGINT', processExitListener);
|
|
38
|
-
process.once('SIGQUIT', processExitListener);
|
|
39
|
-
});
|
|
40
25
|
}
|
|
41
26
|
|
|
42
27
|
/*
|
|
@@ -61,7 +46,9 @@ export async function runCliStart(
|
|
|
61
46
|
return await startAsync(workspaceRoot, projectRoot, options);
|
|
62
47
|
} catch (error) {
|
|
63
48
|
logger.error(
|
|
64
|
-
`Failed to start the packager server. Error details: ${
|
|
49
|
+
`Failed to start the packager server. Error details: ${
|
|
50
|
+
error.message ?? error
|
|
51
|
+
}`
|
|
65
52
|
);
|
|
66
53
|
throw error;
|
|
67
54
|
}
|
|
@@ -80,20 +67,10 @@ function startAsync(
|
|
|
80
67
|
{
|
|
81
68
|
cwd: pathResolve(workspaceRoot, projectRoot),
|
|
82
69
|
env: process.env,
|
|
83
|
-
stdio:
|
|
70
|
+
stdio: 'inherit',
|
|
84
71
|
}
|
|
85
72
|
);
|
|
86
73
|
|
|
87
|
-
childProcess.stdout.on('data', (data) => {
|
|
88
|
-
process.stdout.write(data);
|
|
89
|
-
if (data.toString().includes('reload the app')) {
|
|
90
|
-
resolve(childProcess);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
childProcess.stderr.on('data', (data) => {
|
|
94
|
-
process.stderr.write(data);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
74
|
childProcess.on('error', (err) => {
|
|
98
75
|
reject(err);
|
|
99
76
|
});
|
|
@@ -104,6 +81,15 @@ function startAsync(
|
|
|
104
81
|
reject(code);
|
|
105
82
|
}
|
|
106
83
|
});
|
|
84
|
+
|
|
85
|
+
const processExitListener = (signal?: number | NodeJS.Signals) => () => {
|
|
86
|
+
childProcess.kill(signal);
|
|
87
|
+
process.exit();
|
|
88
|
+
};
|
|
89
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
90
|
+
process.once('SIGTERM', processExitListener);
|
|
91
|
+
process.once('SIGINT', processExitListener);
|
|
92
|
+
process.once('SIGQUIT', processExitListener);
|
|
107
93
|
});
|
|
108
94
|
}
|
|
109
95
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { ReactNativeStorybookOptions } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
5
|
+
* @deprecated Going to use the default react storybook target. Use @nx/react:storybook executor instead.
|
|
6
|
+
*/
|
|
3
7
|
export default function reactNativeStorybookExecutor(options: ReactNativeStorybookOptions, context: ExecutorContext): AsyncGenerator<{
|
|
4
8
|
success: boolean;
|
|
5
9
|
}>;
|
|
@@ -8,13 +8,20 @@ const chalk = require("chalk");
|
|
|
8
8
|
const glob_1 = require("glob");
|
|
9
9
|
const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
|
|
10
10
|
const fs_extra_1 = require("fs-extra");
|
|
11
|
+
/**
|
|
12
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
13
|
+
* @deprecated Going to use the default react storybook target. Use @nx/react:storybook executor instead.
|
|
14
|
+
*/
|
|
11
15
|
async function* reactNativeStorybookExecutor(options, context) {
|
|
12
16
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
13
17
|
devkit_1.logger.info(`${chalk.bold.cyan('info')} To see your Storybook stories on the device, you should start your mobile app for the <platform> of your choice (typically ios or android).`);
|
|
14
18
|
// add storybook addons to app's package.json
|
|
15
19
|
const packageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
|
|
20
|
+
const workspacePackageJsonPath = (0, path_1.join)(context.root, 'package.json');
|
|
21
|
+
const workspacePackageJson = (0, devkit_1.readJsonFile)(workspacePackageJsonPath);
|
|
22
|
+
const projectPackageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
|
|
16
23
|
if ((0, fileutils_1.fileExists)(packageJsonPath))
|
|
17
|
-
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(context.projectName,
|
|
24
|
+
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(context.projectName, projectPackageJson, packageJsonPath, workspacePackageJson, context.projectGraph, [
|
|
18
25
|
`@storybook/react-native`,
|
|
19
26
|
'@storybook/addon-ondevice-actions',
|
|
20
27
|
'@storybook/addon-ondevice-backgrounds',
|
|
@@ -28,7 +35,13 @@ async function* reactNativeStorybookExecutor(options, context) {
|
|
|
28
35
|
}
|
|
29
36
|
exports.default = reactNativeStorybookExecutor;
|
|
30
37
|
function runCliStorybook(workspaceRoot, options) {
|
|
31
|
-
const storiesFiles = options.searchDir.flatMap((dir) =>
|
|
38
|
+
const storiesFiles = options.searchDir.flatMap((dir) => {
|
|
39
|
+
const storyFilePaths = (0, glob_1.sync)((0, path_1.join)(dir, options.pattern));
|
|
40
|
+
return storyFilePaths.map((storyFilePath) => {
|
|
41
|
+
const loaderPath = (0, path_1.resolve)((0, path_1.dirname)(options.outputFile));
|
|
42
|
+
return (0, path_1.relative)(loaderPath, storyFilePath);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
32
45
|
if (storiesFiles.length === 0) {
|
|
33
46
|
devkit_1.logger.warn(`${chalk.bold.yellow('warn')} No stories found.`);
|
|
34
47
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { ExecutorContext, logger } from '@nx/devkit';
|
|
1
|
+
import { join, relative, resolve, dirname } from 'path';
|
|
2
|
+
import { ExecutorContext, logger, readJsonFile } from '@nx/devkit';
|
|
3
3
|
import { fileExists } from '@nx/workspace/src/utilities/fileutils';
|
|
4
4
|
import * as chalk from 'chalk';
|
|
5
5
|
import { sync as globSync } from 'glob';
|
|
@@ -10,7 +10,12 @@ import {
|
|
|
10
10
|
syncDeps,
|
|
11
11
|
} from '../sync-deps/sync-deps.impl';
|
|
12
12
|
import { writeFileSync } from 'fs-extra';
|
|
13
|
+
import { PackageJson } from 'nx/src/utils/package-json';
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* TODO (@xiongemi): remove this function in v19.
|
|
17
|
+
* @deprecated Going to use the default react storybook target. Use @nx/react:storybook executor instead.
|
|
18
|
+
*/
|
|
14
19
|
export default async function* reactNativeStorybookExecutor(
|
|
15
20
|
options: ReactNativeStorybookOptions,
|
|
16
21
|
context: ExecutorContext
|
|
@@ -25,13 +30,21 @@ export default async function* reactNativeStorybookExecutor(
|
|
|
25
30
|
|
|
26
31
|
// add storybook addons to app's package.json
|
|
27
32
|
const packageJsonPath = join(context.root, projectRoot, 'package.json');
|
|
33
|
+
const workspacePackageJsonPath = join(context.root, 'package.json');
|
|
34
|
+
|
|
35
|
+
const workspacePackageJson = readJsonFile<PackageJson>(
|
|
36
|
+
workspacePackageJsonPath
|
|
37
|
+
);
|
|
38
|
+
const projectPackageJson = readJsonFile<PackageJson>(packageJsonPath);
|
|
39
|
+
|
|
28
40
|
if (fileExists(packageJsonPath))
|
|
29
41
|
displayNewlyAddedDepsMessage(
|
|
30
42
|
context.projectName,
|
|
31
43
|
await syncDeps(
|
|
32
44
|
context.projectName,
|
|
33
|
-
|
|
34
|
-
|
|
45
|
+
projectPackageJson,
|
|
46
|
+
packageJsonPath,
|
|
47
|
+
workspacePackageJson,
|
|
35
48
|
context.projectGraph,
|
|
36
49
|
[
|
|
37
50
|
`@storybook/react-native`,
|
|
@@ -53,9 +66,15 @@ export function runCliStorybook(
|
|
|
53
66
|
workspaceRoot: string,
|
|
54
67
|
options: ReactNativeStorybookOptions
|
|
55
68
|
) {
|
|
56
|
-
const storiesFiles: string[] = options.searchDir.flatMap((dir) =>
|
|
57
|
-
globSync(join(dir, options.pattern))
|
|
58
|
-
|
|
69
|
+
const storiesFiles: string[] = options.searchDir.flatMap((dir) => {
|
|
70
|
+
const storyFilePaths: string[] = globSync(join(dir, options.pattern));
|
|
71
|
+
|
|
72
|
+
return storyFilePaths.map((storyFilePath) => {
|
|
73
|
+
const loaderPath: string = resolve(dirname(options.outputFile));
|
|
74
|
+
return relative(loaderPath, storyFilePath);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
59
78
|
if (storiesFiles.length === 0) {
|
|
60
79
|
logger.warn(`${chalk.bold.yellow('warn')} No stories found.`);
|
|
61
80
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"outputCapture": "direct-nodejs",
|
|
4
4
|
"cli": "nx",
|
|
5
5
|
"$id": "NxReactNativeSyncDeps",
|
|
6
|
-
"$schema": "
|
|
6
|
+
"$schema": "https://json-schema.org/schema",
|
|
7
7
|
"title": "Sync Deps for React Native",
|
|
8
8
|
"description": "Updates `package.json` with project dependencies.",
|
|
9
9
|
"type": "object",
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"default": [],
|
|
25
25
|
"description": "An array of npm packages to exclude."
|
|
26
|
+
},
|
|
27
|
+
"all": {
|
|
28
|
+
"type": "boolean",
|
|
29
|
+
"description": "Copy all dependencies and devDependencies from the workspace root package.json.",
|
|
30
|
+
"default": false
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ExecutorContext, ProjectGraph } from '@nx/devkit';
|
|
2
2
|
import { ReactNativeSyncDepsOptions } from './schema';
|
|
3
|
+
import { PackageJson } from 'nx/src/utils/package-json';
|
|
3
4
|
export interface ReactNativeSyncDepsOutput {
|
|
4
5
|
success: boolean;
|
|
5
6
|
}
|
|
6
7
|
export default function syncDepsExecutor(options: ReactNativeSyncDepsOptions, context: ExecutorContext): AsyncGenerator<ReactNativeSyncDepsOutput>;
|
|
7
|
-
export declare function syncDeps(projectName: string,
|
|
8
|
+
export declare function syncDeps(projectName: string, projectPackageJson: PackageJson, projectPackageJsonPath: string, workspacePackageJson: PackageJson, projectGraph?: ProjectGraph, include?: string[], exclude?: string[], all?: boolean): Promise<string[]>;
|
|
8
9
|
export declare function displayNewlyAddedDepsMessage(projectName: string, deps: string[]): void;
|
|
@@ -7,22 +7,29 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const find_all_npm_dependencies_1 = require("../../utils/find-all-npm-dependencies");
|
|
8
8
|
async function* syncDepsExecutor(options, context) {
|
|
9
9
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
10
|
-
|
|
10
|
+
const workspacePackageJsonPath = (0, path_1.join)(context.root, 'package.json');
|
|
11
|
+
const projectPackageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
|
|
12
|
+
const workspacePackageJson = (0, devkit_1.readJsonFile)(workspacePackageJsonPath);
|
|
13
|
+
const projectPackageJson = (0, devkit_1.readJsonFile)(projectPackageJsonPath);
|
|
14
|
+
displayNewlyAddedDepsMessage(context.projectName, await syncDeps(context.projectName, projectPackageJson, projectPackageJsonPath, workspacePackageJson, context.projectGraph, typeof options.include === 'string'
|
|
11
15
|
? options.include.split(',')
|
|
12
16
|
: options.include, typeof options.exclude === 'string'
|
|
13
17
|
? options.exclude.split(',')
|
|
14
|
-
: options.exclude));
|
|
18
|
+
: options.exclude, options.all));
|
|
15
19
|
yield { success: true };
|
|
16
20
|
}
|
|
17
21
|
exports.default = syncDepsExecutor;
|
|
18
|
-
async function syncDeps(projectName,
|
|
19
|
-
let npmDeps =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
async function syncDeps(projectName, projectPackageJson, projectPackageJsonPath, workspacePackageJson, projectGraph = (0, devkit_1.readCachedProjectGraph)(), include = [], exclude = [], all = false) {
|
|
23
|
+
let npmDeps = all
|
|
24
|
+
? Object.keys(workspacePackageJson.dependencies || {})
|
|
25
|
+
: (0, find_all_npm_dependencies_1.findAllNpmDependencies)(projectGraph, projectName);
|
|
26
|
+
let npmDevdeps = all
|
|
27
|
+
? Object.keys(workspacePackageJson.devDependencies || {})
|
|
28
|
+
: [];
|
|
22
29
|
const newDeps = [];
|
|
23
30
|
let updated = false;
|
|
24
|
-
if (!
|
|
25
|
-
|
|
31
|
+
if (!projectPackageJson.dependencies) {
|
|
32
|
+
projectPackageJson.dependencies = {};
|
|
26
33
|
updated = true;
|
|
27
34
|
}
|
|
28
35
|
if (include && include.length) {
|
|
@@ -31,15 +38,30 @@ async function syncDeps(projectName, projectRoot, workspaceRoot, projectGraph, i
|
|
|
31
38
|
if (exclude && exclude.length) {
|
|
32
39
|
npmDeps = npmDeps.filter((dep) => !exclude.includes(dep));
|
|
33
40
|
}
|
|
41
|
+
if (!projectPackageJson.devDependencies) {
|
|
42
|
+
projectPackageJson.devDependencies = {};
|
|
43
|
+
}
|
|
44
|
+
if (!projectPackageJson.dependencies) {
|
|
45
|
+
projectPackageJson.dependencies = {};
|
|
46
|
+
}
|
|
34
47
|
npmDeps.forEach((dep) => {
|
|
35
|
-
if (!
|
|
36
|
-
|
|
48
|
+
if (!projectPackageJson.dependencies[dep] &&
|
|
49
|
+
!projectPackageJson.devDependencies[dep]) {
|
|
50
|
+
projectPackageJson.dependencies[dep] = '*';
|
|
51
|
+
newDeps.push(dep);
|
|
52
|
+
updated = true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
npmDevdeps.forEach((dep) => {
|
|
56
|
+
if (!projectPackageJson.dependencies[dep] &&
|
|
57
|
+
!projectPackageJson.devDependencies[dep]) {
|
|
58
|
+
projectPackageJson.devDependencies[dep] = '*';
|
|
37
59
|
newDeps.push(dep);
|
|
38
60
|
updated = true;
|
|
39
61
|
}
|
|
40
62
|
});
|
|
41
63
|
if (updated) {
|
|
42
|
-
(0, devkit_1.writeJsonFile)(
|
|
64
|
+
(0, devkit_1.writeJsonFile)(projectPackageJsonPath, projectPackageJson);
|
|
43
65
|
}
|
|
44
66
|
return newDeps;
|
|
45
67
|
}
|