@nx/react-native 20.2.0-beta.3 → 20.2.0-beta.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "20.2.0-beta.3",
3
+ "version": "20.2.0-beta.4",
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": [
@@ -36,12 +36,12 @@
36
36
  "node-fetch": "^2.6.7",
37
37
  "tsconfig-paths": "^4.1.2",
38
38
  "tslib": "^2.3.0",
39
- "@nx/devkit": "20.2.0-beta.3",
40
- "@nx/jest": "20.2.0-beta.3",
41
- "@nx/js": "20.2.0-beta.3",
42
- "@nx/eslint": "20.2.0-beta.3",
43
- "@nx/react": "20.2.0-beta.3",
44
- "@nx/workspace": "20.2.0-beta.3"
39
+ "@nx/devkit": "20.2.0-beta.4",
40
+ "@nx/jest": "20.2.0-beta.4",
41
+ "@nx/js": "20.2.0-beta.4",
42
+ "@nx/eslint": "20.2.0-beta.4",
43
+ "@nx/react": "20.2.0-beta.4",
44
+ "@nx/workspace": "20.2.0-beta.4"
45
45
  },
46
46
  "executors": "./executors.json",
47
47
  "ng-update": {
@@ -5,7 +5,6 @@ exports.reactNativeApplicationGeneratorInternal = reactNativeApplicationGenerato
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
7
7
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
8
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
9
8
  const add_linting_1 = require("../../utils/add-linting");
10
9
  const add_jest_1 = require("../../utils/add-jest");
11
10
  const chmod_android_gradle_files_1 = require("../../utils/chmod-android-gradle-files");
@@ -18,6 +17,7 @@ const create_application_files_1 = require("./lib/create-application-files");
18
17
  const add_e2e_1 = require("./lib/add-e2e");
19
18
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
20
19
  const sync_deps_impl_1 = require("../../executors/sync-deps/sync-deps.impl");
20
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
21
21
  async function reactNativeApplicationGenerator(host, schema) {
22
22
  return await reactNativeApplicationGeneratorInternal(host, {
23
23
  addPlugin: false,
@@ -25,14 +25,15 @@ async function reactNativeApplicationGenerator(host, schema) {
25
25
  });
26
26
  }
27
27
  async function reactNativeApplicationGeneratorInternal(host, schema) {
28
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react-native', 'application');
29
- const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
30
28
  const tasks = [];
31
29
  const jsInitTask = await (0, js_1.initGenerator)(host, {
32
30
  ...schema,
33
31
  skipFormat: true,
32
+ addTsPlugin: schema.useTsSolution,
33
+ formatter: schema.formatter,
34
34
  });
35
35
  tasks.push(jsInitTask);
36
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
36
37
  const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
37
38
  tasks.push(initTask);
38
39
  if (!options.skipPackageJson) {
@@ -76,6 +77,15 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
76
77
  ],
77
78
  });
78
79
  }
80
+ (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.appProjectRoot, 'tsconfig.app.json', {
81
+ jsx: 'react-jsx',
82
+ module: 'esnext',
83
+ moduleResolution: 'bundler',
84
+ noUnusedLocals: false,
85
+ lib: ['dom'],
86
+ }, options.linter === 'eslint'
87
+ ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
88
+ : undefined);
79
89
  if (!options.skipFormat) {
80
90
  await (0, devkit_1.formatFiles)(host);
81
91
  }
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProject = addProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
5
7
  function addProject(host, options) {
6
8
  const nxJson = (0, devkit_1.readNxJson)(host);
7
9
  const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
@@ -14,9 +16,25 @@ function addProject(host, options) {
14
16
  targets: hasPlugin ? {} : getTargets(options),
15
17
  tags: options.parsedTags,
16
18
  };
17
- (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
18
- ...project,
19
- });
19
+ if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
20
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
21
+ name: (0, get_import_path_1.getImportPath)(host, options.name),
22
+ version: '0.0.1',
23
+ private: true,
24
+ nx: {
25
+ name: options.name,
26
+ projectType: 'application',
27
+ sourceRoot: `${options.appProjectRoot}/src`,
28
+ targets: hasPlugin ? {} : getTargets(options),
29
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
30
+ },
31
+ });
32
+ }
33
+ else {
34
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, {
35
+ ...project,
36
+ });
37
+ }
20
38
  }
