From aac3979373e28b39b40c50f6a46cf7947520da7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <105714958+Nwflower@users.noreply.github.com> Date: Sat, 5 Dec 2026 21:34:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor:=20=E6=94=B6=E6=95=9B=E6=A0=B9?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=B8=83=E5=B1=80=E5=B9=B6=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=B8=8E=E8=84=9A=E6=9C=AC=E5=BD=92=E5=B1=9E?= =?UTF-8?q?=20(#203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 收敛根目录布局并统一资源与脚本归属 * fix: 停止监视器时等待显示定位协程退出 --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .../changes}/auto-display-resolution.json | 0 .../changes}/dev-release-title-filter.json | 0 .../changes}/market-install-latest.json | 0 .../changes}/recover-moved-vm-registry.json | 0 .../changes}/recover-retained-vulkan-manifest.json | 0 .../changes}/refactor-pipeline-update-perf.json | 0 .../changes}/remove-modifier-key-mapping.json | 0 AGENTS.md | 2 +- {assets => build/assets}/logo.png | Bin {assets => build/assets}/logo.svg | 0 console_other.go | 6 ------ docs/changelog.md | 4 ++-- docs/testing.md | 2 +- frontend/scripts/test-brand.mjs | 6 +++--- frontend/src/i18n/domains/core.gen.ts | 2 +- frontend/src/i18n/domains/plugins.gen.ts | 2 +- frontend/src/i18n/domains/settings.gen.ts | 2 +- frontend/src/i18n/domains/vm.gen.ts | 2 +- frontend/src/i18n/domains/wizard.gen.ts | 2 +- frontend/src/i18n/keys.gen.ts | 2 +- internal/app/vm_monitor.go | 9 ++++++++- internal/archtest/unused_test.go | 2 +- internal/cli/console_other.go | 6 ++++++ .../cli/console_windows.go | 6 +++--- internal/i18n/catalog_gen.go | 2 +- internal/tray/tray.go | 2 +- main.go | 4 ++-- scripts/brand/wordmark.py | 10 +++++----- scripts/changelog.mjs | 6 +++--- scripts/ci/pr-review.test.mjs | 2 +- {cmd => scripts}/i18ngen/main.go | 6 +++--- scripts/test.mjs | 2 +- 33 files changed, 49 insertions(+), 42 deletions(-) rename {changes => .github/changes}/auto-display-resolution.json (100%) rename {changes => .github/changes}/dev-release-title-filter.json (100%) rename {changes => .github/changes}/market-install-latest.json (100%) rename {changes => .github/changes}/recover-moved-vm-registry.json (100%) rename {changes => .github/changes}/recover-retained-vulkan-manifest.json (100%) rename {changes => .github/changes}/refactor-pipeline-update-perf.json (100%) rename {changes => .github/changes}/remove-modifier-key-mapping.json (100%) rename {assets => build/assets}/logo.png (100%) rename {assets => build/assets}/logo.svg (100%) delete mode 100644 console_other.go create mode 100644 internal/cli/console_other.go rename console_windows.go => internal/cli/console_windows.go (93%) rename {cmd => scripts}/i18ngen/main.go (97%) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index c2f1b42..8e1835c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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/.json`(纯内部重构无需添加) +- [ ] 面向用户或集成方的变化已写入 `.github/changes/.json`(纯内部重构无需添加) diff --git a/changes/auto-display-resolution.json b/.github/changes/auto-display-resolution.json similarity index 100% rename from changes/auto-display-resolution.json rename to .github/changes/auto-display-resolution.json diff --git a/changes/dev-release-title-filter.json b/.github/changes/dev-release-title-filter.json similarity index 100% rename from changes/dev-release-title-filter.json rename to .github/changes/dev-release-title-filter.json diff --git a/changes/market-install-latest.json b/.github/changes/market-install-latest.json similarity index 100% rename from changes/market-install-latest.json rename to .github/changes/market-install-latest.json diff --git a/changes/recover-moved-vm-registry.json b/.github/changes/recover-moved-vm-registry.json similarity index 100% rename from changes/recover-moved-vm-registry.json rename to .github/changes/recover-moved-vm-registry.json diff --git a/changes/recover-retained-vulkan-manifest.json b/.github/changes/recover-retained-vulkan-manifest.json similarity index 100% rename from changes/recover-retained-vulkan-manifest.json rename to .github/changes/recover-retained-vulkan-manifest.json diff --git a/changes/refactor-pipeline-update-perf.json b/.github/changes/refactor-pipeline-update-perf.json similarity index 100% rename from changes/refactor-pipeline-update-perf.json rename to .github/changes/refactor-pipeline-update-perf.json diff --git a/changes/remove-modifier-key-mapping.json b/.github/changes/remove-modifier-key-mapping.json similarity index 100% rename from changes/remove-modifier-key-mapping.json rename to .github/changes/remove-modifier-key-mapping.json diff --git a/AGENTS.md b/AGENTS.md index d28c64a..7de0e7f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,7 +48,7 @@ Reims-Go 发布的便携运行时基于团队独立维护的 `reims-go/reims-vgp ## 版本变更与开源合规 -面向用户或集成方的变化随改动写入 `changes/.json`,准备正式版时编入 [`CHANGELOG.md`](CHANGELOG.md),格式与命令见 [`docs/changelog.md`](docs/changelog.md)。 +面向用户或集成方的变化随改动写入 `.github/changes/.json`,准备正式版时编入 [`CHANGELOG.md`](CHANGELOG.md),格式与命令见 [`docs/changelog.md`](docs/changelog.md)。 Reims-Go 自身代码采用 [Apache-2.0](LICENSE) 协议。便携运行时以独立子进程和独立压缩包形式集成,公开运行时发布必须同处附带对应源码包、本地补丁与完整许可证文本(见 [`NOTICE.md`](NOTICE.md))。应用不打包也不托管任何 Apple 系统文件。 diff --git a/assets/logo.png b/build/assets/logo.png similarity index 100% rename from assets/logo.png rename to build/assets/logo.png diff --git a/assets/logo.svg b/build/assets/logo.svg similarity index 100% rename from assets/logo.svg rename to build/assets/logo.svg diff --git a/console_other.go b/console_other.go deleted file mode 100644 index 3fb0717..0000000 --- a/console_other.go +++ /dev/null @@ -1,6 +0,0 @@ -//go:build !windows - -package main - -// attachConsole is only needed for Windows GUI-subsystem builds. -func attachConsole() {} diff --git a/docs/changelog.md b/docs/changelog.md index 8e8ee98..0f77b39 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,10 +1,10 @@ # 更新日志编写与发布 -[`CHANGELOG.md`](../CHANGELOG.md) 保存已编入版本的客户端变更,也是 GitHub Release 说明的正文来源。待发布的条目随改动提交到仓库根目录的 `changes/`。便携运行时 `runtime-*` 在对应的运行时 Release 中记录。客户端条目只在需要时写明它依赖的运行时版本。 +[`CHANGELOG.md`](../CHANGELOG.md) 保存已编入版本的客户端变更,也是 GitHub Release 说明的正文来源。待发布的条目随改动提交到 `.github/changes/`。便携运行时 `runtime-*` 在对应的运行时 Release 中记录。客户端条目只在需要时写明它依赖的运行时版本。 ## 写入待发布条目 -每项值得告知用户或集成方的变化写一个 `changes/.json`,文件名用小写英文和连字符。将同一行为涉及的多个提交合为一条。内部重构、纯格式调整和日常依赖更新留在提交记录中。 +每项值得告知用户或集成方的变化写一个 `.github/changes/.json`,文件名用小写英文和连字符。将同一行为涉及的多个提交合为一条。内部重构、纯格式调整和日常依赖更新留在提交记录中。 ```json { diff --git a/docs/testing.md b/docs/testing.md index 991862c..f1a3dc2 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -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 中完成首启数据目录设置 | diff --git a/frontend/scripts/test-brand.mjs b/frontend/scripts/test-brand.mjs index 67a0bc5..ab95a09 100644 --- a/frontend/scripts/test-brand.mjs +++ b/frontend/scripts/test-brand.mjs @@ -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') }) diff --git a/frontend/src/i18n/domains/core.gen.ts b/frontend/src/i18n/domains/core.gen.ts index f861315..cc6e0d7 100644 --- a/frontend/src/i18n/domains/core.gen.ts +++ b/frontend/src/i18n/domains/core.gen.ts @@ -1,4 +1,4 @@ -// Code generated by cmd/i18ngen; DO NOT EDIT. +// Code generated by scripts/i18ngen; DO NOT EDIT. export const coreZh: Record = { "affinityMenu": "处理器相关性…", diff --git a/frontend/src/i18n/domains/plugins.gen.ts b/frontend/src/i18n/domains/plugins.gen.ts index 274e7c4..017f0a8 100644 --- a/frontend/src/i18n/domains/plugins.gen.ts +++ b/frontend/src/i18n/domains/plugins.gen.ts @@ -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 = { diff --git a/frontend/src/i18n/domains/settings.gen.ts b/frontend/src/i18n/domains/settings.gen.ts index 75e1652..3784225 100644 --- a/frontend/src/i18n/domains/settings.gen.ts +++ b/frontend/src/i18n/domains/settings.gen.ts @@ -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 = { diff --git a/frontend/src/i18n/domains/vm.gen.ts b/frontend/src/i18n/domains/vm.gen.ts index 6061102..04fefd6 100644 --- a/frontend/src/i18n/domains/vm.gen.ts +++ b/frontend/src/i18n/domains/vm.gen.ts @@ -1,4 +1,4 @@ -// Code generated by cmd/i18ngen; DO NOT EDIT. +// Code generated by scripts/i18ngen; DO NOT EDIT. export const vmZh: Record = { "attachGuestTools": "挂载 Guest Tools", diff --git a/frontend/src/i18n/domains/wizard.gen.ts b/frontend/src/i18n/domains/wizard.gen.ts index 38f9fe2..a8516ab 100644 --- a/frontend/src/i18n/domains/wizard.gen.ts +++ b/frontend/src/i18n/domains/wizard.gen.ts @@ -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 = { diff --git a/frontend/src/i18n/keys.gen.ts b/frontend/src/i18n/keys.gen.ts index 6fe552c..2866c02 100644 --- a/frontend/src/i18n/keys.gen.ts +++ b/frontend/src/i18n/keys.gen.ts @@ -1,4 +1,4 @@ -// Code generated by cmd/i18ngen; DO NOT EDIT. +// Code generated by scripts/i18ngen; DO NOT EDIT. export type I18nKey = | "aboutCommunity" diff --git a/internal/app/vm_monitor.go b/internal/app/vm_monitor.go index 010c61f..ba318b9 100644 --- a/internal/app/vm_monitor.go +++ b/internal/app/vm_monitor.go @@ -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 { diff --git a/internal/archtest/unused_test.go b/internal/archtest/unused_test.go index 0e5c966..38dd5a0 100644 --- a/internal/archtest/unused_test.go +++ b/internal/archtest/unused_test.go @@ -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} diff --git a/internal/cli/console_other.go b/internal/cli/console_other.go new file mode 100644 index 0000000..dbfb16f --- /dev/null +++ b/internal/cli/console_other.go @@ -0,0 +1,6 @@ +//go:build !windows + +package cli + +// AttachConsole is only needed for Windows GUI-subsystem builds. +func AttachConsole() {} diff --git a/console_windows.go b/internal/cli/console_windows.go similarity index 93% rename from console_windows.go rename to internal/cli/console_windows.go index a5fe986..c62997f 100644 --- a/console_windows.go +++ b/internal/cli/console_windows.go @@ -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 diff --git a/internal/i18n/catalog_gen.go b/internal/i18n/catalog_gen.go index c08f618..92a092f 100644 --- a/internal/i18n/catalog_gen.go +++ b/internal/i18n/catalog_gen.go @@ -1,4 +1,4 @@ -// Code generated by cmd/i18ngen; DO NOT EDIT. +// Code generated by scripts/i18ngen; DO NOT EDIT. package i18n diff --git a/internal/tray/tray.go b/internal/tray/tray.go index 51b646d..957d4bd 100644 --- a/internal/tray/tray.go +++ b/internal/tray/tray.go @@ -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 { diff --git a/main.go b/main.go index a01e0da..7f90345 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/scripts/brand/wordmark.py b/scripts/brand/wordmark.py index be5739a..0c18ab3 100644 --- a/scripts/brand/wordmark.py +++ b/scripts/brand/wordmark.py @@ -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"^.*?]*>", "", logo, flags=re.S).rsplit("", 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__": diff --git a/scripts/changelog.mjs b/scripts/changelog.mjs index 59a9598..89dffaf 100644 --- a/scripts/changelog.mjs +++ b/scripts/changelog.mjs @@ -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 .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)`) diff --git a/scripts/ci/pr-review.test.mjs b/scripts/ci/pr-review.test.mjs index 66b011e..06bafe3 100644 --- a/scripts/ci/pr-review.test.mjs +++ b/scripts/ci/pr-review.test.mjs @@ -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 }); diff --git a/cmd/i18ngen/main.go b/scripts/i18ngen/main.go similarity index 97% rename from cmd/i18ngen/main.go rename to scripts/i18ngen/main.go index 76c1c9f..e0445a0 100644 --- a/cmd/i18ngen/main.go +++ b/scripts/i18ngen/main.go @@ -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 := "" diff --git a/scripts/test.mjs b/scripts/test.mjs index 9441303..da9187e 100644 --- a/scripts/test.mjs +++ b/scripts/test.mjs @@ -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() -- 2.54.1 From 74242c323ad78bae556db35e99aea10be2484147 Mon Sep 17 00:00:00 2001 From: YXC0915 Date: Sun, 6 Dec 2026 00:39:23 +0800 Subject: [PATCH 2/2] Keep ARM image downloads behind the installer boundary --- internal/app/arm_image.go | 10 +++------- internal/app/installer_coordinator.go | 8 ++++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/app/arm_image.go b/internal/app/arm_image.go index abc5564..2e62d63 100644 --- a/internal/app/arm_image.go +++ b/internal/app/arm_image.go @@ -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 diff --git a/internal/app/installer_coordinator.go b/internal/app/installer_coordinator.go index c476dba..bdbbb67 100644 --- a/internal/app/installer_coordinator.go +++ b/internal/app/installer_coordinator.go @@ -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() -- 2.54.1