@nx/react-native 0.0.0-pr-27957-a99d5ea → 0.0.0-pr-28218-5048fd1

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/.eslintrc.json CHANGED
@@ -43,6 +43,18 @@
43
43
  }
44
44
  ]
45
45
  }
46
+ },
47
+ {
48
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
49
+ "rules": {
50
+ "no-restricted-imports": [
51
+ "error",
52
+ {
53
+ "name": "fs-extra",
54
+ "message": "Please use equivalent utilities from `node:fs` instead."
55
+ }
56
+ ]
57
+ }
46
58
  }
47
59
  ]
48
60
  }
package/generators.json CHANGED
@@ -24,7 +24,7 @@
24
24
  "description": "Create a React Native library."
25
25
  },
26
26
  "component": {
27
- "factory": "./src/generators/component/component#reactNativeComponentGeneratorInternal",
27
+ "factory": "./src/generators/component/component",
28
28
  "schema": "./src/generators/component/schema.json",
29
29
  "description": "Create a React Native component.",
30
30
  "aliases": ["c"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/react-native",
3
- "version": "0.0.0-pr-27957-a99d5ea",
3
+ "version": "0.0.0-pr-28218-5048fd1",
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": [
@@ -29,7 +29,6 @@
29
29
  "ajv": "^8.12.0",
30
30
  "chalk": "^4.1.0",
31
31
  "enhanced-resolve": "^5.8.3",
32
- "fs-extra": "^11.1.0",
33
32
  "glob": "7.1.4",
34
33
  "ignore": "^5.0.4",
35
34
  "metro-config": "~0.80.4",
@@ -37,13 +36,12 @@
37
36
  "node-fetch": "^2.6.7",
38
37
  "tsconfig-paths": "^4.1.2",
39
38
  "tslib": "^2.3.0",
40
- "@nx/devkit": "0.0.0-pr-27957-a99d5ea",
41
- "@nx/jest": "0.0.0-pr-27957-a99d5ea",
42
- "@nx/js": "0.0.0-pr-27957-a99d5ea",
43
- "@nx/eslint": "0.0.0-pr-27957-a99d5ea",
44
- "@nx/react": "0.0.0-pr-27957-a99d5ea",
45
- "@nx/workspace": "0.0.0-pr-27957-a99d5ea",
46
- "@nrwl/react-native": "0.0.0-pr-27957-a99d5ea"
39
+ "@nx/devkit": "0.0.0-pr-28218-5048fd1",
40
+ "@nx/jest": "0.0.0-pr-28218-5048fd1",
41
+ "@nx/js": "0.0.0-pr-28218-5048fd1",
42
+ "@nx/eslint": "0.0.0-pr-28218-5048fd1",
43
+ "@nx/react": "0.0.0-pr-28218-5048fd1",
44
+ "@nx/workspace": "0.0.0-pr-28218-5048fd1"
47
45
  },
48
46
  "executors": "./executors.json",
49
47
  "ng-update": {
@@ -55,4 +53,4 @@
55
53
  "access": "public"
56
54
  },
57
55
  "type": "commonjs"
58
- }
56
+ }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withNxMetro = withNxMetro;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const metro_config_1 = require("metro-config");
6
- const fs_extra_1 = require("fs-extra");
6
+ const node_fs_1 = require("node:fs");
7
7
  const path_1 = require("path");
8
8
  const metro_resolver_1 = require("./metro-resolver");
