ngx-tethys 17.0.0-next.4 → 17.0.0-next.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/esm2022/version.mjs +2 -2
  3. package/fesm2022/ngx-tethys.mjs +1 -1
  4. package/fesm2022/ngx-tethys.mjs.map +1 -1
  5. package/package.json +1 -1
  6. package/schematics/ng-update/core/complete.d.ts +0 -1
  7. package/schematics/ng-update/core/complete.js +1 -10
  8. package/schematics/ng-update/update-17/class-name-migration.d.ts +12 -0
  9. package/schematics/ng-update/update-17/class-name-migration.js +62 -0
  10. package/schematics/ng-update/update-17/index.js +4 -3
  11. package/schematics/ng-update/update-17/index.spec.js +57 -0
  12. package/schematics/ng-update/update-17/update-data.d.ts +2 -0
  13. package/schematics/ng-update/update-17/update-data.js +788 -0
  14. package/schematics/version.d.ts +1 -1
  15. package/schematics/version.js +1 -1
  16. package/schematics/ng-update/core/html-parsing.d.ts +0 -175
  17. package/schematics/ng-update/core/html-parsing.js +0 -237
  18. package/schematics/ng-update/core/module-specifiers.d.ts +0 -4
  19. package/schematics/ng-update/core/module-specifiers.js +0 -20
  20. package/schematics/ng-update/core/upgrade-data.d.ts +0 -14
  21. package/schematics/ng-update/core/upgrade-data.js +0 -12
  22. package/schematics/ng-update/data/after-insert-element.d.ts +0 -40
  23. package/schematics/ng-update/data/after-insert-element.js +0 -27
  24. package/schematics/ng-update/data/attribute-selectors.d.ts +0 -2
  25. package/schematics/ng-update/data/attribute-selectors.js +0 -53
  26. package/schematics/ng-update/data/before-insert-element.d.ts +0 -40
  27. package/schematics/ng-update/data/before-insert-element.js +0 -27
  28. package/schematics/ng-update/data/class-names.d.ts +0 -2
  29. package/schematics/ng-update/data/class-names.js +0 -837
  30. package/schematics/ng-update/data/constructor-checks.d.ts +0 -2
  31. package/schematics/ng-update/data/constructor-checks.js +0 -4
  32. package/schematics/ng-update/data/css-selectors.d.ts +0 -20
  33. package/schematics/ng-update/data/css-selectors.js +0 -49
  34. package/schematics/ng-update/data/element-selectors.d.ts +0 -2
  35. package/schematics/ng-update/data/element-selectors.js +0 -33
  36. package/schematics/ng-update/data/entry-points.d.ts +0 -18
  37. package/schematics/ng-update/data/entry-points.js +0 -21
  38. package/schematics/ng-update/data/index.d.ts +0 -17
  39. package/schematics/ng-update/data/index.js +0 -53
  40. package/schematics/ng-update/data/input-names-removal.d.ts +0 -33
  41. package/schematics/ng-update/data/input-names-removal.js +0 -43
  42. package/schematics/ng-update/data/input-names.d.ts +0 -2
  43. package/schematics/ng-update/data/input-names.js +0 -69
  44. package/schematics/ng-update/data/input-values.d.ts +0 -40
  45. package/schematics/ng-update/data/input-values.js +0 -132
  46. package/schematics/ng-update/data/method-call-checks.d.ts +0 -2
  47. package/schematics/ng-update/data/method-call-checks.js +0 -4
  48. package/schematics/ng-update/data/output-names-removal.d.ts +0 -33
  49. package/schematics/ng-update/data/output-names-removal.js +0 -19
  50. package/schematics/ng-update/data/output-names.d.ts +0 -2
  51. package/schematics/ng-update/data/output-names.js +0 -4
  52. package/schematics/ng-update/data/property-names.d.ts +0 -2
  53. package/schematics/ng-update/data/property-names.js +0 -4
  54. package/schematics/ng-update/data/symbol-removal.d.ts +0 -11
  55. package/schematics/ng-update/data/symbol-removal.js +0 -4
  56. package/schematics/ng-update/migrations/after-insert-element.d.ts +0 -17
  57. package/schematics/ng-update/migrations/after-insert-element.js +0 -53
  58. package/schematics/ng-update/migrations/before-insert-element.d.ts +0 -17
  59. package/schematics/ng-update/migrations/before-insert-element.js +0 -53
  60. package/schematics/ng-update/migrations/checks/action-menu-removal-rule.d.ts +0 -13
  61. package/schematics/ng-update/migrations/checks/action-menu-removal-rule.js +0 -80
  62. package/schematics/ng-update/migrations/checks/label-removal-rule.d.ts +0 -9
  63. package/schematics/ng-update/migrations/checks/label-removal-rule.js +0 -77
  64. package/schematics/ng-update/migrations/class-names.d.ts +0 -50
  65. package/schematics/ng-update/migrations/class-names.js +0 -105
  66. package/schematics/ng-update/migrations/entry-points.d.ts +0 -17
  67. package/schematics/ng-update/migrations/entry-points.js +0 -69
  68. package/schematics/ng-update/migrations/input-names-removal.d.ts +0 -16
  69. package/schematics/ng-update/migrations/input-names-removal.js +0 -43
  70. package/schematics/ng-update/migrations/input-values.d.ts +0 -16
  71. package/schematics/ng-update/migrations/input-values.js +0 -65
  72. package/schematics/ng-update/migrations/output-names-removal.d.ts +0 -16
  73. package/schematics/ng-update/migrations/output-names-removal.js +0 -43
