-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.js
50 lines (43 loc) · 1.07 KB
/
generate.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import meow from 'meow';
import { Octokit } from '@octokit/rest';
import generateReleaseNotes from './lib/generateReleaseNotes.js';
const cli = meow(`
Usage
$ generate-github-release-notes <owner> <repository> <since-tag> <release-tag>
Options
--github-api-token, Token to use when connecting to the github API
Examples
$ generate-github-release-notes jrjohnson generate-github-release-notes 1.0.1 2.0.0
`,
{
booleanDefault: undefined,
importMeta: import.meta,
flags: {
githubApiToken: {
type: 'string',
},
}
}
);
if (cli.input.length < 4) {
cli.showHelp();
}
const owner = cli.input[0];
const repository = cli.input[1];
const sinceTag = cli.input[2];
const releaseTag = cli.input[3];
let auth = undefined;
if (cli.flags.githubApiToken) {
auth = cli.flags.githubApiToken;
}
const octokit = new Octokit({
auth,
userAgent: 'github release notes',
request: {
timeout: 5000
}
});
generateReleaseNotes(octokit, owner, repository, sinceTag, releaseTag).then(releaseNotes => {
process.stdout.write(releaseNotes);
process.exit(0);
});