@nx/expo 18.1.0-beta.0 → 18.1.0-beta.10

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/expo",
3
- "version": "18.1.0-beta.0",
3
+ "version": "18.1.0-beta.10",
4
4
  "private": false,
5
5
  "description": "The Expo Plugin for Nx contains executors and generators for managing and developing an expo application within your workspace. For example, you can directly build for different target platforms as well as generate projects and publish your code.",
6
6
  "keywords": [
@@ -26,7 +26,7 @@
26
26
  "main": "./index.js",
27
27
  "types": "index.d.ts",
28
28
  "dependencies": {
29
- "@nx/devkit": "18.1.0-beta.0",
29
+ "@nx/devkit": "18.1.0-beta.10",
30
30
  "chalk": "^4.1.0",
31
31
  "enhanced-resolve": "^5.8.3",
32
32
  "fs-extra": "^11.1.0",
@@ -36,13 +36,13 @@
36
36
  "tslib": "^2.3.0",
37
37
  "tsconfig-paths": "^4.1.2",
38
38
  "tsconfig-paths-webpack-plugin": "^4.0.0",
39
- "@nx/jest": "18.1.0-beta.0",
40
- "@nx/js": "18.1.0-beta.0",
41
- "@nx/eslint": "18.1.0-beta.0",
42
- "@nx/react": "18.1.0-beta.0",
43
- "@nx/web": "18.1.0-beta.0",
44
- "@nx/webpack": "18.1.0-beta.0",
45
- "@nrwl/expo": "18.1.0-beta.0"
39
+ "@nx/jest": "18.1.0-beta.10",
40
+ "@nx/js": "18.1.0-beta.10",
41
+ "@nx/eslint": "18.1.0-beta.10",
42
+ "@nx/react": "18.1.0-beta.10",
43
+ "@nx/web": "18.1.0-beta.10",
44
+ "@nx/webpack": "18.1.0-beta.10",
45
+ "@nrwl/expo": "18.1.0-beta.10"
46
46
  },
47
47
  "executors": "./executors.json",
48
48
  "ng-update": {
package/plugin.d.ts CHANGED
@@ -1 +1 @@
1
- export { createNodes, ExpoPluginOptions } from './plugins/plugin';
1
+ export { createNodes, createDependencies, ExpoPluginOptions, } from './plugins/plugin';
package/plugin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createNodes = void 0;
3
+ exports.createDependencies = 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; } });
@@ -11,7 +11,7 @@
11
11
  "port": {
12
12
  "type": "number",
13
13
  "description": "Port to start the native Metro bundler on (does not apply to web or tunnel)",
14
- "default": 19000,
14
+ "default": 4200,
15
15
  "alias": "p"
16
16
  },
17
17
  "clear": {
@@ -59,7 +59,9 @@ function serveAsync(workspaceRoot, projectRoot, options) {
59
59
  });
60
60
  childProcess.stdout.on('data', (data) => {
61
61
  process.stdout.write(data);
62
- if (data.toString().includes('Bundling complete')) {
62
+ if (data
63
+ .toString()
64
+ .includes('Bundling complete' || data.toString().includes('Bundled'))) {
63
65
  resolve(childProcess);
64
66
  }
65
67
  });
@@ -1,4 +1,5 @@
1
1
  export interface ExpoSyncDepsOptions {
2
2
  include: string[] | string; // default is an empty array []
3
3
  exclude: string[] | string; // default is an empty array []
4
+ all: boolean; // default is false
4
5
  }
@@ -23,6 +23,11 @@
23
23
  },
24
24
  "default": [],
25
25
  "description": "An array of npm packages to exclude."
26
+ },
27
+ "all": {
28
+ "type": "boolean",
29
+ "description": "Copy all dependencies and devDependencies from the workspace root package.json.",
30
+ "default": false
26
31
  }
27
32
  }
28
33
  }
