@wordpress-flow/cli 1.0.12 → 1.0.13

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,6 +18,462 @@ 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
+
21
477
  // ../../node_modules/react/cjs/react.development.js
22
478
  var require_react_development = __commonJS((exports, module) => {
23
479
  if (true) {
@@ -1830,12 +2286,12 @@ var require_react = __commonJS((exports, module) => {
1830
2286
  });
1831
2287
 
1832
2288
  // src/build/block-build-worker.ts
2289
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
1833
2290
  var react = __toESM(require_react(), 1);
1834
2291
  import { parentPort, workerData } from "worker_threads";
1835
2292
  import * as path from "path";
1836
2293
  import * as fs from "fs";
1837
2294
  import * as esbuild from "esbuild";
1838
- import { execSync } from "child_process";
1839
2295
  async function buildBlock() {
1840
2296
  const { block, outputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
1841
2297
  try {
@@ -2028,12 +2484,29 @@ function parseBlockJsonFromSource(block) {
2028
2484
  }
2029
2485
  async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2030
2486
  const webpackBinary = findWebpackBinary();
2031
- const command = `"${webpackBinary}" --config "${webpackConfigPath}" --env entry="${entryPoint}" --env output="${outputDir}" --mode production`;
2032
- execSync(command, {
2487
+ const args = [
2488
+ "--config",
2489
+ webpackConfigPath,
2490
+ "--env",
2491
+ `entry=${entryPoint}`,
2492
+ "--env",
2493
+ `output=${outputDir}`,
2494
+ "--mode",
2495
+ "production"
2496
+ ];
2497
+ const result = import_cross_spawn.default.sync(webpackBinary, args, {
2033
2498
  cwd: path.dirname(webpackConfigPath),
2034
2499
  stdio: "pipe",
2035
- env: { ...process.env, PATH: process.env.PATH }
2500
+ env: { ...process.env }
2036
2501
  });
2502
+ if (result.error) {
2503
+ throw result.error;
2504
+ }
2505
+ if (result.status !== 0) {
2506
+ const stderr = result.stderr?.toString() || "";
2507
+ const stdout = result.stdout?.toString() || "";
2508
+ throw new Error(`Webpack build failed (exit code ${result.status}): ${stderr || stdout}`);
2509
+ }
2037
2510
  }
2038
2511
  function findWebpackBinary() {
2039
2512
  const possiblePaths = [
package/dist/index.js CHANGED
@@ -81051,6 +81051,462 @@ 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
+
81054
81510
  // ../../node_modules/commander/esm.mjs
81055
81511
  var import__ = __toESM(require_commander(), 1);
81056
81512
  var {
@@ -115884,7 +116340,7 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
115884
116340
  // package.json
115885
116341
  var package_default = {
115886
116342
  name: "@wordpress-flow/cli",
115887
- version: "1.0.12",
116343
+ version: "1.0.13",
115888
116344
  type: "module",
115889
116345
  description: "TypeScript-based WordPress block creation system",
115890
116346
  main: "dist/index.js",
@@ -115910,6 +116366,7 @@ var package_default = {
115910
116366
  chalk: "^4.1.2",
115911
116367
  chokidar: "^3.5.3",
115912
116368
  commander: "^11.0.0",
116369
+ "cross-spawn": "^7.0.6",
115913
116370
  dotenv: "^17.2.3",
115914
116371
  esbuild: "^0.19.0",
115915
116372
  glob: "^11.0.3",
@@ -115918,6 +116375,7 @@ var package_default = {
115918
116375
  "react-dom": "^18.3.1"
115919
116376
  },
115920
116377
  devDependencies: {
116378
+ "@types/cross-spawn": "^6.0.6",
115921
116379
  "@types/glob": "^9.0.0",
115922
116380
  "@types/mysql": "^2.15.27",
115923
116381
  "@types/node": "^20.0.0",
@@ -116406,9 +116864,9 @@ import * as fs17 from "fs";
116406
116864
  import * as path19 from "path";
116407
116865
 
116408
116866
  // src/build/webpack-runner.ts
116867
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
116409
116868
  import * as path17 from "path";
116410
116869
  import * as fs15 from "fs";
116411
- import { execSync } from "child_process";
116412
116870
  var import_chalk3 = __toESM(require_source(), 1);
116413
116871
 
116414
116872
  class WebpackRunner {
@@ -116431,50 +116889,67 @@ class WebpackRunner {
116431
116889
  fs15.mkdirSync(outputDir, { recursive: true });
116432
116890
  const webpackBinary = this.findWebpackBinary();
116433
116891
  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}`);
116892
+ const args = [
116893
+ "--config",
116894
+ webpackConfigPath,
116895
+ "--env",
116896
+ `entry=${entryPoint}`,
116897
+ "--env",
116898
+ `output=${outputDir}`,
116899
+ "--mode",
116900
+ "production"
116901
+ ];
116902
+ logger.debug(`Full command: ${webpackBinary} ${args.join(" ")}`);
116436
116903
  const workingDir = path17.dirname(webpackConfigPath);
116437
116904
  logger.debug(`Running webpack from directory: ${workingDir}`);
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) {
116905
+ const result2 = import_cross_spawn.default.sync(webpackBinary, args, {
116906
+ cwd: workingDir,
116907
+ stdio: "pipe",
116908
+ env: { ...process.env }
116909
+ });
116910
+ if (result2.error) {
116911
+ console.error("");
116912
+ console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116913
+ console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
116914
+ console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116915
+ console.error("");
116916
+ console.error(import_chalk3.default.yellow("Error:"));
116917
+ console.error(import_chalk3.default.gray(result2.error.message));
116918
+ console.error("");
116919
+ console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116920
+ console.error("");
116921
+ throw result2.error;
116922
+ }
116923
+ if (result2.status !== 0) {
116924
+ const stderr = result2.stderr?.toString() || "";
116925
+ const stdout = result2.stdout?.toString() || "";
116448
116926
  console.error("");
116449
116927
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116450
116928
  console.error(import_chalk3.default.red.bold(" WEBPACK BUILD FAILED"));
116451
116929
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116452
116930
  console.error("");
116453
116931
  console.error(import_chalk3.default.yellow("Command that failed:"));
116454
- console.error(import_chalk3.default.gray(command));
116932
+ console.error(import_chalk3.default.gray(`${webpackBinary} ${args.join(" ")}`));
116455
116933
  console.error("");
116456
116934
  console.error(import_chalk3.default.yellow("Working directory:"));
116457
116935
  console.error(import_chalk3.default.gray(workingDir));
116458
116936
  console.error("");
116459
- if (error.stdout?.trim()) {
116937
+ if (stdout.trim()) {
116460
116938
  console.error(import_chalk3.default.yellow("Standard output:"));
116461
- console.error(error.stdout);
116939
+ console.error(stdout);
116462
116940
  console.error("");
116463
116941
  }
116464
- if (error.stderr?.trim()) {
116942
+ if (stderr.trim()) {
116465
116943
  console.error(import_chalk3.default.yellow("Error output:"));
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);
116944
+ console.error(stderr);
116472
116945
  console.error("");
116473
116946
  }
116474
116947
  console.error(import_chalk3.default.red("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"));
116475
116948
  console.error("");
116476
- throw new Error(`Webpack build failed`);
116949
+ throw new Error(`Webpack build failed (exit code ${result2.status})`);
116477
116950
  }
116951
+ logger.debug("Webpack build completed successfully");
116952
+ logger.debug(`Output: ${result2.stdout?.toString() || ""}`);
116478
116953
  }
116479
116954
  findWebpackBinary() {
116480
116955
  const possiblePaths = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",
@@ -26,6 +26,7 @@
26
26
  "chalk": "^4.1.2",
27
27
  "chokidar": "^3.5.3",
28
28
  "commander": "^11.0.0",
29
+ "cross-spawn": "^7.0.6",
29
30
  "dotenv": "^17.2.3",
30
31
  "esbuild": "^0.19.0",
31
32
  "glob": "^11.0.3",
@@ -34,6 +35,7 @@
34
35
  "react-dom": "^18.3.1"
35
36
  },
36
37
  "devDependencies": {
38
+ "@types/cross-spawn": "^6.0.6",
37
39
  "@types/glob": "^9.0.0",
38
40
  "@types/mysql": "^2.15.27",
39
41
  "@types/node": "^20.0.0",