21
39
  function getTargets(options) {
22
40
  const architect = {};
@@ -16,6 +16,9 @@ export interface Schema {
16
16
  bundler: 'webpack' | 'vite'; // default is webpack
17
17
  install: boolean; // default is true
18
18
  skipPackageJson?: boolean; //default is false
19
+ // Internal options
19
20
  addPlugin?: boolean;
20
21
  nxCloudToken?: string;
22
+ useTsSolution?: boolean;
23
+ formatter?: 'prettier' | 'none';
21
24
  }
@@ -44,13 +44,15 @@
44
44
  "description": "The tool to use for running lint checks.",
45
45
  "type": "string",
46
46
  "enum": ["eslint", "none"],
47
- "default": "eslint"
47
+ "default": "none",
48
+ "x-priority": "important"
48
49
  },
49
50
  "unitTestRunner": {
50
51
  "type": "string",
51
52
  "enum": ["jest", "none"],
52
53
  "description": "Test runner to use for unit tests",
53
- "default": "jest"
54
+ "default": "none",
55
+ "x-priority": "important"
54
56
  },
55
57
  "tags": {
56
58
  "type": "string",
@@ -71,7 +73,8 @@
71
73
  "description": "Adds the specified e2e test runner.",
72
74
  "type": "string",
73
75
  "enum": ["playwright", "cypress", "detox", "none"],
74
- "default": "playwright"
76
+ "default": "none",
77
+ "x-priority": "important"
75
78
  },
76
79
  "install": {
77
80
  "type": "boolean",
@@ -7,28 +7,31 @@
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
- "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component ",
11
- "description": "Generate a component in the `mylib` library"
10
+ "description": "Generate a component with the exported symbol matching the file name. It results in the component `Foo` at `mylib/src/lib/foo.tsx`",
11
+ "command": "nx g @nx/react-native:component mylib/src/lib/foo"
12
12
  },
13
13
  {
14
- "command": "nx g @nx/react-native:component mylib/src/lib/my-component/my-component --classComponent",
15
- "description": "Generate a class component in the `mylib` library"
14
+ "description": "Generate a component with the exported symbol different from the file name. It results in the component `Custom` at `mylib/src/lib/foo.tsx`",
15
+ "command": "nx g @nx/react-native:component mylib/src/lib/foo --name=custom"
16
+ },
17
+ {
18
+ "description": "Generate a class component at `mylib/src/lib/foo.tsx`",
19
+ "command": "nx g @nx/react-native:component mylib/src/lib/foo --classComponent"
16
20
  }
17
21
  ],
18
22
  "properties": {
19
23
  "path": {
20
24
  "type": "string",
21
- "description": "The path at which to create the component file.",
25
+ "description": "The file path to the component without the file extension. Relative to the current working directory.",
22
26
  "$default": {
23
27
  "$source": "argv",
24
28
  "index": 0
25
29
  },
26
- "x-prompt": "What path would you like to use for the component?"
30
+ "x-prompt": "What is the component file path?"
27
31
  },
28
32
  "name": {
29
33
  "type": "string",
30
- "description": "The name of the component.",
31
- "x-prompt": "What name would you like to use for the component?"
34
+ "description": "The component symbol name. Defaults to the last segment of the file path."
32
35
  },
33
36
  "js": {
34
37
  "type": "boolean",
@@ -5,7 +5,6 @@ exports.reactNativeInitGeneratorInternal = reactNativeInitGeneratorInternal;
5
5
  exports.updateDependencies = updateDependencies;
6
6
  const devkit_1 = require("@nx/devkit");
7
7
  const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
8
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
9
8
  const plugin_1 = require("../../../plugins/plugin");
10
9
  const versions_1 = require("../../utils/versions");
11
10
  const add_git_ignore_entry_1 = require("./lib/add-git-ignore-entry");
@@ -16,7 +15,6 @@ function reactNativeInitGenerator(host, schema) {
16
15
  });
17
16
  }
