@dsh-workbench/shared 1.5.2-alpha.3 → 1.5.2-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,7 +16,7 @@ export type DshCompatibility = {
|
|
|
16
16
|
readonly requirements: readonly DshRequirement[];
|
|
17
17
|
} | {
|
|
18
18
|
readonly verdict: 'unknown';
|
|
19
|
-
readonly reason: 'no-requirement' | 'missing-dsh-version' | 'malformed';
|
|
19
|
+
readonly reason: 'no-requirement' | 'peer-only' | 'missing-dsh-version' | 'malformed';
|
|
20
20
|
readonly requirements: readonly DshRequirement[];
|
|
21
21
|
};
|
|
22
22
|
export declare function dshRequirementsOf(manifest: DshManifestFields): readonly DshRequirement[];
|
|
@@ -23,13 +23,16 @@ export function dshCompatibilityOf(input) {
|
|
|
23
23
|
const requirements = input.requirements;
|
|
24
24
|
if (requirements.length === 0)
|
|
25
25
|
return { verdict: 'unknown', reason: 'no-requirement', requirements };
|
|
26
|
+
const engines = requirements.filter((item) => item.source === 'engines');
|
|
27
|
+
if (engines.length === 0)
|
|
28
|
+
return { verdict: 'unknown', reason: 'peer-only', requirements };
|
|
26
29
|
const version = input.dshVersion?.trim() ?? '';
|
|
27
30
|
if (version === '' || semver.valid(version) === null) {
|
|
28
31
|
return { verdict: 'unknown', reason: 'missing-dsh-version', requirements };
|
|
29
32
|
}
|
|
30
33
|
const unsatisfied = [];
|
|
31
34
|
let malformed = false;
|
|
32
|
-
for (const requirement of
|
|
35
|
+
for (const requirement of engines) {
|
|
33
36
|
const range = semver.validRange(requirement.range);
|
|
34
37
|
if (range === null) {
|
|
35
38
|
malformed = true;
|
package/package.json
CHANGED
|
@@ -46,7 +46,7 @@ describe('dsh 兼容判定:engines 优先,再看 dsh peers', () => {
|
|
|
46
46
|
expect(verdictOf(manifest, '0.2.2').verdict).toBe('compatible');
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
it('没有 engines
|
|
49
|
+
it('没有 engines:peer 只收 dsh 那几个、别的不算;但 peer 不能判兼容', () => {
|
|
50
50
|
const manifest = {
|
|
51
51
|
name: 'x',
|
|
52
52
|
peerDependencies: {
|
|
@@ -56,7 +56,15 @@ describe('dsh 兼容判定:engines 优先,再看 dsh peers', () => {
|
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
58
|
expect(dshRequirementsOf(manifest).map((item) => item.range)).toEqual(['>=0.2.0', '>=0.2.0']);
|
|
59
|
-
expect(verdictOf(manifest, '0.2.2')
|
|
59
|
+
expect(verdictOf(manifest, '0.2.2')).toMatchObject({ verdict: 'unknown', reason: 'peer-only' });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('★ peer 钉的是那个包的版本,不是 dsh 的版本:精确钉旧 rc 也不判不兼容', () => {
|
|
63
|
+
const manifest = {
|
|
64
|
+
name: '@dsh-workbench/shared',
|
|
65
|
+
peerDependencies: { '@deepseek-ai/dsh-client-ui-primitives': '0.2.2-rc.2' },
|
|
66
|
+
};
|
|
67
|
+
expect(verdictOf(manifest, '0.2.2-rc.5')).toMatchObject({ verdict: 'unknown', reason: 'peer-only' });
|
|
60
68
|
});
|
|
61
69
|
|
|
62
70
|
it('拿不到 dsh 版本 / 区间非法 / 没写要求 → 都是未知,不假装兼容', () => {
|
|
@@ -21,7 +21,7 @@ export type DshCompatibility =
|
|
|
21
21
|
| { readonly verdict: 'incompatible'; readonly requirements: readonly DshRequirement[] }
|
|
22
22
|
| {
|
|
23
23
|
readonly verdict: 'unknown';
|
|
24
|
-
readonly reason: 'no-requirement' | 'missing-dsh-version' | 'malformed';
|
|
24
|
+
readonly reason: 'no-requirement' | 'peer-only' | 'missing-dsh-version' | 'malformed';
|
|
25
25
|
readonly requirements: readonly DshRequirement[];
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -48,13 +48,15 @@ export function dshCompatibilityOf(input: {
|
|
|
48
48
|
}): DshCompatibility {
|
|
49
49
|
const requirements = input.requirements;
|
|
50
50
|
if (requirements.length === 0) return { verdict: 'unknown', reason: 'no-requirement', requirements };
|
|
51
|
+
const engines = requirements.filter((item) => item.source === 'engines');
|
|
52
|
+
if (engines.length === 0) return { verdict: 'unknown', reason: 'peer-only', requirements };
|
|
51
53
|
const version = input.dshVersion?.trim() ?? '';
|
|
52
54
|
if (version === '' || semver.valid(version) === null) {
|
|
53
55
|
return { verdict: 'unknown', reason: 'missing-dsh-version', requirements };
|
|
54
56
|
}
|
|
55
57
|
const unsatisfied: DshRequirement[] = [];
|
|
56
58
|
let malformed = false;
|
|
57
|
-
for (const requirement of
|
|
59
|
+
for (const requirement of engines) {
|
|
58
60
|
const range = semver.validRange(requirement.range);
|
|
59
61
|
if (range === null) {
|
|
60
62
|
malformed = true;
|