@nx/nest 16.8.0-beta.0 → 16.8.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/generators.json CHANGED
@@ -108,7 +108,7 @@
108
108
  },
109
109
  "generators": {
110
110
  "application": {
111
- "factory": "./src/generators/application/application",
111
+ "factory": "./src/generators/application/application#applicationGeneratorInternal",
112
112
  "schema": "./src/generators/application/schema.json",
113
113
  "aliases": ["app"],
114
114
  "x-type": "application",
@@ -128,7 +128,7 @@
128
128
  "hidden": true
129
129
  },
130
130
  "library": {
131
- "factory": "./src/generators/library/library",
131
+ "factory": "./src/generators/library/library#libraryGeneratorInternal",
132
132
  "schema": "./src/generators/library/schema.json",
133
133
  "aliases": ["lib"],
134
134
  "x-type": "library",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nest",
3
- "version": "16.8.0-beta.0",
3
+ "version": "16.8.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": {
@@ -31,11 +31,11 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@nestjs/schematics": "^9.1.0",
34
- "@nrwl/nest": "16.8.0-beta.0",
35
- "@nx/devkit": "16.8.0-beta.0",
36
- "@nx/js": "16.8.0-beta.0",
37
- "@nx/linter": "16.8.0-beta.0",
38
- "@nx/node": "16.8.0-beta.0",
34
+ "@nrwl/nest": "16.8.0-beta.2",
35
+ "@nx/devkit": "16.8.0-beta.2",
36
+ "@nx/js": "16.8.0-beta.2",
37
+ "@nx/linter": "16.8.0-beta.2",
38
+ "@nx/node": "16.8.0-beta.2",
39
39
  "@phenomnomnominal/tsquery": "~5.0.1",
40
40
  "enquirer": "~2.3.6",
41
41
  "semver": "7.5.3",
@@ -45,5 +45,5 @@
45
45
  "access": "public"
46
46
  },
47
47
  "type": "commonjs",
48
- "gitHead": "818352404283c1d34ab303d91b3bd16474f54916"
48
+ "gitHead": "9bcc04742f9e1516d8c1ddbfb1907770c347876f"
49
49
  }
@@ -1,5 +1,6 @@
1
1
  import type { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { ApplicationGeneratorOptions } from './schema';
3
3
  export declare function applicationGenerator(tree: Tree, rawOptions: ApplicationGeneratorOptions): Promise<GeneratorCallback>;
4
+ export declare function applicationGeneratorInternal(tree: Tree, rawOptions: ApplicationGeneratorOptions): Promise<GeneratorCallback>;
4
5
  export default applicationGenerator;
5
6
  export declare const applicationSchematic: (generatorOptions: ApplicationGeneratorOptions) => (tree: any, context: any) => Promise<any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applicationSchematic = exports.applicationGenerator = void 0;
3
+ exports.applicationSchematic = exports.applicationGeneratorInternal = exports.applicationGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const node_1 = require("@nx/node");
@@ -8,7 +8,13 @@ const init_1 = require("../init/init");
8
8
  const lib_1 = require("./lib");
9
9
  function applicationGenerator(tree, rawOptions) {
10
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const options = (0, lib_1.normalizeOptions)(tree, rawOptions);
11
+ return yield applicationGeneratorInternal(tree, Object.assign({ projectNameAndRootFormat: 'derived' }, rawOptions));
12
+ });
13
+ }
14
+ exports.applicationGenerator = applicationGenerator;
15
+ function applicationGeneratorInternal(tree, rawOptions) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const options = yield (0, lib_1.normalizeOptions)(tree, rawOptions);
12
18
  const initTask = yield (0, init_1.initGenerator)(tree, {
13
19
  skipPackageJson: options.skipPackageJson,
14
20
  unitTestRunner: options.unitTestRunner,
@@ -23,6 +29,6 @@ function applicationGenerator(tree, rawOptions) {
23
29
  return (0, devkit_1.runTasksInSerial)(initTask, nodeApplicationTask);
24
30
  });
25
31
  }
26
- exports.applicationGenerator = applicationGenerator;
32
+ exports.applicationGeneratorInternal = applicationGeneratorInternal;
27
33
  exports.default = applicationGenerator;
28
34
  exports.applicationSchematic = (0, devkit_1.convertNxGenerator)(applicationGenerator);
@@ -5,7 +5,7 @@ const devkit_1 = require("@nx/devkit");
5
5
  function createFiles(tree, options) {
6
6
  (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), (0, devkit_1.joinPathFragments)(options.appProjectRoot, 'src'), {
7
7
  tmpl: '',
8
- name: options.name,
8
+ name: options.appProjectName,
9
9
  root: options.appProjectRoot,
10
10
  });
