sdc-build-wp 5.3.1 → 5.3.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/lib/components/cache.js +6 -5
- package/lib/components/errors.js +6 -0
- package/lib/components/server.js +1 -1
- package/lib/help.js +1 -1
- package/lib/project.js +59 -7
- package/lib/tui.js +21 -3
- package/package.json +1 -1
package/lib/components/cache.js
CHANGED
|
@@ -8,7 +8,7 @@ export default class CacheComponent extends BaseComponent {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
10
|
this.description = 'Build caching';
|
|
11
|
-
this.cacheDir =
|
|
11
|
+
this.cacheDir = this.project.cacheDir;
|
|
12
12
|
this.manifestPath = `${this.cacheDir}/manifest.json`;
|
|
13
13
|
this.manifest = {};
|
|
14
14
|
this.hashCache = new Map();
|
|
@@ -47,6 +47,7 @@ export default class CacheComponent extends BaseComponent {
|
|
|
47
47
|
|
|
48
48
|
async ensureGitignore() {
|
|
49
49
|
const gitignorePath = path.join(this.project.path, '.gitignore');
|
|
50
|
+
const cacheIgnoreEntry = `${path.basename(this.project.sdcDir)}/${path.basename(this.cacheDir)}/`;
|
|
50
51
|
|
|
51
52
|
try {
|
|
52
53
|
let gitignoreContent = '';
|
|
@@ -60,16 +61,16 @@ export default class CacheComponent extends BaseComponent {
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
const lines = gitignoreContent.split('\n');
|
|
63
|
-
let hasSDCBuild = lines.some(line => line.trim() ===
|
|
64
|
+
let hasSDCBuild = lines.some(line => line.trim() === cacheIgnoreEntry);
|
|
64
65
|
let needsUpdate = false;
|
|
65
66
|
|
|
66
67
|
if (!hasSDCBuild) {
|
|
67
68
|
if (gitignoreContent && !gitignoreContent.endsWith('\n')) {
|
|
68
69
|
gitignoreContent += '\n';
|
|
69
70
|
}
|
|
70
|
-
gitignoreContent +=
|
|
71
|
+
gitignoreContent += `${cacheIgnoreEntry}\n`;
|
|
71
72
|
needsUpdate = true;
|
|
72
|
-
this.log('info',
|
|
73
|
+
this.log('info', `Added ${cacheIgnoreEntry} to .gitignore`);
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
if (needsUpdate || !gitignoreExists) {
|
|
@@ -277,7 +278,7 @@ export default class CacheComponent extends BaseComponent {
|
|
|
277
278
|
async watch() {
|
|
278
279
|
this.watcher = this.chokidar.watch([
|
|
279
280
|
`${this.project.path}/**/*`,
|
|
280
|
-
`!${this.project.
|
|
281
|
+
`!${this.project.sdcDir}/**/*`,
|
|
281
282
|
`!${this.project.paths.nodeModules}/**/*`,
|
|
282
283
|
`!${this.project.paths.composer.vendor}/**/*`,
|
|
283
284
|
`!${this.project.path}/.git/**/*`
|
package/lib/components/errors.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BaseComponent from './base.js';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
import fs from 'fs-extra';
|
|
3
4
|
import { Tail } from 'tail';
|
|
4
5
|
|
|
@@ -23,6 +24,11 @@ export default class ErrorsComponent extends BaseComponent {
|
|
|
23
24
|
|
|
24
25
|
async watch() {
|
|
25
26
|
let component = this;
|
|
27
|
+
try {
|
|
28
|
+
await fs.access(this.project.paths.errorLog);
|
|
29
|
+
} catch {
|
|
30
|
+
await fs.ensureFile(path.resolve(this.project.paths.errorLog));
|
|
31
|
+
}
|
|
26
32
|
try {
|
|
27
33
|
await fs.access(this.project.paths.errorLog);
|
|
28
34
|
new Tail(this.project.paths.errorLog).on('line', function(data) {
|
package/lib/components/server.js
CHANGED
|
@@ -16,7 +16,7 @@ export default class ServerComponent extends BaseComponent {
|
|
|
16
16
|
this.server = create('SDC WP Build Server');
|
|
17
17
|
this.watchedFiles = [];
|
|
18
18
|
this.ignoredFiles = [
|
|
19
|
-
|
|
19
|
+
`${this.project.cacheDir}/**`,
|
|
20
20
|
`node_modules/**`,
|
|
21
21
|
`vendor/**/*`,
|
|
22
22
|
`**/*.map`
|
package/lib/help.js
CHANGED
|
@@ -45,7 +45,7 @@ ${chalk.yellow('Watch Mode Controls:')}
|
|
|
45
45
|
${chalk.green('[q]')} Quit and exit
|
|
46
46
|
|
|
47
47
|
${chalk.yellow('Configuration:')}
|
|
48
|
-
Place your configuration in ${chalk.cyan(
|
|
48
|
+
Place your configuration in ${chalk.cyan(`${project.sdcDirName}/${project.configFileName}`)}
|
|
49
49
|
See documentation for available options.
|
|
50
50
|
`);
|
|
51
51
|
}
|
package/lib/project.js
CHANGED
|
@@ -29,7 +29,12 @@ let project = {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
project.sdcDirName = '.sdc-build-wp';
|
|
33
|
+
project.cacheDirName = 'cache';
|
|
34
|
+
project.configFileName = 'config.json';
|
|
35
|
+
project.sdcDir = path.join(project.path, project.sdcDirName);
|
|
36
|
+
project.cacheDir = path.join(project.sdcDir, project.cacheDirName);
|
|
37
|
+
const configPath = path.join(project.sdcDir, project.configFileName);
|
|
33
38
|
|
|
34
39
|
project.paths = {
|
|
35
40
|
src: {
|
|
@@ -66,7 +71,7 @@ project.chokidarOpts = {
|
|
|
66
71
|
`${project.paths.composer.vendor}/**/*`,
|
|
67
72
|
project.paths.theme.scss,
|
|
68
73
|
`${project.path}/blocks/*/build/*.php`,
|
|
69
|
-
`${project.
|
|
74
|
+
`${project.cacheDir}/**/*`,
|
|
70
75
|
]
|
|
71
76
|
};
|
|
72
77
|
|
|
@@ -148,6 +153,24 @@ export async function init() {
|
|
|
148
153
|
process.on('uncaughtException', async (error) => {
|
|
149
154
|
log('error', `Uncaught Exception: ${error.message}`);
|
|
150
155
|
log('warn', 'Attempting graceful shutdown');
|
|
156
|
+
|
|
157
|
+
// Clean up terminal state
|
|
158
|
+
if (process.stdin.isTTY) {
|
|
159
|
+
try {
|
|
160
|
+
process.stdin.setRawMode(false);
|
|
161
|
+
process.stdin.pause();
|
|
162
|
+
process.stdin.removeAllListeners('data');
|
|
163
|
+
} catch (e) {
|
|
164
|
+
// Ignore errors
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (process.stdout.isTTY) {
|
|
169
|
+
process.stdout.write('\x1b[?25h');
|
|
170
|
+
process.stdout.write('\x1b[0m');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
tui.destroy();
|
|
151
174
|
await utils.stopActiveComponents();
|
|
152
175
|
process.exit(1);
|
|
153
176
|
});
|
|
@@ -162,7 +185,19 @@ export async function init() {
|
|
|
162
185
|
await project.configWatcher.close();
|
|
163
186
|
project.configWatcher = null;
|
|
164
187
|
}
|
|
188
|
+
|
|
189
|
+
if (process.stdin.isTTY) {
|
|
190
|
+
try {
|
|
191
|
+
process.stdin.setRawMode(false);
|
|
192
|
+
} catch (e) {
|
|
193
|
+
// Ignore errors if raw mode is already off
|
|
194
|
+
}
|
|
195
|
+
process.stdin.pause();
|
|
196
|
+
process.stdin.removeAllListeners('data');
|
|
197
|
+
}
|
|
198
|
+
|
|
165
199
|
tui.destroy();
|
|
200
|
+
|
|
166
201
|
if (tui.getLogHistory) {
|
|
167
202
|
const logDump = tui.getLogHistory();
|
|
168
203
|
if (logDump && logDump.trim()) {
|
|
@@ -170,13 +205,29 @@ export async function init() {
|
|
|
170
205
|
}
|
|
171
206
|
}
|
|
172
207
|
log('info', `Exited sdc-build-wp`);
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
process.
|
|
208
|
+
|
|
209
|
+
if (process.stdout.isTTY) {
|
|
210
|
+
process.stdout.write('\x1b[?25h');
|
|
211
|
+
process.stdout.write('\x1b[0m');
|
|
176
212
|
}
|
|
213
|
+
|
|
177
214
|
setTimeout(() => process.exit(0), 100);
|
|
178
215
|
});
|
|
179
216
|
|
|
217
|
+
process.on('exit', () => {
|
|
218
|
+
if (process.stdin.isTTY) {
|
|
219
|
+
try {
|
|
220
|
+
process.stdin.setRawMode(false);
|
|
221
|
+
} catch (e) {
|
|
222
|
+
// Ignore errors
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (process.stdout.isTTY) {
|
|
226
|
+
process.stdout.write('\x1b[?25h');
|
|
227
|
+
process.stdout.write('\x1b[0m');
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
|
|
180
231
|
}
|
|
181
232
|
|
|
182
233
|
export function keypressListen() {
|
|
@@ -362,13 +413,14 @@ async function handleCreateNew() {
|
|
|
362
413
|
export async function convertPackageToConfig() {
|
|
363
414
|
if (!project.package.sdc) { return; }
|
|
364
415
|
try {
|
|
416
|
+
await fs.mkdir(project.sdcDir, { recursive: true });
|
|
365
417
|
await fs.writeFile(configPath, JSON.stringify(project.package.sdc, null, '\t'));
|
|
366
|
-
log('success',
|
|
418
|
+
log('success', `Converted package.json sdc to ${path.basename(project.sdcDir)}/${project.configFileName}`);
|
|
367
419
|
delete project.package.sdc;
|
|
368
420
|
await fs.writeFile(path.join(project.path, 'package.json'), JSON.stringify(project.package, null, '\t'));
|
|
369
421
|
log('success', 'Updated package.json to remove sdc');
|
|
370
422
|
} catch (error) {
|
|
371
|
-
log('error', `Failed to convert package.json sdc to .
|
|
423
|
+
log('error', `Failed to convert package.json sdc to ${path.basename(project.sdcDir)}/${project.configFileName}: ${error.message}`);
|
|
372
424
|
process.exit(1);
|
|
373
425
|
}
|
|
374
426
|
}
|
package/lib/tui.js
CHANGED
|
@@ -21,9 +21,17 @@ class TUI {
|
|
|
21
21
|
|
|
22
22
|
init() {
|
|
23
23
|
if (this.isInitialized) {
|
|
24
|
+
// If already initialized, redraw the header to reflect current state
|
|
25
|
+
this.updateHeader();
|
|
26
|
+
this.render();
|
|
24
27
|
return;
|
|
25
28
|
}
|
|
26
29
|
|
|
30
|
+
if (process.stdout.isTTY) {
|
|
31
|
+
process.stdout.write('\x1b[?25h');
|
|
32
|
+
process.stdout.write('\x1b[0m');
|
|
33
|
+
}
|
|
34
|
+
|
|
27
35
|
this.screen = blessed.screen({
|
|
28
36
|
smartCSR: true,
|
|
29
37
|
fullUnicode: true,
|
|
@@ -131,9 +139,6 @@ class TUI {
|
|
|
131
139
|
const lines = [];
|
|
132
140
|
|
|
133
141
|
let titleLine = ' ' + chalk.bold.blue('SDC Build WP');
|
|
134
|
-
if (this.watchMode) {
|
|
135
|
-
titleLine += chalk.gray(' (watch mode)');
|
|
136
|
-
}
|
|
137
142
|
if (this.isPaused) {
|
|
138
143
|
titleLine += chalk.bold.yellow(' [PAUSED]');
|
|
139
144
|
}
|
|
@@ -332,11 +337,24 @@ class TUI {
|
|
|
332
337
|
|
|
333
338
|
destroy() {
|
|
334
339
|
if (this.isInitialized && this.screen) {
|
|
340
|
+
if (this.screen.program) {
|
|
341
|
+
this.screen.program.showCursor();
|
|
342
|
+
this.screen.program.normalBuffer();
|
|
343
|
+
this.screen.program.reset();
|
|
344
|
+
}
|
|
345
|
+
|
|
335
346
|
this.screen.destroy();
|
|
336
347
|
this.isInitialized = false;
|
|
337
348
|
this.screen = null;
|
|
338
349
|
this.headerBox = null;
|
|
339
350
|
this.logBox = null;
|
|
351
|
+
|
|
352
|
+
if (process.stdout.isTTY) {
|
|
353
|
+
process.stdout.write('\x1b[?25h');
|
|
354
|
+
process.stdout.write('\x1b[0m');
|
|
355
|
+
process.stdout.write('\x1b[2J');
|
|
356
|
+
process.stdout.write('\x1b[H');
|
|
357
|
+
}
|
|
340
358
|
}
|
|
341
359
|
}
|
|
342
360
|
}
|