This repository has been archived by the owner on Sep 28, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
108 lines (100 loc) · 3.29 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
var gulp = require('gulp');
var fs = require('fs');
var path = require('path');
var shell = require('gulp-shell');
var prompt = require('gulp-prompt');
var folders = require('gulp-folders');
//复制 src/root 目录
gulp.task('CopyRoot', folders('./src/root', function (folder) {
var srcPath, destPath;
if (folder === 'root') {
srcPath = [
'./src/root/root/**/*',
'./src/root/root/**/.*',
'!**/README'];
destPath = './dist';
return gulp.src(srcPath).pipe(gulp.dest(destPath));
} else {
srcPath = [
path.join('./src/root', folder, '**'),
path.join('./src/root', folder, '**', '.*'),
'!**/README'];
destPath = path.join('./dist', folder.replace('__', '/'));
return gulp.src(srcPath).pipe(gulp.dest(destPath));
}
}));
//复制 src/configs 目录
gulp.task('CopyConfig', function () {
gulp.src('gulpfile.js').pipe(prompt.prompt({
type: 'input',
name: 'name',
message: 'Please enter the configuration environment name:'
}, function (res) {
gulp.src([
path.join('./src/config', res.name, '**'),
path.join('./src/config', res.name, '**', '.*'),
'!**/README'])
.pipe(gulp.dest('./dist'));
}));
});
//复制 src/framework 目录
gulp.task('CopyFramework', function () {
gulp.src([
'./src/framework/**',
'./src/framework/**/.*',
'!**/README'])
.pipe(gulp.dest('./dist'));
});
//初始化插件
gulp.task('InitAddon', function () {
gulp.src('gulpfile.js').pipe(prompt.prompt({
type: 'input',
name: 'name',
message: 'Please enter the name of the addon:'
}, function (res) {
gulp.src('gulpfile.js', {read: false})
.pipe(shell([
'cd dist && php think addon -a ' + res.name + ' -c disable',
'cd dist && php think addon -a ' + res.name + ' -c upgrade',
'cd dist && php think addon -a ' + res.name + ' -c enable'
]));
}));
});
//初始化 src
gulp.task('InitSrc', function () {
gulp.src([
'./example/**',
'!**/*'])
.pipe(gulp.dest('./src'));
});
//初始化 fastadmin
gulp.task('InitFastadmin', function () {
fs.exists('./fastadmin', function (exists) {
if (exists) {
gulp.src('gulpfile.js', {read: false})
.pipe(shell([
'cd fastadmin && bower install',
'cd fastadmin && composer install'
]));
} else {
gulp.src('gulpfile.js', {read: false})
.pipe(shell('git clone https://gitee.com/karson/fastadmin.git'))
.pipe(shell([
'cd fastadmin && bower install',
'cd fastadmin && composer install'
]));
}
});
});
//安装 fastadmin
gulp.task('InstallFastadmin', function () {
gulp.src('gulpfile.js', {read: false})
.pipe(shell('cd dist && php think install'));
});
//复制 fastadmin 目录
gulp.task('CopyFastadmin', function () {
gulp.src([
'./fastadmin/**',
'./fastadmin/**/.*'])
.pipe(gulp.dest('./dist'));
});