@dugararchit/cdk 0.0.0-dugararchit
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/_index.scss +8 -0
- package/a11y/_index.import.scss +2 -0
- package/a11y/_index.scss +102 -0
- package/a11y/a11y-prebuilt.scss +3 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs +2381 -0
- package/fesm2022/stagefright5-cdk-a11y.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs +267 -0
- package/fesm2022/stagefright5-cdk-accordion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs +185 -0
- package/fesm2022/stagefright5-cdk-bidi.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs +250 -0
- package/fesm2022/stagefright5-cdk-clipboard.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs +128 -0
- package/fesm2022/stagefright5-cdk-coercion.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-collections.mjs +472 -0
- package/fesm2022/stagefright5-cdk-collections.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs +3690 -0
- package/fesm2022/stagefright5-cdk-drag-drop.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs +159 -0
- package/fesm2022/stagefright5-cdk-keycodes.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-layout.mjs +246 -0
- package/fesm2022/stagefright5-cdk-layout.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-observers.mjs +203 -0
- package/fesm2022/stagefright5-cdk-observers.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs +3033 -0
- package/fesm2022/stagefright5-cdk-overlay.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-platform.mjs +375 -0
- package/fesm2022/stagefright5-cdk-platform.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-portal.mjs +672 -0
- package/fesm2022/stagefright5-cdk-portal.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs +1399 -0
- package/fesm2022/stagefright5-cdk-scrolling.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs +624 -0
- package/fesm2022/stagefright5-cdk-stepper.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-table.mjs +2346 -0
- package/fesm2022/stagefright5-cdk-table.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs +324 -0
- package/fesm2022/stagefright5-cdk-testing-protractor.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs +364 -0
- package/fesm2022/stagefright5-cdk-testing-selenium-webdriver.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs +806 -0
- package/fesm2022/stagefright5-cdk-testing-testbed.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-testing.mjs +740 -0
- package/fesm2022/stagefright5-cdk-testing.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs +453 -0
- package/fesm2022/stagefright5-cdk-text-field.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk-tree.mjs +945 -0
- package/fesm2022/stagefright5-cdk-tree.mjs.map +1 -0
- package/fesm2022/stagefright5-cdk.mjs +26 -0
- package/fesm2022/stagefright5-cdk.mjs.map +1 -0
- package/overlay/_index-deprecated.scss +13 -0
- package/overlay/_index.import.scss +13 -0
- package/overlay/_index.scss +148 -0
- package/overlay/overlay-prebuilt.scss +3 -0
- package/package.json +159 -0
- package/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/BUILD.bazel +104 -0
- package/schematics/schematics/README.md +4 -0
- package/schematics/schematics/collection.json +18 -0
- package/schematics/schematics/index.ts +22 -0
- package/schematics/schematics/migration.json +50 -0
- package/schematics/schematics/ng-add/index.spec.ts +50 -0
- package/schematics/schematics/ng-add/index.ts +39 -0
- package/schematics/schematics/ng-add/package-config.ts +62 -0
- package/schematics/schematics/ng-add/schema.json +16 -0
- package/schematics/schematics/ng-add/schema.ts +12 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template +53 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +17 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +29 -0
- package/schematics/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template +43 -0
- package/schematics/schematics/ng-generate/drag-drop/index.spec.ts +205 -0
- package/schematics/schematics/ng-generate/drag-drop/index.ts +35 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.json +93 -0
- package/schematics/schematics/ng-generate/drag-drop/schema.ts +11 -0
- package/schematics/schematics/ng-update/data/attribute-selectors.ts +29 -0
- package/schematics/schematics/ng-update/data/class-names.ts +50 -0
- package/schematics/schematics/ng-update/data/constructor-checks.ts +75 -0
- package/schematics/schematics/ng-update/data/css-selectors.ts +33 -0
- package/schematics/schematics/ng-update/data/element-selectors.ts +21 -0
- package/schematics/schematics/ng-update/data/index.ts +18 -0
- package/schematics/schematics/ng-update/data/input-names.ts +118 -0
- package/schematics/schematics/ng-update/data/method-call-checks.ts +63 -0
- package/schematics/schematics/ng-update/data/output-names.ts +42 -0
- package/schematics/schematics/ng-update/data/property-names.ts +151 -0
- package/schematics/schematics/ng-update/data/symbol-removal.ts +22 -0
- package/schematics/schematics/ng-update/devkit-file-system.ts +87 -0
- package/schematics/schematics/ng-update/devkit-migration-rule.ts +185 -0
- package/schematics/schematics/ng-update/devkit-migration.ts +47 -0
- package/schematics/schematics/ng-update/find-stylesheets.ts +43 -0
- package/schematics/schematics/ng-update/html-parsing/angular.ts +49 -0
- package/schematics/schematics/ng-update/html-parsing/elements.ts +66 -0
- package/schematics/schematics/ng-update/index.ts +113 -0
- package/schematics/schematics/ng-update/migrations/attribute-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/class-inheritance.ts +63 -0
- package/schematics/schematics/ng-update/migrations/class-names.ts +107 -0
- package/schematics/schematics/ng-update/migrations/constructor-signature.ts +170 -0
- package/schematics/schematics/ng-update/migrations/css-selectors.ts +83 -0
- package/schematics/schematics/ng-update/migrations/element-selectors.ts +75 -0
- package/schematics/schematics/ng-update/migrations/input-names.ts +83 -0
- package/schematics/schematics/ng-update/migrations/method-call-arguments.ts +70 -0
- package/schematics/schematics/ng-update/migrations/misc-template.ts +36 -0
- package/schematics/schematics/ng-update/migrations/output-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/property-names.ts +61 -0
- package/schematics/schematics/ng-update/migrations/symbol-removal.ts +51 -0
- package/schematics/schematics/ng-update/migrations/tilde-import-v13/tilde-import-migration.ts +40 -0
- package/schematics/schematics/ng-update/public-api.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/index.spec.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution.spec.ts +32 -0
- package/schematics/schematics/ng-update/test-cases/misc/external-resource-resolution_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets-test.scss +3 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets.spec.ts +50 -0
- package/schematics/schematics/ng-update/test-cases/misc/global-stylesheets_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks.spec.ts +20 -0
- package/schematics/schematics/ng-update/test-cases/misc/method-call-checks_input.ts +18 -0
- package/schematics/schematics/ng-update/test-cases/misc/module-resolution.spec.ts +27 -0
- package/schematics/schematics/ng-update/test-cases/v13/misc/tilde-import-v13.spec.ts +149 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_expected_output.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/attribute-selectors_input.ts +36 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_expected_output.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/class-names_input.ts +8 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_expected_output.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/input-names_input.ts +22 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_expected_output.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v6/property-names_input.ts +64 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_expected_output.ts +28 -0
- package/schematics/schematics/ng-update/test-cases/v7/property-names_input.ts +28 -0
- package/schematics/schematics/ng-update/typescript/base-types.ts +22 -0
- package/schematics/schematics/ng-update/typescript/imports.ts +54 -0
- package/schematics/schematics/ng-update/typescript/literal.ts +32 -0
- package/schematics/schematics/ng-update/typescript/module-specifiers.ts +39 -0
- package/schematics/schematics/ng-update/update-schematic.md +209 -0
- package/schematics/schematics/ng-update/upgrade-data.ts +79 -0
- package/schematics/schematics/paths.ts +15 -0
- package/schematics/schematics/testing/BUILD.bazel +27 -0
- package/schematics/schematics/testing/file-content.ts +20 -0
- package/schematics/schematics/testing/index.ts +14 -0
- package/schematics/schematics/testing/post-scheduled-tasks.ts +45 -0
- package/schematics/schematics/testing/resolve-bazel-path.ts +46 -0
- package/schematics/schematics/testing/test-app.ts +21 -0
- package/schematics/schematics/testing/test-case-setup.ts +236 -0
- package/schematics/schematics/testing/test-library.ts +21 -0
- package/schematics/schematics/testing/test-project.ts +40 -0
- package/schematics/schematics/testing/tsconfig.json +7 -0
- package/schematics/schematics/tsconfig.json +28 -0
- package/schematics/schematics/update-tool/BUILD.bazel +19 -0
- package/schematics/schematics/update-tool/component-resource-collector.ts +195 -0
- package/schematics/schematics/update-tool/file-system.ts +78 -0
- package/schematics/schematics/update-tool/index.ts +191 -0
- package/schematics/schematics/update-tool/logger.ts +23 -0
- package/schematics/schematics/update-tool/migration.ts +88 -0
- package/schematics/schematics/update-tool/public-api.ts +16 -0
- package/schematics/schematics/update-tool/target-version.ts +31 -0
- package/schematics/schematics/update-tool/tsconfig.json +7 -0
- package/schematics/schematics/update-tool/update-recorder.ts +14 -0
- package/schematics/schematics/update-tool/utils/decorators.ts +54 -0
- package/schematics/schematics/update-tool/utils/functions.ts +18 -0
- package/schematics/schematics/update-tool/utils/imports.ts +128 -0
- package/schematics/schematics/update-tool/utils/line-mappings.ts +84 -0
- package/schematics/schematics/update-tool/utils/parse-tsconfig.ts +25 -0
- package/schematics/schematics/update-tool/utils/property-name.ts +28 -0
- package/schematics/schematics/update-tool/utils/virtual-host.ts +116 -0
- package/schematics/schematics/update-tool/version-changes.ts +49 -0
- package/schematics/schematics/utils/ast/ng-module-imports.spec.ts +43 -0
- package/schematics/schematics/utils/ast/ng-module-imports.ts +102 -0
- package/schematics/schematics/utils/ast.ts +88 -0
- package/schematics/schematics/utils/build-component.ts +252 -0
- package/schematics/schematics/utils/get-project.ts +27 -0
- package/schematics/schematics/utils/html-manipulation.ts +105 -0
- package/schematics/schematics/utils/index.ts +19 -0
- package/schematics/schematics/utils/parse5-element.ts +34 -0
- package/schematics/schematics/utils/project-index-file.ts +21 -0
- package/schematics/schematics/utils/project-main-file.ts +26 -0
- package/schematics/schematics/utils/project-style-file.ts +53 -0
- package/schematics/schematics/utils/project-targets.ts +43 -0
- package/schematics/schematics/utils/project-tsconfig-paths.spec.ts +91 -0
- package/schematics/schematics/utils/project-tsconfig-paths.ts +49 -0
- package/schematics/schematics/utils/schematic-options.ts +65 -0
- package/schematics/schematics/utils/vendored-ast-utils/index.ts +599 -0
- package/scrolling/virtual-scroll-viewport.scss +87 -0
- package/table/table.scss +3 -0
- package/text-field/_index.import.scss +2 -0
- package/text-field/_index.scss +89 -0
- package/text-field/text-field-prebuilt.scss +4 -0
- package/types/stagefright5-cdk-a11y.d.ts +1160 -0
- package/types/stagefright5-cdk-accordion.d.ts +95 -0
- package/types/stagefright5-cdk-bidi.d.ts +95 -0
- package/types/stagefright5-cdk-clipboard.d.ts +116 -0
- package/types/stagefright5-cdk-coercion.d.ts +101 -0
- package/types/stagefright5-cdk-collections.d.ts +405 -0
- package/types/stagefright5-cdk-drag-drop.d.ts +1471 -0
- package/types/stagefright5-cdk-keycodes.d.ts +142 -0
- package/types/stagefright5-cdk-layout.d.ts +96 -0
- package/types/stagefright5-cdk-observers.d.ts +91 -0
- package/types/stagefright5-cdk-overlay.d.ts +1258 -0
- package/types/stagefright5-cdk-platform.d.ts +130 -0
- package/types/stagefright5-cdk-portal.d.ts +327 -0
- package/types/stagefright5-cdk-scrolling.d.ts +631 -0
- package/types/stagefright5-cdk-stepper.d.ts +302 -0
- package/types/stagefright5-cdk-table.d.ts +1128 -0
- package/types/stagefright5-cdk-testing-protractor.d.ts +146 -0
- package/types/stagefright5-cdk-testing-selenium-webdriver.d.ts +161 -0
- package/types/stagefright5-cdk-testing-testbed.d.ts +168 -0
- package/types/stagefright5-cdk-testing.d.ts +735 -0
- package/types/stagefright5-cdk-text-field.d.ts +171 -0
- package/types/stagefright5-cdk-tree.d.ts +522 -0
- package/types/stagefright5-cdk.d.ts +14 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {WorkspacePath} from '../../update-tool/file-system';
|
|
10
|
+
import {findInputsOnElementWithAttr, findInputsOnElementWithTag} from '../html-parsing/angular';
|
|
11
|
+
import {ResolvedResource} from '../../update-tool/component-resource-collector';
|
|
12
|
+
import {Migration} from '../../update-tool/migration';
|
|
13
|
+
|
|
14
|
+
import {InputNameUpgradeData} from '../data';
|
|
15
|
+
import {findAllSubstringIndices} from '../typescript/literal';
|
|
16
|
+
import {getVersionUpgradeData, UpgradeData} from '../upgrade-data';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Migration that walks through every template or stylesheet and replaces outdated input
|
|
20
|
+
* names to the new input name. Selectors in stylesheets could also target input
|
|
21
|
+
* bindings declared as static attribute. See for example:
|
|
22
|
+
*
|
|
23
|
+
* e.g. `<my-component color="primary">` becomes `my-component[color]`
|
|
24
|
+
*/
|
|
25
|
+
export class InputNamesMigration extends Migration<UpgradeData> {
|
|
26
|
+
/** Change data that upgrades to the specified target version. */
|
|
27
|
+
data: InputNameUpgradeData[] = getVersionUpgradeData(this, 'inputNames');
|
|
28
|
+
|
|
29
|
+
// Only enable the migration rule if there is upgrade data.
|
|
30
|
+
enabled = this.data.length !== 0;
|
|
31
|
+
|
|
32
|
+
override visitStylesheet(stylesheet: ResolvedResource): void {
|
|
33
|
+
this.data.forEach(name => {
|
|
34
|
+
const currentSelector = `[${name.replace}]`;
|
|
35
|
+
const updatedSelector = `[${name.replaceWith}]`;
|
|
36
|
+
|
|
37
|
+
findAllSubstringIndices(stylesheet.content, currentSelector)
|
|
38
|
+
.map(offset => stylesheet.start + offset)
|
|
39
|
+
.forEach(start =>
|
|
40
|
+
this._replaceInputName(
|
|
41
|
+
stylesheet.filePath,
|
|
42
|
+
start,
|
|
43
|
+
currentSelector.length,
|
|
44
|
+
updatedSelector,
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
override visitTemplate(template: ResolvedResource): void {
|
|
51
|
+
this.data.forEach(name => {
|
|
52
|
+
const limitedTo = name.limitedTo;
|
|
53
|
+
const relativeOffsets: number[] = [];
|
|
54
|
+
|
|
55
|
+
if (limitedTo.attributes) {
|
|
56
|
+
relativeOffsets.push(
|
|
57
|
+
...findInputsOnElementWithAttr(template.content, name.replace, limitedTo.attributes),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (limitedTo.elements) {
|
|
62
|
+
relativeOffsets.push(
|
|
63
|
+
...findInputsOnElementWithTag(template.content, name.replace, limitedTo.elements),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
relativeOffsets
|
|
68
|
+
.map(offset => template.start + offset)
|
|
69
|
+
.forEach(start =>
|
|
70
|
+
this._replaceInputName(template.filePath, start, name.replace.length, name.replaceWith),
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private _replaceInputName(
|
|
76
|
+
filePath: WorkspacePath,
|
|
77
|
+
start: number,
|
|
78
|
+
width: number,
|
|
79
|
+
newName: string,
|
|
80
|
+
) {
|
|
81
|
+
this.fileSystem.edit(filePath).remove(start, width).insertRight(start, newName);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as ts from 'typescript';
|
|
10
|
+
import {Migration} from '../../update-tool/migration';
|
|
11
|
+
|
|
12
|
+
import {MethodCallUpgradeData} from '../data';
|
|
13
|
+
import {getVersionUpgradeData, UpgradeData} from '../upgrade-data';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Migration that visits every TypeScript method call expression and checks if the
|
|
17
|
+
* argument count is invalid and needs to be *manually* updated.
|
|
18
|
+
*/
|
|
19
|
+
export class MethodCallArgumentsMigration extends Migration<UpgradeData> {
|
|
20
|
+
/** Change data that upgrades to the specified target version. */
|
|
21
|
+
data: MethodCallUpgradeData[] = getVersionUpgradeData(this, 'methodCallChecks');
|
|
22
|
+
|
|
23
|
+
// Only enable the migration rule if there is upgrade data.
|
|
24
|
+
enabled = this.data.length !== 0;
|
|
25
|
+
|
|
26
|
+
override visitNode(node: ts.Node): void {
|
|
27
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression)) {
|
|
28
|
+
this._checkPropertyAccessMethodCall(node);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private _checkPropertyAccessMethodCall(node: ts.CallExpression) {
|
|
33
|
+
const propertyAccess = node.expression as ts.PropertyAccessExpression;
|
|
34
|
+
|
|
35
|
+
if (!ts.isIdentifier(propertyAccess.name)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const hostType = this.typeChecker.getTypeAtLocation(propertyAccess.expression);
|
|
40
|
+
const hostTypeName = hostType.symbol && hostType.symbol.name;
|
|
41
|
+
const methodName = propertyAccess.name.text;
|
|
42
|
+
|
|
43
|
+
if (!hostTypeName) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// TODO(devversion): Revisit the implementation of this upgrade rule. It seems difficult
|
|
48
|
+
// and ambiguous to maintain the data for this rule. e.g. consider a method which has the
|
|
49
|
+
// same amount of arguments but just had a type change. In that case we could still add
|
|
50
|
+
// new entries to the upgrade data that match the current argument length to just show
|
|
51
|
+
// a failure message, but adding that data becomes painful if the method has optional
|
|
52
|
+
// parameters and it would mean that the error message would always show up, even if the
|
|
53
|
+
// argument is in some cases still assignable to the new parameter type. We could re-use
|
|
54
|
+
// the logic we have in the constructor-signature checks to check for assignability and
|
|
55
|
+
// to make the upgrade data less verbose.
|
|
56
|
+
const failure = this.data
|
|
57
|
+
.filter(data => data.method === methodName && data.className === hostTypeName)
|
|
58
|
+
.map(data => data.invalidArgCounts.find(f => f.count === node.arguments.length))[0];
|
|
59
|
+
|
|
60
|
+
if (!failure) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.createFailureAtNode(
|
|
65
|
+
node,
|
|
66
|
+
`Found call to "${hostTypeName + '.' + methodName}" ` +
|
|
67
|
+
`with ${failure.count} arguments. Message: ${failure.message}`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {TargetVersion} from '../../update-tool/target-version';
|
|
10
|
+
import {ResolvedResource} from '../../update-tool/component-resource-collector';
|
|
11
|
+
import {Migration} from '../../update-tool/migration';
|
|
12
|
+
import {findAllSubstringIndices} from '../typescript/literal';
|
|
13
|
+
import {UpgradeData} from '../upgrade-data';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Migration that walks through every template and reports if there are
|
|
17
|
+
* instances of outdated Angular CDK API that can't be migrated automatically.
|
|
18
|
+
*/
|
|
19
|
+
export class MiscTemplateMigration extends Migration<UpgradeData> {
|
|
20
|
+
// Only enable this rule if the migration targets version 6. The rule
|
|
21
|
+
// currently only includes migrations for V6 deprecations.
|
|
22
|
+
enabled = this.targetVersion === TargetVersion.V6;
|
|
23
|
+
|
|
24
|
+
override visitTemplate(template: ResolvedResource): void {
|
|
25
|
+
// Migration for https://github.com/angular/components/pull/10325 (v6)
|
|
26
|
+
findAllSubstringIndices(template.content, 'cdk-focus-trap').forEach(offset => {
|
|
27
|
+
this.failures.push({
|
|
28
|
+
filePath: template.filePath,
|
|
29
|
+
position: template.getCharacterAndLineOfPosition(template.start + offset),
|
|
30
|
+
message:
|
|
31
|
+
`Found deprecated element selector "cdk-focus-trap" which has been ` +
|
|
32
|
+
`changed to an attribute selector "[cdkTrapFocus]".`,
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {WorkspacePath} from '../../update-tool/file-system';
|
|
10
|
+
import {ResolvedResource} from '../../update-tool/component-resource-collector';
|
|
11
|
+
import {Migration} from '../../update-tool/migration';
|
|
12
|
+
|
|
13
|
+
import {OutputNameUpgradeData} from '../data';
|
|
14
|
+
import {findOutputsOnElementWithAttr, findOutputsOnElementWithTag} from '../html-parsing/angular';
|
|
15
|
+
import {getVersionUpgradeData, UpgradeData} from '../upgrade-data';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Migration that walks through every inline or external HTML template and switches
|
|
19
|
+
* changed output binding names to the proper new output name.
|
|
20
|
+
*/
|
|
21
|
+
export class OutputNamesMigration extends Migration<UpgradeData> {
|
|
22
|
+
/** Change data that upgrades to the specified target version. */
|
|
23
|
+
data: OutputNameUpgradeData[] = getVersionUpgradeData(this, 'outputNames');
|
|
24
|
+
|
|
25
|
+
// Only enable the migration rule if there is upgrade data.
|
|
26
|
+
enabled = this.data.length !== 0;
|
|
27
|
+
|
|
28
|
+
override visitTemplate(template: ResolvedResource): void {
|
|
29
|
+
this.data.forEach(name => {
|
|
30
|
+
const limitedTo = name.limitedTo;
|
|
31
|
+
const relativeOffsets: number[] = [];
|
|
32
|
+
|
|
33
|
+
if (limitedTo.attributes) {
|
|
34
|
+
relativeOffsets.push(
|
|
35
|
+
...findOutputsOnElementWithAttr(template.content, name.replace, limitedTo.attributes),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (limitedTo.elements) {
|
|
40
|
+
relativeOffsets.push(
|
|
41
|
+
...findOutputsOnElementWithTag(template.content, name.replace, limitedTo.elements),
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
relativeOffsets
|
|
46
|
+
.map(offset => template.start + offset)
|
|
47
|
+
.forEach(start =>
|
|
48
|
+
this._replaceOutputName(template.filePath, start, name.replace.length, name.replaceWith),
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private _replaceOutputName(
|
|
54
|
+
filePath: WorkspacePath,
|
|
55
|
+
start: number,
|
|
56
|
+
width: number,
|
|
57
|
+
newName: string,
|
|
58
|
+
) {
|
|
59
|
+
this.fileSystem.edit(filePath).remove(start, width).insertRight(start, newName);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as ts from 'typescript';
|
|
10
|
+
import {Migration} from '../../update-tool/migration';
|
|
11
|
+
|
|
12
|
+
import {PropertyNameUpgradeData} from '../data';
|
|
13
|
+
import {getVersionUpgradeData, UpgradeData} from '../upgrade-data';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Migration that walks through every property access expression and updates
|
|
17
|
+
* accessed properties that have been updated to a new name.
|
|
18
|
+
*/
|
|
19
|
+
export class PropertyNamesMigration extends Migration<UpgradeData> {
|
|
20
|
+
/** Change data that upgrades to the specified target version. */
|
|
21
|
+
data: PropertyNameUpgradeData[] = getVersionUpgradeData(this, 'propertyNames');
|
|
22
|
+
|
|
23
|
+
// Only enable the migration rule if there is upgrade data.
|
|
24
|
+
enabled = this.data.length !== 0;
|
|
25
|
+
|
|
26
|
+
override visitNode(node: ts.Node): void {
|
|
27
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
28
|
+
this._visitPropertyAccessExpression(node);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private _visitPropertyAccessExpression(node: ts.PropertyAccessExpression) {
|
|
33
|
+
const hostType = this.typeChecker.getTypeAtLocation(node.expression);
|
|
34
|
+
const typeNames: string[] = [];
|
|
35
|
+
|
|
36
|
+
if (hostType) {
|
|
37
|
+
if (hostType.isIntersection()) {
|
|
38
|
+
hostType.types.forEach(type => {
|
|
39
|
+
if (type.symbol) {
|
|
40
|
+
typeNames.push(type.symbol.getName());
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
} else if (hostType.symbol) {
|
|
44
|
+
typeNames.push(hostType.symbol.getName());
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.data.forEach(data => {
|
|
49
|
+
if (node.name.text !== data.replace) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!data.limitedTo || typeNames.some(type => data.limitedTo.classes.includes(type))) {
|
|
54
|
+
this.fileSystem
|
|
55
|
+
.edit(this.fileSystem.resolve(node.getSourceFile().fileName))
|
|
56
|
+
.remove(node.name.getStart(), node.name.getWidth())
|
|
57
|
+
.insertRight(node.name.getStart(), data.replaceWith);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import * as ts from 'typescript';
|
|
10
|
+
import {Migration} from '../../update-tool/migration';
|
|
11
|
+
import {SymbolRemovalUpgradeData} from '../data';
|
|
12
|
+
import {getVersionUpgradeData, UpgradeData} from '../upgrade-data';
|
|
13
|
+
|
|
14
|
+
/** Migration that flags imports for symbols that have been removed. */
|
|
15
|
+
export class SymbolRemovalMigration extends Migration<UpgradeData> {
|
|
16
|
+
/** Change data that upgrades to the specified target version. */
|
|
17
|
+
data: SymbolRemovalUpgradeData[] = getVersionUpgradeData(this, 'symbolRemoval');
|
|
18
|
+
|
|
19
|
+
// Only enable the migration rule if there is upgrade data.
|
|
20
|
+
enabled = this.data.length !== 0;
|
|
21
|
+
|
|
22
|
+
override visitNode(node: ts.Node): void {
|
|
23
|
+
if (!ts.isImportDeclaration(node) || !ts.isStringLiteral(node.moduleSpecifier)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const namedBindings = node.importClause && node.importClause.namedBindings;
|
|
28
|
+
|
|
29
|
+
if (!namedBindings || !ts.isNamedImports(namedBindings)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const moduleNameMatches = this.data.filter(
|
|
34
|
+
entry => (node.moduleSpecifier as ts.StringLiteral).text === entry.module,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if (!moduleNameMatches.length) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
namedBindings.elements.forEach(element => {
|
|
42
|
+
const elementName = element.propertyName?.text || element.name.text;
|
|
43
|
+
|
|
44
|
+
moduleNameMatches.forEach(match => {
|
|
45
|
+
if (match.name === elementName) {
|
|
46
|
+
this.createFailureAtNode(element, match.message);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {extname} from '@angular-devkit/core';
|
|
10
|
+
import {ResolvedResource} from '../../../update-tool/component-resource-collector';
|
|
11
|
+
import {TargetVersion} from '../../../update-tool/target-version';
|
|
12
|
+
import {DevkitMigration} from '../../devkit-migration';
|
|
13
|
+
|
|
14
|
+
/** Migration that removes tilde symbols from imports. */
|
|
15
|
+
export class TildeImportMigration extends DevkitMigration<null> {
|
|
16
|
+
enabled = this.targetVersion === TargetVersion.V13;
|
|
17
|
+
|
|
18
|
+
override visitStylesheet(stylesheet: ResolvedResource): void {
|
|
19
|
+
const extension = extname(stylesheet.filePath);
|
|
20
|
+
|
|
21
|
+
if (extension === '.scss' || extension === '.css') {
|
|
22
|
+
const content = stylesheet.content;
|
|
23
|
+
const migratedContent = content.replace(
|
|
24
|
+
/@(?:import|use) +['"](~@angular\/.*)['"].*;?/g,
|
|
25
|
+
(match, importPath) => {
|
|
26
|
+
const index = match.indexOf(importPath);
|
|
27
|
+
const newImportPath = importPath.replace(/^~|\.scss$/g, '');
|
|
28
|
+
return match.slice(0, index) + newImportPath + match.slice(index + importPath.length);
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
if (migratedContent && migratedContent !== content) {
|
|
33
|
+
this.fileSystem
|
|
34
|
+
.edit(stylesheet.filePath)
|
|
35
|
+
.remove(0, stylesheet.content.length)
|
|
36
|
+
.insertLeft(0, migratedContent);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google LLC All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export * from './data/index';
|
|
10
|
+
export * from './devkit-migration';
|
|
11
|
+
export * from './devkit-migration-rule';
|
|
12
|
+
export * from './html-parsing/angular';
|
|
13
|
+
export * from './html-parsing/elements';
|
|
14
|
+
export * from './typescript/base-types';
|
|
15
|
+
export * from './typescript/imports';
|
|
16
|
+
export * from './typescript/literal';
|
|
17
|
+
export * from './typescript/module-specifiers';
|
|
18
|
+
export * from './upgrade-data';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {defineJasmineTestCases, findBazelVersionTestCases} from '@dugararchit/cdk/schematics/testing';
|
|
2
|
+
import {MIGRATION_PATH} from '../../paths';
|
|
3
|
+
import {getAllVersionNames} from '../../update-tool/target-version';
|
|
4
|
+
|
|
5
|
+
describe('CDK upgrade test cases', () => {
|
|
6
|
+
const versionNames = getAllVersionNames().map(versionName => versionName.toLowerCase());
|
|
7
|
+
const testCasesMap = findBazelVersionTestCases(
|
|
8
|
+
'angular_material/src/cdk/schematics/ng-update/test-cases',
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
// Setup the test cases for each target version. The test cases will be automatically
|
|
12
|
+
// detected through Bazel's runfiles manifest.
|
|
13
|
+
versionNames.forEach(version =>
|
|
14
|
+
describe(`${version} update`, () => {
|
|
15
|
+
defineJasmineTestCases(version, MIGRATION_PATH, testCasesMap.get(version));
|
|
16
|
+
}),
|
|
17
|
+
);
|
|
18
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {resolveBazelPath} from '@dugararchit/cdk/schematics/testing';
|
|
2
|
+
import {MIGRATION_PATH} from '../../../paths';
|
|
3
|
+
import {createTestCaseSetup} from '../../../testing';
|
|
4
|
+
|
|
5
|
+
describe('ng-update external resource resolution', () => {
|
|
6
|
+
it('should properly resolve referenced resources in components', async () => {
|
|
7
|
+
const {runFixers, writeFile, appTree} = await createTestCaseSetup(
|
|
8
|
+
'migration-v6',
|
|
9
|
+
MIGRATION_PATH,
|
|
10
|
+
[resolveBazelPath(__dirname, './external-resource-resolution_input.ts')],
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const testContent = `<div cdk-connected-overlay [origin]="test"></div>`;
|
|
14
|
+
const expected = `<div cdk-connected-overlay [cdkConnectedOverlayOrigin]="test"></div>`;
|
|
15
|
+
|
|
16
|
+
writeFile('/projects/material/test.html', testContent);
|
|
17
|
+
writeFile('/projects/cdk-testing/src/some-tmpl.html', testContent);
|
|
18
|
+
writeFile('/projects/cdk-testing/src/test-cases/local.html', testContent);
|
|
19
|
+
|
|
20
|
+
await runFixers();
|
|
21
|
+
|
|
22
|
+
expect(appTree.readContent('/projects/material/test.html'))
|
|
23
|
+
.withContext('Expected absolute devkit tree paths to work.')
|
|
24
|
+
.toBe(expected);
|
|
25
|
+
expect(appTree.readContent('/projects/cdk-testing/src/some-tmpl.html'))
|
|
26
|
+
.withContext('Expected relative paths with parent segments to work.')
|
|
27
|
+
.toBe(expected);
|
|
28
|
+
expect(appTree.readContent('/projects/cdk-testing/src/test-cases/local.html'))
|
|
29
|
+
.withContext('Expected relative paths without explicit dot to work.')
|
|
30
|
+
.toBe(expected);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {Component} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Component({
|
|
4
|
+
standalone: false,
|
|
5
|
+
selector: 'test-cmp',
|
|
6
|
+
templateUrl: '/projects/material/test.html',
|
|
7
|
+
})
|
|
8
|
+
export class MyTestComp {}
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
standalone: false,
|
|
12
|
+
selector: 'test-cmp2',
|
|
13
|
+
templateUrl: '../some-tmpl.html',
|
|
14
|
+
})
|
|
15
|
+
export class MyTestComp2 {}
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
standalone: false,
|
|
19
|
+
selector: 'test-cmp3',
|
|
20
|
+
templateUrl: 'local.html',
|
|
21
|
+
})
|
|
22
|
+
export class MyTestComp3 {}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {resolveBazelPath} from '@dugararchit/cdk/schematics/testing';
|
|
2
|
+
import {readFileSync} from 'fs';
|
|
3
|
+
import {MIGRATION_PATH} from '../../../paths';
|
|
4
|
+
import {createTestCaseSetup} from '../../../testing';
|
|
5
|
+
|
|
6
|
+
describe('global stylesheets migration', () => {
|
|
7
|
+
it('should not check stylesheet twice if referenced in component', async () => {
|
|
8
|
+
const {runFixers, writeFile, appTree} = await createTestCaseSetup(
|
|
9
|
+
'migration-v6',
|
|
10
|
+
MIGRATION_PATH,
|
|
11
|
+
[resolveBazelPath(__dirname, './global-stylesheets_input.ts')],
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const testStylesheetPath = 'projects/cdk-testing/src/test-cases/global-stylesheets-test.scss';
|
|
15
|
+
|
|
16
|
+
// Copy the test stylesheets file into the test CLI application. That way it will
|
|
17
|
+
// be picked up by the update-tool.
|
|
18
|
+
writeFile(
|
|
19
|
+
testStylesheetPath,
|
|
20
|
+
readFileSync(resolveBazelPath(__dirname, './global-stylesheets-test.scss'), 'utf8'),
|
|
21
|
+
);
|
|
22
|
+
writeFile('/projects/cdk-testing/third_party/materialize.css/bundle.css', '');
|
|
23
|
+
|
|
24
|
+
await runFixers();
|
|
25
|
+
|
|
26
|
+
// if the external stylesheet would have been checked multiple times, the migrated
|
|
27
|
+
// stylesheet would not match the expected output and the devkit would throw that
|
|
28
|
+
// the same replacements were recorded for the same source file.
|
|
29
|
+
expect(appTree.readContent(testStylesheetPath)).toBe(`[cdkPortalOutlet] {\n color: red;\n}\n`);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should not check stylesheets outside of project target', async () => {
|
|
33
|
+
const {runFixers, writeFile, appTree} = await createTestCaseSetup(
|
|
34
|
+
'migration-v6',
|
|
35
|
+
MIGRATION_PATH,
|
|
36
|
+
[],
|
|
37
|
+
);
|
|
38
|
+
const subProjectStylesheet = '[cdkPortalHost] {\n color: red;\n}\n';
|
|
39
|
+
|
|
40
|
+
writeFile('/sub_project/node_modules/materialize.css/package.json', '');
|
|
41
|
+
writeFile('/sub_project/assets/test.css', subProjectStylesheet);
|
|
42
|
+
|
|
43
|
+
// Run the fixers and expect no error to be thrown.
|
|
44
|
+
await expectAsync(runFixers()).not.toBeRejected();
|
|
45
|
+
|
|
46
|
+
// if the external stylesheet that is not of a project target would have been checked
|
|
47
|
+
// by accident, the stylesheet would differ from the original file content.
|
|
48
|
+
expect(appTree.readContent('/sub_project/assets/test.css')).toBe(subProjectStylesheet);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {resolveBazelPath} from '@dugararchit/cdk/schematics/testing';
|
|
2
|
+
import {MIGRATION_PATH} from '../../../paths';
|
|
3
|
+
import {createTestCaseSetup} from '../../../testing';
|
|
4
|
+
|
|
5
|
+
describe('v6 method call checks', () => {
|
|
6
|
+
it('should properly report invalid method calls', async () => {
|
|
7
|
+
const {runFixers} = await createTestCaseSetup('migration-v6', MIGRATION_PATH, [
|
|
8
|
+
resolveBazelPath(__dirname, './method-call-checks_input.ts'),
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const {logOutput} = await runFixers();
|
|
12
|
+
|
|
13
|
+
expect(logOutput).toMatch(
|
|
14
|
+
/@15:5 - Found call to "FocusMonitor\.monitor".*renderer.*has been removed/,
|
|
15
|
+
);
|
|
16
|
+
expect(logOutput).toMatch(
|
|
17
|
+
/@16:5 - Found call to "FocusMonitor\.monitor".*renderer.*has been removed/,
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {AfterViewInit, ElementRef, Renderer2} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
class FocusMonitor {
|
|
4
|
+
monitor(_htmlElement: any, _renderer: Renderer2, _checkChildren: boolean) {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class A implements AfterViewInit {
|
|
8
|
+
self = {a: this.focusMonitor};
|
|
9
|
+
|
|
10
|
+
constructor(private focusMonitor: FocusMonitor,
|
|
11
|
+
private elementRef: ElementRef,
|
|
12
|
+
private renderer: Renderer2) {}
|
|
13
|
+
|
|
14
|
+
ngAfterViewInit() {
|
|
15
|
+
this.focusMonitor.monitor(this.elementRef.nativeElement, this.renderer, true);
|
|
16
|
+
this.self.a.monitor(this.elementRef.nativeElement, this.renderer, true);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {MIGRATION_PATH} from '../../../paths';
|
|
2
|
+
import {createTestCaseSetup} from '../../../testing';
|
|
3
|
+
|
|
4
|
+
describe('ng update typescript program module resolution', () => {
|
|
5
|
+
// Regression test for: https://github.com/angular/components/issues/22919.
|
|
6
|
+
it(
|
|
7
|
+
'should not error if module resolution tries a non-existent path where a path segment ' +
|
|
8
|
+
'matches an existing file',
|
|
9
|
+
async () => {
|
|
10
|
+
const {runFixers, writeFile} = await createTestCaseSetup('migration-v6', MIGRATION_PATH, []);
|
|
11
|
+
|
|
12
|
+
writeFile('/node_modules/some-other-module/package.json', `{}`);
|
|
13
|
+
writeFile('/node_modules/some-other-module/styles.css', '');
|
|
14
|
+
|
|
15
|
+
// We add an import to a non-existent sub-path of `some-other-module/styles`. The TypeScript
|
|
16
|
+
// module resolution logic could try various sub-paths. This previously resulted in an error
|
|
17
|
+
// as the devkit tree `getDir` logic accidentally walked up the path and threw an error if
|
|
18
|
+
// a path segment is an actual file.
|
|
19
|
+
writeFile(
|
|
20
|
+
'/projects/cdk-testing/src/main.ts',
|
|
21
|
+
`import 'some-other-module/styles.css/non/existent';`,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
await expectAsync(runFixers()).toBeResolved();
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
});
|