2025-08-26 12:32:21 -07:00
|
|
|
/**
|
|
|
|
|
* Version utilities for Brainy
|
|
|
|
|
*/
|
|
|
|
|
|
feat: add node: protocol to all Node.js built-in imports for bundler compatibility
- Updated all fs, path, crypto, os, url, util, events, http, https, net, child_process, stream, and zlib imports
- Changed both static imports and dynamic imports to use node: protocol
- This makes Brainy more bundler-friendly by explicitly marking Node.js built-ins
- Prevents bundlers from attempting to polyfill or bundle these modules
- Reduces bundle size for web applications using Brainy
- Improves tree-shaking and dead code elimination
Benefits for external bundlers:
- Clear distinction between Node.js built-ins and external dependencies
- No ambiguity about what needs polyfilling
- Smaller bundles for browser builds
- Better compatibility with modern bundlers (Webpack 5, Vite, Rollup, esbuild)
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-17 14:20:21 -07:00
|
|
|
import { readFileSync } from 'node:fs'
|
|
|
|
|
import { join, dirname } from 'node:path'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
2025-08-28 16:58:35 -07:00
|
|
|
|
|
|
|
|
// Get package.json path relative to this file
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url)
|
|
|
|
|
const __dirname = dirname(__filename)
|
|
|
|
|
const packageJsonPath = join(__dirname, '../../package.json')
|
|
|
|
|
|
|
|
|
|
let cachedVersion: string | null = null
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the current Brainy package version
|
|
|
|
|
* @returns The current version string
|
|
|
|
|
*/
|
|
|
|
|
export function getBrainyVersion(): string {
|
2025-08-28 16:58:35 -07:00
|
|
|
if (!cachedVersion) {
|
|
|
|
|
try {
|
|
|
|
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))
|
|
|
|
|
cachedVersion = packageJson.version
|
|
|
|
|
} catch {
|
|
|
|
|
// Fallback version if package.json can't be read
|
|
|
|
|
cachedVersion = '2.7.1'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return cachedVersion!
|
2025-08-26 12:32:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get version information for augmentation metadata
|
|
|
|
|
* @param service The service/augmentation name
|
|
|
|
|
* @returns Version metadata object
|
|
|
|
|
*/
|
|
|
|
|
export function getAugmentationVersion(service: string): { augmentation: string; version: string } {
|
|
|
|
|
return {
|
|
|
|
|
augmentation: service,
|
|
|
|
|
version: getBrainyVersion()
|
|
|
|
|
}
|
|
|
|
|
}
|