Auto-fix formatting issues
This commit is contained in:
50
bin/options/icon.ts
vendored
50
bin/options/icon.ts
vendored
@@ -20,14 +20,7 @@ type PlatformIconConfig = {
|
|||||||
};
|
};
|
||||||
const ICON_CONFIG = {
|
const ICON_CONFIG = {
|
||||||
minFileSize: 100,
|
minFileSize: 100,
|
||||||
supportedFormats: [
|
supportedFormats: ['png', 'ico', 'jpeg', 'jpg', 'webp', 'icns'] as const,
|
||||||
'png',
|
|
||||||
'ico',
|
|
||||||
'jpeg',
|
|
||||||
'jpg',
|
|
||||||
'webp',
|
|
||||||
'icns',
|
|
||||||
] as const,
|
|
||||||
whiteBackground: { r: 255, g: 255, b: 255 },
|
whiteBackground: { r: 255, g: 255, b: 255 },
|
||||||
transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },
|
transparentBackground: { r: 255, g: 255, b: 255, alpha: 0 },
|
||||||
downloadTimeout: {
|
downloadTimeout: {
|
||||||
@@ -43,14 +36,8 @@ const PLATFORM_CONFIG: Record<'win' | 'linux' | 'macos', PlatformIconConfig> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const API_KEYS = {
|
const API_KEYS = {
|
||||||
logoDev: [
|
logoDev: ['pk_JLLMUKGZRpaG5YclhXaTkg', 'pk_Ph745P8mQSeYFfW2Wk039A'],
|
||||||
'pk_JLLMUKGZRpaG5YclhXaTkg',
|
brandfetch: ['1idqvJC0CeFSeyp3Yf7', '1idej-yhU_ThggIHFyG'],
|
||||||
'pk_Ph745P8mQSeYFfW2Wk039A',
|
|
||||||
],
|
|
||||||
brandfetch: [
|
|
||||||
'1idqvJC0CeFSeyp3Yf7',
|
|
||||||
'1idej-yhU_ThggIHFyG',
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +70,9 @@ async function copyWindowsIconIfNeeded(
|
|||||||
await fsExtra.copy(convertedPath, finalIconPath);
|
await fsExtra.copy(convertedPath, finalIconPath);
|
||||||
return finalIconPath;
|
return finalIconPath;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn(`Failed to copy Windows icon: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
logger.warn(
|
||||||
|
`Failed to copy Windows icon: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
||||||
|
);
|
||||||
return convertedPath;
|
return convertedPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +177,10 @@ async function convertIconFormat(
|
|||||||
/**
|
/**
|
||||||
* Processes downloaded or local icon for platform-specific format
|
* Processes downloaded or local icon for platform-specific format
|
||||||
*/
|
*/
|
||||||
async function processIcon(iconPath: string, appName: string): Promise<string | null> {
|
async function processIcon(
|
||||||
|
iconPath: string,
|
||||||
|
appName: string,
|
||||||
|
): Promise<string | null> {
|
||||||
if (!iconPath || !appName) return iconPath;
|
if (!iconPath || !appName) return iconPath;
|
||||||
|
|
||||||
// Check if already in correct platform format
|
// Check if already in correct platform format
|
||||||
@@ -219,7 +211,10 @@ async function getDefaultIcon(): Promise<string> {
|
|||||||
|
|
||||||
if (IS_WIN) {
|
if (IS_WIN) {
|
||||||
const defaultIcoPath = generateIconPath('icon', true);
|
const defaultIcoPath = generateIconPath('icon', true);
|
||||||
const defaultPngPath = path.join(npmDirectory, 'src-tauri/png/icon_512.png');
|
const defaultPngPath = path.join(
|
||||||
|
npmDirectory,
|
||||||
|
'src-tauri/png/icon_512.png',
|
||||||
|
);
|
||||||
|
|
||||||
// Try default ico first
|
// Try default ico first
|
||||||
if (await fsExtra.pathExists(defaultIcoPath)) {
|
if (await fsExtra.pathExists(defaultIcoPath)) {
|
||||||
@@ -235,7 +230,9 @@ async function getDefaultIcon(): Promise<string> {
|
|||||||
return await copyWindowsIconIfNeeded(convertedPath, 'icon');
|
return await copyWindowsIconIfNeeded(convertedPath, 'icon');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.warn(`Failed to convert default png to ico: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
logger.warn(
|
||||||
|
`Failed to convert default png to ico: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +247,9 @@ async function getDefaultIcon(): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Linux and macOS defaults
|
// Linux and macOS defaults
|
||||||
const iconPath = IS_LINUX ? 'src-tauri/png/icon_512.png' : 'src-tauri/icons/icon.icns';
|
const iconPath = IS_LINUX
|
||||||
|
? 'src-tauri/png/icon_512.png'
|
||||||
|
: 'src-tauri/icons/icon.icns';
|
||||||
return path.join(npmDirectory, iconPath);
|
return path.join(npmDirectory, iconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,8 +342,13 @@ async function tryGetFavicon(
|
|||||||
|
|
||||||
const convertedPath = await convertIconFormat(faviconPath, appName);
|
const convertedPath = await convertIconFormat(faviconPath, appName);
|
||||||
if (convertedPath) {
|
if (convertedPath) {
|
||||||
const finalPath = await copyWindowsIconIfNeeded(convertedPath, appName);
|
const finalPath = await copyWindowsIconIfNeeded(
|
||||||
spinner.succeed(chalk.green('Icon fetched and converted successfully!'));
|
convertedPath,
|
||||||
|
appName,
|
||||||
|
);
|
||||||
|
spinner.succeed(
|
||||||
|
chalk.green('Icon fetched and converted successfully!'),
|
||||||
|
);
|
||||||
return finalPath;
|
return finalPath;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user