@@ -1,8 +1,9 @@
1
- import { ExecutorContext } from '@nx/devkit';
1
+ import { ExecutorContext, ProjectGraph } from '@nx/devkit';
2
2
  import { ExpoSyncDepsOptions } from './schema';
3
+ import { PackageJson } from 'nx/src/utils/package-json';
3
4
  export interface ReactNativeSyncDepsOutput {
4
5
  success: boolean;
5
6
  }
6
7
  export default function syncDepsExecutor(options: ExpoSyncDepsOptions, context: ExecutorContext): AsyncGenerator<ReactNativeSyncDepsOutput>;
7
- export declare function syncDeps(projectRoot: string, workspaceRoot: string, include?: string[], exclude?: string[]): Promise<string[]>;
8
+ export declare function syncDeps(projectName: string, projectPackageJson: PackageJson, projectPackageJsonPath: string, workspacePackageJson: PackageJson, projectGraph?: ProjectGraph, include?: string[], exclude?: string[], all?: boolean): Promise<string[]>;
8
9
  export declare function displayNewlyAddedDepsMessage(projectName: string, deps: string[]): void;
@@ -4,27 +4,32 @@ exports.displayNewlyAddedDepsMessage = exports.syncDeps = void 0;
4
4
  const path_1 = require("path");
5
5
  const chalk = require("chalk");
6
6
  const devkit_1 = require("@nx/devkit");
7
+ const find_all_npm_dependencies_1 = require("../../utils/find-all-npm-dependencies");
7
8
  async function* syncDepsExecutor(options, context) {
8
9
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
9
- displayNewlyAddedDepsMessage(context.projectName, await syncDeps(projectRoot, context.root, typeof options.include === 'string'
10
+ const workspacePackageJsonPath = (0, path_1.join)(context.root, 'package.json');
11
+ const projectPackageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
12
+ const workspacePackageJson = (0, devkit_1.readJsonFile)(workspacePackageJsonPath);
13
+ const projectPackageJson = (0, devkit_1.readJsonFile)(projectPackageJsonPath);
14
+ displayNewlyAddedDepsMessage(context.projectName, await syncDeps(context.projectName, projectPackageJson, projectPackageJsonPath, workspacePackageJson, context.projectGraph, typeof options.include === 'string'
10
15
  ? options.include.split(',')
11
16
  : options.include, typeof options.exclude === 'string'
12
17
  ? options.exclude.split(',')
13
- : options.exclude));
18
+ : options.exclude, options.all));
14
19
  yield { success: true };
15
20
  }
16
21
  exports.default = syncDepsExecutor;
