修复 AGC 版本测试在 Windows 上的路径问题并澄清 bump-version 提示

- build-release.test.mjs 用 fileURLToPath 替代 URL.pathname,修复 Windows 下 /C:/... 路径导致的 3 个用例失败(既有的跨平台问题)

- bump-version.mjs 的 --no-commit 输出改为“已写入版本文件,未创建提交”,避免被误认为不改文件的干跑
This commit is contained in:
2026-09-07 13:33:41 +08:00
parent 78088e422a
commit 57cd81d551
2 changed files with 7 additions and 4 deletions
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { test } from 'node:test';
import { fileURLToPath } from 'node:url';
import {
bumpVersion,
@@ -10,7 +11,9 @@ import {
} from './build-release.mjs';
test('selects an explicit release artifact when configured', () => {
const artifactPath = new URL('../package.json', import.meta.url).pathname;
const artifactPath = fileURLToPath(
new URL('../package.json', import.meta.url),
);
const previous = process.env.AGC_UPDATE_ARTIFACT;
process.env.AGC_UPDATE_ARTIFACT = artifactPath;
try {
@@ -30,7 +33,7 @@ test('does not select unsupported files', () => {
test('manifest contains version, download URL and integrity fields', () => {
const manifest = createUpdateManifest(
new URL('../package.json', import.meta.url).pathname,
fileURLToPath(new URL('../package.json', import.meta.url)),
);
assert.match(manifest.version, /^\d+\.\d+\.\d+$/u);
assert.match(
@@ -46,7 +49,7 @@ test('manifest preserves multiline release notes', () => {
process.env.AGC_UPDATE_RELEASE_NOTES = '第一行\n第二行\r\n第三行';
try {
const manifest = createUpdateManifest(
new URL('../package.json', import.meta.url).pathname,
fileURLToPath(new URL('../package.json', import.meta.url)),
);
assert.equal(manifest.releaseNotes, '第一行\n第二行\r\n第三行');
} finally {
@@ -43,7 +43,7 @@ writeVersionFiles(next);
if (noCommit) {
console.log(
`[bump-version] 版本 ${current} -> ${next}dry-run,未提交,如需提交去掉 --no-commit`,
`[bump-version] 版本 ${current} -> ${next}已写入版本文件,未创建提交,可用 git diff 复核;去掉 --no-commit 即提交`,
);
process.exit(0);
}