diff --git a/.gitignore b/.gitignore index bce6c56d3..5d7bccec3 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,8 @@ npm-debug.log debug.log /tags /atom-shell/ -/electron/ /out/ +/cache/ docs/output docs/includes spec/fixtures/evil-files/ diff --git a/build/config.js b/build/config.js index f71edf1bf..9605a6e4d 100644 --- a/build/config.js +++ b/build/config.js @@ -10,8 +10,9 @@ const appMetadata = require('../package.json') const repositoryRootPath = path.resolve(__dirname, '..') const buildOutputPath = path.join(repositoryRootPath, 'out') const intermediateAppPath = path.join(buildOutputPath, 'app') +const cachePath = path.join(repositoryRootPath, 'cache') module.exports = { appMetadata, - repositoryRootPath, buildOutputPath, intermediateAppPath, + repositoryRootPath, buildOutputPath, intermediateAppPath, cachePath } diff --git a/build/lib/copy-assets.js b/build/lib/copy-assets.js index 5a47788d4..29eee4ee4 100644 --- a/build/lib/copy-assets.js +++ b/build/lib/copy-assets.js @@ -16,6 +16,7 @@ module.exports = function () { path.join(CONFIG.repositoryRootPath, 'keymaps'), path.join(CONFIG.repositoryRootPath, 'menus'), path.join(CONFIG.repositoryRootPath, 'node_modules'), + path.join(CONFIG.repositoryRootPath, 'package.json'), path.join(CONFIG.repositoryRootPath, 'static'), path.join(CONFIG.repositoryRootPath, 'src'), path.join(CONFIG.repositoryRootPath, 'vendor') diff --git a/build/lib/package-application.js b/build/lib/package-application.js index 88cc79cfc..d201f1cf6 100644 --- a/build/lib/package-application.js +++ b/build/lib/package-application.js @@ -7,6 +7,7 @@ // other than transpilation. It looks like it has a programmatic API. We'll need to // copy more stuff such as the package.json for the packager to work correctly. +const path = require('path') const electronPackager = require('electron-packager') const CONFIG = require('../config') @@ -14,7 +15,36 @@ const CONFIG = require('../config') module.exports = function () { console.log(`Running electron-packager on ${CONFIG.intermediateAppPath}`) // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md - // electronPackager(...) + electronPackager({ + arch: process.arch, + asar: {unpack: buildAsarUnpackGlobExpression()}, + download: {cache: CONFIG.cachePath}, + dir: CONFIG.intermediateAppPath, + ignore: buildIgnoredPathsRegExp(), + out: CONFIG.buildOutputPath, + overwrite: true, + platform: process.platform + }, (err, appPaths) => { + if (err) { + console.error(err) + } else { + console.log(`Application bundle(s) created on ${appPaths}`) + } + }) +} + +function buildAsarUnpackGlobExpression () { + const unpack = [ + '*.node', + 'ctags-config', + 'ctags-darwin', + 'ctags-linux', + 'ctags-win32.exe', + path.join('**', 'node_modules', 'spellchecker', '**'), + path.join('**', 'resources', 'atom.png') + ] + + return `{${unpack.join(',')}}` } function buildIgnoredPathsRegExp () {