Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c181cc3c50 | ||
|
|
ee45f40888 | ||
|
|
7d02b77d7a | ||
|
|
74242c323a | ||
|
|
7f07999a3b | ||
|
|
2caf459647 | ||
|
|
aac3979373 |
No files matched your search
@@ -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`(纯内部重构无需添加)
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"group": "fixes",
|
||||
"order": 0,
|
||||
"authors": ["yxc0915"],
|
||||
"zh": "修复 ARM macOS 虚拟机从客户端停止时无法触发正常关机的问题。",
|
||||
"en": "Fix Stop for ARM macOS VMs so the guest can shut down normally."
|
||||
}
|
||||
File renamed without changes.
@@ -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 |
@@ -1,6 +0,0 @@
|
||||
//go:build !windows
|
||||
|
||||
package main
|
||||
|
||||
// attachConsole is only needed for Windows GUI-subsystem builds.
|
||||
func attachConsole() {}
|
||||
+2
-2
@@ -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
@@ -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 中完成首启数据目录设置 |
|
||||
|
||||
|
||||
@@ -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,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,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,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,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,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,4 +1,4 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
// Code generated by scripts/i18ngen; DO NOT EDIT.
|
||||
|
||||
export type I18nKey =
|
||||
| "aboutCommunity"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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,4 +1,4 @@
|
||||
// Code generated by cmd/i18ngen; DO NOT EDIT.
|
||||
// Code generated by scripts/i18ngen; DO NOT EDIT.
|
||||
|
||||
package i18n
|
||||
|
||||
|
||||
@@ -822,20 +822,59 @@ func (d *StambhaDriver) Stop(ctx context.Context, name string, force bool, _, _
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
if err := conn.Execute("system_powerdown", nil); err != nil {
|
||||
err = requestStambhaShutdown(ctx, conn)
|
||||
_ = conn.Close()
|
||||
// Stela interprets two power-button pulses within three seconds as a
|
||||
// held hardware button. Keep the VM lock across that interval even
|
||||
// if the caller cancels or QMP cannot confirm delivery.
|
||||
retryAfter := time.Now().Add(4 * time.Second)
|
||||
defer func() { time.Sleep(time.Until(retryAfter)) }()
|
||||
if err != nil {
|
||||
if live, checkErr := stambhaLiveProcess(dir); checkErr == nil && live.PID == 0 {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
wait, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||
wait, cancel := context.WithTimeout(ctx, 90*time.Second)
|
||||
defer cancel()
|
||||
err = host.WaitProcessExit(wait, uint32(proc.PID), "qemu-system-x86_64.exe")
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return fmt.Errorf("macOS is still running. Shut down from the Apple menu or explicitly force stop the VM (%w)", err)
|
||||
return fmt.Errorf("macOS did not finish shutting down. Check the VM for apps that need attention or shut down from the Apple menu (%w)", err)
|
||||
}
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
func requestStambhaShutdown(ctx context.Context, conn qmp.Executor) (err error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
// Stela translates system_powerdown into an SMC power-button pulse.
|
||||
// Send the three modifiers in the same input report before the pulse.
|
||||
// macOS can then perform an orderly shutdown and prompt to save work.
|
||||
keys := []string{"ctrl", "alt", "meta_l"}
|
||||
defer func() { err = errors.Join(err, qmp.ReleaseInputs(conn, keys, nil)) }()
|
||||
if err := qmp.PressKeys(conn, keys...); err != nil {
|
||||
return err
|
||||
}
|
||||
timer := time.NewTimer(650 * time.Millisecond)
|
||||
defer timer.Stop()
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-timer.C:
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := conn.Execute("system_powerdown", nil); err != nil {
|
||||
return err
|
||||
}
|
||||
// Keep the modifiers down while Stela and the guest handle the pulse.
|
||||
time.Sleep(1500 * time.Millisecond)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *StambhaDriver) Delete(_ context.Context, name string, keepFiles bool, _, _ io.Writer) error {
|
||||
return d.withVM(name, func(dir string, proc stambhaProcess) error {
|
||||
if proc.PID != 0 {
|
||||
|
||||
@@ -495,3 +495,45 @@ func assertEnvVal(t *testing.T, env []string, key, want string) {
|
||||
t.Fatalf("env %s = %q, want %q (env=%v)", key, got, want, env)
|
||||
}
|
||||
}
|
||||
|
||||
type shutdownRecorder struct {
|
||||
commands []string
|
||||
onHold func()
|
||||
}
|
||||
|
||||
func (r *shutdownRecorder) Execute(command string, args any) error {
|
||||
data, err := json.Marshal(args)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.commands = append(r.commands, command+" "+string(data))
|
||||
if command == "input-send-event" && len(r.commands) == 1 && r.onHold != nil {
|
||||
r.onHold()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestRequestStambhaShutdown(t *testing.T) {
|
||||
const hold = "input-send-event " + `{"events":[{"data":{"down":true,"key":{"data":"ctrl","type":"qcode"}},"type":"key"},{"data":{"down":true,"key":{"data":"alt","type":"qcode"}},"type":"key"},{"data":{"down":true,"key":{"data":"meta_l","type":"qcode"}},"type":"key"}]}`
|
||||
release := strings.ReplaceAll(hold, `"down":true`, `"down":false`)
|
||||
t.Run("holds all modifiers before one power pulse", func(t *testing.T) {
|
||||
qmp := &shutdownRecorder{}
|
||||
if err := requestStambhaShutdown(context.Background(), qmp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if want := []string{hold, "system_powerdown null", release}; !slices.Equal(qmp.commands, want) {
|
||||
t.Fatalf("QMP commands = %v, want %v", qmp.commands, want)
|
||||
}
|
||||
})
|
||||
t.Run("cancellation prevents the power pulse", func(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
qmp := &shutdownRecorder{onHold: cancel}
|
||||
if err := requestStambhaShutdown(ctx, qmp); !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("shutdown error = %v, want context cancellation", err)
|
||||
}
|
||||
if !slices.Equal(qmp.commands, []string{hold, release}) {
|
||||
t.Fatalf("unexpected QMP commands after cancellation: %v", qmp.commands)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -120,6 +120,14 @@ func SendKey(q Executor, key string, down bool) error {
|
||||
return sendKeys(q, down, key)
|
||||
}
|
||||
|
||||
// PressKeys sends one input report containing all the key-down events.
|
||||
func PressKeys(q Executor, keys ...string) error {
|
||||
if q == nil {
|
||||
return errors.New("QMP session is unavailable")
|
||||
}
|
||||
return sendKeys(q, true, keys...)
|
||||
}
|
||||
|
||||
// ReleaseInputs clears held keys and pointer buttons in one QMP input report.
|
||||
func ReleaseInputs(q Executor, keys, buttons []string) error {
|
||||
if q == nil {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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__":
|
||||
|
||||
@@ -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)`)
|
||||
|
||||
@@ -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
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user