diff --git a/extensions/acpx/src/config.ts b/extensions/acpx/src/config.ts index 612147320d5..9fbac17f39d 100644 --- a/extensions/acpx/src/config.ts +++ b/extensions/acpx/src/config.ts @@ -9,7 +9,6 @@ export type AcpxPermissionMode = (typeof ACPX_PERMISSION_MODES)[number]; export const ACPX_NON_INTERACTIVE_POLICIES = ["deny", "fail"] as const; export type AcpxNonInteractivePermissionPolicy = (typeof ACPX_NON_INTERACTIVE_POLICIES)[number]; -export const ACPX_PINNED_VERSION = "0.1.16"; export const ACPX_VERSION_ANY = "any"; const ACPX_BIN_NAME = process.platform === "win32" ? "acpx.cmd" : "acpx"; @@ -56,6 +55,14 @@ export function resolveAcpxPluginRoot(moduleUrl: string = import.meta.url): stri } export const ACPX_PLUGIN_ROOT = resolveAcpxPluginRoot(); +const pluginPkg = JSON.parse(fs.readFileSync(path.join(ACPX_PLUGIN_ROOT, "package.json"), "utf8")); +const acpxVersion: unknown = pluginPkg?.dependencies?.acpx; +if (typeof acpxVersion !== "string" || acpxVersion.trim() === "") { + throw new Error( + `Could not read acpx version from ${path.join(ACPX_PLUGIN_ROOT, "package.json")} — expected a non-empty string at dependencies.acpx` + ); +} +export const ACPX_PINNED_VERSION: string = acpxVersion.replace(/^[^0-9]*/, ""); export const ACPX_BUNDLED_BIN = path.join(ACPX_PLUGIN_ROOT, "node_modules", ".bin", ACPX_BIN_NAME); export function buildAcpxLocalInstallCommand(version: string = ACPX_PINNED_VERSION): string { return `npm install --omit=dev --no-save --package-lock=false acpx@${version}`;