2021-04-13 13:31:17 +10:00
|
|
|
const builder = require('electron-builder')
|
|
|
|
const path = require('path')
|
|
|
|
const fs = require('fs')
|
|
|
|
const basefile = __dirname + '/'
|
|
|
|
const package = fs.readFileSync(basefile + 'package.json')
|
|
|
|
const data = JSON.parse(package)
|
|
|
|
const version = data.version
|
|
|
|
const codename = data.codename
|
|
|
|
const ver = `${version} (${codename})`
|
|
|
|
const construct = require('./view/make/make.js')
|
|
|
|
const { platform, arch } = process
|
2019-05-26 21:42:52 +10:00
|
|
|
const Platform = builder.Platform
|
|
|
|
const Arch = builder.Arch
|
2021-04-13 13:31:17 +10:00
|
|
|
const config = {
|
|
|
|
productName: 'TheDesk',
|
|
|
|
appId: 'top.thedesk',
|
|
|
|
asarUnpack: ['node_modules/itunes-nowplaying-mac', 'main/script'],
|
|
|
|
afterSign: 'build/notarize.js',
|
2019-05-26 21:42:52 +10:00
|
|
|
directories: {
|
2021-04-13 13:31:17 +10:00
|
|
|
output: '../build',
|
2019-05-26 21:42:52 +10:00
|
|
|
},
|
|
|
|
win: {
|
2021-04-13 13:31:17 +10:00
|
|
|
icon: 'build/thedesk.ico',
|
2021-04-13 16:09:41 +10:00
|
|
|
target: ['nsis', 'appx', 'portable'],
|
|
|
|
publish: []
|
2019-05-26 21:42:52 +10:00
|
|
|
},
|
|
|
|
appx: {
|
2021-04-13 13:31:17 +10:00
|
|
|
identityName: '53491Cutls.TheDesk',
|
|
|
|
applicationId: 'Cutls.TheDesk',
|
|
|
|
publisherDisplayName: 'Cutls',
|
|
|
|
publisher: 'CN=629757F5-A5EE-474F-9562-B304A89A9FD1',
|
|
|
|
languages: ['JA-JP', 'EN-US'],
|
2019-05-26 21:42:52 +10:00
|
|
|
},
|
|
|
|
nsis: {
|
|
|
|
oneClick: false,
|
2021-04-13 13:31:17 +10:00
|
|
|
allowToChangeInstallationDirectory: true,
|
|
|
|
artifactName: 'TheDesk-setup.${ext}',
|
2019-05-26 21:42:52 +10:00
|
|
|
},
|
|
|
|
linux: {
|
2021-04-13 13:31:17 +10:00
|
|
|
target: ['zip', 'appImage', 'snap', 'deb'],
|
|
|
|
category: 'Network',
|
2019-05-26 21:42:52 +10:00
|
|
|
},
|
|
|
|
mac: {
|
2021-04-13 13:31:17 +10:00
|
|
|
hardenedRuntime: true,
|
|
|
|
gatekeeperAssess: false,
|
|
|
|
entitlements: 'build/entitlements.mac.plist',
|
|
|
|
entitlementsInherit: 'build/entitlements.mac.plist',
|
2019-05-26 21:42:52 +10:00
|
|
|
},
|
2021-04-13 13:31:17 +10:00
|
|
|
dmg: {
|
|
|
|
sign: false,
|
2019-05-26 21:42:52 +10:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-04-13 13:31:17 +10:00
|
|
|
async function build(os, arch, config) {
|
|
|
|
let targets = new Map()
|
|
|
|
let archToType = new Map()
|
|
|
|
archToType.set(arch, [])
|
|
|
|
targets.set(os, archToType)
|
|
|
|
await builder.build({
|
|
|
|
targets: targets,
|
|
|
|
config: config,
|
2021-04-13 16:54:31 +10:00
|
|
|
publish: 'never'
|
2021-04-13 13:31:17 +10:00
|
|
|
})
|
2019-05-26 21:42:52 +10:00
|
|
|
}
|
2021-04-14 14:58:21 +10:00
|
|
|
async function cmd(options) {
|
|
|
|
if (isTrue(options, 'help', 'h')) {
|
|
|
|
return console.log(help())
|
|
|
|
}
|
|
|
|
if (isTrue(options, 'onlyStore') || isTrue(options, 'withStore')) {
|
2021-04-13 13:31:17 +10:00
|
|
|
console.log('start building for application stores')
|
|
|
|
construct(ver, basefile, false, true)
|
2021-04-14 16:21:00 +10:00
|
|
|
if ((platform == 'win32' && !isTrue(options, 'skiWindows')) || isTrue(options, 'windows', 'w')) {
|
2021-04-14 14:58:21 +10:00
|
|
|
if ((isTrue(options, 'withIa32') && arch == 'x64') || arch == 'ia32') {
|
2021-04-13 13:31:17 +10:00
|
|
|
await build(Platform.WINDOWS, Arch.ia32, config)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk ${version}.exe`,
|
2021-04-13 14:48:59 +10:00
|
|
|
'../build/TheDesk-ia32-store.exe'
|
2021-04-13 13:31:17 +10:00
|
|
|
)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk-setup.exe`,
|
2021-04-13 14:48:59 +10:00
|
|
|
'../build/TheDesk-setup-ia32-store.exe'
|
2021-04-13 13:31:17 +10:00
|
|
|
)
|
|
|
|
}
|
|
|
|
if (arch == 'x64') {
|
|
|
|
await build(Platform.WINDOWS, Arch.x64, config)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk ${version}.exe`,
|
2021-04-13 14:48:59 +10:00
|
|
|
'../build/TheDesk-store.exe'
|
|
|
|
)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk-setup.exe`,
|
2021-04-13 17:28:35 +10:00
|
|
|
'../build/TheDesk-setup-store.exe'
|
2021-04-13 13:31:17 +10:00
|
|
|
)
|
|
|
|
}
|
2021-04-14 16:21:00 +10:00
|
|
|
}
|
|
|
|
if ((platform == 'linux' && !isTrue(options, 'skipLinux')) || isTrue(options, 'linux', 'l')) {
|
2021-04-13 14:48:59 +10:00
|
|
|
if (arch == 'ia32') {
|
2021-04-13 13:31:17 +10:00
|
|
|
await build(Platform.LINUX, Arch.ia32, config)
|
|
|
|
}
|
2021-04-14 14:58:21 +10:00
|
|
|
if ((isTrue(options, 'withIa32') && arch == 'x64')) {
|
2021-04-13 14:48:59 +10:00
|
|
|
console.log('snapcraft does not curretly support builing i386 on amd64')
|
|
|
|
}
|
2021-04-13 13:31:17 +10:00
|
|
|
if (arch == 'x64') {
|
|
|
|
await build(Platform.LINUX, Arch.x64, config)
|
2021-04-14 14:58:21 +10:00
|
|
|
if (!isTrue(options, 'onlyStore')) {
|
2021-04-13 13:31:17 +10:00
|
|
|
fs.renameSync(
|
|
|
|
`../build/thedesk_${version}_amd64.snap`,
|
|
|
|
`../build/thedesk_${version}_amd64-store.snap`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2019-05-26 21:42:52 +10:00
|
|
|
}
|
2021-04-13 13:31:17 +10:00
|
|
|
}
|
2021-04-14 14:58:21 +10:00
|
|
|
if (!isTrue(options, 'onlyStore')) {
|
2021-04-13 13:31:17 +10:00
|
|
|
console.log('start building for normal usage')
|
|
|
|
construct(ver, basefile, false, false)
|
2021-04-14 16:21:00 +10:00
|
|
|
if ((platform == 'win32' && !isTrue(options, 'skiWindows')) || isTrue(options, 'windows', 'w')) {
|
2021-04-14 14:58:21 +10:00
|
|
|
if ((isTrue(options, 'withIa32') && arch == 'x64') || arch == 'ia32') {
|
2021-04-13 13:31:17 +10:00
|
|
|
await build(Platform.WINDOWS, Arch.ia32, config)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk ${version}.exe`,
|
|
|
|
'../build/TheDesk-ia32.exe'
|
|
|
|
)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk-setup.exe`,
|
|
|
|
'../build/TheDesk-setup-ia32.exe'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if (arch == 'x64') {
|
|
|
|
await build(Platform.WINDOWS, Arch.x64, config)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk ${version}.exe`,
|
|
|
|
'../build/TheDesk.exe'
|
|
|
|
)
|
|
|
|
}
|
2021-04-14 14:58:21 +10:00
|
|
|
if ((isTrue(options, 'withArm64') && arch == 'x64') || arch == 'arm64') {
|
2021-04-14 14:11:33 +10:00
|
|
|
await build(Platform.WINDOWS, Arch.arm64, config)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk ${version}.exe`,
|
|
|
|
'../build/TheDesk-arm64.exe'
|
|
|
|
)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/TheDesk-setup.exe`,
|
|
|
|
'../build/TheDesk-setup-arm64.exe'
|
|
|
|
)
|
|
|
|
}
|
2021-04-14 16:21:00 +10:00
|
|
|
}
|
|
|
|
if ((platform == 'linux' && !isTrue(options, 'skipLinux')) || isTrue(options, 'linux', 'l')) {
|
2021-04-13 15:56:58 +10:00
|
|
|
if (arch == 'ia32') {
|
2021-04-13 13:31:17 +10:00
|
|
|
await build(Platform.LINUX, Arch.ia32, config)
|
|
|
|
}
|
2021-04-14 14:58:21 +10:00
|
|
|
if (isTrue(options, 'withIa32') && arch == 'x64') {
|
2021-04-13 15:56:58 +10:00
|
|
|
console.log('snapcraft does not curretly support builing i386 on amd64')
|
|
|
|
}
|
2021-04-13 13:31:17 +10:00
|
|
|
if (arch == 'x64') {
|
|
|
|
await build(Platform.LINUX, Arch.x64, config)
|
|
|
|
fs.renameSync(
|
|
|
|
`../build/thedesk_${version}_amd64.snap`,
|
|
|
|
`../build/thedesk_${version}_amd64-normal.snap`
|
|
|
|
)
|
2021-04-14 14:58:21 +10:00
|
|
|
if (isTrue(options, 'onlyStore') || isTrue(options, 'withStore')) {
|
2021-04-13 13:31:17 +10:00
|
|
|
fs.renameSync(
|
|
|
|
`../build/thedesk_${version}_amd64-store.snap`,
|
|
|
|
`../build/thedesk_${version}_amd64.snap`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 16:21:00 +10:00
|
|
|
}
|
|
|
|
if (platform == 'darwin' && !isTrue(options, 'skipMacOS')) {
|
|
|
|
if(isTrue(options, 'unnotarize')) delete config.afterSign
|
2021-04-13 13:31:17 +10:00
|
|
|
await build(Platform.MAC, Arch.x64, config)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 14:58:21 +10:00
|
|
|
function isTrue(options, long, short) {
|
2021-04-13 13:31:17 +10:00
|
|
|
const { argv } = process
|
2021-04-14 14:58:21 +10:00
|
|
|
if (options ? options[long] : 0) return true
|
2021-04-13 13:31:17 +10:00
|
|
|
if (argv.includes(`--${long}`)) return true
|
|
|
|
if (short && argv.includes(`-${short}`)) return true
|
|
|
|
return false
|
|
|
|
}
|
2021-04-14 14:58:21 +10:00
|
|
|
function help() {
|
|
|
|
return `
|
|
|
|
TheDesk Builder command tool
|
|
|
|
yarn build [options] (or node build.js [options])
|
|
|
|
yarn build:[preset] (check package.json)
|
|
|
|
|
|
|
|
--help or -h: show help
|
|
|
|
|
2021-04-14 16:21:00 +10:00
|
|
|
[Build for other platforms]
|
|
|
|
--windows (-w)
|
|
|
|
--linux (-l)
|
|
|
|
|
|
|
|
--skipWindows
|
|
|
|
--skipLinux
|
|
|
|
--skipMacOS
|
|
|
|
To skip building for itself platform.
|
|
|
|
|
|
|
|
|
|
|
|
[only Windows, Linux]
|
|
|
|
--onlyStore: application store of platforms assets(without update check)
|
|
|
|
--withStore: application store assets and normal version
|
2021-04-14 14:58:21 +10:00
|
|
|
|
|
|
|
[only Windows]
|
|
|
|
|
|
|
|
--withIa32: ia32 build on x64 system(if your machine is ia32, it will be built if this arg is not passed)
|
|
|
|
--withArm64(beta) arm64 build on x64 system(if your machine is arm64, it will be built if this arg is not passed, and not build store build for arm64)
|
|
|
|
|
2021-04-14 16:21:00 +10:00
|
|
|
[only macOS]
|
|
|
|
--unnotarize: Without notarize
|
2021-04-14 14:58:21 +10:00
|
|
|
`
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builder
|
|
|
|
* @module builder
|
|
|
|
* @param {Object} [options] - Options
|
|
|
|
* @param {boolean} [options.onlyStore] - App Store of platforms assets(without update check)
|
|
|
|
* @param {boolean} [options.withStore] - App Store of platforms assets(without update check) assets and normal version
|
|
|
|
* @param {boolean} [options.withIa32] - [Windows only] ia32 build on x64 system(if your machine is ia32, it will be built if this arg is not passed)
|
|
|
|
* @param {boolean} [options.withArm64] - [Windows only(beta)] arm64 build on x64 system(if your machine is arm64, it will be built if this arg is not passed, and not build store build for arm64)
|
|
|
|
* @return {void}
|
|
|
|
*/
|
|
|
|
module.exports = cmd
|