Repository navigation
Expand file tree
/
Copy pathgulpfile.mjs
More file actions
143 lines (129 loc) · 3.24 KB
/
Copy pathgulpfile.mjs
File metadata and controls
143 lines (129 loc) · 3.24 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
/* eslint-disable no-console */
import { deleteAsync } from 'del';
import { existsSync, readFileSync } from 'fs';
import gulp from 'gulp';
import zip from 'gulp-zip';
let versionNumber = '';
try {
const data = readFileSync('tutor.php', 'utf8');
versionNumber = data.match(/Version:\s*([\d.]+(?:-[a-zA-Z0-9]+)?)/i)?.[1] || '';
console.log(versionNumber);
} catch (err) {
console.log(err);
}
const build_name = `tutor-${versionNumber}.zip`;
function cleanZip() {
return deleteAsync(`./${build_name}`);
}
function cleanBuild() {
return deleteAsync('./build');
}
function copy() {
return gulp
.src(
[
'./**/*.*',
'!./build/**',
'!./assets/**/*.map',
'!./assets/core/**',
'!./assets/src/**',
'!./assets/.sass-cache',
'!./node_modules/**',
'!./v2-library/**',
'!./test/**',
'!./.docz/**',
'!./**/*.zip',
'!.github',
'!.vscode',
'!./readme.md',
'!.DS_Store',
'!./**/.DS_Store',
'!./LICENSE.txt',
'!./*.lock',
'!./*.js',
'!./*.mjs',
'!./*.json',
'!./**/*.ignore',
'!yarn-error.log',
'!bin/**',
'!tests/**',
'!.env',
'!vendor/bin/**',
'!vendor/doctrine/**',
'!vendor/myclabs/**',
'!vendor/nikic/**',
'!vendor/phar-io/**',
'!vendor/phpdocumentor/**',
'!vendor/phpspec/**',
'!vendor/phpunit/**',
'!vendor/sebastian/**',
'!vendor/theseer/**',
'!vendor/webmozart/**',
'!vendor/yoast/**',
'!.phpunit.result.cache',
'!*.yml',
'!*.yaml',
'!phpunit.xml.dist',
'!phpunit.xml',
'!phpcs.xml',
'!phpcs.xml.dist',
'!./includes/droip/**',
'!./includes/kirki/**',
'!./cypress/**',
'!./cypress.config.ts',
'!.husky',
'!.lintstagedrc',
'!./stories/**',
'!rsbuild.config.ts',
'!phpstan.neon',
'!.claude',
'!.cursor',
'!docs/**',
],
{
allowEmpty: true,
buffer: true,
encoding: false,
},
)
.pipe(gulp.dest('build/tutor/'));
}
function copyTutorDroip() {
const droipDistPath = 'includes/droip/dist';
if (!existsSync(droipDistPath)) {
console.log('⚠️ Droip files not found, skipping...');
return Promise.resolve();
}
return gulp
.src(`${droipDistPath}/**`, {
allowEmpty: true,
buffer: true,
encoding: false,
})
.pipe(gulp.dest('build/tutor/includes/droip'));
}
function copyTutorKirki() {
const kirkiDistPath = 'includes/kirki/dist';
if (!existsSync(kirkiDistPath)) {
console.log('⚠️ Kirki files not found, skipping...');
return Promise.resolve();
}
return gulp
.src(`${kirkiDistPath}/**`, {
allowEmpty: true,
buffer: true,
encoding: false,
})
.pipe(gulp.dest('build/tutor/includes/kirki'));
}
function makeZip() {
return gulp
.src('./build/**/*.*', {
buffer: true,
allowEmpty: true,
encoding: false,
})
.pipe(zip(build_name))
.pipe(gulp.dest('./'));
}
export const build = gulp.series(cleanZip, cleanBuild, copy, copyTutorDroip, copyTutorKirki, makeZip, cleanBuild);