diff --git a/.changeset/tidy-yaks-turn.md b/.changeset/tidy-yaks-turn.md new file mode 100644 index 00000000..9f808502 --- /dev/null +++ b/.changeset/tidy-yaks-turn.md @@ -0,0 +1,5 @@ +--- +"@phase21/logos": minor +--- + +Light version support improved diff --git a/.gitignore b/.gitignore index faf4c630..cc124816 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ optimized/ package-lock.json logos.tgz yarn.lock -.env \ No newline at end of file +.env + +changeset-details.md \ No newline at end of file diff --git a/helpers/utils.js b/helpers/utils.js index 68c7dd30..eb989e92 100644 --- a/helpers/utils.js +++ b/helpers/utils.js @@ -72,7 +72,7 @@ function generateFunction(batchName, switchCase, mode) { return ${getPlaceholderImage(mode)} } - switch (sanitizeName(\`\${id}\${light ? "l" : ""}\`).toLowerCase()) { + switch (sanitizeName(\`\${id}\${light ? "light" : ""}\`).toLowerCase()) { ${switchCase} default: return light ? ${batchName}(id) : ${getPlaceholderImage(mode)} diff --git a/package.json b/package.json index 8e90c082..dccfeac0 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dropbox": "^10.34.0", "node-fetch": "^2.7.0", "dotenv": "^16.4.1", - "prettier": "^3.2.4", + "prettier": "^3.2.5", "rimraf": "^5.0.5", "svgo": "^3.2.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d332d02f..75839ce8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,8 +40,8 @@ importers: specifier: ^2.7.0 version: 2.7.0 prettier: - specifier: ^3.2.4 - version: 3.2.4 + specifier: ^3.2.5 + version: 3.2.5 rimraf: specifier: ^5.0.5 version: 5.0.5 @@ -73,8 +73,8 @@ importers: specifier: workspace:* version: link:.. '@testing-library/jest-dom': - specifier: ^6.4.1 - version: 6.4.1(jest@27.5.1) + specifier: ^6.4.2 + version: 6.4.2(jest@27.5.1) '@testing-library/react': specifier: ^14.2.1 version: 14.2.1(react-dom@18.2.0)(react@18.2.0) @@ -5605,8 +5605,8 @@ packages: pretty-format: 27.5.1 dev: true - /@testing-library/jest-dom@6.4.1(jest@27.5.1): - resolution: {integrity: sha512-Z7qMM3J2Zw5H/nC2/5CYx5YcuaD56JmDFKNIozZ89VIo6o6Y9FMhssics4e2madEKYDNEpZz3+glPGz0yWMOag==} + /@testing-library/jest-dom@6.4.2(jest@27.5.1): + resolution: {integrity: sha512-CzqH0AFymEMG48CpzXFriYYkOjk6ZGPCLMhW9e9jg3KMCn5OfJecF8GtGW7yGfR/IgCe3SX8BSwjdzI6BBbZLw==} engines: {node: '>=14', npm: '>=6', yarn: '>=1'} peerDependencies: '@jest/globals': '>= 28' @@ -13743,8 +13743,8 @@ packages: hasBin: true dev: true - /prettier@3.2.4: - resolution: {integrity: sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==} + /prettier@3.2.5: + resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==} engines: {node: '>=14'} hasBin: true dev: true diff --git a/raw/chains/Chain11155420.svg b/raw/chains/Chain11155420.svg index 098392b7..a165bc09 100644 --- a/raw/chains/Chain11155420.svg +++ b/raw/chains/Chain11155420.svg @@ -1,21 +1,3 @@ - - - - - - - + + diff --git a/raw/chains/Chain25.svg b/raw/chains/Chain25.svg deleted file mode 100644 index ef24586b..00000000 --- a/raw/chains/Chain25.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/raw/chains/Chain280L.svg b/raw/chains/Chain280-light.svg similarity index 100% rename from raw/chains/Chain280L.svg rename to raw/chains/Chain280-light.svg diff --git a/raw/chains/Chain324L.svg b/raw/chains/Chain324-light.svg similarity index 100% rename from raw/chains/Chain324L.svg rename to raw/chains/Chain324-light.svg diff --git a/raw/chains/Chain43288.svg b/raw/chains/Chain43288.svg deleted file mode 100644 index cb504527..00000000 --- a/raw/chains/Chain43288.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/raw/chains/Chain5000L.svg b/raw/chains/Chain5000-light.svg similarity index 100% rename from raw/chains/Chain5000L.svg rename to raw/chains/Chain5000-light.svg diff --git a/raw/chains/Chain5001L.svg b/raw/chains/Chain5001-light.svg similarity index 100% rename from raw/chains/Chain5001L.svg rename to raw/chains/Chain5001-light.svg diff --git a/raw/chains/Chain534352.svg b/raw/chains/Chain534352.svg deleted file mode 100644 index b5cb2df4..00000000 --- a/raw/chains/Chain534352.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/raw/chains/Chain59140L.svg b/raw/chains/Chain59140-light.svg similarity index 100% rename from raw/chains/Chain59140L.svg rename to raw/chains/Chain59140-light.svg diff --git a/raw/chains/Chain59144L.svg b/raw/chains/Chain59144-light.svg similarity index 100% rename from raw/chains/Chain59144L.svg rename to raw/chains/Chain59144-light.svg diff --git a/raw/chains/Chain599.svg b/raw/chains/Chain599.svg index cf4a63a1..f91b74a5 100644 --- a/raw/chains/Chain599.svg +++ b/raw/chains/Chain599.svg @@ -1,7 +1,7 @@ diff --git a/raw/symbols/et-hx-light.svg b/raw/symbols/et-hx-light.svg new file mode 100644 index 00000000..e20c59e1 --- /dev/null +++ b/raw/symbols/et-hx-light.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/raw/symbols/mati-cx-dark.svg b/raw/symbols/mati-cx-light.svg similarity index 100% rename from raw/symbols/mati-cx-dark.svg rename to raw/symbols/mati-cx-light.svg diff --git a/scripts/build-svg.js b/scripts/build-svg.js index 908dcb48..c6eccb03 100644 --- a/scripts/build-svg.js +++ b/scripts/build-svg.js @@ -10,14 +10,18 @@ const outputPath = './dist'; const categories = ['chain', 'symbol', 'api-provider']; +let chainLightLogos = []; +let apiProviderLightLogos = []; +let symbolLightLogos = []; + function getManualLogos(mode) { switch (mode) { case 'chain': - return ['5001L', '5000L', '280L', '324L', '59140L', '59144L']; + return [...chainLightLogos]; case 'symbol': - return []; + return [...symbolLightLogos]; case 'api-provider': - return []; + return [...apiProviderLightLogos]; default: break; } @@ -133,10 +137,27 @@ async function renameFiles() { }); } +async function findLightLogos() { + const [chainFiles, apiProviderFiles, symbolFiles] = await Promise.all([ + fs.readdir('./optimized/chain', 'utf-8'), + fs.readdir('./optimized/api-provider', 'utf-8'), + fs.readdir('./optimized/symbol', 'utf-8') + ]); + + chainLightLogos = chainFiles + .filter((file) => file.includes('light')) + .map((file) => file.replace('Chain', '')) + + apiProviderLightLogos = apiProviderFiles.filter((file) => file.includes('light')); + + symbolLightLogos = symbolFiles.filter((file) => file.includes('light')); +} + async function main() { console.log('🏗 Building logo package...'); rimraf(`${outputPath}/`) - .then(() => Promise.all([renameFiles()])) + .then(findLightLogos) + .then(renameFiles) .then(() => Promise.all([generateLogos('cjs'), generateLogos('esm')])) .then(() => console.log('✅ Finished building package.')); } diff --git a/scripts/fetch-missing.js b/scripts/fetch-missing.js index c9164fd1..a626aef5 100644 --- a/scripts/fetch-missing.js +++ b/scripts/fetch-missing.js @@ -1,6 +1,7 @@ require('dotenv').config(); const chains = require('@phase21/chains'); const fs = require('fs/promises'); +const { existsSync } = require('node:fs'); const utils = require('../helpers/utils'); const { apisData, getApiProviderAliases } = require('@phase21/api-integrations'); const dropbox = require('dropbox'); @@ -68,6 +69,26 @@ function getLogoList(mode) { } } +async function checkAlternateLogos(foundLogos) { + categories.forEach(async (category) => { + const alternateLogos = getLogoList(category).reduce((acc, chain) => { + const foundLogo = foundLogos.find((foundLogo) => foundLogo.name.toLowerCase().includes(chain.toLowerCase() + '-light')); + if (foundLogo) { + acc.push(foundLogo); + } + return acc; + }, []); + alternateLogos.map((foundLogo) => { + const prefix = category === 'chain' ? 'Chain' : ''; + if (existsSync(`./raw/${category}s/${prefix}${foundLogo.name}`)) { + return; + } + console.log('Found alternate logo:', foundLogo.name); + downloadLogos(category, foundLogo); + }); + }); +} + async function searchLogos() { console.log('🏗 Fetching logo files...'); const foundLogos = await fetchLogos(); @@ -75,20 +96,22 @@ async function searchLogos() { missingLogos.map((missingLogoCategory) => { missingLogoCategory.logos.map((missingLogo) => { foundLogos.map((foundLogo) => { - if (foundLogo.name.toLowerCase() === `${missingLogo.toLowerCase()}.svg`) { - downloadLogos(missingLogoCategory.category, foundLogo.name); + if (utils.sanitizeName(foundLogo.name).toLowerCase() === `${utils.sanitizeName(missingLogo).toLowerCase()}`) { + downloadLogos(missingLogoCategory.category, foundLogo); } }); }); }); + console.log('🏗 Checking for alternate logos...'); + await checkAlternateLogos(foundLogos) // Check for alternate logos console.log('✅ Finished fetching logo files.'); } async function fetchLogos() { const dbx = await getDropbox(); try { - const response = await dbx.filesListFolder({ path: '' }); + const response = await dbx.filesListFolder({ path: '', recursive: true }); return response.result.entries; } catch (error) { console.error(error); @@ -96,8 +119,7 @@ async function fetchLogos() { } } -async function saveToDisk(file, category, blob) { - const prefix = category === 'chain' ? 'Chain' : ''; +async function saveToDisk(prefix, file, category, blob) { fs.writeFile(`./raw/${category}s/${prefix}${file}`, blob, function (err) { if (err) { console.error(err); @@ -106,12 +128,20 @@ async function saveToDisk(file, category, blob) { } async function downloadLogos(category, file) { + const prefix = category === 'chain' ? 'Chain' : ''; + if (existsSync(`./raw/${category}s/${prefix}${file.name}`)) { + console.log(`File ${file.name} already exists`); + return; + } + const dbx = await getDropbox(); try { - const response = await dbx.filesDownload({ path: `/${file}` }); + const response = await dbx.filesDownload({ path: file.path_lower }); var blob = response.result.fileBinary; - await saveToDisk(file, category, blob); - console.log(`Downloaded ${file}`); + await saveToDisk(prefix, file.name, category, blob); + const path = `../raw/${category}s/${prefix}${file.name}`; + await fs.appendFile('./.changeset/changeset-details.md', `||${file.name.replace('.svg', '')}|${category}|\n`, 'utf-8'); + console.log(`Downloaded ${file.name}`); } catch (error) { console.error(error); } diff --git a/scripts/release.js b/scripts/release.js index 293b1751..cc5171fc 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -4,15 +4,28 @@ async function getChangeset() { return await fs.readdir('./.changeset'); } +async function getDetails() { + try { + const details = await fs.readFile('./.changeset/changeset-details.md', 'utf-8'); + return details; + } catch (error) { + return ''; + } +} + async function createChangeset() { + const details = await getDetails(); + const changeset = `--- "@phase21/logos": patch --- -# What's Changed -Release created by the release script. -Logos updated. -`; +Some changes have been made to the \`logos\`. + +|Logo|Name|Category| +|---|---|---| +` + details; + await fs.writeFile('./.changeset/changeset.md', changeset); console.log('✨ Created changeset file.'); } @@ -20,7 +33,7 @@ Logos updated. async function checkChangeset() { const changeset = await getChangeset(); - if (changeset.some(file => file.endsWith('.md'))) { + if (changeset.some(file => file.match(/changeset.md$/))) { console.log('There is already a .md file in the .changeset directory.'); } else { await createChangeset(); diff --git a/viewer/package.json b/viewer/package.json index 8c703e02..e61fe02e 100644 --- a/viewer/package.json +++ b/viewer/package.json @@ -9,7 +9,7 @@ "@chakra-ui/react": "^2.8.2", "@emotion/react": "^11.11.3", "@emotion/styled": "^11.11.0", - "@testing-library/jest-dom": "^6.4.1", + "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", "@testing-library/user-event": "^14.5.2", "@phase21/logos": "workspace:*",