2016-03-23 07:40:44 +03:00
#!/usr/bin/env node
'use strict'
2016-08-30 12:48:43 +03:00
// Run bootstrap first to ensure all the dependencies used later in this script
// are installed.
require('./bootstrap')
2016-08-01 21:15:19 +03:00
// Needed so we can require src/module-cache.coffee during generateModuleCache
2016-07-28 19:32:10 +03:00
require('coffee-script/register')
2016-08-03 16:51:34 +03:00
require('colors')
2016-07-28 19:32:10 +03:00
2016-08-11 21:51:08 +03:00
const argv = require('yargs')
.usage('Usage: $0 [options]')
.help('help')
2016-08-15 15:41:49 +03:00
.describe('code-sign', 'Code-sign executables (macOS and Windows only)')
.describe('create-windows-installer', 'Create installer (Windows only)')
2016-08-15 14:06:36 +03:00
.describe('create-debian-package', 'Create .deb package (Linux only)')
2016-08-15 17:00:33 +03:00
.describe('create-rpm-package', 'Create .rpm package (Linux only)')
2016-08-11 21:51:08 +03:00
.describe('compress-artifacts', 'Compress Atom binaries (and symbols on macOS)')
2016-08-12 00:58:08 +03:00
.describe('install', 'Install Atom')
2016-08-11 21:51:08 +03:00
.argv
2016-07-26 15:51:51 +03:00
const cleanOutputDirectory = require('./lib/clean-output-directory')
2016-08-06 19:40:47 +03:00
const codeSignOnMac = require('./lib/code-sign-on-mac')
2016-08-09 14:28:59 +03:00
const compressArtifacts = require('./lib/compress-artifacts')
2016-07-27 17:09:49 +03:00
const copyAssets = require('./lib/copy-assets')
2016-08-15 13:05:50 +03:00
const createDebianPackage = require('./lib/create-debian-package')
2016-08-15 17:00:33 +03:00
const createRpmPackage = require('./lib/create-rpm-package')
2016-08-06 19:40:47 +03:00
const createWindowsInstaller = require('./lib/create-windows-installer')
2016-08-11 13:54:30 +03:00
const downloadChromedriver = require('./lib/download-chromedriver')
2016-08-01 18:22:30 +03:00
const dumpSymbols = require('./lib/dump-symbols')
2016-08-03 18:45:43 +03:00
const generateAPIDocs = require('./lib/generate-api-docs')
2016-07-30 17:35:22 +03:00
const generateMetadata = require('./lib/generate-metadata')
const generateModuleCache = require('./lib/generate-module-cache')
2016-08-03 16:50:27 +03:00
const installApplication = require('./lib/install-application')
2016-07-30 17:35:22 +03:00
const packageApplication = require('./lib/package-application')
const prebuildLessCache = require('./lib/prebuild-less-cache')
2016-03-23 07:40:44 +03:00
const transpileBabelPaths = require('./lib/transpile-babel-paths')
2016-03-23 08:06:28 +03:00
const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths')
2016-07-27 17:53:38 +03:00
const transpileCsonPaths = require('./lib/transpile-cson-paths')
2016-07-28 19:18:16 +03:00
const transpilePegJsPaths = require('./lib/transpile-peg-js-paths')
2016-03-23 07:40:44 +03:00
2016-08-03 16:45:57 +03:00
process.on('unhandledRejection', function (e) {
2016-08-29 11:37:46 +03:00
console.error(e.stack || e)
2016-08-03 16:45:57 +03:00
process.exit(1)
})
2016-08-12 00:20:02 +03:00
cleanOutputDirectory()
copyAssets()
transpileBabelPaths()
transpileCoffeeScriptPaths()
transpileCsonPaths()
transpilePegJsPaths()
generateModuleCache()
prebuildLessCache()
generateMetadata()
generateAPIDocs()
downloadChromedriver()
2016-08-02 00:06:18 +03:00
dumpSymbols()
.then(packageApplication)
2016-08-02 10:19:03 +03:00
.then(packagedAppPath => {
2016-08-06 19:40:47 +03:00
if (process.platform === 'darwin') {
if (argv.codeSign) {
codeSignOnMac(packagedAppPath)
} else {
2016-08-08 16:18:21 +03:00
console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray)
2016-08-06 19:40:47 +03:00
}
} else if (process.platform === 'win32') {
2016-08-15 17:05:57 +03:00
if (argv.createWindowsInstaller) {
2016-08-11 21:51:08 +03:00
return createWindowsInstaller(packagedAppPath, argv.codeSign).then(() => packagedAppPath)
}
else {
2016-08-29 12:42:21 +03:00
console.log('Skipping creating installer. Specify the --create-windows-installer option to create a Squirrel-based Windows installer. Code-signing was skipped too.'.gray)
2016-08-11 21:51:08 +03:00
}
2016-08-15 13:05:50 +03:00
} else if (process.platform === 'linux') {
if (argv.createDebianPackage) {
createDebianPackage(packagedAppPath)
} else {
console.log('Skipping creating debian package. Specify the --create-debian-package option to create it.'.gray)
}
2016-08-15 17:00:33 +03:00
if (argv.createRpmPackage) {
createRpmPackage(packagedAppPath)
} else {
console.log('Skipping creating rpm package. Specify the --create-rpm-package option to create it.'.gray)
}
2016-08-02 10:19:03 +03:00
}
2016-08-15 13:05:50 +03:00
return Promise.resolve(packagedAppPath)
2016-08-06 19:40:47 +03:00
}).then(packagedAppPath => {
2016-08-09 14:28:59 +03:00
if (argv.compressArtifacts) {
compressArtifacts(packagedAppPath)
} else {
console.log('Skipping artifacts compression. Specify the --compress-artifacts option to compress Atom binaries (and symbols on macOS)'.gray)
}
2016-08-03 16:50:27 +03:00
if (argv.install) {
installApplication(packagedAppPath)
} else {
2016-08-08 16:18:21 +03:00
console.log('Skipping installation. Specify the --install option to install Atom'.gray)
2016-08-03 16:50:27 +03:00
}
2016-08-02 10:19:03 +03:00
})