@nx/react-native 16.8.0-beta.3 → 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
@@ -1,43 +1,39 @@
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 migration adds dependsOn to project.json.
7
6
  *
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) === '@nx/react-native:start') {
15
- config.targets['start'].dependsOn = [
16
- 'ensure-symlink',
17
- 'sync-deps',
18
- 'pod-install',
19
- ];
20
- config.targets['run-ios'].dependsOn = [
21
- 'ensure-symlink',
22
- 'sync-deps',
23
- 'pod-install',
24
- ];
25
- config.targets['bundle-ios'].dependsOn = ['ensure-symlink'];
26
- config.targets['run-android'].dependsOn = ['ensure-symlink', 'sync-deps'];
27
- config.targets['build-android'].dependsOn = [
28
- 'ensure-symlink',
29
- 'sync-deps',
30
- ];
31
- config.targets['build-ios'].dependsOn = [
32
- 'ensure-symlink',
33
- 'sync-deps',
34
- 'pod-install',
35
- ];
36
- config.targets['pod-install'].dependsOn = ['ensure-symlink', 'sync-deps'];
37
- config.targets['bundle-android'].dependsOn = ['ensure-symlink'];
38
- (0, devkit_1.updateProjectConfiguration)(tree, name, config);
39
- }
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 === '@nx/react-native:start') {
12
+ config.targets['start'].dependsOn = [
13
+ 'ensure-symlink',
14
+ 'sync-deps',
15
+ 'pod-install',
16
+ ];
17
+ config.targets['run-ios'].dependsOn = [
18
+ 'ensure-symlink',
19
+ 'sync-deps',
20
+ 'pod-install',
21
+ ];
22
+ config.targets['bundle-ios'].dependsOn = ['ensure-symlink'];
23
+ config.targets['run-android'].dependsOn = ['ensure-symlink', 'sync-deps'];
24
+ config.targets['build-android'].dependsOn = [
25
+ 'ensure-symlink',
26
+ 'sync-deps',
27
+ ];
28
+ config.targets['build-ios'].dependsOn = [
29
+ 'ensure-symlink',
30
+ 'sync-deps',
31
+ 'pod-install',
32
+ ];
33
+ config.targets['pod-install'].dependsOn = ['ensure-symlink', 'sync-deps'];
34
+ config.targets['bundle-android'].dependsOn = ['ensure-symlink'];
35
+ (0, devkit_1.updateProjectConfiguration)(tree, name, config);
40
36
  }
41
- });
37
+ }
42
38
  }
43
39
  exports.default = update;
@@ -1,28 +1,24 @@
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 migration updates metro.config.js to export config as a default.
8
7
  *
9
8
  */
