From 4cc4c89fa3a394691ec1fa1493758b22a6f76783 Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Sun, 23 Jun 2024 20:23:26 +1000 Subject: [PATCH] refactor: Replace git-log-parser with simple-git (#101) * chore: Add gitlog * Try simple-git * Working implementation * Clean-up --- package.json | 5 +- pnpm-lock.yaml | 220 ++++++++++------------------------------- src/publish/index.js | 82 +++++++-------- src/publish/types.d.ts | 38 ++----- 4 files changed, 97 insertions(+), 248 deletions(-) diff --git a/package.json b/package.json index abf5dad..7f2322e 100644 --- a/package.json +++ b/package.json @@ -67,14 +67,13 @@ "commander": "^12.1.0", "current-git-branch": "^1.1.0", "esbuild-register": "^3.5.0", - "git-log-parser": "^1.2.0", "interpret": "^3.1.1", "jsonfile": "^6.1.0", "liftoff": "^5.0.0", "minimist": "^1.2.8", "rollup-plugin-preserve-directives": "^0.4.0", "semver": "^7.6.2", - "stream-to-array": "^2.3.0", + "simple-git": "^3.25.0", "v8flags": "^4.0.1", "vite-plugin-dts": "^3.9.1", "vite-plugin-externalize-deps": "^0.8.0", @@ -84,14 +83,12 @@ "@antfu/eslint-config": "^2.21.0", "@arethetypeswrong/cli": "^0.15.3", "@types/current-git-branch": "^1.1.6", - "@types/git-log-parser": "^1.2.3", "@types/interpret": "^1.1.3", "@types/jsonfile": "^6.1.4", "@types/liftoff": "^4.0.3", "@types/minimist": "^1.2.5", "@types/node": "^20.14.2", "@types/semver": "^7.5.8", - "@types/stream-to-array": "^2.3.3", "@types/v8flags": "^3.1.3", "eslint": "^9.4.0", "eslint-plugin-format": "^0.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8753b7f..8994786 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,9 +20,6 @@ importers: esbuild-register: specifier: ^3.5.0 version: 3.5.0(esbuild@0.20.2) - git-log-parser: - specifier: ^1.2.0 - version: 1.2.0 interpret: specifier: ^3.1.1 version: 3.1.1 @@ -41,9 +38,9 @@ importers: semver: specifier: ^7.6.2 version: 7.6.2 - stream-to-array: - specifier: ^2.3.0 - version: 2.3.0 + simple-git: + specifier: ^3.25.0 + version: 3.25.0 v8flags: specifier: ^4.0.1 version: 4.0.1 @@ -66,9 +63,6 @@ importers: '@types/current-git-branch': specifier: ^1.1.6 version: 1.1.6 - '@types/git-log-parser': - specifier: ^1.2.3 - version: 1.2.3 '@types/interpret': specifier: ^1.1.3 version: 1.1.3 @@ -87,9 +81,6 @@ importers: '@types/semver': specifier: ^7.5.8 version: 7.5.8 - '@types/stream-to-array': - specifier: ^2.3.3 - version: 2.3.3 '@types/v8flags': specifier: ^3.1.3 version: 3.1.3 @@ -596,6 +587,12 @@ packages: resolution: {integrity: sha512-f5DRIOZf7wxogefH03RjMPMdBF7ADTWUMoOs9kaJo06EfwF+aFhMZMDZxHg/Xe12hptN9xoZjGso2fdjapBRIA==} engines: {node: '>=10'} + '@kwsites/file-exists@1.1.1': + resolution: {integrity: sha512-m9/5YGR18lIwxSFDwfE3oA7bWuq9kdau6ugN4H2rJeyhFQZcG9AgSHkQtSD15a8WvTgfz9aikZMrKPHvbpqFiw==} + + '@kwsites/promise-deferred@1.1.1': + resolution: {integrity: sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==} + '@microsoft/api-extractor-model@7.28.13': resolution: {integrity: sha512-39v/JyldX4MS9uzHcdfmjjfS6cYGAoXV+io8B5a338pkHiSt+gy2eXQ0Q7cGFJ7quSa1VqqlMdlPrB6sLR/cAw==} @@ -864,9 +861,6 @@ packages: '@types/fined@1.1.5': resolution: {integrity: sha512-2N93vadEGDFhASTIRbizbl4bNqpMOId5zZfj6hHqYZfEzEfO9onnU4Im8xvzo8uudySDveDHBOOSlTWf38ErfQ==} - '@types/git-log-parser@1.2.3': - resolution: {integrity: sha512-T+qpPYiSfsDhldenqLNL17bNluhAJr+3zgXeuGHys1XYeKja/sr33TRNXhfoQDLL3DbWxXLe5F/Uj2ViLjp5Lw==} - '@types/interpret@1.1.3': resolution: {integrity: sha512-uBaBhj/BhilG58r64mtDb/BEdH51HIQLgP5bmWzc5qCtFMja8dCk/IOJmk36j0lbi9QHwI6sbtUNGuqXdKCAtQ==} @@ -903,9 +897,6 @@ packages: '@types/semver@7.5.8': resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} - '@types/stream-to-array@2.3.3': - resolution: {integrity: sha512-fWXKc6enNlT2l0nXZcxHNQvNSg9IIBgHQR1bHfAVjcJD+zlx9F0o6W+qGWerB1eGBszV4+dsge3id4PEp6SptA==} - '@types/unist@2.0.10': resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} @@ -1107,9 +1098,6 @@ packages: ansicolors@0.3.2: resolution: {integrity: sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg==} - any-promise@1.3.0: - resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} - are-docs-informative@0.0.2: resolution: {integrity: sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==} engines: {node: '>=14'} @@ -1120,9 +1108,6 @@ packages: argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - argv-formatter@1.0.0: - resolution: {integrity: sha512-F2+Hkm9xFaRg+GkaNnbwXNDV5O6pnCFEmqyhvfC/Ic5LbgOWjJh3L+mN/s91rxVL3znE7DYVpW0GJFT+4YBgWw==} - array-each@1.0.1: resolution: {integrity: sha512-zHjL5SZa68hkKHBFBK6DJCTtr9sfTCPCaph/L7tMSLcTFgy+zX7E+6q5UArbtOtMBCtxdICpfTCspRse+ywyXA==} engines: {node: '>=0.10.0'} @@ -1332,9 +1317,6 @@ packages: core-js-compat@3.37.0: resolution: {integrity: sha512-vYq4L+T8aS5UuFg4UwDhc7YNRWVeVZwltad9C/jV3R2LgVOpS9BDr7l/WL6BN0dbV3k1XejPTHqqEzJgsa0frA==} - core-util-is@1.0.3: - resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} - cross-spawn@5.1.0: resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} @@ -1372,8 +1354,8 @@ packages: supports-color: optional: true - debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + debug@4.3.5: + resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -1430,9 +1412,6 @@ packages: resolution: {integrity: sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==} engines: {node: '>=12'} - duplexer2@0.1.4: - resolution: {integrity: sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==} - duplexer@0.1.2: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} @@ -1863,9 +1842,6 @@ packages: get-tsconfig@4.7.5: resolution: {integrity: sha512-ZCuZCnlqNzjb4QprAzXKdpp/gh6KTxSJuw3IBsPnV/7fV4NxC9ckB+vPTt8w7fJA0TaSD7c55BR47JD6MEDyDw==} - git-log-parser@1.2.0: - resolution: {integrity: sha512-rnCVNfkTL8tdNryFuaY0fYiBWEBcgF748O6ZI61rslBvr2o7U65c2/6npCRqH40vuAhtgtDiqLTJjBVdrejCzA==} - glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -2112,9 +2088,6 @@ packages: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} - isarray@1.0.0: - resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} - isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -2632,9 +2605,6 @@ packages: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - process-nextick-args@2.0.1: - resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} @@ -2683,9 +2653,6 @@ packages: resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} engines: {node: '>=8'} - readable-stream@2.3.8: - resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} - readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -2774,9 +2741,6 @@ packages: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} - safe-buffer@5.1.2: - resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} - safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} @@ -2848,6 +2812,9 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + simple-git@3.25.0: + resolution: {integrity: sha512-KIY5sBnzc4yEcJXW7Tdv4viEz8KyG+nU0hay+DWZasvdFOYKeUZ6Xc25LUHHjw0tinPT7O1eY6pzX7pRT1K8rw==} + sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} @@ -2875,9 +2842,6 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} - spawn-error-forwarder@1.0.0: - resolution: {integrity: sha512-gRjMgK5uFjbCvdibeGJuy3I5OYz6VLoVdsOJdA6wV0WlfQVLFueoqMxwwYD9RODdgb6oUIvlRlsyFSiQkMKu0g==} - spdx-correct@3.2.0: resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} @@ -2893,9 +2857,6 @@ packages: spdx-license-ids@3.0.17: resolution: {integrity: sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==} - split2@1.0.0: - resolution: {integrity: sha512-NKywug4u4pX/AZBB1FCPzZ6/7O+Xhz1qMVbzTvvKvikjO99oPN87SkK08mEY9P63/5lWjK+wgOOgApnTg5r6qg==} - split2@4.2.0: resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} engines: {node: '>= 10.x'} @@ -2909,12 +2870,6 @@ packages: std-env@3.7.0: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} - stream-combiner2@1.1.1: - resolution: {integrity: sha512-3PnJbYgS56AeWgtKF5jtJRT6uFJe56Z0Hc5Ngg/6sI6rIt8iiMBTa9cvdyFfpMQjaVHr8dusbNeFGIIonxOvKw==} - - stream-to-array@2.3.0: - resolution: {integrity: sha512-UsZtOYEn4tWU2RGLOXr/o/xjRBftZRlG3dEWoaHr8j4GuypJ3isitGbVyjQKAuMu+xbiop8q224TjiZWc4XTZA==} - string-argv@0.3.2: resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==} engines: {node: '>=0.6.19'} @@ -2923,9 +2878,6 @@ packages: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} - string_decoder@1.1.1: - resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} - string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} @@ -3007,9 +2959,6 @@ packages: text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - through2@2.0.5: - resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==} - through@2.3.8: resolution: {integrity: sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==} @@ -3048,10 +2997,6 @@ packages: resolution: {integrity: sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==} engines: {node: '>=18'} - traverse@0.6.8: - resolution: {integrity: sha512-aXJDbk6SnumuaZSANd21XAo15ucCDE38H4fkqiGsc3MhCK+wOlZvLP9cB/TvpHT0mOyWgC4Z8EwRlzqYSUzdsA==} - engines: {node: '>= 0.4'} - ts-api-utils@1.3.0: resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==} engines: {node: '>=16'} @@ -3376,10 +3321,6 @@ packages: xmlchars@2.2.0: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} - xtend@4.0.2: - resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} - engines: {node: '>=0.4'} - y18n@5.0.8: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} @@ -3526,7 +3467,7 @@ snapshots: '@babel/traverse': 7.23.7 '@babel/types': 7.23.6 convert-source-map: 2.0.0 - debug: 4.3.4 + debug: 4.3.5 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -3641,7 +3582,7 @@ snapshots: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.24.5 '@babel/types': 7.23.6 - debug: 4.3.4 + debug: 4.3.5 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -3771,7 +3712,7 @@ snapshots: '@eslint/config-array@0.15.1': dependencies: '@eslint/object-schema': 2.1.3 - debug: 4.3.4 + debug: 4.3.5 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -3779,7 +3720,7 @@ snapshots: '@eslint/eslintrc@3.1.0': dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.5 espree: 10.0.1 globals: 14.0.0 ignore: 5.3.1 @@ -3826,6 +3767,14 @@ snapshots: string-argv: 0.3.2 type-detect: 4.0.8 + '@kwsites/file-exists@1.1.1': + dependencies: + debug: 4.3.5 + transitivePeerDependencies: + - supports-color + + '@kwsites/promise-deferred@1.1.1': {} + '@microsoft/api-extractor-model@7.28.13(@types/node@20.14.2)': dependencies: '@microsoft/tsdoc': 0.14.2 @@ -4090,10 +4039,6 @@ snapshots: '@types/fined@1.1.5': {} - '@types/git-log-parser@1.2.3': - dependencies: - '@types/node': 20.14.2 - '@types/interpret@1.1.3': dependencies: '@types/node': 20.14.2 @@ -4134,10 +4079,6 @@ snapshots: '@types/semver@7.5.8': {} - '@types/stream-to-array@2.3.3': - dependencies: - '@types/node': 20.14.2 - '@types/unist@2.0.10': {} '@types/v8flags@3.1.3': {} @@ -4166,7 +4107,7 @@ snapshots: '@typescript-eslint/types': 7.12.0 '@typescript-eslint/typescript-estree': 7.12.0(typescript@5.4.5) '@typescript-eslint/visitor-keys': 7.12.0 - debug: 4.3.4 + debug: 4.3.5 eslint: 9.4.0 optionalDependencies: typescript: 5.4.5 @@ -4182,7 +4123,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 7.12.0(typescript@5.4.5) '@typescript-eslint/utils': 7.12.0(eslint@9.4.0)(typescript@5.4.5) - debug: 4.3.4 + debug: 4.3.5 eslint: 9.4.0 ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: @@ -4196,7 +4137,7 @@ snapshots: dependencies: '@typescript-eslint/types': 7.12.0 '@typescript-eslint/visitor-keys': 7.12.0 - debug: 4.3.4 + debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.4 @@ -4374,7 +4315,7 @@ snapshots: agent-base@7.1.0: dependencies: - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -4405,8 +4346,6 @@ snapshots: ansicolors@0.3.2: {} - any-promise@1.3.0: {} - are-docs-informative@0.0.2: {} argparse@1.0.10: @@ -4415,8 +4354,6 @@ snapshots: argparse@2.0.1: {} - argv-formatter@1.0.0: {} - array-each@1.0.1: {} array-ify@1.0.0: {} @@ -4621,8 +4558,6 @@ snapshots: dependencies: browserslist: 4.23.0 - core-util-is@1.0.3: {} - cross-spawn@5.1.0: dependencies: lru-cache: 4.1.5 @@ -4660,7 +4595,7 @@ snapshots: dependencies: ms: 2.1.3 - debug@4.3.4: + debug@4.3.5: dependencies: ms: 2.1.2 @@ -4700,10 +4635,6 @@ snapshots: dotenv@16.3.2: {} - duplexer2@0.1.4: - dependencies: - readable-stream: 2.3.8 - duplexer@0.1.2: {} electron-to-chromium@1.4.767: {} @@ -4733,7 +4664,7 @@ snapshots: esbuild-register@3.5.0(esbuild@0.20.2): dependencies: - debug: 4.3.4 + debug: 4.3.5 esbuild: 0.20.2 transitivePeerDependencies: - supports-color @@ -4841,7 +4772,7 @@ snapshots: eslint-plugin-import-x@0.5.1(eslint@9.4.0)(typescript@5.4.5): dependencies: '@typescript-eslint/utils': 7.12.0(eslint@9.4.0)(typescript@5.4.5) - debug: 4.3.4 + debug: 4.3.5 doctrine: 3.0.0 eslint: 9.4.0 eslint-import-resolver-node: 0.3.9 @@ -4859,7 +4790,7 @@ snapshots: '@es-joy/jsdoccomment': 0.43.1 are-docs-informative: 0.0.2 comment-parser: 1.4.1 - debug: 4.3.4 + debug: 4.3.5 escape-string-regexp: 4.0.0 eslint: 9.4.0 esquery: 1.5.0 @@ -4925,7 +4856,7 @@ snapshots: eslint-plugin-toml@0.11.0(eslint@9.4.0): dependencies: - debug: 4.3.4 + debug: 4.3.5 eslint: 9.4.0 eslint-compat-utils: 0.5.0(eslint@9.4.0) lodash: 4.17.21 @@ -4989,7 +4920,7 @@ snapshots: eslint-plugin-yml@1.14.0(eslint@9.4.0): dependencies: - debug: 4.3.4 + debug: 4.3.5 eslint: 9.4.0 eslint-compat-utils: 0.5.0(eslint@9.4.0) lodash: 4.17.21 @@ -5032,7 +4963,7 @@ snapshots: ajv: 6.12.6 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.5 escape-string-regexp: 4.0.0 eslint-scope: 8.0.1 eslint-visitor-keys: 4.0.0 @@ -5247,15 +5178,6 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 - git-log-parser@1.2.0: - dependencies: - argv-formatter: 1.0.0 - spawn-error-forwarder: 1.0.0 - split2: 1.0.0 - stream-combiner2: 1.1.1 - through2: 2.0.5 - traverse: 0.6.8 - glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -5345,14 +5267,14 @@ snapshots: http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color https-proxy-agent@7.0.4: dependencies: agent-base: 7.1.0 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -5471,8 +5393,6 @@ snapshots: dependencies: is-docker: 2.2.1 - isarray@1.0.0: {} - isexe@2.0.0: {} isobject@3.0.1: {} @@ -5686,7 +5606,7 @@ snapshots: micromark@2.11.4: dependencies: - debug: 4.3.4 + debug: 4.3.5 parse-entities: 2.0.0 transitivePeerDependencies: - supports-color @@ -6032,8 +5952,6 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.2.0 - process-nextick-args@2.0.1: {} - proxy-from-env@1.1.0: {} pseudomap@1.0.2: {} @@ -6079,16 +5997,6 @@ snapshots: parse-json: 5.2.0 type-fest: 0.6.0 - readable-stream@2.3.8: - dependencies: - core-util-is: 1.0.3 - inherits: 2.0.4 - isarray: 1.0.0 - process-nextick-args: 2.0.1 - safe-buffer: 5.1.2 - string_decoder: 1.1.1 - util-deprecate: 1.0.2 - readable-stream@3.6.2: dependencies: inherits: 2.0.4 @@ -6192,8 +6100,6 @@ snapshots: dependencies: mri: 1.2.0 - safe-buffer@5.1.2: {} - safe-buffer@5.2.1: {} safer-buffer@2.1.2: {} @@ -6246,6 +6152,14 @@ snapshots: signal-exit@4.1.0: {} + simple-git@3.25.0: + dependencies: + '@kwsites/file-exists': 1.1.1 + '@kwsites/promise-deferred': 1.1.1 + debug: 4.3.5 + transitivePeerDependencies: + - supports-color + sisteransi@1.0.5: {} skin-tone@2.0.0: @@ -6271,8 +6185,6 @@ snapshots: source-map@0.6.1: {} - spawn-error-forwarder@1.0.0: {} - spdx-correct@3.2.0: dependencies: spdx-expression-parse: 3.0.1 @@ -6292,10 +6204,6 @@ snapshots: spdx-license-ids@3.0.17: {} - split2@1.0.0: - dependencies: - through2: 2.0.5 - split2@4.2.0: {} sprintf-js@1.0.3: {} @@ -6304,15 +6212,6 @@ snapshots: std-env@3.7.0: {} - stream-combiner2@1.1.1: - dependencies: - duplexer2: 0.1.4 - readable-stream: 2.3.8 - - stream-to-array@2.3.0: - dependencies: - any-promise: 1.3.0 - string-argv@0.3.2: {} string-width@4.2.3: @@ -6321,10 +6220,6 @@ snapshots: is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - string_decoder@1.1.1: - dependencies: - safe-buffer: 5.1.2 - string_decoder@1.3.0: dependencies: safe-buffer: 5.2.1 @@ -6399,11 +6294,6 @@ snapshots: text-table@0.2.0: {} - through2@2.0.5: - dependencies: - readable-stream: 2.3.8 - xtend: 4.0.2 - through@2.3.8: {} tinybench@2.6.0: {} @@ -6437,8 +6327,6 @@ snapshots: dependencies: punycode: 2.3.1 - traverse@0.6.8: {} - ts-api-utils@1.3.0(typescript@5.4.5): dependencies: typescript: 5.4.5 @@ -6534,7 +6422,7 @@ snapshots: vite-node@1.6.0(@types/node@20.14.2): dependencies: cac: 6.7.14 - debug: 4.3.4 + debug: 4.3.5 pathe: 1.1.2 picocolors: 1.0.1 vite: 5.2.13(@types/node@20.14.2) @@ -6553,7 +6441,7 @@ snapshots: '@microsoft/api-extractor': 7.43.0(@types/node@20.14.2) '@rollup/pluginutils': 5.1.0(rollup@4.14.1) '@vue/language-core': 1.8.27(typescript@5.4.5) - debug: 4.3.4 + debug: 4.3.5 kolorist: 1.8.0 magic-string: 0.30.10 typescript: 5.4.5 @@ -6584,7 +6472,7 @@ snapshots: vite-tsconfig-paths@4.3.2(typescript@5.4.5)(vite@5.2.13(@types/node@20.14.2)): dependencies: - debug: 4.3.4 + debug: 4.3.5 globrex: 0.1.2 tsconfck: 3.0.3(typescript@5.4.5) optionalDependencies: @@ -6615,7 +6503,7 @@ snapshots: '@vitest/utils': 1.6.0 acorn-walk: 8.3.2 chai: 4.4.1 - debug: 4.3.4 + debug: 4.3.5 execa: 8.0.1 local-pkg: 0.5.0 magic-string: 0.30.10 @@ -6642,7 +6530,7 @@ snapshots: vue-eslint-parser@9.4.3(eslint@9.4.0): dependencies: - debug: 4.3.4 + debug: 4.3.5 eslint: 9.4.0 eslint-scope: 7.2.2 eslint-visitor-keys: 3.4.3 @@ -6725,8 +6613,6 @@ snapshots: xmlchars@2.2.0: {} - xtend@4.0.2: {} - y18n@5.0.8: {} yallist@2.1.2: {} diff --git a/src/publish/index.js b/src/publish/index.js index 8e0e032..84fe0d1 100644 --- a/src/publish/index.js +++ b/src/publish/index.js @@ -7,8 +7,7 @@ import { existsSync, readdirSync } from 'node:fs' import * as semver from 'semver' import currentGitBranch from 'current-git-branch' import { parse as parseCommit } from '@commitlint/parse' -import log from 'git-log-parser' -import streamToArray from 'stream-to-array' +import { simpleGit } from 'simple-git' import { capitalize, getSorterFn, @@ -61,7 +60,7 @@ export const publish = async (options) => { // Get the latest tag let latestTag = filteredTags.at(-1) - let range = `${latestTag}..HEAD` + let rangeFrom = latestTag // If RELEASE_ALL is set via a commit subject or body, all packages will be // released regardless if they have changed files matching the package srcDir. @@ -87,7 +86,7 @@ export const publish = async (options) => { // Is it the first release? Is it a major version? if (!latestTag || (semver.patch(tag) === 0 && semver.minor(tag) === 0)) { - range = `origin/main..HEAD` + rangeFrom = 'origin/main' latestTag = tag } } else { @@ -95,41 +94,36 @@ export const publish = async (options) => { } } - console.info(`Git Range: ${range}`) + console.info(`Git Range: ${rangeFrom}..HEAD`) + + const rawCommitsLog = (await simpleGit().log({ from: rangeFrom, to: 'HEAD' })).all + .filter((c) => { + const exclude = [ + c.message.startsWith('Merge branch '), // No merge commits + c.message.startsWith(releaseCommitMsg('')), // No example update commits + ].some(Boolean) + + return !exclude + }) /** * Get the commits since the latest tag * @type {import('./types.js').Commit[]} */ - const commitsSinceLatestTag = ( - await new Promise((resolve, reject) => { - /** @type {NodeJS.ReadableStream} */ - const strm = log.parse({ - _: range, - }) - - streamToArray(strm, (err, arr) => { - if (err) return reject(err) - - Promise.all( - arr.map(async (d) => { - const parsed = await parseCommit(d.subject) - - return { ...d, parsed } - }), - ).then((res) => resolve(res.filter(Boolean))) - }) - }) - ).filter((/** @type {import('./types.js').Commit} */ commit) => { - const exclude = [ - commit.subject.startsWith('Merge branch '), // No merge commits - commit.subject.startsWith(releaseCommitMsg('')), // No example update commits - ].some(Boolean) - - return !exclude - }) + const commitsSinceLatestTag = await Promise.all(rawCommitsLog.map(async (c) => { + const parsed = await parseCommit(c.message) + return { + hash: c.hash.substring(0, 7), + body: c.body, + message: c.message, + author_name: c.author_name, + author_email: c.author_email, + type: parsed.type?.toLowerCase() ?? 'other', + scope: parsed.scope, + } + })) - console.info(`Parsing ${commitsSinceLatestTag.length} commits since ${latestTag}...`) + console.info(`Parsing ${commitsSinceLatestTag.length} commits since ${rangeFrom}...`) /** * Parses the commit messsages, log them, and determine the type of release needed @@ -141,17 +135,17 @@ export const publish = async (options) => { */ let recommendedReleaseLevel = commitsSinceLatestTag.reduce( (releaseLevel, commit) => { - if (commit.parsed.type) { - if (['fix', 'refactor', 'perf'].includes(commit.parsed.type)) { + if (commit.type) { + if (['fix', 'refactor', 'perf'].includes(commit.type)) { releaseLevel = Math.max(releaseLevel, 0) } - if (['feat'].includes(commit.parsed.type)) { + if (['feat'].includes(commit.type)) { releaseLevel = Math.max(releaseLevel, 1) } if (commit.body.includes('BREAKING CHANGE')) { releaseLevel = Math.max(releaseLevel, 2) } - if (commit.subject.includes('RELEASE_ALL') || commit.body.includes('RELEASE_ALL')) { + if (commit.message.includes('RELEASE_ALL') || commit.body.includes('RELEASE_ALL')) { RELEASE_ALL = true } } @@ -257,11 +251,9 @@ export const publish = async (options) => { const changelogCommitsMd = await Promise.all( Object.entries( commitsSinceLatestTag.reduce((prev, curr) => { - const type = curr.parsed.type?.toLowerCase() ?? 'other' - return { ...prev, - [type]: [...(prev[type] ?? []), curr], + [curr.type]: [...(prev[curr.type] ?? []), curr], } }, /** @type {Record} */ ({})), ) @@ -287,7 +279,7 @@ export const publish = async (options) => { let username = '' if (ghToken) { - const query = `${commit.author.email || commit.committer.email}` + const query = commit.author_email const res = await fetch( `https://api.github.com/search/users?q=${query}`, @@ -303,13 +295,13 @@ export const publish = async (options) => { } } - const scope = commit.parsed.scope ? `${commit.parsed.scope}: ` : '' - const subject = commit.parsed.subject || commit.subject + const scope = commit.scope ? `${commit.scope}: ` : '' + const message = commit.message - return `- ${scope}${subject} (${commit.commit.short}) ${ + return `- ${scope}${message} (${commit.hash}) ${ username ? `by @${username}` - : `by ${commit.author.name || commit.author.email}` + : `by ${commit.author_name || commit.author_email}` }` }), ).then((c) => /** @type {const} */ ([type, c])) diff --git a/src/publish/types.d.ts b/src/publish/types.d.ts index 9128a96..c4e0e93 100644 --- a/src/publish/types.d.ts +++ b/src/publish/types.d.ts @@ -1,37 +1,11 @@ export type Commit = { - commit: CommitOrTree - tree: CommitOrTree - author: AuthorOrCommitter - committer: AuthorOrCommitter - subject: string + hash: string body: string - parsed: Parsed -} - -export type CommitOrTree = { - long: string - short: string -} - -export type AuthorOrCommitter = { - name: string - email: string - date: string -} - -export type Parsed = { - type: string | null - scope?: string | null - subject: string - merge?: null - header: string - body?: null - footer?: null - notes?: Array | null - references?: Array | null - mentions?: Array | null - revert?: null - raw: string + message: string + author_name: string + author_email: string + type: string + scope: string | null | undefined } export type Package = {