1
0
mirror of https://github.com/tabler/tabler-icons.git synced 2025-08-16 19:14:01 +02:00

new releases flow

This commit is contained in:
codecalm
2020-03-22 13:01:56 +01:00
parent 4b8d213a1f
commit 5fb2a9255c
2 changed files with 88 additions and 69 deletions

View File

@@ -5,7 +5,8 @@ const gulp = require('gulp'),
path = require('path'), path = require('path'),
p = require('./package.json'), p = require('./package.json'),
zip = require('gulp-zip'), zip = require('gulp-zip'),
puppeteer = require('puppeteer'); puppeteer = require('puppeteer'),
argv = require('minimist')(process.argv.slice(2));
async function asyncForEach(array, callback) { async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) { for (let index = 0; index < array.length; index++) {
@@ -112,7 +113,54 @@ const printChangelog = function(newIcons, modifiedIcons, renamedIcons) {
} }
}; };
const generateIconsPreview = function(files, destFile, cb, columnsCount = 17) {
const padding = 29,
paddingOuter = 5,
iconSize = 24;
const iconsCount = files.length,
rowsCount = Math.ceil(iconsCount / columnsCount),
width = columnsCount * (iconSize + padding) + 2 * paddingOuter - padding,
height = rowsCount * (iconSize + padding) + 2 * paddingOuter - padding;
let svgContentSymbols = '',
svgContentIcons = '',
x = paddingOuter,
y = paddingOuter;
files.forEach(function (file, i) {
let name = path.basename(file, '.svg');
let svgFile = fs.readFileSync(file),
svgFileContent = svgFile.toString();
svgFileContent = svgFileContent
.replace('<svg xmlns="http://www.w3.org/2000/svg"', `<symbol id="${name}"`)
.replace(' width="24" height="24"', '')
.replace('</svg>', '</symbol>')
.replace(/\n\s+/g, '');
svgContentSymbols += `\t${svgFileContent}\n`;
svgContentIcons += `\t<use xlink:href="#${name}" x="${x}" y="${y}" width="${iconSize}" height="${iconSize}" />\n`;
x += padding + iconSize;
if (i % columnsCount === columnsCount - 1) {
x = paddingOuter;
y += padding + iconSize;
}
});
const svgContent = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" style="color: #354052"><rect x="0" y="0" width="${width}" height="${height}" fill="#fff"></rect>\n${svgContentSymbols}\n${svgContentIcons}\n</svg>`;
fs.writeFileSync(destFile, svgContent);
createScreenshot(destFile);
cb();
};
//*********************************************************************************************
gulp.task('build-zip', function () { gulp.task('build-zip', function () {
const version = p.version; const version = p.version;
@@ -169,49 +217,11 @@ gulp.task('icons-sprite', function (cb) {
}); });
gulp.task('icons-preview', function (cb) { gulp.task('icons-preview', function (cb) {
const columnsCount = 17,
padding = 29,
paddingOuter = 5,
iconSize = 24;
glob("_site/icons/*.svg", {}, function (er, files) { glob("_site/icons/*.svg", {}, function (er, files) {
const iconsCount = files.length, console.log('files', files);
rowsCount = Math.ceil(iconsCount / columnsCount),
width = columnsCount * (iconSize + padding) + 2 * paddingOuter - padding,
height = rowsCount * (iconSize + padding) + 2 * paddingOuter - padding;
let svgContentSymbols = '', generateIconsPreview(files, '.github/icons.svg', cb);
svgContentIcons = '',
x = paddingOuter,
y = paddingOuter;
files.forEach(function (file, i) {
let name = path.basename(file, '.svg');
let svgFile = fs.readFileSync(file),
svgFileContent = svgFile.toString();
svgFileContent = svgFileContent
.replace('<svg xmlns="http://www.w3.org/2000/svg"', `<symbol id="${name}"`)
.replace(' width="24" height="24"', '')
.replace('</svg>', '</symbol>')
.replace(/\n\s+/g, '');
svgContentSymbols += `\t${svgFileContent}\n`;
svgContentIcons += `\t<use xlink:href="#${name}" x="${x}" y="${y}" width="${iconSize}" height="${iconSize}" />\n`;
x += padding + iconSize;
if (i % columnsCount === columnsCount - 1) {
x = paddingOuter;
y += padding + iconSize;
}
});
const svgContent = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 ${width} ${height}" width="${width}" height="${height}" style="color: #354052"><rect x="0" y="0" width="${width}" height="${height}" fill="#fff"></rect>\n${svgContentSymbols}\n${svgContentIcons}\n</svg>`;
fs.writeFileSync('.github/icons.svg', svgContent);
createScreenshot('.github/icons.svg');
cb();
}); });
}); });
@@ -302,8 +312,9 @@ gulp.task('changelog-commit', function(cb) {
}); });
gulp.task('changelog-diff', function (cb) { gulp.task('changelog-diff', function (cb) {
const version = p.version; const version = argv['latest-tag'] || `v${p.version}`;
cp.exec(`git diff v${version} HEAD --name-status`, function(err, ret) {
cp.exec(`git diff ${version} HEAD --name-status`, function (err, ret) {
let newIcons = [], modifiedIcons = [], renamedIcons = []; let newIcons = [], modifiedIcons = [], renamedIcons = [];

View File

@@ -35,12 +35,20 @@
"glob": "7.1.6", "glob": "7.1.6",
"gulp": "4.0.2", "gulp": "4.0.2",
"gulp-zip": "5.0.1", "gulp-zip": "5.0.1",
"minimist": "1.2.5",
"puppeteer": "2.1.1", "puppeteer": "2.1.1",
"release-it": "13.1.2" "release-it": "13.1.2"
}, },
"release-it": { "release-it": {
"hooks": {
"after:bump": "npm run build && npm run png",
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
},
"git": { "git": {
"tagName": "v${version}" "changelog": "gulp changelog-diff --silent --latest-tag ${latestTag}",
"tagName": "v${version}",
"requireBranch": "master",
"requireCommits": true
}, },
"github": { "github": {
"release": true "release": true