Skip to content

Commit

Permalink
ci: update changelog generator
Browse files Browse the repository at this point in the history
  • Loading branch information
jpntex committed Nov 2, 2023
1 parent fe691f6 commit f372379
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 118 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "../.scripts/changelog.js",
"changelog": ["../.scripts/changelog.js", { "repo": "indielayer/ui" }],
"commit": false,
"fixed": [],
"linked": [],
Expand Down
25 changes: 19 additions & 6 deletions .scripts/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ const { getInfo, getInfoFromPullRequest } = require('@changesets/get-github-info
module.exports = {
getDependencyReleaseLine: async (
changesets,
dependenciesUpdated
dependenciesUpdated,
options
) => {
if (!options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}

if (dependenciesUpdated.length === 0) return ''

const changesetLink = `- Updated dependencies [${(
await Promise.all(
changesets.map(async (cs) => {
if (cs.commit) {
const { links } = await getInfo({
repo: 'indielayer/ui',
repo: options.repo,
commit: cs.commit,
})
Expand All @@ -30,7 +37,13 @@ module.exports = {

return [changesetLink, ...updatedDepenenciesList].join('\n')
},
getReleaseLine: async (changeset, type) => {
getReleaseLine: async (changeset, type, options) => {
if (!options || !options.repo) {
throw new Error(
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}

let prFromSummary
let commitFromSummary
const usersFromSummary = []
Expand Down Expand Up @@ -62,14 +75,14 @@ module.exports = {
const links = await (async () => {
if (prFromSummary !== undefined) {
let { links } = await getInfoFromPullRequest({
repo: 'indielayer/ui',
repo: options.repo,
pull: prFromSummary,
})

if (commitFromSummary) {
links = {
...links,
commit: `[\`${commitFromSummary}\`](https://github.com/indielayer/ui/commit/${commitFromSummary})`,
commit: `[\`${commitFromSummary}\`](https://github.com/${options.repo}/commit/${commitFromSummary})`,
}
}

Expand All @@ -79,7 +92,7 @@ module.exports = {

if (commitToFetchFrom) {
const { links } = await getInfo({
repo: 'indielayer/ui',
repo: options.repo,
commit: commitToFetchFrom,
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
},
"homepage": "https://github.com/indielayer/ui#readme",
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@changesets/get-github-info": "^0.5.2",
"@indielayer/eslint-config-vue": "^3.3.0",
"eslint": "^8.43.0",
"is-ci": "^3.0.1",
Expand Down
Loading

0 comments on commit f372379

Please sign in to comment.