Add command to generate CHANGELOG This forms the basis of the CHANGELOG, but the commits need to be formatted with the linkify command and sorted into the various sections.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
diff --git a/gulpfile.js b/gulpfile.js
index 7f39ee9..0b5752e 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -8,6 +8,7 @@ const replace = require('gulp-replace');
const pump = require('pump');
const fs = require('fs');
const simpleGit = require('simple-git');
+const shelljs = require('shelljs');
const paths = {
componentsFile: 'components.json',
@@ -185,13 +186,13 @@ function languagePlugins(cb) {
});
}
-function changelog(cb) {
+const ISSUE_RE = /#(\d+)(?![\d\]])/g;
+const ISSUE_SUB = '[#$1](https://github.com/PrismJS/prism/issues/$1)';
+
+function linkify(cb) {
return pump([
src(paths.changelog),
- replace(
- /#(\d+)(?![\d\]])/g,
- '[#$1](https://github.com/PrismJS/prism/issues/$1)'
- ),
+ replace(ISSUE_RE, ISSUE_SUB),
replace(
/\[[\da-f]+(?:, *[\da-f]+)*\]/g,
m => m.replace(/([\da-f]{7})[\da-f]*/g, '[`$1`](https://github.com/PrismJS/prism/commit/$1)')
@@ -200,6 +201,44 @@ function changelog(cb) {
], cb);
}
+const COMMIT_RE = /^([\da-z]{8})\s(.*)/;
+
+function changes(cb) {
+ const tag = shelljs.exec('git describe --abbrev=0 --tags', { silent: true }).stdout;
+ const commits = shelljs
+ .exec(
+ `git log ${tag.trim()}..HEAD --oneline`,
+ { silent: true }
+ )
+ .stdout.split('\n')
+ .map(line => line.trim())
+ .filter(line => line !== '')
+ .map(line => {
+ const [,hash, msg] = COMMIT_RE.exec(line);
+ return `* ${msg.replace(ISSUE_RE, ISSUE_SUB)} [\`${hash}\`](https://github.com/PrismJS/prism/commit/${hash})`
+ })
+ .join('\n');
+
+ const changes = `## Unreleased
+
+${commits}
+
+### New components
+
+### Updated components
+
+### Updated plugins
+
+### Updated themes
+
+### Other changes
+
+* __Website__`;
+
+ console.log(changes);
+ cb();
+}
+
const components = minifyComponents;
const plugins = series(languagePlugins, minifyPlugins);
@@ -221,6 +260,6 @@ function gitChanges(cb) {
exports.watch = watchComponentsAndPlugins;
exports.default = parallel(components, plugins, componentsJsonToJs, build);
-exports.changelog = changelog;
-
exports.premerge = gitChanges;
+exports.linkify = linkify;
+exports.changes = changes;
diff --git a/package-lock.json b/package-lock.json
index b82f822..e682769 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4233,6 +4233,17 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
+ "shelljs": {
+ "version": "0.8.3",
+ "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz",
+ "integrity": "sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A==",
+ "dev": true,
+ "requires": {
+ "glob": "^7.0.0",
+ "interpret": "^1.0.0",
+ "rechoir": "^0.6.2"
+ }
+ },
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
diff --git a/package.json b/package.json
index aee18db..b2c17e5 100755
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
"jsdom": "^13.0.0",
"mocha": "^6.0.0",
"pump": "^3.0.0",
+ "shelljs": "^0.8.3",
"simple-git": "^1.107.0",
"yargs": "^13.2.2"
},