@nx/react-native 16.8.0-beta.4 → 16.8.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.
Files changed (65) hide show
  1. package/package.json +10 -10
  2. package/plugins/metro-resolver.js +4 -5
  3. package/plugins/with-nx-metro.js +23 -27
  4. package/src/executors/build-android/build-android.impl.js +6 -9
  5. package/src/executors/build-ios/build-ios.impl.js +8 -11
  6. package/src/executors/bundle/bundle.impl.js +6 -9
  7. package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -7
  8. package/src/executors/pod-install/pod-install.impl.js +5 -8
  9. package/src/executors/run-android/run-android.impl.js +23 -39
  10. package/src/executors/run-ios/run-ios.impl.js +25 -41
  11. package/src/executors/start/lib/is-packager-running.js +9 -12
  12. package/src/executors/start/start.impl.js +38 -43
  13. package/src/executors/storybook/storybook.impl.js +17 -20
  14. package/src/executors/sync-deps/sync-deps.impl.js +32 -37
  15. package/src/generators/application/application.js +23 -21
  16. package/src/generators/application/application.spec.ts +41 -38
  17. package/src/generators/application/lib/add-detox.js +15 -7
  18. package/src/generators/application/lib/add-project.js +4 -2
  19. package/src/generators/application/lib/create-application-files.js +6 -1
  20. package/src/generators/application/lib/nomalize-options.spec.ts +30 -25
  21. package/src/generators/application/lib/normalize-options.js +30 -23
  22. package/src/generators/component/component.js +9 -9
  23. package/src/generators/component/component.spec.ts +14 -22
  24. package/src/generators/component/lib/normalize-options.js +36 -37
  25. package/src/generators/component-story/component-story.js +6 -9
  26. package/src/generators/component-story/component-story.spec.ts +7 -7
  27. package/src/generators/init/init.js +56 -29
  28. package/src/generators/init/init.spec.ts +1 -1
  29. package/src/generators/library/lib/normalize-options.js +21 -18
  30. package/src/generators/library/library.js +94 -79
  31. package/src/generators/library/library.spec.ts +47 -57
  32. package/src/generators/stories/stories-app.spec.ts +20 -37
  33. package/src/generators/stories/stories-lib.spec.ts +10 -18
  34. package/src/generators/stories/stories.js +39 -44
  35. package/src/generators/storybook-configuration/configuration.js +29 -34
  36. package/src/generators/storybook-configuration/configuration.spec.ts +10 -12
  37. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +1 -1
  38. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +7 -7
  39. package/src/generators/storybook-configuration/lib/create-storybook-files.js +30 -34
  40. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +1 -1
  41. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +7 -7
  42. package/src/generators/upgrade-native/upgrade-native.js +13 -16
  43. package/src/migrations/update-12-10-0/add-react-native-svg-12-10-0.js +11 -16
  44. package/src/migrations/update-12-5-0/update-jest-for-react-native.js +5 -8
  45. package/src/migrations/update-13-5-0/add-babel-config-root-13-5-0.js +12 -15
  46. package/src/migrations/update-13-5-0/update-react-native-typing-svg-13-5-0.js +7 -11
  47. package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js +16 -20
  48. package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js +23 -28
  49. package/src/migrations/update-14-0-2/change-main-to-class-name-14-0-2.js +26 -30
  50. package/src/migrations/update-14-2-1/rename-blockList-metro-config.js +16 -20
  51. package/src/migrations/update-14-5-5/add-exclude-sync-deps.js +12 -16
  52. package/src/migrations/update-14-5-8/change-searchDir-storybook.js +12 -16
  53. package/src/migrations/update-14-6-0/remove-jest-transform.js +13 -17
  54. package/src/migrations/update-15-0-0/add-babel-inputs.js +3 -6
  55. package/src/migrations/update-15-9-1/add-build-ios-target.js +19 -23
  56. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
  57. package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +2 -3
  58. package/src/migrations/update-16-6-0/add-depends-on.js +29 -33
  59. package/src/migrations/update-16-6-0/update-metro-config.js +11 -15
  60. package/src/utils/add-jest.js +19 -22
  61. package/src/utils/add-linting.js +26 -29
  62. package/src/utils/chmod-android-gradle-files.js +1 -1
  63. package/src/utils/find-all-npm-dependencies.js +1 -2
  64. package/src/utils/symlink-task.js +1 -1
  65. package/src/utils/testing-generators.js +19 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "16.8.0-beta.4",
