@onecx/nx-migration-utils 6.0.0-rc.8 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/package.json +4 -2
  2. package/src/index.d.ts +20 -2
  3. package/src/index.js +20 -2
  4. package/src/index.js.map +1 -1
  5. package/src/lib/angular/html-templates.utils.d.ts +48 -0
  6. package/src/lib/angular/html-templates.utils.js +108 -0
  7. package/src/lib/angular/html-templates.utils.js.map +1 -0
  8. package/src/lib/angular/index.d.ts +16 -0
  9. package/src/lib/angular/index.js +20 -0
  10. package/src/lib/angular/index.js.map +1 -1
  11. package/src/lib/angular/model/matching-module.model.d.ts +4 -0
  12. package/src/lib/angular/model/matching-module.model.js +3 -0
  13. package/src/lib/angular/model/matching-module.model.js.map +1 -0
  14. package/src/lib/angular/model/module.model.d.ts +3 -0
  15. package/src/lib/angular/model/module.model.js +3 -0
  16. package/src/lib/angular/model/module.model.js.map +1 -0
  17. package/src/lib/angular/model/provider.model.d.ts +4 -0
  18. package/src/lib/angular/model/provider.model.js +3 -0
  19. package/src/lib/angular/model/provider.model.js.map +1 -0
  20. package/src/lib/angular/parameters.utils.d.ts +11 -0
  21. package/src/lib/angular/parameters.utils.js +49 -0
  22. package/src/lib/angular/parameters.utils.js.map +1 -0
  23. package/src/lib/angular/replacement-in-files.utils.d.ts +17 -0
  24. package/src/lib/angular/replacement-in-files.utils.js +52 -0
  25. package/src/lib/angular/replacement-in-files.utils.js.map +1 -0
  26. package/src/lib/angular/utils/detection/detect-modules-importing-module.utils.d.ts +12 -0
  27. package/src/lib/angular/utils/detection/detect-modules-importing-module.utils.js +40 -0
  28. package/src/lib/angular/utils/detection/detect-modules-importing-module.utils.js.map +1 -0
  29. package/src/lib/angular/utils/detection/detect-variables-with-module.utils.d.ts +10 -0
  30. package/src/lib/angular/utils/detection/detect-variables-with-module.utils.js +15 -0
  31. package/src/lib/angular/utils/detection/detect-variables-with-module.utils.js.map +1 -0
  32. package/src/lib/angular/utils/detection/detect-variables-with-provider.utils.d.ts +10 -0
  33. package/src/lib/angular/utils/detection/detect-variables-with-provider.utils.js +15 -0
  34. package/src/lib/angular/utils/detection/detect-variables-with-provider.utils.js.map +1 -0
  35. package/src/lib/angular/utils/modification/add-provider-import-if-does-not-exist.utils.d.ts +9 -0
  36. package/src/lib/angular/utils/modification/add-provider-import-if-does-not-exist.utils.js +24 -0
  37. package/src/lib/angular/utils/modification/add-provider-import-if-does-not-exist.utils.js.map +1 -0
  38. package/src/lib/angular/utils/modification/add-provider-import-in-file.utils.d.ts +8 -0
  39. package/src/lib/angular/utils/modification/add-provider-import-in-file.utils.js +25 -0
  40. package/src/lib/angular/utils/modification/add-provider-import-in-file.utils.js.map +1 -0
  41. package/src/lib/angular/utils/modification/add-provider-in-module-if-does-not-exist.utils.d.ts +11 -0
  42. package/src/lib/angular/utils/modification/add-provider-in-module-if-does-not-exist.utils.js +25 -0
  43. package/src/lib/angular/utils/modification/add-provider-in-module-if-does-not-exist.utils.js.map +1 -0
  44. package/src/lib/angular/utils/modification/add-provider-in-module.utils.d.ts +10 -0
  45. package/src/lib/angular/utils/modification/add-provider-in-module.utils.js +29 -0
  46. package/src/lib/angular/utils/modification/add-provider-in-module.utils.js.map +1 -0
  47. package/src/lib/angular/utils/patterns.utils.d.ts +26 -0
  48. package/src/lib/angular/utils/patterns.utils.js +42 -0
  49. package/src/lib/angular/utils/patterns.utils.js.map +1 -0
  50. package/src/lib/angular/utils/validation/is-provider-import-in-file.utils.d.ts +8 -0
  51. package/src/lib/angular/utils/validation/is-provider-import-in-file.utils.js +19 -0
  52. package/src/lib/angular/utils/validation/is-provider-import-in-file.utils.js.map +1 -0
  53. package/src/lib/angular/utils/validation/is-provider-in-module.utils.d.ts +11 -0
  54. package/src/lib/angular/utils/validation/is-provider-in-module.utils.js +22 -0
  55. package/src/lib/angular/utils/validation/is-provider-in-module.utils.js.map +1 -0
  56. package/src/lib/common-migrations/common-migrate-onecx-to-v6.utils.d.ts +2 -0
  57. package/src/lib/common-migrations/common-migrate-onecx-to-v6.utils.js +278 -0
  58. package/src/lib/common-migrations/common-migrate-onecx-to-v6.utils.js.map +1 -0
  59. package/src/lib/utils/detect-method-calls-in-files.d.ts +0 -8
  60. package/src/lib/utils/detect-method-calls-in-files.js +0 -28
  61. package/src/lib/utils/detect-method-calls-in-files.js.map +1 -1
  62. package/src/lib/utils/detect-method-calls-in-files.utils.d.ts +20 -0
  63. package/src/lib/utils/detect-method-calls-in-files.utils.js +138 -0
  64. package/src/lib/utils/detect-method-calls-in-files.utils.js.map +1 -0
  65. package/src/lib/utils/detection/detect-variables-with-identifier.utils.d.ts +9 -0
  66. package/src/lib/utils/detection/detect-variables-with-identifier.utils.js +27 -0
  67. package/src/lib/utils/detection/detect-variables-with-identifier.utils.js.map +1 -0
  68. package/src/lib/utils/import-statements.utils.d.ts +137 -0
  69. package/src/lib/utils/import-statements.utils.js +319 -0
  70. package/src/lib/utils/import-statements.utils.js.map +1 -0
  71. package/src/lib/utils/modification/add-new-import.utils.d.ts +8 -0
  72. package/src/lib/utils/modification/add-new-import.utils.js +14 -0
  73. package/src/lib/utils/modification/add-new-import.utils.js.map +1 -0
  74. package/src/lib/utils/modification/add-to-first-import.utils.d.ts +8 -0
  75. package/src/lib/utils/modification/add-to-first-import.utils.js +21 -0
  76. package/src/lib/utils/modification/add-to-first-import.utils.js.map +1 -0
  77. package/src/lib/utils/modification/remove-import-specifier.utils.d.ts +9 -0
  78. package/src/lib/utils/modification/remove-import-specifier.utils.js +33 -0
  79. package/src/lib/utils/modification/remove-import-specifier.utils.js.map +1 -0
  80. package/src/lib/utils/modification/remove-json-references.utils.d.ts +11 -0
  81. package/src/lib/utils/modification/remove-json-references.utils.js +34 -0
  82. package/src/lib/utils/modification/remove-json-references.utils.js.map +1 -0
  83. package/src/lib/utils/modification/replace-tag-in-html.utils.d.ts +9 -0
  84. package/src/lib/utils/modification/replace-tag-in-html.utils.js +29 -0
  85. package/src/lib/utils/modification/replace-tag-in-html.utils.js.map +1 -0
  86. package/src/lib/utils/modification/update-json-files.utils.d.ts +18 -0
  87. package/src/lib/utils/modification/update-json-files.utils.js +28 -0
  88. package/src/lib/utils/modification/update-json-files.utils.js.map +1 -0
  89. package/src/lib/utils/modification/update-style-sheet.utils.d.ts +11 -0
  90. package/src/lib/utils/modification/update-style-sheet.utils.js +23 -0
  91. package/src/lib/utils/modification/update-style-sheet.utils.js.map +1 -0
  92. package/src/lib/utils/modification/update-style-sheets.utils.d.ts +20 -0
  93. package/src/lib/utils/modification/update-style-sheets.utils.js +31 -0
  94. package/src/lib/utils/modification/update-style-sheets.utils.js.map +1 -0
  95. package/src/lib/utils/patterns.utils.d.ts +31 -0
  96. package/src/lib/utils/patterns.utils.js +51 -0
  97. package/src/lib/utils/patterns.utils.js.map +1 -0
  98. package/src/lib/utils/print-warnings.d.ts +0 -5
  99. package/src/lib/utils/print-warnings.js +0 -5
  100. package/src/lib/utils/print-warnings.js.map +1 -1
  101. package/src/lib/utils/print-warnings.utils.d.ts +6 -0
  102. package/src/lib/utils/print-warnings.utils.js +15 -0
  103. package/src/lib/utils/print-warnings.utils.js.map +1 -0
  104. package/src/lib/utils/typescript-files.utils.d.ts +20 -0
  105. package/src/lib/utils/typescript-files.utils.js +57 -0
  106. package/src/lib/utils/typescript-files.utils.js.map +1 -0
  107. package/src/lib/utils/update-gitignore.utils.d.ts +9 -0
  108. package/src/lib/utils/update-gitignore.utils.js +42 -0
  109. package/src/lib/utils/update-gitignore.utils.js.map +1 -0
  110. package/src/lib/utils/validation/has-html-tag.utils.d.ts +10 -0
  111. package/src/lib/utils/validation/has-html-tag.utils.js +29 -0
  112. package/src/lib/utils/validation/has-html-tag.utils.js.map +1 -0
  113. package/src/lib/utils/validation/is-file-style-sheet.utils.d.ts +8 -0
  114. package/src/lib/utils/validation/is-file-style-sheet.utils.js +14 -0
  115. package/src/lib/utils/validation/is-file-style-sheet.utils.js.map +1 -0
  116. package/src/lib/utils/validation/is-import-in-content.utils.d.ts +7 -0
  117. package/src/lib/utils/validation/is-import-in-content.utils.js +17 -0
  118. package/src/lib/utils/validation/is-import-in-content.utils.js.map +1 -0
  119. package/src/lib/utils/validation/is-import-in-file-content.utils.d.ts +8 -0
  120. package/src/lib/utils/validation/is-import-in-file-content.utils.js +18 -0
  121. package/src/lib/utils/validation/is-import-in-file-content.utils.js.map +1 -0
  122. package/src/lib/utils/validation/is-namespace-import-in-content.utils.d.ts +7 -0
  123. package/src/lib/utils/validation/is-namespace-import-in-content.utils.js +17 -0
  124. package/src/lib/utils/validation/is-namespace-import-in-content.utils.js.map +1 -0
  125. package/src/test-setup.d.ts +1 -0
  126. package/src/test-setup.js +6 -0
  127. package/src/test-setup.js.map +1 -0
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@onecx/nx-migration-utils",
3
- "version": "6.0.0-rc.8",
3
+ "version": "6.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "peerDependencies": {
6
+ "node-html-parser": "^7.0.1",
6
7
  "tslib": "^2.3.0",
