@wordpress-flow/cli 1.2.11 → 1.2.12
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/index.js +62 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -114591,6 +114591,7 @@ var $watch = watch;
|
|
|
114591
114591
|
// src/dev/dev-mode-orchestrator.ts
|
|
114592
114592
|
import * as path17 from "path";
|
|
114593
114593
|
import * as fs15 from "fs";
|
|
114594
|
+
import * as esbuild from "esbuild";
|
|
114594
114595
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
114595
114596
|
|
|
114596
114597
|
// src/build/block-scanner.ts
|
|
@@ -116185,7 +116186,7 @@ class DockerEnvManager {
|
|
|
116185
116186
|
// package.json
|
|
116186
116187
|
var package_default = {
|
|
116187
116188
|
name: "@wordpress-flow/cli",
|
|
116188
|
-
version: "1.2.
|
|
116189
|
+
version: "1.2.12",
|
|
116189
116190
|
type: "module",
|
|
116190
116191
|
description: "TypeScript-based WordPress block creation system",
|
|
116191
116192
|
main: "dist/index.js",
|
|
@@ -116547,14 +116548,11 @@ class DevModeOrchestrator {
|
|
|
116547
116548
|
return;
|
|
116548
116549
|
const config = this.configManager.getConfig();
|
|
116549
116550
|
const postTypes = config.sync.postTypes || ["post", "page"];
|
|
116550
|
-
console.log(`[DEBUG] Initial push - Post types: ${JSON.stringify(postTypes)}`);
|
|
116551
116551
|
const contentFiles = [];
|
|
116552
116552
|
for (const postType of postTypes) {
|
|
116553
116553
|
const typeDir = path17.join(this.contentDir, postType);
|
|
116554
|
-
console.log(`[DEBUG] Checking directory: ${typeDir}, exists: ${fs15.existsSync(typeDir)}`);
|
|
116555
116554
|
if (fs15.existsSync(typeDir)) {
|
|
116556
116555
|
const files = this.findMDXFiles(typeDir);
|
|
116557
|
-
console.log(`[DEBUG] Found ${files.length} files in ${postType}`);
|
|
116558
116556
|
contentFiles.push(...files);
|
|
116559
116557
|
}
|
|
116560
116558
|
}
|
|
@@ -116687,6 +116685,9 @@ class DevModeOrchestrator {
|
|
|
116687
116685
|
}
|
|
116688
116686
|
startWatchers() {
|
|
116689
116687
|
this.startBlockWatcher();
|
|
116688
|
+
if (this.scriptsPath) {
|
|
116689
|
+
this.startScriptWatcher();
|
|
116690
|
+
}
|
|
116690
116691
|
if (this.templatesDir && this.options.buildTemplates) {
|
|
116691
116692
|
this.startTemplateWatcher();
|
|
116692
116693
|
}
|
|
@@ -116730,6 +116731,20 @@ class DevModeOrchestrator {
|
|
|
116730
116731
|
logger.debug("Block watcher ready");
|
|
116731
116732
|
});
|
|
116732
116733
|
}
|
|
116734
|
+
startScriptWatcher() {
|
|
116735
|
+
if (!this.scriptsPath || !fs15.existsSync(this.scriptsPath))
|
|
116736
|
+
return;
|
|
116737
|
+
logger.debug(`Watching scripts: ${this.scriptsPath}`);
|
|
116738
|
+
const watcher = $watch("**/*.{ts,js}", {
|
|
116739
|
+
cwd: this.scriptsPath,
|
|
116740
|
+
...this.getWatcherOptions()
|
|
116741
|
+
});
|
|
116742
|
+
this.watchers.push(watcher);
|
|
116743
|
+
watcher.on("add", (filePath2) => this.handleScriptFileEvent("add", filePath2)).on("change", (filePath2) => this.handleScriptFileEvent("change", filePath2)).on("unlink", (filePath2) => this.handleScriptFileEvent("unlink", filePath2)).on("error", (error) => logger.error("Script watcher error:", error));
|
|
116744
|
+
watcher.on("ready", () => {
|
|
116745
|
+
logger.debug("Script watcher ready");
|
|
116746
|
+
});
|
|
116747
|
+
}
|
|
116733
116748
|
startTemplateWatcher() {
|
|
116734
116749
|
if (!this.templatesDir || !fs15.existsSync(this.templatesDir))
|
|
116735
116750
|
return;
|
|
@@ -116758,8 +116773,6 @@ class DevModeOrchestrator {
|
|
|
116758
116773
|
const config = this.configManager.getConfig();
|
|
116759
116774
|
const postTypes = config.sync.postTypes || ["post", "page"];
|
|
116760
116775
|
const watchPatterns = postTypes.map((type) => `${type}/**/*.mdx`);
|
|
116761
|
-
console.log(`[DEBUG] Post types from config: ${JSON.stringify(postTypes)}`);
|
|
116762
|
-
console.log(`[DEBUG] Watch patterns: ${JSON.stringify(watchPatterns)}`);
|
|
116763
116776
|
logger.debug(`Watching content: ${this.contentDir} (${postTypes.join(", ")})`);
|
|
116764
116777
|
const watcher = $watch(watchPatterns, {
|
|
116765
116778
|
cwd: this.contentDir,
|
|
@@ -116792,6 +116805,44 @@ class DevModeOrchestrator {
|
|
|
116792
116805
|
this.rescanBlocks();
|
|
116793
116806
|
}, this.rescanDebounceMs);
|
|
116794
116807
|
}
|
|
116808
|
+
handleScriptFileEvent(eventType, filePath2) {
|
|
116809
|
+
const fullPath = path17.resolve(this.scriptsPath, filePath2);
|
|
116810
|
+
const scriptName = path17.basename(filePath2, path17.extname(filePath2));
|
|
116811
|
+
if (eventType === "unlink") {
|
|
116812
|
+
const outputPath = path17.join(this.scriptsOutputDir, `${scriptName}.js`);
|
|
116813
|
+
if (fs15.existsSync(outputPath)) {
|
|
116814
|
+
fs15.unlinkSync(outputPath);
|
|
116815
|
+
console.log(`\uD83D\uDDD1️ ${scriptName}.js deleted`);
|
|
116816
|
+
}
|
|
116817
|
+
} else {
|
|
116818
|
+
this.buildScript(fullPath, scriptName);
|
|
116819
|
+
}
|
|
116820
|
+
}
|
|
116821
|
+
async buildScript(scriptPath, scriptName) {
|
|
116822
|
+
const startTime = Date.now();
|
|
116823
|
+
process.stdout.write(`\uD83D\uDCDC ${scriptName} → `);
|
|
116824
|
+
try {
|
|
116825
|
+
const outputPath = path17.join(this.scriptsOutputDir, `${scriptName}.js`);
|
|
116826
|
+
await esbuild.build({
|
|
116827
|
+
entryPoints: [scriptPath],
|
|
116828
|
+
outfile: outputPath,
|
|
116829
|
+
bundle: true,
|
|
116830
|
+
minify: false,
|
|
116831
|
+
platform: "browser",
|
|
116832
|
+
target: "es2015",
|
|
116833
|
+
format: "iife",
|
|
116834
|
+
external: ["react", "react-dom", "@wordpress/*", "jquery"],
|
|
116835
|
+
define: { "process.env.NODE_ENV": '"development"' },
|
|
116836
|
+
logLevel: "warning",
|
|
116837
|
+
allowOverwrite: true,
|
|
116838
|
+
sourcemap: true
|
|
116839
|
+
});
|
|
116840
|
+
const duration = `${((Date.now() - startTime) / 1000).toFixed(1)}s`;
|
|
116841
|
+
console.log(`✅ (${duration})`);
|
|
116842
|
+
} catch (error) {
|
|
116843
|
+
console.log(`❌ ${error.message}`);
|
|
116844
|
+
}
|
|
116845
|
+
}
|
|
116795
116846
|
handleTemplateFileEvent(eventType, filePath2) {
|
|
116796
116847
|
const fullPath = path17.resolve(this.templatesDir, filePath2);
|
|
116797
116848
|
this.changeQueue.queueTemplateChange(fullPath, eventType);
|
|
@@ -117210,14 +117261,14 @@ class WebpackRunner {
|
|
|
117210
117261
|
// src/build/script-builder.ts
|
|
117211
117262
|
import * as fs17 from "fs";
|
|
117212
117263
|
import * as path19 from "path";
|
|
117213
|
-
import * as
|
|
117264
|
+
import * as esbuild2 from "esbuild";
|
|
117214
117265
|
class ScriptBuilder {
|
|
117215
117266
|
async buildScript(scriptPath, outputDir, scriptName) {
|
|
117216
117267
|
try {
|
|
117217
117268
|
logger.debug(`Building script: ${scriptName}`);
|
|
117218
117269
|
fs17.mkdirSync(outputDir, { recursive: true });
|
|
117219
117270
|
const outputPath = path19.join(outputDir, scriptName.replace(/\.ts$/, ".js"));
|
|
117220
|
-
await
|
|
117271
|
+
await esbuild2.build({
|
|
117221
117272
|
entryPoints: [scriptPath],
|
|
117222
117273
|
outfile: outputPath,
|
|
117223
117274
|
bundle: true,
|
|
@@ -117264,7 +117315,7 @@ class ScriptBuilder {
|
|
|
117264
117315
|
}
|
|
117265
117316
|
|
|
117266
117317
|
// src/build/block-builder.ts
|
|
117267
|
-
import * as
|
|
117318
|
+
import * as esbuild3 from "esbuild";
|
|
117268
117319
|
class BlockBuilder {
|
|
117269
117320
|
webpackRunner;
|
|
117270
117321
|
scriptBuilder;
|
|
@@ -117341,7 +117392,7 @@ if (document.readyState === 'loading') {
|
|
|
117341
117392
|
try {
|
|
117342
117393
|
logger.debug(`Generating SSR version for ${block.name} using esbuild`);
|
|
117343
117394
|
const ssrPath = path20.join(outputDir, "ssr.js");
|
|
117344
|
-
await
|
|
117395
|
+
await esbuild3.build({
|
|
117345
117396
|
entryPoints: [block.filePath],
|
|
117346
117397
|
outfile: ssrPath,
|
|
117347
117398
|
platform: "node",
|
|
@@ -117437,7 +117488,7 @@ if (document.readyState === 'loading') {
|
|
|
117437
117488
|
if (typeof global.React === "undefined") {
|
|
117438
117489
|
global.React = require_react();
|
|
117439
117490
|
}
|
|
117440
|
-
await
|
|
117491
|
+
await esbuild3.build({
|
|
117441
117492
|
entryPoints: [filePath2],
|
|
117442
117493
|
outfile: tempFile,
|
|
117443
117494
|
platform: "node",
|