This repository was archived by the owner on Sep 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
109 lines (97 loc) · 3.13 KB
/
Copy pathgulpfile.js
File metadata and controls
109 lines (97 loc) · 3.13 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
/**
* Node.js (npm) and gulp [https://gulpjs.com/] are used to manage dev dependencies.
*
* Once Node.js and gulp are installed on your system
* (see their official documentation),
* run 'npm install' in the project directory to install
* all development dependencies
*
* Available gulp tasks:
* gulp version -> changes the theme version in various files throught the project (prompt asks for new version)
* gulp clean -> deletes the dist folder
* gulp copy -> copies all files to the dist folder (minifies resources and cleans the dist folder beforhand)
* gulp zip -> creates the zip file for the theme from dist folder (runs gulp copy as a dependend task)
*/
const gulp = require('gulp');
const pjson = require('./package.json');
const del = require('del');
const zip = require('gulp-zip');
const lec = require('gulp-line-ending-corrector');
/**
* Deletes the dist folder
*/
gulp.task('clean', function () {
return del(['dist/']);
});
/**
* Copies all files to the dist folder.
* @TODO might not need to run sourcemaps for each run of copy.
*/
gulp.task('copy', gulp.series('clean', function () {
return gulp.src([
'**/*.*',
// Repo / VCS noise (dotfiles usually excluded by default, but keep for clarity)
'!.gitignore',
'!.git/**',
// Node / JS tooling metadata
'!package.json',
'!package-lock.json',
'!webpack.config.wp.js',
'!webpack.config.chat.js',
// Composer + scoper/build tooling (not needed in final plugin)
'!composer.json',
'!composer.lock',
'!composer-dev.json',
'!composer-dev.lock',
'!fix-autoloader.php',
'!scoper.inc.php',
// Docs and backup/internal material
'!README.md',
'!AGENTS-PROJECT-BUILD.md',
'!AGENTS_*.md',
'!{_docs,_docs/**}',
'!{_bak,_bak/**}',
// Build / tooling scripts
'!gulpfile.js',
'!{scripts,scripts/**}',
// Build outputs and working dirs
'!dist/**/*.*',
// Dependency trees and dev-only frontend sources
'!{node_modules,node_modules/**/*.*}',
'!{app,app/**/*.*}',
'!{webpack,webpack/**/*.*}',
])
.pipe(gulp.dest('./dist/convoworks-wp'));
}));
/**
* Creates the zip file for the theme from dist folder
* (has task that copies all required theme files
* to dist folder)
*/
gulp.task('zip', function () {
return gulp.src('convoworks-wp/**', { cwd: 'dist', base: 'dist', dot: true })
.pipe(zip(`convoworks-wp-v${pjson.version}.zip`))
.pipe(gulp.dest('dist'))
.on('end', function () {
del(['dist/convoworks-wp']);
});
});
/**
* One-off task to normalize line endings across the project to LF.
*
* Usage:
* npm run fix:eol
*/
gulp.task('fix-eol', function () {
return gulp.src([
'**/*.{php,js,jsx,ts,tsx,json,css,scss,less,html,htm,md,txt,xml,yml,yaml,ini,sh,bat,ps1,cmd,twig,vue,svg,po,pot}',
'!node_modules/**',
'!dist/**',
'!.git/**',
], { base: '.' })
.pipe(lec({
eolc: 'LF',
encoding: 'utf8',
}))
.pipe(gulp.dest('.'));
});