@nx/react-native 0.0.0-pr-29703-8312c59 → 0.0.0-pr-29705-bc2a0dd

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": "0.0.0-pr-29703-8312c59",
3
+ "version": "0.0.0-pr-29705-bc2a0dd",
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": "0.0.0-pr-29703-8312c59",
40
- "@nx/jest": "0.0.0-pr-29703-8312c59",
41
- "@nx/js": "0.0.0-pr-29703-8312c59",
42
- "@nx/eslint": "0.0.0-pr-29703-8312c59",
43
- "@nx/react": "0.0.0-pr-29703-8312c59",
44
- "@nx/workspace": "0.0.0-pr-29703-8312c59"
39
+ "@nx/devkit": "0.0.0-pr-29705-bc2a0dd",
40
+ "@nx/jest": "0.0.0-pr-29705-bc2a0dd",
41
+ "@nx/js": "0.0.0-pr-29705-bc2a0dd",
42
+ "@nx/eslint": "0.0.0-pr-29705-bc2a0dd",
43
+ "@nx/react": "0.0.0-pr-29705-bc2a0dd",
44
+ "@nx/workspace": "0.0.0-pr-29705-bc2a0dd"
45
45
  },
46
46
  "executors": "./executors.json",
47
47
  "ng-update": {
@@ -51,11 +51,11 @@ async function reactNativeApplicationGeneratorInternal(host, schema) {
51
51
  ],
52
52
  });
53
53
  tasks.push(lintTask);
54
- const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, options.addPlugin);
54
+ const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.projectName, options.appProjectRoot, options.js, options.skipPackageJson, options.addPlugin, 'tsconfig.app.json');
55
55
  tasks.push(jestTask);
56
56
  const webTask = await (0, web_configuration_1.webConfigurationGenerator)(host, {
57
57
  ...options,
58
- project: options.name,
58
+ project: options.projectName,
59
59
  skipFormat: true,
60
60
  });
61
61
  tasks.push(webTask);
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addProject = addProject;
4
4
  const devkit_1 = require("@nx/devkit");
