Repository navigation
fix(manifest): support DSH 0.2.x — 0.2.0 currently rejects the whole bundle #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rezon-aki
wants to merge
1
commit into
Max-Samson:main
Choose a base branch
from
rezon-aki:fix/dsh-0.2-compat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /** | ||
| * DSH 运行时兼容性门禁——把"假绿"换成真检查。 | ||
| * | ||
| * DSH 启动时会用 dsh-app-boot 的 evaluatePluginCompatibility 判定每个 profile bundle 的 | ||
| * peerDependencies;判为不兼容的 bundle 会被整包跳过,用量面板与全部路由一起消失, | ||
| * 只在 dsh web 的 stderr 留一行。本文件直接调用同一个函数,对着插件自己的 manifest 断言 | ||
| * 声明仍然成立,并且**覆盖各线正式版**(0.2.0 / 0.2.1),而不只是 rc —— "<0.2.0" 那个区间 | ||
| * 正是"rc 通过、正式版被拒",也就是这里要拦住的东西。 | ||
| * | ||
| * 解析不到 DSH 安装时跳过:插件自身的 CI 只装插件,不装 DSH。 | ||
| */ | ||
| import assert from 'node:assert/strict' | ||
| import test from 'node:test' | ||
| import { readFileSync } from 'node:fs' | ||
| import { createRequire } from 'node:module' | ||
| import { dirname, join } from 'node:path' | ||
| import { fileURLToPath, pathToFileURL } from 'node:url' | ||
|
|
||
| const root = dirname(dirname(fileURLToPath(import.meta.url))) | ||
| const manifest = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) | ||
|
|
||
| /** 声明支持的 DSH 运行时版本(含各线正式版)。 */ | ||
| const SUPPORTED = ['0.1.0-rc.6', '0.1.5', '0.1.9', '0.2.0-rc.1', '0.2.0-rc.2', '0.2.0', '0.2.1'] | ||
| /** 明确不支持、必须被拒的版本;要放宽区间就先改这里。 */ | ||
| const REJECTED = ['0.3.0'] | ||
|
|
||
| /** 候选 DSH 安装根(DSH_CHECKOUT 优先,其次本机全局安装)。 */ | ||
| const DSH_ROOTS = [process.env.DSH_CHECKOUT, '/usr/local/lib/node_modules/@deepseek-ai/dsh'].filter(Boolean) | ||
|
|
||
| /** 取真正的判定函数与提供它的 DSH 根;取不到返回 undefined(CI 上正常)。 */ | ||
| async function loadDsh() { | ||
| for (const base of DSH_ROOTS) { | ||
| try { | ||
| const req = createRequire(join(base, 'package.json')) | ||
| const entry = req.resolve('@deepseek-ai/dsh-app-boot') | ||
| return { root: base, module: await import(pathToFileURL(entry).href) } | ||
| } catch { | ||
| // 换下一个候选 | ||
| } | ||
| } | ||
| return undefined | ||
| } | ||
|
|
||
| const dsh = await loadDsh() | ||
| const skip = dsh === undefined ? 'DSH is not installed in this environment' : false | ||
|
|
||
| test('peerDependencies accept every supported DSH runtime', { skip }, () => { | ||
| for (const version of SUPPORTED) { | ||
| const issue = dsh.module.evaluatePluginCompatibility(manifest, {}, version) | ||
| assert.equal(issue, undefined, `dsh ${version} rejects ${JSON.stringify(issue?.peers ?? {})}`) | ||
| } | ||
| }) | ||
|
|
||
| test('peerDependencies still reject runtimes outside the declared lines', { skip }, () => { | ||
| for (const version of REJECTED) { | ||
| const issue = dsh.module.evaluatePluginCompatibility(manifest, {}, version) | ||
| assert.notEqual(issue, undefined, `dsh ${version} is accepted but the plugin declares no support for it`) | ||
| } | ||
| }) | ||
|
|
||
| test('every DSH package the manifest names is installed in the target DSH', { skip }, () => { | ||
| const named = [...Object.keys(manifest.peerDependencies ?? {}), ...(manifest.dsh?.client?.inject ?? [])] | ||
| const req = createRequire(join(dsh.root, 'package.json')) | ||
| const missing = [...new Set(named)].filter((name) => { | ||
| if (name !== '@deepseek-ai/dsh' && !name.startsWith('@deepseek-ai/dsh-')) return false | ||
| for (const specifier of [`${name}/package.json`, name]) { | ||
| try { | ||
| req.resolve(specifier) | ||
| return false | ||
| } catch { | ||
| // 试下一个 specifier | ||
| } | ||
| } | ||
| return true | ||
| }) | ||
| assert.deepEqual(missing, [], `declared but absent from DSH ${dsh.module.getDshRuntimeVersion()}`) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Ensure the compatibility regression is actually exercised in CI
The current CI workflow installs only this plugin and supplies no DSH_CHECKOUT, so all three new compatibility tests always skip. At the same time, manifest.test.mjs removes the existing literal-range assertion. Reintroducing the old '<0.2.0' upper bound would therefore still produce a green standard CI run. Locally, npm run verify reports 46 passed / 3 skipped; explicitly setting DSH_CHECKOUT to a nonexistent directory also silently skips because loadDsh catches every resolution/import failure.
Please keep an unconditional range-semantics regression test or wire a pinned DSH installation into CI so these checks run. When DSH_CHECKOUT is explicitly supplied, a broken checkout/import should fail the test instead of being treated as an absent optional environment.