sdc-build-wp 5.3.1 → 5.3.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/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 +10 -4
- package/lib/tui.js +3 -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
|
|
|
@@ -362,13 +367,14 @@ async function handleCreateNew() {
|
|
|
362
367
|
export async function convertPackageToConfig() {
|
|
363
368
|
if (!project.package.sdc) { return; }
|
|
364
369
|
try {
|
|
370
|
+
await fs.mkdir(project.sdcDir, { recursive: true });
|
|
365
371
|
await fs.writeFile(configPath, JSON.stringify(project.package.sdc, null, '\t'));
|
|
366
|
-
log('success',
|
|
372
|
+
log('success', `Converted package.json sdc to ${path.basename(project.sdcDir)}/${project.configFileName}`);
|
|
367
373
|
delete project.package.sdc;
|
|
368
374
|
await fs.writeFile(path.join(project.path, 'package.json'), JSON.stringify(project.package, null, '\t'));
|
|
369
375
|
log('success', 'Updated package.json to remove sdc');
|
|
370
376
|
} catch (error) {
|
|
371
|
-
log('error', `Failed to convert package.json sdc to .
|
|
377
|
+
log('error', `Failed to convert package.json sdc to ${path.basename(project.sdcDir)}/${project.configFileName}: ${error.message}`);
|
|
372
378
|
process.exit(1);
|
|
373
379
|
}
|
|
374
380
|
}
|
package/lib/tui.js
CHANGED
|
@@ -21,6 +21,9 @@ 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
|
|
|
@@ -131,9 +134,6 @@ class TUI {
|
|
|
131
134
|
const lines = [];
|
|
132
135
|
|
|
133
136
|
let titleLine = ' ' + chalk.bold.blue('SDC Build WP');
|
|
134
|
-
if (this.watchMode) {
|
|
135
|
-
titleLine += chalk.gray(' (watch mode)');
|
|
136
|
-
}
|
|
137
137
|
if (this.isPaused) {
|
|
138
138
|
titleLine += chalk.bold.yellow(' [PAUSED]');
|
|
139
139
|
}
|