mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:31:06 +00:00
refactor: share plugin package version lookup
This commit is contained in:
@@ -1,31 +1,14 @@
|
||||
import type { Agent } from "node:https";
|
||||
import { createRequire } from "node:module";
|
||||
import * as Lark from "@larksuiteoapi/node-sdk";
|
||||
import { resolveAmbientNodeProxyAgent } from "openclaw/plugin-sdk/extension-shared";
|
||||
import {
|
||||
readPluginPackageVersion,
|
||||
resolveAmbientNodeProxyAgent,
|
||||
} from "openclaw/plugin-sdk/extension-shared";
|
||||
import type { FeishuConfig, FeishuDomain, ResolvedFeishuAccount } from "./types.js";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const PACKAGE_JSON_CANDIDATES = [
|
||||
"../package.json",
|
||||
"./package.json",
|
||||
"../../package.json",
|
||||
] as const;
|
||||
|
||||
function readPluginVersion(): string {
|
||||
for (const candidate of PACKAGE_JSON_CANDIDATES) {
|
||||
try {
|
||||
const version = (require(candidate) as { version?: unknown }).version;
|
||||
if (typeof version === "string" && version.trim().length > 0) {
|
||||
return version;
|
||||
}
|
||||
} catch {
|
||||
// Ignore missing candidate paths across source and bundled layouts.
|
||||
}
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
const pluginVersion = readPluginVersion();
|
||||
const pluginVersion = readPluginPackageVersion({ require });
|
||||
|
||||
export { pluginVersion };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user