From 823389fb1acaf6defc3839a2512e2617a97314cf Mon Sep 17 00:00:00 2001 From: codecalm Date: Sun, 22 Mar 2020 16:47:31 +0100 Subject: gulp changelog generate, new icons --- gulpfile.js | 73 ++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 23 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 9afd7e0..3de333d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -217,10 +217,7 @@ gulp.task('icons-sprite', function (cb) { }); gulp.task('icons-preview', function (cb) { - - glob("_site/icons/*.svg", {}, function (er, files) { - console.log('files', files); - + glob("icons/*.svg", {}, function (er, files) { generateIconsPreview(files, '.github/icons.svg', cb); }); }); @@ -311,38 +308,68 @@ gulp.task('changelog-commit', function (cb) { }); }); -gulp.task('changelog-diff', function (cb) { +gulp.task('changelog', function (cb) { const version = argv['latest-tag'] || `v${p.version}`; - - cp.exec(`git diff ${version} HEAD --name-status`, function (err, ret) { - let newIcons = [], modifiedIcons = [], renamedIcons = []; + if(version) { + cp.exec(`git diff ${version} HEAD --name-status`, function (err, ret) { - ret.replace(/A\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { - newIcons.push(fileName); - }); + let newIcons = [], modifiedIcons = [], renamedIcons = []; - ret.replace(/M\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { - modifiedIcons.push(fileName); - }); + ret.replace(/A\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + newIcons.push(fileName); + }); - ret.replace(/R[0-9]+\s+src\/_icons\/([a-z1-9-]+)\.svg\s+src\/_icons\/([a-z1-9-]+).svg/g, function (m, fileNameBefore, fileNameAfter) { - renamedIcons.push([fileNameBefore, fileNameAfter]); - }); + ret.replace(/M\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + modifiedIcons.push(fileName); + }); - modifiedIcons = modifiedIcons.filter(function (el) { - return newIcons.indexOf(el) < 0; + ret.replace(/R[0-9]+\s+src\/_icons\/([a-z1-9-]+)\.svg\s+src\/_icons\/([a-z1-9-]+).svg/g, function (m, fileNameBefore, fileNameAfter) { + renamedIcons.push([fileNameBefore, fileNameAfter]); + }); + + modifiedIcons = modifiedIcons.filter(function (el) { + return newIcons.indexOf(el) < 0; + }); + + printChangelog(newIcons, modifiedIcons, renamedIcons); + + cb(); }); + } +}); - printChangelog(newIcons, modifiedIcons, renamedIcons); +gulp.task('changelog-image', function (cb) { + const version = argv['latest-version'] || `${p.version}`, + newVersion = argv['new-version'] || `${p.version}`; + + if(version) { + cp.exec(`git diff v${version} HEAD --name-status`, function (err, ret) { + + let newIcons = []; + ret.replace(/[AD]\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + newIcons.push(fileName); + }); + + newIcons = newIcons.map(function(icon){ + return `./icons/${icon}.svg`; + }); + + if(newIcons.length > 0) { + generateIconsPreview(newIcons, `packages/tabler-icons-${newVersion}.svg`, cb, 6); + } else { + cb(); + } + }); + } else { cb(); - }); + } }); gulp.task('svg-to-png', gulp.series('build-jekyll', 'clean-png', async (cb) => { - let files = glob.sync("_site/icons/*.svg"); + let files = glob.sync("./icons/*.svg"); await asyncForEach(files, async function (file, i) { let name = path.basename(file, '.svg'); @@ -355,4 +382,4 @@ gulp.task('svg-to-png', gulp.series('build-jekyll', 'clean-png', async (cb) => { cb(); })); -gulp.task('build', gulp.series('optimize', 'build-jekyll', 'build-copy', 'icons-sprite', 'icons-preview', 'svg-to-png', 'build-zip')); +gulp.task('build', gulp.series('optimize', 'build-jekyll', 'build-copy', 'icons-sprite', 'icons-preview', 'svg-to-png', 'changelog-image', 'build-zip')); -- cgit v1.2.1