mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 12:26:38 -06:00
refactor(matrix): simplify dependency availability check
This commit is contained in:
@@ -173,12 +173,8 @@ describe("ensureMatrixSdkInstalled", () => {
|
||||
throw new Error("Cannot find module");
|
||||
});
|
||||
await expect(ensureMatrixSdkInstalled({ resolveFn })).rejects.toThrow(
|
||||
/matrix-js-sdk.*@matrix-org\/matrix-sdk-crypto-nodejs.*@matrix-org\/matrix-sdk-crypto-wasm/s,
|
||||
/Matrix plugin dependencies are missing: matrix-js-sdk, @matrix-org\/matrix-sdk-crypto-nodejs, @matrix-org\/matrix-sdk-crypto-wasm\. Repair this plugin with `openclaw plugins update matrix` or run `openclaw doctor --fix`\./,
|
||||
);
|
||||
await expect(ensureMatrixSdkInstalled({ resolveFn })).rejects.toThrow(
|
||||
/openclaw plugins update matrix/,
|
||||
);
|
||||
await expect(ensureMatrixSdkInstalled({ resolveFn })).rejects.toThrow(/openclaw doctor --fix/);
|
||||
});
|
||||
|
||||
it("lists only the packages that fail to resolve", async () => {
|
||||
|
||||
@@ -26,19 +26,15 @@ type MatrixCryptoRuntimeDeps = {
|
||||
};
|
||||
|
||||
function resolveMissingMatrixPackages(resolveFn?: (id: string) => string): string[] {
|
||||
try {
|
||||
const resolve = resolveFn ?? defaultResolveFn;
|
||||
return REQUIRED_MATRIX_PACKAGES.filter((pkg) => {
|
||||
try {
|
||||
resolve(pkg);
|
||||
return false;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} catch {
|
||||
return [...REQUIRED_MATRIX_PACKAGES];
|
||||
}
|
||||
const resolve = resolveFn ?? defaultResolveFn;
|
||||
return REQUIRED_MATRIX_PACKAGES.filter((pkg) => {
|
||||
try {
|
||||
resolve(pkg);
|
||||
return false;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function isMatrixSdkAvailable(): boolean {
|
||||
@@ -46,9 +42,8 @@ export function isMatrixSdkAvailable(): boolean {
|
||||
}
|
||||
|
||||
function buildMatrixDepsMissingMessage(missing: string[]): string {
|
||||
const packages = missing.length > 0 ? missing.join(", ") : REQUIRED_MATRIX_PACKAGES.join(", ");
|
||||
return [
|
||||
`Matrix plugin dependencies are missing: ${packages}.`,
|
||||
`Matrix plugin dependencies are missing: ${missing.join(", ")}.`,
|
||||
"Repair this plugin with `openclaw plugins update matrix` or run `openclaw doctor --fix`.",
|
||||
].join(" ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user