forked from jsonwebtoken/jsonwebtoken.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
281 lines (258 loc) · 9.11 KB
/
Gruntfile.js
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
279
280
281
const extensionManifest = require("./manifest.json");
const getLanguages = require("./views/website/libraries/support/get-languages.js");
module.exports = (grunt) => {
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-stylus");
grunt.loadNpmTasks("grunt-contrib-pug");
grunt.loadNpmTasks("grunt-webpack");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-crx");
grunt.initConfig({
clean: {
website: ["dist/website"],
extension: ["dist/extension"],
},
copy: {
website: {
files: [{
expand: true,
cwd: "img/website",
src: ["**"],
dest: "dist/website/img",
},
{
expand: true,
src: ["fonts/**", "opensearch.xml"],
dest: "dist/website",
},
{
expand: true,
flatten: true,
src: [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/codemirror/lib/codemirror.css",
"node_modules/codemirror/addon/lint/lint.css",
"css/budicon.css",
"css/google-roboto-mono.css",
],
dest: "dist/website/css/",
},
{
src: ["sitemap.xml"],
dest: "dist/website/",
},
],
},
extension: {
files: [{
expand: true,
flatten: true,
src: ["manifest.json", "html/extension/bg.html"],
dest: "dist/extension",
},
{
expand: true,
cwd: "img/extension",
src: ["**"],
dest: "dist/extension/img",
},
{
expand: true,
src: ["fonts/**"],
dest: "dist/extension",
},
{
expand: true,
flatten: true,
src: [
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/codemirror/lib/codemirror.css",
"node_modules/codemirror/addon/lint/lint.css",
"css/budicon.css",
"css/google-roboto-mono.css",
],
dest: "dist/extension/css/",
},
],
},
},
crx: {
pack: {
src: "dist/extension/**/*",
dest: "dist/chrome-jwt-debugger-extension-v" +
`${extensionManifest.version}.zip`,
},
},
exec: {
firefoxExtensionPack: {
command: "node_modules/web-ext/bin/web-ext build " +
"--source-dir=dist/extension --artifacts-dir=dist " +
"--overwrite-dest",
},
renameFirefoxExtension: {
command: `mv dist/jwt_debugger-${extensionManifest.version}.zip ` +
"dist/firefox-jwt-debugger-extension-" +
`v${extensionManifest.version}.zip`,
},
},
stylus: {
website: {
files: {
"dist/website/css/index.css": "stylus/website/index.styl",
},
},
extension: {
files: {
"dist/extension/css/index.css": "stylus/extension/index.styl",
},
},
},
pug: {
website: {
options: {
data: {
languages: getLanguages(),
},
},
files: {
"dist/website/index.html": "views/website/index.pug",
"dist/website/introduction/index.html": "views/website/introduction.pug",
"dist/website/libraries/index.html": "views/website/libraries.pug",
},
},
extension: {
files: {
"dist/extension/index.html": "views/extension/index.pug",
},
},
},
webpack: {
websiteProd: require("./webpack.website-prod.js"),
websiteDev: require("./webpack.website-dev.js"),
extensionProd: require("./webpack.extension-prod.js"),
extensionDev: require("./webpack.extension-dev.js"),
unitTests: require("./webpack.website-unit-tests.js"),
},
watch: {
websiteSrc: {
files: ["src/*.js", "src/website/**", "src/editor/**"],
tasks: "webpack:websiteDev",
},
extensionSrc: {
files: ["src/*.js", "src/extension/**", "src/editor/**"],
tasks: "webpack:extensionDev",
},
websiteImg: {
files: ["img/website/**"],
tasks: "copy:website",
},
extensionImg: {
files: ["img/extension/**"],
tasks: "copy:extension",
},
opensearch: {
files: "opensearch.xml",
tasks: "copy:website",
},
assets: {
files: [
"fonts/**",
"node_modules/bootstrap/dist/css/bootstrap.min.css",
"node_modules/codemirror/lib/codemirror.css",
"node_modules/codemirror/addon/lint/lint.css",
"css/budicon.css",
],
tasks: "copy",
},
websiteViews: {
files: [
"stylus/*.styl",
"stylus/website/**",
"views/*.pug",
"views/website/**",
],
tasks: ["build-website-views"],
},
extensionViews: {
files: [
"stylus/*.styl",
"stylus/extension/**",
// Yes, we still share styles with the website, it's really hard
// to refactor them out without breaking stuff
"stylus/website/**",
"views/*.pug",
"views/extension/**",
],
tasks: ["build-extension-views"],
},
},
mochaTest: {
unit: {
options: {},
src: ["dist/test/unit-tests.js"],
},
functional: {
options: {
// Higher default timeout to account for some animations
timeout: 10000,
},
src: ["test/functional/**.js"],
},
},
connect: {
website: {
options: {
hostname: "127.0.0.1",
base: "dist/website",
},
},
},
});
grunt.registerTask("build-website-views", ["stylus:website"]);
grunt.registerTask("build-extension-views", [
"stylus:extension",
"pug:extension",
]);
grunt.registerTask("build-website", [
"clean:website",
"copy:website",
"build-website-views",
"webpack:websiteProd",
]);
grunt.registerTask("build-website-dev", [
"clean:website",
"copy:website",
"build-website-views",
"webpack:websiteDev",
]);
grunt.registerTask("build-extension", [
"clean:extension",
"copy:extension",
"build-extension-views",
"webpack:extensionProd",
"crx:pack",
"exec:firefoxExtensionPack",
"exec:renameFirefoxExtension",
]);
grunt.registerTask("build-extension-dev", [
"clean:extension",
"copy:extension",
"build-extension-views",
"webpack:extensionDev",
]);
grunt.registerTask("build", ["build-website", "build-extension"]);
grunt.registerTask("build-dev", ["build-website-dev", "build-extension-dev"]);
grunt.registerTask("unit-tests", ["webpack:unitTests", "mochaTest:unit"]);
grunt.registerTask("functional-tests", [
"build-website-dev",
"pug:website",
"connect:website",
"mochaTest:functional",
]);
grunt.registerTask("test", ["unit-tests", "functional-tests"]);
grunt.registerTask("default", ["build-dev", "connect:website", "watch"]);
};