-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
122 lines (117 loc) · 3.97 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
module.exports = function (grunt) {
// Setup urls for the keyshare server, api server, and irma_js
// these are used to configure the webclient
if ( (typeof(grunt.option("irma_server_url")) === "undefined") ) {
console.log("INFO: don't forget setting irma_server_url in conf.json or specify as grunt parameter");
}
if ( (typeof(grunt.option("idin_server_url")) === "undefined") ) {
console.log("INFO: don't forget setting idin_server_url in conf.json or specify as grunt parameter");
}
if ( (typeof(grunt.option("language")) === "undefined") ) {
console.log("INFO: No language chosen, assuming nl");
}
if ( (typeof(grunt.option("idin_credential_id")) === "undefined") ) {
console.log("INFO: No idin_credential_id chosen, assuming pbdf.pbdf.idin");
}
var conf = {
idin_server_url: grunt.option("idin_server_url") || "<IDIN_SERVER_URL>",
irma_server_url: grunt.option("irma_server_url") || "<IRMA_SERVER_URL>",
language: grunt.option("language") || "nl",
idin_credential_id: grunt.option("idin_credential_id") || "pbdf.pbdf.idin",
};
conf.irma_server_url += "/api/v2";
console.log("Configuration:", conf);
grunt.initConfig({
copy: {
node_modules: {
cwd: "node_modules",
src: [
"@privacybydesign/irma-frontend/dist/irma.js",
"bootstrap/dist/**",
"jquery/dist/jquery.min.js",
"js-cookie/src/js.cookie.js",
"jwt-decode/build/jwt-decode.js"
],
dest: "build/node_modules",
expand: "true",
},
non_html: {
cwd: "src",
src: ["**/*", "!**/*.html"],
dest: "build/",
expand: "true",
},
translated: {
cwd: "translated/" + conf.language,
src: ["**/*.html"],
dest: "build/",
expand: "true",
},
},
watch: {
webfiles: {
files: [
"./src/**/*",
"!./src/**/*.html",
],
tasks: ["copy:non_html"],
},
htmlfiles: {
files: [
"./src/**/*.html",
],
tasks: ["translate"],
},
translationfiles: {
files: [
"./src/languages/*",
],
tasks: ["translate"],
},
},
multi_lang_site_generator: {
default: {
options: {
vocabs: ["en", "nl"],
vocab_directory: "src/languages",
output_directory: "translated",
},
files: {
"index.html": ["src/index.html"],
"done.html": ["src/done.html"],
"error.html": ["src/error.html"],
"enroll.html": ["src/enroll.html"],
},
},
},
json_generator: {
configuration: {
dest: "build/conf.json",
options: conf,
},
}
});
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-multi-lang-site-generator");
grunt.loadNpmTasks("grunt-json-generator");
grunt.registerTask("default", [
"copy:non_html",
"json_generator",
"copy:node_modules",
"multi_lang_site_generator",
"copy:translated",
"watch",
]);
grunt.registerTask("build", [
"copy:non_html",
"json_generator",
"copy:node_modules",
"multi_lang_site_generator",
"copy:translated",
]);
grunt.registerTask("translate", [
"multi_lang_site_generator",
"copy:translated",
]);
};