-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore:
schematics
add badge migration, refactor (#5809)
- Loading branch information
1 parent
0467739
commit 9ca6e20
Showing
33 changed files
with
462 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export * from './asset'; | ||
export * from './migration-warning'; | ||
export * from './removable-input'; | ||
export * from './removed-module'; | ||
export * from './replacement-attribute'; | ||
export * from './replacement-attribute-value'; | ||
export * from './replacement-enum'; | ||
export * from './replacement-identifier'; | ||
export * from './replacement-service'; | ||
export * from './replacement-tag'; | ||
export * from './replacement-type'; | ||
export * from './template-resource'; |
2 changes: 1 addition & 1 deletion
2
...interfaces/replaceable-attribute-value.ts → ...interfaces/replacement-attribute-value.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...pdate/interfaces/replaceable-attribute.ts → ...pdate/interfaces/replacement-attribute.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ng-update/interfaces/replacement-const.ts → ...date/interfaces/replacement-identifier.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
projects/cdk/schematics/ng-update/interfaces/replacement-service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/ng-update/interfaces/replaceable-tag.ts → ...s/ng-update/interfaces/replacement-tag.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...cs/ng-update/interfaces/type-to-rename.ts → .../ng-update/interfaces/replacement-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
projects/cdk/schematics/ng-update/utils/templates/replace-attrs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {UpdateRecorder} from '@angular-devkit/schematics'; | ||
import {DevkitFileSystem} from 'ng-morph'; | ||
|
||
import { | ||
findAttributeOnElementWithAttrs, | ||
findAttributeOnElementWithTag, | ||
} from '../../../utils/templates/elements'; | ||
import { | ||
getTemplateFromTemplateResource, | ||
getTemplateOffset, | ||
} from '../../../utils/templates/template-resource'; | ||
import {ReplacementAttribute} from '../../interfaces/replacement-attribute'; | ||
import {TemplateResource} from '../../interfaces/template-resource'; | ||
|
||
export function replaceAttrs({ | ||
resource, | ||
recorder, | ||
fileSystem, | ||
data, | ||
}: { | ||
fileSystem: DevkitFileSystem; | ||
recorder: UpdateRecorder; | ||
resource: TemplateResource; | ||
data: readonly ReplacementAttribute[]; | ||
}): void { | ||
const template = getTemplateFromTemplateResource(resource, fileSystem); | ||
const templateOffset = getTemplateOffset(resource); | ||
|
||
data.forEach(({from, to}) => { | ||
const offsets = [ | ||
...findAttributeOnElementWithTag( | ||
template, | ||
from.attrName, | ||
from.withTagNames || [], | ||
from.filterFn, | ||
), | ||
...findAttributeOnElementWithAttrs( | ||
template, | ||
from.attrName, | ||
from.withAttrsNames || [], | ||
from.filterFn, | ||
), | ||
]; | ||
|
||
offsets.forEach(offset => { | ||
recorder.remove(offset + templateOffset, from.attrName.length); | ||
recorder.insertRight(offset + templateOffset, to.attrName); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
projects/cdk/schematics/ng-update/v3-30/constants/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {ReplacementConst} from '../../interfaces/replacement-const'; | ||
import {ReplacementIdentifier} from '../../interfaces/replacement-identifier'; | ||
import {ICONS} from './icons'; | ||
|
||
export const ICONS_TS: ReplacementConst[] = ICONS.map(({from, to}) => ({ | ||
export const ICONS_TS: ReplacementIdentifier[] = ICONS.map(({from, to}) => ({ | ||
from: {name: from, moduleSpecifier: `@taiga-ui/proprietary-icons`}, | ||
to: {name: to, moduleSpecifier: `@taiga-ui/proprietary-tds-icons`}, | ||
})); |
4 changes: 2 additions & 2 deletions
4
projects/cdk/schematics/ng-update/v3-35/constants/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {ReplacementConst} from '../../interfaces/replacement-const'; | ||
import {ReplacementIdentifier} from '../../interfaces/replacement-identifier'; | ||
import {ICONS} from './icons'; | ||
|
||
export const ICONS_TS: ReplacementConst[] = ICONS.map(({from, to}) => ({ | ||
export const ICONS_TS: ReplacementIdentifier[] = ICONS.map(({from, to}) => ({ | ||
from: {name: from, moduleSpecifier: `@taiga-ui/proprietary-icons`}, | ||
to: {name: to, moduleSpecifier: `@taiga-ui/proprietary-tds-icons`}, | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
projects/cdk/schematics/ng-update/v3/constants/deprecated-functions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.