@wordpress-flow/cli 1.2.10 → 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 +77 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -78019,9 +78019,9 @@ var require_readdirp = __commonJS((exports, module) => {
|
|
|
78019
78019
|
async _formatEntry(dirent, path8) {
|
|
78020
78020
|
let entry;
|
|
78021
78021
|
try {
|
|
78022
|
-
const
|
|
78023
|
-
const fullPath = sysPath.resolve(sysPath.join(path8,
|
|
78024
|
-
entry = { path: sysPath.relative(this._root, fullPath), fullPath, basename:
|
|
78022
|
+
const basename3 = this._isDirent ? dirent.name : dirent;
|
|
78023
|
+
const fullPath = sysPath.resolve(sysPath.join(path8, basename3));
|
|
78024
|
+
entry = { path: sysPath.relative(this._root, fullPath), fullPath, basename: basename3 };
|
|
78025
78025
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
78026
78026
|
} catch (err) {
|
|
78027
78027
|
this._onError(err);
|
|
@@ -79944,16 +79944,16 @@ var require_nodefs_handler = __commonJS((exports, module) => {
|
|
|
79944
79944
|
_watchWithNodeFs(path8, listener) {
|
|
79945
79945
|
const opts = this.fsw.options;
|
|
79946
79946
|
const directory = sysPath.dirname(path8);
|
|
79947
|
-
const
|
|
79947
|
+
const basename3 = sysPath.basename(path8);
|
|
79948
79948
|
const parent = this.fsw._getWatchedDir(directory);
|
|
79949
|
-
parent.add(
|
|
79949
|
+
parent.add(basename3);
|
|
79950
79950
|
const absolutePath = sysPath.resolve(path8);
|
|
79951
79951
|
const options = { persistent: opts.persistent };
|
|
79952
79952
|
if (!listener)
|
|
79953
79953
|
listener = EMPTY_FN;
|
|
79954
79954
|
let closer;
|
|
79955
79955
|
if (opts.usePolling) {
|
|
79956
|
-
options.interval = opts.enableBinaryInterval && isBinaryPath(
|
|
79956
|
+
options.interval = opts.enableBinaryInterval && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
|
|
79957
79957
|
closer = setFsWatchFileListener(path8, absolutePath, options, {
|
|
79958
79958
|
listener,
|
|
79959
79959
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -79972,10 +79972,10 @@ var require_nodefs_handler = __commonJS((exports, module) => {
|
|
|
79972
79972
|
return;
|
|
79973
79973
|
}
|
|
79974
79974
|
const dirname2 = sysPath.dirname(file);
|
|
79975
|
-
const
|
|
79975
|
+
const basename3 = sysPath.basename(file);
|
|
79976
79976
|
const parent = this.fsw._getWatchedDir(dirname2);
|
|
79977
79977
|
let prevStats = stats;
|
|
79978
|
-
if (parent.has(
|
|
79978
|
+
if (parent.has(basename3))
|
|
79979
79979
|
return;
|
|
79980
79980
|
const listener = async (path8, newStats) => {
|
|
79981
79981
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
@@ -79998,9 +79998,9 @@ var require_nodefs_handler = __commonJS((exports, module) => {
|
|
|
79998
79998
|
prevStats = newStats2;
|
|
79999
79999
|
}
|
|
80000
80000
|
} catch (error) {
|
|
80001
|
-
this.fsw._remove(dirname2,
|
|
80001
|
+
this.fsw._remove(dirname2, basename3);
|
|
80002
80002
|
}
|
|
80003
|
-
} else if (parent.has(
|
|
80003
|
+
} else if (parent.has(basename3)) {
|
|
80004
80004
|
const at2 = newStats.atimeMs;
|
|
80005
80005
|
const mt = newStats.mtimeMs;
|
|
80006
80006
|
if (!at2 || at2 <= mt || mt !== prevStats.mtimeMs) {
|
|
@@ -85709,7 +85709,7 @@ class PullCommand {
|
|
|
85709
85709
|
errors: []
|
|
85710
85710
|
};
|
|
85711
85711
|
try {
|
|
85712
|
-
const postTypes = options.postTypes || ["post", "page"];
|
|
85712
|
+
const postTypes = options.postTypes || config.sync.postTypes || ["post", "page"];
|
|
85713
85713
|
const outputDir = options.outputDir || config.paths.content;
|
|
85714
85714
|
fs3.mkdirSync(outputDir, { recursive: true });
|
|
85715
85715
|
let totalProcessed = 0;
|
|
@@ -85783,7 +85783,6 @@ class PullCommand {
|
|
|
85783
85783
|
const blocks = this.blockParser.parse(post.content.raw);
|
|
85784
85784
|
const frontmatter = {
|
|
85785
85785
|
title: post.title.rendered,
|
|
85786
|
-
slug: post.slug,
|
|
85787
85786
|
postId: post.id,
|
|
85788
85787
|
status: post.status
|
|
85789
85788
|
};
|
|
@@ -113220,13 +113219,14 @@ ${"=".repeat(80)}`);
|
|
|
113220
113219
|
`);
|
|
113221
113220
|
const pathParts = filePath2.split(path6.sep);
|
|
113222
113221
|
const postType = pathParts[pathParts.length - 2];
|
|
113222
|
+
const slug = path6.basename(filePath2, ".mdx");
|
|
113223
113223
|
const postData = {
|
|
113224
113224
|
title: { raw: mdxFile.frontmatter.title },
|
|
113225
113225
|
content: { raw: htmlContent },
|
|
113226
113226
|
excerpt: mdxFile.frontmatter.excerpt ? { raw: mdxFile.frontmatter.excerpt } : undefined,
|
|
113227
113227
|
status: mdxFile.frontmatter.status,
|
|
113228
113228
|
type: postType,
|
|
113229
|
-
slug
|
|
113229
|
+
slug,
|
|
113230
113230
|
categories: mdxFile.frontmatter.categories,
|
|
113231
113231
|
tags: mdxFile.frontmatter.tags,
|
|
113232
113232
|
meta: mdxFile.frontmatter.meta,
|
|
@@ -113272,13 +113272,14 @@ ${"=".repeat(80)}`);
|
|
|
113272
113272
|
const htmlContent = await this.getBlockRenderer().renderMDXContentToHTML(mdxFile.content);
|
|
113273
113273
|
const pathParts = filePath2.split(path6.sep);
|
|
113274
113274
|
const postType = pathParts[pathParts.length - 2];
|
|
113275
|
+
const slug = path6.basename(filePath2, ".mdx");
|
|
113275
113276
|
const postData = {
|
|
113276
113277
|
title: { raw: mdxFile.frontmatter.title },
|
|
113277
113278
|
content: { raw: htmlContent },
|
|
113278
113279
|
excerpt: mdxFile.frontmatter.excerpt ? { raw: mdxFile.frontmatter.excerpt } : undefined,
|
|
113279
113280
|
status: mdxFile.frontmatter.status,
|
|
113280
113281
|
type: postType,
|
|
113281
|
-
slug
|
|
113282
|
+
slug,
|
|
113282
113283
|
categories: mdxFile.frontmatter.categories,
|
|
113283
113284
|
tags: mdxFile.frontmatter.tags,
|
|
113284
113285
|
meta: mdxFile.frontmatter.meta,
|
|
@@ -114590,6 +114591,7 @@ var $watch = watch;
|
|
|
114590
114591
|
// src/dev/dev-mode-orchestrator.ts
|
|
114591
114592
|
import * as path17 from "path";
|
|
114592
114593
|
import * as fs15 from "fs";
|
|
114594
|
+
import * as esbuild from "esbuild";
|
|
114593
114595
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
114594
114596
|
|
|
114595
114597
|
// src/build/block-scanner.ts
|
|
@@ -116184,7 +116186,7 @@ class DockerEnvManager {
|
|
|
116184
116186
|
// package.json
|
|
116185
116187
|
var package_default = {
|
|
116186
116188
|
name: "@wordpress-flow/cli",
|
|
116187
|
-
version: "1.2.
|
|
116189
|
+
version: "1.2.12",
|
|
116188
116190
|
type: "module",
|
|
116189
116191
|
description: "TypeScript-based WordPress block creation system",
|
|
116190
116192
|
main: "dist/index.js",
|
|
@@ -116546,14 +116548,11 @@ class DevModeOrchestrator {
|
|
|
116546
116548
|
return;
|
|
116547
116549
|
const config = this.configManager.getConfig();
|
|
116548
116550
|
const postTypes = config.sync.postTypes || ["post", "page"];
|
|
116549
|
-
console.log(`[DEBUG] Initial push - Post types: ${JSON.stringify(postTypes)}`);
|
|
116550
116551
|
const contentFiles = [];
|
|
116551
116552
|
for (const postType of postTypes) {
|
|
116552
116553
|
const typeDir = path17.join(this.contentDir, postType);
|
|
116553
|
-
console.log(`[DEBUG] Checking directory: ${typeDir}, exists: ${fs15.existsSync(typeDir)}`);
|
|
116554
116554
|
if (fs15.existsSync(typeDir)) {
|
|
116555
116555
|
const files = this.findMDXFiles(typeDir);
|
|
116556
|
-
console.log(`[DEBUG] Found ${files.length} files in ${postType}`);
|
|
116557
116556
|
contentFiles.push(...files);
|
|
116558
116557
|
}
|
|
116559
116558
|
}
|
|
@@ -116686,6 +116685,9 @@ class DevModeOrchestrator {
|
|
|
116686
116685
|
}
|
|
116687
116686
|
startWatchers() {
|
|
116688
116687
|
this.startBlockWatcher();
|
|
116688
|
+
if (this.scriptsPath) {
|
|
116689
|
+
this.startScriptWatcher();
|
|
116690
|
+
}
|
|
116689
116691
|
if (this.templatesDir && this.options.buildTemplates) {
|
|
116690
116692
|
this.startTemplateWatcher();
|
|
116691
116693
|
}
|
|
@@ -116729,6 +116731,20 @@ class DevModeOrchestrator {
|
|
|
116729
116731
|
logger.debug("Block watcher ready");
|
|
116730
116732
|
});
|
|
116731
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
|
+
}
|
|
116732
116748
|
startTemplateWatcher() {
|
|
116733
116749
|
if (!this.templatesDir || !fs15.existsSync(this.templatesDir))
|
|
116734
116750
|
return;
|
|
@@ -116757,8 +116773,6 @@ class DevModeOrchestrator {
|
|
|
116757
116773
|
const config = this.configManager.getConfig();
|
|
116758
116774
|
const postTypes = config.sync.postTypes || ["post", "page"];
|
|
116759
116775
|
const watchPatterns = postTypes.map((type) => `${type}/**/*.mdx`);
|
|
116760
|
-
console.log(`[DEBUG] Post types from config: ${JSON.stringify(postTypes)}`);
|
|
116761
|
-
console.log(`[DEBUG] Watch patterns: ${JSON.stringify(watchPatterns)}`);
|
|
116762
116776
|
logger.debug(`Watching content: ${this.contentDir} (${postTypes.join(", ")})`);
|
|
116763
116777
|
const watcher = $watch(watchPatterns, {
|
|
116764
116778
|
cwd: this.contentDir,
|
|
@@ -116791,6 +116805,44 @@ class DevModeOrchestrator {
|
|
|
116791
116805
|
this.rescanBlocks();
|
|
116792
116806
|
}, this.rescanDebounceMs);
|
|
116793
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
|
+
}
|
|
116794
116846
|
handleTemplateFileEvent(eventType, filePath2) {
|
|
116795
116847
|
const fullPath = path17.resolve(this.templatesDir, filePath2);
|
|
116796
116848
|
this.changeQueue.queueTemplateChange(fullPath, eventType);
|
|
@@ -117209,14 +117261,14 @@ class WebpackRunner {
|
|
|
117209
117261
|
// src/build/script-builder.ts
|
|
117210
117262
|
import * as fs17 from "fs";
|
|
117211
117263
|
import * as path19 from "path";
|
|
117212
|
-
import * as
|
|
117264
|
+
import * as esbuild2 from "esbuild";
|
|
117213
117265
|
class ScriptBuilder {
|
|
117214
117266
|
async buildScript(scriptPath, outputDir, scriptName) {
|
|
117215
117267
|
try {
|
|
117216
117268
|
logger.debug(`Building script: ${scriptName}`);
|
|
117217
117269
|
fs17.mkdirSync(outputDir, { recursive: true });
|
|
117218
117270
|
const outputPath = path19.join(outputDir, scriptName.replace(/\.ts$/, ".js"));
|
|
117219
|
-
await
|
|
117271
|
+
await esbuild2.build({
|
|
117220
117272
|
entryPoints: [scriptPath],
|
|
117221
117273
|
outfile: outputPath,
|
|
117222
117274
|
bundle: true,
|
|
@@ -117263,7 +117315,7 @@ class ScriptBuilder {
|
|
|
117263
117315
|
}
|
|
117264
117316
|
|
|
117265
117317
|
// src/build/block-builder.ts
|
|
117266
|
-
import * as
|
|
117318
|
+
import * as esbuild3 from "esbuild";
|
|
117267
117319
|
class BlockBuilder {
|
|
117268
117320
|
webpackRunner;
|
|
117269
117321
|
scriptBuilder;
|
|
@@ -117340,7 +117392,7 @@ if (document.readyState === 'loading') {
|
|
|
117340
117392
|
try {
|
|
117341
117393
|
logger.debug(`Generating SSR version for ${block.name} using esbuild`);
|
|
117342
117394
|
const ssrPath = path20.join(outputDir, "ssr.js");
|
|
117343
|
-
await
|
|
117395
|
+
await esbuild3.build({
|
|
117344
117396
|
entryPoints: [block.filePath],
|
|
117345
117397
|
outfile: ssrPath,
|
|
117346
117398
|
platform: "node",
|
|
@@ -117436,7 +117488,7 @@ if (document.readyState === 'loading') {
|
|
|
117436
117488
|
if (typeof global.React === "undefined") {
|
|
117437
117489
|
global.React = require_react();
|
|
117438
117490
|
}
|
|
117439
|
-
await
|
|
117491
|
+
await esbuild3.build({
|
|
117440
117492
|
entryPoints: [filePath2],
|
|
117441
117493
|
outfile: tempFile,
|
|
117442
117494
|
platform: "node",
|