sdc-build-wp 5.0.1 → 5.0.2
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/README.md +1 -0
- package/lib/build.js +6 -8
- package/lib/components/scripts.js +6 -2
- package/lib/project.js +9 -6
- package/lib/utils.js +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
package/lib/build.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as utils from './utils.js';
|
|
|
3
3
|
import log from './logging.js';
|
|
4
4
|
|
|
5
5
|
export async function build(watch = false) {
|
|
6
|
-
if (project.
|
|
6
|
+
if (project.builds.includes('cache')) {
|
|
7
7
|
try {
|
|
8
8
|
await project.components.cache.init();
|
|
9
9
|
} catch (error) {
|
|
@@ -48,7 +48,7 @@ export async function build(watch = false) {
|
|
|
48
48
|
project.builds.splice(project.builds.indexOf('server'), 1);
|
|
49
49
|
project.builds.push('server');
|
|
50
50
|
log('info', `Started watching [${project.builds.join(', ')}]`);
|
|
51
|
-
log('info', `[r] to restart, [p] to pause/resume, [q] to quit`);
|
|
51
|
+
log('info', `[r] to restart, [c] to clear cache, [p] to pause/resume, [q] to quit`);
|
|
52
52
|
|
|
53
53
|
for (let build of project.builds) {
|
|
54
54
|
try {
|
|
@@ -63,10 +63,8 @@ export async function build(watch = false) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export function restartBuild() {
|
|
67
|
-
utils.stopActiveComponents();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
build(true);
|
|
71
|
-
}, 100);
|
|
66
|
+
export async function restartBuild() {
|
|
67
|
+
await utils.stopActiveComponents();
|
|
68
|
+
utils.clearScreen();
|
|
69
|
+
build(true);
|
|
72
70
|
}
|
|
@@ -54,7 +54,10 @@ export default class ScriptsComponent extends BaseComponent {
|
|
|
54
54
|
|
|
55
55
|
try {
|
|
56
56
|
const result = await esbuild.build({
|
|
57
|
-
platform: '
|
|
57
|
+
platform: 'browser',
|
|
58
|
+
format: 'iife',
|
|
59
|
+
globalName: 'sdcBuild',
|
|
60
|
+
treeShaking: true,
|
|
58
61
|
entryPoints: [entry],
|
|
59
62
|
bundle: true,
|
|
60
63
|
minify: true,
|
|
@@ -97,7 +100,8 @@ export default class ScriptsComponent extends BaseComponent {
|
|
|
97
100
|
try {
|
|
98
101
|
await this.process();
|
|
99
102
|
} catch (error) {
|
|
100
|
-
|
|
103
|
+
console.error(error);
|
|
104
|
+
this.log('error', `Failed to process scripts`);
|
|
101
105
|
}
|
|
102
106
|
});
|
|
103
107
|
}
|
package/lib/project.js
CHANGED
|
@@ -143,17 +143,17 @@ export async function init() {
|
|
|
143
143
|
log('warn', 'Continuing build process despite error');
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
process.on('uncaughtException', (error) => {
|
|
146
|
+
process.on('uncaughtException', async (error) => {
|
|
147
147
|
log('error', `Uncaught Exception: ${error.message}`);
|
|
148
148
|
log('warn', 'Attempting graceful shutdown');
|
|
149
|
-
utils.stopActiveComponents();
|
|
149
|
+
await utils.stopActiveComponents();
|
|
150
150
|
process.exit(1);
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
process.on('SIGINT', async function() {
|
|
154
154
|
console.log(`\r`);
|
|
155
155
|
if (project.isRunning) {
|
|
156
|
-
utils.stopActiveComponents();
|
|
156
|
+
await utils.stopActiveComponents();
|
|
157
157
|
project.isRunning = false;
|
|
158
158
|
utils.clearScreen();
|
|
159
159
|
}
|
|
@@ -178,7 +178,7 @@ export function keypressListen() {
|
|
|
178
178
|
process.stdin.resume();
|
|
179
179
|
process.stdin.setEncoding('utf8');
|
|
180
180
|
|
|
181
|
-
process.stdin.on('data', (key) => {
|
|
181
|
+
process.stdin.on('data', async (key) => {
|
|
182
182
|
switch (key) {
|
|
183
183
|
case '\r': // [Enter]/[Return]
|
|
184
184
|
console.log('\r');
|
|
@@ -196,9 +196,12 @@ export function keypressListen() {
|
|
|
196
196
|
log('warn', 'Paused build process');
|
|
197
197
|
}
|
|
198
198
|
break;
|
|
199
|
+
case 'c':
|
|
200
|
+
await project.components.cache.clearCache();
|
|
201
|
+
break;
|
|
199
202
|
case 'r':
|
|
200
203
|
log('info', 'Restarted build process');
|
|
201
|
-
restartBuild();
|
|
204
|
+
await restartBuild();
|
|
202
205
|
break;
|
|
203
206
|
}
|
|
204
207
|
});
|
|
@@ -254,7 +257,7 @@ export function setupConfigWatcher() {
|
|
|
254
257
|
configWatcher.on('change', async () => {
|
|
255
258
|
if (!project.isRunning) { return; }
|
|
256
259
|
await loadConfig();
|
|
257
|
-
restartBuild();
|
|
260
|
+
await restartBuild();
|
|
258
261
|
});
|
|
259
262
|
configWatcher.on('error', (error) => {
|
|
260
263
|
console.error(error);
|
package/lib/utils.js
CHANGED
|
@@ -13,10 +13,10 @@ export function clearScreen() {
|
|
|
13
13
|
process.stdout.write('\x1B[2J\x1B[0f');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function stopActiveComponents() {
|
|
16
|
+
export async function stopActiveComponents() {
|
|
17
17
|
if (project.configWatcher) {
|
|
18
18
|
try {
|
|
19
|
-
project.configWatcher.close();
|
|
19
|
+
await project.configWatcher.close();
|
|
20
20
|
} catch (error) {
|
|
21
21
|
console.error(error);
|
|
22
22
|
log('error', 'Failed to stop config file watcher');
|
|
@@ -36,7 +36,7 @@ export function stopActiveComponents() {
|
|
|
36
36
|
}
|
|
37
37
|
if (component.watcher) {
|
|
38
38
|
try {
|
|
39
|
-
component.watcher.close();
|
|
39
|
+
await component.watcher.close();
|
|
40
40
|
} catch (error) {
|
|
41
41
|
console.warn(`Failed to stop watcher for ${component.constructor.name}:`, error.message);
|
|
42
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdc-build-wp",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Custom WordPress build process.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"chalk": "^5.4.1",
|
|
33
33
|
"chokidar": "^4.0.3",
|
|
34
34
|
"esbuild": "^0.25.8",
|
|
35
|
-
"eslint": "^9.
|
|
35
|
+
"eslint": "^9.32.0",
|
|
36
36
|
"fs-extra": "^11.3.0",
|
|
37
37
|
"postcss": "^8.5.6",
|
|
38
38
|
"postcss-scss": "^4.0.9",
|
|
39
39
|
"postcss-sort-media-queries": "^5.2.0",
|
|
40
40
|
"sass": "^1.89.2",
|
|
41
41
|
"sharp": "^0.34.3",
|
|
42
|
-
"stylelint": "^16.
|
|
42
|
+
"stylelint": "^16.23.0",
|
|
43
43
|
"svgo": "^4.0.0",
|
|
44
44
|
"tail": "^2.2.6",
|
|
45
45
|
"yargs": "^18.0.0"
|