mirror of
https://github.com/zen-browser/surfer.git
synced 2025-07-08 17:30:02 +02:00
✨ MacOS icon support
This commit is contained in:
parent
f6cd3b37b2
commit
1a5ec090b8
3 changed files with 35 additions and 2 deletions
|
@ -39,6 +39,7 @@
|
||||||
"homepage": "https://github.com/dothq/melon#readme",
|
"homepage": "https://github.com/dothq/melon#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@resvg/resvg-js": "^1.4.0",
|
"@resvg/resvg-js": "^1.4.0",
|
||||||
|
"async-icns": "^1.0.2",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"cli-progress": "^3.9.1",
|
"cli-progress": "^3.9.1",
|
||||||
|
|
|
@ -11,14 +11,15 @@ import {
|
||||||
writeFileSync,
|
writeFileSync,
|
||||||
copyFileSync,
|
copyFileSync,
|
||||||
} from 'fs'
|
} from 'fs'
|
||||||
import { copyFile, readFile, writeFile } from 'fs/promises'
|
import { copyFile, readFile, rmdir, writeFile } from 'fs/promises'
|
||||||
import { every } from 'modern-async'
|
import { every } from 'modern-async'
|
||||||
import { dirname, extname, join } from 'path'
|
import { dirname, extname, join } from 'path'
|
||||||
import sharp from 'sharp'
|
import sharp from 'sharp'
|
||||||
import pngToIco from 'png-to-ico'
|
import pngToIco from 'png-to-ico'
|
||||||
|
import asyncIcns from 'async-icns'
|
||||||
|
|
||||||
import { config } from '../..'
|
import { config } from '../..'
|
||||||
import { CONFIGS_DIR, ENGINE_DIR } from '../../constants'
|
import { CONFIGS_DIR, ENGINE_DIR, MELON_TMP_DIR } from '../../constants'
|
||||||
import { log } from '../../log'
|
import { log } from '../../log'
|
||||||
import {
|
import {
|
||||||
addHash,
|
addHash,
|
||||||
|
@ -76,6 +77,9 @@ function constructConfig(name: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
// Main code
|
||||||
|
|
||||||
async function setupImages(configPath: string, outputPath: string) {
|
async function setupImages(configPath: string, outputPath: string) {
|
||||||
log.debug('Generating icons')
|
log.debug('Generating icons')
|
||||||
|
|
||||||
|
@ -93,6 +97,7 @@ async function setupImages(configPath: string, outputPath: string) {
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
log.debug('Generating Windows Icons')
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
join(outputPath, 'firefox.ico'),
|
join(outputPath, 'firefox.ico'),
|
||||||
await pngToIco([join(configPath, 'logo512.png')])
|
await pngToIco([join(configPath, 'logo512.png')])
|
||||||
|
@ -102,6 +107,21 @@ async function setupImages(configPath: string, outputPath: string) {
|
||||||
await pngToIco([join(configPath, 'logo64.png')])
|
await pngToIco([join(configPath, 'logo64.png')])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: Custom MacOS icon support
|
||||||
|
if (process.platform == 'darwin') {
|
||||||
|
log.debug('Generating Mac Icons')
|
||||||
|
const tmp = join(MELON_TMP_DIR, 'macos_icon_info.iconset')
|
||||||
|
|
||||||
|
if (existsSync(tmp)) await rmdir(tmp, { recursive: true })
|
||||||
|
|
||||||
|
asyncIcns.convert({
|
||||||
|
input: join(configPath, 'logo.png'),
|
||||||
|
output: join(outputPath, 'firefox.icns'),
|
||||||
|
sizes: [16, 32, 64, 128, 256, 512],
|
||||||
|
tmpDirectory: tmp,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
mkdirSync(join(outputPath, 'content'), { recursive: true })
|
mkdirSync(join(outputPath, 'content'), { recursive: true })
|
||||||
|
|
||||||
await sharp(join(configPath, 'logo.png'))
|
await sharp(join(configPath, 'logo.png'))
|
||||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -1344,6 +1344,13 @@ array-union@^2.1.0:
|
||||||
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
|
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
|
||||||
integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==
|
integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==
|
||||||
|
|
||||||
|
async-icns@^1.0.2:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/async-icns/-/async-icns-1.0.2.tgz#944295960cde2ea934ec5b126ca8d8fbd9ae824e"
|
||||||
|
integrity sha512-d2P/f3aAWdOE3+tEqTW4HLj9Ob7/t54/NH2nRFK9Q7ZhJJXK7TlF1G3vgB6UP/ILHjI3Akjv+d8sFXyAZxCIFQ==
|
||||||
|
dependencies:
|
||||||
|
commander "^9.2.0"
|
||||||
|
|
||||||
asynckit@^0.4.0:
|
asynckit@^0.4.0:
|
||||||
version "0.4.0"
|
version "0.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
|
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
|
||||||
|
@ -1670,6 +1677,11 @@ commander@^6.2.1:
|
||||||
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
|
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
|
||||||
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==
|
integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==
|
||||||
|
|
||||||
|
commander@^9.2.0:
|
||||||
|
version "9.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/commander/-/commander-9.2.0.tgz#6e21014b2ed90d8b7c9647230d8b7a94a4a419a9"
|
||||||
|
integrity sha512-e2i4wANQiSXgnrBlIatyHtP1odfUp0BbV5Y5nEGbxtIrStkEOAAzCUirvLBNXHLr7kwLvJl6V+4V3XV9x7Wd9w==
|
||||||
|
|
||||||
concat-map@0.0.1:
|
concat-map@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue