-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
166 lines (131 loc) · 4.41 KB
/
gulpfile.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
var gulp = require('gulp');
var jsdoc = require('gulp-jsdoc');
var git = require('gulp-git');
var del = require('del');
var Q = require('q');
var exec = require('child_process').exec;
var repos = [
"https://github.com/ludei/cocoon-common",
"https://github.com/CocoonIO/cocoon-canvasplus",
"https://github.com/ludei/atomic-plugins-inapps",
"https://github.com/ludei/atomic-plugins-googleplaygames",
"https://github.com/ludei/atomic-plugins-ads",
"https://github.com/ludei/atomic-plugins-facebook",
"https://github.com/ludei/atomic-plugins-share",
"https://github.com/ludei/atomic-plugins-notifications",
"https://github.com/ludei/atomic-plugins-gamecenter",
"https://github.com/ludei/atomic-plugins-multiplayer",
"https://github.com/ludei/atomic-plugins-social"
];
gulp.task('clean', function () {
return del([
'srcs',
'repos',
'dist'
]);
});
gulp.task('clone', ['clean'], function() {
var deferred = Q.defer();
var count = repos.length;
for (var i = 0; i < repos.length; i++) {
var index = repos[i].lastIndexOf("/");
var name = repos[i].substring(index);
git.clone(repos[i], {args: './repos/' + name, quiet: true}, function(err) {
if (err)
deferred.reject(new Error(err));
count--;
if (count === 0) {
deferred.resolve();
}
});
}
return deferred.promise;
});
gulp.task('copy-js', ['clone'], function() {
var all_srcs = [];
for (var i = 0; i < repos.length; i++) {
var index = repos[i].lastIndexOf("/");
var name = repos[i].substring(index);
var srcs = repos.map(function(repo) {
var index = repo.lastIndexOf("/");
var name = repo.substring(index);
return "./repos/" + name + "/src/js/**/*.js";
});
all_srcs = all_srcs.concat(srcs);
all_srcs.push('./src/js/**/*.js');
}
return gulp.src(all_srcs).pipe(gulp.dest('./srcs/js/'));
});
gulp.task('doc-js', ['copy-js'], function() {
var config = require('./doc_template/js/jsdoc.conf.json');
var infos = {
plugins: config.plugins
}
var templates = config.templates;
templates.path = 'doc_template/js';
return gulp.src("srcs/js/**/*.js")
.pipe(jsdoc.parser(infos))
.pipe(jsdoc.generator('dist/doc/js', templates));
});
// gulp.task('doc-android', ['clone'], function() {
// var deferred = Q.defer();
// var count = repos.length;
// var srcs = [];
// for (var i = 0; i < repos.length; i++) {
// var index = repos[i].lastIndexOf("/");
// var name = repos[i].substring(index);
// srcs.push('../../repos/' + name + '/src/atomic/android');
// count--;
// if (count === 0) {
// exec('mkdir -p ./dist/doc/android; cd doc_template/android; ( cat config ; echo "INPUT=' + srcs.join(" ") + '"; echo "FILE_PATTERNS=*.java" ) | doxygen -', function (err, stdout, stderr) {
// if (err)
// deferred.reject(new Error(stderr));
// else
// deferred.resolve();
// });
// }
// }
// return deferred.promise;
// });
// gulp.task('doc-ios', ['clone'], function() {
// var deferred = Q.defer();
// var count = repos.length;
// var srcs = [];
// for (var i = 0; i < repos.length; i++) {
// var index = repos[i].lastIndexOf("/");
// var name = repos[i].substring(index);
// srcs.push('../../repos/' + name + '/src/atomic/ios');
// count--;
// if (count === 0) {
// exec('mkdir -p ./dist/doc/ios; cd doc_template/ios; ( cat config ; echo "INPUT=' + srcs.join(" ") + '"; echo "FILE_PATTERNS=*.h" ) | doxygen -', function (err, stdout, stderr) {
// if (err)
// deferred.reject(new Error(stderr));
// else
// deferred.resolve();
// });
// }
// }
// return deferred.promise;
// });
// gulp.task('doc-cpp', ['clone'], function() {
// var deferred = Q.defer();
// var count = repos.length;
// var srcs = [];
// for (var i = 0; i < repos.length; i++) {
// var index = repos[i].lastIndexOf("/");
// var name = repos[i].substring(index);
// srcs.push('../../repos/' + name + '/src/cpp');
// count--;
// if (count === 0) {
// exec('mkdir -p ./dist/doc/cpp; cd doc_template/cpp; ( cat config ; echo "INPUT=' + srcs.join(" ") + '"; echo "FILE_PATTERNS=*.h" ) | doxygen -', function (err, stdout, stderr) {
// if (err)
// deferred.reject(new Error(stderr));
// else
// deferred.resolve();
// });
// }
// }
// return deferred.promise;
// });
gulp.task('doc', ["doc-js"]);
gulp.task('default', ['doc']);