Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #19324 from atom/pr/15431
Browse files Browse the repository at this point in the history
Integrate packager improvements from #15431
  • Loading branch information
rafeca committed May 13, 2019
2 parents fe95e05 + 6b3e906 commit 1edf94a
Showing 1 changed file with 30 additions and 38 deletions.
68 changes: 30 additions & 38 deletions script/lib/package-application.js
Expand Up @@ -4,38 +4,42 @@ const assert = require('assert')
const childProcess = require('child_process')
const electronPackager = require('electron-packager')
const fs = require('fs-extra')
const hostArch = require('electron-packager/targets').hostArch
const includePathInPackagedApp = require('./include-path-in-packaged-app')
const getLicenseText = require('./get-license-text')
const path = require('path')
const spawnSync = require('./spawn-sync')

const CONFIG = require('../config')
const HOST_ARCH = hostArch()

module.exports = function () {
const appName = getAppName()
console.log(`Running electron-packager on ${CONFIG.intermediateAppPath} with app name "${appName}"`)
return runPackager({
'appBundleId': 'com.github.atom',
'appCopyright': `Copyright © 2014-${(new Date()).getFullYear()} GitHub, Inc. All rights reserved.`,
'appVersion': CONFIG.appMetadata.version,
'arch': process.platform === 'darwin' ? 'x64' : process.arch, // OS X is 64-bit only
'asar': {unpack: buildAsarUnpackGlobExpression()},
'buildVersion': CONFIG.appMetadata.version,
'download': {cache: CONFIG.electronDownloadPath},
'dir': CONFIG.intermediateAppPath,
'extendInfo': path.join(CONFIG.repositoryRootPath, 'resources', 'mac', 'atom-Info.plist'),
'helperBundleId': 'com.github.atom.helper',
'icon': getIcon(),
'name': appName,
'out': CONFIG.buildOutputPath,
'overwrite': true,
'derefSymlinks': false,
'platform': process.platform,
'electronVersion': CONFIG.appMetadata.electronVersion,
'win32metadata': {
'CompanyName': 'GitHub, Inc.',
'FileDescription': 'Atom',
'ProductName': 'Atom'
appBundleId: 'com.github.atom',
appCopyright: `Copyright © 2014-${(new Date()).getFullYear()} GitHub, Inc. All rights reserved.`,
appVersion: CONFIG.appMetadata.version,
arch: process.platform === 'darwin' ? 'x64' : HOST_ARCH, // OS X is 64-bit only
asar: {unpack: buildAsarUnpackGlobExpression()},
buildVersion: CONFIG.appMetadata.version,
derefSymlinks: false,
download: {cache: CONFIG.electronDownloadPath},
dir: CONFIG.intermediateAppPath,
electronVersion: CONFIG.appMetadata.electronVersion,
extendInfo: path.join(CONFIG.repositoryRootPath, 'resources', 'mac', 'atom-Info.plist'),
helperBundleId: 'com.github.atom.helper',
icon: path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'atom'),
name: appName,
out: CONFIG.buildOutputPath,
overwrite: true,
platform: process.platform,
// Atom doesn't have devDependencies, but if prune is true, it will delete the non-standard packageDependencies.
prune: false,
win32metadata: {
CompanyName: 'GitHub, Inc.',
FileDescription: 'Atom',
ProductName: 'Atom'
}
}).then((packagedAppPath) => {
let bundledResourcesPath
Expand Down Expand Up @@ -122,21 +126,9 @@ function getAppName () {
}
}

function getIcon () {
switch (process.platform) {
case 'darwin':
return path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'atom.icns')
case 'linux':
// Don't pass an icon, as the dock/window list icon is set via the icon
// option in the BrowserWindow constructor in atom-window.coffee.
return null
default:
return path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'atom.ico')
}
}

async function runPackager (options) {
const packageOutputDirPaths = await electronPackager(options)

assert(packageOutputDirPaths.length === 1, 'Generated more than one electron application!')

return renamePackagedAppDir(packageOutputDirPaths[0])
Expand All @@ -152,19 +144,19 @@ function renamePackagedAppDir (packageOutputDirPath) {
} else if (process.platform === 'linux') {
const appName = CONFIG.channel !== 'stable' ? `atom-${CONFIG.channel}` : 'atom'
let architecture
if (process.arch === 'ia32') {
if (HOST_ARCH === 'ia32') {
architecture = 'i386'
} else if (process.arch === 'x64') {
} else if (HOST_ARCH === 'x64') {
architecture = 'amd64'
} else {
architecture = process.arch
architecture = HOST_ARCH
}
packagedAppPath = path.join(CONFIG.buildOutputPath, `${appName}-${CONFIG.appMetadata.version}-${architecture}`)
if (fs.existsSync(packagedAppPath)) fs.removeSync(packagedAppPath)
fs.renameSync(packageOutputDirPath, packagedAppPath)
} else {
packagedAppPath = path.join(CONFIG.buildOutputPath, CONFIG.appName)
if (process.platform === 'win32' && process.arch !== 'ia32') {
if (process.platform === 'win32' && HOST_ARCH !== 'ia32') {
packagedAppPath += ` ${process.arch}`
}
if (fs.existsSync(packagedAppPath)) fs.removeSync(packagedAppPath)
Expand Down

0 comments on commit 1edf94a

Please sign in to comment.