sdc-build-wp 3.3.0 → 3.4.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/index.js CHANGED
@@ -5,7 +5,10 @@ import parseArgs from 'minimist';
5
5
  const argv = parseArgs(process.argv.slice(2));
6
6
  import chokidar from 'chokidar';
7
7
  import { glob, globSync } from 'glob';
8
+ import { existsSync } from 'node:fs';
9
+ import { Tail } from 'tail';
8
10
 
11
+ import log from './lib/logging.js';
9
12
  import bustCache from './lib/bustCache.js';
10
13
  import { buildSass, buildSassTheme } from './lib/style.js';
11
14
  import buildJS from './lib/scripts.js';
@@ -50,6 +53,28 @@ function frontrunImages() {
50
53
  });
51
54
  }
52
55
 
56
+ function runBlocks() {
57
+ for (var block of blockGlob) {
58
+ buildBlock(block);
59
+ }
60
+ bustFunctionsCache();
61
+ }
62
+
63
+ function runSass() {
64
+ buildSassTheme();
65
+ for (var block of filesSass) {
66
+ buildSass(block.file, block.name, sassGlob);
67
+ bustFunctionsCache();
68
+ }
69
+ }
70
+
71
+ function runJS() {
72
+ for (var block of filesJS) {
73
+ buildJS(block.file, block.name, jsGlob);
74
+ bustFunctionsCache();
75
+ }
76
+ }
77
+
53
78
  let entries = {};
54
79
  for (const [name, files] of Object.entries(project.package.sdc.entries)) {
55
80
  entries[name] = [];
@@ -84,64 +109,36 @@ for (const [name, files] of Object.entries(entries)) {
84
109
  });
85
110
  }
86
111
 
87
- function runBlocks() {
88
- for (var block of blockGlob) {
89
- buildBlock(block);
90
- }
91
- bustFunctionsCache();
92
- }
93
-
94
112
  runBlocks();
113
+ runSass();
114
+ runJS();
115
+ frontrunImages()
116
+ buildFonts(project.path + '/_src/fonts');
117
+
95
118
  if (argv.watch) {
119
+ buildBrowserSync();
96
120
  chokidar.watch(blockGlob, chokidarOpts).on('all', (event, path) => {
97
121
  runBlocks();
98
122
  });
99
- }
100
-
101
- function runSass() {
102
- buildSassTheme();
103
- for (var block of filesSass) {
104
- buildSass(block.file, block.name, sassGlob);
105
- bustFunctionsCache();
106
- }
107
- }
108
-
109
- runSass();
110
- if (argv.watch) {
111
123
  chokidar.watch(sassGlob, chokidarOpts).on('all', (event, path) => {
112
124
  runSass();
113
125
  });
114
- }
115
-
116
- function runJS() {
117
- for (var block of filesJS) {
118
- buildJS(block.file, block.name, jsGlob);
119
- bustFunctionsCache();
120
- }
121
- }
122
-
123
- runJS();
124
- if (argv.watch) {
125
- chokidar.watch(jsGlob, chokidarOpts).on('all', (event, path) => {
126
- runJS();
127
- });
128
- }
129
-
130
- if (argv.watch) {
131
126
  chokidar.watch(project.path + '/theme.json', chokidarOpts).on('all', (event, path) => {
132
127
  runSass();
133
128
  });
134
- }
135
-
136
- frontrunImages()
137
- if (argv.watch) {
129
+ chokidar.watch(jsGlob, chokidarOpts).on('all', (event, path) => {
130
+ runJS();
131
+ });
138
132
  chokidar.watch(project.path + '/_src/images/**/*', chokidarOpts).on('all', (event, path) => {
139
133
  frontrunImages();
140
134
  });
141
- }
142
-
143
- buildFonts(project.path + '/_src/fonts');
144
-
145
- if (argv.watch) {
146
- buildBrowserSync();
135
+ let errorLogPath = process.env.ERROR_LOG_PATH || project.package.sdc?.error_log_path || '../../../../../logs/php/error.log';
136
+ if (existsSync(errorLogPath)) {
137
+ let errorLogTail = new Tail(errorLogPath);
138
+ errorLogTail.on('line', function(data) {
139
+ log('php', data);
140
+ });
141
+ } else {
142
+ log('info', `Cannot find error log @ ${errorLogPath}. Skipping watching php error logs`);
143
+ }
147
144
  }
@@ -27,6 +27,14 @@ const buildBrowserSync = () => {
27
27
  bottom: '0',
28
28
  borderRadius: '5px 0px 0px'
29
29
  }
30
+ },
31
+ snippetOptions: {
32
+ rule: {
33
+ match: /<\/body>/i,
34
+ fn: function (snippet, match) {
35
+ return snippet + match;
36
+ }
37
+ }
30
38
  }
31
39
  });
32
40
  };
package/lib/logging.js CHANGED
@@ -32,6 +32,13 @@ function log(type, ...messages) {
32
32
  ...messages
33
33
  );
34
34
  break;
35
+ case 'php':
36
+ console.log.call(
37
+ console,
38
+ chalk.blue('ℹ'),
39
+ ...messages
40
+ );
41
+ break;
35
42
  case 'info':
36
43
  default:
37
44
  console.log.call(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Custom WordPress build process.",
5
5
  "engines": {
6
6
  "node": "^20"
@@ -41,6 +41,7 @@
41
41
  "postcss-scss": "^4.0.9",
42
42
  "postcss-sort-media-queries": "^5.2.0",
43
43
  "sass": "^1.75.0",
44
- "stylelint": "^16.4.0"
44
+ "stylelint": "^16.4.0",
45
+ "tail": "^2.2.6"
45
46
  }
46
47
  }