@abp/ng.schematics 5.0.1 → 5.0.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.
Files changed (141) hide show
  1. package/README.md +3 -3
  2. package/collection.json +29 -29
  3. package/commands/api/files-enum/proxy/__namespace@dir__/__name@kebab__.enum.ts.template +8 -8
  4. package/commands/api/files-model/proxy/__namespace@dir__/models.ts.template +9 -9
  5. package/commands/api/files-service/proxy/__namespace@dir__/__name@kebab__.service.ts.template +25 -25
  6. package/commands/api/index.d.ts +2 -2
  7. package/commands/api/index.js +112 -112
  8. package/commands/api/schema.json +45 -45
  9. package/commands/proxy-add/index.d.ts +2 -2
  10. package/commands/proxy-add/index.js +41 -41
  11. package/commands/proxy-add/schema.json +45 -45
  12. package/commands/proxy-index/index.d.ts +4 -4
  13. package/commands/proxy-index/index.js +14 -14
  14. package/commands/proxy-index/schema.json +18 -18
  15. package/commands/proxy-refresh/index.d.ts +3 -3
  16. package/commands/proxy-refresh/index.js +27 -27
  17. package/commands/proxy-refresh/schema.json +45 -45
  18. package/commands/proxy-remove/index.d.ts +3 -3
  19. package/commands/proxy-remove/index.js +33 -33
  20. package/commands/proxy-remove/schema.json +45 -45
  21. package/constants/api.d.ts +1 -1
  22. package/constants/api.js +4 -4
  23. package/constants/index.d.ts +4 -4
  24. package/constants/index.js +16 -16
  25. package/constants/proxy.d.ts +4 -4
  26. package/constants/proxy.js +24 -24
  27. package/constants/system-types.d.ts +1 -1
  28. package/constants/system-types.js +27 -27
  29. package/constants/volo.d.ts +1 -1
  30. package/constants/volo.js +4 -4
  31. package/enums/binding-source-id.d.ts +6 -6
  32. package/enums/binding-source-id.js +10 -10
  33. package/enums/exception.d.ts +16 -16
  34. package/enums/exception.js +2 -2
  35. package/enums/import-keyword.d.ts +4 -4
  36. package/enums/import-keyword.js +8 -8
  37. package/enums/index.d.ts +4 -4
  38. package/enums/index.js +16 -16
  39. package/enums/method-modifier.d.ts +6 -6
  40. package/enums/method-modifier.js +10 -10
  41. package/index.d.ts +1 -1
  42. package/index.js +2 -2
  43. package/models/api-definition.d.ts +72 -72
  44. package/models/api-definition.js +2 -2
  45. package/models/generate-proxy-schema.d.ts +18 -18
  46. package/models/generate-proxy-schema.js +2 -2
  47. package/models/import.d.ts +11 -11
  48. package/models/import.js +13 -13
  49. package/models/index.d.ts +10 -10
  50. package/models/index.js +22 -22
  51. package/models/method.d.ts +31 -31
  52. package/models/method.js +61 -61
  53. package/models/model.d.ts +48 -48
  54. package/models/model.js +71 -71
  55. package/models/project.d.ts +5 -5
  56. package/models/project.js +2 -2
  57. package/models/proxy-config.d.ts +4 -4
  58. package/models/proxy-config.js +2 -2
  59. package/models/service.d.ts +21 -21
  60. package/models/service.js +11 -11
  61. package/models/tree.d.ts +1 -1
  62. package/models/tree.js +2 -2
  63. package/models/util.d.ts +7 -7
  64. package/models/util.js +2 -2
  65. package/package.json +1 -1
  66. package/test-setup.d.ts +1 -1
  67. package/test-setup.js +3 -3
  68. package/utils/angular/ast-utils.d.ts +115 -115
  69. package/utils/angular/ast-utils.js +598 -598
  70. package/utils/angular/change.d.ts +66 -66
  71. package/utils/angular/change.js +96 -96
  72. package/utils/angular/config.d.ts +455 -455
  73. package/utils/angular/config.js +70 -70
  74. package/utils/angular/dependencies.d.ts +23 -23
  75. package/utils/angular/dependencies.js +58 -58
  76. package/utils/angular/find-module.d.ts +35 -35
  77. package/utils/angular/find-module.js +105 -105
  78. package/utils/angular/index.d.ts +17 -17
  79. package/utils/angular/index.js +29 -29
  80. package/utils/angular/json-file.d.ts +23 -23
  81. package/utils/angular/json-file.js +61 -61
  82. package/utils/angular/json-utils.d.ts +14 -14
  83. package/utils/angular/json-utils.js +158 -158
  84. package/utils/angular/latest-versions.d.ts +18 -18
  85. package/utils/angular/latest-versions.js +26 -26
  86. package/utils/angular/lint-fix.d.ts +9 -9
  87. package/utils/angular/lint-fix.js +41 -41
  88. package/utils/angular/ng-ast-utils.d.ts +5 -5
  89. package/utils/angular/ng-ast-utils.js +75 -75
  90. package/utils/angular/parse-name.d.ts +13 -13
  91. package/utils/angular/parse-name.js +21 -21
  92. package/utils/angular/paths.d.ts +8 -8
  93. package/utils/angular/paths.js +21 -21
  94. package/utils/angular/project-targets.d.ts +9 -9
  95. package/utils/angular/project-targets.js +15 -15
  96. package/utils/angular/tsconfig.d.ts +16 -16
  97. package/utils/angular/tsconfig.js +62 -62
  98. package/utils/angular/validation.d.ts +4 -4
  99. package/utils/angular/validation.js +73 -73
  100. package/utils/angular/workspace-models.d.ts +159 -159
  101. package/utils/angular/workspace-models.js +29 -29
  102. package/utils/angular/workspace.d.ts +18 -18
  103. package/utils/angular/workspace.js +75 -75
  104. package/utils/api.d.ts +2 -2
  105. package/utils/api.js +8 -8
  106. package/utils/ast.d.ts +4 -4
  107. package/utils/ast.js +23 -23
  108. package/utils/barrel.d.ts +4 -4
  109. package/utils/barrel.js +92 -92
  110. package/utils/common.d.ts +6 -6
  111. package/utils/common.js +33 -33
  112. package/utils/enum.d.ts +18 -18
  113. package/utils/enum.js +40 -40
  114. package/utils/file.d.ts +2 -2
  115. package/utils/file.js +9 -9
  116. package/utils/generics.d.ts +24 -24
  117. package/utils/generics.js +87 -87
  118. package/utils/import.d.ts +3 -3
  119. package/utils/import.js +11 -11
  120. package/utils/index.d.ts +19 -19
  121. package/utils/index.js +31 -31
  122. package/utils/model.d.ts +11 -11
  123. package/utils/model.js +141 -141
  124. package/utils/namespace.d.ts +1 -1
  125. package/utils/namespace.js +18 -18
  126. package/utils/path.d.ts +2 -2
  127. package/utils/path.js +36 -36
  128. package/utils/rule.d.ts +4 -4
  129. package/utils/rule.js +27 -27
  130. package/utils/service.d.ts +6 -6
  131. package/utils/service.js +82 -82
  132. package/utils/source.d.ts +13 -13
  133. package/utils/source.js +162 -162
  134. package/utils/text.d.ts +9 -9
  135. package/utils/text.js +46 -46
  136. package/utils/tree.d.ts +13 -13
  137. package/utils/tree.js +56 -56
  138. package/utils/type.d.ts +12 -12
  139. package/utils/type.js +102 -102
  140. package/utils/workspace.d.ts +8 -8
  141. package/utils/workspace.js +66 -66
