-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
150 lines (131 loc) · 4.92 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
const { series, parallel } = require('gulp');
const { src, dest } = require('gulp');
const del = require('del');
const zip = require('gulp-zip');
const config = {
srcPath: './',
buildPath: './dist/component/',
rootPath: './dist/',
componentName: 'speasyimagegallery',
com_package_name: 'com_speasyimagegallery_fullpackage_v2.0.2.zip',
moduleExts: ['xml','php','js','css','jpg','png','gif','ttf','otf','woff','woff2','svg','eot']
}
const tasks = {
manifest: {
src: [config.srcPath + 'administrator/components/com_' + config.componentName + '/' + config.componentName + '.xml', config.srcPath + 'administrator/components/com_' + config.componentName + '/installer.script.php'],
dest: config.buildPath
},
admin: {
src: [
config.srcPath + 'administrator/components/com_' + config.componentName + '/**/*.{xml,php,js,css,jpg,png,gif,ttf,otf,woff,woff2,svg,eot,sql,json}'
],
dest: config.buildPath + '/admin'
},
site: {
src: [config.srcPath + 'components/com_' + config.componentName + '/**/*.{xml,php,js,css,jpg,png,gif,ttf,otf,woff,woff2,svg,eot,json,txt}'],
dest: config.buildPath + '/site'
},
modules: [
{
name: 'speasyimagegallery',
exts: config.moduleExts
}
],
}
// clean rootpath
function clean() {
return del([config.rootPath]);
}
// manifest task
function manifest() {
return src(tasks.manifest.src, {allowEmpty: true})
.pipe(dest(tasks.manifest.dest));
}
// admin tasks
function admin() {
return src(tasks.admin.src)
.pipe(dest(tasks.admin.dest));
}
// site tasks
function site() {
return src(tasks.site.src)
.pipe(dest(tasks.site.dest));
}
// modules tasks
function modules(callback) {
let modules = typeof (tasks.modules) == 'object' && tasks.modules instanceof Array && tasks.modules.length > 0 ? tasks.modules : false;
let module_tasks = [];
if (modules) {
modules.map(module => {
let mod_task = (taskDone) => {
src([ config.srcPath + 'modules/mod_' + module.name + '/**/*.{' + module.exts.join(',') + '}', config.srcPath + 'language/en-GB/en-GB.mod_' + module.name + '*.ini'], {allowEmpty: true})
.pipe(dest(config.buildPath + '/modules/mod_' + module.name + '/'));
taskDone();
}
module_tasks.push(mod_task);
});
}
return series(...module_tasks, seriesDone => {
seriesDone();
callback();
})();
}
// plugin tasks
function plugins(callback) {
let plugins = typeof (tasks.plugins) == 'object' && tasks.plugins instanceof Array && tasks.plugins.length > 0 ? tasks.plugins : false;
let plugin_tasks = [];
if (plugins) {
plugins.map(plugin => {
let plg_task = taskDone => {
src([plugin.path + '/' + plugin.name + '/**/*.{xml,php,js,css,jpg,png,gif,ttf,otf,woff,woff2,svg,eot,json}',
config.srcPath + 'administrator/language/en-GB/en-GB.plg_' + plugin.type + '_' + plugin.name + '*.ini'], { allowEmpty: true })
.pipe(dest(config.buildPath + '/plugins/' + plugin.name));
taskDone();
}
plugin_tasks.push(plg_task);
});
}
return series(...plugin_tasks, seriesDone => {
seriesDone();
callback();
})();
}
// admin language task
function adminLanguage(callback) {
return src([config.srcPath + 'administrator/language/en-GB/en-GB.com_' + config.componentName + '*.ini'], { allowEmpty: true })
.pipe(dest(config.buildPath + '/language/admin/en-GB'));
}
// site language task
function siteLanguage(callback) {
return src([config.srcPath + 'language/en-GB/en-GB.com_' + config.componentName + '.ini'], { allowEmpty: true })
.pipe(dest(config.buildPath + '/language/site/en-GB'));
}
// modules language
function moduleLanguages(callback) {
let modules = typeof (tasks.modules) == 'object' && tasks.modules instanceof Array && tasks.modules.length > 0 ? tasks.modules : false;
let module_language_tasks = [];
if (modules) {
modules.map(module => {
let mod_task = (taskDone) => {
src([ config.srcPath + 'language/en-GB/en-GB.mod_' + module.name + '.ini', config.srcPath + 'language/en-GB/en-GB.mod_' + module.name + '.sys.ini'], {allowEmpty: true})
.pipe(dest(config.buildPath + '/modules/mod_' + module.name + '/language'));
taskDone();
}
module_language_tasks.push(mod_task);
});
}
return series(...module_language_tasks, seriesDone => {
seriesDone();
callback();
})();
}
// make component package
function componentPackage(callback) {
return src(config.buildPath + '/**')
.pipe(zip(config.com_package_name))
.pipe(dest(config.buildPath));
}
exports.default = series(
clean,modules, plugins, manifest, admin, site, adminLanguage, siteLanguage,
componentPackage
)