Skip to content

Commit

Permalink
chore: check proprietary using two packages (#8685)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirpotekhin authored Aug 26, 2024
1 parent 6529962 commit f28acd1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
5 changes: 4 additions & 1 deletion projects/cdk/schematics/ng-update/v4/migrate-icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ export function migrateIcons(options: TuiSchema): Rule {
}

function hasProprietaryIcons(tree: Tree): boolean {
return !!getPackageJsonDependency(tree, '@taiga-ui/proprietary-icons');
return (
!!getPackageJsonDependency(tree, '@taiga-ui/proprietary-icons') ||
!!getPackageJsonDependency(tree, '@taiga-ui/proprietary')
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ export function renameProprietaryIcons(

const regex = /['"`]tuiIcon(?!Button\b)[A-Z][a-zA-Z0-9]*\b/g;

const invalidIcons = new Set();

text = text.replaceAll(regex, (icon) => {
if (icon.match(/['"`]tuiIcon(?!Tds)\w*/)) {
logger.warn(
`[WARNING] in ${file.getSourceFile().getFilePath()}: Invalid icon name ${icon}. Please select an icon from the proprietary pack.`,
);
invalidIcons.add(icon.slice(1));

return icon;
}

return convertString(icon);
});

const invalidIcons = [...new Set(text.match(/\b(tuiIcon(?!Tds|Button)\w*)\b/g))];

if (invalidIcons.length) {
const message = `TODO (Taiga UI migration): invalid icons ${invalidIcons.join(', ')}. Please select an icon from the proprietary pack`;
if (invalidIcons.size > 0) {
const message = `TODO (Taiga UI migration): invalid icons ${Array.from(invalidIcons).join(', ')}. Please select an icon from the proprietary pack`;
const todo = file.getFilePath().endsWith('html')
? `<!-- ${message} -->`
: `// ${message}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ export function migrateProprietary(
options: TuiSchema,
): void {
try {
const hasProprietary = !!getPackageJsonDependency(
fileSystem.tree,
'@taiga-ui/proprietary-core',
)?.version;
const hasProprietary =
!!getPackageJsonDependency(fileSystem.tree, '@taiga-ui/proprietary-core') ||
!!getPackageJsonDependency(fileSystem.tree, '@taiga-ui/proprietary');

if (!hasProprietary) {
return;
Expand Down
7 changes: 3 additions & 4 deletions projects/cdk/schematics/ng-update/v4/steps/migrate-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ function addProviders(callExpression: Node, fileSystem: DevkitFileSystem): void
);

getActiveProject();
const proprietary = getPackageJsonDependency(
fileSystem.tree,
'@taiga-ui/proprietary-core',
);
const proprietary =
getPackageJsonDependency(fileSystem.tree, '@taiga-ui/proprietary-core') ||
getPackageJsonDependency(fileSystem.tree, '@taiga-ui/proprietary');

if (proprietary) {
array.addElement('TBANK_PROVIDERS');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Test {
icon = iconsName.tuiIconStart;
}`;

const PROPR_COMPONENT_AFTER = `// TODO (Taiga UI migration): invalid icons tuiIconStar, tuiIconArrowDown, tuiIconStart. Please select an icon from the proprietary pack
const PROPR_COMPONENT_AFTER = `// TODO (Taiga UI migration): invalid icons tuiIconStar, tuiIconArrowDown. Please select an icon from the proprietary pack
import { Component } from "@angular/core";
const iconsMap = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Test {
@Input() illustration: string | null = null;
readonly operationIcon: TuiFeedItemIcon = {
icon: '@tui.tds-transport-auto-ruble-medium',
icon: '@tui.fancy.medium.transport-auto-ruble',
color: '#428BF9',
background: '#428bf91f',
};
Expand Down

0 comments on commit f28acd1

Please sign in to comment.