Skip to content

Commit 349bde2

Browse files
author
wangsai
committed
lumen
1 parent 7a4b3a4 commit 349bde2

File tree

1 file changed

+104
-9
lines changed

1 file changed

+104
-9
lines changed

Gruntfile.js

Lines changed: 104 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ moment.locale('zh-cn');
1010
module.exports = function(grunt) {
1111

1212
var DOWNLOAD_PREFIX = 'http://down.golaravel.com/laravel/';
13-
var tags;
13+
var laravel-tags;
14+
var lumen-tags;
1415

1516
// Project configuration.
1617
grunt.initConfig({
@@ -28,20 +29,20 @@ module.exports = function(grunt) {
2829
stdout: false,
2930
stderr: false
3031
},
31-
git_clone: {
32+
clone_laravel: {
3233
cmd: 'git clone https://github.com/laravel/laravel --depth=1 --no-single-branch -q',
3334
stdout: false,
3435
stderr: false
3536
},
36-
git_tag_list: {
37+
list_laravel_tags: {
3738
cmd: 'git tag --list',
3839
cwd: './laravel',
3940
callback: function(err, stdout, stderr) {
4041
if(stderr.length > 0) {
4142
grunt.fail.fatal('git tag failed!');
4243
}
4344

44-
tags = stdout.toString().trim().split('\n').filter(function(tag){
45+
var tags = stdout.toString().trim().split('\n').filter(function(tag){
4546
if(/^v3/.test(tag)) {
4647
return false;
4748
}
@@ -59,14 +60,17 @@ module.exports = function(grunt) {
5960
tags.push('master');
6061

6162
console.log(tags);
63+
64+
laravel-tags = tags;
6265
},
6366
stdout: false,
6467
stderr: false
6568
},
66-
git_export_versions: {
69+
export_laravel_versions: {
6770
cmd: function() {
6871
var template = '{{#tags}}git archive --format=tar --prefix=laravel-{{this}}/ {{this}} | tar xf - && {{/tags}}';
6972
var cmd;
73+
var tags = laravel-tags;
7074

7175
template = handlebars.compile(template);
7276
cmd = template({tags: tags}).replace(/&&\s*$/g, '');
@@ -78,12 +82,12 @@ module.exports = function(grunt) {
7882
stdout: false,
7983
stderr: false
8084
},
81-
composer: {
85+
laravel_composer_install: {
8286
cmd: function(){
8387
var cwd = process.cwd();
84-
// var template = '{{#tags}}(cd {{../cwd}}/{{this}} && composer install) && {{/tags}}';
8588
var template = '{{#tags}}(echo {{this}} && composer install -d laravel-{{this}}) && {{/tags}}';
8689
var cmd;
90+
var tags = lumen-tags;
8791

8892
template = handlebars.compile(template);
8993
cmd = template({tags: tags, cwd: cwd}).replace(/&&\s*$/g, '');
@@ -94,6 +98,74 @@ module.exports = function(grunt) {
9498
cwd: 'laravel',
9599
stdout: false,
96100
stderr: false
101+
},
102+
103+
104+
clone_lumen: {
105+
cmd: 'git clone https://github.com/laravel/lumen --depth=1 --no-single-branch -q',
106+
stdout: false,
107+
stderr: false
108+
},
109+
list_lumen_tags: {
110+
cmd: 'git tag --list',
111+
cwd: './lumen',
112+
callback: function(err, stdout, stderr) {
113+
if(stderr.length > 0) {
114+
grunt.fail.fatal('git tag failed!');
115+
}
116+
117+
var tags = stdout.toString().trim().split('\n').filter(function(tag){
118+
return true;
119+
});
120+
121+
tags = _.chain(tags).groupBy(function(ver){
122+
return [semver.major(ver), semver.minor(ver)].join('.');
123+
}).map(function(group){
124+
console.log(_.last(group));
125+
return _.last(group);
126+
}).value();
127+
128+
tags.push('master');
129+
130+
console.log(tags);
131+
132+
lumen-tags = tags;
133+
},
134+
stdout: false,
135+
stderr: false
136+
},
137+
export_lumen_versions: {
138+
cmd: function() {
139+
var template = '{{#tags}}git archive --format=tar --prefix=lumen-{{this}}/ {{this}} | tar xf - && {{/tags}}';
140+
var cmd;
141+
var tags = lumen-tags;
142+
143+
template = handlebars.compile(template);
144+
cmd = template({tags: tags}).replace(/&&\s*$/g, '');
145+
146+
console.log(cmd);
147+
return cmd;
148+
},
149+
cwd: 'lumen',
150+
stdout: false,
151+
stderr: false
152+
},
153+
lumen_composer_install: {
154+
cmd: function(){
155+
var cwd = process.cwd();
156+
var template = '{{#tags}}(echo {{this}} && composer install -d lumen-{{this}}) && {{/tags}}';
157+
var cmd;
158+
var tags = lumen-tags;
159+
160+
template = handlebars.compile(template);
161+
cmd = template({tags: tags, cwd: cwd}).replace(/&&\s*$/g, '');
162+
163+
console.log(cmd);
164+
return cmd;
165+
},
166+
cwd: 'lumen',
167+
stdout: false,
168+
stderr: false
97169
}
98170
},
99171
clean: ['laravel'],
@@ -105,6 +177,13 @@ module.exports = function(grunt) {
105177
cwd: './laravel',
106178
src: ['laravel-*'],
107179
dest: './laravel'
180+
},
181+
{
182+
filter: 'isDirectory',
183+
expand: true,
184+
cwd: './lumen',
185+
src: ['lumen-*'],
186+
dest: './lumen'
108187
}
109188
]
110189
}
@@ -120,6 +199,11 @@ module.exports = function(grunt) {
120199
expand: true,
121200
cwd: 'laravel',
122201
src: ['*.zip', 'laravel-*.json']
202+
},
203+
{
204+
expand: true,
205+
cwd: 'lumen',
206+
src: ['*.zip']
123207
}
124208
]
125209
}
@@ -196,9 +280,10 @@ module.exports = function(grunt) {
196280

197281
grunt.registerTask('version_list', 'save all laravel & lumen zips\' url to a json file', function(){
198282
var laravels;
283+
var lumens;
199284
var now = moment().format('LLL');
200285

201-
laravels = _.map(tags, function(tag){
286+
laravels = _.map(laravel-tags, function(tag){
202287
var states = fs.statSync('laravel/laravel-' + tag + '.zip');
203288

204289
return {
@@ -208,7 +293,17 @@ module.exports = function(grunt) {
208293
};
209294
}).reverse();
210295

211-
grunt.file.write('laravel/laravel-versions.json', 'listLaravelVersions(' + JSON.stringify({time: now, laravels: laravels}) + ');');
296+
lumens = _.map(lumen-tags, function(tag){
297+
var states = fs.statSync('lumen/lumen-' + tag + '.zip');
298+
299+
return {
300+
version: tag,
301+
download_url: DOWNLOAD_PREFIX + 'lumen-' + tag + '.zip',
302+
size: states.size
303+
};
304+
}).reverse();
305+
306+
grunt.file.write('laravel/laravel-versions.json', 'listLaravelVersions(' + JSON.stringify({time: now, laravels: laravels, lumens: lumens}) + ');');
212307
});
213308

214309
};

0 commit comments

Comments
 (0)