@nx/react-native 16.6.0-beta.3 → 16.6.0-beta.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/migrations.json +78 -0
- package/package.json +13 -12
- package/plugins/with-nx-metro.d.ts +5 -1
- package/plugins/with-nx-metro.js +27 -22
- package/src/executors/build-android/build-android.impl.js +18 -32
- package/src/executors/build-android/build-android.impl.ts +21 -50
- package/src/executors/build-android/schema.d.ts +5 -3
- package/src/executors/build-android/schema.json +14 -8
- package/src/executors/build-ios/build-ios.impl.d.ts +1 -1
- package/src/executors/build-ios/build-ios.impl.js +23 -42
- package/src/executors/build-ios/build-ios.impl.ts +26 -64
- package/src/executors/build-ios/schema.d.ts +3 -0
- package/src/executors/build-ios/schema.json +8 -6
- package/src/executors/bundle/bundle.impl.js +19 -17
- package/src/executors/bundle/bundle.impl.ts +24 -23
- package/src/executors/pod-install/pod-install.impl.js +1 -1
- package/src/executors/pod-install/pod-install.impl.ts +1 -1
- package/src/executors/pod-install/schema.d.ts +3 -1
- package/src/executors/pod-install/schema.json +11 -1
- package/src/executors/run-android/run-android.impl.js +47 -26
- package/src/executors/run-android/run-android.impl.ts +40 -45
- package/src/executors/run-android/schema.d.ts +2 -2
- package/src/executors/run-android/schema.json +9 -5
- package/src/executors/run-ios/run-ios.impl.js +47 -31
- package/src/executors/run-ios/run-ios.impl.ts +42 -56
- package/src/executors/run-ios/schema.d.ts +1 -1
- package/src/executors/run-ios/schema.json +7 -6
- package/src/executors/start/start.impl.d.ts +4 -2
- package/src/executors/start/start.impl.js +35 -24
- package/src/executors/start/start.impl.ts +42 -35
- package/src/executors/storybook/schema.d.ts +1 -1
- package/src/generators/application/application.js +1 -3
- package/src/generators/application/files/app/Gemfile.template +2 -2
- package/src/generators/application/files/app/android/app/build.gradle.template +2 -49
- package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +1 -4
- package/src/generators/application/files/app/android/app/src/main/res/drawable/rn_edit_text_material.xml +1 -1
- package/src/generators/application/files/app/android/build.gradle.template +1 -1
- 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 +2 -1
- package/src/generators/application/files/app/android/gradle.properties +1 -1
- package/src/generators/application/files/app/android/gradlew.bat +9 -6
- package/src/generators/application/files/app/android/gradlew.template +14 -4
- package/src/generators/application/files/app/android/settings.gradle.template +1 -2
- package/src/generators/application/files/app/ios/Podfile.template +8 -6
- package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +0 -10
- package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +6 -2
- package/src/generators/application/files/app/metro.config.js.template +32 -35
- package/src/generators/application/files/app/package.json.template +1 -0
- package/src/generators/application/lib/add-project.js +7 -0
- package/src/generators/init/init.js +1 -2
- package/src/generators/library/library.js +1 -1
- 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 +43 -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 +71 -0
- package/src/utils/get-cli-options.js +4 -1
- package/src/utils/pod-install-task.d.ts +10 -2
- package/src/utils/pod-install-task.js +12 -4
- package/src/utils/versions.d.ts +10 -9
- package/src/utils/versions.js +11 -10
- package/src/generators/application/files/app/.ruby-version +0 -1
- /package/src/generators/library/files/lib/{package.json__tmpl__ → package.json.template} +0 -0
- /package/src/generators/library/files/lib/src/{index.ts__tmpl__ → index.ts.template} +0 -0
- /package/src/generators/library/files/lib/{tsconfig.json__tmpl__ → tsconfig.json.template} +0 -0
- /package/src/generators/library/files/lib/{tsconfig.lib.json__tmpl__ → tsconfig.lib.json.template} +0 -0
|
@@ -4,42 +4,49 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const child_process_1 = require("child_process");
|
|
6
6
|
const os_1 = require("os");
|
|
7
|
-
const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
|
|
8
|
-
const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
|
|
9
|
-
const pod_install_task_1 = require("../../utils/pod-install-task");
|
|
10
7
|
const start_impl_1 = require("../start/start.impl");
|
|
11
8
|
const get_cli_options_1 = require("../../utils/get-cli-options");
|
|
12
|
-
let childProcess;
|
|
13
9
|
function runIosExecutor(options, context) {
|
|
14
10
|
return tslib_1.__asyncGenerator(this, arguments, function* runIosExecutor_1() {
|
|
11
|
+
var _a, e_1, _b, _c;
|
|
15
12
|
if ((0, os_1.platform)() !== 'darwin') {
|
|
16
13
|
throw new Error(`The run-ios build requires Mac to run`);
|
|
17
14
|
}
|
|
18
15
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
19
|
-
(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
if (options.packager && options.mode !== 'Release') {
|
|
17
|
+
const startResults = (0, start_impl_1.default)({
|
|
18
|
+
port: options.port,
|
|
19
|
+
resetCache: options.resetCache,
|
|
20
|
+
interactive: true,
|
|
21
|
+
}, context);
|
|
22
|
+
try {
|
|
23
|
+
for (var _d = true, startResults_1 = tslib_1.__asyncValues(startResults), startResults_1_1; startResults_1_1 = yield tslib_1.__await(startResults_1.next()), _a = startResults_1_1.done, !_a; _d = true) {
|
|
24
|
+
_c = startResults_1_1.value;
|
|
25
|
+
_d = false;
|
|
26
|
+
const result = _c;
|
|
27
|
+
if (result.success) {
|
|
28
|
+
yield tslib_1.__await(runCliRunIOS(context.root, projectRoot, options));
|
|
29
|
+
yield yield tslib_1.__await({
|
|
30
|
+
success: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return yield tslib_1.__await(result);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
39
|
+
finally {
|
|
40
|
+
try {
|
|
41
|
+
if (!_d && !_a && (_b = startResults_1.return)) yield tslib_1.__await(_b.call(startResults_1));
|
|
42
|
+
}
|
|
43
|
+
finally { if (e_1) throw e_1.error; }
|
|
41
44
|
}
|
|
42
45
|
}
|
|
46
|
+
else {
|
|
47
|
+
yield tslib_1.__await(runCliRunIOS(context.root, projectRoot, options));
|
|
48
|
+
}
|
|
49
|
+
yield yield tslib_1.__await({ success: true });
|
|
43
50
|
});
|
|
44
51
|
}
|
|
45
52
|
exports.default = runIosExecutor;
|
|
@@ -49,19 +56,28 @@ function runCliRunIOS(workspaceRoot, projectRoot, options) {
|
|
|
49
56
|
* Call the react native cli with option `--no-packager`
|
|
50
57
|
* Not passing '--packager' due to cli will launch start command from the project root
|
|
51
58
|
*/
|
|
52
|
-
childProcess = (0, child_process_1.fork)(
|
|
53
|
-
|
|
59
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['run-ios', ...createRunIOSOptions(options), '--no-packager'], {
|
|
60
|
+
stdio: 'inherit',
|
|
61
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
54
62
|
env: Object.assign(Object.assign({}, process.env), { RCT_METRO_PORT: options.port.toString() }),
|
|
55
63
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Ensure the child process is killed when the parent exits
|
|
66
|
+
*/
|
|
67
|
+
const processExitListener = (signal) => () => {
|
|
68
|
+
childProcess.kill(signal);
|
|
69
|
+
process.exit();
|
|
70
|
+
};
|
|
71
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
72
|
+
process.once('SIGTERM', processExitListener);
|
|
73
|
+
process.once('SIGINT', processExitListener);
|
|
74
|
+
process.once('SIGQUIT', processExitListener);
|
|
59
75
|
childProcess.on('error', (err) => {
|
|
60
76
|
reject(err);
|
|
61
77
|
});
|
|
62
78
|
childProcess.on('exit', (code) => {
|
|
63
79
|
if (code === 0) {
|
|
64
|
-
resolve(
|
|
80
|
+
resolve(childProcess);
|
|
65
81
|
}
|
|
66
82
|
else {
|
|
67
83
|
reject(code);
|
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import {
|
|
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
|
|
7
|
-
import {
|
|
8
|
-
displayNewlyAddedDepsMessage,
|
|
9
|
-
syncDeps,
|
|
10
|
-
} from '../sync-deps/sync-deps.impl';
|
|
11
|
-
import { podInstall } from '../../utils/pod-install-task';
|
|
12
|
-
import { ReactNativeRunIosOptions } from './schema';
|
|
13
|
-
import { runCliStart } from '../start/start.impl';
|
|
6
|
+
import startExecutor from '../start/start.impl';
|
|
14
7
|
import { getCliOptions } from '../../utils/get-cli-options';
|
|
15
8
|
|
|
9
|
+
import { ReactNativeRunIosOptions } from './schema';
|
|
16
10
|
export interface ReactNativeRunIosOutput {
|
|
17
11
|
success: boolean;
|
|
18
12
|
}
|
|
19
13
|
|
|
20
|
-
let childProcess: ChildProcess;
|
|
21
|
-
|
|
22
14
|
export default async function* runIosExecutor(
|
|
23
15
|
options: ReactNativeRunIosOptions,
|
|
24
16
|
context: ExecutorContext
|
|
@@ -28,77 +20,71 @@ export default async function* runIosExecutor(
|
|
|
28
20
|
}
|
|
29
21
|
const projectRoot =
|
|
30
22
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
31
|
-
ensureNodeModulesSymlink(context.root, projectRoot);
|
|
32
|
-
if (options.sync) {
|
|
33
|
-
displayNewlyAddedDepsMessage(
|
|
34
|
-
context.projectName,
|
|
35
|
-
await syncDeps(
|
|
36
|
-
context.projectName,
|
|
37
|
-
projectRoot,
|
|
38
|
-
context.root,
|
|
39
|
-
context.projectGraph
|
|
40
|
-
)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
23
|
|
|
44
|
-
if (options.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
24
|
+
if (options.packager && options.mode !== 'Release') {
|
|
25
|
+
const startResults = startExecutor(
|
|
26
|
+
{
|
|
27
|
+
port: options.port,
|
|
28
|
+
resetCache: options.resetCache,
|
|
29
|
+
interactive: true,
|
|
30
|
+
},
|
|
31
|
+
context
|
|
48
32
|
);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
interactive: options.interactive,
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
await Promise.all(tasks);
|
|
64
|
-
|
|
65
|
-
yield { success: true };
|
|
66
|
-
} finally {
|
|
67
|
-
if (childProcess) {
|
|
68
|
-
childProcess.kill();
|
|
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
|
+
}
|
|
69
42
|
}
|
|
43
|
+
} else {
|
|
44
|
+
await runCliRunIOS(context.root, projectRoot, options);
|
|
70
45
|
}
|
|
46
|
+
|
|
47
|
+
yield { success: true };
|
|
71
48
|
}
|
|
72
49
|
|
|
73
50
|
function runCliRunIOS(
|
|
74
51
|
workspaceRoot: string,
|
|
75
52
|
projectRoot: string,
|
|
76
53
|
options: ReactNativeRunIosOptions
|
|
77
|
-
) {
|
|
78
|
-
return new Promise((resolve, reject) => {
|
|
54
|
+
): Promise<ChildProcess> {
|
|
55
|
+
return new Promise<ChildProcess>((resolve, reject) => {
|
|
79
56
|
/**
|
|
80
57
|
* Call the react native cli with option `--no-packager`
|
|
81
58
|
* Not passing '--packager' due to cli will launch start command from the project root
|
|
82
59
|
*/
|
|
83
|
-
childProcess = fork(
|
|
84
|
-
|
|
60
|
+
const childProcess = fork(
|
|
61
|
+
require.resolve('react-native/cli.js'),
|
|
85
62
|
['run-ios', ...createRunIOSOptions(options), '--no-packager'],
|
|
86
63
|
{
|
|
87
|
-
|
|
64
|
+
stdio: 'inherit',
|
|
65
|
+
cwd: pathResolve(workspaceRoot, projectRoot),
|
|
88
66
|
env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
|
|
89
67
|
}
|
|
90
68
|
);
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Ensure the child process is killed when the parent exits
|
|
72
|
+
*/
|
|
73
|
+
const processExitListener = (signal?: number | NodeJS.Signals) => () => {
|
|
74
|
+
childProcess.kill(signal);
|
|
75
|
+
process.exit();
|
|
76
|
+
};
|
|
77
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
78
|
+
process.once('SIGTERM', processExitListener);
|
|
79
|
+
process.once('SIGINT', processExitListener);
|
|
80
|
+
process.once('SIGQUIT', processExitListener);
|
|
95
81
|
|
|
96
82
|
childProcess.on('error', (err) => {
|
|
97
83
|
reject(err);
|
|
98
84
|
});
|
|
99
85
|
childProcess.on('exit', (code) => {
|
|
100
86
|
if (code === 0) {
|
|
101
|
-
resolve(
|
|
87
|
+
resolve(childProcess);
|
|
102
88
|
} else {
|
|
103
89
|
reject(code);
|
|
104
90
|
}
|
|
@@ -4,7 +4,7 @@ import { ReactNativeStartOptions } from '../start/schema';
|
|
|
4
4
|
// part of options form https://github.com/react-native-community/cli/blob/main/packages/cli-platform-ios/src/commands/runIOS/index.ts
|
|
5
5
|
export interface ReactNativeRunIosOptions extends ReactNativeBuildIosOptions {
|
|
6
6
|
/**
|
|
7
|
-
* @deprecated use mode instead, will be removed in nx 17.
|
|
7
|
+
* @deprecated TODO(v17) use mode instead, will be removed in nx 17.
|
|
8
8
|
*/
|
|
9
9
|
xcodeConfiguration?: string;
|
|
10
10
|
|
|
@@ -19,10 +19,6 @@
|
|
|
19
19
|
{
|
|
20
20
|
"name": "Run iOS on a device with udid",
|
|
21
21
|
"keys": ["udid"]
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "Run `pod install` before building iOS app",
|
|
25
|
-
"keys": ["install"]
|
|
26
22
|
}
|
|
27
23
|
],
|
|
28
24
|
"properties": {
|
|
@@ -87,17 +83,22 @@
|
|
|
87
83
|
"description": "Explicitly select which scheme and configuration to use before running a build"
|
|
88
84
|
},
|
|
89
85
|
"extraParams": {
|
|
90
|
-
"
|
|
86
|
+
"oneOf": [
|
|
87
|
+
{ "type": "array", "items": { "type": "string" } },
|
|
88
|
+
{ "type": "string" }
|
|
89
|
+
],
|
|
91
90
|
"description": "Custom params that will be passed to xcodebuild command."
|
|
92
91
|
},
|
|
93
92
|
"install": {
|
|
94
93
|
"type": "boolean",
|
|
95
94
|
"description": "Runs `pod install` for native modules before building iOS app.",
|
|
96
|
-
"default": true
|
|
95
|
+
"default": true,
|
|
96
|
+
"x-deprecated": "Add `pod-install` to dependsOn for this target in project.json instead."
|
|
97
97
|
},
|
|
98
98
|
"sync": {
|
|
99
99
|
"type": "boolean",
|
|
100
100
|
"description": "Syncs npm dependencies to `package.json` (for React Native autolink).",
|
|
101
|
+
"x-deprecated": "Add `sync-deps` to dependsOn for this target in project.json instead.",
|
|
101
102
|
"default": true
|
|
102
103
|
},
|
|
103
104
|
"resetCache": {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ExecutorContext } from '@nx/devkit';
|
|
3
|
+
import { ChildProcess } from 'child_process';
|
|
2
4
|
import { ReactNativeStartOptions } from './schema';
|
|
3
5
|
export interface ReactNativeStartOutput {
|
|
4
|
-
|
|
6
|
+
port?: number;
|
|
5
7
|
success: boolean;
|
|
6
8
|
}
|
|
7
9
|
export default function startExecutor(options: ReactNativeStartOptions, context: ExecutorContext): AsyncGenerator<ReactNativeStartOutput>;
|
|
8
|
-
export declare function runCliStart(workspaceRoot: string, projectRoot: string, options: ReactNativeStartOptions): Promise<
|
|
10
|
+
export declare function runCliStart(workspaceRoot: string, projectRoot: string, options: ReactNativeStartOptions): Promise<ChildProcess>;
|
|
@@ -2,33 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runCliStart = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const chalk = require("chalk");
|
|
6
5
|
const devkit_1 = require("@nx/devkit");
|
|
7
6
|
const child_process_1 = require("child_process");
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
|
|
10
9
|
const is_packager_running_1 = require("./lib/is-packager-running");
|
|
11
|
-
let childProcess;
|
|
12
10
|
function startExecutor(options, context) {
|
|
13
11
|
return tslib_1.__asyncGenerator(this, arguments, function* startExecutor_1() {
|
|
14
12
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
15
13
|
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
baseUrl,
|
|
24
|
-
success: true,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
if (childProcess) {
|
|
29
|
-
childProcess.kill();
|
|
30
|
-
}
|
|
14
|
+
const startProcess = yield tslib_1.__await(runCliStart(context.root, projectRoot, options));
|
|
15
|
+
yield yield tslib_1.__await({
|
|
16
|
+
port: options.port,
|
|
17
|
+
success: true,
|
|
18
|
+
});
|
|
19
|
+
if (!startProcess) {
|
|
20
|
+
return yield tslib_1.__await(void 0);
|
|
31
21
|
}
|
|
22
|
+
yield tslib_1.__await(new Promise((resolve) => {
|
|
23
|
+
const processExitListener = (signal) => () => {
|
|
24
|
+
startProcess.kill(signal);
|
|
25
|
+
resolve();
|
|
26
|
+
process.exit();
|
|
27
|
+
};
|
|
28
|
+
process.once('exit', (signal) => startProcess.kill(signal));
|
|
29
|
+
process.once('SIGTERM', processExitListener);
|
|
30
|
+
process.once('SIGINT', processExitListener);
|
|
31
|
+
process.once('SIGQUIT', processExitListener);
|
|
32
|
+
}));
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
exports.default = startExecutor;
|
|
@@ -40,7 +41,7 @@ function runCliStart(workspaceRoot, projectRoot, options) {
|
|
|
40
41
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
41
42
|
const result = yield (0, is_packager_running_1.isPackagerRunning)(options.port);
|
|
42
43
|
if (result === 'running') {
|
|
43
|
-
devkit_1.logger.info(
|
|
44
|
+
devkit_1.logger.info(`JS server already running on port ${options.port}.`);
|
|
44
45
|
}
|
|
45
46
|
else if (result === 'unrecognized') {
|
|
46
47
|
devkit_1.logger.warn('JS server not recognized.');
|
|
@@ -49,7 +50,7 @@ function runCliStart(workspaceRoot, projectRoot, options) {
|
|
|
49
50
|
// result === 'not_running'
|
|
50
51
|
devkit_1.logger.info('Starting JS server...');
|
|
51
52
|
try {
|
|
52
|
-
yield startAsync(workspaceRoot, projectRoot, options);
|
|
53
|
+
return yield startAsync(workspaceRoot, projectRoot, options);
|
|
53
54
|
}
|
|
54
55
|
catch (error) {
|
|
55
56
|
devkit_1.logger.error(`Failed to start the packager server. Error details: ${error.message}`);
|
|
@@ -61,16 +62,26 @@ function runCliStart(workspaceRoot, projectRoot, options) {
|
|
|
61
62
|
exports.runCliStart = runCliStart;
|
|
62
63
|
function startAsync(workspaceRoot, projectRoot, options) {
|
|
63
64
|
return new Promise((resolve, reject) => {
|
|
64
|
-
childProcess = (0, child_process_1.fork)(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['start', ...createStartOptions(options)], {
|
|
66
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
67
|
+
env: process.env,
|
|
68
|
+
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
|
69
|
+
});
|
|
70
|
+
childProcess.stdout.on('data', (data) => {
|
|
71
|
+
process.stdout.write(data);
|
|
72
|
+
if (data.toString().includes('reload the app')) {
|
|
73
|
+
resolve(childProcess);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
childProcess.stderr.on('data', (data) => {
|
|
77
|
+
process.stderr.write(data);
|
|
78
|
+
});
|
|
68
79
|
childProcess.on('error', (err) => {
|
|
69
80
|
reject(err);
|
|
70
81
|
});
|
|
71
82
|
childProcess.on('exit', (code) => {
|
|
72
83
|
if (code === 0) {
|
|
73
|
-
resolve(
|
|
84
|
+
resolve(childProcess);
|
|
74
85
|
}
|
|
75
86
|
else {
|
|
76
87
|
reject(code);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import * as chalk from 'chalk';
|
|
2
1
|
import { ExecutorContext, logger } from '@nx/devkit';
|
|
3
2
|
import { ChildProcess, fork } from 'child_process';
|
|
4
|
-
import {
|
|
3
|
+
import { resolve as pathResolve } from 'path';
|
|
5
4
|
import { ensureNodeModulesSymlink } from '../../utils/ensure-node-modules-symlink';
|
|
6
5
|
import { isPackagerRunning } from './lib/is-packager-running';
|
|
7
6
|
import { ReactNativeStartOptions } from './schema';
|
|
8
7
|
|
|
9
8
|
export interface ReactNativeStartOutput {
|
|
10
|
-
|
|
9
|
+
port?: number;
|
|
11
10
|
success: boolean;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
let childProcess: ChildProcess;
|
|
15
|
-
|
|
16
13
|
export default async function* startExecutor(
|
|
17
14
|
options: ReactNativeStartOptions,
|
|
18
15
|
context: ExecutorContext
|
|
@@ -21,27 +18,27 @@ export default async function* startExecutor(
|
|
|
21
18
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
22
19
|
ensureNodeModulesSymlink(context.root, projectRoot);
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
const baseUrl = `http://localhost:${options.port}`;
|
|
26
|
-
const appName = context.projectName;
|
|
27
|
-
logger.info(chalk.cyan(`Packager is ready at ${baseUrl}`));
|
|
28
|
-
logger.info(
|
|
29
|
-
`Use ${chalk.bold(`nx run-android ${appName}`)} or ${chalk.bold(
|
|
30
|
-
`nx run-ios ${appName}`
|
|
31
|
-
)} to run the native app.`
|
|
32
|
-
);
|
|
21
|
+
const startProcess = await runCliStart(context.root, projectRoot, options);
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
yield {
|
|
24
|
+
port: options.port,
|
|
25
|
+
success: true,
|
|
26
|
+
};
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
success: true,
|
|
39
|
-
};
|
|
40
|
-
} finally {
|
|
41
|
-
if (childProcess) {
|
|
42
|
-
childProcess.kill();
|
|
43
|
-
}
|
|
28
|
+
if (!startProcess) {
|
|
29
|
+
return;
|
|
44
30
|
}
|
|
31
|
+
await new Promise<void>((resolve) => {
|
|
32
|
+
const processExitListener = (signal?: number | NodeJS.Signals) => () => {
|
|
33
|
+
startProcess.kill(signal);
|
|
34
|
+
resolve();
|
|
35
|
+
process.exit();
|
|
36
|
+
};
|
|
37
|
+
process.once('exit', (signal) => startProcess.kill(signal));
|
|
38
|
+
process.once('SIGTERM', processExitListener);
|
|
39
|
+
process.once('SIGINT', processExitListener);
|
|
40
|
+
process.once('SIGQUIT', processExitListener);
|
|
41
|
+
});
|
|
45
42
|
}
|
|
46
43
|
|
|
47
44
|
/*
|
|
@@ -52,10 +49,10 @@ export async function runCliStart(
|
|
|
52
49
|
workspaceRoot: string,
|
|
53
50
|
projectRoot: string,
|
|
54
51
|
options: ReactNativeStartOptions
|
|
55
|
-
): Promise<
|
|
52
|
+
): Promise<ChildProcess> {
|
|
56
53
|
const result = await isPackagerRunning(options.port);
|
|
57
54
|
if (result === 'running') {
|
|
58
|
-
logger.info(
|
|
55
|
+
logger.info(`JS server already running on port ${options.port}.`);
|
|
59
56
|
} else if (result === 'unrecognized') {
|
|
60
57
|
logger.warn('JS server not recognized.');
|
|
61
58
|
} else {
|
|
@@ -63,7 +60,7 @@ export async function runCliStart(
|
|
|
63
60
|
logger.info('Starting JS server...');
|
|
64
61
|
|
|
65
62
|
try {
|
|
66
|
-
await startAsync(workspaceRoot, projectRoot, options);
|
|
63
|
+
return await startAsync(workspaceRoot, projectRoot, options);
|
|
67
64
|
} catch (error) {
|
|
68
65
|
logger.error(
|
|
69
66
|
`Failed to start the packager server. Error details: ${error.message}`
|
|
@@ -77,24 +74,34 @@ function startAsync(
|
|
|
77
74
|
workspaceRoot: string,
|
|
78
75
|
projectRoot: string,
|
|
79
76
|
options: ReactNativeStartOptions
|
|
80
|
-
): Promise<
|
|
81
|
-
return new Promise((resolve, reject) => {
|
|
82
|
-
childProcess = fork(
|
|
83
|
-
|
|
77
|
+
): Promise<ChildProcess> {
|
|
78
|
+
return new Promise<ChildProcess>((resolve, reject) => {
|
|
79
|
+
const childProcess = fork(
|
|
80
|
+
require.resolve('react-native/cli.js'),
|
|
84
81
|
['start', ...createStartOptions(options)],
|
|
85
|
-
{
|
|
82
|
+
{
|
|
83
|
+
cwd: pathResolve(workspaceRoot, projectRoot),
|
|
84
|
+
env: process.env,
|
|
85
|
+
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
|
86
|
+
}
|
|
86
87
|
);
|
|
87
88
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
childProcess.stdout.on('data', (data) => {
|
|
90
|
+
process.stdout.write(data);
|
|
91
|
+
if (data.toString().includes('reload the app')) {
|
|
92
|
+
resolve(childProcess);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
childProcess.stderr.on('data', (data) => {
|
|
96
|
+
process.stderr.write(data);
|
|
97
|
+
});
|
|
91
98
|
|
|
92
99
|
childProcess.on('error', (err) => {
|
|
93
100
|
reject(err);
|
|
94
101
|
});
|
|
95
102
|
childProcess.on('exit', (code) => {
|
|
96
103
|
if (code === 0) {
|
|
97
|
-
resolve(
|
|
104
|
+
resolve(childProcess);
|
|
98
105
|
} else {
|
|
99
106
|
reject(code);
|
|
100
107
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.reactNativeApplicationSchematic = exports.reactNativeApplicationGenerator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const pod_install_task_1 = require("../../utils/pod-install-task");
|
|
7
6
|
const symlink_task_1 = require("../../utils/symlink-task");
|
|
8
7
|
const add_linting_1 = require("../../utils/add-linting");
|
|
9
8
|
const add_jest_1 = require("../../utils/add-jest");
|
|
@@ -25,12 +24,11 @@ function reactNativeApplicationGenerator(host, schema) {
|
|
|
25
24
|
const jestTask = yield (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson);
|
|
26
25
|
const detoxTask = yield (0, add_detox_1.addDetox)(host, options);
|
|
27
26
|
const symlinkTask = (0, symlink_task_1.runSymlink)(host.root, options.appProjectRoot);
|
|
28
|
-
const podInstallTask = (0, pod_install_task_1.runPodInstall)((0, devkit_1.joinPathFragments)(host.root, options.iosProjectRoot), options.install);
|
|
29
27
|
const chmodTaskGradlew = (0, chmod_android_gradle_files_1.chmodAndroidGradlewFilesTask)((0, devkit_1.joinPathFragments)(host.root, options.androidProjectRoot));
|
|
30
28
|
if (!options.skipFormat) {
|
|
31
29
|
yield (0, devkit_1.formatFiles)(host);
|
|
32
30
|
}
|
|
33
|
-
return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask,
|
|
31
|
+
return (0, devkit_1.runTasksInSerial)(initTask, lintTask, jestTask, detoxTask, symlinkTask, chmodTaskGradlew);
|
|
34
32
|
});
|
|
35
33
|
}
|
|
36
34
|
exports.reactNativeApplicationGenerator = reactNativeApplicationGenerator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
|
|
3
3
|
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
|
|
4
|
-
ruby
|
|
4
|
+
ruby ">= 2.6.10"
|
|
5
5
|
|
|
6
|
-
gem 'cocoapods', '~> 1.
|
|
6
|
+
gem 'cocoapods', '~> 1.12'
|