-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
160 lines (137 loc) · 4.26 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
make = "make -f ./node_modules/microflo/Makefile"
common_options = [
"BUILD_DIR=#{process.cwd()}/build"
"MICROFLO=./node_modules/.bin/microflo"
"GRAPH=graphs/microsynchro.fbp"
"MICROFLO_SOURCE_DIR=`pwd`/node_modules/microflo/microflo"
]
microflo = (target) ->
build = [ make, target ]
build = build.concat common_options
return build.join ' '
flash = (device) ->
build = [ make, "upload", "SERIALPORT=#{device}" ]
build = build.concat common_options
return build.join ' '
module.exports = ->
# Project configuration
pkg = @file.readJSON 'package.json'
repo = pkg.repository.url.replace 'git://', 'https://'+process.env.GH_TOKEN+'@'
@initConfig
pkg: @file.readJSON 'package.json'
# MicroFlo
exec:
microflo_emscripten: microflo "build-emscripten"
microflo_arduino: microflo "build-arduino"
microflo_flash: flash '/dev/ttyACM0'
# Updating the package manifest files
noflo_manifest:
update:
files:
'component.json': ['graphs/*', 'components/*']
'package.json': ['graphs/*', 'components/*']
# CoffeeScript compilation of tests
coffee:
spec:
options:
bare: true
expand: true
cwd: 'spec'
src: ['**.coffee']
dest: 'spec'
ext: '.js'
# Browser build of NoFlo
noflo_browser:
build:
options:
debug: true
files:
"browser/<%=pkg.name%>.js": ['component.json']
# JavaScript minification for the browser
uglify:
options:
report: 'min'
noflo:
files:
"./browser/<%=pkg.name%>.min.js": ["./browser/<%=pkg.name%>.js"]
# Automated recompilation and testing when developing
watch:
files: ['spec/*.coffee', 'components/*.coffee']
tasks: ['test']
# BDD tests on Node.js
cafemocha:
nodejs:
src: ['spec/*.coffee']
options:
reporter: 'spec'
# Generate runner.html
noflo_browser_mocha:
all:
options:
scripts: ["../browser/<%=pkg.name%>.js"]
files:
'spec/runner.html': ['spec/*.js']
# BDD tests on browser
mocha_phantomjs:
options:
output: 'spec/result.xml'
reporter: 'spec'
all: ['spec/runner.html']
# Coding standards
coffeelint:
components: ['Gruntfile.coffee', 'spec/*.coffee', 'components/*.coffee']
options:
'max_line_length':
'level': 'ignore'
'gh-pages':
options:
base: 'browser'
clone: 'gh-pages'
message: 'Updating'
repo: repo
user:
name: 'NoFlo bot'
email: '[email protected]'
silent: true
src: '**/*'
# Grunt plugins used for building
@loadNpmTasks 'grunt-contrib-coffee'
@loadNpmTasks 'grunt-noflo-manifest'
@loadNpmTasks 'grunt-noflo-browser'
@loadNpmTasks 'grunt-contrib-uglify'
# Grunt plugins used for testing
@loadNpmTasks 'grunt-contrib-watch'
@loadNpmTasks 'grunt-cafe-mocha'
@loadNpmTasks 'grunt-mocha-phantomjs'
@loadNpmTasks 'grunt-coffeelint'
@loadNpmTasks 'grunt-exec'
# Grunt plugins used for deploying
@loadNpmTasks 'grunt-gh-pages'
# Our local tasks
@registerTask 'build:microflo', '', (target = 'all') =>
fs = require 'fs'
if not fs.existsSync 'thirdparty'
# TEMP HACK
fs.symlinkSync 'node_modules/microflo/thirdparty', 'thirdparty'
if target in ['all', 'emscripten']
@task.run 'exec:microflo_emscripten'
if target in ['all', 'arduino']
@task.run 'exec:microflo_arduino'
@registerTask 'flash', '', () =>
@task.run 'exec:microflo_flash'
@registerTask 'build', 'Build NoFlo for the chosen target platform', (target = 'all') =>
if target is 'all' or target is 'browser' or target is 'nodejs'
@task.run 'coffee'
@task.run 'noflo_manifest'
if target is 'all' or target is 'browser'
@task.run 'noflo_browser'
@task.run 'uglify'
@registerTask 'test', 'Build NoFlo and run automated tests', (target = 'all') =>
@task.run "build:#{target}"
if target is 'all' or target is 'nodejs'
@task.run 'cafemocha'
if target is 'all' or target is 'browser'
@task.run 'noflo_browser'
@task.run 'noflo_browser_mocha'
@task.run 'mocha_phantomjs'
@registerTask 'default', ['test']