Skip to content

Commit 3fd7b2c

Browse files
committed
fix(projects): fix cli
1 parent 61f407c commit 3fd7b2c

File tree

4 files changed

+244
-430
lines changed

4 files changed

+244
-430
lines changed

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@soybeanjs/changelog",
3-
"version": "0.0.7",
3+
"version": "0.2.2",
44
"description": "generate changelog form git tags and commits for github",
55
"author": {
66
"name": "Soybean",
@@ -50,15 +50,14 @@
5050
"convert-gitmoji": "0.1.3",
5151
"dayjs": "1.11.9",
5252
"execa": "8.0.1",
53-
"ofetch": "1.1.1"
53+
"ofetch": "1.2.0"
5454
},
5555
"devDependencies": {
56-
"@soybeanjs/cli": "0.6.6",
56+
"@soybeanjs/cli": "0.6.7",
5757
"@types/cli-progress": "3.11.0",
58-
"@types/node": "20.5.1",
58+
"@types/node": "20.5.2",
5959
"eslint": "8.47.0",
6060
"eslint-config-soybeanjs": "0.5.5",
61-
"githublogen": "workspace:*",
6261
"simple-git-hooks": "2.9.0",
6362
"tsx": "3.12.7",
6463
"typescript": "5.1.6",

packages/githublogen/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@
3636
},
3737
"dependencies": {
3838
"@soybeanjs/changelog": "workspace:*",
39-
"c12": "1.4.1",
39+
"c12": "1.4.2",
4040
"cac": "6.7.14",
41-
"execa": "7.1.1",
42-
"kolorist": "1.8.0"
41+
"execa": "8.0.1",
42+
"kolorist": "1.8.0",
43+
"ofetch": "1.2.0"
4344
},
4445
"devDependencies": {
45-
"@soybeanjs/cli": "0.5.0",
46-
"@types/node": "20.2.5",
47-
"typescript": "5.1.3",
46+
"@soybeanjs/cli": "0.6.7",
47+
"@types/node": "20.5.2",
48+
"typescript": "5.1.6",
4849
"unbuild": "1.2.1"
4950
}
5051
}

packages/githublogen/src/cli.ts

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,57 @@ import { getChangelogMarkdown } from '@soybeanjs/changelog';
55
import { version } from '../package.json';
66
import { hasTagOnGitHub, isRepoShallow, sendRelease } from './github';
77

8-
const cli = cac('githublogen');
8+
function setupCli() {
9+
const cli = cac('githublogen');
910

10-
cli.version(version).option('-t, --token <path>', 'GitHub Token').help();
11+
cli.version(version).option('-t, --token <path>', 'GitHub Token').help();
1112

12-
cli.command('').action(async (args: any) => {
13-
try {
14-
const cwd = process.cwd();
13+
cli.command('').action(async (args: any) => {
14+
try {
15+
const cwd = process.cwd();
1516

16-
const { options, commits, markdown } = await getChangelogMarkdown(
17-
{
18-
cwd,
19-
...args
20-
},
21-
false
22-
);
23-
console.log('markdown: ', markdown);
17+
const { options, commits, markdown } = await getChangelogMarkdown(
18+
{
19+
cwd,
20+
...args
21+
},
22+
false
23+
);
2424

25-
consola.log(cyan(options.from) + dim(' -> ') + blue(options.to) + dim(` (${commits.length} commits)`));
25+
consola.log(cyan(options.from) + dim(' -> ') + blue(options.to) + dim(` (${commits.length} commits)`));
2626

27-
if (!(await hasTagOnGitHub(options.to, options.github.repo, options.github.token))) {
28-
consola.error(yellow(`Current ref "${bold(options.to)}" is not available as tags on GitHub. Release skipped.`));
27+
if (!(await hasTagOnGitHub(options.to, options.github.repo, options.github.token))) {
28+
consola.error(yellow(`Current ref "${bold(options.to)}" is not available as tags on GitHub. Release skipped.`));
2929

30-
if (process.exitCode) {
31-
process.exitCode = 1;
30+
if (process.exitCode) {
31+
process.exitCode = 1;
32+
}
3233
}
33-
}
3434

35-
if (!commits.length && (await isRepoShallow())) {
36-
consola.error(
37-
yellow(
38-
'The repo seems to be clone shallowly, which make changelog failed to generate. You might want to specify `fetch-depth: 0` in your CI config.'
39-
)
40-
);
41-
if (process.exitCode) {
42-
process.exitCode = 1;
35+
if (!commits.length && (await isRepoShallow())) {
36+
consola.error(
37+
yellow(
38+
'The repo seems to be clone shallowly, which make changelog failed to generate. You might want to specify `fetch-depth: 0` in your CI config.'
39+
)
40+
);
41+
if (process.exitCode) {
42+
process.exitCode = 1;
43+
}
44+
return;
4345
}
44-
return;
45-
}
4646

47-
await sendRelease(options, markdown);
48-
} catch (e: any) {
49-
consola.error(red(String(e)));
50-
if (e?.stack) {
51-
consola.error(dim(e.stack?.split('\n').slice(1).join('\n')));
47+
await sendRelease(options, markdown);
48+
} catch (e: any) {
49+
consola.error(red(String(e)));
50+
if (e?.stack) {
51+
consola.error(dim(e.stack?.split('\n').slice(1).join('\n')));
52+
}
53+
54+
process.exit(1);
5255
}
56+
});
57+
58+
cli.parse();
59+
}
5360

54-
process.exit(1);
55-
}
56-
});
61+
setupCli();

0 commit comments

Comments
 (0)