@wordpress-flow/cli 1.2.8 → 1.2.10
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 +98 -37
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -80768,8 +80768,10 @@ var DEFAULTS = {
|
|
|
80768
80768
|
plugins: "./plugins"
|
|
80769
80769
|
},
|
|
80770
80770
|
sync: {
|
|
80771
|
+
postTypes: ["post", "page"],
|
|
80771
80772
|
excludePostTypes: [],
|
|
80772
|
-
includedPostStatuses: ["publish", "draft"]
|
|
80773
|
+
includedPostStatuses: ["publish", "draft"],
|
|
80774
|
+
conflictResolution: "manual"
|
|
80773
80775
|
},
|
|
80774
80776
|
dev: {
|
|
80775
80777
|
port: 8888,
|
|
@@ -80896,8 +80898,10 @@ class ConfigManager {
|
|
|
80896
80898
|
partsOutput: `${theme}/parts`
|
|
80897
80899
|
},
|
|
80898
80900
|
sync: {
|
|
80901
|
+
postTypes: raw.sync?.postTypes || DEFAULTS.sync.postTypes,
|
|
80899
80902
|
excludePostTypes: raw.sync?.excludePostTypes || DEFAULTS.sync.excludePostTypes,
|
|
80900
|
-
includedPostStatuses: raw.sync?.includedPostStatuses || DEFAULTS.sync.includedPostStatuses
|
|
80903
|
+
includedPostStatuses: raw.sync?.includedPostStatuses || DEFAULTS.sync.includedPostStatuses,
|
|
80904
|
+
conflictResolution: raw.sync?.conflictResolution || DEFAULTS.sync.conflictResolution
|
|
80901
80905
|
},
|
|
80902
80906
|
dev: {
|
|
80903
80907
|
port: raw.dev?.port || DEFAULTS.dev.port,
|
|
@@ -84899,15 +84903,27 @@ class DatabaseClient {
|
|
|
84899
84903
|
await this.connect();
|
|
84900
84904
|
try {
|
|
84901
84905
|
logger.debug("Creating new post in database...");
|
|
84902
|
-
const
|
|
84906
|
+
const useSpecificId = post.id !== undefined;
|
|
84907
|
+
const query = useSpecificId ? `
|
|
84908
|
+
INSERT INTO wp_posts (
|
|
84909
|
+
ID, post_title, post_content, post_excerpt, post_status,
|
|
84910
|
+
post_type, post_name, post_author, post_date,
|
|
84911
|
+
post_date_gmt, post_modified, post_modified_gmt,
|
|
84912
|
+
guid, comment_status, ping_status, to_ping, pinged,
|
|
84913
|
+
post_content_filtered, post_password, post_parent,
|
|
84914
|
+
menu_order, post_mime_type, comment_count
|
|
84915
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), UTC_TIMESTAMP(), NOW(), UTC_TIMESTAMP(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
84916
|
+
` : `
|
|
84903
84917
|
INSERT INTO wp_posts (
|
|
84904
84918
|
post_title, post_content, post_excerpt, post_status,
|
|
84905
84919
|
post_type, post_name, post_author, post_date,
|
|
84906
84920
|
post_date_gmt, post_modified, post_modified_gmt,
|
|
84907
|
-
guid, comment_status, ping_status
|
|
84908
|
-
|
|
84921
|
+
guid, comment_status, ping_status, to_ping, pinged,
|
|
84922
|
+
post_content_filtered, post_password, post_parent,
|
|
84923
|
+
menu_order, post_mime_type, comment_count
|
|
84924
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), UTC_TIMESTAMP(), NOW(), UTC_TIMESTAMP(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
84909
84925
|
`;
|
|
84910
|
-
const
|
|
84926
|
+
const baseValues = [
|
|
84911
84927
|
post.title.raw || post.title.rendered,
|
|
84912
84928
|
post.content.raw,
|
|
84913
84929
|
post.excerpt?.raw || post.excerpt?.rendered || "",
|
|
@@ -84917,10 +84933,21 @@ class DatabaseClient {
|
|
|
84917
84933
|
post.author || 1,
|
|
84918
84934
|
"",
|
|
84919
84935
|
post.comment_status || "open",
|
|
84920
|
-
post.ping_status || "open"
|
|
84936
|
+
post.ping_status || "open",
|
|
84937
|
+
"",
|
|
84938
|
+
"",
|
|
84939
|
+
"",
|
|
84940
|
+
"",
|
|
84941
|
+
0,
|
|
84942
|
+
0,
|
|
84943
|
+
"",
|
|
84944
|
+
0
|
|
84921
84945
|
];
|
|
84946
|
+
const values = useSpecificId ? [post.id, ...baseValues] : baseValues;
|
|
84947
|
+
logger.debug(`useSpecificId: ${useSpecificId}, values count: ${values.length}`);
|
|
84948
|
+
logger.debug(`Query: ${query}`);
|
|
84922
84949
|
const [result2] = await this.connection.execute(query, values);
|
|
84923
|
-
const insertId = result2.insertId;
|
|
84950
|
+
const insertId = useSpecificId ? post.id : result2.insertId;
|
|
84924
84951
|
const guid = `${this.config.wordpressUrl}/?p=${insertId}`;
|
|
84925
84952
|
await this.connection.execute("UPDATE wp_posts SET guid = ? WHERE ID = ?", [guid, insertId]);
|
|
84926
84953
|
if (post.meta) {
|
|
@@ -113153,13 +113180,16 @@ class PushCommand {
|
|
|
113153
113180
|
if (!baseDir) {
|
|
113154
113181
|
throw new Error("No base directory specified and no files provided");
|
|
113155
113182
|
}
|
|
113156
|
-
const
|
|
113157
|
-
const
|
|
113183
|
+
const config = this.configManager.getConfig();
|
|
113184
|
+
const postTypes = config.sync?.postTypes || ["post", "page"];
|
|
113158
113185
|
try {
|
|
113159
|
-
const
|
|
113160
|
-
const
|
|
113161
|
-
|
|
113162
|
-
|
|
113186
|
+
const allFiles = [];
|
|
113187
|
+
for (const postType of postTypes) {
|
|
113188
|
+
const pattern = path6.join(baseDir, `${postType}/**/*.mdx`);
|
|
113189
|
+
const files = await glob(pattern);
|
|
113190
|
+
allFiles.push(...files);
|
|
113191
|
+
logger.debug(`Found ${files.length} ${postType}(s)`);
|
|
113192
|
+
}
|
|
113163
113193
|
return allFiles;
|
|
113164
113194
|
} catch (error) {
|
|
113165
113195
|
throw error;
|
|
@@ -113199,12 +113229,20 @@ ${"=".repeat(80)}`);
|
|
|
113199
113229
|
slug: mdxFile.frontmatter.slug,
|
|
113200
113230
|
categories: mdxFile.frontmatter.categories,
|
|
113201
113231
|
tags: mdxFile.frontmatter.tags,
|
|
113202
|
-
meta: mdxFile.frontmatter.meta
|
|
113232
|
+
meta: mdxFile.frontmatter.meta,
|
|
113233
|
+
id: isUpdate ? mdxFile.frontmatter.postId : undefined
|
|
113203
113234
|
};
|
|
113204
113235
|
let updatedPost;
|
|
113205
113236
|
if (isUpdate) {
|
|
113206
|
-
|
|
113207
|
-
|
|
113237
|
+
const existingPost = await connection.getPost(mdxFile.frontmatter.postId);
|
|
113238
|
+
if (existingPost) {
|
|
113239
|
+
updatedPost = await connection.updatePost(mdxFile.frontmatter.postId, postData);
|
|
113240
|
+
logger.debug(`Updated post: ${updatedPost.title.rendered} (ID: ${updatedPost.id})`);
|
|
113241
|
+
} else {
|
|
113242
|
+
logger.debug(`Post ${mdxFile.frontmatter.postId} not found, creating new post`);
|
|
113243
|
+
updatedPost = await connection.createPost(postData);
|
|
113244
|
+
logger.info(`Created new post: ${updatedPost.title.rendered} (ID: ${updatedPost.id})`);
|
|
113245
|
+
}
|
|
113208
113246
|
await this.updateMDXAfterPush(filePath2, updatedPost);
|
|
113209
113247
|
} else {
|
|
113210
113248
|
updatedPost = await connection.createPost(postData);
|
|
@@ -113213,18 +113251,24 @@ ${"=".repeat(80)}`);
|
|
|
113213
113251
|
}
|
|
113214
113252
|
}
|
|
113215
113253
|
async processFileQuiet(filePath2, options, connection, result2) {
|
|
113254
|
+
logger.debug(`[processFileQuiet] Starting to process: ${filePath2}`);
|
|
113216
113255
|
const mdxFile = await this.parseFile(filePath2);
|
|
113217
113256
|
const isUpdate = !!mdxFile.frontmatter.postId;
|
|
113257
|
+
logger.debug(`[processFileQuiet] isUpdate: ${isUpdate}, postId: ${mdxFile.frontmatter.postId}`);
|
|
113218
113258
|
if (isUpdate && !options.force) {
|
|
113259
|
+
logger.debug(`[processFileQuiet] Checking for conflicts...`);
|
|
113219
113260
|
const conflict = await this.checkForConflicts(mdxFile, connection);
|
|
113220
113261
|
if (conflict) {
|
|
113262
|
+
logger.debug(`[processFileQuiet] Conflict found, skipping`);
|
|
113221
113263
|
result2.conflicts.push(conflict);
|
|
113222
113264
|
return;
|
|
113223
113265
|
}
|
|
113224
113266
|
}
|
|
113225
113267
|
if (options.dryRun) {
|
|
113268
|
+
logger.debug(`[processFileQuiet] Dry run, skipping`);
|
|
113226
113269
|
return;
|
|
113227
113270
|
}
|
|
113271
|
+
logger.debug(`[processFileQuiet] Rendering MDX to HTML...`);
|
|
113228
113272
|
const htmlContent = await this.getBlockRenderer().renderMDXContentToHTML(mdxFile.content);
|
|
113229
113273
|
const pathParts = filePath2.split(path6.sep);
|
|
113230
113274
|
const postType = pathParts[pathParts.length - 2];
|
|
@@ -113237,15 +113281,29 @@ ${"=".repeat(80)}`);
|
|
|
113237
113281
|
slug: mdxFile.frontmatter.slug,
|
|
113238
113282
|
categories: mdxFile.frontmatter.categories,
|
|
113239
113283
|
tags: mdxFile.frontmatter.tags,
|
|
113240
|
-
meta: mdxFile.frontmatter.meta
|
|
113284
|
+
meta: mdxFile.frontmatter.meta,
|
|
113285
|
+
id: isUpdate ? mdxFile.frontmatter.postId : undefined
|
|
113241
113286
|
};
|
|
113242
113287
|
let updatedPost;
|
|
113243
113288
|
if (isUpdate) {
|
|
113244
|
-
|
|
113289
|
+
logger.debug(`[processFileQuiet] Checking if post ${mdxFile.frontmatter.postId} exists...`);
|
|
113290
|
+
const existingPost = await connection.getPost(mdxFile.frontmatter.postId);
|
|
113291
|
+
if (existingPost) {
|
|
113292
|
+
logger.debug(`[processFileQuiet] Post ${mdxFile.frontmatter.postId} exists, updating...`);
|
|
113293
|
+
updatedPost = await connection.updatePost(mdxFile.frontmatter.postId, postData);
|
|
113294
|
+
} else {
|
|
113295
|
+
logger.debug(`[processFileQuiet] Post ${mdxFile.frontmatter.postId} not found, creating new...`);
|
|
113296
|
+
updatedPost = await connection.createPost(postData);
|
|
113297
|
+
logger.debug(`[processFileQuiet] Created new post with ID: ${updatedPost.id}`);
|
|
113298
|
+
}
|
|
113245
113299
|
} else {
|
|
113300
|
+
logger.debug(`[processFileQuiet] No postId, creating new post...`);
|
|
113246
113301
|
updatedPost = await connection.createPost(postData);
|
|
113302
|
+
logger.debug(`[processFileQuiet] Created new post with ID: ${updatedPost.id}`);
|
|
113247
113303
|
}
|
|
113304
|
+
logger.debug(`[processFileQuiet] Updating MDX file...`);
|
|
113248
113305
|
await this.updateMDXAfterPush(filePath2, updatedPost);
|
|
113306
|
+
logger.debug(`[processFileQuiet] Done`);
|
|
113249
113307
|
}
|
|
113250
113308
|
async checkForConflicts(mdxFile, connection) {
|
|
113251
113309
|
if (!mdxFile.frontmatter.postId) {
|
|
@@ -113254,13 +113312,7 @@ ${"=".repeat(80)}`);
|
|
|
113254
113312
|
try {
|
|
113255
113313
|
const wpPost = await connection.getPost(mdxFile.frontmatter.postId);
|
|
113256
113314
|
if (!wpPost) {
|
|
113257
|
-
return
|
|
113258
|
-
postId: mdxFile.frontmatter.postId,
|
|
113259
|
-
localPath: mdxFile.path,
|
|
113260
|
-
wordpressPost: null,
|
|
113261
|
-
localFile: mdxFile,
|
|
113262
|
-
conflictType: "missing-source"
|
|
113263
|
-
};
|
|
113315
|
+
return null;
|
|
113264
113316
|
}
|
|
113265
113317
|
return null;
|
|
113266
113318
|
} catch (error) {
|
|
@@ -115894,7 +115946,7 @@ class DockerEnvManager {
|
|
|
115894
115946
|
});
|
|
115895
115947
|
}
|
|
115896
115948
|
async stop() {
|
|
115897
|
-
logger.
|
|
115949
|
+
logger.progress("\uD83D\uDC33 Stopping Docker containers...");
|
|
115898
115950
|
try {
|
|
115899
115951
|
execSync(`docker stop ${this.containerNames.wordpress}`, {
|
|
115900
115952
|
stdio: "pipe"
|
|
@@ -116132,7 +116184,7 @@ class DockerEnvManager {
|
|
|
116132
116184
|
// package.json
|
|
116133
116185
|
var package_default = {
|
|
116134
116186
|
name: "@wordpress-flow/cli",
|
|
116135
|
-
version: "1.2.
|
|
116187
|
+
version: "1.2.10",
|
|
116136
116188
|
type: "module",
|
|
116137
116189
|
description: "TypeScript-based WordPress block creation system",
|
|
116138
116190
|
main: "dist/index.js",
|
|
@@ -116492,14 +116544,18 @@ class DevModeOrchestrator {
|
|
|
116492
116544
|
async performInitialContentPush() {
|
|
116493
116545
|
if (!fs15.existsSync(this.contentDir))
|
|
116494
116546
|
return;
|
|
116495
|
-
const
|
|
116496
|
-
const
|
|
116547
|
+
const config = this.configManager.getConfig();
|
|
116548
|
+
const postTypes = config.sync.postTypes || ["post", "page"];
|
|
116549
|
+
console.log(`[DEBUG] Initial push - Post types: ${JSON.stringify(postTypes)}`);
|
|
116497
116550
|
const contentFiles = [];
|
|
116498
|
-
|
|
116499
|
-
|
|
116500
|
-
|
|
116501
|
-
|
|
116502
|
-
|
|
116551
|
+
for (const postType of postTypes) {
|
|
116552
|
+
const typeDir = path17.join(this.contentDir, postType);
|
|
116553
|
+
console.log(`[DEBUG] Checking directory: ${typeDir}, exists: ${fs15.existsSync(typeDir)}`);
|
|
116554
|
+
if (fs15.existsSync(typeDir)) {
|
|
116555
|
+
const files = this.findMDXFiles(typeDir);
|
|
116556
|
+
console.log(`[DEBUG] Found ${files.length} files in ${postType}`);
|
|
116557
|
+
contentFiles.push(...files);
|
|
116558
|
+
}
|
|
116503
116559
|
}
|
|
116504
116560
|
if (contentFiles.length === 0) {
|
|
116505
116561
|
return;
|
|
@@ -116698,8 +116754,13 @@ class DevModeOrchestrator {
|
|
|
116698
116754
|
startPageWatcher() {
|
|
116699
116755
|
if (!fs15.existsSync(this.contentDir))
|
|
116700
116756
|
return;
|
|
116701
|
-
|
|
116702
|
-
const
|
|
116757
|
+
const config = this.configManager.getConfig();
|
|
116758
|
+
const postTypes = config.sync.postTypes || ["post", "page"];
|
|
116759
|
+
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
|
+
logger.debug(`Watching content: ${this.contentDir} (${postTypes.join(", ")})`);
|
|
116763
|
+
const watcher = $watch(watchPatterns, {
|
|
116703
116764
|
cwd: this.contentDir,
|
|
116704
116765
|
...this.getWatcherOptions()
|
|
116705
116766
|
});
|