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
This commit is contained in:
parent
412b124b96
commit
4c100e26da
8 changed files with 26 additions and 26 deletions
|
|
@ -2,7 +2,7 @@ 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 { CURRENT_MANIFEST_VERSION } from "../shared/constants.js";
|
import { LATEST_MANIFEST_VERSION } from "../shared/constants.js";
|
||||||
import type { McpbManifest } from "../types.js";
|
import type { McpbManifest } from "../types.js";
|
||||||
|
|
||||||
interface PackageJson {
|
interface PackageJson {
|
||||||
|
|
@ -774,7 +774,7 @@ export function buildManifest(
|
||||||
const { keywords, license, repository } = optionalFields;
|
const { keywords, license, repository } = optionalFields;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
manifest_version: CURRENT_MANIFEST_VERSION,
|
manifest_version: LATEST_MANIFEST_VERSION,
|
||||||
name,
|
name,
|
||||||
...(displayName && displayName !== name
|
...(displayName && displayName !== name
|
||||||
? { display_name: displayName }
|
? { display_name: displayName }
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import { basename, join, relative, resolve, sep } from "path";
|
||||||
import { getAllFilesWithCount, readMcpbIgnorePatterns } from "../node/files.js";
|
import { getAllFilesWithCount, readMcpbIgnorePatterns } from "../node/files.js";
|
||||||
import { validateManifest } from "../node/validate.js";
|
import { validateManifest } from "../node/validate.js";
|
||||||
import {
|
import {
|
||||||
CURRENT_MANIFEST_SCHEMA,
|
LATEST_MANIFEST_SCHEMA,
|
||||||
CURRENT_MANIFEST_VERSION,
|
LATEST_MANIFEST_VERSION,
|
||||||
} from "../shared/constants.js";
|
} from "../shared/constants.js";
|
||||||
import { getLogger } from "../shared/log.js";
|
import { getLogger } from "../shared/log.js";
|
||||||
import { initExtension } from "./init.js";
|
import { initExtension } from "./init.js";
|
||||||
|
|
@ -95,7 +95,7 @@ export async function packExtension({
|
||||||
try {
|
try {
|
||||||
const manifestContent = readFileSync(manifestPath, "utf-8");
|
const manifestContent = readFileSync(manifestPath, "utf-8");
|
||||||
const manifestData = JSON.parse(manifestContent);
|
const manifestData = JSON.parse(manifestContent);
|
||||||
manifest = CURRENT_MANIFEST_SCHEMA.parse(manifestData);
|
manifest = LATEST_MANIFEST_SCHEMA.parse(manifestData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("ERROR: Failed to parse manifest.json");
|
logger.error("ERROR: Failed to parse manifest.json");
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|
@ -105,12 +105,12 @@ export async function packExtension({
|
||||||
}
|
}
|
||||||
|
|
||||||
const manifestVersion = manifest.manifest_version || manifest.dxt_version;
|
const manifestVersion = manifest.manifest_version || manifest.dxt_version;
|
||||||
if (manifestVersion !== CURRENT_MANIFEST_VERSION) {
|
if (manifestVersion !== LATEST_MANIFEST_VERSION) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`ERROR: Manifest version mismatch. Expected "${CURRENT_MANIFEST_VERSION}", found "${manifestVersion}"`,
|
`ERROR: Manifest version mismatch. Expected "${LATEST_MANIFEST_VERSION}", found "${manifestVersion}"`,
|
||||||
);
|
);
|
||||||
logger.error(
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import prettyBytes from "pretty-bytes";
|
||||||
|
|
||||||
import { unpackExtension } from "../cli/unpack.js";
|
import { unpackExtension } from "../cli/unpack.js";
|
||||||
import {
|
import {
|
||||||
CURRENT_MANIFEST_SCHEMA,
|
LATEST_MANIFEST_SCHEMA,
|
||||||
CURRENT_MANIFEST_SCHEMA_LOOSE,
|
LATEST_MANIFEST_SCHEMA_LOOSE,
|
||||||
} from "../shared/constants.js";
|
} from "../shared/constants.js";
|
||||||
|
|
||||||
export function validateManifest(inputPath: string): boolean {
|
export function validateManifest(inputPath: string): boolean {
|
||||||
|
|
@ -24,7 +24,7 @@ export function validateManifest(inputPath: string): boolean {
|
||||||
const manifestContent = readFileSync(manifestPath, "utf-8");
|
const manifestContent = readFileSync(manifestPath, "utf-8");
|
||||||
const manifestData = JSON.parse(manifestContent);
|
const manifestData = JSON.parse(manifestContent);
|
||||||
|
|
||||||
const result = CURRENT_MANIFEST_SCHEMA.safeParse(manifestData);
|
const result = LATEST_MANIFEST_SCHEMA.safeParse(manifestData);
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
console.log("Manifest schema validation passes!");
|
console.log("Manifest schema validation passes!");
|
||||||
|
|
@ -74,7 +74,7 @@ export async function cleanMcpb(inputPath: string) {
|
||||||
const manifestPath = resolve(unpackPath, "manifest.json");
|
const manifestPath = resolve(unpackPath, "manifest.json");
|
||||||
const originalManifest = await fs.readFile(manifestPath, "utf-8");
|
const originalManifest = await fs.readFile(manifestPath, "utf-8");
|
||||||
const manifestData = JSON.parse(originalManifest);
|
const manifestData = JSON.parse(originalManifest);
|
||||||
const result = CURRENT_MANIFEST_SCHEMA_LOOSE.safeParse(manifestData);
|
const result = LATEST_MANIFEST_SCHEMA_LOOSE.safeParse(manifestData);
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
export {
|
export {
|
||||||
CURRENT_MANIFEST_VERSION,
|
LATEST_MANIFEST_VERSION,
|
||||||
McpbManifestSchema,
|
McpbManifestSchema,
|
||||||
v0_1,
|
v0_1,
|
||||||
v0_2,
|
v0_2,
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ export * as v0_1 from "./0.1.js";
|
||||||
export * as v0_2 from "./0.2.js";
|
export * as v0_2 from "./0.2.js";
|
||||||
export * as latest from "./latest.js";
|
export * as latest from "./latest.js";
|
||||||
export {
|
export {
|
||||||
MANIFEST_VERSION as CURRENT_MANIFEST_VERSION,
|
MANIFEST_VERSION as LATEST_MANIFEST_VERSION,
|
||||||
McpbManifestSchema,
|
McpbManifestSchema,
|
||||||
} from "./latest.js";
|
} from "./latest.js";
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ import { McpbManifestSchema as LooseManifestSchemaV0_2 } from "../schemas_loose/
|
||||||
import { McpbManifestSchema as CurrentLooseManifestSchema } from "../schemas_loose/latest.js";
|
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
|
* Map of manifest versions to their strict schemas
|
||||||
|
|
@ -27,11 +27,11 @@ export const MANIFEST_SCHEMAS_LOOSE = {
|
||||||
} as const;
|
} 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;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import { execSync } from "node:child_process";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import { join } from "node:path";
|
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 {
|
interface ExecSyncError extends Error {
|
||||||
stdout: Buffer;
|
stdout: Buffer;
|
||||||
|
|
@ -93,7 +93,7 @@ describe("DXT CLI", () => {
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
join(tempDir, "manifest.json"),
|
join(tempDir, "manifest.json"),
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
manifest_version: CURRENT_MANIFEST_VERSION,
|
manifest_version: LATEST_MANIFEST_VERSION,
|
||||||
name: "Test Extension",
|
name: "Test Extension",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
description: "A test extension",
|
description: "A test extension",
|
||||||
|
|
@ -190,7 +190,7 @@ describe("DXT CLI", () => {
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
join(tempExecDir, "manifest.json"),
|
join(tempExecDir, "manifest.json"),
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
manifest_version: CURRENT_MANIFEST_VERSION,
|
manifest_version: LATEST_MANIFEST_VERSION,
|
||||||
name: "Test Executable Extension",
|
name: "Test Executable Extension",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
description: "A test extension with executable files",
|
description: "A test extension with executable files",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
getDefaultRepositoryUrl,
|
getDefaultRepositoryUrl,
|
||||||
readPackageJson,
|
readPackageJson,
|
||||||
} from "../src/cli/init.js";
|
} 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
|
// Mock the fs module
|
||||||
jest.mock("fs", () => ({
|
jest.mock("fs", () => ({
|
||||||
|
|
@ -218,7 +218,7 @@ describe("init functions", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(manifest).toEqual({
|
expect(manifest).toEqual({
|
||||||
manifest_version: CURRENT_MANIFEST_VERSION,
|
manifest_version: LATEST_MANIFEST_VERSION,
|
||||||
name: "test-extension",
|
name: "test-extension",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
description: "Test description",
|
description: "Test description",
|
||||||
|
|
@ -304,7 +304,7 @@ describe("init functions", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(manifest).toEqual({
|
expect(manifest).toEqual({
|
||||||
manifest_version: CURRENT_MANIFEST_VERSION,
|
manifest_version: LATEST_MANIFEST_VERSION,
|
||||||
name: "test-extension",
|
name: "test-extension",
|
||||||
display_name: "Test Extension",
|
display_name: "Test Extension",
|
||||||
version: "1.0.0",
|
version: "1.0.0",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue