@wordpress-flow/cli 1.0.14 → 1.0.15

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.
@@ -18,462 +18,6 @@ var __toESM = (mod, isNodeMode, target) => {
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
19
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
20
20
 
21
- // ../../node_modules/isexe/windows.js
22
- var require_windows = __commonJS((exports, module) => {
23
- module.exports = isexe;
24
- isexe.sync = sync;
25
- var fs = __require("fs");
26
- function checkPathExt(path, options) {
27
- var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
28
- if (!pathext) {
29
- return true;
30
- }
31
- pathext = pathext.split(";");
32
- if (pathext.indexOf("") !== -1) {
33
- return true;
34
- }
35
- for (var i = 0;i < pathext.length; i++) {
36
- var p = pathext[i].toLowerCase();
37
- if (p && path.substr(-p.length).toLowerCase() === p) {
38
- return true;
39
- }
40
- }
41
- return false;
42
- }
43
- function checkStat(stat, path, options) {
44
- if (!stat.isSymbolicLink() && !stat.isFile()) {
45
- return false;
46
- }
47
- return checkPathExt(path, options);
48
- }
49
- function isexe(path, options, cb) {
50
- fs.stat(path, function(er, stat) {
51
- cb(er, er ? false : checkStat(stat, path, options));
52
- });
53
- }
54
- function sync(path, options) {
55
- return checkStat(fs.statSync(path), path, options);
56
- }
57
- });
58
-
59
- // ../../node_modules/isexe/mode.js
60
- var require_mode = __commonJS((exports, module) => {
61
- module.exports = isexe;
62
- isexe.sync = sync;
63
- var fs = __require("fs");
64
- function isexe(path, options, cb) {
65
- fs.stat(path, function(er, stat) {
66
- cb(er, er ? false : checkStat(stat, options));
67
- });
68
- }
69
- function sync(path, options) {
70
- return checkStat(fs.statSync(path), options);
71
- }
72
- function checkStat(stat, options) {
73
- return stat.isFile() && checkMode(stat, options);
74
- }
75
- function checkMode(stat, options) {
76
- var mod = stat.mode;
77
- var uid = stat.uid;
78
- var gid = stat.gid;
79
- var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
80
- var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
81
- var u = parseInt("100", 8);
82
- var g = parseInt("010", 8);
83
- var o = parseInt("001", 8);
84
- var ug = u | g;
85
- var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
86
- return ret;
87
- }
88
- });
89
-
90
- // ../../node_modules/isexe/index.js
91
- var require_isexe = __commonJS((exports, module) => {
92
- var fs = __require("fs");
93
- var core;
94
- if (process.platform === "win32" || global.TESTING_WINDOWS) {
95
- core = require_windows();
96
- } else {
97
- core = require_mode();
98
- }
99
- module.exports = isexe;
100
- isexe.sync = sync;
101
- function isexe(path, options, cb) {
102
- if (typeof options === "function") {
103
- cb = options;
104
- options = {};
105
- }
106
- if (!cb) {
107
- if (typeof Promise !== "function") {
108
- throw new TypeError("callback not provided");
109
- }
110
- return new Promise(function(resolve, reject) {
111
- isexe(path, options || {}, function(er, is) {
112
- if (er) {
113
- reject(er);
114
- } else {
115
- resolve(is);
116
- }
117
- });
118
- });
119
- }
120
- core(path, options || {}, function(er, is) {
121
- if (er) {
122
- if (er.code === "EACCES" || options && options.ignoreErrors) {
123
- er = null;
124
- is = false;
125
- }
126
- }
127
- cb(er, is);
128
- });
129
- }
130
- function sync(path, options) {
131
- try {
132
- return core.sync(path, options || {});
133
- } catch (er) {
134
- if (options && options.ignoreErrors || er.code === "EACCES") {
135
- return false;
136
- } else {
137
- throw er;
138
- }
139
- }
140
- }
141
- });
142
-
143
- // ../../node_modules/which/which.js
144
- var require_which = __commonJS((exports, module) => {
145
- var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
146
- var path = __require("path");
147
- var COLON = isWindows ? ";" : ":";
148
- var isexe = require_isexe();
149
- var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
150
- var getPathInfo = (cmd, opt) => {
151
- const colon = opt.colon || COLON;
152
- const pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [""] : [
153
- ...isWindows ? [process.cwd()] : [],
154
- ...(opt.path || process.env.PATH || "").split(colon)
155
- ];
156
- const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
157
- const pathExt = isWindows ? pathExtExe.split(colon) : [""];
158
- if (isWindows) {
159
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
160
- pathExt.unshift("");
161
- }
162
- return {
163
- pathEnv,
164
- pathExt,
165
- pathExtExe
166
- };
167
- };
168
- var which = (cmd, opt, cb) => {
169
- if (typeof opt === "function") {
170
- cb = opt;
171
- opt = {};
172
- }
173
- if (!opt)
174
- opt = {};
175
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
176
- const found = [];
177
- const step = (i) => new Promise((resolve, reject) => {
178
- if (i === pathEnv.length)
179
- return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
180
- const ppRaw = pathEnv[i];
181
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
182
- const pCmd = path.join(pathPart, cmd);
183
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
184
- resolve(subStep(p, i, 0));
185
- });
186
- const subStep = (p, i, ii) => new Promise((resolve, reject) => {
187
- if (ii === pathExt.length)
188
- return resolve(step(i + 1));
189
- const ext = pathExt[ii];
190
- isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
191
- if (!er && is) {
192
- if (opt.all)
193
- found.push(p + ext);
194
- else
195
- return resolve(p + ext);
196
- }
197
- return resolve(subStep(p, i, ii + 1));
198
- });
199
- });
200
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
201
- };
202
- var whichSync = (cmd, opt) => {
203
- opt = opt || {};
204
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
205
- const found = [];
206
- for (let i = 0;i < pathEnv.length; i++) {
207
- const ppRaw = pathEnv[i];
208
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
209
- const pCmd = path.join(pathPart, cmd);
210
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
211
- for (let j = 0;j < pathExt.length; j++) {
212
- const cur = p + pathExt[j];
213
- try {
214
- const is = isexe.sync(cur, { pathExt: pathExtExe });
215
- if (is) {
216
- if (opt.all)
217
- found.push(cur);
218
- else
219
- return cur;
220
- }
221
- } catch (ex) {}
222
- }
223
- }
224
- if (opt.all && found.length)
225
- return found;
226
- if (opt.nothrow)
227
- return null;
228
- throw getNotFoundError(cmd);
229
- };
230
- module.exports = which;
231
- which.sync = whichSync;
232
- });
233
-
234
- // ../../node_modules/path-key/index.js
235
- var require_path_key = __commonJS((exports, module) => {
236
- var pathKey = (options = {}) => {
237
- const environment = options.env || process.env;
238
- const platform = options.platform || process.platform;
239
- if (platform !== "win32") {
240
- return "PATH";
241
- }
242
- return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
243
- };
244
- module.exports = pathKey;
245
- module.exports.default = pathKey;
246
- });
247
-
248
- // ../../node_modules/cross-spawn/lib/util/resolveCommand.js
249
- var require_resolveCommand = __commonJS((exports, module) => {
250
- var path = __require("path");
251
- var which = require_which();
252
- var getPathKey = require_path_key();
253
- function resolveCommandAttempt(parsed, withoutPathExt) {
254
- const env = parsed.options.env || process.env;
255
- const cwd = process.cwd();
256
- const hasCustomCwd = parsed.options.cwd != null;
257
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
258
- if (shouldSwitchCwd) {
259
- try {
260
- process.chdir(parsed.options.cwd);
261
- } catch (err) {}
262
- }
263
- let resolved;
264
- try {
265
- resolved = which.sync(parsed.command, {
266
- path: env[getPathKey({ env })],
267
- pathExt: withoutPathExt ? path.delimiter : undefined
268
- });
269
- } catch (e) {} finally {
270
- if (shouldSwitchCwd) {
271
- process.chdir(cwd);
272
- }
273
- }
274
- if (resolved) {
275
- resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
276
- }
277
- return resolved;
278
- }
279
- function resolveCommand(parsed) {
280
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
281
- }
282
- module.exports = resolveCommand;
283
- });
284
-
285
- // ../../node_modules/cross-spawn/lib/util/escape.js
286
- var require_escape = __commonJS((exports, module) => {
287
- var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
288
- function escapeCommand(arg) {
289
- arg = arg.replace(metaCharsRegExp, "^$1");
290
- return arg;
291
- }
292
- function escapeArgument(arg, doubleEscapeMetaChars) {
293
- arg = `${arg}`;
294
- arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
295
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
296
- arg = `"${arg}"`;
297
- arg = arg.replace(metaCharsRegExp, "^$1");
298
- if (doubleEscapeMetaChars) {
299
- arg = arg.replace(metaCharsRegExp, "^$1");
300
- }
301
- return arg;
302
- }
303
- exports.command = escapeCommand;
304
- exports.argument = escapeArgument;
305
- });
306
-
307
- // ../../node_modules/shebang-regex/index.js
308
- var require_shebang_regex = __commonJS((exports, module) => {
309
- module.exports = /^#!(.*)/;
310
- });
311
-
312
- // ../../node_modules/shebang-command/index.js
313
- var require_shebang_command = __commonJS((exports, module) => {
314
- var shebangRegex = require_shebang_regex();
315
- module.exports = (string = "") => {
316
- const match = string.match(shebangRegex);
317
- if (!match) {
318
- return null;
319
- }
320
- const [path, argument] = match[0].replace(/#! ?/, "").split(" ");
321
- const binary = path.split("/").pop();
322
- if (binary === "env") {
323
- return argument;
324
- }
325
- return argument ? `${binary} ${argument}` : binary;
326
- };
327
- });
328
-
329
- // ../../node_modules/cross-spawn/lib/util/readShebang.js
330
- var require_readShebang = __commonJS((exports, module) => {
331
- var fs = __require("fs");
332
- var shebangCommand = require_shebang_command();
333
- function readShebang(command) {
334
- const size = 150;
335
- const buffer = Buffer.alloc(size);
336
- let fd;
337
- try {
338
- fd = fs.openSync(command, "r");
339
- fs.readSync(fd, buffer, 0, size, 0);
340
- fs.closeSync(fd);
341
- } catch (e) {}
342
- return shebangCommand(buffer.toString());
343
- }
344
- module.exports = readShebang;
345
- });
346
-
347
- // ../../node_modules/cross-spawn/lib/parse.js
348
- var require_parse = __commonJS((exports, module) => {
349
- var path = __require("path");
350
- var resolveCommand = require_resolveCommand();
351
- var escape = require_escape();
352
- var readShebang = require_readShebang();
353
- var isWin = process.platform === "win32";
354
- var isExecutableRegExp = /\.(?:com|exe)$/i;
355
- var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
356
- function detectShebang(parsed) {
357
- parsed.file = resolveCommand(parsed);
358
- const shebang = parsed.file && readShebang(parsed.file);
359
- if (shebang) {
360
- parsed.args.unshift(parsed.file);
361
- parsed.command = shebang;
362
- return resolveCommand(parsed);
363
- }
364
- return parsed.file;
365
- }
366
- function parseNonShell(parsed) {
367
- if (!isWin) {
368
- return parsed;
369
- }
370
- const commandFile = detectShebang(parsed);
371
- const needsShell = !isExecutableRegExp.test(commandFile);
372
- if (parsed.options.forceShell || needsShell) {
373
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
374
- parsed.command = path.normalize(parsed.command);
375
- parsed.command = escape.command(parsed.command);
376
- parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
377
- const shellCommand = [parsed.command].concat(parsed.args).join(" ");
378
- parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
379
- parsed.command = process.env.comspec || "cmd.exe";
380
- parsed.options.windowsVerbatimArguments = true;
381
- }
382
- return parsed;
383
- }
384
- function parse(command, args, options) {
385
- if (args && !Array.isArray(args)) {
386
- options = args;
387
- args = null;
388
- }
389
- args = args ? args.slice(0) : [];
390
- options = Object.assign({}, options);
391
- const parsed = {
392
- command,
393
- args,
394
- options,
395
- file: undefined,
396
- original: {
397
- command,
398
- args
399
- }
400
- };
401
- return options.shell ? parsed : parseNonShell(parsed);
402
- }
403
- module.exports = parse;
404
- });
405
-
406
- // ../../node_modules/cross-spawn/lib/enoent.js
407
- var require_enoent = __commonJS((exports, module) => {
408
- var isWin = process.platform === "win32";
409
- function notFoundError(original, syscall) {
410
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
411
- code: "ENOENT",
412
- errno: "ENOENT",
413
- syscall: `${syscall} ${original.command}`,
414
- path: original.command,
415
- spawnargs: original.args
416
- });
417
- }
418
- function hookChildProcess(cp, parsed) {
419
- if (!isWin) {
420
- return;
421
- }
422
- const originalEmit = cp.emit;
423
- cp.emit = function(name, arg1) {
424
- if (name === "exit") {
425
- const err = verifyENOENT(arg1, parsed);
426
- if (err) {
427
- return originalEmit.call(cp, "error", err);
428
- }
429
- }
430
- return originalEmit.apply(cp, arguments);
431
- };
432
- }
433
- function verifyENOENT(status, parsed) {
434
- if (isWin && status === 1 && !parsed.file) {
435
- return notFoundError(parsed.original, "spawn");
436
- }
437
- return null;
438
- }
439
- function verifyENOENTSync(status, parsed) {
440
- if (isWin && status === 1 && !parsed.file) {
441
- return notFoundError(parsed.original, "spawnSync");
442
- }
443
- return null;
444
- }
445
- module.exports = {
446
- hookChildProcess,
447
- verifyENOENT,
448
- verifyENOENTSync,
449
- notFoundError
450
- };
451
- });
452
-
453
- // ../../node_modules/cross-spawn/index.js
454
- var require_cross_spawn = __commonJS((exports, module) => {
455
- var cp = __require("child_process");
456
- var parse = require_parse();
457
- var enoent = require_enoent();
458
- function spawn(command, args, options) {
459
- const parsed = parse(command, args, options);
460
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
461
- enoent.hookChildProcess(spawned, parsed);
462
- return spawned;
463
- }
464
- function spawnSync(command, args, options) {
465
- const parsed = parse(command, args, options);
466
- const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
467
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
468
- return result;
469
- }
470
- module.exports = spawn;
471
- module.exports.spawn = spawn;
472
- module.exports.sync = spawnSync;
473
- module.exports._parse = parse;
474
- module.exports._enoent = enoent;
475
- });
476
-
477
21
  // ../../node_modules/react/cjs/react.development.js
