This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gruntfile.js
180 lines (164 loc) · 2.92 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
module.exports = function( grunt ) {
require( 'load-grunt-tasks' )( grunt );
// Project configuration.
grunt.initConfig( {
// Package
pkg: grunt.file.readJSON( 'package.json' ),
// JSHint
jshint: {
all: [ 'Gruntfile.js', 'package.json' ]
},
// PHP Code Sniffer
phpcs: {
application: {
src: [
'**/*.php',
'!deploy/**',
'!node_modules/**',
]
},
options: {
standard: 'phpcs.ruleset.xml',
showSniffCodes: true
}
},
// PHPLint
phplint: {
options: {
phpArgs: {
'-lf': null
}
},
all: [ '**/*.php', '!node_modules/**' ]
},
// PHP Mess Detector
phpmd: {
application: {
dir: '.'
},
options: {
exclude: 'deploy,node_modules',
reportFormat: 'xml',
rulesets: 'phpmd.ruleset.xml'
}
},
// Make POT
makepot: {
target: {
options: {
domainPath: 'languages',
type: 'wp-plugin',
updatePoFiles: true,
updateTimestamp: false,
exclude: [
'deploy/.*',
'node_modules/.*'
],
}
}
},
// Copy
copy: {
deploy: {
src: [
'**',
'!Gruntfile.js',
'!package.json',
'!phpcs.ruleset.xml',
'!phpmd.ruleset.xml',
'!README.md',
'!deploy/**',
'!etc/**',
'!node_modules/**',
'!wp-svn/**'
],
dest: 'deploy/latest',
expand: true
},
},
// Clean
clean: {
deploy: {
src: [ 'deploy/latest' ]
},
},
// Compress
compress: {
deploy: {
options: {
archive: 'deploy/archives/<%= pkg.name %>.<%= pkg.version %>.zip'
},
expand: true,
cwd: 'deploy/latest',
src: ['**/*'],
dest: '<%= pkg.name %>/'
}
},
// Git checkout
gitcheckout: {
tag: {
options: {
branch: 'tags/<%= pkg.version %>'
}
},
develop: {
options: {
branch: 'develop'
}
}
},
// S3
aws_s3: {
options: {
region: 'eu-central-1'
},
deploy: {
options: {
bucket: 'downloads.pronamic.eu',
differential: true
},
files: [
{
expand: true,
cwd: 'deploy/archives/',
src: '<%= pkg.name %>.<%= pkg.version %>.zip',
dest: 'plugins/<%= pkg.name %>/'
}
]
}
},
// WordPress deploy
rt_wp_deploy: {
app: {
options: {
svnUrl: 'http://plugins.svn.wordpress.org/<%= pkg.name %>/',
svnDir: 'deploy/wp-svn',
svnUsername: 'pronamic',
deployDir: 'deploy/latest',
version: '<%= pkg.version %>',
}
}
},
} );
// Default task(s).
grunt.registerTask( 'default', [ 'jshint', 'phplint', 'phpmd', 'phpcs' ] );
grunt.registerTask( 'pot', [ 'makepot' ] );
grunt.registerTask( 'deploy', [
'default',
'clean:deploy',
'copy:deploy',
'compress:deploy'
] );
grunt.registerTask( 'wp-deploy', [
'gitcheckout:tag',
'deploy',
'rt_wp_deploy',
'gitcheckout:develop'
] );
grunt.registerTask( 's3-deploy', [
'gitcheckout:tag',
'deploy',
'aws_s3:deploy',
'gitcheckout:develop'
] );
};