forked from angular-ui/angular-google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
134 lines (105 loc) · 4.8 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
log = require('util').log
_ = require 'lodash'
karmaRunner = require './grunt/karma'
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-curl'
'grunt-verbosity'
'grunt-webpack'
'grunt-angular-architecture-graph'
].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
# console.log allExamplesOpen, true
showOpenType = (toIterate = allExamplesOpen) ->
_(toIterate).each (v, k) ->
log "#{k} -> #{v.path}"
#showAllExamples()
options.open = _.extend options.open, allExamplesOpen
grunt.initConfig options
# Default task: build a release in dist/
grunt.registerTask "default", [
'bower', 'curl',
'verbosity', 'clean:dist', 'jshint', 'mkdir', 'coffee',
'concat:libs', 'replace', 'webpack', 'concat:dist', 'concat:streetview'
'copy', 'uglify:dist', 'uglify:streetview', 'karma']
# run default "grunt" prior to generate _SpecRunner.html
grunt.registerTask "spec", [
'bower', 'curl',
'verbosity', "clean:dist", "jshint", "mkdir", "coffee", "concat:libs", "replace", "webpack", "concat",
"copy", "connect:jasmineServer", "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", "concat", "copy"]
grunt.registerTask "dev", dev.concat ["uglify:distMapped", "uglify:streetviewMapped", "karma"]
grunt.registerTask "fast", dev.concat ["karma"]
grunt.registerTask "mappAll", [
'bower', 'curl',
"clean:dist", "jshint", "mkdir", "coffee", "concat:libs", "replace", "webpack", "concat", "uglify"
"copy", "karma", "graph"]
grunt.registerTask "build-street-view", ['clean:streetview','mkdir','coffee', 'concat:libs', 'replace',
'concat:streetview', 'concat:streetviewMapped', 'uglify:streetview', 'uglify:streetviewMapped']
grunt.registerTask "buildAll", "mappAll"
# 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', 'mappAll', 'bump-commit']
grunt.registerTask 'bump-@-prerelease', ['changelog','bump-only:prerelease', 'mappAll', 'bump-commit']
grunt.registerTask 'bump-@', ['changelog','bump-only', 'mappAll', 'bump-commit']
grunt.registerTask 'bump-@-minor', ['changelog','bump-only:minor', 'mappAll', 'bump-commit']
grunt.registerTask 'bump-@-major', ['changelog','bump-only:major', 'mappAll', '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', ->
karmaRunner(grunt) @async()
#to see all tasks available don't forget "grunt --help" !!!