-
Notifications
You must be signed in to change notification settings - Fork 45
/
gulpfile.js
61 lines (56 loc) · 1.79 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
const gulp = require("gulp");
const gulpWpPot = require("gulp-wp-pot");
const gulpZip = require("gulp-zip");
const gulpFreemius = require("gulp-freemius-deploy");
const del = require("del");
const pkg = require("./package.json");
const freemiusConfig = require("./fs-config.json");
// register the freemius-deploy task
gulpFreemius(gulp, {
...freemiusConfig,
zip_name: `${pkg.name}.v${pkg.version}.zip`,
zip_path: "./dist/",
add_contributor: true
});
// clean up the files created by the tasks
function clean(){
return del([
`./languages/${pkg.name}.pot`,
`./dist/${pkg.name}.v${pkg.version}.zip`
]);
}
// extract a .pot file from all PHP files excluding those in the node_modules dir
function translate(){
return gulp.src("./**/*.php")
.pipe(gulpWpPot({
"domain": `${pkg.name}`,
"package": `${pkg.title}`,
"bugReport": `${pkg.bugs}`,
"team": `${pkg.author}`,
"lastTranslator": `${pkg.author}`
}))
.pipe(gulp.dest(`./languages/${pkg.name}.pot`));
}
// create a .zip containing just the production code for the plugin
function zip(){
return gulp.src([
"**/*",
"!package*.json",
"!./{node_modules,node_modules/**/*}",
"!./{dist,dist/**/*}",
'!./{vendor,vendor/**/*}',
"!./{src,src/**/*}",
'!./{gutenberg/src,gutenberg/src/**/*,gutenberg/config,gutenberg/config/**/*}',
"!fs-config.json",
"!composer.json",
"!composer.lock",
"!gulpfile*.js",
"!webpack*.js",
"!./{gulpfile.js,gulpfile.js/**/*}",
'!README.md',
'!Gruntfile.js'
])
.pipe(gulpZip(`${pkg.name}.v${pkg.version}.zip`))
.pipe(gulp.dest("./dist"));
}
exports.default = gulp.series(clean, translate, zip);