@nestjs/schematics 11.0.9 → 12.0.0-alpha.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/dist/lib/application/files/js/package.json +10 -10
- package/dist/lib/application/files/ts/package.json +3 -3
- package/dist/lib/application/files/ts/tsconfig.json +0 -1
- package/dist/lib/application/files/ts-esm/.prettierrc +4 -0
- package/dist/lib/application/files/ts-esm/README.md +98 -0
- package/dist/lib/application/files/ts-esm/eslint.config.mjs +34 -0
- package/dist/lib/application/files/ts-esm/nest-cli.json +8 -0
- package/dist/lib/application/files/ts-esm/package.json +50 -0
- package/dist/lib/application/files/ts-esm/src/app.controller.__specFileSuffix__.ts +22 -0
- package/dist/lib/application/files/ts-esm/src/app.controller.ts +12 -0
- package/dist/lib/application/files/ts-esm/src/app.module.ts +10 -0
- package/dist/lib/application/files/ts-esm/src/app.service.ts +8 -0
- package/dist/lib/application/files/ts-esm/src/main.ts +8 -0
- package/dist/lib/application/files/ts-esm/test/app.e2e-__specFileSuffix__.ts +25 -0
- package/dist/lib/application/files/ts-esm/tsconfig.build.json +4 -0
- package/dist/lib/application/files/ts-esm/tsconfig.json +24 -0
- package/dist/lib/application/files/ts-esm/vitest.config.e2e.ts +10 -0
- package/dist/lib/application/files/ts-esm/vitest.config.ts +10 -0
- package/dist/lib/application/schema.json +14 -0
- package/dist/lib/library/files/ts/tsconfig.lib.json +1 -0
- package/dist/lib/sub-app/files/ts/tsconfig.app.json +1 -0
- package/dist/lib/sub-app/workspace/ts/tsconfig.app.json +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/{lib → src/lib}/application/application.factory.d.ts +1 -1
- package/dist/src/lib/application/application.factory.js +64 -0
- package/dist/{lib → src/lib}/class/class.factory.d.ts +1 -1
- package/dist/src/lib/class/class.factory.js +48 -0
- package/dist/{lib → src/lib}/client-app/angular/angular.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/client-app/angular/angular.factory.js +23 -26
- package/dist/{lib → src/lib}/configuration/configuration.factory.d.ts +1 -1
- package/dist/src/lib/configuration/configuration.factory.js +24 -0
- package/dist/{lib → src/lib}/controller/controller.factory.d.ts +1 -1
- package/dist/src/lib/controller/controller.factory.js +69 -0
- package/dist/{lib → src/lib}/decorator/decorator.factory.d.ts +1 -1
- package/dist/src/lib/decorator/decorator.factory.js +32 -0
- package/dist/src/lib/defaults.js +14 -0
- package/dist/{lib → src/lib}/filter/filter.factory.d.ts +1 -1
- package/dist/src/lib/filter/filter.factory.js +40 -0
- package/dist/{lib → src/lib}/gateway/gateway.factory.d.ts +1 -1
- package/dist/src/lib/gateway/gateway.factory.js +69 -0
- package/dist/{lib → src/lib}/guard/guard.factory.d.ts +1 -1
- package/dist/src/lib/guard/guard.factory.js +40 -0
- package/dist/{lib → src/lib}/interceptor/interceptor.factory.d.ts +1 -1
- package/dist/src/lib/interceptor/interceptor.factory.js +41 -0
- package/dist/{lib → src/lib}/interface/interface.factory.d.ts +1 -1
- package/dist/src/lib/interface/interface.factory.js +31 -0
- package/dist/{lib → src/lib}/library/library.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/library/library.factory.js +51 -64
- package/dist/{lib → src/lib}/middleware/middleware.factory.d.ts +1 -1
- package/dist/src/lib/middleware/middleware.factory.js +40 -0
- package/dist/{lib → src/lib}/module/module.factory.d.ts +1 -1
- package/dist/src/lib/module/module.factory.js +57 -0
- package/dist/{lib → src/lib}/pipe/pipe.factory.d.ts +1 -1
- package/dist/src/lib/pipe/pipe.factory.js +41 -0
- package/dist/{lib → src/lib}/provider/provider.factory.d.ts +1 -1
- package/dist/src/lib/provider/provider.factory.js +73 -0
- package/dist/{lib → src/lib}/readers/file-system.reader.d.ts +1 -1
- package/dist/{lib → src/lib}/readers/file-system.reader.js +3 -7
- package/dist/src/lib/readers/index.d.ts +2 -0
- package/dist/src/lib/readers/index.js +2 -0
- package/dist/src/lib/readers/reader.js +1 -0
- package/dist/{lib → src/lib}/resolver/resolver.factory.d.ts +1 -1
- package/dist/src/lib/resolver/resolver.factory.js +68 -0
- package/dist/{lib → src/lib}/resource/resource.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/resource/resource.factory.js +35 -38
- package/dist/{lib → src/lib}/service/service.factory.d.ts +1 -1
- package/dist/src/lib/service/service.factory.js +71 -0
- package/dist/{lib → src/lib}/sub-app/sub-app.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/sub-app/sub-app.factory.js +94 -69
- package/dist/{utils → src/utils}/dependencies.utils.js +7 -12
- package/dist/{utils → src/utils}/formatting.js +1 -4
- package/dist/src/utils/index.d.ts +11 -0
- package/dist/src/utils/index.js +11 -0
- package/dist/src/utils/jest-module-mapper.js +6 -0
- package/dist/{utils → src/utils}/json-file.util.js +9 -13
- package/dist/{utils → src/utils}/metadata.manager.d.ts +1 -1
- package/dist/{utils → src/utils}/metadata.manager.js +11 -15
- package/dist/{utils → src/utils}/module-import.declarator.d.ts +2 -2
- package/dist/{utils → src/utils}/module-import.declarator.js +6 -10
- package/dist/{utils → src/utils}/module-metadata.declarator.d.ts +1 -1
- package/dist/src/utils/module-metadata.declarator.js +8 -0
- package/dist/{utils → src/utils}/module.declarator.d.ts +2 -2
- package/dist/src/utils/module.declarator.js +30 -0
- package/dist/{utils → src/utils}/module.finder.js +3 -7
- package/dist/src/utils/name.parser.js +13 -0
- package/dist/{utils → src/utils}/object-sorting.js +1 -4
- package/dist/src/utils/path.solver.js +8 -0
- package/dist/src/utils/source-root.helpers.js +20 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +21 -49
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -18
- package/dist/lib/application/application.factory.js +0 -63
- package/dist/lib/class/class.factory.js +0 -51
- package/dist/lib/configuration/configuration.factory.js +0 -27
- package/dist/lib/controller/controller.factory.js +0 -72
- package/dist/lib/decorator/decorator.factory.js +0 -35
- package/dist/lib/defaults.js +0 -17
- package/dist/lib/filter/filter.factory.js +0 -43
- package/dist/lib/gateway/gateway.factory.js +0 -72
- package/dist/lib/guard/guard.factory.js +0 -43
- package/dist/lib/interceptor/interceptor.factory.js +0 -44
- package/dist/lib/interface/interface.factory.js +0 -34
- package/dist/lib/middleware/middleware.factory.js +0 -43
- package/dist/lib/module/module.factory.js +0 -60
- package/dist/lib/pipe/pipe.factory.js +0 -44
- package/dist/lib/provider/provider.factory.js +0 -76
- package/dist/lib/readers/index.d.ts +0 -2
- package/dist/lib/readers/index.js +0 -18
- package/dist/lib/readers/reader.js +0 -2
- package/dist/lib/resolver/resolver.factory.js +0 -71
- package/dist/lib/service/service.factory.js +0 -74
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -27
- package/dist/utils/jest-module-mapper.js +0 -9
- package/dist/utils/module-metadata.declarator.js +0 -12
- package/dist/utils/module.declarator.js +0 -34
- package/dist/utils/name.parser.js +0 -17
- package/dist/utils/path.solver.js +0 -12
- package/dist/utils/source-root.helpers.js +0 -24
- /package/dist/{lib → src/lib}/defaults.d.ts +0 -0
- /package/dist/{lib → src/lib}/readers/reader.d.ts +0 -0
- /package/dist/{utils → src/utils}/dependencies.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/formatting.d.ts +0 -0
- /package/dist/{utils → src/utils}/jest-module-mapper.d.ts +0 -0
- /package/dist/{utils → src/utils}/json-file.util.d.ts +0 -0
- /package/dist/{utils → src/utils}/module.finder.d.ts +0 -0
- /package/dist/{utils → src/utils}/name.parser.d.ts +0 -0
- /package/dist/{utils → src/utils}/object-sorting.d.ts +0 -0
- /package/dist/{utils → src/utils}/path.solver.d.ts +0 -0
- /package/dist/{utils → src/utils}/source-root.helpers.d.ts +0 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.JSONFile = void 0;
|
|
4
|
-
const jsonc_parser_1 = require("jsonc-parser");
|
|
5
|
-
class JSONFile {
|
|
1
|
+
import { applyEdits, findNodeAtLocation, getNodeValue, modify, parseTree, printParseErrorCode, } from 'jsonc-parser';
|
|
2
|
+
export class JSONFile {
|
|
6
3
|
host;
|
|
7
4
|
path;
|
|
8
5
|
content;
|
|
@@ -23,12 +20,12 @@ class JSONFile {
|
|
|
23
20
|
return this._jsonAst;
|
|
24
21
|
}
|
|
25
22
|
const errors = [];
|
|
26
|
-
this._jsonAst =
|
|
23
|
+
this._jsonAst = parseTree(this.content, errors, {
|
|
27
24
|
allowTrailingComma: true,
|
|
28
25
|
});
|
|
29
26
|
if (errors.length) {
|
|
30
27
|
const { error, offset } = errors[0];
|
|
31
|
-
throw new Error(`Failed to parse "${this.path}" as JSON AST Object. ${
|
|
28
|
+
throw new Error(`Failed to parse "${this.path}" as JSON AST Object. ${printParseErrorCode(error)} at location: ${offset}.`);
|
|
32
29
|
}
|
|
33
30
|
return this._jsonAst;
|
|
34
31
|
}
|
|
@@ -38,10 +35,10 @@ class JSONFile {
|
|
|
38
35
|
return undefined;
|
|
39
36
|
}
|
|
40
37
|
if (jsonPath.length === 0) {
|
|
41
|
-
return
|
|
38
|
+
return getNodeValue(jsonAstNode);
|
|
42
39
|
}
|
|
43
|
-
const node =
|
|
44
|
-
return node === undefined ? undefined :
|
|
40
|
+
const node = findNodeAtLocation(jsonAstNode, jsonPath);
|
|
41
|
+
return node === undefined ? undefined : getNodeValue(node);
|
|
45
42
|
}
|
|
46
43
|
modify(jsonPath, value, insertInOrder) {
|
|
47
44
|
let getInsertionIndex;
|
|
@@ -52,14 +49,14 @@ class JSONFile {
|
|
|
52
49
|
else if (insertInOrder !== false) {
|
|
53
50
|
getInsertionIndex = insertInOrder;
|
|
54
51
|
}
|
|
55
|
-
const edits =
|
|
52
|
+
const edits = modify(this.content, jsonPath, value, {
|
|
56
53
|
getInsertionIndex,
|
|
57
54
|
formattingOptions: {
|
|
58
55
|
insertSpaces: true,
|
|
59
56
|
tabSize: 2,
|
|
60
57
|
},
|
|
61
58
|
});
|
|
62
|
-
this.content =
|
|
59
|
+
this.content = applyEdits(this.content, edits);
|
|
63
60
|
this.host.overwrite(this.path, this.content);
|
|
64
61
|
this._jsonAst = undefined;
|
|
65
62
|
}
|
|
@@ -69,4 +66,3 @@ class JSONFile {
|
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
|
-
exports.JSONFile = JSONFile;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MetadataManager = void 0;
|
|
4
|
-
const typescript_1 = require("typescript");
|
|
5
|
-
class MetadataManager {
|
|
1
|
+
import { createSourceFile, ScriptTarget, SyntaxKind, } from 'typescript';
|
|
2
|
+
export class MetadataManager {
|
|
6
3
|
content;
|
|
7
4
|
constructor(content) {
|
|
8
5
|
this.content = content;
|
|
9
6
|
}
|
|
10
7
|
insert(metadata, symbol, staticOptions) {
|
|
11
|
-
const source =
|
|
8
|
+
const source = createSourceFile('filename.ts', this.content, ScriptTarget.ES2017);
|
|
12
9
|
const moduleDecoratorNode = this.findFirstDecoratorMetadata(source, 'Module');
|
|
13
10
|
if (!moduleDecoratorNode) {
|
|
14
11
|
return;
|
|
15
12
|
}
|
|
16
13
|
const matchingProperties = moduleDecoratorNode.properties
|
|
17
|
-
.filter((prop) => prop.kind ===
|
|
14
|
+
.filter((prop) => prop.kind === SyntaxKind.PropertyAssignment)
|
|
18
15
|
.filter((prop) => {
|
|
19
16
|
const name = prop.name;
|
|
20
17
|
switch (name.kind) {
|
|
21
|
-
case
|
|
18
|
+
case SyntaxKind.Identifier:
|
|
22
19
|
return name.getText(source) === metadata;
|
|
23
|
-
case
|
|
20
|
+
case SyntaxKind.StringLiteral:
|
|
24
21
|
return name.text === metadata;
|
|
25
22
|
default:
|
|
26
23
|
return false;
|
|
@@ -47,15 +44,15 @@ class MetadataManager {
|
|
|
47
44
|
}
|
|
48
45
|
findFirstDecoratorMetadata(source, identifier) {
|
|
49
46
|
for (const node of this.getSourceNodes(source)) {
|
|
50
|
-
const isDecoratorFactoryNode = node.kind ===
|
|
51
|
-
node.expression.kind ===
|
|
47
|
+
const isDecoratorFactoryNode = node.kind === SyntaxKind.Decorator &&
|
|
48
|
+
node.expression.kind === SyntaxKind.CallExpression;
|
|
52
49
|
if (!isDecoratorFactoryNode)
|
|
53
50
|
continue;
|
|
54
51
|
const expr = node.expression;
|
|
55
|
-
const isExpectedExpression = expr.arguments[0]?.kind ===
|
|
52
|
+
const isExpectedExpression = expr.arguments[0]?.kind === SyntaxKind.ObjectLiteralExpression;
|
|
56
53
|
if (!isExpectedExpression)
|
|
57
54
|
continue;
|
|
58
|
-
if (expr.expression.kind ===
|
|
55
|
+
if (expr.expression.kind === SyntaxKind.Identifier) {
|
|
59
56
|
const escapedText = expr.expression.escapedText;
|
|
60
57
|
const isTargetIdentifier = escapedText
|
|
61
58
|
? escapedText.toLowerCase() === identifier.toLowerCase()
|
|
@@ -136,7 +133,7 @@ class MetadataManager {
|
|
|
136
133
|
}
|
|
137
134
|
let toInsert;
|
|
138
135
|
let position = node.getEnd();
|
|
139
|
-
if (node.kind ===
|
|
136
|
+
if (node.kind === SyntaxKind.ArrayLiteralExpression) {
|
|
140
137
|
position--;
|
|
141
138
|
toInsert = staticOptions ? this.addBlankLines(symbol) : `${symbol}`;
|
|
142
139
|
}
|
|
@@ -172,4 +169,3 @@ class MetadataManager {
|
|
|
172
169
|
return `\n ${expr}\n `;
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
|
-
exports.MetadataManager = MetadataManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeclarationOptions } from './module.declarator';
|
|
2
|
-
import { PathSolver } from './path.solver';
|
|
1
|
+
import { DeclarationOptions } from './module.declarator.js';
|
|
2
|
+
import { PathSolver } from './path.solver.js';
|
|
3
3
|
export declare class ModuleImportDeclarator {
|
|
4
4
|
private solver;
|
|
5
5
|
constructor(solver?: PathSolver);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const path_solver_1 = require("./path.solver");
|
|
6
|
-
class ModuleImportDeclarator {
|
|
1
|
+
import { normalize } from '@angular-devkit/core';
|
|
2
|
+
import { PathSolver } from './path.solver.js';
|
|
3
|
+
export class ModuleImportDeclarator {
|
|
7
4
|
solver;
|
|
8
|
-
constructor(solver = new
|
|
5
|
+
constructor(solver = new PathSolver()) {
|
|
9
6
|
this.solver = solver;
|
|
10
7
|
}
|
|
11
8
|
declare(content, options) {
|
|
@@ -29,12 +26,11 @@ class ModuleImportDeclarator {
|
|
|
29
26
|
computeRelativePath(options) {
|
|
30
27
|
let importModulePath;
|
|
31
28
|
if (options.type !== undefined) {
|
|
32
|
-
importModulePath =
|
|
29
|
+
importModulePath = normalize(`/${options.path}/${options.name}.${options.type}`);
|
|
33
30
|
}
|
|
34
31
|
else {
|
|
35
|
-
importModulePath =
|
|
32
|
+
importModulePath = normalize(`/${options.path}/${options.name}`);
|
|
36
33
|
}
|
|
37
34
|
return this.solver.relative(options.module, importModulePath);
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
|
-
exports.ModuleImportDeclarator = ModuleImportDeclarator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MetadataManager } from './metadata.manager.js';
|
|
2
|
+
export class ModuleMetadataDeclarator {
|
|
3
|
+
declare(content, options) {
|
|
4
|
+
const manager = new MetadataManager(content);
|
|
5
|
+
const inserted = manager.insert(options.metadata, options.symbol, options.staticOptions);
|
|
6
|
+
return inserted ?? content;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Path } from '@angular-devkit/core';
|
|
2
|
-
import { ModuleImportDeclarator } from './module-import.declarator';
|
|
3
|
-
import { ModuleMetadataDeclarator } from './module-metadata.declarator';
|
|
2
|
+
import { ModuleImportDeclarator } from './module-import.declarator.js';
|
|
3
|
+
import { ModuleMetadataDeclarator } from './module-metadata.declarator.js';
|
|
4
4
|
export interface DeclarationOptions {
|
|
5
5
|
metadata: string;
|
|
6
6
|
type?: string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { capitalize, classify } from '@angular-devkit/core/src/utils/strings';
|
|
2
|
+
import { ModuleImportDeclarator } from './module-import.declarator.js';
|
|
3
|
+
import { ModuleMetadataDeclarator } from './module-metadata.declarator.js';
|
|
4
|
+
export class ModuleDeclarator {
|
|
5
|
+
imports;
|
|
6
|
+
metadata;
|
|
7
|
+
constructor(imports = new ModuleImportDeclarator(), metadata = new ModuleMetadataDeclarator()) {
|
|
8
|
+
this.imports = imports;
|
|
9
|
+
this.metadata = metadata;
|
|
10
|
+
}
|
|
11
|
+
declare(content, options) {
|
|
12
|
+
options = this.computeSymbol(options);
|
|
13
|
+
content = this.imports.declare(content, options);
|
|
14
|
+
content = this.metadata.declare(content, options);
|
|
15
|
+
return content;
|
|
16
|
+
}
|
|
17
|
+
computeSymbol(options) {
|
|
18
|
+
const target = Object.assign({}, options);
|
|
19
|
+
if (options.className) {
|
|
20
|
+
target.symbol = options.className;
|
|
21
|
+
}
|
|
22
|
+
else if (options.type !== undefined) {
|
|
23
|
+
target.symbol = classify(options.name).concat(capitalize(options.type));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
target.symbol = classify(options.name);
|
|
27
|
+
}
|
|
28
|
+
return target;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ModuleFinder = void 0;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
class ModuleFinder {
|
|
1
|
+
import { join } from '@angular-devkit/core';
|
|
2
|
+
export class ModuleFinder {
|
|
6
3
|
tree;
|
|
7
4
|
constructor(tree) {
|
|
8
5
|
this.tree = tree;
|
|
@@ -18,8 +15,7 @@ class ModuleFinder {
|
|
|
18
15
|
}
|
|
19
16
|
const moduleFilename = directory.subfiles.find((filename) => /\.module\.(t|j)s$/.test(filename));
|
|
20
17
|
return moduleFilename !== undefined
|
|
21
|
-
?
|
|
18
|
+
? join(directory.path, moduleFilename.valueOf())
|
|
22
19
|
: this.findIn(directory.parent);
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.ModuleFinder = ModuleFinder;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { basename, dirname, normalize } from '@angular-devkit/core';
|
|
2
|
+
export class NameParser {
|
|
3
|
+
parse(options) {
|
|
4
|
+
const nameWithoutPath = basename(options.name);
|
|
5
|
+
const namePath = dirname((options.path === undefined ? '' : options.path)
|
|
6
|
+
.concat('/')
|
|
7
|
+
.concat(options.name));
|
|
8
|
+
return {
|
|
9
|
+
name: nameWithoutPath,
|
|
10
|
+
path: normalize('/'.concat(namePath)),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inPlaceSortByKeys = inPlaceSortByKeys;
|
|
4
|
-
function inPlaceSortByKeys(object) {
|
|
1
|
+
export function inPlaceSortByKeys(object) {
|
|
5
2
|
const sorted = {};
|
|
6
3
|
const keys = Object.keys(object);
|
|
7
4
|
keys.sort();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { basename, dirname, relative } from '@angular-devkit/core';
|
|
2
|
+
export class PathSolver {
|
|
3
|
+
relative(from, to) {
|
|
4
|
+
const placeholder = '/placeholder';
|
|
5
|
+
const relativeDir = relative(dirname((placeholder + from)), dirname((placeholder + to)));
|
|
6
|
+
return (relativeDir.startsWith('.') ? relativeDir : './' + relativeDir).concat(relativeDir.length === 0 ? basename(to) : '/' + basename(to));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { join, normalize } from '@angular-devkit/core';
|
|
2
|
+
import { DEFAULT_PATH_NAME } from '../lib/defaults.js';
|
|
3
|
+
export function isInRootDirectory(host, extraFiles = []) {
|
|
4
|
+
const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
|
|
5
|
+
return files.map((file) => host.exists(file)).some((isPresent) => isPresent);
|
|
6
|
+
}
|
|
7
|
+
export function mergeSourceRoot(options) {
|
|
8
|
+
return (host) => {
|
|
9
|
+
const isInRoot = isInRootDirectory(host, ['tsconfig.json', 'package.json']);
|
|
10
|
+
if (!isInRoot) {
|
|
11
|
+
return host;
|
|
12
|
+
}
|
|
13
|
+
const defaultSourceRoot = options.sourceRoot !== undefined ? options.sourceRoot : DEFAULT_PATH_NAME;
|
|
14
|
+
options.path =
|
|
15
|
+
options.path !== undefined
|
|
16
|
+
? join(normalize(defaultSourceRoot), options.path)
|
|
17
|
+
: normalize(defaultSourceRoot);
|
|
18
|
+
return host;
|
|
19
|
+
};
|
|
20
|
+
}
|