@@ -1,17 +0,0 @@
1
- import { Migration, ResolvedResource } from '@angular/cdk/schematics';
2
- import { TethysUpgradeData } from '../core/upgrade-data';
3
- import { AfterInsertElementUpgradeData } from '../data/after-insert-element';
4
- /**
5
- * Migration that walks through every template or stylesheet and replaces deprecated input
6
- * names.Then insert a new element after the last child node in the current element, and the attribute will be removed from the current element and placed on the inserted element
7
- * Selectors in stylesheets could also target input
8
- * bindings declared as static attribute. See for example:
9
- *
10
- * 迁移将遍历每个模板或样式表,并移除废弃的输入名称,并在当前元素的最后一个子节点后插入元素。
11
- */
12
- export declare class AfterInsertElementMigration extends Migration<TethysUpgradeData> {
13
- data: AfterInsertElementUpgradeData[];
14
- enabled: boolean;
15
- visitTemplate(template: ResolvedResource): void;
16
- private _afterInsertElement;
17
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AfterInsertElementMigration = void 0;
4
- const schematics_1 = require("@angular/cdk/schematics");
5
- const html_parsing_1 = require("../core/html-parsing");
6
- const upgrade_data_1 = require("../core/upgrade-data");
7
- /**
8
- * Migration that walks through every template or stylesheet and replaces deprecated input
9
- * names.Then insert a new element after the last child node in the current element, and the attribute will be removed from the current element and placed on the inserted element
10
- * Selectors in stylesheets could also target input
11
- * bindings declared as static attribute. See for example:
12
- *
13
- * 迁移将遍历每个模板或样式表,并移除废弃的输入名称,并在当前元素的最后一个子节点后插入元素。
14
- */
15
- class AfterInsertElementMigration extends schematics_1.Migration {
16
- constructor() {
17
- super(...arguments);
18
- this.data = (0, upgrade_data_1.getTethysVersionUpgradeData)(this, 'afterInsertElement');
19
- this.enabled = this.data.length !== 0;
20
- }
21
- visitTemplate(template) {
22
- this.data.forEach(name => {
23
- const limitedTo = name.limitedTo;
24
- const relativeOffsets = [];
25
- if (limitedTo.attributes) {
26
- relativeOffsets.push(...(0, html_parsing_1.findWholeInputsOnElementWithAttrInputBrackets)(template.content, name.replace, limitedTo.attributes));
27
- }
28
- if (limitedTo.elements) {
29
- relativeOffsets.push(...(0, html_parsing_1.findWholeInputsOnElementWithTagInputBrackets)(template.content, name.replace, limitedTo.elements));
30
- }
31
- relativeOffsets
32
- .map(offset => {
33
- return {
34
- start: template.start + offset.start,
35
- length: offset.end - offset.start,
36
- endTagStart: template.start + offset.endTagStart,
37
- replaceValue: offset.value
38
- };
39
- })
40
- .forEach(value => this._afterInsertElement(template.filePath, value.start, value.length, name.insert, value.endTagStart, name.replace, value.replaceValue));
41
- });
42
- }
43
- _afterInsertElement(filePath, start, width, insert, endTagStart, replace, replaceValue) {
44
- if (insert.includes(replace)) {
45
- const insertWithValue = insert.replace(replace, `'${replaceValue}'`);
46
- this.fileSystem.edit(filePath).remove(start, width).insertLeft(endTagStart, insertWithValue);
47
- }
48
- else {
49
- this.fileSystem.edit(filePath).remove(start, width).insertLeft(endTagStart, insert);
50
- }
51
- }
52
- }
53
- exports.AfterInsertElementMigration = AfterInsertElementMigration;
@@ -1,17 +0,0 @@
1
- import { Migration, ResolvedResource } from '@angular/cdk/schematics';
2
- import { TethysUpgradeData } from '../core/upgrade-data';
3
- import { BeforeInsertElementUpgradeData } from '../data/before-insert-element';
4
- /**
5
- * Migration that walks through every template or stylesheet and replaces deprecated input
6
- * names.Then insert a new element before the first child node in the current element, and the attribute will be removed from the current element and placed on the inserted element
7
- * Selectors in stylesheets could also target input
8
- * bindings declared as static attribute. See for example:
9
- *
10
- * 迁移将遍历每个模板或样式表,并移除废弃的输入名称,并在当前元素的第一个子节点前插入元素。
11
- */
12
- export declare class BeforeInsertElementMigration extends Migration<TethysUpgradeData> {
13
- data: BeforeInsertElementUpgradeData[];
14
- enabled: boolean;
15
- visitTemplate(template: ResolvedResource): void;
16
- private _beforeInsertElement;
17
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BeforeInsertElementMigration = void 0;
4
- const schematics_1 = require("@angular/cdk/schematics");
5
- const html_parsing_1 = require("../core/html-parsing");
6
- const upgrade_data_1 = require("../core/upgrade-data");
7
- /**
8
- * Migration that walks through every template or stylesheet and replaces deprecated input
9
- * names.Then insert a new element before the first child node in the current element, and the attribute will be removed from the current element and placed on the inserted element
10
- * Selectors in stylesheets could also target input
11
- * bindings declared as static attribute. See for example:
12
- *
13
- * 迁移将遍历每个模板或样式表,并移除废弃的输入名称,并在当前元素的第一个子节点前插入元素。
14
- */
15
- class BeforeInsertElementMigration extends schematics_1.Migration {
16
- constructor() {
17
- super(...arguments);
18
- this.data = (0, upgrade_data_1.getTethysVersionUpgradeData)(this, 'beforeInsertElement');
19
- this.enabled = this.data.length !== 0;
20
- }
21
- visitTemplate(template) {
22
- this.data.forEach(name => {
23
- const limitedTo = name.limitedTo;
24
- const relativeOffsets = [];
25
- if (limitedTo.attributes) {
26
- relativeOffsets.push(...(0, html_parsing_1.findWholeInputsOnElementWithAttrInputBrackets)(template.content, name.replace, limitedTo.attributes));
27
- }
28
- if (limitedTo.elements) {
29
- relativeOffsets.push(...(0, html_parsing_1.findWholeInputsOnElementWithTagInputBrackets)(template.content, name.replace, limitedTo.elements));
30
- }
31
- relativeOffsets
32
- .map(offset => {
33
- return {
34
- start: template.start + offset.start,
35
- length: offset.end - offset.start,
36
- startTagEnd: template.start + offset.startTagEnd,
37
- replaceValue: offset.value
38
- };
39
- })
40
- .forEach(value => this._beforeInsertElement(template.filePath, value.start, value.length, name.insert, value.startTagEnd, name.replace, value.replaceValue));
41
- });
42
- }
43
- _beforeInsertElement(filePath, start, width, insert, startTagEnd, replace, replaceValue) {
44
- if (insert.includes(replace)) {
45
- const insertWithValue = insert.replace(replace, `"${replaceValue}"`);
46
- this.fileSystem.edit(filePath).remove(start, width).insertRight(startTagEnd, insertWithValue);
47
- }
48
- else {
49
- this.fileSystem.edit(filePath).remove(start, width).insertRight(startTagEnd, insert);
50
- }
51
- }
52
- }
53
- exports.BeforeInsertElementMigration = BeforeInsertElementMigration;
@@ -1,13 +0,0 @@
1
- /**
2
- * Use of this source code is governed by an MIT-style license that can be
3
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
4
- */
5
- import { Migration, ResolvedResource, UpgradeData } from '@angular/cdk/schematics';
6
- import * as ts from 'typescript';
7
- export declare class ActionMenuRemovalRule extends Migration<UpgradeData> {
8
- enabled: boolean;
9
- visitTemplate(template: ResolvedResource): void;
10
- visitNode(node: ts.Node): void;
11
- private _visitIdentifier;
12
- visitStylesheet(stylesheet: ResolvedResource): void;
13
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- /**
3
- * Use of this source code is governed by an MIT-style license that can be
4
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.ActionMenuRemovalRule = void 0;
8
- const tslib_1 = require("tslib");
9
- const schematics_1 = require("@angular/cdk/schematics");
10
- const ts = tslib_1.__importStar(require("typescript"));
11
- const html_parsing_1 = require("../../core/html-parsing");
12
- class ActionMenuRemovalRule extends schematics_1.Migration {
13
- constructor() {
14
- super(...arguments);
15
- this.enabled = true;
16
- }
17
- visitTemplate(template) {
18
- (0, html_parsing_1.findWholeInputsNameAndValueOnElementWithTag)(template.content, 'thyTheme', 'group', ['thy-action-menu']).forEach(offset => {
19
- this.failures.push({
20
- filePath: template.filePath,
21
- position: template.getCharacterAndLineOfPosition(offset.start),
22
- message: `Remove deprecated thy-action-menu component with input "thyTheme". Please manually use "thy-dropdown-menu-group" to instead.`
23
- });
24
- });
25
- (0, schematics_1.findInputsOnElementWithAttr)(template.content, 'thyPlacement', ['thyActionMenuToggle', '[thyActionMenuToggle]']).forEach(offset => {
26
- this.failures.push({
27
- filePath: template.filePath,
28
- position: template.getCharacterAndLineOfPosition(offset),
29
- message: `Found input "thyPlacement" in deprecated thyActionMenuToggle directive. Please manually use camel case. (eg.right bottom to rightBottom)`
30
- });
31
- });
32
- }
33
- // 提示给用户,删除的导出类
34
- visitNode(node) {
35
- if (ts.isIdentifier(node)) {
36
- this._visitIdentifier(node);
37
- }
38
- }
39
- _visitIdentifier(identifier) {
40
- if (identifier.getText() === 'ThyActionMenuTheme') {
41
- this.createFailureAtNode(identifier, `Remove deprecated "ThyActionMenuTheme".`);
42
- }
43
- if (identifier.getText() === 'ThyActionMenuDividerType') {
44
- this.createFailureAtNode(identifier, `Remove deprecated "ThyActionMenuDividerType".`);
45
- }
46
- if (identifier.getText() === 'ThyActionMenuDividerTitleDirective') {
47
- this.createFailureAtNode(identifier, `Remove deprecated "ThyActionMenuDividerTitleDirective".`);
48
- }
49
- }
50
- visitStylesheet(stylesheet) {
51
- (0, schematics_1.findAllSubstringIndices)(stylesheet.content, '$action-menu-divider-margin-y')
52
- .map(offset => stylesheet.start + offset)
53
- .forEach(start => {
54
- this.failures.push({
55
- filePath: stylesheet.filePath,
56
- position: stylesheet.getCharacterAndLineOfPosition(start),
57
- message: `Replace $action-menu-divider-margin-y(5px) with $dropdown-menu-divider-margin-y(4px)`
58
- });
59
- });
60
- (0, schematics_1.findAllSubstringIndices)(stylesheet.content, '$action-menu-group-name-padding-y')
61
- .map(offset => stylesheet.start + offset)
62
- .forEach(start => {
63
- this.failures.push({
64
- filePath: stylesheet.filePath,
65
- position: stylesheet.getCharacterAndLineOfPosition(start),
66
- message: `Replace $action-menu-group-name-padding-y(5px) with $dropdown-menu-group-name-padding-y(2px)`
67
- });
68
- });
69
- (0, schematics_1.findAllSubstringIndices)(stylesheet.content, '$label-')
70
- .map(offset => stylesheet.start + offset)
71
- .forEach(start => {
72
- this.failures.push({
73
- filePath: stylesheet.filePath,
74
- position: stylesheet.getCharacterAndLineOfPosition(start),
75
- message: `Found deprecated label style variables`
76
- });
77
- });
78
- }
79
- }
80
- exports.ActionMenuRemovalRule = ActionMenuRemovalRule;
@@ -1,9 +0,0 @@
1
- /**
2
- * Use of this source code is governed by an MIT-style license that can be
3
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
4
- */
5
- import { Migration, ResolvedResource, UpgradeData } from '@angular/cdk/schematics';
6
- export declare class LabelRemovalRule extends Migration<UpgradeData> {
7
- enabled: boolean;
8
- visitTemplate(template: ResolvedResource): void;
9
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- /**
3
- * Use of this source code is governed by an MIT-style license that can be
4
- * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LabelRemovalRule = void 0;
8
- const schematics_1 = require("@angular/cdk/schematics");
9
- const html_parsing_1 = require("../../core/html-parsing");
10
- class LabelRemovalRule extends schematics_1.Migration {
11
- constructor() {
12
- super(...arguments);
13
- this.enabled = true;
14
- }
15
- visitTemplate(template) {
16
- // 给 tag 插入 icon 时,需要用户确认下是否已经导入了 icon 模块
17
- (0, schematics_1.findInputsOnElementWithAttr)(template.content, 'thyBeforeIcon', ['thyLabel', '[thyLabel]']).forEach(offset => {
18
- this.failures.push({
19
- filePath: template.filePath,
20
- position: template.getCharacterAndLineOfPosition(offset),
21
- message: `Replace input "thyBeforeIcon" in deprecated thyLabel directive. Confirm whether the "ThyIconModule" is imported, if not, please import.`
22
- });
23
- });
24
- (0, schematics_1.findInputsOnElementWithAttr)(template.content, 'thyAfterIcon', ['thyLabel', '[thyLabel]']).forEach(offset => {
25
- this.failures.push({
26
- filePath: template.filePath,
27
- position: template.getCharacterAndLineOfPosition(offset),
28
- message: `Replace input "thyAfterIcon" in deprecated thyLabel directive. Confirm whether the "ThyIconModule" is imported, if not, please import.`
29
- });
30
- });
31
- // 提示给用户,移除了 thyLabel 的属性,thyTag 没有对应功能
32
- (0, schematics_1.findInputsOnElementWithAttr)(template.content, 'thyIconPrefix', ['thyLabel', '[thyLabel]']).forEach(offset => {
33
- this.failures.push({
34
- filePath: template.filePath,
35
- position: template.getCharacterAndLineOfPosition(offset),
36
- message: `Remove input "thyIconPrefix" in deprecated thyLabel directive. Please manually use "thy-icon" to instead.`
37
- });
38
- });
39
- (0, schematics_1.findInputsOnElementWithAttr)(template.content, 'thyBackgroundOpacity', ['thyLabel', '[thyLabel]']).forEach(offset => {
40
- this.failures.push({
41
- filePath: template.filePath,
42
- position: template.getCharacterAndLineOfPosition(offset),
43
- message: `Remove input "thyBackgroundOpacity" in deprecated thyLabel directive.`
44
- });
45
- });
46
- (0, schematics_1.findInputsOnElementWithAttr)(template.content, 'thyOnRemove', ['thyLabel', '[thyLabel]']).forEach(offset => {
47
- this.failures.push({
48
- filePath: template.filePath,
49
- position: template.getCharacterAndLineOfPosition(offset),
50
- message: `Remove input "thyOnRemove" in deprecated thyLabel directive. If it has a corresponding useless function, please manually delete it.`
51
- });
52
- });
53
- // 提示给用户,thyLabel 变成 thyTag 后大小有变化
54
- (0, html_parsing_1.findWholeInputsNameAndValueOnElementWithAttr)(template.content, 'thySize', 'default', ['thyLabel', '[thyLabel]']).forEach(offset => {
55
- this.failures.push({
56
- filePath: template.filePath,
57
- position: template.getCharacterAndLineOfPosition(offset.start),
58
- message: `Replace input "thySize" in deprecated thyLabel directive. Notice: default22(thyLabel) -> md24(thyTag).`
59
- });
60
- });
61
- (0, html_parsing_1.findWholeInputsNameAndValueOnElementWithAttr)(template.content, 'thySize', '', ['thyLabel', '[thyLabel]']).forEach(offset => {
62
- this.failures.push({
63
- filePath: template.filePath,
64
- position: template.getCharacterAndLineOfPosition(offset.start),
65
- message: `Replace input "thySize" in deprecated thyLabel directive. Notice: default22(thyLabel) -> md24(thyTag)`
66
- });
67
- });
68
- (0, html_parsing_1.findWholeInputsNameAndValueOnElementWithAttr)(template.content, 'thySize', 'xlg', ['thyLabel', '[thyLabel]']).forEach(offset => {
69
- this.failures.push({
70
- filePath: template.filePath,
71
- position: template.getCharacterAndLineOfPosition(offset.start),
72
- message: `Replace input "thySize" in deprecated thyLabel directive. Notice: xlg36(thyLabel) -> lg28(thyTag)`
73
- });
74
- });
75
- }
76
- }
77
- exports.LabelRemovalRule = LabelRemovalRule;
@@ -1,50 +0,0 @@
1
- import { ClassNameUpgradeData, Migration } from '@angular/cdk/schematics';
2
- import * as ts from 'typescript';
3
- import { TethysUpgradeData } from '../core/upgrade-data';
4
- /**
5
- * Migration that walks through every identifier that is part of ngx-tethys
6
- * and replaces the outdated name with the new one if specified in the upgrade data.
7
- *
8
- * 本迁移将遍历作为 ngx-tethys 一部分的每个标识符,并按升级数据的规定,用新的标识符替换过时的名称。
9
- *
10
- */
11
- export declare class ClassNamesMigration extends Migration<TethysUpgradeData> {
12
- /**
13
- * Change data that upgrades to the specified target version.
14
- *
15
- * 要升级到指定目标版本的更改数据。
16
- *
17
- */
18
- data: ClassNameUpgradeData[];
19
- /**
20
- * List of identifier names that have been imported from `ngx-tethys`
21
- * in the current source file and therefore can be considered trusted.
22
- *
23
- * 从 `ngx-tethys` 导入的标识符名称列表,因此可以认为是受信任的。
24
- *
25
- */
26
- trustedIdentifiers: Set<string>;
27
- /**
28
- * List of namespaces that have been imported from `ngx-tethys`.
29
- *
30
- * 从 `ngx-tethys` 导入的命名空间列表。
31
- *
32
- */
33
- trustedNamespaces: Set<string>;
34
- enabled: boolean;
35
- visitNode(node: ts.Node): void;
36
- /**
37
- * Method that is called for every identifier inside of the specified project.
38
- *
39
- * 针对指定项目内的每个标识符调用的方法。
40
- *
41
- */
42
- private _visitIdentifier;
43
- /**
44
- * Creates a failure and replacement for the specified identifier.
45
- *
46
- * 创建一个针对指定的标识符的失败规则和替换规则。
47
- *
48
- */
49
- private _createFailureWithReplacement;
50
- }
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ClassNamesMigration = void 0;
4
- const tslib_1 = require("tslib");
5
- const schematics_1 = require("@angular/cdk/schematics");
6
- const ts = tslib_1.__importStar(require("typescript"));
7
- const module_specifiers_1 = require("../core/module-specifiers");
8
- /**
9
- * Migration that walks through every identifier that is part of ngx-tethys
10
- * and replaces the outdated name with the new one if specified in the upgrade data.
11
- *
12
- * 本迁移将遍历作为 ngx-tethys 一部分的每个标识符,并按升级数据的规定,用新的标识符替换过时的名称。
13
- *
14
- */
15
- class ClassNamesMigration extends schematics_1.Migration {
16
- constructor() {
17
- super(...arguments);
18
- /**
19
- * Change data that upgrades to the specified target version.
20
- *
21
- * 要升级到指定目标版本的更改数据。
22
- *
23
- */
24
- this.data = (0, schematics_1.getVersionUpgradeData)(this, 'classNames');
25
- /**
26
- * List of identifier names that have been imported from `ngx-tethys`
27
- * in the current source file and therefore can be considered trusted.
28
- *
29
- * 从 `ngx-tethys` 导入的标识符名称列表,因此可以认为是受信任的。
30
- *
31
- */
32
- this.trustedIdentifiers = new Set();
33
- /**
34
- * List of namespaces that have been imported from `ngx-tethys`.
35
- *
36
- * 从 `ngx-tethys` 导入的命名空间列表。
37
- *
38
- */
39
- this.trustedNamespaces = new Set();
40
- // Only enable the migration rule if there is upgrade data.
41
- this.enabled = this.data.length !== 0;
42
- }
43
- visitNode(node) {
44
- if (ts.isIdentifier(node)) {
45
- this._visitIdentifier(node);
46
- }
47
- }
48
- /**
49
- * Method that is called for every identifier inside of the specified project.
50
- *
51
- * 针对指定项目内的每个标识符调用的方法。
52
- *
53
- */
54
- _visitIdentifier(identifier) {
55
- // For identifiers that aren't listed in the className data, the whole check can be
56
- // skipped safely.
57
- if (!this.data.some(data => data.replace === identifier.text)) {
58
- return;
59
- }
60
- // For namespace imports that are referring to ngx-tethys, we store the
61
- // namespace name in order to be able to safely find identifiers that don't belong to the
62
- // developer's application.
63
- if ((0, schematics_1.isNamespaceImportNode)(identifier) && (0, module_specifiers_1.isNgxTethysImportDeclaration)(identifier)) {
64
- this.trustedNamespaces.add(identifier.text);
65
- return this._createFailureWithReplacement(identifier);
66
- }
67
- // For export declarations that are referring to ngx-tethys, the identifier
68
- // can be immediately updated to the new name.
69
- if ((0, schematics_1.isExportSpecifierNode)(identifier) && (0, module_specifiers_1.isNgxTethysExportDeclaration)(identifier)) {
70
- return this._createFailureWithReplacement(identifier);
71
- }
72
- // For import declarations that are referring to ngx-tethys, the name of
73
- // the import identifiers. This allows us to identify identifiers that belong to ngx-tethys, and we won't accidentally touch a developer's identifier.
74
- if ((0, schematics_1.isImportSpecifierNode)(identifier) && (0, module_specifiers_1.isNgxTethysImportDeclaration)(identifier)) {
75
- this.trustedIdentifiers.add(identifier.text);
76
- return this._createFailureWithReplacement(identifier);
77
- }
78
- // In case the identifier is part of a property access expression, we need to verify that the
79
- // property access originates from a namespace that has been imported from ngx-tethys.
80
- if (ts.isPropertyAccessExpression(identifier.parent)) {
81
- const expression = identifier.parent.expression;
82
- if (ts.isIdentifier(expression) && this.trustedNamespaces.has(expression.text)) {
83
- return this._createFailureWithReplacement(identifier);
84
- }
85
- }
86
- else if (this.trustedIdentifiers.has(identifier.text)) {
87
- return this._createFailureWithReplacement(identifier);
88
- }
89
- }
90
- /**
91
- * Creates a failure and replacement for the specified identifier.
92
- *
93
- * 创建一个针对指定的标识符的失败规则和替换规则。
94
- *
95
- */
96
- _createFailureWithReplacement(identifier) {
97
- const classData = this.data.find(data => data.replace === identifier.text);
98
- const filePath = this.fileSystem.resolve(identifier.getSourceFile().fileName);
99
- this.fileSystem
100
- .edit(filePath)
101
- .remove(identifier.getStart(), identifier.getWidth())
102
- .insertRight(identifier.getStart(), classData.replaceWith);
103
- }
104
- }
105
- exports.ClassNamesMigration = ClassNamesMigration;
@@ -1,17 +0,0 @@
1
- import { Migration } from '@angular/cdk/schematics';
2
- import * as ts from 'typescript';
3
- import { TethysUpgradeData } from '../core/upgrade-data';
4
- import { EntryPointUpgradeData } from '../data/entry-points';
5
- /**
6
- * Migration that walks through every ts file
7
- * and replaces the outdated entry points with the new one if specified in the upgrade data.
8
- *
9
- * 本迁移将遍历每个 ts 文件,并按升级数据的规定,用新的导入入口替换过时的导入入口。
10
- *
11
- */
12
- export declare class EntryPointsMigration extends Migration<TethysUpgradeData> {
13
- data: EntryPointUpgradeData[];
14
- enabled: boolean;
15
- visitNode(node: ts.Node): void;
16
- private _replace;
17
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntryPointsMigration = void 0;
4
- const tslib_1 = require("tslib");
5
- const schematics_1 = require("@angular/cdk/schematics");
6
- const ts = tslib_1.__importStar(require("typescript"));
7
- const upgrade_data_1 = require("../core/upgrade-data");
8
- /**
9
- * Migration that walks through every ts file
10
- * and replaces the outdated entry points with the new one if specified in the upgrade data.
11
- *
12
- * 本迁移将遍历每个 ts 文件,并按升级数据的规定,用新的导入入口替换过时的导入入口。
13
- *
14
- */
15
- class EntryPointsMigration extends schematics_1.Migration {
16
- constructor() {
17
- super(...arguments);
18
- this.data = (0, upgrade_data_1.getTethysVersionUpgradeData)(this, 'entryPoints');
19
- this.enabled = this.data.length !== 0;
20
- }
21
- visitNode(node) {
22
- if (!ts.isImportDeclaration(node) || !ts.isStringLiteralLike(node.moduleSpecifier)) {
23
- return;
24
- }
25
- const importLocation = node.moduleSpecifier.text;
26
- this.data.forEach(name => {
27
- if (importLocation === name.replace) {
28
- this._replace(node, name.replaceWith);
29
- }
30
- });
31
- }
32
- _replace(node, newValue) {
33
- const filePath = this.fileSystem.resolve(node.getSourceFile().fileName);
34
- const replaceWith = this.fileSystem.read(filePath).indexOf(newValue);
35
- // 当前文件之前有替换后的导入路径,避免重复,要把相同的导入合并
36
- if (replaceWith >= 0) {
37
- const leftBrackets = this.fileSystem.read(filePath).lastIndexOf('{', replaceWith);
38
- const rightBrackets = this.fileSystem.read(filePath).lastIndexOf('}', replaceWith);
39
- const replaceWithImports = this.fileSystem.read(filePath).substring(leftBrackets + 1, rightBrackets);
40
- const replaceWithStart = this.fileSystem.read(filePath).lastIndexOf('import', replaceWith);
41
- const replaceWithEnd = this.fileSystem.read(filePath).indexOf(';', replaceWith);
42
- if (replaceWithImports.indexOf(newValue)) {
43
- // 当前文件之前有替换后的导入内容,使用之前的就可以,不需要再次添加。例:之前有 tag 模块,label 替换完会重复:import { ThyTagModule , ThyTagModule } from 'ngx-tethys/tag';
44
- this.fileSystem
45
- .edit(filePath)
46
- .remove(replaceWithStart, replaceWithEnd - replaceWithStart + 1)
47
- .remove(node.moduleSpecifier.getStart() + 1, node.moduleSpecifier.getWidth() - 2)
48
- .insertRight(node.moduleSpecifier.getStart() + 1, newValue);
49
- }
50
- else {
51
- // 当前文件之前没有替换后的导入内容,追加上替换后的导入内容
52
- this.fileSystem
53
- .edit(filePath)
54
- .remove(replaceWithStart, replaceWithEnd - replaceWithStart + 1)
55
- .insertRight(node.importClause.getStart() + 1, replaceWithImports + ',')
56
- .remove(node.moduleSpecifier.getStart() + 1, node.moduleSpecifier.getWidth() - 2)
57
- .insertRight(node.moduleSpecifier.getStart() + 1, newValue);
58
- }
59
- }
60
- else {
61
- // 当前文件之前没有替换后的导入路径,直接替换
62
- this.fileSystem
63
- .edit(filePath)
64
- .remove(node.moduleSpecifier.getStart() + 1, node.moduleSpecifier.getWidth() - 2)
65
- .insertRight(node.moduleSpecifier.getStart() + 1, newValue);
66
- }
67
- }
68
- }
69
- exports.EntryPointsMigration = EntryPointsMigration;
@@ -1,16 +0,0 @@
1
- import { Migration, ResolvedResource } from '@angular/cdk/schematics';
2
- import { TethysUpgradeData } from '../core/upgrade-data';
3
- import { InputNameRemovalUpgradeData } from '../data';
4
- /**
5
- * Migration that walks through every template or stylesheet and removes deprecated input
6
- * names. Selectors in stylesheets could also target input
7
- * bindings declared as static attribute. See for example:
8
- *
9
- * 迁移将遍历每个模板或样式表,并将废弃的输入名称移除。
10
- */
11
- export declare class InputNamesRemovalMigration extends Migration<TethysUpgradeData> {
12
- data: InputNameRemovalUpgradeData[];
13
- enabled: boolean;
14
- visitTemplate(template: ResolvedResource): void;
15
- private _removeInputName;
16
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InputNamesRemovalMigration = void 0;
4
- const schematics_1 = require("@angular/cdk/schematics");
5
- const html_parsing_1 = require("../core/html-parsing");
6
- const upgrade_data_1 = require("../core/upgrade-data");
7
- /**
8
- * Migration that walks through every template or stylesheet and removes deprecated input
9
- * names. Selectors in stylesheets could also target input
10
- * bindings declared as static attribute. See for example:
11
- *
12
- * 迁移将遍历每个模板或样式表,并将废弃的输入名称移除。
13
- */
14
- class InputNamesRemovalMigration extends schematics_1.Migration {
15
- constructor() {
16
- super(...arguments);
17
- this.data = (0, upgrade_data_1.getTethysVersionUpgradeData)(this, 'inputNamesRemoval');
18
- this.enabled = this.data.length !== 0;
19
- }
20
- visitTemplate(template) {
21
- this.data.forEach(name => {
22
- const limitedTo = name.limitedTo;
23
- const relativeOffsets = [];
24
- if (limitedTo.attributes) {
25
- relativeOffsets.push(...(0, html_parsing_1.findWholeInputsOnElementWithAttr)(template.content, name.remove, limitedTo.attributes));
26
- }
27
- if (limitedTo.elements) {
28
- relativeOffsets.push(...(0, html_parsing_1.findWholeInputsOnElementWithTag)(template.content, name.remove, limitedTo.elements));
29
- }
30
- relativeOffsets
31
- .map(offset => {
32
- return { start: template.start + offset.start, length: offset.end - offset.start };
33
- })
34
- .forEach(value => {
35
- this._removeInputName(template.filePath, value.start, value.length);
36
- });
37
- });
38
- }
39
- _removeInputName(filePath, start, width) {
40
- this.fileSystem.edit(filePath).remove(start, width);
41
- }
42
- }
43
- exports.InputNamesRemovalMigration = InputNamesRemovalMigration;
@@ -1,16 +0,0 @@
1
- import { Migration, ResolvedResource } from '@angular/cdk/schematics';
2
- import { TethysUpgradeData } from '../core/upgrade-data';
3
- import { InputValueUpgradeData } from '../data';
4
- /**
5
- * Migration that walks through every template or stylesheet and replaces deprecated input
6
- * name and value to the new input names and values. Selectors in stylesheets could also target input
7
- * bindings declared as static attribute. See for example:
8
- *
9
- * 迁移将遍历每个模板或样式表,并将废弃的输入名称与值替换为新的输入名称与值。
10
- */
11
- export declare class InputValuesMigration extends Migration<TethysUpgradeData> {
12
- data: InputValueUpgradeData[];
13
- enabled: boolean;
14
- visitTemplate(template: ResolvedResource): void;
15
- private _replaceInput;
16
- }