This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
forked from luuxis/Selvania-Launcher
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/luuxis/Selvania-Launcher
- Loading branch information
Showing
15 changed files
with
8,528 additions
and
8,182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,108 @@ | ||
const builder = require('electron-builder') | ||
const nodeFetch = require('node-fetch') | ||
const fs = require('fs') | ||
const png2icons = require('png2icons') | ||
const Jimp = require('jimp') | ||
const { preductname } = require('./package.json') | ||
|
||
builder | ||
.build({ | ||
config: { | ||
generateUpdatesFilesForAllChannels: false, | ||
appId: preductname, | ||
productName: preductname, | ||
artifactName: '${productName}-${os}-${arch}.${ext}', | ||
files: ['src/**/*', 'package.json', 'LICENSE.md'], | ||
extraResources: [ | ||
{ | ||
from: 'src/libraries', | ||
to: 'libraries', | ||
}, | ||
], | ||
directories: { output: 'dist' }, | ||
compression: 'maximum', | ||
asar: true, | ||
publish: [ | ||
{ | ||
provider: 'github', | ||
releaseType: 'release', | ||
}, | ||
], | ||
win: { | ||
icon: './src/assets/images/icon.ico', | ||
target: [ | ||
{ | ||
target: 'nsis', | ||
arch: ['x64'], | ||
class Index { | ||
async build() { | ||
builder | ||
.build({ | ||
config: { | ||
generateUpdatesFilesForAllChannels: false, | ||
appId: preductname, | ||
productName: preductname, | ||
artifactName: '${productName}-${os}-${arch}.${ext}', | ||
files: ['src/**/*', 'package.json', 'LICENSE.md'], | ||
extraResources: [ | ||
{ | ||
from: 'src/libraries', | ||
to: 'libraries', | ||
}, | ||
], | ||
directories: { output: 'dist' }, | ||
compression: 'maximum', | ||
asar: true, | ||
publish: [ | ||
{ | ||
provider: 'github', | ||
releaseType: 'release', | ||
}, | ||
], | ||
win: { | ||
icon: './src/assets/images/icon.ico', | ||
target: [ | ||
{ | ||
target: 'nsis', | ||
arch: ['x64'], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
nsis: { | ||
oneClick: true, | ||
allowToChangeInstallationDirectory: false, | ||
createDesktopShortcut: true, | ||
runAfterFinish: true, | ||
}, | ||
mac: { | ||
icon: './src/assets/images/icon.icns', | ||
category: 'public.app-category.games', | ||
target: [ | ||
{ | ||
target: 'dmg', | ||
arch: ['x64', 'arm64'], | ||
nsis: { | ||
oneClick: true, | ||
allowToChangeInstallationDirectory: false, | ||
createDesktopShortcut: true, | ||
runAfterFinish: true, | ||
}, | ||
], | ||
}, | ||
linux: { | ||
icon: './src/assets/images/icon.png', | ||
target: [ | ||
{ | ||
target: 'AppImage', | ||
arch: ['x64'], | ||
mac: { | ||
icon: './src/assets/images/icon.icns', | ||
category: 'public.app-category.games', | ||
target: [ | ||
{ | ||
target: 'dmg', | ||
arch: ['x64', 'arm64'], | ||
}, | ||
], | ||
}, | ||
{ | ||
target: 'tar.gz', | ||
arch: ['x64'], | ||
linux: { | ||
icon: './src/assets/images/icon.png', | ||
target: [ | ||
{ | ||
target: 'AppImage', | ||
arch: ['x64'], | ||
}, | ||
{ | ||
target: 'tar.gz', | ||
arch: ['x64'], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}) | ||
.then(() => { | ||
console.log('La compilación ha sido compilada') | ||
}) | ||
.catch((err) => { | ||
console.error('Se ha producido un error al comipar: ', err) | ||
}) | ||
}, | ||
}) | ||
.then(() => { | ||
console.log('La compilación ha sido compilada') | ||
}) | ||
.catch((err) => { | ||
console.error('Se ha producido un error al comipar: ', err) | ||
}) | ||
} | ||
|
||
async iconSet(url) { | ||
let Buffer = await nodeFetch(url) | ||
if (Buffer.status == 200) { | ||
Buffer = await Buffer.buffer() | ||
const image = await Jimp.read(Buffer) | ||
Buffer = await image.resize(256, 256).getBufferAsync(Jimp.MIME_PNG) | ||
fs.writeFileSync( | ||
'src/assets/images/icon.icns', | ||
png2icons.createICNS(Buffer, png2icons.BILINEAR, 0) | ||
) | ||
fs.writeFileSync( | ||
'src/assets/images/icon.ico', | ||
png2icons.createICO(Buffer, png2icons.HERMITE, 0, false) | ||
) | ||
fs.writeFileSync('src/assets/images/icon.png', Buffer) | ||
} else { | ||
console.log('connection error') | ||
} | ||
} | ||
} | ||
|
||
process.argv.forEach((val) => { | ||
if (val.startsWith('--icon')) { | ||
return new Index().iconSet(val.split('=')[1]) | ||
} else if (val.startsWith('--build')) { | ||
new Index().build() | ||
} | ||
}) |
Oops, something went wrong.