@wordpress-flow/cli 1.0.8 → 1.0.10
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/dist/build/block-build-worker.js +47 -6
- package/dist/index.js +70 -35
- package/package.json +1 -1
|
@@ -1835,7 +1835,7 @@ import { parentPort, workerData } from "worker_threads";
|
|
|
1835
1835
|
import * as path from "path";
|
|
1836
1836
|
import * as fs from "fs";
|
|
1837
1837
|
import * as esbuild from "esbuild";
|
|
1838
|
-
import {
|
|
1838
|
+
import { spawnSync } from "child_process";
|
|
1839
1839
|
async function buildBlock() {
|
|
1840
1840
|
const { block, outputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
|
|
1841
1841
|
try {
|
|
@@ -1859,10 +1859,35 @@ async function buildBlock() {
|
|
|
1859
1859
|
};
|
|
1860
1860
|
} catch (error) {
|
|
1861
1861
|
cleanupTempFiles(tempDir);
|
|
1862
|
+
const errorDetails = [
|
|
1863
|
+
`Error: ${error.message || String(error)}`
|
|
1864
|
+
];
|
|
1865
|
+
if (error.stack) {
|
|
1866
|
+
errorDetails.push(`Stack: ${error.stack}`);
|
|
1867
|
+
}
|
|
1868
|
+
if (error.code) {
|
|
1869
|
+
errorDetails.push(`Code: ${error.code}`);
|
|
1870
|
+
}
|
|
1871
|
+
if (error.syscall) {
|
|
1872
|
+
errorDetails.push(`Syscall: ${error.syscall}`);
|
|
1873
|
+
}
|
|
1874
|
+
if (error.path) {
|
|
1875
|
+
errorDetails.push(`Path: ${error.path}`);
|
|
1876
|
+
}
|
|
1877
|
+
if (error.spawnargs) {
|
|
1878
|
+
errorDetails.push(`Spawn args: ${JSON.stringify(error.spawnargs)}`);
|
|
1879
|
+
}
|
|
1880
|
+
if (error.stderr) {
|
|
1881
|
+
errorDetails.push(`Stderr: ${error.stderr.toString()}`);
|
|
1882
|
+
}
|
|
1883
|
+
if (error.stdout) {
|
|
1884
|
+
errorDetails.push(`Stdout: ${error.stdout.toString()}`);
|
|
1885
|
+
}
|
|
1862
1886
|
return {
|
|
1863
1887
|
success: false,
|
|
1864
1888
|
blockName: block.name,
|
|
1865
|
-
error:
|
|
1889
|
+
error: errorDetails.join(`
|
|
1890
|
+
`)
|
|
1866
1891
|
};
|
|
1867
1892
|
}
|
|
1868
1893
|
}
|
|
@@ -2003,13 +2028,29 @@ function parseBlockJsonFromSource(block) {
|
|
|
2003
2028
|
}
|
|
2004
2029
|
async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
|
|
2005
2030
|
const webpackBinary = findWebpackBinary();
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2008
|
-
|
|
2031
|
+
const args = [
|
|
2032
|
+
"--config",
|
|
2033
|
+
webpackConfigPath,
|
|
2034
|
+
"--env",
|
|
2035
|
+
`entry=${entryPoint}`,
|
|
2036
|
+
"--env",
|
|
2037
|
+
`output=${outputDir}`,
|
|
2038
|
+
"--mode",
|
|
2039
|
+
"production"
|
|
2040
|
+
];
|
|
2041
|
+
const result = spawnSync(webpackBinary, args, {
|
|
2009
2042
|
cwd: path.dirname(webpackConfigPath),
|
|
2010
2043
|
stdio: "pipe",
|
|
2011
|
-
|
|
2044
|
+
env: { ...process.env }
|
|
2012
2045
|
});
|
|
2046
|
+
if (result.error) {
|
|
2047
|
+
throw result.error;
|
|
2048
|
+
}
|
|
2049
|
+
if (result.status !== 0) {
|
|
2050
|
+
const stderr = result.stderr?.toString() || "";
|
|
2051
|
+
const stdout = result.stdout?.toString() || "";
|
|
2052
|
+
throw new Error(`Webpack build failed (exit code ${result.status}): ${stderr || stdout}`);
|
|
2053
|
+
}
|
|
2013
2054
|
}
|
|
2014
2055
|
function findWebpackBinary() {
|
|
2015
2056
|
const possiblePaths = [
|
package/dist/index.js
CHANGED
|
@@ -114915,7 +114915,10 @@ class AbortableWorkerPool {
|
|
|
114915
114915
|
scriptsPath: this.scriptsPath,
|
|
114916
114916
|
tempDir
|
|
114917
114917
|
};
|
|
114918
|
-
const worker = new Worker(this.workerPath, {
|
|
114918
|
+
const worker = new Worker(this.workerPath, {
|
|
114919
|
+
workerData,
|
|
114920
|
+
env: process.env
|
|
114921
|
+
});
|
|
114919
114922
|
const startTime = Date.now();
|
|
114920
114923
|
const activeWorker = {
|
|
114921
114924
|
worker,
|
|
@@ -115881,7 +115884,7 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
|
|
|
115881
115884
|
// package.json
|
|
115882
115885
|
var package_default = {
|
|
115883
115886
|
name: "@wordpress-flow/cli",
|
|
115884
|
-
version: "1.0.
|
|
115887
|
+
version: "1.0.10",
|
|
115885
115888
|
type: "module",
|
|
115886
115889
|
description: "TypeScript-based WordPress block creation system",
|
|
115887
115890
|
main: "dist/index.js",
|
|
@@ -116405,7 +116408,7 @@ import * as path19 from "path";
|
|
|
116405
116408
|
// src/build/webpack-runner.ts
|
|
116406
116409
|
import * as path17 from "path";
|
|
116407
116410
|
import * as fs15 from "fs";
|
|
116408
|
-
import {
|
|
116411
|
+
import { spawnSync } from "child_process";
|
|
116409
116412
|
var import_chalk3 = __toESM(require_source(), 1);
|
|
116410
116413
|
|
|
116411
116414
|
class WebpackRunner {
|
|
@@ -116428,54 +116431,67 @@ class WebpackRunner {
|
|
|
116428
116431
|
fs15.mkdirSync(outputDir, { recursive: true });
|
|
116429
116432
|
const webpackBinary = this.findWebpackBinary();
|
|
116430
116433
|
logger.debug(`Using webpack binary: ${webpackBinary}`);
|
|
116431
|
-
const
|
|
116432
|
-
|
|
116433
|
-
|
|
116434
|
-
|
|
116435
|
-
|
|
116436
|
-
|
|
116437
|
-
|
|
116438
|
-
|
|
116439
|
-
|
|
116440
|
-
|
|
116441
|
-
|
|
116442
|
-
|
|
116443
|
-
|
|
116444
|
-
|
|
116445
|
-
|
|
116446
|
-
|
|
116447
|
-
|
|
116448
|
-
}
|
|
116434
|
+
const args = [
|
|
116435
|
+
"--config",
|
|
116436
|
+
webpackConfigPath,
|
|
116437
|
+
"--env",
|
|
116438
|
+
`entry=${entryPoint}`,
|
|
116439
|
+
"--env",
|
|
116440
|
+
`output=${outputDir}`,
|
|
116441
|
+
"--mode",
|
|
116442
|
+
"production"
|
|
116443
|
+
];
|
|
116444
|
+
logger.debug(`Full command: ${webpackBinary} ${args.join(" ")}`);
|
|
116445
|
+
const workingDir = path17.dirname(webpackConfigPath);
|
|
116446
|
+
logger.debug(`Running webpack from directory: ${workingDir}`);
|
|
116447
|
+
const result2 = spawnSync(webpackBinary, args, {
|
|
116448
|
+
cwd: workingDir,
|
|
116449
|
+
stdio: "pipe",
|
|
116450
|
+
env: { ...process.env }
|
|
116451
|
+
});
|
|
116452
|
+
if (result2.error) {
|
|
116453
|
+
console.error("");
|
|
116454
|
+
console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
116455
|
+
console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
|
|
116456
|
+
console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
116457
|
+
console.error("");
|
|
116458
|
+
console.error(import_chalk3.default.yellow("Error:"));
|
|
116459
|
+
console.error(import_chalk3.default.gray(result2.error.message));
|
|
116460
|
+
console.error("");
|
|
116461
|
+
console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
116462
|
+
console.error("");
|
|
116463
|
+
throw result2.error;
|
|
116464
|
+
}
|
|
116465
|
+
if (result2.status !== 0) {
|
|
116466
|
+
const stderr = result2.stderr?.toString() || "";
|
|
116467
|
+
const stdout = result2.stdout?.toString() || "";
|
|
116449
116468
|
console.error("");
|
|
116450
116469
|
console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
116451
116470
|
console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
|
|
116452
116471
|
console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
116453
116472
|
console.error("");
|
|
116454
116473
|
console.error(import_chalk3.default.yellow("Command that failed:"));
|
|
116455
|
-
console.error(import_chalk3.default.gray(
|
|
116474
|
+
console.error(import_chalk3.default.gray(`${webpackBinary} ${args.join(" ")}`));
|
|
116456
116475
|
console.error("");
|
|
116457
116476
|
console.error(import_chalk3.default.yellow("Working directory:"));
|
|
116458
|
-
console.error(import_chalk3.default.gray(
|
|
116477
|
+
console.error(import_chalk3.default.gray(workingDir));
|
|
116459
116478
|
console.error("");
|
|
116460
|
-
if (
|
|
116479
|
+
if (stdout.trim()) {
|
|
116461
116480
|
console.error(import_chalk3.default.yellow("Standard output:"));
|
|
116462
|
-
console.error(
|
|
116481
|
+
console.error(stdout);
|
|
116463
116482
|
console.error("");
|
|
116464
116483
|
}
|
|
116465
|
-
if (
|
|
116484
|
+
if (stderr.trim()) {
|
|
116466
116485
|
console.error(import_chalk3.default.yellow("Error output:"));
|
|
116467
|
-
console.error(
|
|
116468
|
-
console.error("");
|
|
116469
|
-
}
|
|
116470
|
-
if (!error.stdout && !error.stderr) {
|
|
116471
|
-
console.error(import_chalk3.default.yellow("Error message:"));
|
|
116472
|
-
console.error(error.message);
|
|
116486
|
+
console.error(stderr);
|
|
116473
116487
|
console.error("");
|
|
116474
116488
|
}
|
|
116475
116489
|
console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
|
|
116476
116490
|
console.error("");
|
|
116477
|
-
throw new Error(`Webpack build failed`);
|
|
116491
|
+
throw new Error(`Webpack build failed (exit code ${result2.status})`);
|
|
116478
116492
|
}
|
|
116493
|
+
logger.debug("Webpack build completed successfully");
|
|
116494
|
+
logger.debug(`Output: ${result2.stdout?.toString() || ""}`);
|
|
116479
116495
|
}
|
|
116480
116496
|
findWebpackBinary() {
|
|
116481
116497
|
const possiblePaths = [
|
|
@@ -116909,10 +116925,26 @@ class WorkerPool {
|
|
|
116909
116925
|
resolve7(results);
|
|
116910
116926
|
}
|
|
116911
116927
|
}).catch((error) => {
|
|
116928
|
+
const errorDetails = [
|
|
116929
|
+
`Error: ${error.message || String(error)}`
|
|
116930
|
+
];
|
|
116931
|
+
if (error.stack) {
|
|
116932
|
+
errorDetails.push(`Stack: ${error.stack}`);
|
|
116933
|
+
}
|
|
116934
|
+
if (error.code) {
|
|
116935
|
+
errorDetails.push(`Code: ${error.code}`);
|
|
116936
|
+
}
|
|
116937
|
+
if (error.syscall) {
|
|
116938
|
+
errorDetails.push(`Syscall: ${error.syscall}`);
|
|
116939
|
+
}
|
|
116940
|
+
if (error.path) {
|
|
116941
|
+
errorDetails.push(`Path: ${error.path}`);
|
|
116942
|
+
}
|
|
116912
116943
|
const result2 = {
|
|
116913
116944
|
success: false,
|
|
116914
116945
|
blockName: block.name,
|
|
116915
|
-
error:
|
|
116946
|
+
error: errorDetails.join(`
|
|
116947
|
+
`)
|
|
116916
116948
|
};
|
|
116917
116949
|
results.push(result2);
|
|
116918
116950
|
completed++;
|
|
@@ -116943,7 +116975,10 @@ class WorkerPool {
|
|
|
116943
116975
|
scriptsPath: this.scriptsPath,
|
|
116944
116976
|
tempDir
|
|
116945
116977
|
};
|
|
116946
|
-
const worker = new Worker2(this.workerPath, {
|
|
116978
|
+
const worker = new Worker2(this.workerPath, {
|
|
116979
|
+
workerData,
|
|
116980
|
+
env: process.env
|
|
116981
|
+
});
|
|
116947
116982
|
const timeout = setTimeout(() => {
|
|
116948
116983
|
worker.terminate();
|
|
116949
116984
|
reject(new Error(`Worker timeout for block: ${block.name}`));
|