push registry
This commit is contained in:
22
manager.js
22
manager.js
@@ -8,6 +8,8 @@ const entries = await fs.readdir(".", { withFileTypes: true }); // all files and
|
|||||||
|
|
||||||
let update = [];
|
let update = [];
|
||||||
let added = [];
|
let added = [];
|
||||||
|
let removed = [];
|
||||||
|
let foundPlugins = new Set();
|
||||||
|
|
||||||
// Load existing registry or create new one
|
// Load existing registry or create new one
|
||||||
let registry;
|
let registry;
|
||||||
@@ -38,6 +40,8 @@ for (const entry of entries) {
|
|||||||
const manifest = await fs.readJson(manifestPath); // manifest = data from manyplug.json
|
const manifest = await fs.readJson(manifestPath); // manifest = data from manyplug.json
|
||||||
const pluginName = manifest.name || entry.name;
|
const pluginName = manifest.name || entry.name;
|
||||||
|
|
||||||
|
foundPlugins.add(pluginName);
|
||||||
|
|
||||||
// Check if plugin exists in registry and version changed
|
// Check if plugin exists in registry and version changed
|
||||||
const existing = registry.plugins[pluginName]; // existing = plugin in registry.json
|
const existing = registry.plugins[pluginName]; // existing = plugin in registry.json
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
@@ -61,6 +65,17 @@ for (const entry of entries) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for removed plugins (exist in registry but not in filesystem)
|
||||||
|
for (const pluginName in registry.plugins) {
|
||||||
|
if (!foundPlugins.has(pluginName)) {
|
||||||
|
removed.push({
|
||||||
|
name: pluginName,
|
||||||
|
version: registry.plugins[pluginName].version
|
||||||
|
});
|
||||||
|
delete registry.plugins[pluginName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update timestamp
|
// Update timestamp
|
||||||
registry.lastUpdated = new Date().toISOString();
|
registry.lastUpdated = new Date().toISOString();
|
||||||
|
|
||||||
@@ -68,7 +83,10 @@ await fs.writeJson(regPath, registry, { spaces: 2 });
|
|||||||
|
|
||||||
console.log(chalk.green(`Registry synced\n`));
|
console.log(chalk.green(`Registry synced\n`));
|
||||||
console.log(chalk.blue(` New plugins registred (${added.length}):`));
|
console.log(chalk.blue(` New plugins registred (${added.length}):`));
|
||||||
console.log(chalk.blue(added.map(a => ` + ${a.name} (${a.version})`).join('\n')));
|
console.log(chalk.blue(added.map(a => ` + ${a.name} (${a.version})`).join('\n') || ' (none)'));
|
||||||
|
|
||||||
console.log(chalk.yellow(` Plugins updated (${update.length}):`));
|
console.log(chalk.yellow(` Plugins updated (${update.length}):`));
|
||||||
console.log(chalk.yellow(update.map(u => ` * ${u.name} (${u.oldVersion}) -> (${u.newVersion})`).join('\n')));
|
console.log(chalk.yellow(update.map(u => ` * ${u.name} (${u.oldVersion}) -> (${u.newVersion})`).join('\n') || ' (none)'));
|
||||||
|
|
||||||
|
console.log(chalk.red(` Plugins removed (${removed.length}):`));
|
||||||
|
console.log(chalk.red(removed.map(r => ` - ${r.name} (${r.version})`).join('\n') || ' (none)'));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"lastUpdated": "2026-04-17T19:02:06.357Z",
|
"lastUpdated": "2026-04-21T05:56:16.900Z",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"a": {
|
"a": {
|
||||||
"name": "a",
|
"name": "a",
|
||||||
@@ -53,11 +53,12 @@
|
|||||||
"service": false,
|
"service": false,
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
},
|
},
|
||||||
"xp": {
|
"obrigado": {
|
||||||
"name": "xp",
|
"name": "obrigado",
|
||||||
"version": "0.1.0",
|
"author": "SyntaxError <dev@maneos.net> (https://git.maneos.net)",
|
||||||
"category": "social",
|
"version": "1.0.0",
|
||||||
"service": true,
|
"category": "fun",
|
||||||
|
"service": false,
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user