Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
hunghg255 committed Sep 3, 2023
1 parent 1e5d503 commit 5bb8f8a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@
"dev": "unbuild --stub",
"test": "vitest",
"lint": "eslint .",
"release": "bumpp -r",
"start": "nr dev && node cli.mjs",
"start": "npm run dev && node cli.mjs --all true",
"typecheck": "tsc --noEmit",
"changelog": "npx changeloggithub@latest --all true"
"release": "bumpp -r && npx changeloggithub@latest --all true && git add CHANGELOG.md && git commit -m 'chore: update changelog' && git push"
},
"dependencies": {
"@antfu/utils": "^0.7.6",
Expand Down
5 changes: 3 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ cli

try {
console.log()
console.log(dim(`changelo${bold('github')} `) + dim(`v${version}`))
console.log(dim(`changeloggithub `) + dim(`v${version}\n`))

const { config, md, commits } = await generate(args as any) as any;

if (config.all) {
await fs.writeFile(config.output || 'CHANGELOG.md', md, 'utf-8')
console.log(yellow(`Saved to ${config.output || 'CHANGELOG.md'}`))
console.log(yellow(`\nSaved to ${config.output || 'CHANGELOG.md'}`))
return
}

webUrl = `https://github.com/${config.github}/releases/new?title=${encodeURIComponent(String(config.name || config.to))}&body=${encodeURIComponent(String(md))}&tag=${encodeURIComponent(String(config.to))}&prerelease=${config.prerelease}`

console.log(dim('--------------'))
console.log(cyan(config.from) + dim(' -> ') + blue(config.to) + dim(` (${commits.length} commits)`))
console.log(dim('--------------'))
console.log()
Expand Down
7 changes: 6 additions & 1 deletion src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { resolveConfig } from './config';
import { parseCommits } from './parse';
import { getGitDiff } from './changelogen/git';
import { getAllGitTag } from './git';
import { blue, cyan, dim } from 'kolorist';

export async function generate(options: ChangelogOptions) {
const resolved = await resolveConfig(options);
Expand All @@ -16,6 +17,8 @@ export async function generate(options: ChangelogOptions) {

tags.unshift(resolved.from as string);

console.log(dim('--------------'));

for (let index = 0; index < tags.length; index++) {
let tagS = tags[index];
let nextTagS = tags[index + 1];
Expand Down Expand Up @@ -47,12 +50,14 @@ export async function generate(options: ChangelogOptions) {
});

sec += '\n';

console.log(cyan(tag) + dim(' -> ') + blue(nextTag) + dim(` (${commits.length} commits)`));
md.push(sec);
}

md.reverse();

console.log(dim('--------------'));

return { config: resolved, md: md, commits: [] };
}

Expand Down
3 changes: 1 addition & 2 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export async function getLastGitTag(delta = 0) {
}

export async function getAllGitTag() {
const tags = await execCommand('git', ['--no-pager', 'tag', '-l', '--sort=creatordate', '--format="%(refname:short) %(creatordate:short)"']).then(r => r.split('\n'))
return tags;
return execCommand('git', ['--no-pager', 'tag', '-l', '--sort=creatordate', '--format="%(refname:short) %(creatordate:short)"']).then(r => r.split('\n'));
}

export async function isRefGitTag(to: string) {
Expand Down

0 comments on commit 5bb8f8a

Please sign in to comment.