11
11
  }
@@ -1,5 +1,5 @@
1
1
  import { Tree } from '@nx/devkit';
2
2
  import type { Schema as NodeApplicationGeneratorOptions } from '@nx/node/src/generators/application/schema';
3
3
  import type { ApplicationGeneratorOptions, NormalizedOptions } from '../schema';
4
- export declare function normalizeOptions(tree: Tree, options: ApplicationGeneratorOptions): NormalizedOptions;
4
+ export declare function normalizeOptions(tree: Tree, options: ApplicationGeneratorOptions): Promise<NormalizedOptions>;
5
5
  export declare function toNodeApplicationGeneratorOptions(options: NormalizedOptions): NodeApplicationGeneratorOptions;
@@ -1,19 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toNodeApplicationGeneratorOptions = exports.normalizeOptions = void 0;
4
- const devkit_1 = require("@nx/devkit");
5
- const devkit_2 = require("@nx/devkit");
4
+ const tslib_1 = require("tslib");
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const linter_1 = require("@nx/linter");
7
7
  function normalizeOptions(tree, options) {
8
8
  var _a, _b, _c, _d;
9
- const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
10
- const appDirectory = projectDirectory
11
- ? `${(0, devkit_2.names)(projectDirectory).fileName}/${(0, devkit_2.names)(options.name).fileName}`
12
- : (0, devkit_2.names)(options.name).fileName;
13
- const appProjectRoot = options.rootProject
14
- ? '.'
15
- : (0, devkit_2.joinPathFragments)(layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : (0, devkit_2.getWorkspaceLayout)(tree).appsDir, appDirectory);
16
- return Object.assign(Object.assign({}, options), { strict: (_a = options.strict) !== null && _a !== void 0 ? _a : false, appProjectRoot, linter: (_b = options.linter) !== null && _b !== void 0 ? _b : linter_1.Linter.EsLint, unitTestRunner: (_c = options.unitTestRunner) !== null && _c !== void 0 ? _c : 'jest', e2eTestRunner: (_d = options.e2eTestRunner) !== null && _d !== void 0 ? _d : 'jest' });
9
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
+ const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
11
+ name: options.name,
12
+ projectType: 'application',
13
+ directory: options.directory,
14
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
15
+ rootProject: options.rootProject,
16
+ callingGenerator: '@nx/nest:application',
17
+ });
18
+ options.rootProject = appProjectRoot === '.';
19
+ options.projectNameAndRootFormat = projectNameAndRootFormat;
20
+ return Object.assign(Object.assign({}, options), { strict: (_a = options.strict) !== null && _a !== void 0 ? _a : false, appProjectName,
21
+ appProjectRoot, linter: (_b = options.linter) !== null && _b !== void 0 ? _b : linter_1.Linter.EsLint, unitTestRunner: (_c = options.unitTestRunner) !== null && _c !== void 0 ? _c : 'jest', e2eTestRunner: (_d = options.e2eTestRunner) !== null && _d !== void 0 ? _d : 'jest' });
22
+ });
17
23
  }
18
24
  exports.normalizeOptions = normalizeOptions;
19
25
  function toNodeApplicationGeneratorOptions(options) {
@@ -1,8 +1,10 @@
1
- import { Linter } from '@nx/linter';
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/linter';
2
3
 
3
4
  export interface ApplicationGeneratorOptions {
4
5
  name: string;
5
6
  directory?: string;
7
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
6
8
  frontendProject?: string;
7
9
  linter?: Linter;
8
10
  skipFormat?: boolean;
@@ -17,5 +19,6 @@ export interface ApplicationGeneratorOptions {
17
19
  }
18
20
 
19
21
  interface NormalizedOptions extends ApplicationGeneratorOptions {
22
+ appProjectName: string;
20
23
  appProjectRoot: Path;
21
24
  }
@@ -13,12 +13,18 @@
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use for the node application?"
16
+ "x-prompt": "What name would you like to use for the node application?",
17
+ "pattern": "^[a-zA-Z][^:]*$"
17
18
  },
18
19
  "directory": {
19
20
  "description": "The directory of the new application.",
20
21
  "type": "string"
21
22
  },
23
+ "projectNameAndRootFormat": {
24
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
25
+ "type": "string",
26
+ "enum": ["as-provided", "derived"]
27
+ },
22
28
  "skipFormat": {
23
29
  "description": "Skip formatting files.",
24
30
  "type": "boolean",
@@ -11,9 +11,7 @@ function addProject(tree, options) {
11
11
  executor: '@nx/js:tsc',
12
12
  outputs: ['{options.outputPath}'],
13
13
  options: {
14
- outputPath: options.libsDir && options.libsDir !== '.'
15
- ? `dist/${options.libsDir}/${options.projectDirectory}`
16
- : `dist/${options.projectDirectory}`,
14
+ outputPath: `dist/${options.projectRoot}`,
17
15
  tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
18
16
  packageJson: `${options.projectRoot}/package.json`,
19
17
  main: `${options.projectRoot}/src/index.ts`,
@@ -1,5 +1,5 @@
1
- import type { LibraryGeneratorSchema as JsLibraryGeneratorSchema } from '@nx/js/src/utils/schema';
2
1
  import { Tree } from '@nx/devkit';
2
+ import type { LibraryGeneratorSchema as JsLibraryGeneratorSchema } from '@nx/js/src/utils/schema';
3
3
  import type { LibraryGeneratorOptions, NormalizedOptions } from '../schema';
4
- export declare function normalizeOptions(tree: Tree, options: LibraryGeneratorOptions): NormalizedOptions;
4
+ export declare function normalizeOptions(tree: Tree, options: LibraryGeneratorOptions): Promise<NormalizedOptions>;
5
5
  export declare function toJsLibraryGeneratorOptions(options: LibraryGeneratorOptions): JsLibraryGeneratorSchema;
@@ -1,27 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toJsLibraryGeneratorOptions = exports.normalizeOptions = void 0;
4
- const linter_1 = require("@nx/linter");
5
- const devkit_1 = require("@nx/devkit");
4
+ const tslib_1 = require("tslib");
5
+ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
6
6
  const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
7
+ const linter_1 = require("@nx/linter");
7
8
  function normalizeOptions(tree, options) {
8
9
  var _a, _b, _c, _d, _e, _f, _g, _h;
9
- const { layoutDirectory, projectDirectory } = (0, devkit_1.extractLayoutDirectory)(options.directory);
10
- const { libsDir: defaultLibsDir } = (0, devkit_1.getWorkspaceLayout)(tree);
11
- const libsDir = layoutDirectory !== null && layoutDirectory !== void 0 ? layoutDirectory : defaultLibsDir;
12
- const name = (0, devkit_1.names)(options.name).fileName;
13
- const fullProjectDirectory = projectDirectory
14
- ? `${(0, devkit_1.names)(projectDirectory).fileName}/${name}`
15
- : name;
16
- const projectName = fullProjectDirectory.replace(new RegExp('/', 'g'), '-');
17
- const fileName = options.simpleName ? name : projectName;
18
- const projectRoot = (0, devkit_1.joinPathFragments)(libsDir, fullProjectDirectory);
19
- const parsedTags = options.tags
20
- ? options.tags.split(',').map((s) => s.trim())
21
- : [];
22
- const normalized = Object.assign(Object.assign({}, options), { strict: (_a = options.strict) !== null && _a !== void 0 ? _a : true, controller: (_b = options.controller) !== null && _b !== void 0 ? _b : false, fileName, global: (_c = options.global) !== null && _c !== void 0 ? _c : false, linter: (_d = options.linter) !== null && _d !== void 0 ? _d : linter_1.Linter.EsLint, parsedTags, prefix: (0, get_npm_scope_1.getNpmScope)(tree), projectDirectory: fullProjectDirectory, projectName,
23
- projectRoot, service: (_e = options.service) !== null && _e !== void 0 ? _e : false, target: (_f = options.target) !== null && _f !== void 0 ? _f : 'es6', testEnvironment: (_g = options.testEnvironment) !== null && _g !== void 0 ? _g : 'node', unitTestRunner: (_h = options.unitTestRunner) !== null && _h !== void 0 ? _h : 'jest', libsDir });
24
- return normalized;
10
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
+ const { projectName, names: projectNames, projectRoot, importPath, } = yield (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
12
+ name: options.name,
13
+ projectType: 'library',
14
+ directory: options.directory,
15
+ importPath: options.importPath,
16
+ projectNameAndRootFormat: options.projectNameAndRootFormat,
17
+ callingGenerator: '@nx/nest:library',
18
+ });
19
+ const fileName = options.simpleName
20
+ ? projectNames.projectSimpleName
21
+ : projectNames.projectFileName;
22
+ const parsedTags = options.tags
23
+ ? options.tags.split(',').map((s) => s.trim())
24
+ : [];
25
+ const normalized = Object.assign(Object.assign({}, options), { strict: (_a = options.strict) !== null && _a !== void 0 ? _a : true, controller: (_b = options.controller) !== null && _b !== void 0 ? _b : false, fileName, global: (_c = options.global) !== null && _c !== void 0 ? _c : false, linter: (_d = options.linter) !== null && _d !== void 0 ? _d : linter_1.Linter.EsLint, parsedTags, prefix: (0, get_npm_scope_1.getNpmScope)(tree), // we could also allow customizing this
26
+ projectName,
27
+ projectRoot,
28
+ importPath, service: (_e = options.service) !== null && _e !== void 0 ? _e : false, target: (_f = options.target) !== null && _f !== void 0 ? _f : 'es6', testEnvironment: (_g = options.testEnvironment) !== null && _g !== void 0 ? _g : 'node', unitTestRunner: (_h = options.unitTestRunner) !== null && _h !== void 0 ? _h : 'jest' });
29
+ return normalized;
30
+ });
25
31
  }
26
32
  exports.normalizeOptions = normalizeOptions;
27
33
  function toJsLibraryGeneratorOptions(options) {
@@ -1,5 +1,6 @@
1
1
  import type { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { LibraryGeneratorOptions } from './schema';
3
3
  export declare function libraryGenerator(tree: Tree, rawOptions: LibraryGeneratorOptions): Promise<GeneratorCallback>;
4
+ export declare function libraryGeneratorInternal(tree: Tree, rawOptions: LibraryGeneratorOptions): Promise<GeneratorCallback>;
4
5
  export default libraryGenerator;
5
6
  export declare const librarySchematic: (generatorOptions: LibraryGeneratorOptions) => (tree: any, context: any) => Promise<any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.librarySchematic = exports.libraryGenerator = void 0;
3
+ exports.librarySchematic = exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
@@ -8,7 +8,13 @@ const lib_1 = require("../init/lib");
8
8
  const lib_2 = require("./lib");
9
9
  function libraryGenerator(tree, rawOptions) {
10
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
- const options = (0, lib_2.normalizeOptions)(tree, rawOptions);
11
+ return yield libraryGeneratorInternal(tree, Object.assign({ projectNameAndRootFormat: 'derived' }, rawOptions));
12
+ });
13
+ }
14
+ exports.libraryGenerator = libraryGenerator;
15
+ function libraryGeneratorInternal(tree, rawOptions) {
16
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
17
+ const options = yield (0, lib_2.normalizeOptions)(tree, rawOptions);
12
18
  yield (0, js_1.libraryGenerator)(tree, (0, lib_2.toJsLibraryGeneratorOptions)(options));
13
19
  const installDepsTask = (0, lib_1.addDependencies)(tree);
14
20
  (0, lib_2.deleteFiles)(tree, options);
@@ -22,6 +28,6 @@ function libraryGenerator(tree, rawOptions) {
22
28
  return installDepsTask;
23
29
  });
24
30
  }
