version.test.ts 798 B

123456789101112131415
  1. // 类型包的版本钉在扩展 API 版本上(docs/plugins/extension-host.md §17.9):
  2. // 插件作者按包版本判断能用哪些能力,两处不一致就会装错版本。
  3. import { readFile } from "node:fs/promises";
  4. import { describe, expect, it } from "vitest";
  5. // 示例插件与类型包都不在 shared 的依赖链上,这里按相对路径读协议源码,只取这一个常量。
  6. import { EXTENSION_API_VERSION } from "../../shared/src/extension-host/manifest.js";
  7. describe("@zcode-dev/plugin-api version", () => {
  8. it("equals EXTENSION_API_VERSION", async () => {
  9. const manifest = JSON.parse(
  10. await readFile(new URL("../package.json", import.meta.url), "utf8"),
  11. ) as { version?: unknown };
  12. expect(manifest.version).toBe(EXTENSION_API_VERSION);
  13. });
  14. });