-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cdk): add array of icons, used in taiga components (#5005)
- Loading branch information
1 parent
42b5676
commit c989f60
Showing
4 changed files
with
124 additions
and
2 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @description: | ||
* AUTOGENERATED | ||
* | ||
* Array of icons used in taiga-ui components | ||
*/ | ||
export const TUI_USED_ICONS = [ | ||
`tuiIconMirMono`, | ||
`tuiIconVisaMono`, | ||
`tuiIconElectronMono`, | ||
`tuiIconCloseLarge`, | ||
`tuiIconChevronDownLarge`, | ||
`tuiIconButton`, | ||
`tuiIconLink`, | ||
`tuiIconMenuLarge`, | ||
`tuiIconCode`, | ||
`tuiIconSun`, | ||
`tuiIconMoon`, | ||
`tuiIconSearch`, | ||
`tuiIconChevronRight`, | ||
`tuiIconChevronLeftLarge`, | ||
`tuiIconXLarge`, | ||
`tuiIconClose`, | ||
`tuiIconArrowLeft`, | ||
`tuiIconArrowRight`, | ||
`tuiIconRotate`, | ||
`tuiIconMinus`, | ||
`tuiIconPlus`, | ||
`tuiIconMinimize`, | ||
`tuiIconEye`, | ||
`tuiIconEyeOff`, | ||
`tuiIconDrag`, | ||
`tuiIconSortDescending`, | ||
`tuiIconSortAscending`, | ||
`tuiIconSortOff`, | ||
`tuiIconCheckLarge`, | ||
`tuiIconChevronLeft`, | ||
`tuiIconX`, | ||
`tuiIconChevronRightLarge`, | ||
`tuiIconHelpCircle`, | ||
`tuiIconCheck`, | ||
`tuiIconFileLarge`, | ||
`tuiIconTrashLarge`, | ||
`tuiIconAlertCircleLarge`, | ||
`tuiIconCheckCircleLarge`, | ||
`tuiIconAlertCircle`, | ||
`tuiIconWarningLarge`, | ||
`tuiIconChevronDown`, | ||
]; |
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,68 @@ | ||
import {readdirSync, readFileSync, statSync, writeFileSync} from 'fs'; | ||
import {basename, join} from 'path'; | ||
|
||
(function main(): void { | ||
const rootDirectory = process.env.ROOT_FOLDER || `./projects`; | ||
const excludedFolders = [ | ||
`demo`, | ||
`demo-integrations`, | ||
`eslint-plugin`, | ||
`taiga-schematics`, | ||
`testing`, | ||
`test`, | ||
`i18n`, | ||
`icons`, | ||
`schematics`, | ||
]; | ||
|
||
generateUsedIcons(rootDirectory, excludedFolders); | ||
})(); | ||
|
||
function generateUsedIcons(rootDirectory: string, excludedFolders: string[]): void { | ||
const tuiIconNames = findTuiIconNames(rootDirectory, excludedFolders); | ||
|
||
writeFileSync( | ||
`./projects/cdk/constants/used-icons.ts`, | ||
`/** | ||
* @description: | ||
* AUTOGENERATED | ||
* | ||
* Array of icons used in taiga-ui components | ||
*/ | ||
export const TUI_USED_ICONS = ${JSON.stringify(tuiIconNames)}`, | ||
); | ||
} | ||
|
||
function findTuiIconNames(rootDir: string, excludedFolders: string[]): string[] { | ||
const tuiIconNames = new Set<string>(); | ||
|
||
function traverseDirectory(directory: string): void { | ||
const files = readdirSync(directory); | ||
|
||
for (const file of files) { | ||
const filePath = join(directory, file); | ||
const stat = statSync(filePath); | ||
|
||
if (stat.isDirectory()) { | ||
const folderName = basename(filePath); | ||
|
||
if (!excludedFolders.includes(folderName)) { | ||
traverseDirectory(filePath); | ||
} | ||
} else if (stat.isFile()) { | ||
const fileContents = readFileSync(filePath, `utf-8`); | ||
const tuiIconMatches = fileContents.match(/\btuiIcon\w+(?=\s|'|")/g); | ||
|
||
if (tuiIconMatches) { | ||
tuiIconMatches.forEach(match => { | ||
tuiIconNames.add(match); | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
traverseDirectory(rootDir); | ||
|
||
return Array.from(tuiIconNames); | ||
} |