@o3r/schematics 9.3.0-alpha.7 → 9.3.0-alpha.70
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 +23 -18
- package/src/cli/environment.d.ts +2 -0
- package/src/cli/environment.d.ts.map +1 -0
- package/src/cli/environment.js +5 -0
- package/src/cli/environment.js.map +1 -0
- package/src/interfaces/angular-workspace.d.ts +16 -14
- package/src/interfaces/angular-workspace.d.ts.map +1 -1
- package/src/modules/modules.constants.d.ts +6 -2
- package/src/modules/modules.constants.d.ts.map +1 -1
- package/src/modules/modules.constants.js +5 -3
- package/src/modules/modules.constants.js.map +1 -1
- package/src/rule-factories/check-packages-peers/index.d.ts.map +1 -1
- package/src/rule-factories/check-packages-peers/index.js +4 -4
- package/src/rule-factories/check-packages-peers/index.js.map +1 -1
- package/src/rule-factories/dev-tools/devtools-registration.d.ts +20 -0
- package/src/rule-factories/dev-tools/devtools-registration.d.ts.map +1 -0
- package/src/rule-factories/dev-tools/devtools-registration.js +50 -0
- package/src/rule-factories/dev-tools/devtools-registration.js.map +1 -0
- package/src/rule-factories/dev-tools/index.d.ts +2 -0
- package/src/rule-factories/dev-tools/index.d.ts.map +1 -0
- package/src/rule-factories/dev-tools/index.js +5 -0
- package/src/rule-factories/dev-tools/index.js.map +1 -0
- package/src/rule-factories/index.d.ts +1 -0
- package/src/rule-factories/index.d.ts.map +1 -1
- package/src/rule-factories/index.js +1 -0
- package/src/rule-factories/index.js.map +1 -1
- package/src/rule-factories/ng-add/index.d.ts +3 -6
- package/src/rule-factories/ng-add/index.d.ts.map +1 -1
- package/src/rule-factories/ng-add/index.js +107 -83
- package/src/rule-factories/ng-add/index.js.map +1 -1
- package/src/utility/collection.d.ts +2 -5
- package/src/utility/collection.d.ts.map +1 -1
- package/src/utility/collection.js +11 -9
- package/src/utility/collection.js.map +1 -1
- package/src/utility/component.d.ts.map +1 -1
- package/src/utility/component.js +4 -3
- package/src/utility/component.js.map +1 -1
- package/src/utility/environment.d.ts +27 -0
- package/src/utility/environment.d.ts.map +1 -0
- package/src/utility/environment.js +51 -0
- package/src/utility/environment.js.map +1 -0
- package/src/utility/error.d.ts +7 -0
- package/src/utility/error.d.ts.map +1 -0
- package/src/utility/error.js +17 -0
- package/src/utility/error.js.map +1 -0
- package/src/utility/generation.d.ts +0 -1
- package/src/utility/generation.d.ts.map +1 -1
- package/src/utility/generation.js +7 -11
- package/src/utility/generation.js.map +1 -1
- package/src/utility/index.d.ts +9 -7
- package/src/utility/index.d.ts.map +1 -1
- package/src/utility/index.js +9 -7
- package/src/utility/index.js.map +1 -1
- package/src/utility/loaders.d.ts +19 -17
- package/src/utility/loaders.d.ts.map +1 -1
- package/src/utility/loaders.js +38 -18
- package/src/utility/loaders.js.map +1 -1
- package/src/utility/modules.d.ts +2 -7
- package/src/utility/modules.d.ts.map +1 -1
- package/src/utility/modules.js +5 -10
- package/src/utility/modules.js.map +1 -1
- package/src/utility/monorepo.d.ts +6 -0
- package/src/utility/monorepo.d.ts.map +1 -1
- package/src/utility/monorepo.js +12 -1
- package/src/utility/monorepo.js.map +1 -1
- package/src/utility/package-manager-runner.d.ts +16 -1
- package/src/utility/package-manager-runner.d.ts.map +1 -1
- package/src/utility/package-manager-runner.js +39 -1
- package/src/utility/package-manager-runner.js.map +1 -1
@@ -1,7 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getDestinationPath = exports.TYPES_DEFAULT_FOLDER = exports.OTTER_ITEM_TYPES = void 0;
|
4
|
+
const error_1 = require("./error");
|
4
5
|
const loaders_1 = require("./loaders");
|
6
|
+
const collection_1 = require("./collection");
|
5
7
|
/** List of Otter items types */
|
6
8
|
exports.OTTER_ITEM_TYPES = [
|
7
9
|
'@o3r/core:component',
|
@@ -31,7 +33,6 @@ exports.TYPES_DEFAULT_FOLDER = {
|
|
31
33
|
};
|
32
34
|
/**
|
33
35
|
* Get destination path for a generated item
|
34
|
-
*
|
35
36
|
* @param typeOfItem
|
36
37
|
* @param directory
|
37
38
|
* @param tree
|
@@ -41,27 +42,22 @@ function getDestinationPath(typeOfItem, directory, tree, project) {
|
|
41
42
|
if (directory) {
|
42
43
|
return directory;
|
43
44
|
}
|
44
|
-
/**
|
45
|
-
* @param workspace
|
46
|
-
* @param generatorName
|
47
|
-
*/
|
48
|
-
const getSchematicsPropertyFrom = (workspace, generatorName) => {
|
49
|
-
return workspace.schematics?.[generatorName] || null;
|
50
|
-
};
|
51
45
|
/**
|
52
46
|
* @param generatorName
|
53
47
|
* @param propTree
|
54
48
|
* @param propProject
|
55
49
|
*/
|
56
50
|
const getSchematicsProperty = (generatorName, propTree, propProject) => {
|
57
|
-
const
|
58
|
-
|
51
|
+
const workspace = (0, loaders_1.getWorkspaceConfig)(propTree);
|
52
|
+
const [collection, schematicName] = generatorName.split(':');
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
54
|
+
return workspace && (0, collection_1.getDefaultOptionsForSchematic)(workspace, collection, schematicName, { projectName: propProject || undefined }) || null;
|
59
55
|
};
|
60
56
|
const config = getSchematicsProperty(typeOfItem, tree, project);
|
61
57
|
if (config && config.path) {
|
62
58
|
return config.path;
|
63
59
|
}
|
64
|
-
throw new
|
60
|
+
throw new error_1.O3rCliError('No destination directory configured.');
|
65
61
|
}
|
66
62
|
exports.getDestinationPath = getDestinationPath;
|
67
63
|
//# sourceMappingURL=generation.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generation.js","sourceRoot":"","sources":["../../../src/utility/generation.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"generation.js","sourceRoot":"","sources":["../../../src/utility/generation.ts"],"names":[],"mappings":";;;AAEA,mCAAsC;AACtC,uCAA+C;AAC/C,6CAA6D;AAY7D,gCAAgC;AACnB,QAAA,gBAAgB,GAAwB;IACnD,qBAAqB;IACrB,gBAAgB;IAChB,mBAAmB;IACnB,iBA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,CAAC;IACrK,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,qBAAqB,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChE,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE;QACzB,OAAO,MAAM,CAAC,IAAc,CAAC;KAC9B;IAED,MAAM,IAAI,mBAAW,CAAC,sCAAsC,CAAC,CAAC;AAChE,CAAC;AAvBD,gDAuBC"}
|
package/src/utility/index.d.ts
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
export * from './ast';
|
2
|
+
export * from './collection';
|
2
3
|
export * from './component';
|
3
4
|
export * from './dependencies';
|
5
|
+
export * from './environment';
|
6
|
+
export * from './error';
|
4
7
|
export * from './file-info';
|
5
8
|
export * from './generation';
|
6
9
|
export * from './gitignore';
|
7
10
|
export * from './loaders';
|
8
|
-
export * from './
|
9
|
-
export * from './routes';
|
10
|
-
export * from './sub-entry';
|
11
|
-
export * from './template-property.helper';
|
11
|
+
export * from './logo';
|
12
12
|
export * from './matching-peers';
|
13
|
+
export * from './modules';
|
14
|
+
export * from './monorepo';
|
13
15
|
export * from './package-manager-runner';
|
14
16
|
export * from './package-version';
|
15
17
|
export * from './question';
|
16
|
-
export * from './
|
18
|
+
export * from './routes';
|
19
|
+
export * from './sub-entry';
|
20
|
+
export * from './template-property.helper';
|
17
21
|
export * from './update-imports';
|
18
|
-
export * from './collection';
|
19
|
-
export * from './logo';
|
20
22
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utility/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utility/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC"}
|
package/src/utility/index.js
CHANGED
@@ -2,22 +2,24 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
4
|
tslib_1.__exportStar(require("./ast"), exports);
|
5
|
+
tslib_1.__exportStar(require("./collection"), exports);
|
5
6
|
tslib_1.__exportStar(require("./component"), exports);
|
6
7
|
tslib_1.__exportStar(require("./dependencies"), exports);
|
8
|
+
tslib_1.__exportStar(require("./environment"), exports);
|
9
|
+
tslib_1.__exportStar(require("./error"), exports);
|
7
10
|
tslib_1.__exportStar(require("./file-info"), exports);
|
8
11
|
tslib_1.__exportStar(require("./generation"), exports);
|
9
12
|
tslib_1.__exportStar(require("./gitignore"), exports);
|
10
13
|
tslib_1.__exportStar(require("./loaders"), exports);
|
11
|
-
tslib_1.__exportStar(require("./
|
12
|
-
tslib_1.__exportStar(require("./routes"), exports);
|
13
|
-
tslib_1.__exportStar(require("./sub-entry"), exports);
|
14
|
-
tslib_1.__exportStar(require("./template-property.helper"), exports);
|
14
|
+
tslib_1.__exportStar(require("./logo"), exports);
|
15
15
|
tslib_1.__exportStar(require("./matching-peers"), exports);
|
16
|
+
tslib_1.__exportStar(require("./modules"), exports);
|
17
|
+
tslib_1.__exportStar(require("./monorepo"), exports);
|
16
18
|
tslib_1.__exportStar(require("./package-manager-runner"), exports);
|
17
19
|
tslib_1.__exportStar(require("./package-version"), exports);
|
18
20
|
tslib_1.__exportStar(require("./question"), exports);
|
19
|
-
tslib_1.__exportStar(require("./
|
21
|
+
tslib_1.__exportStar(require("./routes"), exports);
|
22
|
+
tslib_1.__exportStar(require("./sub-entry"), exports);
|
23
|
+
tslib_1.__exportStar(require("./template-property.helper"), exports);
|
20
24
|
tslib_1.__exportStar(require("./update-imports"), exports);
|
21
|
-
tslib_1.__exportStar(require("./collection"), exports);
|
22
|
-
tslib_1.__exportStar(require("./logo"), exports);
|
23
25
|
//# sourceMappingURL=index.js.map
|
package/src/utility/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utility/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB;AACtB,sDAA4B;AAC5B,yDAA+B;AAC/B,sDAA4B;AAC5B,uDAA6B;AAC7B,sDAA4B;AAC5B,oDAA0B;AAC1B,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utility/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB;AACtB,uDAA6B;AAC7B,sDAA4B;AAC5B,yDAA+B;AAC/B,wDAA8B;AAC9B,kDAAwB;AACxB,sDAA4B;AAC5B,uDAA6B;AAC7B,sDAA4B;AAC5B,oDAA0B;AAC1B,iDAAuB;AACvB,2DAAiC;AACjC,oDAA0B;AAC1B,qDAA2B;AAC3B,mEAAyC;AACzC,4DAAkC;AAClC,qDAA2B;AAC3B,mDAAyB;AACzB,sDAA4B;AAC5B,qEAA2C;AAC3C,2DAAiC"}
|
package/src/utility/loaders.d.ts
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
+
import type { DirEntry, FileEntry } from '@angular-devkit/schematics';
|
1
2
|
import { Tree } from '@angular-devkit/schematics';
|
2
3
|
import { NodeDependencyType } from '@schematics/angular/utility/dependencies';
|
3
4
|
import type { PackageJson } from 'type-fest';
|
4
5
|
import type { WorkspaceProject, WorkspaceSchema } from '../interfaces/index';
|
5
6
|
/**
|
6
|
-
* Load the angular.json file
|
7
7
|
*
|
8
|
+
* Helper function that looks for files in the Tree
|
9
|
+
* @param directory where to perform the search
|
10
|
+
* @param fileMatchesCriteria a function defining the criteria to look for
|
11
|
+
* @param ignoreDirectories optional parameter to ignore folders
|
12
|
+
*/
|
13
|
+
export declare function findFilenameInTree(directory: DirEntry, fileMatchesCriteria: (file: string) => boolean, ignoreDirectories?: string[]): FileEntry[];
|
14
|
+
/**
|
15
|
+
* Load the angular.json file
|
8
16
|
* @param tree File tree
|
9
17
|
* @param angularJsonFile Angular.json file path
|
10
18
|
* @throws Angular JSON invalid or non exist
|
@@ -13,7 +21,6 @@ import type { WorkspaceProject, WorkspaceSchema } from '../interfaces/index';
|
|
13
21
|
export declare function readAngularJson(tree: Tree, angularJsonFile?: string): WorkspaceSchema;
|
14
22
|
/**
|
15
23
|
* Load the Workspace configuration object
|
16
|
-
*
|
17
24
|
* @param tree File tree
|
18
25
|
* @param workspaceConfigFile Workspace config file path, /angular.json in an Angular project
|
19
26
|
* @returns null if the given config file does not exist
|
@@ -21,7 +28,6 @@ export declare function readAngularJson(tree: Tree, angularJsonFile?: string): W
|
|
21
28
|
export declare function getWorkspaceConfig<T extends WorkspaceSchema = WorkspaceSchema>(tree: Tree, workspaceConfigFile?: string): WorkspaceSchema | null;
|
22
29
|
/**
|
23
30
|
* Update angular.json file
|
24
|
-
*
|
25
31
|
* @param tree File tree
|
26
32
|
* @param workspace Angular workspace
|
27
33
|
* @param angularJsonFile Angular.json file path
|
@@ -29,7 +35,6 @@ export declare function getWorkspaceConfig<T extends WorkspaceSchema = Workspace
|
|
29
35
|
export declare function writeAngularJson(tree: Tree, workspace: WorkspaceSchema, angularJsonFile?: string): import("@angular-devkit/schematics/src/tree/interface").Tree;
|
30
36
|
/**
|
31
37
|
* Load the target's package.json file
|
32
|
-
*
|
33
38
|
* @param tree File tree
|
34
39
|
* @param workspaceProject Angular workspace project
|
35
40
|
* @throws Package JSON invalid or non exist
|
@@ -37,38 +42,42 @@ export declare function writeAngularJson(tree: Tree, workspace: WorkspaceSchema,
|
|
37
42
|
export declare function readPackageJson(tree: Tree, workspaceProject: WorkspaceProject): PackageJson;
|
38
43
|
/**
|
39
44
|
* Get the workspace project
|
40
|
-
*
|
41
45
|
* @param tree File tree
|
42
46
|
* @param projectName Name of the Angular project
|
43
47
|
* @param projectType
|
48
|
+
* @deprecated please use {@link getWorkspaceConfig} instead. Will be removed in v10
|
44
49
|
*/
|
45
50
|
export declare function getProjectFromTree(tree: Tree, projectName?: string | null, projectType?: 'application' | 'library'): WorkspaceProject & {
|
46
51
|
name: string;
|
47
52
|
} | undefined;
|
48
53
|
/**
|
49
54
|
* Returns the root directory of a project with the given name ( a relative path from the project root)
|
50
|
-
*
|
51
55
|
* @param tree Files tree
|
52
56
|
* @param projectName Name of the project inside the workspace
|
57
|
+
* @deprecated please use {@link getWorkspaceConfig} instead. Will be removed in v10
|
53
58
|
*/
|
54
59
|
export declare function getProjectRootDir(tree: Tree, projectName?: string | null): string | undefined;
|
55
60
|
/**
|
56
61
|
* Return the type of install to run depending on the project type (Peer or default)
|
57
|
-
*
|
62
|
+
* @deprecated please use {@link getProjectNewDependenciesType} instead. Will be removed in v10
|
58
63
|
* @param tree
|
59
64
|
*/
|
60
65
|
export declare function getProjectDepType(tree: Tree): NodeDependencyType.Default | NodeDependencyType.Peer;
|
66
|
+
/**
|
67
|
+
* Return the type of install to run depending on the project type (Peer or default)
|
68
|
+
* @param project
|
69
|
+
* @param tree
|
70
|
+
*/
|
71
|
+
export declare function getProjectNewDependenciesType(project?: WorkspaceProject): NodeDependencyType.Default | NodeDependencyType.Peer;
|
61
72
|
/**
|
62
73
|
* Get the default project name
|
63
|
-
*
|
64
|
-
* @deprecated use {@link getProjectFromTree} function instead, will be removed in Otter V10
|
74
|
+
* @deprecated use {@link getWorkspaceConfig} function instead, will be removed in Otter V10
|
65
75
|
* @param projectType
|
66
76
|
* @param tree File tree
|
67
77
|
*/
|
68
78
|
export declare function getDefaultProjectName(tree: Tree, projectType?: 'application' | 'library'): string | undefined;
|
69
79
|
/**
|
70
80
|
* Get the folder of the templates for a specific sub-schematics
|
71
|
-
*
|
72
81
|
* @param rootPath Root directory of the schematics ran
|
73
82
|
* @param currentPath Directory of the current sub-schematics ran
|
74
83
|
* @param templateFolder Folder containing the templates
|
@@ -76,7 +85,6 @@ export declare function getDefaultProjectName(tree: Tree, projectType?: 'applica
|
|
76
85
|
export declare function getTemplateFolder(rootPath: string, currentPath: string, templateFolder?: string): string;
|
77
86
|
/**
|
78
87
|
* Get the path of all the files in the Tree
|
79
|
-
*
|
80
88
|
* @param basePath Base path from which starting the list
|
81
89
|
* @param tree Schematics file tree
|
82
90
|
* @param excludes Array of globs to be ignored
|
@@ -85,7 +93,6 @@ export declare function getTemplateFolder(rootPath: string, currentPath: string,
|
|
85
93
|
export declare function getAllFilesInTree(tree: Tree, basePath?: string, excludes?: string[], recursive?: boolean): string[];
|
86
94
|
/**
|
87
95
|
* Get all files with specific extension from the specified folder for all the projects described in the workspace
|
88
|
-
*
|
89
96
|
* @deprecated please use {@link getFilesInFolderFromWorkspaceProjectsInTree}, will be removed in v9
|
90
97
|
* @param tree
|
91
98
|
* @param folderInProject
|
@@ -94,7 +101,6 @@ export declare function getAllFilesInTree(tree: Tree, basePath?: string, exclude
|
|
94
101
|
export declare function getFilesInFolderFromWorkspaceProjects(tree: Tree, folderInProject: string, extension: string): string[];
|
95
102
|
/**
|
96
103
|
* Get all files with specific extension from the specified folder for all the projects described in the workspace
|
97
|
-
*
|
98
104
|
* @param tree
|
99
105
|
* @param folderInProject
|
100
106
|
* @param extension
|
@@ -102,28 +108,24 @@ export declare function getFilesInFolderFromWorkspaceProjects(tree: Tree, folder
|
|
102
108
|
export declare function getFilesInFolderFromWorkspaceProjectsInTree(tree: Tree, folderInProject: string, extension: string): string[];
|
103
109
|
/**
|
104
110
|
* Get all files with specific extension from the tree
|
105
|
-
*
|
106
111
|
* @param tree
|
107
112
|
* @param extension
|
108
113
|
*/
|
109
114
|
export declare function getFilesWithExtensionFromTree(tree: Tree, extension: string): string[];
|
110
115
|
/**
|
111
116
|
* Get all files with specific extension from the root of all the projects described in the workspace
|
112
|
-
*
|
113
117
|
* @param tree
|
114
118
|
* @param extension
|
115
119
|
*/
|
116
120
|
export declare function getFilesFromRootOfWorkspaceProjects(tree: Tree, extension: string): string[];
|
117
121
|
/**
|
118
122
|
* Get all files with specific extension from the src folder for all the projects described in the workspace
|
119
|
-
*
|
120
123
|
* @param tree
|
121
124
|
* @param extension
|
122
125
|
*/
|
123
126
|
export declare function getFilesFromWorkspaceProjects(tree: Tree, extension: string): string[];
|
124
127
|
/**
|
125
128
|
* Get all the typescript files from the src folder for all the projects described in the workspace
|
126
|
-
*
|
127
129
|
* @param tree
|
128
130
|
*/
|
129
131
|
export declare function getSourceFilesFromWorkspaceProjects(tree: Tree): string[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../../../src/utility/loaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAI9E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../../../src/utility/loaders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAuB,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE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,OAAO,CAAC,EAAE,gBAAgB,wDAEvE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE7G;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,SAAc,UAGpG;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,SAAM,EAAE,QAAQ,GAAE,MAAM,EAAO,EAAE,SAAS,UAAO,GAAG,MAAM,EAAE,CAQjH;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAS3G;AAED;;;;;GAKG;AACH,wBAAgB,2CAA2C,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,YAOjH;AAGD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAK1E;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAEhF;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,YAE1E;AAGD;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,IAAI,YAE7D"}
|
package/src/utility/loaders.js
CHANGED
@@ -1,14 +1,37 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getSourceFilesFromWorkspaceProjects = exports.getFilesFromWorkspaceProjects = exports.getFilesFromRootOfWorkspaceProjects = exports.getFilesWithExtensionFromTree = exports.getFilesInFolderFromWorkspaceProjectsInTree = exports.getFilesInFolderFromWorkspaceProjects = exports.getAllFilesInTree = exports.getTemplateFolder = exports.getDefaultProjectName = exports.getProjectDepType = exports.getProjectRootDir = exports.getProjectFromTree = exports.readPackageJson = exports.writeAngularJson = exports.getWorkspaceConfig = exports.readAngularJson = void 0;
|
3
|
+
exports.getSourceFilesFromWorkspaceProjects = exports.getFilesFromWorkspaceProjects = exports.getFilesFromRootOfWorkspaceProjects = exports.getFilesWithExtensionFromTree = exports.getFilesInFolderFromWorkspaceProjectsInTree = exports.getFilesInFolderFromWorkspaceProjects = exports.getAllFilesInTree = exports.getTemplateFolder = exports.getDefaultProjectName = exports.getProjectNewDependenciesType = exports.getProjectDepType = exports.getProjectRootDir = exports.getProjectFromTree = exports.readPackageJson = exports.writeAngularJson = exports.getWorkspaceConfig = exports.readAngularJson = exports.findFilenameInTree = void 0;
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
5
5
|
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
6
6
|
const globby_1 = require("globby");
|
7
7
|
const minimatch_1 = require("minimatch");
|
8
8
|
const path = require("node:path");
|
9
|
+
function findFilenameInTreeRec(memory, directory, fileMatchesCriteria, ignoreDirectories) {
|
10
|
+
if (ignoreDirectories.some(i => directory.path.split(path.posix.sep).includes(i))) {
|
11
|
+
return memory;
|
12
|
+
}
|
13
|
+
directory.subfiles
|
14
|
+
.filter(fileMatchesCriteria)
|
15
|
+
.forEach((file) => memory.add(directory.file(file)));
|
16
|
+
directory.subdirs
|
17
|
+
.forEach((dir) => findFilenameInTreeRec(memory, directory.dir(dir), fileMatchesCriteria, ignoreDirectories));
|
18
|
+
return memory;
|
19
|
+
}
|
9
20
|
/**
|
10
|
-
* Load the angular.json file
|
11
21
|
*
|
22
|
+
* Helper function that looks for files in the Tree
|
23
|
+
* @param directory where to perform the search
|
24
|
+
* @param fileMatchesCriteria a function defining the criteria to look for
|
25
|
+
* @param ignoreDirectories optional parameter to ignore folders
|
26
|
+
*/
|
27
|
+
function findFilenameInTree(directory, fileMatchesCriteria, ignoreDirectories = ['node_modules', '.git', '.yarn']) {
|
28
|
+
const memory = new Set();
|
29
|
+
findFilenameInTreeRec(memory, directory, fileMatchesCriteria, ignoreDirectories);
|
30
|
+
return Array.from(memory);
|
31
|
+
}
|
32
|
+
exports.findFilenameInTree = findFilenameInTree;
|
33
|
+
/**
|
34
|
+
* Load the angular.json file
|
12
35
|
* @param tree File tree
|
13
36
|
* @param angularJsonFile Angular.json file path
|
14
37
|
* @throws Angular JSON invalid or non exist
|
@@ -24,7 +47,6 @@ function readAngularJson(tree, angularJsonFile = '/angular.json') {
|
|
24
47
|
exports.readAngularJson = readAngularJson;
|
25
48
|
/**
|
26
49
|
* Load the Workspace configuration object
|
27
|
-
*
|
28
50
|
* @param tree File tree
|
29
51
|
* @param workspaceConfigFile Workspace config file path, /angular.json in an Angular project
|
30
52
|
* @returns null if the given config file does not exist
|
@@ -38,7 +60,6 @@ function getWorkspaceConfig(tree, workspaceConfigFile = '/angular.json') {
|
|
38
60
|
exports.getWorkspaceConfig = getWorkspaceConfig;
|
39
61
|
/**
|
40
62
|
* Update angular.json file
|
41
|
-
*
|
42
63
|
* @param tree File tree
|
43
64
|
* @param workspace Angular workspace
|
44
65
|
* @param angularJsonFile Angular.json file path
|
@@ -50,7 +71,6 @@ function writeAngularJson(tree, workspace, angularJsonFile = '/angular.json') {
|
|
50
71
|
exports.writeAngularJson = writeAngularJson;
|
51
72
|
/**
|
52
73
|
* Load the target's package.json file
|
53
|
-
*
|
54
74
|
* @param tree File tree
|
55
75
|
* @param workspaceProject Angular workspace project
|
56
76
|
* @throws Package JSON invalid or non exist
|
@@ -66,10 +86,10 @@ function readPackageJson(tree, workspaceProject) {
|
|
66
86
|
exports.readPackageJson = readPackageJson;
|
67
87
|
/**
|
68
88
|
* Get the workspace project
|
69
|
-
*
|
70
89
|
* @param tree File tree
|
71
90
|
* @param projectName Name of the Angular project
|
72
91
|
* @param projectType
|
92
|
+
* @deprecated please use {@link getWorkspaceConfig} instead. Will be removed in v10
|
73
93
|
*/
|
74
94
|
function getProjectFromTree(tree, projectName, projectType) {
|
75
95
|
const workspace = getWorkspaceConfig(tree);
|
@@ -95,9 +115,9 @@ function getProjectFromTree(tree, projectName, projectType) {
|
|
95
115
|
exports.getProjectFromTree = getProjectFromTree;
|
96
116
|
/**
|
97
117
|
* Returns the root directory of a project with the given name ( a relative path from the project root)
|
98
|
-
*
|
99
118
|
* @param tree Files tree
|
100
119
|
* @param projectName Name of the project inside the workspace
|
120
|
+
* @deprecated please use {@link getWorkspaceConfig} instead. Will be removed in v10
|
101
121
|
*/
|
102
122
|
function getProjectRootDir(tree, projectName) {
|
103
123
|
return getProjectFromTree(tree, projectName)?.root;
|
@@ -105,7 +125,7 @@ function getProjectRootDir(tree, projectName) {
|
|
105
125
|
exports.getProjectRootDir = getProjectRootDir;
|
106
126
|
/**
|
107
127
|
* Return the type of install to run depending on the project type (Peer or default)
|
108
|
-
*
|
128
|
+
* @deprecated please use {@link getProjectNewDependenciesType} instead. Will be removed in v10
|
109
129
|
* @param tree
|
110
130
|
*/
|
111
131
|
function getProjectDepType(tree) {
|
@@ -114,10 +134,18 @@ function getProjectDepType(tree) {
|
|
114
134
|
return projectType === 'application' ? dependencies_1.NodeDependencyType.Default : dependencies_1.NodeDependencyType.Peer;
|
115
135
|
}
|
116
136
|
exports.getProjectDepType = getProjectDepType;
|
137
|
+
/**
|
138
|
+
* Return the type of install to run depending on the project type (Peer or default)
|
139
|
+
* @param project
|
140
|
+
* @param tree
|
141
|
+
*/
|
142
|
+
function getProjectNewDependenciesType(project) {
|
143
|
+
return project?.projectType === 'library' ? dependencies_1.NodeDependencyType.Peer : dependencies_1.NodeDependencyType.Default;
|
144
|
+
}
|
145
|
+
exports.getProjectNewDependenciesType = getProjectNewDependenciesType;
|
117
146
|
/**
|
118
147
|
* Get the default project name
|
119
|
-
*
|
120
|
-
* @deprecated use {@link getProjectFromTree} function instead, will be removed in Otter V10
|
148
|
+
* @deprecated use {@link getWorkspaceConfig} function instead, will be removed in Otter V10
|
121
149
|
* @param projectType
|
122
150
|
* @param tree File tree
|
123
151
|
*/
|
@@ -127,7 +155,6 @@ function getDefaultProjectName(tree, projectType) {
|
|
127
155
|
exports.getDefaultProjectName = getDefaultProjectName;
|
128
156
|
/**
|
129
157
|
* Get the folder of the templates for a specific sub-schematics
|
130
|
-
*
|
131
158
|
* @param rootPath Root directory of the schematics ran
|
132
159
|
* @param currentPath Directory of the current sub-schematics ran
|
133
160
|
* @param templateFolder Folder containing the templates
|
@@ -139,7 +166,6 @@ function getTemplateFolder(rootPath, currentPath, templateFolder = 'templates')
|
|
139
166
|
exports.getTemplateFolder = getTemplateFolder;
|
140
167
|
/**
|
141
168
|
* Get the path of all the files in the Tree
|
142
|
-
*
|
143
169
|
* @param basePath Base path from which starting the list
|
144
170
|
* @param tree Schematics file tree
|
145
171
|
* @param excludes Array of globs to be ignored
|
@@ -157,7 +183,6 @@ function getAllFilesInTree(tree, basePath = '/', excludes = [], recursive = true
|
|
157
183
|
exports.getAllFilesInTree = getAllFilesInTree;
|
158
184
|
/**
|
159
185
|
* Get all files with specific extension from the specified folder for all the projects described in the workspace
|
160
|
-
*
|
161
186
|
* @deprecated please use {@link getFilesInFolderFromWorkspaceProjectsInTree}, will be removed in v9
|
162
187
|
* @param tree
|
163
188
|
* @param folderInProject
|
@@ -175,7 +200,6 @@ function getFilesInFolderFromWorkspaceProjects(tree, folderInProject, extension)
|
|
175
200
|
exports.getFilesInFolderFromWorkspaceProjects = getFilesInFolderFromWorkspaceProjects;
|
176
201
|
/**
|
177
202
|
* Get all files with specific extension from the specified folder for all the projects described in the workspace
|
178
|
-
*
|
179
203
|
* @param tree
|
180
204
|
* @param folderInProject
|
181
205
|
* @param extension
|
@@ -191,7 +215,6 @@ function getFilesInFolderFromWorkspaceProjectsInTree(tree, folderInProject, exte
|
|
191
215
|
exports.getFilesInFolderFromWorkspaceProjectsInTree = getFilesInFolderFromWorkspaceProjectsInTree;
|
192
216
|
/**
|
193
217
|
* Get all files with specific extension from the tree
|
194
|
-
*
|
195
218
|
* @param tree
|
196
219
|
* @param extension
|
197
220
|
*/
|
@@ -204,7 +227,6 @@ function getFilesWithExtensionFromTree(tree, extension) {
|
|
204
227
|
exports.getFilesWithExtensionFromTree = getFilesWithExtensionFromTree;
|
205
228
|
/**
|
206
229
|
* Get all files with specific extension from the root of all the projects described in the workspace
|
207
|
-
*
|
208
230
|
* @param tree
|
209
231
|
* @param extension
|
210
232
|
*/
|
@@ -214,7 +236,6 @@ function getFilesFromRootOfWorkspaceProjects(tree, extension) {
|
|
214
236
|
exports.getFilesFromRootOfWorkspaceProjects = getFilesFromRootOfWorkspaceProjects;
|
215
237
|
/**
|
216
238
|
* Get all files with specific extension from the src folder for all the projects described in the workspace
|
217
|
-
*
|
218
239
|
* @param tree
|
219
240
|
* @param extension
|
220
241
|
*/
|
@@ -224,7 +245,6 @@ function getFilesFromWorkspaceProjects(tree, extension) {
|
|
224
245
|
exports.getFilesFromWorkspaceProjects = getFilesFromWorkspaceProjects;
|
225
246
|
/**
|
226
247
|
* Get all the typescript files from the src folder for all the projects described in the workspace
|
227
|
-
*
|
228
248
|
* @param tree
|
229
249
|
*/
|
230
250
|
function getSourceFilesFromWorkspaceProjects(tree) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"loaders.js","sourceRoot":"","sources":["../../../src/utility/loaders.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"loaders.js","sourceRoot":"","sources":["../../../src/utility/loaders.ts"],"names":[],"mappings":";;;AACA,2DAAuE;AACvE,2EAA8E;AAC9E,mCAA4C;AAC5C,yCAAsC;AACtC,kCAAkC;AAIlC,SAAS,qBAAqB,CAAC,MAAsB,EAAE,SAAmB,EAAE,mBAA8C,EAAE,iBAA2B;IACrJ,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC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d.ts
CHANGED
@@ -2,7 +2,6 @@ import { SchematicContext, Tree, UpdateRecorder } from '@angular-devkit/schemati
|
|
2
2
|
import * as ts from 'typescript';
|
3
3
|
/**
|
4
4
|
* Get the path to the app.module.ts
|
5
|
-
*
|
6
5
|
* @param tree File tree
|
7
6
|
* @param context Context of the rule
|
8
7
|
* @param projectName The name of the project where to search for an app module file
|
@@ -13,12 +12,12 @@ export declare function getAppModuleFilePath(tree: Tree, context: SchematicConte
|
|
13
12
|
*
|
14
13
|
* @param tree File tree
|
15
14
|
* @param context Context of the rule
|
15
|
+
* @param projectName
|
16
16
|
*/
|
17
|
-
export declare function getMainFilePath(tree: Tree, context: SchematicContext): string | undefined;
|
17
|
+
export declare function getMainFilePath(tree: Tree, context: SchematicContext, projectName?: string): string | undefined;
|
18
18
|
/**
|
19
19
|
* Returns true if the project is an application and contains a TS file that imports the angular RouterModule in
|
20
20
|
* one of its modules.
|
21
|
-
*
|
22
21
|
* @param tree
|
23
22
|
* @param options @see RuleFactory.options
|
24
23
|
* @param options.projectName
|
@@ -28,7 +27,6 @@ export declare function isApplicationThatUsesRouterModule(tree: Tree, options: {
|
|
28
27
|
}): boolean | "" | undefined;
|
29
28
|
/**
|
30
29
|
* Add import to the main module
|
31
|
-
*
|
32
30
|
* @param name
|
33
31
|
* @param file
|
34
32
|
* @param sourceFile
|
@@ -43,7 +41,6 @@ export declare function isApplicationThatUsesRouterModule(tree: Tree, options: {
|
|
43
41
|
export declare function addImportToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, sourceFileContent: string, context: SchematicContext, recorder: UpdateRecorder, moduleFilePath: string, moduleIndex: number, moduleFunction?: string, override?: boolean): UpdateRecorder;
|
44
42
|
/**
|
45
43
|
* Insert import on top of the main module file
|
46
|
-
*
|
47
44
|
* @param name
|
48
45
|
* @param file
|
49
46
|
* @param sourceFile
|
@@ -54,7 +51,6 @@ export declare function addImportToModuleFile(name: string, file: string, source
|
|
54
51
|
export declare function insertImportToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, recorder: UpdateRecorder, moduleFilePath: string, isDefault?: boolean): UpdateRecorder;
|
55
52
|
/**
|
56
53
|
* Add providers to the main module
|
57
|
-
*
|
58
54
|
* @param name
|
59
55
|
* @param file
|
60
56
|
* @param sourceFile
|
@@ -68,7 +64,6 @@ export declare function insertImportToModuleFile(name: string, file: string, sou
|
|
68
64
|
export declare function addProviderToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, sourceFileContent: string, context: SchematicContext, recorder: UpdateRecorder, moduleFilePath: string, moduleIndex: number, customProvider?: string): UpdateRecorder;
|
69
65
|
/**
|
70
66
|
* Add custom code before the module definition
|
71
|
-
*
|
72
67
|
* @param line
|
73
68
|
* @param file
|
74
69
|
* @param recorder
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../../src/utility/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAuB,IAAI,EAAE,cAAc,EAAC,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAejC
|
1
|
+
{"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../../src/utility/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAuB,IAAI,EAAE,cAAc,EAAC,MAAM,4BAA4B,CAAC;AACvG,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAejC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,sBA0DtG;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,CAAC,EAAE,MAAM,sBAU1F;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,4BAgB1G;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EACrI,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,UAAQ,kBAoB3H;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,kBAMpK;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EACrI,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,kBAY3G;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAK3G"}
|
package/src/utility/modules.js
CHANGED
@@ -12,13 +12,12 @@ const ast_1 = require("./ast");
|
|
12
12
|
const loaders_1 = require("./loaders");
|
13
13
|
/**
|
14
14
|
* Get the path to the app.module.ts
|
15
|
-
*
|
16
15
|
* @param tree File tree
|
17
16
|
* @param context Context of the rule
|
18
17
|
* @param projectName The name of the project where to search for an app module file
|
19
18
|
*/
|
20
19
|
function getAppModuleFilePath(tree, context, projectName) {
|
21
|
-
const workspaceProject = (0, loaders_1.
|
20
|
+
const workspaceProject = projectName ? (0, loaders_1.getWorkspaceConfig)(tree)?.projects[projectName] : undefined;
|
22
21
|
// exit if not an application
|
23
22
|
if (!workspaceProject) {
|
24
23
|
context.logger.debug('Aborted. App module file path will be searched only in application project.');
|
@@ -69,9 +68,10 @@ exports.getAppModuleFilePath = getAppModuleFilePath;
|
|
69
68
|
*
|
70
69
|
* @param tree File tree
|
71
70
|
* @param context Context of the rule
|
71
|
+
* @param projectName
|
72
72
|
*/
|
73
|
-
function getMainFilePath(tree, context) {
|
74
|
-
const workspaceProject = (0, loaders_1.
|
73
|
+
function getMainFilePath(tree, context, projectName) {
|
74
|
+
const workspaceProject = projectName ? (0, loaders_1.getWorkspaceConfig)(tree)?.projects[projectName] : undefined;
|
75
75
|
// exit if not an application
|
76
76
|
if (!workspaceProject) {
|
77
77
|
context.logger.debug('Register localization on main module only in application project');
|
@@ -84,13 +84,12 @@ exports.getMainFilePath = getMainFilePath;
|
|
84
84
|
/**
|
85
85
|
* Returns true if the project is an application and contains a TS file that imports the angular RouterModule in
|
86
86
|
* one of its modules.
|
87
|
-
*
|
88
87
|
* @param tree
|
89
88
|
* @param options @see RuleFactory.options
|
90
89
|
* @param options.projectName
|
91
90
|
*/
|
92
91
|
function isApplicationThatUsesRouterModule(tree, options) {
|
93
|
-
const workspaceProject = (0, loaders_1.
|
92
|
+
const workspaceProject = options.projectName ? (0, loaders_1.getWorkspaceConfig)(tree)?.projects[options.projectName] : undefined;
|
94
93
|
const cwd = process.cwd().replace(/[\\/]+/g, '/');
|
95
94
|
const root = (workspaceProject?.root && cwd.endsWith(workspaceProject.root)) ? workspaceProject.root.replace(/[^\\/]+/g, '..') : '.';
|
96
95
|
return workspaceProject?.sourceRoot &&
|
@@ -110,7 +109,6 @@ function isApplicationThatUsesRouterModule(tree, options) {
|
|
110
109
|
exports.isApplicationThatUsesRouterModule = isApplicationThatUsesRouterModule;
|
111
110
|
/**
|
112
111
|
* Add import to the main module
|
113
|
-
*
|
114
112
|
* @param name
|
115
113
|
* @param file
|
116
114
|
* @param sourceFile
|
@@ -149,7 +147,6 @@ function addImportToModuleFile(name, file, sourceFile, sourceFileContent, contex
|
|
149
147
|
exports.addImportToModuleFile = addImportToModuleFile;
|
150
148
|
/**
|
151
149
|
* Insert import on top of the main module file
|
152
|
-
*
|
153
150
|
* @param name
|
154
151
|
* @param file
|
155
152
|
* @param sourceFile
|
@@ -167,7 +164,6 @@ function insertImportToModuleFile(name, file, sourceFile, recorder, moduleFilePa
|
|
167
164
|
exports.insertImportToModuleFile = insertImportToModuleFile;
|
168
165
|
/**
|
169
166
|
* Add providers to the main module
|
170
|
-
*
|
171
167
|
* @param name
|
172
168
|
* @param file
|
173
169
|
* @param sourceFile
|
@@ -194,7 +190,6 @@ function addProviderToModuleFile(name, file, sourceFile, sourceFileContent, cont
|
|
194
190
|
exports.addProviderToModuleFile = addProviderToModuleFile;
|
195
191
|
/**
|
196
192
|
* Add custom code before the module definition
|
197
|
-
*
|
198
193
|
* @param line
|
199
194
|
* @param file
|
200
195
|
* @param recorder
|