10
- function update(tree) {
11
- var _a, _b;
12
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
13
- const projects = (0, devkit_1.getProjects)(tree);
14
- for (const [_, config] of projects.entries()) {
15
- if (((_b = (_a = config.targets) === null || _a === void 0 ? void 0 : _a['start']) === null || _b === void 0 ? void 0 : _b.executor) === '@nx/react-native:start') {
16
- if (tree.exists((0, path_1.join)(config.root, 'metro.config.js'))) {
17
- const oldConfig = tree
18
- .read((0, path_1.join)(config.root, 'metro.config.js'))
19
- .toString();
20
- tree.write((0, path_1.join)(config.root, 'metro-v71.config.js'), oldConfigComment + oldConfig);
21
- tree.write((0, path_1.join)(config.root, 'metro.config.js'), content);
22
- }
9
+ async function update(tree) {
10
+ const projects = (0, devkit_1.getProjects)(tree);
11
+ for (const [_, config] of projects.entries()) {
12
+ if (config.targets?.['start']?.executor === '@nx/react-native:start') {
13
+ if (tree.exists((0, path_1.join)(config.root, 'metro.config.js'))) {
14
+ const oldConfig = tree
15
+ .read((0, path_1.join)(config.root, 'metro.config.js'))
16
+ .toString();
17
+ tree.write((0, path_1.join)(config.root, 'metro-v71.config.js'), oldConfigComment + oldConfig);
18
+ tree.write((0, path_1.join)(config.root, 'metro.config.js'), content);
23
19
  }
24
20
  }
25
- });
21
+ }
26
22
  }
27
23
  exports.default = update;
28
24
  const oldConfigComment = `/**
@@ -1,27 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addJest = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const jest_1 = require("@nx/jest");
7
- function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
8
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
9
- if (unitTestRunner !== 'jest') {
10
- return () => { };
11
- }
12
- const jestTask = yield (0, jest_1.configurationGenerator)(host, {
13
- js,
14
- project: projectName,
15
- supportTsx: true,
16
- skipSerializers: true,
17
- setupFile: 'none',
18
- compiler: 'babel',
19
- skipPackageJson,
20
- skipFormat: true,
21
- });
22
- // overwrite the jest.config.ts file because react native needs to have special transform property
23
- const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
24
- const content = `module.exports = {
6
+ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson) {
7
+ if (unitTestRunner !== 'jest') {
8
+ return () => { };
9
+ }
10
+ const jestTask = await (0, jest_1.configurationGenerator)(host, {
11
+ js,
12
+ project: projectName,
13
+ supportTsx: true,
14
+ skipSerializers: true,
15
+ setupFile: 'none',
16
+ compiler: 'babel',
17
+ skipPackageJson,
18
+ skipFormat: true,
19
+ });
20
+ // overwrite the jest.config.ts file because react native needs to have special transform property
21
+ const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;
22
+ const content = `module.exports = {
25
23
  displayName: '${projectName}',
26
24
  preset: 'react-native',
27
25
  resolver: '@nx/jest/plugins/resolver',
@@ -32,8 +30,7 @@ function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPack
32
30
  },
33
31
  coverageDirectory: '${(0, devkit_1.offsetFromRoot)(appProjectRoot)}coverage/${appProjectRoot}'
34
32
  };`;
35
- host.write(configPath, content);
36
- return jestTask;
37
- });
33
+ host.write(configPath, content);
34
+ return jestTask;
38
35
  }
39
36
  exports.addJest = addJest;
@@ -1,39 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addLinting = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const linter_1 = require("@nx/linter");
6
5
  const devkit_1 = require("@nx/devkit");
7
6
  const lint_1 = require("@nx/react/src/utils/lint");
8
7
  const eslint_file_1 = require("@nx/linter/src/generators/utils/eslint-file");
9
- function addLinting(host, options) {
10
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- if (options.linter === linter_1.Linter.None) {
12
- return () => { };
13
- }
14
- const tasks = [];
15
- const lintTask = yield (0, linter_1.lintProjectGenerator)(host, {
16
- linter: options.linter,
17
- project: options.projectName,
18
- tsConfigPaths: options.tsConfigPaths,
19
- eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
20
- skipFormat: true,
21
- skipPackageJson: options.skipPackageJson,
22
- });
23
- tasks.push(lintTask);
24
- if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
25
- (0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
26
- (0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
27
- 'public',
28
- '.cache',
29
- 'node_modules',
30
- ]);
31
- }
32
- if (!options.skipPackageJson) {
33
- const installTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
34
- tasks.push(installTask);
35
- }
36
- return (0, devkit_1.runTasksInSerial)(...tasks);
8
+ async function addLinting(host, options) {
9
+ if (options.linter === linter_1.Linter.None) {
10
+ return () => { };
11
+ }
12
+ const tasks = [];
13
+ const lintTask = await (0, linter_1.lintProjectGenerator)(host, {
14
+ linter: options.linter,
15
+ project: options.projectName,
16
+ tsConfigPaths: options.tsConfigPaths,
17
+ eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
18
+ skipFormat: true,
19
+ skipPackageJson: options.skipPackageJson,
37
20
  });
21
+ tasks.push(lintTask);
22
+ if ((0, eslint_file_1.isEslintConfigSupported)(host)) {
23
+ (0, eslint_file_1.addExtendsToLintConfig)(host, options.projectRoot, 'plugin:@nx/react');
24
+ (0, eslint_file_1.addIgnoresToLintConfig)(host, options.projectRoot, [
25
+ 'public',
26
+ '.cache',
27
+ 'node_modules',
28
+ ]);
29
+ }
30
+ if (!options.skipPackageJson) {
31
+ const installTask = await (0, devkit_1.addDependenciesToPackageJson)(host, lint_1.extraEslintDependencies.dependencies, lint_1.extraEslintDependencies.devDependencies);
32
+ tasks.push(installTask);
33
+ }
34
+ return (0, devkit_1.runTasksInSerial)(...tasks);
38
35
  }
