From e307642f9b09722b211ae27b0c83722c2a27bcca Mon Sep 17 00:00:00 2001 From: Matthew Kalinin Date: Mon, 1 Apr 2024 15:54:28 +0300 Subject: [PATCH] generate icons list in md file --- docs/icons.md | 126 ++++++++++++++ src/icons/types/{rubrics.ts => icons.ts} | 208 +++++++++++------------ tools/icons/generate-docs.ts | 35 ++++ tools/icons/generate-types.ts | 12 +- tools/icons/get-uniq-names.ts | 6 + tools/icons/local.ts | 2 +- tools/scripts/sync-icons.ts | 8 +- tools/utils/prettier-format.ts | 6 + 8 files changed, 287 insertions(+), 116 deletions(-) create mode 100644 docs/icons.md rename src/icons/types/{rubrics.ts => icons.ts} (98%) create mode 100644 tools/icons/generate-docs.ts create mode 100644 tools/icons/get-uniq-names.ts create mode 100644 tools/utils/prettier-format.ts diff --git a/docs/icons.md b/docs/icons.md new file mode 100644 index 0000000..ae909c0 --- /dev/null +++ b/docs/icons.md @@ -0,0 +1,126 @@ +# List of supported icons + +| Name | Normal Size | Small Size | +| --------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| airport | ![airport](../../static/icons/airport_24.svg) | ![airport](../../static/icons/airport_14.svg) | +| attraction | ![attraction](../../static/icons/attraction_24.svg) | ![attraction](../../static/icons/attraction_14.svg) | +| auto | ![auto](../../static/icons/auto_24.svg) | ![auto](../../static/icons/auto_14.svg) | +| aviary | ![aviary](../../static/icons/aviary_24.svg) | none | +| baby_shop | ![baby_shop](../../static/icons/baby_shop_24.svg) | ![baby_shop](../../static/icons/baby_shop_14.svg) | +| banks | ![banks](../../static/icons/banks_24.svg) | ![banks](../../static/icons/banks_14.svg) | +| barbeque | ![barbeque](../../static/icons/barbeque_24.svg) | none | +| bars | ![bars](../../static/icons/bars_24.svg) | ![bars](../../static/icons/bars_14.svg) | +| beach | ![beach](../../static/icons/beach_24.svg) | ![beach](../../static/icons/beach_14.svg) | +| bench | ![bench](../../static/icons/bench_24.svg) | none | +| bike | ![bike](../../static/icons/bike_24.svg) | none | +| bike_rent | ![bike_rent](../../static/icons/bike_rent_24.svg) | ![bike_rent](../../static/icons/bike_rent_14.svg) | +| boat_station | ![boat_station](../../static/icons/boat_station_24.svg) | ![boat_station](../../static/icons/boat_station_14.svg) | +| bookstore | ![bookstore](../../static/icons/bookstore_24.svg) | ![bookstore](../../static/icons/bookstore_14.svg) | +| buddhism | ![buddhism](../../static/icons/buddhism_24.svg) | ![buddhism](../../static/icons/buddhism_14.svg) | +| building | ![building](../../static/icons/building_24.svg) | none | +| bus | ![bus](../../static/icons/bus_24.svg) | none | +| cafe | ![cafe](../../static/icons/cafe_24.svg) | ![cafe](../../static/icons/cafe_14.svg) | +| car_park | ![car_park](../../static/icons/car_park_24.svg) | none | +| catholic_church | ![catholic_church](../../static/icons/catholic_church_24.svg) | ![catholic_church](../../static/icons/catholic_church_14.svg) | +| cemetery | ![cemetery](../../static/icons/cemetery_24.svg) | ![cemetery](../../static/icons/cemetery_14.svg) | +| childrens_playground | ![childrens_playground](../../static/icons/childrens_playground_24.svg) | none | +| cinemas | ![cinemas](../../static/icons/cinemas_24.svg) | ![cinemas](../../static/icons/cinemas_14.svg) | +| clothes_shop | ![clothes_shop](../../static/icons/clothes_shop_24.svg) | ![clothes_shop](../../static/icons/clothes_shop_14.svg) | +| college | ![college](../../static/icons/college_24.svg) | ![college](../../static/icons/college_14.svg) | +| concert_hall | ![concert_hall](../../static/icons/concert_hall_24.svg) | ![concert_hall](../../static/icons/concert_hall_14.svg) | +| confectionary | ![confectionary](../../static/icons/confectionary_24.svg) | ![confectionary](../../static/icons/confectionary_14.svg) | +| currency_exchange | ![currency_exchange](../../static/icons/currency_exchange_24.svg) | ![currency_exchange](../../static/icons/currency_exchange_14.svg) | +| dental | ![dental](../../static/icons/dental_24.svg) | ![dental](../../static/icons/dental_14.svg) | +| driving_school | ![driving_school](../../static/icons/driving_school_24.svg) | ![driving_school](../../static/icons/driving_school_14.svg) | +| drugstores | ![drugstores](../../static/icons/drugstores_24.svg) | ![drugstores](../../static/icons/drugstores_14.svg) | +| dry_cleaning | ![dry_cleaning](../../static/icons/dry_cleaning_24.svg) | ![dry_cleaning](../../static/icons/dry_cleaning_14.svg) | +| equestrian | ![equestrian](../../static/icons/equestrian_24.svg) | ![equestrian](../../static/icons/equestrian_14.svg) | +| fast_food | ![fast_food](../../static/icons/fast_food_24.svg) | ![fast_food](../../static/icons/fast_food_14.svg) | +| film_studio | ![film_studio](../../static/icons/film_studio_24.svg) | ![film_studio](../../static/icons/film_studio_14.svg) | +| fire_station | ![fire_station](../../static/icons/fire_station_24.svg) | ![fire_station](../../static/icons/fire_station_14.svg) | +| fitness | ![fitness](../../static/icons/fitness_24.svg) | ![fitness](../../static/icons/fitness_14.svg) | +| flower_shop | ![flower_shop](../../static/icons/flower_shop_24.svg) | ![flower_shop](../../static/icons/flower_shop_14.svg) | +| forest | ![forest](../../static/icons/forest_24.svg) | ![forest](../../static/icons/forest_14.svg) | +| fountain | ![fountain](../../static/icons/fountain_24.svg) | none | +| furniture_store | ![furniture_store](../../static/icons/furniture_store_24.svg) | ![furniture_store](../../static/icons/furniture_store_14.svg) | +| garden | ![garden](../../static/icons/garden_24.svg) | ![garden](../../static/icons/garden_14.svg) | +| gasstation | ![gasstation](../../static/icons/gasstation_24.svg) | ![gasstation](../../static/icons/gasstation_14.svg) | +| government | ![government](../../static/icons/government_24.svg) | ![government](../../static/icons/government_14.svg) | +| hairdressers | ![hairdressers](../../static/icons/hairdressers_24.svg) | ![hairdressers](../../static/icons/hairdressers_14.svg) | +| haulier | ![haulier](../../static/icons/haulier_24.svg) | ![haulier](../../static/icons/haulier_14.svg) | +| helicopter | ![helicopter](../../static/icons/helicopter_24.svg) | none | +| hospital | ![hospital](../../static/icons/hospital_24.svg) | ![hospital](../../static/icons/hospital_14.svg) | +| hotels | ![hotels](../../static/icons/hotels_24.svg) | ![hotels](../../static/icons/hotels_14.svg) | +| hypermarket | ![hypermarket](../../static/icons/hypermarket_24.svg) | ![hypermarket](../../static/icons/hypermarket_14.svg) | +| industrial_enterprise | ![industrial_enterprise](../../static/icons/industrial_enterprise_24.svg) | ![industrial_enterprise](../../static/icons/industrial_enterprise_14.svg) | +| information | ![information](../../static/icons/information_24.svg) | ![information](../../static/icons/information_14.svg) | +| kindergarten | ![kindergarten](../../static/icons/kindergarten_24.svg) | ![kindergarten](../../static/icons/kindergarten_14.svg) | +| landmark | ![landmark](../../static/icons/landmark_24.svg) | ![landmark](../../static/icons/landmark_14.svg) | +| laundry | ![laundry](../../static/icons/laundry_24.svg) | ![laundry](../../static/icons/laundry_14.svg) | +| library | ![library](../../static/icons/library_24.svg) | ![library](../../static/icons/library_14.svg) | +| malls | ![malls](../../static/icons/malls_24.svg) | ![malls](../../static/icons/malls_14.svg) | +| medicine | ![medicine](../../static/icons/medicine_24.svg) | ![medicine](../../static/icons/medicine_14.svg) | +| memorable_event | ![memorable_event](../../static/icons/memorable_event_24.svg) | ![memorable_event](../../static/icons/memorable_event_14.svg) | +| metro | ![metro](../../static/icons/metro_24.svg) | ![metro](../../static/icons/metro_14.svg) | +| metro_bus | ![metro_bus](../../static/icons/metro_bus_24.svg) | ![metro_bus](../../static/icons/metro_bus_14.svg) | +| metro_cable | ![metro_cable](../../static/icons/metro_cable_24.svg) | ![metro_cable](../../static/icons/metro_cable_14.svg) | +| metro_entrance | ![metro_entrance](../../static/icons/metro_entrance_24.svg) | none | +| metro_funicular | ![metro_funicular](../../static/icons/metro_funicular_24.svg) | ![metro_funicular](../../static/icons/metro_funicular_14.svg) | +| metro_light | ![metro_light](../../static/icons/metro_light_24.svg) | ![metro_light](../../static/icons/metro_light_14.svg) | +| metro_monorail | ![metro_monorail](../../static/icons/metro_monorail_24.svg) | ![metro_monorail](../../static/icons/metro_monorail_14.svg) | +| metro_tram | ![metro_tram](../../static/icons/metro_tram_24.svg) | ![metro_tram](../../static/icons/metro_tram_14.svg) | +| mobile_phones | ![mobile_phones](../../static/icons/mobile_phones_24.svg) | ![mobile_phones](../../static/icons/mobile_phones_14.svg) | +| money_coin | ![money_coin](../../static/icons/money_coin_24.svg) | none | +| monument | ![monument](../../static/icons/monument_24.svg) | none | +| mosque | ![mosque](../../static/icons/mosque_24.svg) | ![mosque](../../static/icons/mosque_14.svg) | +| mountain | ![mountain](../../static/icons/mountain_24.svg) | none | +| museum | ![museum](../../static/icons/museum_24.svg) | ![museum](../../static/icons/museum_14.svg) | +| office | ![office](../../static/icons/office_24.svg) | ![office](../../static/icons/office_14.svg) | +| office_service | ![office_service](../../static/icons/office_service_24.svg) | ![office_service](../../static/icons/office_service_14.svg) | +| orthodox_church | ![orthodox_church](../../static/icons/orthodox_church_24.svg) | ![orthodox_church](../../static/icons/orthodox_church_14.svg) | +| park | ![park](../../static/icons/park_24.svg) | ![park](../../static/icons/park_14.svg) | +| pavilion | ![pavilion](../../static/icons/pavilion_24.svg) | none | +| pet_playground | ![pet_playground](../../static/icons/pet_playground_24.svg) | none | +| petshop | ![petshop](../../static/icons/petshop_24.svg) | ![petshop](../../static/icons/petshop_14.svg) | +| photo | ![photo](../../static/icons/photo_24.svg) | ![photo](../../static/icons/photo_14.svg) | +| picnic | ![picnic](../../static/icons/picnic_24.svg) | none | +| pier | ![pier](../../static/icons/pier_24.svg) | none | +| playground | ![playground](../../static/icons/playground_24.svg) | none | +| police | ![police](../../static/icons/police_24.svg) | ![police](../../static/icons/police_14.svg) | +| police_post | ![police_post](../../static/icons/police_post_24.svg) | ![police_post](../../static/icons/police_post_14.svg) | +| port | ![port](../../static/icons/port_24.svg) | ![port](../../static/icons/port_14.svg) | +| post_office | ![post_office](../../static/icons/post_office_24.svg) | ![post_office](../../static/icons/post_office_14.svg) | +| printing_services | ![printing_services](../../static/icons/printing_services_24.svg) | ![printing_services](../../static/icons/printing_services_14.svg) | +| protestant_church | ![protestant_church](../../static/icons/protestant_church_24.svg) | ![protestant_church](../../static/icons/protestant_church_14.svg) | +| racing | ![racing](../../static/icons/racing_24.svg) | ![racing](../../static/icons/racing_14.svg) | +| railway | ![railway](../../static/icons/railway_24.svg) | ![railway](../../static/icons/railway_14.svg) | +| railway_station | ![railway_station](../../static/icons/railway_station_24.svg) | ![railway_station](../../static/icons/railway_station_14.svg) | +| recycling | ![recycling](../../static/icons/recycling_24.svg) | none | +| restaurants | ![restaurants](../../static/icons/restaurants_24.svg) | ![restaurants](../../static/icons/restaurants_14.svg) | +| rezervation | ![rezervation](../../static/icons/rezervation_24.svg) | ![rezervation](../../static/icons/rezervation_14.svg) | +| sanatorium | ![sanatorium](../../static/icons/sanatorium_24.svg) | ![sanatorium](../../static/icons/sanatorium_14.svg) | +| science | ![science](../../static/icons/science_24.svg) | ![science](../../static/icons/science_14.svg) | +| skating_rink | ![skating_rink](../../static/icons/skating_rink_24.svg) | ![skating_rink](../../static/icons/skating_rink_14.svg) | +| software | ![software](../../static/icons/software_24.svg) | ![software](../../static/icons/software_14.svg) | +| spa | ![spa](../../static/icons/spa_24.svg) | ![spa](../../static/icons/spa_14.svg) | +| sport | ![sport](../../static/icons/sport_24.svg) | none | +| sport_school | ![sport_school](../../static/icons/sport_school_24.svg) | none | +| sportcenter | ![sportcenter](../../static/icons/sportcenter_24.svg) | ![sportcenter](../../static/icons/sportcenter_14.svg) | +| spring | ![spring](../../static/icons/spring_24.svg) | none | +| stadium | ![stadium](../../static/icons/stadium_24.svg) | ![stadium](../../static/icons/stadium_14.svg) | +| supermarket | ![supermarket](../../static/icons/supermarket_24.svg) | ![supermarket](../../static/icons/supermarket_14.svg) | +| sushi | ![sushi](../../static/icons/sushi_24.svg) | ![sushi](../../static/icons/sushi_14.svg) | +| swimming_pool | ![swimming_pool](../../static/icons/swimming_pool_24.svg) | ![swimming_pool](../../static/icons/swimming_pool_14.svg) | +| synagogue | ![synagogue](../../static/icons/synagogue_24.svg) | ![synagogue](../../static/icons/synagogue_14.svg) | +| tailor | ![tailor](../../static/icons/tailor_24.svg) | ![tailor](../../static/icons/tailor_14.svg) | +| taxi | ![taxi](../../static/icons/taxi_24.svg) | ![taxi](../../static/icons/taxi_14.svg) | +| theatre | ![theatre](../../static/icons/theatre_24.svg) | ![theatre](../../static/icons/theatre_14.svg) | +| ticket_office | ![ticket_office](../../static/icons/ticket_office_24.svg) | ![ticket_office](../../static/icons/ticket_office_14.svg) | +| tire_fitting | ![tire_fitting](../../static/icons/tire_fitting_24.svg) | ![tire_fitting](../../static/icons/tire_fitting_14.svg) | +| tram | ![tram](../../static/icons/tram_24.svg) | none | +| trash | ![trash](../../static/icons/trash_24.svg) | none | +| travel_agency | ![travel_agency](../../static/icons/travel_agency_24.svg) | ![travel_agency](../../static/icons/travel_agency_14.svg) | +| viewpoint | ![viewpoint](../../static/icons/viewpoint_24.svg) | none | +| waterfall | ![waterfall](../../static/icons/waterfall_24.svg) | none | +| wc | ![wc](../../static/icons/wc_24.svg) | none | +| zoo | ![zoo](../../static/icons/zoo_24.svg) | ![zoo](../../static/icons/zoo_14.svg) | diff --git a/src/icons/types/rubrics.ts b/src/icons/types/icons.ts similarity index 98% rename from src/icons/types/rubrics.ts rename to src/icons/types/icons.ts index 6cf060e..bb83046 100644 --- a/src/icons/types/rubrics.ts +++ b/src/icons/types/icons.ts @@ -1,126 +1,126 @@ /** Don't edit manually. Generated by script: ./tools/icons/generate-types.ts */ type IconName = - | 'post_office' - | 'information' - | 'industrial_enterprise' - | 'science' - | 'police' - | 'police_post' - | 'college' - | 'library' - | 'fire_station' - | 'government' - | 'protestant_church' - | 'orthodox_church' - | 'mosque' - | 'synagogue' + | 'airport' + | 'attraction' + | 'auto' + | 'aviary' + | 'baby_shop' + | 'banks' + | 'barbeque' + | 'bars' + | 'beach' + | 'bench' + | 'bike' + | 'bike_rent' + | 'boat_station' + | 'bookstore' | 'buddhism' - | 'cemetery' - | 'kindergarten' - | 'office' + | 'building' + | 'bus' + | 'cafe' + | 'car_park' | 'catholic_church' - | 'drugstores' - | 'hospital' - | 'medicine' - | 'dental' + | 'cemetery' + | 'childrens_playground' | 'cinemas' - | 'film_studio' + | 'clothes_shop' + | 'college' | 'concert_hall' - | 'attraction' - | 'ticket_office' - | 'driving_school' - | 'racing' - | 'banks' + | 'confectionary' | 'currency_exchange' - | 'software' - | 'travel_agency' - | 'haulier' - | 'tailor' - | 'hairdressers' + | 'dental' + | 'driving_school' + | 'drugstores' | 'dry_cleaning' - | 'laundry' - | 'printing_services' - | 'bike_rent' - | 'mobile_phones' - | 'photo' - | 'hotels' - | 'gasstation' - | 'tire_fitting' + | 'equestrian' + | 'fast_food' + | 'film_studio' + | 'fire_station' | 'fitness' - | 'sportcenter' - | 'sport_school' - | 'boat_station' - | 'office_service' - | 'spa' - | 'metro_bus' - | 'metro_light' - | 'railway' - | 'railway_station' - | 'port' - | 'airport' - | 'metro_cable' - | 'metro_funicular' - | 'metro_tram' - | 'metro' - | 'pier' - | 'bus' - | 'tram' - | 'metro_entrance' - | 'metro_monorail' - | 'taxi' - | 'hypermarket' - | 'petshop' - | 'bookstore' - | 'clothes_shop' - | 'furniture_store' | 'flower_shop' - | 'baby_shop' - | 'auto' - | 'malls' - | 'sport' - | 'supermarket' - | 'skating_rink' - | 'swimming_pool' - | 'waterfall' - | 'spring' + | 'forest' | 'fountain' - | 'theatre' + | 'furniture_store' + | 'garden' + | 'gasstation' + | 'government' + | 'hairdressers' + | 'haulier' + | 'helicopter' + | 'hospital' + | 'hotels' + | 'hypermarket' + | 'industrial_enterprise' + | 'information' + | 'kindergarten' | 'landmark' + | 'laundry' + | 'library' + | 'malls' + | 'medicine' | 'memorable_event' + | 'metro' + | 'metro_bus' + | 'metro_cable' + | 'metro_entrance' + | 'metro_funicular' + | 'metro_light' + | 'metro_monorail' + | 'metro_tram' + | 'mobile_phones' + | 'money_coin' + | 'monument' + | 'mosque' + | 'mountain' | 'museum' - | 'beach' - | 'zoo' - | 'garden' + | 'office' + | 'office_service' + | 'orthodox_church' | 'park' - | 'forest' + | 'pavilion' + | 'pet_playground' + | 'petshop' + | 'photo' + | 'picnic' + | 'pier' + | 'playground' + | 'police' + | 'police_post' + | 'port' + | 'post_office' + | 'printing_services' + | 'protestant_church' + | 'racing' + | 'railway' + | 'railway_station' + | 'recycling' + | 'restaurants' | 'rezervation' - | 'equestrian' - | 'stadium' | 'sanatorium' - | 'mountain' - | 'restaurants' - | 'cafe' - | 'fast_food' + | 'science' + | 'skating_rink' + | 'software' + | 'spa' + | 'sport' + | 'sport_school' + | 'sportcenter' + | 'spring' + | 'stadium' + | 'supermarket' | 'sushi' - | 'bars' - | 'confectionary' - | 'wc' + | 'swimming_pool' + | 'synagogue' + | 'tailor' + | 'taxi' + | 'theatre' + | 'ticket_office' + | 'tire_fitting' + | 'tram' | 'trash' - | 'helicopter' - | 'building' - | 'bench' - | 'aviary' - | 'money_coin' - | 'recycling' - | 'barbeque' - | 'pavilion' - | 'picnic' - | 'monument' - | 'childrens_playground' - | 'pet_playground' - | 'playground' + | 'travel_agency' | 'viewpoint' - | 'bike' - | 'car_park'; + | 'waterfall' + | 'wc' + | 'zoo'; export {IconName}; diff --git a/tools/icons/generate-docs.ts b/tools/icons/generate-docs.ts new file mode 100644 index 0000000..4fc7299 --- /dev/null +++ b/tools/icons/generate-docs.ts @@ -0,0 +1,35 @@ +import {existsSync} from 'fs'; +import fs from 'fs/promises'; +import path from 'path'; +import {prettierFormat} from '../utils/prettier-format'; +import {BASE_DIR, ICONS_PATH} from './local'; + +const DOCS_FILE_PATH = path.join(BASE_DIR, 'docs/icons.md'); +const TITLE = '# List of supported icons'; +const TABLE_HEADER = ` +| Name | Normal Size | Small Size | +| --- | --- | --- | +`; + +export const generateIconsDocsList = async (iconNames: string[]) => { + let content = `${TITLE}\n\n${TABLE_HEADER}`; + content += iconNames + .map((name) => { + const normalFileName = `${name}_24.svg`; + const smallFileName = `${name}_14.svg`; + + const normalAbsolutePath = path.join(ICONS_PATH, normalFileName); + const smallAbsolutePath = path.join(ICONS_PATH, smallFileName); + + const normalRelativePath = `../../static/icons/${normalFileName}`; + const smallRelativePath = `../../static/icons/${smallFileName}`; + + const normalIcon = existsSync(normalAbsolutePath) ? `![${name}](${normalRelativePath})` : `none`; + const smallIcon = existsSync(smallAbsolutePath) ? `![${name}](${smallRelativePath})` : `none`; + + return `| ${name} | ${normalIcon} | ${smallIcon} |`; + }) + .join('\n'); + const formattedContent = await prettierFormat(content, 'markdown'); + await fs.writeFile(DOCS_FILE_PATH, formattedContent); +}; diff --git a/tools/icons/generate-types.ts b/tools/icons/generate-types.ts index e1d36d0..0250d68 100644 --- a/tools/icons/generate-types.ts +++ b/tools/icons/generate-types.ts @@ -1,24 +1,18 @@ import fs from 'fs/promises'; -import {uniq} from 'lodash'; import path from 'path'; -import prettier from 'prettier'; -import {IconDescription, SIZE_REGEXP} from './fetch-icons'; +import {prettierFormat} from '../utils/prettier-format'; import {BASE_DIR} from './local'; const TYPES_PATH = path.join(BASE_DIR, 'src/icons/types'); -export const generateIconsTypes = async (icons: IconDescription[]) => { +export const generateIconsTypes = async (iconNames: string[]) => { const type = 'IconName'; - const iconNames = uniq(icons.map(({name}) => name.replace(SIZE_REGEXP, ''))); const content = ` /** Don't edit manually. Generated by script: ./tools/icons/generate-types.ts */ type ${type} =${iconNames.map((name) => `| '${name}'`).join('\n')}; export {${type}}; `; - - const prettierConfig = await prettier.resolveConfig(process.cwd()); - const formattedContent = await prettier.format(content, {...prettierConfig, parser: 'typescript'}); - + const formattedContent = await prettierFormat(content, 'typescript'); await fs.writeFile(path.join(TYPES_PATH, 'rubrics.ts'), formattedContent); }; diff --git a/tools/icons/get-uniq-names.ts b/tools/icons/get-uniq-names.ts new file mode 100644 index 0000000..6f0adf4 --- /dev/null +++ b/tools/icons/get-uniq-names.ts @@ -0,0 +1,6 @@ +import {uniq} from 'lodash'; +import {IconDescription, SIZE_REGEXP} from './fetch-icons'; + +export const getUniqNames = (icons: IconDescription[]) => { + return uniq(icons.map(({name}) => name.replace(SIZE_REGEXP, ''))).sort(); +}; diff --git a/tools/icons/local.ts b/tools/icons/local.ts index 446cb0b..caa71fb 100644 --- a/tools/icons/local.ts +++ b/tools/icons/local.ts @@ -3,7 +3,7 @@ import path from 'path'; import {IconDescriptionWithData} from './get-image-files'; export const BASE_DIR = path.join(__dirname, '../../'); -const ICONS_PATH = path.join(BASE_DIR, 'static/icons'); +export const ICONS_PATH = path.join(BASE_DIR, 'static/icons'); export type LocalIconDescription = { name: string; diff --git a/tools/scripts/sync-icons.ts b/tools/scripts/sync-icons.ts index 5f3e51c..4368b7a 100644 --- a/tools/scripts/sync-icons.ts +++ b/tools/scripts/sync-icons.ts @@ -1,10 +1,14 @@ +import {generateIconsDocsList} from '../icons/generate-docs'; import {generateIconsTypes} from '../icons/generate-types'; +import {getUniqNames} from '../icons/get-uniq-names'; import {updateIcons} from '../icons/update-icons'; async function main() { try { - const icons = await updateIcons(); - await generateIconsTypes(icons); + const iconsDescription = await updateIcons(); + const iconNames = getUniqNames(iconsDescription); + await generateIconsTypes(iconNames); + await generateIconsDocsList(iconNames); } catch (error) { console.error(error.message || error.toString()); } diff --git a/tools/utils/prettier-format.ts b/tools/utils/prettier-format.ts new file mode 100644 index 0000000..8afc85a --- /dev/null +++ b/tools/utils/prettier-format.ts @@ -0,0 +1,6 @@ +import prettier from 'prettier'; + +export const prettierFormat = async (rawContent: string, parser: prettier.Options['parser']): Promise => { + const prettierConfig = await prettier.resolveConfig(process.cwd()); + return prettier.format(rawContent, {...prettierConfig, parser}); +};