From 4f69b4439c6dafda2126d5951658b34211406c41 Mon Sep 17 00:00:00 2001 From: shipjs Date: Mon, 24 Feb 2020 19:11:32 +0100 Subject: [PATCH] fix: specify path for changelog WIP --- packages/shipjs/package.json | 6 +- .../src/step/prepare/updateChangelog.js | 27 +++++- yarn.lock | 87 ++----------------- 3 files changed, 34 insertions(+), 86 deletions(-) diff --git a/packages/shipjs/package.json b/packages/shipjs/package.json index 2876ab15..f9bba1d6 100644 --- a/packages/shipjs/package.json +++ b/packages/shipjs/package.json @@ -43,7 +43,9 @@ "arg": "4.1.3", "chalk": "3.0.0", "change-case": "4.1.1", - "conventional-changelog": "^3.1.15", + "conventional-changelog-angular": "^5.0.6", + "conventional-changelog-core": "^4.1.4", + "conventional-changelog-preset-loader": "^2.3.0", "dotenv": "^8.2.0", "ejs": "^3.0.0", "esm": "3.2.25", @@ -75,4 +77,4 @@ "jest": "24.9.0", "jest-watch-typeahead": "0.4.2" } -} \ No newline at end of file +} diff --git a/packages/shipjs/src/step/prepare/updateChangelog.js b/packages/shipjs/src/step/prepare/updateChangelog.js index 4940387a..a4113a15 100644 --- a/packages/shipjs/src/step/prepare/updateChangelog.js +++ b/packages/shipjs/src/step/prepare/updateChangelog.js @@ -1,6 +1,7 @@ import path from 'path'; import fs from 'fs'; -import conventionalChangelog from 'conventional-changelog'; +import conventionalChangelogCore from 'conventional-changelog-core'; +import conventionalChangelogPresetLoader from 'conventional-changelog-preset-loader'; import tempfile from 'tempfile'; import addStream from 'add-stream'; import runStep from '../runStep'; @@ -39,6 +40,7 @@ export default ({ gitRawCommitsOpts, resolve, reject, + dir, }); }); } @@ -118,6 +120,21 @@ function prepareParams({ } const templateContext = args.context && require(path.resolve(dir, args.context)); + + if (args.preset) { + try { + args.config = conventionalChangelogPresetLoader(args.preset); + } catch (err) { + if (typeof args.preset === 'object') { + args.warn(`Preset: "${args.preset.name}" ${err.message}`); + } else if (typeof args.preset === 'string') { + args.warn(`Preset: "${args.preset}" ${err.message}`); + } else { + args.warn(`Preset: ${err.message}`); + } + } + } + return { args, gitRawCommitsOpts, templateContext }; } @@ -127,11 +144,15 @@ function runConventionalChangelog({ gitRawCommitsOpts, resolve, reject, + dir, }) { - const changelogStream = conventionalChangelog( + const changelogStream = conventionalChangelogCore( args, templateContext, - gitRawCommitsOpts + gitRawCommitsOpts, + undefined, + undefined, + { path: dir } ).on('error', reject); const readStream = fs.createReadStream(args.infile).on('error', reject); diff --git a/yarn.lock b/yarn.lock index 883ced2f..b7453666 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4036,29 +4036,6 @@ conventional-changelog-angular@^5.0.3, conventional-changelog-angular@^5.0.6: compare-func "^1.3.1" q "^1.5.1" -conventional-changelog-atom@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/conventional-changelog-atom/-/conventional-changelog-atom-2.0.3.tgz#3bd14280aa09fe3ec49a0e8fe97b5002db02aad4" - integrity sha512-szZe2ut97qNO6vCCMkm1I/tWu6ol4Rr8a9Lx0y/VlpDnpY0PNp+oGpFgU55lplhx+I3Lro9Iv4/gRj0knfgjzg== - dependencies: - q "^1.5.1" - -conventional-changelog-codemirror@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/conventional-changelog-codemirror/-/conventional-changelog-codemirror-2.0.3.tgz#ebc088154684f8f5171446b8d546ba6b460d46f2" - integrity sha512-t2afackdgFV2yBdHhWPqrKbpaQeVnz2hSJKdWqjasPo5EpIB6TBL0er3cOP1mnGQmuzk9JSvimNSuqjWGDtU5Q== - dependencies: - q "^1.5.1" - -conventional-changelog-conventionalcommits@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/conventional-changelog-conventionalcommits/-/conventional-changelog-conventionalcommits-4.2.3.tgz#22855b32d57d0328951c1c2dc01b172a5f24ea37" - integrity sha512-atGa+R4vvEhb8N/8v3IoW59gCBJeeFiX6uIbPu876ENAmkMwsenyn0R21kdDHJFLQdy6zW4J6b4xN8KI3b9oww== - dependencies: - compare-func "^1.3.1" - lodash "^4.17.15" - q "^1.5.1" - conventional-changelog-core@^3.1.6: version "3.2.3" resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-3.2.3.tgz#b31410856f431c847086a7dcb4d2ca184a7d88fb" @@ -4078,11 +4055,12 @@ conventional-changelog-core@^3.1.6: read-pkg-up "^3.0.0" through2 "^3.0.0" -conventional-changelog-core@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/conventional-changelog-core/-/conventional-changelog-core-4.1.1.tgz#956f1a2fb476ef2f66c93f673ac040a4159de167" - integrity sha512-fBre5P6U9n914Da6Cj82vIfRU2DhTLGr1eDPXWA7AamxTpd4cd0jgdS7Aieas5Vn5WXOJNFRDNl6PrYLEonImg== +conventional-changelog-core@^4.1.4: + version "4.1.4" + resolved "https://registry.npmjs.org/conventional-changelog-core/-/conventional-changelog-core-4.1.4.tgz#39be27fca6ef20a0f998d7a3a1e97cfa8a055cb6" + integrity sha512-LO58ZbEpp1Ul+y/vOI8rJRsWkovsYkCFbOCVgi6UnVfU8WC0F8K8VQQwaBZWWUpb6JvEiN4GBR5baRP2txZ+Vg== dependencies: + add-stream "^1.0.0" conventional-changelog-writer "^4.0.11" conventional-commits-parser "^3.0.8" dateformat "^3.0.0" @@ -4097,42 +4075,6 @@ conventional-changelog-core@^4.1.1: read-pkg-up "^3.0.0" through2 "^3.0.0" -conventional-changelog-ember@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/conventional-changelog-ember/-/conventional-changelog-ember-2.0.4.tgz#c29b78e4af7825cbecb6c3fd6086ca5c09471ac1" - integrity sha512-q1u73sO9uCnxN4TSw8xu6MRU8Y1h9kpwtcdJuNRwu/LSKI1IE/iuNSH5eQ6aLlQ3HTyrIpTfUuVybW4W0F17rA== - dependencies: - q "^1.5.1" - -conventional-changelog-eslint@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/conventional-changelog-eslint/-/conventional-changelog-eslint-3.0.4.tgz#8f4736a23e0cd97e890e76fccc287db2f205f2ff" - integrity sha512-CPwTUENzhLGl3auunrJxiIEWncAGaby7gOFCdj2gslIuOFJ0KPJVOUhRz4Da/I53sdo/7UncUJkiLg94jEsjxg== - dependencies: - q "^1.5.1" - -conventional-changelog-express@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/conventional-changelog-express/-/conventional-changelog-express-2.0.1.tgz#fea2231d99a5381b4e6badb0c1c40a41fcacb755" - integrity sha512-G6uCuCaQhLxdb4eEfAIHpcfcJ2+ao3hJkbLrw/jSK/eROeNfnxCJasaWdDAfFkxsbpzvQT4W01iSynU3OoPLIw== - dependencies: - q "^1.5.1" - -conventional-changelog-jquery@^3.0.6: - version "3.0.6" - resolved "https://registry.yarnpkg.com/conventional-changelog-jquery/-/conventional-changelog-jquery-3.0.6.tgz#460236ad8fb1d29ff932a14fe4e3a45379b63c5e" - integrity sha512-gHAABCXUNA/HjnZEm+vxAfFPJkgtrZvCDIlCKfdPVXtCIo/Q0lN5VKpx8aR5p8KdVRQFF3OuTlvv5kv6iPuRqA== - dependencies: - q "^1.5.1" - -conventional-changelog-jshint@^2.0.3: - version "2.0.3" - resolved "https://registry.yarnpkg.com/conventional-changelog-jshint/-/conventional-changelog-jshint-2.0.3.tgz#ef6e2caf2ee6ffdfda78fcdf7ce87cf6c512d728" - integrity sha512-Pc2PnMPcez634ckzr4EOWviwRSpZcURaK7bjyD9oK6N5fsC/a+3G7LW5m/JpcHPhA9ZxsfIbm7uqZ3ZDGsQ/sw== - dependencies: - compare-func "^1.3.1" - q "^1.5.1" - conventional-changelog-preset-loader@^2.1.1, conventional-changelog-preset-loader@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/conventional-changelog-preset-loader/-/conventional-changelog-preset-loader-2.3.0.tgz#580fa8ab02cef22c24294d25e52d7ccd247a9a6a" @@ -4154,23 +4096,6 @@ conventional-changelog-writer@^4.0.11, conventional-changelog-writer@^4.0.6: split "^1.0.0" through2 "^3.0.0" -conventional-changelog@^3.1.15: - version "3.1.15" - resolved "https://registry.yarnpkg.com/conventional-changelog/-/conventional-changelog-3.1.15.tgz#103d0b550436cf83e8a59ba88be82ece2613cd9f" - integrity sha512-CoWM+Z9bYyF00QzNpTnxkCLiuLAeRocJz3C/foFjvhsdltdtkJgMChp7GytQNjm4pT7JFBVJTpqLHTpxNtOzaA== - dependencies: - conventional-changelog-angular "^5.0.6" - conventional-changelog-atom "^2.0.3" - conventional-changelog-codemirror "^2.0.3" - conventional-changelog-conventionalcommits "^4.2.3" - conventional-changelog-core "^4.1.1" - conventional-changelog-ember "^2.0.4" - conventional-changelog-eslint "^3.0.4" - conventional-changelog-express "^2.0.1" - conventional-changelog-jquery "^3.0.6" - conventional-changelog-jshint "^2.0.3" - conventional-changelog-preset-loader "^2.3.0" - conventional-commits-filter@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/conventional-commits-filter/-/conventional-commits-filter-2.0.2.tgz#f122f89fbcd5bb81e2af2fcac0254d062d1039c1" @@ -6069,7 +5994,7 @@ git-semver-tags@^2.0.3: git-semver-tags@^3.0.1: version "3.0.1" - resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-3.0.1.tgz#9cb9e4974437de1f71f32da3bfe74f4d35afb1b9" + resolved "https://registry.npmjs.org/git-semver-tags/-/git-semver-tags-3.0.1.tgz#9cb9e4974437de1f71f32da3bfe74f4d35afb1b9" integrity sha512-Hzd1MOHXouITfCasrpVJbRDg9uvW7LfABk3GQmXYZByerBDrfrEMP9HXpNT7RxAbieiocP6u+xq20DkvjwxnCA== dependencies: meow "^5.0.0"