sdc-build-wp 5.4.5 → 5.5.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/lib/build.js +2 -2
- package/lib/components/errors.js +2 -2
- package/lib/components/fonts.js +2 -2
- package/lib/components/server.js +3 -3
- package/lib/help.js +26 -26
- package/lib/logging.js +12 -12
- package/lib/tui.js +68 -8
- package/package.json +6 -8
package/lib/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as project } from './project.js';
|
|
2
2
|
import * as utils from './utils.js';
|
|
3
3
|
import log from './logging.js';
|
|
4
|
-
import
|
|
4
|
+
import { styleText } from 'node:util';
|
|
5
5
|
import tui from './tui.js';
|
|
6
6
|
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ export async function build(watch = false) {
|
|
|
10
10
|
if (watch) {
|
|
11
11
|
tui.init();
|
|
12
12
|
tui.setComponents(project.builds, true);
|
|
13
|
-
const commands = `Commands: ${
|
|
13
|
+
const commands = `Commands: ${styleText(['underline', 'green'], 'r')}estart, ${styleText(['underline', 'green'], 'c')}lear cache, ${styleText(['underline', 'green'], 'p')}ause/resume, ${styleText(['underline', 'green'], 'n')}ew component, ${styleText(['underline', 'green'], 'q')}uit`;
|
|
14
14
|
tui.setCommands(commands);
|
|
15
15
|
}
|
|
16
16
|
|
package/lib/components/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseComponent from './base.js';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import fs from 'fs
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
4
|
import { Tail } from 'tail';
|
|
5
5
|
|
|
6
6
|
export default class ErrorsComponent extends BaseComponent {
|
|
@@ -27,7 +27,7 @@ export default class ErrorsComponent extends BaseComponent {
|
|
|
27
27
|
try {
|
|
28
28
|
await fs.access(this.project.paths.errorLog);
|
|
29
29
|
} catch {
|
|
30
|
-
await fs.
|
|
30
|
+
await fs.writeFile(path.resolve(this.project.paths.errorLog), '');
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
await fs.access(this.project.paths.errorLog);
|
package/lib/components/fonts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseComponent from './base.js';
|
|
2
2
|
import { readdir } from 'fs/promises';
|
|
3
|
-
import fs from 'fs
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
4
|
|
|
5
5
|
export default class FontsComponent extends BaseComponent {
|
|
6
6
|
|
|
@@ -25,7 +25,7 @@ export default class FontsComponent extends BaseComponent {
|
|
|
25
25
|
try {
|
|
26
26
|
const fontsDir = await readdir(entry);
|
|
27
27
|
if (fontsDir.length == 0) { throw new Error('No files present'); }
|
|
28
|
-
await fs.
|
|
28
|
+
await fs.cp(entry, `${this.project.path}${entryLabel}`, { recursive: true });
|
|
29
29
|
entryLabel += ` (${fontsDir.filter(file => !file.startsWith('.')).length} files)`;
|
|
30
30
|
} catch (error) {
|
|
31
31
|
this.log('error', `${error} at ${entry.replace(this.project.path, '')}/. Skipping font copy`);
|
package/lib/components/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { readFile } from 'fs/promises';
|
|
5
5
|
import { create } from 'browser-sync';
|
|
6
|
-
import
|
|
6
|
+
import { styleText } from 'node:util';
|
|
7
7
|
import tui from '../tui.js';
|
|
8
8
|
|
|
9
9
|
export default class ServerComponent extends BaseComponent {
|
|
@@ -120,9 +120,9 @@ export default class ServerComponent extends BaseComponent {
|
|
|
120
120
|
if (tui.isInitialized) {
|
|
121
121
|
tui.setURLs(localURL, this.usedOptions.urls.external || '');
|
|
122
122
|
} else {
|
|
123
|
-
this.log('info', `Local server: ${
|
|
123
|
+
this.log('info', `Local server: ${styleText('green', localURL)} (${this.usedOptions.urls.local})`);
|
|
124
124
|
if (this.usedOptions.urls.external) {
|
|
125
|
-
this.log('info', `External server: ${
|
|
125
|
+
this.log('info', `External server: ${styleText('green', this.usedOptions.urls.external)}`);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
package/lib/help.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
import project from './project.js';
|
|
2
|
-
import
|
|
2
|
+
import { styleText } from 'node:util';
|
|
3
3
|
import log from './logging.js';
|
|
4
4
|
|
|
5
5
|
export default function() {
|
|
6
6
|
log(null, `
|
|
7
|
-
${
|
|
7
|
+
${styleText(['bold', 'blue'], 'SDC Build WP')} - Custom WordPress build process
|
|
8
8
|
|
|
9
|
-
${
|
|
9
|
+
${styleText('yellow', 'Usage:')} sdc-build-wp [options] [arguments]
|
|
10
10
|
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
${
|
|
11
|
+
${styleText('yellow', 'Options:')}
|
|
12
|
+
${styleText('green', '-h, --help')} Show this help message and exit
|
|
13
|
+
${styleText('green', '-v, --version')} Show version number and exit
|
|
14
|
+
${styleText('green', '-w, --watch')} Build and watch for changes
|
|
15
|
+
${styleText('green', '-b, --builds BUILDS')} Build with specific components (comma-separated)
|
|
16
|
+
${styleText('green', '--no-cache')} Disable build caching for this run
|
|
17
|
+
${styleText('green', '--clear-cache')} Clear all cached data and exit
|
|
18
18
|
|
|
19
|
-
${
|
|
19
|
+
${styleText('yellow', 'Available Components:')}
|
|
20
20
|
${Object.entries(project.components).map(([key, component]) => {
|
|
21
|
-
return ` ${
|
|
21
|
+
return ` ${styleText('cyan', key.padEnd(12))} ${component.description}`;
|
|
22
22
|
}).join('\n')}
|
|
23
23
|
|
|
24
|
-
${
|
|
25
|
-
${
|
|
24
|
+
${styleText('yellow', 'Examples:')}
|
|
25
|
+
${styleText('dim', '# Basic build')}
|
|
26
26
|
sdc-build-wp
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${styleText('dim', '# Build and watch for changes')}
|
|
29
29
|
sdc-build-wp --watch
|
|
30
30
|
|
|
31
|
-
${
|
|
31
|
+
${styleText('dim', '# Build only specific components')}
|
|
32
32
|
sdc-build-wp --watch --builds=style,scripts
|
|
33
33
|
|
|
34
|
-
${
|
|
34
|
+
${styleText('dim', '# Build without cache')}
|
|
35
35
|
sdc-build-wp --no-cache
|
|
36
36
|
|
|
37
|
-
${
|
|
37
|
+
${styleText('dim', '# Clear cache and exit')}
|
|
38
38
|
sdc-build-wp --clear-cache
|
|
39
39
|
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
${
|
|
44
|
-
${
|
|
45
|
-
${
|
|
40
|
+
${styleText('yellow', 'Watch Mode Controls:')}
|
|
41
|
+
${styleText('green', '[r]')} Restart build process
|
|
42
|
+
${styleText('green', '[c]')} Clear cache
|
|
43
|
+
${styleText('green', '[p]')} Pause/Resume watching
|
|
44
|
+
${styleText('green', '[n]')} New component
|
|
45
|
+
${styleText('green', '[q]')} Quit and exit
|
|
46
46
|
|
|
47
|
-
${
|
|
48
|
-
Place your configuration in ${
|
|
47
|
+
${styleText('yellow', 'Configuration:')}
|
|
48
|
+
Place your configuration in ${styleText('cyan', `${project.sdcDirName}/${project.configFileName}`)}
|
|
49
49
|
See documentation for available options.
|
|
50
50
|
`);
|
|
51
51
|
}
|
package/lib/logging.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// based heavily on Nick Salloum's 'node-pretty-log'
|
|
2
2
|
// https://github.com/callmenick/node-pretty-log
|
|
3
|
-
import
|
|
3
|
+
import { styleText } from 'node:util';
|
|
4
4
|
import { default as project } from './project.js';
|
|
5
5
|
import tui from './tui.js';
|
|
6
6
|
|
|
@@ -14,28 +14,28 @@ function log(type, ...messages) {
|
|
|
14
14
|
|
|
15
15
|
switch (type) {
|
|
16
16
|
case 'success':
|
|
17
|
-
icon =
|
|
18
|
-
time =
|
|
17
|
+
icon = styleText('green', '✔');
|
|
18
|
+
time = styleText('gray', getTime());
|
|
19
19
|
break;
|
|
20
20
|
case 'error':
|
|
21
|
-
icon =
|
|
22
|
-
time =
|
|
21
|
+
icon = styleText('red', '✖');
|
|
22
|
+
time = styleText(['bgRed', 'gray'], getTime());
|
|
23
23
|
if (project.builds.includes('server') && project.isRunning) {
|
|
24
24
|
project.components.server.server.notify('ERROR', 2500);
|
|
25
25
|
}
|
|
26
26
|
break;
|
|
27
27
|
case 'warn':
|
|
28
|
-
icon =
|
|
29
|
-
time =
|
|
28
|
+
icon = styleText('yellow', '⚠');
|
|
29
|
+
time = styleText(['bgYellow', 'gray'], getTime());
|
|
30
30
|
break;
|
|
31
31
|
case 'php':
|
|
32
|
-
icon =
|
|
33
|
-
time =
|
|
34
|
-
prefix =
|
|
32
|
+
icon = styleText('blue', 'ℹ');
|
|
33
|
+
time = styleText('gray', getTime());
|
|
34
|
+
prefix = styleText('gray', 'PHP: ');
|
|
35
35
|
break;
|
|
36
36
|
case 'info':
|
|
37
|
-
icon =
|
|
38
|
-
time =
|
|
37
|
+
icon = styleText('blue', 'ℹ');
|
|
38
|
+
time = styleText(['bgBlue', 'gray'], getTime());
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
41
|
|
package/lib/tui.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import blessed from 'blessed';
|
|
2
|
-
import
|
|
2
|
+
import { styleText } from 'node:util';
|
|
3
3
|
import log from './logging.js';
|
|
4
4
|
|
|
5
5
|
class TUI {
|
|
@@ -16,6 +16,7 @@ class TUI {
|
|
|
16
16
|
this.components = [];
|
|
17
17
|
this.watchMode = false;
|
|
18
18
|
this.isPaused = false;
|
|
19
|
+
this.isMouseEnabled = true;
|
|
19
20
|
this._logHistory = [];
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -101,10 +102,26 @@ class TUI {
|
|
|
101
102
|
});
|
|
102
103
|
|
|
103
104
|
this.screen.key(['enter', 'return'], () => {
|
|
105
|
+
if (!this.isMouseEnabled) {
|
|
106
|
+
this.enableMouseCapture();
|
|
107
|
+
this.updateHeader();
|
|
108
|
+
this.render();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
104
111
|
this.logBox.log('');
|
|
105
112
|
this.screen.render();
|
|
106
113
|
});
|
|
107
114
|
|
|
115
|
+
const handleMouseDisable = () => {
|
|
116
|
+
if (this.isMouseEnabled) {
|
|
117
|
+
this.disableMouseCapture();
|
|
118
|
+
this.updateHeader();
|
|
119
|
+
this.render();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
this.logBox.on('click', handleMouseDisable);
|
|
123
|
+
this.headerBox.on('click', handleMouseDisable);
|
|
124
|
+
|
|
108
125
|
this.screen.key(['down'], () => {
|
|
109
126
|
this.logBox.scroll(1);
|
|
110
127
|
this.screen.render();
|
|
@@ -138,23 +155,26 @@ class TUI {
|
|
|
138
155
|
|
|
139
156
|
const lines = [];
|
|
140
157
|
|
|
141
|
-
let titleLine = ' ' +
|
|
158
|
+
let titleLine = ' ' + styleText(['bold', 'blue'], 'SDC Build WP');
|
|
142
159
|
if (this.isPaused) {
|
|
143
|
-
titleLine +=
|
|
160
|
+
titleLine += styleText(['bold', 'yellow'], ' [PAUSED]');
|
|
161
|
+
}
|
|
162
|
+
if (!this.isMouseEnabled) {
|
|
163
|
+
titleLine += styleText(['bold', 'yellow'], ' [TEXT SELECT - Press Enter to Exit]');
|
|
144
164
|
}
|
|
145
165
|
if (this.components.length > 0) {
|
|
146
|
-
titleLine +=
|
|
166
|
+
titleLine += styleText('gray', ' [') + styleText('cyan', this.components.join(', ')) + styleText('gray', ']');
|
|
147
167
|
}
|
|
148
168
|
lines.push(titleLine);
|
|
149
169
|
|
|
150
170
|
if (this.urls.local || this.urls.external) {
|
|
151
171
|
let urlLine = ' ';
|
|
152
172
|
if (this.urls.local) {
|
|
153
|
-
urlLine += `Local: ${
|
|
173
|
+
urlLine += `Local: ${styleText('green', this.urls.local)}`;
|
|
154
174
|
}
|
|
155
175
|
if (this.urls.external) {
|
|
156
176
|
if (urlLine.length > 1) urlLine += ' ';
|
|
157
|
-
urlLine += `External: ${
|
|
177
|
+
urlLine += `External: ${styleText('green', this.urls.external)}`;
|
|
158
178
|
}
|
|
159
179
|
lines.push(urlLine);
|
|
160
180
|
} else {
|
|
@@ -167,7 +187,11 @@ class TUI {
|
|
|
167
187
|
lines.push(' ');
|
|
168
188
|
}
|
|
169
189
|
|
|
170
|
-
|
|
190
|
+
if (!this.isMouseEnabled) {
|
|
191
|
+
lines.push(' ' + styleText('yellow', 'Text select on. Press Enter to enable mouse.'));
|
|
192
|
+
} else {
|
|
193
|
+
lines.push(' ');
|
|
194
|
+
}
|
|
171
195
|
|
|
172
196
|
this.headerBox.setContent(lines.join('\n'));
|
|
173
197
|
}
|
|
@@ -319,7 +343,8 @@ class TUI {
|
|
|
319
343
|
commands: this.commands,
|
|
320
344
|
components: [...this.components],
|
|
321
345
|
watchMode: this.watchMode,
|
|
322
|
-
isPaused: this.isPaused
|
|
346
|
+
isPaused: this.isPaused,
|
|
347
|
+
isMouseEnabled: this.isMouseEnabled
|
|
323
348
|
};
|
|
324
349
|
}
|
|
325
350
|
|
|
@@ -330,11 +355,45 @@ class TUI {
|
|
|
330
355
|
this.components = [...state.components];
|
|
331
356
|
this.watchMode = state.watchMode;
|
|
332
357
|
this.isPaused = state.isPaused;
|
|
358
|
+
this.isMouseEnabled = state.isMouseEnabled ?? true;
|
|
359
|
+
if (this.isMouseEnabled) {
|
|
360
|
+
this.enableMouseCapture();
|
|
361
|
+
} else {
|
|
362
|
+
this.disableMouseCapture();
|
|
363
|
+
}
|
|
333
364
|
this.updateHeader();
|
|
334
365
|
this.render();
|
|
335
366
|
}
|
|
336
367
|
}
|
|
337
368
|
|
|
369
|
+
enableMouseCapture() {
|
|
370
|
+
if (!this.screen || this.isMouseEnabled) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
this.isMouseEnabled = true;
|
|
374
|
+
if (this.screen.enableMouse) {
|
|
375
|
+
this.screen.enableMouse();
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (this.screen.program && this.screen.program.enableMouse) {
|
|
379
|
+
this.screen.program.enableMouse();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
disableMouseCapture() {
|
|
384
|
+
if (!this.screen || !this.isMouseEnabled) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
this.isMouseEnabled = false;
|
|
388
|
+
if (this.screen.disableMouse) {
|
|
389
|
+
this.screen.disableMouse();
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (this.screen.program && this.screen.program.disableMouse) {
|
|
393
|
+
this.screen.program.disableMouse();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
338
397
|
destroy() {
|
|
339
398
|
if (this.isInitialized && this.screen) {
|
|
340
399
|
if (this.screen.program) {
|
|
@@ -348,6 +407,7 @@ class TUI {
|
|
|
348
407
|
this.screen = null;
|
|
349
408
|
this.headerBox = null;
|
|
350
409
|
this.logBox = null;
|
|
410
|
+
this.isMouseEnabled = true;
|
|
351
411
|
|
|
352
412
|
if (process.stdout.isTTY) {
|
|
353
413
|
process.stdout.write('\x1b[?25h');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdc-build-wp",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Custom WordPress build process.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -26,20 +26,18 @@
|
|
|
26
26
|
"@stylistic/stylelint-plugin": "^4.0.0",
|
|
27
27
|
"@typescript-eslint/eslint-plugin": "^8.48.1",
|
|
28
28
|
"@typescript-eslint/parser": "^8.48.1",
|
|
29
|
-
"@wordpress/scripts": "^31.
|
|
30
|
-
"autoprefixer": "^10.4.
|
|
29
|
+
"@wordpress/scripts": "^31.4.0",
|
|
30
|
+
"autoprefixer": "^10.4.24",
|
|
31
31
|
"blessed": "^0.1.81",
|
|
32
32
|
"browser-sync": "^3.0.4",
|
|
33
|
-
"chalk": "^5.6.2",
|
|
34
33
|
"chokidar": "^5.0.0",
|
|
35
|
-
"esbuild": "^0.27.
|
|
34
|
+
"esbuild": "^0.27.3",
|
|
36
35
|
"eslint": "^9.39.1",
|
|
37
|
-
"fs-extra": "^11.3.2",
|
|
38
36
|
"postcss": "^8.5.6",
|
|
39
37
|
"postcss-scss": "^4.0.9",
|
|
40
38
|
"postcss-sort-media-queries": "^5.2.0",
|
|
41
|
-
"prettier": "^3.
|
|
42
|
-
"sass": "^1.
|
|
39
|
+
"prettier": "^3.8.1",
|
|
40
|
+
"sass": "^1.97.3",
|
|
43
41
|
"sharp": "^0.34.5",
|
|
44
42
|
"stylelint": "^16.26.1",
|
|
45
43
|
"svgo": "^4.0.0",
|