feat: Release v4.0.5 - Auto-install dependencies via bootstrap hooks
Fixed better-sqlite3 distribution by implementing self-bootstrapping hooks that auto-install dependencies on first run. This eliminates the need for users to have native compilation tools or manually install dependencies. ## Solution Instead of bundling 25MB of better-sqlite3 binaries in git or requiring manual npm install, hooks now bootstrap themselves on first execution: 1. Created `src/shared/bootstrap.ts` with `ensureDependencies()` function 2. Added bootstrap calls to all hook entry points (context, new, save, summary, cleanup) 3. Created `plugin/scripts/package.json` declaring better-sqlite3 dependency 4. Bootstrap checks if `node_modules` exists, runs `npm install` if missing 5. npm automatically downloads prebuilt better-sqlite3 binary for user's platform ## Changes **Core Bootstrap System:** - Added src/shared/bootstrap.ts: Auto-install dependencies using npm - Modified all hooks (context, new, save, summary, cleanup) to call ensureDependencies() - Created plugin/scripts/package.json with better-sqlite3 dependency **Build & Distribution:** - Removed node_modules copying logic from build script - Build output is now compact (hooks + package.json, no binaries) - Updated marketplace.json to point to GitHub for direct installation **Documentation:** - Updated README: GitHub Marketplace installation is now recommended method - Installation instructions emphasize no compilation needed - Version bumped to 4.0.5 throughout ## Benefits - ✅ No git bloat (repo stays small, no 25MB binaries committed) - ✅ No compilation needed (npm downloads prebuilt binaries) - ✅ Works on all platforms (npm handles platform-specific binaries) - ✅ Zero manual steps (hooks bootstrap themselves automatically) - ✅ Idempotent (skips install if dependencies already exist) Installation now works via simple: ``` /plugin marketplace add https://github.com/thedotmack/claude-mem /plugin install claude-mem ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import { execSync } from 'child_process';
|
||||
import { existsSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
/**
|
||||
* Bootstrap function to ensure dependencies are installed
|
||||
* This runs on first hook execution after plugin installation from GitHub
|
||||
*
|
||||
* When installed via GitHub Marketplace, files are downloaded but npm install
|
||||
* doesn't run automatically. This function checks for node_modules and installs
|
||||
* dependencies if needed.
|
||||
*/
|
||||
export function ensureDependencies(): void {
|
||||
try {
|
||||
// Get plugin root from environment variable
|
||||
const pluginRoot = process.env.CLAUDE_PLUGIN_ROOT;
|
||||
if (!pluginRoot) {
|
||||
console.error('[bootstrap] CLAUDE_PLUGIN_ROOT not set, skipping dependency check');
|
||||
return;
|
||||
}
|
||||
|
||||
const scriptsDir = join(pluginRoot, 'scripts');
|
||||
const nodeModulesPath = join(scriptsDir, 'node_modules');
|
||||
|
||||
// Check if dependencies are already installed
|
||||
if (existsSync(nodeModulesPath)) {
|
||||
return; // Already installed
|
||||
}
|
||||
|
||||
console.error('[bootstrap] Installing dependencies in plugin/scripts...');
|
||||
|
||||
// Install dependencies using npm
|
||||
execSync('npm install', {
|
||||
cwd: scriptsDir,
|
||||
stdio: 'inherit', // Show install progress
|
||||
timeout: 60000 // 60 second timeout
|
||||
});
|
||||
|
||||
console.error('[bootstrap] Dependencies installed successfully');
|
||||
} catch (error) {
|
||||
console.error('[bootstrap] Failed to install dependencies:', error instanceof Error ? error.message : error);
|
||||
// Don't throw - allow hook to continue, it will fail on import but with clearer error
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user