9
9
  async function withNxMetro(userConfig, opts = {}) {
@@ -12,14 +12,14 @@ async function withNxMetro(userConfig, opts = {}) {
12
12
  process.env.NX_REACT_NATIVE_DEBUG = 'true';
13
13
  if (opts.extensions)
14
14
  extensions.push(...opts.extensions);
15
- let watchFolders = (0, fs_extra_1.readdirSync)(devkit_1.workspaceRoot)
15
+ let watchFolders = (0, node_fs_1.readdirSync)(devkit_1.workspaceRoot)
16
16
  .filter((fileName) => !['dist', 'e2e'].includes(fileName) && !fileName.startsWith('.'))
17
17
  .map((fileName) => (0, path_1.join)(devkit_1.workspaceRoot, fileName))
18
- .filter((filePath) => (0, fs_extra_1.statSync)(filePath).isDirectory());
18
+ .filter((filePath) => (0, node_fs_1.statSync)(filePath).isDirectory());
19
19
  if (opts.watchFolders?.length) {
20
20
  watchFolders = watchFolders.concat(opts.watchFolders);
21
21
  }
22
- watchFolders = [...new Set(watchFolders)].filter((folder) => (0, fs_extra_1.existsSync)(folder));
22
+ watchFolders = [...new Set(watchFolders)].filter((folder) => (0, node_fs_1.existsSync)(folder));
23
23
  const nxConfig = {
24
24
  resolver: {
25
25
  resolveRequest: (0, metro_resolver_1.getResolveRequest)(extensions, opts.exportsConditionNames, opts.mainFields),
package/project.json CHANGED
@@ -44,9 +44,6 @@
44
44
  "options": {
45
45
  "command": "node ./scripts/copy-readme.js react-native"
46
46
  }
47
- },
48
- "add-extra-dependencies": {
49
- "command": "node ./scripts/add-dependency-to-build.js react-native @nrwl/react-native"
50
47
  }
51
48
  }
52
49
  }
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = reactNativeStorybookExecutor;
4
4
  exports.runCliStorybook = runCliStorybook;
5
+ const node_fs_1 = require("node:fs");
5
6
  const path_1 = require("path");
6
7
  const devkit_1 = require("@nx/devkit");
7
8
  const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
8
9
  const chalk = require("chalk");
9
10
  const glob_1 = require("glob");
10
11
  const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
11
- const fs_extra_1 = require("fs-extra");
12
12
  /**
13
13
  * TODO (@xiongemi): remove this function in v20.
14
14
  * @deprecated Going to use the default react storybook target. Use @nx/react:storybook executor instead.
@@ -53,5 +53,5 @@ export function loadStories() {
53
53
  ${storiesFiles.map((story) => `require('${story}')`).join(',\n')}
54
54
  ];
55
55
  }`;
56
- (0, fs_extra_1.writeFileSync)((0, path_1.join)(workspaceRoot, options.outputFile), newContents);
56
+ (0, node_fs_1.writeFileSync)((0, path_1.join)(workspaceRoot, options.outputFile), newContents);
57
57
  }
@@ -20,7 +20,6 @@ const sync_deps_impl_1 = require("../../executors/sync-deps/sync-deps.impl");
20
20
  async function reactNativeApplicationGenerator(host, schema) {
21
21
  return await reactNativeApplicationGeneratorInternal(host, {
22
22
  addPlugin: false,
23
- projectNameAndRootFormat: 'derived',
24
23
  ...schema,
25
24
  });
26
25
  }
@@ -9,7 +9,6 @@ async function normalizeOptions(host, options) {
9
9
  projectType: 'application',
10
10
  directory: options.directory,
11
11
  projectNameAndRootFormat: options.projectNameAndRootFormat,
12
- callingGenerator: '@nx/react-native:application',
13
12
  });
14
13
  options.projectNameAndRootFormat = projectNameAndRootFormat;
15
14
  const nxJson = (0, devkit_1.readNxJson)(host);
@@ -10,7 +10,6 @@ export interface Schema {
10
10
  projectNameAndRootFormat?: ProjectNameAndRootFormat;
11
11
  tags?: string;
12
12
  unitTestRunner: 'jest' | 'none'; // default is jest
13
- pascalCaseFiles?: boolean;
14
13
  classComponent?: boolean;
15
14
  js?: boolean;
16
15
  linter: Linter | LinterType;
@@ -1,5 +1,4 @@
1
1
  import { Schema } from './schema';
2
2
  import { Tree } from '@nx/devkit';
3
3
  export declare function reactNativeComponentGenerator(host: Tree, schema: Schema): Promise<void>;
4
- export declare function reactNativeComponentGeneratorInternal(host: Tree, schema: Schema): Promise<void>;
5
4
  export default reactNativeComponentGenerator;
@@ -1,19 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.reactNativeComponentGenerator = reactNativeComponentGenerator;
4
- exports.reactNativeComponentGeneratorInternal = reactNativeComponentGeneratorInternal;
5
4
  const devkit_1 = require("@nx/devkit");
6
5
  const normalize_options_1 = require("./lib/normalize-options");
7
6
  const add_import_1 = require("./lib/add-import");
8
7
  const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
9
8
  const path_1 = require("path");
10
9
  async function reactNativeComponentGenerator(host, schema) {
11
- return reactNativeComponentGeneratorInternal(host, {
12
- nameAndDirectoryFormat: 'derived',
13
- ...schema,
14
- });
15
- }
16
- async function reactNativeComponentGeneratorInternal(host, schema) {
17
10
  const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
18
11
  createComponentFiles(host, options);
19
12
  addExportsToBarrel(host, options);
@@ -6,16 +6,10 @@ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/a
6
6
  async function normalizeOptions(host, options) {
7
7
  assertValidOptions(options);
8
8
  const { artifactName: name, directory, fileName, filePath, project: projectName, } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(host, {
9
- artifactType: 'component',
10
- callingGenerator: '@nx/react-native:component',
11
9
  name: options.name,
12
10
  directory: options.directory,
13
- derivedDirectory: options.directory,
14
- flat: options.flat,
15
11
  nameAndDirectoryFormat: options.nameAndDirectoryFormat,
16
- project: options.project,
17
12
  fileExtension: 'tsx',
18
- pascalCaseFile: options.pascalCaseFiles,
19
13
  });
20
14
  const project = (0, devkit_1.getProjects)(host).get(projectName);
21
15
  const { className } = (0, devkit_1.names)(name);
@@ -1,24 +1,14 @@
1
+ import type { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
+
1
3
  /**
2
4
  * Same as the @nx/react library schema, except it removes keys: style, routing, globalCss
3
5
  */
4
6
  export interface Schema {
5
7
  name: string;
6
- /**
7
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20.
8
- */
9
- project: string;
10
8
  skipTests?: boolean;
11
9
  directory?: string;
12
10
  export?: boolean;
13
- /**
14
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19.
15
- */
16
- pascalCaseFiles?: boolean;
17
11
  classComponent?: boolean;
18
12
  js?: boolean;
19
- /**
20
- * @deprecated Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19.
21
- */
22
- flat?: boolean;
23
- nameAndDirectoryFormat?: 'as-provided' | 'derived';
13
+ nameAndDirectoryFormat?: NameAndDirectoryFormat;
24
14
  }
@@ -7,24 +7,15 @@
7
7
  "type": "object",
8
8
  "examples": [
9
9
  {
10
- "command": "nx g @nx/react-native:component my-component --project=mylib",
10
+ "command": "nx g @nx/react-native:component my-component --directory=mylib/src/lib/my-component",
11
11
  "description": "Generate a component in the `mylib` library"
12
12
  },
13
13
  {
14
- "command": "nx g @nx/react-native:component my-component --project=mylib --classComponent",
14
+ "command": "nx g @nx/react-native:component my-component --directory=mylib/src/lib/my-component --classComponent",
15
15
  "description": "Generate a class component in the `mylib` library"
16
16
  }
17
17
  ],
18
18
  "properties": {
19
- "project": {
20
- "type": "string",
21
- "description": "The name of the project.",
22
- "alias": "p",
23
- "$default": {
24
- "$source": "projectName"
25
- },
26
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
27
- },
28
19
  "name": {
29
20
  "type": "string",
30
21
  "description": "The name of the component.",
@@ -54,12 +45,6 @@
54
45
  "type": "string",
55
46
  "enum": ["as-provided", "derived"]
56
47
  },
57
- "flat": {
58
- "type": "boolean",
59
- "description": "Create component at the source root rather than its own directory.",
60
- "default": false,
61
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. This option will be removed in Nx v19."
62
- },
63
48
  "export": {
64
49
  "type": "boolean",
65
50
  "description": "When true, the component is exported from the project `index.ts` (if it exists).",
@@ -67,13 +52,6 @@
67
52
  "default": false,
68
53
  "x-prompt": "Should this component be exported in the project?"
69
54
  },
70
- "pascalCaseFiles": {
71
- "type": "boolean",
72
- "description": "Use pascal case component file name (e.g. `App.tsx`).",
73
- "alias": "P",
74
- "default": false,
75
- "x-deprecated": "Provide the `name` in pascal-case and use the `as-provided` format. This option will be removed in Nx v19."
76
- },
77
55
  "classComponent": {
78
56
  "type": "boolean",
79
57
  "alias": "C",
@@ -10,7 +10,6 @@ async function normalizeOptions(host, options) {
10
10
  directory: options.directory,
11
11
  importPath: options.importPath,
12
12
  projectNameAndRootFormat: options.projectNameAndRootFormat,
13
- callingGenerator: '@nx/react-native:library',
14
13
  });
15
14
  const nxJson = (0, devkit_1.readNxJson)(host);
16
15
  const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -14,7 +14,6 @@ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-projec
14
14
  async function reactNativeLibraryGenerator(host, schema) {
15
15
  return await reactNativeLibraryGeneratorInternal(host, {
16
16
  addPlugin: false,
17
- projectNameAndRootFormat: 'derived',
18
17
  ...schema,
19
18
  });
20
19
  }
@@ -11,7 +11,6 @@ export interface Schema {
11
11
  skipTsConfig: boolean;
12
12
  skipFormat: boolean;
13
13
  tags?: string;
14
- pascalCaseFiles?: boolean;
15
14
  unitTestRunner: 'jest' | 'none';
16
15
  linter: Linter | LinterType;
17
16
  publishable?: boolean;
@@ -62,12 +62,6 @@
62
62
  "description": "Do not update `tsconfig.json` for development experience.",
63
63
  "x-priority": "internal"
64
64
  },
65
- "pascalCaseFiles": {
66
- "type": "boolean",
67
- "description": "Use pascal case component file name (e.g. `App.tsx`).",
68
- "alias": "P",
69
- "default": false
70
- },
71
65
  "publishable": {
72
66
  "type": "boolean",
73
67
  "description": "Create a publishable library."
@@ -34,14 +34,12 @@ export default defineConfig({
34
34
  define: {
35
35
  global: 'window',
36
36
  },
37
-
38
37
  resolve: {
39
38
  extensions,
40
39
  alias: {
41
40
  'react-native': 'react-native-web',
42
41
  },
43
42
  },
44
-
45
43
  build: {
46
44
  reportCompressedSize: true,
47
45
  commonjsOptions: { transformMixedEsModules: true },
@@ -50,7 +48,6 @@ export default defineConfig({
50
48
  plugins: [rollupPlugin([/react-native-vector-icons/])],
51
49
  },
52
50
  },
53
-
54
51
  server: {
55
52
  port: 4200,
56
53
  host: 'localhost',
@@ -59,12 +56,10 @@ export default defineConfig({
59
56
  allow: ['..'],
60
57
  },
61
58
  },
62
-
63
59
  preview: {
64
60
  port: 4300,
65
61
  host: 'localhost',
66
62
  },
67
-
68
63
  optimizeDeps: {
69
64
  esbuildOptions: {
70
65
  resolveExtensions: extensions,
@@ -72,9 +67,7 @@ export default defineConfig({
72
67
  loader: { '.js': 'jsx' },
73
68
  },
74
69
  },
75
-
76
70
  plugins: [react(), nxViteTsPaths()],
77
-
78
71
  // Uncomment this if you are using workers.
79
72
  // worker: {
80
73
  // plugins: [ nxViteTsPaths() ],
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = update;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const fs_extra_1 = require("fs-extra");
5
+ const node_fs_1 = require("node:fs");
6
6
  /**
7
7
  * Remove ensure-symlink target.
8
8
  * It is going to be supported by react-native version 0.73 by default.
@@ -14,7 +14,7 @@ async function update(tree) {
14
14
  '@nx/react-native:ensure-symlink') {
15
15
  removeTargets(config.targets, 'ensure-symlink');
16
16
  (0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
17
- (0, fs_extra_1.removeSync)(`${config.root}/node_modules`);
17
+ (0, node_fs_1.rmSync)(`${config.root}/node_modules`, { recursive: true, force: true });
18
18
  }
19
19
  }
20
20
  }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ensureNodeModulesSymlink = ensureNodeModulesSymlink;
4
- const path_1 = require("path");
4
+ const node_fs_1 = require("node:fs");
5
5
  const os_1 = require("os");
6
- const fs_extra_1 = require("fs-extra");
6
+ const path_1 = require("path");
7
7
  /**
8
8
  * This function symlink workspace node_modules folder with app project's node_mdules folder.
9
9
  * For yarn and npm, it will symlink the entire node_modules folder.
@@ -14,14 +14,14 @@ const fs_extra_1 = require("fs-extra");
14
14
  */
15
15
  function ensureNodeModulesSymlink(workspaceRoot, projectRoot) {
16
16
  const worksapceNodeModulesPath = (0, path_1.join)(workspaceRoot, 'node_modules');
17
- if (!(0, fs_extra_1.existsSync)(worksapceNodeModulesPath)) {
17
+ if (!(0, node_fs_1.existsSync)(worksapceNodeModulesPath)) {
18
18
  throw new Error(`Cannot find ${worksapceNodeModulesPath}`);
19
19
  }
20
20
  const appNodeModulesPath = (0, path_1.join)(workspaceRoot, projectRoot, 'node_modules');
21
21
  // `mklink /D` requires admin privilege in Windows so we need to use junction
22
22
  const symlinkType = (0, os_1.platform)() === 'win32' ? 'junction' : 'dir';
23
- if ((0, fs_extra_1.existsSync)(appNodeModulesPath)) {
24
- (0, fs_extra_1.removeSync)(appNodeModulesPath);
23
+ if ((0, node_fs_1.existsSync)(appNodeModulesPath)) {
24
+ (0, node_fs_1.rmSync)(appNodeModulesPath, { recursive: true, force: true });
25
25
  }
26
- (0, fs_extra_1.symlinkSync)(worksapceNodeModulesPath, appNodeModulesPath, symlinkType);
26
+ (0, node_fs_1.symlinkSync)(worksapceNodeModulesPath, appNodeModulesPath, symlinkType);
27
27
  }
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runPodInstall = runPodInstall;
4
4
  exports.podInstall = podInstall;
5
5
  const child_process_1 = require("child_process");
6
+ const node_fs_1 = require("node:fs");
6
7
  const os_1 = require("os");
8
+ const path_1 = require("path");
7
9
  const chalk = require("chalk");
8
10
  const devkit_1 = require("@nx/devkit");
9
- const fs_extra_1 = require("fs-extra");
10
- const path_1 = require("path");
11
11
  const podInstallErrorMessage = `
12
12
  Running ${chalk.bold('pod install')} failed, see above.
13
13
  Do you have CocoaPods (https://cocoapods.org/) installed?
@@ -34,7 +34,7 @@ function runPodInstall(iosDirectory, install = true, options = {
34
34
  devkit_1.logger.info('Skipping `pod install` on non-darwin platform');
35
35
  return;
36
36
  }
37
- if (!install || !(0, fs_extra_1.existsSync)((0, path_1.join)(iosDirectory, 'Podfile'))) {
37
+ if (!install || !(0, node_fs_1.existsSync)((0, path_1.join)(iosDirectory, 'Podfile'))) {
38
38
  devkit_1.logger.info('Skipping `pod install`');
39
39
  return;
40
40
  }
@@ -49,10 +49,11 @@ function podInstall(iosDirectory, options = {
49
49
  useBundler: false,
50
50
  }) {
51
51
  try {
52
- if ((0, fs_extra_1.existsSync)((0, path_1.join)(iosDirectory, '.xcode.env'))) {
52
+ if ((0, node_fs_1.existsSync)((0, path_1.join)(iosDirectory, '.xcode.env'))) {
53
53
  (0, child_process_1.execSync)('touch .xcode.env', {
54
54
  cwd: iosDirectory,
55
55
  stdio: 'inherit',
56
+ windowsHide: true,
56
57
  });
57
58
  }
58
59
  const podCommand = [
@@ -63,6 +64,7 @@ function podInstall(iosDirectory, options = {
63
64
  (0, child_process_1.execSync)(podCommand, {
64
65
  cwd: iosDirectory,
65
66
  stdio: 'inherit',
67
+ windowsHide: true,
66
68
  });
67
69
  }
68
70
  catch (e) {