Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

feat: add dashboard-icons as icon fallback source

dbraendle7800b41dcb95
diff --git a/bin/options/icon.ts b/bin/options/icon.ts
index 6b303714..863e14fa 100644
--- a/bin/options/icon.ts
+++ b/bin/options/icon.ts
@@ -398,6 +398,29 @@ function generateIconServiceUrls(domain: string): string[] {
];
}
+/**
+ * Generates dashboard-icons URLs for an app name.
+ * Uses walkxcode/dashboard-icons, the most popular icon set for selfhosted dashboards.
+ * Tries multiple slug variations to maximize match rate.
+ */
+function generateDashboardIconUrls(appName: string): string[] {
+ const baseUrl =
+ 'https://cdn.jsdelivr.net/gh/walkxcode/dashboard-icons/png';
+ const name = appName.toLowerCase().trim();
+ const slugs = new Set<string>();
+
+ // Exact name
+ slugs.add(name);
+ // Replace spaces with hyphens
+ slugs.add(name.replace(/\s+/g, '-'));
+ // Remove common suffixes
+ slugs.add(name.replace(/[-\s]?(ng|ngx|web|app|server|ui)$/i, ''));
+
+ return [...slugs]
+ .filter((s) => s.length > 0)
+ .map((slug) => `${baseUrl}/${slug}.png`);
+}
+
/**
* Attempts to fetch favicon from website
*/
@@ -409,14 +432,48 @@ async function tryGetFavicon(
const domain = new URL(url).hostname;
const spinner = getSpinner(`Fetching icon from ${domain}...`);
- const serviceUrls = generateIconServiceUrls(domain);
-
const isCI =
process.env.CI === 'true' || process.env.GITHUB_ACTIONS === 'true';
const downloadTimeout = isCI
? ICON_CONFIG.downloadTimeout.ci
: ICON_CONFIG.downloadTimeout.default;
+ // Try dashboard-icons first (accurate match by app name, covers
+ // selfhosted apps behind auth where domain-based services fail)
+ if (appName) {
+ const dashboardIconUrls = generateDashboardIconUrls(appName);
+ for (const iconUrl of dashboardIconUrls) {
+ try {
+ const iconPath = await downloadIcon(iconUrl, false, downloadTimeout);
+ if (!iconPath) continue;
+
+ const convertedPath = await convertIconFormat(iconPath, appName);
+ if (convertedPath) {
+ const finalPath = await copyWindowsIconIfNeeded(
+ convertedPath,
+ appName,
+ );
+ spinner.succeed(
+ chalk.green(
+ `Icon found via dashboard-icons for "${appName}"!`,
+ ),
+ );
+ return finalPath;
+ }
+ } catch (error: unknown) {
+ if (error instanceof Error) {
+ logger.debug(
+ `Dashboard icon ${iconUrl} failed: ${error.message}`,
+ );
+ }
+ continue;
+ }
+ }
+ }
+
+ // Fall back to domain-based icon services
+ const serviceUrls = generateIconServiceUrls(domain);
+
for (const serviceUrl of serviceUrls) {
try {
const faviconPath = await downloadIcon(