Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/scripts/use-runner-pnpm-for-dimina-fe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env node

// dimina/fe 是 submodule 里的一个独立 pnpm workspace,它的 package.json 声明
// packageManager: pnpm@12.2.0,和本仓根声明的版本不是同一个。pnpm 一进这个目录
// 就会去下载并切换到它声明的那个版本,而 runner 上这次切换会 exec 下载包里的
// pnpm.exe——Windows 二进制——于是 Linux 和 macOS 上直接以
// `Syntax error: ")" unexpected` 退出 2。Install dimina/fe deps 和随后的
// build:container 都断在这里。
//
// pnpm 12 已经没有能关掉版本自管的配置项了:--config.manage-package-manager-versions、
// npm_config_* 环境变量、--pm-on-fail 都不阻止切换,唯一的开关得写进那个 workspace
// 自己的 pnpm-workspace.yaml,而那是 submodule 的文件。所以这里在 runner 的工作副本
// 上摘掉这个字段,让 submodule 用 runner 上已经装好的 pnpm。改动不提交,也不进
// submodule。
//
// 两边版本一致(或 submodule 自己去掉了这个字段)时什么都不做,可以重复跑。

import { readFileSync, writeFileSync } from 'node:fs'

const FE_MANIFEST = 'dimina/fe/package.json'

const source = readFileSync(FE_MANIFEST, 'utf8')
const declared = JSON.parse(source).packageManager

if (!declared) {
console.log(`${FE_MANIFEST} 没有声明 packageManager,无需处理`)
process.exit(0)
}

const rootDeclared = JSON.parse(readFileSync('package.json', 'utf8')).packageManager

if (declared === rootDeclared) {
console.log(`dimina/fe 与本仓根都是 ${declared},不会触发版本切换,无需处理`)
process.exit(0)
}

// 只删这一行,其余原样保留:这份 manifest 属于 submodule,不做格式化重写。
const stripped = source.replace(/^[ \t]*"packageManager":[ \t]*"[^"]*",?\r?\n/m, '')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add a behavioral regression test for the manifest rewrite

This repairs a confirmed all-platform release failure with new JSON-rewrite logic, but adds no regression test, while the normal CI path does not execute these release-only steps. A fixture-based test should exercise the mismatched, matching, and missing packageManager cases—and verify the rewritten file remains valid JSON—so formatting or workflow changes cannot silently reintroduce the failure.

AGENTS.md reference: AGENTS.md:L20-L21

Useful? React with 👍 / 👎.


if (stripped === source) {
throw new Error(`在 ${FE_MANIFEST} 里没找到可删除的 packageManager 行`)
}

JSON.parse(stripped)
writeFileSync(FE_MANIFEST, stripped)

console.log(
`已在 runner 的工作副本上移除 dimina/fe 的 packageManager(${declared}),`
+ `改用本仓根的 ${rootDeclared}`,
)
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ jobs:
- name: Install workspace deps
run: pnpm install --frozen-lockfile --prefer-offline

# 必须排在任何进入 dimina/fe 的步骤之前:装依赖和 build:container 都会在那里
# 起 pnpm,而 submodule 声明的 pnpm 版本和本仓根不同时,切换会 exec 到
# pnpm.exe 并让这一步直接退出 2。脚本里写了完整来龙去脉。
- name: Use the runner's pnpm inside dimina/fe
run: node .github/scripts/use-runner-pnpm-for-dimina-fe.js

- name: Install dimina/fe deps
working-directory: dimina/fe
run: pnpm install --no-frozen-lockfile
Expand Down Expand Up @@ -354,6 +360,10 @@ jobs:
- name: Install workspace deps
run: pnpm install --frozen-lockfile --prefer-offline --ignore-scripts

# 同 build-clients:进 dimina/fe 之前先摘掉它声明的 pnpm 版本。
- name: Use the runner's pnpm inside dimina/fe
run: node .github/scripts/use-runner-pnpm-for-dimina-fe.js

- name: Install dimina/fe deps
working-directory: dimina/fe
run: pnpm install --no-frozen-lockfile --ignore-scripts
Expand Down
Loading