@o3r/schematics 9.1.0-alpha.20 → 9.1.0-alpha.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. package/index.d.ts +7 -0
  2. package/index.d.ts.map +1 -0
  3. package/index.js +10 -0
  4. package/index.js.map +1 -0
  5. package/interfaces/angular-workspace.d.ts +62 -0
  6. package/interfaces/angular-workspace.d.ts.map +1 -0
  7. package/interfaces/angular-workspace.js +3 -0
  8. package/interfaces/angular-workspace.js.map +1 -0
  9. package/interfaces/index.d.ts +3 -0
  10. package/interfaces/index.d.ts.map +1 -0
  11. package/interfaces/index.js +6 -0
  12. package/interfaces/index.js.map +1 -0
  13. package/interfaces/schematic-option.d.ts +5 -0
  14. package/interfaces/schematic-option.d.ts.map +1 -0
  15. package/interfaces/schematic-option.js +3 -0
  16. package/interfaces/schematic-option.js.map +1 -0
  17. package/modules/index.d.ts +3 -0
  18. package/modules/index.d.ts.map +1 -0
  19. package/modules/index.js +6 -0
  20. package/modules/index.js.map +1 -0
  21. package/modules/modules.constants.d.ts +34 -0
  22. package/modules/modules.constants.d.ts.map +1 -0
  23. package/modules/modules.constants.js +12 -0
  24. package/modules/modules.constants.js.map +1 -0
  25. package/modules/modules.helpers.d.ts +60 -0
  26. package/modules/modules.helpers.d.ts.map +1 -0
  27. package/modules/modules.helpers.js +165 -0
  28. package/modules/modules.helpers.js.map +1 -0
  29. package/package.json +4 -4
  30. package/public_api.d.ts +2 -0
  31. package/public_api.d.ts.map +1 -0
  32. package/public_api.js +5 -0
  33. package/public_api.js.map +1 -0
  34. package/rule-factories/add-imports/index.d.ts +12 -0
  35. package/rule-factories/add-imports/index.d.ts.map +1 -0
  36. package/rule-factories/add-imports/index.js +26 -0
  37. package/rule-factories/add-imports/index.js.map +1 -0
  38. package/rule-factories/check-packages-peers/index.d.ts +8 -0
  39. package/rule-factories/check-packages-peers/index.d.ts.map +1 -0
  40. package/rule-factories/check-packages-peers/index.js +106 -0
  41. package/rule-factories/check-packages-peers/index.js.map +1 -0
  42. package/rule-factories/eslint-fix/index.d.ts +28 -0
  43. package/rule-factories/eslint-fix/index.d.ts.map +1 -0
  44. package/rule-factories/eslint-fix/index.js +71 -0
  45. package/rule-factories/eslint-fix/index.js.map +1 -0
  46. package/rule-factories/index.d.ts +9 -0
  47. package/rule-factories/index.d.ts.map +1 -0
  48. package/rule-factories/index.js +12 -0
  49. package/rule-factories/index.js.map +1 -0
  50. package/rule-factories/interfaces.d.ts +6 -0
  51. package/rule-factories/interfaces.d.ts.map +1 -0
  52. package/rule-factories/interfaces.js +3 -0
  53. package/rule-factories/interfaces.js.map +1 -0
  54. package/rule-factories/ng-add/index.d.ts +38 -0
  55. package/rule-factories/ng-add/index.d.ts.map +1 -0
  56. package/rule-factories/ng-add/index.js +174 -0
  57. package/rule-factories/ng-add/index.js.map +1 -0
  58. package/rule-factories/remove-packages/index.d.ts +9 -0
  59. package/rule-factories/remove-packages/index.d.ts.map +1 -0
  60. package/rule-factories/remove-packages/index.js +29 -0
  61. package/rule-factories/remove-packages/index.js.map +1 -0
  62. package/rule-factories/update-imports/index.d.ts +5 -0
  63. package/rule-factories/update-imports/index.d.ts.map +1 -0
  64. package/rule-factories/update-imports/index.js +8 -0
  65. package/rule-factories/update-imports/index.js.map +1 -0
  66. package/rule-factories/update-imports/list-of-vars.d.ts +15 -0
  67. package/rule-factories/update-imports/list-of-vars.d.ts.map +1 -0
  68. package/rule-factories/update-imports/list-of-vars.js +44 -0
  69. package/rule-factories/update-imports/list-of-vars.js.map +1 -0
  70. package/rule-factories/update-imports/update-imports-with-scope.d.ts +12 -0
  71. package/rule-factories/update-imports/update-imports-with-scope.d.ts.map +1 -0
  72. package/rule-factories/update-imports/update-imports-with-scope.js +34 -0
  73. package/rule-factories/update-imports/update-imports-with-scope.js.map +1 -0
  74. package/rule-factories/update-imports/update-ts-imports.d.ts +11 -0
  75. package/rule-factories/update-imports/update-ts-imports.d.ts.map +1 -0
  76. package/rule-factories/update-imports/update-ts-imports.js +32 -0
  77. package/rule-factories/update-imports/update-ts-imports.js.map +1 -0
  78. package/rule-factories/update-imports/v7-to-v8-map-object.d.ts +8 -0
  79. package/rule-factories/update-imports/v7-to-v8-map-object.d.ts.map +1 -0
  80. package/rule-factories/update-imports/v7-to-v8-map-object.js +2049 -0
  81. package/rule-factories/update-imports/v7-to-v8-map-object.js.map +1 -0
  82. package/rule-factories/vscode-extensions/index.d.ts +8 -0
  83. package/rule-factories/vscode-extensions/index.d.ts.map +1 -0
  84. package/rule-factories/vscode-extensions/index.js +26 -0
  85. package/rule-factories/vscode-extensions/index.js.map +1 -0
  86. package/rules/index.d.ts +2 -0
  87. package/rules/index.d.ts.map +1 -0
  88. package/rules/index.js +5 -0
  89. package/rules/index.js.map +1 -0
  90. package/rules/install.d.ts +9 -0
  91. package/rules/install.d.ts.map +1 -0
  92. package/rules/install.js +21 -0
  93. package/rules/install.js.map +1 -0
  94. package/schematics/ng-add/index.js.map +1 -0
  95. package/schematics/ng-add/schema.js.map +1 -0
  96. package/tasks/eslint/index.d.ts +10 -0
  97. package/tasks/eslint/index.d.ts.map +1 -0
  98. package/tasks/eslint/index.js +29 -0
  99. package/tasks/eslint/index.js.map +1 -0
  100. package/tasks/index.d.ts +5 -0
  101. package/tasks/index.d.ts.map +1 -0
  102. package/tasks/index.js +8 -0
  103. package/tasks/index.js.map +1 -0
  104. package/tasks/link/index.d.ts +10 -0
  105. package/tasks/link/index.d.ts.map +1 -0
  106. package/tasks/link/index.js +26 -0
  107. package/tasks/link/index.js.map +1 -0
  108. package/tasks/ng-add/index.d.ts +30 -0
  109. package/tasks/ng-add/index.d.ts.map +1 -0
  110. package/tasks/ng-add/index.js +30 -0
  111. package/tasks/ng-add/index.js.map +1 -0
  112. package/tasks/package-manager/add-dev-dependency.d.ts +24 -0
  113. package/tasks/package-manager/add-dev-dependency.d.ts.map +1 -0
  114. package/tasks/package-manager/add-dev-dependency.js +34 -0
  115. package/tasks/package-manager/add-dev-dependency.js.map +1 -0
  116. package/tasks/package-manager/index.d.ts +4 -0
  117. package/tasks/package-manager/index.d.ts.map +1 -0
  118. package/tasks/package-manager/index.js +7 -0
  119. package/tasks/package-manager/index.js.map +1 -0
  120. package/tasks/package-manager/interfaces.d.ts +14 -0
  121. package/tasks/package-manager/interfaces.d.ts.map +1 -0
  122. package/tasks/package-manager/interfaces.js +3 -0
  123. package/tasks/package-manager/interfaces.js.map +1 -0
  124. package/tasks/package-manager/npm-install.d.ts +24 -0
  125. package/tasks/package-manager/npm-install.d.ts.map +1 -0
  126. package/tasks/package-manager/npm-install.js +35 -0
  127. package/tasks/package-manager/npm-install.js.map +1 -0
  128. package/utility/ast.d.ts +142 -0
  129. package/utility/ast.d.ts.map +1 -0
  130. package/utility/ast.js +325 -0
  131. package/utility/ast.js.map +1 -0
  132. package/utility/collection.d.ts +10 -0
  133. package/utility/collection.d.ts.map +1 -0
  134. package/utility/collection.js +20 -0
  135. package/utility/collection.js.map +1 -0
  136. package/utility/component.d.ts +46 -0
  137. package/utility/component.d.ts.map +1 -0
  138. package/utility/component.js +104 -0
  139. package/utility/component.js.map +1 -0
  140. package/utility/dependencies.d.ts +18 -0
  141. package/utility/dependencies.d.ts.map +1 -0
  142. package/utility/dependencies.js +31 -0
  143. package/utility/dependencies.js.map +1 -0
  144. package/utility/file-info.d.ts +23 -0
  145. package/utility/file-info.d.ts.map +1 -0
  146. package/utility/file-info.js +36 -0
  147. package/utility/file-info.js.map +1 -0
  148. package/utility/generation.d.ts +22 -0
  149. package/utility/generation.d.ts.map +1 -0
  150. package/utility/generation.js +67 -0
  151. package/utility/generation.js.map +1 -0
  152. package/utility/gitignore.d.ts +12 -0
  153. package/utility/gitignore.d.ts.map +1 -0
  154. package/utility/gitignore.js +28 -0
  155. package/utility/gitignore.js.map +1 -0
  156. package/utility/index.d.ts +18 -0
  157. package/utility/index.d.ts.map +1 -0
  158. package/utility/index.js +21 -0
  159. package/utility/index.js.map +1 -0
  160. package/utility/loaders.d.ts +122 -0
  161. package/utility/loaders.d.ts.map +1 -0
  162. package/utility/loaders.js +222 -0
  163. package/utility/loaders.js.map +1 -0
  164. package/utility/matching-peers.d.ts +24 -0
  165. package/utility/matching-peers.d.ts.map +1 -0
  166. package/utility/matching-peers.js +41 -0
  167. package/utility/matching-peers.js.map +1 -0
  168. package/utility/modules.d.ts +73 -0
  169. package/utility/modules.d.ts.map +1 -0
  170. package/utility/modules.js +201 -0
  171. package/utility/modules.js.map +1 -0
  172. package/utility/monorepo.d.ts +17 -0
  173. package/utility/monorepo.d.ts.map +1 -0
  174. package/utility/monorepo.js +30 -0
  175. package/utility/monorepo.js.map +1 -0
  176. package/utility/package-manager-runner.d.ts +43 -0
  177. package/utility/package-manager-runner.d.ts.map +1 -0
  178. package/utility/package-manager-runner.js +61 -0
  179. package/utility/package-manager-runner.js.map +1 -0
  180. package/utility/package-version.d.ts +17 -0
  181. package/utility/package-version.d.ts.map +1 -0
  182. package/utility/package-version.js +34 -0
  183. package/utility/package-version.js.map +1 -0
  184. package/utility/routes.d.ts +40 -0
  185. package/utility/routes.d.ts.map +1 -0
  186. package/utility/routes.js +103 -0
  187. package/utility/routes.js.map +1 -0
  188. package/utility/sub-entry.d.ts +18 -0
  189. package/utility/sub-entry.d.ts.map +1 -0
  190. package/utility/sub-entry.js +51 -0
  191. package/utility/sub-entry.js.map +1 -0
  192. package/utility/template-property.helper.d.ts +101 -0
  193. package/utility/template-property.helper.d.ts.map +1 -0
  194. package/utility/template-property.helper.js +175 -0
  195. package/utility/template-property.helper.js.map +1 -0
  196. package/utility/update-imports.d.ts +25 -0
  197. package/utility/update-imports.d.ts.map +1 -0
  198. package/utility/update-imports.js +86 -0
  199. package/utility/update-imports.js.map +1 -0
