2013-08-14 20:06:16 +04:00
|
|
|
fs = require 'fs'
|
2013-05-30 04:35:00 +04:00
|
|
|
path = require 'path'
|
2013-10-21 17:42:55 +04:00
|
|
|
os = require 'os'
|
2015-08-19 00:31:03 +03:00
|
|
|
glob = require 'glob'
|
|
|
|
usesBabel = require './lib/uses-babel'
|
2015-08-22 02:00:39 +03:00
|
|
|
babelOptions = require '../static/babelrc'
|
2013-05-30 04:35:00 +04:00
|
|
|
|
2014-01-06 12:31:04 +04:00
|
|
|
# Add support for obselete APIs of vm module so we can make some third-party
|
|
|
|
# modules work under node v0.11.x.
|
|
|
|
require 'vm-compatibility-layer'
|
|
|
|
|
2013-10-15 20:34:59 +04:00
|
|
|
_ = require 'underscore-plus'
|
2013-08-20 21:52:18 +04:00
|
|
|
|
2013-11-21 22:39:31 +04:00
|
|
|
packageJson = require '../package.json'
|
2013-08-20 21:52:18 +04:00
|
|
|
|
2013-05-29 04:30:09 +04:00
|
|
|
module.exports = (grunt) ->
|
2015-12-19 18:06:56 +03:00
|
|
|
require('time-grunt')(grunt)
|
|
|
|
|
2015-08-19 00:31:03 +03:00
|
|
|
grunt.loadNpmTasks('grunt-babel')
|
2013-11-21 22:39:31 +04:00
|
|
|
grunt.loadNpmTasks('grunt-coffeelint')
|
|
|
|
grunt.loadNpmTasks('grunt-lesslint')
|
2015-08-22 02:56:32 +03:00
|
|
|
grunt.loadNpmTasks('grunt-standard')
|
2013-11-21 22:39:31 +04:00
|
|
|
grunt.loadNpmTasks('grunt-cson')
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-csslint')
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-coffee')
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-less')
|
|
|
|
grunt.loadNpmTasks('grunt-shell')
|
2015-05-20 22:21:18 +03:00
|
|
|
grunt.loadNpmTasks('grunt-download-electron')
|
2015-07-29 21:56:40 +03:00
|
|
|
grunt.loadNpmTasks('grunt-electron-installer')
|
2014-01-10 23:32:40 +04:00
|
|
|
grunt.loadNpmTasks('grunt-peg')
|
2013-11-21 22:39:31 +04:00
|
|
|
grunt.loadTasks('tasks')
|
|
|
|
|
|
|
|
# This allows all subsequent paths to the relative to the root of the repo
|
|
|
|
grunt.file.setBase(path.resolve('..'))
|
|
|
|
|
2015-09-22 03:48:16 +03:00
|
|
|
# Options
|
|
|
|
installDir = grunt.option('install-dir')
|
|
|
|
buildDir = grunt.option('build-dir')
|
|
|
|
buildDir ?= path.join(os.tmpdir(), 'atom-build')
|
|
|
|
buildDir = path.resolve(buildDir)
|
2015-09-08 09:05:13 +03:00
|
|
|
disableAutoUpdate = grunt.option('no-auto-update') ? false
|
2014-07-23 04:32:00 +04:00
|
|
|
|
2015-09-17 02:32:30 +03:00
|
|
|
channel = grunt.option('channel')
|
2015-11-11 01:37:01 +03:00
|
|
|
releasableBranches = ['stable', 'beta']
|
|
|
|
if process.env.APPVEYOR and not process.env.APPVEYOR_PULL_REQUEST_NUMBER
|
|
|
|
channel ?= process.env.APPVEYOR_REPO_BRANCH if process.env.APPVEYOR_REPO_BRANCH in releasableBranches
|
|
|
|
|
|
|
|
if process.env.TRAVIS and not process.env.TRAVIS_PULL_REQUEST
|
|
|
|
channel ?= process.env.TRAVIS_BRANCH if process.env.TRAVIS_BRANCH in releasableBranches
|
|
|
|
|
|
|
|
if process.env.JANKY_BRANCH
|
|
|
|
channel ?= process.env.JANKY_BRANCH if process.env.JANKY_BRANCH in releasableBranches
|
|
|
|
|
2015-09-17 02:32:30 +03:00
|
|
|
channel ?= 'dev'
|
|
|
|
|
2015-09-22 03:48:16 +03:00
|
|
|
metadata = packageJson
|
2015-09-21 19:21:29 +03:00
|
|
|
appName = packageJson.productName
|
2015-09-22 03:48:16 +03:00
|
|
|
appFileName = packageJson.name
|
|
|
|
apmFileName = 'apm'
|
2015-09-21 19:21:29 +03:00
|
|
|
|
2015-09-22 03:48:16 +03:00
|
|
|
if channel is 'beta'
|
|
|
|
appName += ' Beta'
|
|
|
|
appFileName += '-beta'
|
|
|
|
apmFileName += '-beta'
|
2014-07-23 04:32:00 +04:00
|
|
|
|
2015-09-26 14:12:08 +03:00
|
|
|
appName += '.app' if process.platform is 'darwin'
|
2014-05-16 23:10:55 +04:00
|
|
|
shellAppDir = path.join(buildDir, appName)
|
2015-09-22 03:48:16 +03:00
|
|
|
symbolsDir = path.join(buildDir, 'Atom.breakpad.syms')
|
|
|
|
|
2013-10-29 00:38:33 +04:00
|
|
|
if process.platform is 'win32'
|
2015-09-22 03:48:16 +03:00
|
|
|
homeDir = process.env.USERPROFILE
|
2013-12-17 21:39:49 +04:00
|
|
|
contentsDir = shellAppDir
|
2013-10-29 01:26:54 +04:00
|
|
|
appDir = path.join(shellAppDir, 'resources', 'app')
|
2014-07-03 01:06:04 +04:00
|
|
|
installDir ?= path.join(process.env.ProgramFiles, appName)
|
2014-07-05 22:06:07 +04:00
|
|
|
killCommand = 'taskkill /F /IM atom.exe'
|
2014-03-17 11:28:36 +04:00
|
|
|
else if process.platform is 'darwin'
|
2015-09-22 03:48:16 +03:00
|
|
|
homeDir = process.env.HOME
|
2013-10-29 01:26:54 +04:00
|
|
|
contentsDir = path.join(shellAppDir, 'Contents')
|
|
|
|
appDir = path.join(contentsDir, 'Resources', 'app')
|
2014-07-03 01:06:04 +04:00
|
|
|
installDir ?= path.join('/Applications', appName)
|
2014-07-05 21:41:45 +04:00
|
|
|
killCommand = 'pkill -9 Atom'
|
2014-03-17 11:28:36 +04:00
|
|
|
else
|
2015-09-22 03:48:16 +03:00
|
|
|
homeDir = process.env.HOME
|
2014-03-17 11:28:36 +04:00
|
|
|
contentsDir = shellAppDir
|
|
|
|
appDir = path.join(shellAppDir, 'resources', 'app')
|
2014-07-03 01:06:04 +04:00
|
|
|
installDir ?= process.env.INSTALL_PREFIX ? '/usr/local'
|
2014-08-27 02:10:43 +04:00
|
|
|
killCommand ='pkill -9 atom'
|
2013-06-18 20:50:25 +04:00
|
|
|
|
2014-09-24 00:09:22 +04:00
|
|
|
installDir = path.resolve(installDir)
|
2015-09-22 03:48:16 +03:00
|
|
|
electronDownloadDir = path.join(homeDir, '.atom', 'electron')
|
2014-09-24 00:09:22 +04:00
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
coffeeConfig =
|
|
|
|
glob_to_multiple:
|
|
|
|
expand: true
|
|
|
|
src: [
|
|
|
|
'src/**/*.coffee'
|
2015-04-21 01:28:26 +03:00
|
|
|
'spec/*.coffee'
|
|
|
|
'!spec/*-spec.coffee'
|
2013-09-20 01:30:39 +04:00
|
|
|
'exports/**/*.coffee'
|
2013-08-14 20:06:16 +04:00
|
|
|
'static/**/*.coffee'
|
|
|
|
]
|
|
|
|
dest: appDir
|
|
|
|
ext: '.js'
|
|
|
|
|
2015-08-19 00:31:03 +03:00
|
|
|
babelConfig =
|
2015-08-19 03:50:49 +03:00
|
|
|
options: babelOptions
|
2015-08-19 00:31:03 +03:00
|
|
|
dist:
|
|
|
|
files: []
|
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
lessConfig =
|
|
|
|
options:
|
|
|
|
paths: [
|
2013-09-04 23:14:57 +04:00
|
|
|
'static/variables'
|
2013-08-14 20:06:16 +04:00
|
|
|
'static'
|
|
|
|
]
|
|
|
|
glob_to_multiple:
|
|
|
|
expand: true
|
|
|
|
src: [
|
|
|
|
'static/**/*.less'
|
|
|
|
]
|
|
|
|
dest: appDir
|
|
|
|
ext: '.css'
|
|
|
|
|
2013-09-17 01:57:48 +04:00
|
|
|
prebuildLessConfig =
|
|
|
|
src: [
|
|
|
|
'static/**/*.less'
|
|
|
|
]
|
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
csonConfig =
|
|
|
|
options:
|
|
|
|
rootObject: true
|
2015-09-22 03:48:16 +03:00
|
|
|
cachePath: path.join(homeDir, '.atom', 'compile-cache', 'grunt-cson')
|
2014-07-24 21:39:13 +04:00
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
glob_to_multiple:
|
|
|
|
expand: true
|
|
|
|
src: [
|
2013-10-05 00:15:09 +04:00
|
|
|
'menus/*.cson'
|
2013-08-21 01:12:17 +04:00
|
|
|
'keymaps/*.cson'
|
2013-08-14 20:06:16 +04:00
|
|
|
'static/**/*.cson'
|
|
|
|
]
|
|
|
|
dest: appDir
|
|
|
|
ext: '.json'
|
|
|
|
|
2014-01-10 23:32:40 +04:00
|
|
|
pegConfig =
|
|
|
|
glob_to_multiple:
|
|
|
|
expand: true
|
|
|
|
src: ['src/**/*.pegjs']
|
|
|
|
dest: appDir
|
|
|
|
ext: '.js'
|
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
for child in fs.readdirSync('node_modules') when child isnt '.bin'
|
|
|
|
directory = path.join('node_modules', child)
|
2014-10-13 18:42:47 +04:00
|
|
|
metadataPath = path.join(directory, 'package.json')
|
|
|
|
continue unless grunt.file.isFile(metadataPath)
|
|
|
|
|
|
|
|
{engines, theme} = grunt.file.readJSON(metadataPath)
|
2013-08-14 20:06:16 +04:00
|
|
|
if engines?.atom?
|
|
|
|
coffeeConfig.glob_to_multiple.src.push("#{directory}/**/*.coffee")
|
2015-04-20 23:25:05 +03:00
|
|
|
coffeeConfig.glob_to_multiple.src.push("!#{directory}/spec/**/*.coffee")
|
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less")
|
2015-04-20 23:32:27 +03:00
|
|
|
lessConfig.glob_to_multiple.src.push("!#{directory}/spec/**/*.less")
|
2015-04-21 00:09:31 +03:00
|
|
|
|
|
|
|
unless theme
|
|
|
|
prebuildLessConfig.src.push("#{directory}/**/*.less")
|
|
|
|
prebuildLessConfig.src.push("!#{directory}/spec/**/*.less")
|
2015-04-20 23:25:05 +03:00
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson")
|
2015-04-20 23:32:27 +03:00
|
|
|
csonConfig.glob_to_multiple.src.push("!#{directory}/spec/**/*.cson")
|
2015-04-20 23:25:05 +03:00
|
|
|
|
2015-04-20 23:24:36 +03:00
|
|
|
pegConfig.glob_to_multiple.src.push("#{directory}/lib/*.pegjs")
|
2013-08-14 20:06:16 +04:00
|
|
|
|
2015-08-19 00:31:03 +03:00
|
|
|
for jsFile in glob.sync("#{directory}/lib/**/*.js")
|
|
|
|
if usesBabel(jsFile)
|
|
|
|
babelConfig.dist.files.push({
|
|
|
|
src: [jsFile]
|
2015-08-19 01:43:38 +03:00
|
|
|
dest: path.join(appDir, jsFile)
|
2015-08-19 00:31:03 +03:00
|
|
|
})
|
|
|
|
|
2013-05-29 04:30:09 +04:00
|
|
|
grunt.initConfig
|
|
|
|
pkg: grunt.file.readJSON('package.json')
|
|
|
|
|
2015-09-22 03:48:16 +03:00
|
|
|
atom: {
|
2015-09-26 00:47:58 +03:00
|
|
|
appName, channel, metadata, disableAutoUpdate,
|
2015-09-22 03:48:16 +03:00
|
|
|
appFileName, apmFileName,
|
|
|
|
appDir, buildDir, contentsDir, installDir, shellAppDir, symbolsDir,
|
|
|
|
}
|
2013-06-27 20:07:33 +04:00
|
|
|
|
2014-08-20 03:52:12 +04:00
|
|
|
docsOutputDir: 'docs/output'
|
2014-06-27 01:30:43 +04:00
|
|
|
|
2015-08-19 00:31:03 +03:00
|
|
|
babel: babelConfig
|
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
coffee: coffeeConfig
|
2013-05-30 04:35:00 +04:00
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
less: lessConfig
|
2013-05-30 04:35:00 +04:00
|
|
|
|
2013-09-17 01:57:48 +04:00
|
|
|
'prebuild-less': prebuildLessConfig
|
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
cson: csonConfig
|
2013-05-30 04:35:00 +04:00
|
|
|
|
2014-01-10 23:32:40 +04:00
|
|
|
peg: pegConfig
|
|
|
|
|
2013-05-29 04:30:09 +04:00
|
|
|
coffeelint:
|
|
|
|
options:
|
2014-08-11 08:41:55 +04:00
|
|
|
configFile: 'coffeelint.json'
|
2013-06-13 00:04:10 +04:00
|
|
|
src: [
|
|
|
|
'dot-atom/**/*.coffee'
|
2013-09-20 01:30:39 +04:00
|
|
|
'exports/**/*.coffee'
|
2013-06-13 00:04:10 +04:00
|
|
|
'src/**/*.coffee'
|
2014-01-15 01:28:30 +04:00
|
|
|
]
|
|
|
|
build: [
|
|
|
|
'build/tasks/**/*.coffee'
|
|
|
|
'build/Gruntfile.coffee'
|
2013-06-13 00:04:10 +04:00
|
|
|
]
|
2013-05-29 22:50:53 +04:00
|
|
|
test: [
|
|
|
|
'spec/*.coffee'
|
|
|
|
]
|
2013-05-29 04:30:09 +04:00
|
|
|
|
2015-08-22 02:56:32 +03:00
|
|
|
standard:
|
|
|
|
src: [
|
|
|
|
'src/**/*.js'
|
|
|
|
'static/*.js'
|
|
|
|
]
|
|
|
|
|
2013-05-29 23:13:47 +04:00
|
|
|
csslint:
|
|
|
|
options:
|
|
|
|
'adjoining-classes': false
|
2013-09-05 01:04:24 +04:00
|
|
|
'duplicate-background-images': false
|
2013-06-12 21:07:04 +04:00
|
|
|
'box-model': false
|
2013-06-12 20:57:58 +04:00
|
|
|
'box-sizing': false
|
|
|
|
'bulletproof-font-face': false
|
|
|
|
'compatible-vendor-prefixes': false
|
2013-08-09 03:46:58 +04:00
|
|
|
'display-property-grouping': false
|
2013-05-29 23:13:47 +04:00
|
|
|
'fallback-colors': false
|
2013-06-12 21:13:09 +04:00
|
|
|
'font-sizes': false
|
2013-06-12 20:57:58 +04:00
|
|
|
'gradients': false
|
2013-06-12 21:07:04 +04:00
|
|
|
'ids': false
|
2013-06-12 20:57:58 +04:00
|
|
|
'important': false
|
2013-06-12 21:07:04 +04:00
|
|
|
'known-properties': false
|
2013-06-18 06:58:21 +04:00
|
|
|
'outline-none': false
|
2013-06-12 21:07:04 +04:00
|
|
|
'overqualified-elements': false
|
|
|
|
'qualified-headings': false
|
|
|
|
'unique-headings': false
|
|
|
|
'universal-selector': false
|
2013-06-12 03:34:48 +04:00
|
|
|
'vendor-prefix': false
|
|
|
|
src: [
|
|
|
|
'static/**/*.css'
|
|
|
|
]
|
2013-05-29 04:30:09 +04:00
|
|
|
|
2013-06-12 20:57:58 +04:00
|
|
|
lesslint:
|
|
|
|
src: [
|
|
|
|
'static/**/*.less'
|
|
|
|
]
|
|
|
|
|
2015-05-20 22:12:09 +03:00
|
|
|
'download-electron':
|
|
|
|
version: packageJson.electronVersion
|
|
|
|
outputDir: 'electron'
|
|
|
|
downloadDir: electronDownloadDir
|
2015-05-21 00:50:52 +03:00
|
|
|
rebuild: true # rebuild native modules after electron is updated
|
2015-01-14 01:37:21 +03:00
|
|
|
token: process.env.ATOM_ACCESS_TOKEN
|
2013-12-03 15:54:42 +04:00
|
|
|
|
2014-11-13 04:14:20 +03:00
|
|
|
'create-windows-installer':
|
2015-07-29 21:31:54 +03:00
|
|
|
installer:
|
2015-07-29 20:52:43 +03:00
|
|
|
appDirectory: shellAppDir
|
|
|
|
outputDirectory: path.join(buildDir, 'installer')
|
|
|
|
authors: 'GitHub Inc.'
|
|
|
|
loadingGif: path.resolve(__dirname, '..', 'resources', 'win', 'loading.gif')
|
2015-09-22 03:48:16 +03:00
|
|
|
iconUrl: "https://raw.githubusercontent.com/atom/atom/master/resources/app-icons/#{channel}/atom.ico"
|
|
|
|
setupIcon: path.resolve(__dirname, '..', 'resources', 'app-icons', channel, 'atom.ico')
|
2015-10-30 00:35:10 +03:00
|
|
|
remoteReleases: "https://atom.io/api/updates?version=#{metadata.version}"
|
2014-11-13 04:14:20 +03:00
|
|
|
|
2013-08-29 01:11:05 +04:00
|
|
|
shell:
|
|
|
|
'kill-atom':
|
2014-07-05 21:41:45 +04:00
|
|
|
command: killCommand
|
2013-08-29 01:11:05 +04:00
|
|
|
options:
|
|
|
|
stdout: false
|
|
|
|
stderr: false
|
|
|
|
failOnError: false
|
|
|
|
|
2015-08-19 00:31:03 +03:00
|
|
|
grunt.registerTask('compile', ['babel', 'coffee', 'prebuild-less', 'cson', 'peg'])
|
2015-08-22 02:56:32 +03:00
|
|
|
grunt.registerTask('lint', ['standard', 'coffeelint', 'csslint', 'lesslint'])
|
2013-10-11 22:39:16 +04:00
|
|
|
grunt.registerTask('test', ['shell:kill-atom', 'run-specs'])
|
2014-03-17 11:44:58 +04:00
|
|
|
|
2015-11-11 01:37:01 +03:00
|
|
|
ciTasks = []
|
|
|
|
ciTasks.push('output-disk-space') unless process.env.CI
|
|
|
|
ciTasks.push('download-electron')
|
|
|
|
ciTasks.push('download-electron-chromedriver')
|
|
|
|
ciTasks.push('build')
|
2015-11-17 19:42:17 +03:00
|
|
|
ciTasks.push('fingerprint')
|
2014-09-12 22:14:08 +04:00
|
|
|
ciTasks.push('dump-symbols') if process.platform isnt 'win32'
|
2015-04-09 00:04:50 +03:00
|
|
|
ciTasks.push('set-version', 'check-licenses', 'lint', 'generate-asar')
|
2014-09-22 21:33:29 +04:00
|
|
|
ciTasks.push('mkdeb') if process.platform is 'linux'
|
2015-11-11 01:37:01 +03:00
|
|
|
ciTasks.push('codesign:exe') if process.platform is 'win32' and not process.env.CI
|
2015-07-29 21:31:54 +03:00
|
|
|
ciTasks.push('create-windows-installer:installer') if process.platform is 'win32'
|
2015-04-15 16:20:54 +03:00
|
|
|
ciTasks.push('test') if process.platform is 'darwin'
|
2015-11-11 01:37:01 +03:00
|
|
|
ciTasks.push('codesign:installer') if process.platform is 'win32' and not process.env.CI
|
|
|
|
ciTasks.push('codesign:app') if process.platform is 'darwin' and not process.env.CI
|
|
|
|
ciTasks.push('publish-build') unless process.env.CI
|
2014-09-10 21:08:06 +04:00
|
|
|
grunt.registerTask('ci', ciTasks)
|
|
|
|
|
2015-05-20 22:21:18 +03:00
|
|
|
defaultTasks = ['download-electron', 'download-electron-chromedriver', 'build', 'set-version', 'generate-asar']
|
2015-05-21 00:48:11 +03:00
|
|
|
unless process.platform is 'linux' or grunt.option('no-install')
|
|
|
|
defaultTasks.push 'install'
|
2014-03-17 11:44:58 +04:00
|
|
|
grunt.registerTask('default', defaultTasks)
|