sdc-build-wp 5.6.0 → 5.6.1

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.
@@ -1,6 +1,7 @@
1
+ import { fileURLToPath } from 'url';
1
2
  import BaseComponent from './base.js';
2
- import { access, stat, readFile } from 'fs/promises';
3
- import { execFile } from 'child_process';
3
+ import { stat, readFile } from 'fs/promises';
4
+ import { exec } from 'child_process';
4
5
  import { promisify } from 'util';
5
6
  import { createHash } from 'crypto';
6
7
 
@@ -9,31 +10,6 @@ export default class BlocksComponent extends BaseComponent {
9
10
  constructor() {
10
11
  super();
11
12
  this.description = `Process the theme's WordPress blocks`;
12
- this._didLogWpScriptsFallback = false;
13
- }
14
-
15
- async getWpScriptsRunner() {
16
- const localWpScripts = `${this.project.path}/node_modules/@wordpress/scripts/bin/wp-scripts.js`;
17
-
18
- try {
19
- await access(localWpScripts);
20
- return {
21
- command: process.execPath,
22
- baseArgs: [localWpScripts]
23
- };
24
- } catch {
25
- if (!this._didLogWpScriptsFallback) {
26
- this.log('info', 'Using temporary @wordpress/scripts via npx for block builds');
27
- this._didLogWpScriptsFallback = true;
28
- }
29
-
30
- const npxCommand = process.platform === 'win32' ? 'npx.cmd' : 'npx';
31
-
32
- return {
33
- command: npxCommand,
34
- baseArgs: ['--yes', '--package', '@wordpress/scripts@31', 'wp-scripts']
35
- };
36
- }
37
13
  }
38
14
 
39
15
  async init() {
@@ -156,17 +132,17 @@ export default class BlocksComponent extends BaseComponent {
156
132
  this.clearHashCache([workingBlockJson, ...dependencies]);
157
133
 
158
134
  try {
159
- const runner = await this.getWpScriptsRunner();
160
- const args = [
161
- ...runner.baseArgs,
162
- 'build',
135
+ const cmds = [
136
+ `${this.project.path}/node_modules/@wordpress/scripts/bin/wp-scripts.js`,
137
+ `build`,
163
138
  `--source-path=.${entry.replace(this.project.path, '')}/src`,
164
139
  `--output-path=.${entry.replace(this.project.path, '')}/build`,
165
- '--webpack-copy-php'
140
+ `--webpack-copy-php`,
141
+ `--config=${this.path.resolve(this.path.dirname(fileURLToPath(import.meta.url)), '../../webpack.config.js')}`,
166
142
  ];
167
- const execFilePromise = promisify(execFile);
143
+ const execPromise = promisify(exec);
168
144
  const timeoutMS = 40000;
169
- const buildPromise = execFilePromise(runner.command, args, {
145
+ const buildPromise = execPromise(cmds.join(' '), {
170
146
  maxBuffer: 1024 * 1024 * 10,
171
147
  cwd: this.project.path
172
148
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sdc-build-wp",
3
- "version": "5.6.0",
3
+ "version": "5.6.1",
4
4
  "description": "Custom WordPress build process.",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -26,6 +26,8 @@
26
26
  "@stylistic/stylelint-plugin": "^4.0.0",
27
27
  "@typescript-eslint/eslint-plugin": "^8.48.1",
28
28
  "@typescript-eslint/parser": "^8.48.1",
29
+ "@wordpress/scripts": "^31.4.0",
30
+ "ajv": "^8.18.0",
29
31
  "autoprefixer": "^10.4.24",
30
32
  "browser-sync": "^3.0.4",
31
33
  "chokidar": "^5.0.0",
package/webpack.config.js CHANGED
@@ -1,11 +1,4 @@
1
- let defaultConfig = {};
2
-
3
- try {
4
- const wpConfig = await import('@wordpress/scripts/config/webpack.config.js');
5
- defaultConfig = wpConfig.default || {};
6
- } catch {
7
- defaultConfig = {};
8
- }
1
+ import defaultConfig from '@wordpress/scripts/config/webpack.config.js';
9
2
 
10
3
  export default {
11
4
  ...defaultConfig,