import {
BranchProtectionEngine,
BranchProtectionManager,
PROTECTION_PRESETS
} from 'wit';
// Create engine
const engine = new BranchProtectionEngine(gitDir);
const manager = engine.getManager();
// Add rule
const rule = manager.addRule('main', {
...PROTECTION_PRESETS.strict,
description: 'Main branch protection',
});
// Check operations
const pushResult = engine.canPush('main', userId);
const forcePushResult = engine.canForcePush('main', userId);
const deleteResult = engine.canDeleteBranch('main', userId);
const mergeResult = engine.canMerge('main', {
approvalCount: 2,
passedChecks: ['test', 'build'],
isBranchUpToDate: true,
});
// Get summary
const summary = engine.getProtectionSummary('main');
console.log('Protected:', summary.isProtected);
console.log('Blocks push:', summary.blocksPush);