Skip to content

Commit

Permalink
adding new grunt features
Browse files Browse the repository at this point in the history
  • Loading branch information
imkevinxu committed Oct 8, 2014
1 parent 3b841c4 commit ba0691d
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 46 deletions.
1 change: 1 addition & 0 deletions Gruntfile.coffee
Expand Up @@ -9,6 +9,7 @@ module.exports = (grunt) ->
fonts: name + '/static/fonts'
img: name + '/static/img'
js: name + '/static/js'
config: name + '/config'
tests: 'tests'

# Loads grunt config automatically via broken up tasks
Expand Down
31 changes: 21 additions & 10 deletions grunt/aliases.yaml
Expand Up @@ -5,7 +5,7 @@ lint_stylesheets:
- 'scsslint'

lint_scripts:
- 'coffeelint'
- 'coffeelint:scripts'

lint:
- 'lint_stylesheets'
Expand All @@ -19,8 +19,7 @@ build_stylesheets:

build_scripts:
- 'clean:scripts'
- 'coffee'
- 'copy:tests'
- 'coffee:scripts'

build_images:
- 'clean:images'
Expand All @@ -34,19 +33,31 @@ build:
heroku:
- 'build'

compile:
dev:
- 'lint'
- 'build'
- 'notify:compile'
- 'open:dev'
- 'watch'

test:
- 'clean:tests'
lint_jasmine:
- 'coffeelint:jasmine'

build_jasmine:
- 'copy:jasmine'
- 'coffee'
- 'jasmine'
- 'copy:coverage'
- 'copy:specRunner'
- 'clean:specRunner'
- 'replace:coverage'
- 'replace:specRunner'

dev:
- 'compile'
- 'test'
- 'concurrent:dev'
test:
- 'shell:flake8'
- 'shell:django'
- 'clean:jasmine'
- 'lint_jasmine'
- 'build_jasmine'
- 'notify:test'
- 'concurrent:tests'
7 changes: 6 additions & 1 deletion grunt/clean.coffee
Expand Up @@ -12,7 +12,12 @@ module.exports =

images: ['<%= paths.img %>/compressed']

tests: ['<%= paths.tests %>/*']
tests: [
'<%= paths.tests %>/*'
'.coverage'
]

jasmine: ['<%= paths.tests %>/jasmine']

specRunner: ['_SpecRunner.html']

Expand Down
2 changes: 1 addition & 1 deletion grunt/coffee.coffee
Expand Up @@ -14,7 +14,7 @@ module.exports =
ext: '.js'
]

tests:
jasmine:
options:
sourceMap: true
files: [
Expand Down
2 changes: 1 addition & 1 deletion grunt/coffeelint.coffee
Expand Up @@ -5,4 +5,4 @@ module.exports =

scripts: ['<%= paths.js %>/coffee/*.coffee']

tests: ['<%= paths.js %>/tests/coffee/*.coffee']
jasmine: ['<%= paths.js %>/tests/coffee/*.coffee']
8 changes: 3 additions & 5 deletions grunt/concurrent.coffee
Expand Up @@ -3,13 +3,11 @@ module.exports =
# Run grunt tasks concurrently
# https://github.com/sindresorhus/grunt-concurrent

# Concurrently run two continuous tasks during development
# - Static server at localhost:9000 to watch jasmine test spec runner
# - Watch when files change and re-compile
dev:
tests:
options:
logConcurrentOutput: true
tasks: [
'connect:jasmine'
'connect:tests'
'watch'
'shell:tdaemon'
]
4 changes: 1 addition & 3 deletions grunt/connect.coffee
Expand Up @@ -3,11 +3,9 @@ module.exports =
# Start a static web server
# https://github.com/gruntjs/grunt-contrib-connect

jasmine:
tests:
options:
port: 9000
hostname: 'localhost'
livereload: true
keepalive: true
open:
target: 'http://localhost:9000/tests/jasmine.html'
8 changes: 6 additions & 2 deletions grunt/copy.coffee
Expand Up @@ -3,12 +3,16 @@ module.exports =
# Copy files and folders
# https://github.com/gruntjs/grunt-contrib-copy

tests:
jasmine:
expand: true
flatten: true
src: '<%= paths.js %>/tests/lib/*.js'
dest: '<%= paths.js %>/tests/build/'

coverage:
src: '<%= paths.tests %>/jasmine/index.html'
dest: '<%= paths.tests %>/jasmine/coverage.html'

specRunner:
src: '_SpecRunner.html'
dest: '<%= paths.tests %>/jasmine.html'
dest: '<%= paths.tests %>/jasmine/index.html'
11 changes: 6 additions & 5 deletions grunt/jasmine.coffee
Expand Up @@ -11,20 +11,21 @@ module.exports =
specs: '<%= paths.js %>/tests/build/*Spec.js'
helpers: '<%= paths.js %>/tests/build/*Helper.js'
vendor: [
'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'
'<%= paths.js %>/lib/*.js',
]
'<%= paths.js %>/lib/jquery.js'
'<%= paths.js %>/lib/*.js'
]
keepRunner: true
template: require('grunt-template-jasmine-istanbul')
templateOptions:
coverage: '<%= paths.tests %>/coverage/coverage.json'
coverage: '<%= paths.tests %>/jasmine/coverage.json'
report: [
{
type: 'html'
options:
dir: '<%= paths.tests %>/coverage'
dir: '<%= paths.tests %>/jasmine'
}
{ type: 'text-summary' }
{ type: 'text' }
]

src: '<%= paths.js %>/build/*.js'
13 changes: 13 additions & 0 deletions grunt/open.coffee
@@ -0,0 +1,13 @@
module.exports =

# Open urls and files from a grunt task
# https://github.com/jsoverson/grunt-open

jasmine:
path: 'http://localhost:9000/tests/jasmine/'

django:
path: 'http://localhost:9000/tests/django/'

dev:
path: 'http://localhost:8000'
22 changes: 18 additions & 4 deletions grunt/replace.coffee
Expand Up @@ -11,23 +11,37 @@ module.exports =
to: '/static'
]

coverage:
src: ['<%= paths.tests %>/jasmine/coverage.html']
overwrite: true
replacements: [
from: '<div class="header high">'
to: '<div class="header high">
<h1>
<a href="/tests/jasmine" style="color: #000;">
Click here for Jasmine Tests
</a>
</h1>
'
]

specRunner:
src: ['<%= paths.tests %>/jasmine.html']
src: ['<%= paths.tests %>/jasmine/index.html']
overwrite: true
replacements: [
{
from: '.grunt'
to: '../.grunt'
to: '../../.grunt'
}
{
from: '<%= name %>'
to: '../<%= name %>'
to: '../../<%= name %>'
}
{
from: '</body>'
to: '
<h1 style="font-family: Helvetica Neue; font-weight: 300;">
<a href="/tests/coverage" style="color: #007069;">
<a href="/tests/jasmine/coverage.html" style="color: #007069;">
Click here for JS Test Coverage
</a>
</h1></body>
Expand Down
13 changes: 13 additions & 0 deletions grunt/shell.coffee
@@ -0,0 +1,13 @@
module.exports =

# Run shell commands
# https://github.com/sindresorhus/grunt-shell

flake8:
command: 'flake8 <%= name %>'

django:
command: 'coverage run $(which django-admin.py) test && coverage combine && coverage report && coverage html'

tdaemon:
command: 'python <%= paths.config %>/lib/tdaemon.py <%= name %> -t django-nose-coverage --ignore-dirs=static,templates'
23 changes: 9 additions & 14 deletions grunt/watch.coffee
Expand Up @@ -33,25 +33,20 @@ module.exports =
]

scripts:
files: [
'<%= paths.js %>/coffee/*.coffee'
]
files: ['<%= paths.js %>/coffee/*.coffee']
tasks: [
'newer:coffeelint:scripts'
'newer:coffee:scripts'
'test'
]

tests:
files: [
'<%= paths.js %>/tests/coffee/*.coffee'
]
tasks: [
'newer:coffeelint:tests'
'newer:coffee:tests'
'test'
]

images:
files: ['<%= paths.img %>/**/*.{png,jpg,gif,svg}']
tasks: ['newer:imagemin']

jasmine:
files: ['<%= paths.js %>/tests/coffee/*.coffee']
tasks: [
'lint_jasmine'
'build_jasmine'
'notify:test'
]

0 comments on commit ba0691d

Please sign in to comment.