fix: use correct manifest types for reading vs building
Apply proper type distinction: - Reading/validating existing manifests: Use McpbManifest (any version) - Building/creating new manifests: Use McpbManifestLatest (latest only) Changes: - src/shared/config.ts: Revert to McpbManifest for config operations - src/cli/init.ts: Use McpbManifestLatest for new manifest creation - test/config.test.ts: Use McpbManifest for testing config operations This ensures backward compatibility when reading existing manifests while enforcing latest schema for new builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
ddad8064ef
commit
184173e342
3 changed files with 21 additions and 21 deletions
|
|
@ -3,7 +3,7 @@ import { existsSync, readFileSync, writeFileSync } from "fs";
|
|||
import { basename, join, resolve } from "path";
|
||||
|
||||
import { LATEST_MANIFEST_VERSION } from "../shared/constants.js";
|
||||
import type { McpbManifest } from "../types.js";
|
||||
import type { McpbManifestLatest } from "../types.js";
|
||||
|
||||
interface PackageJson {
|
||||
name?: string;
|
||||
|
|
@ -878,7 +878,7 @@ export function buildManifest(
|
|||
resources: string;
|
||||
default_locale: string;
|
||||
},
|
||||
): McpbManifest {
|
||||
): McpbManifestLatest {
|
||||
const { name, displayName, version, description, authorName } = basicInfo;
|
||||
const { authorEmail, authorUrl } = authorInfo;
|
||||
const { serverType, entryPoint, mcp_config } = serverConfig;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type {
|
||||
Logger,
|
||||
McpbManifestLatest,
|
||||
McpbManifest,
|
||||
McpbUserConfigValues,
|
||||
McpServerConfig,
|
||||
} from "../types.js";
|
||||
|
|
@ -85,7 +85,7 @@ export function replaceVariables(
|
|||
}
|
||||
|
||||
interface GetMcpConfigForManifestOptions {
|
||||
manifest: McpbManifestLatest;
|
||||
manifest: McpbManifest;
|
||||
extensionPath: string;
|
||||
systemDirs: Record<string, string>;
|
||||
userConfig: McpbUserConfigValues;
|
||||
|
|
@ -179,7 +179,7 @@ export async function getMcpConfigForManifest(
|
|||
}
|
||||
|
||||
interface HasRequiredConfigMissingOptions {
|
||||
manifest: McpbManifestLatest;
|
||||
manifest: McpbManifest;
|
||||
userConfig?: McpbUserConfigValues;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import {
|
|||
hasRequiredConfigMissing,
|
||||
replaceVariables,
|
||||
} from "../src/shared/config";
|
||||
import type { Logger, McpbManifestLatest } from "../src/types";
|
||||
import type { Logger, McpbManifest } from "../src/types";
|
||||
|
||||
describe("replaceVariables", () => {
|
||||
it("should replace variables in strings", () => {
|
||||
|
|
@ -89,7 +89,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
data: "/data",
|
||||
};
|
||||
|
||||
const baseManifest: McpbManifestLatest = {
|
||||
const baseManifest: McpbManifest = {
|
||||
manifest_version: "0.3",
|
||||
name: "test-extension",
|
||||
version: "1.0.0",
|
||||
|
|
@ -114,7 +114,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
const manifest = {
|
||||
...baseManifest,
|
||||
server: undefined,
|
||||
} as unknown as McpbManifestLatest;
|
||||
} as unknown as McpbManifest;
|
||||
|
||||
const result = await getMcpConfigForManifest({
|
||||
manifest,
|
||||
|
|
@ -129,7 +129,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
});
|
||||
|
||||
it("should return undefined when required config is missing", async () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
apiKey: {
|
||||
|
|
@ -171,7 +171,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
});
|
||||
|
||||
it("should apply platform overrides", async () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
server: {
|
||||
type: "node",
|
||||
|
|
@ -203,7 +203,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
});
|
||||
|
||||
it("should handle user config variable replacement with defaults", async () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
port: {
|
||||
|
|
@ -236,7 +236,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
});
|
||||
|
||||
it("should handle user config variable replacement with user values", async () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
paths: {
|
||||
|
|
@ -270,7 +270,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
});
|
||||
|
||||
it("should convert boolean user config values to strings", async () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
verbose: {
|
||||
|
|
@ -304,7 +304,7 @@ describe("getMcpConfigForManifest", () => {
|
|||
});
|
||||
|
||||
describe("hasRequiredConfigMissing", () => {
|
||||
const baseManifest: McpbManifestLatest = {
|
||||
const baseManifest: McpbManifest = {
|
||||
manifest_version: "0.3",
|
||||
name: "test-extension",
|
||||
version: "1.0.0",
|
||||
|
|
@ -329,7 +329,7 @@ describe("hasRequiredConfigMissing", () => {
|
|||
});
|
||||
|
||||
it("should return false when no config fields are required", () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
port: {
|
||||
|
|
@ -349,7 +349,7 @@ describe("hasRequiredConfigMissing", () => {
|
|||
});
|
||||
|
||||
it("should return false when required config is provided", () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
apiKey: {
|
||||
|
|
@ -369,7 +369,7 @@ describe("hasRequiredConfigMissing", () => {
|
|||
});
|
||||
|
||||
it("should return true when required config is undefined", () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
apiKey: {
|
||||
|
|
@ -389,7 +389,7 @@ describe("hasRequiredConfigMissing", () => {
|
|||
});
|
||||
|
||||
it("should return true when required config is empty string", () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
apiKey: {
|
||||
|
|
@ -409,7 +409,7 @@ describe("hasRequiredConfigMissing", () => {
|
|||
});
|
||||
|
||||
it("should return true when required config is array with invalid values", () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
paths: {
|
||||
|
|
@ -430,7 +430,7 @@ describe("hasRequiredConfigMissing", () => {
|
|||
});
|
||||
|
||||
it("should return true when required config is empty array", () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
paths: {
|
||||
|
|
@ -459,7 +459,7 @@ describe("hasRequiredConfigMissing", () => {
|
|||
});
|
||||
|
||||
it("should handle multiple required config fields", () => {
|
||||
const manifest: McpbManifestLatest = {
|
||||
const manifest: McpbManifest = {
|
||||
...baseManifest,
|
||||
user_config: {
|
||||
apiKey: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue