forked from noflo/noflo-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.coffee
278 lines (266 loc) · 8.95 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
module.exports = ->
# Project configuration
@initConfig
pkg: @file.readJSON 'package.json'
# Browser build of NoFlo
webpack:
build: require './webpack.config.js'
# Vulcanization compiles the Polymer elements into a HTML file
exec:
vulcanize:
command: 'node_modules/.bin/polymer-bundler index.dist.html > index.html'
cwd: __dirname
# Directory cleaning
clean:
build: [
'browser'
]
dist: [
'dist'
]
files: [
'./index.js'
'./index.html'
'./dev.html'
]
themes: [
'themes'
]
specs: [
'spec/*.js'
]
'string-replace':
app:
files:
'./dev.html': './index.dist.html'
'./index.html': './index.html'
'./browser/noflo-ui.min.js': './browser/noflo-ui.min.js'
'./index.js': './index.js'
'./config.xml': './config.dist.xml'
'./manifest.json': './manifest.dist.json'
'./manifest.webapp.json': './manifest.dist.webapp.json'
options:
replacements: [
pattern: /\$NOFLO_OAUTH_PROVIDER/ig
replacement: process.env.NOFLO_OAUTH_PROVIDER or 'https://github.com'
,
pattern: /\$NOFLO_OAUTH_GATE/ig
replacement: process.env.NOFLO_OAUTH_GATE or 'https://noflo-gate.herokuapp.com'
,
pattern: /\$NOFLO_OAUTH_SERVICE_USER/ig
replacement: process.env.NOFLO_OAUTH_SERVICE_USER or 'https://api.flowhub.io'
,
pattern: /\$NOFLO_OAUTH_CLIENT_ID/ig
replacement: process.env.NOFLO_OAUTH_CLIENT_ID or '46fe25abef8d07e6dc2d'
,
pattern: /\$NOFLO_OAUTH_CLIENT_REDIRECT/ig
replacement: process.env.NOFLO_OAUTH_CLIENT_REDIRECT or 'http://localhost:9999'
,
pattern: /\$NOFLO_OAUTH_CLIENT_SECRET/ig
replacement: process.env.NOFLO_OAUTH_CLIENT_SECRET or ''
,
pattern: /\$NOFLO_OAUTH_SSL_CLIENT_ID/ig
replacement: process.env.NOFLO_OAUTH_SSL_CLIENT_ID or ''
,
pattern: /\$NOFLO_OAUTH_SSL_CLIENT_REDIRECT/ig
replacement: process.env.NOFLO_OAUTH_SSL_CLIENT_REDIRECT or ''
,
pattern: /\$NOFLO_OAUTH_SSL_CLIENT_SECRET/ig
replacement: process.env.NOFLO_OAUTH_SSL_CLIENT_SECRET or ''
,
pattern: /\$NOFLO_OAUTH_SSL_ENDPOINT_AUTHENTICATE/ig
replacement: process.env.NOFLO_SSL_OAUTH_ENDPOINT_AUTHENTICATE or '/authenticate/ssl'
,
pattern: /\$NOFLO_OAUTH_CHROME_CLIENT_ID/ig
replacement: process.env.NOFLO_OAUTH_CHROME_CLIENT_ID or 'f29ae9f73bfb223d69d7'
,
pattern: /\$NOFLO_OAUTH_CHROME_CLIENT_REDIRECT/ig
replacement: process.env.NOFLO_OAUTH_CHROME_CLIENT_REDIRECT or 'https://hfhpoogbmnkfihpcaoigganphdglajmp.chromiumapp.org/'
,
pattern: /\$NOFLO_OAUTH_CHROME_CLIENT_SECRET/ig
replacement: process.env.NOFLO_OAUTH_CHROME_CLIENT_SECRET or ''
,
pattern: /\$NOFLO_OAUTH_CHROME_ENDPOINT_AUTHENTICATE/ig
replacement: process.env.NOFLO_CHROME_OAUTH_ENDPOINT_AUTHENTICATE or '/authenticate/chrome'
,
pattern: /\$NOFLO_OAUTH_ENDPOINT_AUTHORIZE/ig
replacement: process.env.NOFLO_OAUTH_ENDPOINT_AUTHORIZE or '/login/oauth/authorize'
,
pattern: /\$NOFLO_OAUTH_ENDPOINT_TOKEN/ig
replacement: process.env.NOFLO_OAUTH_ENDPOINT_TOKEN or '/login/oauth/access_token'
,
pattern: /\$NOFLO_OAUTH_ENDPOINT_AUTHENTICATE/ig
replacement: process.env.NOFLO_OAUTH_ENDPOINT_AUTHENTICATE or '/authenticate'
,
pattern: /\$NOFLO_OAUTH_ENDPOINT_USER/ig
replacement: process.env.NOFLO_OAUTH_ENDPOINT_USER or '/user'
,
pattern: /\$NOFLO_REGISTRY_SERVICE/ig
replacement: process.env.NOFLO_REGISTRY_SERVICE or 'https://api.flowhub.io'
,
pattern: /\$NOFLO_APP_NAME/ig
replacement: process.env.NOFLO_APP_NAME or process.env.NOFLO_APP_TITLE or 'NoFlo UI'
,
pattern: /\$NOFLO_APP_TITLE/ig
replacement: process.env.NOFLO_APP_TITLE or 'NoFlo Development Environment'
,
pattern: /\$NOFLO_APP_LOADING/ig
replacement: process.env.NOFLO_APP_LOADING or 'Preparing NoFlo UI...'
,
pattern: /\$NOFLO_ORGANIZATION/ig
replacement: process.env.NOFLO_ORGANIZATION or 'NoFlo Community'
,
pattern: /\$NOFLO_WEBSITE/ig
replacement: process.env.NOFLO_WEBSITE or 'http://noflojs.org'
,
pattern: /\$NOFLO_APP_DESCRIPTION/ig
replacement: process.env.NOFLO_APP_DESCRIPTION or 'Flow-Based Programming Environment'
,
pattern: /\$NOFLO_APP_VERSION/ig
replacement: process.env.NOFLO_APP_VERSION or '<%= pkg.version %>'
,
pattern: /\$NOFLO_THEME/ig
replacement: process.env.NOFLO_THEME or 'noflo'
,
pattern: /\$NOFLO_USER_LOGIN_ENABLED/ig
replacement: process.env.NOFLO_USER_LOGIN_ENABLED or true
]
analytics:
files:
'./dist/index.html': './dist/index.html'
options:
replacements: [
pattern: '<!-- $NOFLO_APP_ANALYTICS -->'
replacement: process.env.NOFLO_APP_ANALYTICS or "<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-75936-14', 'noflojs.org');
ga('send', 'pageview');
</script>"
]
compress:
app:
options:
archive: 'noflo-<%= pkg.version %>.zip'
files: [
src: [
'browser/noflo-ui.min.js'
'browser/noflo-ui.min.js.map'
]
expand: true
dest: '/'
,
src: require './externals.conf.js'
expand: true
dest: '/'
,
src: [
'index.js'
'index.html'
]
expand: true
dest: '/'
,
src: ['app/*']
expand: true
dest: '/'
,
src: [
'manifest.json'
'manifest.webapp.json'
]
expand: true
dest: '/'
,
src: ['config.xml']
expand: true
dest: '/'
,
src: ["#{process.env.NOFLO_THEME or 'noflo'}.ico"]
expand: true
dest: '/'
,
src: [
'css/*'
]
expand: true
dest: '/'
]
unzip:
dist: 'noflo-<%= pkg.version %>.zip'
'gh-pages':
options:
base: 'dist'
clone: 'gh-pages'
message: 'Updating web version to <%= pkg.version %>'
src: '**/*'
sharedstylecomponent:
'elements/the-graph-styles.html': [
'node_modules/the-graph/themes/the-graph-dark.css'
'node_modules/the-graph/themes/the-graph-light.css'
]
'elements/codemirror-styles.html': [
'node_modules/codemirror/addon/lint/lint.css'
'node_modules/codemirror/lib/codemirror.css'
'node_modules/codemirror/theme/mdn-like.css'
'css/codemirror-noflo.css'
]
# Grunt plugins used for building
@loadNpmTasks 'grunt-webpack'
@loadNpmTasks 'grunt-exec'
@loadNpmTasks 'grunt-contrib-clean'
@loadNpmTasks 'grunt-string-replace'
# Grunt plugins used for mobile app building
@loadNpmTasks 'grunt-contrib-compress'
@loadNpmTasks 'grunt-zip'
@loadNpmTasks 'grunt-gh-pages'
# Our local tasks
grunt = @
@registerMultiTask 'sharedstylecomponent', 'Combine CSS files into a Polymer shared style element', ->
path = require 'path'
sources = @data.map (file) ->
grunt.file.read file
template = """
<!-- Generated from <%= files %> -->
<dom-module id="<%= id %>">
<template>
<style>
<%= sources %>
</style>
</template>
</dom-module>
"""
id = path.basename @target, path.extname @target
result = grunt.template.process template,
data:
id: id
files: @data.join ', '
sources: sources.join '\n'
grunt.file.write @target, result
grunt.log.writeln "Generated #{@target} from #{@data.join(', ')}"
@registerTask 'nuke', [
'clean'
]
@registerTask 'build', [
'webpack'
'sharedstylecomponent'
'exec:vulcanize'
'string-replace:app'
'compress'
]
@registerTask 'rebuild', [
'nuke'
'build'
]
@registerTask 'default', [
'build'
]
@registerTask 'pages', [
'build'
'clean:dist'
'unzip'
'string-replace:analytics'
'gh-pages'
]