feat: cache logos locally, show config_path, rename Sync button (#511)
- logoCacheService.ts: download script logos to public/logos/ for local serving - cache-logos.ts: build-time script caching 500+ logos from PocketBase - scripts.ts router: resolve local logo paths, resyncScripts now caches logos - autoSyncService.js: cache logos during background auto-sync - ScriptDetailModal: show config_path per install method - ResyncButton: renamed 'Sync Json Files' to 'Sync Scripts' - GeneralSettingsModal: updated auto-sync description text - .gitignore: ignore public/logos/ and data/*.db
This commit is contained in:
committed by
GitHub
parent
d8e92e0445
commit
e2a950da58
32
scripts/cache-logos.ts
Normal file
32
scripts/cache-logos.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Build-time script: fetch all logos from PocketBase and cache them to public/logos/.
|
||||
* Called as part of `npm run build` so the app starts with logos pre-cached.
|
||||
*/
|
||||
|
||||
import { getPb } from '../src/server/services/pbService';
|
||||
import { cacheLogos } from '../src/server/services/logoCacheService';
|
||||
|
||||
async function main() {
|
||||
console.log('[cache-logos] Fetching script list from PocketBase...');
|
||||
const pb = getPb();
|
||||
const records = await pb.collection('script_scripts').getFullList({
|
||||
fields: 'slug,logo',
|
||||
batch: 500,
|
||||
});
|
||||
|
||||
const entries = records
|
||||
.filter((r) => r.logo)
|
||||
.map((r) => ({ slug: r.slug, url: r.logo }));
|
||||
|
||||
console.log(`[cache-logos] Caching ${entries.length} logos...`);
|
||||
const result = await cacheLogos(entries);
|
||||
console.log(
|
||||
`[cache-logos] Done: ${result.downloaded} downloaded, ${result.skipped} already cached, ${result.errors} errors`,
|
||||
);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('[cache-logos] Failed:', err);
|
||||
// Non-fatal — build should continue even if logo caching fails
|
||||
process.exit(0);
|
||||
});
|
||||
Reference in New Issue
Block a user