7
8
  "@phenomnomnominal/tsquery": "^6",
8
9
  "@nx/devkit": "^20.3.0",
9
- "typescript": "^5.5.4"
10
+ "typescript": "^5.5.4",
11
+ "postcss": "^8.5.3"
10
12
  },
11
13
  "type": "commonjs",
12
14
  "main": "./src/index.js",
package/src/index.d.ts CHANGED
@@ -1,2 +1,20 @@
1
- export * from './lib/utils/detect-method-calls-in-files';
2
- export * from './lib/utils/print-warnings';
1
+ export * from './lib/common-migrations/common-migrate-onecx-to-v6.utils';
2
+ export * from './lib/utils/detect-method-calls-in-files.utils';
3
+ export * from './lib/utils/import-statements.utils';
4
+ export * from './lib/utils/print-warnings.utils';
5
+ export * from './lib/utils/typescript-files.utils';
6
+ export * from './lib/utils/update-gitignore.utils';
7
+ export * from './lib/utils/detection/detect-variables-with-identifier.utils';
8
+ export * from './lib/utils/modification/update-json-files.utils';
9
+ export * from './lib/utils/modification/update-style-sheets.utils';
10
+ export * from './lib/utils/modification/update-style-sheet.utils';
11
+ export * from './lib/utils/modification/remove-json-references.utils';
12
+ export * from './lib/utils/modification/add-new-import.utils';
13
+ export * from './lib/utils/modification/add-to-first-import.utils';
14
+ export * from './lib/utils/modification/replace-tag-in-html.utils';
15
+ export * from './lib/utils/modification/remove-import-specifier.utils';
16
+ export * from './lib/utils/validation/is-file-style-sheet.utils';
17
+ export * from './lib/utils/validation/has-html-tag.utils';
18
+ export * from './lib/utils/validation/is-import-in-content.utils';
19
+ export * from './lib/utils/validation/is-namespace-import-in-content.utils';
20
+ export * from './lib/utils/validation/is-import-in-file-content.utils';
package/src/index.js CHANGED
@@ -2,6 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  // General purpose and framework-agnostic utilities for NX migrations
5
- tslib_1.__exportStar(require("./lib/utils/detect-method-calls-in-files"), exports);
6
- tslib_1.__exportStar(require("./lib/utils/print-warnings"), exports);
5
+ tslib_1.__exportStar(require("./lib/common-migrations/common-migrate-onecx-to-v6.utils"), exports);
6
+ tslib_1.__exportStar(require("./lib/utils/detect-method-calls-in-files.utils"), exports);
7
+ tslib_1.__exportStar(require("./lib/utils/import-statements.utils"), exports);
8
+ tslib_1.__exportStar(require("./lib/utils/print-warnings.utils"), exports);
9
+ tslib_1.__exportStar(require("./lib/utils/typescript-files.utils"), exports);
10
+ tslib_1.__exportStar(require("./lib/utils/update-gitignore.utils"), exports);
11
+ tslib_1.__exportStar(require("./lib/utils/detection/detect-variables-with-identifier.utils"), exports);
12
+ tslib_1.__exportStar(require("./lib/utils/modification/update-json-files.utils"), exports);
13
+ tslib_1.__exportStar(require("./lib/utils/modification/update-style-sheets.utils"), exports);
14
+ tslib_1.__exportStar(require("./lib/utils/modification/update-style-sheet.utils"), exports);
15
+ tslib_1.__exportStar(require("./lib/utils/modification/remove-json-references.utils"), exports);
16
+ tslib_1.__exportStar(require("./lib/utils/modification/add-new-import.utils"), exports);
17
+ tslib_1.__exportStar(require("./lib/utils/modification/add-to-first-import.utils"), exports);
18
+ tslib_1.__exportStar(require("./lib/utils/modification/replace-tag-in-html.utils"), exports);
19
+ tslib_1.__exportStar(require("./lib/utils/modification/remove-import-specifier.utils"), exports);
20
+ tslib_1.__exportStar(require("./lib/utils/validation/is-file-style-sheet.utils"), exports);
21
+ tslib_1.__exportStar(require("./lib/utils/validation/has-html-tag.utils"), exports);
22
+ tslib_1.__exportStar(require("./lib/utils/validation/is-import-in-content.utils"), exports);
23
+ tslib_1.__exportStar(require("./lib/utils/validation/is-namespace-import-in-content.utils"), exports);
24
+ tslib_1.__exportStar(require("./lib/utils/validation/is-import-in-file-content.utils"), exports);
7
25
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/nx-migration-utils/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,mFAAwD;AACxD,qEAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/nx-migration-utils/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AACrE,mGAAwE;AAExE,yFAA8D;AAC9D,8EAAmD;AACnD,2EAAgD;AAChD,6EAAkD;AAClD,6EAAkD;AAElD,uGAA4E;AAE5E,2FAAgE;AAChE,6FAAkE;AAClE,4FAAiE;AACjE,gGAAqE;AACrE,wFAA6D;AAC7D,6FAAkE;AAClE,6FAAkE;AAClE,iGAAsE;AAGtE,2FAAgE;AAChE,oFAAyD;AACzD,4FAAiE;AACjE,sGAA2E;AAC3E,iGAAsE"}
@@ -0,0 +1,48 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Node } from 'typescript';
3
+ /**
4
+ * Changes all occurrences of a specific HTML tag name in Angular component templates.
5
+ * @param tree - The Nx Tree representing the file system.
6
+ * @param dirPath - Directory path to search for files.
7
+ * @param oldTagName - The tag name to replace.
8
+ * @param newTagName - The new tag name to use.
9
+ */
10
+ export declare function replaceTagInAngularTemplates(tree: Tree, dirPath: string, oldTagName: string, newTagName: string): void;
11
+ /**
12
+ * Processes a TypeScript file to find and update Angular component templates.
13
+ * @param tree - The Nx Tree.
14
+ * @param filePath - Path to the TypeScript file.
15
+ * @param oldTagName - The tag name to replace.
16
+ * @param newTagName - The new tag name to use.
17
+ */
18
+ export declare function replaceTagInInlineAndExternalTemplate(tree: Tree, filePath: string, oldTagName: string, newTagName: string): void;
19
+ /**
20
+ * Processes inline Angular templates in a TypeScript file and replaces tag names.
21
+ * @param tree - The Nx Tree.
22
+ * @param filePath - Path to the TypeScript file.
23
+ * @param oldTagName - The tag name to replace.
24
+ * @param newTagName - The new tag name to use.
25
+ */
26
+ export declare function replaceTagInInlineTemplates(tree: Tree, filePath: string, oldTagName: string, newTagName: string): void;
27
+ /**
28
+ * Processes an external HTML template file and replaces tag names.
29
+ * @param tree - The Nx Tree.
30
+ * @param filePath - Path to the HTML file.
31
+ * @param contentAst - The AST of the source file.
32
+ * @param oldTagName - The tag name to replace.
33
+ * @param newTagName - The new tag name to use.
34
+ */
35
+ export declare function replaceTagInExternalTemplates(tree: Tree, filePath: string, contentAst: Node, oldTagName: string, newTagName: string): void;
36
+ /**
37
+ * Extracts inline template nodes from a TypeScript AST.
38
+ * @param contentAst - The parsed TypeScript AST.
39
+ * @returns An array of inline template nodes.
40
+ */
41
+ export declare function getInlineTemplateNodes(contentAst: Node): Node[];
42
+ /**
43
+ * Extracts resolved external template file paths from a TypeScript AST.
44
+ * @param contentAst - The parsed TypeScript AST.
45
+ * @param filePath - The path to the TypeScript file.
46
+ * @returns An array of resolved external HTML file paths.
47
+ */
48
+ export declare function getExternalTemplatePaths(contentAst: Node, filePath: string): string[];
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceTagInAngularTemplates = replaceTagInAngularTemplates;
4
+ exports.replaceTagInInlineAndExternalTemplate = replaceTagInInlineAndExternalTemplate;
5
+ exports.replaceTagInInlineTemplates = replaceTagInInlineTemplates;
6
+ exports.replaceTagInExternalTemplates = replaceTagInExternalTemplates;
7
+ exports.getInlineTemplateNodes = getInlineTemplateNodes;
8
+ exports.getExternalTemplatePaths = getExternalTemplatePaths;
9
+ const devkit_1 = require("@nx/devkit");
10
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
11
+ const path_1 = require("path");
12
+ const typescript_1 = require("typescript");
13
+ const has_html_tag_utils_1 = require("../utils/validation/has-html-tag.utils");
14
+ const replace_tag_in_html_utils_1 = require("../utils/modification/replace-tag-in-html.utils");
15
+ /**
16
+ * Changes all occurrences of a specific HTML tag name in Angular component templates.
17
+ * @param tree - The Nx Tree representing the file system.
18
+ * @param dirPath - Directory path to search for files.
19
+ * @param oldTagName - The tag name to replace.
20
+ * @param newTagName - The new tag name to use.
21
+ */
22
+ function replaceTagInAngularTemplates(tree, dirPath, oldTagName, newTagName) {
23
+ (0, devkit_1.visitNotIgnoredFiles)(tree, dirPath, (file) => {
24
+ if (file.endsWith('.ts')) {
25
+ replaceTagInInlineAndExternalTemplate(tree, file, oldTagName, newTagName);
26
+ }
27
+ });
28
+ }
29
+ /**
30
+ * Processes a TypeScript file to find and update Angular component templates.
31
+ * @param tree - The Nx Tree.
32
+ * @param filePath - Path to the TypeScript file.
33
+ * @param oldTagName - The tag name to replace.
34
+ * @param newTagName - The new tag name to use.
35
+ */
36
+ function replaceTagInInlineAndExternalTemplate(tree, filePath, oldTagName, newTagName) {
37
+ try {
38
+ const tsContent = tree.read(filePath, 'utf8');
39
+ if (!tsContent)
40
+ return;
41
+ const contentAst = (0, tsquery_1.ast)(tsContent);
42
+ replaceTagInInlineTemplates(tree, filePath, oldTagName, newTagName);
43
+ replaceTagInExternalTemplates(tree, filePath, contentAst, oldTagName, newTagName);
44
+ }
45
+ catch (error) {
46
+ console.error(`Error processing file ${filePath}: `, error);
47
+ }
48
+ }
49
+ /**
50
+ * Processes inline Angular templates in a TypeScript file and replaces tag names.
51
+ * @param tree - The Nx Tree.
52
+ * @param filePath - Path to the TypeScript file.
53
+ * @param oldTagName - The tag name to replace.
54
+ * @param newTagName - The new tag name to use.
55
+ */
56
+ function replaceTagInInlineTemplates(tree, filePath, oldTagName, newTagName) {
57
+ const fileContent = tree.read(filePath, 'utf-8');
58
+ if (!fileContent)
59
+ return;
60
+ const querySelectorInlineTemplate = 'PropertyAssignment:has(Identifier[name="template"]) > NoSubstitutionTemplateLiteral';
61
+ const updatedContent = (0, tsquery_1.replace)(fileContent, querySelectorInlineTemplate, (node) => {
62
+ const originalText = node.getText();
63
+ if (!(0, has_html_tag_utils_1.hasHtmlTag)(tree, originalText, oldTagName))
64
+ return originalText;
65
+ const updatedHtml = (0, replace_tag_in_html_utils_1.replaceTagInHtml)(tree, originalText, oldTagName, newTagName);
66
+ return updatedHtml;
67
+ }, typescript_1.ScriptKind.TS);
68
+ if (updatedContent !== fileContent) {
69
+ tree.write(filePath, updatedContent);
70
+ }
71
+ }
72
+ /**
73
+ * Processes an external HTML template file and replaces tag names.
74
+ * @param tree - The Nx Tree.
75
+ * @param filePath - Path to the HTML file.
76
+ * @param contentAst - The AST of the source file.
77
+ * @param oldTagName - The tag name to replace.
78
+ * @param newTagName - The new tag name to use.
79
+ */
80
+ function replaceTagInExternalTemplates(tree, filePath, contentAst, oldTagName, newTagName) {
81
+ const externalTemplates = getExternalTemplatePaths(contentAst, filePath);
82
+ externalTemplates.forEach((path) => {
83
+ const html = tree.read(path, 'utf-8');
84
+ if (!html || !(0, has_html_tag_utils_1.hasHtmlTag)(tree, path, oldTagName))
85
+ return;
86
+ const modifiedHtml = (0, replace_tag_in_html_utils_1.replaceTagInHtml)(tree, html, oldTagName, newTagName);
87
+ tree.write(path, modifiedHtml);
88
+ });
89
+ }
90
+ /**
91
+ * Extracts inline template nodes from a TypeScript AST.
92
+ * @param contentAst - The parsed TypeScript AST.
93
+ * @returns An array of inline template nodes.
94
+ */
95
+ function getInlineTemplateNodes(contentAst) {
96
+ return (0, tsquery_1.query)(contentAst, 'PropertyAssignment:has(Identifier[name="template"]) > NoSubstitutionTemplateLiteral');
97
+ }
98
+ /**
99
+ * Extracts resolved external template file paths from a TypeScript AST.
100
+ * @param contentAst - The parsed TypeScript AST.
101
+ * @param filePath - The path to the TypeScript file.
102
+ * @returns An array of resolved external HTML file paths.
103
+ */
104
+ function getExternalTemplatePaths(contentAst, filePath) {
105
+ const nodes = (0, tsquery_1.query)(contentAst, 'PropertyAssignment:has(Identifier[name="templateUrl"]) > StringLiteral');
106
+ return nodes.filter(typescript_1.isStringLiteral).map((node) => (0, path_1.join)((0, path_1.dirname)(filePath), node.text));
107
+ }
108
+ //# sourceMappingURL=html-templates.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-templates.utils.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/angular/html-templates.utils.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,16 @@
1
+ export * from './model/matching-module.model';
2
+ export * from './model/module.model';
3
+ export * from './model/provider.model';
4
+ export * from './html-templates.utils';
5
+ export * from './parameters.utils';
6
+ export * from './replacement-in-files.utils';
7
+ export * from './utils/patterns.utils';
8
+ export * from './utils/detection/detect-modules-importing-module.utils';
9
+ export * from './utils/detection/detect-variables-with-module.utils';
10
+ export * from './utils/detection/detect-variables-with-provider.utils';
11
+ export * from './utils/modification/add-provider-import-if-does-not-exist.utils';
12
+ export * from './utils/modification/add-provider-import-in-file.utils';
13
+ export * from './utils/modification/add-provider-in-module-if-does-not-exist.utils';
14
+ export * from './utils/modification/add-provider-in-module.utils';
15
+ export * from './utils/validation/is-provider-import-in-file.utils';
16
+ export * from './utils/validation/is-provider-in-module.utils';
@@ -1,3 +1,23 @@
1
1
  "use strict";