3
+ "version": "16.8.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,14 +25,14 @@
25
25
  "main": "./index.js",
26
26
  "types": "index.d.ts",
27
27
  "dependencies": {
28
- "@nrwl/react-native": "16.8.0-beta.4",
29
- "@nx/detox": "16.8.0-beta.4",
30
- "@nx/devkit": "16.8.0-beta.4",
31
- "@nx/jest": "16.8.0-beta.4",
32
- "@nx/js": "16.8.0-beta.4",
33
- "@nx/linter": "16.8.0-beta.4",
34
- "@nx/react": "16.8.0-beta.4",
35
- "@nx/workspace": "16.8.0-beta.4",
28
+ "@nrwl/react-native": "16.8.0-beta.5",
29
+ "@nx/detox": "16.8.0-beta.5",
30
+ "@nx/devkit": "16.8.0-beta.5",
31
+ "@nx/jest": "16.8.0-beta.5",
32
+ "@nx/js": "16.8.0-beta.5",
33
+ "@nx/linter": "16.8.0-beta.5",
34
+ "@nx/react": "16.8.0-beta.5",
35
+ "@nx/workspace": "16.8.0-beta.5",
36
36
  "chalk": "^4.1.0",
37
37
  "enhanced-resolve": "^5.8.3",
38
38
  "fs-extra": "^11.1.0",
@@ -58,5 +58,5 @@
58
58
  "access": "public"
59
59
  },
60
60
  "type": "commonjs",
61
- "gitHead": "c9aad2dc8c2b34531cf61549bff872e68c481e4e"
61
+ "gitHead": "ad2d1e8a55b2d1b358bb5e7483343d9757ff2c53"
62
62
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getResolveRequest = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const metroResolver = require("metro-resolver");
6
5
  const tsconfig_paths_1 = require("tsconfig-paths");
7
6
  const chalk = require("chalk");
