2017-10-19 23:04:47 +00:00
|
|
|
/* eslint-disable no-sync */
|
2016-05-25 14:37:27 +00:00
|
|
|
|
2017-10-15 06:05:28 +00:00
|
|
|
import * as fs from 'fs-extra'
|
|
|
|
import * as cp from 'child_process'
|
|
|
|
import * as path from 'path'
|
2017-10-16 22:35:39 +00:00
|
|
|
import * as electronInstaller from 'electron-winstaller'
|
2017-11-20 01:30:16 +00:00
|
|
|
import { getProductName, getCompanyName } from '../app/package-info'
|
2017-10-15 06:05:28 +00:00
|
|
|
import {
|
|
|
|
getDistPath,
|
|
|
|
getOSXZipPath,
|
|
|
|
getWindowsIdentifierName,
|
|
|
|
getWindowsStandaloneName,
|
|
|
|
getWindowsInstallerName,
|
|
|
|
shouldMakeDelta,
|
|
|
|
getUpdatesURL,
|
2019-11-20 17:44:01 +00:00
|
|
|
getIconFileName,
|
2017-10-15 06:05:28 +00:00
|
|
|
} from './dist-info'
|
2020-07-09 12:09:09 +00:00
|
|
|
import { isAppveyor, isGitHubActions } from './build-platforms'
|
2017-10-15 06:05:28 +00:00
|
|
|
|
|
|
|
const distPath = getDistPath()
|
|
|
|
const productName = getProductName()
|
2017-07-28 11:21:48 +00:00
|
|
|
const outputDir = path.join(distPath, '..', 'installer')
|
2016-05-25 14:37:27 +00:00
|
|
|
|
|
|
|
if (process.platform === 'darwin') {
|
|
|
|
packageOSX()
|
|
|
|
} else if (process.platform === 'win32') {
|
|
|
|
packageWindows()
|
2017-07-28 11:21:48 +00:00
|
|
|
} else if (process.platform === 'linux') {
|
|
|
|
packageLinux()
|
2016-05-25 14:37:27 +00:00
|
|
|
} else {
|
|
|
|
console.error(`I dunno how to package for ${process.platform} :(`)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
2017-07-13 13:36:37 +00:00
|
|
|
function packageOSX() {
|
2017-10-15 06:05:28 +00:00
|
|
|
const dest = getOSXZipPath()
|
2016-05-25 14:37:27 +00:00
|
|
|
fs.removeSync(dest)
|
|
|
|
|
2017-07-13 13:36:37 +00:00
|
|
|
cp.execSync(
|
|
|
|
`ditto -ck --keepParent "${distPath}/${productName}.app" "${dest}"`
|
|
|
|
)
|
2016-05-25 14:37:27 +00:00
|
|
|
console.log(`Zipped to ${dest}`)
|
|
|
|
}
|
|
|
|
|
2017-07-13 13:36:37 +00:00
|
|
|
function packageWindows() {
|
|
|
|
const setupCertificatePath = path.join(
|
|
|
|
__dirname,
|
|
|
|
'setup-windows-certificate.ps1'
|
|
|
|
)
|
|
|
|
const cleanupCertificatePath = path.join(
|
|
|
|
__dirname,
|
|
|
|
'cleanup-windows-certificate.ps1'
|
|
|
|
)
|
2016-07-04 05:25:36 +00:00
|
|
|
|
2020-07-09 12:09:09 +00:00
|
|
|
if (isAppveyor() || isGitHubActions()) {
|
2016-07-04 05:25:36 +00:00
|
|
|
cp.execSync(`powershell ${setupCertificatePath}`)
|
|
|
|
}
|
|
|
|
|
2017-07-13 13:36:37 +00:00
|
|
|
const iconSource = path.join(
|
|
|
|
__dirname,
|
|
|
|
'..',
|
|
|
|
'app',
|
|
|
|
'static',
|
|
|
|
'logos',
|
2019-11-20 17:44:01 +00:00
|
|
|
`${getIconFileName()}.ico`
|
2017-07-13 13:36:37 +00:00
|
|
|
)
|
2016-09-08 03:42:41 +00:00
|
|
|
|
2017-03-27 04:54:19 +00:00
|
|
|
if (!fs.existsSync(iconSource)) {
|
2017-03-29 03:49:55 +00:00
|
|
|
console.error(`expected setup icon not found at location: ${iconSource}`)
|
2016-09-08 03:42:41 +00:00
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
2017-07-13 13:36:37 +00:00
|
|
|
const splashScreenPath = path.resolve(
|
|
|
|
__dirname,
|
|
|
|
'../app/static/logos/win32-installer-splash.gif'
|
|
|
|
)
|
2017-05-11 19:11:01 +00:00
|
|
|
|
|
|
|
if (!fs.existsSync(splashScreenPath)) {
|
2017-07-13 13:36:37 +00:00
|
|
|
console.error(
|
2017-12-12 05:21:47 +00:00
|
|
|
`expected setup splash screen gif not found at location: ${splashScreenPath}`
|
2017-07-13 13:36:37 +00:00
|
|
|
)
|
2017-05-11 19:11:01 +00:00
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
2017-05-16 08:36:27 +00:00
|
|
|
const iconUrl = 'https://desktop.githubusercontent.com/app-icon.ico'
|
2017-03-27 04:54:19 +00:00
|
|
|
|
2017-10-15 06:05:28 +00:00
|
|
|
const nugetPkgName = getWindowsIdentifierName()
|
2017-10-15 06:02:33 +00:00
|
|
|
const options: electronInstaller.Options = {
|
2017-07-14 14:05:04 +00:00
|
|
|
name: nugetPkgName,
|
2016-09-27 01:47:48 +00:00
|
|
|
appDirectory: distPath,
|
|
|
|
outputDirectory: outputDir,
|
2017-10-15 06:05:28 +00:00
|
|
|
authors: getCompanyName(),
|
2017-03-27 04:54:19 +00:00
|
|
|
iconUrl: iconUrl,
|
|
|
|
setupIcon: iconSource,
|
2017-05-11 19:11:01 +00:00
|
|
|
loadingGif: splashScreenPath,
|
2017-07-14 14:05:04 +00:00
|
|
|
exe: `${nugetPkgName}.exe`,
|
|
|
|
title: productName,
|
2017-10-15 06:05:28 +00:00
|
|
|
setupExe: getWindowsStandaloneName(),
|
|
|
|
setupMsi: getWindowsInstallerName(),
|
2017-07-13 17:49:13 +00:00
|
|
|
}
|
|
|
|
|
2017-10-15 06:05:28 +00:00
|
|
|
if (shouldMakeDelta()) {
|
|
|
|
options.remoteReleases = getUpdatesURL()
|
2016-09-27 01:47:48 +00:00
|
|
|
}
|
|
|
|
|
2020-07-09 12:09:09 +00:00
|
|
|
if (isAppveyor() || isGitHubActions()) {
|
2017-03-27 09:47:35 +00:00
|
|
|
const certificatePath = path.join(__dirname, 'windows-certificate.pfx')
|
2020-06-24 18:28:06 +00:00
|
|
|
options.signWithParams = `/f ${certificatePath} /p ${process.env.WINDOWS_CERT_PASSWORD} /tr http://timestamp.digicert.com /td sha256 /fd sha256`
|
2016-09-27 01:47:48 +00:00
|
|
|
}
|
|
|
|
|
2016-05-25 14:47:51 +00:00
|
|
|
electronInstaller
|
2016-09-27 01:47:48 +00:00
|
|
|
.createWindowsInstaller(options)
|
2016-07-04 05:25:36 +00:00
|
|
|
.then(() => {
|
|
|
|
console.log(`Installers created in ${outputDir}`)
|
|
|
|
cp.execSync(`powershell ${cleanupCertificatePath}`)
|
2016-05-25 14:47:51 +00:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2016-07-04 05:25:36 +00:00
|
|
|
cp.execSync(`powershell ${cleanupCertificatePath}`)
|
2016-05-25 14:47:51 +00:00
|
|
|
console.error(`Error packaging: ${e}`)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
2016-05-25 14:37:27 +00:00
|
|
|
}
|
2017-07-28 11:21:48 +00:00
|
|
|
|
2017-12-10 07:24:53 +00:00
|
|
|
function packageLinux() {
|
|
|
|
const electronBuilder = path.resolve(
|
|
|
|
__dirname,
|
|
|
|
'..',
|
|
|
|
'node_modules',
|
|
|
|
'.bin',
|
|
|
|
'electron-builder'
|
|
|
|
)
|
2017-07-28 11:21:48 +00:00
|
|
|
|
2017-12-11 00:07:19 +00:00
|
|
|
const configPath = path.resolve(__dirname, 'electron-builder-linux.yml')
|
2017-10-01 21:48:29 +00:00
|
|
|
|
2017-12-10 07:24:53 +00:00
|
|
|
const args = [
|
|
|
|
'build',
|
|
|
|
'--prepackaged',
|
|
|
|
distPath,
|
|
|
|
'--x64',
|
|
|
|
'--config',
|
|
|
|
configPath,
|
|
|
|
]
|
2017-10-01 21:48:29 +00:00
|
|
|
|
2017-12-10 07:24:53 +00:00
|
|
|
cp.spawnSync(electronBuilder, args, { stdio: 'inherit' })
|
2017-07-28 11:21:48 +00:00
|
|
|
}
|