mirror of
https://github.com/simple-icons/simple-icons.git
synced 2025-01-25 01:32:58 +02:00
Automatically update milestone (SVG count) in README (#6951)
* Automatically update milestone (SVG count) in README * Use updateRange variale * Rewrite 2 lines * Simplify code * Format new file * Fix error in script * Apply suggested changes
This commit is contained in:
parent
2670ac084c
commit
ed4c29f7b6
2
.github/workflows/create-release.yml
vendored
2
.github/workflows/create-release.yml
vendored
@ -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
|
||||
|
@ -4,7 +4,7 @@
|
||||
</a>
|
||||
<h3 align="center">Simple Icons</h3>
|
||||
<p align="center">
|
||||
Over 2000 Free SVG icons for popular brands. See them all on one page at <a href="https://simpleicons.org">SimpleIcons.org</a>. Contributions, corrections & requests can be made on GitHub.</p>
|
||||
Over 2100 Free SVG icons for popular brands. See them all on one page at <a href="https://simpleicons.org">SimpleIcons.org</a>. Contributions, corrections & requests can be made on GitHub.</p>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
38
scripts/release/update-svgs-count.js
Normal file
38
scripts/release/update-svgs-count.js
Normal file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* @fileoverview
|
||||
* Replaces the SVG count milestone "Over <NUMBER> 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);
|
Loading…
x
Reference in New Issue
Block a user