@onecx/nx-migration-utils 6.0.0-rc.9 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -2
- package/src/index.d.ts +20 -2
- package/src/index.js +20 -2
- package/src/index.js.map +1 -1
- package/src/lib/angular/html-templates.utils.d.ts +48 -0
- package/src/lib/angular/html-templates.utils.js +108 -0
- package/src/lib/angular/html-templates.utils.js.map +1 -0
- package/src/lib/angular/index.d.ts +16 -0
- package/src/lib/angular/index.js +20 -0
- package/src/lib/angular/index.js.map +1 -1
- package/src/lib/angular/model/matching-module.model.d.ts +4 -0
- package/src/lib/angular/model/matching-module.model.js +3 -0
- package/src/lib/angular/model/matching-module.model.js.map +1 -0
- package/src/lib/angular/model/module.model.d.ts +3 -0
- package/src/lib/angular/model/module.model.js +3 -0
- package/src/lib/angular/model/module.model.js.map +1 -0
- package/src/lib/angular/model/provider.model.d.ts +4 -0
- package/src/lib/angular/model/provider.model.js +3 -0
- package/src/lib/angular/model/provider.model.js.map +1 -0
- package/src/lib/angular/parameters.utils.d.ts +11 -0
- package/src/lib/angular/parameters.utils.js +49 -0
- package/src/lib/angular/parameters.utils.js.map +1 -0
- package/src/lib/angular/replacement-in-files.utils.d.ts +17 -0
- package/src/lib/angular/replacement-in-files.utils.js +52 -0
- package/src/lib/angular/replacement-in-files.utils.js.map +1 -0
- package/src/lib/angular/utils/detection/detect-modules-importing-module.utils.d.ts +12 -0
- package/src/lib/angular/utils/detection/detect-modules-importing-module.utils.js +40 -0
- package/src/lib/angular/utils/detection/detect-modules-importing-module.utils.js.map +1 -0
- package/src/lib/angular/utils/detection/detect-variables-with-module.utils.d.ts +10 -0
- package/src/lib/angular/utils/detection/detect-variables-with-module.utils.js +15 -0
- package/src/lib/angular/utils/detection/detect-variables-with-module.utils.js.map +1 -0
- package/src/lib/angular/utils/detection/detect-variables-with-provider.utils.d.ts +10 -0
- package/src/lib/angular/utils/detection/detect-variables-with-provider.utils.js +15 -0
- package/src/lib/angular/utils/detection/detect-variables-with-provider.utils.js.map +1 -0
- package/src/lib/angular/utils/modification/add-provider-import-if-does-not-exist.utils.d.ts +9 -0
- package/src/lib/angular/utils/modification/add-provider-import-if-does-not-exist.utils.js +24 -0
- package/src/lib/angular/utils/modification/add-provider-import-if-does-not-exist.utils.js.map +1 -0
- package/src/lib/angular/utils/modification/add-provider-import-in-file.utils.d.ts +8 -0
- package/src/lib/angular/utils/modification/add-provider-import-in-file.utils.js +25 -0
- package/src/lib/angular/utils/modification/add-provider-import-in-file.utils.js.map +1 -0
- package/src/lib/angular/utils/modification/add-provider-in-module-if-does-not-exist.utils.d.ts +11 -0
- package/src/lib/angular/utils/modification/add-provider-in-module-if-does-not-exist.utils.js +25 -0
- package/src/lib/angular/utils/modification/add-provider-in-module-if-does-not-exist.utils.js.map +1 -0
- package/src/lib/angular/utils/modification/add-provider-in-module.utils.d.ts +10 -0
- package/src/lib/angular/utils/modification/add-provider-in-module.utils.js +29 -0
- package/src/lib/angular/utils/modification/add-provider-in-module.utils.js.map +1 -0
- package/src/lib/angular/utils/patterns.utils.d.ts +26 -0
- package/src/lib/angular/utils/patterns.utils.js +42 -0
- package/src/lib/angular/utils/patterns.utils.js.map +1 -0
- package/src/lib/angular/utils/validation/is-provider-import-in-file.utils.d.ts +8 -0
- package/src/lib/angular/utils/validation/is-provider-import-in-file.utils.js +19 -0
- package/src/lib/angular/utils/validation/is-provider-import-in-file.utils.js.map +1 -0
- package/src/lib/angular/utils/validation/is-provider-in-module.utils.d.ts +11 -0
- package/src/lib/angular/utils/validation/is-provider-in-module.utils.js +22 -0
- package/src/lib/angular/utils/validation/is-provider-in-module.utils.js.map +1 -0
- package/src/lib/common-migrations/common-migrate-onecx-to-v6.utils.d.ts +2 -0
- package/src/lib/common-migrations/common-migrate-onecx-to-v6.utils.js +278 -0
- package/src/lib/common-migrations/common-migrate-onecx-to-v6.utils.js.map +1 -0
- package/src/lib/utils/detect-method-calls-in-files.d.ts +0 -8
- package/src/lib/utils/detect-method-calls-in-files.js +0 -28
- package/src/lib/utils/detect-method-calls-in-files.js.map +1 -1
- package/src/lib/utils/detect-method-calls-in-files.utils.d.ts +20 -0
- package/src/lib/utils/detect-method-calls-in-files.utils.js +138 -0
- package/src/lib/utils/detect-method-calls-in-files.utils.js.map +1 -0
- package/src/lib/utils/detection/detect-variables-with-identifier.utils.d.ts +9 -0
- package/src/lib/utils/detection/detect-variables-with-identifier.utils.js +27 -0
- package/src/lib/utils/detection/detect-variables-with-identifier.utils.js.map +1 -0
- package/src/lib/utils/import-statements.utils.d.ts +137 -0
- package/src/lib/utils/import-statements.utils.js +319 -0
- package/src/lib/utils/import-statements.utils.js.map +1 -0
- package/src/lib/utils/modification/add-new-import.utils.d.ts +8 -0
- package/src/lib/utils/modification/add-new-import.utils.js +14 -0
- package/src/lib/utils/modification/add-new-import.utils.js.map +1 -0
- package/src/lib/utils/modification/add-to-first-import.utils.d.ts +8 -0
- package/src/lib/utils/modification/add-to-first-import.utils.js +21 -0
- package/src/lib/utils/modification/add-to-first-import.utils.js.map +1 -0
- package/src/lib/utils/modification/remove-import-specifier.utils.d.ts +9 -0
- package/src/lib/utils/modification/remove-import-specifier.utils.js +33 -0
- package/src/lib/utils/modification/remove-import-specifier.utils.js.map +1 -0
- package/src/lib/utils/modification/remove-json-references.utils.d.ts +11 -0
- package/src/lib/utils/modification/remove-json-references.utils.js +34 -0
- package/src/lib/utils/modification/remove-json-references.utils.js.map +1 -0
- package/src/lib/utils/modification/replace-tag-in-html.utils.d.ts +9 -0
- package/src/lib/utils/modification/replace-tag-in-html.utils.js +29 -0
- package/src/lib/utils/modification/replace-tag-in-html.utils.js.map +1 -0
- package/src/lib/utils/modification/update-json-files.utils.d.ts +18 -0
- package/src/lib/utils/modification/update-json-files.utils.js +28 -0
- package/src/lib/utils/modification/update-json-files.utils.js.map +1 -0
- package/src/lib/utils/modification/update-style-sheet.utils.d.ts +11 -0
- package/src/lib/utils/modification/update-style-sheet.utils.js +23 -0
- package/src/lib/utils/modification/update-style-sheet.utils.js.map +1 -0
- package/src/lib/utils/modification/update-style-sheets.utils.d.ts +20 -0
- package/src/lib/utils/modification/update-style-sheets.utils.js +31 -0
- package/src/lib/utils/modification/update-style-sheets.utils.js.map +1 -0
- package/src/lib/utils/patterns.utils.d.ts +31 -0
- package/src/lib/utils/patterns.utils.js +51 -0
- package/src/lib/utils/patterns.utils.js.map +1 -0
- package/src/lib/utils/print-warnings.d.ts +0 -5
- package/src/lib/utils/print-warnings.js +0 -5
- package/src/lib/utils/print-warnings.js.map +1 -1
- package/src/lib/utils/print-warnings.utils.d.ts +6 -0
- package/src/lib/utils/print-warnings.utils.js +15 -0
- package/src/lib/utils/print-warnings.utils.js.map +1 -0
- package/src/lib/utils/typescript-files.utils.d.ts +20 -0
- package/src/lib/utils/typescript-files.utils.js +57 -0
- package/src/lib/utils/typescript-files.utils.js.map +1 -0
- package/src/lib/utils/update-gitignore.utils.d.ts +9 -0
- package/src/lib/utils/update-gitignore.utils.js +42 -0
- package/src/lib/utils/update-gitignore.utils.js.map +1 -0
- package/src/lib/utils/validation/has-html-tag.utils.d.ts +10 -0
- package/src/lib/utils/validation/has-html-tag.utils.js +29 -0
- package/src/lib/utils/validation/has-html-tag.utils.js.map +1 -0
- package/src/lib/utils/validation/is-file-style-sheet.utils.d.ts +8 -0
- package/src/lib/utils/validation/is-file-style-sheet.utils.js +14 -0
- package/src/lib/utils/validation/is-file-style-sheet.utils.js.map +1 -0
- package/src/lib/utils/validation/is-import-in-content.utils.d.ts +7 -0
- package/src/lib/utils/validation/is-import-in-content.utils.js +17 -0
- package/src/lib/utils/validation/is-import-in-content.utils.js.map +1 -0
- package/src/lib/utils/validation/is-import-in-file-content.utils.d.ts +8 -0
- package/src/lib/utils/validation/is-import-in-file-content.utils.js +18 -0
- package/src/lib/utils/validation/is-import-in-file-content.utils.js.map +1 -0
- package/src/lib/utils/validation/is-namespace-import-in-content.utils.d.ts +7 -0
- package/src/lib/utils/validation/is-namespace-import-in-content.utils.js +17 -0
- package/src/lib/utils/validation/is-namespace-import-in-content.utils.js.map +1 -0
- package/src/test-setup.d.ts +1 -0
- package/src/test-setup.js +6 -0
- package/src/test-setup.js.map +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import postcss from 'postcss';
|
|
3
|
+
/**
|
|
4
|
+
* Updates all stylesheet files within a specified directory using a PostCSS-based updater function.
|
|
5
|
+
* Only processes files that are identified as stylesheets (e.g., .css, .scss).
|
|
6
|
+
* Optionally logs warnings if certain content conditions are met.
|
|
7
|
+
*
|
|
8
|
+
* @param tree - The Nx Tree (virtual file system).
|
|
9
|
+
* @param dirPath - The directory path to search for stylesheet files.
|
|
10
|
+
* @param updater - A function that receives the parsed PostCSS root and returns the updated stylesheet as a string.
|
|
11
|
+
* @param options - Optional settings:
|
|
12
|
+
* - warn: Whether to print warnings.
|
|
13
|
+
* - warning: The warning message to display.
|
|
14
|
+
* - contentCondition: A string to match in file paths for triggering warnings.
|
|
15
|
+
*/
|
|
16
|
+
export declare function updateStyleSheets(tree: Tree, dirPath: string, updater: (styleSheetContent: postcss.Root) => string, options?: {
|
|
17
|
+
warn: boolean;
|
|
18
|
+
warning: string;
|
|
19
|
+
contentCondition: string;
|
|
20
|
+
}): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateStyleSheets = updateStyleSheets;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const print_warnings_utils_1 = require("../print-warnings.utils");
|
|
6
|
+
const is_file_style_sheet_utils_1 = require("../validation/is-file-style-sheet.utils");
|
|
7
|
+
const update_style_sheet_utils_1 = require("./update-style-sheet.utils");
|
|
8
|
+
/**
|
|
9
|
+
* Updates all stylesheet files within a specified directory using a PostCSS-based updater function.
|
|
10
|
+
* Only processes files that are identified as stylesheets (e.g., .css, .scss).
|
|
11
|
+
* Optionally logs warnings if certain content conditions are met.
|
|
12
|
+
*
|
|
13
|
+
* @param tree - The Nx Tree (virtual file system).
|
|
14
|
+
* @param dirPath - The directory path to search for stylesheet files.
|
|
15
|
+
* @param updater - A function that receives the parsed PostCSS root and returns the updated stylesheet as a string.
|
|
16
|
+
* @param options - Optional settings:
|
|
17
|
+
* - warn: Whether to print warnings.
|
|
18
|
+
* - warning: The warning message to display.
|
|
19
|
+
* - contentCondition: A string to match in file paths for triggering warnings.
|
|
20
|
+
*/
|
|
21
|
+
function updateStyleSheets(tree, dirPath, updater, options) {
|
|
22
|
+
const foundInFiles = [];
|
|
23
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, dirPath, (file) => {
|
|
24
|
+
if ((0, is_file_style_sheet_utils_1.isStyleSheet)(file)) {
|
|
25
|
+
options && file.includes(options.contentCondition) && foundInFiles.push(file);
|
|
26
|
+
(0, update_style_sheet_utils_1.updateStyleSheet)(tree, file, updater);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
options?.warn && (0, print_warnings_utils_1.printWarnings)(options.warning, foundInFiles);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=update-style-sheets.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-style-sheets.utils.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/utils/modification/update-style-sheets.utils.ts"],"names":[],"mappings":";;AAmBA,8CAgBC;AAnCD,uCAAuD;AACvD,kEAAuD;AACvD,uFAAsE;AACtE,yEAA6D;AAG7D;;;;;;;;;;;;GAYG;AACH,SAAgB,iBAAiB,CAC/B,IAAU,EACV,OAAe,EACf,OAAoD,EACpD,OAAsE;IAEtE,MAAM,YAAY,GAAa,EAAE,CAAA;IAEjC,IAAA,6BAAoB,EAAC,IAAI,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;QAC3C,IAAI,IAAA,wCAAY,EAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC7E,IAAA,2CAAgB,EAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,IAAI,IAAI,IAAA,oCAAa,EAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a pattern to look for a variable containing the identifier
|
|
3
|
+
* @param identifierName - identifier to look for
|
|
4
|
+
* @returns {string} ast query pattern
|
|
5
|
+
*/
|
|
6
|
+
export declare function variableContainingIdentifierPattern(identifierName: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a pattern to look for import.
|
|
9
|
+
* @param importPath - import path to look for
|
|
10
|
+
* @returns {string} ast query pattern
|
|
11
|
+
*/
|
|
12
|
+
export declare function importPattern(importPath: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a pattern to look for namespace import (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#namespace_import).
|
|
15
|
+
* @param importPath - import path to look for
|
|
16
|
+
* @returns {string} ast query pattern
|
|
17
|
+
*/
|
|
18
|
+
export declare function importNamespacePattern(importPath: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a pattern to look for named import (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#named_import).
|
|
21
|
+
* @param importPath - import path to look for
|
|
22
|
+
* @returns {string} ast query pattern
|
|
23
|
+
*/
|
|
24
|
+
export declare function importNamedImportsPattern(importPath: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a pattern to look for import specifier.
|
|
27
|
+
* @param importPath - import path to look for
|
|
28
|
+
* @param specifier - specifier to look for, e.g., "MyClass"
|
|
29
|
+
* @returns {string} ast query pattern
|
|
30
|
+
*/
|
|
31
|
+
export declare function importSpecifierPattern(importPath: string, specifier: string): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// General patterns
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.variableContainingIdentifierPattern = variableContainingIdentifierPattern;
|
|
5
|
+
exports.importPattern = importPattern;
|
|
6
|
+
exports.importNamespacePattern = importNamespacePattern;
|
|
7
|
+
exports.importNamedImportsPattern = importNamedImportsPattern;
|
|
8
|
+
exports.importSpecifierPattern = importSpecifierPattern;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a pattern to look for a variable containing the identifier
|
|
11
|
+
* @param identifierName - identifier to look for
|
|
12
|
+
* @returns {string} ast query pattern
|
|
13
|
+
*/
|
|
14
|
+
function variableContainingIdentifierPattern(identifierName) {
|
|
15
|
+
return `VariableDeclaration:has(Identifier[name=${identifierName}])`;
|
|
16
|
+
}
|
|
17
|
+
// Import patterns
|
|
18
|
+
/**
|
|
19
|
+
* Creates a pattern to look for import.
|
|
20
|
+
* @param importPath - import path to look for
|
|
21
|
+
* @returns {string} ast query pattern
|
|
22
|
+
*/
|
|
23
|
+
function importPattern(importPath) {
|
|
24
|
+
return `ImportDeclaration:has(StringLiteral[value=${importPath}])`;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a pattern to look for namespace import (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#namespace_import).
|
|
28
|
+
* @param importPath - import path to look for
|
|
29
|
+
* @returns {string} ast query pattern
|
|
30
|
+
*/
|
|
31
|
+
function importNamespacePattern(importPath) {
|
|
32
|
+
return `ImportDeclaration:has(StringLiteral[value=${importPath}]):has(NamespaceImport)`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a pattern to look for named import (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#named_import).
|
|
36
|
+
* @param importPath - import path to look for
|
|
37
|
+
* @returns {string} ast query pattern
|
|
38
|
+
*/
|
|
39
|
+
function importNamedImportsPattern(importPath) {
|
|
40
|
+
return `${importPattern(importPath)} NamedImports`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a pattern to look for import specifier.
|
|
44
|
+
* @param importPath - import path to look for
|
|
45
|
+
* @param specifier - specifier to look for, e.g., "MyClass"
|
|
46
|
+
* @returns {string} ast query pattern
|
|
47
|
+
*/
|
|
48
|
+
function importSpecifierPattern(importPath, specifier) {
|
|
49
|
+
return `ImportDeclaration:has(StringLiteral[value=${importPath}]):has(ImportSpecifier:has(Identifier[name=${specifier}]))`;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=patterns.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.utils.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/utils/patterns.utils.ts"],"names":[],"mappings":";AAAA,mBAAmB;;AAOnB,kFAEC;AASD,sCAEC;AAOD,wDAEC;AAOD,8DAEC;AAQD,wDAEC;AA9CD;;;;GAIG;AACH,SAAgB,mCAAmC,CAAC,cAAsB;IACxE,OAAO,2CAA2C,cAAc,IAAI,CAAA;AACtE,CAAC;AAED,kBAAkB;AAElB;;;;GAIG;AACH,SAAgB,aAAa,CAAC,UAAkB;IAC9C,OAAO,6CAA6C,UAAU,IAAI,CAAA;AACpE,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,UAAkB;IACvD,OAAO,6CAA6C,UAAU,yBAAyB,CAAA;AACzF,CAAC;AAED;;;;GAIG;AACH,SAAgB,yBAAyB,CAAC,UAAkB;IAC1D,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,eAAe,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAC,UAAkB,EAAE,SAAiB;IAC1E,OAAO,6CAA6C,UAAU,8CAA8C,SAAS,KAAK,CAAA;AAC5H,CAAC"}
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printWarnings = printWarnings;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
/**
|
|
6
|
-
* Prints a warning message if there are affected files.
|
|
7
|
-
* @param warning The warning message to print.
|
|
8
|
-
* @param affectedFiles An array of affected file paths.
|
|
9
|
-
*/
|
|
10
5
|
function printWarnings(warning, affectedFiles) {
|
|
11
6
|
if (affectedFiles.length > 0) {
|
|
12
7
|
devkit_1.logger.warn(warning);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-warnings.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/utils/print-warnings.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"print-warnings.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/utils/print-warnings.ts"],"names":[],"mappings":";;AACA,sCAQC;AATD,uCAAmC;AACnC,SAAgB,aAAa,CAAC,OAAe,EAAE,aAAuB;IAClE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACpB,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACxB,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC7B,eAAM,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;IACJ,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printWarnings = printWarnings;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* Prints a warning message if there are affected files.
|
|
7
|
+
* @param warning The warning message to print.
|
|
8
|
+
* @param affectedFiles An array of affected file paths.
|
|
9
|
+
*/
|
|
10
|
+
function printWarnings(warning, affectedFiles) {
|
|
11
|
+
if (affectedFiles.length > 0) {
|
|
12
|
+
devkit_1.logger.warn(`${warning} Found in: ${affectedFiles.join(',')}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=print-warnings.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"print-warnings.utils.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/utils/print-warnings.utils.ts"],"names":[],"mappings":";;AAOA,sCAIC;AAXD,uCAAmC;AAEnC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,OAAe,EAAE,aAAuB;IACpE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,eAAM,CAAC,IAAI,CAAC,GAAG,OAAO,cAAc,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a file's content matches a given tsquery string.
|
|
3
|
+
* @param fileContent - The content of the TypeScript file.
|
|
4
|
+
* @param queryStr - A tsquery selector string.
|
|
5
|
+
* @returns True if the file matches the query; otherwise, false.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fileMatchesQuery(fileContent: string, queryStr: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Removes empty slots (i.e., omitted expressions like `[1,,2]`) from all array literals
|
|
10
|
+
* in a given TypeScript code string.
|
|
11
|
+
* @param code - The TypeScript source code as a string.
|
|
12
|
+
* @returns A new string with all empty array slots removed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function removeEmptySlotsFromArrays(code: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Determines whether a given string is likely to represent a file path.
|
|
17
|
+
* @param input - The input string to evaluate.
|
|
18
|
+
* @returns `true` if the input appears to be a file path, otherwise `false`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isFilePath(input: string): boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fileMatchesQuery = fileMatchesQuery;
|
|
4
|
+
exports.removeEmptySlotsFromArrays = removeEmptySlotsFromArrays;
|
|
5
|
+
exports.isFilePath = isFilePath;
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const typescript_1 = require("typescript");
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a file's content matches a given tsquery string.
|
|
11
|
+
* @param fileContent - The content of the TypeScript file.
|
|
12
|
+
* @param queryStr - A tsquery selector string.
|
|
13
|
+
* @returns True if the file matches the query; otherwise, false.
|
|
14
|
+
*/
|
|
15
|
+
function fileMatchesQuery(fileContent, queryStr) {
|
|
16
|
+
try {
|
|
17
|
+
const contentAst = (0, tsquery_1.ast)(fileContent);
|
|
18
|
+
return (0, tsquery_1.query)(contentAst, queryStr).length > 0;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Removes empty slots (i.e., omitted expressions like `[1,,2]`) from all array literals
|
|
26
|
+
* in a given TypeScript code string.
|
|
27
|
+
* @param code - The TypeScript source code as a string.
|
|
28
|
+
* @returns A new string with all empty array slots removed.
|
|
29
|
+
*/
|
|
30
|
+
function removeEmptySlotsFromArrays(code) {
|
|
31
|
+
try {
|
|
32
|
+
return (0, tsquery_1.replace)(code, 'ArrayLiteralExpression', (node) => {
|
|
33
|
+
if (!(0, typescript_1.isArrayLiteralExpression)(node))
|
|
34
|
+
return null;
|
|
35
|
+
const elements = node.elements.filter((expression) => expression.kind !== typescript_1.SyntaxKind.OmittedExpression);
|
|
36
|
+
if (elements.length === node.elements.length)
|
|
37
|
+
return null;
|
|
38
|
+
const updatedArray = typescript_1.factory.updateArrayLiteralExpression(node, elements);
|
|
39
|
+
return (0, typescript_1.createPrinter)().printNode(typescript_1.EmitHint.Unspecified, updatedArray, node.getSourceFile());
|
|
40
|
+
}, typescript_1.ScriptKind.TS);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error(`Failed to remove empty array slots: `, error);
|
|
44
|
+
return code;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Determines whether a given string is likely to represent a file path.
|
|
49
|
+
* @param input - The input string to evaluate.
|
|
50
|
+
* @returns `true` if the input appears to be a file path, otherwise `false`.
|
|
51
|
+
*/
|
|
52
|
+
function isFilePath(input) {
|
|
53
|
+
const hasExtension = !!(0, path_1.extname)(input);
|
|
54
|
+
const looksLikePath = input.includes('/') || (0, path_1.isAbsolute)(input);
|
|
55
|
+
return hasExtension && looksLikePath;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=typescript-files.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-files.utils.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/utils/typescript-files.utils.ts"],"names":[],"mappings":";;AAUA,4CAOC;AAQD,gEAqBC;AAOD,gCAIC;AAzDD,uDAA+D;AAC/D,+BAA0C;AAC1C,2CAA+G;AAE/G;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,WAAmB,EAAE,QAAgB;IACpE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,WAAW,CAAC,CAAA;QACnC,OAAO,IAAA,eAAK,EAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,IAAY;IACrD,IAAI,CAAC;QACH,OAAO,IAAA,iBAAO,EACZ,IAAI,EACJ,wBAAwB,EACxB,CAAC,IAAI,EAAE,EAAE;YACP,IAAI,CAAC,IAAA,qCAAwB,EAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAA;YAEhD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,uBAAU,CAAC,iBAAiB,CAAC,CAAA;YAEvG,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,QAAQ,CAAC,MAAM;gBAAE,OAAO,IAAI,CAAA;YAEzD,MAAM,YAAY,GAAG,oBAAO,CAAC,4BAA4B,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YACzE,OAAO,IAAA,0BAAa,GAAE,CAAC,SAAS,CAAC,qBAAQ,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;QAC5F,CAAC,EACD,uBAAU,CAAC,EAAE,CACd,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAA;QAC5D,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,UAAU,CAAC,KAAa;IACtC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAA,cAAO,EAAC,KAAK,CAAC,CAAA;IACrC,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,IAAA,iBAAU,EAAC,KAAK,CAAC,CAAA;IAC9D,OAAO,YAAY,IAAI,aAAa,CAAA;AACtC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Adds an entry to .gitignore if it doesn't already exist.
|
|
4
|
+
*/
|
|
5
|
+
export declare function addGitignoreEntry(tree: Tree, entry: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Removes an entry from .gitignore if it exists.
|
|
8
|
+
*/
|
|
9
|
+
export declare function removeGitignoreEntry(tree: Tree, entry: string): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addGitignoreEntry = addGitignoreEntry;
|
|
4
|
+
exports.removeGitignoreEntry = removeGitignoreEntry;
|
|
5
|
+
const normalizeLine = (line) => line.trim();
|
|
6
|
+
/**
|
|
7
|
+
* Adds an entry to .gitignore if it doesn't already exist.
|
|
8
|
+
*/
|
|
9
|
+
function addGitignoreEntry(tree, entry) {
|
|
10
|
+
const gitignorePath = '.gitignore';
|
|
11
|
+
const normalizedEntry = normalizeLine(entry);
|
|
12
|
+
if (!tree.exists(gitignorePath)) {
|
|
13
|
+
tree.write(gitignorePath, `${normalizedEntry}\n`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const content = tree.read(gitignorePath, 'utf-8');
|
|
17
|
+
if (!content)
|
|
18
|
+
return;
|
|
19
|
+
const lines = content.split('\n').map(normalizeLine);
|
|
20
|
+
if (!lines.includes(normalizedEntry)) {
|
|
21
|
+
const updatedContent = content.trimEnd() + `\n${normalizedEntry}\n`;
|
|
22
|
+
tree.write(gitignorePath, updatedContent);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Removes an entry from .gitignore if it exists.
|
|
27
|
+
*/
|
|
28
|
+
function removeGitignoreEntry(tree, entry) {
|
|
29
|
+
const gitignorePath = '.gitignore';
|
|
30
|
+
const normalizedEntry = normalizeLine(entry);
|
|
31
|
+
if (!tree.exists(gitignorePath))
|
|
32
|
+
return;
|
|
33
|
+
const content = tree.read(gitignorePath, 'utf-8');
|
|
34
|
+
if (!content)
|
|
35
|
+
return;
|
|
36
|
+
const lines = content.split('\n');
|
|
37
|
+
const filteredLines = lines.filter((line) => normalizeLine(line) !== normalizedEntry);
|
|
38
|
+
if (lines.length !== filteredLines.length) {
|
|
39
|
+
tree.write(gitignorePath, filteredLines.join('\n') + '\n');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=update-gitignore.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-gitignore.utils.js","sourceRoot":"","sources":["../../../../../../libs/nx-migration-utils/src/lib/utils/update-gitignore.utils.ts"],"names":[],"mappings":";;AAOA,8CAkBC;AAKD,oDAgBC;AA5CD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;AAEnD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,IAAU,EAAE,KAAa;IACzD,MAAM,aAAa,GAAG,YAAY,CAAA;IAClC,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IAE5C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,GAAG,eAAe,IAAI,CAAC,CAAA;QACjD,OAAM;IACR,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACjD,IAAI,CAAC,OAAO;QAAE,OAAM;IAEpB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAEpD,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QACrC,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,KAAK,eAAe,IAAI,CAAA;QACnE,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,cAAc,CAAC,CAAA;IAC3C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,IAAU,EAAE,KAAa;IAC5D,MAAM,aAAa,GAAG,YAAY,CAAA;IAClC,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA;IAE5C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;QAAE,OAAM;IAEvC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACjD,IAAI,CAAC,OAAO;QAAE,OAAM;IAEpB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEjC,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,eAAe,CAAC,CAAA;IAErF,IAAI,KAAK,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,EAAE,CAAC;QAC1C,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;IAC5D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a specific tag exists in HTML content or an HTML file using Nx Tree.
|
|
4
|
+
* Automatically detects if the input is a HTML file path.
|
|
5
|
+
* @param tree - The Nx Tree (virtual file system).
|
|
6
|
+
* @param input - HTML string or file path.
|
|
7
|
+
* @param tagName - The tag name to search for.
|
|
8
|
+
* @returns True if the tag is found, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hasHtmlTag(tree: Tree, input: string, tagName: string): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasHtmlTag = hasHtmlTag;
|
|
4
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
+
const typescript_files_utils_1 = require("../typescript-files.utils");
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a specific tag exists in HTML content or an HTML file using Nx Tree.
|
|
8
|
+
* Automatically detects if the input is a HTML file path.
|
|
9
|
+
* @param tree - The Nx Tree (virtual file system).
|
|
10
|
+
* @param input - HTML string or file path.
|
|
11
|
+
* @param tagName - The tag name to search for.
|
|
12
|
+
* @returns True if the tag is found, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function hasHtmlTag(tree, input, tagName) {
|
|
15
|
+
try {
|
|
16
|
+
const isHtmlFile = (0, typescript_files_utils_1.isFilePath)(input) && input.endsWith('.html');
|
|
17
|
+
const html = isHtmlFile ? tree.read(input, 'utf-8') : input;
|
|
18
|
+
if (!html) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const root = (0, node_html_parser_1.parse)(html);
|
|
22
|
+
return root.querySelectorAll(tagName).length > 0;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
console.error(`Error checking for tag "${tagName}": `, error);
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=has-html-tag.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-html-tag.utils.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/utils/validation/has-html-tag.utils.ts"],"names":[],"mappings":";;AAYA,gCAgBC;AA3BD,uDAAwC;AACxC,sEAAsD;AAEtD;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,IAAU,EAAE,KAAa,EAAE,OAAe;IACnE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAA,mCAAU,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAC/D,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAE3D,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,IAAI,GAAG,IAAA,wBAAK,EAAC,IAAI,CAAC,CAAA;QAExB,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,OAAO,KAAK,EAAE,KAAK,CAAC,CAAA;QAC7D,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines whether a given file path points to a stylesheet file.
|
|
3
|
+
* Supports `.css` and `.scss` extensions.
|
|
4
|
+
*
|
|
5
|
+
* @param filePath - The file path to check.
|
|
6
|
+
* @returns True if the file is a stylesheet, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isStyleSheet(filePath: string): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStyleSheet = isStyleSheet;
|
|
4
|
+
/**
|
|
5
|
+
* Determines whether a given file path points to a stylesheet file.
|
|
6
|
+
* Supports `.css` and `.scss` extensions.
|
|
7
|
+
*
|
|
8
|
+
* @param filePath - The file path to check.
|
|
9
|
+
* @returns True if the file is a stylesheet, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
function isStyleSheet(filePath) {
|
|
12
|
+
return filePath.endsWith('.css') || filePath.endsWith('.scss');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=is-file-style-sheet.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-file-style-sheet.utils.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/utils/validation/is-file-style-sheet.utils.ts"],"names":[],"mappings":";;AAOA,oCAEC;AATD;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,QAAgB;IAC3C,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAChE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if file contains import.
|
|
3
|
+
* @param fileContent - the content of the file to check
|
|
4
|
+
* @param importPath - import path to look for
|
|
5
|
+
* @returns {boolean} if file contains the import
|
|
6
|
+
*/
|
|
7
|
+
export declare function isImportInContent(fileContent: string, importPath: string): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isImportInContent = isImportInContent;
|
|
4
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
5
|
+
const patterns_utils_1 = require("../patterns.utils");
|
|
6
|
+
/**
|
|
7
|
+
* Checks if file contains import.
|
|
8
|
+
* @param fileContent - the content of the file to check
|
|
9
|
+
* @param importPath - import path to look for
|
|
10
|
+
* @returns {boolean} if file contains the import
|
|
11
|
+
*/
|
|
12
|
+
function isImportInContent(fileContent, importPath) {
|
|
13
|
+
const contentAst = (0, tsquery_1.ast)(fileContent);
|
|
14
|
+
const imports = (0, tsquery_1.query)(contentAst, (0, patterns_utils_1.importPattern)(importPath));
|
|
15
|
+
return imports.length > 0;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=is-import-in-content.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-import-in-content.utils.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/utils/validation/is-import-in-content.utils.ts"],"names":[],"mappings":";;AASA,8CAMC;AAfD,uDAAsD;AACtD,sDAAiD;AAEjD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,WAAmB,EAAE,UAAkB;IACvE,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,WAAW,CAAC,CAAA;IAEnC,MAAM,OAAO,GAAG,IAAA,eAAK,EAAoB,UAAU,EAAE,IAAA,8BAAa,EAAC,UAAU,CAAC,CAAC,CAAA;IAE/E,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if file contains import specifier.
|
|
3
|
+
* @param fileContent - the content of the file to check
|
|
4
|
+
* @param importPath - import path to look for
|
|
5
|
+
* @param specifier - import specifier to look for
|
|
6
|
+
* @returns {boolean} if file contains the import
|
|
7
|
+
*/
|
|
8
|
+
export declare function isImportSpecifierInContent(fileContent: string, importPath: string, specifier: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isImportSpecifierInContent = isImportSpecifierInContent;
|
|
4
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
5
|
+
const patterns_utils_1 = require("../patterns.utils");
|
|
6
|
+
/**
|
|
7
|
+
* Checks if file contains import specifier.
|
|
8
|
+
* @param fileContent - the content of the file to check
|
|
9
|
+
* @param importPath - import path to look for
|
|
10
|
+
* @param specifier - import specifier to look for
|
|
11
|
+
* @returns {boolean} if file contains the import
|
|
12
|
+
*/
|
|
13
|
+
function isImportSpecifierInContent(fileContent, importPath, specifier) {
|
|
14
|
+
const contentAst = (0, tsquery_1.ast)(fileContent);
|
|
15
|
+
const imports = (0, tsquery_1.query)(contentAst, (0, patterns_utils_1.importSpecifierPattern)(importPath, specifier));
|
|
16
|
+
return imports.length > 0;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=is-import-in-file-content.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-import-in-file-content.utils.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/utils/validation/is-import-in-file-content.utils.ts"],"names":[],"mappings":";;AAUA,gEAMC;AAhBD,uDAAsD;AACtD,sDAA0D;AAE1D;;;;;;GAMG;AACH,SAAgB,0BAA0B,CAAC,WAAmB,EAAE,UAAkB,EAAE,SAAiB;IACnG,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,WAAW,CAAC,CAAA;IAEnC,MAAM,OAAO,GAAG,IAAA,eAAK,EAAoB,UAAU,EAAE,IAAA,uCAAsB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAA;IAEnG,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if file contains namespace import (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#namespace_import).
|
|
3
|
+
* @param fileContent - the content of the file to check
|
|
4
|
+
* @param importPath - import path to look for
|
|
5
|
+
* @returns {boolean} if file contains the namespace import
|
|
6
|
+
*/
|
|
7
|
+
export declare function isNamespaceImportInContent(fileContent: string, importPath: string): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNamespaceImportInContent = isNamespaceImportInContent;
|
|
4
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
5
|
+
const patterns_utils_1 = require("../patterns.utils");
|
|
6
|
+
/**
|
|
7
|
+
* Checks if file contains namespace import (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#namespace_import).
|
|
8
|
+
* @param fileContent - the content of the file to check
|
|
9
|
+
* @param importPath - import path to look for
|
|
10
|
+
* @returns {boolean} if file contains the namespace import
|
|
11
|
+
*/
|
|
12
|
+
function isNamespaceImportInContent(fileContent, importPath) {
|
|
13
|
+
const contentAst = (0, tsquery_1.ast)(fileContent);
|
|
14
|
+
const namespaceImports = (0, tsquery_1.query)(contentAst, (0, patterns_utils_1.importNamespacePattern)(importPath));
|
|
15
|
+
return namespaceImports.length > 0;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=is-namespace-import-in-content.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-namespace-import-in-content.utils.js","sourceRoot":"","sources":["../../../../../../../libs/nx-migration-utils/src/lib/utils/validation/is-namespace-import-in-content.utils.ts"],"names":[],"mappings":";;AAUA,gEAMC;AAhBD,uDAAsD;AACtD,sDAA0D;AAG1D;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,WAAmB,EAAE,UAAkB;IAChF,MAAM,UAAU,GAAG,IAAA,aAAG,EAAC,WAAW,CAAC,CAAA;IAEnC,MAAM,gBAAgB,GAAG,IAAA,eAAK,EAAoB,UAAU,EAAE,IAAA,uCAAsB,EAAC,UAAU,CAAC,CAAC,CAAA;IAEjG,OAAO,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../../../../libs/nx-migration-utils/src/test-setup.ts"],"names":[],"mappings":";;AAAA,2CAAsC;AACtC,0CAAyC;AACzC,gBAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA"}
|