| #!/usr/bin/env node |
| |
| |
| |
| |
| |
| 'use strict'; |
| const fs = require('fs'); |
| const path = require('path'); |
|
|
| const FORGE = path.join(__dirname, '..'); |
| const FLM_LIST = 'C:\\Program Files\\flm\\model_list.json'; |
| const REGISTRY = path.join(FORGE, 'registry.json'); |
|
|
| function main() { |
| if (!fs.existsSync(REGISTRY)) { console.log('No registry.json — nothing to register.'); return; } |
| const reg = JSON.parse(fs.readFileSync(REGISTRY, 'utf8').replace(/^/, '')); |
| const ml = JSON.parse(fs.readFileSync(FLM_LIST, 'utf8').replace(/^/, '')); |
|
|
| |
| const stamp = new Date().toISOString().replace(/[:.]/g, '-'); |
| fs.copyFileSync(FLM_LIST, path.join(FORGE, `model_list.backup-${stamp}.json`)); |
|
|
| let added = 0, kept = 0; |
| for (const [key, sizes] of Object.entries(reg.models || {})) { |
| for (const [size, entry] of Object.entries(sizes)) { |
| ml.models[key] = ml.models[key] || {}; |
| if (ml.models[key][size] && JSON.stringify(ml.models[key][size]) === JSON.stringify(entry)) { kept++; continue; } |
| ml.models[key][size] = entry; |
| added++; |
| console.log(`registered: ${key}:${size} -> ${entry.name}`); |
| } |
| } |
| try { |
| fs.writeFileSync(FLM_LIST, JSON.stringify(ml, null, 2)); |
| } catch (e) { |
| console.error('\n[!] Could not write ' + FLM_LIST); |
| console.error(' This needs administrator rights — double-click register-admin.bat instead.'); |
| process.exit(1); |
| } |
| console.log(`\nDone: ${added} entries written, ${kept} already current.`); |
| console.log('Verify with: flm list (your models end in -forge)'); |
| } |
|
|
| main(); |
|
|