keepchanges 1.0.0-beta.3 → 1.0.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/README.md +23 -3
- package/README.zh-CN.md +22 -3
- package/dist/cli.mjs +52 -21
- package/dist/{commit-FX77u6Sj.mjs → commit-DBopyhs1.mjs} +2 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,9 +49,9 @@ npx keepchanges <version> [options]
|
|
|
49
49
|
|
|
50
50
|
| Argument or option | Default | Description |
|
|
51
51
|
| --- | --- | --- |
|
|
52
|
-
| `<version>` | Required | Version to generate. Accepts `1.1.0` or `v1.1.0
|
|
53
|
-
| `--from <ref>` | Latest tag | Overrides the starting Git ref used to read commits. |
|
|
54
|
-
| `--to <ref>` | `HEAD` | Sets the ending Git ref. It cannot be combined with `--release`, and must resolve to the current `HEAD` when used with `--commit`. |
|
|
52
|
+
| `<version>` | Required | Version to generate. Accepts `1.1.0` or `v1.1.0`. A version containing `-`, such as `1.1.0-beta.1`, is treated as a prerelease. |
|
|
53
|
+
| `--from <ref>` | Latest matching tag | Overrides the starting Git ref used to read commits. A version such as `1.0.0` uses the configured tag prefix. |
|
|
54
|
+
| `--to <ref>` | `HEAD` | Sets the ending Git ref. A version such as `1.1.0` uses the configured tag prefix. It cannot be combined with `--release`, and must resolve to the current `HEAD` when used with `--commit`. |
|
|
55
55
|
| `--repository <source>` | Auto-detected | Sets a GitHub `owner/repo` slug or a complete GitHub/Gitea URL. It takes precedence over `package.json` and `origin`. |
|
|
56
56
|
| `--output <path>` | `CHANGELOG.md` | Sets the changelog file path. Relative paths are resolved from the current working directory. |
|
|
57
57
|
| `--dry` | `false` | Prints the current release preview without writing files or performing commit, tag, push, or release API mutations. |
|
|
@@ -59,6 +59,8 @@ npx keepchanges <version> [options]
|
|
|
59
59
|
| `--release` | `false` | Runs the complete release flow: writes files, creates or reuses a release commit, creates an annotated tag, pushes `HEAD` and the tag, then creates or updates the repository Release. This implies `--commit`. |
|
|
60
60
|
| `--author <author>` | Release bot | Sets the generated release commit author in `"Name <email>"` format; requires `--commit` or `--release`. |
|
|
61
61
|
| `-t, --token <token>` | Environment | Resolves authors and publishes Releases. GitHub precedence is `--token`, `GITHUB_TOKEN`, then `GH_TOKEN`; Gitea uses `GITEA_TOKEN`. |
|
|
62
|
+
| `--tag-prefix <prefix>` | `v` | Sets the prefix used to find and create version tags, such as `package@`. |
|
|
63
|
+
| `--no-tag-prefix` | `false` | Finds and creates version tags without a prefix. |
|
|
62
64
|
| `--name <name>` | Version tag | Sets the remote Release name; only valid with `--release`. |
|
|
63
65
|
| `-d, --draft` | `false` | Creates a draft Release; only valid with `--release`. |
|
|
64
66
|
| `--prerelease` | Inferred | Explicitly marks a prerelease. By default it is inferred from `-` in the version; only valid with `--release`. |
|
|
@@ -99,6 +101,18 @@ Create a GitHub Release:
|
|
|
99
101
|
GITHUB_TOKEN=github_pat_xxx npx keepchanges 1.1.0 --release
|
|
100
102
|
```
|
|
101
103
|
|
|
104
|
+
Use version tags without a prefix:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx keepchanges 1.1.0 --no-tag-prefix
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Use a package-specific tag prefix:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npx keepchanges 1.1.0 --tag-prefix 'package@'
|
|
114
|
+
```
|
|
115
|
+
|
|
102
116
|
Preview a Release without writing, committing, tagging, pushing, or calling the
|
|
103
117
|
release API:
|
|
104
118
|
|
|
@@ -127,6 +141,12 @@ and the release ends with a version comparison link. GitHub and Gitea both
|
|
|
127
141
|
support author resolution and Release publishing. Gitea uses `GITEA_TOKEN` to
|
|
128
142
|
resolve primary commit authors and publish Releases.
|
|
129
143
|
|
|
144
|
+
Version tags use the `v` prefix by default. The configured prefix applies to
|
|
145
|
+
new tags, existing-tag lookup, version-shaped `--from` and `--to` values,
|
|
146
|
+
comparison links, and repository Release names. Branch names, commit hashes,
|
|
147
|
+
`HEAD`, and other non-version refs are used unchanged. Tag lookup only considers
|
|
148
|
+
the configured prefix, so independent tag sequences do not affect each other.
|
|
149
|
+
|
|
130
150
|
Entries use Git author names by default and include `Co-Authored-By`
|
|
131
151
|
participants. Bot accounts are omitted. With the corresponding provider token,
|
|
132
152
|
the CLI attempts to resolve email addresses to usernames.
|
package/README.zh-CN.md
CHANGED
|
@@ -48,9 +48,9 @@ npx keepchanges <version> [options]
|
|
|
48
48
|
|
|
49
49
|
| 参数 | 默认值 | 说明 |
|
|
50
50
|
| --- | --- | --- |
|
|
51
|
-
| `<version>` | 必填 | 要生成的版本号。可以传入 `1.1.0` 或 `v1.1.0
|
|
52
|
-
| `--from <ref>` |
|
|
53
|
-
| `--to <ref>` | `HEAD` | 指定读取 commit 的结束 Git ref
|
|
51
|
+
| `<version>` | 必填 | 要生成的版本号。可以传入 `1.1.0` 或 `v1.1.0`。包含 `-` 的版本会作为预发布版本,例如 `1.1.0-beta.1`。 |
|
|
52
|
+
| `--from <ref>` | 匹配前缀的最近 tag | 指定读取 commit 的起始 Git ref,并覆盖自动选择结果。`1.0.0` 这类版本会自动应用配置的 tag 前缀。 |
|
|
53
|
+
| `--to <ref>` | `HEAD` | 指定读取 commit 的结束 Git ref。`1.1.0` 这类版本会自动应用配置的 tag 前缀。不能与 `--release` 一起使用;与 `--commit` 一起使用时必须指向当前 `HEAD`。 |
|
|
54
54
|
| `--repository <source>` | 自动检测 | 指定 `owner/repo` 格式的 GitHub 仓库或 GitHub/Gitea 完整 URL。优先级高于 `package.json` 和 `origin`。 |
|
|
55
55
|
| `--output <path>` | `CHANGELOG.md` | 指定 changelog 文件路径。相对路径以当前工作目录为基准。 |
|
|
56
56
|
| `--dry` | `false` | 输出当前版本预览,不写入文件,也不执行 commit、tag、push 或发布 API。 |
|
|
@@ -58,6 +58,8 @@ npx keepchanges <version> [options]
|
|
|
58
58
|
| `--release` | `false` | 执行完整发布流程:写入文件、创建或复用 release commit、创建 annotated tag、推送 `HEAD` 和 tag,然后创建或更新仓库 Release。该参数隐含 `--commit`。 |
|
|
59
59
|
| `--author <author>` | release bot | 设置自动创建的 release commit 作者,格式必须为 `"Name <email>"`;需要与 `--commit` 或 `--release` 一起使用。 |
|
|
60
60
|
| `-t, --token <token>` | 环境变量 | 仓库访问令牌,用于解析作者及发布 Release。GitHub 优先级为 `--token`、`GITHUB_TOKEN`、`GH_TOKEN`;Gitea 使用 `GITEA_TOKEN`。 |
|
|
61
|
+
| `--tag-prefix <prefix>` | `v` | 设置查找和创建版本 tag 时使用的前缀,例如 `package@`。 |
|
|
62
|
+
| `--no-tag-prefix` | `false` | 查找和创建不带前缀的版本 tag。 |
|
|
61
63
|
| `--name <name>` | 版本 tag | 设置远程 Release 名称;仅适用于 `--release`。 |
|
|
62
64
|
| `-d, --draft` | `false` | 创建 draft Release;仅适用于 `--release`。 |
|
|
63
65
|
| `--prerelease` | 根据版本推断 | 显式标记为 prerelease;默认根据版本是否包含 `-` 推断,仅适用于 `--release`。 |
|
|
@@ -98,6 +100,18 @@ npx keepchanges 1.1.0 --commit \
|
|
|
98
100
|
GITHUB_TOKEN=github_pat_xxx npx keepchanges 1.1.0 --release
|
|
99
101
|
```
|
|
100
102
|
|
|
103
|
+
使用无前缀版本 tag:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npx keepchanges 1.1.0 --no-tag-prefix
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
使用 package 专属 tag 前缀:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npx keepchanges 1.1.0 --tag-prefix 'package@'
|
|
113
|
+
```
|
|
114
|
+
|
|
101
115
|
预览 Release,不写文件、不提交、不创建 tag、不推送且不调用发布 API:
|
|
102
116
|
|
|
103
117
|
```bash
|
|
@@ -123,6 +137,11 @@ GitHub 地址会被自动识别。自托管 Gitea 需要在 `package.json` 中
|
|
|
123
137
|
GitHub 和 Gitea 均支持作者解析和 Release 发布;Gitea 使用 `GITEA_TOKEN`
|
|
124
138
|
解析 commit 主作者并发布 Release。
|
|
125
139
|
|
|
140
|
+
版本 tag 默认使用 `v` 前缀。配置的前缀会统一应用于新 tag、已有 tag 查找、
|
|
141
|
+
版本形式的 `--from` 和 `--to`、比较链接及仓库 Release 名称。分支名、commit
|
|
142
|
+
hash、`HEAD` 等非版本 ref 保持不变。自动查找 tag 时只考虑配置的前缀,因此
|
|
143
|
+
彼此独立的 tag 序列不会相互影响。
|
|
144
|
+
|
|
126
145
|
默认使用 Git 提交中的作者名,并将 `Co-Authored-By` 参与者一起写入记录,bot
|
|
127
146
|
账号会被忽略。提供对应平台的 token 后,会尝试将邮箱解析为用户名。
|
|
128
147
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as insertRelease, c as defaultConfig, i as hasRelease, n as parseCommits, o as readChangelog, r as generateChangelog, s as writeChangelog } from "./commit-
|
|
2
|
+
import { a as insertRelease, c as defaultConfig, i as hasRelease, n as parseCommits, o as readChangelog, r as generateChangelog, s as writeChangelog } from "./commit-DBopyhs1.mjs";
|
|
3
3
|
import { readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import { normalizeFull } from "verkit";
|
|
5
5
|
import process from "node:process";
|
|
@@ -8,30 +8,47 @@ import { resolve } from "node:path";
|
|
|
8
8
|
import ansis from "ansis";
|
|
9
9
|
import { x } from "tinyexec";
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version = "1.0.
|
|
11
|
+
var version = "1.0.1";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/git.ts
|
|
14
|
+
function versionTagPattern(tagPrefix) {
|
|
15
|
+
return `${tagPrefix.replace(/[\\*?[\]]/g, "\\$&")}[0-9]*`;
|
|
16
|
+
}
|
|
14
17
|
async function git(cwd, ...args) {
|
|
15
18
|
const result = await x("git", args, { nodeOptions: { cwd } });
|
|
16
19
|
if (result.exitCode !== 0) throw new Error(result.stderr.trim() || `Git exited with status ${result.exitCode}`);
|
|
17
20
|
return result.stdout;
|
|
18
21
|
}
|
|
19
|
-
async function getLatestTag(cwd) {
|
|
20
|
-
|
|
22
|
+
async function getLatestTag(cwd, tagPrefix) {
|
|
23
|
+
const args = [
|
|
21
24
|
"describe",
|
|
22
25
|
"--tags",
|
|
23
26
|
"--abbrev=0"
|
|
24
|
-
]
|
|
27
|
+
];
|
|
28
|
+
if (tagPrefix !== void 0) args.push("--match", versionTagPattern(tagPrefix));
|
|
29
|
+
return (await x("git", args, { nodeOptions: { cwd } })).stdout.trim();
|
|
25
30
|
}
|
|
26
31
|
async function getTagCommit(cwd, tag) {
|
|
27
32
|
return git(cwd, "rev-list", "-n", "1", tag).then((output) => output.trim() || void 0).catch(() => void 0);
|
|
28
33
|
}
|
|
29
|
-
async function
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
async function resolveVersionRef(cwd, ref, tagPrefix) {
|
|
35
|
+
const version = normalizeFull(ref);
|
|
36
|
+
if (!version) return ref;
|
|
37
|
+
const candidates = [.../* @__PURE__ */ new Set([`${tagPrefix}${version}`, ref])];
|
|
38
|
+
for (const candidate of candidates) if (await getTagCommit(cwd, `refs/tags/${candidate}`)) return candidate;
|
|
39
|
+
return ref;
|
|
40
|
+
}
|
|
41
|
+
async function getPreviousTag(cwd, tag, releaseRef, tagPrefix) {
|
|
42
|
+
const releaseVersion = normalizeFull(tag.slice(tagPrefix.length));
|
|
43
|
+
if (releaseVersion && !releaseVersion.includes("-")) {
|
|
44
|
+
const previousStable = (await git(cwd, "tag", "--merged", releaseRef, "--sort=-version:refname")).trim().split("\n").find((candidate) => {
|
|
45
|
+
if (candidate === tag || !candidate.startsWith(tagPrefix)) return false;
|
|
46
|
+
const version = normalizeFull(candidate.slice(tagPrefix.length));
|
|
47
|
+
return Boolean(version && !version.includes("-"));
|
|
48
|
+
});
|
|
32
49
|
if (previousStable) return previousStable;
|
|
33
50
|
}
|
|
34
|
-
return git(cwd, "describe", "--tags", "--abbrev=0", `${releaseRef}^`).then((output) => output.trim()).catch(() => "");
|
|
51
|
+
return git(cwd, "describe", "--tags", "--abbrev=0", "--match", versionTagPattern(tagPrefix), `${releaseRef}^`).then((output) => output.trim()).catch(() => "");
|
|
35
52
|
}
|
|
36
53
|
async function getRemoteTagCommit(cwd, tag) {
|
|
37
54
|
const refs = (await git(cwd, "ls-remote", "--tags", "origin", `refs/tags/${tag}`, `refs/tags/${tag}^{}`)).trim().split("\n").filter(Boolean);
|
|
@@ -320,7 +337,7 @@ async function createChanges(options, environment) {
|
|
|
320
337
|
const env = environment.env ?? process.env;
|
|
321
338
|
const stdout = environment.stdout ?? ((value) => process.stdout.write(value));
|
|
322
339
|
const colors = environment.colors ?? ansis;
|
|
323
|
-
const tag =
|
|
340
|
+
const tag = `${options.tagPrefix}${options.version}`;
|
|
324
341
|
const repository = await resolveRepository(environment.cwd, options.repository);
|
|
325
342
|
const token = repository?.provider.token(options.token, env);
|
|
326
343
|
validateReleaseSupport(options, repository);
|
|
@@ -336,10 +353,12 @@ async function createChanges(options, environment) {
|
|
|
336
353
|
taggedCommit = await getTagCommit(environment.cwd, tag);
|
|
337
354
|
releaseRef = tag;
|
|
338
355
|
}
|
|
339
|
-
const from = options.from ?? (taggedCommit ? await getPreviousTag(environment.cwd, tag, releaseRef) : await getLatestTag(environment.cwd));
|
|
356
|
+
const from = options.from ?? (taggedCommit ? await getPreviousTag(environment.cwd, tag, releaseRef, options.tagPrefix) : await getLatestTag(environment.cwd, options.tagPrefix));
|
|
340
357
|
const to = releaseRef || options.to;
|
|
341
|
-
const
|
|
342
|
-
const
|
|
358
|
+
const resolvedFrom = from ? await resolveVersionRef(environment.cwd, from, options.tagPrefix) : "";
|
|
359
|
+
const resolvedTo = await resolveVersionRef(environment.cwd, to, options.tagPrefix);
|
|
360
|
+
const comparisonFrom = resolvedFrom || (repository ? await git(environment.cwd, "rev-list", "--max-parents=0", resolvedTo).then((value) => value.trim()) : "");
|
|
361
|
+
const commits = parseCommits(await readGitCommits(environment.cwd, resolvedFrom, resolvedTo));
|
|
343
362
|
if (token && repository) await repository.provider.resolveAuthors?.(commits, repository, token, environment.fetch ?? globalThis.fetch);
|
|
344
363
|
const style = {
|
|
345
364
|
emoji: options.emoji,
|
|
@@ -350,7 +369,8 @@ async function createChanges(options, environment) {
|
|
|
350
369
|
version: options.version,
|
|
351
370
|
commits,
|
|
352
371
|
repository,
|
|
353
|
-
comparisonFrom
|
|
372
|
+
comparisonFrom,
|
|
373
|
+
comparisonTo: normalizeFull(options.to) ? resolvedTo : tag
|
|
354
374
|
}, style);
|
|
355
375
|
const repositoryRelease = {
|
|
356
376
|
tag,
|
|
@@ -360,7 +380,7 @@ async function createChanges(options, environment) {
|
|
|
360
380
|
draft: options.draft
|
|
361
381
|
};
|
|
362
382
|
const preview = {
|
|
363
|
-
from:
|
|
383
|
+
from: resolvedFrom || comparisonFrom,
|
|
364
384
|
tag,
|
|
365
385
|
commitCount: commits.length,
|
|
366
386
|
body
|
|
@@ -383,7 +403,7 @@ async function createChanges(options, environment) {
|
|
|
383
403
|
const releaseExists = hasRelease(currentChangelog, options.version);
|
|
384
404
|
await writeChangelog(outputPath, insertRelease(currentChangelog, release));
|
|
385
405
|
const versionPath = await updateVersion(environment.cwd, options.version);
|
|
386
|
-
if (options.commit || options.release) await commitReleaseFiles(options, environment.cwd, outputPath, versionPath, releaseExists);
|
|
406
|
+
if (options.commit || options.release) await commitReleaseFiles(options, environment.cwd, outputPath, versionPath, releaseExists, tag);
|
|
387
407
|
if (options.release) {
|
|
388
408
|
const gitIdentity = resolveGitIdentity(options.author);
|
|
389
409
|
await git(environment.cwd, ...gitIdentity, "tag", "-a", tag, "-m", tag);
|
|
@@ -396,12 +416,12 @@ function validateReleaseSupport(options, repository) {
|
|
|
396
416
|
if (!repository) throw new Error("A supported repository is required to release");
|
|
397
417
|
if (!repository.provider.publishRelease && !repository.provider.manualReleaseUrl) throw new Error(`${repository.provider.name} does not support releases`);
|
|
398
418
|
}
|
|
399
|
-
async function commitReleaseFiles(options, cwd, outputPath, versionPath, releaseExists) {
|
|
419
|
+
async function commitReleaseFiles(options, cwd, outputPath, versionPath, releaseExists, tag) {
|
|
400
420
|
const releasePaths = [outputPath, versionPath].filter((path) => path !== void 0);
|
|
401
421
|
if (!(await git(cwd, "status", "--porcelain", "--", ...releasePaths)).trim()) return;
|
|
402
422
|
await git(cwd, "add", "--", ...releasePaths);
|
|
403
423
|
const versionChanges = versionPath ? await git(cwd, "status", "--porcelain", "--", versionPath) : "";
|
|
404
|
-
const commitMessage = versionPath && !versionChanges.trim() ? `docs(changelog): ${releaseExists ? "update" : "add"}
|
|
424
|
+
const commitMessage = versionPath && !versionChanges.trim() ? `docs(changelog): ${releaseExists ? "update" : "add"} ${tag} release notes` : `chore(release): ${tag}`;
|
|
405
425
|
await git(cwd, ...resolveGitIdentity(options.author), "commit", "-m", commitMessage, ...options.author ? ["--author", options.author] : [], "--only", "--", ...releasePaths);
|
|
406
426
|
}
|
|
407
427
|
async function publishRelease(repository, release, token, preview, environment, manualAction = "create") {
|
|
@@ -435,6 +455,9 @@ function resolveOptions(versionArgument, options) {
|
|
|
435
455
|
if (!version) throw new Error(`Invalid release version: ${versionArgument}`);
|
|
436
456
|
const commit = options.commit ?? defaultConfig.cli.commit;
|
|
437
457
|
const release = options.release ?? defaultConfig.cli.release;
|
|
458
|
+
let tagPrefix = defaultConfig.cli.tagPrefix;
|
|
459
|
+
if (typeof options.tagPrefix === "string") tagPrefix = options.tagPrefix;
|
|
460
|
+
else if (options.tagPrefix === false) tagPrefix = "";
|
|
438
461
|
if (options.to !== void 0 && release) throw new Error("--to cannot be used with --release");
|
|
439
462
|
if (options.author !== void 0 && !commit && !release) throw new Error("--author requires --commit or --release");
|
|
440
463
|
if (!release && (options.name !== void 0 || options.draft !== void 0 || options.prerelease !== void 0)) throw new Error("--name, --draft, and --prerelease require --release");
|
|
@@ -449,6 +472,7 @@ function resolveOptions(versionArgument, options) {
|
|
|
449
472
|
release,
|
|
450
473
|
author: options.author ?? defaultConfig.cli.author,
|
|
451
474
|
token: options.token,
|
|
475
|
+
tagPrefix,
|
|
452
476
|
name: options.name,
|
|
453
477
|
draft: options.draft ?? defaultConfig.cli.draft,
|
|
454
478
|
prerelease: options.prerelease,
|
|
@@ -459,12 +483,19 @@ function resolveOptions(versionArgument, options) {
|
|
|
459
483
|
}
|
|
460
484
|
//#endregion
|
|
461
485
|
//#region src/cli.ts
|
|
462
|
-
const cli = cac("keepchanges").option("--from <ref>", "Start Git reference").option("--to <ref>", "End Git reference").option("--repository <source>", "Repository slug or URL").option("--output <path>", "Changelog file path").option("--dry", "Preview without modifying files or remotes").option("--commit", "Commit the changelog and version update").option("--release", "Publish a repository release").option("--author <author>", "Commit author in \"Name <email>\" format").option("-t, --token <token>", "Repository token").option("--name <name>", "Repository release name").option("-d, --draft", "Create a draft repository release").option("--prerelease", "Mark the repository release as prerelease").option("--emoji", "Use emojis in changelog section titles").option("--capitalize", "Capitalize changelog entries").option("--group", "Group repeated commit scopes");
|
|
463
|
-
cli.command("
|
|
486
|
+
const cli = cac("keepchanges").option("--from <ref>", "Start Git reference").option("--to <ref>", "End Git reference").option("--repository <source>", "Repository slug or URL").option("--output <path>", "Changelog file path").option("--dry", "Preview without modifying files or remotes").option("--commit", "Commit the changelog and version update").option("--release", "Publish a repository release").option("--author <author>", "Commit author in \"Name <email>\" format").option("-t, --token <token>", "Repository token").option("--no-tag-prefix", "Create version tags without a prefix").option("--tag-prefix <prefix>", "Prefix used for version tags", { default: defaultConfig.cli.tagPrefix }).option("--name <name>", "Repository release name").option("-d, --draft", "Create a draft repository release").option("--prerelease", "Mark the repository release as prerelease").option("--emoji", "Use emojis in changelog section titles").option("--capitalize", "Capitalize changelog entries").option("--group", "Group repeated commit scopes");
|
|
487
|
+
cli.command("<version>").usage("<version> [options]").action(async (versionArgument, options) => {
|
|
464
488
|
await createChanges(resolveOptions(versionArgument, options), { cwd: process.cwd() });
|
|
465
489
|
});
|
|
466
490
|
cli.help();
|
|
467
491
|
cli.version(version);
|
|
468
|
-
|
|
492
|
+
try {
|
|
493
|
+
cli.parse(process.argv, { run: false });
|
|
494
|
+
await cli.runMatchedCommand();
|
|
495
|
+
} catch (error) {
|
|
496
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
497
|
+
process.stderr.write(`${message}\n`);
|
|
498
|
+
process.exitCode = 1;
|
|
499
|
+
}
|
|
469
500
|
//#endregion
|
|
470
501
|
export {};
|
|
@@ -9,6 +9,7 @@ const defaultConfig = {
|
|
|
9
9
|
commit: false,
|
|
10
10
|
release: false,
|
|
11
11
|
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>",
|
|
12
|
+
tagPrefix: "v",
|
|
12
13
|
draft: false
|
|
13
14
|
},
|
|
14
15
|
changelog: {
|
|
@@ -59,7 +60,7 @@ function resolveChangelogConfig(overrides = {}) {
|
|
|
59
60
|
function generateChangelog(options, overrides = {}) {
|
|
60
61
|
const config = resolveChangelogConfig(overrides);
|
|
61
62
|
const changes = [...renderSection(options.commits.filter((commit) => commit.isBreaking), config.breakingChanges, config, options.repository), ...Object.entries(config.types).flatMap(([type, section]) => renderSection(options.commits.filter((commit) => !commit.isBreaking && commit.type === type), section, config, options.repository))];
|
|
62
|
-
const body = [...changes.length ? changes : [`*${config.messages.noSignificantChanges}*`], ...options.repository && options.comparisonFrom ? ["", `##### [${config.messages.viewChanges.replace("{provider}", options.repository.provider.name)}](${options.repository.provider.compareUrl(options.repository, options.comparisonFrom, `v${options.version}`)})`] : []].join("\n").trim();
|
|
63
|
+
const body = [...changes.length ? changes : [`*${config.messages.noSignificantChanges}*`], ...options.repository && options.comparisonFrom ? ["", `##### [${config.messages.viewChanges.replace("{provider}", options.repository.provider.name)}](${options.repository.provider.compareUrl(options.repository, options.comparisonFrom, options.comparisonTo ?? `v${options.version}`)})`] : []].join("\n").trim();
|
|
63
64
|
return {
|
|
64
65
|
body,
|
|
65
66
|
release: [
|
package/dist/index.d.mts
CHANGED
|
@@ -90,6 +90,7 @@ interface KeepChangesConfig {
|
|
|
90
90
|
commit: boolean;
|
|
91
91
|
release: boolean;
|
|
92
92
|
author: string;
|
|
93
|
+
tagPrefix: string;
|
|
93
94
|
draft: boolean;
|
|
94
95
|
};
|
|
95
96
|
changelog: ChangelogConfig;
|
|
@@ -102,6 +103,7 @@ declare const defaultConfig: {
|
|
|
102
103
|
commit: false;
|
|
103
104
|
release: false;
|
|
104
105
|
author: string;
|
|
106
|
+
tagPrefix: string;
|
|
105
107
|
draft: false;
|
|
106
108
|
};
|
|
107
109
|
changelog: {
|
|
@@ -140,6 +142,7 @@ interface GenerateChangelogOptions {
|
|
|
140
142
|
commits: Commit[];
|
|
141
143
|
repository?: Repository;
|
|
142
144
|
comparisonFrom?: string;
|
|
145
|
+
comparisonTo?: string;
|
|
143
146
|
}
|
|
144
147
|
interface GeneratedChangelog {
|
|
145
148
|
body: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as insertRelease, c as defaultConfig, i as hasRelease, l as resolveChangelogConfig, n as parseCommits, o as readChangelog, r as generateChangelog, s as writeChangelog, t as parseCommit } from "./commit-
|
|
1
|
+
import { a as insertRelease, c as defaultConfig, i as hasRelease, l as resolveChangelogConfig, n as parseCommits, o as readChangelog, r as generateChangelog, s as writeChangelog, t as parseCommit } from "./commit-DBopyhs1.mjs";
|
|
2
2
|
export { defaultConfig, generateChangelog, hasRelease, insertRelease, parseCommit, parseCommits, readChangelog, resolveChangelogConfig, writeChangelog };
|