同步 GitHub 上游目录重整 #203 #2

Merged
yxc0915 merged 3 commits from sync/github-main-aac39793 into main 2026-12-05 16:47:07 +00:00
36 changed files with 60 additions and 49 deletions

No files matched your search

+1 -1
View File
@@ -21,4 +21,4 @@
- [ ] 改动归属清晰,跨仓实现已按职责拆分并附上游源码或提交依据
- [ ] 涉及默认值、配置迁移或插件行为时,已附上[已有用户升级兼容性](https://github.com/Nwflower/Reims-Go/blob/main/docs/pr-review-guidelines.md#已有用户升级兼容性)验证记录
- [ ] `node scripts/debug/check.mjs`、`node scripts/changelog.mjs check` 与 `node scripts/test.mjs ci` 通过
- [ ] 面向用户或集成方的变化已写入 `changes/<slug>.json`(纯内部重构无需添加)
- [ ] 面向用户或集成方的变化已写入 `.github/changes/<slug>.json`(纯内部重构无需添加)
+1 -1
View File
@@ -48,7 +48,7 @@ Reims-Go 发布的便携运行时基于团队独立维护的 `reims-go/reims-vgp
## 版本变更与开源合规
面向用户或集成方的变化随改动写入 `changes/<slug>.json`,准备正式版时编入 [`CHANGELOG.md`](CHANGELOG.md),格式与命令见 [`docs/changelog.md`](docs/changelog.md)。
面向用户或集成方的变化随改动写入 `.github/changes/<slug>.json`,准备正式版时编入 [`CHANGELOG.md`](CHANGELOG.md),格式与命令见 [`docs/changelog.md`](docs/changelog.md)。
Reims-Go 自身代码采用 [Apache-2.0](LICENSE) 协议。便携运行时以独立子进程和独立压缩包形式集成,公开运行时发布必须同处附带对应源码包、本地补丁与完整许可证文本(见 [`NOTICE.md`](NOTICE.md))。应用不打包也不托管任何 Apple 系统文件。
File renamed without changes.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

-6
View File
@@ -1,6 +0,0 @@
//go:build !windows
package main
// attachConsole is only needed for Windows GUI-subsystem builds.
func attachConsole() {}
+2 -2
View File
@@ -1,10 +1,10 @@
# 更新日志编写与发布
[`CHANGELOG.md`](../CHANGELOG.md) 保存已编入版本的客户端变更,也是 GitHub Release 说明的正文来源。待发布的条目随改动提交到仓库根目录的 `changes/`。便携运行时 `runtime-*` 在对应的运行时 Release 中记录。客户端条目只在需要时写明它依赖的运行时版本。
[`CHANGELOG.md`](../CHANGELOG.md) 保存已编入版本的客户端变更,也是 GitHub Release 说明的正文来源。待发布的条目随改动提交到 `.github/changes/`。便携运行时 `runtime-*` 在对应的运行时 Release 中记录。客户端条目只在需要时写明它依赖的运行时版本。
## 写入待发布条目
每项值得告知用户或集成方的变化写一个 `changes/<slug>.json`,文件名用小写英文和连字符。将同一行为涉及的多个提交合为一条。内部重构、纯格式调整和日常依赖更新留在提交记录中。
每项值得告知用户或集成方的变化写一个 `.github/changes/<slug>.json`,文件名用小写英文和连字符。将同一行为涉及的多个提交合为一条。内部重构、纯格式调整和日常依赖更新留在提交记录中。
```json
{
+1 -1
View File
@@ -9,7 +9,7 @@
| 改动持久化或升级 | `node scripts/test.mjs quick storage` | 配置和数据目录、迁移及插件状态存储,使用真实临时文件 |
| 改动调试工具 | `node scripts/test.mjs quick tooling` | 临时目录和工单工具自测 |
| 改动 GitHub 自动化脚本 | `node scripts/test.mjs quick automation` | `scripts/ci/` 下 PR 审核、Issue 分诊、代码诊断和申报校验脚本的自测 |
| 跨模块改动或提 PR | `node scripts/test.mjs ci` | 前端测试和类型检查、`cmd/`、`internal/`、`pkg/`、`scripts/` 下的 Go 测试与 vet、调试工具自测、GitHub 自动化脚本自测 |
| 跨模块改动或提 PR | `node scripts/test.mjs ci` | 前端测试和类型检查、`internal/`、`pkg/`、`scripts/` 下的 Go 测试与 vet、调试工具自测、GitHub 自动化脚本自测 |
| 核对发布候选 | `node scripts/test.mjs release` | 使用 `desktop,production` 构建标签运行同一套 Go 检查,禁用测试结果缓存并随机化用例顺序 |
| Windows 桌面冒烟 | `node scripts/test.mjs webview2 build/bin/reims-go.exe` | 启动已构建的客户端,在真实 WebView2 中完成首启数据目录设置 |
+3 -3
View File
@@ -1,5 +1,5 @@
// scripts/brand/wordmark.py is the single source of the icon and the wordmark
// geometry: it copies assets/logo.svg into public/ and generates
// geometry: it copies build/assets/logo.svg into public/ and generates
// wordmark.gen.ts. Neither copy may be edited by hand.
import test from 'node:test'
import assert from 'node:assert/strict'
@@ -8,8 +8,8 @@ import path from 'node:path'
const repoRoot = path.resolve(import.meta.dirname, '..', '..')
test('frontend/public/logo.svg is the copy of assets/logo.svg', () => {
const source = fs.readFileSync(path.join(repoRoot, 'assets', 'logo.svg'))
test('frontend/public/logo.svg is the copy of build/assets/logo.svg', () => {
const source = fs.readFileSync(path.join(repoRoot, 'build', 'assets', 'logo.svg'))
const served = fs.readFileSync(path.join(repoRoot, 'frontend', 'public', 'logo.svg'))
assert.ok(source.equals(served), 'run python scripts/brand/wordmark.py to refresh frontend/public/logo.svg')
})
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by cmd/i18ngen; DO NOT EDIT.
// Code generated by scripts/i18ngen; DO NOT EDIT.
export const coreZh: Record<string, string> = {
"affinityMenu": "处理器相关性…",
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by cmd/i18ngen; DO NOT EDIT.
// Code generated by scripts/i18ngen; DO NOT EDIT.
import { registerBuiltinDomain } from '../runtime'
export const pluginsZh: Record<string, string> = {
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by cmd/i18ngen; DO NOT EDIT.
// Code generated by scripts/i18ngen; DO NOT EDIT.
import { registerBuiltinDomain } from '../runtime'
export const settingsZh: Record<string, string> = {
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by cmd/i18ngen; DO NOT EDIT.
// Code generated by scripts/i18ngen; DO NOT EDIT.
export const vmZh: Record<string, string> = {
"attachGuestTools": "挂载 Guest Tools",
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by cmd/i18ngen; DO NOT EDIT.
// Code generated by scripts/i18ngen; DO NOT EDIT.
import { registerBuiltinDomain } from '../runtime'
export const wizardZh: Record<string, string> = {
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by cmd/i18ngen; DO NOT EDIT.
// Code generated by scripts/i18ngen; DO NOT EDIT.
export type I18nKey =
| "aboutCommunity"
+3 -7
View File
@@ -10,7 +10,6 @@ import (
"github.com/Nwflower/reims-go/internal/fetch"
"github.com/Nwflower/reims-go/internal/host"
"github.com/Nwflower/reims-go/internal/macos/installer"
"github.com/Nwflower/reims-go/internal/netproxy"
)
@@ -37,7 +36,7 @@ func (a *App) DownloadARMImage() (string, error) {
var cancel context.CancelFunc
run, id, owned := installerDownloads.reserveOrFind("arm-ipsw", armImageBuild, "installer-download", func(initialPhase string) string {
ctx, cancel = context.WithCancel(a.baseCtx())
return tasks.startWithInstaller("installer-download", "macOS 27.2.1 · ARM64", "", "arm-ipsw", armImageBuild, initialPhase, cancel)
return tasks.startWithInstaller("installer-download", "macOS 27.2.1 路 ARM64", "", "arm-ipsw", armImageBuild, initialPhase, cancel)
})
if !owned {
return id, nil
@@ -67,13 +66,10 @@ func (a *App) DownloadARMImage() (string, error) {
if err != nil && ctx.Err() != nil {
err = ctx.Err()
}
var result *installer.Result
if err == nil {
result = &installer.Result{Image: path}
} else {
if err != nil {
path = ""
}
installerDownloads.complete(run, result, err)
installerDownloads.completeImage(run, path, err)
tasks.finish(id, path, err)
}()
return id, nil
+8
View File
@@ -148,6 +148,14 @@ func (c *installerCoordinator) complete(run *installerDownloadRun, res *installe
close(run.done)
}
func (c *installerCoordinator) completeImage(run *installerDownloadRun, path string, err error) {
if err != nil {
c.complete(run, nil, err)
return
}
c.complete(run, &installer.Result{Image: path}, nil)
}
func (c *installerCoordinator) hasActive(kind, version string) bool {
c.mu.Lock()
defer c.mu.Unlock()
+8 -1
View File
@@ -101,6 +101,11 @@ func (a *App) startVMMonitor(name string, detail driver.VMInfo, startAt time.Tim
ctx, cancel := context.WithCancel(a.baseCtx())
done := make(chan struct{})
var prevDone chan struct{}
var displayWG sync.WaitGroup
needsDisplayPosition := vmstart.ReadVMDisplay(detail.Directory).TargetDisplay != ""
if needsDisplayPosition {
displayWG.Add(1)
}
vmMonitors.mu.Lock()
if cur, ok := vmMonitors.entries[name]; ok {
cur.cancel()
@@ -114,8 +119,9 @@ func (a *App) startVMMonitor(name string, detail driver.VMInfo, startAt time.Tim
waitVMMonitorDone(prevDone)
}
if vmstart.ReadVMDisplay(detail.Directory).TargetDisplay != "" {
if needsDisplayPosition {
go func() {
defer displayWG.Done()
positionCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
ticker := time.NewTicker(250 * time.Millisecond)
@@ -129,6 +135,7 @@ func (a *App) startVMMonitor(name string, detail driver.VMInfo, startAt time.Tim
go func() {
defer func() {
cancel()
displayWG.Wait()
vmMonitors.mu.Lock()
close(done)
if cur, ok := vmMonitors.entries[name]; ok && cur.id == myID {
+1 -1
View File
@@ -28,7 +28,7 @@ func TestProductCodeHasNoUncalledFunctions(t *testing.T) {
self := ""
if fn != nil {
self = s.dir() + "." + fn.Name.Name
checked := strings.HasPrefix(s.rel, "internal/") && !strings.HasPrefix(s.rel, "internal/testutil/") || strings.HasPrefix(s.rel, "cmd/")
checked := strings.HasPrefix(s.rel, "internal/") && !strings.HasPrefix(s.rel, "internal/testutil/") || strings.HasPrefix(s.rel, "scripts/i18ngen/")
entry := fn.Name.Name == "main" || fn.Name.Name == "init" || fn.Name.Name == "_"
if checked && !entry && (fn.Recv == nil || !fn.Name.IsExported()) {
decls[self] = decl{s, fn}
+6
View File
@@ -0,0 +1,6 @@
//go:build !windows
package cli
// AttachConsole is only needed for Windows GUI-subsystem builds.
func AttachConsole() {}
@@ -1,6 +1,6 @@
//go:build windows
package main
package cli
import (
"os"
@@ -14,12 +14,12 @@ var (
const attachParentProcess = ^uintptr(0) // ATTACH_PARENT_PROCESS, (DWORD)-1
// attachConsole gives command-line mode somewhere to write. reims-go.exe is
// AttachConsole gives command-line mode somewhere to write. reims-go.exe is
// a GUI-subsystem program, so Windows starts it without a console. Handles
// the caller passed in (a pipe, a file: how agents and scripts run it) are
// kept; only missing ones are pointed at the console of the terminal that
// launched it.
func attachConsole() {
func AttachConsole() {
out, errOut, in := usable(os.Stdout), usable(os.Stderr), usable(os.Stdin)
if out && errOut && in {
return
+1 -1
View File
@@ -1,4 +1,4 @@
// Code generated by cmd/i18ngen; DO NOT EDIT.
// Code generated by scripts/i18ngen; DO NOT EDIT.
package i18n
+1 -1
View File
@@ -337,7 +337,7 @@ func maxf(a, b float64) float64 {
return b
}
// resizePNGIcon scales an embedded PNG (e.g. assets/logo.png) to size×size PNG
// resizePNGIcon scales an embedded PNG (e.g. build/assets/logo.png) to size×size PNG
// bytes suitable for Windows CreateIconFromResourceEx.
func resizePNGIcon(srcPNG []byte, size int) ([]byte, error) {
if len(srcPNG) == 0 || size <= 0 {
+2 -2
View File
@@ -23,7 +23,7 @@ import (
//go:embed all:frontend/dist
var assets embed.FS
//go:embed assets/logo.png
//go:embed build/assets/logo.png
var trayIconPNG []byte
//go:embed LICENSE
@@ -45,7 +45,7 @@ func main() {
return
}
if cli.IsCommand(args) {
attachConsole()
cli.AttachConsole()
os.Exit(cli.Main(args))
}
launch, _ := cli.ParseWindowArgs(args)
+5 -5
View File
@@ -10,11 +10,11 @@ It writes .github/readme/banner-{light,dark}.svg,
frontend/src/components/wordmark.gen.ts and frontend/public/logo.svg, and
needs only the standard library.
assets/logo.svg is the source of the icon: this script copies it to
build/assets/logo.svg is the source of the icon: this script copies it to
frontend/public/logo.svg and embeds it in the banners. The raster icons
assets/logo.png (embedded by main.go for the tray), build/appicon.png and
build/assets/logo.png (embedded by main.go for the tray), build/appicon.png and
build/windows/icon.ico are exported from the same artwork by hand, so
re-export them whenever assets/logo.svg changes.
re-export them whenever build/assets/logo.svg changes.
"""
import math
@@ -163,7 +163,7 @@ def wordmark(theme, style=STYLE, gid="wm"):
def banner(theme, style=STYLE):
logo = (ROOT / "assets/logo.svg").read_text(encoding="utf-8")
logo = (ROOT / "build/assets/logo.svg").read_text(encoding="utf-8")
icon_body = re.sub(r"^.*?<svg[^>]*>", "", logo, flags=re.S).rsplit("</svg>", 1)[0]
wm = wordmark(theme, style)
icon, gap = 180, 26
@@ -235,7 +235,7 @@ def main():
(ROOT / f".github/readme/banner-{theme}.svg").write_text(banner(theme), encoding="utf-8")
(ROOT / "frontend/src/components/wordmark.gen.ts").write_text(ts_module(), encoding="utf-8")
# The frontend serves the icon from public/, so keep that copy byte-identical.
(ROOT / "frontend/public/logo.svg").write_bytes((ROOT / "assets/logo.svg").read_bytes())
(ROOT / "frontend/public/logo.svg").write_bytes((ROOT / "build/assets/logo.svg").read_bytes())
if __name__ == "__main__":
+3 -3
View File
@@ -6,7 +6,7 @@ import { cachePath, REPO_ROOT, resolveStorageRoot } from './debug/paths.mjs'
import { createTemporaryFiles } from './debug/temporary-files.mjs'
const changelog = path.join(REPO_ROOT, 'CHANGELOG.md')
const changes = path.join(REPO_ROOT, 'changes')
const changes = path.join(REPO_ROOT, '.github', 'changes')
const versionPart = '(?:0|[1-9]\\d*)'
const tagPattern = `v${versionPart}\\.${versionPart}\\.${versionPart}`
const versionHeading = new RegExp(`^## (${tagPattern}) — (\\d{4}-\\d{2}-\\d{2})$`, 'm')
@@ -60,7 +60,7 @@ function readChanges() {
throw error
}
const fragments = files.map((file) => {
const label = `changes/${file.name}`
const label = `.github/changes/${file.name}`
if (!file.isFile() || !/^[a-z0-9]+(?:-[a-z0-9]+)*\.json$/.test(file.name)) {
throw new Error(`${label} must be a regular <slug>.json file`)
}
@@ -194,7 +194,7 @@ function prepare(tag, date, storage) {
}
for (const { name, raw } of fragments) {
const file = path.join(changes, name)
if (fs.readFileSync(file, 'utf8') !== raw) throw new Error(`changes/${name} was edited during preparation`)
if (fs.readFileSync(file, 'utf8') !== raw) throw new Error(`.github/changes/${name} was edited during preparation`)
fs.unlinkSync(file)
}
console.log(`changelog: ${tag} prepared, cleared ${fragments.length} fragment(s)`)
+1 -1
View File
@@ -113,7 +113,7 @@ test("effective diff statistics exclude generated files and locks before determi
"999\t999\tgo.sum",
"999\t999\tfrontend/package-lock.json",
"999\t999\tfrontend/pnpm-lock.yaml",
"-\t-\tassets/logo.png",
"-\t-\tbuild/assets/logo.png",
].join("\0") + "\0");
assert.deepEqual(stats, { files: 2, lines: 15 });
assert.deepEqual(reviewProfile({ files: 5, lines: 300 }), { tier: "small", effort: "low", concurrency: 4, maxTokensBudget: 400_000 });
@@ -213,7 +213,7 @@ func writeGoCatalog(root string, zhByDom, enByDom map[string]map[string]parsedEn
keys := sortedKeys(zhMerged)
var b bytes.Buffer
b.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n\npackage i18n\n\n")
b.WriteString("// Code generated by scripts/i18ngen; DO NOT EDIT.\n\npackage i18n\n\n")
b.WriteString("var catalog = map[Locale]map[string]string{\n")
b.WriteString("\tZhCN: {\n")
for _, k := range keys {
@@ -281,7 +281,7 @@ func writeFrontendCatalogs(root string, zhByDom, enByDom map[string]map[string]p
}
var b bytes.Buffer
b.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n")
b.WriteString("// Code generated by scripts/i18ngen; DO NOT EDIT.\n")
if isLazy {
b.WriteString("import { registerBuiltinDomain } from '../runtime'\n\n")
} else {
@@ -308,7 +308,7 @@ func writeFrontendCatalogs(root string, zhByDom, enByDom map[string]map[string]p
sort.Strings(allFEKeys)
var kb bytes.Buffer
kb.WriteString("// Code generated by cmd/i18ngen; DO NOT EDIT.\n\n")
kb.WriteString("// Code generated by scripts/i18ngen; DO NOT EDIT.\n\n")
kb.WriteString("export type I18nKey =\n")
for i, k := range allFEKeys {
sep := ""
+1 -1
View File
@@ -7,7 +7,7 @@ import { cachePath, REPO_ROOT, resolveStorageRoot } from './debug/paths.mjs'
import { createTemporaryFiles } from './debug/temporary-files.mjs'
const frontend = path.join(REPO_ROOT, 'frontend')
const goTrees = ['./cmd/...', './internal/...', './pkg/...', './scripts/...']
const goTrees = ['./internal/...', './pkg/...', './scripts/...']
const ciTests = fs.readdirSync(path.join(REPO_ROOT, 'scripts', 'ci'))
.filter((name) => name.endsWith('.test.mjs'))
.sort()