mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-13 03:34:55 +08:00
Compare commits
5 Commits
85f67c2ec6
...
v1.2.256.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b3169e5f6 | ||
|
|
9d2e245a99 | ||
|
|
0513c3a128 | ||
|
|
5082c4c245 | ||
|
|
659b4d0e60 |
20
.github/workflows/plugin-registry-check.yml
vendored
Normal file
20
.github/workflows/plugin-registry-check.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Plugin Registry Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'Community/plugins-registry.json'
|
||||
|
||||
jobs:
|
||||
check-collision:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Run Hash Collision Check
|
||||
run: node Community/scripts/check-hash-collision.js
|
||||
1
Community/plugins-registry.json
Normal file
1
Community/plugins-registry.json
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
40
Community/scripts/check-hash-collision.js
Normal file
40
Community/scripts/check-hash-collision.js
Normal file
@@ -0,0 +1,40 @@
|
||||
// Community/scripts/check-hash-collision.js
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const registryPath = path.join(__dirname, '../plugins-registry.json');
|
||||
const registry = JSON.parse(fs.readFileSync(registryPath, 'utf8'));
|
||||
|
||||
function getStableId(pluginId) {
|
||||
let hash = 23;
|
||||
for (let i = 0; i < pluginId.length; i++) {
|
||||
hash = (hash * 31 + pluginId.charCodeAt(i)) | 0;
|
||||
}
|
||||
return Math.abs(hash) + 1000;
|
||||
}
|
||||
|
||||
const seenIds = new Set();
|
||||
let hasError = false;
|
||||
|
||||
console.log("🔍 Starting to check for plugin ID conflicts...");
|
||||
|
||||
registry.forEach(item => {
|
||||
const stableId = getStableId(item.id);
|
||||
|
||||
console.log(`Checking [${item.id}] -> Hash: ${stableId}`);
|
||||
|
||||
if (seenIds.has(stableId)) {
|
||||
console.error(`⛔ Fatel error! Conflict detected!`);
|
||||
console.error(`The hash value (${stableId}) calculated from the plugin ID [${item.id}] is duplicated with an existing plugin.`);
|
||||
hasError = true;
|
||||
}
|
||||
seenIds.add(stableId);
|
||||
});
|
||||
|
||||
if (hasError) {
|
||||
console.log("⛔ Check failed, please change the plugin ID.");
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log("✅ The check passed; no conflicts were found.");
|
||||
process.exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user