This repository has been archived by the owner on Nov 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Gruntfile.coffee
167 lines (124 loc) · 5.85 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
log = require('util').log
_ = require 'lodash'
kickoff = require 'karma-kickoff'
argv = require('yargs').argv
coffeelint = require './grunt/coffeelint'
watch = require './grunt/options/watch'
module.exports = (grunt) ->
# Load the required plugins
require('./grunt/bower')(grunt)
[
"grunt-contrib-uglify"
"grunt-contrib-jshint"
"grunt-contrib-concat"
"grunt-contrib-clean"
"grunt-contrib-connect"
"grunt-contrib-copy"
"grunt-contrib-watch"
"grunt-open"
"grunt-mkdir"
"grunt-contrib-coffee"
"grunt-conventional-changelog"
"grunt-bump"
'grunt-replace'
'grunt-subgrunt'
'grunt-debug-task'
'grunt-verbosity'
'grunt-webpack'
'grunt-angular-architecture-graph'
'grunt-ng-annotate'
].forEach (gruntLib) -> grunt.loadNpmTasks gruntLib
#squishing this file done by moving grunt options out to its own file. This way we can focus on tasks!
options = require('./grunt/options')(grunt)
allExamples = grunt.file.expand('example/*.html')
#map allExamples listed from grunt.file.expand to an open format of 'example' -> path
allExamplesOpen = {}
allExamples.forEach (path) ->
root = path.replace('example/', '').replace('.html', '')
pathValue = "http://localhost:3100/#{path}"
allExamplesOpen[root] =
path: pathValue
showOpenType = (toIterate = allExamplesOpen) ->
_(toIterate).each (v, k) ->
log "#{k} -> #{v.path}"
#showAllExamples()
options.open = _.extend options.open, allExamplesOpen
grunt.initConfig options
lints = _.keys(_.omit(watch.coffeelint, 'options'))
coffeeLints = lints.map (n) -> "coffeelint:#{n}"
coffeeLintsThrow = lints.map (n) -> "coffeelint:#{n}:throw"
lints.forEach (n) ->
grunt.registerTask "coffeelint:#{n}", ->
coffeelint({src:watch.coffeelint[n].files, doThrow:false}, @async())
grunt.registerTask "coffeelint:#{n}:throw", ->
coffeelint({src:watch.coffeelint[n].files}, @async())
grunt.registerTask 'lint', coffeeLints
grunt.registerTask 'lintWatch', lints.map (n) -> "watch:coffeelint-#{n}"
grunt.registerTask 'build', coffeeLintsThrow.concat ['bower', 'clean:dist', 'jshint', 'mkdir', 'lint', 'coffee', 'ngAnnotate',
'concat:libs', 'replace', 'webpack:commonjsDeps']
grunt.registerTask 'buildDist', ['build', 'concat:dist']
grunt.registerTask "default", [ 'verbosity', 'buildDist', 'copy', 'uglify:dist', 'uglify:streetview', 'karma']
grunt.registerTask "buildAll", ["build", "concat", "uglify", "copy", "karma", "graph"]
# run default "grunt" prior to generate _SpecRunner.html
grunt.registerTask "spec", [ 'verbosity', "buildDist",
"copy", "karma", "open:jasmine", "watch:spec"]
grunt.registerTask "coverage", ['connect:coverage','open:coverage', "watch:spec"]
grunt.registerTask 'default-no-specs', [
"clean:dist", "jshint", "mkdir", "coffee", "concat:libs", "replace", "concat:dist",
"copy", "uglify:dist"]
grunt.registerTask 'offline', ['default-no-specs', 'watch:offline']
dev = ["clean:dist", "jshint", "mkdir", "coffee", "concat:libs", "replace", "webpack:commonjsDeps", "concat", "copy"]
grunt.registerTask "dev", dev.concat ["uglify:distMapped", "uglify:streetviewMapped", "karma"]
grunt.registerTask "fast", dev.concat ["karma"]
grunt.registerTask "build-street-view", ['clean:streetview','mkdir','coffee', 'concat:libs', 'replace',
'concat:streetview', 'concat:streetviewMapped', 'uglify:streetview', 'uglify:streetviewMapped']
# Run the example page by creating a local copy of angular-google-maps.js
# and running a webserver on port 3100 with livereload. Web page is opened
# automatically in the default browser.
grunt.registerTask 'graph', ['angular_architecture_graph']
grunt.registerTask 'bump-@-preminor', ['changelog', 'bump-only:preminor', 'buildAll', 'bump-commit']
grunt.registerTask 'bump-@-prerelease', ['changelog','bump-only:prerelease', 'buildAll', 'bump-commit']
grunt.registerTask 'bump-@', ['changelog','bump-only', 'buildAll', 'bump-commit']
grunt.registerTask 'bump-@-minor', ['changelog','bump-only:minor', 'buildAll', 'bump-commit']
grunt.registerTask 'bump-@-major', ['changelog','bump-only:major', 'buildAll', 'bump-commit']
exampleOpenTasks = []
_.each allExamplesOpen, (v, key) ->
basicTask = "open:" + key
#register individual task (runs by itself)
grunt.registerTask key, ["fast", "clean:example", "connect:server", basicTask, "watch:all"]
exampleOpenTasks.push basicTask
allExamplesTaskToRun = ["fast", "clean:example", "connect:server"].concat(exampleOpenTasks).concat ['watch:all']
listWithQuotes = (collection, doLog = true) ->
last = collection.length - 1
all = ''
collection.forEach (t, i) ->
all += if i < last then "'#{t}'," else "'#{t}'"
if doLog
return log all
all
grunt.registerTask 'listExamples', showOpenType
grunt.registerTask 'listAllOpen', ->
showOpenType(options.open)
grunt.registerTask 'listAllExamplesTasks', ->
listWithQuotes exampleOpenTasks
grunt.registerTask 'allExamples', allExamplesTaskToRun
grunt.registerTask 'server', ["connect:server", "watch:all"]
grunt.registerTask 's', 'server'
grunt.registerTask 'karma', 'karma runner', ->
kickoff @async(),
logFn: grunt.log.oklns
configFile: require.resolve './karma.conf.coffee'
grunt.registerTask 'karma:acceptance', 'karma runner', ->
kickoff @async(),
logFn: grunt.log.oklns
configFile: require.resolve './karma.acceptance.conf.coffee'
grunt.registerTask 'karmaSpecific', 'karma runner', ->
kickoff @async(),
configFile: require.resolve './karma.conf.coffee'
logFn: grunt.log.oklns
appendFiles: argv.files.split(',')
lengthToPop: 1
reporters: ['mocha']
grunt.registerTask 'buildSpecFile', ['buildDist', 'karmaSpecific']
grunt.registerTask 'buildSpec', ['buildDist', 'karma']
#to see all tasks available don't forget "grunt --help" !!!