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'
|
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-08-20 21:52:18 +04:00
|
|
|
fm = require 'json-front-matter'
|
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
|
|
|
|
2014-01-01 05:01:23 +04:00
|
|
|
# Shim harmony collections in case grunt was invoked without harmony
|
|
|
|
# collections enabled
|
|
|
|
_.extend(global, require('harmony-collections')) unless global.WeakMap?
|
|
|
|
|
2013-05-29 04:30:09 +04:00
|
|
|
module.exports = (grunt) ->
|
2013-11-21 22:39:31 +04:00
|
|
|
grunt.loadNpmTasks('grunt-coffeelint')
|
|
|
|
grunt.loadNpmTasks('grunt-lesslint')
|
|
|
|
grunt.loadNpmTasks('grunt-cson')
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-csslint')
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-coffee')
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-less')
|
|
|
|
grunt.loadNpmTasks('grunt-markdown')
|
|
|
|
grunt.loadNpmTasks('grunt-shell')
|
|
|
|
grunt.loadNpmTasks('grunt-download-atom-shell')
|
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('..'))
|
|
|
|
|
2013-11-14 05:52:22 +04:00
|
|
|
if not grunt.option('verbose')
|
|
|
|
grunt.log.writeln = (args...) -> grunt.log
|
2013-11-14 22:53:19 +04:00
|
|
|
grunt.log.write = (args...) -> grunt.log
|
2013-11-14 05:52:22 +04:00
|
|
|
|
2013-08-20 21:52:18 +04:00
|
|
|
[major, minor, patch] = packageJson.version.split('.')
|
2013-10-29 00:38:33 +04:00
|
|
|
if process.platform is 'win32'
|
|
|
|
appName = 'Atom'
|
|
|
|
tmpDir = os.tmpdir()
|
|
|
|
installRoot = process.env.ProgramFiles
|
2013-10-29 01:26:54 +04:00
|
|
|
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
|
|
|
|
shellAppDir = path.join(buildDir, appName)
|
2013-12-17 21:39:49 +04:00
|
|
|
contentsDir = shellAppDir
|
2013-10-29 01:26:54 +04:00
|
|
|
appDir = path.join(shellAppDir, 'resources', 'app')
|
2013-12-03 16:13:17 +04:00
|
|
|
atomShellDownloadDir = path.join(os.tmpdir(), 'atom-cached-atom-shells')
|
2013-10-29 00:38:33 +04:00
|
|
|
else
|
|
|
|
appName = 'Atom.app'
|
|
|
|
tmpDir = '/tmp'
|
|
|
|
installRoot = '/Applications'
|
2013-10-29 01:26:54 +04:00
|
|
|
buildDir = grunt.option('build-dir') ? path.join(tmpDir, 'atom-build')
|
|
|
|
shellAppDir = path.join(buildDir, appName)
|
|
|
|
contentsDir = path.join(shellAppDir, 'Contents')
|
|
|
|
appDir = path.join(contentsDir, 'Resources', 'app')
|
2013-12-03 16:13:17 +04:00
|
|
|
atomShellDownloadDir = '/tmp/atom-cached-atom-shells'
|
2013-10-29 00:38:33 +04:00
|
|
|
|
2013-10-28 22:39:48 +04:00
|
|
|
installDir = path.join(installRoot, appName)
|
2013-06-18 20:50:25 +04:00
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
coffeeConfig =
|
|
|
|
options:
|
|
|
|
sourceMap: true
|
|
|
|
glob_to_multiple:
|
|
|
|
expand: true
|
|
|
|
src: [
|
|
|
|
'src/**/*.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'
|
|
|
|
|
|
|
|
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-09-18 02:04:46 +04:00
|
|
|
'node_modules/bootstrap/less/bootstrap.less'
|
2013-09-17 01:57:48 +04:00
|
|
|
]
|
|
|
|
|
2013-08-14 20:06:16 +04:00
|
|
|
csonConfig =
|
|
|
|
options:
|
|
|
|
rootObject: true
|
|
|
|
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)
|
2013-09-17 01:57:48 +04:00
|
|
|
{engines, theme} = grunt.file.readJSON(path.join(directory, 'package.json'))
|
2013-08-14 20:06:16 +04:00
|
|
|
if engines?.atom?
|
|
|
|
coffeeConfig.glob_to_multiple.src.push("#{directory}/**/*.coffee")
|
|
|
|
lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less")
|
2013-09-17 01:57:48 +04:00
|
|
|
prebuildLessConfig.src.push("#{directory}/**/*.less") unless theme
|
2013-08-14 20:06:16 +04:00
|
|
|
csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson")
|
2014-01-10 23:32:40 +04:00
|
|
|
pegConfig.glob_to_multiple.src.push("#{directory}/**/*.pegjs")
|
2013-08-14 20:06:16 +04:00
|
|
|
|
2013-05-29 04:30:09 +04:00
|
|
|
grunt.initConfig
|
|
|
|
pkg: grunt.file.readJSON('package.json')
|
|
|
|
|
2013-06-27 20:07:33 +04:00
|
|
|
atom: {appDir, appName, buildDir, contentsDir, installDir, shellAppDir}
|
|
|
|
|
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:
|
2013-06-06 19:16:23 +04:00
|
|
|
no_empty_param_list:
|
|
|
|
level: 'error'
|
2013-05-29 04:30:09 +04:00
|
|
|
max_line_length:
|
|
|
|
level: 'ignore'
|
2013-10-11 02:05:58 +04:00
|
|
|
indentation:
|
|
|
|
level: 'ignore'
|
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
|
|
|
|
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'
|
|
|
|
]
|
|
|
|
|
2013-08-20 03:20:13 +04:00
|
|
|
markdown:
|
|
|
|
guides:
|
|
|
|
files: [
|
2013-08-20 21:52:18 +04:00
|
|
|
expand: true
|
2013-08-20 03:20:13 +04:00
|
|
|
cwd: 'docs'
|
2013-08-20 21:52:18 +04:00
|
|
|
src: '**/*.md'
|
|
|
|
dest: 'docs/output/'
|
2013-08-20 03:20:13 +04:00
|
|
|
ext: '.html'
|
|
|
|
]
|
2013-08-20 21:52:18 +04:00
|
|
|
options:
|
|
|
|
template: 'docs/template.jst'
|
|
|
|
templateContext:
|
|
|
|
tag: "v#{major}.#{minor}"
|
|
|
|
markdownOptions:
|
|
|
|
gfm: true
|
|
|
|
preCompile: (src, context) ->
|
|
|
|
parsed = fm.parse(src)
|
|
|
|
_.extend(context, parsed.attributes)
|
|
|
|
parsed.body
|
|
|
|
|
2013-12-03 15:54:42 +04:00
|
|
|
'download-atom-shell':
|
|
|
|
version: packageJson.atomShellVersion
|
|
|
|
outputDir: 'atom-shell'
|
2013-12-03 16:13:17 +04:00
|
|
|
downloadDir: atomShellDownloadDir
|
2013-12-03 15:54:42 +04:00
|
|
|
rebuild: true # rebuild native modules after atom-shell is updated
|
|
|
|
|
2013-08-29 01:11:05 +04:00
|
|
|
shell:
|
|
|
|
'kill-atom':
|
2013-09-26 04:10:01 +04:00
|
|
|
command: 'pkill -9 Atom'
|
2013-08-29 01:11:05 +04:00
|
|
|
options:
|
|
|
|
stdout: false
|
|
|
|
stderr: false
|
|
|
|
failOnError: false
|
|
|
|
|
2014-01-10 23:32:40 +04:00
|
|
|
grunt.registerTask('compile', ['coffee', 'prebuild-less', 'cson', 'peg'])
|
2013-06-12 20:57:58 +04:00
|
|
|
grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint'])
|
2013-10-11 22:39:16 +04:00
|
|
|
grunt.registerTask('test', ['shell:kill-atom', 'run-specs'])
|
2014-02-18 00:03:20 +04:00
|
|
|
grunt.registerTask('ci', ['output-disk-space', 'download-atom-shell', 'build', 'set-version', 'check-licenses', 'lint', 'test', 'codesign', 'publish-build'])
|
2013-08-20 03:20:13 +04:00
|
|
|
grunt.registerTask('docs', ['markdown:guides', 'build-docs'])
|
2014-01-15 04:15:48 +04:00
|
|
|
grunt.registerTask('default', ['download-atom-shell', 'build', 'set-version', 'install'])
|