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
bf6e026d75
commit
6f65847656
3 changed files with 36 additions and 2 deletions
|
|
@ -58,8 +58,10 @@
|
||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:patterns && tsc",
|
"build": "npm run build:patterns:if-needed && tsc",
|
||||||
"build:patterns": "tsx scripts/buildEmbeddedPatterns.ts",
|
"build:patterns": "tsx scripts/buildEmbeddedPatterns.ts",
|
||||||
|
"build:patterns:if-needed": "node scripts/check-patterns.js || npm run build:patterns",
|
||||||
|
"build:patterns:force": "npm run build:patterns",
|
||||||
"prepare": "npm run build",
|
"prepare": "npm run build",
|
||||||
"test": "npm run test:unit",
|
"test": "npm run test:unit",
|
||||||
"test:watch": "vitest --config tests/configs/vitest.unit.config.ts",
|
"test:watch": "vitest --config tests/configs/vitest.unit.config.ts",
|
||||||
|
|
|
||||||
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
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* 🧠 BRAINY EMBEDDED PATTERNS
|
* 🧠 BRAINY EMBEDDED PATTERNS
|
||||||
*
|
*
|
||||||
* AUTO-GENERATED - DO NOT EDIT
|
* AUTO-GENERATED - DO NOT EDIT
|
||||||
* Generated: 2025-08-26T20:39:24.051Z
|
* Generated: 2025-08-27T16:37:10.556Z
|
||||||
* Patterns: 220
|
* Patterns: 220
|
||||||
* Coverage: 94-98% of all queries
|
* Coverage: 94-98% of all queries
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue