forked from noflo/noflo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
170 lines (153 loc) · 4.32 KB
/
Gruntfile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
module.exports = ->
# Project configuration
@initConfig
pkg: @file.readJSON 'package.json'
# CoffeeScript compilation
coffee:
libraries:
expand: true
cwd: 'src/lib'
src: ['**.coffee']
dest: 'lib'
ext: '.js'
libraries_nodejs:
expand: true
cwd: 'src/lib/nodejs'
src: ['**.coffee']
dest: 'lib/nodejs'
ext: '.js'
bin:
expand: true
cwd: 'src/bin'
src: ['**.coffee']
dest: 'bin'
ext: '.js'
spec:
options:
bare: true
expand: true
cwd: 'spec'
src: ['**.coffee']
dest: 'spec'
ext: '.js'
# Browser version building
component:
install:
options:
action: 'install'
component_build:
noflo:
output: './browser/'
config: './component.json'
scripts: true
styles: false
plugins: ['coffee']
configure: (builder) ->
# Enable Component plugins
json = require 'component-json'
builder.use json()
# JavaScript minification for the browser
uglify:
options:
banner: '/* NoFlo <%= pkg.version %> - Flow-Based Programming environment. See http://noflojs.org for more information. */'
report: 'min'
noflo:
files:
'./browser/noflo.min.js': ['./browser/noflo.js']
# Automated recompilation and testing when developing
watch:
files: ['spec/*.coffee', 'spec/**/*.coffee', 'test/*.coffee', 'src/**/*.coffee']
tasks: ['test']
# Unit tests
nodeunit:
all: ['test/*.coffee']
# BDD tests on Node.js
cafemocha:
nodejs:
src: ['spec/*.coffee']
options:
reporter: 'dot'
# Web server for the browser tests
connect:
server:
options:
port: 8000
# BDD tests on browser
mocha_phantomjs:
all:
options:
output: 'spec/result.xml'
reporter: 'dot'
urls: ['http://localhost:8000/spec/runner.html']
# Coding standards
coffeelint:
libraries:
files:
src: ['src/lib/*.coffee', 'src/bin/*.coffee']
options:
max_line_length:
value: 80
level: 'warn'
no_trailing_semicolons:
level: 'warn'
components:
files:
src: ['src/components/*.coffee']
options:
max_line_length:
value: 80
level: 'warn'
# Release automation
bumpup: ['package.json', 'component.json']
tagrelease:
file: 'package.json'
prefix: ''
exec:
npm_publish:
cmd: 'npm publish'
# Grunt plugins used for building
@loadNpmTasks 'grunt-contrib-coffee'
@loadNpmTasks 'grunt-component'
@loadNpmTasks 'grunt-component-build'
@loadNpmTasks 'grunt-contrib-uglify'
# Grunt plugins used for testing
@loadNpmTasks 'grunt-contrib-watch'
@loadNpmTasks 'grunt-contrib-nodeunit'
@loadNpmTasks 'grunt-contrib-connect'
@loadNpmTasks 'grunt-cafe-mocha'
@loadNpmTasks 'grunt-mocha-phantomjs'
@loadNpmTasks 'grunt-coffeelint'
# Grunt plugins used for release automation
@loadNpmTasks 'grunt-bumpup'
@loadNpmTasks 'grunt-tagrelease'
@loadNpmTasks 'grunt-exec'
# Our local tasks
@registerTask 'build', 'Build NoFlo for the chosen target platform', (target = 'all') =>
@task.run 'coffee'
if target is 'all' or target is 'browser'
@task.run 'component'
@task.run 'component_build'
@task.run 'uglify'
@registerTask 'test', 'Build NoFlo and run automated tests', (target = 'all') =>
@task.run 'coffeelint'
@task.run 'coffee'
if target is 'all' or target is 'nodejs'
@task.run 'nodeunit'
@task.run 'cafemocha'
if target is 'all' or target is 'browser'
@task.run 'connect'
@task.run 'component'
@task.run 'component_build'
@task.run 'mocha_phantomjs'
@registerTask 'default', ['test']
# Task for releasing new NoFlo versions
#
# Builds, runs tests, updates package.json, tags a release, and publishes on NPM
#
# Usage: grunt release:patch
@registerTask 'release', 'Build, test, tag, and release NoFlo', (type = 'patch') =>
@task.run 'build'
@task.run 'test'
@task.run "bumpup:#{type}"
@task.run 'tagrelease'
@task.run 'exec:npm_publish'