17
- async function syncDeps(projectRoot, workspaceRoot, include = [], exclude = []) {
18
- const workspacePackageJsonPath = (0, path_1.join)(workspaceRoot, 'package.json');
19
- const workspacePackageJson = (0, devkit_1.readJsonFile)(workspacePackageJsonPath);
20
- let npmDeps = Object.keys(workspacePackageJson.dependencies || {});
21
- let npmDevdeps = Object.keys(workspacePackageJson.devDependencies || {});
22
- const packageJsonPath = (0, path_1.join)(workspaceRoot, projectRoot, 'package.json');
23
- const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
22
+ async function syncDeps(projectName, projectPackageJson, projectPackageJsonPath, workspacePackageJson, projectGraph = (0, devkit_1.readCachedProjectGraph)(), include = [], exclude = [], all = false) {
23
+ let npmDeps = all
24
+ ? Object.keys(workspacePackageJson.dependencies || {})
25
+ : (0, find_all_npm_dependencies_1.findAllNpmDependencies)(projectGraph, projectName);
26
+ let npmDevdeps = all
27
+ ? Object.keys(workspacePackageJson.devDependencies || {})
28
+ : [];
24
29
  const newDeps = [];
25
30
  let updated = false;
26
- if (!packageJson.dependencies) {
27
- packageJson.dependencies = {};
31
+ if (!projectPackageJson.dependencies) {
32
+ projectPackageJson.dependencies = {};
28
33
  updated = true;
29
34
  }
30
35
  if (include && include.length) {
@@ -33,28 +38,30 @@ async function syncDeps(projectRoot, workspaceRoot, include = [], exclude = [])
33
38
  if (exclude && exclude.length) {
34
39
  npmDeps = npmDeps.filter((dep) => !exclude.includes(dep));
35
40
  }
36
- if (!packageJson.devDependencies) {
37
- packageJson.devDependencies = {};
41
+ if (!projectPackageJson.devDependencies) {
42
+ projectPackageJson.devDependencies = {};
38
43
  }
39
- if (!packageJson.dependencies) {
40
- packageJson.dependencies = {};
44
+ if (!projectPackageJson.dependencies) {
45
+ projectPackageJson.dependencies = {};
41
46
  }
42
47
  npmDeps.forEach((dep) => {
43
- if (!packageJson.dependencies[dep] && !packageJson.devDependencies[dep]) {
44
- packageJson.dependencies[dep] = '*';
48
+ if (!projectPackageJson.dependencies[dep] &&
49
+ !projectPackageJson.devDependencies[dep]) {
50
+ projectPackageJson.dependencies[dep] = '*';
45
51
  newDeps.push(dep);
46
52
  updated = true;
47
53
  }
48
54
  });
49
55
  npmDevdeps.forEach((dep) => {
50
- if (!packageJson.dependencies[dep] && !packageJson.devDependencies[dep]) {
51
- packageJson.devDependencies[dep] = '*';
56
+ if (!projectPackageJson.dependencies[dep] &&
57
+ !projectPackageJson.devDependencies[dep]) {
58
+ projectPackageJson.devDependencies[dep] = '*';
52
59
  newDeps.push(dep);
53
60
  updated = true;
54
61
  }
55
62
  });
56
63
  if (updated) {
57
- (0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
64
+ (0, devkit_1.writeJsonFile)(projectPackageJsonPath, projectPackageJson);
58
65
  }
59
66
  return newDeps;
60
67
  }
@@ -9,8 +9,12 @@ const install_impl_1 = require("../install/install.impl");
9
9
  let childProcess;
10
10
  async function* buildExecutor(options, context) {
11
11
  const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
12
+ const workspacePackageJsonPath = (0, path_1.join)(context.root, 'package.json');
13
+ const projectPackageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
14
+ const workspacePackageJson = (0, devkit_1.readJsonFile)(workspacePackageJsonPath);
15
+ const projectPackageJson = (0, devkit_1.readJsonFile)(projectPackageJsonPath);
12
16
  await (0, install_impl_1.installAsync)(context.root, { packages: ['expo-updates'] });
13
- (0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(projectRoot, context.root, ['expo-updates']));
17
+ (0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, await (0, sync_deps_impl_1.syncDeps)(context.projectName, projectPackageJson, projectPackageJsonPath, workspacePackageJson, context.projectGraph, ['expo-updates']));
14
18
  try {
15
19
  await runCliUpdate(context.root, projectRoot, options);
16
20
  yield { success: true };
@@ -387,7 +387,7 @@ export const App = () => {
387
387
  </View>
388
388
  </View>
389
389
  <View style={styles.codeBlock}>
390
- <Text style={[styles.monospace]}>nx connect-to-nx-cloud</Text>
390
+ <Text style={[styles.monospace]}>nx connect</Text>
391
391
  </View>
392
392
  </View>
393
393
  </TouchableOpacity>
@@ -10,8 +10,8 @@ async function addE2e(tree, options) {
10
10
  const port = hasPlugin ? 8081 : 4200;
11
11
  switch (options.e2eTestRunner) {
12
12
  case 'cypress': {
13
- const hasNxExportPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(tree);
14
- if (!hasNxExportPlugin) {
13
+ const hasNxExpoPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(tree);
14
+ if (!hasNxExpoPlugin) {
15
15
  (0, web_1.webStaticServeGenerator)(tree, {
16
16
  buildTarget: `${options.projectName}:export`,
17
17
  targetName: 'serve-static',
@@ -36,7 +36,7 @@ async function addE2e(tree, options) {
36
36
  devServerTarget: `${options.projectName}:serve`,
37
37
  port,
38
38
  baseUrl: `http://localhost:${port}`,
39
- ciWebServerCommand: hasNxExportPlugin
39
+ ciWebServerCommand: hasNxExpoPlugin
40
40
  ? `nx run ${options.projectName}:serve-static`
41
41
  : undefined,
42
42
  jsx: true,
@@ -12,7 +12,10 @@ async function normalizeOptions(host, options) {
12
12
  callingGenerator: '@nx/expo:application',
13
13
  });
14
14
  options.projectNameAndRootFormat = projectNameAndRootFormat;
15
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
15
+ const nxJson = (0, devkit_1.readNxJson)(host);
16
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
+ nxJson.useInferencePlugins !== false;
18
+ options.addPlugin ??= addPluginDefault;
16
19
  const { className } = (0, devkit_1.names)(options.name);
17
20
  const parsedTags = options.tags
18
21
  ? options.tags.split(',').map((s) => s.trim())
@@ -12,7 +12,10 @@ function expoInitGenerator(tree, schema) {
12
12
  }
13
13
  exports.expoInitGenerator = expoInitGenerator;
14
14
  async function expoInitGeneratorInternal(host, schema) {
15
- schema.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
15
+ const nxJson = (0, devkit_1.readNxJson)(host);
16
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
+ nxJson.useInferencePlugins !== false;
18
+ schema.addPlugin ??= addPluginDefault;
16
19
  (0, add_git_ignore_entry_1.addGitIgnoreEntry)(host);
17
20
  if (schema.addPlugin) {
18
21
  addPlugin(host);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
4
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
6
  async function normalizeOptions(host, options) {
6
7
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(host, {
@@ -11,7 +12,10 @@ async function normalizeOptions(host, options) {
11
12
  projectNameAndRootFormat: options.projectNameAndRootFormat,
12
13
  callingGenerator: '@nx/expo:library',
13
14
  });
14
- options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
15
+ const nxJson = (0, devkit_1.readNxJson)(host);
16
+ const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
17
+ nxJson.useInferencePlugins !== false;
18
+ options.addPlugin ??= addPluginDefault;
15
19
  const parsedTags = options.tags
16
20
  ? options.tags.split(',').map((s) => s.trim())
17
21
  : [];
@@ -0,0 +1,2 @@
1
+ import { ProjectGraph } from '@nx/devkit';
2
+ export declare function findAllNpmDependencies(graph: ProjectGraph, projectName: string, list?: string[], seen?: Set<string>): string[];
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findAllNpmDependencies = void 0;
4
+ function findAllNpmDependencies(graph, projectName, list = [], seen = new Set()) {
5
+ // In case of bad circular dependencies
6
+ if (seen.has(projectName)) {
7
+ return list;
8
+ }
9
+ seen.add(projectName);
10
+ const node = graph.externalNodes[projectName];
11
+ // Don't want to include '@nx/react-native' and '@nx/expo' because React Native
12
+ // autolink will warn that the package has no podspec file for iOS.
13
+ if (node) {
14
+ if (node.name !== `npm:@nx/react-native` &&
15
+ node.name !== `npm:@nrwl/react-native` &&
16
+ node.name !== `npm:@nx/expo` &&
17
+ node.name !== `npm:@nrwl/expo`) {
18
+ list.push(node.data.packageName);
19
+ }
20
+ }
21
+ else {
22
+ // it's workspace project, search for it's dependencies
23
+ graph.dependencies[projectName]?.forEach((dep) => findAllNpmDependencies(graph, dep.target, list, seen));
24
+ }
25
+ return list;
26
+ }
27
+ exports.findAllNpmDependencies = findAllNpmDependencies;