-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monorepo support #85
Comments
I believe that this feature has been completed in this PR #68 |
Are the values in |
Why there is this usecase? or user how to use that? |
I think there is another feature that can be implemented - "A filter for monorepos". Here is the usecase: We are using pnpm to manage a monorepo, but we only want to automatically generate changelogs for certain packages. Specifically, we need to generate changelogs for |
I think we might return an object from
Subdir can be used by CLI to run changelog update against each package. Also manually by user to read config from root but update changeloges in a subdir only (even without workspace support)
Yes this also 👍🏼 |
Any progress? |
Hi @azat-io, currently is pending, because I waiting for those PR's to merge |
Tips To manage my monorepo versions and have the advantages of
{
"loglevel": "verbose",
"version": "0.47.26",
"yes": true,
"command": {
"version": {
"allowBranch": ["master"],
"message": "chore(release): bump version %v",
"conventionalCommits": true,
"forceGitTag": false,
"changelog": false,
"push": true,
"gitTagVersion": true,
"tagVersionPrefix": "v",
"commitHooks": true
}
},
"npmClient": "pnpm",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
} `` import { exec } from 'node:child_process'
import { existsSync, promises as fsp } from 'node:fs'
import { generateMarkDown, getGitDiff, parseCommits, loadChangelogConfig, syncGithubRelease } from 'changelogen'
async function execPromise(command: string): Promise<{ stdout: string; stderr: string }> {
return await new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`🔴 [cli](${command}) Execution failed - ${error.message}.`)
reject(error)
} else {
resolve({ stdout, stderr })
}
})
})
}
async function updateChangelog() {
const { stdout: lastTag } = await execPromise("git tag --sort=-v:refname | sed -n '1p'")
const { stdout: penultimateTag } = await execPromise("git tag --sort=-v:refname | sed -n '2p'")
const lastTagTrimed = lastTag.trim()
const penultimateTagTrimed = penultimateTag.trim()
const config = await loadChangelogConfig(process.cwd(), {
from: penultimateTagTrimed,
to: lastTagTrimed,
})
const rawCommits = await getGitDiff(penultimateTagTrimed, lastTagTrimed)
const commits = parseCommits(rawCommits, config).filter((commit) => {
return (
config.types[commit.type] &&
!(commit.type === 'chore' && (commit.scope === 'deps' || commit.scope === 'release') && !commit.isBreaking)
)
})
const newChangelog = await generateMarkDown(commits, config)
let changelogMD: string
if (typeof config.output === 'string' && existsSync(config.output)) {
changelogMD = await fsp.readFile(config.output, 'utf8')
} else {
changelogMD = '# Changelog\n\n'
}
const lastEntry = changelogMD.match(/^###?\s+.*$/m)
if (lastEntry) {
changelogMD = changelogMD.slice(0, lastEntry.index) + newChangelog + '\n\n' + changelogMD.slice(lastEntry.index)
} else {
changelogMD += '\n' + newChangelog + '\n\n'
}
await fsp.writeFile(config.output as string, changelogMD)
const changelogWithoutTitle = newChangelog.split('\n').slice(2).join('\n')
console.log(changelogWithoutTitle)
await execPromise(`git add -u`)
await execPromise(`git commit --amend --no-edit`)
await execPromise(`git push origin HEAD --force`)
try {
await syncGithubRelease(config, {
version: lastTagTrimed.replace('v', ''),
body: changelogWithoutTitle,
})
console.log('Release pushed to GitHub.')
} catch (error: any) {
console.error('error', error)
}
}
updateChangelog()
{
"scripts": {
"release": "pnnp release:bump-version && pnpm release:changelogen",
"release:bump-version": "lerna version",
"release:changelogen": "ts-node ./changelog-generate.ts"
},
} You have to run pnpm release |
How do you handle this use case ATM without native support for monorepos? Is there an alternative tool (expect for "Changesets")? |
Moving from #18 also awesome works in #45 by @leo91000 and #83 by @aa900031
These are smaller tasks breakdown in order to support mono repos progressively since this is a rather big change in changelogen.
workspaces
config object (auto-detected withresolveWorkspace
frompkg-types
)subDir
config defaulting to/
and when is set, filters commits only relevant to this subpath and also operatespackage.json
andCHANGELOG.md
in{rootDir}/{subDir}
for updating--release
to use workspace config when is set/detected and operate release on each monorepo project withbaseDir
set (using sorted/ordered graph resolved by pkg-types)scopeMap
(auto added scopes using scope map config #86) with workspace config to automatically apply scoped changelogesNote: PRs are more than welcome to implement each task. If you see an improvement in the roadmap for implementation please comment below. 🙏🏼
The text was updated successfully, but these errors were encountered: