@wordpress-flow/cli 1.0.14 → 1.0.20

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 {
@@ -2315,35 +1859,10 @@ async function buildBlock() {
2315
1859
  };
2316
1860
  } catch (error) {
2317
1861
  cleanupTempFiles(tempDir);
2318
- const errorDetails = [
2319
- `Error: ${error.message || String(error)}`
2320
- ];
2321
- if (error.stack) {
2322
- errorDetails.push(`Stack: ${error.stack}`);
2323
- }
2324
- if (error.code) {
2325
- errorDetails.push(`Code: ${error.code}`);
2326
- }
2327
- if (error.syscall) {
2328
- errorDetails.push(`Syscall: ${error.syscall}`);
2329
- }
2330
- if (error.path) {
2331
- errorDetails.push(`Path: ${error.path}`);
2332
- }
2333
- if (error.spawnargs) {
2334
- errorDetails.push(`Spawn args: ${JSON.stringify(error.spawnargs)}`);
2335
- }
2336
- if (error.stderr) {
2337
- errorDetails.push(`Stderr: ${error.stderr.toString()}`);
2338
- }
2339
- if (error.stdout) {
2340
- errorDetails.push(`Stdout: ${error.stdout.toString()}`);
2341
- }
2342
1862
  return {
2343
1863
  success: false,
2344
1864
  blockName: block.name,
2345
- error: errorDetails.join(`
2346
- `)
1865
+ error: error.message || String(error)
2347
1866
  };
2348
1867
  }
2349
1868
  }
@@ -2483,33 +2002,26 @@ function parseBlockJsonFromSource(block) {
2483
2002
  };
2484
2003
  }
2485
2004
  async function runWebpackBuild(entryPoint, outputDir, webpackConfigPath) {
2486
- const args = getWebpackArgs(webpackConfigPath, entryPoint, outputDir);
2487
- const result = import_cross_spawn.default.sync("npx", args, {
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, {
2488
2009
  cwd: path.dirname(webpackConfigPath),
2489
- stdio: "pipe",
2490
- env: { ...process.env }
2010
+ encoding: "utf8",
2011
+ stdio: "pipe"
2491
2012
  });
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
2013
  }
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"
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")
2512
2018
  ];
2019
+ for (const webpackPath of possiblePaths) {
2020
+ if (fs.existsSync(webpackPath)) {
2021
+ return webpackPath;
2022
+ }
2023
+ }
2024
+ return "npx webpack";
2513
2025
  }
2514
2026
  function verifyBuildOutput(outputDir) {
2515
2027
  const requiredFiles = ["block.json", "index.js", "ssr.js"];