@nx/nest 21.0.0-beta.0 → 21.0.0-beta.2

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/nest",
3
- "version": "21.0.0-beta.0",
3
+ "version": "21.0.0-beta.2",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Nest contains executors and generators for allowing your workspace to create powerful Nest best in class APIs.",
6
6
  "repository": {
@@ -32,10 +32,10 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@nestjs/schematics": "^9.1.0",
35
- "@nx/devkit": "21.0.0-beta.0",
36
- "@nx/js": "21.0.0-beta.0",
37
- "@nx/eslint": "21.0.0-beta.0",
38
- "@nx/node": "21.0.0-beta.0",
35
+ "@nx/devkit": "21.0.0-beta.2",
36
+ "@nx/js": "21.0.0-beta.2",
37
+ "@nx/eslint": "21.0.0-beta.2",
38
+ "@nx/node": "21.0.0-beta.2",
39
39
  "tslib": "^2.3.0"
40
40
  },
41
41
  "publishConfig": {
@@ -10,6 +10,7 @@ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
10
10
  async function applicationGenerator(tree, rawOptions) {
11
11
  return await applicationGeneratorInternal(tree, {
12
12
  addPlugin: false,
13
+ useProjectJson: true,
13
14
  ...rawOptions,
14
15
  });
15
16
  }
@@ -5,8 +5,9 @@ exports.toNodeApplicationGeneratorOptions = toNodeApplicationGeneratorOptions;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
7
  const eslint_1 = require("@nx/eslint");
8
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
8
9
  async function normalizeOptions(tree, options) {
9
- await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'application');
10
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'application');
10
11
  const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
11
12
  name: options.name,
12
13
  projectType: 'application',
@@ -26,6 +27,7 @@ async function normalizeOptions(tree, options) {
26
27
  linter: options.linter ?? eslint_1.Linter.EsLint,
27
28
  unitTestRunner: options.unitTestRunner ?? 'jest',
28
29
  e2eTestRunner: options.e2eTestRunner ?? 'jest',
30
+ useProjectJson: options.useProjectJson ?? !(0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree),
29
31
  };
30
32
  }
31
33
  function toNodeApplicationGeneratorOptions(options) {
@@ -45,5 +47,6 @@ function toNodeApplicationGeneratorOptions(options) {
45
47
  bundler: 'webpack', // Some features require webpack plugins such as TS transformers
46
48
  isNest: true,
47
49
  addPlugin: options.addPlugin,
50
+ useProjectJson: options.useProjectJson,
48
51
  };
49
52
  }
@@ -16,6 +16,7 @@ export interface ApplicationGeneratorOptions {
16
16
  strict?: boolean;
17
17
  addPlugin?: boolean;
18
18
  useTsSolution?: boolean;
19
+ useProjectJson?: boolean;
19
20
  }
20
21
 
21
22
  interface NormalizedOptions extends ApplicationGeneratorOptions {
@@ -78,6 +78,10 @@
78
78
  "type": "boolean",
79
79
  "description": "Adds strictNullChecks, noImplicitAny, strictBindCallApply, forceConsistentCasingInFileNames and noFallthroughCasesInSwitch to tsconfig.",
80
80
  "default": false
81
+ },
82
+ "useProjectJson": {
83
+ "type": "boolean",
84
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
81
85
  }
82
86
  },
83
87
  "additionalProperties": false,
@@ -7,6 +7,7 @@ function addProject(tree, options) {
7
7
  return;
8
8
  }
9
9
  const project = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
