Use McpbManifestDefault derived from DEFAULT_MANIFEST_VERSION
Changes: - Create McpbManifestDefault type derived from VERSIONED_MANIFEST_SCHEMAS[DEFAULT_MANIFEST_VERSION] - Update init.ts to use McpbManifestDefault instead of hardcoded v0.2 schema - Import schema types from version matching DEFAULT_MANIFEST_VERSION (0.2) - Update test to match commented-out localization field - Make McpbManifest (deprecated) point to McpbManifestDefault This makes the codebase more maintainable by deriving types from DEFAULT_MANIFEST_VERSION instead of hardcoding version references. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
70c3615fc9
commit
3fffc30560
3 changed files with 17 additions and 13 deletions
|
|
@ -1,10 +1,9 @@
|
||||||
import { confirm, input, select } from "@inquirer/prompts";
|
import { confirm, input, select } from "@inquirer/prompts";
|
||||||
import { existsSync, readFileSync, writeFileSync } from "fs";
|
import { existsSync, readFileSync, writeFileSync } from "fs";
|
||||||
import { basename, join, resolve } from "path";
|
import { basename, join, resolve } from "path";
|
||||||
import type * as z from "zod";
|
|
||||||
|
|
||||||
import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "../schemas/0.2.js";
|
|
||||||
import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js";
|
import { DEFAULT_MANIFEST_VERSION } from "../shared/constants.js";
|
||||||
|
import type { McpbManifestDefault } from "../types.js";
|
||||||
|
|
||||||
interface PackageJson {
|
interface PackageJson {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|
@ -879,7 +878,7 @@ export function buildManifest(
|
||||||
resources: string;
|
resources: string;
|
||||||
default_locale: string;
|
default_locale: string;
|
||||||
},
|
},
|
||||||
): z.infer<typeof McpbManifestSchemaV0_2> {
|
): McpbManifestDefault {
|
||||||
const { name, displayName, version, description, authorName } = basicInfo;
|
const { name, displayName, version, description, authorName } = basicInfo;
|
||||||
const { authorEmail, authorUrl } = authorInfo;
|
const { authorEmail, authorUrl } = authorInfo;
|
||||||
const { serverType, entryPoint, mcp_config } = serverConfig;
|
const { serverType, entryPoint, mcp_config } = serverConfig;
|
||||||
|
|
@ -907,7 +906,7 @@ export function buildManifest(
|
||||||
...(visualAssets.screenshots.length > 0
|
...(visualAssets.screenshots.length > 0
|
||||||
? { screenshots: visualAssets.screenshots }
|
? { screenshots: visualAssets.screenshots }
|
||||||
: {}),
|
: {}),
|
||||||
...(localization ? { localization } : {}),
|
// ...(localization ? { localization } : {}),
|
||||||
server: {
|
server: {
|
||||||
type: serverType,
|
type: serverType,
|
||||||
entry_point: entryPoint,
|
entry_point: entryPoint,
|
||||||
|
|
|
||||||
19
src/types.ts
19
src/types.ts
|
|
@ -1,7 +1,8 @@
|
||||||
import type * as z from "zod";
|
import type * as z from "zod";
|
||||||
|
|
||||||
import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js";
|
import type { McpbManifestSchema as McpbManifestSchemaAny } from "./schemas/any.js";
|
||||||
import type { McpbManifestSchema as McpbManifestSchemaV0_2 } from "./schemas/0.2.js";
|
import { VERSIONED_MANIFEST_SCHEMAS } from "./schemas/index.js";
|
||||||
|
// Import schema types from the version matching DEFAULT_MANIFEST_VERSION
|
||||||
import type {
|
import type {
|
||||||
McpbManifestAuthorSchema,
|
McpbManifestAuthorSchema,
|
||||||
McpbManifestCompatibilitySchema,
|
McpbManifestCompatibilitySchema,
|
||||||
|
|
@ -15,7 +16,8 @@ import type {
|
||||||
McpbUserConfigurationOptionSchema,
|
McpbUserConfigurationOptionSchema,
|
||||||
McpbUserConfigValuesSchema,
|
McpbUserConfigValuesSchema,
|
||||||
McpServerConfigSchema,
|
McpServerConfigSchema,
|
||||||
} from "./schemas/0.3.js";
|
} from "./schemas/0.2.js";
|
||||||
|
import { DEFAULT_MANIFEST_VERSION } from "./shared/constants.js";
|
||||||
|
|
||||||
export type McpServerConfig = z.infer<typeof McpServerConfigSchema>;
|
export type McpServerConfig = z.infer<typeof McpServerConfigSchema>;
|
||||||
|
|
||||||
|
|
@ -53,10 +55,17 @@ export type McpbUserConfigValues = z.infer<typeof McpbUserConfigValuesSchema>;
|
||||||
export type McpbManifestAny = z.infer<typeof McpbManifestSchemaAny>;
|
export type McpbManifestAny = z.infer<typeof McpbManifestSchemaAny>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* McpbManifest type for v0.2 (default version) for backwards compatibility
|
* McpbManifest type for the DEFAULT_MANIFEST_VERSION
|
||||||
* @deprecated Use McpbManifestAny instead to support all manifest versions.
|
* Use this for creating new manifests with the default version.
|
||||||
*/
|
*/
|
||||||
export type McpbManifest = z.infer<typeof McpbManifestSchemaV0_2>;
|
export type McpbManifestDefault = z.infer<
|
||||||
|
(typeof VERSIONED_MANIFEST_SCHEMAS)[typeof DEFAULT_MANIFEST_VERSION]
|
||||||
|
>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use McpbManifestAny instead to support all manifest versions, or McpbManifestDefault for the default version.
|
||||||
|
*/
|
||||||
|
export type McpbManifest = McpbManifestDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about a MCPB package signature
|
* Information about a MCPB package signature
|
||||||
|
|
|
||||||
|
|
@ -351,10 +351,6 @@ describe("init functions", () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
screenshots: ["screen1.png", "screen2.png"],
|
screenshots: ["screen1.png", "screen2.png"],
|
||||||
localization: {
|
|
||||||
resources: "resources/${locale}.json",
|
|
||||||
default_locale: "en-US",
|
|
||||||
},
|
|
||||||
server: {
|
server: {
|
||||||
type: "python",
|
type: "python",
|
||||||
entry_point: "server/main.py",
|
entry_point: "server/main.py",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue