@nx/react-native 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba

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 (71) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/migrations.json +78 -287
  4. package/package.json +11 -10
  5. package/plugins/plugin.js +17 -38
  6. package/plugins/with-nx-metro.js +3 -2
  7. package/project.json +1 -3
  8. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +1 -1
  9. package/src/executors/ensure-symlink/ensure-symlink.impl.js +1 -1
  10. package/src/executors/storybook/schema.d.ts +1 -0
  11. package/src/executors/storybook/storybook.impl.d.ts +1 -1
  12. package/src/executors/storybook/storybook.impl.js +10 -3
  13. package/src/generators/application/files/app/Gemfile.template +4 -2
  14. package/src/generators/application/files/app/android/app/build.gradle.template +0 -1
  15. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +1 -3
  16. package/src/generators/application/files/app/android/build.gradle.template +3 -3
  17. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  18. package/src/generators/application/files/app/android/gradlew.bat +10 -10
  19. package/src/generators/application/files/app/android/gradlew.template +7 -7
  20. package/src/generators/application/files/app/ios/Podfile.template +2 -17
  21. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +2 -2
  22. package/src/generators/application/files/app/ios/__className__/Info.plist.template +1 -1
  23. package/src/generators/application/files/app/ios/__className__/PrivacyInfo.xcprivacy +38 -0
  24. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +5 -1
  25. package/src/generators/application/files/app/metro.config.js.template +1 -1
  26. package/src/generators/application/files/app/tsconfig.app.json.template +1 -1
  27. package/src/generators/application/lib/normalize-options.d.ts +3 -0
  28. package/src/generators/application/lib/normalize-options.js +23 -0
  29. package/src/generators/application/schema.json +2 -2
  30. package/src/generators/component/schema.d.ts +1 -1
  31. package/src/generators/component/schema.json +1 -1
  32. package/src/generators/init/init.js +44 -31
  33. package/src/generators/init/lib/gitignore-entries.d.ts +1 -1
  34. package/src/generators/init/lib/gitignore-entries.js +2 -2
  35. package/src/generators/library/files/lib/tsconfig.lib.json.template +1 -1
  36. package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +3 -3
  37. package/src/migrations/update-18-0-0/change-storybook-targets.js +1 -1
  38. package/src/utils/add-jest.js +2 -2
  39. package/src/utils/versions.d.ts +9 -9
  40. package/src/utils/versions.js +9 -9
  41. package/src/executors/build-android/build-android.impl.ts +0 -69
  42. package/src/executors/build-ios/build-ios.impl.ts +0 -77
  43. package/src/executors/bundle/bundle.impl.ts +0 -77
  44. package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -22
  45. package/src/executors/pod-install/pod-install.impl.ts +0 -21
  46. package/src/executors/run-android/run-android.impl.ts +0 -94
  47. package/src/executors/run-ios/run-ios.impl.ts +0 -92
  48. package/src/executors/start/start.impl.ts +0 -111
  49. package/src/executors/storybook/storybook.impl.ts +0 -85
  50. package/src/executors/sync-deps/sync-deps.impl.ts +0 -140
  51. package/src/executors/upgrade/upgrade.impl.ts +0 -64
  52. package/src/generators/application/application.spec.ts +0 -258
  53. package/src/generators/application/files/app/test-setup.ts.template +0 -1
  54. package/src/generators/application/lib/normalize-options.spec.ts +0 -196
  55. package/src/generators/component/component.spec.ts +0 -127
  56. package/src/generators/init/init.spec.ts +0 -38
  57. package/src/generators/library/files/lib/test-setup.ts.template +0 -1
  58. package/src/generators/library/library.spec.ts +0 -420
  59. package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +0 -2
  60. package/src/migrations/update-15-0-0/add-babel-inputs.js +0 -9
  61. package/src/migrations/update-15-0-0/add-babel-inputs.spec.ts +0 -73
  62. package/src/migrations/update-15-9-1/add-build-ios-target.d.ts +0 -5
  63. package/src/migrations/update-15-9-1/add-build-ios-target.js +0 -29
  64. package/src/migrations/update-15-9-1/add-build-ios-target.spec.ts +0 -36
  65. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +0 -37
  66. package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
  67. package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
  68. package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
  69. package/src/utils/add-linting.spec.ts +0 -40
  70. package/src/utils/ensure-node-modules-symlink.spec.ts +0 -108
  71. package/src/utils/find-all-npm-dependencies.spec.ts +0 -103
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- /**
5
- * Add build-ios target for react-native
6
- */
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
- };
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);
25
- }
26
- }
27
- await (0, devkit_1.formatFiles)(tree);
28
- }
29
- exports.default = update;
@@ -1,36 +0,0 @@
1
- import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import update from './add-build-ios-target';
4
-
5
- describe('add-build-ios-target', () => {
6
- let tree: Tree;
7
-
8
- beforeEach(async () => {
9
- tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10
- addProjectConfiguration(tree, 'product', {
11
- root: 'apps/product',
12
- sourceRoot: 'apps/product/src',
13
- targets: {
14
- start: {
15
- executor: '@nrwl/react-native:start',
16
- },
17
- },
18
- });
19
- });
20
-
21
- it(`should update project.json with target build-ios and pod-install`, async () => {
22
- await update(tree);
23
-
24
- getProjects(tree).forEach((project) => {
25
- expect(project.targets['build-ios']).toEqual({
26
- executor: '@nrwl/react-native:build-ios',
27
- outputs: ['{projectRoot}/ios/build/Build'],
28
- options: {},
29
- });
30
- expect(project.targets['pod-install']).toEqual({
31
- executor: '@nrwl/react-native:pod-install',
32
- options: {},
33
- });
34
- });
35
- });
36
- });
@@ -1,37 +0,0 @@
1
- import { Tree, readJson, updateJson } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import replacePackage from './update-16-0-0-add-nx-packages';
4
-
5
- describe('update-16-0-0-add-nx-packages', () => {
6
- let tree: Tree;
7
- beforeEach(() => {
8
- tree = createTreeWithEmptyWorkspace();
9
-
10
- updateJson(tree, 'package.json', (json) => {
11
- json.devDependencies['@nrwl/react-native'] = '16.0.0';
12
- return json;
13
- });
14
- });
15
-
16
- it('should remove the dependency on @nrwl/react-native', async () => {
17
- await replacePackage(tree);
18
-
19
- expect(
20
- readJson(tree, 'package.json').dependencies['@nrwl/react-native']
21
- ).not.toBeDefined();
22
- expect(
23
- readJson(tree, 'package.json').devDependencies['@nrwl/react-native']
24
- ).not.toBeDefined();
25
- });
26
-
27
- it('should add a dependency on @nx/react-native', async () => {
28
- await replacePackage(tree);
29
-
30
- const packageJson = readJson(tree, 'package.json');
31
- const newDependencyVersion =
32
- packageJson.devDependencies['@nx/react-native'] ??
33
- packageJson.dependencies['@nx/react-native'];
34
-
35
- expect(newDependencyVersion).toBeDefined();
36
- });
37
- });
@@ -1,39 +0,0 @@
1
- import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import update from './add-web-configuration';
4
-
5
- describe('add-web-configuration', () => {
6
- let tree: Tree;
7
-
8
- beforeEach(async () => {
9
- tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10
- addProjectConfiguration(tree, 'product', {
11
- root: 'apps/product',
12
- sourceRoot: 'apps/product/src',
13
- targets: {
14
- start: {
15
- executor: '@nx/react-native:start',
16
- options: {},
17
- },
18
- serve: {
19
- executor: 'nx:run-commands',
20
- options: {
21
- command: 'nx start product',
22
- },
23
- },
24
- },
25
- });
26
- });
27
-
28
- it(`should add web configuration`, async () => {
29
- await update(tree);
30
-
31
- tree.exists('apps/product/webpack.config.js');
32
- getProjects(tree).forEach((project) => {
33
- expect(project.targets['build'].executor).toEqual('@nx/webpack:webpack');
34
- expect(project.targets['serve'].executor).toEqual(
35
- '@nx/webpack:dev-server'
36
- );
37
- });
38
- });
39
- });
@@ -1,68 +0,0 @@
1
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
2
- import { Tree, addProjectConfiguration } from '@nx/devkit';
3
- import update from './remove-block-list';
4
-
5
- describe('remove-block-list', () => {
6
- let tree: Tree;
7
-
8
- beforeEach(() => {
9
- tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10
- addProjectConfiguration(tree, 'product', {
11
- root: 'apps/product',
12
- targets: {
13
- start: {
14
- executor: '@nx/react-native:start',
15
- },
16
- },
17
- });
18
- tree.write(
19
- 'apps/product/metro.config.js',
20
- `
21
- const { withNxMetro } = require('@nx/expo');
22
- const { getDefaultConfig } = require('@expo/metro-config');
23
- const { mergeConfig } = require('metro-config');
24
- const exclusionList = require('metro-config/src/defaults/exclusionList');
25
-
26
- const defaultConfig = getDefaultConfig(__dirname);
27
- const { assetExts, sourceExts } = defaultConfig.resolver;
28
-
29
- /**
30
- * Metro configuration
31
- * https://facebook.github.io/metro/docs/configuration
32
- *
33
- * @type {import('metro-config').MetroConfig}
34
- */
35
- const customConfig = {
36
- transformer: {
37
- babelTransformerPath: require.resolve('react-native-svg-transformer'),
38
- },
39
- resolver: {
40
- assetExts: assetExts.filter((ext) => ext !== 'svg'),
41
- sourceExts: [...sourceExts, 'svg'],
42
- blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
43
- unstable_enableSymlinks: true,
44
- unstable_enablePackageExports: true,
45
- },
46
- };
47
-
48
-
49
- module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
50
- // Change this to true to see debugging info.
51
- // Useful if you have issues resolving modules
52
- debug: false,
53
- // all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
54
- extensions: [],
55
- // Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
56
- watchFolders: [],
57
- });`
58
- );
59
- });
60
-
61
- it('should remove blockList', async () => {
62
- await update(tree);
63
- const metroConfig = tree.read(`apps/product/metro.config.js`).toString();
64
- expect(metroConfig).not.toContain('blockList');
65
- expect(metroConfig).not.toContain('unstable_enableSymlinks');
66
- expect(metroConfig).not.toContain('unstable_enablePackageExports');
67
- });
68
- });
@@ -1,40 +0,0 @@
1
- import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import update from './remove-symlink-target';
4
-
5
- describe('remove-symlink-target', () => {
6
- let tree: Tree;
7
-
8
- beforeEach(async () => {
9
- tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10
- addProjectConfiguration(tree, 'product', {
11
- root: 'apps/product',
12
- sourceRoot: 'apps/product/src',
13
- targets: {
14
- 'ensure-symlink': {
15
- executor: '@nx/react-native:ensure-symlink',
16
- options: {},
17
- },
18
- 'bundle-android': {
19
- executor: '@nx/react-native:bundle',
20
- dependsOn: ['ensure-symlink'],
21
- outputs: ['{options.bundleOutput}'],
22
- options: {
23
- entryFile: 'src/main.tsx',
24
- platform: 'android',
25
- bundleOutput: 'dist/apps/techy-jokes/android/main.jsbundle',
26
- },
27
- },
28
- },
29
- });
30
- });
31
-
32
- it(`should remove ensure-symlink target from project.json`, async () => {
33
- await update(tree);
34
-
35
- getProjects(tree).forEach((project) => {
36
- expect(project.targets['ensure-symlink']).toBeUndefined();
37
- expect(project.targets['bundle-android'].dependsOn).toEqual([]);
38
- });
39
- });
40
- });
@@ -1,40 +0,0 @@
1
- import { readProjectConfiguration, Tree } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import { Linter } from '@nx/eslint';
4
- import { libraryGenerator } from '@nx/js';
5
- import { addLinting } from './add-linting';
6
-
7
- describe('Add Linting', () => {
8
- let tree: Tree;
9
-
10
- beforeEach(async () => {
11
- tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
12
- await libraryGenerator(tree, {
13
- name: 'my-lib',
14
- linter: Linter.None,
15
- });
16
- });
17
-
18
- it('should add a .eslintrc.json when is passed', async () => {
19
- await addLinting(tree, {
20
- projectName: 'my-lib',
21
- linter: Linter.EsLint,
22
- tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
23
- projectRoot: 'libs/my-lib',
24
- });
25
-
26
- expect(tree.exists('libs/my-lib/.eslintrc.json')).toBeTruthy();
27
- });
28
-
29
- it('should not add lint target when "none" is passed', async () => {
30
- await addLinting(tree, {
31
- projectName: 'my-lib',
32
- linter: Linter.None,
33
- tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
34
- projectRoot: 'libs/my-lib',
35
- });
36
- const project = readProjectConfiguration(tree, 'my-lib');
37
-
38
- expect(project.targets.lint).toBeUndefined();
39
- });
40
- });
@@ -1,108 +0,0 @@
1
- import { tmpdir } from 'os';
2
- import { join } from 'path';
3
- import * as fs from 'fs-extra';
4
- import { ensureNodeModulesSymlink } from './ensure-node-modules-symlink';
5
-
6
- const workspaceDir = join(tmpdir(), 'nx-react-native-test');
7
- const appDir = 'apps/myapp';
8
- const appDirAbsolutePath = join(workspaceDir, appDir);
9
-
10
- describe('ensureNodeModulesSymlink', () => {
11
- beforeEach(() => {
12
- if (fs.existsSync(workspaceDir)) fs.removeSync(workspaceDir);
13
- fs.mkdirSync(workspaceDir);
14
- fs.mkdirSync(appDirAbsolutePath, { recursive: true });
15
- fs.mkdirSync(appDirAbsolutePath, { recursive: true });
16
- fs.writeFileSync(
17
- join(appDirAbsolutePath, 'package.json'),
18
- JSON.stringify({
19
- name: 'myapp',
20
- dependencies: { 'react-native': '*' },
21
- })
22
- );
23
- fs.writeFileSync(
24
- join(workspaceDir, 'package.json'),
25
- JSON.stringify({
26
- name: 'workspace',
27
- dependencies: {
28
- '@nx/react-native': '9999.9.9',
29
- '@react-native-community/cli-platform-ios': '7777.7.7',
30
- '@react-native-community/cli-platform-android': '7777.7.7',
31
- 'react-native': '0.9999.0',
32
- },
33
- })
34
- );
35
- });
36
-
37
- afterEach(() => {
38
- if (fs.existsSync(workspaceDir)) fs.removeSync(workspaceDir);
39
- });
40
-
41
- it('should create symlinks', () => {
42
- createNpmDirectory('@nx/react-native', '9999.9.9');
43
- createNpmDirectory(
44
- '@react-native-community/cli-platform-android',
45
- '7777.7.7'
46
- );
47
- createNpmDirectory('@react-native-community/cli-platform-ios', '7777.7.7');
48
- createNpmDirectory('hermes-engine', '3333.3.3');
49
- createNpmDirectory('react-native', '0.9999.0');
50
- createNpmDirectory('jsc-android', '888888.0.0');
51
- createNpmDirectory('@babel/runtime', '5555.0.0');
52
-
53
- ensureNodeModulesSymlink(workspaceDir, appDir);
54
-
55
- expectSymlinkToExist('@nx/react-native');
56
- expectSymlinkToExist('react-native');
57
- expectSymlinkToExist('jsc-android');
58
- expectSymlinkToExist('hermes-engine');
59
- expectSymlinkToExist('@react-native-community/cli-platform-ios');
60
- expectSymlinkToExist('@react-native-community/cli-platform-android');
61
- expectSymlinkToExist('@babel/runtime');
62
- });
63
-
64
- it('should add packages listed in workspace package.json', () => {
65
- fs.writeFileSync(
66
- join(workspaceDir, 'package.json'),
67
- JSON.stringify({
68
- name: 'workspace',
69
- dependencies: {
70
- random: '9999.9.9',
71
- },
72
- })
73
- );
74
- createNpmDirectory('@nx/react-native', '9999.9.9');
75
- createNpmDirectory(
76
- '@react-native-community/cli-platform-android',
77
- '7777.7.7'
78
- );
79
- createNpmDirectory('@react-native-community/cli-platform-ios', '7777.7.7');
80
- createNpmDirectory('hermes-engine', '3333.3.3');
81
- createNpmDirectory('react-native', '0.9999.0');
82
- createNpmDirectory('jsc-android', '888888.0.0');
83
- createNpmDirectory('@babel/runtime', '5555.0.0');
84
- createNpmDirectory('random', '9999.9.9');
85
-
86
- ensureNodeModulesSymlink(workspaceDir, appDir);
87
-
88
- expectSymlinkToExist('random');
89
- });
90
-
91
- function createNpmDirectory(packageName, version) {
92
- const dir = join(workspaceDir, `node_modules/${packageName}`);
93
- fs.mkdirSync(dir, { recursive: true });
94
- fs.writeFileSync(
95
- join(dir, 'package.json'),
96
- JSON.stringify({ name: packageName, version: version })
97
- );
98
- return dir;
99
- }
100
-
101
- function expectSymlinkToExist(packageName) {
102
- expect(
103
- fs.existsSync(
104
- join(appDirAbsolutePath, `node_modules/${packageName}/package.json`)
105
- )
106
- ).toBe(true);
107
- }
108
- });
@@ -1,103 +0,0 @@
1
- import { findAllNpmDependencies } from './find-all-npm-dependencies';
2
- import { DependencyType, 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: DependencyType.static, source: 'myapp', target: 'lib1' },
65
- { type: DependencyType.static, source: 'myapp', target: 'lib2' },
66
- {
67
- type: DependencyType.static,
68
- source: 'myapp',
69
- target: 'npm:react-native-image-picker',
70
- },
71
- {
72
- type: DependencyType.static,
73
- source: 'myapp',
74
- target: 'npm:@nx/react-native',
75
- },
76
- ],
77
- lib1: [
78
- { type: DependencyType.static, source: 'lib1', target: 'lib2' },
79
- {
80
- type: DependencyType.static,
81
- source: 'lib3',
82
- target: 'npm:react-native-snackbar',
83
- },
84
- ],
85
- lib2: [{ type: DependencyType.static, source: 'lib2', target: 'lib3' }],
86
- lib3: [
87
- {
88
- type: DependencyType.static,
89
- source: 'lib3',
90
- target: 'npm:react-native-dialog',
91
- },
92
- ],
93
- },
94
- };
95
-
96
- const result = findAllNpmDependencies(graph, 'myapp');
97
-
98
- expect(result).toEqual([
99
- 'react-native-dialog',
100
- 'react-native-snackbar',
101
- 'react-native-image-picker',
102
- ]);
103
- });