From 4c100e26dab115c54f7351891641e4518410ed89 Mon Sep 17 00:00:00 2001 From: Joan Xie Date: Wed, 24 Sep 2025 14:26:55 -0700 Subject: [PATCH] refactor: rename CURRENT_MANIFEST_VERSION to LATEST_MANIFEST_VERSION - Rename CURRENT_MANIFEST_VERSION to LATEST_MANIFEST_VERSION - Rename CURRENT_MANIFEST_SCHEMA to LATEST_MANIFEST_SCHEMA - Rename CURRENT_MANIFEST_SCHEMA_LOOSE to LATEST_MANIFEST_SCHEMA_LOOSE - Update all references throughout codebase and tests --- src/cli/init.ts | 4 ++-- src/cli/pack.ts | 12 ++++++------ src/node/validate.ts | 8 ++++---- src/schemas.ts | 2 +- src/schemas/index.ts | 2 +- src/shared/constants.ts | 12 ++++++------ test/cli.test.ts | 6 +++--- test/init.test.ts | 6 +++--- 8 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/cli/init.ts b/src/cli/init.ts index 17b95a9..a3ae0db 100644 --- a/src/cli/init.ts +++ b/src/cli/init.ts @@ -2,7 +2,7 @@ import { confirm, input, select } from "@inquirer/prompts"; import { existsSync, readFileSync, writeFileSync } from "fs"; import { basename, join, resolve } from "path"; -import { CURRENT_MANIFEST_VERSION } from "../shared/constants.js"; +import { LATEST_MANIFEST_VERSION } from "../shared/constants.js"; import type { McpbManifest } from "../types.js"; interface PackageJson { @@ -774,7 +774,7 @@ export function buildManifest( const { keywords, license, repository } = optionalFields; return { - manifest_version: CURRENT_MANIFEST_VERSION, + manifest_version: LATEST_MANIFEST_VERSION, name, ...(displayName && displayName !== name ? { display_name: displayName } diff --git a/src/cli/pack.ts b/src/cli/pack.ts index 0e51d9b..58b3c1c 100644 --- a/src/cli/pack.ts +++ b/src/cli/pack.ts @@ -14,8 +14,8 @@ import { basename, join, relative, resolve, sep } from "path"; import { getAllFilesWithCount, readMcpbIgnorePatterns } from "../node/files.js"; import { validateManifest } from "../node/validate.js"; import { - CURRENT_MANIFEST_SCHEMA, - CURRENT_MANIFEST_VERSION, + LATEST_MANIFEST_SCHEMA, + LATEST_MANIFEST_VERSION, } from "../shared/constants.js"; import { getLogger } from "../shared/log.js"; import { initExtension } from "./init.js"; @@ -95,7 +95,7 @@ export async function packExtension({ try { const manifestContent = readFileSync(manifestPath, "utf-8"); const manifestData = JSON.parse(manifestContent); - manifest = CURRENT_MANIFEST_SCHEMA.parse(manifestData); + manifest = LATEST_MANIFEST_SCHEMA.parse(manifestData); } catch (error) { logger.error("ERROR: Failed to parse manifest.json"); if (error instanceof Error) { @@ -105,12 +105,12 @@ export async function packExtension({ } const manifestVersion = manifest.manifest_version || manifest.dxt_version; - if (manifestVersion !== CURRENT_MANIFEST_VERSION) { + if (manifestVersion !== LATEST_MANIFEST_VERSION) { logger.error( - `ERROR: Manifest version mismatch. Expected "${CURRENT_MANIFEST_VERSION}", found "${manifestVersion}"`, + `ERROR: Manifest version mismatch. Expected "${LATEST_MANIFEST_VERSION}", found "${manifestVersion}"`, ); logger.error( - ` Please update the manifest_version in your manifest.json to "${CURRENT_MANIFEST_VERSION}"`, + ` Please update the manifest_version in your manifest.json to "${LATEST_MANIFEST_VERSION}"`, ); return false; } diff --git a/src/node/validate.ts b/src/node/validate.ts index 5b44189..7a94d53 100644 --- a/src/node/validate.ts +++ b/src/node/validate.ts @@ -7,8 +7,8 @@ import prettyBytes from "pretty-bytes"; import { unpackExtension } from "../cli/unpack.js"; import { - CURRENT_MANIFEST_SCHEMA, - CURRENT_MANIFEST_SCHEMA_LOOSE, + LATEST_MANIFEST_SCHEMA, + LATEST_MANIFEST_SCHEMA_LOOSE, } from "../shared/constants.js"; export function validateManifest(inputPath: string): boolean { @@ -24,7 +24,7 @@ export function validateManifest(inputPath: string): boolean { const manifestContent = readFileSync(manifestPath, "utf-8"); const manifestData = JSON.parse(manifestContent); - const result = CURRENT_MANIFEST_SCHEMA.safeParse(manifestData); + const result = LATEST_MANIFEST_SCHEMA.safeParse(manifestData); if (result.success) { console.log("Manifest schema validation passes!"); @@ -74,7 +74,7 @@ export async function cleanMcpb(inputPath: string) { const manifestPath = resolve(unpackPath, "manifest.json"); const originalManifest = await fs.readFile(manifestPath, "utf-8"); const manifestData = JSON.parse(originalManifest); - const result = CURRENT_MANIFEST_SCHEMA_LOOSE.safeParse(manifestData); + const result = LATEST_MANIFEST_SCHEMA_LOOSE.safeParse(manifestData); if (!result.success) { throw new Error( diff --git a/src/schemas.ts b/src/schemas.ts index 4bf0ea8..4bbaa7c 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -1,5 +1,5 @@ export { - CURRENT_MANIFEST_VERSION, + LATEST_MANIFEST_VERSION, McpbManifestSchema, v0_1, v0_2, diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 427aad4..9e4a580 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -2,6 +2,6 @@ export * as v0_1 from "./0.1.js"; export * as v0_2 from "./0.2.js"; export * as latest from "./latest.js"; export { - MANIFEST_VERSION as CURRENT_MANIFEST_VERSION, + MANIFEST_VERSION as LATEST_MANIFEST_VERSION, McpbManifestSchema, } from "./latest.js"; diff --git a/src/shared/constants.ts b/src/shared/constants.ts index ec7b865..1e4c2d0 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -6,9 +6,9 @@ import { McpbManifestSchema as LooseManifestSchemaV0_2 } from "../schemas_loose/ import { McpbManifestSchema as CurrentLooseManifestSchema } from "../schemas_loose/latest.js"; /** - * Current manifest version - the version that new manifests should use + * Latest manifest version - the version that new manifests should use */ -export const CURRENT_MANIFEST_VERSION = "0.2" as const; +export const LATEST_MANIFEST_VERSION = "0.2" as const; /** * Map of manifest versions to their strict schemas @@ -27,11 +27,11 @@ export const MANIFEST_SCHEMAS_LOOSE = { } as const; /** - * Get the current manifest schema based on CURRENT_MANIFEST_VERSION + * Get the latest manifest schema based on LATEST_MANIFEST_VERSION */ -export const CURRENT_MANIFEST_SCHEMA = CurrentManifestSchema; +export const LATEST_MANIFEST_SCHEMA = CurrentManifestSchema; /** - * Get the current loose manifest schema based on CURRENT_MANIFEST_VERSION + * Get the latest loose manifest schema based on LATEST_MANIFEST_VERSION */ -export const CURRENT_MANIFEST_SCHEMA_LOOSE = CurrentLooseManifestSchema; +export const LATEST_MANIFEST_SCHEMA_LOOSE = CurrentLooseManifestSchema; diff --git a/test/cli.test.ts b/test/cli.test.ts index dd18635..0357635 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -2,7 +2,7 @@ import { execSync } from "node:child_process"; import fs from "node:fs"; import { join } from "node:path"; -import { CURRENT_MANIFEST_VERSION } from "../src/schemas.js"; +import { LATEST_MANIFEST_VERSION } from "../src/schemas.js"; interface ExecSyncError extends Error { stdout: Buffer; @@ -93,7 +93,7 @@ describe("DXT CLI", () => { fs.writeFileSync( join(tempDir, "manifest.json"), JSON.stringify({ - manifest_version: CURRENT_MANIFEST_VERSION, + manifest_version: LATEST_MANIFEST_VERSION, name: "Test Extension", version: "1.0.0", description: "A test extension", @@ -190,7 +190,7 @@ describe("DXT CLI", () => { fs.writeFileSync( join(tempExecDir, "manifest.json"), JSON.stringify({ - manifest_version: CURRENT_MANIFEST_VERSION, + manifest_version: LATEST_MANIFEST_VERSION, name: "Test Executable Extension", version: "1.0.0", description: "A test extension with executable files", diff --git a/test/init.test.ts b/test/init.test.ts index f79191e..2b65ada 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -10,7 +10,7 @@ import { getDefaultRepositoryUrl, readPackageJson, } from "../src/cli/init.js"; -import { CURRENT_MANIFEST_VERSION } from "../src/schemas.js"; +import { LATEST_MANIFEST_VERSION } from "../src/schemas.js"; // Mock the fs module jest.mock("fs", () => ({ @@ -218,7 +218,7 @@ describe("init functions", () => { ); expect(manifest).toEqual({ - manifest_version: CURRENT_MANIFEST_VERSION, + manifest_version: LATEST_MANIFEST_VERSION, name: "test-extension", version: "1.0.0", description: "Test description", @@ -304,7 +304,7 @@ describe("init functions", () => { ); expect(manifest).toEqual({ - manifest_version: CURRENT_MANIFEST_VERSION, + manifest_version: LATEST_MANIFEST_VERSION, name: "test-extension", display_name: "Test Extension", version: "1.0.0",