( allScripts: InternalScript[], apps: AppEntry[], tagAppMap: Record<string, string[]>, )
| 687 | } |
| 688 | |
| 689 | function attachScriptsToApps( |
| 690 | allScripts: InternalScript[], |
| 691 | apps: AppEntry[], |
| 692 | tagAppMap: Record<string, string[]>, |
| 693 | ): void { |
| 694 | const appScriptsMap: Record<string, InternalScript[]> = {}; |
| 695 | |
| 696 | for (const s of allScripts) { |
| 697 | if (!s.matchedApp) continue; |
| 698 | const appIds = Array.isArray(s.matchedApp) ? s.matchedApp : [s.matchedApp]; |
| 699 | for (const appId of appIds) { |
| 700 | if (!appScriptsMap[appId]) appScriptsMap[appId] = []; |
| 701 | appScriptsMap[appId].push(s); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | const imageTagPairs = detectImageTagPairs(allScripts); |
| 706 | const skinVariants = detectSkinVariants(allScripts); |
| 707 | |
| 708 | for (const app of apps) { |
| 709 | const scripts = appScriptsMap[app.id] || []; |
| 710 | app.scripts = scripts.map((s) => ({ |
| 711 | name: s.name, |
| 712 | file: s.file || s.name || '', |
| 713 | findRegex: s.findRegex, |
| 714 | replaceString: s.replaceString, |
| 715 | type: s.type, |
| 716 | disabled: s.disabled, |
| 717 | placement: s.placement, |
| 718 | runOnEdit: s.runOnEdit, |
| 719 | source: s._source || 'unknown', |
| 720 | })); |
| 721 | |
| 722 | app.imageTagPairs = imageTagPairs.filter((p) => { |
| 723 | const appIds = tagAppMap[p.tag]; |
| 724 | return appIds ? appIds.includes(app.id) : false; |
| 725 | }); |
| 726 | |
| 727 | app.skinVariants = skinVariants.filter((v) => |
| 728 | v.variants.some((va) => scripts.some((s) => (s.file || s.name || '') === va.file)), |
| 729 | ); |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | // ── App Consolidation via LLM ───────────────────────────────────── |
| 734 |
no test coverage detected