diff --git a/deps/chakrashim/CHANGELOG.md b/deps/chakrashim/CHANGELOG.md new file mode 100644 index 00000000000..bb314cf3c04 --- /dev/null +++ b/deps/chakrashim/CHANGELOG.md @@ -0,0 +1,171 @@ +# ChakraShim ChangeLog + +## 2016-04-01, node-chakracore-6.0.0-pre6 + +### Commits + +* [[`d9469f1`] (/~https://github.com/nodejs/node-chakracore/commit/d9469f1)] - chakrashim: update chakracore to 1.1.0.5 +* [[`b838007`] (/~https://github.com/nodejs/node-chakracore/commit/b838007)] - chakrashim: use microtask queue to run Promise +* [[`2723d94`] (/~https://github.com/nodejs/node-chakracore/commit/2723d94)] - test: address 2 new failures on node-chakracore +* [[`88dc654`] (/~https://github.com/nodejs/node-chakracore/commit/88dc654)] - Merge remote-tracking branch 'nodejs/master' +* [[`803af69`] (/~https://github.com/nodejs/node-chakracore/commit/803af69)] - chakrashim: add dummy Debug.MakeMirror +* [[`e7b09ef`] (/~https://github.com/nodejs/node-chakracore/commit/e7b09ef)] - chakrashim: better StackTrace API compat +* [[`c6d6e6b`] (/~https://github.com/nodejs/node-chakracore/commit/c6d6e6b)] - chakrashim: implement new APIs added in v8 +* [[`58ff8db`] (/~https://github.com/nodejs/node-chakracore/commit/58ff8db)] - Merge remote-tracking branch 'nodejs/master' +* [[`878b8fd`] (/~https://github.com/nodejs/node-chakracore/commit/878b8fd)] - chakrashim: fix ObjectTemplate callbacks compat +* [[`75ace7d`] (/~https://github.com/nodejs/node-chakracore/commit/75ace7d)] - chakrashim: ensure chakra_shim_native buffer is null terminated +* [[`adfadcc`] (/~https://github.com/nodejs/node-chakracore/commit/adfadcc)] - test: fix unittest for Chakra engine +* [[`d875ac9`] (/~https://github.com/nodejs/node-chakracore/commit/d875ac9)] - Merge remote-tracking branch 'nodejs/master' +* [[`9e23f00`] (/~https://github.com/nodejs/node-chakracore/commit/9e23f00)] - chakrashim: allow Persistent::Reset after V8::Dispose + +## 2016-02-29, node-chakracore-6.0.0-pre5 + +### Commits + +* [[`fc3cf3e`] (/~https://github.com/nodejs/node-chakracore/commit/fc3cf3e)] - deps: Updated chakracore to 1.1.0.4 +* [[`e2fc338`] (/~https://github.com/nodejs/node-chakracore/commit/e2fc338)] - test: Skip running test-tick-processor +* [[`50d1014`] (/~https://github.com/nodejs/node-chakracore/commit/50d1014)] - chakrashim: Make --v8-options work +* [[`8932128`] (/~https://github.com/nodejs/node-chakracore/commit/8932128)] - Merge remote-tracking branch 'nodejs/master' + +## 2016-02-10, node-chakracore-6.0.0-pre4 + +### Commits + +* [[`a34dd03`] (/~https://github.com/nodejs/node-chakracore/commit/a34dd03)] - deps: Update chakracore to 1.1.0.3 +* [[`ee02cb6`] (/~https://github.com/nodejs/node-chakracore/commit/ee02cb6)] - chakrashim: Fixed breaking v8 APIs after merge +* [[`53bfef3`] (/~https://github.com/nodejs/node-chakracore/commit/53bfef3)] - Merge remote-tracking branch 'nodejs/master' into chnext + +## 2016-01-29, node-chakracore-6.0.0-pre3 + +### Commits + +* [[`668b620`] (/~https://github.com/nodejs/node-chakracore/commit/668b620)] - deps: Updated chakracore to 1.1.0.2 +* [[`88ce3d5`] (/~https://github.com/nodejs/node-chakracore/commit/88ce3d5)] - chakrashim: Update v8 version +* [[`e335592`] (/~https://github.com/nodejs/node-chakracore/commit/e335592)] - chakrashim: Fixed v8 APIs +* [[`d720b2f`] (/~https://github.com/nodejs/node-chakracore/commit/d720b2f)] - Merge remote-tracking branch 'nodejs/master' into chnext +* [[`87d88dd`] (/~https://github.com/nodejs/node-chakracore/commit/87d88dd)] - doc: Fix broken link in README.md +* [[`fb09510`] (/~https://github.com/nodejs/node-chakracore/commit/fb09510)] - test: Disabled more unit test for chakracore +* [[`c2c6337`] (/~https://github.com/nodejs/node-chakracore/commit/c2c6337)] - chakrashim: Bump-up the v8-version. +* [[`c4f1afc`] (/~https://github.com/nodejs/node-chakracore/commit/c4f1afc)] - chakrashim: Fixed v8 APIs after merge +* [[`c4dee62`] (/~https://github.com/nodejs/node-chakracore/commit/c4dee62)] - Merge remote-tracking branch 'nodejs/master' into chnext +* [[`d69e2c8`] (/~https://github.com/nodejs/node-chakracore/commit/d69e2c8)] - chakrashim: Add 'Debug' object only when needed + +## 2016-01-15, node-chakracore-6.0.0-pre2 + +### Commits + +* [[`e300485`] (/~https://github.com/nodejs/node-chakracore/commit/e300485)] - chakrashim: tweak chakra_shim.js for eslint +* [[`5fe1c8f`] (/~https://github.com/nodejs/node-chakracore/commit/5fe1c8f)] - docs: revert README.md bad merge +* [[`a3007fa`] (/~https://github.com/nodejs/node-chakracore/commit/a3007fa)] - chakrashim: sync to chakracore 1.1.0.1 +* [[`a5804dd`] (/~https://github.com/nodejs/node-chakracore/commit/a5804dd)] - tool: Removed unnecessary arg from vcbuild.bat +* [[`3518aee`] (/~https://github.com/nodejs/node-chakracore/commit/3518aee)] - deps: Update chakrashim's v8 header file version +* [[`1e3e8b8`] (/~https://github.com/nodejs/node-chakracore/commit/1e3e8b8)] - Merge remote-tracking branch 'nodejs/master' into chnext +* [[`65b49fc`] (/~https://github.com/nodejs/node-chakracore/commit/65b49fc)] - doc: Added IoT-Readme.md + +## 2016-01-13, node-chakracore-6.0.0-pre1 + +### Commits + +* [[`5d860fd`] (/~https://github.com/nodejs/node-chakracore/commit/5d860fd)] - chakrashim: sync to chakracore release/1.1 +* [[`6c70170`] (/~https://github.com/nodejs/node-chakracore/commit/6c70170)] - chakrashim: Fixed multiple unittest bugs +* [[`ee68330`] (/~https://github.com/nodejs/node-chakracore/commit/ee68330)] - chakrashim: Fix for nan v2.2 APIs +* [[`6bc3ef3`] (/~https://github.com/nodejs/node-chakracore/commit/6bc3ef3)] - doc: Updated README.md for chakracore +* [[`49bb95d`] (/~https://github.com/nodejs/node-chakracore/commit/49bb95d)] - test: Fixed unit test for chakra engine +* [[`889af37`] (/~https://github.com/nodejs/node-chakracore/commit/889af37)] - chakrashim: add chakracore source +* [[`cb4788a`] (/~https://github.com/nodejs/node-chakracore/commit/cb4788a)] - Merge remote-tracking branch 'nodejs/master' into chnext-chakracore +* [[`8d722fa`] (/~https://github.com/nodejs/node-chakracore/commit/8d722fa)] - chakrashim: Implement IsMap/IsSet after merge +* [[`b259f11`] (/~https://github.com/nodejs/node-chakracore/commit/b259f11)] - chakrashim: update AUTHORS +* [[`377347e`] (/~https://github.com/nodejs/node-chakracore/commit/377347e)] - chakrashim: handle index properties in Object::Get/Set +* [[`a1a43a2`] (/~https://github.com/nodejs/node-chakracore/commit/a1a43a2)] - chakrashim: lint errors cleanup +* [[`d1e310e`] (/~https://github.com/nodejs/node-chakracore/commit/d1e310e)] - Show JS exception details for FATAL ERROR message +* [[`f44ff42`] (/~https://github.com/nodejs/node-chakracore/commit/f44ff42)] - chakrashim: misc chakrashim related cleanup +* [[`f14d337`] (/~https://github.com/nodejs/node-chakracore/commit/f14d337)] - chakrashim: handle Value::ToInteger overflow case +* [[`b6e38eb`] (/~https://github.com/nodejs/node-chakracore/commit/b6e38eb)] - chakrashim: Added dummy 'Debug' in global object +* [[`04446e4`] (/~https://github.com/nodejs/node-chakracore/commit/04446e4)] - chakrashim: Implemented ScriptOrigin signature +* [[`7953699`] (/~https://github.com/nodejs/node-chakracore/commit/7953699)] - Merge remote-tracking branch 'nodejs/master' into chnext +* [[`26c1f6d`] (/~https://github.com/nodejs/node-chakracore/commit/26c1f6d)] - chakrashim: JsCollectGarbage and cleanup +* [[`98d84cd`] (/~https://github.com/nodejs/node-chakracore/commit/98d84cd)] - Merge remote-tracking branch 'nodejs/master' into chnext +* [[`1f2ab92`] (/~https://github.com/nodejs/node-chakracore/commit/1f2ab92)] - chakrashim: Remove option to build with 'chakra' +* [[`c115f42`] (/~https://github.com/nodejs/node-chakracore/commit/c115f42)] - chakrashim: Removed --no-duplicate-basename option +* [[`c9cf4ff`] (/~https://github.com/nodejs/node-chakracore/commit/c9cf4ff)] - chakrashim: isMapIterator/isSetIterator bug fix +* [[`82ad0b3`] (/~https://github.com/nodejs/node-chakracore/commit/82ad0b3)] - Added back jslint prefer-const rule +* [[`0e514a5`] (/~https://github.com/nodejs/node-chakracore/commit/0e514a5)] - Merge remote-tracking branch 'nodejs/master' into chnext +* [[`5a3fca2`] (/~https://github.com/nodejs/node-chakracore/commit/5a3fca2)] - chakrashim: Update chakracore to new header +* [[`490ef58`] (/~https://github.com/nodejs/node-chakracore/commit/490ef58)] - chakrashim: Implemeted v8 APIs after merge +* [[`52780c7`] (/~https://github.com/nodejs/node-chakracore/commit/52780c7)] - Merge remote-tracking branch 'nodejs/master' into chnext +* [[`5f6bc43`] (/~https://github.com/nodejs/node-chakracore/commit/5f6bc43)] - chakrashim: Fixed discrepencies in ToInteger +* [[`0c45b5c`] (/~https://github.com/nodejs/node-chakracore/commit/0c45b5c)] - chakrashim,msi: build with chakracore +* [[`e4eec51`] (/~https://github.com/nodejs/node-chakracore/commit/e4eec51)] - chakrashim: Implemented 2 new nan.h APIs +* [[`777a042`] (/~https://github.com/nodejs/node-chakracore/commit/777a042)] - Revert "lib,buffer: temp workaround chakra bug" +* [[`1a9ddec`] (/~https://github.com/nodejs/node-chakracore/commit/1a9ddec)] - Merge remote-tracking branch 'node/master' into chnext +* [[`e4207e2`] (/~https://github.com/nodejs/node-chakracore/commit/e4207e2)] - lib,buffer: temp workaround chakra bug +* [[`3a55f98`] (/~https://github.com/nodejs/node-chakracore/commit/3a55f98)] - lib: mark Buffer/SlowBuffer not supporting @@species +* [[`91b675a`] (/~https://github.com/nodejs/node-chakracore/commit/91b675a)] - Merge remote-tracking branch 'node/master' into chnext +* [[`2d1b2b4`] (/~https://github.com/nodejs/node-chakracore/commit/2d1b2b4)] - chakrashim: update AUTHORS, cpplint +* [[`e4b077c`] (/~https://github.com/nodejs/node-chakracore/commit/e4b077c)] - chakrashim: add implement v8::FunctionTemplate::Inherit I was implement v8::FunctionTemplate::Inherit and use in my game engine. +* [[`189df5f`] (/~https://github.com/nodejs/node-chakracore/commit/189df5f)] - chakrashim: fix Object::SetInternalField … When use SetInternalField with Interger will assert: +* [[`f017c07`] (/~https://github.com/nodejs/node-chakracore/commit/f017c07)] - chakrashim: update AUTHORS +* [[`17b1ed8`] (/~https://github.com/nodejs/node-chakracore/commit/17b1ed8)] - chakrashim: remove unused code +* [[`7f4cf1f`] (/~https://github.com/nodejs/node-chakracore/commit/7f4cf1f)] - chakrashim: remove supportsOverrideToString +* [[`47477f6`] (/~https://github.com/nodejs/node-chakracore/commit/47477f6)] - chakrashim: fix index/toInteger int overflow +* [[`56dc0bb`] (/~https://github.com/nodejs/node-chakracore/commit/56dc0bb)] - chakrashim: fix Object::SetInternalField +* [[`7a1fb01`] (/~https://github.com/nodejs/node-chakracore/commit/7a1fb01)] - win,cctest: link as console subsystem +* [[`c10332c`] (/~https://github.com/nodejs/node-chakracore/commit/c10332c)] - chakrashim: fix x64 build +* [[`776499c`] (/~https://github.com/nodejs/node-chakracore/commit/776499c)] - chakrashim: Removed word 'TH2' from chnext codebase +* [[`efc1c4b`] (/~https://github.com/nodejs/node-chakracore/commit/efc1c4b)] - chakrashim: fix TryCatch exception reporting +* [[`ace0109`] (/~https://github.com/nodejs/node-chakracore/commit/ace0109)] - chakrashim: remove unused code +* [[`436704c`] (/~https://github.com/nodejs/node-chakracore/commit/436704c)] - Merge remote-tracking branch 'node/master' into chnext +* [[`fea88a4`] (/~https://github.com/nodejs/node-chakracore/commit/fea88a4)] - chakrashim: revert StackFrame method renaming +* [[`566cff6`] (/~https://github.com/nodejs/node-chakracore/commit/566cff6)] - chakrashim: minor cleanup +* [[`8d73cfe`] (/~https://github.com/nodejs/node-chakracore/commit/8d73cfe)] - chakrashim: Code refactoring for cached propertyIds +* [[`c932f01`] (/~https://github.com/nodejs/node-chakracore/commit/c932f01)] - Merge remote-tracking branch 'node/master' into chnext +* [[`33d79fa`] (/~https://github.com/nodejs/node-chakracore/commit/33d79fa)] - chakrashim: some minor shim cleanups +* [[`72f0702`] (/~https://github.com/nodejs/node-chakracore/commit/72f0702)] - chakrashim: more v8.h shim alignment for nan.h +* [[`8519d37`] (/~https://github.com/nodejs/node-chakracore/commit/8519d37)] - chakrashim: Add support for --use-strict flag +* [[`c21ef4b`] (/~https://github.com/nodejs/node-chakracore/commit/c21ef4b)] - chakrashim: remove SAL annotations +* [[`56a5330`] (/~https://github.com/nodejs/node-chakracore/commit/56a5330)] - chakrashim: do not pass nullptr to JsCallFunction +* [[`b461501`] (/~https://github.com/nodejs/node-chakracore/commit/b461501)] - chakrashim: align Local/Persistent with official v8.h +* [[`39685df`] (/~https://github.com/nodejs/node-chakracore/commit/39685df)] - chakrashim: Refactored LoadProc changes added earlier +* [[`2c45af2`] (/~https://github.com/nodejs/node-chakracore/commit/2c45af2)] - chakrashim: Load chakra.dll dynamically for TH2 +* [[`e282ea0`] (/~https://github.com/nodejs/node-chakracore/commit/e282ea0)] - chakrashim: add missing Exception methods +* [[`a58a3cb`] (/~https://github.com/nodejs/node-chakracore/commit/a58a3cb)] - chakrashim : Minor code cleanup +* [[`42923c5`] (/~https://github.com/nodejs/node-chakracore/commit/42923c5)] - Merge remote-tracking branch 'node/master' +* [[`8cbbfbc`] (/~https://github.com/nodejs/node-chakracore/commit/8cbbfbc)] - chakrashim: some v8.h shim cleanup +* [[`5a54c00`] (/~https://github.com/nodejs/node-chakracore/commit/5a54c00)] - Merge pull request #64 from Microsoft/CodeCleanup +* [[`da8a753`] (/~https://github.com/nodejs/node-chakracore/commit/da8a753)] - Merge remote-tracking branch 'iojs/master' into chnext +* [[`c50ad9d`] (/~https://github.com/nodejs/node-chakracore/commit/c50ad9d)] - Merge remote-tracking branch 'iojs/next' into chnext +* [[`9a88a51`] (/~https://github.com/nodejs/node-chakracore/commit/9a88a51)] - chakrashim: handle Symbol as property name +* [[`e17502f`] (/~https://github.com/nodejs/node-chakracore/commit/e17502f)] - chakrashim: improve typed array and instanceof perf +* [[`a3d55af`] (/~https://github.com/nodejs/node-chakracore/commit/a3d55af)] - chakrashim: some performance improvements +* [[`f33e43f`] (/~https://github.com/nodejs/node-chakracore/commit/f33e43f)] - chakrashim: Use new Jsrt APIs JsGetContextOfObject, JsGetContextData and JsSetContextData +* [[`8851bb6`] (/~https://github.com/nodejs/node-chakracore/commit/8851bb6)] - chakrashim: Removed cross context shim code +* [[`87862dc`] (/~https://github.com/nodejs/node-chakracore/commit/87862dc)] - chakrashim: enable chakra experimental features +* [[`d24d422`] (/~https://github.com/nodejs/node-chakracore/commit/d24d422)] - chakrashim: implement ArrayBuffer::New on external memory +* [[`39db229`] (/~https://github.com/nodejs/node-chakracore/commit/39db229)] - Merge remote-tracking branch 'iojs/next' into chnext +* [[`45411a7`] (/~https://github.com/nodejs/node-chakracore/commit/45411a7)] - chakrashim: changes to build with iojs next +* [[`f218364`] (/~https://github.com/nodejs/node-chakracore/commit/f218364)] - chakrashim: add gyp flag msvs_use_library_dependency_inputs +* [[`d57d102`] (/~https://github.com/nodejs/node-chakracore/commit/d57d102)] - gyp: add msvs_use_library_dependency_inputs support +* [[`0a2b36a`] (/~https://github.com/nodejs/node-chakracore/commit/0a2b36a)] - chakrashim: fix Script::Compile AV +* [[`549e280`] (/~https://github.com/nodejs/node-chakracore/commit/549e280)] - chakrashim: specify msvs_windows_target_platform_version +* [[`914f1b4`] (/~https://github.com/nodejs/node-chakracore/commit/914f1b4)] - gyp: add msvs_windows_target_platform_version support +* [[`9a1945b`] (/~https://github.com/nodejs/node-chakracore/commit/9a1945b)] - chakrashim: revert error types proxy change +* [[`9d2faef`] (/~https://github.com/nodejs/node-chakracore/commit/9d2faef)] - win,gyp: quote action command +* [[`f345fb0`] (/~https://github.com/nodejs/node-chakracore/commit/f345fb0)] - chakrashim: skip setweak/clearweak work when disposing runtime +* [[`79d4877`] (/~https://github.com/nodejs/node-chakracore/commit/79d4877)] - repl,chakra: make 'Unterminated ...' errors recoverable +* [[`70f8352`] (/~https://github.com/nodejs/node-chakracore/commit/70f8352)] - chakrashim: use proxy to patch error types +* [[`26ff29c`] (/~https://github.com/nodejs/node-chakracore/commit/26ff29c)] - chakrashim: fix some cross-context bugs +* [[`93adbaa`] (/~https://github.com/nodejs/node-chakracore/commit/93adbaa)] - chakrashim: display out of memory error message +* [[`0c41b45`] (/~https://github.com/nodejs/node-chakracore/commit/0c41b45)] - chakrashim: fix cross context strictmode/bound function +* [[`94628e0`] (/~https://github.com/nodejs/node-chakracore/commit/94628e0)] - chakrashim: revive object during ClearWeak +* [[`8a10839`] (/~https://github.com/nodejs/node-chakracore/commit/8a10839)] - chakrashim: vm proxy and other fixes +* [[`13de41a`] (/~https://github.com/nodejs/node-chakracore/commit/13de41a)] - build: refactor engine switch and process.jsEngine +* [[`4fb398a`] (/~https://github.com/nodejs/node-chakracore/commit/4fb398a)] - chakrashim: reformat to pass cpplint +* [[`07547c2`] (/~https://github.com/nodejs/node-chakracore/commit/07547c2)] - chakrashim: per isolate message listeners and embedded data +* [[`2bb7fc3`] (/~https://github.com/nodejs/node-chakracore/commit/2bb7fc3)] - chakrashim: clean up warning on std::map use +* [[`ffe5db1`] (/~https://github.com/nodejs/node-chakracore/commit/ffe5db1)] - chakrashim: fix toString on cross context objects +* [[`f60c528`] (/~https://github.com/nodejs/node-chakracore/commit/f60c528)] - chakrashim: callbackinfo holder and accessor signature +* [[`aa96260`] (/~https://github.com/nodejs/node-chakracore/commit/aa96260)] - node-gyp: revert arm specific libs change +* [[`c2b8d43`] (/~https://github.com/nodejs/node-chakracore/commit/c2b8d43)] - chakrashim: disable warning c4091 and remove arm specific lib +* [[`8403d34`] (/~https://github.com/nodejs/node-chakracore/commit/8403d34)] - npm: change node-gyp module to support chakrashim and ARM +* [[`6c445c6`] (/~https://github.com/nodejs/node-chakracore/commit/6c445c6)] - openssl: enable building on ARM with chakrashim +* [[`47000c7`] (/~https://github.com/nodejs/node-chakracore/commit/47000c7)] - add chakrashim and enable node.js on chakra diff --git a/deps/chakrashim/tools/update-changelog.js b/deps/chakrashim/tools/update-changelog.js new file mode 100644 index 00000000000..7f0fe95c562 --- /dev/null +++ b/deps/chakrashim/tools/update-changelog.js @@ -0,0 +1,210 @@ +// Copyright Microsoft. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and / or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. + +var child_process = require('child_process'); +var fs = require('fs'); +var path = require('path'); + +const header = "# ChakraShim ChangeLog"; +const commitUrl = "/~https://github.com/nodejs/node-chakracore/commit/"; +const releasePrefix = "node-chakracore"; +const EOL_REGEX = /\r\n|\n|\r/; +var srcroot; +var lastRelease; +var changeLog = []; + +function changelogFile() { + return path.join(srcroot, 'CHANGELOG.md'); +} + +// Load existing CHANGELOG.md content +function loadChangelogFile() { + fs.readFile(changelogFile(), function(err, data) { + // ignore err, if so assume no existing CHANGELOG file + if (data) { + console.log('Found existing CHANGELOG'); + data = data.toString(); + + var r = new RegExp("##.*, (" + releasePrefix + "[^,\n]*)\n").exec(data); + if (r) { + lastRelease = r[1].replace(EOL_REGEX, ''); + console.log('Existing CHANGELOG has last release', lastRelease); + } + + changeLog = data.split(EOL_REGEX); + } else { + changeLog.push(header); + } + + while (changeLog.length < 2) { + changeLog.push(''); + } + + loadGitReleaseTags(); + }); +} + +// Load existing git release tags +function loadGitReleaseTags() { + var releaseTags = []; + git_pipe([ + 'tag', '-l', + '--format=%(refname:short) %(objectname:short) ' + + '%(taggerdate:short) %(authordate:short)', // at least 1 date available + releasePrefix + '*'], + line => { + var r = /^(\S+) (\S+)\s+(\S+)/.exec(line); + if (r) { + releaseTags.push({name: r[1], commit: r[2], date: r[3]}); + } + }, + () => matchReleases(releaseTags, lastRelease) + ); +} + +// Match last release, figure out next release and update ranges +function matchReleases(releaseTags, lastRelease) { + var ver; + command_pipe(process.argv[0], ['--version'], + line => { + ver = ver || line.replace(/^v/, ''); + }, + () => { + // Figure out new release name + var newReleaseName = releasePrefix + '-' + ver; + var patch; + if (releaseTags.length > 0) { + var lastReleaseName = releaseTags[releaseTags.length - 1].name; + if (lastReleaseName.indexOf(newReleaseName) == 0) { + patch = +lastReleaseName.substr(newReleaseName.length) + 1; + } + } + newReleaseName += patch || 1; + + if (lastRelease == newReleaseName) { + return console.log('CHANGELOG already has', newReleaseName, + 'changes. \nPlease update manually, or remove', newReleaseName, + 'section and run this script again to regenerate updates.'); + } + + // Remove (... - lastRelease) from releaseTags + if (lastRelease) { + var lastIndex = releaseTags.findIndex(v => v.name == lastRelease); + if (lastIndex < 0) { + return console.error('ERROR:', lastRelease, + 'not found in release tags.', + 'Please fetch release tags (git fetch --tags ...)'); + } + releaseTags.splice(0, lastIndex); + } + + // Last range to be updated + releaseTags.push({ + name: newReleaseName, + commit: 'HEAD', + date: new Date().toISOString().replace(/T.*/,'')}); + + updateChangelogs(releaseTags); + }); +} + +// Update change logs for every range in releaseTags +function updateChangelogs(releaseTags) { + if (releaseTags.length >= 2) { + const last = releaseTags.shift(); + const next = releaseTags[0]; + var commits = []; + return git_pipe([ + 'log', '--first-parent', '--pretty=%h %s', + last.commit + '..' + next.commit, '--', srcroot + '/../..'], + line => { + var r = /^(\S+) (.+)$/.exec(line); + if (r) { + commits.push({commit: r[1], subject: r[2]}); + } + }, + () => { + var output = '## ' + next.date + ", " + next.name + + '\n\n### Commits\n\n'; + commits.forEach(c => { + const sha = c.commit; + output += `* [[\`${sha}\`] (${commitUrl + sha})] - ${c.subject}\n`; + }); + + changeLog.splice(2, 0, output); + updateChangelogs(releaseTags); + }); + } else { + return saveChangelog(); + } +} + +function pipe(proc, onLine) { + var last; + + function addData(chunk) { + var lines = ((last || '') + chunk).split(EOL_REGEX); + last = lines[lines.length - 1]; + + for (var i = 0; i < lines.length - 1; i++) { + onLine(lines[i]); + } + } + + proc.stdout.on('data', function(data) { + addData(data.toString()); + }).on('end', function() { + if (last !== undefined) { + onLine(last); + } + }); + + return proc; +} + +function command_pipe(command, args, onLine, done) { + return pipe(child_process.spawn(command, args), onLine).on( + 'exit', function(code) { + if (code != 0) { + return console.log(command, args, 'exits abnormally:', code); + } + done(); + }); +} + +function git_pipe(args, onLine, done) { + return command_pipe('git', args, onLine, done); +} + +// Save updated changelog +function saveChangelog() { + fs.writeFile(changelogFile(), + changeLog.join('\n'), + function(err) { + if (err) throw err; + console.log('Updated ' + path.relative('', changelogFile())); + }); +} + +// Start +srcroot = process.argv.length > 2 ? + process.argv[2] : path.join(path.dirname(process.argv[1]), '..'); + +loadChangelogFile();