sdc-build-wp 5.6.1 → 5.6.3

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/.stylelintrc.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
- "plugins": [
3
- "@stylistic/stylelint-plugin"
4
- ],
2
+ "plugins": ["@stylistic/stylelint-plugin", "stylelint-use-logical"],
5
3
  "rules": {
6
4
  "@stylistic/indentation": "tab",
7
5
  "@stylistic/max-empty-lines": 1,
8
6
  "rule-empty-line-before": [
9
7
  "always",
10
8
  {
11
- "ignore": [ "after-comment" ]
9
+ "ignore": ["after-comment"]
12
10
  }
13
11
  ],
14
12
  "@stylistic/block-opening-brace-space-before": "always-multi-line",
@@ -21,6 +19,23 @@
21
19
  "color-named": "never",
22
20
  "shorthand-property-no-redundant-values": true,
23
21
  "@stylistic/number-leading-zero": "always",
24
- "@stylistic/no-eol-whitespace": true
22
+ "@stylistic/no-eol-whitespace": true,
23
+ "csstools/use-logical": [
24
+ "always",
25
+ {
26
+ "except": [
27
+ "width",
28
+ "height",
29
+ "min-width",
30
+ "max-width",
31
+ "min-height",
32
+ "max-height",
33
+ "top",
34
+ "right",
35
+ "bottom",
36
+ "left"
37
+ ]
38
+ }
39
+ ]
25
40
  }
26
41
  }
package/lib/build.js CHANGED
@@ -4,17 +4,16 @@ import log from './logging.js';
4
4
  import { styleText } from 'node:util';
5
5
  import tui from './tui.js';
6
6
 
