diff --git a/build/build.js b/build/build.js index 77be716eb..056e787ff 100644 --- a/build/build.js +++ b/build/build.js @@ -7,9 +7,11 @@ const copyAssets = require('./lib/copy-assets') const transpileBabelPaths = require('./lib/transpile-babel-paths') const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths') const transpileCsonPaths = require('./lib/transpile-cson-paths') +const packageApplication = require('./lib/package-application') cleanOutputDirectory() copyAssets() transpileBabelPaths() transpileCoffeeScriptPaths() transpileCsonPaths() +packageApplication() diff --git a/build/lib/package-application.js b/build/lib/package-application.js new file mode 100644 index 000000000..88cc79cfc --- /dev/null +++ b/build/lib/package-application.js @@ -0,0 +1,76 @@ +'use strict' + +// This is where we'll run electron-packager on our intermediate app dir. +// It takes an ignore regex for paths to exclude, and I've started on a function +// to build up this regexp based on existing work in build-task.coffee. We should +// try to lean on electron-packager to do as much of the work for us as possible +// 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 electronPackager = require('electron-packager') + +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(...) +} + +function buildIgnoredPathsRegExp () { + const ignoredPaths = [ + '.DS_Store', + '.jshintrc', + '.npmignore', + '.pairs', + '.travis.yml', + 'appveyor.yml', + '.idea', + '.editorconfig', + '.lint', + '.lintignore', + '.eslintrc', + '.jshintignore', + 'coffeelint.json', + '.coffeelintignore', + '.gitattributes', + '.gitkeep', + path.join('git-utils', 'deps'), + path.join('oniguruma', 'deps'), + path.join('less', 'dist'), + path.join('npm', 'doc'), + path.join('npm', 'html'), + path.join('npm', 'man'), + path.join('npm', 'node_modules', '.bin', 'beep'), + path.join('npm', 'node_modules', '.bin', 'clear'), + path.join('npm', 'node_modules', '.bin', 'starwars'), + path.join('pegjs', 'examples'), + path.join('get-parameter-names', 'node_modules', 'testla'), + path.join('get-parameter-names', 'node_modules', '.bin', 'testla'), + path.join('jasmine-reporters', 'ext'), + path.join('jasmine-node', 'node_modules', 'gaze'), + path.join('jasmine-node', 'spec'), + path.join('node_modules', 'nan'), + path.join('node_modules', 'native-mate'), + path.join('build', 'binding.Makefile'), + path.join('build', 'config.gypi'), + path.join('build', 'gyp-mac-tool'), + path.join('build', 'Makefile'), + path.join('build', 'Release', 'obj.target'), + path.join('build', 'Release', 'obj'), + path.join('build', 'Release', '.deps'), + path.join('vendor', 'apm'), + + // These are only required in dev-mode, when pegjs grammars aren't precompiled + path.join('snippets', 'node_modules', 'loophole'), + path.join('snippets', 'node_modules', 'pegjs'), + path.join('snippets', 'node_modules', '.bin', 'pegjs'), + ] + + const regExpSource = ignoredPaths.map(path => '(' + escapeRegExp(path) + ')').join('|') + return new RegExp(regExpSource) +} + +function escapeRegExp (string) { + string.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&") +} diff --git a/build/package.json b/build/package.json index 0b2c461cf..6f883b78c 100644 --- a/build/package.json +++ b/build/package.json @@ -2,6 +2,7 @@ "name": "atom-build-scripts", "description": "Atom build scripts", "dependencies": { + "electron-packager": "^7.3.0", "fs-extra": "0.30.0", "glob": "7.0.3", "mkdirp": "0.5.1"