@@ -1,71 +1,71 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAppFromConfig = exports.getConfig = exports.configPath = exports.updateWorkspaceSchema = exports.addProjectToWorkspace = exports.getWorkspaceSchema = exports.getWorkspacePath = void 0;
4
- /* eslint-disable @typescript-eslint/ban-types */
5
- /**
6
- * @license
7
- * Copyright Google Inc. All Rights Reserved.
8
- *
9
- * Use of this source code is governed by an MIT-style license that can be
10
- * found in the LICENSE file at https://angular.io/license
11
- */
12
- const core_1 = require("@angular-devkit/core");
13
- const schematics_1 = require("@angular-devkit/schematics");
14
- function getWorkspacePath(host) {
15
- const possibleFiles = ['/angular.json', '/.angular.json'];
16
- const path = possibleFiles.filter(path => host.exists(path))[0];
17
- return path;
18
- }
19
- exports.getWorkspacePath = getWorkspacePath;
20
- function getWorkspaceSchema(host) {
21
- const path = getWorkspacePath(host);
22
- const configBuffer = host.read(path);
23
- if (configBuffer === null) {
24
- throw new schematics_1.SchematicsException(`Could not find (${path})`);
25
- }
26
- const content = configBuffer.toString();
27
- return core_1.parseJson(content, core_1.JsonParseMode.Loose);
28
- }
29
- exports.getWorkspaceSchema = getWorkspaceSchema;
30
- function addProjectToWorkspace(workspace, name, project) {
31
- return (_host, _context) => {
32
- if (workspace.projects[name]) {
33
- throw new Error(`Project '${name}' already exists in workspace.`);
34
- }
35
- // Add project to workspace.
36
- workspace.projects[name] = project;
37
- if (!workspace.defaultProject && Object.keys(workspace.projects).length === 1) {
38
- // Make the new project the default one.
39
- workspace.defaultProject = name;
40
- }
41
- return updateWorkspaceSchema(workspace);
42
- };
43
- }
44
- exports.addProjectToWorkspace = addProjectToWorkspace;
45
- function updateWorkspaceSchema(workspace) {
46
- return (host, _context) => {
47
- host.overwrite(getWorkspacePath(host), JSON.stringify(workspace, null, 2));
48
- };
49
- }
50
- exports.updateWorkspaceSchema = updateWorkspaceSchema;
51
- exports.configPath = '/.angular-cli.json';
52
- function getConfig(host) {
53
- const configBuffer = host.read(exports.configPath);
54
- if (configBuffer === null) {
55
- throw new schematics_1.SchematicsException('Could not find .angular-cli.json');
56
- }
57
- const config = core_1.parseJson(configBuffer.toString(), core_1.JsonParseMode.Loose);
58
- return config;
59
- }
60
- exports.getConfig = getConfig;
61
- function getAppFromConfig(config, appIndexOrName) {
62
- if (!config.apps) {
63
- return null;
64
- }
65
- if (parseInt(appIndexOrName) >= 0) {
66
- return config.apps[parseInt(appIndexOrName)];
67
- }
68
- return config.apps.filter(app => app.name === appIndexOrName)[0];
69
- }
70
- exports.getAppFromConfig = getAppFromConfig;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAppFromConfig = exports.getConfig = exports.configPath = exports.updateWorkspaceSchema = exports.addProjectToWorkspace = exports.getWorkspaceSchema = exports.getWorkspacePath = void 0;
4
+ /* eslint-disable @typescript-eslint/ban-types */
5
+ /**
6
+ * @license
7
+ * Copyright Google Inc. All Rights Reserved.
8
+ *
9
+ * Use of this source code is governed by an MIT-style license that can be
10
+ * found in the LICENSE file at https://angular.io/license
11
+ */
12
+ const core_1 = require("@angular-devkit/core");
13
+ const schematics_1 = require("@angular-devkit/schematics");
14
+ function getWorkspacePath(host) {
15
+ const possibleFiles = ['/angular.json', '/.angular.json'];
16
+ const path = possibleFiles.filter(path => host.exists(path))[0];
17
+ return path;
18
+ }
19
+ exports.getWorkspacePath = getWorkspacePath;
20
+ function getWorkspaceSchema(host) {
21
+ const path = getWorkspacePath(host);
22
+ const configBuffer = host.read(path);
23
+ if (configBuffer === null) {
24
+ throw new schematics_1.SchematicsException(`Could not find (${path})`);
25
+ }
26
+ const content = configBuffer.toString();
27
+ return core_1.parseJson(content, core_1.JsonParseMode.Loose);
28
+ }
29
+ exports.getWorkspaceSchema = getWorkspaceSchema;
30
+ function addProjectToWorkspace(workspace, name, project) {
31
+ return (_host, _context) => {
32
+ if (workspace.projects[name]) {
33
+ throw new Error(`Project '${name}' already exists in workspace.`);
34
+ }
35
+ // Add project to workspace.
36
+ workspace.projects[name] = project;
37
+ if (!workspace.defaultProject && Object.keys(workspace.projects).length === 1) {
38
+ // Make the new project the default one.
39
+ workspace.defaultProject = name;
40
+ }
41
+ return updateWorkspaceSchema(workspace);
42
+ };
43
+ }
44
+ exports.addProjectToWorkspace = addProjectToWorkspace;
45
+ function updateWorkspaceSchema(workspace) {
46
+ return (host, _context) => {
47
+ host.overwrite(getWorkspacePath(host), JSON.stringify(workspace, null, 2));
48
+ };
49
+ }
50
+ exports.updateWorkspaceSchema = updateWorkspaceSchema;
51
+ exports.configPath = '/.angular-cli.json';
52
+ function getConfig(host) {
53
+ const configBuffer = host.read(exports.configPath);
54
+ if (configBuffer === null) {
55
+ throw new schematics_1.SchematicsException('Could not find .angular-cli.json');
56
+ }
57
+ const config = core_1.parseJson(configBuffer.toString(), core_1.JsonParseMode.Loose);
58
+ return config;
59
+ }
60
+ exports.getConfig = getConfig;
61
+ function getAppFromConfig(config, appIndexOrName) {
62
+ if (!config.apps) {
63
+ return null;
64
+ }
65
+ if (parseInt(appIndexOrName) >= 0) {
66
+ return config.apps[parseInt(appIndexOrName)];
67
+ }
68
+ return config.apps.filter(app => app.name === appIndexOrName)[0];
69
+ }
70
+ exports.getAppFromConfig = getAppFromConfig;
71
71
  //# sourceMappingURL=config.js.map
