@nx/expo 20.5.0-rc.4 → 20.6.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/expo",
3
- "version": "20.5.0-rc.4",
3
+ "version": "20.6.0-beta.0",
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": [
@@ -28,13 +28,13 @@
28
28
  "main": "./index",
29
29
  "types": "index.d.ts",
30
30
  "dependencies": {
31
- "@nx/devkit": "20.5.0-rc.4",
32
- "@nx/eslint": "20.5.0-rc.4",
33
- "@nx/jest": "20.5.0-rc.4",
34
- "@nx/js": "20.5.0-rc.4",
35
- "@nx/react": "20.5.0-rc.4",
36
- "@nx/web": "20.5.0-rc.4",
37
- "@nx/webpack": "20.5.0-rc.4",
31
+ "@nx/devkit": "20.6.0-beta.0",
32
+ "@nx/eslint": "20.6.0-beta.0",
33
+ "@nx/jest": "20.6.0-beta.0",
34
+ "@nx/js": "20.6.0-beta.0",
35
+ "@nx/react": "20.6.0-beta.0",
36
+ "@nx/web": "20.6.0-beta.0",
37
+ "@nx/webpack": "20.6.0-beta.0",
38
38
  "enhanced-resolve": "^5.8.3",
39
39
  "metro-config": "~0.80.4",
40
40
  "metro-resolver": "~0.80.4",
@@ -20,6 +20,7 @@ const sort_fields_1 = require("@nx/js/src/utils/package-json/sort-fields");
20
20
  async function expoApplicationGenerator(host, schema) {
21
21
  return await expoApplicationGeneratorInternal(host, {
22
22
  addPlugin: false,
23
+ useProjectJson: true,
23
24
  ...schema,
24
25
  });
25
26
  }
@@ -45,7 +46,7 @@ async function expoApplicationGeneratorInternal(host, schema) {
45
46
  // If we are using the new TS solution
46
47
  // We need to update the workspace file (package.json or pnpm-workspaces.yaml) to include the new project
47
48
  if (options.isTsSolutionSetup) {
48
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
49
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.appProjectRoot);
49
50
  }
50
51
  const lintTask = await (0, add_linting_1.addLinting)(host, {
51
52
  ...options,
@@ -2,13 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addE2e = addE2e;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const web_1 = require("@nx/web");
6
- const versions_1 = require("../../../utils/versions");
7
- const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
5
+ const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
8
6
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
9
7
  const find_plugin_for_config_file_1 = require("@nx/devkit/src/utils/find-plugin-for-config-file");
10
- const e2e_web_server_info_utils_1 = require("@nx/devkit/src/generators/e2e-web-server-info-utils");
11
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
+ const web_1 = require("@nx/web");
9
+ const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
10
+ const versions_1 = require("../../../utils/versions");
12
11
  async function addE2e(tree, options) {
13
12
  const hasPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(tree);
14
13
  if (!hasPlugin) {
@@ -21,15 +20,15 @@ async function addE2e(tree, options) {
21
20
  switch (options.e2eTestRunner) {
22
21
  case 'cypress': {
23
22
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', versions_1.nxVersion);
24
- if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree)) {
25
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
26
- name: options.e2eProjectName,
27
- version: '0.0.1',
28
- private: true,
29
- nx: {
30
- implicitDependencies: [options.projectName],
31
- },
32
- });
23
+ const packageJson = {
24
+ name: options.e2eProjectName,
25
+ version: '0.0.1',
26
+ private: true,
27
+ };
28
+ if (!options.useProjectJson) {
29
+ packageJson.nx = {
30
+ implicitDependencies: [options.projectName],
31
+ };
33
32
  }
34
33
  else {
35
34
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
@@ -41,6 +40,9 @@ async function addE2e(tree, options) {
41
40
  tags: [],
42
41
  });
43
42
  }
43
+ if (!options.useProjectJson || options.isTsSolutionSetup) {
44
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
45
+ }
44
46
  const e2eTask = await configurationGenerator(tree, {
45
47
  ...options,
46
48
  project: options.e2eProjectName,
@@ -76,15 +78,15 @@ async function addE2e(tree, options) {
76
78
  }
77
79
  case 'playwright': {
78
80
  const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', versions_1.nxVersion);
79
- if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree)) {
80
- (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), {
81
- name: options.e2eProjectName,
82
- version: '0.0.1',
83
- private: true,
84
- nx: {
85
- implicitDependencies: [options.projectName],
86
- },
87
- });
81
+ const packageJson = {
82
+ name: options.e2eProjectName,
83
+ version: '0.0.1',
84
+ private: true,
85
+ };
86
+ if (!options.useProjectJson) {
87
+ packageJson.nx = {
88
+ implicitDependencies: [options.projectName],
89
+ };
88
90
  }
89
91
  else {
90
92
  (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
@@ -93,8 +95,12 @@ async function addE2e(tree, options) {
93
95
  sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
94
96
  targets: {},
95
97
  implicitDependencies: [options.projectName],
98
+ tags: [],
96
99
  });
97
100
  }
101
+ if (!options.useProjectJson || options.isTsSolutionSetup) {
102
+ (0, devkit_1.writeJson)(tree, (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'package.json'), packageJson);
103
+ }
98
104
  const e2eTask = await configurationGenerator(tree, {
99
105
  project: options.e2eProjectName,
100
106
  skipFormat: true,
@@ -2,9 +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 has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
6
5
  const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
7
- const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
+ const has_expo_plugin_1 = require("../../../utils/has-expo-plugin");
8
7
  function addProject(host, options) {
9
8
  const hasPlugin = (0, has_expo_plugin_1.hasExpoPlugin)(host);
10
9
  if (!hasPlugin) {
@@ -17,12 +16,12 @@ function addProject(host, options) {
17
16
  targets: hasPlugin ? {} : getTargets(options),
18
17
  tags: options.parsedTags,
19
18
  };
20
- if ((0, ts_solution_setup_1.isUsingTsSolutionSetup)(host)) {
21
- const packageJson = {
22
- name: options.importPath,
23
- version: '0.0.1',
24
- private: true,
25
- };
19
+ const packageJson = {
20
+ name: options.importPath,
21
+ version: '0.0.1',
22
+ private: true,
23
+ };
24
+ if (!options.useProjectJson) {
26
25
  if (options.importPath !== options.projectName) {
27
26
  packageJson.nx = { name: options.projectName };
28
27
  }
@@ -34,11 +33,13 @@ function addProject(host, options) {
34
33
  packageJson.nx ??= {};
35
34
  packageJson.nx.tags = options.parsedTags;
36
35
  }
37
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
38
36
  }
39
37
  else {
40
38
  (0, devkit_1.addProjectConfiguration)(host, options.projectName, projectConfiguration, options.standaloneConfig);
41
39
  }
40
+ if (!options.useProjectJson || options.isTsSolutionSetup) {
41
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'package.json'), packageJson);
42
+ }
42
43
  }
43
44
  function getTargets(options) {
44
45
  const architect = {};
@@ -22,6 +22,7 @@ async function normalizeOptions(host, options) {
22
22
  const rootProject = appProjectRoot === '.';
23
23
  const isTsSolutionSetup = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
24
24
  const appProjectName = !isTsSolutionSetup || options.name ? projectName : importPath;
25
+ const useProjectJson = options.useProjectJson ?? !isTsSolutionSetup;
25
26
  const e2eProjectName = rootProject ? 'e2e' : `${appProjectName}-e2e`;
26
27
  const e2eProjectRoot = rootProject ? 'e2e' : `${appProjectRoot}-e2e`;
27
28
  return {
@@ -40,5 +41,6 @@ async function normalizeOptions(host, options) {
40
41
  e2eProjectName,
41
42
  e2eProjectRoot,
42
43
  isTsSolutionSetup,
44
+ useProjectJson,
43
45
  };
44
46
  }
@@ -20,4 +20,5 @@ export interface Schema {
20
20
  nxCloudToken?: string;
21
21
  useTsSolution?: boolean;
22
22
  formatter?: 'prettier' | 'none';
23
+ useProjectJson?: boolean;
23
24
  }
@@ -86,6 +86,10 @@
86
86
  "type": "boolean",
87
87
  "description": "Do not add dependencies to `package.json`.",
88
88
  "default": false
89
+ },
90
+ "useProjectJson": {
91
+ "type": "boolean",
92
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
89
93
  }
90
94
  },
91
95
  "required": ["directory"]
@@ -1,7 +1,7 @@
1
- # <%= name %>
1
+ # <%= projectName %>
2
2
 
3
3
  This library was generated with [Nx](https://nx.dev).
4
4
 
5
5
  ## Running unit tests
6
6
 
7
- Run `nx test <%= name %>` to execute the unit tests via [Jest](https://jestjs.io).
7
+ Run `nx test <%= projectName %>` to execute the unit tests via [Jest](https://jestjs.io).
@@ -1,7 +1,6 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import { Schema } from '../schema';
3
- export interface NormalizedSchema extends Schema {
4
- name: string;
3
+ export interface NormalizedSchema extends Omit<Schema, 'name'> {
5
4
  fileName: string;
6
5
  projectName: string;
7
6
  projectRoot: string;
@@ -20,16 +20,17 @@ async function normalizeOptions(host, options) {
20
20
  ? options.tags.split(',').map((s) => s.trim())
21
21
  : [];
22
22
  const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(host);
23
+ const useProjectJson = options.useProjectJson ?? !isUsingTsSolutionConfig;
23
24
  const normalized = {
24
25
  ...options,
25
26
  fileName: projectName,
26
27
  routePath: `/${projectNames.projectSimpleName}`,
27
- name: projectName,
28
28
  projectName: isUsingTsSolutionConfig && !options.name ? importPath : projectName,
29
29
  projectRoot,
30
30
  parsedTags,
31
31
  importPath,
32
32
  isUsingTsSolutionConfig,
33
+ useProjectJson,
33
34
  };
34
35
  return normalized;
35
36
  }
@@ -21,6 +21,7 @@ const versions_1 = require("../../utils/versions");
21
21
  async function expoLibraryGenerator(host, schema) {
22
22
  return await expoLibraryGeneratorInternal(host, {
23
23
  addPlugin: false,
24
+ useProjectJson: true,
24
25
  ...schema,
25
26
  });
26
27
  }
@@ -36,7 +37,7 @@ async function expoLibraryGeneratorInternal(host, schema) {
36
37
  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)`);
37
38
  }
38
39
  if (options.isUsingTsSolutionConfig) {
39
- (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
40
+ await (0, ts_solution_setup_1.addProjectToTsSolutionWorkspace)(host, options.projectRoot);
40
41
  }
41
42
  const initTask = await (0, init_1.default)(host, { ...options, skipFormat: true });
42
43
  tasks.push(initTask);
@@ -90,7 +91,7 @@ async function expoLibraryGeneratorInternal(host, schema) {
90
91
  tasks.push(() => (0, devkit_1.installPackagesTask)(host, true));
91
92
  }
92
93
  tasks.push(() => {
93
- (0, log_show_project_command_1.logShowProjectCommand)(options.name);
94
+ (0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
94
95
  });
95
96
  return (0, devkit_1.runTasksInSerial)(...tasks);
96
97
  }
@@ -102,17 +103,22 @@ async function addProject(host, options) {
102
103
  tags: options.parsedTags,
103
104
  targets: {},
104
105
  };
106
+ let packageJson = {
107
+ name: options.importPath,
108
+ version: '0.0.1',
109
+ peerDependencies: {
110
+ react: versions_1.reactVersion,
111
+ 'react-native': versions_1.reactNativeVersion,
112
+ },
113
+ };
105
114
  if (options.isUsingTsSolutionConfig) {
106
- const packageJson = {
107
- name: options.projectName,
108
- version: '0.0.1',
115
+ packageJson = {
116
+ ...packageJson,
109
117
  ...determineEntryFields(options),
110
118
  files: options.publishable ? ['dist', '!**/*.tsbuildinfo'] : undefined,
111
- peerDependencies: {
112
- react: versions_1.reactVersion,
113
- 'react-native': versions_1.reactNativeVersion,
114
- },
115
119
  };
120
+ }
121
+ if (!options.useProjectJson) {
116
122
  if (options.projectName !== options.importPath) {
117
123
  packageJson.nx = { name: options.projectName };
118
124
  }
@@ -120,10 +126,15 @@ async function addProject(host, options) {
120
126
  packageJson.nx ??= {};
121
127
  packageJson.nx.tags = options.parsedTags;
122
128
  }
123
- (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), packageJson);
124
129
  }
125
130
  else {
126
- (0, devkit_1.addProjectConfiguration)(host, options.name, project);
131
+ (0, devkit_1.addProjectConfiguration)(host, options.projectName, project);
132
+ }
133
+ if (!options.useProjectJson ||
134
+ options.isUsingTsSolutionConfig ||
135
+ options.publishable ||
136
+ options.buildable) {
137
+ (0, devkit_1.writeJson)(host, (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'), packageJson);
127
138
  }
128
139
  if (options.publishable || options.buildable) {
129
140
  const external = new Set([
@@ -169,7 +180,6 @@ function updateTsConfig(tree, options) {
169
180
  function createFiles(host, options) {
170
181
  (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/lib'), options.projectRoot, {
171
182
  ...options,
172
- ...(0, devkit_1.names)(options.name),
173
183
  tmpl: '',
174
184
  offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
175
185
  rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot),
@@ -19,4 +19,5 @@ export interface Schema {
19
19
  setParserOptionsProject?: boolean;
20
20
  skipPackageJson?: boolean; // default is false
21
21
  addPlugin?: boolean;
22
+ useProjectJson?: boolean;
22
23
  }
@@ -89,6 +89,10 @@
89
89
  "type": "boolean",
90
90
  "description": "Do not add dependencies to `package.json`.",
91
91
  "default": false
92
+ },
93
+ "useProjectJson": {
94
+ "type": "boolean",
95
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
92
96
  }
93
97
  },
94
98
  "required": ["directory"]