@@ -20,7 +19,7 @@ function getResolveRequest(extensions) {
20
19
  const debug = process.env.NX_REACT_NATIVE_DEBUG === 'true';
21
20
  if (debug)
22
21
  console.log(chalk.cyan(`[Nx] Resolving: ${realModuleName}`));
23
- const { resolveRequest } = _context, context = tslib_1.__rest(_context, ["resolveRequest"]);
22
+ const { resolveRequest, ...context } = _context;
24
23
  const resolvedPath = resolveRequestFromContext(resolveRequest, _context, realModuleName, platform, debug) ||
25
24
  defaultMetroResolver(context, realModuleName, platform, debug) ||
26
25
  tsconfigPathsResolver(context, extensions, realModuleName, platform, debug) ||
@@ -36,7 +35,7 @@ function resolveRequestFromContext(resolveRequest, context, realModuleName, plat
36
35
  try {
37
36
  return resolveRequest(context, realModuleName, platform);
38
37
  }
39
- catch (_a) {
38
+ catch {
40
39
  if (debug)
41
40
  console.log(chalk.cyan(`[Nx] Unable to resolve with default resolveRequest: ${realModuleName}`));
42
41
  }
@@ -49,7 +48,7 @@ function defaultMetroResolver(context, realModuleName, platform, debug) {
49
48
  try {
50
49
  return metroResolver.resolve(context, realModuleName, platform);
51
50
  }
52
- catch (_a) {
51
+ catch {
53
52
  if (debug)
54
53
  console.log(chalk.cyan(`[Nx] Unable to resolve with default Metro resolver: ${realModuleName}`));
55
54
  }
@@ -68,7 +67,7 @@ function pnpmResolver(extensions, context, realModuleName, debug) {
68
67
  return { type: 'sourceFile', filePath };
69
68
  }
70
69
  }
71
- catch (_a) {
70
+ catch {
72
71
  if (debug)
73
72
  console.log(chalk.cyan(`[Nx] Unable to resolve with default PNPM resolver: ${realModuleName}`));
74
73
  }
@@ -1,37 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNxMetro = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const metro_config_1 = require("metro-config");
7
6
  const path_1 = require("path");
8
7
  const fs_extra_1 = require("fs-extra");
9
8
  const metro_resolver_1 = require("./metro-resolver");
10
- function withNxMetro(userConfig, opts = {}) {
11
- var _a;
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
- });
9
+ async function withNxMetro(userConfig, opts = {}) {
10
+ const extensions = ['', 'ts', 'tsx', 'js', 'jsx', 'json'];
11
+ if (opts.debug)
12
+ process.env.NX_REACT_NATIVE_DEBUG = 'true';
13
+ if (opts.extensions)
14
+ extensions.push(...opts.extensions);
15
+ let watchFolders = [
16
+ (0, path_1.join)(devkit_1.workspaceRoot, 'node_modules'),
17
+ (0, path_1.join)(devkit_1.workspaceRoot, (0, devkit_1.workspaceLayout)().libsDir),
18
+ (0, path_1.join)(devkit_1.workspaceRoot, 'packages'),
19
+ (0, path_1.join)(devkit_1.workspaceRoot, '.storybook'),
20
+ ];
21
+ if (opts.watchFolders?.length) {
22
+ watchFolders = watchFolders.concat(opts.watchFolders);
23
+ }
24
+ watchFolders = watchFolders.filter((folder) => (0, fs_extra_1.existsSync)(folder));
25
+ const nxConfig = {
26
+ resolver: {
27
+ resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions),
28
+ },
29
+ watchFolders,
30
+ };
31
+ return (0, metro_config_1.mergeConfig)(userConfig, nxConfig);
36
32
  }
37
33
  exports.withNxMetro = withNxMetro;
@@ -1,17 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const path_1 = require("path");
5
4
  const child_process_1 = require("child_process");
6
5
  const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
7
6
  const get_cli_options_1 = require("../../utils/get-cli-options");
8
- function buildAndroidExecutor(options, context) {
9
- return tslib_1.__asyncGenerator(this, arguments, function* buildAndroidExecutor_1() {
10
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
11
- (0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
12
- yield tslib_1.__await(runCliBuild(context.root, projectRoot, options));
13
- yield yield tslib_1.__await({ success: true });
14
- });
7
+ async function* buildAndroidExecutor(options, context) {
8
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
9
+ (0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
10
+ await runCliBuild(context.root, projectRoot, options);
11
+ yield { success: true };
15
12
  }
16
13
  exports.default = buildAndroidExecutor;
17
14
  function runCliBuild(workspaceRoot, projectRoot, options) {
@@ -23,7 +20,7 @@ function runCliBuild(workspaceRoot, projectRoot, options) {
23
20
  const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['build-android', ...createBuildAndroidOptions(options), '--no-packager'], {
24
21
  stdio: 'inherit',
25
22
  cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
26
- env: Object.assign(Object.assign({}, process.env), { RCT_METRO_PORT: options.port.toString() }),
23
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
27
24
  });
28
25
  /**
29
26
  * Ensure the child process is killed when the parent exits
@@ -1,19 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const path_1 = require("path");
5
4
  const child_process_1 = require("child_process");
6
5
  const os_1 = require("os");
7
6
  const get_cli_options_1 = require("../../utils/get-cli-options");
8
- function buildIosExecutor(options, context) {
9
- return tslib_1.__asyncGenerator(this, arguments, function* buildIosExecutor_1() {
10
- if ((0, os_1.platform)() !== 'darwin') {
11
- throw new Error(`The run-ios build requires Mac to run`);
12
- }
13
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
14
- yield tslib_1.__await(runCliBuildIOS(context.root, projectRoot, options));
15
- return yield tslib_1.__await({ success: true });
16
- });
7
+ async function* buildIosExecutor(options, context) {
8
+ if ((0, os_1.platform)() !== 'darwin') {
9
+ throw new Error(`The run-ios build requires Mac to run`);
10
+ }
11
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
12
+ await runCliBuildIOS(context.root, projectRoot, options);
13
+ return { success: true };
17
14
  }
18
15
  exports.default = buildIosExecutor;
19
16
  function runCliBuildIOS(workspaceRoot, projectRoot, options) {
@@ -24,7 +21,7 @@ function runCliBuildIOS(workspaceRoot, projectRoot, options) {
24
21
  ...(process.env.NX_VERBOSE_LOGGING === 'true' ? ['--verbose'] : []),
25
22
  ], {
26
23
  cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
27
- env: Object.assign(Object.assign({}, process.env), { RCT_METRO_PORT: options.port.toString() }),
24
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
28
25
  });
29
26
  /**
30
27
  * Ensure the child process is killed when the parent exits
@@ -1,18 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const path_1 = require("path");
7
6
  const child_process_1 = require("child_process");
8
- function bundleExecutor(options, context) {
9
- return tslib_1.__asyncGenerator(this, arguments, function* bundleExecutor_1() {
10
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
11
- options.bundleOutput = (0, path_1.join)(context.root, options.bundleOutput);
12
- (0, fileutils_1.createDirectory)((0, path_1.dirname)(options.bundleOutput));
13
- yield tslib_1.__await(runCliBuild(context.root, projectRoot, options));
14
- yield yield tslib_1.__await({ success: true });
15
- });
7
+ async function* bundleExecutor(options, context) {
8
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
9
+ options.bundleOutput = (0, path_1.join)(context.root, options.bundleOutput);
10
+ (0, fileutils_1.createDirectory)((0, path_1.dirname)(options.bundleOutput));
11
+ await runCliBuild(context.root, projectRoot, options);
12
+ yield { success: true };
16
13
  }
17
14
  exports.default = bundleExecutor;
18
15
  function runCliBuild(workspaceRoot, projectRoot, options) {
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
5
- function ensureSymlinkExecutor(_, context) {
6
- return tslib_1.__asyncGenerator(this, arguments, function* ensureSymlinkExecutor_1() {
7
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
8
- (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
9
- yield yield tslib_1.__await({ success: true });
10
- });
4
+ async function* ensureSymlinkExecutor(_, context) {
5
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
6
+ (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
7
+ yield { success: true };
11
8
  }
12
9
  exports.default = ensureSymlinkExecutor;
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const path_1 = require("path");
5
4
  const pod_install_task_1 = require("../../utils/pod-install-task");
6
- function podInstall(options, context) {
7
- return tslib_1.__asyncGenerator(this, arguments, function* podInstall_1() {
8
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
9
- const iosDirectory = (0, path_1.join)(context.root, projectRoot, 'ios');
10
- yield tslib_1.__await((0, pod_install_task_1.runPodInstall)(iosDirectory, true, options)());
11
- yield yield tslib_1.__await({ success: true });
12
- });
5
+ async function* podInstall(options, context) {
6
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
7
+ const iosDirectory = (0, path_1.join)(context.root, projectRoot, 'ios');
8
+ await (0, pod_install_task_1.runPodInstall)(iosDirectory, true, options)();
9
+ yield { success: true };
13
10
  }
14
11
  exports.default = podInstall;
@@ -1,52 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const path_1 = require("path");
5
4
  const child_process_1 = require("child_process");
6
5
  const start_impl_1 = require("../start/start.impl");
7
6
  const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
8
7
  const get_cli_options_1 = require("../../utils/get-cli-options");
9
8
  let childProcess;
10
- function runAndroidExecutor(options, context) {
11
- return tslib_1.__asyncGenerator(this, arguments, function* runAndroidExecutor_1() {
12
- var _a, e_1, _b, _c;
13
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
14
- (0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
15
- if (options.packager && options.mode !== 'Release') {
16
- const startResults = (0, start_impl_1.default)({
17
- port: options.port,
18
- resetCache: options.resetCache,
19
- interactive: true,
20
- }, context);
21
- try {
22
- 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) {
23
- _c = startResults_1_1.value;
24
- _d = false;
25
- const result = _c;
26
- if (result.success) {
27
- yield tslib_1.__await(runCliRunAndroid(context.root, projectRoot, options));
28
- yield yield tslib_1.__await({
29
- success: true,
30
- });
31
- }
32
- else {
33
- return yield tslib_1.__await(result);
34
- }
35
- }
9
+ async function* runAndroidExecutor(options, context) {
10
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
11
+ (0, chmod_android_gradle_files_1.chmodAndroidGradlewFiles)((0, path_1.join)(projectRoot, 'android'));
12
+ if (options.packager && options.mode !== 'Release') {
13
+ const startResults = (0, start_impl_1.default)({
14
+ port: options.port,
15
+ resetCache: options.resetCache,
16
+ interactive: true,
17
+ }, context);
18
+ for await (const result of startResults) {
19
+ if (result.success) {
20
+ await runCliRunAndroid(context.root, projectRoot, options);
21
+ yield {
22
+ success: true,
23
+ };
36
24
  }
37
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
38
- finally {
39
- try {
40
- if (!_d && !_a && (_b = startResults_1.return)) yield tslib_1.__await(_b.call(startResults_1));
41
- }
42
- finally { if (e_1) throw e_1.error; }
25
+ else {
26
+ return result;
43
27
  }
44
28
  }
45
- else {
46
- yield tslib_1.__await(runCliRunAndroid(context.root, projectRoot, options));
47
- }
48
- yield yield tslib_1.__await({ success: true });
49
- });
29
+ }
30
+ else {
31
+ await runCliRunAndroid(context.root, projectRoot, options);
32
+ }
33
+ yield { success: true };
50
34
  }
51
35
  exports.default = runAndroidExecutor;
52
36
  function runCliRunAndroid(workspaceRoot, projectRoot, options) {
@@ -58,7 +42,7 @@ function runCliRunAndroid(workspaceRoot, projectRoot, options) {
58
42
  childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['run-android', ...createRunAndroidOptions(options), '--no-packager'], {
59
43
  stdio: 'inherit',
60
44
  cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
61
- env: Object.assign(Object.assign({}, process.env), { RCT_METRO_PORT: options.port.toString() }),
45
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
62
46
  });
63
47
  /**
64
48
  * Ensure the child process is killed when the parent exits
@@ -1,53 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const path_1 = require("path");
5
4
  const child_process_1 = require("child_process");
6
5
  const os_1 = require("os");
7
6
  const start_impl_1 = require("../start/start.impl");
8
7
  const get_cli_options_1 = require("../../utils/get-cli-options");
9
- function runIosExecutor(options, context) {
10
- return tslib_1.__asyncGenerator(this, arguments, function* runIosExecutor_1() {
11
- var _a, e_1, _b, _c;
12
- if ((0, os_1.platform)() !== 'darwin') {
13
- throw new Error(`The run-ios build requires Mac to run`);
14
- }
15
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
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
- }
8
+ async function* runIosExecutor(options, context) {
9
+ if ((0, os_1.platform)() !== 'darwin') {
10
+ throw new Error(`The run-ios build requires Mac to run`);
11
+ }
12
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
13
+ if (options.packager && options.mode !== 'Release') {
14
+ const startResults = (0, start_impl_1.default)({
15
+ port: options.port,
16
+ resetCache: options.resetCache,
17
+ interactive: true,
18
+ }, context);
19
+ for await (const result of startResults) {
20
+ if (result.success) {
21
+ await runCliRunIOS(context.root, projectRoot, options);
22
+ yield {
23
+ success: true,
24
+ };
37
25
  }
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; }
26
+ else {
27
+ return result;
44
28
  }
45
29
  }
46
- else {
47
- yield tslib_1.__await(runCliRunIOS(context.root, projectRoot, options));
48
- }
49
- yield yield tslib_1.__await({ success: true });
50
- });
30
+ }
31
+ else {
32
+ await runCliRunIOS(context.root, projectRoot, options);
33
+ }
34
+ yield { success: true };
51
35
  }
52
36
  exports.default = runIosExecutor;
53
37
  function runCliRunIOS(workspaceRoot, projectRoot, options) {
@@ -59,7 +43,7 @@ function runCliRunIOS(workspaceRoot, projectRoot, options) {
59
43
  const childProcess = (0, child_process_1.fork)(require.resolve('react-native/cli.js'), ['run-ios', ...createRunIOSOptions(options), '--no-packager'], {
60
44
  stdio: 'inherit',
61
45
  cwd: (0, path_1.resolve)(workspaceRoot, projectRoot),
62
- env: Object.assign(Object.assign({}, process.env), { RCT_METRO_PORT: options.port.toString() }),
46
+ env: { ...process.env, RCT_METRO_PORT: options.port.toString() },
63
47
  });
64
48
  /**
65
49
  * Ensure the child process is killed when the parent exits
@@ -1,18 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isPackagerRunning = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const node_fetch_1 = require("node-fetch");
6
- function isPackagerRunning(packagerPort) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- try {
9
- const resp = yield (0, node_fetch_1.default)(`http://localhost:${packagerPort}/status`);
10
- const data = yield resp.text();
11
- return data === 'packager-status:running' ? 'running' : 'unrecognized';
12
- }
13
- catch (_a) {
14
- return 'not_running';
15
- }
16
- });
5
+ async function isPackagerRunning(packagerPort) {
6
+ try {
7
+ const resp = await (0, node_fetch_1.default)(`http://localhost:${packagerPort}/status`);
8
+ const data = await resp.text();
9
+ return data === 'packager-status:running' ? 'running' : 'unrecognized';
10
+ }
11
+ catch {
12
+ return 'not_running';
13
+ }
17
14
  }
18
15
  exports.isPackagerRunning = isPackagerRunning;
@@ -1,35 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCliStart = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const child_process_1 = require("child_process");
7
6
  const path_1 = require("path");
8
7
  const ensure_node_modules_symlink_1 = require("../../utils/ensure-node-modules-symlink");
9
8
  const is_packager_running_1 = require("./lib/is-packager-running");
10
- function startExecutor(options, context) {
11
- return tslib_1.__asyncGenerator(this, arguments, function* startExecutor_1() {
12
- const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
13
- (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
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);
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
- }));
9
+ async function* startExecutor(options, context) {
10
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
11
+ (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(context.root, projectRoot);
12
+ const startProcess = await runCliStart(context.root, projectRoot, options);
13
+ yield {
14
+ port: options.port,
15
+ success: true,
16
+ };
17
+ if (!startProcess) {
18
+ return;
19
+ }
20
+ await new Promise((resolve) => {
21
+ const processExitListener = (signal) => () => {
22
+ startProcess.kill(signal);
23
+ resolve();
24
+ process.exit();
25
+ };
26
+ process.once('exit', (signal) => startProcess.kill(signal));
27
+ process.once('SIGTERM', processExitListener);
28
+ process.once('SIGINT', processExitListener);
29
+ process.once('SIGQUIT', processExitListener);
33
30
  });
34
31
  }
35
32
  exports.default = startExecutor;
@@ -37,27 +34,25 @@ exports.default = startExecutor;
37
34
  * Starts the JS bundler and checks for "running" status before notifying
38
35
  * that packager has started.
39
36
  */
40
- function runCliStart(workspaceRoot, projectRoot, options) {
41
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
- const result = yield (0, is_packager_running_1.isPackagerRunning)(options.port);
43
- if (result === 'running') {
44
- devkit_1.logger.info(`JS server already running on port ${options.port}.`);
37
+ async function runCliStart(workspaceRoot, projectRoot, options) {
38
+ const result = await (0, is_packager_running_1.isPackagerRunning)(options.port);
39
+ if (result === 'running') {
40
+ devkit_1.logger.info(`JS server already running on port ${options.port}.`);
41
+ }
42
+ else if (result === 'unrecognized') {
43
+ devkit_1.logger.warn('JS server not recognized.');
44
+ }
45
+ else {
46
+ // result === 'not_running'
47
+ devkit_1.logger.info('Starting JS server...');
48
+ try {
49
+ return await startAsync(workspaceRoot, projectRoot, options);
45
50
  }
46
- else if (result === 'unrecognized') {
47
- devkit_1.logger.warn('JS server not recognized.');
51
+ catch (error) {
52
+ devkit_1.logger.error(`Failed to start the packager server. Error details: ${error.message}`);
53
+ throw error;
48
54
  }
49
- else {
50
- // result === 'not_running'
51
- devkit_1.logger.info('Starting JS server...');
52
- try {
53
- return yield startAsync(workspaceRoot, projectRoot, options);
54
- }
55
- catch (error) {
56
- devkit_1.logger.error(`Failed to start the packager server. Error details: ${error.message}`);
57
- throw error;
58
- }
59
- }
60
- });
55
+ }
61
56
  }
62
57
  exports.runCliStart = runCliStart;
63
58
  function startAsync(workspaceRoot, projectRoot, options) {