@wordpress-flow/cli 1.2.8 → 1.2.9
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 +65 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -84899,15 +84899,27 @@ class DatabaseClient {
|
|
|
84899
84899
|
await this.connect();
|
|
84900
84900
|
try {
|
|
84901
84901
|
logger.debug("Creating new post in database...");
|
|
84902
|
-
const
|
|
84902
|
+
const useSpecificId = post.id !== undefined;
|
|
84903
|
+
const query = useSpecificId ? `
|
|
84904
|
+
INSERT INTO wp_posts (
|
|
84905
|
+
ID, post_title, post_content, post_excerpt, post_status,
|
|
84906
|
+
post_type, post_name, post_author, post_date,
|
|
84907
|
+
post_date_gmt, post_modified, post_modified_gmt,
|
|
84908
|
+
guid, comment_status, ping_status, to_ping, pinged,
|
|
84909
|
+
post_content_filtered, post_password, post_parent,
|
|
84910
|
+
menu_order, post_mime_type, comment_count
|
|
84911
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), UTC_TIMESTAMP(), NOW(), UTC_TIMESTAMP(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
84912
|
+
` : `
|
|
84903
84913
|
INSERT INTO wp_posts (
|
|
84904
84914
|
post_title, post_content, post_excerpt, post_status,
|
|
84905
84915
|
post_type, post_name, post_author, post_date,
|
|
84906
84916
|
post_date_gmt, post_modified, post_modified_gmt,
|
|
84907
|
-
guid, comment_status, ping_status
|
|
84908
|
-
|
|
84917
|
+
guid, comment_status, ping_status, to_ping, pinged,
|
|
84918
|
+
post_content_filtered, post_password, post_parent,
|
|
84919
|
+
menu_order, post_mime_type, comment_count
|
|
84920
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, NOW(), UTC_TIMESTAMP(), NOW(), UTC_TIMESTAMP(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
84909
84921
|
`;
|
|
84910
|
-
const
|
|
84922
|
+
const baseValues = [
|
|
84911
84923
|
post.title.raw || post.title.rendered,
|
|
84912
84924
|
post.content.raw,
|
|
84913
84925
|
post.excerpt?.raw || post.excerpt?.rendered || "",
|
|
@@ -84917,10 +84929,21 @@ class DatabaseClient {
|
|
|
84917
84929
|
post.author || 1,
|
|
84918
84930
|
"",
|
|
84919
84931
|
post.comment_status || "open",
|
|
84920
|
-
post.ping_status || "open"
|
|
84932
|
+
post.ping_status || "open",
|
|
84933
|
+
"",
|
|
84934
|
+
"",
|
|
84935
|
+
"",
|
|
84936
|
+
"",
|
|
84937
|
+
0,
|
|
84938
|
+
0,
|
|
84939
|
+
"",
|
|
84940
|
+
0
|
|
84921
84941
|
];
|
|
84942
|
+
const values = useSpecificId ? [post.id, ...baseValues] : baseValues;
|
|
84943
|
+
logger.debug(`useSpecificId: ${useSpecificId}, values count: ${values.length}`);
|
|
84944
|
+
logger.debug(`Query: ${query}`);
|
|
84922
84945
|
const [result2] = await this.connection.execute(query, values);
|
|
84923
|
-
const insertId = result2.insertId;
|
|
84946
|
+
const insertId = useSpecificId ? post.id : result2.insertId;
|
|
84924
84947
|
const guid = `${this.config.wordpressUrl}/?p=${insertId}`;
|
|
84925
84948
|
await this.connection.execute("UPDATE wp_posts SET guid = ? WHERE ID = ?", [guid, insertId]);
|
|
84926
84949
|
if (post.meta) {
|
|
@@ -113199,12 +113222,20 @@ ${"=".repeat(80)}`);
|
|
|
113199
113222
|
slug: mdxFile.frontmatter.slug,
|
|
113200
113223
|
categories: mdxFile.frontmatter.categories,
|
|
113201
113224
|
tags: mdxFile.frontmatter.tags,
|
|
113202
|
-
meta: mdxFile.frontmatter.meta
|
|
113225
|
+
meta: mdxFile.frontmatter.meta,
|
|
113226
|
+
id: isUpdate ? mdxFile.frontmatter.postId : undefined
|
|
113203
113227
|
};
|
|
113204
113228
|
let updatedPost;
|
|
113205
113229
|
if (isUpdate) {
|
|
113206
|
-
|
|
113207
|
-
|
|
113230
|
+
const existingPost = await connection.getPost(mdxFile.frontmatter.postId);
|
|
113231
|
+
if (existingPost) {
|
|
113232
|
+
updatedPost = await connection.updatePost(mdxFile.frontmatter.postId, postData);
|
|
113233
|
+
logger.debug(`Updated post: ${updatedPost.title.rendered} (ID: ${updatedPost.id})`);
|
|
113234
|
+
} else {
|
|
113235
|
+
logger.debug(`Post ${mdxFile.frontmatter.postId} not found, creating new post`);
|
|
113236
|
+
updatedPost = await connection.createPost(postData);
|
|
113237
|
+
logger.info(`Created new post: ${updatedPost.title.rendered} (ID: ${updatedPost.id})`);
|
|
113238
|
+
}
|
|
113208
113239
|
await this.updateMDXAfterPush(filePath2, updatedPost);
|
|
113209
113240
|
} else {
|
|
113210
113241
|
updatedPost = await connection.createPost(postData);
|
|
@@ -113213,18 +113244,24 @@ ${"=".repeat(80)}`);
|
|
|
113213
113244
|
}
|
|
113214
113245
|
}
|
|
113215
113246
|
async processFileQuiet(filePath2, options, connection, result2) {
|
|
113247
|
+
logger.debug(`[processFileQuiet] Starting to process: ${filePath2}`);
|
|
113216
113248
|
const mdxFile = await this.parseFile(filePath2);
|
|
113217
113249
|
const isUpdate = !!mdxFile.frontmatter.postId;
|
|
113250
|
+
logger.debug(`[processFileQuiet] isUpdate: ${isUpdate}, postId: ${mdxFile.frontmatter.postId}`);
|
|
113218
113251
|
if (isUpdate && !options.force) {
|
|
113252
|
+
logger.debug(`[processFileQuiet] Checking for conflicts...`);
|
|
113219
113253
|
const conflict = await this.checkForConflicts(mdxFile, connection);
|
|
113220
113254
|
if (conflict) {
|
|
113255
|
+
logger.debug(`[processFileQuiet] Conflict found, skipping`);
|
|
113221
113256
|
result2.conflicts.push(conflict);
|
|
113222
113257
|
return;
|
|
113223
113258
|
}
|
|
113224
113259
|
}
|
|
113225
113260
|
if (options.dryRun) {
|
|
113261
|
+
logger.debug(`[processFileQuiet] Dry run, skipping`);
|
|
113226
113262
|
return;
|
|
113227
113263
|
}
|
|
113264
|
+
logger.debug(`[processFileQuiet] Rendering MDX to HTML...`);
|
|
113228
113265
|
const htmlContent = await this.getBlockRenderer().renderMDXContentToHTML(mdxFile.content);
|
|
113229
113266
|
const pathParts = filePath2.split(path6.sep);
|
|
113230
113267
|
const postType = pathParts[pathParts.length - 2];
|
|
@@ -113237,15 +113274,29 @@ ${"=".repeat(80)}`);
|
|
|
113237
113274
|
slug: mdxFile.frontmatter.slug,
|
|
113238
113275
|
categories: mdxFile.frontmatter.categories,
|
|
113239
113276
|
tags: mdxFile.frontmatter.tags,
|
|
113240
|
-
meta: mdxFile.frontmatter.meta
|
|
113277
|
+
meta: mdxFile.frontmatter.meta,
|
|
113278
|
+
id: isUpdate ? mdxFile.frontmatter.postId : undefined
|
|
113241
113279
|
};
|
|
113242
113280
|
let updatedPost;
|
|
113243
113281
|
if (isUpdate) {
|
|
113244
|
-
|
|
113282
|
+
logger.debug(`[processFileQuiet] Checking if post ${mdxFile.frontmatter.postId} exists...`);
|
|
113283
|
+
const existingPost = await connection.getPost(mdxFile.frontmatter.postId);
|
|
113284
|
+
if (existingPost) {
|
|
113285
|
+
logger.debug(`[processFileQuiet] Post ${mdxFile.frontmatter.postId} exists, updating...`);
|
|
113286
|
+
updatedPost = await connection.updatePost(mdxFile.frontmatter.postId, postData);
|
|
113287
|
+
} else {
|
|
113288
|
+
logger.debug(`[processFileQuiet] Post ${mdxFile.frontmatter.postId} not found, creating new...`);
|
|
113289
|
+
updatedPost = await connection.createPost(postData);
|
|
113290
|
+
logger.debug(`[processFileQuiet] Created new post with ID: ${updatedPost.id}`);
|
|
113291
|
+
}
|
|
113245
113292
|
} else {
|
|
113293
|
+
logger.debug(`[processFileQuiet] No postId, creating new post...`);
|
|
113246
113294
|
updatedPost = await connection.createPost(postData);
|
|
113295
|
+
logger.debug(`[processFileQuiet] Created new post with ID: ${updatedPost.id}`);
|
|
113247
113296
|
}
|
|
113297
|
+
logger.debug(`[processFileQuiet] Updating MDX file...`);
|
|
113248
113298
|
await this.updateMDXAfterPush(filePath2, updatedPost);
|
|
113299
|
+
logger.debug(`[processFileQuiet] Done`);
|
|
113249
113300
|
}
|
|
113250
113301
|
async checkForConflicts(mdxFile, connection) {
|
|
113251
113302
|
if (!mdxFile.frontmatter.postId) {
|
|
@@ -113254,13 +113305,7 @@ ${"=".repeat(80)}`);
|
|
|
113254
113305
|
try {
|
|
113255
113306
|
const wpPost = await connection.getPost(mdxFile.frontmatter.postId);
|
|
113256
113307
|
if (!wpPost) {
|
|
113257
|
-
return
|
|
113258
|
-
postId: mdxFile.frontmatter.postId,
|
|
113259
|
-
localPath: mdxFile.path,
|
|
113260
|
-
wordpressPost: null,
|
|
113261
|
-
localFile: mdxFile,
|
|
113262
|
-
conflictType: "missing-source"
|
|
113263
|
-
};
|
|
113308
|
+
return null;
|
|
113264
113309
|
}
|
|
113265
113310
|
return null;
|
|
113266
113311
|
} catch (error) {
|
|
@@ -115894,7 +115939,7 @@ class DockerEnvManager {
|
|
|
115894
115939
|
});
|
|
115895
115940
|
}
|
|
115896
115941
|
async stop() {
|
|
115897
|
-
logger.
|
|
115942
|
+
logger.progress("\uD83D\uDC33 Stopping Docker containers...");
|
|
115898
115943
|
try {
|
|
115899
115944
|
execSync(`docker stop ${this.containerNames.wordpress}`, {
|
|
115900
115945
|
stdio: "pipe"
|
|
@@ -116132,7 +116177,7 @@ class DockerEnvManager {
|
|
|
116132
116177
|
// package.json
|
|
116133
116178
|
var package_default = {
|
|
116134
116179
|
name: "@wordpress-flow/cli",
|
|
116135
|
-
version: "1.2.
|
|
116180
|
+
version: "1.2.9",
|
|
116136
116181
|
type: "module",
|
|
116137
116182
|
description: "TypeScript-based WordPress block creation system",
|
|
116138
116183
|
main: "dist/index.js",
|