@nx/react-native 16.8.0-beta.4 → 16.8.0-beta.6

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
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
5
  const path_1 = require("path");
@@ -28,7 +27,7 @@ function updateJestConfig(tree) {
28
27
  .replace(`...workspacePreset,`, "resolver: '@nrwl/jest/plugins/resolver',")
29
28
  .replace(`const workspacePreset = require('../../jest.preset');`, ''));
30
29
  }
31
- catch (_a) {
30
+ catch {
32
31
  devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update jest.config.js for project ${project}.`);
33
32
  }
34
33
  try {
@@ -47,15 +46,13 @@ function updateJestConfig(tree) {
47
46
  .replace(`import { jest } from '@jest/globals';`, ''));
48
47
  }
49
48
  }
50
- catch (_b) {
49
+ catch {
51
50
  devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update test-setup for project ${project}.`);
52
51
  }
53
52
  });
54
53
  }
55
- function update(tree) {
56
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
57
- updateJestConfig(tree);
58
- yield (0, devkit_1.formatFiles)(tree);
59
- });
54
+ async function update(tree) {
55
+ updateJestConfig(tree);
56
+ await (0, devkit_1.formatFiles)(tree);
60
57
  }
61
58
  exports.default = update;
@@ -1,21 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
6
- function update(tree) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- const projects = (0, devkit_1.getProjects)(tree);
9
- if (tree.exists('/babel.config.json') || tree.exists('/babel.config.js')) {
10
- return;
11
- }
12
- const hasReactNaiveProject = Array.from(projects)
13
- .map(([_, project]) => project)
14
- .some((project) => { var _a, _b; return ((_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.executor) === '@nrwl/react-native:start'; });
15
- if (hasReactNaiveProject) {
16
- (0, add_babel_inputs_1.addBabelInputs)(tree);
17
- }
18
- yield (0, devkit_1.formatFiles)(tree);
19
- });
5
+ async function update(tree) {
6
+ const projects = (0, devkit_1.getProjects)(tree);
7
+ if (tree.exists('/babel.config.json') || tree.exists('/babel.config.js')) {
8
+ return;
9
+ }
10
+ const hasReactNaiveProject = Array.from(projects)
11
+ .map(([_, project]) => project)
12
+ .some((project) => project.targets?.start?.executor === '@nrwl/react-native:start');
13
+ if (hasReactNaiveProject) {
14
+ (0, add_babel_inputs_1.addBabelInputs)(tree);
15
+ }
16
+ await (0, devkit_1.formatFiles)(tree);
20
17
  }
21
18
  exports.default = update;
@@ -1,22 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  /**
6
5
  * Update svg typings in tsconfig for react native app
7
6
  * Replace node_modules/@nrwl/react/typings/image.d.ts with node_modules/@nrwl/react-native/typings/svg.d.ts
8
7
  */