25
- exports.libraryGenerator = libraryGenerator;
31
+ exports.libraryGeneratorInternal = libraryGeneratorInternal;
26
32
  exports.default = libraryGenerator;
27
33
  exports.librarySchematic = (0, devkit_1.convertNxGenerator)(libraryGenerator);
@@ -1,11 +1,13 @@
1
- import { Linter } from '@nx/linter';
2
- import { UnitTestRunner } from '../utils';
1
+ import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
+ import type { Linter } from '@nx/linter';
3
+ import type { UnitTestRunner } from '../utils';
3
4
 
4
5
  export interface LibraryGeneratorOptions {
5
6
  name: string;
6
7
  buildable?: boolean;
7
8
  controller?: boolean;
8
9
  directory?: string;
10
+ projectNameAndRootFormat?: ProjectNameAndRootFormat;
9
11
  global?: boolean;
10
12
  importPath?: string;
11
13
  linter?: Linter;
@@ -38,8 +40,6 @@ export interface NormalizedOptions extends LibraryGeneratorOptions {
38
40
  fileName: string;
39
41
  parsedTags: string[];
40
42
  prefix: string;
41
- projectDirectory: string;
42
43
  projectName: string;
43
44
  projectRoot: Path;
44
- libsDir: string;
45
45
  }
@@ -19,13 +19,19 @@
19
19
  "$source": "argv",
20
20
  "index": 0
21
21
  },
22
- "x-prompt": "What name would you like to use for the library?"
22
+ "x-prompt": "What name would you like to use for the library?",
23
+ "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
23
24
  },
24
25
  "directory": {
25
26
  "description": "A directory where the library is placed.",
26
27
  "type": "string",
27
28
  "alias": "dir"
28
29
  },
30
+ "projectNameAndRootFormat": {
31
+ "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
32
+ "type": "string",
33
+ "enum": ["as-provided", "derived"]
34
+ },
29
35
  "linter": {
30
36
  "description": "The tool to use for running lint checks.",
31
37
  "type": "string",