@wordpress-flow/cli 1.0.9 → 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.
@@ -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 { execSync } from "child_process";
1838
+ import { spawnSync } from "child_process";
1839
1839
  async function buildBlock() {
1840
1840
  const { block, outputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
1841
1841
  try {
@@ -2028,13 +2028,29 @@ function parseBlockJsonFromSource(block) {
2028
2028
  }
2029
2029
  async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2030
2030
  const webpackBinary = findWebpackBinary();
2031
- const envString = `--env entry="${entryPoint}" --env output="${outputDir}"`;
2032
- const command = `${webpackBinary} --config "${webpackConfigPath}" ${envString} --mode production`;
2033
- execSync(command, {
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, {
2034
2042
  cwd: path.dirname(webpackConfigPath),
2035
2043
  stdio: "pipe",
2036
2044
  env: { ...process.env }
2037
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
+ }
2038
2054
  }
2039
2055
  function findWebpackBinary() {
2040
2056
  const possiblePaths = [
package/dist/index.js CHANGED
@@ -115884,7 +115884,7 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
115884
115884
  // package.json
115885
115885
  var package_default = {
115886
115886
  name: "@wordpress-flow/cli",
115887
- version: "1.0.9",
115887
+ version: "1.0.10",
115888
115888
  type: "module",
115889
115889
  description: "TypeScript-based WordPress block creation system",
115890
115890
  main: "dist/index.js",
@@ -116408,7 +116408,7 @@ import * as path19 from "path";
116408
116408
  // src/build/webpack-runner.ts
116409
116409
  import * as path17 from "path";
116410
116410
  import * as fs15 from "fs";
116411
- import { execSync } from "child_process";
116411
+ import { spawnSync } from "child_process";
116412
116412
  var import_chalk3 = __toESM(require_source(), 1);
116413
116413
 
116414
116414
  class WebpackRunner {
@@ -116431,55 +116431,67 @@ class WebpackRunner {
116431
116431
  fs15.mkdirSync(outputDir, { recursive: true });
116432
116432
  const webpackBinary = this.findWebpackBinary();
116433
116433
  logger.debug(`Using webpack binary: ${webpackBinary}`);
116434
- const envVars = {
116435
- entry: entryPoint,
116436
- output: outputDir
116437
- };
116438
- const envString = Object.entries(envVars).map(([key, value]) => `--env ${key}="${value}"`).join(" ");
116439
- const command = `${webpackBinary} --config "${webpackConfigPath}" ${envString} --mode production`;
116440
- logger.debug(`Full command: ${command}`);
116441
- try {
116442
- const workingDir = path17.dirname(webpackConfigPath);
116443
- logger.debug(`Running webpack from directory: ${workingDir}`);
116444
- const output2 = execSync(command, {
116445
- cwd: workingDir,
116446
- encoding: "utf8",
116447
- stdio: "pipe",
116448
- env: { ...process.env }
116449
- });
116450
- logger.debug("Webpack build completed successfully");
116451
- logger.debug(`Output: ${output2}`);
116452
- } catch (error) {
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() || "";
116453
116468
  console.error("");
116454
116469
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116455
116470
  console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
116456
116471
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116457
116472
  console.error("");
116458
116473
  console.error(import_chalk3.default.yellow("Command that failed:"));
116459
- console.error(import_chalk3.default.gray(command));
116474
+ console.error(import_chalk3.default.gray(`${webpackBinary} ${args.join(" ")}`));
116460
116475
  console.error("");
116461
116476
  console.error(import_chalk3.default.yellow("Working directory:"));
116462
- console.error(import_chalk3.default.gray(path17.dirname(webpackConfigPath)));
116477
+ console.error(import_chalk3.default.gray(workingDir));
116463
116478
  console.error("");
116464
- if (error.stdout && error.stdout.trim()) {
116479
+ if (stdout.trim()) {
116465
116480
  console.error(import_chalk3.default.yellow("Standard output:"));
116466
- console.error(error.stdout);
116481
+ console.error(stdout);
116467
116482
  console.error("");
116468
116483
  }
116469
- if (error.stderr && error.stderr.trim()) {
116484
+ if (stderr.trim()) {
116470
116485
  console.error(import_chalk3.default.yellow("Error output:"));
116471
- console.error(error.stderr);
116472
- console.error("");
116473
- }
116474
- if (!error.stdout && !error.stderr) {
116475
- console.error(import_chalk3.default.yellow("Error message:"));
116476
- console.error(error.message);
116486
+ console.error(stderr);
116477
116487
  console.error("");
116478
116488
  }
116479
116489
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116480
116490
  console.error("");
116481
- throw new Error(`Webpack build failed`);
116491
+ throw new Error(`Webpack build failed (exit code ${result2.status})`);
116482
116492
  }
116493
+ logger.debug("Webpack build completed successfully");
116494
+ logger.debug(`Output: ${result2.stdout?.toString() || ""}`);
116483
116495
  }
116484
116496
  findWebpackBinary() {
116485
116497
  const possiblePaths = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",