@nx/react-native 16.6.0-beta.3 → 16.6.0-beta.5
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 +23 -0
- package/migrations.json +78 -0
- package/package.json +15 -13
- 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/files/app/src/app/App.tsx.template +1 -1
- package/src/generators/application/files/app/tsconfig.app.json.template +1 -0
- package/src/generators/application/files/app/tsconfig.json.template +1 -7
- package/src/generators/application/lib/add-project.js +7 -0
- package/src/generators/init/init.js +1 -2
- package/src/generators/library/library.js +5 -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
package/.eslintrc.json
CHANGED
|
@@ -14,6 +14,29 @@
|
|
|
14
14
|
"rules": {
|
|
15
15
|
"@nx/nx-plugin-checks": "error"
|
|
16
16
|
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"files": ["./package.json"],
|
|
20
|
+
"parser": "jsonc-eslint-parser",
|
|
21
|
+
"rules": {
|
|
22
|
+
"@nx/dependency-checks": [
|
|
23
|
+
"error",
|
|
24
|
+
{
|
|
25
|
+
"buildTargets": ["build-base"],
|
|
26
|
+
"ignoredDependencies": [
|
|
27
|
+
"nx",
|
|
28
|
+
"eslint",
|
|
29
|
+
"prettier",
|
|
30
|
+
"typescript",
|
|
31
|
+
"react",
|
|
32
|
+
"react-native",
|
|
33
|
+
// These are in ensurePackage
|
|
34
|
+
"@nx/rollup",
|
|
35
|
+
"@nx/storybook"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
17
40
|
}
|
|
18
41
|
]
|
|
19
42
|
}
|
package/migrations.json
CHANGED
|
@@ -89,6 +89,18 @@
|
|
|
89
89
|
"version": "16.1.0-beta.0",
|
|
90
90
|
"description": "Upgrade @storybook/react-native to 6.5",
|
|
91
91
|
"implementation": "./src/migrations/update-16-1-0/upgrade-storybook-6-5"
|
|
92
|
+
},
|
|
93
|
+
"update-16-6-0-add-dependsOn": {
|
|
94
|
+
"cli": "nx",
|
|
95
|
+
"version": "16.6.0-beta.0",
|
|
96
|
+
"description": "Add dependsOn like ensure-symlink or sync-deps to targets",
|
|
97
|
+
"implementation": "./src/migrations/update-16-6-0/add-depends-on"
|
|
98
|
+
},
|
|
99
|
+
"update-16-6-0-update-metro-config": {
|
|
100
|
+
"cli": "nx",
|
|
101
|
+
"version": "16.6.0-beta.0",
|
|
102
|
+
"description": "Update metro.config.js to use the new metro config format",
|
|
103
|
+
"implementation": "./src/migrations/update-16-6-0/update-metro-config"
|
|
92
104
|
}
|
|
93
105
|
},
|
|
94
106
|
"packageJsonUpdates": {
|
|
@@ -1348,6 +1360,72 @@
|
|
|
1348
1360
|
"alwaysAddToPackageJson": false
|
|
1349
1361
|
}
|
|
1350
1362
|
}
|
|
1363
|
+
},
|
|
1364
|
+
"16.6.0": {
|
|
1365
|
+
"version": "16.6.0-beta.0",
|
|
1366
|
+
"packages": {
|
|
1367
|
+
"react-native": {
|
|
1368
|
+
"version": "0.72.3",
|
|
1369
|
+
"alwaysAddToPackageJson": false
|
|
1370
|
+
},
|
|
1371
|
+
"@types/react-native": {
|
|
1372
|
+
"version": "0.72.2",
|
|
1373
|
+
"alwaysAddToPackageJson": false
|
|
1374
|
+
},
|
|
1375
|
+
"metro": {
|
|
1376
|
+
"version": "0.76.7",
|
|
1377
|
+
"alwaysAddToPackageJson": false
|
|
1378
|
+
},
|
|
1379
|
+
"metro-resolver": {
|
|
1380
|
+
"version": "0.76.7",
|
|
1381
|
+
"alwaysAddToPackageJson": false
|
|
1382
|
+
},
|
|
1383
|
+
"metro-config": {
|
|
1384
|
+
"version": "0.76.7",
|
|
1385
|
+
"alwaysAddToPackageJson": false
|
|
1386
|
+
},
|
|
1387
|
+
"metro-react-native-babel-preset": {
|
|
1388
|
+
"version": "0.76.7",
|
|
1389
|
+
"alwaysAddToPackageJson": false
|
|
1390
|
+
},
|
|
1391
|
+
"metro-babel-register": {
|
|
1392
|
+
"version": "0.76.7",
|
|
1393
|
+
"alwaysAddToPackageJson": false
|
|
1394
|
+
},
|
|
1395
|
+
"metro-react-native-babel-transformer": {
|
|
1396
|
+
"version": "0.76.7",
|
|
1397
|
+
"alwaysAddToPackageJson": false
|
|
1398
|
+
},
|
|
1399
|
+
"@react-native/metro-config": {
|
|
1400
|
+
"version": "^0.72.9",
|
|
1401
|
+
"alwaysAddToPackageJson": false,
|
|
1402
|
+
"addToPackageJson": "devDependencies"
|
|
1403
|
+
},
|
|
1404
|
+
"@react-native-community/cli": {
|
|
1405
|
+
"version": "11.3.5",
|
|
1406
|
+
"alwaysAddToPackageJson": false
|
|
1407
|
+
},
|
|
1408
|
+
"@react-native-community/cli-platform-android": {
|
|
1409
|
+
"version": "11.3.5",
|
|
1410
|
+
"alwaysAddToPackageJson": false
|
|
1411
|
+
},
|
|
1412
|
+
"@react-native-community/cli-platform-ios": {
|
|
1413
|
+
"version": "11.3.5",
|
|
1414
|
+
"alwaysAddToPackageJson": false
|
|
1415
|
+
},
|
|
1416
|
+
"@babel/runtime": {
|
|
1417
|
+
"version": "7.22.6",
|
|
1418
|
+
"alwaysAddToPackageJson": false
|
|
1419
|
+
},
|
|
1420
|
+
"@react-native-async-storage/async-storage": {
|
|
1421
|
+
"version": "1.19.0",
|
|
1422
|
+
"alwaysAddToPackageJson": false
|
|
1423
|
+
},
|
|
1424
|
+
"react-native-safe-area-context": {
|
|
1425
|
+
"version": "4.7.1",
|
|
1426
|
+
"alwaysAddToPackageJson": false
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1351
1429
|
}
|
|
1352
1430
|
}
|
|
1353
1431
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "16.6.0-beta.
|
|
3
|
+
"version": "16.6.0-beta.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
|
|
6
6
|
"keywords": [
|
|
@@ -25,26 +25,28 @@
|
|
|
25
25
|
"main": "./index",
|
|
26
26
|
"types": "index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@nrwl/react-native": "16.6.0-beta.
|
|
29
|
-
"@nx/detox": "16.6.0-beta.
|
|
30
|
-
"@nx/devkit": "16.6.0-beta.
|
|
31
|
-
"@nx/jest": "16.6.0-beta.
|
|
32
|
-
"@nx/js": "16.6.0-beta.
|
|
33
|
-
"@nx/linter": "16.6.0-beta.
|
|
34
|
-
"@nx/react": "16.6.0-beta.
|
|
35
|
-
"@nx/workspace": "16.6.0-beta.
|
|
28
|
+
"@nrwl/react-native": "16.6.0-beta.5",
|
|
29
|
+
"@nx/detox": "16.6.0-beta.5",
|
|
30
|
+
"@nx/devkit": "16.6.0-beta.5",
|
|
31
|
+
"@nx/jest": "16.6.0-beta.5",
|
|
32
|
+
"@nx/js": "16.6.0-beta.5",
|
|
33
|
+
"@nx/linter": "16.6.0-beta.5",
|
|
34
|
+
"@nx/react": "16.6.0-beta.5",
|
|
35
|
+
"@nx/workspace": "16.6.0-beta.5",
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
37
|
"enhanced-resolve": "^5.8.3",
|
|
38
38
|
"fs-extra": "^11.1.0",
|
|
39
39
|
"glob": "7.1.4",
|
|
40
40
|
"ignore": "^5.0.4",
|
|
41
|
-
"metro-
|
|
41
|
+
"metro-config": "0.76.7",
|
|
42
|
+
"metro-resolver": "0.76.7",
|
|
42
43
|
"minimatch": "3.0.5",
|
|
43
44
|
"node-fetch": "^2.6.7",
|
|
44
|
-
"tsconfig-paths": "^4.1.2"
|
|
45
|
+
"tsconfig-paths": "^4.1.2",
|
|
46
|
+
"tslib": "^2.3.0"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
|
-
"react-native": ">= 0.
|
|
49
|
+
"react-native": ">= 0.72.0 < 0.73.0"
|
|
48
50
|
},
|
|
49
51
|
"builders": "./executors.json",
|
|
50
52
|
"ng-update": {
|
|
@@ -55,5 +57,5 @@
|
|
|
55
57
|
"publishConfig": {
|
|
56
58
|
"access": "public"
|
|
57
59
|
},
|
|
58
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "aab868aa0c30949832fe2c4b9cb109c204442e39"
|
|
59
61
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import type { MetroConfig } from 'metro-config';
|
|
1
2
|
interface WithNxOptions {
|
|
2
3
|
debug?: boolean;
|
|
3
4
|
extensions?: string[];
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated TODO(v17) in the metro.config.js, pass in to the getDefaultConfig instead: getDefaultConfig(__dirname)
|
|
7
|
+
*/
|
|
4
8
|
projectRoot?: string;
|
|
5
9
|
watchFolders?: string[];
|
|
6
10
|
}
|
|
7
|
-
export declare function withNxMetro(
|
|
11
|
+
export declare function withNxMetro(userConfig: MetroConfig, opts?: WithNxOptions): Promise<import("metro-config").ConfigT>;
|
|
8
12
|
export {};
|
package/plugins/with-nx-metro.js
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withNxMetro = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const metro_config_1 = require("metro-config");
|
|
5
7
|
const path_1 = require("path");
|
|
6
8
|
const fs_extra_1 = require("fs-extra");
|
|
7
9
|
const metro_resolver_1 = require("./metro-resolver");
|
|
8
|
-
function withNxMetro(
|
|
10
|
+
function withNxMetro(userConfig, opts = {}) {
|
|
9
11
|
var _a;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
(0
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
const extensions = ['', 'ts', 'tsx', 'js', 'jsx', 'json'];
|
|
14
|
+
if (opts.debug)
|
|
15
|
+
process.env.NX_REACT_NATIVE_DEBUG = 'true';
|
|
16
|
+
if (opts.extensions)
|
|
17
|
+
extensions.push(...opts.extensions);
|
|
18
|
+
let watchFolders = [
|
|
19
|
+
(0, path_1.join)(devkit_1.workspaceRoot, 'node_modules'),
|
|
20
|
+
(0, path_1.join)(devkit_1.workspaceRoot, (0, devkit_1.workspaceLayout)().libsDir),
|
|
21
|
+
(0, path_1.join)(devkit_1.workspaceRoot, 'packages'),
|
|
22
|
+
(0, path_1.join)(devkit_1.workspaceRoot, '.storybook'),
|
|
23
|
+
];
|
|
24
|
+
if ((_a = opts.watchFolders) === null || _a === void 0 ? void 0 : _a.length) {
|
|
25
|
+
watchFolders = watchFolders.concat(opts.watchFolders);
|
|
26
|
+
}
|
|
27
|
+
watchFolders = watchFolders.filter((folder) => (0, fs_extra_1.existsSync)(folder));
|
|
28
|
+
const nxConfig = {
|
|
29
|
+
resolver: {
|
|
30
|
+
resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions),
|
|
31
|
+
},
|
|
32
|
+
watchFolders,
|
|
33
|
+
};
|
|
34
|
+
return (0, metro_config_1.mergeConfig)(userConfig, nxConfig);
|
|
35
|
+
});
|
|
31
36
|
}
|
|
32
37
|
exports.withNxMetro = withNxMetro;
|
|
@@ -2,60 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
|
|
6
5
|
const child_process_1 = require("child_process");
|
|
7
6
|
const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
|
|
8
|
-
const start_impl_1 = require("../start/start.impl");
|
|
9
|
-
const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
|
|
10
7
|
const get_cli_options_1 = require("../../utils/get-cli-options");
|
|
11
|
-
let childProcess;
|
|
12
8
|
function buildAndroidExecutor(options, context) {
|
|
13
9
|
return tslib_1.__asyncGenerator(this, arguments, function* buildAndroidExecutor_1() {
|
|
14
10
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
15
|
-
(0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
|
|
16
|
-
if (options.sync) {
|
|
17
|
-
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, yield tslib_1.__await((0, sync_deps_impl_1.syncDeps)(context.projectName, projectRoot, context.root, context.projectGraph)));
|
|
18
|
-
}
|
|
19
11
|
(0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (options.packager && options.mode !== 'release') {
|
|
23
|
-
tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
|
|
24
|
-
port: options.port,
|
|
25
|
-
resetCache: options.resetCache,
|
|
26
|
-
interactive: options.interactive,
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
yield tslib_1.__await(Promise.all(tasks));
|
|
30
|
-
yield yield tslib_1.__await({ success: true });
|
|
31
|
-
}
|
|
32
|
-
finally {
|
|
33
|
-
if (childProcess) {
|
|
34
|
-
childProcess.kill();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
12
|
+
yield tslib_1.__await(runCliBuild(context.root, projectRoot, options));
|
|
13
|
+
yield yield tslib_1.__await({ success: true });
|
|
37
14
|
});
|
|
38
15
|
}
|
|
39
16
|
exports.default = buildAndroidExecutor;
|
|
40
17
|
function runCliBuild(workspaceRoot, projectRoot, options) {
|
|
41
|
-
return new Promise((
|
|
18
|
+
return new Promise((res, reject) => {
|
|
42
19
|
/**
|
|
43
20
|
* Call the react native cli with option `--no-packager`
|
|
44
21
|
* Not passing '--packager' due to cli will launch start command from the project root
|
|
45
22
|
*/
|
|
46
|
-
childProcess = (0, child_process_1.fork)(
|
|
47
|
-
|
|
23
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['build-android', ...createBuildAndroidOptions(options), '--no-packager'], {
|
|
24
|
+
stdio: 'inherit',
|
|
25
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
48
26
|
env: Object.assign(Object.assign({}, process.env), { RCT_METRO_PORT: options.port.toString() }),
|
|
49
27
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Ensure the child process is killed when the parent exits
|
|
30
|
+
*/
|
|
31
|
+
const processExitListener = (signal) => () => {
|
|
32
|
+
childProcess.kill(signal);
|
|
33
|
+
process.exit();
|
|
34
|
+
};
|
|
35
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
36
|
+
process.once('SIGTERM', processExitListener);
|
|
37
|
+
process.once('SIGINT', processExitListener);
|
|
38
|
+
process.once('SIGQUIT', processExitListener);
|
|
53
39
|
childProcess.on('error', (err) => {
|
|
54
40
|
reject(err);
|
|
55
41
|
});
|
|
56
42
|
childProcess.on('exit', (code) => {
|
|
57
43
|
if (code === 0) {
|
|
58
|
-
|
|
44
|
+
res(childProcess);
|
|
59
45
|
}
|
|
60
46
|
else {
|
|
61
47
|
reject(code);
|
|
@@ -1,62 +1,24 @@
|
|
|
1
|
-
import { ExecutorContext
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import { ensureNodeModulesSymlink } from '../../utils/ensure-node-modules-symlink';
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { join, resolve as pathResolve } from 'path';
|
|
4
3
|
import { ChildProcess, fork } from 'child_process';
|
|
5
4
|
import { ReactNativeBuildAndroidOptions } from './schema';
|
|
6
5
|
import { chmodAndroidGradlewFiles } from '../../utils/chmod-android-gradle-files';
|
|
7
|
-
import { runCliStart } from '../start/start.impl';
|
|
8
|
-
import {
|
|
9
|
-
displayNewlyAddedDepsMessage,
|
|
10
|
-
syncDeps,
|
|
11
|
-
} from '../sync-deps/sync-deps.impl';
|
|
12
6
|
import { getCliOptions } from '../../utils/get-cli-options';
|
|
13
7
|
|
|
14
8
|
export interface ReactNativeBuildOutput {
|
|
15
9
|
success: boolean;
|
|
16
10
|
}
|
|
17
11
|
|
|
18
|
-
let childProcess: ChildProcess;
|
|
19
|
-
|
|
20
12
|
export default async function* buildAndroidExecutor(
|
|
21
13
|
options: ReactNativeBuildAndroidOptions,
|
|
22
14
|
context: ExecutorContext
|
|
23
15
|
): AsyncGenerator<ReactNativeBuildOutput> {
|
|
24
16
|
const projectRoot =
|
|
25
17
|
context.projectsConfigurations.projects[context.projectName].root;
|
|
26
|
-
ensureNodeModulesSymlink(context.root, projectRoot);
|
|
27
|
-
if (options.sync) {
|
|
28
|
-
displayNewlyAddedDepsMessage(
|
|
29
|
-
context.projectName,
|
|
30
|
-
await syncDeps(
|
|
31
|
-
context.projectName,
|
|
32
|
-
projectRoot,
|
|
33
|
-
context.root,
|
|
34
|
-
context.projectGraph
|
|
35
|
-
)
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
18
|
chmodAndroidGradlewFiles(join(projectRoot, 'android'));
|
|
40
19
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (options.packager && options.mode !== 'release') {
|
|
44
|
-
tasks.push(
|
|
45
|
-
runCliStart(context.root, projectRoot, {
|
|
46
|
-
port: options.port,
|
|
47
|
-
resetCache: options.resetCache,
|
|
48
|
-
interactive: options.interactive,
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
await Promise.all(tasks);
|
|
54
|
-
yield { success: true };
|
|
55
|
-
} finally {
|
|
56
|
-
if (childProcess) {
|
|
57
|
-
childProcess.kill();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
20
|
+
await runCliBuild(context.root, projectRoot, options);
|
|
21
|
+
yield { success: true };
|
|
60
22
|
}
|
|
61
23
|
|
|
62
24
|
function runCliBuild(
|
|
@@ -64,30 +26,39 @@ function runCliBuild(
|
|
|
64
26
|
projectRoot: string,
|
|
65
27
|
options: ReactNativeBuildAndroidOptions
|
|
66
28
|
) {
|
|
67
|
-
return new Promise((
|
|
29
|
+
return new Promise<ChildProcess>((res, reject) => {
|
|
68
30
|
/**
|
|
69
31
|
* Call the react native cli with option `--no-packager`
|
|
70
32
|
* Not passing '--packager' due to cli will launch start command from the project root
|
|
71
33
|
*/
|
|
72
|
-
childProcess = fork(
|
|
73
|
-
|
|
34
|
+
const childProcess = fork(
|
|
35
|
+
require.resolve('react-native/cli.js'),
|
|
74
36
|
['build-android', ...createBuildAndroidOptions(options), '--no-packager'],
|
|
75
37
|
{
|
|
76
|
-
|
|
38
|
+
stdio: 'inherit',
|
|
39
|
+
cwd: pathResolve(workspaceRoot, projectRoot),
|
|
77
40
|
env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
|
|
78
41
|
}
|
|
79
42
|
);
|
|
80
43
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Ensure the child process is killed when the parent exits
|
|
46
|
+
*/
|
|
47
|
+
const processExitListener = (signal?: number | NodeJS.Signals) => () => {
|
|
48
|
+
childProcess.kill(signal);
|
|
49
|
+
process.exit();
|
|
50
|
+
};
|
|
51
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
52
|
+
process.once('SIGTERM', processExitListener);
|
|
53
|
+
process.once('SIGINT', processExitListener);
|
|
54
|
+
process.once('SIGQUIT', processExitListener);
|
|
84
55
|
|
|
85
56
|
childProcess.on('error', (err) => {
|
|
86
57
|
reject(err);
|
|
87
58
|
});
|
|
88
59
|
childProcess.on('exit', (code) => {
|
|
89
60
|
if (code === 0) {
|
|
90
|
-
|
|
61
|
+
res(childProcess);
|
|
91
62
|
} else {
|
|
92
63
|
reject(code);
|
|
93
64
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// options taken from https://github.com/react-native-community/cli/blob/main/packages/cli-platform-android/src/commands/buildAndroid/index.ts
|
|
2
|
+
// https://github.com/react-native-community/cli/blob/main/packages/cli-platform-android/README.md#build-android
|
|
2
3
|
|
|
3
4
|
import { ReactNativeStartOptions } from '../start/schema';
|
|
4
5
|
|
|
@@ -20,12 +21,13 @@ export interface ReactNativeBuildAndroidOptions
|
|
|
20
21
|
// react native options
|
|
21
22
|
mode: string; // default is debug
|
|
22
23
|
activeArchOnly: boolean; // default is false
|
|
23
|
-
|
|
24
|
-
tasks?: Array<string>;
|
|
24
|
+
tasks?: string | Array<string>;
|
|
25
25
|
extraParams?: Array<string>;
|
|
26
|
-
interactive
|
|
26
|
+
interactive: boolean;
|
|
27
27
|
|
|
28
28
|
// nx options
|
|
29
|
+
// @deprecated, no longer used
|
|
29
30
|
packager: boolean; // default is true
|
|
31
|
+
// @deprecated, add to sync-deps to dependsOn
|
|
30
32
|
sync: boolean;
|
|
31
33
|
}
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"packager": {
|
|
52
52
|
"type": "boolean",
|
|
53
53
|
"description": "Launch packager while building",
|
|
54
|
-
"default": true
|
|
54
|
+
"default": true,
|
|
55
|
+
"x-deprecated": "Run `nx run <project>:start` instead. Will be removed in Nx 17."
|
|
55
56
|
},
|
|
56
57
|
"port": {
|
|
57
58
|
"type": "number",
|
|
@@ -59,10 +60,10 @@
|
|
|
59
60
|
"default": 8081
|
|
60
61
|
},
|
|
61
62
|
"tasks": {
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
"type": "string"
|
|
65
|
-
|
|
63
|
+
"oneOf": [
|
|
64
|
+
{ "type": "array", "items": { "type": "string" } },
|
|
65
|
+
{ "type": "string" }
|
|
66
|
+
],
|
|
66
67
|
"description": "Run custom Gradle tasks. By default it's \"assembleDebug\". Will override passed mode and variant arguments.",
|
|
67
68
|
"examples": [
|
|
68
69
|
"assembleDebug",
|
|
@@ -79,8 +80,12 @@
|
|
|
79
80
|
"default": false
|
|
80
81
|
},
|
|
81
82
|
"extraParams": {
|
|
82
|
-
"
|
|
83
|
-
|
|
83
|
+
"oneOf": [
|
|
84
|
+
{ "type": "array", "items": { "type": "string" } },
|
|
85
|
+
{ "type": "string" }
|
|
86
|
+
],
|
|
87
|
+
"description": "Custom params passed to gradle build command",
|
|
88
|
+
"examples": ["-x lint -x test"]
|
|
84
89
|
},
|
|
85
90
|
"interactive": {
|
|
86
91
|
"type": "boolean",
|
|
@@ -89,7 +94,8 @@
|
|
|
89
94
|
"sync": {
|
|
90
95
|
"type": "boolean",
|
|
91
96
|
"description": "Syncs npm dependencies to `package.json` (for React Native autolink).",
|
|
92
|
-
"default": true
|
|
97
|
+
"default": true,
|
|
98
|
+
"x-deprecated": "Add sync-deps to dependsOn instead"
|
|
93
99
|
},
|
|
94
100
|
"resetCache": {
|
|
95
101
|
"type": "boolean",
|
|
@@ -3,4 +3,4 @@ import { ReactNativeBuildIosOptions } from './schema';
|
|
|
3
3
|
export interface ReactNativeBuildIosOutput {
|
|
4
4
|
success: boolean;
|
|
5
5
|
}
|
|
6
|
-
export default function
|
|
6
|
+
export default function buildIosExecutor(options: ReactNativeBuildIosOptions, context: ExecutorContext): AsyncGenerator<ReactNativeBuildIosOutput>;
|
|
@@ -4,64 +4,45 @@ 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
|
-
const start_impl_1 = require("../start/start.impl");
|
|
11
7
|
const get_cli_options_1 = require("../../utils/get-cli-options");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return tslib_1.__asyncGenerator(this, arguments, function* runIosExecutor_1() {
|
|
8
|
+
function buildIosExecutor(options, context) {
|
|
9
|
+
return tslib_1.__asyncGenerator(this, arguments, function* buildIosExecutor_1() {
|
|
15
10
|
if ((0, os_1.platform)() !== 'darwin') {
|
|
16
11
|
throw new Error(`The run-ios build requires Mac to run`);
|
|
17
12
|
}
|
|
18
13
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, yield tslib_1.__await((0, sync_deps_impl_1.syncDeps)(context.projectName, projectRoot, context.root, context.projectGraph)));
|
|
22
|
-
}
|
|
23
|
-
if (options.install) {
|
|
24
|
-
yield tslib_1.__await((0, pod_install_task_1.podInstall)((0, path_1.join)(context.root, projectRoot, 'ios'), options.buildFolder));
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
const tasks = [runCliBuildIOS(context.root, projectRoot, options)];
|
|
28
|
-
if (options.packager && options.mode !== 'Release') {
|
|
29
|
-
tasks.push((0, start_impl_1.runCliStart)(context.root, projectRoot, {
|
|
30
|
-
port: options.port,
|
|
31
|
-
resetCache: options.resetCache,
|
|
32
|
-
interactive: options.interactive,
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
yield tslib_1.__await(Promise.all(tasks));
|
|
36
|
-
yield yield tslib_1.__await({ success: true });
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
if (childProcess) {
|
|
40
|
-
childProcess.kill();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
14
|
+
yield tslib_1.__await(runCliBuildIOS(context.root, projectRoot, options));
|
|
15
|
+
return yield tslib_1.__await({ success: true });
|
|
43
16
|
});
|
|
44
17
|
}
|
|
45
|
-
exports.default =
|
|
18
|
+
exports.default = buildIosExecutor;
|
|
46
19
|
function runCliBuildIOS(workspaceRoot, projectRoot, options) {
|
|
47
20
|
return new Promise((resolve, reject) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
cwd: (0, path_1.
|
|
21
|
+
const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), [
|
|
22
|
+
'build-ios',
|
|
23
|
+
...createBuildIOSOptions(options),
|
|
24
|
+
...(process.env.NX_VERBOSE_LOGGING === 'true' ? ['--verbose'] : []),
|
|
25
|
+
], {
|
|
26
|
+
cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
|
|
54
27
|
env: Object.assign(Object.assign({}, process.env), { RCT_METRO_PORT: options.port.toString() }),
|
|
55
28
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Ensure the child process is killed when the parent exits
|
|
31
|
+
*/
|
|
32
|
+
const processExitListener = (signal) => () => {
|
|
33
|
+
childProcess.kill(signal);
|
|
34
|
+
process.exit();
|
|
35
|
+
};
|
|
36
|
+
process.once('exit', (signal) => childProcess.kill(signal));
|
|
37
|
+
process.once('SIGTERM', processExitListener);
|
|
38
|
+
process.once('SIGINT', processExitListener);
|
|
39
|
+
process.once('SIGQUIT', processExitListener);
|
|
59
40
|
childProcess.on('error', (err) => {
|
|
60
41
|
reject(err);
|
|
61
42
|
});
|
|
62
43
|
childProcess.on('exit', (code) => {
|
|
63
44
|
if (code === 0) {
|
|
64
|
-
resolve(
|
|
45
|
+
resolve(childProcess);
|
|
65
46
|
}
|
|
66
47
|
else {
|
|
67
48
|
reject(code);
|