mirror of
https://github.com/penpot/penpot.git
synced 2026-11-06 18:10:39 +00:00
The plugin compared the full major.minor.patch of the running Penpot version with the MCP package version. The MCP package version is only set per minor release (2.15.0, 2.16.0, 2.17.0), so every Penpot patch release (for example 2.16.2 or 2.17.2) showed the "Version mismatch detected" warning although nothing changed for the MCP. Compare only major.minor, move the check into a small module with unit tests, and update the README versioning note to match. AI-assisted-by: claude-opus-5-5 Signed-off-by: robertkodra <36516516+robertkodra@users.noreply.github.com>
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
/**
|
|
* Extracts the major.minor prefix from a version string.
|
|
*
|
|
* Patch releases of Penpot do not change the plugin API the MCP server is
|
|
* written against, and the MCP package version is only set per minor
|
|
* release, so the patch component is not part of the compatibility check.
|
|
*
|
|
* @param version - a version string starting with major.minor (e.g. "2.18.1")
|
|
* @returns the major.minor prefix, or the original string if it does not match
|
|
*/
|
|
export function extractMinorVersion(version: string): string {
|
|
const match = version.match(/^(\d+\.\d+)(?:\.|$)/);
|
|
return match ? match[1] : version;
|
|
}
|
|
|
|
/**
|
|
* Returns whether an MCP build is intended for the running Penpot version.
|
|
*
|
|
* Local development builds of Penpot report "0.0.0" and are always treated
|
|
* as compatible.
|
|
*
|
|
* @param penpotVersion - the running Penpot version, as major.minor prefix
|
|
* @param mcpVersion - the version the MCP build targets, as major.minor prefix
|
|
*/
|
|
export function isCompatibleVersion(penpotVersion: string, mcpVersion: string): boolean {
|
|
return penpotVersion === "0.0" || penpotVersion === mcpVersion;
|
|
}
|