sdc-build-wp 4.3.0 → 4.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/README.md +1 -0
- package/index.js +34 -12
- package/lib/components/base.js +1 -1
- package/lib/components/blocks.js +2 -4
- package/lib/components/fonts.js +2 -4
- package/lib/components/images.js +2 -4
- package/lib/components/php.js +2 -4
- package/lib/components/scripts.js +2 -4
- package/lib/components/server.js +2 -4
- package/lib/components/style.js +2 -4
- package/lib/project.js +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -1,35 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import parseArgs from 'minimist';
|
|
3
3
|
const argv = parseArgs(process.argv.slice(2));
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
4
6
|
import { promises as fs } from 'fs';
|
|
5
7
|
import { Tail } from 'tail';
|
|
6
8
|
import project from './lib/project.js';
|
|
7
9
|
import log from './lib/logging.js';
|
|
8
10
|
import * as LibComponents from './lib/components/index.js';
|
|
9
11
|
|
|
10
|
-
project.components =
|
|
11
|
-
style: new LibComponents.style(),
|
|
12
|
-
scripts: new LibComponents.scripts(),
|
|
13
|
-
blocks: new LibComponents.blocks(),
|
|
14
|
-
images: new LibComponents.images(),
|
|
15
|
-
fonts: new LibComponents.fonts(),
|
|
16
|
-
php: new LibComponents.php(),
|
|
17
|
-
server: new LibComponents.server()
|
|
18
|
-
};
|
|
12
|
+
project.components = Object.fromEntries(Object.entries(LibComponents).map(([name, Class]) => [name, new Class()]));
|
|
19
13
|
|
|
20
|
-
|
|
14
|
+
if (argv.help || argv.h) {
|
|
15
|
+
console.log(`
|
|
16
|
+
Usage: sdc-build-wp [options] [arguments]
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
-h, --help Show help message and exit
|
|
20
|
+
-v, --version Version
|
|
21
|
+
-w, --watch Build and watch
|
|
22
|
+
-b, --build BUILDS Build with specific components
|
|
23
|
+
|
|
24
|
+
Components:
|
|
25
|
+
|
|
26
|
+
${Object.entries(project.components).map(([key, component]) => {
|
|
27
|
+
return `${key}\t\t${component.description}\r\n`;
|
|
28
|
+
}).join('')}
|
|
29
|
+
Examples:
|
|
30
|
+
|
|
31
|
+
sdc-build-wp
|
|
32
|
+
sdc-build-wp --watch
|
|
33
|
+
sdc-build-wp --watch --builds=style,scripts
|
|
34
|
+
`);
|
|
35
|
+
|
|
36
|
+
process.exit(0);
|
|
37
|
+
} else if (argv.version || argv.v) {
|
|
38
|
+
console.log(JSON.parse(await fs.readFile(path.join(path.dirname(fileURLToPath(import.meta.url)), 'package.json'))).version);
|
|
39
|
+
process.exit(0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
project.builds = argv.builds ? argv.builds.split(',') : Object.keys(project.components);
|
|
21
43
|
|
|
22
44
|
(async() => {
|
|
23
45
|
|
|
24
46
|
let initialBuildTimerStart = Date.now();
|
|
25
47
|
log('info', `Starting initial build`);
|
|
26
|
-
for (let build of builds) {
|
|
48
|
+
for (let build of project.builds) {
|
|
27
49
|
await project.components[build].init();
|
|
28
50
|
}
|
|
29
51
|
log('info', `Finished initial build in ${Math.round((Date.now() - initialBuildTimerStart) / 1000)} seconds`);
|
|
30
52
|
|
|
31
53
|
if (argv.watch) {
|
|
32
|
-
for (let build of builds) {
|
|
54
|
+
for (let build of project.builds) {
|
|
33
55
|
await project.components[build].watch();
|
|
34
56
|
}
|
|
35
57
|
try {
|
package/lib/components/base.js
CHANGED
|
@@ -8,6 +8,7 @@ import { glob } from 'node:fs/promises';
|
|
|
8
8
|
class BaseComponent {
|
|
9
9
|
|
|
10
10
|
constructor() {
|
|
11
|
+
this.description = '';
|
|
11
12
|
this.timer = null;
|
|
12
13
|
this.path = path;
|
|
13
14
|
this.utils = utils;
|
|
@@ -17,7 +18,6 @@ class BaseComponent {
|
|
|
17
18
|
this.glob = glob;
|
|
18
19
|
this.files = [];
|
|
19
20
|
this.globs = [];
|
|
20
|
-
this.slug = 'base';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async init() {
|
package/lib/components/blocks.js
CHANGED
|
@@ -3,11 +3,11 @@ import { stat } from 'fs/promises';
|
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import process from 'process';
|
|
5
5
|
|
|
6
|
-
class BlocksComponent extends BaseComponent {
|
|
6
|
+
export default class BlocksComponent extends BaseComponent {
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
-
this.
|
|
10
|
+
this.description = `Process the theme's WordPress blocks`;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async init() {
|
|
@@ -108,5 +108,3 @@ function cmd(commands) {
|
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
|
|
112
|
-
export { BlocksComponent as default }
|
package/lib/components/fonts.js
CHANGED
|
@@ -2,11 +2,11 @@ import BaseComponent from './base.js';
|
|
|
2
2
|
import { readdir } from 'fs/promises';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
|
|
5
|
-
class FontsComponent extends BaseComponent {
|
|
5
|
+
export default class FontsComponent extends BaseComponent {
|
|
6
6
|
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
|
-
this.
|
|
9
|
+
this.description = `Copy font files`;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
async init() {
|
|
@@ -37,5 +37,3 @@ class FontsComponent extends BaseComponent {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
export { FontsComponent as default }
|
package/lib/components/images.js
CHANGED
|
@@ -4,11 +4,11 @@ import imageminJpegtran from 'imagemin-jpegtran';
|
|
|
4
4
|
import imageminPngquant from 'imagemin-pngquant';
|
|
5
5
|
import imageminSvgo from 'imagemin-svgo';
|
|
6
6
|
|
|
7
|
-
class ImagesComponent extends BaseComponent {
|
|
7
|
+
export default class ImagesComponent extends BaseComponent {
|
|
8
8
|
|
|
9
9
|
constructor() {
|
|
10
10
|
super();
|
|
11
|
-
this.
|
|
11
|
+
this.description = `Compress image files`;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async init() {
|
|
@@ -56,5 +56,3 @@ class ImagesComponent extends BaseComponent {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
export { ImagesComponent as default }
|
package/lib/components/php.js
CHANGED
|
@@ -3,11 +3,11 @@ import { fileURLToPath } from 'url';
|
|
|
3
3
|
import { exec } from 'child_process';
|
|
4
4
|
import { promisify } from 'util';
|
|
5
5
|
|
|
6
|
-
class PHPComponent extends BaseComponent {
|
|
6
|
+
export default class PHPComponent extends BaseComponent {
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
-
this.
|
|
10
|
+
this.description = `Lint (and fix) php files`;
|
|
11
11
|
this.execPromise = promisify(exec);
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -103,5 +103,3 @@ class PHPComponent extends BaseComponent {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
export { PHPComponent as default }
|
|
@@ -3,11 +3,11 @@ import * as esbuild from 'esbuild';
|
|
|
3
3
|
import { ESLint } from 'eslint';
|
|
4
4
|
import * as eslintConfig from '../../eslint.config.js';
|
|
5
5
|
|
|
6
|
-
class ScriptsComponent extends BaseComponent {
|
|
6
|
+
export default class ScriptsComponent extends BaseComponent {
|
|
7
7
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
10
|
-
this.
|
|
10
|
+
this.description = `Process javascript files`;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
async init() {
|
|
@@ -83,5 +83,3 @@ class ScriptsComponent extends BaseComponent {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
export { ScriptsComponent as default }
|
package/lib/components/server.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import BaseComponent from './base.js';
|
|
2
2
|
import { create as bsCreate } from 'browser-sync';
|
|
3
3
|
|
|
4
|
-
class ServerComponent extends BaseComponent {
|
|
4
|
+
export default class ServerComponent extends BaseComponent {
|
|
5
5
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super();
|
|
8
|
-
this.
|
|
8
|
+
this.description = `Run a dev proxy server for live reloading`;
|
|
9
9
|
this.server = bsCreate();
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -66,5 +66,3 @@ class ServerComponent extends BaseComponent {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
export { ServerComponent as default }
|
package/lib/components/style.js
CHANGED
|
@@ -8,11 +8,11 @@ import autoprefixer from 'autoprefixer';
|
|
|
8
8
|
import sortMQ from 'postcss-sort-media-queries';
|
|
9
9
|
import stylelint from 'stylelint';
|
|
10
10
|
|
|
11
|
-
class StyleComponent extends BaseComponent {
|
|
11
|
+
export default class StyleComponent extends BaseComponent {
|
|
12
12
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
|
-
this.
|
|
15
|
+
this.description = `Process sass files`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
async init() {
|
|
@@ -194,5 +194,3 @@ class StyleComponent extends BaseComponent {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
}
|
|
197
|
-
|
|
198
|
-
export { StyleComponent as default }
|
package/lib/project.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sdc-build-wp",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.2",
|
|
4
4
|
"description": "Custom WordPress build process.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@stylistic/stylelint-plugin": "^3.1.2",
|
|
26
|
-
"@wordpress/scripts": "^30.
|
|
26
|
+
"@wordpress/scripts": "^30.12.0",
|
|
27
27
|
"autoprefixer": "^10.4.20",
|
|
28
28
|
"browser-sync": "^3.0.3",
|
|
29
29
|
"chalk": "^5.4.1",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"postcss": "^8.5.3",
|
|
40
40
|
"postcss-scss": "^4.0.9",
|
|
41
41
|
"postcss-sort-media-queries": "^5.2.0",
|
|
42
|
-
"sass": "^1.85.
|
|
43
|
-
"stylelint": "^16.
|
|
42
|
+
"sass": "^1.85.1",
|
|
43
|
+
"stylelint": "^16.15.0",
|
|
44
44
|
"tail": "^2.2.6"
|
|
45
45
|
}
|
|
46
46
|
}
|