@nx/react-native 20.0.8 → 20.1.0-beta.0

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.0.8",
3
+ "version": "20.1.0-beta.0",
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.0.8",
40
- "@nx/jest": "20.0.8",
41
- "@nx/js": "20.0.8",
42
- "@nx/eslint": "20.0.8",
43
- "@nx/react": "20.0.8",
44
- "@nx/workspace": "20.0.8"
39
+ "@nx/devkit": "20.1.0-beta.0",
40
+ "@nx/jest": "20.1.0-beta.0",
41
+ "@nx/js": "20.1.0-beta.0",
42
+ "@nx/eslint": "20.1.0-beta.0",
43
+ "@nx/react": "20.1.0-beta.0",
44
+ "@nx/workspace": "20.1.0-beta.0"
45
45
  },
46
46
  "executors": "./executors.json",
47
47
  "ng-update": {
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, createDependencies, ReactNativePluginOptions, } from './plugins/plugin';
1
+ export { createNodes, createNodesV2, ReactNativePluginOptions, } from './plugins/plugin';
package/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDependencies = exports.createNodes = void 0;
3
+ exports.createNodesV2 = exports.createNodes = void 0;
4
4
  var plugin_1 = require("./plugins/plugin");
5
5
  Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
- Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
6
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return plugin_1.createNodesV2; } });
@@ -1,4 +1,4 @@
1
- import { CreateDependencies, CreateNodes } from '@nx/devkit';
1
+ import { CreateNodes, CreateNodesV2 } from '@nx/devkit';
2
2
  export interface ReactNativePluginOptions {
3
3
  startTargetName?: string;
4
4
  podInstallTargetName?: string;
@@ -10,5 +10,5 @@ export interface ReactNativePluginOptions {
10
10
  syncDepsTargetName?: string;
11
11
  upgradeTargetName?: string;
12
12
  }
13
- export declare const createDependencies: CreateDependencies;
13
+ export declare const createNodesV2: CreateNodesV2<ReactNativePluginOptions>;
14
14
  export declare const createNodes: CreateNodes<ReactNativePluginOptions>;
package/plugins/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = exports.createDependencies = void 0;
3
+ exports.createNodes = exports.createNodesV2 = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const path_1 = require("path");
6
6
  const js_1 = require("@nx/js");
@@ -9,49 +9,69 @@ const fs_1 = require("fs");
9
9
  const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
10
  const cache_directory_1 = require("nx/src/utils/cache-directory");
11
11
  const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
12
- const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'react-native.hash');
13
- const targetsCache = readTargetsCache();
14
- function readTargetsCache() {
12
+ const devkit_internals_1 = require("nx/src/devkit-internals");
13
+ function readTargetsCache(cachePath) {
15
14
  return (0, fs_1.existsSync)(cachePath) ? (0, devkit_1.readJsonFile)(cachePath) : {};
16
15
  }
17
- function writeTargetsToCache() {
18
- const oldCache = readTargetsCache();
16
+ function writeTargetsToCache(cachePath, targetsCache) {
17
+ const oldCache = readTargetsCache(cachePath);
19
18
  (0, devkit_1.writeJsonFile)(cachePath, {
20
19
  ...oldCache,
21
- ...targetsCache,
20
+ targetsCache,
22
21
  });
23
22
  }
24
- const createDependencies = () => {
25
- writeTargetsToCache();
26
- return [];
27
- };
28
- exports.createDependencies = createDependencies;
29
- exports.createNodes = [
30
- '**/app.{json,config.js}',
31
- async (configFilePath, options, context) => {
32
- options = normalizeOptions(options);
33
- const projectRoot = (0, path_1.dirname)(configFilePath);
34
- // Do not create a project if package.json or project.json or metro.config.js isn't there.
35
- const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
36
- if (!siblingFiles.includes('package.json') ||
37
- !siblingFiles.includes('metro.config.js')) {
38
- return {};
23
+ exports.createNodesV2 = [
24
+ '**/app.{json,config.js,config.ts}',
25
+ async (configFiles, options, context) => {
26
+ const optionsHash = (0, devkit_internals_1.hashObject)(options);
27
+ const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `expo-${optionsHash}.hash`);
28
+ const targetsCache = readTargetsCache(cachePath);
29
+ try {
30
+ return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => createNodesInternal(configFile, options, context, targetsCache), configFiles, options, context);
39
31
  }
40
- const appConfig = await getAppConfig(configFilePath, context);
41
- if (appConfig.expo) {
42
- return {};
32
+ finally {
33
+ writeTargetsToCache(cachePath, targetsCache);
43
34
  }
44
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
45
- targetsCache[hash] ??= buildReactNativeTargets(projectRoot, options, context);
46
- return {
47
- projects: {
48
- [projectRoot]: {
49
- targets: targetsCache[hash],
50
- },
51
- },
52
- };
53
35
  },
54
36
  ];
37
+ exports.createNodes = [
38
+ '**/app.{json,config.js,config.ts}',
39
+ async (configFilePath, options, context) => {
40
+ const optionsHash = (0, devkit_internals_1.hashObject)(options);
41
+ const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, `react-native-${optionsHash}.hash`);
42
+ const targetsCache = readTargetsCache(cachePath);
43
+ const result = await createNodesInternal(configFilePath, options, context, targetsCache);
44
+ writeTargetsToCache(cachePath, targetsCache);
45
+ return result;
46
+ },
47
+ ];
48
+ async function createNodesInternal(configFile, options, context, targetsCache) {
49
+ options = normalizeOptions(options);
50
+ const projectRoot = (0, path_1.dirname)(configFile);
51
+ // Do not create a project if package.json or project.json or metro.config.js isn't there.
52
+ const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
53
+ if (!siblingFiles.includes('package.json') ||
54
+ !siblingFiles.includes('metro.config.js')) {
55
+ return {};
56
+ }
57
+ // Check if it's an Expo project
58
+ const packageJson = (0, devkit_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, projectRoot, 'package.json'));
59
+ const appConfig = await getAppConfig(configFile, context);
60
+ if (appConfig.expo ||
61
+ packageJson.dependencies?.['expo'] ||
62
+ packageJson.devDependencies?.['expo']) {
63
+ return {};
64
+ }
65
+ const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot))]);
66
+ targetsCache[hash] ??= buildReactNativeTargets(projectRoot, options, context);
67
+ return {
68
+ projects: {
69
+ [projectRoot]: {
70
+ targets: targetsCache[hash],
71
+ },
72
+ },
73
+ };
74
+ }
55
75
  function buildReactNativeTargets(projectRoot, options, context) {
56
76
  const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
57
77
  const targets = {
@@ -11,7 +11,7 @@ const create_process_options_1 = require("./lib/create-process-options");
11
11
  async function convertToInferred(tree, options) {
12
12
  const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
13
13
  const migrationLogs = new aggregate_log_util_1.AggregatedLog();
14
- const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPluginV1)(tree, projectGraph, '@nx/react-native/plugin', plugin_1.createNodes, {
14
+ const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/react-native/plugin', plugin_1.createNodesV2, {
15
15
  buildAndroidTargetName: 'build-android',
16
16
  buildIosTargetName: 'build-ios',
17
17
  bundleTargetName: 'bundle',
@@ -35,11 +35,11 @@ async function reactNativeLibraryGeneratorInternal(host, schema) {
35
35
  if (!options.skipPackageJson) {
36
36
  tasks.push((0, ensure_dependencies_1.ensureDependencies)(host));
37
37
  }
38
+ createFiles(host, options);
38
39
  const addProjectTask = await addProject(host, options);
39
40
  if (addProjectTask) {
40
41
  tasks.push(addProjectTask);
41
42
  }
42
- createFiles(host, options);
43
43
  const lintTask = await (0, add_linting_1.addLinting)(host, {
44
44
  ...options,
45
45
  projectName: options.name,