From e17904eb5638ea589b00a7f3a4d48461f0123828 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 6 Jun 2025 18:35:54 +1000 Subject: [PATCH] Simplify checkPluginVersion (#9740) --- src/frontend/lib/functions/Plugins.tsx | 26 +++++++------------------- src/frontend/package.json | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/frontend/lib/functions/Plugins.tsx b/src/frontend/lib/functions/Plugins.tsx index fabde26e4c..e54eb1d123 100644 --- a/src/frontend/lib/functions/Plugins.tsx +++ b/src/frontend/lib/functions/Plugins.tsx @@ -3,28 +3,16 @@ import { type InvenTreePluginContext } from '../types/Plugins'; -function extractVersion(version: string) { - // Extract the version number from the string - const [major, minor, patch] = version - .split('.') - .map((v) => Number.parseInt(v, 10)); - - return { major, minor, patch }; -} - /** - * Check th e + * Check that the plugin version matches the expected version. + * This is a helper function which only generates a warning if there is a mismatch. */ export function checkPluginVersion(context: InvenTreePluginContext) { - const pluginVersion = extractVersion(INVENTREE_PLUGIN_VERSION); - const systemVersion = extractVersion(context.version.inventree); + const systemVersion: string = context?.version?.inventree || ''; - const mismatch = `Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${context.version}`; - - // A major version mismatch indicates a potentially breaking change - if (pluginVersion.major !== systemVersion.major) { - console.warn(mismatch); - } else if (INVENTREE_PLUGIN_VERSION != context.version.inventree) { - console.info(mismatch); + if (INVENTREE_PLUGIN_VERSION != systemVersion) { + console.info( + `Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${systemVersion}` + ); } } diff --git a/src/frontend/package.json b/src/frontend/package.json index 4ae8c80ab8..408f6428ae 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -1,7 +1,7 @@ { "name": "@inventreedb/ui", "description": "UI components for the InvenTree project", - "version": "0.0.8", + "version": "0.1.0", "private": false, "type": "module", "license": "MIT",