-
Notifications
You must be signed in to change notification settings - Fork 349
/
Gruntfile.js
142 lines (135 loc) · 5.14 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
php: {
options: {
process: function(source, path) {
source = source.replace(/'dev';/g, "'';");
return source.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
},
src: [
'src/webconsole.settings.php',
'src/vendor/eazy-jsonrpc/src/BaseJsonRpcServer.php',
'src/close.tag.php',
'src/webconsole.main.php'
],
dest : 'release/parts/webconsole.html'
},
css: {
src: [
'src/vendor/normalize/normalize.css',
'src/vendor/jquery.terminal/css/jquery.terminal-0.11.12.min.css',
'src/css/webconsole.css'
],
dest: 'release/parts/all.css'
},
js: {
options: {
process: function(source, path) {
return source.replace('webconsole.php', '');
}
},
src: [
'src/vendor/jquery.terminal/js/jquery-1.7.1.min.js',
'src/vendor/jquery.terminal/js/jquery.mousewheel-min.js',
'src/vendor/jquery.terminal/js/jquery.terminal-0.11.12.min.js',
'src/js/webconsole.js'
],
dest: 'release/parts/all.js'
},
html: {
options: {
process: function(source, path) {
return source.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
},
src: 'src/html/head.html',
dest : 'release/parts/head.html'
},
text: {
options: {
process: function(source, path) {
// Images
source = source.replace(/!.*\n\s*/g, '');
// Quotes
source = source.replace(/`(\$[^`]+)`/g, '$1');
source = source.replace(/`/g, '"');
// Download link
source = source.replace(/\[(Download)\]\([^\)]+\)\s*/g, '$1 ');
// Other links
source = source.replace(/\[([^\]]+)\]\s*/g, '$1 ');
// Lists
// source = source.replace(/\s+- /g, '\n - ');
// Trailing spaces
return source.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
},
src: 'README.md',
dest : 'release/parts/README.txt'
},
},
cssmin: {
css: {
options: {'keepSpecialComments': 0},
src: '<%= concat.css.dest %>',
dest: 'release/parts/all.min.css'
}
},
uglify: {
js: {
options: {'preserveComments': false},
src: '<%= concat.js.dest %>',
dest: 'release/parts/all.min.js'
}
},
preprocess: {
php: {
options: {
context : {
DATE: grunt.template.today('yyyy-mm-dd'),
YEAR: grunt.template.today('yyyy'),
VERSION: '<%= pkg.version %>'
}
},
src: 'release/parts/webconsole.html',
dest: 'release/parts/webconsole.php'
}
},
replace: {
php: {
options: {
patterns: [
{
match: /__NO_LOGIN__/g,
replacement: '<?php echo $NO_LOGIN ? "true" : "false" ?>'
}
]
},
src: 'release/parts/webconsole.php',
dest: 'release/webconsole.php'
}
},
compress: {
all: {
options: {
archive: 'release/webconsole-<%= pkg.version %>.zip'
},
files: [
{expand: true, cwd: 'release/', src: 'webconsole.php', dest: 'webconsole/'},
{expand: true, cwd: 'release/parts/', src: 'README.txt', dest: 'webconsole/'},
{expand: true, cwd: 'src/', src: 'useful/*', dest: 'webconsole/'},
{expand: true, cwd: 'src/', src: 'useful/.*', dest: 'webconsole/'}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-preprocess');
grunt.loadNpmTasks('grunt-replace');
grunt.registerTask('default', ['concat', 'cssmin', 'uglify', 'preprocess', 'replace', 'compress']);
};