forked from BoldGrid/prime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
152 lines (134 loc) · 3.54 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
/**
* Primary Tasks:
*
* gulp install-framework: Places the theme framework in your inc folder.
*/
var gulp = require( 'gulp' ),
argv = require( 'yargs' ).argv,
sequence = require( 'run-sequence' ),
unzip = require( 'gulp-unzip' ),
download = require( 'gulp-download' ),
debug = require( 'gulp-debug' ),
del = require( 'del' ),
bower = require( 'gulp-bower' );
//Configs
var config = {
src : '.',
defaultThemeFolderName : 'starter-master',
mergeDest : './generated/',
tempDir : './boldgrid-gulp-parent-temp',
bower : './bower_components',
defaultChild : 'https://github.com/BoldGrid/starter/archive/master.zip',
frameworkDest : '/inc/boldgrid-theme-framework',
localFramework : '../boldgrid-theme-framework/boldgrid-theme-framework',
};
config.themeFolderName = ( argv.themeFolderName) ? argv.themeFolderName : config.defaultThemeFolderName;
config.mergeDest += config.themeFolderName;
/**
* Child Download
*/
gulp.task('child-download', function () {
var child = ( argv.child ) ? argv.child : config.defaultChild,
childZip = ( argv.childZip ) ? argv.childZip : '',
zip;
if ( childZip ) {
zip = gulp.src( childZip );
} else {
zip = download( child );
}
return zip
.pipe( unzip() )
.pipe( gulp.dest( config.tempDir ) );
} );
gulp.task('child-copy-files', function () {
return gulp.src( [
config.tempDir + '/' + config.themeFolderName + '/**',
'!' + config.tempDir + '/' + config.themeFolderName + '/',
'!' + config.tempDir + '/*/functions.php',
'!' + config.tempDir + '/*/README.md',
'!' + config.tempDir + '/*/LICENSE',
] )
.pipe( debug() )
.pipe( gulp.dest( config.mergeDest ) );
});
gulp.task('child-remove-temp', function () {
return del( config.tempDir ) ;
} );
// Download framework.
gulp.task('bower', function () {
return bower().pipe( gulp.dest( config.bower ) );
});
// Copy from bower into parent dest.
gulp.task('framework', function () {
return gulp.src( config.bower + '/boldgrid-theme-framework/boldgrid-theme-framework/**/*' )
.pipe( gulp.dest( '.' + config.frameworkDest ) );
});
// Copy from bower into parent dest.
gulp.task('local-framework', function () {
return gulp.src( [
config.localFramework + '/**/*'
] )
.pipe( gulp.dest( config.mergeDest + config.frameworkDest ) );
});
//Copy parent into new copy.
gulp.task('parent', function () {
return gulp.src( [
'!./.git',
'!./.git/**',
'!./bower_components',
'!./bower_components/**',
'!./clone',
'!./gulpfile.js',
'!./package.json',
'!./bower.json',
'!./node_modules',
'!./generated',
'!./generated/**',
'!./node_modules/**',
'!./inc/boldgrid-theme-framework',
'!./inc/boldgrid-theme-framework/**',
'./**/*'
] )
.pipe( gulp.dest( config.mergeDest ) );
});
// Remove an existing copy of merge theme.
gulp.task( 'clean-output', function () {
return del( config.mergeDest, { force: true } );
});
// Copy child into merged.
gulp.task( 'child-theme', function ( cb ) {
sequence (
'child-download',
'child-copy-files',
'child-remove-temp',
cb
);
});
//Create a child theme with framework in same directory.
gulp.task( 'generate-local', function ( cb ) {
sequence (
'clean-output',
'local-framework',
'parent',
'child-theme',
cb
);
});
// Create a child theme with bower dependencies.
gulp.task( 'generate', function ( cb ) {
sequence (
'clean-output',
'install-framework',
'parent',
'child-theme',
cb
);
});
// Install theme framework into the parent theme.
gulp.task( 'install-framework', function ( cb ) {
return sequence (
'bower',
'framework',
cb
);
});