7
-
8
7
  export async function build(watch = false) {
9
8
 
10
9
  if (watch) {
11
10
  tui.init();
12
11
  tui.setComponents(project.builds, true);
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`;
12
+ const commands = `${styleText('gray', '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
13
  tui.setCommands(commands);
15
14
  }
16
15
 
17
- log('info', `Started sdc-build-wp`);
16
+ log('info', 'Started sdc-build-wp');
18
17
 
19
18
  if (project.builds.includes('cache')) {
20
19
  try {
@@ -61,6 +60,7 @@ export async function build(watch = false) {
61
60
  project.builds.splice(project.builds.indexOf('server'), 1);
62
61
  project.builds.push('server');
63
62
 
63
+ tui.finishInitialLoading();
64
64
  log('info', `Finished initial build in ${Math.round((performance.now() - initialBuildTimerStart) / 1000)} seconds`);
65
65
  log('info', `Started watching [${project.builds.join(', ')}]`);
66
66
 
@@ -77,6 +77,7 @@ export async function build(watch = false) {
77
77
  }
78
78
  }
79
79
  } else {
80
+ tui.finishInitialLoading();
80
81
  log('info', `Finished initial build in ${Math.round((performance.now() - initialBuildTimerStart) / 1000)} seconds`);
81
82
  process.emit('SIGINT');
82
83
  }
package/lib/tui.js CHANGED
@@ -1,16 +1,31 @@
1
1
  import React from 'react';
2
2
  import { Box, Text, render as renderInk, useInput, useStdout } from 'ink';
3
+ import Spinner from 'ink-spinner';
4
+ import { TitledBox, titleStyles } from '@mishieck/ink-titled-box';
3
5
  import { styleText } from 'node:util';
4
6
  import log from './logging.js';
5
7
 
6
8
  const sgrMouseRegex = /\x1b\[<(\d+);(\d+);(\d+)([mM])/g;
9
+ const ansiSgrRegex = /\x1b\[[0-9;]*m/g;
10
+ const headerColumnGap = 2;
11
+
12
+ function getVisibleTextLength(text) {
13
+ return (text || '').replace(ansiSgrRegex, '').length;
14
+ }
15
+
16
+ function getWrappedLineCount(text, width) {
17
+ return Math.max(1, Math.ceil(getVisibleTextLength(text) / Math.max(1, width)));
18
+ }
7
19
 
8
20
  function TUIRoot({ tui }) {
9
21
  const { stdout } = useStdout();
10
22
  const terminalRows = stdout?.rows || 24;
11
- const headerLines = tui.getHeaderLines();
23
+ const terminalColumns = stdout?.columns || 80;
24
+ const header = tui.getHeaderLayout(terminalColumns);
12
25
  const promptLines = tui.getPromptRenderLines();
13
- const availableLogRows = Math.max(3, terminalRows - headerLines.length - promptLines.length - 6);
26
+ const isInitialLoading = tui.isInitialLoading();
27
+ const loadingLineCount = isInitialLoading ? 1 : 0;
28
+ const availableLogRows = Math.max(3, terminalRows - header.lineCount - promptLines.length - loadingLineCount - 4);
14
29
  const visibleLogs = tui.getVisibleLogLines(availableLogRows);
15
30
 
16
31
  useInput((input, key) => {
@@ -51,23 +66,45 @@ function TUIRoot({ tui }) {
51
66
  Box,
52
67
  { flexDirection: 'column' },
53
68
  React.createElement(
54
- Box,
69
+ TitledBox,
55
70
  {
56
71
  borderStyle: 'round',
72
+ titles: ['SDC Build WP'],
57
73
  borderColor: 'blue',
58
74
  paddingX: 1,
59
75
  flexDirection: 'column'
60
76
  },
61
- headerLines.map((line, index) => React.createElement(Text, { key: `header-${index}` }, line))
77
+ header.titleLine || header.urlLine
78
+ ? React.createElement(
79
+ Box,
80
+ {
81
+ flexDirection: 'row',
82
+ flexWrap: 'wrap',
83
+ columnGap: headerColumnGap
84
+ },
85
+ header.titleLine ? React.createElement(Text, { key: 'header-title' }, header.titleLine) : null,
86
+ header.urlLine ? React.createElement(Text, { key: 'header-url' }, header.urlLine) : null
87
+ )
88
+ : null,
89
+ header.detailLines.map((line, index) => React.createElement(Text, { key: `header-${index}` }, line)),
90
+ isInitialLoading
91
+ ? React.createElement(
92
+ Text,
93
+ { color: 'cyan' },
94
+ React.createElement(Spinner, { type: 'dots' }),
95
+ ' Initial loading...'
96
+ )
97
+ : null
62
98
  ),
63
99
  React.createElement(
64
100
  Box,
65
101
  {
66
102
  borderStyle: 'single',
67
103
  borderColor: 'blue',
104
+ borderTop: false,
68
105
  paddingX: 1,
69
106
  flexDirection: 'column',
70
- height: availableLogRows + 2
107
+ height: availableLogRows + 1
71
108
  },
72
109
  visibleLogs.map((line, index) => React.createElement(Text, { key: `log-${index}` }, line))
73
110
  ),
@@ -104,14 +141,17 @@ class TUI {
104
141
  this._logScrollOffset = 0;
105
142
  this._activePrompt = null;
106
143
  this._mouseDataHandler = null;
144
+ this._isInitialLoading = false;
107
145
  }
108
146
 
109
147
  init() {
110
148
  if (this.isInitialized) {
149
+ this._isInitialLoading = true;
111
150
  this.render();
112
151
  return;
113
152
  }
114
153
 
154
+ this._isInitialLoading = true;
115
155
  this.isInitialized = true;
116
156
  this.app = renderInk(React.createElement(TUIRoot, { tui: this }), {
117
157
  exitOnCtrlC: false,
@@ -126,6 +166,19 @@ class TUI {
126
166
  this.render();
127
167
  }
128
168
 
169
+ isInitialLoading() {
170
+ return this._isInitialLoading;
171
+ }
172
+
173
+ finishInitialLoading() {
174
+ if (!this._isInitialLoading) {
175
+ return;
176
+ }
177
+
178
+ this._isInitialLoading = false;
179
+ this.render();
180
+ }
181
+
129
182
  isMouseEscapeSequence(input) {
130
183
  if (!input || typeof input !== 'string') {
131
184
  return false;
@@ -189,50 +242,63 @@ class TUI {
189
242
  process.stdout.write('\x1b[?1000l\x1b[?1002l\x1b[?1006l');
190
243
  }
191
244
 
192
- getHeaderLines() {
193
- const lines = [];
245
+ getHeaderLayout(terminalColumns = 80) {
246
+ const detailLines = [];
247
+ const innerWidth = Math.max(1, terminalColumns - 4);
248
+ const statusMessages = [];
194
249
 
195
- let titleLine = ' ' + styleText(['bold', 'blue'], 'SDC Build WP');
196
- if (this.isPaused) {
197
- titleLine += styleText(['bold', 'yellow'], ' [PAUSED]');
198
- }
199
- if (!this.isMouseEnabled) {
200
- titleLine += styleText(['bold', 'yellow'], ' [TEXT SELECT - Press Enter to Exit]');
201
- }
250
+ let titleLine = '';
202
251
  if (this.components.length > 0) {
203
- titleLine += styleText('gray', ' [') + styleText('cyan', this.components.join(', ')) + styleText('gray', ']');
252
+ titleLine = styleText('gray', 'Components: ') + styleText('cyan', this.components.join(', '));
204
253
  }
205
- lines.push(titleLine);
206
254
 
255
+ let urlLine = '';
207
256
  if (this.urls.local || this.urls.external) {
208
- let urlLine = ' ';
209
257
  if (this.urls.local) {
210
- urlLine += `Local: ${styleText('green', this.urls.local)}`;
258
+ urlLine = `${styleText('gray', 'Local:')} ${styleText('green', this.urls.local)}`;
211
259
  }
212
260
  if (this.urls.external) {
213
- if (urlLine.length > 1) {
261
+ if (urlLine) {
214
262
  urlLine += ' ';
215
263
  }
216
- urlLine += `External: ${styleText('green', this.urls.external)}`;
264
+ urlLine += `${styleText('gray', 'External:')} ${styleText('green', this.urls.external)}`;
217
265
  }
218
- lines.push(urlLine);
219
- } else {
220
- lines.push(' ');
221
266
  }
222
267
 
223
268
  if (this.commands) {
224
- lines.push(' ' + this.commands);
225
- } else {
226
- lines.push(' ');
269
+ detailLines.push(this.commands);
270
+ }
271
+
272
+ if (this.isPaused) {
273
+ statusMessages.push(styleText(['bold', 'yellow'], 'PAUSED'));
227
274
  }
228
275
 
229
276
  if (!this.isMouseEnabled) {
230
- lines.push(' ' + styleText('yellow', 'Text select on. Press Enter to enable mouse.'));
231
- } else {
232
- lines.push(' ');
277
+ statusMessages.push(styleText(['bold', 'yellow'], 'TEXT SELECT') + styleText('yellow', ' - Press [ENTER] to enable scroll.'));
233
278
  }
234
279
 
235
- return lines;
280
+ if (statusMessages.length > 0) {
281
+ detailLines.push(statusMessages.join(styleText('gray', ' | ')));
282
+ }
283
+
284
+ const hasTitleOrUrl = Boolean(titleLine || urlLine);
285
+ const titleWidth = getVisibleTextLength(titleLine);
286
+ const urlWidth = getVisibleTextLength(urlLine);
287
+ const topLineCount = hasTitleOrUrl
288
+ ? (titleLine && urlLine
289
+ ? (titleWidth + headerColumnGap + urlWidth <= innerWidth
290
+ ? 1
291
+ : getWrappedLineCount(titleLine, innerWidth) + getWrappedLineCount(urlLine, innerWidth))
292
+ : getWrappedLineCount(titleLine || urlLine, innerWidth))
293
+ : 0;
294
+ const detailLineCount = detailLines.reduce((count, line) => count + getWrappedLineCount(line, innerWidth), 0);
295
+
296
+ return {
297
+ titleLine,
298
+ urlLine,
299
+ detailLines,
300
+ lineCount: topLineCount + detailLineCount
301
+ };
236
302
  }
237
303
 
238
304
  setURLs(local, external) {
@@ -325,7 +391,7 @@ class TUI {
325
391
  return [
326
392
  this._activePrompt.prompt,
327
393
  `${styleText('gray', '>')} ${this._activePrompt.value}${cursor}`,
328
- styleText('gray', 'Type your value, Enter to submit, Esc/q to cancel.')
394
+ styleText('gray', 'Type your value, Enter to submit, Esc to cancel.')
329
395
  ];
330
396
  }
331
397
 
@@ -375,7 +441,7 @@ class TUI {
375
441
  resolve(value);
376
442
  return;
377
443
  }
378
- if (key.escape || input === 'q') {
444
+ if (key.escape) {
379
445
  const resolve = this._activePrompt.resolve;
380
446
  this._activePrompt = null;
381
447
  this.render();
@@ -489,6 +555,7 @@ class TUI {
489
555
  this.isMouseEnabled = true;
490
556
  this._activePrompt = null;
491
557
  this._logScrollOffset = 0;
558
+ this._isInitialLoading = false;
492
559
 
493
560
  if (process.stdout.isTTY) {
494
561
  process.stdout.write('\x1b[?25h');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "5.6.1",
3
+ "version": "5.6.3",
4
4
  "description": "Custom WordPress build process.",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -22,28 +22,31 @@
22
22
  "sdc-build-wp": "./index.js"
23
23
  },
24
24
  "dependencies": {
25
- "@stylistic/eslint-plugin": "^5.6.1",
26
- "@stylistic/stylelint-plugin": "^4.0.0",
27
- "@typescript-eslint/eslint-plugin": "^8.48.1",
28
- "@typescript-eslint/parser": "^8.48.1",
29
- "@wordpress/scripts": "^31.4.0",
25
+ "@mishieck/ink-titled-box": "^0.4.2",
26
+ "@stylistic/eslint-plugin": "^5.10.0",
27
+ "@stylistic/stylelint-plugin": "^5.0.1",
28
+ "@typescript-eslint/eslint-plugin": "^8.57.0",
29
+ "@typescript-eslint/parser": "^8.57.1",
30
+ "@wordpress/scripts": "^31.6.0",
30
31
  "ajv": "^8.18.0",
31
- "autoprefixer": "^10.4.24",
32
+ "autoprefixer": "^10.4.27",
32
33
  "browser-sync": "^3.0.4",
33
34
  "chokidar": "^5.0.0",
34
- "esbuild": "^0.27.3",
35
- "eslint": "^9.39.1",
35
+ "esbuild": "^0.27.4",
36
+ "eslint": "^10.0.3",
36
37
  "ink": "^6.8.0",
37
- "postcss": "^8.5.6",
38
+ "ink-spinner": "^5.0.0",
39
+ "postcss": "^8.5.8",
38
40
  "postcss-scss": "^4.0.9",
39
- "postcss-sort-media-queries": "^5.2.0",
41
+ "postcss-sort-media-queries": "^6.3.2",
40
42
  "prettier": "^3.8.1",
41
43
  "react": "^19.2.4",
42
44
  "react-dom": "^19.2.4",
43
- "sass": "^1.97.3",
45
+ "sass": "^1.98.0",
44
46
  "sharp": "^0.34.5",
45
- "stylelint": "^16.26.1",
46
- "svgo": "^4.0.0",
47
+ "stylelint": "^17.4.0",
48
+ "stylelint-use-logical": "^2.1.3",
49
+ "svgo": "^4.0.1",
47
50
  "tail": "^2.2.6",
48
51
  "yargs": "^18.0.0"
49
52
  }