@kaynooo/cli-changelog 0.0.0-stage → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +212 -2
- package/dist/cli.js +3038 -0
- package/package.json +33 -4
- package/src/changelog.ts +150 -0
- package/src/cli.ts +298 -0
- package/src/config.ts +147 -0
- package/src/discord.ts +158 -0
- package/src/flags.ts +92 -0
- package/src/generate.ts +23 -0
- package/src/git.ts +166 -0
- package/src/gitea.ts +326 -0
- package/src/highlights.ts +142 -0
- package/src/index.ts +9 -0
- package/src/markdown.ts +199 -0
- package/src/parse.ts +8 -0
- package/src/types.ts +185 -0
- package/src/ui.ts +20 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { ChangelogConfig, GitCommit } from './changelog'
|
|
2
|
+
|
|
3
|
+
export type ChangelogenOptions = ChangelogConfig
|
|
4
|
+
|
|
5
|
+
export interface GiteaRepo {
|
|
6
|
+
owner: string
|
|
7
|
+
repo: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface GiteaAuth {
|
|
11
|
+
token: string
|
|
12
|
+
url: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type Commit = GitCommit
|
|
16
|
+
|
|
17
|
+
export interface ChangelogOptions extends Partial<ChangelogenOptions> {
|
|
18
|
+
/**
|
|
19
|
+
* Dry run. Skip releasing to the forge.
|
|
20
|
+
*/
|
|
21
|
+
dry?: boolean
|
|
22
|
+
/**
|
|
23
|
+
* Whether to include contributors in release notes.
|
|
24
|
+
*
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
contributors?: boolean
|
|
28
|
+
/**
|
|
29
|
+
* Name of the release
|
|
30
|
+
*/
|
|
31
|
+
name?: string
|
|
32
|
+
/**
|
|
33
|
+
* Mark the release as a draft
|
|
34
|
+
*/
|
|
35
|
+
draft?: boolean
|
|
36
|
+
/**
|
|
37
|
+
* Mark the release as prerelease
|
|
38
|
+
*/
|
|
39
|
+
prerelease?: boolean
|
|
40
|
+
/**
|
|
41
|
+
* The forge's API token
|
|
42
|
+
*/
|
|
43
|
+
token?: string
|
|
44
|
+
/**
|
|
45
|
+
* Custom titles
|
|
46
|
+
*/
|
|
47
|
+
titles?: {
|
|
48
|
+
breakingChanges?: string
|
|
49
|
+
/**
|
|
50
|
+
* Title of the section `highlights` opens the notes with
|
|
51
|
+
*/
|
|
52
|
+
highlights?: string
|
|
53
|
+
/**
|
|
54
|
+
* Title of the collapsed block holding every type marked `folded`
|
|
55
|
+
*/
|
|
56
|
+
maintenance?: string
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Capitalize commit messages
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
capitalize?: boolean
|
|
63
|
+
/**
|
|
64
|
+
* Nest commit messages under their scopes
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
group?: boolean | 'multiple'
|
|
68
|
+
/**
|
|
69
|
+
* Use emojis in section titles
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
emoji?: boolean
|
|
73
|
+
/**
|
|
74
|
+
* The forge's host, for links and the API: github.com for a repo whose origin is there, else the `forge` key of ~/.config/kaynooo-cli/config.json, else origin's host
|
|
75
|
+
*/
|
|
76
|
+
baseUrl?: string
|
|
77
|
+
/**
|
|
78
|
+
* The forge's API, without its scheme
|
|
79
|
+
* @default api.github.com on GitHub, `<baseUrl>/api/v1` elsewhere
|
|
80
|
+
*/
|
|
81
|
+
baseUrlApi?: string
|
|
82
|
+
/**
|
|
83
|
+
* Which API the release goes through: `github`, or `gitea` for Gitea and Forgejo
|
|
84
|
+
* @default github when baseUrl is github.com, gitea otherwise
|
|
85
|
+
*/
|
|
86
|
+
provider?: 'gitea' | 'github'
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Walk only the first parent of each merge, so a merged history shows as the merge commit instead of its commits.
|
|
90
|
+
*
|
|
91
|
+
* @default false
|
|
92
|
+
*/
|
|
93
|
+
firstParent?: boolean
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Set when no earlier tag was found: `from` is then the root commit, shown as the start, and the range takes in every commit up to `to`, the root included.
|
|
97
|
+
*
|
|
98
|
+
* @internal set by resolveConfig, whatever a config says
|
|
99
|
+
*/
|
|
100
|
+
fromRoot?: boolean
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Filter tags
|
|
104
|
+
*/
|
|
105
|
+
tagFilter?: (tag: string) => boolean
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Roll up intermediate releases into the range so a minor/major note lists
|
|
109
|
+
* every commit since the previous minor/major, not only since the last patch.
|
|
110
|
+
*/
|
|
111
|
+
rollup?: {
|
|
112
|
+
/**
|
|
113
|
+
* On a minor release (`x.y.0`), start the range at the previous minor
|
|
114
|
+
* (`x.(y-1).0`) instead of the last patch, absorbing all patch commits.
|
|
115
|
+
*
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
minor?: boolean
|
|
119
|
+
/**
|
|
120
|
+
* On a major release (`x.0.0`), start the range at the previous major
|
|
121
|
+
* (`(x-1).0.0`), absorbing all minor and patch commits.
|
|
122
|
+
*
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
major?: boolean
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Release repository, defaults to `repo`
|
|
130
|
+
*/
|
|
131
|
+
releaseRepo?: string
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Can be set to a custom tag string
|
|
135
|
+
* Any `%s` placeholders in the tag string will be replaced
|
|
136
|
+
* If the tag string does _not_ contain any `%s` placeholders,
|
|
137
|
+
* then the version number will be appended to the tag.
|
|
138
|
+
*
|
|
139
|
+
* @default `v%s`.
|
|
140
|
+
*/
|
|
141
|
+
tag?: string
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Discord webhook the release is posted to once it is out on the forge, as an embed
|
|
145
|
+
*
|
|
146
|
+
* @default process.env.DISCORD_WEBHOOK
|
|
147
|
+
*/
|
|
148
|
+
discordWebhook?: string
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Open the notes and the Discord post with the released version's section of a Markdown page, the `## 1.2.0` heading for tag `v1.2.0`, ending on a link to it
|
|
152
|
+
*/
|
|
153
|
+
highlights?: {
|
|
154
|
+
/**
|
|
155
|
+
* The page's Markdown, from the project root
|
|
156
|
+
*/
|
|
157
|
+
file: string
|
|
158
|
+
/**
|
|
159
|
+
* Where the page is published: its links resolve against it, and the notes link to the version's heading on it
|
|
160
|
+
*/
|
|
161
|
+
url: string
|
|
162
|
+
/**
|
|
163
|
+
* Maps a link target as the page writes it to the one the published page has, when the site serves its pages elsewhere than their files: `(target) => target.replace(/\.md(?=#|$)/, '')`. What it returns still resolves against `url`; `undefined` keeps the target
|
|
164
|
+
*/
|
|
165
|
+
link?: LinkMap
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Files to upload as assets to the release
|
|
170
|
+
* `--assets path1,path2` or `--assets path1 --assets path2`
|
|
171
|
+
*/
|
|
172
|
+
assets?: string[] | string
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type LinkMap = (target: string) => string | undefined
|
|
176
|
+
|
|
177
|
+
export type ResolvedChangelogOptions = Required<ChangelogOptions>
|
|
178
|
+
|
|
179
|
+
export interface AuthorInfo {
|
|
180
|
+
commits: string[]
|
|
181
|
+
login?: string
|
|
182
|
+
avatar?: string
|
|
183
|
+
email: string
|
|
184
|
+
name: string
|
|
185
|
+
}
|
package/src/ui.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { paint } from '@kaynooo/cli-kit'
|
|
2
|
+
|
|
3
|
+
// Read per call: the colour flags are applied to the environment once the arguments are parsed.
|
|
4
|
+
export const out = () => paint(process.stdout)
|
|
5
|
+
export const err = () => paint(process.stderr)
|
|
6
|
+
|
|
7
|
+
// Under --json stdout carries the result alone, so what the commands and the libraries log goes to stderr while `body` runs.
|
|
8
|
+
export async function stdoutToStderr<T>(active: boolean, body: () => Promise<T>): Promise<T> {
|
|
9
|
+
const log = console.log
|
|
10
|
+
|
|
11
|
+
if (active)
|
|
12
|
+
console.log = (...args: unknown[]) => console.error(...args.length === 0 ? [''] : args)
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
return await body()
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
console.log = log
|
|
19
|
+
}
|
|
20
|
+
}
|