2
2
  // Angular specific NX migration utilities
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const tslib_1 = require("tslib");
5
+ // Model
6
+ tslib_1.__exportStar(require("./model/matching-module.model"), exports);
7
+ tslib_1.__exportStar(require("./model/module.model"), exports);
8
+ tslib_1.__exportStar(require("./model/provider.model"), exports);
9
+ // Utils
10
+ tslib_1.__exportStar(require("./html-templates.utils"), exports);
11
+ tslib_1.__exportStar(require("./parameters.utils"), exports);
12
+ tslib_1.__exportStar(require("./replacement-in-files.utils"), exports);
13
+ tslib_1.__exportStar(require("./utils/patterns.utils"), exports);
14
+ tslib_1.__exportStar(require("./utils/detection/detect-modules-importing-module.utils"), exports);
15
+ tslib_1.__exportStar(require("./utils/detection/detect-variables-with-module.utils"), exports);
16
+ tslib_1.__exportStar(require("./utils/detection/detect-variables-with-provider.utils"), exports);
17
+ tslib_1.__exportStar(require("./utils/modification/add-provider-import-if-does-not-exist.utils"), exports);
18
+ tslib_1.__exportStar(require("./utils/modification/add-provider-import-in-file.utils"), exports);
19
+ tslib_1.__exportStar(require("./utils/modification/add-provider-in-module-if-does-not-exist.utils"), exports);
20
+ tslib_1.__exportStar(require("./utils/modification/add-provider-in-module.utils"), exports);
21
+ tslib_1.__exportStar(require("./utils/validation/is-provider-import-in-file.utils"), exports);
22
+ tslib_1.__exportStar(require("./utils/validation/is-provider-in-module.utils"), exports);
3
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/angular/index.ts"],"names":[],"mappings":";AAAA,0CAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/angular/index.ts"],"names":[],"mappings":";AAAA,0CAA0C;;;AAE1C,QAAQ;AACR,wEAA6C;AAC7C,+DAAoC;AACpC,iEAAsC;AAEtC,QAAQ;AACR,iEAAsC;AACtC,6DAAkC;AAClC,uEAA4C;AAC5C,iEAAsC;AACtC,kGAAuE;AACvE,+FAAoE;AACpE,iGAAsE;AACtE,2GAAgF;AAChF,iGAAsE;AACtE,8GAAmF;AACnF,4FAAiE;AACjE,8FAAmE;AACnE,yFAA8D"}
@@ -0,0 +1,4 @@
1
+ export interface MatchingModule {
2
+ name: string;
3
+ filePath: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=matching-module.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matching-module.model.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/angular/model/matching-module.model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export interface Module {
2
+ name: string;
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=module.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.model.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/angular/model/module.model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export interface Provider {
2
+ name: string;
3
+ importPath: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=provider.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.model.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/angular/model/provider.model.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Removes constructor parameters of specified class types from TypeScript files.
4
+ *
5
+ * @param tree - The Nx virtual file system tree.
6
+ * @param directoryPath - Directory to search for files.
7
+ * @param classNames - List of class names whose parameters should be removed.
8
+ * @param filterQuery - Optional custom string query to filter files before applying changes.
9
+ * This can be used to limit the operation to files containing specific content (e.g., a class name or decorator).
10
+ */
11
+ export declare function removeParameters(tree: Tree, directoryPath: string, classNames: string[], filterQuery?: string): void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeParameters = removeParameters;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
6
+ const typescript_1 = require("typescript");
7
+ const detect_method_calls_in_files_utils_1 = require("../utils/detect-method-calls-in-files.utils");
8
+ const typescript_files_utils_1 = require("../utils/typescript-files.utils");
9
+ /**
10
+ * Removes constructor parameters of specified class types from TypeScript files.
11
+ *
12
+ * @param tree - The Nx virtual file system tree.
13
+ * @param directoryPath - Directory to search for files.
14
+ * @param classNames - List of class names whose parameters should be removed.
15
+ * @param filterQuery - Optional custom string query to filter files before applying changes.
16
+ * This can be used to limit the operation to files containing specific content (e.g., a class name or decorator).
17
+ */
18
+ function removeParameters(tree, directoryPath, classNames, filterQuery) {
19
+ (0, devkit_1.visitNotIgnoredFiles)(tree, directoryPath, (filePath) => {
20
+ if (!filePath.endsWith('.ts'))
21
+ return;
22
+ try {
23
+ const fileContent = tree.read(filePath, 'utf-8');
24
+ if (!fileContent)
25
+ return;
26
+ const contentAst = (0, tsquery_1.ast)(fileContent);
27
+ if (filterQuery && !(0, typescript_files_utils_1.fileMatchesQuery)(fileContent, filterQuery))
28
+ return;
29
+ const parameterNames = classNames.flatMap((className) => (0, detect_method_calls_in_files_utils_1.getParameterNames)(contentAst, className));
30
+ if (!parameterNames.length)
31
+ return;
32
+ const parametersQuery = classNames
33
+ .map((className) => `Parameter:has(TypeReference:has(Identifier[name="${className}"]))`)
34
+ .join(', ');
35
+ const parameterNamesQuery = parameterNames
36
+ .map((parameterName) => `NewExpression > Identifier[name="${parameterName}"]`)
37
+ .join(', ');
38
+ let updatedContent = (0, tsquery_1.replace)(fileContent, parametersQuery, () => '', typescript_1.ScriptKind.TS);
39
+ updatedContent = (0, tsquery_1.replace)(updatedContent, parameterNamesQuery, () => '', typescript_1.ScriptKind.TS);
40
+ if (updatedContent !== fileContent) {
41
+ tree.write(filePath, updatedContent);
42
+ }
43
+ }
44
+ catch (error) {
45
+ console.error(`Error removing parameters from file ${filePath}: `, error);
46
+ }
47
+ });
48
+ }
49
+ //# sourceMappingURL=parameters.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.utils.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/angular/parameters.utils.ts"],"names":[],"mappings":";;AAeA,4CAiCC;AAhDD,uCAAuD;AACvD,uDAAwD;AACxD,2CAAuC;AACvC,oGAA+E;AAC/E,4EAAkE;AAElE;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,IAAU,EAAE,aAAqB,EAAE,UAAoB,EAAE,WAAoB;IAC5G,IAAA,6BAAoB,EAAC,IAAI,EAAE,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;QACrD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAM;QAErC,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YAChD,IAAI,CAAC,WAAW;gBAAE,OAAM;YAExB,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,WAAW,CAAC,CAAA;YAEnC,IAAI,WAAW,IAAI,CAAC,IAAA,yCAAgB,EAAC,WAAW,EAAE,WAAW,CAAC;gBAAE,OAAM;YAEtE,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAA,sDAAiB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAA;YAClG,IAAI,CAAC,cAAc,CAAC,MAAM;gBAAE,OAAM;YAElC,MAAM,eAAe,GAAG,UAAU;iBAC/B,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,oDAAoD,SAAS,MAAM,CAAC;iBACvF,IAAI,CAAC,IAAI,CAAC,CAAA;YAEb,MAAM,mBAAmB,GAAG,cAAc;iBACvC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,oCAAoC,aAAa,IAAI,CAAC;iBAC7E,IAAI,CAAC,IAAI,CAAC,CAAA;YAEb,IAAI,cAAc,GAAG,IAAA,iBAAO,EAAC,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,uBAAU,CAAC,EAAE,CAAC,CAAA;YACnF,cAAc,GAAG,IAAA,iBAAO,EAAC,cAAc,EAAE,mBAAmB,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,uBAAU,CAAC,EAAE,CAAC,CAAA;YAEtF,IAAI,cAAc,KAAK,WAAW,EAAE,CAAC;gBACnC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,uCAAuC,QAAQ,IAAI,EAAE,KAAK,CAAC,CAAA;QAC3E,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Applies a tsquery-based replacement to a single TypeScript file.
4
+ * @param tree - The Nx virtual file system tree.
5
+ * @param filePath - Path to the TypeScript file to update.
6
+ * @param queryStr - A tsquery selector string used to identify nodes for replacement.
7
+ * @param replacement - The replacement string. If empty, trailing commas and empty array slots are cleaned up.
8
+ */
9
+ export declare function replaceInFile(tree: Tree, filePath: string, queryStr: string, replacement: string): void;
10
+ /**
11
+ * Applies a tsquery-based replacement to all `.ts` files in a given directory.
12
+ * @param tree - The Nx virtual file system tree.
13
+ * @param directoryPath - Path to the directory containing TypeScript files.
14
+ * @param queryStr - A tsquery selector string used to identify nodes for replacement.
15
+ * @param replacement - The replacement string. If empty, trailing commas and empty array slots are cleaned up.
16
+ */
17
+ export declare function replaceInFiles(tree: Tree, directoryPath: string, queryStr: string, replacement: string, filterQuery?: string): void;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replaceInFile = replaceInFile;
4
+ exports.replaceInFiles = replaceInFiles;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
7
+ const typescript_1 = require("typescript");
8
+ const typescript_files_utils_1 = require("../utils/typescript-files.utils");
9
+ /**
10
+ * Applies a tsquery-based replacement to a single TypeScript file.
11
+ * @param tree - The Nx virtual file system tree.
12
+ * @param filePath - Path to the TypeScript file to update.
13
+ * @param queryStr - A tsquery selector string used to identify nodes for replacement.
14
+ * @param replacement - The replacement string. If empty, trailing commas and empty array slots are cleaned up.
15
+ */
16
+ function replaceInFile(tree, filePath, queryStr, replacement) {
17
+ try {
18
+ const fileContent = tree.read(filePath, 'utf-8');
19
+ if (!fileContent)
20
+ return;
21
+ let updatedContent = (0, tsquery_1.replace)(fileContent, queryStr, () => replacement, typescript_1.ScriptKind.TS);
22
+ if (replacement === '') {
23
+ updatedContent = (0, typescript_files_utils_1.removeEmptySlotsFromArrays)(updatedContent);
24
+ }
25
+ if (updatedContent !== fileContent) {
26
+ tree.write(filePath, updatedContent);
27
+ }
28
+ }
29
+ catch (error) {
30
+ console.error(`Error doing replacement for file ${filePath}: `, error);
31
+ }
32
+ }
33
+ /**
34
+ * Applies a tsquery-based replacement to all `.ts` files in a given directory.
35
+ * @param tree - The Nx virtual file system tree.
36
+ * @param directoryPath - Path to the directory containing TypeScript files.
37
+ * @param queryStr - A tsquery selector string used to identify nodes for replacement.
38
+ * @param replacement - The replacement string. If empty, trailing commas and empty array slots are cleaned up.
39
+ */
40
+ function replaceInFiles(tree, directoryPath, queryStr, replacement, filterQuery) {
41
+ (0, devkit_1.visitNotIgnoredFiles)(tree, directoryPath, (filePath) => {
42
+ if (!filePath.endsWith('.ts'))
43
+ return;
44
+ const fileContent = tree.read(filePath, 'utf-8');
45
+ if (!fileContent)
46
+ return;
47
+ if (filterQuery && !(0, typescript_files_utils_1.fileMatchesQuery)(fileContent, filterQuery))
48
+ return;
49
+ replaceInFile(tree, filePath, queryStr, replacement);
50
+ });
51
+ }
52
+ //# sourceMappingURL=replacement-in-files.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replacement-in-files.utils.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/angular/replacement-in-files.utils.ts"],"names":[],"mappings":";;AAYA,sCAgBC;AASD,wCAWC;AAhDD,uCAAuD;AACvD,uDAAmD;AACnD,2CAAuC;AACvC,4EAA8F;AAE9F;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,IAAU,EAAE,QAAgB,EAAE,QAAgB,EAAE,WAAmB;IAC/F,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAChD,IAAI,CAAC,WAAW;YAAE,OAAM;QAExB,IAAI,cAAc,GAAG,IAAA,iBAAO,EAAC,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,uBAAU,CAAC,EAAE,CAAC,CAAA;QACrF,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;YACvB,cAAc,GAAG,IAAA,mDAA0B,EAAC,cAAc,CAAC,CAAA;QAC7D,CAAC;QAED,IAAI,cAAc,KAAK,WAAW,EAAE,CAAC;YACnC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAA;QACtC,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,oCAAoC,QAAQ,IAAI,EAAE,KAAK,CAAC,CAAA;IACxE,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAAU,EAAE,aAAqB,EAAE,QAAgB,EAAE,WAAmB,EAAE,WAAoB;IAC3H,IAAA,6BAAoB,EAAC,IAAI,EAAE,aAAa,EAAE,CAAC,QAAQ,EAAE,EAAE;QACrD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAM;QAErC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAChD,IAAI,CAAC,WAAW;YAAE,OAAM;QAExB,IAAI,WAAW,IAAI,CAAC,IAAA,yCAAgB,EAAC,WAAW,EAAE,WAAW,CAAC;YAAE,OAAM;QAEtE,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { MatchingModule } from '../../model/matching-module.model';
3
+ import { Module } from '../../model/module.model';
4
+ /**
5
+ * Detects Angular module definitions that import given module.
6
+ * @param tree - the file tree to search in
7
+ * @param rootDir - the directory to start searching from
8
+ * @param module - the module to search for
9
+ * @param variablesIncludingModule - the list of variable names containing the module to search for
10
+ * @returns {MatchingModule[]} a list of found modules that import the module via direct declaration or variable
11
+ */
12
+ export declare function detectModulesImportingModule(tree: Tree, rootDir: string, module: Module, variablesIncludingModule: string[]): MatchingModule[];
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectModulesImportingModule = detectModulesImportingModule;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const tsquery_1 = require("@phenomnomnominal/tsquery");
6
+ const patterns_utils_1 = require("../patterns.utils");
7
+ /**
8
+ * Detects Angular module definitions that import given module.
9
+ * @param tree - the file tree to search in
10
+ * @param rootDir - the directory to start searching from
11
+ * @param module - the module to search for
12
+ * @param variablesIncludingModule - the list of variable names containing the module to search for
13
+ * @returns {MatchingModule[]} a list of found modules that import the module via direct declaration or variable
14
+ */
15
+ function detectModulesImportingModule(tree, rootDir, module, variablesIncludingModule) {
16
+ const matchingModules = [];
17
+ // Query for import in module directly
18
+ const directImportPattern = (0, patterns_utils_1.moduleImportIdentifierPattern)(module.name);
19
+ // Query for import via a variable
20
+ const importViaVariablePatterns = variablesIncludingModule.map((name) => (0, patterns_utils_1.moduleImportIdentifierPattern)(name));
21
+ (0, devkit_1.visitNotIgnoredFiles)(tree, rootDir, (file) => {
22
+ const content = tree.read(file, 'utf-8');
23
+ if (!content)
24
+ return;
25
+ const contentAst = (0, tsquery_1.ast)(content);
26
+ const allPatterns = [...importViaVariablePatterns, directImportPattern].join(', ');
27
+ const moduleNamesInFile = (0, tsquery_1.query)(contentAst, allPatterns)
28
+ .map((classDeclaration) => classDeclaration.name?.text)
29
+ .filter((className) => !!className)
30
+ .map((className) => {
31
+ return {
32
+ name: className,
33
+ filePath: file,
34
+ };
35
+ });
36
+ matchingModules.push(...moduleNamesInFile);
37
+ });
38
+ return matchingModules;
39
+ }
40
+ //# sourceMappingURL=detect-modules-importing-module.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-modules-importing-module.utils.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-migration-utils/src/lib/angular/utils/detection/detect-modules-importing-module.utils.ts"],"names":[],"mappings":";;AAeA,oEAgCC;AA/CD,uCAAuD;AACvD,uDAAsD;AAItD,sDAAiE;AAEjE;;;;;;;GAOG;AACH,SAAgB,4BAA4B,CAC1C,IAAU,EACV,OAAe,EACf,MAAc,EACd,wBAAkC;IAElC,MAAM,eAAe,GAAqB,EAAE,CAAA;IAC5C,sCAAsC;IACtC,MAAM,mBAAmB,GAAG,IAAA,8CAA6B,EAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACtE,kCAAkC;IAClC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,8CAA6B,EAAC,IAAI,CAAC,CAAC,CAAA;IAE7G,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACxC,IAAI,CAAC,OAAO;YAAE,OAAM;QAEpB,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,OAAO,CAAC,CAAA;QAE/B,MAAM,WAAW,GAAG,CAAC,GAAG,yBAAyB,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClF,MAAM,iBAAiB,GAAqB,IAAA,eAAK,EAAmB,UAAU,EAAE,WAAW,CAAC;aACzF,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC;aACtD,MAAM,CAAC,CAAC,SAAS,EAAuB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;aACvD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YACjB,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,IAAI;aACf,CAAA;QACH,CAAC,CAAC,CAAA;QACJ,eAAe,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;IAEF,OAAO,eAAe,CAAA;AACxB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Module } from '../../model/module.model';
3
+ /**
4
+ * Detects variables that include the Angular module.
5
+ * @param tree - the file tree to search in
6
+ * @param rootDir - the directory to start searching from
7
+ * @param module - the module to search for
8
+ * @returns {string[]} a list of variable names that include the module
9
+ */
10
+ export declare function detectVariablesWithModule(tree: Tree, rootDir: string, module: Module): string[];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectVariablesWithModule = detectVariablesWithModule;
4
+ const detect_variables_with_identifier_utils_1 = require("../../../utils/detection/detect-variables-with-identifier.utils");
5
+ /**
6
+ * Detects variables that include the Angular module.
7
+ * @param tree - the file tree to search in
8
+ * @param rootDir - the directory to start searching from
9
+ * @param module - the module to search for
10
+ * @returns {string[]} a list of variable names that include the module
11
+ */
12
+ function detectVariablesWithModule(tree, rootDir, module) {
13
+ return (0, detect_variables_with_identifier_utils_1.detectVariablesWithIdentifier)(tree, rootDir, module.name);
14
+ }
15
+ //# sourceMappingURL=detect-variables-with-module.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-variables-with-module.utils.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-migration-utils/src/lib/angular/utils/detection/detect-variables-with-module.utils.ts"],"names":[],"mappings":";;AAWA,8DAEC;AAZD,4HAA+G;AAG/G;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAAC,IAAU,EAAE,OAAe,EAAE,MAAc;IACnF,OAAO,IAAA,sEAA6B,EAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;AAClE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Provider } from '../../model/provider.model';
3
+ /**
4
+ * Detects variables that include the Angular provider.
5
+ * @param tree - the file tree to search in
6
+ * @param rootDir - the directory to start searching from
7
+ * @param provider - the provider to search for
8
+ * @returns {string[]} a list of variable names that include the provider
9
+ */
10
+ export declare function detectVariablesWithProvider(tree: Tree, rootDir: string, provider: Provider): string[];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectVariablesWithProvider = detectVariablesWithProvider;
4
+ const detect_variables_with_identifier_utils_1 = require("../../../utils/detection/detect-variables-with-identifier.utils");
5
+ /**
6
+ * Detects variables that include the Angular provider.
7
+ * @param tree - the file tree to search in
8
+ * @param rootDir - the directory to start searching from
9
+ * @param provider - the provider to search for
10
+ * @returns {string[]} a list of variable names that include the provider
11
+ */
12
+ function detectVariablesWithProvider(tree, rootDir, provider) {
13
+ return (0, detect_variables_with_identifier_utils_1.detectVariablesWithIdentifier)(tree, rootDir, provider.name);
14
+ }
15
+ //# sourceMappingURL=detect-variables-with-provider.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-variables-with-provider.utils.js","sourceRoot":"","sources":["../../../../../../../../libs/nx-migration-utils/src/lib/angular/utils/detection/detect-variables-with-provider.utils.ts"],"names":[],"mappings":";;AAWA,kEAEC;AAZD,4HAA+G;AAG/G;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAAC,IAAU,EAAE,OAAe,EAAE,QAAkB;IACzF,OAAO,IAAA,sEAA6B,EAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;AACpE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Tree } from '@nx/devkit';
2
+ import { Provider } from '../../model/provider.model';
3
+ /**
4
+ * Modify the file content so the import for Angular provider exists if it was not present already.
5
+ * @param tree - the file tree used for file content reading
6
+ * @param filePath - the path to a file to validate and update
7
+ * @param provider - angular provider to import
8
+ */
9
+ export declare function addProviderImportIfDoesNotExist(tree: Tree, filePath: string, provider: Provider): void;