5
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");
7
6
  function addProject(host, options) {
8
7
  const nxJson = (0, devkit_1.readNxJson)(host);
9
8
  const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
@@ -18,13 +17,10 @@ function addProject(host, options) {
18
17
  };
19
18
  if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
20
19
  (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), {
21
- name: (0, get_import_path_1.getImportPath)(host, options.name),
20
+ name: options.projectName,
22
21
  version: '0.0.1',
23
22
  private: true,
24
23
  nx: {
25
- name: options.name,
26
- projectType: 'application',
27
- sourceRoot: `${options.appProjectRoot}/src`,
28
24
  targets: hasPlugin ? {} : getTargets(options),
29
25
  tags: options.parsedTags?.length ? options.parsedTags : undefined,
30
26
  },
@@ -4,6 +4,7 @@ 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
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
7
8
  async function normalizeOptions(host, options) {
8
9
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'application');
9
10
  const { projectName: appProjectName, names: projectNames, projectRoot: appProjectRoot, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -25,6 +26,7 @@ async function normalizeOptions(host, options) {
25
26
  ? options.tags.split(',').map((s) => s.trim())
26
27
  : [];
27
28
  const entryFile = options.js ? 'src/main.js' : 'src/main.tsx';
29
+ const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
28
30
  return {
29
31
  ...options,
30
32
  name: projectNames.projectSimpleName,
@@ -32,7 +34,9 @@ async function normalizeOptions(host, options) {
32
34
  fileName,
33
35
  lowerCaseName: className.toLowerCase(),
34
36
  displayName: options.displayName || className,
35
- projectName: appProjectName,
37
+ projectName: isTsSolutionSetup
38
+ ? (0, get_import_path_1.getImportPath)(host, appProjectName)
39
+ : appProjectName,
36
40
  appProjectRoot,
37
41
  iosProjectRoot,
38
42
  androidProjectRoot,
@@ -41,6 +45,6 @@ async function normalizeOptions(host, options) {
41
45
  rootProject,
42
46
  e2eProjectName,
43
47
  e2eProjectRoot,
44
- isTsSolutionSetup: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
48
+ isTsSolutionSetup,
45
49
  };
46
50
  }
@@ -6,6 +6,7 @@ const normalize_options_1 = require("./lib/normalize-options");
6
6
  const add_import_1 = require("./lib/add-import");
7
7
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
8
8
  const path_1 = require("path");
9
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
9
10
  async function reactNativeComponentGenerator(host, schema) {
10
11
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
11
12
  createComponentFiles(host, options);
@@ -27,7 +28,8 @@ function addExportsToBarrel(host, options) {
27
28
  tsModule = (0, ensure_typescript_1.ensureTypescript)();
28
29
  }
29
30
  const workspace = (0, devkit_1.getProjects)(host);
30
- const isApp = workspace.get(options.projectName).projectType === 'application';
31
+ const proj = workspace.get(options.projectName);
32
+ const isApp = (0, ts_solution_setup_1.getProjectType)(host, proj.root, proj.projectType) === 'application';
31
33
  if (options.export && !isApp) {
32
34
  const indexFilePath = (0, devkit_1.joinPathFragments)(options.projectSourceRoot, options.fileExtensionType === 'js' ? 'index.js' : 'index.ts');
33
35
  if (!host.exists(indexFilePath)) {
@@ -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 artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-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
  const { artifactName: name, directory, fileName, filePath, fileExtension, fileExtensionType, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
8
9
  path: options.path,
@@ -13,8 +14,9 @@ async function normalizeOptions(host, options) {
13
14
  });
14
15
  const project = (0, devkit_1.getProjects)(host).get(projectName);
15
16
  const { className } = (0, devkit_1.names)(name);
16
- const { sourceRoot: projectSourceRoot, projectType } = project;
17
- if (options.export && projectType === 'application') {
17
+ const { root, sourceRoot: projectSourceRoot, projectType } = project;
18
+ if (options.export &&
19
+ (0, ts_solution_setup_1.getProjectType)(host, root, projectType) === 'application') {
18
20
  devkit_1.logger.warn(`The "--export" option should not be used with applications and will do nothing.`);
19
21
  }
20
22
  options.classComponent = options.classComponent ?? false;
@@ -4,6 +4,7 @@ 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
6
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
+ const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
7
8
  async function normalizeOptions(host, options) {
8
9
  await (0, project_name_and_root_utils_1.ensureProjectName)(host, options, 'library');
9
10
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -19,15 +20,18 @@ async function normalizeOptions(host, options) {
19
20
  const parsedTags = options.tags
20
21
  ? options.tags.split(',').map((s) => s.trim())
21
22
  : [];
23
+ const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
22
24
  const normalized = {
23
25
  ...options,
24
26
  fileName: projectName,
25
27
  routePath: `/${projectNames.projectSimpleName}`,
26
- name: projectName,
28
+ name: isUsingTsSolutionConfig
29
+ ? (0, get_import_path_1.getImportPath)(host, projectName)
30
+ : projectName,
27
31
  projectRoot,
28
32
  parsedTags,
29
33
  importPath,
30
- isUsingTsSolutionConfig: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host),
34
+ isUsingTsSolutionConfig,
31
35
  };
32
36
  return normalized;
33
37
  }
@@ -12,7 +12,6 @@ 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");
16
15
  const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
17
16
  async function reactNativeLibraryGenerator(host, schema) {
18
17
  return await reactNativeLibraryGeneratorInternal(host, {
@@ -49,7 +48,7 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
49
48
  ],
50
49
  });
51
50
  tasks.push(lintTask);
52
- const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin);
51
+ const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson, options.addPlugin, 'tsconfig.lib.json');
53
52
  tasks.push(jestTask);
54
53
  if (options.publishable || options.buildable) {
55
54
  updateLibPackageNpmScope(host, options);
@@ -92,14 +91,11 @@ async function addProject(host, options) {
92
91
  };
93
92
  const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
94
93
  if (options.isUsingTsSolutionConfig) {
95
- (0, devkit_1.writeJson)(host, packageJsonPath, {
96
- name: (0, get_import_path_1.getImportPath)(host, options.name),
94
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), {
95
+ name: options.name,
97
96
  version: '0.0.1',
98
97
  ...determineEntryFields(options),
99
98
  nx: {
100
- name: options.name,
101
- sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
102
- projectType: 'library',
103
99
  tags: options.parsedTags?.length ? options.parsedTags : undefined,
104
100
  },
105
101
  });
@@ -1,2 +1,2 @@
1
1
  import { Tree } from '@nx/devkit';
2
- export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean, addPlugin: boolean): Promise<import("@nx/devkit").GeneratorCallback>;
2
+ export declare function addJest(host: Tree, unitTestRunner: 'jest' | 'none', projectName: string, appProjectRoot: string, js: boolean, skipPackageJson: boolean, addPlugin: boolean, runtimeTsconfigFileName: string): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addJest = addJest;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const jest_1 = require("@nx/jest");
6
- async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin) {
6
+ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, skipPackageJson, addPlugin, runtimeTsconfigFileName) {
7
7
  if (unitTestRunner !== 'jest') {
8
8
  return () => { };
9
9
  }
@@ -17,6 +17,7 @@ async function addJest(host, unitTestRunner, projectName, appProjectRoot, js, sk
17
17
  skipPackageJson,
18
18
  skipFormat: true,
19
19
  addPlugin,
20
+ runtimeTsconfigFileName,
20
21
  });
21
22
  // overwrite the jest.config.ts file because react native needs to have special transform property
22
23
  const configPath = `${appProjectRoot}/jest.config.${js ? 'js' : 'ts'}`;