9
- function update(tree) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- projects.forEach((project) => {
13
- var _a, _b;
14
- if (((_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.executor) !== '@nrwl/react-native:start')
15
- return;
16
- updateReactNativeSvgTypingInTsconfig(tree, project);
17
- });
18
- yield (0, devkit_1.formatFiles)(tree);
8
+ async function update(tree) {
9
+ const projects = (0, devkit_1.getProjects)(tree);
10
+ projects.forEach((project) => {
11
+ if (project.targets?.start?.executor !== '@nrwl/react-native:start')
12
+ return;
13
+ updateReactNativeSvgTypingInTsconfig(tree, project);
19
14
  });
15
+ await (0, devkit_1.formatFiles)(tree);
20
16
  }
21
17
  exports.default = update;
22
18
  function updateReactNativeSvgTypingInTsconfig(host, project) {
@@ -1,32 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  /**
6
5
  * Add projectRoot and watchFolders options in metro.config.js
7
6
  * @param tree
8
7
  */
9
- function update(tree) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- projects.forEach((project) => {
13
- var _a, _b;
14
- const metroConfigPath = `${project.root}/metro.config.js`;
15
- if (((_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.executor) !== '@nrwl/react-native:start' ||
16
- !tree.exists(metroConfigPath))
8
+ async function update(tree) {
9
+ const projects = (0, devkit_1.getProjects)(tree);
10
+ projects.forEach((project) => {
11
+ const metroConfigPath = `${project.root}/metro.config.js`;
12
+ if (project.targets?.start?.executor !== '@nrwl/react-native:start' ||
13
+ !tree.exists(metroConfigPath))
14
+ return;
15
+ try {
16
+ const metroConfigContent = tree.read(metroConfigPath, 'utf-8');
17
+ if (metroConfigContent.includes('projectRoot: __dirname')) {
17
18
  return;
18
- try {
19
- const metroConfigContent = tree.read(metroConfigPath, 'utf-8');
20
- if (metroConfigContent.includes('projectRoot: __dirname')) {
21
- return;
22
- }
23
- tree.write(metroConfigPath, metroConfigContent.replace('debug: ', 'projectRoot: __dirname, watchFolders: [], debug: '));
24
19
  }
25
- catch (_c) {
26
- devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update ${metroConfigPath} for project ${project.root}.`);
27
- }
28
- });
29
- yield (0, devkit_1.formatFiles)(tree);
20
+ tree.write(metroConfigPath, metroConfigContent.replace('debug: ', 'projectRoot: __dirname, watchFolders: [], debug: '));
21
+ }
22
+ catch {
23
+ devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update ${metroConfigPath} for project ${project.root}.`);
24
+ }
30
25
  });
26
+ await (0, devkit_1.formatFiles)(tree);
31
27
  }
32
28
  exports.default = update;
@@ -1,38 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const path_1 = require("path");
6
5
  /**
7
6
  * This function udpate the entry file option under bundle target for react native apps
8
7
  */
9
- function update(tree) {
10
- var _a, _b, _c, _d;
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const projects = (0, devkit_1.getProjects)(tree);
13
- const updateTargetEntryFile = (target, config) => {
14
- var _a, _b, _c;
15
- if (!((_c = (_b = (_a = config.targets) === null || _a === void 0 ? void 0 : _a[target]) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.entryFile)) {
16
- return;
17
- }
18
- if (tree.exists((0, path_1.join)(config.root, 'src/main.tsx'))) {
19
- config.targets[target].options.entryFile = `src/main.tsx`;
20
- }
21
- if (tree.exists((0, path_1.join)(config.root, 'src/main.js'))) {
22
- config.targets[target].options.entryFile = `src/main.js`;
23
- }
24
- };
25
- for (const [name, config] of projects.entries()) {
26
- if (((_b = (_a = config.targets) === null || _a === void 0 ? void 0 : _a['bundle-ios']) === null || _b === void 0 ? void 0 : _b.executor) === '@nrwl/react-native:bundle') {
27
- updateTargetEntryFile('bundle-ios', config);
28
- }
29
- if (((_d = (_c = config.targets) === null || _c === void 0 ? void 0 : _c['bundle-android']) === null || _d === void 0 ? void 0 : _d.executor) ===
30
- '@nrwl/react-native:bundle') {
31
- updateTargetEntryFile('bundle-android', config);
32
- }
33
- (0, devkit_1.updateProjectConfiguration)(tree, name, config);
8
+ async function update(tree) {
9
+ const projects = (0, devkit_1.getProjects)(tree);
10
+ const updateTargetEntryFile = (target, config) => {
11
+ if (!config.targets?.[target]?.options?.entryFile) {
12
+ return;
34
13
  }
35
- yield (0, devkit_1.formatFiles)(tree);
36
- });
14
+ if (tree.exists((0, path_1.join)(config.root, 'src/main.tsx'))) {
15
+ config.targets[target].options.entryFile = `src/main.tsx`;
16
+ }
17
+ if (tree.exists((0, path_1.join)(config.root, 'src/main.js'))) {
18
+ config.targets[target].options.entryFile = `src/main.js`;
19
+ }
20
+ };
21
+ for (const [name, config] of projects.entries()) {
22
+ if (config.targets?.['bundle-ios']?.executor === '@nrwl/react-native:bundle') {
23
+ updateTargetEntryFile('bundle-ios', config);
24
+ }
25
+ if (config.targets?.['bundle-android']?.executor ===
26
+ '@nrwl/react-native:bundle') {
27
+ updateTargetEntryFile('bundle-android', config);
28
+ }
29
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
30
+ }
31
+ await (0, devkit_1.formatFiles)(tree);
37
32
  }
38
33
  exports.default = update;
@@ -1,41 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const path_1 = require("path");
6
5
  /**
7
6
  * This function changes "main" tag to project's className
8
7
  */
9
- function update(tree) {
10
- var _a, _b;
11
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
- const projects = (0, devkit_1.getProjects)(tree);
13
- for (const [name, config] of projects.entries()) {
14
- if (((_b = (_a = config.targets) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.executor) !== '@nrwl/react-native:start')
15
- continue;
16
- let mailFilePath;
17
- if (tree.exists((0, path_1.join)(config.root, 'src/main.tsx'))) {
18
- mailFilePath = (0, path_1.join)(config.root, 'src/main.tsx');
19
- }
20
- if (tree.exists((0, path_1.join)(config.root, 'src/main.js'))) {
21
- mailFilePath = (0, path_1.join)(config.root, 'src/main.js');
22
- }
23
- if (!mailFilePath) {
24
- continue;
25
- }
26
- try {
27
- const { className } = (0, devkit_1.names)(name);
28
- const content = tree.read(mailFilePath, 'utf-8');
29
- if (!content.includes(`'main'`)) {
30
- return;
31
- }
32
- tree.write(mailFilePath, content.replace(`'main'`, `'${className}'`));
33
- }
34
- catch (_c) {
35
- devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update ${mailFilePath} for project ${name}.`);
8
+ async function update(tree) {
9
+ const projects = (0, devkit_1.getProjects)(tree);
10
+ for (const [name, config] of projects.entries()) {
11
+ if (config.targets?.start?.executor !== '@nrwl/react-native:start')
12
+ continue;
13
+ let mailFilePath;
14
+ if (tree.exists((0, path_1.join)(config.root, 'src/main.tsx'))) {
15
+ mailFilePath = (0, path_1.join)(config.root, 'src/main.tsx');
16
+ }
17
+ if (tree.exists((0, path_1.join)(config.root, 'src/main.js'))) {
18
+ mailFilePath = (0, path_1.join)(config.root, 'src/main.js');
19
+ }
20
+ if (!mailFilePath) {
21
+ continue;
22
+ }
23
+ try {
24
+ const { className } = (0, devkit_1.names)(name);
25
+ const content = tree.read(mailFilePath, 'utf-8');
26
+ if (!content.includes(`'main'`)) {
27
+ return;
36
28
  }
29
+ tree.write(mailFilePath, content.replace(`'main'`, `'${className}'`));
30
+ }
31
+ catch {
32
+ devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update ${mailFilePath} for project ${name}.`);
37
33
  }
38
- yield (0, devkit_1.formatFiles)(tree);
39
- });
34
+ }
35
+ await (0, devkit_1.formatFiles)(tree);
40
36
  }
41
37
  exports.default = update;
@@ -1,32 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  /**
6
5
  * Rename blacklistRE to blockList in metro.config.js
7
6
  * @param tree
8
7
  */
9
- function update(tree) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- projects.forEach((project) => {
13
- var _a, _b;
14
- const metroConfigPath = `${project.root}/metro.config.js`;
15
- if (((_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.executor) !== '@nrwl/react-native:start' ||
16
- !tree.exists(metroConfigPath))
8
+ async function update(tree) {
9
+ const projects = (0, devkit_1.getProjects)(tree);
10
+ projects.forEach((project) => {
11
+ const metroConfigPath = `${project.root}/metro.config.js`;
12
+ if (project.targets?.start?.executor !== '@nrwl/react-native:start' ||
13
+ !tree.exists(metroConfigPath))
14
+ return;
15
+ try {
16
+ const metroConfigContent = tree.read(metroConfigPath, 'utf-8');
17
+ if (!metroConfigContent.includes('blacklistRE:')) {
17
18
  return;
18
- try {
19
- const metroConfigContent = tree.read(metroConfigPath, 'utf-8');
20
- if (!metroConfigContent.includes('blacklistRE:')) {
21
- return;
22
- }
23
- tree.write(metroConfigPath, metroConfigContent.replace('blacklistRE:', 'blockList:'));
24
19
  }
25
- catch (_c) {
26
- devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update ${metroConfigPath} for project ${project.root}.`);
27
- }
28
- });
29
- yield (0, devkit_1.formatFiles)(tree);
20
+ tree.write(metroConfigPath, metroConfigContent.replace('blacklistRE:', 'blockList:'));
21
+ }
22
+ catch {
23
+ devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update ${metroConfigPath} for project ${project.root}.`);
24
+ }
30
25
  });
26
+ await (0, devkit_1.formatFiles)(tree);
31
27
  }
32
28
  exports.default = update;
@@ -1,25 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  /**
6
5
  * This function changes include field from string to array for sync-deps target
7
6
  */
8
- function update(tree) {
9
- var _a, _b, _c, _d, _e;
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- for (const [name, config] of projects.entries()) {
13
- if (((_b = (_a = config.targets) === null || _a === void 0 ? void 0 : _a['sync-deps']) === null || _b === void 0 ? void 0 : _b.executor) !== '@nrwl/react-native:sync-deps')
14
- continue;
15
- const include = (_e = (_d = (_c = config.targets) === null || _c === void 0 ? void 0 : _c['sync-deps']) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.include;
16
- if (!include || !include.length) {
17
- continue;
18
- }
19
- config.targets['sync-deps'].options.include = include.split(',');
20
- (0, devkit_1.updateProjectConfiguration)(tree, name, config);
7
+ async function update(tree) {
8
+ const projects = (0, devkit_1.getProjects)(tree);
9
+ for (const [name, config] of projects.entries()) {
10
+ if (config.targets?.['sync-deps']?.executor !== '@nrwl/react-native:sync-deps')
11
+ continue;
12
+ const include = config.targets?.['sync-deps']?.options?.include;
13
+ if (!include || !include.length) {
14
+ continue;
21
15
  }
22
- yield (0, devkit_1.formatFiles)(tree);
23
- });
16
+ config.targets['sync-deps'].options.include = include.split(',');
17
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
18
+ }
19
+ await (0, devkit_1.formatFiles)(tree);
24
20
  }
25
21
  exports.default = update;
@@ -1,25 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  /**
6
5
  * This function changes searchDir field from string to array for storybook target
7
6
  */
8
- function update(tree) {
9
- var _a, _b, _c, _d, _e;
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- for (const [name, config] of projects.entries()) {
13
- if (((_b = (_a = config.targets) === null || _a === void 0 ? void 0 : _a['storybook']) === null || _b === void 0 ? void 0 : _b.executor) !== '@nrwl/react-native:storybook')
14
- continue;
15
- const searchDir = (_e = (_d = (_c = config.targets) === null || _c === void 0 ? void 0 : _c['storybook']) === null || _d === void 0 ? void 0 : _d.options) === null || _e === void 0 ? void 0 : _e.searchDir;
16
- if (!searchDir || !searchDir.length || Array.isArray(searchDir)) {
17
- continue;
18
- }
19
- config.targets['storybook'].options.searchDir = searchDir.split(',');
20
- (0, devkit_1.updateProjectConfiguration)(tree, name, config);
7
+ async function update(tree) {
8
+ const projects = (0, devkit_1.getProjects)(tree);
9
+ for (const [name, config] of projects.entries()) {
10
+ if (config.targets?.['storybook']?.executor !== '@nrwl/react-native:storybook')
11
+ continue;
12
+ const searchDir = config.targets?.['storybook']?.options?.searchDir;
13
+ if (!searchDir || !searchDir.length || Array.isArray(searchDir)) {
14
+ continue;
21
15
  }
22
- yield (0, devkit_1.formatFiles)(tree);
23
- });
16
+ config.targets['storybook'].options.searchDir = searchDir.split(',');
17
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
18
+ }
19
+ await (0, devkit_1.formatFiles)(tree);
24
20
  }
25
21
  exports.default = update;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
6
5
  const jest_1 = require("@nx/jest");
@@ -8,32 +7,29 @@ const path_1 = require("path");
8
7
  /**
9
8
  * Remove transfrom and testRunner in jest
10
9
  */
11
- function update(tree) {
12
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (options, projectName) => {
14
- if (options.jestConfig && tree.exists(options.jestConfig)) {
15
- const jestConfig = tree.read(options.jestConfig, 'utf-8');
16
- if (jestConfig.includes(`preset: 'react-native'`)) {
17
- const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
18
- removeTransform(tree, project);
19
- renameBabelJson(tree, project);
20
- }
10
+ async function update(tree) {
11
+ (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/jest:jest', (options, projectName) => {
12
+ if (options.jestConfig && tree.exists(options.jestConfig)) {
13
+ const jestConfig = tree.read(options.jestConfig, 'utf-8');
14
+ if (jestConfig.includes(`preset: 'react-native'`)) {
15
+ const project = (0, devkit_1.readProjectConfiguration)(tree, projectName);
16
+ removeTransform(tree, project);
17
+ renameBabelJson(tree, project);
21
18
  }
22
- });
23
- yield (0, devkit_1.formatFiles)(tree);
19
+ }
24
20
  });
21
+ await (0, devkit_1.formatFiles)(tree);
25
22
  }
26
23
  exports.default = update;
27
24
  function removeTransform(host, project) {
28
- var _a, _b, _c;
29
- const jestConfigPath = (_c = (_b = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.test) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.jestConfig;
25
+ const jestConfigPath = project.targets?.test?.options?.jestConfig;
30
26
  if (!jestConfigPath || !host.exists(jestConfigPath))
31
27
  return;
32
28
  try {
33
29
  (0, jest_1.removePropertyFromJestConfig)(host, jestConfigPath, 'transform');
34
30
  (0, jest_1.removePropertyFromJestConfig)(host, jestConfigPath, 'testRunner');
35
31
  }
36
- catch (_d) {
32
+ catch {
37
33
  devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to update ${jestConfigPath} for project ${project.root}.`);
38
34
  }
39
35
  }
@@ -51,7 +47,7 @@ function renameBabelJson(host, project) {
51
47
  host.write(babelJsonPath, buffer);
52
48
  host.delete(babelrcPath);
53
49
  }
54
- catch (_a) {
50
+ catch {
55
51
  devkit_1.logger.error((0, devkit_1.stripIndents) `Unable to rename from ${babelrcPath} to ${babelJsonPath} for project ${project.root}.`);
56
52
  }
57
53
  }
@@ -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 devkit_1 = require("@nx/devkit");
5
4
  const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
6
- function default_1(tree) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- (0, add_babel_inputs_1.addBabelInputs)(tree);
9
- yield (0, devkit_1.formatFiles)(tree);
10
- });
5
+ async function default_1(tree) {
6
+ (0, add_babel_inputs_1.addBabelInputs)(tree);
7
+ await (0, devkit_1.formatFiles)(tree);
11
8
  }
12
9
  exports.default = default_1;
@@ -1,33 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const devkit_1 = require("@nx/devkit");
5
4
  /**
6
5
  * Add build-ios target for react-native
7
6
  */
8
- function update(tree) {
9
- var _a, _b;
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const projects = (0, devkit_1.getProjects)(tree);
12
- for (const [name, config] of projects.entries()) {
13
- if (((_b = (_a = config.targets) === null || _a === void 0 ? void 0 : _a['start']) === null || _b === void 0 ? void 0 : _b.executor) === '@nrwl/react-native:start') {
14
- if (!config.targets['build-ios']) {
15
- config.targets['build-ios'] = {
16
- executor: '@nrwl/react-native:build-ios',
17
- outputs: ['{projectRoot}/ios/build/Build'],
18
- options: {},
19
- };
20
- }
21
- if (!config.targets['pod-install']) {
22
- config.targets['pod-install'] = {
23
- executor: '@nrwl/react-native:pod-install',
24
- options: {},
25
- };
26
- }
27
- (0, devkit_1.updateProjectConfiguration)(tree, name, config);
7
+ async function update(tree) {
8
+ const projects = (0, devkit_1.getProjects)(tree);
9
+ for (const [name, config] of projects.entries()) {
10
+ if (config.targets?.['start']?.executor === '@nrwl/react-native:start') {
11
+ if (!config.targets['build-ios']) {
12
+ config.targets['build-ios'] = {
13
+ executor: '@nrwl/react-native:build-ios',
14
+ outputs: ['{projectRoot}/ios/build/Build'],
15
+ options: {},
16
+ };
28
17
  }
18
+ if (!config.targets['pod-install']) {
19
+ config.targets['pod-install'] = {
20
+ executor: '@nrwl/react-native:pod-install',
21
+ options: {},
22
+ };
23
+ }
24
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
29
25
  }
30
- yield (0, devkit_1.formatFiles)(tree);
31
- });
26
+ }
27
+ await (0, devkit_1.formatFiles)(tree);
32
28
  }
33
29
  exports.default = update;
@@ -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 devkit_1 = require("@nx/devkit");
5
4
  const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
6
- function replacePackage(tree) {
7
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
- yield (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/react-native', '@nx/react-native');
9
- yield (0, devkit_1.formatFiles)(tree);
10
- });
5
+ async function replacePackage(tree) {
6
+ await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/react-native', '@nx/react-native');
7
+ await (0, devkit_1.formatFiles)(tree);
11
8
  }
12
9
  exports.default = replacePackage;
@@ -8,11 +8,10 @@ const devkit_1 = require("@nx/devkit");
8
8
  function update(tree) {
9
9
  if (tree.exists('package.json')) {
10
10
  (0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
11
- var _a, _b;
12
- if ((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a['react-native-storybook-loader']) {
11
+ if (packageJson.dependencies?.['react-native-storybook-loader']) {
13
12
  delete packageJson.dependencies['react-native-storybook-loader'];
14
13
  }
15
- if ((_b = packageJson.devDependencies) === null || _b === void 0 ? void 0 : _b['react-native-storybook-loader']) {
14
+ if (packageJson.devDependencies?.['react-native-storybook-loader']) {
16
15
  delete packageJson.devDependencies['react-native-storybook-loader'];
17
16
  }
18
17
  return packageJson;