mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-21 22:30:53 +00:00
* Pass more stuff to window * Expose form functions to plugin context * Breaking: Render plugin component in context tree - Required due to createRoot function - Adds necessary context providers * Fix context * Provide MantineThemeContext * Bundle mantine/core * Hack for useNavigate within ApiForm - Errors out if called within plugin context - Workaround to catch the error * Update build cmd * Define config for building "Library" mode * Update package.json * Add basic index file * Factor out ApiEndpoints * factor out ModelType * Factor out role enums * Further refactoring * More refactoring * Cleanup * Expose apiUrl function * Add instance data to plugin context type def * Tweaks for loading plugin components - LanguageContext must be on the inside * Tweak StylishText * Externalize notifications system * Update lingui config * Add functions for checking plugin interface version * Extract package version at build time * Enhance version checking * Revert variable name change * Public package * Add README.md * adjust packge name * Adjust name to include org * Update project files * Add basic changelog info * Refactoring to expose URL functions * Refactor navigation functions * Update package and README * Improve navigateToLink function * Refactor stylish text - Move into ./lib - Do not require user state * Revert changes - StylishText throws error in plugin - Low priority, can work out later * expose function to refresh page index * Provide RemoteComponent with a method to reload itself * Bump version * Cleanup tests * Prevent duplicate --emptyOutDir arg * Tweak playwright tests * Expose role and permission enums * Fix imports * Updated docs * Fix spelling, typos, etc * Include more package version information * Expose more version context * Cleanup * Probably don't need hooks * Fix links * Docs updates * Fix links
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
/**
|
|
* Extract package version information from package.json
|
|
*/
|
|
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const packageJson = JSON.parse(readFileSync('./package.json', 'utf-8'));
|
|
|
|
// Function to get the version of a specific package
|
|
function getPackageVersion(pkg: string) {
|
|
const version: string =
|
|
packageJson.dependencies[pkg] ||
|
|
packageJson.peerDependencies[pkg] ||
|
|
packageJson.devDependencies[pkg];
|
|
|
|
if (!version) {
|
|
throw new Error(`Package ${pkg} not found in package.json`);
|
|
}
|
|
|
|
// Strip any version prefix (e.g. "^", "~", "@")
|
|
const versionMatch = version.match(/(\d+\.\d+\.\d+)/);
|
|
if (!versionMatch) {
|
|
throw new Error(`Invalid version format for package ${pkg}: ${version}`);
|
|
}
|
|
|
|
return JSON.stringify(versionMatch[0]);
|
|
}
|
|
|
|
// Export InvenTree package information
|
|
export const INVENTREE_LIB_VERSION: string = JSON.stringify(
|
|
packageJson.version
|
|
);
|
|
|
|
// Export information about other core package versions
|
|
// This is because we need to ensure that the versions of these packages are compatible with plugins
|
|
export const __INVENTREE_VERSION_INFO__ = {
|
|
__INVENTREE_LIB_VERSION__: INVENTREE_LIB_VERSION,
|
|
__INVENTREE_REACT_VERSION__: getPackageVersion('react'),
|
|
__INVENTREE_REACT_DOM_VERSION__: getPackageVersion('react-dom'),
|
|
__INVENTREE_MANTINE_VERSION__: getPackageVersion('@mantine/core')
|
|
};
|