@@ -1,23 +1,23 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Tree } from '@angular-devkit/schematics';
9
- export declare enum NodeDependencyType {
10
- Default = "dependencies",
11
- Dev = "devDependencies",
12
- Peer = "peerDependencies",
13
- Optional = "optionalDependencies"
14
- }
15
- export interface NodeDependency {
16
- type: NodeDependencyType;
17
- name: string;
18
- version: string;
19
- overwrite?: boolean;
20
- }
21
- export declare function addPackageJsonDependency(tree: Tree, dependency: NodeDependency, pkgJsonPath?: string): void;
22
- export declare function removePackageJsonDependency(tree: Tree, name: string, pkgJsonPath?: string): void;
23
- export declare function getPackageJsonDependency(tree: Tree, name: string, pkgJsonPath?: string): NodeDependency | null;
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { Tree } from '@angular-devkit/schematics';
9
+ export declare enum NodeDependencyType {
10
+ Default = "dependencies",
11
+ Dev = "devDependencies",
12
+ Peer = "peerDependencies",
13
+ Optional = "optionalDependencies"
14
+ }
15
+ export interface NodeDependency {
16
+ type: NodeDependencyType;
17
+ name: string;
18
+ version: string;
19
+ overwrite?: boolean;
20
+ }
21
+ export declare function addPackageJsonDependency(tree: Tree, dependency: NodeDependency, pkgJsonPath?: string): void;
22
+ export declare function removePackageJsonDependency(tree: Tree, name: string, pkgJsonPath?: string): void;
23
+ export declare function getPackageJsonDependency(tree: Tree, name: string, pkgJsonPath?: string): NodeDependency | null;
@@ -1,59 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPackageJsonDependency = exports.removePackageJsonDependency = exports.addPackageJsonDependency = exports.NodeDependencyType = void 0;
4
- const json_file_1 = require("./json-file");
5
- const PKG_JSON_PATH = '/package.json';
6
- var NodeDependencyType;
7
- (function (NodeDependencyType) {
8
- NodeDependencyType["Default"] = "dependencies";
9
- NodeDependencyType["Dev"] = "devDependencies";
10
- NodeDependencyType["Peer"] = "peerDependencies";
11
- NodeDependencyType["Optional"] = "optionalDependencies";
12
- })(NodeDependencyType = exports.NodeDependencyType || (exports.NodeDependencyType = {}));
13
- const ALL_DEPENDENCY_TYPE = [
14
- NodeDependencyType.Default,
15
- NodeDependencyType.Dev,
16
- NodeDependencyType.Optional,
17
- NodeDependencyType.Peer,
18
- ];
19
- function addPackageJsonDependency(tree, dependency, pkgJsonPath = PKG_JSON_PATH) {
20
- const json = new json_file_1.JSONFile(tree, pkgJsonPath);
21
- if (json.error) {
22
- throw json.error;
23
- }
24
- const { overwrite, type, name, version } = dependency;
25
- const path = [type, name];
26
- if (overwrite || !json.get(path)) {
27
- json.modify(path, version);
28
- }
29
- }
30
- exports.addPackageJsonDependency = addPackageJsonDependency;
31
- function removePackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
32
- const json = new json_file_1.JSONFile(tree, pkgJsonPath);
33
- if (json.error) {
34
- throw json.error;
35
- }
36
- for (const depType of ALL_DEPENDENCY_TYPE) {
37
- json.remove([depType, name]);
38
- }
39
- }
40
- exports.removePackageJsonDependency = removePackageJsonDependency;
41
- function getPackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
42
- const json = new json_file_1.JSONFile(tree, pkgJsonPath);
43
- if (json.error) {
44
- throw json.error;
45
- }
46
- for (const depType of ALL_DEPENDENCY_TYPE) {
47
- const version = json.get([depType, name]);
48
- if (typeof version === 'string') {
49
- return {
50
- type: depType,
51
- name: name,
52
- version,
53
- };
54
- }
55
- }
56
- return null;
57
- }
58
- exports.getPackageJsonDependency = getPackageJsonDependency;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageJsonDependency = exports.removePackageJsonDependency = exports.addPackageJsonDependency = exports.NodeDependencyType = void 0;
4
+ const json_file_1 = require("./json-file");
5
+ const PKG_JSON_PATH = '/package.json';
6
+ var NodeDependencyType;
7
+ (function (NodeDependencyType) {
8
+ NodeDependencyType["Default"] = "dependencies";
9
+ NodeDependencyType["Dev"] = "devDependencies";
10
+ NodeDependencyType["Peer"] = "peerDependencies";
11
+ NodeDependencyType["Optional"] = "optionalDependencies";
12
+ })(NodeDependencyType = exports.NodeDependencyType || (exports.NodeDependencyType = {}));
13
+ const ALL_DEPENDENCY_TYPE = [
14
+ NodeDependencyType.Default,
15
+ NodeDependencyType.Dev,
16
+ NodeDependencyType.Optional,
17
+ NodeDependencyType.Peer,
18
+ ];
19
+ function addPackageJsonDependency(tree, dependency, pkgJsonPath = PKG_JSON_PATH) {
20
+ const json = new json_file_1.JSONFile(tree, pkgJsonPath);
21
+ if (json.error) {
22
+ throw json.error;
23
+ }
24
+ const { overwrite, type, name, version } = dependency;
25
+ const path = [type, name];
26
+ if (overwrite || !json.get(path)) {
27
+ json.modify(path, version);
28
+ }
29
+ }
30
+ exports.addPackageJsonDependency = addPackageJsonDependency;
31
+ function removePackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
32
+ const json = new json_file_1.JSONFile(tree, pkgJsonPath);
33
+ if (json.error) {
34
+ throw json.error;
35
+ }
36
+ for (const depType of ALL_DEPENDENCY_TYPE) {
37
+ json.remove([depType, name]);
38
+ }
39
+ }
40
+ exports.removePackageJsonDependency = removePackageJsonDependency;
41
+ function getPackageJsonDependency(tree, name, pkgJsonPath = PKG_JSON_PATH) {
42
+ const json = new json_file_1.JSONFile(tree, pkgJsonPath);
43
+ if (json.error) {
44
+ throw json.error;
45
+ }
46
+ for (const depType of ALL_DEPENDENCY_TYPE) {
47
+ const version = json.get([depType, name]);
48
+ if (typeof version === 'string') {
49
+ return {
50
+ type: depType,
51
+ name: name,
52
+ version,
53
+ };
54
+ }
55
+ }
56
+ return null;
57
+ }
58
+ exports.getPackageJsonDependency = getPackageJsonDependency;
59
59
  //# sourceMappingURL=dependencies.js.map
