@dsh-workbench/shared 1.5.2-alpha.2 → 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.
- package/dist/host/adapters/adapter-set.d.ts +1 -1
- package/dist/host/adapters/adapter-set.js +1 -0
- package/dist/host/adapters/port-types.d.ts +8 -0
- package/dist/host/adapters/supply-port.js +1 -0
- package/dist/host/runtime/dsh-compat.d.ts +1 -1
- package/dist/host/runtime/dsh-compat.js +4 -1
- package/dist/host/supply/release-probe.d.ts +9 -0
- package/dist/host/supply/release-probe.js +20 -0
- package/dist/testing/fake-adapter-set.js +2 -0
- package/package.json +1 -1
- package/src/host/adapters/__tests__/adapter-set.test.ts +1 -0
- package/src/host/adapters/adapter-set.ts +1 -0
- package/src/host/adapters/port-types.ts +9 -0
- package/src/host/adapters/supply-port.ts +1 -0
- package/src/host/runtime/__tests__/dsh-compat.test.ts +10 -2
- package/src/host/runtime/dsh-compat.ts +4 -2
- package/src/host/supply/__tests__/release-probe.test.ts +23 -0
- package/src/host/supply/release-probe.ts +39 -0
- package/src/testing/fake-adapter-set.ts +2 -0
|
@@ -15,7 +15,7 @@ export type AdapterSetLoad = {
|
|
|
15
15
|
readonly detail: string;
|
|
16
16
|
readonly cause?: unknown;
|
|
17
17
|
};
|
|
18
|
-
export declare const CORE_METHODS: readonly [readonly ["data", "read"], readonly ["data", "request"], readonly ["data", "requestMany"], readonly ["data", "submit"], readonly ["data", "plan"], readonly ["data", "submitPlan"], readonly ["supply", "resolvePluginSource"], readonly ["supply", "libInstallCommand"], readonly ["supply", "libUninstallCommand"], readonly ["supply", "pluginInstallPlan"], readonly ["supply", "recoveryCommand"], readonly ["supply", "latestVersion"], readonly ["supply", "missingReleaseParts"], readonly ["supply", "probeRelease"], readonly ["supply", "splitNpmSpec"], readonly ["profile", "dirOf"], readonly ["profile", "dshPlugins"], readonly ["profile", "selfUpdateView"], readonly ["probe", "probeUnits"], readonly ["probe", "registerPreflight"], readonly ["probe", "declaredPluginCommands"]];
|
|
18
|
+
export declare const CORE_METHODS: readonly [readonly ["data", "read"], readonly ["data", "request"], readonly ["data", "requestMany"], readonly ["data", "submit"], readonly ["data", "plan"], readonly ["data", "submitPlan"], readonly ["supply", "resolvePluginSource"], readonly ["supply", "libInstallCommand"], readonly ["supply", "libUninstallCommand"], readonly ["supply", "pluginInstallPlan"], readonly ["supply", "recoveryCommand"], readonly ["supply", "latestVersion"], readonly ["supply", "missingReleaseParts"], readonly ["supply", "probeRelease"], readonly ["supply", "versionManifestOf"], readonly ["supply", "splitNpmSpec"], readonly ["profile", "dirOf"], readonly ["profile", "dshPlugins"], readonly ["profile", "selfUpdateView"], readonly ["probe", "probeUnits"], readonly ["probe", "registerPreflight"], readonly ["probe", "declaredPluginCommands"]];
|
|
19
19
|
export declare function validateAdapterSet(value: unknown, spec: string): AdapterSetLoad;
|
|
20
20
|
export declare function loadAdapterSet(ctx: DshHostContext, spec: string | undefined): Promise<AdapterSetLoad>;
|
|
21
21
|
export declare function withDefaultAdapterSet(defaults: AdapterSet, loaded: AdapterSetLoad): AdapterSet;
|
|
@@ -55,6 +55,13 @@ export interface SupplyMissingPartsOptions {
|
|
|
55
55
|
readonly version: string;
|
|
56
56
|
readonly force?: boolean;
|
|
57
57
|
}
|
|
58
|
+
export interface SupplyVersionManifestOptions {
|
|
59
|
+
readonly seam: Seam;
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly version: string;
|
|
62
|
+
readonly registry: string;
|
|
63
|
+
readonly force?: boolean;
|
|
64
|
+
}
|
|
58
65
|
export interface SupplyProbeReleaseOptions {
|
|
59
66
|
readonly seam: Seam;
|
|
60
67
|
readonly package: string;
|
|
@@ -83,6 +90,7 @@ export interface EnvSupplyPort {
|
|
|
83
90
|
latestVersion(options: SupplyLatestOptions): Promise<string | undefined>;
|
|
84
91
|
missingReleaseParts(options: SupplyMissingPartsOptions): Promise<readonly string[]>;
|
|
85
92
|
probeRelease(options: SupplyProbeReleaseOptions): Promise<SupplyRelease | undefined>;
|
|
93
|
+
versionManifestOf(options: SupplyVersionManifestOptions): Promise<Readonly<Record<string, unknown>> | undefined>;
|
|
86
94
|
splitNpmSpec(spec: string): SupplyNpmRef | undefined;
|
|
87
95
|
}
|
|
88
96
|
export interface ModulePort {
|
|
@@ -21,6 +21,7 @@ export function supplyPortOf(ctx) {
|
|
|
21
21
|
latestVersion: (options) => env.latestVersion(options),
|
|
22
22
|
missingReleaseParts: (options) => env.missingReleaseParts(options),
|
|
23
23
|
probeRelease: (options) => env.probeRelease(options),
|
|
24
|
+
versionManifestOf: (options) => env.versionManifestOf(options),
|
|
24
25
|
splitNpmSpec: (spec) => env.splitNpmSpec(spec),
|
|
25
26
|
isolatedRoot: () => modules.isolatedRoot(),
|
|
26
27
|
isolatedHome: () => modules.isolatedHome(),
|
|
@@ -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;
|
|
@@ -6,6 +6,7 @@ export interface ReleaseProbe {
|
|
|
6
6
|
latestVersion(options: LatestVersionOptions): Promise<string | undefined>;
|
|
7
7
|
missingReleaseParts(options: MissingPartsOptions): Promise<readonly string[]>;
|
|
8
8
|
probeRelease(options: ProbeReleaseOptions): Promise<PluginRelease | undefined>;
|
|
9
|
+
versionManifestOf(options: VersionManifestOptions): Promise<Readonly<Record<string, unknown>> | undefined>;
|
|
9
10
|
reset(): void;
|
|
10
11
|
}
|
|
11
12
|
export declare function createReleaseProbe(input?: {
|
|
@@ -19,6 +20,14 @@ interface LatestVersionOptions {
|
|
|
19
20
|
readonly prereleaseChannels?: readonly string[];
|
|
20
21
|
readonly cacheDir?: string | undefined;
|
|
21
22
|
}
|
|
23
|
+
interface VersionManifestOptions {
|
|
24
|
+
readonly seam: Seam;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly version: string;
|
|
27
|
+
readonly registry: string;
|
|
28
|
+
readonly force?: boolean;
|
|
29
|
+
readonly cacheDir?: string | undefined;
|
|
30
|
+
}
|
|
22
31
|
interface MissingPartsOptions {
|
|
23
32
|
readonly seam: Seam;
|
|
24
33
|
readonly name: string;
|
|
@@ -65,15 +65,18 @@ function versionCacheTtl(value) {
|
|
|
65
65
|
export function createReleaseProbe(input = {}) {
|
|
66
66
|
const latestCache = new Map();
|
|
67
67
|
const existsCache = new Map();
|
|
68
|
+
const manifestCache = new Map();
|
|
68
69
|
const head = input.head ?? defaultHead;
|
|
69
70
|
const ready = (call) => versionExists(existsCache, { ...call, head });
|
|
70
71
|
return {
|
|
71
72
|
latestVersion: async (options) => latestVersionOf(latestCache, ready, options),
|
|
72
73
|
missingReleaseParts: async (options) => missingPartsOf(ready, options),
|
|
73
74
|
probeRelease: async (options) => probeOf(latestCache, ready, options),
|
|
75
|
+
versionManifestOf: async (options) => manifestOfVersion(manifestCache, options),
|
|
74
76
|
reset: () => {
|
|
75
77
|
latestCache.clear();
|
|
76
78
|
existsCache.clear();
|
|
79
|
+
manifestCache.clear();
|
|
77
80
|
},
|
|
78
81
|
};
|
|
79
82
|
}
|
|
@@ -152,6 +155,23 @@ async function versionExists(existsCache, options) {
|
|
|
152
155
|
existsCache.set(key, entry);
|
|
153
156
|
return entry;
|
|
154
157
|
}
|
|
158
|
+
async function manifestOfVersion(cache, options) {
|
|
159
|
+
const { seam, name, version, registry, force = false, cacheDir } = options;
|
|
160
|
+
const key = `${registry}|${name}@${version}`;
|
|
161
|
+
const hit = cache.get(key);
|
|
162
|
+
const ttl = hit?.value === undefined ? VERSION_CHECK_FAILURE_TTL_MS : VERSION_CHECK_TTL_MS;
|
|
163
|
+
if (!force && hit !== undefined && now() - hit.at < ttl)
|
|
164
|
+
return hit.value;
|
|
165
|
+
const pnpm = process.env.DSH_WB_PNPM?.trim() ?? '';
|
|
166
|
+
const spec = `${quoteShellArg(`${name}@${version}`)} engines peerDependencies name --json --registry ${quoteShellArg(registry)}${cacheFlag(cacheDir)}`;
|
|
167
|
+
const found = await viewOnce(seam, [`npm view ${spec}`, `${pnpm === '' ? 'pnpm' : pnpm} view ${spec}`]);
|
|
168
|
+
const parsed = found.ok ? parseJsonLoose(found.stdout) : undefined;
|
|
169
|
+
const value = typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
|
|
170
|
+
? parsed
|
|
171
|
+
: undefined;
|
|
172
|
+
cache.set(key, { at: now(), value });
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
155
175
|
async function missingPartsOf(ready, options) {
|
|
156
176
|
const { seam, name, registry, version, force = false, cacheDir } = options;
|
|
157
177
|
const checked = await Promise.all(RELEASE_PACKAGES.filter((part) => part !== name).map(async (part) => ({
|
|
@@ -42,6 +42,7 @@ const supply = {
|
|
|
42
42
|
latestVersion: async () => undefined,
|
|
43
43
|
missingReleaseParts: async () => [],
|
|
44
44
|
probeRelease: async () => undefined,
|
|
45
|
+
versionManifestOf: async () => undefined,
|
|
45
46
|
splitNpmSpec: () => undefined,
|
|
46
47
|
};
|
|
47
48
|
const modules = {
|
|
@@ -130,6 +131,7 @@ export function fakeAdapterSet(overrides = {}) {
|
|
|
130
131
|
latestVersion: release.latestVersion,
|
|
131
132
|
missingReleaseParts: release.missingReleaseParts,
|
|
132
133
|
probeRelease: release.probeRelease,
|
|
134
|
+
versionManifestOf: release.versionManifestOf,
|
|
133
135
|
};
|
|
134
136
|
return {
|
|
135
137
|
apiVersion: ADAPTER_SET_API_VERSION,
|
package/package.json
CHANGED
|
@@ -75,6 +75,14 @@ export interface SupplyMissingPartsOptions {
|
|
|
75
75
|
readonly force?: boolean;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export interface SupplyVersionManifestOptions {
|
|
79
|
+
readonly seam: Seam;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly version: string;
|
|
82
|
+
readonly registry: string;
|
|
83
|
+
readonly force?: boolean;
|
|
84
|
+
}
|
|
85
|
+
|
|
78
86
|
export interface SupplyProbeReleaseOptions {
|
|
79
87
|
readonly seam: Seam;
|
|
80
88
|
readonly package: string;
|
|
@@ -101,6 +109,7 @@ export interface EnvSupplyPort {
|
|
|
101
109
|
latestVersion(options: SupplyLatestOptions): Promise<string | undefined>;
|
|
102
110
|
missingReleaseParts(options: SupplyMissingPartsOptions): Promise<readonly string[]>;
|
|
103
111
|
probeRelease(options: SupplyProbeReleaseOptions): Promise<SupplyRelease | undefined>;
|
|
112
|
+
versionManifestOf(options: SupplyVersionManifestOptions): Promise<Readonly<Record<string, unknown>> | undefined>;
|
|
104
113
|
splitNpmSpec(spec: string): SupplyNpmRef | undefined;
|
|
105
114
|
}
|
|
106
115
|
|
|
@@ -26,6 +26,7 @@ export function supplyPortOf(ctx: DshHostContext): SupplyPort {
|
|
|
26
26
|
latestVersion: (options) => env.latestVersion(options),
|
|
27
27
|
missingReleaseParts: (options) => env.missingReleaseParts(options),
|
|
28
28
|
probeRelease: (options) => env.probeRelease(options),
|
|
29
|
+
versionManifestOf: (options) => env.versionManifestOf(options),
|
|
29
30
|
splitNpmSpec: (spec) => env.splitNpmSpec(spec),
|
|
30
31
|
isolatedRoot: () => modules.isolatedRoot(),
|
|
31
32
|
isolatedHome: () => modules.isolatedHome(),
|
|
@@ -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;
|
|
@@ -60,6 +60,29 @@ afterEach(() => {
|
|
|
60
60
|
vi.useRealTimers();
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
describe('某一版的 engines / peers 自己问:市场据此判兼容', () => {
|
|
64
|
+
it('★ 解析成清单字段;同一版第二次直接走缓存', async () => {
|
|
65
|
+
const { probe, seam, fake } = harness((call) =>
|
|
66
|
+
String(call.command).includes('engines')
|
|
67
|
+
? { stdout: JSON.stringify({ name: 'p', version: '1.2.3', engines: { dsh: '>=0.2.3' } }) }
|
|
68
|
+
: {},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const manifest = await probe.versionManifestOf({ seam, name: 'p', version: '1.2.3', registry: REGISTRY });
|
|
72
|
+
expect(manifest).toEqual({ name: 'p', version: '1.2.3', engines: { dsh: '>=0.2.3' } });
|
|
73
|
+
|
|
74
|
+
const again = await probe.versionManifestOf({ seam, name: 'p', version: '1.2.3', registry: REGISTRY });
|
|
75
|
+
expect(again).toEqual(manifest);
|
|
76
|
+
expect(fake.calls.filter((call) => String(call.command).includes('engines'))).toHaveLength(1);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('★ 问不到就是 undefined(调用方据此给「未验证」,不假装兼容)', async () => {
|
|
80
|
+
const { probe, seam } = harness(() => ({}));
|
|
81
|
+
|
|
82
|
+
expect(await probe.versionManifestOf({ seam, name: 'q', version: '9.9.9', registry: REGISTRY })).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
63
86
|
describe('查新版那一次网络请求', () => {
|
|
64
87
|
it('★ 按 registry 问一次、拿网络那档超时,不是本地账本那档', async () => {
|
|
65
88
|
const { fake, probe, seam } = harness([{ stdout: '1.1.5\n' }]);
|
|
@@ -90,12 +90,14 @@ export interface ReleaseProbe {
|
|
|
90
90
|
latestVersion(options: LatestVersionOptions): Promise<string | undefined>;
|
|
91
91
|
missingReleaseParts(options: MissingPartsOptions): Promise<readonly string[]>;
|
|
92
92
|
probeRelease(options: ProbeReleaseOptions): Promise<PluginRelease | undefined>;
|
|
93
|
+
versionManifestOf(options: VersionManifestOptions): Promise<Readonly<Record<string, unknown>> | undefined>;
|
|
93
94
|
reset(): void;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
export function createReleaseProbe(input: { readonly head?: TarballHead | undefined } = {}): ReleaseProbe {
|
|
97
98
|
const latestCache = new Map<string, CacheEntry>();
|
|
98
99
|
const existsCache = new Map<string, ExistsEntry>();
|
|
100
|
+
const manifestCache = new Map<string, ManifestEntry>();
|
|
99
101
|
const head = input.head ?? defaultHead;
|
|
100
102
|
const ready = (call: { seam: Seam; name: string; version: string; registry: string; force: boolean; cacheDir?: string | undefined }) =>
|
|
101
103
|
versionExists(existsCache, { ...call, head });
|
|
@@ -104,9 +106,11 @@ export function createReleaseProbe(input: { readonly head?: TarballHead | undefi
|
|
|
104
106
|
latestVersion: async (options) => latestVersionOf(latestCache, ready, options),
|
|
105
107
|
missingReleaseParts: async (options) => missingPartsOf(ready, options),
|
|
106
108
|
probeRelease: async (options) => probeOf(latestCache, ready, options),
|
|
109
|
+
versionManifestOf: async (options) => manifestOfVersion(manifestCache, options),
|
|
107
110
|
reset: () => {
|
|
108
111
|
latestCache.clear();
|
|
109
112
|
existsCache.clear();
|
|
113
|
+
manifestCache.clear();
|
|
110
114
|
},
|
|
111
115
|
};
|
|
112
116
|
}
|
|
@@ -120,6 +124,20 @@ interface LatestVersionOptions {
|
|
|
120
124
|
readonly cacheDir?: string | undefined;
|
|
121
125
|
}
|
|
122
126
|
|
|
127
|
+
interface VersionManifestOptions {
|
|
128
|
+
readonly seam: Seam;
|
|
129
|
+
readonly name: string;
|
|
130
|
+
readonly version: string;
|
|
131
|
+
readonly registry: string;
|
|
132
|
+
readonly force?: boolean;
|
|
133
|
+
readonly cacheDir?: string | undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface ManifestEntry {
|
|
137
|
+
readonly at: number;
|
|
138
|
+
readonly value: Readonly<Record<string, unknown>> | undefined;
|
|
139
|
+
}
|
|
140
|
+
|
|
123
141
|
interface MissingPartsOptions {
|
|
124
142
|
readonly seam: Seam;
|
|
125
143
|
readonly name: string;
|
|
@@ -267,6 +285,27 @@ async function versionExists(
|
|
|
267
285
|
return entry;
|
|
268
286
|
}
|
|
269
287
|
|
|
288
|
+
async function manifestOfVersion(
|
|
289
|
+
cache: Map<string, ManifestEntry>,
|
|
290
|
+
options: VersionManifestOptions,
|
|
291
|
+
): Promise<Readonly<Record<string, unknown>> | undefined> {
|
|
292
|
+
const { seam, name, version, registry, force = false, cacheDir } = options;
|
|
293
|
+
const key = `${registry}|${name}@${version}`;
|
|
294
|
+
const hit = cache.get(key);
|
|
295
|
+
const ttl = hit?.value === undefined ? VERSION_CHECK_FAILURE_TTL_MS : VERSION_CHECK_TTL_MS;
|
|
296
|
+
if (!force && hit !== undefined && now() - hit.at < ttl) return hit.value;
|
|
297
|
+
const pnpm = process.env.DSH_WB_PNPM?.trim() ?? '';
|
|
298
|
+
const spec = `${quoteShellArg(`${name}@${version}`)} engines peerDependencies name --json --registry ${quoteShellArg(registry)}${cacheFlag(cacheDir)}`;
|
|
299
|
+
const found = await viewOnce(seam, [`npm view ${spec}`, `${pnpm === '' ? 'pnpm' : pnpm} view ${spec}`]);
|
|
300
|
+
const parsed = found.ok ? parseJsonLoose(found.stdout) : undefined;
|
|
301
|
+
const value =
|
|
302
|
+
typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
|
|
303
|
+
? (parsed as Readonly<Record<string, unknown>>)
|
|
304
|
+
: undefined;
|
|
305
|
+
cache.set(key, { at: now(), value });
|
|
306
|
+
return value;
|
|
307
|
+
}
|
|
308
|
+
|
|
270
309
|
async function missingPartsOf(
|
|
271
310
|
ready: ReadyOf,
|
|
272
311
|
options: {
|
|
@@ -66,6 +66,7 @@ const supply: EnvSupplyPort = {
|
|
|
66
66
|
latestVersion: async () => undefined,
|
|
67
67
|
missingReleaseParts: async () => [],
|
|
68
68
|
probeRelease: async () => undefined,
|
|
69
|
+
versionManifestOf: async () => undefined,
|
|
69
70
|
splitNpmSpec: () => undefined,
|
|
70
71
|
};
|
|
71
72
|
|
|
@@ -161,6 +162,7 @@ export function fakeAdapterSet(overrides: Partial<AdapterSet> = {}): AdapterSet
|
|
|
161
162
|
latestVersion: release.latestVersion,
|
|
162
163
|
missingReleaseParts: release.missingReleaseParts,
|
|
163
164
|
probeRelease: release.probeRelease,
|
|
165
|
+
versionManifestOf: release.versionManifestOf,
|
|
164
166
|
};
|
|
165
167
|
return {
|
|
166
168
|
apiVersion: ADAPTER_SET_API_VERSION,
|