/** * Version management utilities * Centralizes version information */ // Note: In a real implementation, this would read from package.json // For now, we'll use a hardcoded version to avoid build issues const PACKAGE_VERSION = '1.0.0'; const PACKAGE_NAME = '@brazil-swift-ops/utils'; let cachedVersion = null; /** * Get version information */ export function getVersion() { if (cachedVersion) { return cachedVersion; } cachedVersion = { version: PACKAGE_VERSION, name: PACKAGE_NAME, buildDate: new Date(), gitCommit: typeof process !== 'undefined' ? (process.env?.GIT_COMMIT || process.env?.VERCEL_GIT_COMMIT_SHA) : undefined, gitBranch: typeof process !== 'undefined' ? (process.env?.GIT_BRANCH || process.env?.VERCEL_GIT_COMMIT_REF) : undefined, }; return cachedVersion; } /** * Get version string */ export function getVersionString() { const v = getVersion(); return `${v.name} v${v.version}`; } /** * Compare two version strings * Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2 */ export function compareVersions(v1, v2) { const parts1 = v1.split('.').map(Number); const parts2 = v2.split('.').map(Number); const maxLength = Math.max(parts1.length, parts2.length); for (let i = 0; i < maxLength; i++) { const part1 = parts1[i] || 0; const part2 = parts2[i] || 0; if (part1 < part2) return -1; if (part1 > part2) return 1; } return 0; } /** * Check if version is compatible */ export function isVersionCompatible(version, minVersion, maxVersion) { if (compareVersions(version, minVersion) < 0) { return false; } if (maxVersion && compareVersions(version, maxVersion) > 0) { return false; } return true; } /** * Format version for display */ export function formatVersion(version) { const parts = [`v${version.version}`]; if (version.gitCommit) { parts.push(`(${version.gitCommit.substring(0, 7)})`); } if (version.gitBranch) { parts.push(`[${version.gitBranch}]`); } return parts.join(' '); } //# sourceMappingURL=version.js.map