Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 40862e5

Browse files
committed
fix(changelog): improvements to generation
1 parent eb76422 commit 40862e5

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

Diff for: lib/cli.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,18 @@ program
7272
.action(async (options) => {
7373
console.log('Our config is: ', options)
7474
const { tagPrefix, failOnMissingCommit, releaseBranchPrefix, forceBump, gitUser, gitEmail, changelog } = options
75-
wrapProcess(shipitHandler({ tagPrefix, gitEmail, gitUser, failOnMissingCommit, forceBump, releaseBranchPrefix, generateChangelog: changelog }))
75+
wrapProcess(
76+
shipitHandler({
77+
tagPrefix,
78+
gitEmail,
79+
gitUser,
80+
failOnMissingCommit,
81+
forceBump,
82+
releaseBranchPrefix,
83+
generateChangelog: changelog,
84+
changelogPath: path.resolve(commandCwd, './CHANGELOG.md'),
85+
}),
86+
)
7687
})
7788

7889
program
@@ -95,7 +106,7 @@ program
95106
.command('changelog')
96107
.description('Generate changelog from Git, assuming tag being a release.')
97108
.option('--outputFile <path>', 'Path to file where changelog should be written.', path.resolve(commandCwd, './CHANGELOG.md'))
98-
.option('--gitBaseUrl <url>', 'Absolute URL to ', undefined)
109+
.option('--gitBaseUrl <url>', 'Absolute URL to your git project', undefined)
99110
.action(async (options) => {
100111
console.log('Our config is: ', options)
101112
const { outputFile, gitBaseUrl } = options

Diff for: lib/cli/changelog.ts

-7
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,9 @@ export const changelogHandler = async ({ outputFile, gitBaseUrl }: Props) => {
2828
throw new Error('Could not determine git base URL!')
2929
}
3030

31-
const log = await git.log({ '--max-count': 20 })
3231
await git.fetch(['--tags'])
3332

3433
const tags = await git.tags()
35-
36-
console.log('Last commits: ', log)
37-
console.log('Last tags: ', tags)
38-
3934
const sortedTags = sortTagsDescending(tags.all)
4035

4136
// Sorted from newest to oldest (highest version to lowest).
@@ -66,7 +61,6 @@ export const changelogHandler = async ({ outputFile, gitBaseUrl }: Props) => {
6661
const changelog: string[] = []
6762

6863
changelog.push('# Changelog')
69-
changelog.push(`Current version: ${packageJson.version}`)
7064

7165
result.forEach((a) => {
7266
changelog.push('\n')
@@ -75,7 +69,6 @@ export const changelogHandler = async ({ outputFile, gitBaseUrl }: Props) => {
7569
const logs = a.log as DefaultLogFields[]
7670

7771
logs.forEach((b) => {
78-
console.log(b.refs)
7972
changelog.push(`* ${b.message} \[[${b.hash}](${getCommitLink(gitUrl, b.hash)})\]`)
8073
})
8174
})

Diff for: lib/cli/shipit.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@ interface Props {
1111
releaseBranchPrefix: string
1212
forceBump: boolean
1313
generateChangelog: boolean
14+
changelogPath: string
1415
}
1516

16-
export const shipitHandler = async ({ gitEmail, gitUser, tagPrefix, failOnMissingCommit, forceBump, releaseBranchPrefix, generateChangelog }: Props) => {
17+
export const shipitHandler = async ({
18+
gitEmail,
19+
gitUser,
20+
tagPrefix,
21+
failOnMissingCommit,
22+
forceBump,
23+
releaseBranchPrefix,
24+
generateChangelog,
25+
changelogPath,
26+
}: Props) => {
1727
const git = simpleGit()
1828

1929
// Fetch tags to ensure we have the latest ones.
@@ -94,7 +104,7 @@ export const shipitHandler = async ({ gitEmail, gitUser, tagPrefix, failOnMissin
94104
if (generateChangelog) {
95105
console.log('Generating changelog...')
96106

97-
await changelogHandler({ outputFile: './CHANGELOG.md' })
107+
await changelogHandler({ outputFile: changelogPath })
98108
await git.add('./*').raw('commit', '--amend', '--no-edit')
99109
}
100110

0 commit comments

Comments
 (0)