@wordpress-flow/cli 1.1.1 → 1.1.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/index.js +246 -79
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -85232,7 +85232,7 @@ class DatabaseClient {
|
|
|
85232
85232
|
if (post.tags) {
|
|
85233
85233
|
await this.updatePostTerms(id, post.tags, "post_tag");
|
|
85234
85234
|
}
|
|
85235
|
-
logger.
|
|
85235
|
+
logger.debug(`Post ${id} updated in database`);
|
|
85236
85236
|
const updatedPost = await this.getPost(id);
|
|
85237
85237
|
if (!updatedPost) {
|
|
85238
85238
|
throw new Error(`Failed to retrieve updated post ${id}`);
|
|
@@ -112942,11 +112942,9 @@ class OfficialMDXRenderer {
|
|
|
112942
112942
|
createComponents() {
|
|
112943
112943
|
const components = {};
|
|
112944
112944
|
for (const [name2, component] of this.componentMap.entries()) {
|
|
112945
|
-
logger.info(`[DEBUG] Processing component: ${name2}, type: ${typeof component}`);
|
|
112946
112945
|
const parts = name2.split(".");
|
|
112947
112946
|
const componentName = parts.length === 2 ? parts[1] : name2;
|
|
112948
112947
|
components[componentName] = component;
|
|
112949
|
-
logger.info(`[DEBUG] Added component: ${componentName} (from ${name2})`);
|
|
112950
112948
|
}
|
|
112951
112949
|
return components;
|
|
112952
112950
|
}
|
|
@@ -112966,26 +112964,66 @@ class OfficialMDXRenderer {
|
|
|
112966
112964
|
}
|
|
112967
112965
|
logger.debug("React tree created successfully, starting SSR rendering...");
|
|
112968
112966
|
let html5;
|
|
112967
|
+
const originalConsoleError = console.error;
|
|
112968
|
+
const suppressedWarnings = [];
|
|
112969
|
+
console.error = (...args) => {
|
|
112970
|
+
const msg = args[0]?.toString() || "";
|
|
112971
|
+
if (msg.includes("React.jsx: type is invalid") || msg.includes("Warning:")) {
|
|
112972
|
+
suppressedWarnings.push(msg);
|
|
112973
|
+
return;
|
|
112974
|
+
}
|
|
112975
|
+
originalConsoleError.apply(console, args);
|
|
112976
|
+
};
|
|
112969
112977
|
try {
|
|
112970
112978
|
html5 = $renderToString(reactTree);
|
|
112971
112979
|
logger.debug("React SSR rendering completed successfully");
|
|
112972
112980
|
} catch (ssrError) {
|
|
112973
|
-
|
|
112974
|
-
|
|
112975
|
-
|
|
112976
|
-
|
|
112977
|
-
|
|
112978
|
-
|
|
112979
|
-
|
|
112980
|
-
|
|
112981
|
+
const errorMsg = ssrError.message;
|
|
112982
|
+
if (errorMsg.includes("Element type is invalid") && errorMsg.includes("undefined")) {
|
|
112983
|
+
const availableComponents = Object.keys(components);
|
|
112984
|
+
const helpMsg = this.createUndefinedComponentError(mdxContent, availableComponents, suppressedWarnings);
|
|
112985
|
+
throw new Error(helpMsg);
|
|
112986
|
+
}
|
|
112987
|
+
throw new Error(`SSR render failed: ${errorMsg}`);
|
|
112988
|
+
} finally {
|
|
112989
|
+
console.error = originalConsoleError;
|
|
112981
112990
|
}
|
|
112982
112991
|
logger.debug(`Official MDX rendering completed, HTML length: ${html5.length}`);
|
|
112983
112992
|
return html5;
|
|
112984
112993
|
} catch (error) {
|
|
112985
|
-
|
|
112986
|
-
|
|
112994
|
+
const msg = error.message;
|
|
112995
|
+
if (msg.startsWith("Missing component") || msg.startsWith("A component returned") || msg.startsWith("SSR render failed")) {
|
|
112996
|
+
throw error;
|
|
112997
|
+
}
|
|
112998
|
+
throw new Error(`MDX render failed: ${msg}`);
|
|
112987
112999
|
}
|
|
112988
113000
|
}
|
|
113001
|
+
createUndefinedComponentError(mdxContent, availableComponents, suppressedWarnings = []) {
|
|
113002
|
+
for (const warning of suppressedWarnings) {
|
|
113003
|
+
if (warning.includes("Check the render method of")) {
|
|
113004
|
+
const match3 = warning.match(/Check the render method of `(\w+)`/);
|
|
113005
|
+
if (match3) {
|
|
113006
|
+
return `Component "${match3[1]}" uses an undefined component. Check its imports and child components.`;
|
|
113007
|
+
}
|
|
113008
|
+
}
|
|
113009
|
+
}
|
|
113010
|
+
const componentPattern = /<([A-Z][a-zA-Z0-9]*)/g;
|
|
113011
|
+
const usedComponents = new Set;
|
|
113012
|
+
let match2;
|
|
113013
|
+
while ((match2 = componentPattern.exec(mdxContent)) !== null) {
|
|
113014
|
+
usedComponents.add(match2[1]);
|
|
113015
|
+
}
|
|
113016
|
+
const missingComponents = [];
|
|
113017
|
+
for (const comp of usedComponents) {
|
|
113018
|
+
if (!availableComponents.includes(comp)) {
|
|
113019
|
+
missingComponents.push(comp);
|
|
113020
|
+
}
|
|
113021
|
+
}
|
|
113022
|
+
if (missingComponents.length > 0) {
|
|
113023
|
+
return `Missing component(s): ${missingComponents.join(", ")}. Not built or not exported.`;
|
|
113024
|
+
}
|
|
113025
|
+
return `A block component uses an undefined import. Check that all imports in your block files exist and are exported correctly.`;
|
|
113026
|
+
}
|
|
112989
113027
|
postProcessHTML(html5) {
|
|
112990
113028
|
return html5.replace(/<wp-block-comment[^>]*>([\s\S]*?)<\/wp-block-comment>/g, "$1");
|
|
112991
113029
|
}
|
|
@@ -112997,8 +113035,7 @@ class OfficialMDXRenderer {
|
|
|
112997
113035
|
logger.debug("Official MDX to Gutenberg conversion completed");
|
|
112998
113036
|
return cleanHTML;
|
|
112999
113037
|
} catch (error) {
|
|
113000
|
-
|
|
113001
|
-
throw new Error(`MDX to Gutenberg conversion failed: ${error.message}`);
|
|
113038
|
+
throw error;
|
|
113002
113039
|
}
|
|
113003
113040
|
}
|
|
113004
113041
|
}
|
|
@@ -113032,14 +113069,7 @@ class BlockRenderer {
|
|
|
113032
113069
|
logger.debug("MDX content to HTML rendering completed");
|
|
113033
113070
|
return html5;
|
|
113034
113071
|
} catch (error) {
|
|
113035
|
-
|
|
113036
|
-
logger.error("Error message:", error.message);
|
|
113037
|
-
logger.error("Error name:", error.name);
|
|
113038
|
-
if (error.stack) {
|
|
113039
|
-
logger.error("Error stack trace:");
|
|
113040
|
-
console.error(error.stack);
|
|
113041
|
-
}
|
|
113042
|
-
throw new Error(`Official MDX rendering failed: ${error.message}`);
|
|
113072
|
+
throw error;
|
|
113043
113073
|
}
|
|
113044
113074
|
}
|
|
113045
113075
|
}
|
|
@@ -113377,6 +113407,67 @@ class PushCommand {
|
|
|
113377
113407
|
}
|
|
113378
113408
|
return result2;
|
|
113379
113409
|
}
|
|
113410
|
+
async executeQuiet(options) {
|
|
113411
|
+
try {
|
|
113412
|
+
await this.blockRegistry.loadBuiltBlocks();
|
|
113413
|
+
} catch {}
|
|
113414
|
+
const config2 = this.configManager.getConfig();
|
|
113415
|
+
const connection = await this.connectionManager.createConnection(config2.wordpress);
|
|
113416
|
+
const result2 = {
|
|
113417
|
+
success: false,
|
|
113418
|
+
operation: {
|
|
113419
|
+
type: "push",
|
|
113420
|
+
source: {
|
|
113421
|
+
type: "local",
|
|
113422
|
+
identifier: "multiple",
|
|
113423
|
+
lastModified: new Date
|
|
113424
|
+
},
|
|
113425
|
+
target: {
|
|
113426
|
+
type: "wordpress",
|
|
113427
|
+
identifier: config2.wordpress.wordpressUrl,
|
|
113428
|
+
lastModified: new Date
|
|
113429
|
+
},
|
|
113430
|
+
timestamp: new Date,
|
|
113431
|
+
status: "in-progress"
|
|
113432
|
+
},
|
|
113433
|
+
filesProcessed: 0,
|
|
113434
|
+
errors: [],
|
|
113435
|
+
conflicts: []
|
|
113436
|
+
};
|
|
113437
|
+
try {
|
|
113438
|
+
const mdxFiles = await this.findMDXFiles(options.files, config2.paths.mdxOutputDir);
|
|
113439
|
+
if (mdxFiles.length === 0) {
|
|
113440
|
+
result2.operation.status = "completed";
|
|
113441
|
+
result2.success = true;
|
|
113442
|
+
return result2;
|
|
113443
|
+
}
|
|
113444
|
+
for (const filePath2 of mdxFiles) {
|
|
113445
|
+
try {
|
|
113446
|
+
await this.processFileQuiet(filePath2, options, connection, result2);
|
|
113447
|
+
result2.filesProcessed++;
|
|
113448
|
+
} catch (error) {
|
|
113449
|
+
result2.errors.push({
|
|
113450
|
+
source: filePath2,
|
|
113451
|
+
error: error.message,
|
|
113452
|
+
recoverable: true
|
|
113453
|
+
});
|
|
113454
|
+
}
|
|
113455
|
+
}
|
|
113456
|
+
result2.operation.status = "completed";
|
|
113457
|
+
result2.success = result2.errors.length === 0 || result2.errors.every((e) => e.recoverable);
|
|
113458
|
+
} catch (error) {
|
|
113459
|
+
result2.operation.status = "failed";
|
|
113460
|
+
result2.errors.push({
|
|
113461
|
+
source: "Push operation",
|
|
113462
|
+
error: error.message,
|
|
113463
|
+
recoverable: false
|
|
113464
|
+
});
|
|
113465
|
+
throw error;
|
|
113466
|
+
} finally {
|
|
113467
|
+
await this.connectionManager.closeConnection();
|
|
113468
|
+
}
|
|
113469
|
+
return result2;
|
|
113470
|
+
}
|
|
113380
113471
|
async findMDXFiles(specifiedFiles, baseDir) {
|
|
113381
113472
|
if (specifiedFiles && specifiedFiles.length > 0) {
|
|
113382
113473
|
return specifiedFiles.map((file) => path6.resolve(file));
|
|
@@ -113436,11 +113527,47 @@ ${"=".repeat(80)}`);
|
|
|
113436
113527
|
if (isUpdate) {
|
|
113437
113528
|
updatedPost = await connection.updatePost(mdxFile.frontmatter.postId, postData);
|
|
113438
113529
|
logger.debug(`Updated post: ${updatedPost.title.rendered} (ID: ${updatedPost.id})`);
|
|
113530
|
+
await this.updateMDXAfterPush(filePath2, updatedPost);
|
|
113439
113531
|
} else {
|
|
113440
113532
|
updatedPost = await connection.createPost(postData);
|
|
113441
113533
|
logger.info(`Created new post: ${updatedPost.title.rendered} (ID: ${updatedPost.id})`);
|
|
113442
|
-
await this.
|
|
113534
|
+
await this.updateMDXAfterPush(filePath2, updatedPost);
|
|
113535
|
+
}
|
|
113536
|
+
}
|
|
113537
|
+
async processFileQuiet(filePath2, options, connection, result2) {
|
|
113538
|
+
const mdxFile = await this.parseFile(filePath2);
|
|
113539
|
+
const isUpdate = !!mdxFile.frontmatter.postId;
|
|
113540
|
+
if (isUpdate && !options.force) {
|
|
113541
|
+
const conflict = await this.checkForConflicts(mdxFile, connection);
|
|
113542
|
+
if (conflict) {
|
|
113543
|
+
result2.conflicts.push(conflict);
|
|
113544
|
+
return;
|
|
113545
|
+
}
|
|
113546
|
+
}
|
|
113547
|
+
if (options.dryRun) {
|
|
113548
|
+
return;
|
|
113549
|
+
}
|
|
113550
|
+
const htmlContent = await this.getBlockRenderer().renderMDXContentToHTML(mdxFile.content);
|
|
113551
|
+
const pathParts = filePath2.split(path6.sep);
|
|
113552
|
+
const postType = pathParts[pathParts.length - 2];
|
|
113553
|
+
const postData = {
|
|
113554
|
+
title: { raw: mdxFile.frontmatter.title },
|
|
113555
|
+
content: { raw: htmlContent },
|
|
113556
|
+
excerpt: mdxFile.frontmatter.excerpt ? { raw: mdxFile.frontmatter.excerpt } : undefined,
|
|
113557
|
+
status: mdxFile.frontmatter.status,
|
|
113558
|
+
type: postType,
|
|
113559
|
+
slug: mdxFile.frontmatter.slug,
|
|
113560
|
+
categories: mdxFile.frontmatter.categories,
|
|
113561
|
+
tags: mdxFile.frontmatter.tags,
|
|
113562
|
+
meta: mdxFile.frontmatter.meta
|
|
113563
|
+
};
|
|
113564
|
+
let updatedPost;
|
|
113565
|
+
if (isUpdate) {
|
|
113566
|
+
updatedPost = await connection.updatePost(mdxFile.frontmatter.postId, postData);
|
|
113567
|
+
} else {
|
|
113568
|
+
updatedPost = await connection.createPost(postData);
|
|
113443
113569
|
}
|
|
113570
|
+
await this.updateMDXAfterPush(filePath2, updatedPost);
|
|
113444
113571
|
}
|
|
113445
113572
|
async checkForConflicts(mdxFile, connection) {
|
|
113446
113573
|
if (!mdxFile.frontmatter.postId) {
|
|
@@ -113458,15 +113585,18 @@ ${"=".repeat(80)}`);
|
|
|
113458
113585
|
};
|
|
113459
113586
|
}
|
|
113460
113587
|
const wpModified = new Date(wpPost.modified);
|
|
113461
|
-
const
|
|
113462
|
-
if (wpModified >
|
|
113463
|
-
|
|
113464
|
-
|
|
113465
|
-
|
|
113466
|
-
|
|
113467
|
-
|
|
113468
|
-
|
|
113469
|
-
|
|
113588
|
+
const lastPushed = mdxFile.frontmatter.lastPushed ? new Date(mdxFile.frontmatter.lastPushed) : null;
|
|
113589
|
+
if (lastPushed && wpModified > lastPushed) {
|
|
113590
|
+
const tolerance = 5000;
|
|
113591
|
+
if (wpModified.getTime() - lastPushed.getTime() > tolerance) {
|
|
113592
|
+
return {
|
|
113593
|
+
postId: mdxFile.frontmatter.postId,
|
|
113594
|
+
localPath: mdxFile.path,
|
|
113595
|
+
wordpressPost: wpPost,
|
|
113596
|
+
localFile: mdxFile,
|
|
113597
|
+
conflictType: "wordpress-newer"
|
|
113598
|
+
};
|
|
113599
|
+
}
|
|
113470
113600
|
}
|
|
113471
113601
|
return null;
|
|
113472
113602
|
} catch (error) {
|
|
@@ -113490,22 +113620,43 @@ ${"=".repeat(80)}`);
|
|
|
113490
113620
|
}
|
|
113491
113621
|
}
|
|
113492
113622
|
}
|
|
113493
|
-
async
|
|
113623
|
+
async updateMDXAfterPush(filePath2, wpPost) {
|
|
113494
113624
|
try {
|
|
113495
113625
|
const content4 = fs5.readFileSync(filePath2, "utf8");
|
|
113496
113626
|
const frontmatterMatch = content4.match(/^---\n([\s\S]*?)\n---/);
|
|
113497
|
-
if (frontmatterMatch) {
|
|
113498
|
-
|
|
113499
|
-
|
|
113627
|
+
if (!frontmatterMatch) {
|
|
113628
|
+
logger.warn(`Could not find frontmatter in ${filePath2}`);
|
|
113629
|
+
return;
|
|
113630
|
+
}
|
|
113631
|
+
let frontmatter = frontmatterMatch[1];
|
|
113632
|
+
const postId = wpPost.id;
|
|
113633
|
+
const modified = wpPost.modified || new Date().toISOString();
|
|
113634
|
+
const lastPushed = new Date().toISOString();
|
|
113635
|
+
if (frontmatter.includes("postId:")) {
|
|
113636
|
+
frontmatter = frontmatter.replace(/postId:\s*\d*/, `postId: ${postId}`);
|
|
113637
|
+
} else {
|
|
113638
|
+
frontmatter = `${frontmatter}
|
|
113500
113639
|
postId: ${postId}`;
|
|
113501
|
-
const updatedContent = content4.replace(/^---\n([\s\S]*?)\n---/, `---
|
|
113502
|
-
${updatedFrontmatter}
|
|
113503
|
-
---`);
|
|
113504
|
-
fs5.writeFileSync(filePath2, updatedContent, "utf8");
|
|
113505
|
-
logger.debug(`Updated ${filePath2} with post ID: ${postId}`);
|
|
113506
113640
|
}
|
|
113641
|
+
if (frontmatter.includes("modified:")) {
|
|
113642
|
+
frontmatter = frontmatter.replace(/modified:\s*"[^"]*"/, `modified: "${modified}"`);
|
|
113643
|
+
} else {
|
|
113644
|
+
frontmatter = `${frontmatter}
|
|
113645
|
+
modified: "${modified}"`;
|
|
113646
|
+
}
|
|
113647
|
+
if (frontmatter.includes("lastPushed:")) {
|
|
113648
|
+
frontmatter = frontmatter.replace(/lastPushed:\s*"[^"]*"/, `lastPushed: "${lastPushed}"`);
|
|
113649
|
+
} else {
|
|
113650
|
+
frontmatter = `${frontmatter}
|
|
113651
|
+
lastPushed: "${lastPushed}"`;
|
|
113652
|
+
}
|
|
113653
|
+
const updatedContent = content4.replace(/^---\n([\s\S]*?)\n---/, `---
|
|
113654
|
+
${frontmatter}
|
|
113655
|
+
---`);
|
|
113656
|
+
fs5.writeFileSync(filePath2, updatedContent, "utf8");
|
|
113657
|
+
logger.debug(`Updated ${filePath2} with sync timestamps`);
|
|
113507
113658
|
} catch (error) {
|
|
113508
|
-
logger.warn(`Failed to update MDX file
|
|
113659
|
+
logger.warn(`Failed to update MDX file after push: ${error.message}`);
|
|
113509
113660
|
}
|
|
113510
113661
|
}
|
|
113511
113662
|
}
|
|
@@ -113896,30 +114047,10 @@ class DevModeUI {
|
|
|
113896
114047
|
this.setupEventListeners();
|
|
113897
114048
|
}
|
|
113898
114049
|
setupEventListeners() {
|
|
113899
|
-
this.scheduler.on("taskStart", (task) => {
|
|
113900
|
-
this.onTaskStart(task);
|
|
113901
|
-
});
|
|
113902
|
-
this.scheduler.on("taskComplete", (task, success) => {
|
|
113903
|
-
this.onTaskComplete(task, success);
|
|
113904
|
-
});
|
|
113905
114050
|
this.scheduler.on("queueChange", () => {
|
|
113906
114051
|
this.scheduleRender();
|
|
113907
114052
|
});
|
|
113908
114053
|
}
|
|
113909
|
-
onTaskStart(task) {
|
|
113910
|
-
const icon = this.getTaskIcon(task.type);
|
|
113911
|
-
const name2 = this.formatTaskName(task);
|
|
113912
|
-
logger.info(`${icon} Building: ${name2}`);
|
|
113913
|
-
}
|
|
113914
|
-
onTaskComplete(task, success) {
|
|
113915
|
-
const duration = task.completedAt && task.startedAt ? ((task.completedAt - task.startedAt) / 1000).toFixed(1) : "?";
|
|
113916
|
-
const name2 = this.formatTaskName(task);
|
|
113917
|
-
if (success) {
|
|
113918
|
-
logger.success(`✓ ${name2} (${duration}s)`);
|
|
113919
|
-
} else {
|
|
113920
|
-
logger.error(`✗ ${name2} failed: ${task.error || "Unknown error"}`);
|
|
113921
|
-
}
|
|
113922
|
-
}
|
|
113923
114054
|
getTaskIcon(type) {
|
|
113924
114055
|
switch (type) {
|
|
113925
114056
|
case "block-build":
|
|
@@ -114737,6 +114868,7 @@ var $watch = watch;
|
|
|
114737
114868
|
// src/dev/dev-mode-orchestrator.ts
|
|
114738
114869
|
import * as path16 from "path";
|
|
114739
114870
|
import * as fs14 from "fs";
|
|
114871
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
114740
114872
|
|
|
114741
114873
|
// src/build/block-scanner.ts
|
|
114742
114874
|
import * as fs7 from "fs";
|
|
@@ -115880,7 +116012,7 @@ add_action('enqueue_block_assets', 'wordpress_flow_enqueue_block_scripts');
|
|
|
115880
116012
|
// package.json
|
|
115881
116013
|
var package_default = {
|
|
115882
116014
|
name: "@wordpress-flow/cli",
|
|
115883
|
-
version: "1.1.
|
|
116015
|
+
version: "1.1.2",
|
|
115884
116016
|
type: "module",
|
|
115885
116017
|
description: "TypeScript-based WordPress block creation system",
|
|
115886
116018
|
main: "dist/index.js",
|
|
@@ -115932,6 +116064,9 @@ var package_default = {
|
|
|
115932
116064
|
};
|
|
115933
116065
|
|
|
115934
116066
|
// src/dev/dev-mode-orchestrator.ts
|
|
116067
|
+
var __filename2 = fileURLToPath4(import.meta.url);
|
|
116068
|
+
var __dirname2 = path16.dirname(__filename2);
|
|
116069
|
+
|
|
115935
116070
|
class DevModeOrchestrator {
|
|
115936
116071
|
configManager;
|
|
115937
116072
|
connectionManager;
|
|
@@ -115960,6 +116095,8 @@ class DevModeOrchestrator {
|
|
|
115960
116095
|
scriptsPath;
|
|
115961
116096
|
blockFilePaths = new Map;
|
|
115962
116097
|
importToBlock = new Map;
|
|
116098
|
+
ignoredFiles = new Set;
|
|
116099
|
+
ignoreTimeout = 2000;
|
|
115963
116100
|
constructor(options = {}) {
|
|
115964
116101
|
this.options = {
|
|
115965
116102
|
fresh: false,
|
|
@@ -116015,7 +116152,7 @@ class DevModeOrchestrator {
|
|
|
116015
116152
|
if (config2.build?.webpackConfig) {
|
|
116016
116153
|
this.webpackConfig = this.configManager.resolvePath(config2.build.webpackConfig);
|
|
116017
116154
|
} else {
|
|
116018
|
-
this.webpackConfig = path16.join(
|
|
116155
|
+
this.webpackConfig = path16.join(__dirname2, "..", "webpack.config.cjs");
|
|
116019
116156
|
}
|
|
116020
116157
|
this.scriptsPath = config2.build?.scriptsPath ? this.configManager.resolvePath(config2.build.scriptsPath) : undefined;
|
|
116021
116158
|
this.contentDir = this.configManager.resolvePath(config2.paths.mdxOutputDir);
|
|
@@ -116096,15 +116233,16 @@ class DevModeOrchestrator {
|
|
|
116096
116233
|
this.ui.showInitialBuildComplete(blocks.length, blocks.length, 0, Date.now() - startTime);
|
|
116097
116234
|
return;
|
|
116098
116235
|
}
|
|
116236
|
+
console.log(`\uD83D\uDCE6 Blocks to build: ${blocksToRebuild.map((b) => b.name).join(", ")}`);
|
|
116099
116237
|
let successCount = 0;
|
|
116100
116238
|
let failCount = 0;
|
|
116101
116239
|
const blockScripts = new Map;
|
|
116102
116240
|
const results = await this.workerPool.buildAll(blocksToRebuild, (completed, total, blockName, success) => {
|
|
116103
116241
|
if (success) {
|
|
116104
|
-
|
|
116242
|
+
console.log(` ✅ ${blockName} [${completed}/${total}]`);
|
|
116105
116243
|
successCount++;
|
|
116106
116244
|
} else {
|
|
116107
|
-
|
|
116245
|
+
console.log(` ❌ ${blockName} failed [${completed}/${total}]`);
|
|
116108
116246
|
failCount++;
|
|
116109
116247
|
}
|
|
116110
116248
|
});
|
|
@@ -116212,6 +116350,10 @@ class DevModeOrchestrator {
|
|
|
116212
116350
|
}
|
|
116213
116351
|
handlePageFileEvent(eventType, filePath2) {
|
|
116214
116352
|
const fullPath = path16.resolve(this.contentDir, filePath2);
|
|
116353
|
+
if (this.ignoredFiles.has(fullPath)) {
|
|
116354
|
+
logger.debug(`Ignoring self-triggered change: ${filePath2}`);
|
|
116355
|
+
return;
|
|
116356
|
+
}
|
|
116215
116357
|
this.changeQueue.queuePageChange(fullPath, eventType);
|
|
116216
116358
|
if (eventType === "unlink") {
|
|
116217
116359
|
this.dependencyTracker.removeFile(fullPath);
|
|
@@ -116219,13 +116361,18 @@ class DevModeOrchestrator {
|
|
|
116219
116361
|
this.dependencyTracker.updateFileDependencies(fullPath, "page");
|
|
116220
116362
|
}
|
|
116221
116363
|
}
|
|
116364
|
+
ignoreFileTemporarily(filePath2) {
|
|
116365
|
+
this.ignoredFiles.add(filePath2);
|
|
116366
|
+
setTimeout(() => {
|
|
116367
|
+
this.ignoredFiles.delete(filePath2);
|
|
116368
|
+
}, this.ignoreTimeout);
|
|
116369
|
+
}
|
|
116222
116370
|
async rescanBlocks() {
|
|
116223
116371
|
const blocks = await this.scanBlocks();
|
|
116224
116372
|
logger.debug(`Re-scanned: ${blocks.length} blocks`);
|
|
116225
116373
|
}
|
|
116226
116374
|
async processBatch(batch) {
|
|
116227
116375
|
const blockNames = Array.from(batch.blocks.keys());
|
|
116228
|
-
this.ui.showBatchStart(blockNames.length, batch.templates.length, batch.pages.length);
|
|
116229
116376
|
if (batch.deletedBlocks.length > 0) {
|
|
116230
116377
|
await this.deletionHandler.handleMultipleDeletions(batch.deletedBlocks);
|
|
116231
116378
|
}
|
|
@@ -116260,25 +116407,29 @@ class DevModeOrchestrator {
|
|
|
116260
116407
|
const taskId = this.taskScheduler.scheduleBlockBuild(block.name);
|
|
116261
116408
|
taskIds.push(taskId);
|
|
116262
116409
|
}
|
|
116263
|
-
const
|
|
116264
|
-
|
|
116265
|
-
const
|
|
116410
|
+
for (const block of blocksToRebuild) {
|
|
116411
|
+
const taskId = taskIds.find((id) => id.includes(block.name));
|
|
116412
|
+
const startTime = Date.now();
|
|
116413
|
+
process.stdout.write(`\uD83D\uDD28 ${block.name} → `);
|
|
116414
|
+
const results = await this.workerPool.buildAll([block]);
|
|
116415
|
+
const result2 = results[0];
|
|
116416
|
+
const duration = `${((Date.now() - startTime) / 1000).toFixed(1)}s`;
|
|
116266
116417
|
if (result2.aborted) {
|
|
116418
|
+
console.log(`⏹️ aborted`);
|
|
116267
116419
|
if (taskId)
|
|
116268
116420
|
this.taskScheduler.abortTask(taskId);
|
|
116269
116421
|
continue;
|
|
116270
116422
|
}
|
|
116271
116423
|
if (result2.success) {
|
|
116272
|
-
const
|
|
116273
|
-
|
|
116274
|
-
const hash = this.hashManager.calculateSourceHash(block.filePath);
|
|
116275
|
-
this.hashManager.storeHash(block.name, hash);
|
|
116276
|
-
}
|
|
116424
|
+
const hash = this.hashManager.calculateSourceHash(block.filePath);
|
|
116425
|
+
this.hashManager.storeHash(block.name, hash);
|
|
116277
116426
|
await this.componentRegistry.reloadBlock(result2.blockName);
|
|
116427
|
+
console.log(`✅ (${duration})`);
|
|
116278
116428
|
if (taskId) {
|
|
116279
116429
|
this.taskScheduler.completeTask(taskId, true, result2);
|
|
116280
116430
|
}
|
|
116281
116431
|
} else {
|
|
116432
|
+
console.log(`❌ ${result2.error || "failed"}`);
|
|
116282
116433
|
if (taskId) {
|
|
116283
116434
|
this.taskScheduler.completeTask(taskId, false, null, result2.error);
|
|
116284
116435
|
}
|
|
@@ -116315,15 +116466,27 @@ class DevModeOrchestrator {
|
|
|
116315
116466
|
return;
|
|
116316
116467
|
for (const pagePath of pagePaths) {
|
|
116317
116468
|
const taskId = this.taskScheduler.schedulePagePush(pagePath, []);
|
|
116469
|
+
const fileName = path16.basename(pagePath);
|
|
116470
|
+
const startTime = Date.now();
|
|
116471
|
+
this.ignoreFileTemporarily(pagePath);
|
|
116318
116472
|
try {
|
|
116319
|
-
await this.pushCommand.
|
|
116473
|
+
await this.pushCommand.executeQuiet({
|
|
116320
116474
|
files: [pagePath],
|
|
116321
116475
|
force: false,
|
|
116322
116476
|
dryRun: false
|
|
116323
116477
|
});
|
|
116478
|
+
const duration = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
116479
|
+
console.log(`\uD83D\uDE80 ${fileName} → ✅ (${duration}s)`);
|
|
116324
116480
|
this.taskScheduler.completeTask(taskId, true);
|
|
116325
116481
|
} catch (error) {
|
|
116326
|
-
|
|
116482
|
+
const errorMsg = error.message;
|
|
116483
|
+
if (errorMsg.length > 60) {
|
|
116484
|
+
console.log(`\uD83D\uDE80 ${fileName} → ❌`);
|
|
116485
|
+
console.log(` ${errorMsg}`);
|
|
116486
|
+
} else {
|
|
116487
|
+
console.log(`\uD83D\uDE80 ${fileName} → ❌ ${errorMsg}`);
|
|
116488
|
+
}
|
|
116489
|
+
this.taskScheduler.completeTask(taskId, false, null, errorMsg);
|
|
116327
116490
|
}
|
|
116328
116491
|
}
|
|
116329
116492
|
}
|
|
@@ -116400,6 +116563,7 @@ class DevCommand {
|
|
|
116400
116563
|
|
|
116401
116564
|
// src/commands/build-command.ts
|
|
116402
116565
|
import * as path21 from "path";
|
|
116566
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
116403
116567
|
|
|
116404
116568
|
// src/build/block-builder.ts
|
|
116405
116569
|
import * as fs17 from "fs";
|
|
@@ -116971,6 +117135,9 @@ class WorkerPool {
|
|
|
116971
117135
|
}
|
|
116972
117136
|
|
|
116973
117137
|
// src/commands/build-command.ts
|
|
117138
|
+
var __filename3 = fileURLToPath5(import.meta.url);
|
|
117139
|
+
var __dirname3 = path21.dirname(__filename3);
|
|
117140
|
+
|
|
116974
117141
|
class BuildCommand {
|
|
116975
117142
|
configManager;
|
|
116976
117143
|
blockScanner;
|
|
@@ -116998,7 +117165,7 @@ class BuildCommand {
|
|
|
116998
117165
|
} else if (config2.build?.webpackConfig) {
|
|
116999
117166
|
webpackConfig = this.configManager.resolvePath(config2.build.webpackConfig);
|
|
117000
117167
|
} else {
|
|
117001
|
-
webpackConfig = path21.join(
|
|
117168
|
+
webpackConfig = path21.join(__dirname3, "..", "webpack.config.cjs");
|
|
117002
117169
|
}
|
|
117003
117170
|
const scriptsPath = config2.build?.scriptsPath ? this.configManager.resolvePath(config2.build.scriptsPath) : undefined;
|
|
117004
117171
|
logger.info(`Scanning blocks in: ${blocksDir}`);
|