@@ -1,35 +1,35 @@
1
- /**
2
- * @license
3
- * Copyright Google Inc. All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import { Path } from '@angular-devkit/core';
9
- import { Tree } from '@angular-devkit/schematics';
10
- export interface ModuleOptions {
11
- project?: string;
12
- module?: string;
13
- name: string;
14
- flat?: boolean;
15
- path?: string;
16
- route?: string;
17
- selector?: string;
18
- skipImport?: boolean;
19
- moduleExt?: string;
20
- routingModuleExt?: string;
21
- }
22
- export declare const MODULE_EXT = ".module.ts";
23
- export declare const ROUTING_MODULE_EXT = "-routing.module.ts";
24
- /**
25
- * Find the module referred by a set of options passed to the schematics.
26
- */
27
- export declare function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined;
28
- /**
29
- * Function to find the "closest" module to a generated file's path.
30
- */
31
- export declare function findModule(host: Tree, generateDir: string, moduleExt?: string, routingModuleExt?: string): Path;
32
- /**
33
- * Build a relative path from one file path to another file path.
34
- */
35
- export declare function buildRelativePath(from: string, to: string): string;
1
+ /**
2
+ * @license
3
+ * Copyright Google Inc. All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.io/license
7
+ */
8
+ import { Path } from '@angular-devkit/core';
9
+ import { Tree } from '@angular-devkit/schematics';
10
+ export interface ModuleOptions {
11
+ project?: string;
12
+ module?: string;
13
+ name: string;
14
+ flat?: boolean;
15
+ path?: string;
16
+ route?: string;
17
+ selector?: string;
18
+ skipImport?: boolean;
19
+ moduleExt?: string;
20
+ routingModuleExt?: string;
21
+ }
22
+ export declare const MODULE_EXT = ".module.ts";
23
+ export declare const ROUTING_MODULE_EXT = "-routing.module.ts";
24
+ /**
25
+ * Find the module referred by a set of options passed to the schematics.
26
+ */
27
+ export declare function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined;
28
+ /**
29
+ * Function to find the "closest" module to a generated file's path.
30
+ */
31
+ export declare function findModule(host: Tree, generateDir: string, moduleExt?: string, routingModuleExt?: string): Path;
32
+ /**
33
+ * Build a relative path from one file path to another file path.
34
+ */
35
+ export declare function buildRelativePath(from: string, to: string): string;
@@ -1,106 +1,106 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildRelativePath = exports.findModule = exports.findModuleFromOptions = exports.ROUTING_MODULE_EXT = exports.MODULE_EXT = void 0;
4
- /**
5
- * @license
6
- * Copyright Google Inc. All Rights Reserved.
7
- *
8
- * Use of this source code is governed by an MIT-style license that can be
9
- * found in the LICENSE file at https://angular.io/license
10
- */
11
- const core_1 = require("@angular-devkit/core");
12
- exports.MODULE_EXT = '.module.ts';
13
- exports.ROUTING_MODULE_EXT = '-routing.module.ts';
14
- /**
15
- * Find the module referred by a set of options passed to the schematics.
16
- */
17
- function findModuleFromOptions(host, options) {
18
- if (Object.prototype.hasOwnProperty.call(options, 'skipImport') && options.skipImport) {
19
- return undefined;
20
- }
21
- const moduleExt = options.moduleExt || exports.MODULE_EXT;
22
- const routingModuleExt = options.routingModuleExt || exports.ROUTING_MODULE_EXT;
23
- if (!options.module) {
24
- const pathToCheck = (options.path || '') + '/' + options.name;
25
- return core_1.normalize(findModule(host, pathToCheck, moduleExt, routingModuleExt));
26
- }
27
- else {
28
- const modulePath = core_1.normalize(`/${options.path}/${options.module}`);
29
- const componentPath = core_1.normalize(`/${options.path}/${options.name}`);
30
- const moduleBaseName = core_1.normalize(modulePath).split('/').pop();
31
- const candidateSet = new Set([core_1.normalize(options.path || '/')]);
32
- for (let dir = modulePath; dir != core_1.NormalizedRoot; dir = core_1.dirname(dir)) {
33
- candidateSet.add(dir);
34
- }
35
- for (let dir = componentPath; dir != core_1.NormalizedRoot; dir = core_1.dirname(dir)) {
36
- candidateSet.add(dir);
37
- }
38
- const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
39
- for (const c of candidatesDirs) {
40
- const candidateFiles = ['', `${moduleBaseName}.ts`, `${moduleBaseName}${moduleExt}`].map(x => core_1.join(c, x));
41
- for (const sc of candidateFiles) {
42
- if (host.exists(sc)) {
43
- return core_1.normalize(sc);
44
- }
45
- }
46
- }
47
- throw new Error(`Specified module '${options.module}' does not exist.\n` +
48
- `Looked in the following directories:\n ${candidatesDirs.join('\n ')}`);
49
- }
50
- }
51
- exports.findModuleFromOptions = findModuleFromOptions;
52
- /**
53
- * Function to find the "closest" module to a generated file's path.
54
- */
55
- function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingModuleExt = exports.ROUTING_MODULE_EXT) {
56
- let dir = host.getDir('/' + generateDir);
57
- let foundRoutingModule = false;
58
- while (dir) {
59
- const allMatches = dir.subfiles.filter(p => p.endsWith(moduleExt));
60
- const filteredMatches = allMatches.filter(p => !p.endsWith(routingModuleExt));
61
- foundRoutingModule = foundRoutingModule || allMatches.length !== filteredMatches.length;
62
- if (filteredMatches.length == 1) {
63
- return core_1.join(dir.path, filteredMatches[0]);
64
- }
65
- else if (filteredMatches.length > 1) {
66
- throw new Error('More than one module matches. Use the skip-import option to skip importing ' +
67
- 'the component into the closest module or use the module option to specify a module.');
68
- }
69
- dir = dir.parent;
70
- }
71
- const errorMsg = foundRoutingModule
72
- ? 'Could not find a non Routing NgModule.' +
73
- `\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
74
- '\nUse the skip-import option to skip importing in NgModule.'
75
- : 'Could not find an NgModule. Use the skip-import option to skip importing in NgModule.';
76
- throw new Error(errorMsg);
77
- }
78
- exports.findModule = findModule;
79
- /**
80
- * Build a relative path from one file path to another file path.
81
- */
82
- function buildRelativePath(from, to) {
83
- from = core_1.normalize(from);
84
- to = core_1.normalize(to);
85
- // Convert to arrays.
86
- const fromParts = from.split('/');
87
- const toParts = to.split('/');
88
- // Remove file names (preserving destination)
89
- fromParts.pop();
90
- const toFileName = toParts.pop();
91
- const relativePath = core_1.relative(core_1.normalize(fromParts.join('/') || '/'), core_1.normalize(toParts.join('/') || '/'));
92
- let pathPrefix = '';
93
- // Set the path prefix for same dir or child dir, parent dir starts with `..`
94
- if (!relativePath) {
95
- pathPrefix = '.';
96
- }
97
- else if (!relativePath.startsWith('.')) {
98
- pathPrefix = `./`;
99
- }
100
- if (pathPrefix && !pathPrefix.endsWith('/')) {
101
- pathPrefix += '/';
102
- }
103
- return pathPrefix + (relativePath ? relativePath + '/' : '') + toFileName;
104
- }
105
- exports.buildRelativePath = buildRelativePath;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildRelativePath = exports.findModule = exports.findModuleFromOptions = exports.ROUTING_MODULE_EXT = exports.MODULE_EXT = void 0;
4
+ /**
5
+ * @license
6
+ * Copyright Google Inc. All Rights Reserved.
7
+ *
8
+ * Use of this source code is governed by an MIT-style license that can be
9
+ * found in the LICENSE file at https://angular.io/license
10
+ */
11
+ const core_1 = require("@angular-devkit/core");
12
+ exports.MODULE_EXT = '.module.ts';
13
+ exports.ROUTING_MODULE_EXT = '-routing.module.ts';
14
+ /**
15
+ * Find the module referred by a set of options passed to the schematics.
16
+ */
17
+ function findModuleFromOptions(host, options) {
18
+ if (Object.prototype.hasOwnProperty.call(options, 'skipImport') && options.skipImport) {
19
+ return undefined;
20
+ }
21
+ const moduleExt = options.moduleExt || exports.MODULE_EXT;
22
+ const routingModuleExt = options.routingModuleExt || exports.ROUTING_MODULE_EXT;
23
+ if (!options.module) {
24
+ const pathToCheck = (options.path || '') + '/' + options.name;
25
+ return core_1.normalize(findModule(host, pathToCheck, moduleExt, routingModuleExt));
26
+ }
27
+ else {
28
+ const modulePath = core_1.normalize(`/${options.path}/${options.module}`);
29
+ const componentPath = core_1.normalize(`/${options.path}/${options.name}`);
30
+ const moduleBaseName = core_1.normalize(modulePath).split('/').pop();
31
+ const candidateSet = new Set([core_1.normalize(options.path || '/')]);
32
+ for (let dir = modulePath; dir != core_1.NormalizedRoot; dir = core_1.dirname(dir)) {
33
+ candidateSet.add(dir);
34
+ }
35
+ for (let dir = componentPath; dir != core_1.NormalizedRoot; dir = core_1.dirname(dir)) {
36
+ candidateSet.add(dir);
37
+ }
38
+ const candidatesDirs = [...candidateSet].sort((a, b) => b.length - a.length);
39
+ for (const c of candidatesDirs) {
40
+ const candidateFiles = ['', `${moduleBaseName}.ts`, `${moduleBaseName}${moduleExt}`].map(x => core_1.join(c, x));
41
+ for (const sc of candidateFiles) {
42
+ if (host.exists(sc)) {
43
+ return core_1.normalize(sc);
44
+ }
45
+ }
46
+ }
47
+ throw new Error(`Specified module '${options.module}' does not exist.\n` +
48
+ `Looked in the following directories:\n ${candidatesDirs.join('\n ')}`);
49
+ }
50
+ }
51
+ exports.findModuleFromOptions = findModuleFromOptions;
52
+ /**
53
+ * Function to find the "closest" module to a generated file's path.
54
+ */
55
+ function findModule(host, generateDir, moduleExt = exports.MODULE_EXT, routingModuleExt = exports.ROUTING_MODULE_EXT) {
56
+ let dir = host.getDir('/' + generateDir);
57
+ let foundRoutingModule = false;
58
+ while (dir) {
59
+ const allMatches = dir.subfiles.filter(p => p.endsWith(moduleExt));
60
+ const filteredMatches = allMatches.filter(p => !p.endsWith(routingModuleExt));
61
+ foundRoutingModule = foundRoutingModule || allMatches.length !== filteredMatches.length;
62
+ if (filteredMatches.length == 1) {
63
+ return core_1.join(dir.path, filteredMatches[0]);
64
+ }
65
+ else if (filteredMatches.length > 1) {
66
+ throw new Error('More than one module matches. Use the skip-import option to skip importing ' +
67
+ 'the component into the closest module or use the module option to specify a module.');
68
+ }
69
+ dir = dir.parent;
70
+ }
71
+ const errorMsg = foundRoutingModule
72
+ ? 'Could not find a non Routing NgModule.' +
73
+ `\nModules with suffix '${routingModuleExt}' are strictly reserved for routing.` +
74
+ '\nUse the skip-import option to skip importing in NgModule.'
75
+ : 'Could not find an NgModule. Use the skip-import option to skip importing in NgModule.';
76
+ throw new Error(errorMsg);
77
+ }
78
+ exports.findModule = findModule;
79
+ /**
80
+ * Build a relative path from one file path to another file path.
81
+ */
82
+ function buildRelativePath(from, to) {
83
+ from = core_1.normalize(from);
84
+ to = core_1.normalize(to);
85
+ // Convert to arrays.
86
+ const fromParts = from.split('/');
87
+ const toParts = to.split('/');
88
+ // Remove file names (preserving destination)
89
+ fromParts.pop();
90
+ const toFileName = toParts.pop();
91
+ const relativePath = core_1.relative(core_1.normalize(fromParts.join('/') || '/'), core_1.normalize(toParts.join('/') || '/'));
92
+ let pathPrefix = '';
93
+ // Set the path prefix for same dir or child dir, parent dir starts with `..`
94
+ if (!relativePath) {
95
+ pathPrefix = '.';
96
+ }
97
+ else if (!relativePath.startsWith('.')) {
98
+ pathPrefix = `./`;
99
+ }
100
+ if (pathPrefix && !pathPrefix.endsWith('/')) {
101
+ pathPrefix += '/';
102
+ }
103
+ return pathPrefix + (relativePath ? relativePath + '/' : '') + toFileName;
104
+ }
105
+ exports.buildRelativePath = buildRelativePath;
106
106
  //# sourceMappingURL=find-module.js.map
@@ -1,17 +1,17 @@
1
- export * from './ast-utils';
2
- export * from './change';
3
- export * from './config';
4
- export * from './dependencies';
5
- export * from './find-module';
6
- export * from './json-file';
7
- export * from './json-utils';
8
- export * from './latest-versions';
9
- export * from './lint-fix';
10
- export * from './ng-ast-utils';
11
- export * from './parse-name';
12
- export * from './paths';
13
- export * from './project-targets';
14
- export * from './tsconfig';
15
- export * from './validation';
16
- export * from './workspace';
17
- export * from './workspace-models';
1
+ export * from './ast-utils';
2
+ export * from './change';
3
+ export * from './config';
4
+ export * from './dependencies';
5
+ export * from './find-module';
6
+ export * from './json-file';
7
+ export * from './json-utils';
8
+ export * from './latest-versions';
9
+ export * from './lint-fix';
10
+ export * from './ng-ast-utils';
11
+ export * from './parse-name';
12
+ export * from './paths';
13
+ export * from './project-targets';
14
+ export * from './tsconfig';
15
+ export * from './validation';
16
+ export * from './workspace';
17
+ export * from './workspace-models';