@nx/react-native 18.0.0-beta.1 → 18.0.0-canary.20240201-8762c38

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 (149) hide show
  1. package/.eslintrc.json +6 -1
  2. package/executors.json +5 -0
  3. package/generators.json +10 -9
  4. package/migrations.json +73 -1
  5. package/package.json +10 -15
  6. package/plugins/metro-resolver.js +4 -1
  7. package/plugins/with-nx-metro.js +6 -2
  8. package/src/executors/build-android/build-android.impl.js +1 -5
  9. package/src/executors/build-android/build-android.impl.ts +1 -5
  10. package/src/executors/bundle/schema.d.ts +1 -1
  11. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +4 -0
  12. package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -0
  13. package/src/executors/ensure-symlink/ensure-symlink.impl.ts +4 -0
  14. package/src/executors/run-android/run-android.impl.js +4 -16
  15. package/src/executors/run-android/run-android.impl.ts +8 -17
  16. package/src/executors/run-ios/run-ios.impl.js +4 -16
  17. package/src/executors/run-ios/run-ios.impl.ts +9 -18
  18. package/src/executors/start/schema.d.ts +1 -1
  19. package/src/executors/start/start.impl.js +11 -26
  20. package/src/executors/start/start.impl.ts +14 -28
  21. package/src/executors/storybook/storybook.impl.d.ts +4 -0
  22. package/src/executors/storybook/storybook.impl.js +5 -1
  23. package/src/executors/storybook/storybook.impl.ts +13 -15
  24. package/src/executors/sync-deps/sync-deps.impl.d.ts +2 -2
  25. package/src/executors/sync-deps/sync-deps.impl.js +20 -5
  26. package/src/executors/sync-deps/sync-deps.impl.ts +20 -9
  27. package/src/executors/upgrade/schema.d.ts +1 -0
  28. package/src/executors/upgrade/schema.json +11 -0
  29. package/src/executors/upgrade/upgrade.impl.d.ts +13 -0
  30. package/src/executors/upgrade/upgrade.impl.js +47 -0
  31. package/src/executors/upgrade/upgrade.impl.ts +64 -0
  32. package/src/generators/application/application.js +21 -7
  33. package/src/generators/application/application.spec.ts +27 -0
  34. package/src/generators/application/files/app/.babelrc.js.template +23 -0
  35. package/src/generators/application/files/app/android/app/build.gradle.template +12 -28
  36. package/src/generators/application/files/app/android/app/src/debug/AndroidManifest.xml.template +2 -6
  37. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.kt.template +22 -0
  38. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +45 -0
  39. package/src/generators/application/files/app/android/build.gradle.template +7 -20
  40. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +2 -1
  41. package/src/generators/application/files/app/android/gradle.properties +0 -3
  42. package/src/generators/application/files/app/android/gradlew.template +12 -7
  43. package/src/generators/application/files/app/android/settings.gradle.template +2 -2
  44. package/src/generators/application/files/app/ios/Podfile.template +0 -7
  45. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +5 -0
  46. package/src/generators/application/files/app/ios/__className__/Info.plist.template +5 -8
  47. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +11 -33
  48. package/src/generators/application/files/app/metro.config.js.template +0 -4
  49. package/src/generators/application/files/app/src/app/App.tsx.template +5 -2
  50. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  51. package/src/generators/application/lib/add-e2e.js +47 -0
  52. package/src/generators/application/lib/add-project.js +13 -17
  53. package/src/generators/application/lib/normalize-options.d.ts +4 -0
  54. package/src/generators/application/lib/normalize-options.js +8 -3
  55. package/src/generators/application/lib/normalize-options.spec.ts +48 -5
  56. package/src/generators/application/schema.d.ts +4 -3
  57. package/src/generators/application/schema.json +13 -5
  58. package/src/generators/component-story/component-story.d.ts +5 -8
  59. package/src/generators/component-story/component-story.js +8 -69
  60. package/src/generators/component-story/schema.d.ts +1 -0
  61. package/src/generators/component-story/schema.json +10 -2
  62. package/src/generators/init/init.js +0 -3
  63. package/src/generators/library/files/lib/.babelrc.js.template +21 -0
  64. package/src/generators/library/library.spec.ts +11 -0
  65. package/src/generators/library/schema.json +1 -1
  66. package/src/generators/stories/schema.d.ts +2 -0
  67. package/src/generators/stories/schema.json +14 -1
  68. package/src/generators/stories/stories.d.ts +5 -2
  69. package/src/generators/stories/stories.js +7 -50
  70. package/src/generators/storybook-configuration/configuration.d.ts +6 -2
  71. package/src/generators/storybook-configuration/configuration.js +7 -48
  72. package/src/generators/storybook-configuration/schema.d.ts +3 -2
  73. package/src/generators/storybook-configuration/schema.json +21 -11
  74. package/src/generators/upgrade-native/lib/normalize-options.d.ts +1 -1
  75. package/src/generators/upgrade-native/schema.d.ts +1 -1
  76. package/src/generators/upgrade-native/schema.json +2 -2
  77. package/src/generators/upgrade-native/upgrade-native.d.ts +2 -0
  78. package/src/generators/upgrade-native/upgrade-native.js +3 -0
  79. package/src/generators/web-configuration/files/base-vite/.babelrc.js.template +23 -0
  80. package/src/generators/web-configuration/files/base-vite/index.html__tmpl__ +15 -0
  81. package/src/generators/web-configuration/files/base-vite/public/favicon.ico +0 -0
  82. package/src/generators/web-configuration/files/base-vite/src/assets/.gitkeep +0 -0
  83. package/src/generators/web-configuration/files/base-vite/src/main-web.tsx__tmpl__ +9 -0
  84. package/src/generators/web-configuration/files/base-vite/vite.config.ts__tmpl__ +82 -0
  85. package/src/generators/web-configuration/files/base-webpack/.babelrc.js.template +23 -0
  86. package/src/generators/web-configuration/files/base-webpack/src/assets/.gitkeep +0 -0
  87. package/src/generators/web-configuration/files/base-webpack/src/favicon.ico +0 -0
  88. package/src/generators/web-configuration/files/base-webpack/src/index.html__tmpl__ +14 -0
  89. package/src/generators/web-configuration/files/base-webpack/src/main-web.tsx__tmpl__ +9 -0
  90. package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +77 -0
  91. package/src/generators/web-configuration/lib/normalize-schema.d.ts +17 -0
  92. package/src/generators/web-configuration/lib/normalize-schema.js +16 -0
  93. package/src/generators/web-configuration/lib/webpack-targets.d.ts +7 -0
  94. package/src/generators/web-configuration/lib/webpack-targets.js +75 -0
  95. package/src/generators/web-configuration/schema.d.ts +6 -0
  96. package/src/generators/web-configuration/schema.json +42 -0
  97. package/src/generators/web-configuration/web-configuration.d.ts +12 -0
  98. package/src/generators/web-configuration/web-configuration.js +85 -0
  99. package/src/migrations/update-16-6-0/update-metro-config.js +0 -4
  100. package/src/migrations/update-16-9-0/remove-types-react-native.js +2 -9
  101. package/src/migrations/update-18-0-0/add-upgrade-target.d.ts +6 -0
  102. package/src/migrations/update-18-0-0/add-upgrade-target.js +33 -0
  103. package/src/migrations/update-18-0-0/add-web-configuration.d.ts +8 -0
  104. package/src/migrations/update-18-0-0/add-web-configuration.js +33 -0
  105. package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +39 -0
  106. package/src/migrations/update-18-0-0/change-storybook-targets.d.ts +5 -0
  107. package/src/migrations/update-18-0-0/change-storybook-targets.js +57 -0
  108. package/src/migrations/update-18-0-0/remove-block-list.d.ts +6 -0
  109. package/src/migrations/update-18-0-0/remove-block-list.js +26 -0
  110. package/src/migrations/update-18-0-0/remove-block-list.spec.ts +68 -0
  111. package/src/migrations/update-18-0-0/remove-metro.d.ts +14 -0
  112. package/src/migrations/update-18-0-0/remove-metro.js +29 -0
  113. package/src/migrations/update-18-0-0/remove-symlink-target.d.ts +6 -0
  114. package/src/migrations/update-18-0-0/remove-symlink-target.js +30 -0
  115. package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +40 -0
  116. package/src/utils/add-jest.js +11 -0
  117. package/src/utils/ensure-dependencies.js +2 -6
  118. package/src/utils/testing-generators.js +1 -0
  119. package/src/utils/versions.d.ts +9 -12
  120. package/src/utils/versions.js +10 -13
  121. package/src/generators/application/files/app/android/app/src/debug/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -75
  122. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainActivity.java.template +0 -32
  123. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.java.template +0 -62
  124. package/src/generators/application/files/app/android/app/src/release/java/com/__lowerCaseName__/ReactNativeFlipper.java.template +0 -20
  125. package/src/generators/application/files/app/babel.config.json.template +0 -10
  126. package/src/generators/application/lib/add-detox.d.ts +0 -3
  127. package/src/generators/application/lib/add-detox.js +0 -23
  128. package/src/generators/component-story/component-story.spec.ts +0 -427
  129. package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +0 -32
  130. package/src/generators/library/files/lib/babel.config.json.template +0 -19
  131. package/src/generators/stories/stories-app.spec.ts +0 -128
  132. package/src/generators/stories/stories-lib.spec.ts +0 -105
  133. package/src/generators/storybook-configuration/configuration.spec.ts +0 -135
  134. package/src/generators/storybook-configuration/files/app/storybook.ts.template +0 -9
  135. package/src/generators/storybook-configuration/files/app/toggle-storybook.tsx.template +0 -74
  136. package/src/generators/storybook-configuration/files/root/story-loader.ts.template +0 -5
  137. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.d.ts +0 -6
  138. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +0 -25
  139. package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +0 -161
  140. package/src/generators/storybook-configuration/lib/create-storybook-files.d.ts +0 -6
  141. package/src/generators/storybook-configuration/lib/create-storybook-files.js +0 -42
  142. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.d.ts +0 -7
  143. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +0 -29
  144. package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +0 -65
  145. package/src/utils/find-all-npm-dependencies.d.ts +0 -2
  146. package/src/utils/find-all-npm-dependencies.js +0 -25
  147. package/src/utils/find-all-npm-dependencies.spec.ts +0 -95
  148. package/src/utils/symlink-task.d.ts +0 -2
  149. package/src/utils/symlink-task.js +0 -18
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStorybookFiles = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- const chalk = require("chalk");
7
- /**
8
- * This function generate ./storybook under project root.
9
- */
10
- async function createStorybookFiles(host, schema) {
11
- const { root, projectType, targets, sourceRoot } = (0, devkit_1.readProjectConfiguration)(host, schema.name);
12
- // do not proceed if not a react native project
13
- if (targets?.start?.executor !== '@nx/react-native:start' &&
14
- targets?.start?.executor !== '@nx/expo:start' &&
15
- targets?.start?.executor !== '@nrwl/react-native:start' &&
16
- targets?.start?.executor !== '@nrwl/expo:start') {
17
- devkit_1.logger.error(`Unable to add storybook to ${schema.name}. It is not a Nx React Native / Expo project.`);
18
- return;
19
- }
20
- const storybookUIFileName = schema.js ? 'storybook.js' : 'storybook.ts';
21
- const storybookUIFilePath = (0, path_1.join)(root, `./${storybookUIFileName}`);
22
- if (host.exists(storybookUIFilePath)) {
23
- devkit_1.logger.warn(`${storybookUIFileName} file already exists for ${projectType} ${schema.name}! Skipping generating this file.`);
24
- return;
25
- }
26
- if (projectType !== 'application') {
27
- devkit_1.logger.info(`${chalk.bold.cyan('info')} To see your Storybook stories on the device, you should start your mobile app for the <platform> of your choice (typically ios or android).`);
28
- }
29
- // copy files to app's .storybook folder
30
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/app'), (0, path_1.join)(root, 'src', 'storybook'), {
31
- tmpl: '',
32
- offsetFromRoot: (0, devkit_1.offsetFromRoot)(sourceRoot),
33
- });
34
- // copy files to workspace root's .storybook folder
35
- (0, devkit_1.generateFiles)(host, (0, path_1.join)(__dirname, '../files/root'), (0, path_1.join)(root, (0, devkit_1.offsetFromRoot)(root), '.storybook'), {
36
- tmpl: '',
37
- });
38
- if (schema.js) {
39
- (0, devkit_1.toJS)(host);
40
- }
41
- }
42
- exports.createStorybookFiles = createStorybookFiles;
@@ -1,7 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- import { StorybookConfigureSchema } from '../schema';
3
- /**
4
- * To replace the import statement for storybook.
5
- * Need to import app with storybook toggle from .storybook/toggle-storybook
6
- */
7
- export declare function replaceAppImportWithStorybookToggle(host: Tree, schema: StorybookConfigureSchema): void;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceAppImportWithStorybookToggle = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const path_1 = require("path");
6
- /**
7
- * To replace the import statement for storybook.
8
- * Need to import app with storybook toggle from .storybook/toggle-storybook
9
- */
10
- function replaceAppImportWithStorybookToggle(host, schema) {
11
- const { root, sourceRoot } = (0, devkit_1.readProjectConfiguration)(host, schema.name);
12
- const mainFilePath = (0, path_1.join)(sourceRoot, schema.js ? 'main.js' : 'main.tsx');
13
- const appImportImport = `import App from './app/App';`;
14
- const storybookeToggleImport = `import App from './storybook/toggle-storybook';`;
15
- try {
16
- devkit_1.logger.debug(`Updating import for ${mainFilePath}`);
17
- const contents = host.read(mainFilePath, 'utf-8');
18
- if (!contents.includes(appImportImport) ||
19
- contents.includes(storybookeToggleImport)) {
20
- devkit_1.logger.warn((0, devkit_1.stripIndents) `${mainFilePath} is already udpated.`);
21
- return;
22
- }
23
- host.write(mainFilePath, contents.replace(appImportImport, storybookeToggleImport));
24
- }
25
- catch {
26
- devkit_1.logger.warn((0, devkit_1.stripIndents) `Unable to update import in ${mainFilePath} for project ${root}.`);
27
- }
28
- }
29
- exports.replaceAppImportWithStorybookToggle = replaceAppImportWithStorybookToggle;
@@ -1,65 +0,0 @@
1
- import { addProjectConfiguration, Tree } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
-
4
- import { formatFile } from '../../../utils/format-file';
5
-
6
- import { replaceAppImportWithStorybookToggle } from './replace-app-import-with-storybook-toggle';
7
-
8
- describe('replaceAppImportWithStorybookToggle', () => {
9
- let tree: Tree;
10
-
11
- beforeEach(() => {
12
- tree = createTreeWithEmptyWorkspace();
13
-
14
- addProjectConfiguration(tree, 'products', {
15
- root: 'products',
16
- sourceRoot: 'products/src',
17
- });
18
- });
19
-
20
- it('should update the main file with import from storybook', async () => {
21
- tree.write(
22
- 'products/src/main.tsx',
23
- formatFile`import { AppRegistry } from 'react-native';
24
- import App from './app/App';
25
-
26
- AppRegistry.registerComponent('main', () => App);
27
- `
28
- );
29
- replaceAppImportWithStorybookToggle(tree, {
30
- name: 'products',
31
- js: false,
32
- });
33
-
34
- const mainFile = tree.read('products/src/main.tsx', 'utf-8');
35
- expect(formatFile`${mainFile}`).toEqual(
36
- formatFile`import { AppRegistry } from 'react-native';
37
- import App from './storybook/toggle-storybook';
38
-
39
- AppRegistry.registerComponent('main', () => App);`
40
- );
41
- });
42
-
43
- it('should not update the main file if import is already updated', async () => {
44
- tree.write(
45
- 'products/src/main.tsx',
46
- formatFile`import { AppRegistry } from 'react-native';
47
- import App from './app/App';
48
-
49
- AppRegistry.registerComponent('main', () => App);
50
- `
51
- );
52
- replaceAppImportWithStorybookToggle(tree, {
53
- name: 'products',
54
- js: false,
55
- });
56
-
57
- const mainFile = tree.read('products/src/main.tsx', 'utf-8');
58
- expect(formatFile`${mainFile}`).toEqual(
59
- formatFile`import { AppRegistry } from 'react-native';
60
- import App from './storybook/toggle-storybook';
61
-
62
- AppRegistry.registerComponent('main', () => App);`
63
- );
64
- });
65
- });
@@ -1,2 +0,0 @@
1
- import { ProjectGraph } from '@nx/devkit';
2
- export declare function findAllNpmDependencies(graph: ProjectGraph, projectName: string, list?: string[], seen?: Set<string>): string[];
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findAllNpmDependencies = void 0;
4
- function findAllNpmDependencies(graph, projectName, list = [], seen = new Set()) {
5
- // In case of bad circular dependencies
6
- if (seen.has(projectName)) {
7
- return list;
8
- }
9
- seen.add(projectName);
10
- const node = graph.externalNodes[projectName];
11
- // Don't want to include '@nx/react-native' because React Native
12
- // autolink will warn that the package has no podspec file for iOS.
13
- if (node) {
14
- if (node.name !== 'npm:@nx/react-native' &&
15
- node.name !== 'npm:@nrwl/react-native') {
16
- list.push(node.data.packageName);
17
- }
18
- }
19
- else {
20
- // it's workspace project, search for it's dependencies
21
- graph.dependencies[projectName]?.forEach((dep) => findAllNpmDependencies(graph, dep.target, list, seen));
22
- }
23
- return list;
24
- }
25
- exports.findAllNpmDependencies = findAllNpmDependencies;
@@ -1,95 +0,0 @@
1
- import { findAllNpmDependencies } from './find-all-npm-dependencies';
2
- import { ProjectGraph } from '@nx/devkit';
3
-
4
- test('findAllNpmDependencies', () => {
5
- const graph: ProjectGraph = {
6
- nodes: {
7
- myapp: {
8
- type: 'app',
9
- name: 'myapp',
10
- data: { files: [] },
11
- },
12
- lib1: {
13
- type: 'lib',
14
- name: 'lib1',
15
- data: { files: [] },
16
- },
17
- lib2: {
18
- type: 'lib',
19
- name: 'lib2',
20
- data: { files: [] },
21
- },
22
- lib3: {
23
- type: 'lib',
24
- name: 'lib3',
25
- data: { files: [] },
26
- },
27
- } as any,
28
- externalNodes: {
29
- 'npm:react-native-image-picker': {
30
- type: 'npm',
31
- name: 'npm:react-native-image-picker',
32
- data: {
33
- version: '1',
34
- packageName: 'react-native-image-picker',
35
- },
36
- },
37
- 'npm:react-native-dialog': {
38
- type: 'npm',
39
- name: 'npm:react-native-dialog',
40
- data: {
41
- version: '1',
42
- packageName: 'react-native-dialog',
43
- },
44
- },
45
- 'npm:react-native-snackbar': {
46
- type: 'npm',
47
- name: 'npm:react-native-snackbar',
48
- data: {
49
- version: '1',
50
- packageName: 'react-native-snackbar',
51
- },
52
- },
53
- 'npm:@nx/react-native': {
54
- type: 'npm',
55
- name: 'npm:@nx/react-native',
56
- data: {
57
- version: '1',
58
- packageName: '@nx/react-native',
59
- },
60
- },
61
- },
62
- dependencies: {
63
- myapp: [
64
- { type: 'static', source: 'myapp', target: 'lib1' },
65
- { type: 'static', source: 'myapp', target: 'lib2' },
66
- {
67
- type: 'static',
68
- source: 'myapp',
69
- target: 'npm:react-native-image-picker',
70
- },
71
- {
72
- type: 'static',
73
- source: 'myapp',
74
- target: 'npm:@nx/react-native',
75
- },
76
- ],
77
- lib1: [
78
- { type: 'static', source: 'lib1', target: 'lib2' },
79
- { type: 'static', source: 'lib3', target: 'npm:react-native-snackbar' },
80
- ],
81
- lib2: [{ type: 'static', source: 'lib2', target: 'lib3' }],
82
- lib3: [
83
- { type: 'static', source: 'lib3', target: 'npm:react-native-dialog' },
84
- ],
85
- },
86
- };
87
-
88
- const result = findAllNpmDependencies(graph, 'myapp');
89
-
90
- expect(result).toEqual([
91
- 'react-native-dialog',
92
- 'react-native-snackbar',
93
- 'react-native-image-picker',
94
- ]);
95
- });
@@ -1,2 +0,0 @@
1
- import { GeneratorCallback } from '@nx/devkit';
2
- export declare function runSymlink(workspaceRoot: string, projectRoot: string): GeneratorCallback;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runSymlink = void 0;
4
- const ensure_node_modules_symlink_1 = require("./ensure-node-modules-symlink");
5
- const chalk = require("chalk");
6
- const devkit_1 = require("@nx/devkit");
7
- function runSymlink(workspaceRoot, projectRoot) {
8
- return () => {
9
- devkit_1.logger.info(`creating symlinks for ${chalk.bold(projectRoot)}`);
10
- try {
11
- (0, ensure_node_modules_symlink_1.ensureNodeModulesSymlink)(workspaceRoot, projectRoot);
12
- }
13
- catch {
14
- throw new Error(`Failed to create symlinks for ${chalk.bold(projectRoot)}`);
15
- }
16
- };
17
- }
18
- exports.runSymlink = runSymlink;