forked from fossar/selfoss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
99 lines (86 loc) · 4.16 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
/* version text replace */
replace: {
version: {
src: [
'package.json',
'README.md',
'common.php',
'_docs/website/index.html'
],
overwrite: true,
replacements: [
// rule for package.json
{
from: /"ver": "\d+\.\d+(\-SNAPSHOT)?"/,
to: ('"ver": "' + grunt.option('newversion') + '"')
},
// rule for README.md
{
from: /'version','\d+\.\d+(\-SNAPSHOT)?'/,
to: ("'version','" + grunt.option('newversion') + "'")
},
// rule for common.php
{
from: /Version \d+\.\d+(\-SNAPSHOT)?/,
to: ("Version " + grunt.option('newversion'))
},
// rule for website/index.html
{
from: /selfoss( |\-)\d+\.\d+(\-SNAPSHOT)?/g,
to: ("selfoss$1" + grunt.option('newversion'))
}]
}
},
/* create zip */
compress: {
main: {
options: {
archive: 'selfoss-<%= pkg.ver %>.zip'
},
files: [
{ expand: true, cwd: 'controllers/', src: ['**'], dest: '/controllers'},
{ expand: true, cwd: 'daos/', src: ['**'], dest: '/daos'},
{ expand: true, cwd: 'helpers/', src: ['**'], dest: '/helpers'},
{ expand: true, cwd: 'libs/', src: ['**'], dest: '/libs'},
// public = don't zip all.js and all.css
{ expand: true, cwd: 'public/', src: ['**'], dest: '/public', filter: function(file) {
return file.indexOf('all.js') === -1 && file.indexOf('all.css') === -1;
}},
// copy data: only directory structure and .htaccess for deny
{ expand: true, cwd: 'data/', src: ['**'], dest: '/data', filter: 'isDirectory'},
{ src: ['data/cache/.htaccess'], dest: '' },
{ src: ['data/logs/.htaccess'], dest: '' },
{ src: ['data/sqlite/.htaccess'], dest: '' },
{ expand: true, cwd: 'data/fulltextrss', src: ['**'], dest: '/data/fulltextrss'},
{ expand: true, cwd: 'spouts/', src: ['**'], dest: '/spouts'},
{ expand: true, cwd: 'templates/', src: ['**'], dest: '/templates'},
{ src: ['.htaccess'], dest: '' },
{ src: ['README.md'], dest: '' },
{ src: ['defaults.ini'], dest: '' },
{ src: ['index.php'], dest: '' },
{ src: ['common.php'], dest: '' },
{ src: ['run.php'], dest: '' },
{ src: ['cliupdate.php'], dest: '' }
]
}
}
});
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-compress');
/* task checks whether newversion is given and start replacement in files if correct format is given */
grunt.registerTask('versionupdater', 'version update task', function() {
var version = "" + grunt.option('newversion');
if (typeof grunt.option('newversion') != 'undefined') {
grunt.log.writeln('replace version ' + grunt.option('newversion'));
if (version.search(/^\d+\.\d+(\-SNAPSHOT)?$/) == -1)
grunt.fail.warn('newversion must have the format n.m or n.m-SNAPSHOT (n and m are integer numbers)');
grunt.task.run('replace');
}
});
grunt.registerTask('default', ['versionupdater', 'compress']);
grunt.registerTask('version', ['versionupdater']);
grunt.registerTask('zip', ['compress']);
};