39
36
  exports.addLinting = addLinting;
@@ -15,7 +15,7 @@ function chmodAndroidGradlewFilesTask(androidFolder) {
15
15
  try {
16
16
  chmodAndroidGradlewFiles(androidFolder);
17
17
  }
18
- catch (_a) {
18
+ catch {
19
19
  throw new Error(`chmod failed gradlew file under ${androidFolder}`);
20
20
  }
21
21
  };
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.findAllNpmDependencies = void 0;
4
4
  function findAllNpmDependencies(graph, projectName, list = [], seen = new Set()) {
5
- var _a;
6
5
  // In case of bad circular dependencies
7
6
  if (seen.has(projectName)) {
8
7
  return list;
@@ -19,7 +18,7 @@ function findAllNpmDependencies(graph, projectName, list = [], seen = new Set())
19
18
  }
20
19
  else {
21
20
  // it's workspace project, search for it's dependencies
22
- (_a = graph.dependencies[projectName]) === null || _a === void 0 ? void 0 : _a.forEach((dep) => findAllNpmDependencies(graph, dep.target, list, seen));
21
+ graph.dependencies[projectName]?.forEach((dep) => findAllNpmDependencies(graph, dep.target, list, seen));
23
22
  }
24
23
  return list;
25
24
  }
@@ -10,7 +10,7 @@ function runSymlink(workspaceRoot, projectRoot) {
10
10
  try {
11
11
  (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(workspaceRoot, projectRoot);
12
12
  }
13
- catch (_a) {
13
+ catch {
14
14
  throw new Error(`Failed to create symlinks for ${chalk.bold(projectRoot)}`);
15
15
  }
16
16
  };
@@ -1,35 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createLib = exports.createApp = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const application_1 = require("../generators/application/application");
7
6
  const linter_1 = require("@nx/linter");
8
- function createApp(tree, appName) {
9
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
- yield (0, application_1.default)(tree, {
11
- linter: linter_1.Linter.EsLint,
12
- skipFormat: true,
13
- style: 'css',
14
- unitTestRunner: 'none',
15
- name: appName,
16
- e2eTestRunner: 'none',
17
- install: false,
18
- });
7
+ async function createApp(tree, appName) {
8
+ await (0, application_1.default)(tree, {
9
+ linter: linter_1.Linter.EsLint,
10
+ skipFormat: true,
11
+ style: 'css',
12
+ unitTestRunner: 'none',
13
+ name: appName,
14
+ e2eTestRunner: 'none',
15
+ install: false,
16
+ projectNameAndRootFormat: 'as-provided',
19
17
  });
20
18
  }
21
19
  exports.createApp = createApp;
22
- function createLib(tree, libName) {
23
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
24
- const { fileName } = (0, devkit_1.names)(libName);
25
- tree.write(`/libs/${fileName}/src/index.ts`, `import React from 'react';\n`);
26
- (0, devkit_1.addProjectConfiguration)(tree, fileName, {
27
- tags: [],
28
- root: `libs/${fileName}`,
29
- projectType: 'library',
30
- sourceRoot: `libs/${fileName}/src`,
31
- targets: {},
32
- });
20
+ async function createLib(tree, libName) {
21
+ const { fileName } = (0, devkit_1.names)(libName);
22
+ tree.write(`${fileName}/src/index.ts`, `import React from 'react';\n`);
23
+ (0, devkit_1.addProjectConfiguration)(tree, fileName, {
24
+ tags: [],
25
+ root: `${fileName}`,
26
+ projectType: 'library',
27
+ sourceRoot: `${fileName}/src`,
28
+ targets: {},
33
29
  });
34
30
  }
35
31
  exports.createLib = createLib;