@inventreedb/ui 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,36 +1,9 @@
|
|
|
1
1
|
import { INVENTREE_PLUGIN_VERSION } from "../types/Plugins.js";
|
|
2
|
-
function extractVersion(version) {
|
|
3
|
-
if (!version) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
version = version.toString().trim();
|
|
7
|
-
if (!version.includes(".")) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
const [major, minor, patch] = version.split(".").map((v) => Number.parseInt(v, 10));
|
|
11
|
-
return {
|
|
12
|
-
major,
|
|
13
|
-
minor,
|
|
14
|
-
patch
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
2
|
function checkPluginVersion(context) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
systemVersion = extractVersion(context.version.inventree);
|
|
23
|
-
} catch {
|
|
24
|
-
console.warn("Failed to extract plugin version information");
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const mismatch = `Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${context.version}`;
|
|
28
|
-
if (!pluginVersion || !systemVersion) {
|
|
29
|
-
console.warn("Could not extract plugin version information");
|
|
30
|
-
} else if (pluginVersion.major !== systemVersion.major) {
|
|
31
|
-
console.warn(mismatch);
|
|
32
|
-
} else if (INVENTREE_PLUGIN_VERSION != context.version.inventree) {
|
|
33
|
-
console.info(mismatch);
|
|
3
|
+
var _a;
|
|
4
|
+
const systemVersion = ((_a = context == null ? void 0 : context.version) == null ? void 0 : _a.inventree) || "";
|
|
5
|
+
if (INVENTREE_PLUGIN_VERSION != systemVersion) {
|
|
6
|
+
console.info(`Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${systemVersion}`);
|
|
34
7
|
}
|
|
35
8
|
}
|
|
36
9
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugins.js","sources":["../../lib/functions/Plugins.tsx"],"sourcesContent":["import {\n INVENTREE_PLUGIN_VERSION,\n type InvenTreePluginContext\n} from '../types/Plugins';\n\
|
|
1
|
+
{"version":3,"file":"Plugins.js","sources":["../../lib/functions/Plugins.tsx"],"sourcesContent":["import {\n INVENTREE_PLUGIN_VERSION,\n type InvenTreePluginContext\n} from '../types/Plugins';\n\n/**\n * Check that the plugin version matches the expected version.\n * This is a helper function which only generates a warning if there is a mismatch.\n */\nexport function checkPluginVersion(context: InvenTreePluginContext) {\n const systemVersion: string = context?.version?.inventree || '';\n \n if (INVENTREE_PLUGIN_VERSION != systemVersion) {\n console.info(`Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${systemVersion}`);\n }\n}\n"],"names":["checkPluginVersion","context","systemVersion","version","inventree","INVENTREE_PLUGIN_VERSION","console","info"],"mappings":";AASO,SAASA,mBAAmBC,SAAiC;;AAC5DC,QAAAA,kBAAwBD,wCAASE,YAATF,mBAAkBG,cAAa;AAE7D,MAAIC,4BAA4BH,eAAe;AAC7CI,YAAQC,KAAK,6CAA6CF,wBAAwB,SAASH,aAAa,EAAE;AAAA,EAAA;AAE9G;"}
|
package/dist/types/Plugins.js
CHANGED
|
@@ -3,50 +3,14 @@ import {
|
|
|
3
3
|
type InvenTreePluginContext
|
|
4
4
|
} from '../types/Plugins';
|
|
5
5
|
|
|
6
|
-
function extractVersion(version: string) {
|
|
7
|
-
// Extract the version number from the string
|
|
8
|
-
|
|
9
|
-
if (!version) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
version = version.toString().trim();
|
|
14
|
-
|
|
15
|
-
if (!version.includes('.')) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const [major, minor, patch] = version
|
|
20
|
-
.split('.')
|
|
21
|
-
.map((v) => Number.parseInt(v, 10));
|
|
22
|
-
|
|
23
|
-
return { major, minor, patch };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
6
|
/**
|
|
27
7
|
* Check that the plugin version matches the expected version.
|
|
28
8
|
* This is a helper function which only generates a warning if there is a mismatch.
|
|
29
9
|
*/
|
|
30
10
|
export function checkPluginVersion(context: InvenTreePluginContext) {
|
|
31
|
-
|
|
32
|
-
let systemVersion: any = null;
|
|
11
|
+
const systemVersion: string = context?.version?.inventree || '';
|
|
33
12
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
systemVersion = extractVersion(context.version.inventree);
|
|
37
|
-
} catch {
|
|
38
|
-
console.warn("Failed to extract plugin version information");
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const mismatch = `Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${context.version}`;
|
|
43
|
-
|
|
44
|
-
if (!pluginVersion || !systemVersion) {
|
|
45
|
-
console.warn("Could not extract plugin version information");
|
|
46
|
-
} else if (pluginVersion.major !== systemVersion.major) {
|
|
47
|
-
// A major version mismatch indicates a potentially breaking change
|
|
48
|
-
console.warn(mismatch);
|
|
49
|
-
} else if (INVENTREE_PLUGIN_VERSION != context.version.inventree) {
|
|
50
|
-
console.info(mismatch);
|
|
13
|
+
if (INVENTREE_PLUGIN_VERSION != systemVersion) {
|
|
14
|
+
console.info(`Plugin version mismatch! Expected version ${INVENTREE_PLUGIN_VERSION}, got ${systemVersion}`);
|
|
51
15
|
}
|
|
52
16
|
}
|