fix: Resolve version display issues in Obsidian (v0.3.2)

- Fix version.ts to use build-time injection instead of runtime package.json reading
- Update sync-version.mjs to also sync version.ts file
- Eliminate "Could not read version from package.json" warnings
- Plugin now correctly displays v0.3.2 instead of fallback v0.2.0

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Aaron Bockelie 2025-06-27 13:11:40 -05:00
parent 7d202b8749
commit 1e366dfe56
4 changed files with 14 additions and 28 deletions

View file

@ -1,7 +1,7 @@
{
"id": "obsidian-mcp-plugin",
"name": "Obsidian MCP Plugin",
"version": "0.3.1",
"version": "0.3.2",
"minAppVersion": "0.15.0",
"description": "Semantic MCP server plugin providing AI tools with direct Obsidian vault access via HTTP transport",
"author": "Aaron Bockelie",

View file

@ -1,6 +1,6 @@
{
"name": "obsidian-mcp-plugin",
"version": "0.3.1",
"version": "0.3.2",
"description": "Semantic MCP server plugin providing AI tools with direct Obsidian vault access via HTTP transport",
"main": "main.js",
"scripts": {

View file

@ -1,26 +1,4 @@
import { readFileSync } from 'fs';
import { resolve } from 'path';
let cachedVersion: string | null = null;
// Version is injected at build time by sync-version.mjs
export function getVersion(): string {
if (cachedVersion) {
return cachedVersion;
}
// Fallback version in case reading fails
let version = '0.2.0';
try {
// In an Obsidian plugin, we need to find package.json relative to the plugin directory
// This works whether we're in development (src/) or production (main.js)
const packageJsonPath = resolve(__dirname, '..', 'package.json');
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
version = packageJson.version;
cachedVersion = version;
} catch (error) {
console.warn('Could not read version from package.json, using fallback:', version);
}
return version;
}
return '0.3.2';
}

View file

@ -14,7 +14,15 @@ try {
// Write updated manifest.json
writeFileSync('manifest.json', JSON.stringify(manifest, null, 2) + '\n');
console.log(`✅ Synced version ${version} from package.json to manifest.json`);
// Update version.ts
const versionTs = `// Version is injected at build time by sync-version.mjs
export function getVersion(): string {
return '${version}';
}
`;
writeFileSync('src/version.ts', versionTs);
console.log(`✅ Synced version ${version} from package.json to manifest.json and version.ts`);
} catch (error) {
console.error('❌ Failed to sync version:', error.message);
process.exit(1);