@wordpress-flow/cli 1.0.11 → 1.0.12

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 { spawnSync } from "child_process";
1838
+ import { execSync } from "child_process";
1839
1839
  async function buildBlock() {
1840
1840
  const { block, outputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
1841
1841
  try {
@@ -2027,43 +2027,25 @@ function parseBlockJsonFromSource(block) {
2027
2027
  };
2028
2028
  }
2029
2029
  async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2030
- const webpackCliPath = findWebpackCliPath();
2031
- const args = [
2032
- webpackCliPath,
2033
- "--config",
2034
- webpackConfigPath,
2035
- "--env",
2036
- `entry=${entryPoint}`,
2037
- "--env",
2038
- `output=${outputDir}`,
2039
- "--mode",
2040
- "production"
2041
- ];
2042
- const result = spawnSync(process.execPath, args, {
2030
+ const webpackBinary = findWebpackBinary();
2031
+ const command = `"${webpackBinary}" --config "${webpackConfigPath}" --env entry="${entryPoint}" --env output="${outputDir}" --mode production`;
2032
+ execSync(command, {
2043
2033
  cwd: path.dirname(webpackConfigPath),
2044
2034
  stdio: "pipe",
2045
- env: { ...process.env }
2035
+ env: { ...process.env, PATH: process.env.PATH }
2046
2036
  });
2047
- if (result.error) {
2048
- throw result.error;
2049
- }
2050
- if (result.status !== 0) {
2051
- const stderr = result.stderr?.toString() || "";
2052
- const stdout = result.stdout?.toString() || "";
2053
- throw new Error(`Webpack build failed (exit code ${result.status}): ${stderr || stdout}`);
2054
- }
2055
2037
  }
2056
- function findWebpackCliPath() {
2038
+ function findWebpackBinary() {
2057
2039
  const possiblePaths = [
2058
- path.join(process.cwd(), "packages", "block", "node_modules", "webpack-cli", "bin", "cli.js"),
2059
- path.join(process.cwd(), "node_modules", "webpack-cli", "bin", "cli.js")
2040
+ path.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
2041
+ path.join(process.cwd(), "node_modules", ".bin", "webpack")
2060
2042
  ];
2061
- for (const cliPath of possiblePaths) {
2062
- if (fs.existsSync(cliPath)) {
2063
- return cliPath;
2043
+ for (const webpackPath of possiblePaths) {
2044
+ if (fs.existsSync(webpackPath)) {
2045
+ return webpackPath;
2064
2046
  }
2065
2047
  }
2066
- throw new Error("webpack-cli not found. Please install webpack-cli in your project.");
2048
+ return "npx webpack";
2067
2049
  }
2068
2050
  function verifyBuildOutput(outputDir) {
2069
2051
  const requiredFiles = ["block.json", "index.js", "ssr.js"];
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.11",
115887
+ version: "1.0.12",
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 { spawnSync } from "child_process";
116411
+ import { execSync } from "child_process";
116412
116412
  var import_chalk3 = __toESM(require_source(), 1);
116413
116413
 
116414
116414
  class WebpackRunner {
@@ -116429,85 +116429,68 @@ class WebpackRunner {
116429
116429
  throw new Error(error);
116430
116430
  }
116431
116431
  fs15.mkdirSync(outputDir, { recursive: true });
116432
- const webpackCliPath = this.findWebpackCliPath();
116433
- logger.debug(`Using webpack-cli at: ${webpackCliPath}`);
116434
- const args = [
116435
- webpackCliPath,
116436
- "--config",
116437
- webpackConfigPath,
116438
- "--env",
116439
- `entry=${entryPoint}`,
116440
- "--env",
116441
- `output=${outputDir}`,
116442
- "--mode",
116443
- "production"
116444
- ];
116445
- logger.debug(`Full command: node ${args.join(" ")}`);
116432
+ const webpackBinary = this.findWebpackBinary();
116433
+ logger.debug(`Using webpack binary: ${webpackBinary}`);
116434
+ const command = `"${webpackBinary}" --config "${webpackConfigPath}" --env entry="${entryPoint}" --env output="${outputDir}" --mode production`;
116435
+ logger.debug(`Full command: ${command}`);
116446
116436
  const workingDir = path17.dirname(webpackConfigPath);
116447
116437
  logger.debug(`Running webpack from directory: ${workingDir}`);
116448
- const result2 = spawnSync(process.execPath, args, {
116449
- cwd: workingDir,
116450
- stdio: "pipe",
116451
- env: { ...process.env }
116452
- });
116453
- if (result2.error) {
116454
- console.error("");
116455
- console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116456
- console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
116457
- console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116458
- console.error("");
116459
- console.error(import_chalk3.default.yellow("Error:"));
116460
- console.error(import_chalk3.default.gray(result2.error.message));
116461
- console.error("");
116462
- console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116463
- console.error("");
116464
- throw result2.error;
116465
- }
116466
- if (result2.status !== 0) {
116467
- const stderr = result2.stderr?.toString() || "";
116468
- const stdout = result2.stdout?.toString() || "";
116438
+ try {
116439
+ const output2 = execSync(command, {
116440
+ cwd: workingDir,
116441
+ encoding: "utf8",
116442
+ stdio: "pipe",
116443
+ env: { ...process.env, PATH: process.env.PATH }
116444
+ });
116445
+ logger.debug("Webpack build completed successfully");
116446
+ logger.debug(`Output: ${output2}`);
116447
+ } catch (error) {
116469
116448
  console.error("");
116470
116449
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116471
116450
  console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
116472
116451
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116473
116452
  console.error("");
116474
116453
  console.error(import_chalk3.default.yellow("Command that failed:"));
116475
- console.error(import_chalk3.default.gray(`node ${args.join(" ")}`));
116454
+ console.error(import_chalk3.default.gray(command));
116476
116455
  console.error("");
116477
116456
  console.error(import_chalk3.default.yellow("Working directory:"));
116478
116457
  console.error(import_chalk3.default.gray(workingDir));
116479
116458
  console.error("");
116480
- if (stdout.trim()) {
116459
+ if (error.stdout?.trim()) {
116481
116460
  console.error(import_chalk3.default.yellow("Standard output:"));
116482
- console.error(stdout);
116461
+ console.error(error.stdout);
116483
116462
  console.error("");
116484
116463
  }
116485
- if (stderr.trim()) {
116464
+ if (error.stderr?.trim()) {
116486
116465
  console.error(import_chalk3.default.yellow("Error output:"));
116487
- console.error(stderr);
116466
+ console.error(error.stderr);
116467
+ console.error("");
116468
+ }
116469
+ if (!error.stdout && !error.stderr) {
116470
+ console.error(import_chalk3.default.yellow("Error message:"));
116471
+ console.error(error.message);
116488
116472
  console.error("");
116489
116473
  }
116490
116474
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116491
116475
  console.error("");
116492
- throw new Error(`Webpack build failed (exit code ${result2.status})`);
116476
+ throw new Error(`Webpack build failed`);
116493
116477
  }
116494
- logger.debug("Webpack build completed successfully");
116495
- logger.debug(`Output: ${result2.stdout?.toString() || ""}`);
116496
116478
  }
116497
- findWebpackCliPath() {
116479
+ findWebpackBinary() {
116498
116480
  const possiblePaths = [
116499
- path17.join(process.cwd(), "packages", "block", "node_modules", "webpack-cli", "bin", "cli.js"),
116500
- path17.join(process.cwd(), "node_modules", "webpack-cli", "bin", "cli.js"),
116501
- path17.join(import.meta.dirname, "..", "..", "..", "node_modules", "webpack-cli", "bin", "cli.js"),
116502
- path17.join(process.cwd(), "..", "node_modules", "webpack-cli", "bin", "cli.js")
116481
+ path17.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
116482
+ path17.join(process.cwd(), "node_modules", ".bin", "webpack"),
116483
+ path17.join(import.meta.dirname, "..", "..", "..", "node_modules", ".bin", "webpack"),
116484
+ path17.join(process.cwd(), "..", "node_modules", ".bin", "webpack")
116503
116485
  ];
116504
- for (const cliPath of possiblePaths) {
116505
- if (fs15.existsSync(cliPath)) {
116506
- logger.debug(`Found webpack-cli at: ${cliPath}`);
116507
- return cliPath;
116486
+ for (const webpackPath of possiblePaths) {
116487
+ if (fs15.existsSync(webpackPath)) {
116488
+ logger.debug(`Found webpack at: ${webpackPath}`);
116489
+ return webpackPath;
116508
116490
  }
116509
116491
  }
116510
- throw new Error("webpack-cli not found. Please install webpack-cli in your project.");
116492
+ logger.debug("Using npx webpack as fallback");
116493
+ return "npx webpack";
116511
116494
  }
116512
116495
  }
116513
116496
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",