sdc-build-wp 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +43 -46
- package/lib/browsersync.js +8 -0
- package/lib/logging.js +7 -0
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -5,7 +5,10 @@ import parseArgs from 'minimist';
|
|
|
5
5
|
const argv = parseArgs(process.argv.slice(2));
|
|
6
6
|
import chokidar from 'chokidar';
|
|
7
7
|
import { glob, globSync } from 'glob';
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
9
|
+
import { Tail } from 'tail';
|
|
8
10
|
|
|
11
|
+
import log from './lib/logging.js';
|
|
9
12
|
import bustCache from './lib/bustCache.js';
|
|
10
13
|
import { buildSass, buildSassTheme } from './lib/style.js';
|
|
11
14
|
import buildJS from './lib/scripts.js';
|
|
@@ -50,6 +53,28 @@ function frontrunImages() {
|
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
function runBlocks() {
|
|
57
|
+
for (var block of blockGlob) {
|
|
58
|
+
buildBlock(block);
|
|
59
|
+
}
|
|
60
|
+
bustFunctionsCache();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function runSass() {
|
|
64
|
+
buildSassTheme();
|
|
65
|
+
for (var block of filesSass) {
|
|
66
|
+
buildSass(block.file, block.name, sassGlob);
|
|
67
|
+
bustFunctionsCache();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function runJS() {
|
|
72
|
+
for (var block of filesJS) {
|
|
73
|
+
buildJS(block.file, block.name, jsGlob);
|
|
74
|
+
bustFunctionsCache();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
53
78
|
let entries = {};
|
|
54
79
|
for (const [name, files] of Object.entries(project.package.sdc.entries)) {
|
|
55
80
|
entries[name] = [];
|
|
@@ -84,64 +109,36 @@ for (const [name, files] of Object.entries(entries)) {
|
|
|
84
109
|
});
|
|
85
110
|
}
|
|
86
111
|
|
|
87
|
-
function runBlocks() {
|
|
88
|
-
for (var block of blockGlob) {
|
|
89
|
-
buildBlock(block);
|
|
90
|
-
}
|
|
91
|
-
bustFunctionsCache();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
112
|
runBlocks();
|
|
113
|
+
runSass();
|
|
114
|
+
runJS();
|
|
115
|
+
frontrunImages()
|
|
116
|
+
buildFonts(project.path + '/_src/fonts');
|
|
117
|
+
|
|
95
118
|
if (argv.watch) {
|
|
119
|
+
buildBrowserSync();
|
|
96
120
|
chokidar.watch(blockGlob, chokidarOpts).on('all', (event, path) => {
|
|
97
121
|
runBlocks();
|
|
98
122
|
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function runSass() {
|
|
102
|
-
buildSassTheme();
|
|
103
|
-
for (var block of filesSass) {
|
|
104
|
-
buildSass(block.file, block.name, sassGlob);
|
|
105
|
-
bustFunctionsCache();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
runSass();
|
|
110
|
-
if (argv.watch) {
|
|
111
123
|
chokidar.watch(sassGlob, chokidarOpts).on('all', (event, path) => {
|
|
112
124
|
runSass();
|
|
113
125
|
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function runJS() {
|
|
117
|
-
for (var block of filesJS) {
|
|
118
|
-
buildJS(block.file, block.name, jsGlob);
|
|
119
|
-
bustFunctionsCache();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
runJS();
|
|
124
|
-
if (argv.watch) {
|
|
125
|
-
chokidar.watch(jsGlob, chokidarOpts).on('all', (event, path) => {
|
|
126
|
-
runJS();
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (argv.watch) {
|
|
131
126
|
chokidar.watch(project.path + '/theme.json', chokidarOpts).on('all', (event, path) => {
|
|
132
127
|
runSass();
|
|
133
128
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (argv.watch) {
|
|
129
|
+
chokidar.watch(jsGlob, chokidarOpts).on('all', (event, path) => {
|
|
130
|
+
runJS();
|
|
131
|
+
});
|
|
138
132
|
chokidar.watch(project.path + '/_src/images/**/*', chokidarOpts).on('all', (event, path) => {
|
|
139
133
|
frontrunImages();
|
|
140
134
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
let errorLogPath = process.env.ERROR_LOG_PATH || project.package.sdc?.error_log_path || '../../../../../logs/php/error.log';
|
|
136
|
+
if (existsSync(errorLogPath)) {
|
|
137
|
+
let errorLogTail = new Tail(errorLogPath);
|
|
138
|
+
errorLogTail.on('line', function(data) {
|
|
139
|
+
log('php', data);
|
|
140
|
+
});
|
|
141
|
+
} else {
|
|
142
|
+
log('info', `Cannot find error log @ ${errorLogPath}. Skipping watching php error logs`);
|
|
143
|
+
}
|
|
147
144
|
}
|
package/lib/browsersync.js
CHANGED
package/lib/logging.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdc-build-wp",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Custom WordPress build process.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^20"
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"postcss-scss": "^4.0.9",
|
|
42
42
|
"postcss-sort-media-queries": "^5.2.0",
|
|
43
43
|
"sass": "^1.75.0",
|
|
44
|
-
"stylelint": "^16.4.0"
|
|
44
|
+
"stylelint": "^16.4.0",
|
|
45
|
+
"tail": "^2.2.6"
|
|
45
46
|
}
|
|
46
47
|
}
|