@@ -0,0 +1,222 @@
1
+ "use strict";
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.getProjectFromTree = exports.readPackageJson = exports.writeAngularJson = exports.getWorkspaceConfig = exports.readAngularJson = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
6
+ const commentJson = require("comment-json");
7
+ const globby_1 = require("globby");
8
+ const minimatch_1 = require("minimatch");
9
+ const path = require("node:path");
10
+ /**
11
+ * Load the angular.json file
12
+ *
13
+ * @param tree File tree
14
+ * @param angularJsonFile Angular.json file path
15
+ * @throws Angular JSON invalid or non exist
16
+ * @deprecate use {@link getWorkspaceConfig} function instead, will be removed in Otter v10
17
+ */
18
+ function readAngularJson(tree, angularJsonFile = '/angular.json') {
19
+ const workspaceConfig = tree.read(angularJsonFile);
20
+ if (!workspaceConfig) {
21
+ throw new schematics_1.SchematicsException('Could not find Angular workspace configuration');
22
+ }
23
+ return commentJson.parse(workspaceConfig.toString());
24
+ }
25
+ exports.readAngularJson = readAngularJson;
26
+ /**
27
+ * Load the Workspace configuration object
28
+ *
29
+ * @param tree File tree
30
+ * @param workspaceConfigFile Workspace config file path, /angular.json in an Angular project
31
+ * @returns null if the given config file does not exist
32
+ */
33
+ function getWorkspaceConfig(tree, workspaceConfigFile = '/angular.json') {
34
+ if (!tree.exists(workspaceConfigFile)) {
35
+ return null;
36
+ }
37
+ return tree.readJson(workspaceConfigFile);
38
+ }
39
+ exports.getWorkspaceConfig = getWorkspaceConfig;
40
+ /**
41
+ * Update angular.json file
42
+ *
43
+ * @param tree File tree
44
+ * @param workspace Angular workspace
45
+ * @param angularJsonFile Angular.json file path
46
+ */
47
+ function writeAngularJson(tree, workspace, angularJsonFile = '/angular.json') {
48
+ tree.overwrite(angularJsonFile, commentJson.stringify(workspace, null, 2));
49
+ return tree;
50
+ }
51
+ exports.writeAngularJson = writeAngularJson;
52
+ /**
53
+ * Load the target's package.json file
54
+ *
55
+ * @param tree File tree
56
+ * @param workspaceProject Angular workspace project
57
+ * @throws Package JSON invalid or non exist
58
+ */
59
+ function readPackageJson(tree, workspaceProject) {
60
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
61
+ const workspaceConfig = tree.read(`${workspaceProject.root}/package.json`);
62
+ if (!workspaceConfig) {
63
+ throw new schematics_1.SchematicsException('Could not find NPM Package');
64
+ }
65
+ return commentJson.parse(workspaceConfig.toString());
66
+ }
67
+ exports.readPackageJson = readPackageJson;
68
+ /**
69
+ * Get the workspace project
70
+ *
71
+ * @param tree File tree
72
+ * @param projectName Name of the Angular project
73
+ * @param projectType
74
+ */
75
+ function getProjectFromTree(tree, projectName, projectType) {
76
+ const workspace = readAngularJson(tree);
77
+ const projectGuessedName = projectName || Object.keys(workspace.projects)[0];
78
+ // eslint-disable-next-line max-len
79
+ let workspaceProject = projectGuessedName && workspace.projects[projectGuessedName] && (!projectType || workspace.projects[projectGuessedName]?.projectType === projectType) ?
80
+ {
81
+ ...workspace.projects[projectGuessedName],
82
+ name: projectGuessedName
83
+ } :
84
+ undefined;
85
+ // if not found we fallback to the more relevant first one
86
+ if (!workspaceProject) {
87
+ workspaceProject = Object.entries(workspace.projects)
88
+ .filter(([, project]) => !projectType || project.projectType === projectType)
89
+ .map(([name, project]) => ({ ...project, name }))[0];
90
+ }
91
+ return workspaceProject;
92
+ }
93
+ exports.getProjectFromTree = getProjectFromTree;
94
+ /**
95
+ * Return the type of install to run depending on the project type (Peer or default)
96
+ *
97
+ * @param tree
98
+ */
99
+ function getProjectDepType(tree) {
100
+ const workspaceProject = tree.exists('angular.json') ? getProjectFromTree(tree) : undefined;
101
+ const projectType = workspaceProject?.projectType || 'application';
102
+ return projectType === 'application' ? dependencies_1.NodeDependencyType.Default : dependencies_1.NodeDependencyType.Peer;
103
+ }
104
+ exports.getProjectDepType = getProjectDepType;
105
+ /**
106
+ * Get the default project name
107
+ *
108
+ * @deprecated use {@link getProjectFromTree} function instead, will be removed in Otter V10
109
+ * @param projectType
110
+ * @param tree File tree
111
+ */
112
+ function getDefaultProjectName(tree, projectType) {
113
+ return getProjectFromTree(tree, null, projectType)?.name;
114
+ }
115
+ exports.getDefaultProjectName = getDefaultProjectName;
116
+ /**
117
+ * Get the folder of the templates for a specific sub-schematics
118
+ *
119
+ * @param rootPath Root directory of the schematics ran
120
+ * @param currentPath Directory of the current sub-schematics ran
121
+ * @param templateFolder Folder containing the templates
122
+ */
123
+ function getTemplateFolder(rootPath, currentPath, templateFolder = 'templates') {
124
+ const templateFolderPath = path.resolve(currentPath, templateFolder).replace(/[\\]/g, '/');
125
+ return path.relative(rootPath, templateFolderPath);
126
+ }
127
+ exports.getTemplateFolder = getTemplateFolder;
128
+ /**
129
+ * Get the path of all the files in the Tree
130
+ *
131
+ * @param basePath Base path from which starting the list
132
+ * @param tree Schematics file tree
133
+ * @param excludes Array of globs to be ignored
134
+ */
135
+ function getAllFilesInTree(tree, basePath = '/', excludes = []) {
136
+ if (excludes.length && excludes.some((e) => (0, minimatch_1.minimatch)(basePath, e, { dot: true }))) {
137
+ return [];
138
+ }
139
+ return [
140
+ ...tree.getDir(basePath).subfiles.map((file) => path.posix.join(basePath, file)),
141
+ ...tree.getDir(basePath).subdirs
142
+ .flatMap((dir) => getAllFilesInTree(tree, path.posix.join(basePath, dir), excludes))
143
+ ];
144
+ }
145
+ exports.getAllFilesInTree = getAllFilesInTree;
146
+ /**
147
+ * Get all files with specific extension from the specified folder for all the projects described in the workspace
148
+ *
149
+ * @deprecated please use {@link getFilesInFolderFromWorkspaceProjectsInTree}, will be removed in v9
150
+ * @param tree
151
+ * @param folderInProject
152
+ * @param extension
153
+ */
154
+ function getFilesInFolderFromWorkspaceProjects(tree, folderInProject, extension) {
155
+ const workspace = readAngularJson(tree);
156
+ const projectSources = Object.values(workspace.projects)
157
+ .map((project) => path.join(project.root, folderInProject, '**', `*.${extension}`).replace(/\\/g, '/'));
158
+ return projectSources.reduce((acc, projectSource) => {
159
+ acc.push(...(0, globby_1.sync)(projectSource, { ignore: ['**/node_modules/**'] }));
160
+ return acc;
161
+ }, []);
162
+ }
163
+ exports.getFilesInFolderFromWorkspaceProjects = getFilesInFolderFromWorkspaceProjects;
164
+ /**
165
+ * Get all files with specific extension from the specified folder for all the projects described in the workspace
166
+ *
167
+ * @param tree
168
+ * @param folderInProject
169
+ * @param extension
170
+ */
171
+ function getFilesInFolderFromWorkspaceProjectsInTree(tree, folderInProject, extension) {
172
+ const workspace = readAngularJson(tree);
173
+ const extensionMatcher = new RegExp(`\\.${extension.replace(/^\./, '')}$`);
174
+ const excludes = ['**/node_modules/**', '**/.cache/**'];
175
+ return Object.values(workspace.projects)
176
+ .flatMap((project) => getAllFilesInTree(tree, path.posix.join(project.root, folderInProject), excludes))
177
+ .filter((filePath) => extensionMatcher.test(filePath));
178
+ }
179
+ exports.getFilesInFolderFromWorkspaceProjectsInTree = getFilesInFolderFromWorkspaceProjectsInTree;
180
+ /**
181
+ * Get all files with specific extension from the tree
182
+ *
183
+ * @param tree
184
+ * @param extension
185
+ */
186
+ function getFilesWithExtensionFromTree(tree, extension) {
187
+ const excludes = ['**/node_modules/**', '**/.cache/**'];
188
+ const extensionMatcher = new RegExp(`\\.${extension}$`);
189
+ return getAllFilesInTree(tree, '/', excludes)
190
+ .filter((filePath) => extensionMatcher.test(filePath));
191
+ }
192
+ exports.getFilesWithExtensionFromTree = getFilesWithExtensionFromTree;
193
+ /**
194
+ * Get all files with specific extension from the root of all the projects described in the workspace
195
+ *
196
+ * @param tree
197
+ * @param extension
198
+ */
199
+ function getFilesFromRootOfWorkspaceProjects(tree, extension) {
200
+ return getFilesInFolderFromWorkspaceProjectsInTree(tree, '', extension);
201
+ }
202
+ exports.getFilesFromRootOfWorkspaceProjects = getFilesFromRootOfWorkspaceProjects;
203
+ /**
204
+ * Get all files with specific extension from the src folder for all the projects described in the workspace
205
+ *
206
+ * @param tree
207
+ * @param extension
208
+ */
209
+ function getFilesFromWorkspaceProjects(tree, extension) {
210
+ return getFilesInFolderFromWorkspaceProjectsInTree(tree, 'src', extension);
211
+ }
212
+ exports.getFilesFromWorkspaceProjects = getFilesFromWorkspaceProjects;
213
+ /**
214
+ * Get all the typescript files from the src folder for all the projects described in the workspace
215
+ *
216
+ * @param tree
217
+ */
218
+ function getSourceFilesFromWorkspaceProjects(tree) {
219
+ return getFilesFromWorkspaceProjects(tree, 'ts');
220
+ }
221
+ exports.getSourceFilesFromWorkspaceProjects = getSourceFilesFromWorkspaceProjects;
222
+ //# sourceMappingURL=loaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loaders.js","sourceRoot":"","sources":["../../src/utility/loaders.ts"],"names":[],"mappings":";;;AAAA,2DAAuE;AACvE,2EAA8E;AAC9E,4CAA4C;AAC5C,mCAA4C;AAC5C,yCAAsC;AACtC,kCAAkC;AAIlC;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,IAAU,EAAE,eAAe,GAAG,eAAe;IAC3E,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACnD,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,IAAI,gCAAmB,CAAC,gDAAgD,CAAC,CAAC;KACjF;IAED,OAAO,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAQ,CAAC;AAC9D,CAAC;AAPD,0CAOC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAA8C,IAAU,EAAE,mBAAmB,GAAG,eAAe;IAC/H,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAiB,CAAC;AAC5D,CAAC;AALD,gDAKC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,IAAU,EAAE,SAA0B,EAAE,eAAe,GAAG,eAAe;IACxG,IAAI,CAAC,SAAS,CAAC,eAAe,EA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EAAE,SAAiB;IAC/E,OAAO,2CAA2C,CAAC,IAAI,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;AAC1E,CAAC;AAFD,kFAEC;AAED;;;;;GAKG;AACH,SAAgB,6BAA6B,CAAC,IAAU,EAAE,SAAiB;IACzE,OAAO,2CAA2C,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAC7E,CAAC;AAFD,sEAEC;AAGD;;;;GAIG;AACH,SAAgB,mCAAmC,CAAC,IAAU;IAC5D,OAAO,6BAA6B,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC;AAFD,kFAEC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Retrieve the peer dependencies with the given pattern from the given package json file
3
+ *
4
+ * @param packageJsonPath
5
+ * @param pattern
6
+ */
7
+ export declare function getPeerDepWithPattern(packageJsonPath: string, pattern?: RegExp): {
8
+ packageName: string | undefined;
9
+ packageVersion: string | undefined;
10
+ matchingPackages: string[];
11
+ };
12
+ /**
13
+ * Get the list of o3r peer deps from a given package.json file
14
+ *
15
+ * @param packageJsonPath The package json on which we search for o3r peer deps
16
+ * @param filterBasics If activated it will remove the basic peer deps (o3r/core, o3r/dev-tools and o3r/schematics) from the list of results
17
+ * @param packagePattern Pattern of the package name to look in the packages peer dependencies.
18
+ */
19
+ export declare function getO3rPeerDeps(packageJsonPath: string, filterBasics?: boolean, packagePattern?: RegExp): {
20
+ packageName: string | undefined;
21
+ packageVersion: string | undefined;
22
+ o3rPeerDeps: string[];
23
+ };
24
+ //# sourceMappingURL=matching-peers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matching-peers.d.ts","sourceRoot":"","sources":["../../src/utility/matching-peers.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,SAA0B;;;;EAY/F;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,UAAO,EAAE,cAAc,SAAsB;;;;EAUhH"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getO3rPeerDeps = exports.getPeerDepWithPattern = void 0;
4
+ const fs = require("node:fs");
5
+ /**
6
+ * Retrieve the peer dependencies with the given pattern from the given package json file
7
+ *
8
+ * @param packageJsonPath
9
+ * @param pattern
10
+ */
11
+ function getPeerDepWithPattern(packageJsonPath, pattern = /^@(otter|o3r|ama-sdk)/) {
12
+ const packageJsonContent = JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' }));
13
+ const packageName = packageJsonContent.name;
14
+ const packageVersion = packageJsonContent.version;
15
+ const optionalPackages = Object.entries(packageJsonContent.peerDependenciesMeta || {})
16
+ .filter(([, dep]) => dep?.optional)
17
+ .map(([depName]) => depName);
18
+ const matchingPackages = Object.keys(packageJsonContent.peerDependencies || [])
19
+ .filter(peerDep => pattern.test(peerDep) && !optionalPackages.includes(peerDep));
20
+ return { packageName, packageVersion, matchingPackages };
21
+ }
22
+ exports.getPeerDepWithPattern = getPeerDepWithPattern;
23
+ /**
24
+ * Get the list of o3r peer deps from a given package.json file
25
+ *
26
+ * @param packageJsonPath The package json on which we search for o3r peer deps
27
+ * @param filterBasics If activated it will remove the basic peer deps (o3r/core, o3r/dev-tools and o3r/schematics) from the list of results
28
+ * @param packagePattern Pattern of the package name to look in the packages peer dependencies.
29
+ */
30
+ function getO3rPeerDeps(packageJsonPath, filterBasics = true, packagePattern = /^@(?:o3r|ama-sdk)/) {
31
+ const depsInfo = getPeerDepWithPattern(packageJsonPath, packagePattern);
32
+ return {
33
+ packageName: depsInfo.packageName,
34
+ packageVersion: depsInfo.packageVersion,
35
+ o3rPeerDeps: filterBasics ?
36
+ depsInfo.matchingPackages.filter(peerDep => peerDep !== '@o3r/core' && peerDep !== '@o3r/schematics' && peerDep !== '@o3r/dev-tools')
37
+ : depsInfo.matchingPackages
38
+ };
39
+ }
40
+ exports.getO3rPeerDeps = getO3rPeerDeps;
41
+ //# sourceMappingURL=matching-peers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matching-peers.js","sourceRoot":"","sources":["../../src/utility/matching-peers.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAG9B;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,eAAuB,EAAE,OAAO,GAAG,uBAAuB;IAC9F,MAAM,kBAAkB,GAAgB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5G,MAAM,WAAW,GAAG,kBAAkB,CAAC,IAAI,CAAC;IAC5C,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAClD,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,IAAI,EAAE,CAAC;SACnF,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC;SAClC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAE/B,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,IAAI,EAAE,CAAC;SAC5E,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IAEnF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAC3D,CAAC;AAZD,sDAYC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,eAAuB,EAAE,YAAY,GAAG,IAAI,EAAE,cAAc,GAAG,mBAAmB;IAC/G,MAAM,QAAQ,GAAG,qBAAqB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IACxE,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,cAAc,EAAE,QAAQ,CAAC,cAAc;QACvC,WAAW,EAAE,YAAY,CAAC,CAAC;YACzB,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,iBAAiB,IAAI,OAAO,KAAK,gBAAgB,CAAC;YACrI,CAAC,CAAC,QAAQ,CAAC,gBAAgB;KAC9B,CAAC;AAEJ,CAAC;AAVD,wCAUC"}
@@ -0,0 +1,73 @@
1
+ import { SchematicContext, Tree, UpdateRecorder } from '@angular-devkit/schematics';
2
+ import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
+ /**
4
+ * Get the path to the app.module.ts
5
+ *
6
+ * @param tree File tree
7
+ * @param context Context of the rule
8
+ */
9
+ export declare function getAppModuleFilePath(tree: Tree, context: SchematicContext): string | undefined;
10
+ /**
11
+ * Get the path to the main.ts
12
+ *
13
+ * @param tree File tree
14
+ * @param context Context of the rule
15
+ */
16
+ export declare function getMainFilePath(tree: Tree, context: SchematicContext): string | undefined;
17
+ /**
18
+ * Returns true if the project is an application and contains a TS file that imports the angular RouterModule in
19
+ * one of its modules.
20
+ *
21
+ * @param tree
22
+ */
23
+ export declare function isApplicationThatUsesRouterModule(tree: Tree): boolean | "" | undefined;
24
+ /**
25
+ * Add import to the main module
26
+ *
27
+ * @param name
28
+ * @param file
29
+ * @param sourceFile
30
+ * @param sourceFileContent
31
+ * @param context
32
+ * @param moduleFilePath
33
+ * @param moduleIndex
34
+ * @param recorder
35
+ * @param moduleFunction
36
+ * @param override
37
+ */
38
+ 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;
39
+ /**
40
+ * Insert import on top of the main module file
41
+ *
42
+ * @param name
43
+ * @param file
44
+ * @param sourceFile
45
+ * @param recorder
46
+ * @param moduleFilePath
47
+ * @param isDefault
48
+ */
49
+ export declare function insertImportToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, recorder: UpdateRecorder, moduleFilePath: string, isDefault?: boolean): UpdateRecorder;
50
+ /**
51
+ * Add providers to the main module
52
+ *
53
+ * @param name
54
+ * @param file
55
+ * @param sourceFile
56
+ * @param sourceFileContent
57
+ * @param context
58
+ * @param recorder
59
+ * @param moduleFilePath
60
+ * @param moduleIndex
61
+ * @param customProvider
62
+ */
63
+ export declare function addProviderToModuleFile(name: string, file: string, sourceFile: ts.SourceFile, sourceFileContent: string, context: SchematicContext, recorder: UpdateRecorder, moduleFilePath: string, moduleIndex: number, customProvider?: string): UpdateRecorder;
64
+ /**
65
+ * Add custom code before the module definition
66
+ *
67
+ * @param line
68
+ * @param file
69
+ * @param recorder
70
+ * @param moduleIndex
71
+ */
72
+ export declare function insertBeforeModule(line: string, file: string, recorder: UpdateRecorder, moduleIndex: number): UpdateRecorder;
73
+ //# sourceMappingURL=modules.d.ts.map
@@ -0,0 +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,gFAAgF,CAAC;AAerG;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,sBA0DzE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,sBAUpE;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,IAAI,4BAU3D;AAED;;;;;;;;;;;;;GAaG;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;;;;;;;;;GASG;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;;;;;;;;;;;;GAYG;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;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAK3G"}
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.insertBeforeModule = exports.addProviderToModuleFile = exports.insertImportToModuleFile = exports.addImportToModuleFile = exports.isApplicationThatUsesRouterModule = exports.getMainFilePath = exports.getAppModuleFilePath = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const ts = require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript");
6
+ const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
7
+ const change_1 = require("@schematics/angular/utility/change");
8
+ const fs = require("node:fs");
9
+ const globby_1 = require("globby");
10
+ const path = require("node:path");
11
+ const ast_1 = require("./ast");
12
+ const loaders_1 = require("./loaders");
13
+ /**
14
+ * Get the path to the app.module.ts
15
+ *
16
+ * @param tree File tree
17
+ * @param context Context of the rule
18
+ */
19
+ function getAppModuleFilePath(tree, context) {
20
+ const workspaceProject = (0, loaders_1.getProjectFromTree)(tree, null, 'application');
21
+ // exit if not an application
22
+ if (!workspaceProject) {
23
+ context.logger.debug('Register localization on main module only in application project');
24
+ return undefined;
25
+ }
26
+ const mainFilePath = workspaceProject.architect.build.options.main;
27
+ const mainFile = tree.read(mainFilePath).toString();
28
+ const bootstrapModuleRegexpResult = mainFile.match(/bootstrapModule\(([^)]*)\)/m);
29
+ if (!bootstrapModuleRegexpResult || !bootstrapModuleRegexpResult[1]) {
30
+ throw new schematics_1.SchematicsException('Could not find bootstrap module');
31
+ }
32
+ const bootstrapModule = bootstrapModuleRegexpResult[1];
33
+ const findSource = new RegExp(`import +\\{[^}]*${bootstrapModule}[^}]*\\} +from +['"]([^'"]+)['"] *;`, 'm');
34
+ const bootstrapModuleFileRegExpResult = mainFile.match(findSource);
35
+ if (!bootstrapModuleFileRegExpResult || !bootstrapModuleFileRegExpResult[1]) {
36
+ throw new schematics_1.SchematicsException('Could not find bootstrap module');
37
+ }
38
+ /** Path to the main module file */
39
+ const moduleFilePath = path.join(path.dirname(workspaceProject.architect.build.options.main), bootstrapModuleFileRegExpResult[1] + '.ts');
40
+ const exportAppModuleClassRegExp = new RegExp(`class\\s+${bootstrapModule}`, 'gm');
41
+ if (tree.exists(moduleFilePath) && tree.read(moduleFilePath).toString().match(exportAppModuleClassRegExp)) {
42
+ return moduleFilePath;
43
+ }
44
+ const possibleAppModule = path.join(path.dirname(workspaceProject.architect.build.options.main), path.dirname(bootstrapModuleFileRegExpResult[1]), 'app.module.ts');
45
+ if (tree.exists(possibleAppModule) && tree.read(possibleAppModule).toString().match(exportAppModuleClassRegExp)) {
46
+ return possibleAppModule;
47
+ }
48
+ // search app module source file in tree
49
+ const normalizedFilePath = moduleFilePath.split(path.sep).join(path.posix.sep);
50
+ const prog = ts.createProgram([normalizedFilePath], {});
51
+ const symbols = (0, ast_1.getExportedSymbolsFromFile)(prog, normalizedFilePath);
52
+ const bootstrapModuleSymbol = symbols.find(s => s.name === bootstrapModule);
53
+ const checker = prog.getTypeChecker();
54
+ if (bootstrapModuleSymbol) {
55
+ const pathPlusModuleString = checker.getFullyQualifiedName(bootstrapModuleSymbol);
56
+ const filePath = pathPlusModuleString?.replace(new RegExp(`.${bootstrapModule}`), '').replace(/['"]/g, '');
57
+ const relativeFilePath = filePath ? path.relative(path.dirname(workspaceProject.architect.build.options.main), `${filePath}.ts`) : undefined;
58
+ const filePathInTree = relativeFilePath ? path.join(path.dirname(workspaceProject.architect.build.options.main), relativeFilePath) : undefined;
59
+ if (filePathInTree && tree.exists(filePathInTree) && tree.read(filePathInTree).toString().match(exportAppModuleClassRegExp)) {
60
+ return filePathInTree;
61
+ }
62
+ }
63
+ throw new schematics_1.SchematicsException(`Could not find ${bootstrapModule} source file`);
64
+ }
65
+ exports.getAppModuleFilePath = getAppModuleFilePath;
66
+ /**
67
+ * Get the path to the main.ts
68
+ *
69
+ * @param tree File tree
70
+ * @param context Context of the rule
71
+ */
72
+ function getMainFilePath(tree, context) {
73
+ const workspaceProject = (0, loaders_1.getProjectFromTree)(tree, null, 'application');
74
+ // exit if not an application
75
+ if (!workspaceProject) {
76
+ context.logger.debug('Register localization on main module only in application project');
77
+ return undefined;
78
+ }
79
+ const mainFilePath = workspaceProject.architect.build.options.main;
80
+ return mainFilePath;
81
+ }
82
+ exports.getMainFilePath = getMainFilePath;
83
+ /**
84
+ * Returns true if the project is an application and contains a TS file that imports the angular RouterModule in
85
+ * one of its modules.
86
+ *
87
+ * @param tree
88
+ */
89
+ function isApplicationThatUsesRouterModule(tree) {
90
+ const workspaceProject = (0, loaders_1.getProjectFromTree)(tree, null, 'application');
91
+ return workspaceProject?.sourceRoot &&
92
+ (0, globby_1.sync)(path.posix.join(workspaceProject.sourceRoot, '**', '*.ts')).some((filePath) => {
93
+ const sourceFile = ts.createSourceFile(filePath, fs.readFileSync(filePath).toString(), ts.ScriptTarget.ES2015, true);
94
+ try {
95
+ return !!(0, ast_utils_1.getRouterModuleDeclaration)(sourceFile);
96
+ }
97
+ catch { }
98
+ return false;
99
+ });
100
+ }
101
+ exports.isApplicationThatUsesRouterModule = isApplicationThatUsesRouterModule;
102
+ /**
103
+ * Add import to the main module
104
+ *
105
+ * @param name
106
+ * @param file
107
+ * @param sourceFile
108
+ * @param sourceFileContent
109
+ * @param context
110
+ * @param moduleFilePath
111
+ * @param moduleIndex
112
+ * @param recorder
113
+ * @param moduleFunction
114
+ * @param override
115
+ */
116
+ function addImportToModuleFile(name, file, sourceFile, sourceFileContent, context, recorder, moduleFilePath, moduleIndex, moduleFunction, override = false) {
117
+ const importMatch = sourceFileContent.slice(moduleIndex).match(new RegExp(`(${name})(\\.[a-zA-Z\\s\\n]+\\()?(,\\n?)?`));
118
+ if (!!importMatch && !override) {
119
+ context.logger.warn(`Skipped ${name} (already imported)`);
120
+ return recorder;
121
+ }
122
+ else if (importMatch?.[2]) {
123
+ context.logger.warn(`Skipped ${name}${moduleFunction || ''} (already imported with method). Cannot override automatically`);
124
+ return recorder;
125
+ }
126
+ else if (override && (0, ast_utils_1.isImported)(sourceFile, name, file) && !!importMatch && !Number.isNaN(importMatch.index)) {
127
+ recorder = recorder.remove(moduleIndex + importMatch.index, importMatch[0].length);
128
+ recorder = recorder.insertLeft(moduleIndex + importMatch.index, moduleIndex + importMatch.index > moduleIndex ? name + moduleFunction + (importMatch[3] || '') : name);
129
+ }
130
+ else {
131
+ (0, ast_utils_1.addImportToModule)(sourceFile, moduleFilePath, name, file)
132
+ .forEach((change) => {
133
+ if (change instanceof change_1.InsertChange) {
134
+ recorder = recorder.insertLeft(change.pos, moduleFunction && change.pos > moduleIndex ? change.toAdd.replace(name, name + moduleFunction) : change.toAdd);
135
+ }
136
+ });
137
+ }
138
+ return recorder;
139
+ }
140
+ exports.addImportToModuleFile = addImportToModuleFile;
141
+ /**
142
+ * Insert import on top of the main module file
143
+ *
144
+ * @param name
145
+ * @param file
146
+ * @param sourceFile
147
+ * @param recorder
148
+ * @param moduleFilePath
149
+ * @param isDefault
150
+ */
151
+ function insertImportToModuleFile(name, file, sourceFile, recorder, moduleFilePath, isDefault) {
152
+ const importChange = (0, ast_utils_1.insertImport)(sourceFile, moduleFilePath, name, file, isDefault);
153
+ if (importChange instanceof change_1.InsertChange) {
154
+ return recorder.insertLeft(importChange.pos, importChange.toAdd);
155
+ }
156
+ return recorder;
157
+ }
158
+ exports.insertImportToModuleFile = insertImportToModuleFile;
159
+ /**
160
+ * Add providers to the main module
161
+ *
162
+ * @param name
163
+ * @param file
164
+ * @param sourceFile
165
+ * @param sourceFileContent
166
+ * @param context
167
+ * @param recorder
168
+ * @param moduleFilePath
169
+ * @param moduleIndex
170
+ * @param customProvider
171
+ */
172
+ function addProviderToModuleFile(name, file, sourceFile, sourceFileContent, context, recorder, moduleFilePath, moduleIndex, customProvider) {
173
+ if (new RegExp(name).test(sourceFileContent.substr(moduleIndex))) {
174
+ context.logger.warn(`Skipped ${name} (already provided)`);
175
+ return recorder;
176
+ }
177
+ (0, ast_utils_1.addProviderToModule)(sourceFile, moduleFilePath, name, file)
178
+ .forEach((change) => {
179
+ if (change instanceof change_1.InsertChange) {
180
+ recorder = recorder.insertLeft(change.pos, customProvider && change.pos > moduleIndex ? change.toAdd.replace(name, customProvider) : change.toAdd);
181
+ }
182
+ });
183
+ return recorder;
184
+ }
185
+ exports.addProviderToModuleFile = addProviderToModuleFile;
186
+ /**
187
+ * Add custom code before the module definition
188
+ *
189
+ * @param line
190
+ * @param file
191
+ * @param recorder
192
+ * @param moduleIndex
193
+ */
194
+ function insertBeforeModule(line, file, recorder, moduleIndex) {
195
+ if (file.indexOf(line.replace(/[\r\n ]*/g, '')) === -1) {
196
+ return recorder.insertLeft(moduleIndex - 1, `${line}\n\n`);
197
+ }
198
+ return recorder;
199
+ }
200
+ exports.insertBeforeModule = insertBeforeModule;
201
+ //# sourceMappingURL=modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.js","sourceRoot":"","sources":["../../src/utility/modules.ts"],"names":[],"mappings":";;;AAAA,2DAAuG;AACvG,qGAAqG;AACrG,qEAK+C;AAC/C,+DAAgE;AAChE,8BAA8B;AAC9B,mCAA0C;AAC1C,kCAAkC;AAClC,+BAAiD;AACjD,uCAA6C;AAG7C;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,IAAU,EAAE,OAAyB;IACxE,MAAM,gBAAgB,GAAG,IAAA,4BAAkB,EAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;IACvE,6BAA6B;IAC7B,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;QACzF,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,YAAY,GAAW,gBAAgB,CAAC,SAAU,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;IAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAE,CAAC,QAAQ,EAAE,CAAC;IAErD,MAAM,2BAA2B,GAAG,QAAQ,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAClF,IAAI,CAAC,2BAA2B,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE;QACnE,MAAM,IAAI,gCAAmB,CAAC,iCAAiC,CAAC,CAAC;KAClE;IAED,MAAM,eAAe,GAAG,2BAA2B,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,mBAAmB,eAAe,qCAAqC,EAAE,GAAG,CAAC,CAAC;IAE5G,MAAM,+BAA+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ACjB;IACD,IAAA,+BAAmB,EAAC,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC;SACxD,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAClB,IAAI,MAAM,YAAY,qBAAY,EAAE;YAClC,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,EAAE,cAAc,IAAI,MAAM,CAAC,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SACpJ;IACH,CAAC,CAAC,CAAC;IACL,OAAO,QAAQ,CAAC;AAClB,CAAC;AAbD,0DAaC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,IAAY,EAAE,IAAY,EAAE,QAAwB,EAAE,WAAmB;IAC1G,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE;QACtD,OAAO,QAAQ,CAAC,UAAU,CAAC,WAAW,GAAG,CAAC,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC;KAC5D;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AALD,gDAKC"}
@@ -0,0 +1,17 @@
1
+ import type { Tree } from '@angular-devkit/schematics';
2
+ /**
3
+ * Find the relative path to a configuration file at the monorepo root
4
+ *
5
+ * @param tree
6
+ * @param files List of files to look for, the first of the list will used
7
+ * @param originPath Path from where to calculate the relative path
8
+ * @returns
9
+ */
10
+ export declare function findConfigFileRelativePath(tree: Tree, files: string[], originPath: string): string;
11
+ /**
12
+ * Determine if we are in an Nx Monorepo context
13
+ *
14
+ * @param tree
15
+ */
16
+ export declare function isNxContext(tree: Tree): boolean;
17
+ //# sourceMappingURL=monorepo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monorepo.d.ts","sourceRoot":"","sources":["../../src/utility/monorepo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGvD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,UAOzF;AACD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,WAErC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNxContext = exports.findConfigFileRelativePath = void 0;
4
+ const path = require("node:path");
5
+ /**
6
+ * Find the relative path to a configuration file at the monorepo root
7
+ *
8
+ * @param tree
9
+ * @param files List of files to look for, the first of the list will used
10
+ * @param originPath Path from where to calculate the relative path
11
+ * @returns
12
+ */
13
+ function findConfigFileRelativePath(tree, files, originPath) {
14
+ const foundFile = files.find((file) => tree.exists(`/${file}`));
15
+ if (foundFile === undefined) {
16
+ return '';
17
+ }
18
+ return path.posix.relative(originPath, `/${foundFile}`);
19
+ }
20
+ exports.findConfigFileRelativePath = findConfigFileRelativePath;
21
+ /**
22
+ * Determine if we are in an Nx Monorepo context
23
+ *
24
+ * @param tree
25
+ */
26
+ function isNxContext(tree) {
27
+ return tree.exists('/nx.json');
28
+ }
29
+ exports.isNxContext = isNxContext;
30
+ //# sourceMappingURL=monorepo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monorepo.js","sourceRoot":"","sources":["../../src/utility/monorepo.ts"],"names":[],"mappings":";;;AACA,kCAAkC;AAElC;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CAAC,IAAU,EAAE,KAAe,EAAE,UAAkB;IACxF,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAChE,IAAI,SAAS,KAAK,SAAS,EAAE;QAC3B,OAAO,EAAE,CAAC;KACX;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,SAAS,EAAE,CAAC,CAAC;AAC1D,CAAC;AAPD,gEAOC;AACD;;;;GAIG;AACH,SAAgB,WAAW,CAAC,IAAU;IACpC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACjC,CAAC;AAFD,kCAEC"}