10
+ project.targets ??= {};
10
11
  project.targets.build = {
11
12
  executor: '@nx/js:tsc',
12
13
  outputs: ['{options.outputPath}'],
@@ -4,8 +4,8 @@ exports.createFiles = createFiles;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  function createFiles(tree, options) {
6
6
  const substitutions = {
7
- ...options,
8
7
  ...(0, devkit_1.names)(options.projectName),
8
+ ...options,
9
9
  tmpl: '',
10
10
  offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
11
11
  fileName: options.fileName,
@@ -7,7 +7,9 @@ function deleteFiles(tree, options) {
7
7
  if (options.unitTestRunner !== 'none') {
8
8
  tree.delete((0, devkit_1.joinPathFragments)(options.projectRoot, 'src', 'lib', `${options.fileName}.spec.ts`));
9
9
  }
10
- if (!options.buildable && !options.publishable) {
10
+ if (!options.buildable &&
11
+ !options.publishable &&
12
+ !options.isUsingTsSolutionsConfig) {
11
13
  tree.delete((0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json'));
12
14
  }
13
15
  }
@@ -2,4 +2,4 @@ import { Tree } from '@nx/devkit';
2
2
  import type { LibraryGeneratorSchema as JsLibraryGeneratorSchema } from '@nx/js/src/generators/library/schema';
3
3
  import type { LibraryGeneratorOptions, NormalizedOptions } from '../schema';
4
4
  export declare function normalizeOptions(tree: Tree, options: LibraryGeneratorOptions): Promise<NormalizedOptions>;
5
- export declare function toJsLibraryGeneratorOptions(options: LibraryGeneratorOptions): JsLibraryGeneratorSchema;
5
+ export declare function toJsLibraryGeneratorOptions(options: NormalizedOptions): JsLibraryGeneratorSchema;
@@ -7,9 +7,8 @@ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project
7
7
  const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
8
8
  const eslint_1 = require("@nx/eslint");
9
9
  const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
10
- const get_import_path_1 = require("@nx/js/src/utils/get-import-path");
11
10
  async function normalizeOptions(tree, options) {
12
- await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'library');
11
+ await (0, project_name_and_root_utils_1.ensureRootProjectName)(options, 'library');
13
12
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
14
13
  name: options.name,
15
14
  projectType: 'library',
@@ -26,6 +25,7 @@ async function normalizeOptions(tree, options) {
26
25
  const parsedTags = options.tags
27
26
  ? options.tags.split(',').map((s) => s.trim())
28
27
  : [];
28
+ const isUsingTsSolutionsConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
29
29
  const normalized = {
30
30
  ...options,
31
31
  strict: options.strict ?? true,
@@ -35,15 +35,15 @@ async function normalizeOptions(tree, options) {
35
35
  linter: options.linter ?? eslint_1.Linter.EsLint,
36
36
  parsedTags,
37
37
  prefix: (0, get_npm_scope_1.getNpmScope)(tree), // we could also allow customizing this
38
- projectName: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree)
39
- ? (0, get_import_path_1.getImportPath)(tree, projectName)
40
- : projectName,
38
+ projectName: isUsingTsSolutionsConfig && !options.name ? importPath : projectName,
41
39
  projectRoot,
42
40
  importPath,
43
41
  service: options.service ?? false,
44
42
  target: options.target ?? 'es6',
45
43
  testEnvironment: options.testEnvironment ?? 'node',
46
44
  unitTestRunner: options.unitTestRunner ?? 'jest',
45
+ isUsingTsSolutionsConfig,
46
+ useProjectJson: options.useProjectJson ?? !isUsingTsSolutionsConfig,
47
47
  };
48
48
  return normalized;
49
49
  }
@@ -62,8 +62,8 @@ function toJsLibraryGeneratorOptions(options) {
62
62
  tags: options.tags,
63
63
  testEnvironment: options.testEnvironment,
64
64
  unitTestRunner: options.unitTestRunner,
65
- config: options.standaloneConfig ? 'project' : 'workspace',
66
65
  setParserOptionsProject: options.setParserOptionsProject,
67
66
  addPlugin: options.addPlugin,
67
+ useProjectJson: options.useProjectJson,
68
68
  };
69
69
  }
@@ -3,20 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.libraryGenerator = libraryGenerator;
4
4
  exports.libraryGeneratorInternal = libraryGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
- const js_1 = require("@nx/js");
7
- const lib_1 = require("./lib");
8
- const init_1 = require("../init/init");
9
6
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
7
+ const js_1 = require("@nx/js");
10
8
  const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
9
+ const init_1 = require("../init/init");
10
+ const lib_1 = require("./lib");
11
11
  async function libraryGenerator(tree, rawOptions) {
12
12
  return await libraryGeneratorInternal(tree, {
13
13
  addPlugin: false,
14
+ useProjectJson: true,
14
15
  ...rawOptions,
15
16
  });
16
17
  }
17
18
  async function libraryGeneratorInternal(tree, rawOptions) {
18
19
  const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
19
20
  const jsLibraryTask = await (0, js_1.libraryGenerator)(tree, (0, lib_1.toJsLibraryGeneratorOptions)(options));
21
+ updatePackageJson(tree, options);
20
22
  const initTask = await (0, init_1.default)(tree, rawOptions);
21
23
  const depsTask = (0, ensure_dependencies_1.ensureDependencies)(tree);
22
24
  (0, lib_1.deleteFiles)(tree, options);
@@ -37,3 +39,16 @@ async function libraryGeneratorInternal(tree, rawOptions) {
37
39
  ]);
38
40
  }
39
41
  exports.default = libraryGenerator;
42
+ function updatePackageJson(tree, options) {
43
+ const packageJsonPath = (0, devkit_1.joinPathFragments)(options.projectRoot, 'package.json');
44
+ if (!tree.exists(packageJsonPath)) {
45
+ return;
46
+ }
47
+ const packageJson = (0, devkit_1.readJson)(tree, packageJsonPath);
48
+ if (packageJson.type === 'module') {
49
+ // The @nx/js:lib generator can set the type to 'module' which would
50
+ // potentially break consumers of the library.
51
+ delete packageJson.type;
52
+ }
53
+ (0, devkit_1.writeJson)(tree, packageJsonPath, packageJson);
54
+ }
@@ -28,11 +28,12 @@ export interface LibraryGeneratorOptions {
28
28
  | 'es2021';
29
29
  testEnvironment?: 'jsdom' | 'node';
30
30
  unitTestRunner?: UnitTestRunner;
31
- standaloneConfig?: boolean;
32
31
  setParserOptionsProject?: boolean;
33
32
  skipPackageJson?: boolean;
34
33
  simpleName?: boolean;
35
34
  addPlugin?: boolean;
35
+ isUsingTsSolutionsConfig?: boolean;
36
+ useProjectJson?: boolean;
36
37
  }
37
38
 
38
39
  export interface NormalizedOptions extends LibraryGeneratorOptions {
@@ -118,12 +118,6 @@
118
118
  "type": "boolean",
119
119
  "default": true
120
120
  },
121
- "standaloneConfig": {
122
- "description": "Split the project configuration into <projectRoot>/project.json rather than including it inside workspace.json",
123
- "type": "boolean",
124
- "default": true,
125
- "x-deprecated": "Nx only supports standaloneConfig"
126
- },
127
121
  "setParserOptionsProject": {
128
122
  "type": "boolean",
129
123
  "description": "Whether or not to configure the ESLint \"parserOptions.project\" option. We do not do this by default for lint performance reasons.",
@@ -139,6 +133,10 @@
139
133
  "description": "Don't include the directory in the name of the module of the library.",
140
134
  "type": "boolean",
141
135
  "default": false
136
+ },
137
+ "useProjectJson": {
138
+ "type": "boolean",
139
+ "description": "Use a `project.json` configuration file instead of inlining the Nx configuration in the `package.json` file."
142
140
  }
143
141
  },
144
142
  "additionalProperties": false,