@wordpress-flow/cli 1.0.20 → 1.0.22

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 webpack from "webpack";
1839
1839
  async function buildBlock() {
1840
1840
  const { block, outputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
1841
1841
  try {
@@ -2002,26 +2002,34 @@ function parseBlockJsonFromSource(block) {
2002
2002
  };
2003
2003
  }
2004
2004
  async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2005
- const webpackBinary = findWebpackBinary();
2006
- const envString = `--env entry="${entryPoint}" --env output="${outputDir}"`;
2007
- const command = `${webpackBinary} --config "${webpackConfigPath}" ${envString} --mode production`;
2008
- execSync(command, {
2009
- cwd: path.dirname(webpackConfigPath),
2010
- encoding: "utf8",
2011
- stdio: "pipe"
2012
- });
2013
- }
2014
- function findWebpackBinary() {
2015
- const possiblePaths = [
2016
- path.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
2017
- path.join(process.cwd(), "node_modules", ".bin", "webpack")
2018
- ];
2019
- for (const webpackPath of possiblePaths) {
2020
- if (fs.existsSync(webpackPath)) {
2021
- return webpackPath;
2005
+ const configModule = await import(webpackConfigPath);
2006
+ const configFactory = configModule.default || configModule;
2007
+ const env = { entry: entryPoint, output: outputDir };
2008
+ const baseConfig = typeof configFactory === "function" ? configFactory(env) : configFactory;
2009
+ const config = {
2010
+ ...baseConfig,
2011
+ mode: "production",
2012
+ entry: entryPoint,
2013
+ output: {
2014
+ ...baseConfig.output,
2015
+ path: outputDir
2022
2016
  }
2023
- }
2024
- return "npx webpack";
2017
+ };
2018
+ return new Promise((resolve2, reject) => {
2019
+ webpack(config, (err, stats) => {
2020
+ if (err) {
2021
+ reject(err);
2022
+ return;
2023
+ }
2024
+ if (stats?.hasErrors()) {
2025
+ const info = stats.toJson();
2026
+ reject(new Error(info.errors?.map((e) => e.message).join(`
2027
+ `) || "Webpack build failed"));
2028
+ return;
2029
+ }
2030
+ resolve2();
2031
+ });
2032
+ });
2025
2033
  }
2026
2034
  function verifyBuildOutput(outputDir) {
2027
2035
  const requiredFiles = ["block.json", "index.js", "ssr.js"];
package/dist/index.js CHANGED
@@ -114193,7 +114193,7 @@ var watch = (paths, options) => {
114193
114193
  var $watch = watch;
114194
114194
 
114195
114195
  // src/commands/dev-command.ts
114196
- import * as path16 from "path";
114196
+ import * as path15 from "path";
114197
114197
  import * as fs14 from "fs";
114198
114198
 
114199
114199
  // src/build/block-scanner.ts
@@ -114258,12 +114258,11 @@ class BlockScanner {
114258
114258
 
114259
114259
  // src/build/block-builder.ts
114260
114260
  import * as fs10 from "fs";
114261
- import * as path10 from "path";
114261
+ import * as path9 from "path";
114262
114262
 
114263
114263
  // src/build/webpack-runner.ts
114264
- import * as path8 from "path";
114265
114264
  import * as fs8 from "fs";
114266
- import { execSync } from "child_process";
114265
+ import webpack from "webpack";
114267
114266
  var import_chalk3 = __toESM(require_source(), 1);
114268
114267
 
114269
114268
  class WebpackRunner {
@@ -114284,85 +114283,73 @@ class WebpackRunner {
114284
114283
  throw new Error(error);
114285
114284
  }
114286
114285
  fs8.mkdirSync(outputDir, { recursive: true });
114287
- const webpackBinary = this.findWebpackBinary();
114288
- logger.debug(`Using webpack binary: ${webpackBinary}`);
114289
- const envVars = {
114290
- entry: entryPoint,
114291
- output: outputDir
114292
- };
114293
- const envString = Object.entries(envVars).map(([key, value]) => `--env ${key}="${value}"`).join(" ");
114294
- const command = `${webpackBinary} --config "${webpackConfigPath}" ${envString} --mode production`;
114295
- logger.debug(`Full command: ${command}`);
114296
114286
  try {
114297
- const workingDir = path8.dirname(webpackConfigPath);
114298
- logger.debug(`Running webpack from directory: ${workingDir}`);
114299
- const output2 = execSync(command, {
114300
- cwd: workingDir,
114301
- encoding: "utf8",
114302
- stdio: "pipe"
114287
+ const configModule = await import(webpackConfigPath);
114288
+ const configFactory = configModule.default || configModule;
114289
+ const env2 = { entry: entryPoint, output: outputDir };
114290
+ const baseConfig = typeof configFactory === "function" ? configFactory(env2) : configFactory;
114291
+ const config2 = {
114292
+ ...baseConfig,
114293
+ mode: "production",
114294
+ entry: entryPoint,
114295
+ output: {
114296
+ ...baseConfig.output,
114297
+ path: outputDir
114298
+ }
114299
+ };
114300
+ logger.debug(`Running webpack with config for: ${entryPoint}`);
114301
+ await new Promise((resolve4, reject) => {
114302
+ webpack(config2, (err, stats) => {
114303
+ if (err) {
114304
+ reject(err);
114305
+ return;
114306
+ }
114307
+ if (stats?.hasErrors()) {
114308
+ const info = stats.toJson();
114309
+ reject(new Error(info.errors?.map((e) => e.message).join(`
114310
+ `) || "Webpack build failed"));
114311
+ return;
114312
+ }
114313
+ if (stats?.hasWarnings()) {
114314
+ const info = stats.toJson();
114315
+ info.warnings?.forEach((w) => logger.debug(`Webpack warning: ${w.message}`));
114316
+ }
114317
+ resolve4();
114318
+ });
114303
114319
  });
114304
114320
  logger.debug("Webpack build completed successfully");
114305
- logger.debug(`Output: ${output2}`);
114306
114321
  } catch (error) {
114307
114322
  console.error("");
114308
114323
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
114309
114324
  console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
114310
114325
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
114311
114326
  console.error("");
114312
- console.error(import_chalk3.default.yellow("Command that failed:"));
114313
- console.error(import_chalk3.default.gray(command));
114327
+ console.error(import_chalk3.default.yellow("Entry point:"));
114328
+ console.error(import_chalk3.default.gray(entryPoint));
114314
114329
  console.error("");
114315
- console.error(import_chalk3.default.yellow("Working directory:"));
114316
- console.error(import_chalk3.default.gray(path8.dirname(webpackConfigPath)));
114330
+ console.error(import_chalk3.default.yellow("Output directory:"));
114331
+ console.error(import_chalk3.default.gray(outputDir));
114332
+ console.error("");
114333
+ console.error(import_chalk3.default.yellow("Error message:"));
114334
+ console.error(import_chalk3.default.gray(error.message));
114317
114335
  console.error("");
114318
- if (error.stdout && error.stdout.trim()) {
114319
- console.error(import_chalk3.default.yellow("Standard output:"));
114320
- console.error(error.stdout);
114321
- console.error("");
114322
- }
114323
- if (error.stderr && error.stderr.trim()) {
114324
- console.error(import_chalk3.default.yellow("Error output:"));
114325
- console.error(error.stderr);
114326
- console.error("");
114327
- }
114328
- if (!error.stdout && !error.stderr) {
114329
- console.error(import_chalk3.default.yellow("Error message:"));
114330
- console.error(error.message);
114331
- console.error("");
114332
- }
114333
114336
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
114334
114337
  console.error("");
114335
- throw new Error(`Webpack build failed`);
114338
+ throw new Error(`Webpack build failed: ${error.message}`);
114336
114339
  }
114337
114340
  }
114338
- findWebpackBinary() {
114339
- const possiblePaths = [
114340
- path8.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
114341
- path8.join(process.cwd(), "node_modules", ".bin", "webpack"),
114342
- path8.join(import.meta.dirname, "..", "..", "..", "node_modules", ".bin", "webpack"),
114343
- path8.join(process.cwd(), "..", "node_modules", ".bin", "webpack")
114344
- ];
114345
- for (const webpackPath of possiblePaths) {
114346
- if (fs8.existsSync(webpackPath)) {
114347
- logger.debug(`Found webpack at: ${webpackPath}`);
114348
- return webpackPath;
114349
- }
114350
- }
114351
- logger.debug("Using npx webpack as fallback");
114352
- return "npx webpack";
114353
- }
114354
114341
  }
114355
114342
 
114356
114343
  // src/build/script-builder.ts
114357
114344
  import * as fs9 from "fs";
114358
- import * as path9 from "path";
114345
+ import * as path8 from "path";
114359
114346
  import * as esbuild from "esbuild";
114360
114347
  class ScriptBuilder {
114361
114348
  async buildScript(scriptPath, outputDir, scriptName) {
114362
114349
  try {
114363
114350
  logger.debug(`Building script: ${scriptName}`);
114364
114351
  fs9.mkdirSync(outputDir, { recursive: true });
114365
- const outputPath = path9.join(outputDir, scriptName.replace(/\.ts$/, ".js"));
114352
+ const outputPath = path8.join(outputDir, scriptName.replace(/\.ts$/, ".js"));
114366
114353
  await esbuild.build({
114367
114354
  entryPoints: [scriptPath],
114368
114355
  outfile: outputPath,
@@ -114392,19 +114379,19 @@ class ScriptBuilder {
114392
114379
  async buildScripts(scripts, scriptsPath, outputDir) {
114393
114380
  const outputPaths = [];
114394
114381
  for (const script of scripts) {
114395
- const scriptPath = path9.resolve(scriptsPath, script);
114382
+ const scriptPath = path8.resolve(scriptsPath, script);
114396
114383
  if (!fs9.existsSync(scriptPath)) {
114397
114384
  logger.warn(`Script not found: ${scriptPath}`);
114398
114385
  continue;
114399
114386
  }
114400
- const scriptName = path9.basename(script);
114387
+ const scriptName = path8.basename(script);
114401
114388
  const outputPath = await this.buildScript(scriptPath, outputDir, scriptName);
114402
114389
  outputPaths.push(outputPath);
114403
114390
  }
114404
114391
  return outputPaths;
114405
114392
  }
114406
114393
  getRelativeScriptPath(blockDistPath, scriptPath) {
114407
- const relativePath = path9.relative(blockDistPath, scriptPath);
114394
+ const relativePath = path8.relative(blockDistPath, scriptPath);
114408
114395
  return relativePath.replace(/\\/g, "/");
114409
114396
  }
114410
114397
  }
@@ -114418,7 +114405,7 @@ class BlockBuilder {
114418
114405
  constructor() {
114419
114406
  this.webpackRunner = new WebpackRunner;
114420
114407
  this.scriptBuilder = new ScriptBuilder;
114421
- this.tempDir = path10.join(process.cwd(), ".wordpress-flow-temp");
114408
+ this.tempDir = path9.join(process.cwd(), ".wordpress-flow-temp");
114422
114409
  }
114423
114410
  async buildBlock(block, outputDir, webpackConfigPath, scriptsPath) {
114424
114411
  logger.debug(`Building block: ${block.name}`);
@@ -114427,7 +114414,7 @@ class BlockBuilder {
114427
114414
  logger.debug(`[1/6] Generating entry point...`);
114428
114415
  const entryPoint = await this.generateEntryPoint(block);
114429
114416
  logger.debug(`[2/6] Creating output directory...`);
114430
- const blockOutputDir = path10.join(outputDir, block.name);
114417
+ const blockOutputDir = path9.join(outputDir, block.name);
114431
114418
  fs10.mkdirSync(blockOutputDir, { recursive: true });
114432
114419
  let scriptPaths = [];
114433
114420
  if (block.scripts && block.scripts.length > 0 && scriptsPath) {
@@ -114455,7 +114442,7 @@ class BlockBuilder {
114455
114442
  }
114456
114443
  }
114457
114444
  async buildBlockScripts(scripts, scriptsPath, outputDir) {
114458
- const scriptsOutputDir = path10.join(path10.dirname(outputDir), "scripts");
114445
+ const scriptsOutputDir = path9.join(path9.dirname(outputDir), "scripts");
114459
114446
  return await this.scriptBuilder.buildScripts(scripts, scriptsPath, scriptsOutputDir);
114460
114447
  }
114461
114448
  async generateEntryPoint(block) {
@@ -114479,14 +114466,14 @@ if (document.readyState === 'loading') {
114479
114466
  blockInstance.register();
114480
114467
  }
114481
114468
  `;
114482
- const entryPath = path10.join(this.tempDir, `${block.name}-entry.js`);
114469
+ const entryPath = path9.join(this.tempDir, `${block.name}-entry.js`);
114483
114470
  fs10.writeFileSync(entryPath, entryContent, "utf8");
114484
114471
  return entryPath;
114485
114472
  }
114486
114473
  async generateSSRVersion(block, outputDir) {
114487
114474
  try {
114488
114475
  logger.debug(`Generating SSR version for ${block.name} using esbuild`);
114489
- const ssrPath = path10.join(outputDir, "ssr.js");
114476
+ const ssrPath = path9.join(outputDir, "ssr.js");
114490
114477
  await esbuild2.build({
114491
114478
  entryPoints: [block.filePath],
114492
114479
  outfile: ssrPath,
@@ -114526,7 +114513,7 @@ if (document.readyState === 'loading') {
114526
114513
  throw new Error(`Block ${block.name} must export a valid block instance with toBlockJson() method`);
114527
114514
  }
114528
114515
  const blockJson = blockInstance.toBlockJson();
114529
- const blockJsonPath = path10.join(outputDir, "block.json");
114516
+ const blockJsonPath = path9.join(outputDir, "block.json");
114530
114517
  fs10.writeFileSync(blockJsonPath, JSON.stringify(blockJson, null, 2), "utf8");
114531
114518
  logger.debug(`Generated block.json for ${block.name}`);
114532
114519
  } catch (error) {
@@ -114550,7 +114537,7 @@ if (document.readyState === 'loading') {
114550
114537
  editorStyle: "file:./index.css",
114551
114538
  style: "file:./style-index.css"
114552
114539
  };
114553
- const blockJsonPath = path10.join(outputDir, "block.json");
114540
+ const blockJsonPath = path9.join(outputDir, "block.json");
114554
114541
  fs10.writeFileSync(blockJsonPath, JSON.stringify(fallbackBlockJson, null, 2), "utf8");
114555
114542
  logger.warn(`Used fallback block.json for ${block.name}`);
114556
114543
  }
@@ -114563,7 +114550,7 @@ if (document.readyState === 'loading') {
114563
114550
  }
114564
114551
  async compileAndImport(filePath2) {
114565
114552
  try {
114566
- const tempFile = path10.join(this.tempDir, `${path10.basename(filePath2, path10.extname(filePath2))}-compiled.js`);
114553
+ const tempFile = path9.join(this.tempDir, `${path9.basename(filePath2, path9.extname(filePath2))}-compiled.js`);
114567
114554
  logger.debug(`Compiling ${filePath2} to ${tempFile}`);
114568
114555
  if (typeof global.React === "undefined") {
114569
114556
  global.React = require_react();
@@ -114593,7 +114580,7 @@ if (document.readyState === 'loading') {
114593
114580
  }
114594
114581
  parseBlockFromSource(filePath2) {
114595
114582
  const content4 = fs10.readFileSync(filePath2, "utf8");
114596
- const blockName = path10.basename(filePath2, ".tsx");
114583
+ const blockName = path9.basename(filePath2, ".tsx");
114597
114584
  const blockData = this.extractBlockDataFromSource(content4, filePath2);
114598
114585
  return {
114599
114586
  toBlockJson: () => {
@@ -114703,13 +114690,13 @@ if (document.readyState === 'loading') {
114703
114690
  const requiredFiles = ["block.json", "index.js", "ssr.js"];
114704
114691
  const optionalFiles = ["index.asset.php", "index.css", "style-index.css"];
114705
114692
  for (const file of requiredFiles) {
114706
- const filePath2 = path10.join(outputDir, file);
114693
+ const filePath2 = path9.join(outputDir, file);
114707
114694
  if (!fs10.existsSync(filePath2)) {
114708
114695
  throw new Error(`Required build output file missing: ${file}`);
114709
114696
  }
114710
114697
  }
114711
114698
  for (const file of optionalFiles) {
114712
- const filePath2 = path10.join(outputDir, file);
114699
+ const filePath2 = path9.join(outputDir, file);
114713
114700
  if (fs10.existsSync(filePath2)) {
114714
114701
  logger.debug(`Generated optional file: ${file}`);
114715
114702
  }
@@ -114728,12 +114715,12 @@ if (document.readyState === 'loading') {
114728
114715
 
114729
114716
  // src/build/type-definition-generator.ts
114730
114717
  import * as fs11 from "fs";
114731
- import * as path11 from "path";
114718
+ import * as path10 from "path";
114732
114719
  class TypeDefinitionGenerator {
114733
114720
  async generateDefinitions(blocks, outputPath) {
114734
114721
  logger.debug(`Generating TypeScript definitions for ${blocks.length} blocks`);
114735
114722
  const content4 = this.generateDefinitionContent(blocks);
114736
- const outputDir = path11.dirname(outputPath);
114723
+ const outputDir = path10.dirname(outputPath);
114737
114724
  if (!fs11.existsSync(outputDir)) {
114738
114725
  fs11.mkdirSync(outputDir, { recursive: true });
114739
114726
  }
@@ -114839,7 +114826,7 @@ export {};
114839
114826
  const blockDirs = fs11.readdirSync(distDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
114840
114827
  for (const blockDir of blockDirs) {
114841
114828
  try {
114842
- const blockJsonPath = path11.join(distDir, blockDir, "block.json");
114829
+ const blockJsonPath = path10.join(distDir, blockDir, "block.json");
114843
114830
  if (fs11.existsSync(blockJsonPath)) {
114844
114831
  const blockJson = JSON.parse(fs11.readFileSync(blockJsonPath, "utf8"));
114845
114832
  const blockInfo = {
@@ -114871,7 +114858,7 @@ export {};
114871
114858
 
114872
114859
  // src/build/mdx-dependency-tracker.ts
114873
114860
  import * as fs12 from "fs";
114874
- import * as path12 from "path";
114861
+ import * as path11 from "path";
114875
114862
  class MDXDependencyTracker {
114876
114863
  dependencies = new Map;
114877
114864
  reverseDependencies = new Map;
@@ -114883,7 +114870,7 @@ class MDXDependencyTracker {
114883
114870
  }
114884
114871
  this.dependencies.clear();
114885
114872
  this.reverseDependencies.clear();
114886
- const pattern = path12.join(contentDir, "**/*.mdx");
114873
+ const pattern = path11.join(contentDir, "**/*.mdx");
114887
114874
  const mdxFiles = await glob(pattern);
114888
114875
  logger.debug(`Found ${mdxFiles.length} MDX files`);
114889
114876
  for (const filePath2 of mdxFiles) {
@@ -114922,7 +114909,7 @@ class MDXDependencyTracker {
114922
114909
  blocks.push(componentName);
114923
114910
  }
114924
114911
  }
114925
- logger.debug(`File ${path12.basename(filePath2)} uses blocks: ${blocks.join(", ")}`);
114912
+ logger.debug(`File ${path11.basename(filePath2)} uses blocks: ${blocks.join(", ")}`);
114926
114913
  return blocks;
114927
114914
  }
114928
114915
  getDependentFiles(blockName) {
@@ -114957,13 +114944,13 @@ class MDXDependencyTracker {
114957
114944
  printDependencies() {
114958
114945
  logger.info("=== MDX Dependencies ===");
114959
114946
  for (const [filePath2, blocks] of this.dependencies.entries()) {
114960
- const fileName = path12.basename(filePath2);
114947
+ const fileName = path11.basename(filePath2);
114961
114948
  logger.info(`${fileName}: [${blocks.join(", ")}]`);
114962
114949
  }
114963
114950
  logger.info(`
114964
114951
  === Reverse Dependencies ===`);
114965
114952
  for (const [blockName, files] of this.reverseDependencies.entries()) {
114966
- const fileNames = files.map((f) => path12.basename(f));
114953
+ const fileNames = files.map((f) => path11.basename(f));
114967
114954
  logger.info(`${blockName}: [${fileNames.join(", ")}]`);
114968
114955
  }
114969
114956
  const stats = this.getStats();
@@ -114977,17 +114964,17 @@ class MDXDependencyTracker {
114977
114964
  }
114978
114965
 
114979
114966
  // src/commands/build-command.ts
114980
- import * as path15 from "path";
114967
+ import * as path14 from "path";
114981
114968
 
114982
114969
  // src/build/php-generator.ts
114983
114970
  import * as fs13 from "fs";
114984
- import * as path13 from "path";
114971
+ import * as path12 from "path";
114985
114972
  class PHPGenerator {
114986
114973
  generateScriptRegistrationPHP(scripts, outputPath) {
114987
114974
  const registrations = [];
114988
114975
  scripts.forEach((scriptPaths, blockName) => {
114989
114976
  scriptPaths.forEach((scriptPath, index2) => {
114990
- const scriptName = path13.basename(scriptPath, ".js");
114977
+ const scriptName = path12.basename(scriptPath, ".js");
114991
114978
  const handle = `${blockName.toLowerCase()}-${scriptName}-script`;
114992
114979
  registrations.push({
114993
114980
  blockName,
@@ -115050,7 +115037,7 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
115050
115037
  generateSingleRegistration(reg) {
115051
115038
  const deps = reg.dependencies.map((d) => `'${d}'`).join(", ");
115052
115039
  const scriptPath = reg.scriptPath.includes("dist/") ? reg.scriptPath : `dist/${reg.scriptPath}`;
115053
- return ` // ${reg.blockName} - ${path13.basename(reg.scriptPath)}
115040
+ return ` // ${reg.blockName} - ${path12.basename(reg.scriptPath)}
115054
115041
  wp_register_script(
115055
115042
  '${reg.scriptHandle}',
115056
115043
  get_template_directory_uri() . '/${scriptPath}',
@@ -115063,8 +115050,12 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
115063
115050
 
115064
115051
  // src/build/worker-pool.ts
115065
115052
  import { Worker } from "worker_threads";
115066
- import * as path14 from "path";
115053
+ import * as path13 from "path";
115067
115054
  import * as os from "os";
115055
+ import { fileURLToPath as fileURLToPath4 } from "url";
115056
+ var __filename2 = fileURLToPath4(import.meta.url);
115057
+ var __dirname2 = path13.dirname(__filename2);
115058
+
115068
115059
  class WorkerPool {
115069
115060
  concurrency;
115070
115061
  outputDir;
@@ -115076,7 +115067,7 @@ class WorkerPool {
115076
115067
  this.outputDir = options.outputDir;
115077
115068
  this.webpackConfigPath = options.webpackConfigPath;
115078
115069
  this.scriptsPath = options.scriptsPath;
115079
- this.workerPath = path14.join(import.meta.dirname, "build", "block-build-worker.js");
115070
+ this.workerPath = path13.join(__dirname2, "build", "block-build-worker.js");
115080
115071
  }
115081
115072
  async buildAll(blocks, onProgress) {
115082
115073
  const results = [];
@@ -115123,7 +115114,7 @@ class WorkerPool {
115123
115114
  }
115124
115115
  buildBlockInWorker(block) {
115125
115116
  return new Promise((resolve5, reject) => {
115126
- const tempDir = path14.join(process.cwd(), ".wordpress-flow-temp", `worker-${block.name}-${Date.now()}`);
115117
+ const tempDir = path13.join(process.cwd(), ".wordpress-flow-temp", `worker-${block.name}-${Date.now()}`);
115127
115118
  const workerData = {
115128
115119
  block: {
115129
115120
  name: block.name,
@@ -115230,7 +115221,7 @@ class BuildCommand {
115230
115221
  if (block.scripts && block.scripts.length > 0) {
115231
115222
  const result2 = results.find((r) => r.blockName === block.name);
115232
115223
  if (result2?.success) {
115233
- const scriptPaths = block.scripts.map((script) => `scripts/${path15.basename(script).replace(/\.ts$/, ".js")}`);
115224
+ const scriptPaths = block.scripts.map((script) => `scripts/${path14.basename(script).replace(/\.ts$/, ".js")}`);
115234
115225
  this.blockScripts.set(block.name, scriptPaths);
115235
115226
  }
115236
115227
  }
@@ -115244,7 +115235,7 @@ Failed to build ${failures.length} block(s):`);
115244
115235
  }
115245
115236
  }
115246
115237
  if (this.blockScripts.size > 0) {
115247
- const phpPath = path15.join(path15.dirname(outputDir), "functions-blocks-scripts.php");
115238
+ const phpPath = path14.join(path14.dirname(outputDir), "functions-blocks-scripts.php");
115248
115239
  this.phpGenerator.generateScriptRegistrationPHP(this.blockScripts, phpPath);
115249
115240
  }
115250
115241
  await this.generateTypeDefinitions(outputDir);
@@ -115268,7 +115259,7 @@ Failed to build ${failures.length} block(s):`);
115268
115259
  logger.warn("No blocks found for type generation");
115269
115260
  return;
115270
115261
  }
115271
- const typesPath = path15.join(outputDir, "blocks.d.ts");
115262
+ const typesPath = path14.join(outputDir, "blocks.d.ts");
115272
115263
  await this.typeGenerator.generateDefinitions(blocks, typesPath);
115273
115264
  logger.success(`✅ Generated TypeScript definitions for ${blocks.length} block(s)`);
115274
115265
  } catch (error) {
@@ -115435,7 +115426,7 @@ class DevCommand {
115435
115426
  return new Promise(() => {});
115436
115427
  }
115437
115428
  handleFileEvent(eventType, filePath2, options) {
115438
- const fullPath = path16.resolve(this.configManager.resolvePath(this.configManager.getConfig().paths.mdxOutputDir), filePath2);
115429
+ const fullPath = path15.resolve(this.configManager.resolvePath(this.configManager.getConfig().paths.mdxOutputDir), filePath2);
115439
115430
  logger.debug(`File ${eventType}: ${filePath2}`);
115440
115431
  if (eventType === "unlink") {
115441
115432
  logger.warn(`File deleted: ${filePath2} - Manual WordPress cleanup may be required`);
@@ -115454,7 +115445,7 @@ class DevCommand {
115454
115445
  }
115455
115446
  async handleLocalFileChange(filePath2, options) {
115456
115447
  try {
115457
- logger.info(`\uD83D\uDD04 Processing local file change: ${path16.relative(process.cwd(), filePath2)}`);
115448
+ logger.info(`\uD83D\uDD04 Processing local file change: ${path15.relative(process.cwd(), filePath2)}`);
115458
115449
  await this.pushCommand.execute({
115459
115450
  files: [filePath2],
115460
115451
  force: options.conflictResolution === "local-wins",
@@ -115504,13 +115495,13 @@ class DevCommand {
115504
115495
  handleBlockFileEvent(eventType, filePath2, options) {
115505
115496
  const config2 = this.configManager.getConfig();
115506
115497
  const blocksDir = this.configManager.resolvePath(config2.build?.blocksDir || "./theme/blocks");
115507
- const fullPath = path16.resolve(blocksDir, filePath2);
115498
+ const fullPath = path15.resolve(blocksDir, filePath2);
115508
115499
  logger.debug(`Block file ${eventType}: ${filePath2}`);
115509
115500
  if (eventType === "unlink") {
115510
115501
  logger.warn(`Block file deleted: ${filePath2} - Manual cleanup may be required`);
115511
115502
  return;
115512
115503
  }
115513
- const blockName = path16.basename(filePath2, path16.extname(filePath2));
115504
+ const blockName = path15.basename(filePath2, path15.extname(filePath2));
115514
115505
  this.buildQueue.add(blockName);
115515
115506
  const debounceKey = `block-${blockName}`;
115516
115507
  const existingTimer = this.debounceTimers.get(debounceKey);
@@ -115580,8 +115571,8 @@ class DevCommand {
115580
115571
  const sourceBlocks = await this.blockScanner.scanBlocks(this.configManager.resolvePath(config2.build?.blocksDir || "./theme/blocks"));
115581
115572
  const missingBuilds = [];
115582
115573
  for (const block of sourceBlocks) {
115583
- const blockBuildDir = path16.join(outputDir, block.name);
115584
- const blockJsonPath = path16.join(blockBuildDir, "block.json");
115574
+ const blockBuildDir = path15.join(outputDir, block.name);
115575
+ const blockJsonPath = path15.join(blockBuildDir, "block.json");
115585
115576
  if (!fs14.existsSync(blockJsonPath)) {
115586
115577
  missingBuilds.push(block.name);
115587
115578
  }
@@ -115636,7 +115627,7 @@ class DevCommand {
115636
115627
  if (blocks.length === 0) {
115637
115628
  return;
115638
115629
  }
115639
- const typesPath = path16.join(outputDir, "blocks.d.ts");
115630
+ const typesPath = path15.join(outputDir, "blocks.d.ts");
115640
115631
  await this.typeGenerator.generateDefinitions(blocks, typesPath);
115641
115632
  logger.debug(`\uD83D\uDD27 Updated TypeScript definitions for ${blocks.length} block(s)`);
115642
115633
  } catch (error) {
@@ -115659,7 +115650,7 @@ class DevCommand {
115659
115650
  return;
115660
115651
  }
115661
115652
  logger.info(`\uD83D\uDCC4 Found ${dependentFiles.size} content file(s) that depend on changed blocks`);
115662
- logger.debug(`Dependent files: ${Array.from(dependentFiles).map((f) => path16.basename(f)).join(", ")}`);
115653
+ logger.debug(`Dependent files: ${Array.from(dependentFiles).map((f) => path15.basename(f)).join(", ")}`);
115663
115654
  const config2 = this.configManager.getConfig();
115664
115655
  const contentDir = this.configManager.resolvePath(config2.paths.mdxOutputDir);
115665
115656
  await this.mdxDependencyTracker.scanMDXDependencies(contentDir);
@@ -115694,7 +115685,7 @@ class DevCommand {
115694
115685
 
115695
115686
  // src/commands/build-templates-command.ts
115696
115687
  import * as fs15 from "fs";
115697
- import * as path17 from "path";
115688
+ import * as path16 from "path";
115698
115689
  class BuildTemplatesCommand {
115699
115690
  configManager;
115700
115691
  constructor() {
@@ -115736,8 +115727,8 @@ class BuildTemplatesCommand {
115736
115727
  let errorCount = 0;
115737
115728
  for (let i2 = 0;i2 < templateFiles.length; i2++) {
115738
115729
  const templateFile = templateFiles[i2];
115739
- const relativePath = path17.relative(templatesDir, templateFile);
115740
- const templateName = path17.basename(templateFile, ".mdx");
115730
+ const relativePath = path16.relative(templatesDir, templateFile);
115731
+ const templateName = path16.basename(templateFile, ".mdx");
115741
115732
  logger.step(i2 + 1, templateFiles.length, `Building template: ${relativePath}`);
115742
115733
  try {
115743
115734
  await this.buildTemplate(templateFile, templateName, outputDir, renderer);
@@ -115761,15 +115752,15 @@ class BuildTemplatesCommand {
115761
115752
  const cleanContent = this.removeFrontmatter(mdxContent);
115762
115753
  const html5 = await renderer.renderMDXToHTML(cleanContent);
115763
115754
  const cleanHTML = renderer.postProcessHTML(html5);
115764
- const outputPath = path17.join(outputDir, `${templateName}.html`);
115755
+ const outputPath = path16.join(outputDir, `${templateName}.html`);
115765
115756
  fs15.writeFileSync(outputPath, cleanHTML, "utf8");
115766
- logger.info(`✓ Generated: ${path17.relative(process.cwd(), outputPath)}`);
115757
+ logger.info(`✓ Generated: ${path16.relative(process.cwd(), outputPath)}`);
115767
115758
  }
115768
115759
  findMDXFiles(dir) {
115769
115760
  const files = [];
115770
115761
  const entries = fs15.readdirSync(dir, { withFileTypes: true });
115771
115762
  for (const entry of entries) {
115772
- const fullPath = path17.join(dir, entry.name);
115763
+ const fullPath = path16.join(dir, entry.name);
115773
115764
  if (entry.isDirectory()) {
115774
115765
  files.push(...this.findMDXFiles(fullPath));
115775
115766
  } else if (entry.isFile() && entry.name.endsWith(".mdx")) {
@@ -115786,7 +115777,7 @@ class BuildTemplatesCommand {
115786
115777
  // package.json
115787
115778
  var package_default = {
115788
115779
  name: "@wordpress-flow/cli",
115789
- version: "1.0.20",
115780
+ version: "1.0.22",
115790
115781
  type: "module",
115791
115782
  description: "TypeScript-based WordPress block creation system",
115792
115783
  main: "dist/index.js",
@@ -115794,7 +115785,7 @@ var package_default = {
115794
115785
  "wordpress-flow": "./dist/index.js"
115795
115786
  },
115796
115787
  scripts: {
115797
- build: "bun build ./src/index.ts --outdir ./dist --target node --external esbuild && bun build ./src/build/block-build-worker.ts --outfile ./dist/build/block-build-worker.js --target node --external esbuild"
115788
+ build: "bun build ./src/index.ts --outdir ./dist --target node --external esbuild --external webpack && bun build ./src/build/block-build-worker.ts --outfile ./dist/build/block-build-worker.js --target node --external esbuild --external webpack"
115798
115789
  },
115799
115790
  dependencies: {
115800
115791
  "@babel/core": "^7.28.4",
@@ -115813,18 +115804,24 @@ var package_default = {
115813
115804
  chokidar: "^3.5.3",
115814
115805
  commander: "^11.0.0",
115815
115806
  dotenv: "^17.2.3",
115816
- esbuild: "^0.19.0",
115817
115807
  glob: "^11.0.3",
115818
115808
  mysql2: "^3.15.2",
115819
115809
  react: "^18.3.1",
115820
115810
  "react-dom": "^18.3.1"
115821
115811
  },
115812
+ peerDependencies: {
115813
+ esbuild: "^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.24.0",
115814
+ webpack: "^5.0.0",
115815
+ "webpack-cli": "^5.0.0 || ^6.0.0"
115816
+ },
115822
115817
  devDependencies: {
115823
115818
  "@types/glob": "^9.0.0",
115824
115819
  "@types/mysql": "^2.15.27",
115825
115820
  "@types/node": "^20.0.0",
115826
115821
  "@wordpress/scripts": "^30.24.0",
115822
+ esbuild: "^0.19.0",
115827
115823
  typescript: "^5.0.0",
115824
+ webpack: "^5.97.0",
115828
115825
  "webpack-cli": "^6.0.1"
115829
115826
  },
115830
115827
  keywords: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "wordpress-flow": "./dist/index.js"
9
9
  },
10
10
  "scripts": {
11
- "build": "bun build ./src/index.ts --outdir ./dist --target node --external esbuild && bun build ./src/build/block-build-worker.ts --outfile ./dist/build/block-build-worker.js --target node --external esbuild"
11
+ "build": "bun build ./src/index.ts --outdir ./dist --target node --external esbuild --external webpack && bun build ./src/build/block-build-worker.ts --outfile ./dist/build/block-build-worker.js --target node --external esbuild --external webpack"
12
12
  },
13
13
  "dependencies": {
14
14
  "@babel/core": "^7.28.4",
@@ -27,18 +27,24 @@
27
27
  "chokidar": "^3.5.3",
28
28
  "commander": "^11.0.0",
29
29
  "dotenv": "^17.2.3",
30
- "esbuild": "^0.19.0",
31
30
  "glob": "^11.0.3",
32
31
  "mysql2": "^3.15.2",
33
32
  "react": "^18.3.1",
34
33
  "react-dom": "^18.3.1"
35
34
  },
35
+ "peerDependencies": {
36
+ "esbuild": "^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.24.0",
37
+ "webpack": "^5.0.0",
38
+ "webpack-cli": "^5.0.0 || ^6.0.0"
39
+ },
36
40
  "devDependencies": {
37
41
  "@types/glob": "^9.0.0",
38
42
  "@types/mysql": "^2.15.27",
39
43
  "@types/node": "^20.0.0",
40
44
  "@wordpress/scripts": "^30.24.0",
45
+ "esbuild": "^0.19.0",
41
46
  "typescript": "^5.0.0",
47
+ "webpack": "^5.97.0",
42
48
  "webpack-cli": "^6.0.1"
43
49
  },
44
50
  "keywords": [