@wordpress-flow/cli 1.2.1 → 1.2.2
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.
- package/dist/build/block-build-worker.js +31 -14
- package/dist/index.js +28 -16
- package/package.json +1 -1
|
@@ -1859,10 +1859,22 @@ async function buildBlock() {
|
|
|
1859
1859
|
};
|
|
1860
1860
|
} catch (error) {
|
|
1861
1861
|
cleanupTempFiles(tempDir);
|
|
1862
|
+
let errorMessage = "Unknown error";
|
|
1863
|
+
if (error instanceof Error) {
|
|
1864
|
+
errorMessage = error.message;
|
|
1865
|
+
if (error.stack) {
|
|
1866
|
+
errorMessage += `
|
|
1867
|
+
${error.stack}`;
|
|
1868
|
+
}
|
|
1869
|
+
} else if (typeof error === "string") {
|
|
1870
|
+
errorMessage = error;
|
|
1871
|
+
} else if (error) {
|
|
1872
|
+
errorMessage = JSON.stringify(error);
|
|
1873
|
+
}
|
|
1862
1874
|
return {
|
|
1863
1875
|
success: false,
|
|
1864
1876
|
blockName: block.name,
|
|
1865
|
-
error:
|
|
1877
|
+
error: errorMessage
|
|
1866
1878
|
};
|
|
1867
1879
|
}
|
|
1868
1880
|
}
|
|
@@ -1895,22 +1907,27 @@ async function buildBlockScripts(scripts, scriptsPath, scriptsOutputDir) {
|
|
|
1895
1907
|
for (const script of scripts) {
|
|
1896
1908
|
const scriptPath = path.resolve(scriptsPath, script);
|
|
1897
1909
|
if (!fs.existsSync(scriptPath)) {
|
|
1898
|
-
|
|
1910
|
+
throw new Error(`Script file not found: ${scriptPath}`);
|
|
1899
1911
|
}
|
|
1900
1912
|
const scriptName = path.basename(script);
|
|
1901
1913
|
const outputPath = path.join(scriptsOutputDir, scriptName.replace(/\.ts$/, ".js"));
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
+
try {
|
|
1915
|
+
await esbuild.build({
|
|
1916
|
+
entryPoints: [scriptPath],
|
|
1917
|
+
outfile: outputPath,
|
|
1918
|
+
bundle: true,
|
|
1919
|
+
minify: true,
|
|
1920
|
+
platform: "browser",
|
|
1921
|
+
target: "es2015",
|
|
1922
|
+
format: "iife",
|
|
1923
|
+
external: ["react", "react-dom", "@wordpress/*", "jquery"],
|
|
1924
|
+
define: { "process.env.NODE_ENV": '"production"' },
|
|
1925
|
+
logLevel: "warning",
|
|
1926
|
+
allowOverwrite: true
|
|
1927
|
+
});
|
|
1928
|
+
} catch (err) {
|
|
1929
|
+
throw new Error(`Failed to build script ${script}: ${err.message}`);
|
|
1930
|
+
}
|
|
1914
1931
|
outputPaths.push(outputPath);
|
|
1915
1932
|
}
|
|
1916
1933
|
return outputPaths;
|
package/dist/index.js
CHANGED
|
@@ -81170,7 +81170,7 @@ class ConfigManager {
|
|
|
81170
81170
|
},
|
|
81171
81171
|
build: {
|
|
81172
81172
|
blocksDir: config.paths.blocks,
|
|
81173
|
-
outputDir: config.paths.
|
|
81173
|
+
outputDir: config.paths.blocksDist,
|
|
81174
81174
|
scriptsPath: config.paths.scripts
|
|
81175
81175
|
},
|
|
81176
81176
|
templates: {
|
|
@@ -113061,7 +113061,7 @@ class PushCommand {
|
|
|
113061
113061
|
this.blockRegistry = blockRegistry;
|
|
113062
113062
|
} else {
|
|
113063
113063
|
const config = this.configManager.getConfig();
|
|
113064
|
-
const buildOutputDir = this.configManager.resolvePath(config.paths.
|
|
113064
|
+
const buildOutputDir = this.configManager.resolvePath(config.paths.blocksDist);
|
|
113065
113065
|
this.blockRegistry = new BlockRegistry(buildOutputDir);
|
|
113066
113066
|
}
|
|
113067
113067
|
}
|
|
@@ -114743,6 +114743,7 @@ import * as os from "os";
|
|
|
114743
114743
|
class AbortableWorkerPool {
|
|
114744
114744
|
concurrency;
|
|
114745
114745
|
outputDir;
|
|
114746
|
+
scriptsOutputDir;
|
|
114746
114747
|
webpackConfigPath;
|
|
114747
114748
|
scriptsPath;
|
|
114748
114749
|
workerPath;
|
|
@@ -114750,6 +114751,7 @@ class AbortableWorkerPool {
|
|
|
114750
114751
|
constructor(options) {
|
|
114751
114752
|
this.concurrency = options.concurrency ?? Math.max(1, os.cpus().length - 1);
|
|
114752
114753
|
this.outputDir = options.outputDir;
|
|
114754
|
+
this.scriptsOutputDir = options.scriptsOutputDir;
|
|
114753
114755
|
this.webpackConfigPath = options.webpackConfigPath;
|
|
114754
114756
|
this.scriptsPath = options.scriptsPath;
|
|
114755
114757
|
this.workerPath = path9.join(import.meta.dirname, "build", "block-build-worker.js");
|
|
@@ -114811,22 +114813,23 @@ class AbortableWorkerPool {
|
|
|
114811
114813
|
results.push(result2);
|
|
114812
114814
|
completed++;
|
|
114813
114815
|
activeCount--;
|
|
114814
|
-
onProgress?.(completed, total, result2.blockName, result2.success, result2.
|
|
114816
|
+
onProgress?.(completed, total, result2.blockName, result2.success, result2.error);
|
|
114815
114817
|
if (queue.length > 0) {
|
|
114816
114818
|
processNext();
|
|
114817
114819
|
} else if (activeCount === 0) {
|
|
114818
114820
|
resolve4(results);
|
|
114819
114821
|
}
|
|
114820
114822
|
}).catch((error) => {
|
|
114823
|
+
const errorMsg = error.message || String(error);
|
|
114821
114824
|
const result2 = {
|
|
114822
114825
|
success: false,
|
|
114823
114826
|
blockName: block.name,
|
|
114824
|
-
error:
|
|
114827
|
+
error: errorMsg
|
|
114825
114828
|
};
|
|
114826
114829
|
results.push(result2);
|
|
114827
114830
|
completed++;
|
|
114828
114831
|
activeCount--;
|
|
114829
|
-
onProgress?.(completed, total, block.name, false,
|
|
114832
|
+
onProgress?.(completed, total, block.name, false, errorMsg);
|
|
114830
114833
|
if (queue.length > 0) {
|
|
114831
114834
|
processNext();
|
|
114832
114835
|
} else if (activeCount === 0) {
|
|
@@ -114848,6 +114851,7 @@ class AbortableWorkerPool {
|
|
|
114848
114851
|
scripts: block.scripts
|
|
114849
114852
|
},
|
|
114850
114853
|
outputDir: this.outputDir,
|
|
114854
|
+
scriptsOutputDir: this.scriptsOutputDir,
|
|
114851
114855
|
webpackConfigPath: this.webpackConfigPath,
|
|
114852
114856
|
scriptsPath: this.scriptsPath,
|
|
114853
114857
|
tempDir
|
|
@@ -116264,7 +116268,7 @@ class DockerEnvManager {
|
|
|
116264
116268
|
// package.json
|
|
116265
116269
|
var package_default = {
|
|
116266
116270
|
name: "@wordpress-flow/cli",
|
|
116267
|
-
version: "1.2.
|
|
116271
|
+
version: "1.2.2",
|
|
116268
116272
|
type: "module",
|
|
116269
116273
|
description: "TypeScript-based WordPress block creation system",
|
|
116270
116274
|
main: "dist/index.js",
|
|
@@ -116341,6 +116345,7 @@ class DevModeOrchestrator {
|
|
|
116341
116345
|
isRunning = false;
|
|
116342
116346
|
blocksDir;
|
|
116343
116347
|
outputDir;
|
|
116348
|
+
scriptsOutputDir;
|
|
116344
116349
|
templatesDir;
|
|
116345
116350
|
templatesOutputDir;
|
|
116346
116351
|
templatePartsDir;
|
|
@@ -116461,7 +116466,8 @@ class DevModeOrchestrator {
|
|
|
116461
116466
|
async initializeConfig() {
|
|
116462
116467
|
const config = this.configManager.getConfig();
|
|
116463
116468
|
this.blocksDir = this.configManager.resolvePath(config.paths.blocks);
|
|
116464
|
-
this.outputDir = this.configManager.resolvePath(config.paths.
|
|
116469
|
+
this.outputDir = this.configManager.resolvePath(config.paths.blocksDist);
|
|
116470
|
+
this.scriptsOutputDir = this.configManager.resolvePath(config.paths.scriptsDist);
|
|
116465
116471
|
this.webpackConfig = path17.join(__dirname2, "..", "webpack.config.cjs");
|
|
116466
116472
|
this.scriptsPath = this.configManager.resolvePath(config.paths.scripts);
|
|
116467
116473
|
this.contentDir = this.configManager.resolvePath(config.paths.content);
|
|
@@ -116472,11 +116478,15 @@ class DevModeOrchestrator {
|
|
|
116472
116478
|
if (!fs15.existsSync(this.outputDir)) {
|
|
116473
116479
|
fs15.mkdirSync(this.outputDir, { recursive: true });
|
|
116474
116480
|
}
|
|
116481
|
+
if (!fs15.existsSync(this.scriptsOutputDir)) {
|
|
116482
|
+
fs15.mkdirSync(this.scriptsOutputDir, { recursive: true });
|
|
116483
|
+
}
|
|
116475
116484
|
}
|
|
116476
116485
|
initializeManagers() {
|
|
116477
116486
|
this.workerPool = new AbortableWorkerPool({
|
|
116478
116487
|
concurrency: this.options.concurrency,
|
|
116479
116488
|
outputDir: this.outputDir,
|
|
116489
|
+
scriptsOutputDir: this.scriptsOutputDir,
|
|
116480
116490
|
webpackConfigPath: this.webpackConfig,
|
|
116481
116491
|
scriptsPath: this.scriptsPath
|
|
116482
116492
|
});
|
|
@@ -116555,12 +116565,12 @@ class DevModeOrchestrator {
|
|
|
116555
116565
|
let successCount = 0;
|
|
116556
116566
|
let failCount = 0;
|
|
116557
116567
|
const blockScripts = new Map;
|
|
116558
|
-
const results = await this.workerPool.buildAll(blocksToRebuild, (completed, total, blockName, success) => {
|
|
116568
|
+
const results = await this.workerPool.buildAll(blocksToRebuild, (completed, total, blockName, success, error) => {
|
|
116559
116569
|
if (success) {
|
|
116560
116570
|
console.log(` ✅ ${blockName} [${completed}/${total}]`);
|
|
116561
116571
|
successCount++;
|
|
116562
116572
|
} else {
|
|
116563
|
-
console.log(` ❌ ${blockName} failed [${completed}/${total}]`);
|
|
116573
|
+
console.log(` ❌ ${blockName} failed [${completed}/${total}]: ${error || "unknown error"}`);
|
|
116564
116574
|
failCount++;
|
|
116565
116575
|
}
|
|
116566
116576
|
});
|
|
@@ -116578,7 +116588,8 @@ class DevModeOrchestrator {
|
|
|
116578
116588
|
}
|
|
116579
116589
|
}
|
|
116580
116590
|
if (blockScripts.size > 0) {
|
|
116581
|
-
const
|
|
116591
|
+
const distDir = path17.dirname(this.outputDir);
|
|
116592
|
+
const phpPath = path17.join(distDir, "functions-blocks-scripts.php");
|
|
116582
116593
|
this.phpGenerator.generateScriptRegistrationPHP(blockScripts, phpPath);
|
|
116583
116594
|
}
|
|
116584
116595
|
await this.generateTypeDefinitions();
|
|
@@ -117641,7 +117652,7 @@ class WorkerPool {
|
|
|
117641
117652
|
results.push(result2);
|
|
117642
117653
|
completed++;
|
|
117643
117654
|
activeWorkers--;
|
|
117644
|
-
onProgress?.(completed, total, result2.blockName, result2.success);
|
|
117655
|
+
onProgress?.(completed, total, result2.blockName, result2.success, result2.error);
|
|
117645
117656
|
if (queue.length > 0) {
|
|
117646
117657
|
processNext();
|
|
117647
117658
|
} else if (activeWorkers === 0) {
|
|
@@ -117656,7 +117667,7 @@ class WorkerPool {
|
|
|
117656
117667
|
results.push(result2);
|
|
117657
117668
|
completed++;
|
|
117658
117669
|
activeWorkers--;
|
|
117659
|
-
onProgress?.(completed, total, block.name, false);
|
|
117670
|
+
onProgress?.(completed, total, block.name, false, result2.error);
|
|
117660
117671
|
if (queue.length > 0) {
|
|
117661
117672
|
processNext();
|
|
117662
117673
|
} else if (activeWorkers === 0) {
|
|
@@ -117777,11 +117788,11 @@ class BuildCommand {
|
|
|
117777
117788
|
webpackConfigPath: webpackConfig,
|
|
117778
117789
|
scriptsPath
|
|
117779
117790
|
});
|
|
117780
|
-
const results = await workerPool.buildAll(blocks, (completed, total, blockName, success) => {
|
|
117791
|
+
const results = await workerPool.buildAll(blocks, (completed, total, blockName, success, error) => {
|
|
117781
117792
|
if (success) {
|
|
117782
117793
|
logger.success(`✅ Built: ${blockName} [${completed}/${total}]`);
|
|
117783
117794
|
} else {
|
|
117784
|
-
logger.error(`❌ Failed: ${blockName} [${completed}/${total}]`);
|
|
117795
|
+
logger.error(`❌ Failed: ${blockName} [${completed}/${total}]: ${error || "unknown error"}`);
|
|
117785
117796
|
}
|
|
117786
117797
|
});
|
|
117787
117798
|
for (const block of blocks) {
|
|
@@ -117802,7 +117813,8 @@ Failed to build ${failures.length} block(s):`);
|
|
|
117802
117813
|
}
|
|
117803
117814
|
}
|
|
117804
117815
|
if (this.blockScripts.size > 0) {
|
|
117805
|
-
const
|
|
117816
|
+
const distDir = path22.dirname(outputDir);
|
|
117817
|
+
const phpPath = path22.join(distDir, "functions-blocks-scripts.php");
|
|
117806
117818
|
this.phpGenerator.generateScriptRegistrationPHP(this.blockScripts, phpPath);
|
|
117807
117819
|
}
|
|
117808
117820
|
await this.generateTypeDefinitions(outputDir);
|
|
@@ -117857,7 +117869,7 @@ class BuildTemplatesCommand {
|
|
|
117857
117869
|
return;
|
|
117858
117870
|
}
|
|
117859
117871
|
fs19.mkdirSync(outputDir, { recursive: true });
|
|
117860
|
-
const blocksOutputDir = this.configManager.resolvePath(config.paths.
|
|
117872
|
+
const blocksOutputDir = this.configManager.resolvePath(config.paths.blocksDist);
|
|
117861
117873
|
const blockRegistry = new BlockRegistry(blocksOutputDir);
|
|
117862
117874
|
await blockRegistry.loadBuiltBlocks();
|
|
117863
117875
|
logger.info(`Loaded ${blockRegistry.getAllComponentMappings().length} built blocks`);
|