perf: check in neural patterns to avoid rebuild on every publish
- Add embeddedPatterns.ts to version control (544KB file) - Add check-patterns.js script to detect when rebuild is needed - Modify build scripts to only rebuild patterns when changed - This avoids memory-intensive pattern embedding on every npm publish - Patterns rarely change, so this significantly speeds up releases
This commit is contained in:
parent
394acc3516
commit
e30d207cb6
3 changed files with 36 additions and 2 deletions
32
scripts/check-patterns.js
Normal file
32
scripts/check-patterns.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Check if neural patterns need rebuilding
|
||||
* Only rebuild if:
|
||||
* 1. embeddedPatterns.ts doesn't exist
|
||||
* 2. Pattern library source has changed
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const EMBEDDED_FILE = path.join(__dirname, '../src/neural/embeddedPatterns.ts');
|
||||
const PATTERN_LIBRARY = path.join(__dirname, '../src/neural/patternLibrary.ts');
|
||||
|
||||
// Check if embedded patterns exist
|
||||
if (!fs.existsSync(EMBEDDED_FILE)) {
|
||||
console.log('❌ Embedded patterns not found. Building...');
|
||||
process.exit(1); // Signal need to rebuild
|
||||
}
|
||||
|
||||
// Check if pattern library is newer than embedded patterns
|
||||
const embeddedStats = fs.statSync(EMBEDDED_FILE);
|
||||
const libraryStats = fs.statSync(PATTERN_LIBRARY);
|
||||
|
||||
if (libraryStats.mtime > embeddedStats.mtime) {
|
||||
console.log('🔄 Pattern library has changed. Rebuilding...');
|
||||
process.exit(1); // Signal need to rebuild
|
||||
}
|
||||
|
||||
console.log('✅ Embedded patterns are up-to-date. Skipping rebuild.');
|
||||
process.exit(0); // No rebuild needed
|
||||
Loading…
Add table
Add a link
Reference in a new issue