@nx/angular 22.4.0-canary.20260113-246d4fd → 22.4.0-canary.20260115-21d1555
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/generators.json +2 -1
- package/package.json +10 -10
- package/src/generators/component/lib/component.js +3 -3
- package/src/generators/convert-to-rspack/lib/get-custom-webpack-config.js +7 -7
- package/src/generators/convert-to-with-mf/lib/check-name-matches.d.ts +1 -1
- package/src/generators/convert-to-with-mf/lib/check-name-matches.d.ts.map +1 -1
- package/src/generators/convert-to-with-mf/lib/check-name-matches.js +4 -6
- package/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.d.ts +1 -1
- package/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.d.ts.map +1 -1
- package/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.js +6 -10
- package/src/generators/convert-to-with-mf/lib/is-host-remote-config.d.ts +3 -3
- package/src/generators/convert-to-with-mf/lib/is-host-remote-config.d.ts.map +1 -1
- package/src/generators/convert-to-with-mf/lib/is-host-remote-config.js +11 -21
- package/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.d.ts.map +1 -1
- package/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.js +2 -2
- package/src/generators/scam-to-standalone/lib/get-component-data-from-ast.d.ts.map +1 -1
- package/src/generators/scam-to-standalone/lib/get-component-data-from-ast.js +4 -6
- package/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.d.ts.map +1 -1
- package/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.js +8 -20
- package/src/generators/scam-to-standalone/lib/selector-exists-in-ast.d.ts +1 -1
- package/src/generators/scam-to-standalone/lib/selector-exists-in-ast.d.ts.map +1 -1
- package/src/generators/scam-to-standalone/lib/selector-exists-in-ast.js +3 -3
- package/src/generators/setup-mf/lib/add-remote-to-host.js +3 -3
- package/src/generators/setup-ssr/lib/set-router-initial-navigation.js +6 -6
- package/src/generators/setup-tailwind/setup-tailwind.d.ts.map +1 -1
- package/src/generators/setup-tailwind/setup-tailwind.js +1 -0
- package/src/generators/utils/storybook-ast/component-info.d.ts.map +1 -1
- package/src/generators/utils/storybook-ast/component-info.js +13 -8
- package/src/generators/utils/storybook-ast/module-info.js +3 -3
- package/src/migrations/update-19-6-0/turn-off-dts-by-default.d.ts.map +1 -1
- package/src/migrations/update-19-6-0/turn-off-dts-by-default.js +4 -4
- package/src/migrations/update-20-2-0/migrate-mf-imports-to-new-package.js +5 -5
- package/src/migrations/update-20-2-0/migrate-with-mf-import-to-new-package.js +2 -2
- package/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.d.ts.map +1 -1
- package/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.js +9 -8
- package/src/migrations/update-21-2-0/replace-provide-server-routing.js +2 -2
- package/src/utils/get-mf-projects.d.ts.map +1 -1
- package/src/utils/get-mf-projects.js +3 -5
- package/src/utils/nx-devkit/ast-utils.d.ts.map +1 -1
- package/src/utils/nx-devkit/ast-utils.js +9 -15
- package/src/utils/nx-devkit/route-utils.d.ts.map +1 -1
- package/src/utils/nx-devkit/route-utils.js +8 -16
package/generators.json
CHANGED
|
@@ -161,7 +161,8 @@
|
|
|
161
161
|
"setup-tailwind": {
|
|
162
162
|
"factory": "./src/generators/setup-tailwind/setup-tailwind",
|
|
163
163
|
"schema": "./src/generators/setup-tailwind/schema.json",
|
|
164
|
-
"description": "Configures Tailwind CSS for an application or a buildable/publishable library."
|
|
164
|
+
"description": "Configures Tailwind CSS for an application or a buildable/publishable library.",
|
|
165
|
+
"x-deprecated": "Generating Tailwind configuration is no longer maintained. This generator will be removed in Nx 23."
|
|
165
166
|
},
|
|
166
167
|
"stories": {
|
|
167
168
|
"factory": "./src/generators/stories/stories",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/angular",
|
|
3
|
-
"version": "22.4.0-canary.
|
|
3
|
+
"version": "22.4.0-canary.20260115-21d1555",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Playwright and Cypress. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
"migrations": "./migrations.json"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@nx/devkit": "22.4.0-canary.
|
|
66
|
-
"@nx/eslint": "22.4.0-canary.
|
|
67
|
-
"@nx/js": "22.4.0-canary.
|
|
68
|
-
"@nx/module-federation": "22.4.0-canary.
|
|
69
|
-
"@nx/rspack": "22.4.0-canary.
|
|
70
|
-
"@nx/web": "22.4.0-canary.
|
|
71
|
-
"@nx/webpack": "22.4.0-canary.
|
|
72
|
-
"@nx/workspace": "22.4.0-canary.
|
|
73
|
-
"@phenomnomnominal/tsquery": "~
|
|
65
|
+
"@nx/devkit": "22.4.0-canary.20260115-21d1555",
|
|
66
|
+
"@nx/eslint": "22.4.0-canary.20260115-21d1555",
|
|
67
|
+
"@nx/js": "22.4.0-canary.20260115-21d1555",
|
|
68
|
+
"@nx/module-federation": "22.4.0-canary.20260115-21d1555",
|
|
69
|
+
"@nx/rspack": "22.4.0-canary.20260115-21d1555",
|
|
70
|
+
"@nx/web": "22.4.0-canary.20260115-21d1555",
|
|
71
|
+
"@nx/webpack": "22.4.0-canary.20260115-21d1555",
|
|
72
|
+
"@nx/workspace": "22.4.0-canary.20260115-21d1555",
|
|
73
|
+
"@phenomnomnominal/tsquery": "~6.1.4",
|
|
74
74
|
"@typescript-eslint/type-utils": "^8.0.0",
|
|
75
75
|
"enquirer": "~2.3.6",
|
|
76
76
|
"magic-string": "~0.30.2",
|
|
@@ -46,10 +46,10 @@ function shouldExportInEntryPoint(tree, entryPoint, modulePath) {
|
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
48
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
49
|
-
const {
|
|
49
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
50
50
|
const moduleImportPath = (0, path_1.getRelativeImportToFile)(entryPoint, modulePath);
|
|
51
51
|
const entryPointContent = tree.read(entryPoint, 'utf-8');
|
|
52
|
-
const entryPointAst =
|
|
53
|
-
const moduleExport =
|
|
52
|
+
const entryPointAst = ast(entryPointContent);
|
|
53
|
+
const moduleExport = query(entryPointAst, `ExportDeclaration StringLiteral[value='${moduleImportPath}']`)[0];
|
|
54
54
|
return Boolean(moduleExport);
|
|
55
55
|
}
|
|
@@ -26,13 +26,13 @@ async function getCustomWebpackConfig(tree, projectRoot, pathToCustomWebpackConf
|
|
|
26
26
|
}
|
|
27
27
|
function convertWebpackConfigToUseNxModuleFederationPlugin(webpackConfigContents) {
|
|
28
28
|
let newWebpackConfigContents = webpackConfigContents;
|
|
29
|
-
let
|
|
30
|
-
const withModuleFederationImportNodes = (0, tsquery_1.
|
|
29
|
+
let sourceFile = (0, tsquery_1.ast)(webpackConfigContents);
|
|
30
|
+
const withModuleFederationImportNodes = (0, tsquery_1.query)(sourceFile, 'ImportDeclaration:has(StringLiteral[value=@nx/module-federation/angular])');
|
|
31
31
|
if (withModuleFederationImportNodes.length > 0) {
|
|
32
32
|
const withModuleFederationImportNode = withModuleFederationImportNodes[0];
|
|
33
33
|
newWebpackConfigContents = `${webpackConfigContents.slice(0, withModuleFederationImportNode.getStart())}import { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } from '@nx/module-federation/angular';${webpackConfigContents.slice(withModuleFederationImportNode.getEnd())}`;
|
|
34
|
-
|
|
35
|
-
const exportedWithModuleFederationNodes = (0, tsquery_1.
|
|
34
|
+
sourceFile = (0, tsquery_1.ast)(newWebpackConfigContents);
|
|
35
|
+
const exportedWithModuleFederationNodes = (0, tsquery_1.query)(sourceFile, 'ExportAssignment:has(CallExpression > Identifier[name=withModuleFederation])');
|
|
36
36
|
if (exportedWithModuleFederationNodes.length > 0) {
|
|
37
37
|
const exportedWithModuleFederationNode = exportedWithModuleFederationNodes[0];
|
|
38
38
|
newWebpackConfigContents = `${newWebpackConfigContents.slice(0, exportedWithModuleFederationNode.getStart())}${newWebpackConfigContents.slice(exportedWithModuleFederationNode.getEnd())}
|
|
@@ -50,12 +50,12 @@ function convertWebpackConfigToUseNxModuleFederationPlugin(webpackConfigContents
|
|
|
50
50
|
devkit_1.logger.warn("Could not find 'export default withModuleFederation' in the webpack config file. Skipping conversion.");
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
const withModuleFederationRequireNodes = (0, tsquery_1.
|
|
53
|
+
const withModuleFederationRequireNodes = (0, tsquery_1.query)(sourceFile, 'VariableStatement:has(CallExpression > Identifier[name=withModuleFederation], StringLiteral[value=@nx/module-federation/angular])');
|
|
54
54
|
if (withModuleFederationRequireNodes.length > 0) {
|
|
55
55
|
const withModuleFederationRequireNode = withModuleFederationRequireNodes[0];
|
|
56
56
|
newWebpackConfigContents = `${webpackConfigContents.slice(0, withModuleFederationRequireNode.getStart())}const { NxModuleFederationPlugin, NxModuleFederationDevServerPlugin } = require('@nx/module-federation/rspack');${webpackConfigContents.slice(withModuleFederationRequireNode.getEnd())}`;
|
|
57
|
-
|
|
58
|
-
const exportedWithModuleFederationNodes = (0, tsquery_1.
|
|
57
|
+
sourceFile = (0, tsquery_1.ast)(newWebpackConfigContents);
|
|
58
|
+
const exportedWithModuleFederationNodes = (0, tsquery_1.query)(sourceFile, 'ExpressionStatement:has(BinaryExpression > PropertyAccessExpression:has(Identifier[name=module], Identifier[name=exports]), CallExpression:has(Identifier[name=withModuleFederation]))');
|
|
59
59
|
if (exportedWithModuleFederationNodes.length > 0) {
|
|
60
60
|
const exportedWithModuleFederationNode = exportedWithModuleFederationNodes[0];
|
|
61
61
|
newWebpackConfigContents = `${newWebpackConfigContents.slice(0, exportedWithModuleFederationNode.getStart())}${newWebpackConfigContents.slice(exportedWithModuleFederationNode.getEnd())}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SourceFile } from 'typescript';
|
|
2
|
-
export declare function checkOutputNameMatchesProjectName(
|
|
2
|
+
export declare function checkOutputNameMatchesProjectName(sourceFile: SourceFile, projectName: string): boolean;
|
|
3
3
|
//# sourceMappingURL=check-name-matches.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-name-matches.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/convert-to-with-mf/lib/check-name-matches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,wBAAgB,iCAAiC,CAC/C,
|
|
1
|
+
{"version":3,"file":"check-name-matches.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/convert-to-with-mf/lib/check-name-matches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,MAAM,WAuBpB"}
|
|
@@ -2,19 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkOutputNameMatchesProjectName = checkOutputNameMatchesProjectName;
|
|
4
4
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
5
|
-
function checkOutputNameMatchesProjectName(
|
|
5
|
+
function checkOutputNameMatchesProjectName(sourceFile, projectName) {
|
|
6
6
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
7
|
-
const {
|
|
7
|
+
const { query } = require('@phenomnomnominal/tsquery');
|
|
8
8
|
const OUTPUT_SELECTOR = 'PropertyAssignment:has(Identifier[name=output]) > ObjectLiteralExpression:has(PropertyAssignment:has(Identifier[name=uniqueName]))';
|
|
9
9
|
const UNIQUENAME_SELECTOR = 'ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=uniqueName]) > StringLiteral';
|
|
10
|
-
const outputNodes =
|
|
10
|
+
const outputNodes = query(sourceFile, OUTPUT_SELECTOR);
|
|
11
11
|
if (outputNodes.length === 0) {
|
|
12
12
|
// If the output isnt set in the config, then we can still set the project name correctly
|
|
13
13
|
return true;
|
|
14
14
|
}
|
|
15
|
-
const uniqueNameNodes =
|
|
16
|
-
visitAllChildren: true,
|
|
17
|
-
});
|
|
15
|
+
const uniqueNameNodes = query(outputNodes[0], UNIQUENAME_SELECTOR);
|
|
18
16
|
if (uniqueNameNodes.length === 0) {
|
|
19
17
|
// If the uniqeName isnt set in the config, then we can still set the project name correctly
|
|
20
18
|
return true;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SourceFile } from 'typescript';
|
|
2
|
-
export declare function checkSharedNpmPackagesMatchExpected(
|
|
2
|
+
export declare function checkSharedNpmPackagesMatchExpected(sourceFile: SourceFile): boolean;
|
|
3
3
|
//# sourceMappingURL=check-shared-npm-packages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-shared-npm-packages.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAQ,MAAM,YAAY,CAAC;AAGnD,wBAAgB,mCAAmC,CAAC,
|
|
1
|
+
{"version":3,"file":"check-shared-npm-packages.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/convert-to-with-mf/lib/check-shared-npm-packages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAQ,MAAM,YAAY,CAAC;AAGnD,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,UAAU,WA4DzE"}
|
|
@@ -2,31 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkSharedNpmPackagesMatchExpected = checkSharedNpmPackagesMatchExpected;
|
|
4
4
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
5
|
-
function checkSharedNpmPackagesMatchExpected(
|
|
5
|
+
function checkSharedNpmPackagesMatchExpected(sourceFile) {
|
|
6
6
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
7
|
-
const {
|
|
7
|
+
const { query } = require('@phenomnomnominal/tsquery');
|
|
8
8
|
const SHARE_HELPER_SELECTOR = 'PropertyAssignment:has(Identifier[name=shared]) > CallExpression:has(Identifier[name=share])';
|
|
9
9
|
const SHARED_PACKAGE_CONFIG_SELECTOR = 'ObjectLiteralExpression > PropertyAssignment > ObjectLiteralExpression';
|
|
10
|
-
const shareHelperNodes =
|
|
11
|
-
visitAllChildren: true,
|
|
12
|
-
});
|
|
10
|
+
const shareHelperNodes = query(sourceFile, SHARE_HELPER_SELECTOR);
|
|
13
11
|
let sharedPackageConfigNodes;
|
|
14
12
|
let settingsToMatch = [];
|
|
15
13
|
if (shareHelperNodes.length === 0) {
|
|
16
14
|
// if we arent sharing using share helper, check for standard object sharing syntax
|
|
17
15
|
const SHARED_OBJECT_SELECTOR = 'PropertyAssignment:has(Identifier[name=shared]) > ObjectLiteralExpression';
|
|
18
|
-
const sharedObjectNodes =
|
|
19
|
-
visitAllChildren: true,
|
|
20
|
-
});
|
|
16
|
+
const sharedObjectNodes = query(sourceFile, SHARED_OBJECT_SELECTOR);
|
|
21
17
|
if (sharedObjectNodes.length === 0) {
|
|
22
18
|
// nothing is being shared, we're safe to continue
|
|
23
19
|
return true;
|
|
24
20
|
}
|
|
25
|
-
sharedPackageConfigNodes =
|
|
21
|
+
sharedPackageConfigNodes = query(sourceFile, `${SHARED_OBJECT_SELECTOR} ${SHARED_PACKAGE_CONFIG_SELECTOR}`);
|
|
26
22
|
settingsToMatch = [`singleton: true`, `strictVersion: true`];
|
|
27
23
|
}
|
|
28
24
|
else {
|
|
29
|
-
sharedPackageConfigNodes =
|
|
25
|
+
sharedPackageConfigNodes = query(sourceFile, `${SHARE_HELPER_SELECTOR} ${SHARED_PACKAGE_CONFIG_SELECTOR}`);
|
|
30
26
|
settingsToMatch = [
|
|
31
27
|
`singleton: true`,
|
|
32
28
|
`strictVersion: true`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SourceFile } from 'typescript';
|
|
2
2
|
export type IsHostRemoteConfigResult = 'host' | 'remote' | 'both' | false;
|
|
3
|
-
export declare function isHostRemoteConfig(
|
|
4
|
-
export declare function getRemotesFromHost(
|
|
5
|
-
export declare function getExposedModulesFromRemote(
|
|
3
|
+
export declare function isHostRemoteConfig(sourceFile: SourceFile): IsHostRemoteConfigResult;
|
|
4
|
+
export declare function getRemotesFromHost(sourceFile: SourceFile): any[];
|
|
5
|
+
export declare function getExposedModulesFromRemote(sourceFile: SourceFile): any;
|
|
6
6
|
//# sourceMappingURL=is-host-remote-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-host-remote-config.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/convert-to-with-mf/lib/is-host-remote-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAQ1E,wBAAgB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"is-host-remote-config.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/convert-to-with-mf/lib/is-host-remote-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAQ1E,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,GACrB,wBAAwB,CAmB1B;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,SAyBxD;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,UAAU,OASjE"}
|
|
@@ -7,38 +7,30 @@ const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescri
|
|
|
7
7
|
const REMOTES_EXPRESSION_SELECTOR = 'PropertyAssignment:has(Identifier[name=remotes]) > ObjectLiteralExpression';
|
|
8
8
|
const EXPOSES_EXPRESSION_SELECTOR = 'PropertyAssignment:has(Identifier[name=exposes]) > ObjectLiteralExpression';
|
|
9
9
|
const PROPERTY_SELECTOR = 'ObjectLiteralExpression > PropertyAssignment';
|
|
10
|
-
function isHostRemoteConfig(
|
|
10
|
+
function isHostRemoteConfig(sourceFile) {
|
|
11
11
|
let isHost = false;
|
|
12
12
|
let isRemote = false;
|
|
13
13
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
14
|
-
const {
|
|
15
|
-
const remotesNodes =
|
|
16
|
-
visitAllChildren: true,
|
|
17
|
-
});
|
|
14
|
+
const { query } = require('@phenomnomnominal/tsquery');
|
|
15
|
+
const remotesNodes = query(sourceFile, REMOTES_EXPRESSION_SELECTOR);
|
|
18
16
|
if (remotesNodes.length > 0) {
|
|
19
17
|
isHost = true;
|
|
20
18
|
}
|
|
21
|
-
const exposesNodes =
|
|
22
|
-
visitAllChildren: true,
|
|
23
|
-
});
|
|
19
|
+
const exposesNodes = query(sourceFile, EXPOSES_EXPRESSION_SELECTOR);
|
|
24
20
|
if (exposesNodes.length > 0) {
|
|
25
21
|
isRemote = true;
|
|
26
22
|
}
|
|
27
23
|
let result = isHost && isRemote ? 'both' : isHost ? 'host' : isRemote ? 'remote' : false;
|
|
28
24
|
return result;
|
|
29
25
|
}
|
|
30
|
-
function getRemotesFromHost(
|
|
26
|
+
function getRemotesFromHost(sourceFile) {
|
|
31
27
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
32
|
-
const {
|
|
33
|
-
const remotesObjectNodes =
|
|
34
|
-
visitAllChildren: true,
|
|
35
|
-
});
|
|
28
|
+
const { query } = require('@phenomnomnominal/tsquery');
|
|
29
|
+
const remotesObjectNodes = query(sourceFile, REMOTES_EXPRESSION_SELECTOR);
|
|
36
30
|
if (remotesObjectNodes.length === 0) {
|
|
37
31
|
return [];
|
|
38
32
|
}
|
|
39
|
-
const remotesNodes =
|
|
40
|
-
visitAllChildren: true,
|
|
41
|
-
});
|
|
33
|
+
const remotesNodes = query(remotesObjectNodes[0], PROPERTY_SELECTOR);
|
|
42
34
|
if (remotesNodes.length === 0) {
|
|
43
35
|
return [];
|
|
44
36
|
}
|
|
@@ -54,12 +46,10 @@ function getRemotesFromHost(ast) {
|
|
|
54
46
|
}
|
|
55
47
|
return remotes;
|
|
56
48
|
}
|
|
57
|
-
function getExposedModulesFromRemote(
|
|
49
|
+
function getExposedModulesFromRemote(sourceFile) {
|
|
58
50
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
59
|
-
const {
|
|
60
|
-
const exposesObjectNodes =
|
|
61
|
-
visitAllChildren: true,
|
|
62
|
-
});
|
|
51
|
+
const { query } = require('@phenomnomnominal/tsquery');
|
|
52
|
+
const exposesObjectNodes = query(sourceFile, EXPOSES_EXPRESSION_SELECTOR);
|
|
63
53
|
if (exposesObjectNodes.length === 0) {
|
|
64
54
|
return {};
|
|
65
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-scam-to-standalone.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGnD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,UAAU,EACxB,qBAAqB,EAAE,MAAM,EAC7B,YAAY,EAAE,MAAM,EAAE,EACtB,cAAc,EAAE,MAAM,EAAE,EACxB,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,EACxB,IAAI,EAAE,IAAI,EACV,uBAAuB,EAAE,MAAM,EAC/B,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"convert-scam-to-standalone.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/convert-scam-to-standalone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGnD,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,UAAU,EACxB,qBAAqB,EAAE,MAAM,EAC7B,YAAY,EAAE,MAAM,EAAE,EACtB,cAAc,EAAE,MAAM,EAAE,EACxB,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,EACxB,IAAI,EAAE,IAAI,EACV,uBAAuB,EAAE,MAAM,EAC/B,aAAa,EAAE,MAAM,QA0DtB"}
|
|
@@ -7,8 +7,8 @@ const version_utils_1 = require("../../utils/version-utils");
|
|
|
7
7
|
function convertScamToStandalone(componentAST, componentFileContents, importsArray, providersArray, moduleNodes, tree, normalizedComponentPath, componentName) {
|
|
8
8
|
let newComponentContents = '';
|
|
9
9
|
const COMPONENT_PROPERTY_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=Component]) ObjectLiteralExpression';
|
|
10
|
-
const {
|
|
11
|
-
const componentDecoratorMetadataNode =
|
|
10
|
+
const { query } = require('@phenomnomnominal/tsquery');
|
|
11
|
+
const componentDecoratorMetadataNode = query(componentAST, COMPONENT_PROPERTY_SELECTOR)[0];
|
|
12
12
|
const { major: angularMajorVersion } = (0, version_utils_1.getInstalledAngularVersionInfo)(tree);
|
|
13
13
|
newComponentContents = `${componentFileContents.slice(0, componentDecoratorMetadataNode.getStart() - 1)}({
|
|
14
14
|
imports: [${importsArray.join(',')}],${providersArray.length > 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-component-data-from-ast.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/get-component-data-from-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,IAAI,EACV,uBAAuB,EAAE,MAAM;;;;
|
|
1
|
+
{"version":3,"file":"get-component-data-from-ast.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/get-component-data-from-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,IAAI,EACV,uBAAuB,EAAE,MAAM;;;;EAuBhC"}
|
|
@@ -5,13 +5,11 @@ function getComponentDataFromAST(tree, normalizedComponentPath) {
|
|
|
5
5
|
const COMPONENT_CONTENT_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=Component]))';
|
|
6
6
|
const COMPONENT_NAME_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=Component])) > Identifier';
|
|
7
7
|
const componentFileContents = tree.read(normalizedComponentPath, 'utf-8');
|
|
8
|
-
const {
|
|
9
|
-
const componentAST =
|
|
10
|
-
const componentNode =
|
|
11
|
-
visitAllChildren: true,
|
|
12
|
-
})[0];
|
|
8
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
9
|
+
const componentAST = ast(componentFileContents);
|
|
10
|
+
const componentNode = query(componentAST, COMPONENT_CONTENT_SELECTOR)[0];
|
|
13
11
|
const componentContents = componentFileContents.slice(componentNode.getStart(), componentNode.getEnd());
|
|
14
|
-
const componentNameNode =
|
|
12
|
+
const componentNameNode = query(ast(componentContents), COMPONENT_NAME_SELECTOR)[0];
|
|
15
13
|
const componentName = componentNameNode.getText();
|
|
16
14
|
return { componentFileContents, componentAST, componentName };
|
|
17
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-module-metadata-from-ast.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,UAAU,EACxB,qBAAqB,EAAE,MAAM;;;;;;;
|
|
1
|
+
{"version":3,"file":"get-module-metadata-from-ast.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/get-module-metadata-from-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,UAAU,EACxB,qBAAqB,EAAE,MAAM;;;;;;;EA6D9B"}
|
|
@@ -3,10 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getModuleMetadataFromAST = getModuleMetadataFromAST;
|
|
4
4
|
function getModuleMetadataFromAST(componentAST, componentFileContents) {
|
|
5
5
|
const NGMODULE_CONTENT_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=NgModule]))';
|
|
6
|
-
const {
|
|
7
|
-
const moduleNodes =
|
|
8
|
-
visitAllChildren: true,
|
|
9
|
-
});
|
|
6
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
7
|
+
const moduleNodes = query(componentAST, NGMODULE_CONTENT_SELECTOR);
|
|
10
8
|
const moduleContents = componentFileContents.slice(moduleNodes[0].getStart(), moduleNodes[0].getEnd());
|
|
11
9
|
// verify module is a scam
|
|
12
10
|
const NGMODULE_EXPORTS_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=exports]) ArrayLiteralExpression';
|
|
@@ -14,19 +12,11 @@ function getModuleMetadataFromAST(componentAST, componentFileContents) {
|
|
|
14
12
|
const NGMODULE_IMPORTS_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=imports]) ArrayLiteralExpression';
|
|
15
13
|
const NGMODULE_PROVIDERS_SELECTOR = 'ClassDeclaration > Decorator > CallExpression:has(Identifier[name=NgModule]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=providers]) ArrayLiteralExpression';
|
|
16
14
|
const NGMODULE_NAME_SELECTOR = 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=NgModule])) > Identifier';
|
|
17
|
-
const moduleAST =
|
|
18
|
-
const importsNode =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
visitAllChildren: true,
|
|
23
|
-
})[0];
|
|
24
|
-
const declarationsNode = tsquery(moduleAST, NGMODULE_DECLARATIONS_SELECTOR, {
|
|
25
|
-
visitAllChildren: true,
|
|
26
|
-
})[0];
|
|
27
|
-
const providersNodes = tsquery(moduleAST, NGMODULE_PROVIDERS_SELECTOR, {
|
|
28
|
-
visitAllChildren: true,
|
|
29
|
-
});
|
|
15
|
+
const moduleAST = ast(moduleContents);
|
|
16
|
+
const importsNode = query(moduleAST, NGMODULE_IMPORTS_SELECTOR)[0];
|
|
17
|
+
const exportsNode = query(moduleAST, NGMODULE_EXPORTS_SELECTOR)[0];
|
|
18
|
+
const declarationsNode = query(moduleAST, NGMODULE_DECLARATIONS_SELECTOR)[0];
|
|
19
|
+
const providersNodes = query(moduleAST, NGMODULE_PROVIDERS_SELECTOR);
|
|
30
20
|
const exportsArray = moduleContents
|
|
31
21
|
.slice(exportsNode.getStart(), exportsNode.getEnd())
|
|
32
22
|
.replace('[', '')
|
|
@@ -49,9 +39,7 @@ function getModuleMetadataFromAST(componentAST, componentFileContents) {
|
|
|
49
39
|
.replace(']', '')
|
|
50
40
|
.split(',')
|
|
51
41
|
: [];
|
|
52
|
-
const moduleName =
|
|
53
|
-
visitAllChildren: true,
|
|
54
|
-
})[0].getText();
|
|
42
|
+
const moduleName = query(moduleAST, NGMODULE_NAME_SELECTOR)[0].getText();
|
|
55
43
|
return {
|
|
56
44
|
moduleNodes,
|
|
57
45
|
exportsArray,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SourceFile } from 'typescript';
|
|
2
|
-
export declare function selectorExistsInAST(selector: string,
|
|
2
|
+
export declare function selectorExistsInAST(selector: string, sourceFile: SourceFile): boolean;
|
|
3
3
|
//# sourceMappingURL=selector-exists-in-ast.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selector-exists-in-ast.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/selector-exists-in-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"selector-exists-in-ast.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/scam-to-standalone/lib/selector-exists-in-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,WAG3E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectorExistsInAST = selectorExistsInAST;
|
|
4
|
-
function selectorExistsInAST(selector,
|
|
5
|
-
const {
|
|
6
|
-
return
|
|
4
|
+
function selectorExistsInAST(selector, sourceFile) {
|
|
5
|
+
const { query } = require('@phenomnomnominal/tsquery');
|
|
6
|
+
return query(sourceFile, selector).length > 0;
|
|
7
7
|
}
|
|
@@ -51,9 +51,9 @@ function addRemoteToStaticHost(tree, options, hostProject, isHostUsingTypescript
|
|
|
51
51
|
throw new Error(`The selected host application, ${options.host}, does not contain a module-federation.config.{ts,js} or module-federation.manifest.json file. Are you sure it has been set up as a host application?`);
|
|
52
52
|
}
|
|
53
53
|
const hostMFConfig = tree.read(hostMFConfigPath, 'utf-8');
|
|
54
|
-
const {
|
|
55
|
-
const webpackAst =
|
|
56
|
-
const mfRemotesNode =
|
|
54
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
55
|
+
const webpackAst = ast(hostMFConfig);
|
|
56
|
+
const mfRemotesNode = query(webpackAst, 'ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=remotes]) > ArrayLiteralExpression')[0];
|
|
57
57
|
const endOfPropertiesPos = mfRemotesNode.getEnd() - 1;
|
|
58
58
|
const isCommaNeeded = checkIsCommaNeeded(mfRemotesNode.getText());
|
|
59
59
|
const updatedConfig = `${hostMFConfig.slice(0, endOfPropertiesPos)}${isCommaNeeded ? ',' : ''}'${options.appName}',${hostMFConfig.slice(endOfPropertiesPos)}`;
|
|
@@ -23,7 +23,7 @@ function setRouterInitialNavigation(tree, options) {
|
|
|
23
23
|
}
|
|
24
24
|
function processFileWithStandaloneSetup(tree, filePath, printer) {
|
|
25
25
|
let content = tree.read(filePath, 'utf-8');
|
|
26
|
-
let sourceFile = tsquery_1.
|
|
26
|
+
let sourceFile = (0, tsquery_1.ast)(content);
|
|
27
27
|
const provideRouterCallExpression = getProvideRouterCallExpression(sourceFile);
|
|
28
28
|
if (!provideRouterCallExpression) {
|
|
29
29
|
return;
|
|
@@ -36,9 +36,9 @@ function processFileWithStandaloneSetup(tree, filePath, printer) {
|
|
|
36
36
|
const updatedProvideRouterCallExpression = printer.printNode(typescript_1.EmitHint.Unspecified, updateProvideRouterCallExpression(provideRouterCallExpression), sourceFile);
|
|
37
37
|
content = `${content.slice(0, provideRouterCallExpression.getStart())}${updatedProvideRouterCallExpression}${content.slice(provideRouterCallExpression.getEnd())}`;
|
|
38
38
|
tree.write(filePath, content);
|
|
39
|
-
sourceFile = tsquery_1.
|
|
39
|
+
sourceFile = (0, tsquery_1.ast)(content);
|
|
40
40
|
sourceFile = (0, js_1.insertImport)(tree, sourceFile, filePath, 'withEnabledBlockingInitialNavigation', '@angular/router');
|
|
41
|
-
const withDisabledInitialNavigationImportNode = (0, tsquery_1.
|
|
41
|
+
const withDisabledInitialNavigationImportNode = (0, tsquery_1.query)(sourceFile, 'ImportDeclaration ImportSpecifier:has(Identifier[name=withDisabledInitialNavigation])')[0];
|
|
42
42
|
if (!withDisabledInitialNavigationImportNode) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
@@ -56,7 +56,7 @@ function updateProvideRouterCallExpression(node) {
|
|
|
56
56
|
}
|
|
57
57
|
function processFileWithNgModuleSetup(tree, filePath, printer) {
|
|
58
58
|
const content = tree.read(filePath, 'utf-8');
|
|
59
|
-
const sourceFile = tsquery_1.
|
|
59
|
+
const sourceFile = (0, tsquery_1.ast)(content);
|
|
60
60
|
const routerModuleForRootCallExpression = getRouterModuleForRootCallExpression(sourceFile);
|
|
61
61
|
if (!routerModuleForRootCallExpression) {
|
|
62
62
|
return;
|
|
@@ -83,10 +83,10 @@ function updateRouterModuleForRootCallExpression(node) {
|
|
|
83
83
|
return typescript_1.factory.createCallExpression(node.expression, node.typeArguments, args);
|
|
84
84
|
}
|
|
85
85
|
function getProvideRouterCallExpression(sourceFile) {
|
|
86
|
-
const routerModuleForRootCalls = (0, tsquery_1.
|
|
86
|
+
const routerModuleForRootCalls = (0, tsquery_1.query)(sourceFile.getText(), 'PropertyAssignment:has(Identifier[name=providers]) > ArrayLiteralExpression CallExpression:has(Identifier[name=provideRouter])');
|
|
87
87
|
return routerModuleForRootCalls.length ? routerModuleForRootCalls[0] : null;
|
|
88
88
|
}
|
|
89
89
|
function getRouterModuleForRootCallExpression(sourceFile) {
|
|
90
|
-
const routerModuleForRootCalls = (0, tsquery_1.
|
|
90
|
+
const routerModuleForRootCalls = (0, tsquery_1.query)(sourceFile.getText(), 'Decorator > CallExpression:has(Identifier[name=NgModule]) PropertyAssignment:has(Identifier[name=imports]) > ArrayLiteralExpression CallExpression:has(Identifier[name=forRoot])');
|
|
91
91
|
return routerModuleForRootCalls.length ? routerModuleForRootCalls[0] : null;
|
|
92
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-tailwind.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/setup-tailwind/setup-tailwind.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"setup-tailwind.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/generators/setup-tailwind/setup-tailwind.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAGjB,IAAI,EACL,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,gBAAgB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAoC5B;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -4,6 +4,7 @@ exports.setupTailwindGenerator = setupTailwindGenerator;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const lib_1 = require("./lib");
|
|
6
6
|
async function setupTailwindGenerator(tree, rawOptions) {
|
|
7
|
+
devkit_1.logger.warn(`The 'setup-tailwind' generator is deprecated. Generating Tailwind configuration is no longer maintained. This generator will be removed in Nx 23.`);
|
|
7
8
|
const options = (0, lib_1.normalizeOptions)(rawOptions);
|
|
8
9
|
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
9
10
|
if (rawOptions.buildTarget && !project.targets?.[rawOptions.buildTarget]) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-info.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/utils/storybook-ast/component-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EAEL,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"component-info.d.ts","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/utils/storybook-ast/component-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EAEL,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOhD,MAAM,WAAW,aAAa;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,MAAM,EAAE,EACzB,WAAW,EAAE,MAAM,GAClB,aAAa,EAAE,CAkCjB;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,GACrB,aAAa,EAAE,CAyCjB"}
|
|
@@ -8,7 +8,8 @@ const path_1 = require("path");
|
|
|
8
8
|
const ast_utils_1 = require("../../../utils/nx-devkit/ast-utils");
|
|
9
9
|
const module_info_1 = require("./module-info");
|
|
10
10
|
let tsModule;
|
|
11
|
-
let
|
|
11
|
+
let tsqueryAst;
|
|
12
|
+
let tsqueryQuery;
|
|
12
13
|
function getComponentsInfo(tree, entryPoint, moduleFilePaths, projectName) {
|
|
13
14
|
return moduleFilePaths
|
|
14
15
|
.flatMap((moduleFilePath) => {
|
|
@@ -54,15 +55,17 @@ function getStandaloneComponentsInfo(tree, entryPoint) {
|
|
|
54
55
|
return componentsInfo;
|
|
55
56
|
}
|
|
56
57
|
function getStandaloneComponents(tree, filePath) {
|
|
57
|
-
if (!
|
|
58
|
+
if (!tsqueryAst) {
|
|
58
59
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
59
|
-
|
|
60
|
+
const tsqueryModule = require('@phenomnomnominal/tsquery');
|
|
61
|
+
tsqueryAst = tsqueryModule.ast;
|
|
62
|
+
tsqueryQuery = tsqueryModule.query;
|
|
60
63
|
}
|
|
61
64
|
const fileContent = tree.read(filePath, 'utf-8');
|
|
62
|
-
const
|
|
65
|
+
const sourceFile = tsqueryAst(fileContent);
|
|
63
66
|
// standalone: true is the default, so all components except those with
|
|
64
67
|
// standalone: false are considered standalone
|
|
65
|
-
const standaloneComponentNodes =
|
|
68
|
+
const standaloneComponentNodes = tsqueryQuery(sourceFile, 'ClassDeclaration:has(Decorator > CallExpression:has(Identifier[name=Component]) ObjectLiteralExpression:not(:has(PropertyAssignment:has(Identifier[name=standalone]) > FalseKeyword))) > Identifier');
|
|
66
69
|
return standaloneComponentNodes.map((component) => component.getText());
|
|
67
70
|
}
|
|
68
71
|
function getComponentImportPath(componentName, imports) {
|
|
@@ -94,13 +97,15 @@ function getComponentImportPath(componentName, imports) {
|
|
|
94
97
|
}
|
|
95
98
|
function tryGetComponentInfo(tree, entryPoint, sourceFile, imports, moduleFilePath, symbolName) {
|
|
96
99
|
try {
|
|
97
|
-
if (!
|
|
100
|
+
if (!tsqueryQuery) {
|
|
98
101
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
99
|
-
|
|
102
|
+
const tsqueryModule = require('@phenomnomnominal/tsquery');
|
|
103
|
+
tsqueryAst = tsqueryModule.ast;
|
|
104
|
+
tsqueryQuery = tsqueryModule.query;
|
|
100
105
|
}
|
|
101
106
|
const moduleFolderPath = (0, path_1.dirname)(moduleFilePath);
|
|
102
107
|
// try to get the component from the same file (inline scam)
|
|
103
|
-
const node =
|
|
108
|
+
const node = tsqueryQuery(sourceFile, `ClassDeclaration:has(Decorator > CallExpression > Identifier[name=Component]):has(Identifier[name=${symbolName}])`)[0];
|
|
104
109
|
if (node) {
|
|
105
110
|
return {
|
|
106
111
|
componentFileName: (0, path_1.basename)(moduleFilePath, '.ts'),
|
|
@@ -37,10 +37,10 @@ function getModuleFilePaths(tree, entryPoint) {
|
|
|
37
37
|
}
|
|
38
38
|
function hasNgModule(tree, filePath) {
|
|
39
39
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
40
|
-
const {
|
|
40
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
41
41
|
const fileContent = tree.read(filePath, 'utf-8');
|
|
42
|
-
const
|
|
43
|
-
const ngModule =
|
|
42
|
+
const sourceFile = ast(fileContent);
|
|
43
|
+
const ngModule = query(sourceFile, 'ClassDeclaration > Decorator > CallExpression > Identifier[name=NgModule]');
|
|
44
44
|
return ngModule.length > 0;
|
|
45
45
|
}
|
|
46
46
|
function getDeclaredComponentNodes(declarationsArray) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-off-dts-by-default.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/migrations/update-19-6-0/turn-off-dts-by-default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAqC,MAAM,YAAY,CAAC;AAK1E,yBAA+B,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"turn-off-dts-by-default.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/migrations/update-19-6-0/turn-off-dts-by-default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAqC,MAAM,YAAY,CAAC;AAK1E,yBAA+B,IAAI,EAAE,IAAI,iBA6ExC"}
|
|
@@ -17,13 +17,13 @@ async function default_1(tree) {
|
|
|
17
17
|
}
|
|
18
18
|
const WITH_MODULE_FEDERATION_SELECTOR = 'CallExpression:has(Identifier[name=withModuleFederation]),CallExpression:has(Identifier[name=withModuleFederationForSSR])';
|
|
19
19
|
const EXISTING_MF_OVERRIDES_SELECTOR = 'ObjectLiteralExpression';
|
|
20
|
-
const
|
|
21
|
-
const withModuleFederationNodes = (0, tsquery_1.
|
|
20
|
+
const sourceFile = (0, tsquery_1.ast)(webpackConfigContents);
|
|
21
|
+
const withModuleFederationNodes = (0, tsquery_1.query)(sourceFile, WITH_MODULE_FEDERATION_SELECTOR);
|
|
22
22
|
if (!withModuleFederationNodes.length) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
const withModuleFederationNode = withModuleFederationNodes[0];
|
|
26
|
-
const existingOverridesNodes = (0, tsquery_1.
|
|
26
|
+
const existingOverridesNodes = (0, tsquery_1.query)(withModuleFederationNode, EXISTING_MF_OVERRIDES_SELECTOR);
|
|
27
27
|
if (!existingOverridesNodes.length) {
|
|
28
28
|
// doesn't exist, add it
|
|
29
29
|
webpackConfigContents = `${webpackConfigContents.slice(0, withModuleFederationNode.getEnd() - 1)},${JSON.stringify({ dts: false })}${webpackConfigContents.slice(withModuleFederationNode.getEnd() - 1)}`;
|
|
@@ -40,7 +40,7 @@ async function default_1(tree) {
|
|
|
40
40
|
existingOverrideNode = node;
|
|
41
41
|
}
|
|
42
42
|
const DTS_PROPERTY_SELECTOR = 'PropertyAssignment > Identifier[name=dts]';
|
|
43
|
-
const dtsPropertyNode = (0, tsquery_1.
|
|
43
|
+
const dtsPropertyNode = (0, tsquery_1.query)(existingOverrideNode, DTS_PROPERTY_SELECTOR);
|
|
44
44
|
if (dtsPropertyNode.length) {
|
|
45
45
|
// dts already exists, do nothing
|
|
46
46
|
return;
|
|
@@ -31,15 +31,15 @@ async function migrateMfImportsToNewPackage(tree) {
|
|
|
31
31
|
if (!contents.includes(MF_IMPORT_TO_UPDATE)) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const
|
|
35
|
-
const importNodes = (0, tsquery_1.
|
|
34
|
+
const sourceFile = (0, tsquery_1.ast)(contents);
|
|
35
|
+
const importNodes = (0, tsquery_1.query)(sourceFile, MF_CONFIG_IMPORT_SELECTOR);
|
|
36
36
|
if (importNodes.length === 0) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
const importNode = importNodes[0];
|
|
40
|
-
const importSpecifiers = (0, tsquery_1.
|
|
40
|
+
const importSpecifiers = (0, tsquery_1.query)(importNode, IMPORT_TOKENS_SELECTOR);
|
|
41
41
|
if (importSpecifiers.length > 1) {
|
|
42
|
-
const mfConfigImportSpecifierNode = (0, tsquery_1.
|
|
42
|
+
const mfConfigImportSpecifierNode = (0, tsquery_1.query)(importNode, MF_CONFIG_IMPORT_SPECIFIER_SELECTOR)[0];
|
|
43
43
|
const end = contents.charAt(mfConfigImportSpecifierNode.getEnd()) === ','
|
|
44
44
|
? mfConfigImportSpecifierNode.getEnd() + 1
|
|
45
45
|
: mfConfigImportSpecifierNode.getEnd();
|
|
@@ -47,7 +47,7 @@ async function migrateMfImportsToNewPackage(tree) {
|
|
|
47
47
|
${contents.slice(0, mfConfigImportSpecifierNode.getStart())}${contents.slice(end)}`;
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
const nxWebpackImportStringNodes = (0, tsquery_1.
|
|
50
|
+
const nxWebpackImportStringNodes = (0, tsquery_1.query)(sourceFile, WEBPACK_IMPORT_SELECTOR);
|
|
51
51
|
if (nxWebpackImportStringNodes.length === 0) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
@@ -22,8 +22,8 @@ async function migrateWithMfImport(tree) {
|
|
|
22
22
|
if (!contents.includes('@nx/angular/module-federation')) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
const importNodes = (0, tsquery_1.
|
|
25
|
+
const sourceFile = (0, tsquery_1.ast)(contents);
|
|
26
|
+
const importNodes = (0, tsquery_1.query)(sourceFile, NX_ANGULAR_MODULE_FEDERATION_IMPORT_SELECTOR);
|
|
27
27
|
if (importNodes.length === 0) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/migrations/update-21-0-0/change-data-persistence-operators-imports-to-ngrx-router-store-data-persistence.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAqBpB,yBAA+B,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCxD"}
|
|
@@ -8,7 +8,8 @@ const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
|
|
|
8
8
|
const version_utils_1 = require("../../generators/utils/version-utils");
|
|
9
9
|
const file_change_recorder_1 = require("../../utils/file-change-recorder");
|
|
10
10
|
const projects_1 = require("../utils/projects");
|
|
11
|
-
let
|
|
11
|
+
let tsqueryAst;
|
|
12
|
+
let tsqueryQuery;
|
|
12
13
|
const angularPluginTargetNames = ['npm:@nx/angular', 'npm:@nrwl/angular'];
|
|
13
14
|
const dataPersistenceOperators = [
|
|
14
15
|
'fetch',
|
|
@@ -23,7 +24,9 @@ async function default_1(tree) {
|
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
26
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
26
|
-
|
|
27
|
+
const tsqueryModule = require('@phenomnomnominal/tsquery');
|
|
28
|
+
tsqueryAst = tsqueryModule.ast;
|
|
29
|
+
tsqueryQuery = tsqueryModule.query;
|
|
27
30
|
const cachedFileMap = (0, nx_deps_cache_1.readFileMapCache)().fileMap.projectFileMap;
|
|
28
31
|
const filesWithNxAngularImports = [];
|
|
29
32
|
for (const graphNode of projects) {
|
|
@@ -42,19 +45,19 @@ async function default_1(tree) {
|
|
|
42
45
|
}
|
|
43
46
|
function replaceDataPersistenceInFile(tree, file) {
|
|
44
47
|
const fileContents = tree.read(file, 'utf-8');
|
|
45
|
-
const fileAst =
|
|
48
|
+
const fileAst = tsqueryAst(fileContents);
|
|
46
49
|
// "\\u002F" is the unicode code for "/", there's an issue with the query parser
|
|
47
50
|
// that prevents using "/" directly in regex queries
|
|
48
51
|
// https://github.com/estools/esquery/issues/68#issuecomment-415597670
|
|
49
52
|
const NX_ANGULAR_IMPORT_SELECTOR = 'ImportDeclaration:has(StringLiteral[value=/@(nx|nrwl)\\u002Fangular$/])';
|
|
50
|
-
const nxAngularImports =
|
|
53
|
+
const nxAngularImports = tsqueryQuery(fileAst, NX_ANGULAR_IMPORT_SELECTOR);
|
|
51
54
|
if (!nxAngularImports.length) {
|
|
52
55
|
return false;
|
|
53
56
|
}
|
|
54
57
|
const recorder = new file_change_recorder_1.FileChangeRecorder(tree, file);
|
|
55
58
|
const IMPORT_SPECIFIERS_SELECTOR = 'ImportClause NamedImports ImportSpecifier';
|
|
56
59
|
for (const importDeclaration of nxAngularImports) {
|
|
57
|
-
const importSpecifiers =
|
|
60
|
+
const importSpecifiers = tsqueryQuery(importDeclaration, IMPORT_SPECIFIERS_SELECTOR);
|
|
58
61
|
if (!importSpecifiers.length) {
|
|
59
62
|
continue;
|
|
60
63
|
}
|
|
@@ -65,9 +68,7 @@ function replaceDataPersistenceInFile(tree, file) {
|
|
|
65
68
|
// all imported symbols are data persistence operators, change import path
|
|
66
69
|
if (importSpecifiers.every((i) => isOperatorImport(i))) {
|
|
67
70
|
const IMPORT_PATH_SELECTOR = `${NX_ANGULAR_IMPORT_SELECTOR} > StringLiteral`;
|
|
68
|
-
const importPathNode =
|
|
69
|
-
visitAllChildren: true,
|
|
70
|
-
});
|
|
71
|
+
const importPathNode = tsqueryQuery(importDeclaration, IMPORT_PATH_SELECTOR);
|
|
71
72
|
recorder.replace(importPathNode[0], `'${newImportPath}'`);
|
|
72
73
|
continue;
|
|
73
74
|
}
|
|
@@ -31,8 +31,8 @@ function processFile(tree, filePath) {
|
|
|
31
31
|
!content.includes('@angular/ssr')) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const sourceFile = tsquery_1.
|
|
35
|
-
const providersArray = tsquery_1.
|
|
34
|
+
const sourceFile = (0, tsquery_1.ast)(content);
|
|
35
|
+
const providersArray = (0, tsquery_1.query)(sourceFile, 'PropertyAssignment:has(Identifier[name=providers]) > ArrayLiteralExpression')[0];
|
|
36
36
|
if (!providersArray) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-mf-projects.d.ts","sourceRoot":"","sources":["../../../../../packages/angular/src/utils/get-mf-projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"get-mf-projects.d.ts","sourceRoot":"","sources":["../../../../../packages/angular/src/utils/get-mf-projects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAgCvC,wBAAgB,aAAa,CAC3B,IAAI,EAAE,IAAI,EACV,EAAE,MAAM,EAAE,GAAE;IAAE,MAAM,EAAE,OAAO,CAAA;CAAsB,YA8BpD"}
|
|
@@ -9,11 +9,9 @@ function _getMfProjects(tree, CUSTOM_WEBPACK_OPTION, MODULE_FEDERATION_IDENTIFIE
|
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
const webpackConfig = tree.read(webpackPath, 'utf-8');
|
|
12
|
-
const {
|
|
13
|
-
const
|
|
14
|
-
const moduleFederationWebpackConfig =
|
|
15
|
-
visitAllChildren: true,
|
|
16
|
-
});
|
|
12
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
13
|
+
const sourceFile = ast(webpackConfig);
|
|
14
|
+
const moduleFederationWebpackConfig = query(sourceFile, MODULE_FEDERATION_IDENTIFIER);
|
|
17
15
|
if (!moduleFederationWebpackConfig ||
|
|
18
16
|
moduleFederationWebpackConfig.length === 0) {
|
|
19
17
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/nx-devkit/ast-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EACL,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAItC,KAAK,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAC;AAyDrE;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,EAAE,CAAC,UAAU,EACzB,aAAa,EAAE,aAAa,GAC3B,OAAO,CAmBT;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb,EAAE,CAAC,IAAI,EAAE,CAgEX;AAkKD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,EAAE,CAAC,UAAU,CAyBf;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,EAAE,CAAC,UAAU,CASf;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,GACjB,EAAE,CAAC,UAAU,CASf;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,EAAE,CAAC,UAAU,CASf;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,EAAE,CAAC,UAAU,CAQf;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,EAAE,CAAC,UAAU,CAkCf;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAAE,GACnB,EAAE,CAAC,UAAU,CAkCf;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,GACrB,EAAE,CAAC,UAAU,CAmCf;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,eAAe,EAAE,MAAM,GACtB,MAAM,CAmBR;AAiBD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,EAAE,CAAC,UAAU,EACrB,KAAK,EAAE,MAAM,GACZ,EAAE,CAAC,UAAU,CASf;AAwDD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ast-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/nx-devkit/ast-utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -449,13 +449,11 @@ function isNgStandaloneApp(tree, projectName) {
|
|
|
449
449
|
return false;
|
|
450
450
|
}
|
|
451
451
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
452
|
-
const {
|
|
452
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
453
453
|
const mainFileContents = tree.read(mainFile, 'utf-8');
|
|
454
454
|
const BOOTSTRAP_APPLICATION_SELECTOR = 'CallExpression:has(Identifier[name=bootstrapApplication])';
|
|
455
|
-
const
|
|
456
|
-
const nodes =
|
|
457
|
-
visitAllChildren: true,
|
|
458
|
-
});
|
|
455
|
+
const sourceFile = ast(mainFileContents);
|
|
456
|
+
const nodes = query(sourceFile, BOOTSTRAP_APPLICATION_SELECTOR);
|
|
459
457
|
return nodes.length > 0;
|
|
460
458
|
}
|
|
461
459
|
/**
|
|
@@ -466,13 +464,11 @@ function isNgStandaloneApp(tree, projectName) {
|
|
|
466
464
|
*/
|
|
467
465
|
function addProviderToBootstrapApplication(tree, filePath, providerToAdd) {
|
|
468
466
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
469
|
-
const {
|
|
467
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
470
468
|
const PROVIDERS_ARRAY_SELECTOR = 'CallExpression:has(Identifier[name=bootstrapApplication]) ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=providers]) > ArrayLiteralExpression';
|
|
471
469
|
const fileContents = tree.read(filePath, 'utf-8');
|
|
472
|
-
const
|
|
473
|
-
const providersArrayNodes =
|
|
474
|
-
visitAllChildren: true,
|
|
475
|
-
});
|
|
470
|
+
const sourceFile = ast(fileContents);
|
|
471
|
+
const providersArrayNodes = query(sourceFile, PROVIDERS_ARRAY_SELECTOR);
|
|
476
472
|
if (providersArrayNodes.length === 0) {
|
|
477
473
|
throw new Error(`Providers does not exist in the bootstrapApplication call within ${filePath}.`);
|
|
478
474
|
}
|
|
@@ -489,13 +485,11 @@ function addProviderToBootstrapApplication(tree, filePath, providerToAdd) {
|
|
|
489
485
|
*/
|
|
490
486
|
function addProviderToAppConfig(tree, filePath, providerToAdd) {
|
|
491
487
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
492
|
-
const {
|
|
488
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
493
489
|
const PROVIDERS_ARRAY_SELECTOR = 'VariableDeclaration:has(TypeReference > Identifier[name=ApplicationConfig]) > ObjectLiteralExpression PropertyAssignment:has(Identifier[name=providers]) > ArrayLiteralExpression';
|
|
494
490
|
const fileContents = tree.read(filePath, 'utf-8');
|
|
495
|
-
const
|
|
496
|
-
const providersArrayNodes =
|
|
497
|
-
visitAllChildren: true,
|
|
498
|
-
});
|
|
491
|
+
const sourceFile = ast(fileContents);
|
|
492
|
+
const providersArrayNodes = query(sourceFile, PROVIDERS_ARRAY_SELECTOR);
|
|
499
493
|
if (providersArrayNodes.length === 0) {
|
|
500
494
|
throw new Error(`'providers' does not exist in the application configuration at '${filePath}'.`);
|
|
501
495
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/nx-devkit/route-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,OAAc,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"route-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/angular/src/utils/nx-devkit/route-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAOlC;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,OAAc,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,QAkEpB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,oBAAoB,EAAE,MAAM,EAC5B,aAAa,EAAE,MAAM,QAwEtB"}
|
|
@@ -22,18 +22,16 @@ function addRoute(tree, routesFile, route, lazy = true, routesConst, importPath)
|
|
|
22
22
|
if (!tsModule) {
|
|
23
23
|
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
24
24
|
}
|
|
25
|
-
const {
|
|
25
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
26
26
|
let routesFileContents = tree.read(routesFile, 'utf-8');
|
|
27
27
|
if (!lazy) {
|
|
28
28
|
let parentSourceFile = tsModule.createSourceFile(routesFile, routesFileContents, tsModule.ScriptTarget.Latest, true);
|
|
29
29
|
parentSourceFile = (0, js_1.insertImport)(tree, parentSourceFile, routesFile, routesConst, importPath);
|
|
30
30
|
routesFileContents = tree.read(routesFile, 'utf-8');
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const sourceFile = ast(routesFileContents);
|
|
33
33
|
const ROUTES_ARRAY_SELECTOR = 'VariableDeclaration:has(ArrayType > TypeReference > Identifier[name=Route], Identifier[name=Routes]) > ArrayLiteralExpression';
|
|
34
|
-
const routesArrayNodes =
|
|
35
|
-
visitAllChildren: true,
|
|
36
|
-
});
|
|
34
|
+
const routesArrayNodes = query(sourceFile, ROUTES_ARRAY_SELECTOR);
|
|
37
35
|
const isRoutesArray = routesArrayNodes.length > 0;
|
|
38
36
|
if (!isRoutesArray) {
|
|
39
37
|
if (routesFileContents.includes('@NgModule')) {
|
|
@@ -61,29 +59,23 @@ function addProviderToRoute(tree, routesFile, routeToAddProviderTo, providerToAd
|
|
|
61
59
|
throw new Error(`Path to parent routing declaration (${routesFile}) does not exist. Please ensure path is correct.`);
|
|
62
60
|
}
|
|
63
61
|
(0, ensure_typescript_1.ensureTypescript)();
|
|
64
|
-
const {
|
|
62
|
+
const { ast, query } = require('@phenomnomnominal/tsquery');
|
|
65
63
|
let routesFileContents = tree.read(routesFile, 'utf-8');
|
|
66
|
-
const
|
|
64
|
+
const sourceFile = ast(routesFileContents);
|
|
67
65
|
const ROUTES_ARRAY_SELECTOR = 'VariableDeclaration:has(ArrayType > TypeReference > Identifier[name=Route], Identifier[name=Routes]) > ArrayLiteralExpression';
|
|
68
|
-
const routesArrayNodes =
|
|
69
|
-
visitAllChildren: true,
|
|
70
|
-
});
|
|
66
|
+
const routesArrayNodes = query(sourceFile, ROUTES_ARRAY_SELECTOR);
|
|
71
67
|
const isRoutesArray = routesArrayNodes.length > 0;
|
|
72
68
|
if (!isRoutesArray) {
|
|
73
69
|
throw new Error(`Routing file (${routesFile}) does not a routing configuration. Please ensure the parent contains a routing configuration.`);
|
|
74
70
|
}
|
|
75
71
|
const ROUTE_SELECTOR = `ObjectLiteralExpression:has(PropertyAssignment:has(Identifier[name=path]) > StringLiteral[value=${routeToAddProviderTo}]):last-child`;
|
|
76
72
|
const ROUTE_PATH_PROVIDERS_SELECTOR = 'ObjectLiteralExpression > PropertyAssignment:has(Identifier[name=providers])';
|
|
77
|
-
const selectedRouteNodes =
|
|
78
|
-
visitAllChildren: true,
|
|
79
|
-
});
|
|
73
|
+
const selectedRouteNodes = query(routesArrayNodes[0], ROUTE_SELECTOR);
|
|
80
74
|
if (selectedRouteNodes.length === 0) {
|
|
81
75
|
throw new Error(`Could not find '${routeToAddProviderTo}' in routes definition.`);
|
|
82
76
|
}
|
|
83
77
|
for (const selectedRouteNode of selectedRouteNodes) {
|
|
84
|
-
const routeProivdersNodes =
|
|
85
|
-
visitAllChildren: true,
|
|
86
|
-
});
|
|
78
|
+
const routeProivdersNodes = query(selectedRouteNode, ROUTE_PATH_PROVIDERS_SELECTOR);
|
|
87
79
|
if (routeProivdersNodes.length === 0) {
|
|
88
80
|
const newFileContents = `${routesFileContents.slice(0, selectedRouteNode.getEnd() - 1)}${routesFileContents
|
|
89
81
|
.slice(0, selectedRouteNode.getEnd() - 1)
|