pulsar/Gruntfile.coffee

182 lines
4.8 KiB
CoffeeScript
Raw Normal View History

fs = require 'fs'
2013-05-30 04:35:00 +04:00
path = require 'path'
2013-08-20 21:52:18 +04:00
fm = require 'json-front-matter'
_ = require 'underscore'
packageJson = require './package.json'
2013-05-29 04:30:09 +04:00
module.exports = (grunt) ->
2013-06-27 20:07:33 +04:00
appName = 'Atom.app'
2013-08-20 21:52:18 +04:00
[major, minor, patch] = packageJson.version.split('.')
2013-06-27 20:07:33 +04:00
buildDir = grunt.option('build-dir') ? '/tmp/atom-build'
shellAppDir = path.join(buildDir, appName)
contentsDir = path.join(shellAppDir, 'Contents')
appDir = path.join(contentsDir, 'Resources', 'app')
installDir = path.join('/Applications', appName)
coffeeConfig =
options:
sourceMap: true
glob_to_multiple:
expand: true
src: [
'src/**/*.coffee'
'static/**/*.coffee'
]
dest: appDir
ext: '.js'
lessConfig =
options:
paths: [
'static'
'vendor'
]
glob_to_multiple:
expand: true
src: [
'src/**/*.less'
'static/**/*.less'
'themes/**/*.less'
]
dest: appDir
ext: '.css'
csonConfig =
options:
rootObject: true
glob_to_multiple:
expand: true
src: [
2013-08-21 01:12:17 +04:00
'keymaps/*.cson'
'src/**/*.cson'
'static/**/*.cson'
'themes/**/*.cson'
]
dest: appDir
ext: '.json'
for child in fs.readdirSync('node_modules') when child isnt '.bin'
directory = path.join('node_modules', child)
{engines} = grunt.file.readJSON(path.join(directory, 'package.json'))
if engines?.atom?
coffeeConfig.glob_to_multiple.src.push("#{directory}/**/*.coffee")
lessConfig.glob_to_multiple.src.push("#{directory}/**/*.less")
csonConfig.glob_to_multiple.src.push("#{directory}/**/*.cson")
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}
coffee: coffeeConfig
2013-05-30 04:35:00 +04:00
less: lessConfig
2013-05-30 04:35:00 +04:00
cson: csonConfig
2013-05-30 04:35:00 +04:00
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-06-13 00:04:10 +04:00
src: [
'dot-atom/**/*.coffee'
'src/**/*.coffee'
]
2013-05-29 22:50:53 +04:00
test: [
'spec/*.coffee'
'spec/app/**/*.coffee'
'spec/stdlib/**/*.coffee'
]
2013-05-29 04:30:09 +04:00
2013-05-29 23:13:47 +04:00
csslint:
options:
'adjoining-classes': 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
'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: [
'src/**/*.css',
'static/**/*.css'
'themes/**/*.css'
]
2013-05-29 04:30:09 +04:00
2013-06-12 20:57:58 +04:00
lesslint:
src: [
'src/**/*.less',
'static/**/*.less'
'themes/**/*.less'
]
markdown:
guides:
files: [
2013-08-20 21:52:18 +04:00
expand: true
cwd: 'docs'
2013-08-20 21:52:18 +04:00
src: '**/*.md'
dest: 'docs/output/'
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
shell:
'kill-atom':
command: 'pkill Atom'
options:
stdout: false
stderr: false
failOnError: false
test:
command: "#{path.join(contentsDir, 'MacOS', 'Atom')} --test --resource-path=#{__dirname}"
options:
2013-08-29 01:15:30 +04:00
stdout: true
stderr: true
callback: (error, stdout, stderr, callback) ->
2013-08-29 01:15:30 +04:00
grunt.warn('Specs failed') if error?
callback()
2013-05-29 04:30:09 +04:00
grunt.loadNpmTasks('grunt-coffeelint')
2013-06-12 20:57:58 +04:00
grunt.loadNpmTasks('grunt-lesslint')
2013-06-16 09:09:38 +04:00
grunt.loadNpmTasks('grunt-cson')
2013-05-29 23:13:47 +04:00
grunt.loadNpmTasks('grunt-contrib-csslint')
2013-05-30 04:35:00 +04:00
grunt.loadNpmTasks('grunt-contrib-coffee')
grunt.loadNpmTasks('grunt-contrib-less')
grunt.loadNpmTasks('grunt-markdown')
grunt.loadNpmTasks('grunt-shell')
grunt.loadTasks('tasks')
2013-06-27 20:07:33 +04:00
2013-05-30 04:35:00 +04:00
grunt.registerTask('compile', ['coffee', 'less', 'cson'])
2013-06-12 20:57:58 +04:00
grunt.registerTask('lint', ['coffeelint', 'csslint', 'lesslint'])
grunt.registerTask('test', ['shell:kill-atom', 'shell:test'])
grunt.registerTask('ci', ['lint', 'partial-clean', 'update-atom-shell', 'build', 'set-development-version', 'test'])
2013-07-08 22:29:46 +04:00
grunt.registerTask('deploy', ['partial-clean', 'update-atom-shell', 'build', 'codesign'])
grunt.registerTask('docs', ['markdown:guides', 'build-docs'])
2013-06-21 02:43:51 +04:00
grunt.registerTask('default', ['update-atom-shell', 'build', 'set-development-version', 'install'])