478
22
  var require_react_development = __commonJS((exports, module) => {
479
23
  if (true) {
@@ -2286,12 +1830,12 @@ var require_react = __commonJS((exports, module) => {
2286
1830
  });
2287
1831
 
2288
1832
  // src/build/block-build-worker.ts
2289
- var import_cross_spawn = __toESM(require_cross_spawn(), 1);
2290
1833
  var react = __toESM(require_react(), 1);
2291
1834
  import { parentPort, workerData } from "worker_threads";
2292
1835
  import * as path from "path";
2293
1836
  import * as fs from "fs";
2294
1837
  import * as esbuild from "esbuild";
1838
+ import { execSync } from "child_process";
2295
1839
  async function buildBlock() {
2296
1840
  const { block, outputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
2297
1841
  try {
@@ -2483,33 +2027,25 @@ function parseBlockJsonFromSource(block) {
2483
2027
  };
2484
2028
  }
2485
2029
  async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2486
- const args = getWebpackArgs(webpackConfigPath, entryPoint, outputDir);
2487
- const result = import_cross_spawn.default.sync("npx", args, {
2030
+ const webpackBinary = findWebpackBinary();
2031
+ const command = `${webpackBinary} --config "${webpackConfigPath}" --env entry="${entryPoint}" --env output="${outputDir}" --mode production`;
2032
+ execSync(command, {
2488
2033
  cwd: path.dirname(webpackConfigPath),
2489
- stdio: "pipe",
2490
- env: { ...process.env }
2034
+ encoding: "utf8",
2035
+ stdio: "pipe"
2491
2036
  });
2492
- if (result.error) {
2493
- throw result.error;
2494
- }
2495
- if (result.status !== 0) {
2496
- const stderr = result.stderr?.toString() || "";
2497
- const stdout = result.stdout?.toString() || "";
2498
- throw new Error(`Webpack build failed (exit code ${result.status}): ${stderr || stdout}`);
2499
- }
2500
2037
  }
2501
- function getWebpackArgs(configPath, entryPoint, outputDir) {
2502
- return [
2503
- "webpack",
2504
- "--config",
2505
- configPath,
2506
- "--env",
2507
- `entry=${entryPoint}`,
2508
- "--env",
2509
- `output=${outputDir}`,
2510
- "--mode",
2511
- "production"
2038
+ function findWebpackBinary() {
2039
+ const possiblePaths = [
2040
+ path.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
2041
+ path.join(process.cwd(), "node_modules", ".bin", "webpack")
2512
2042
  ];
2043
+ for (const webpackPath of possiblePaths) {
2044
+ if (fs.existsSync(webpackPath)) {
2045
+ return webpackPath;
2046
+ }
2047
+ }
2048
+ return "npx webpack";
2513
2049
  }
2514
2050
  function verifyBuildOutput(outputDir) {
2515
2051
  const requiredFiles = ["block.json", "index.js", "ssr.js"];
package/dist/index.js CHANGED
@@ -81051,462 +81051,6 @@ var require_fsevents_handler = __commonJS((exports, module) => {
81051
81051
  module.exports.canUse = canUse;
81052
81052
  });
81053
81053
 
81054
- // ../../node_modules/isexe/windows.js
81055
- var require_windows = __commonJS((exports, module) => {
81056
- module.exports = isexe;
81057
- isexe.sync = sync2;
81058
- var fs15 = __require("fs");
81059
- function checkPathExt(path17, options) {
81060
- var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
81061
- if (!pathext) {
81062
- return true;
81063
- }
81064
- pathext = pathext.split(";");
81065
- if (pathext.indexOf("") !== -1) {
81066
- return true;
81067
- }
81068
- for (var i2 = 0;i2 < pathext.length; i2++) {
81069
- var p = pathext[i2].toLowerCase();
81070
- if (p && path17.substr(-p.length).toLowerCase() === p) {
81071
- return true;
81072
- }
81073
- }
81074
- return false;
81075
- }
81076
- function checkStat(stat2, path17, options) {
81077
- if (!stat2.isSymbolicLink() && !stat2.isFile()) {
81078
- return false;
81079
- }
81080
- return checkPathExt(path17, options);
81081
- }
81082
- function isexe(path17, options, cb) {
81083
- fs15.stat(path17, function(er, stat2) {
81084
- cb(er, er ? false : checkStat(stat2, path17, options));
81085
- });
81086
- }
81087
- function sync2(path17, options) {
81088
- return checkStat(fs15.statSync(path17), path17, options);
81089
- }
81090
- });
81091
-
81092
- // ../../node_modules/isexe/mode.js
81093
- var require_mode = __commonJS((exports, module) => {
81094
- module.exports = isexe;
81095
- isexe.sync = sync2;
81096
- var fs15 = __require("fs");
81097
- function isexe(path17, options, cb) {
81098
- fs15.stat(path17, function(er, stat2) {
81099
- cb(er, er ? false : checkStat(stat2, options));
81100
- });
81101
- }
81102
- function sync2(path17, options) {
81103
- return checkStat(fs15.statSync(path17), options);
81104
- }
81105
- function checkStat(stat2, options) {
81106
- return stat2.isFile() && checkMode(stat2, options);
81107
- }
81108
- function checkMode(stat2, options) {
81109
- var mod = stat2.mode;
81110
- var uid = stat2.uid;
81111
- var gid = stat2.gid;
81112
- var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
81113
- var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
81114
- var u = parseInt("100", 8);
81115
- var g = parseInt("010", 8);
81116
- var o = parseInt("001", 8);
81117
- var ug = u | g;
81118
- var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
81119
- return ret;
81120
- }
81121
- });
81122
-
81123
- // ../../node_modules/isexe/index.js
81124
- var require_isexe = __commonJS((exports, module) => {
81125
- var fs15 = __require("fs");
81126
- var core2;
81127
- if (process.platform === "win32" || global.TESTING_WINDOWS) {
81128
- core2 = require_windows();
81129
- } else {
81130
- core2 = require_mode();
81131
- }
81132
- module.exports = isexe;
81133
- isexe.sync = sync2;
81134
- function isexe(path17, options, cb) {
81135
- if (typeof options === "function") {
81136
- cb = options;
81137
- options = {};
81138
- }
81139
- if (!cb) {
81140
- if (typeof Promise !== "function") {
81141
- throw new TypeError("callback not provided");
81142
- }
81143
- return new Promise(function(resolve6, reject) {
81144
- isexe(path17, options || {}, function(er, is2) {
81145
- if (er) {
81146
- reject(er);
81147
- } else {
81148
- resolve6(is2);
81149
- }
81150
- });
81151
- });
81152
- }
81153
- core2(path17, options || {}, function(er, is2) {
81154
- if (er) {
81155
- if (er.code === "EACCES" || options && options.ignoreErrors) {
81156
- er = null;
81157
- is2 = false;
81158
- }
81159
- }
81160
- cb(er, is2);
81161
- });
81162
- }
81163
- function sync2(path17, options) {
81164
- try {
81165
- return core2.sync(path17, options || {});
81166
- } catch (er) {
81167
- if (options && options.ignoreErrors || er.code === "EACCES") {
81168
- return false;
81169
- } else {
81170
- throw er;
81171
- }
81172
- }
81173
- }
81174
- });
81175
-
81176
- // ../../node_modules/which/which.js
81177
- var require_which = __commonJS((exports, module) => {
81178
- var isWindows2 = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
81179
- var path17 = __require("path");
81180
- var COLON = isWindows2 ? ";" : ":";
81181
- var isexe = require_isexe();
81182
- var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
81183
- var getPathInfo = (cmd, opt) => {
81184
- const colon = opt.colon || COLON;
81185
- const pathEnv = cmd.match(/\//) || isWindows2 && cmd.match(/\\/) ? [""] : [
81186
- ...isWindows2 ? [process.cwd()] : [],
81187
- ...(opt.path || process.env.PATH || "").split(colon)
81188
- ];
81189
- const pathExtExe = isWindows2 ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
81190
- const pathExt = isWindows2 ? pathExtExe.split(colon) : [""];
81191
- if (isWindows2) {
81192
- if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
81193
- pathExt.unshift("");
81194
- }
81195
- return {
81196
- pathEnv,
81197
- pathExt,
81198
- pathExtExe
81199
- };
81200
- };
81201
- var which = (cmd, opt, cb) => {
81202
- if (typeof opt === "function") {
81203
- cb = opt;
81204
- opt = {};
81205
- }
81206
- if (!opt)
81207
- opt = {};
81208
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
81209
- const found = [];
81210
- const step = (i2) => new Promise((resolve6, reject) => {
81211
- if (i2 === pathEnv.length)
81212
- return opt.all && found.length ? resolve6(found) : reject(getNotFoundError(cmd));
81213
- const ppRaw = pathEnv[i2];
81214
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
81215
- const pCmd = path17.join(pathPart, cmd);
81216
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
81217
- resolve6(subStep(p, i2, 0));
81218
- });
81219
- const subStep = (p, i2, ii) => new Promise((resolve6, reject) => {
81220
- if (ii === pathExt.length)
81221
- return resolve6(step(i2 + 1));
81222
- const ext2 = pathExt[ii];
81223
- isexe(p + ext2, { pathExt: pathExtExe }, (er, is2) => {
81224
- if (!er && is2) {
81225
- if (opt.all)
81226
- found.push(p + ext2);
81227
- else
81228
- return resolve6(p + ext2);
81229
- }
81230
- return resolve6(subStep(p, i2, ii + 1));
81231
- });
81232
- });
81233
- return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
81234
- };
81235
- var whichSync = (cmd, opt) => {
81236
- opt = opt || {};
81237
- const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
81238
- const found = [];
81239
- for (let i2 = 0;i2 < pathEnv.length; i2++) {
81240
- const ppRaw = pathEnv[i2];
81241
- const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
81242
- const pCmd = path17.join(pathPart, cmd);
81243
- const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
81244
- for (let j = 0;j < pathExt.length; j++) {
81245
- const cur = p + pathExt[j];
81246
- try {
81247
- const is2 = isexe.sync(cur, { pathExt: pathExtExe });
81248
- if (is2) {
81249
- if (opt.all)
81250
- found.push(cur);
81251
- else
81252
- return cur;
81253
- }
81254
- } catch (ex) {}
81255
- }
81256
- }
81257
- if (opt.all && found.length)
81258
- return found;
81259
- if (opt.nothrow)
81260
- return null;
81261
- throw getNotFoundError(cmd);
81262
- };
81263
- module.exports = which;
81264
- which.sync = whichSync;
81265
- });
81266
-
81267
- // ../../node_modules/path-key/index.js
81268
- var require_path_key = __commonJS((exports, module) => {
81269
- var pathKey = (options = {}) => {
81270
- const environment = options.env || process.env;
81271
- const platform = options.platform || process.platform;
81272
- if (platform !== "win32") {
81273
- return "PATH";
81274
- }
81275
- return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
81276
- };
81277
- module.exports = pathKey;
81278
- module.exports.default = pathKey;
81279
- });
81280
-
81281
- // ../../node_modules/cross-spawn/lib/util/resolveCommand.js
81282
- var require_resolveCommand = __commonJS((exports, module) => {
81283
- var path17 = __require("path");
81284
- var which = require_which();
81285
- var getPathKey = require_path_key();
81286
- function resolveCommandAttempt(parsed, withoutPathExt) {
81287
- const env2 = parsed.options.env || process.env;
81288
- const cwd = process.cwd();
81289
- const hasCustomCwd = parsed.options.cwd != null;
81290
- const shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
81291
- if (shouldSwitchCwd) {
81292
- try {
81293
- process.chdir(parsed.options.cwd);
81294
- } catch (err) {}
81295
- }
81296
- let resolved;
81297
- try {
81298
- resolved = which.sync(parsed.command, {
81299
- path: env2[getPathKey({ env: env2 })],
81300
- pathExt: withoutPathExt ? path17.delimiter : undefined
81301
- });
81302
- } catch (e) {} finally {
81303
- if (shouldSwitchCwd) {
81304
- process.chdir(cwd);
81305
- }
81306
- }
81307
- if (resolved) {
81308
- resolved = path17.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
81309
- }
81310
- return resolved;
81311
- }
81312
- function resolveCommand(parsed) {
81313
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
81314
- }
81315
- module.exports = resolveCommand;
81316
- });
81317
-
81318
- // ../../node_modules/cross-spawn/lib/util/escape.js
81319
- var require_escape = __commonJS((exports, module) => {
81320
- var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
81321
- function escapeCommand(arg) {
81322
- arg = arg.replace(metaCharsRegExp, "^$1");
81323
- return arg;
81324
- }
81325
- function escapeArgument(arg, doubleEscapeMetaChars) {
81326
- arg = `${arg}`;
81327
- arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
81328
- arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
81329
- arg = `"${arg}"`;
81330
- arg = arg.replace(metaCharsRegExp, "^$1");
81331
- if (doubleEscapeMetaChars) {
81332
- arg = arg.replace(metaCharsRegExp, "^$1");
81333
- }
81334
- return arg;
81335
- }
81336
- exports.command = escapeCommand;
81337
- exports.argument = escapeArgument;
81338
- });
81339
-
81340
- // ../../node_modules/shebang-regex/index.js
81341
- var require_shebang_regex = __commonJS((exports, module) => {
81342
- module.exports = /^#!(.*)/;
81343
- });
81344
-
81345
- // ../../node_modules/shebang-command/index.js
81346
- var require_shebang_command = __commonJS((exports, module) => {
81347
- var shebangRegex = require_shebang_regex();
81348
- module.exports = (string3 = "") => {
81349
- const match2 = string3.match(shebangRegex);
81350
- if (!match2) {
81351
- return null;
81352
- }
81353
- const [path17, argument] = match2[0].replace(/#! ?/, "").split(" ");
81354
- const binary = path17.split("/").pop();
81355
- if (binary === "env") {
81356
- return argument;
81357
- }
81358
- return argument ? `${binary} ${argument}` : binary;
81359
- };
81360
- });
81361
-
81362
- // ../../node_modules/cross-spawn/lib/util/readShebang.js
81363
- var require_readShebang = __commonJS((exports, module) => {
81364
- var fs15 = __require("fs");
81365
- var shebangCommand = require_shebang_command();
81366
- function readShebang(command) {
81367
- const size = 150;
81368
- const buffer = Buffer.alloc(size);
81369
- let fd;
81370
- try {
81371
- fd = fs15.openSync(command, "r");
81372
- fs15.readSync(fd, buffer, 0, size, 0);
81373
- fs15.closeSync(fd);
81374
- } catch (e) {}
81375
- return shebangCommand(buffer.toString());
81376
- }
81377
- module.exports = readShebang;
81378
- });
81379
-
81380
- // ../../node_modules/cross-spawn/lib/parse.js
81381
- var require_parse3 = __commonJS((exports, module) => {
81382
- var path17 = __require("path");
81383
- var resolveCommand = require_resolveCommand();
81384
- var escape2 = require_escape();
81385
- var readShebang = require_readShebang();
81386
- var isWin = process.platform === "win32";
81387
- var isExecutableRegExp = /\.(?:com|exe)$/i;
81388
- var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
81389
- function detectShebang(parsed) {
81390
- parsed.file = resolveCommand(parsed);
81391
- const shebang = parsed.file && readShebang(parsed.file);
81392
- if (shebang) {
81393
- parsed.args.unshift(parsed.file);
81394
- parsed.command = shebang;
81395
- return resolveCommand(parsed);
81396
- }
81397
- return parsed.file;
81398
- }
81399
- function parseNonShell(parsed) {
81400
- if (!isWin) {
81401
- return parsed;
81402
- }
81403
- const commandFile = detectShebang(parsed);
81404
- const needsShell = !isExecutableRegExp.test(commandFile);
81405
- if (parsed.options.forceShell || needsShell) {
81406
- const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
81407
- parsed.command = path17.normalize(parsed.command);
81408
- parsed.command = escape2.command(parsed.command);
81409
- parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
81410
- const shellCommand = [parsed.command].concat(parsed.args).join(" ");
81411
- parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
81412
- parsed.command = process.env.comspec || "cmd.exe";
81413
- parsed.options.windowsVerbatimArguments = true;
81414
- }
81415
- return parsed;
81416
- }
81417
- function parse5(command, args, options) {
81418
- if (args && !Array.isArray(args)) {
81419
- options = args;
81420
- args = null;
81421
- }
81422
- args = args ? args.slice(0) : [];
81423
- options = Object.assign({}, options);
81424
- const parsed = {
81425
- command,
81426
- args,
81427
- options,
81428
- file: undefined,
81429
- original: {
81430
- command,
81431
- args
81432
- }
81433
- };
81434
- return options.shell ? parsed : parseNonShell(parsed);
81435
- }
81436
- module.exports = parse5;
81437
- });
81438
-
81439
- // ../../node_modules/cross-spawn/lib/enoent.js
81440
- var require_enoent = __commonJS((exports, module) => {
81441
- var isWin = process.platform === "win32";
81442
- function notFoundError(original, syscall) {
81443
- return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
81444
- code: "ENOENT",
81445
- errno: "ENOENT",
81446
- syscall: `${syscall} ${original.command}`,
81447
- path: original.command,
81448
- spawnargs: original.args
81449
- });
81450
- }
81451
- function hookChildProcess(cp, parsed) {
81452
- if (!isWin) {
81453
- return;
81454
- }
81455
- const originalEmit = cp.emit;
81456
- cp.emit = function(name2, arg1) {
81457
- if (name2 === "exit") {
81458
- const err = verifyENOENT(arg1, parsed);
81459
- if (err) {
81460
- return originalEmit.call(cp, "error", err);
81461
- }
81462
- }
81463
- return originalEmit.apply(cp, arguments);
81464
- };
81465
- }
81466
- function verifyENOENT(status, parsed) {
81467
- if (isWin && status === 1 && !parsed.file) {
81468
- return notFoundError(parsed.original, "spawn");
81469
- }
81470
- return null;
81471
- }
81472
- function verifyENOENTSync(status, parsed) {
81473
- if (isWin && status === 1 && !parsed.file) {
81474
- return notFoundError(parsed.original, "spawnSync");
81475
- }
81476
- return null;
81477
- }
81478
- module.exports = {
81479
- hookChildProcess,
81480
- verifyENOENT,
81481
- verifyENOENTSync,
81482
- notFoundError
81483
- };
81484
- });
81485
-
81486
- // ../../node_modules/cross-spawn/index.js
81487
- var require_cross_spawn = __commonJS((exports, module) => {
81488
- var cp = __require("child_process");
81489
- var parse5 = require_parse3();
81490
- var enoent = require_enoent();
81491
- function spawn(command, args, options) {
81492
- const parsed = parse5(command, args, options);
81493
- const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
81494
- enoent.hookChildProcess(spawned, parsed);
81495
- return spawned;
81496
- }
81497
- function spawnSync(command, args, options) {
81498
- const parsed = parse5(command, args, options);
81499
- const result2 = cp.spawnSync(parsed.command, parsed.args, parsed.options);
81500
- result2.error = result2.error || enoent.verifyENOENTSync(result2.status, parsed);
81501
- return result2;
81502
- }
81503
- module.exports = spawn;
81504
- module.exports.spawn = spawn;
81505
- module.exports.sync = spawnSync;
81506
- module.exports._parse = parse5;
81507
- module.exports._enoent = enoent;
81508
- });
81509
-
81510
81054
  // ../../node_modules/commander/esm.mjs
81511
81055
  var import__ = __toESM(require_commander(), 1);
81512
81056
  var {
@@ -115255,7 +114799,7 @@ class BlockScanner {
115255
114799
  }
115256
114800
 
115257
114801
  // src/build/abortable-worker-pool.ts
115258
- import { Worker } from "worker_threads";
114802
+ import { Worker, SHARE_ENV } from "worker_threads";
115259
114803
  import * as path9 from "path";
115260
114804
  import * as os from "os";
115261
114805
  class AbortableWorkerPool {
@@ -115373,7 +114917,7 @@ class AbortableWorkerPool {
115373
114917
  };
115374
114918
  const worker = new Worker(this.workerPath, {
115375
114919
  workerData,
115376
- env: process.env
114920
+ env: SHARE_ENV
115377
114921
  });
115378
114922
  const startTime = Date.now();
115379
114923
  const activeWorker = {
@@ -116340,7 +115884,7 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
116340
115884
  // package.json
116341
115885
  var package_default = {
116342
115886
  name: "@wordpress-flow/cli",
116343
- version: "1.0.14",
115887
+ version: "1.0.15",
116344
115888
  type: "module",
116345
115889
  description: "TypeScript-based WordPress block creation system",
116346
115890
  main: "dist/index.js",
@@ -116864,9 +116408,9 @@ import * as fs17 from "fs";
116864
116408
  import * as path19 from "path";
116865
116409
 
116866
116410
  // src/build/webpack-runner.ts
116867
- var import_cross_spawn = __toESM(require_cross_spawn(), 1);
116868
116411
  import * as path17 from "path";
116869
116412
  import * as fs15 from "fs";
116413
+ import { execSync } from "child_process";
116870
116414
  var import_chalk3 = __toESM(require_source(), 1);
116871
116415
 
116872
116416
  class WebpackRunner {
@@ -116887,68 +116431,67 @@ class WebpackRunner {
116887
116431
  throw new Error(error);
116888
116432
  }
116889
116433
  fs15.mkdirSync(outputDir, { recursive: true });
116890
- const args = [
116891
- "webpack",
116892
- "--config",
116893
- webpackConfigPath,
116894
- "--env",
116895
- `entry=${entryPoint}`,
116896
- "--env",
116897
- `output=${outputDir}`,
116898
- "--mode",
116899
- "production"
116900
- ];
116901
- logger.debug(`Full command: npx ${args.join(" ")}`);
116434
+ const webpackBinary = this.findWebpackBinary();
116435
+ logger.debug(`Using webpack binary: ${webpackBinary}`);
116436
+ const command = `${webpackBinary} --config "${webpackConfigPath}" --env entry="${entryPoint}" --env output="${outputDir}" --mode production`;
116437
+ logger.debug(`Full command: ${command}`);
116902
116438
  const workingDir = path17.dirname(webpackConfigPath);
116903
116439
  logger.debug(`Running webpack from directory: ${workingDir}`);
116904
- const result2 = import_cross_spawn.default.sync("npx", args, {
116905
- cwd: workingDir,
116906
- stdio: "pipe",
116907
- env: { ...process.env }
116908
- });
116909
- if (result2.error) {
116910
- console.error("");
116911
- console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116912
- console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
116913
- console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116914
- console.error("");
116915
- console.error(import_chalk3.default.yellow("Error:"));
116916
- console.error(import_chalk3.default.gray(result2.error.message));
116917
- console.error("");
116918
- console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116919
- console.error("");
116920
- throw result2.error;
116921
- }
116922
- if (result2.status !== 0) {
116923
- const stderr = result2.stderr?.toString() || "";
116924
- const stdout = result2.stdout?.toString() || "";
116440
+ try {
116441
+ const output2 = execSync(command, {
116442
+ cwd: workingDir,
116443
+ encoding: "utf8",
116444
+ stdio: "pipe"
116445
+ });
116446
+ logger.debug("Webpack build completed successfully");
116447
+ logger.debug(`Output: ${output2}`);
116448
+ } catch (error) {
116925
116449
  console.error("");
116926
116450
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116927
116451
  console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
116928
116452
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116929
116453
  console.error("");
116930
116454
  console.error(import_chalk3.default.yellow("Command that failed:"));
116931
- console.error(import_chalk3.default.gray(`npx ${args.join(" ")}`));
116455
+ console.error(import_chalk3.default.gray(command));
116932
116456
  console.error("");
116933
116457
  console.error(import_chalk3.default.yellow("Working directory:"));
116934
116458
  console.error(import_chalk3.default.gray(workingDir));
116935
116459
  console.error("");
116936
- if (stdout.trim()) {
116460
+ if (error.stdout?.trim()) {
116937
116461
  console.error(import_chalk3.default.yellow("Standard output:"));
116938
- console.error(stdout);
116462
+ console.error(error.stdout);
116939
116463
  console.error("");
116940
116464
  }
116941
- if (stderr.trim()) {
116465
+ if (error.stderr?.trim()) {
116942
116466
  console.error(import_chalk3.default.yellow("Error output:"));
116943
- console.error(stderr);
116467
+ console.error(error.stderr);
116468
+ console.error("");
116469
+ }
116470
+ if (!error.stdout && !error.stderr) {
116471
+ console.error(import_chalk3.default.yellow("Error message:"));
116472
+ console.error(error.message);
116944
116473
  console.error("");
116945
116474
  }
116946
116475
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116947
116476
  console.error("");
116948
- throw new Error(`Webpack build failed (exit code ${result2.status})`);
116477
+ throw new Error(`Webpack build failed`);
116478
+ }
116479
+ }
116480
+ findWebpackBinary() {
116481
+ const possiblePaths = [
116482
+ path17.join(process.cwd(), "packages", "block", "node_modules", ".bin", "webpack"),
116483
+ path17.join(process.cwd(), "node_modules", ".bin", "webpack"),
116484
+ path17.join(import.meta.dirname, "..", "..", "..", "node_modules", ".bin", "webpack"),
116485
+ path17.join(process.cwd(), "..", "node_modules", ".bin", "webpack")
116486
+ ];
116487
+ for (const webpackPath of possiblePaths) {
116488
+ if (fs15.existsSync(webpackPath)) {
116489
+ logger.debug(`Found webpack at: ${webpackPath}`);
116490
+ return webpackPath;
116491
+ }
116949
116492
  }
116950
- logger.debug("Webpack build completed successfully");
116951
- logger.debug(`Output: ${result2.stdout?.toString() || ""}`);
116493
+ logger.debug("Using npx webpack as fallback");
116494
+ return "npx webpack";
116952
116495
  }
116953
116496
  }
116954
116497
 
@@ -117326,7 +116869,7 @@ if (document.readyState === 'loading') {
117326
116869
  }
117327
116870
 
117328
116871
  // src/build/worker-pool.ts
117329
- import { Worker as Worker2 } from "worker_threads";
116872
+ import { Worker as Worker2, SHARE_ENV as SHARE_ENV2 } from "worker_threads";
117330
116873
  import * as path20 from "path";
117331
116874
  import * as os2 from "os";
117332
116875
  class WorkerPool {
@@ -117418,7 +116961,7 @@ class WorkerPool {
117418
116961
  };
117419
116962
  const worker = new Worker2(this.workerPath, {
117420
116963
  workerData,
117421
- env: process.env
116964
+ env: SHARE_ENV2
117422
116965
  });
117423
116966
  const timeout = setTimeout(() => {
117424
116967
  worker.terminate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",