feat: add Renovate regex manager and postUpgradeTasks for skill auto-sync
This commit is contained in:
1 parent
c9891ba184
commit
f840ed2cf7
4 files changed
+92
-2
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const rootDir = path.resolve(__dirname, "..");
|
||||
const configPath = path.join(rootDir, "skills.json");
|
||||
|
||||
async function main() {
|
||||
const raw = await fs.readFile(configPath, "utf-8");
|
||||
const config = JSON.parse(raw);
|
||||
|
||||
console.log(`[sync-skills] Found ${Object.keys(config.skills).length} skill definitions`);
|
||||
|
||||
for (const [name, def] of Object.entries(config.skills)) {
|
||||
const { version, url, destination } = def;
|
||||
const targetUrl = url.replace("{version}", version);
|
||||
const destPath = path.join(rootDir, destination);
|
||||
|
||||
console.log(`[sync-skills] Syncing ${name} (${version}) from ${targetUrl}...`);
|
||||
const res = await fetch(targetUrl);
|
||||
if (!res.ok) {
|
||||
throw new Error(`Failed to fetch ${targetUrl}: HTTP ${res.status} ${res.statusText}`);
|
||||
}
|
||||
|
||||
const content = await res.text();
|
||||
if (!content.trim()) {
|
||||
throw new Error(`Fetched empty content for ${name}`);
|
||||
}
|
||||
|
||||
await fs.mkdir(path.dirname(destPath), { recursive: true });
|
||||
await fs.writeFile(destPath, content, "utf-8");
|
||||
console.log(`[sync-skills] ✓ Updated ${destination} (${content.length} bytes)`);
|
||||
}
|
||||
|
||||
console.log("[sync-skills] All skills synced successfully.");
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error("[sync-skills] Error:", err.message);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in new issue
Block a user