From c77eb46c33bf1edf622194ec309b703cb6bae5d2 Mon Sep 17 00:00:00 2001 From: codecalm Date: Sat, 21 Mar 2020 14:05:39 +0100 Subject: changelog generator --- gulpfile.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 37f6b22..3ba79bd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -191,7 +191,7 @@ gulp.task('optimize', function (cb) { .replace(/\s?\/>/g, ' />') .replace(/\n\s*<(line|circle|path|polyline)/g, "\n <$1") .replace(/polyline points="([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s([0-9.]+)"/g, 'line x1="$1" y1="$2" x2="$3" y2="$4"') - .replace(/a([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s?([0-1])\s?([0-1])\s?(-?[0-9.]+)\s?(-?[0-9.]+)/g, 'a$1 $2 $3 $4 $5 $6 $7') + .replace(/a\s?([0-9.]+)\s([0-9.]+)\s([0-9.]+)\s?([0-1])\s?([0-1])\s?(-?[0-9.]+)\s?(-?[0-9.]+)/g, 'a$1 $2 $3 $4 $5 $6 $7') .replace(/\n\n+/g, "\n"); fs.writeFileSync(file, svgFileContent); @@ -201,7 +201,61 @@ gulp.task('optimize', function (cb) { }); }); -gulp.task('build-zip', function(cb) { +gulp.task('prepare-changelog', function(cb) { + cp.exec('git status', function(err, ret) { + let newIcons = [], modifiedIcons = [], renamedIcons = []; + + ret.replace(/new file:\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + newIcons.push(fileName); + }); + + ret.replace(/modified:\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + modifiedIcons.push(fileName); + }); + + ret.replace(/renamed:\s+src\/_icons\/([a-z1-9-]+).svg -> 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; + }); + + if(newIcons.length > 0) { + console.log(`**${newIcons.length} new icons:**\n`); + + newIcons.forEach(function(icon){ + console.log(`- \`${icon}\``); + }); + + console.log(''); + } + + if(modifiedIcons.length > 0) { + console.log(`**Fixed icons:**\n`); + + modifiedIcons.forEach(function(icon){ + console.log(`- \`${icon}\``); + }); + + console.log(''); + } + + if(renamedIcons.length > 0) { + console.log(`**Renamed icons:**\n`); + + renamedIcons.forEach(function(icon){ + console.log(`- \`${icon[0]}\` renamed to \`${icon[1]}\``); + }) + } + + cb(); + }); + + +}); + +gulp.task('build-zip', function() { const version = p.version; return gulp.src('{icons/**/*,icons-png/**/*,tabler-sprite.svg}') -- cgit v1.2.1 From 0908f417fe8cf18f6f88463eced6926c0e9d99de Mon Sep 17 00:00:00 2001 From: codecalm Date: Sat, 21 Mar 2020 20:02:57 +0100 Subject: 16 new icons: `alarm`, `arrow-back`, `arrow-forward`, `artboard`, `award`, `bug`, `calendar-event`, `globe`, `help`, `mug`, `palette`, `pencil`, `record-mail`, `ruler`, `scissors`, `stack` Fixed icons: `directions`, `disabled`, `disc`, `edit`, `switch-vertical` --- gulpfile.js | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 3ba79bd..5210a8d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -222,31 +222,48 @@ gulp.task('prepare-changelog', function(cb) { }); if(newIcons.length > 0) { - console.log(`**${newIcons.length} new icons:**\n`); + let str = ''; + str += `${newIcons.length} new icons: `; - newIcons.forEach(function(icon){ - console.log(`- \`${icon}\``); + newIcons.forEach(function(icon, i){ + str += `\`${icon}\``; + + if((i + 1) <= newIcons.length - 1) { + str += ', ' + } }); - console.log(''); + console.log(str); } if(modifiedIcons.length > 0) { - console.log(`**Fixed icons:**\n`); + let str = ''; + str += `Fixed icons: `; + + modifiedIcons.forEach(function(icon, i){ + str += `\`${icon}\``; - modifiedIcons.forEach(function(icon){ - console.log(`- \`${icon}\``); + if((i + 1) <= modifiedIcons.length - 1) { + str += ', ' + } }); - console.log(''); + console.log(str); } if(renamedIcons.length > 0) { - console.log(`**Renamed icons:**\n`); + let str = ''; + str += `**Renamed icons: `; + + renamedIcons.forEach(function(icon, i){ + str += `\`${icon[0]}\` renamed to \`${icon[1]}\``; + + if((i + 1) <= renamedIcons.length - 1) { + str += ', ' + } + }); - renamedIcons.forEach(function(icon){ - console.log(`- \`${icon[0]}\` renamed to \`${icon[1]}\``); - }) + console.log(str); } cb(); -- cgit v1.2.1 From 92e5bd3b957b3accfe4d3656f6fed1e65412192b Mon Sep 17 00:00:00 2001 From: codecalm Date: Sat, 21 Mar 2020 22:14:34 +0100 Subject: diff changelog --- gulpfile.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 7 deletions(-) (limited to 'gulpfile.js') diff --git a/gulpfile.js b/gulpfile.js index 5210a8d..4e01a03 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -201,7 +201,7 @@ gulp.task('optimize', function (cb) { }); }); -gulp.task('prepare-changelog', function(cb) { +gulp.task('changelog-commit', function(cb) { cp.exec('git status', function(err, ret) { let newIcons = [], modifiedIcons = [], renamedIcons = []; @@ -234,6 +234,7 @@ gulp.task('prepare-changelog', function(cb) { }); console.log(str); + console.log(''); } if(modifiedIcons.length > 0) { @@ -249,27 +250,85 @@ gulp.task('prepare-changelog', function(cb) { }); console.log(str); + console.log(''); } if(renamedIcons.length > 0) { - let str = ''; - str += `**Renamed icons: `; + console.log(`**Renamed icons: `); renamedIcons.forEach(function(icon, i){ - str += `\`${icon[0]}\` renamed to \`${icon[1]}\``; + console.log(`- \`${icon[0]}\` renamed to \`${icon[1]}\``); + }); + } + + cb(); + }); +}); + +gulp.task('changelog-diff', function(cb) { + const version = p.version; + cp.exec(`git diff v${version} HEAD --name-status`, function(err, ret) { + + let newIcons = [], modifiedIcons = [], renamedIcons = []; + + ret.replace(/A\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + newIcons.push(fileName); + }); + + ret.replace(/M\s+src\/_icons\/([a-z1-9-]+)\.svg/g, function (m, fileName) { + modifiedIcons.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]); + }); + + modifiedIcons = modifiedIcons.filter( function( el ) { + return newIcons.indexOf( el ) < 0; + }); + + if(newIcons.length > 0) { + let str = ''; + str += `${newIcons.length} new icons: `; - if((i + 1) <= renamedIcons.length - 1) { + newIcons.forEach(function(icon, i){ + str += `\`${icon}\``; + + if((i + 1) <= newIcons.length - 1) { str += ', ' } }); console.log(str); + console.log(''); } - cb(); - }); + if(modifiedIcons.length > 0) { + let str = ''; + str += `Fixed icons: `; + modifiedIcons.forEach(function(icon, i){ + str += `\`${icon}\``; + if((i + 1) <= modifiedIcons.length - 1) { + str += ', ' + } + }); + + console.log(str); + console.log(''); + } + + if(renamedIcons.length > 0) { + console.log(`**Renamed icons: `); + + renamedIcons.forEach(function(icon, i){ + console.log(`- \`${icon[0]}\` renamed to \`${icon[1]}\``); + }); + } + + cb(); + }); }); gulp.task('build-zip', function() { -- cgit v1.2.1