Move appVersion generation inside generateMetadata

This commit is contained in:
Antonio Scandurra 2016-07-29 16:38:11 +02:00
parent d3f0897ca6
commit 2688f7708d
3 changed files with 16 additions and 15 deletions

View File

@ -4,7 +4,6 @@
'use strict'
const path = require('path')
const childProcess = require('child_process')
const appMetadata = require('../package.json')
const channel = getChannel()
@ -20,16 +19,6 @@ module.exports = {
cachePath
}
function getAppVersion () {
let version = appMetadata.version
if (getChannel() === 'dev') {
const result = childProcess.spawnSync('git', ['rev-parse', '--short', 'HEAD'], {cwd: repositoryRootPath})
const commitHash = result.stdout.toString().trim()
version += '-' + commitHash
}
return version
}
function getChannel () {
if (appMetadata.version.match(/dev/) || isBuildingPR()) {
return 'dev'

View File

@ -1,5 +1,6 @@
'use strict'
const childProcess = require('child_process')
const path = require('path')
const CSON = require('season')
const fs = require('fs-extra')
@ -15,6 +16,7 @@ module.exports = function () {
CONFIG.appMetadata._atomMenu = buildPlatformMenuMetadata()
CONFIG.appMetadata._atomKeymaps = buildPlatformKeymapsMetadata()
CONFIG.appMetadata._deprecatedPackages = deprecatedPackagesMetadata
CONFIG.appMetadata.version = computeAppVersion()
checkDeprecatedPackagesMetadata()
fs.writeFileSync(path.join(CONFIG.intermediateAppPath, 'package.json'), JSON.stringify(CONFIG.appMetadata))
}
@ -130,3 +132,13 @@ function checkDeprecatedPackagesMetadata () {
}
}
}
function computeAppVersion () {
let version = CONFIG.appMetadata.version
if (CONFIG.channel === 'dev') {
const result = childProcess.spawnSync('git', ['rev-parse', '--short', 'HEAD'], {cwd: CONFIG.repositoryRootPath})
const commitHash = result.stdout.toString().trim()
version += '-' + commitHash
}
return version
}

View File

@ -13,10 +13,10 @@ const CONFIG = require('../config')
module.exports = function () {
console.log(`Running electron-packager on ${CONFIG.intermediateAppPath}`)
return runPackager({
'app-version': CONFIG.getAppVersion(),
'app-version': CONFIG.appMetadata.version,
'arch': process.arch,
'asar': {unpack: buildAsarUnpackGlobExpression()},
'build-version': CONFIG.getAppVersion(),
'build-version': CONFIG.appMetadata.version,
'download': {cache: CONFIG.cachePath},
'dir': CONFIG.intermediateAppPath,
'icon': path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'atom.icns'),
@ -68,8 +68,8 @@ function setAtomHelperVersion (packagedAppPath) {
const frameworksPath = path.join(packagedAppPath, 'Atom.app', 'Contents', 'Frameworks')
const helperPListPath = path.join(frameworksPath, 'Atom Helper.app', 'Contents', 'Info.plist')
console.log(`Setting Atom Helper Version for ${helperPListPath}...`)
childProcess.spawnSync('/usr/libexec/PlistBuddy', ['-c', 'Set CFBundleVersion', CONFIG.getAppVersion(), helperPListPath])
childProcess.spawnSync('/usr/libexec/PlistBuddy', ['-c', 'Set CFBundleShortVersionString', CONFIG.getAppVersion(), helperPListPath])
childProcess.spawnSync('/usr/libexec/PlistBuddy', ['-c', 'Set CFBundleVersion', CONFIG.appMetadata.version, helperPListPath])
childProcess.spawnSync('/usr/libexec/PlistBuddy', ['-c', 'Set CFBundleShortVersionString', CONFIG.appMetadata.version, helperPListPath])
}
}