feat: integrate automatic template sanitization into rebuild process

- Update rebuild script to automatically sanitize templates after node processing
- Update documentation to reflect GitHub push protection changes
- Add notes about template sanitization in n8n update process
- Ensures databases are always clean before push

This prevents GitHub push protection from blocking database updates
due to API tokens in workflow templates.

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-07-06 13:34:52 +02:00
parent 74f018049d
commit e912b1c90d
2 changed files with 41 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import { N8nNodeLoader } from '../loaders/node-loader';
import { NodeParser } from '../parsers/node-parser';
import { DocsMapper } from '../mappers/docs-mapper';
import { NodeRepository } from '../database/node-repository';
import { TemplateSanitizer } from '../utils/template-sanitizer';
import * as fs from 'fs';
import * as path from 'path';
@@ -99,6 +100,33 @@ async function rebuild() {
validationResults.issues.forEach(issue => console.log(` - ${issue}`));
}
// Sanitize templates if they exist
console.log('\n🧹 Checking for templates to sanitize...');
const templateCount = db.prepare('SELECT COUNT(*) as count FROM templates').get() as { count: number };
if (templateCount && templateCount.count > 0) {
console.log(` Found ${templateCount.count} templates, sanitizing...`);
const sanitizer = new TemplateSanitizer();
let sanitizedCount = 0;
const templates = db.prepare('SELECT id, name, workflow_json FROM templates').all() as any[];
for (const template of templates) {
const originalWorkflow = JSON.parse(template.workflow_json);
const { sanitized: sanitizedWorkflow, wasModified } = sanitizer.sanitizeWorkflow(originalWorkflow);
if (wasModified) {
const stmt = db.prepare('UPDATE templates SET workflow_json = ? WHERE id = ?');
stmt.run(JSON.stringify(sanitizedWorkflow), template.id);
sanitizedCount++;
console.log(` ✅ Sanitized template ${template.id}: ${template.name}`);
}
}
console.log(` Sanitization complete: ${sanitizedCount} templates cleaned`);
} else {
console.log(' No templates found in database');
}
console.log('\n✨ Rebuild complete!');
db.close();