18
17
  async function reactNativeInitGeneratorInternal(host, schema) {
19
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react-native', 'init');
20
18
  (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
21
19
  const nxJson = (0, devkit_1.readNxJson)(host);
22
20
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -8,5 +8,6 @@ export interface NormalizedSchema extends Schema {
8
8
  parsedTags: string[];
9
9
  appMain?: string;
10
10
  appSourceRoot?: string;
11
+ isUsingTsSolutionConfig: boolean;
11
12
  }
12
13
  export declare function normalizeOptions(host: Tree, options: Schema): Promise<NormalizedSchema>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = normalizeOptions;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  async function normalizeOptions(host, options) {
7
8
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
8
9
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -26,6 +27,7 @@ async function normalizeOptions(host, options) {
26
27
  projectRoot,
27
28
  parsedTags,
28
29
  importPath,
30
+ isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
29
31
  };
30
32
  return normalized;
31
33
  }
@@ -12,6 +12,7 @@ const normalize_options_1 = require("./lib/normalize-options");
12
12
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
13
13
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
14
14
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
15
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
15
16
  async function reactNativeLibraryGenerator(host, schema) {
16
17
  return await reactNativeLibraryGeneratorInternal(host, {
17
18
  addPlugin: false,
@@ -19,17 +20,16 @@ async function reactNativeLibraryGenerator(host, schema) {
19
20
  });
20
21
  }
21
22
  async function reactNativeLibraryGeneratorInternal(host, schema) {
22
- (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(host, 'react-native', 'library');
23
- const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
24
- if (options.publishable === true && !schema.importPath) {
25
- throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
26
- }
27
23
  const tasks = [];
28
24
  const jsInitTask = await (0, js_1.initGenerator)(host, {
29
25
  ...schema,
30
26
  skipFormat: true,
31
27
  });
32
28
  tasks.push(jsInitTask);
29
+ const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
30
+ if (options.publishable === true && !schema.importPath) {
31
+ throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
32
+ }
33
33
  const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
34
34
  tasks.push(initTask);
35
35
  if (!options.skipPackageJson) {
@@ -58,9 +58,20 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
58
58
  (0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
59
59
  ]);
60
60
  }
61
+ (0, ts_solution_setup_1.updateTsconfigFiles)(host, options.projectRoot, 'tsconfig.lib.json', {
62
+ jsx: 'react-jsx',
63
+ module: 'esnext',
64
+ moduleResolution: 'bundler',
65
+ }, options.linter === 'eslint'
66
+ ? ['eslint.config.js', 'eslint.config.cjs', 'eslint.config.mjs']
67
+ : undefined);
61
68
  if (!options.skipFormat) {
62
69
  await (0, devkit_1.formatFiles)(host);
63
70
  }
71
+ // Always run install to link packages.
72
+ if (options.isUsingTsSolutionConfig) {
73
+ tasks.push(() => (0, devkit_1.installPackagesTask)(host));
74
+ }
64
75
  tasks.push(() => {
65
76
  (0, log_show_project_command_1.logShowProjectCommand)(options.name);
66
77
  });
@@ -74,7 +85,28 @@ async function addProject(host, options) {
74
85
  tags: options.parsedTags,
75
86
  targets: {},
76
87
  };
77
- (0, devkit_1.addProjectConfiguration)(host, options.name, project);
88
+ if (options.isUsingTsSolutionConfig) {
89
+ const sourceEntry = !options.buildable
90
+ ? options.js
91
+ ? './src/index.js'
92
+ : './src/index.ts'
93
+ : undefined;
94
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
95
+ name: (0, get_import_path_1.getImportPath)(host, options.name),
96
+ version: '0.0.1',
97
+ main: sourceEntry,
98
+ types: sourceEntry,
99
+ nx: {
100
+ name: options.name,
101
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
102
+ projectType: 'library',
103
+ tags: options.parsedTags?.length ? options.parsedTags : undefined,
104
+ },
105
+ });
106
+ }
107
+ else {
108
+ (0, devkit_1.addProjectConfiguration)(host, options.name, project);
109
+ }
78
110
  if (!options.publishable && !options.buildable) {
79
111
  return () => { };
80
112
  }
@@ -32,13 +32,16 @@
32
32
  "description": "The tool to use for running lint checks.",
33
33
  "type": "string",
34
34
  "enum": ["eslint", "none"],
35
- "default": "eslint"
35
+ "default": "none",
36
+ "x-prompt": "Which linter would you like to use?",
37
+ "x-priority": "important"
36
38
  },
37
39
  "unitTestRunner": {
38
40
  "type": "string",
39
41
  "enum": ["jest", "none"],
40
42
  "description": "Test runner to use for unit tests.",
41
- "default": "jest"
43
+ "default": "none",
44
+ "x-priority": "important"
42
45
  },
43
46
  "tags": {
44
47
  "type": "string",
@@ -40,6 +40,11 @@ async function webConfigurationGenerator(tree, options) {
40
40
  : null,
41
41
  });
42
42
  }
43
+ if (!options.skipPackageJson) {
44
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
45
+ '@types/react-dom': versions_1.typesReactDomVersion,
46
+ }));
47
+ }
43
48
  if (!options.skipFormat) {
44
49
  await (0, devkit_1.formatFiles)(tree);
45
50
  }
@@ -59,6 +64,7 @@ async function addBundlerConfiguration(tree, normalizedSchema) {
59
64
  project: normalizedSchema.project,
60
65
  newProject: true,
61
66
  includeVitest: false,
67
+ projectType: 'application',
62
68
  compiler: 'babel',
63
69
  skipFormat: true,
64
70
  });
@@ -9,6 +9,7 @@ export declare const reactVersion = "18.2.0";
9
9
  export declare const reactDomVersion = "18.2.0";
10
10
  export declare const reactTestRendererVersion = "18.2.0";
11
11
  export declare const typesReactVersion = "~18.2.45";
12
+ export declare const typesReactDomVersion = "18.3.0";
12
13
  export declare const testingLibraryReactNativeVersion = "~12.5.0";
13
14
  export declare const testingLibraryJestNativeVersion = "~5.4.3";
14
15
  export declare const jestReactNativeVersion = "18.0.0";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.babelRuntimeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.jestReactNativeVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.reactNativeWebVersion = exports.reactNativeMetroConfigVersion = exports.reactNativeBabelPresetVersion = exports.reactNativeCommunityCliPlatformAndroidVersion = exports.typesNodeVersion = exports.reactNativeVersion = exports.nxVersion = void 0;
3
+ exports.babelRuntimeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.jestReactNativeVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.typesReactDomVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.reactNativeWebVersion = exports.reactNativeMetroConfigVersion = exports.reactNativeBabelPresetVersion = exports.reactNativeCommunityCliPlatformAndroidVersion = exports.typesNodeVersion = exports.reactNativeVersion = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.reactNativeVersion = '0.74.1';
6
6
  exports.typesNodeVersion = '18.16.9';
@@ -12,6 +12,7 @@ exports.reactVersion = '18.2.0';
12
12
  exports.reactDomVersion = '18.2.0';
13
13
  exports.reactTestRendererVersion = '18.2.0';
14
14
  exports.typesReactVersion = '~18.2.45';
15
+ exports.typesReactDomVersion = '18.3.0';
15
16
  exports.testingLibraryReactNativeVersion = '~12.5.0';
16
17
  exports.testingLibraryJestNativeVersion = '~5.4.3';
17
18
  exports.jestReactNativeVersion = '18.0.0';