2025-12-12 19:45:39 +00:00
|
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
|
|
const { execSync } = require('child_process');
|
|
|
|
|
|
|
2026-04-29 14:41:24 +00:00
|
|
|
|
const stagedFiles = execSync('git diff --cached --name-only', {
|
|
|
|
|
|
encoding: 'utf-8',
|
|
|
|
|
|
})
|
2025-12-12 19:45:39 +00:00
|
|
|
|
.trim()
|
|
|
|
|
|
.split('\n')
|
|
|
|
|
|
.filter(Boolean);
|
|
|
|
|
|
|
2026-04-29 14:41:24 +00:00
|
|
|
|
const hasCodeChanges = stagedFiles.some((file) => file.endsWith('.ts') || file.endsWith('.tsx'));
|
2025-12-12 19:45:39 +00:00
|
|
|
|
|
|
|
|
|
|
const manifestChanged = stagedFiles.includes('manifest.json');
|
|
|
|
|
|
|
|
|
|
|
|
if (hasCodeChanges && !manifestChanged) {
|
|
|
|
|
|
console.error('\x1b[33m⚠️ You have changed the code but have not updated manifest.json.\x1b[0m');
|
|
|
|
|
|
console.error('\x1b[33m Have you forgotten to update the plugin version?\x1b[0m');
|
|
|
|
|
|
console.error('');
|
|
|
|
|
|
console.error('If you are sure that the version does not need to be changed, use:');
|
|
|
|
|
|
console.error(' git commit --no-verify');
|
|
|
|
|
|
console.error('');
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (manifestChanged && hasCodeChanges) {
|
|
|
|
|
|
try {
|
2026-04-29 14:41:24 +00:00
|
|
|
|
const manifestDiff = execSync('git diff --cached manifest.json', {
|
|
|
|
|
|
encoding: 'utf-8',
|
|
|
|
|
|
});
|
2025-12-12 19:45:39 +00:00
|
|
|
|
|
|
|
|
|
|
if (!manifestDiff.includes('"version"')) {
|
|
|
|
|
|
console.error('\x1b[33m⚠️ manifest.json has been modified, but the version has not been updated!\x1b[0m');
|
|
|
|
|
|
console.error('');
|
|
|
|
|
|
console.error('If this is intentional, use:');
|
|
|
|
|
|
console.error(' git commit --no-verify');
|
|
|
|
|
|
console.error('');
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
}
|
2026-04-29 14:41:24 +00:00
|
|
|
|
} catch (error) {}
|
2025-12-12 19:45:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log('\x1b[32m✓ Version check passed\x1b[0m');
|
|
|
|
|
|
process.exit(0);
|