-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
150 lines (146 loc) · 4.59 KB
/
gulpfile.js
File metadata and controls
150 lines (146 loc) · 4.59 KB
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
var gulp = require('gulp'),
replace = require('gulp-replace-task'),
gulpLoadPlugins = require('gulp-load-plugins'),
$ = gulpLoadPlugins(),
options = {
name: 'Exit Intent Popups',
slug: 'popup-maker-exit-intent-popups',
url: 'https://wppopupmaker.com/extensions/exit-intent-popups/',
description: 'Awesomeness!',
author: 'Daniel Iser',
author_url: 'https://wppopupmaker.com/',
packages: []
};
gulp.task('questions', function () {
$.util.log('Welcome to the Popup Maker Extension Boilerplate.');
$.util.log('Please answer the following questions to get started quickly...');
return gulp.src('plugin-name/**/*.*')
.pipe($.prompt.prompt([
{
type: 'input',
name: 'name',
message: 'Name: ',
validate: function(input) {
if (typeof input !== "string" || input === '') {
return "Please enter a valid name.";
}
return true;
}
},
{
type: 'input',
name: 'slug',
message: 'Slug: ',
validate: function(input) {
if (typeof input !== "string" || input === '') {
return "Please enter a valid slug.";
}
return true;
}
},
{
type: 'input',
name: 'url',
message: 'URL: '
},
{
type: 'input',
name: 'description',
message: 'Description: '
},
{
type: 'input',
name: 'author',
message: 'Author Name: '
},
{
type: 'input',
name: 'author_url',
message: 'Author URL: '
},
{
type: 'checkbox',
name: 'packages',
message: 'Choose which packages to include:',
choices: [
{
name: "Triggers"
},
{
name: "Targeting Conditions"
},
{
name: "Global Settings"
},
{
name: "Layouts"
},
{
name: "Popup Settings"
},
{
name: "Theme Settings"
}
]
}
], function(res){
options = res;
$.util.log(options);
}));
});
gulp.task('build', ['questions'], function () {
$.util.log('Starting build for "' + options.name + '"...');
var stream1 = gulp.src('plugin-name/plugin-name.php')
.pipe(replace({
//usePrefix: false,
patterns: [
{
match: 'name',
replacement: options.name
},
{
match: 'url',
replacement: options.url
},
{
match: 'description',
replacement: options.description
},
{
match: 'author',
replacement: options.author
},
{
match: 'author_url',
replacement: options.author_url
},
{
match: 'text_domain',
replacement: options.slug
},
{
match: 'classname',
replacement: options.name.replace(/ /g, '_')
},
{
match: 'package',
replacement: options.name.replace(/ /g, '')
},
{
match: 'constant',
replacement: options.name.toUpperCase().replace(/ /g, '_')
},
{
match: 'prefix',
replacement: options.name.toLowerCase().replace(/ /g, '_')
},
{
match: 'year',
replacement: new Date().getYear()
}
]
}))
.pipe($.rename({basename: options.slug}))
.pipe(gulp.dest(options.slug));
return stream1;
});