-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
202 lines (188 loc) · 5.65 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
module.exports = function (grunt){
let conf = {
cssCwd: 'css',
cssDest: 'css',
jsCwd: 'js',
jsDest: 'js'
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
cmp: grunt.file.readJSON('composer.json'),
// compile sass > css > css.min
// ==================================
sass: {
dist: {
options: {
sourceMap: false,
outputStyle: 'compressed', // expanded, compressed, compact, nested
includePaths: [conf.cssCwd]
},
files: [{
expand: true,
cwd: conf.cssCwd + '/',
src: ['ligatool.scss'],
dest: conf.cssDest + '/',
ext: '.css'
}]
}
},
postcss: {
options: {
processors: [
require('autoprefixer') // add vendor prefixes
]
},
dist: { // = distPortal
src: conf.cssDest + '/*.css'
}
},
// ===================================
watch: {
css: {
files: [conf.cssCwd + '/**/*.scss'],
tasks: ['sass', 'postcss'],
options: {
spawn: false
}
}
},
bumpup: {
options: {
updateProps: {
pkg: 'package.json'
}
},
files: ['package.json', 'composer.json']
},
composer: {
options: {
usePhp: true,
composerLocation: './composer'
},
default: {
options: {
cwd: '.'
}
}
},
copy: {
update: {
files: [
{
expand: true,
src: ['css/**', 'js/**', 'images/**', 'lang/**', 'pages/**', 'sql/**', 'src/**', 'templates/**', 'vendor/**', 'kkl_ligatool.php', 'README.md'],
dest: '<%= cmp.name %>/'
}
]
}
},
compress: {
main: {
options: {
archive: 'target/kkl_ligatool.zip',
mode: 'zip'
},
expand: true,
src: ['css/**', 'js/**', 'images/**', 'lang/**', 'pages/**', 'sql/**', 'src/**', 'templates/**', 'vendor/**', 'kkl_ligatool.php', 'README.md']
},
update: {
options: {
archive: 'target/update/kkl_ligatool.zip',
mode: 'zip'
},
src: [
'<%= cmp.name %>/**'
]
}
},
replace: {
versions: {
options: {
patterns: [
{
match: /Version:\s*(.*)/,
replacement: 'Version: <%= pkg.version %>'
}
]
},
files: [
{
expand: true,
flatten: true,
src: ['README.md', 'kkl_ligatool.php']
}
]
}
},
clean: [
'target',
'vendor',
'target',
'<%= cmp.name %>',
'vendor',
'release.json'
]
});
// Alias task for release
grunt.registerTask('release', function (type){
grunt.task.run('clean'); // clean previous builds
type = type ? type : 'patch'; // default release type
grunt.task.run('bumpup:' + type); // bump up the version
grunt.task.run('replace'); // replace version number in plugin file and readme
grunt.task.run('composer:default:install'); // get php dependencies
grunt.task.run('compress'); // build a release zip
grunt.task.run('compress:main'); // build a release zip
grunt.task.run('copy:update'); // copy files over to build an update zip
grunt.task.run('compress:update'); // build a release zip
});
// Alias task for release with buildmeta suffix support
grunt.registerTask('release', function (type, build){
grunt.task.run('clean'); // clean previous builds
var bumpParts = ['bumpup'];
if (type){
bumpParts.push(type);
}
if (build){
bumpParts.push(build);
}
grunt.task.run(bumpParts.join(':')); // bump up the version
grunt.task.run('replace'); // replace version number in plugin file and readme
grunt.task.run('composer:default:install'); // get php dependencies
grunt.task.run('compress:main'); // build a release zip
grunt.task.run('copy:update'); // copy files over to build an update zip
grunt.task.run('compress:update'); // build a release zip
});
grunt.registerTask('strider:releasefile', function (type){
var artifcatId = process.env.STRIDER_ARTIFACT_ID;
var branch = process.env.STRIDER_BRANCH;
if (!artifcatId || !branch){
grunt.fail.fatal("got no information in environment: STRIDER_ARTIFACT_ID or STRIDER_BRANCH missing!", 1);
}
var name = process.env.STRIDER_PROJECT_NAME;
var cmp = grunt.config.get("cmp");
var projectName = name ? name : cmp.name;
var releaseJson = {
"name": projectName,
"version": cmp.version,
"download_url": cmp.extra.release.baseurl + projectName + "/api/artifact-repository/dl/" + artifcatId + "?branch=" + branch,
"sections": {
"description": cmp.description
}
};
grunt.file.write('release.json', JSON.stringify(releaseJson, null, 2));
});
grunt.registerTask('build', ['clean', 'composer:default:install']);
grunt.registerTask('package', ['default', 'compress:main', 'copy:update', 'compress:update']);
grunt.registerTask('default', ['build']);
grunt.registerTask('dev', ['sass', 'postcss', 'watch']);
// needed modules
grunt.loadNpmTasks('grunt-composer');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-bumpup');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-sass');
};