diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 9bf4be3af..9788ccb7f 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -45,6 +45,8 @@ jobs: run: node ./scripts/release/bump-version.js "${{ needs.release-pr.outputs.new-version }}" - name: Update major version in CDN URLs run: node ./scripts/release/update-cdn-urls.js + - name: Update SVGs count milestone + run: node ./scripts/release/update-svgs-count.js - name: Update slugs table run: node ./scripts/release/update-slugs-table.js - name: Commit version bump diff --git a/README.md b/README.md index 48c0a9345..77a939740 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

Simple Icons

-Over 2000 Free SVG icons for popular brands. See them all on one page at SimpleIcons.org. Contributions, corrections & requests can be made on GitHub.

+Over 2100 Free SVG icons for popular brands. See them all on one page at SimpleIcons.org. Contributions, corrections & requests can be made on GitHub.

diff --git a/scripts/release/bump-version.js b/scripts/release/bump-version.js index 7755b75d8..4072f31dd 100644 --- a/scripts/release/bump-version.js +++ b/scripts/release/bump-version.js @@ -11,7 +11,7 @@ const rootDir = path.resolve(__dirname, '..', '..'); const packageJsonFile = path.resolve(rootDir, 'package.json'); const readManifest = (file) => { - const manifestRaw = fs.readFileSync(file).toString(); + const manifestRaw = fs.readFileSync(file, 'utf-8'); const manifestJson = JSON.parse(manifestRaw); return manifestJson; }; diff --git a/scripts/release/update-cdn-urls.js b/scripts/release/update-cdn-urls.js index a37c00872..be06aa7e7 100644 --- a/scripts/release/update-cdn-urls.js +++ b/scripts/release/update-cdn-urls.js @@ -18,7 +18,7 @@ const getMajorVersion = (semVerVersion) => { }; const getManifest = () => { - const manifestRaw = fs.readFileSync(packageJsonFile).toString(); + const manifestRaw = fs.readFileSync(packageJsonFile, 'utf-8'); return JSON.parse(manifestRaw); }; diff --git a/scripts/release/update-svgs-count.js b/scripts/release/update-svgs-count.js new file mode 100644 index 000000000..a8c48d829 --- /dev/null +++ b/scripts/release/update-svgs-count.js @@ -0,0 +1,38 @@ +#!/usr/bin/env node +/** + * @fileoverview + * Replaces the SVG count milestone "Over Free SVG icons..." located + * at README every time the number of current icons is more than `updateRange` + * more than the previous milestone. + */ + +const fs = require('fs'); +const path = require('path'); + +const regexMatcher = /Over\s(\d+)\s/; +const updateRange = 100; + +const rootDir = path.resolve(__dirname, '..', '..'); +const dataFile = path.resolve(rootDir, '_data', 'simple-icons.json'); +const readmeFile = path.resolve(rootDir, 'README.md'); +const readmeContent = fs.readFileSync(readmeFile, 'utf-8'); + +let overNIconsInReadme; +try { + overNIconsInReadme = parseInt(regexMatcher.exec(readmeContent)[1]); +} catch (err) { + console.error( + 'Failed to obtain number of SVG icons of current milestone in README:', + err, + ); + process.exit(1); +} + +const nIcons = require(dataFile).icons.length, + newNIcons = overNIconsInReadme + updateRange; +if (nIcons <= newNIcons) { + process.exit(0); +} + +const newContent = readmeContent.replace(regexMatcher, `Over ${newNIcons} `); +fs.writeFileSync(readmeFile, newContent);