forked from ipfs/ipfs-webui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-release-notes-generator.cjs
49 lines (42 loc) · 1.31 KB
/
custom-release-notes-generator.cjs
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
/* eslint-disable import/esm-extensions */
// @ts-check
const config = require('conventional-changelog-conventionalcommits')
const { readFileSync } = require('fs')
/**
* @typedef {import('conventional-changelog-conventionalcommits')} ConventionalChangelogConventionalcommits
* @typedef {Exclude<Awaited<ReturnType<ConventionalChangelogConventionalcommits>>, undefined>} ConventionalChangelogConventionalcommitsReturnType
* @typedef {Parameters<ConventionalChangelogConventionalcommits>[0]} ConventionalChangelogConventionalcommitsOptions
*/
/**
* @returns {string}
*/
const getCID = () => {
try {
const cid = readFileSync('.cid', 'utf8')
return cid.trim()
} catch (err) {
console.log('err', err)
return ''
}
}
/**
*
* @param {ConventionalChangelogConventionalcommitsOptions} options
*/
module.exports = async (options) => {
const defaultConfig = /** @type {ConventionalChangelogConventionalcommitsReturnType} */(await config(options))
const { writerOpts } = defaultConfig
const { mainTemplate, commitPartial, footerPartial } = writerOpts
let { headerPartial } = writerOpts
headerPartial += `\n\n CID \`${getCID()}\`\n\n --- \n\n`
return {
...defaultConfig,
writerOpts: {
...writerOpts,
headerPartial,
mainTemplate,
commitPartial,
footerPartial
}
}
}