@wordpress-flow/cli 1.1.4 → 1.2.0
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/build/block-build-worker.js +1 -1
- package/dist/index.js +324 -245
- package/package.json +1 -1
|
@@ -1890,7 +1890,7 @@ if (document.readyState === 'loading') {
|
|
|
1890
1890
|
return entryPath;
|
|
1891
1891
|
}
|
|
1892
1892
|
async function buildBlockScripts(scripts, scriptsPath, outputDir) {
|
|
1893
|
-
const scriptsOutputDir = path.join(
|
|
1893
|
+
const scriptsOutputDir = path.join(outputDir, "scripts");
|
|
1894
1894
|
fs.mkdirSync(scriptsOutputDir, { recursive: true });
|
|
1895
1895
|
const outputPaths = [];
|
|
1896
1896
|
for (const script of scripts) {
|
package/dist/index.js
CHANGED
|
@@ -80897,13 +80897,33 @@ Conflict Resolution:`));
|
|
|
80897
80897
|
// src/config/config-manager.ts
|
|
80898
80898
|
import * as fs2 from "fs";
|
|
80899
80899
|
import * as path2 from "path";
|
|
80900
|
+
var DEFAULTS = {
|
|
80901
|
+
paths: {
|
|
80902
|
+
theme: "./theme",
|
|
80903
|
+
content: "./content",
|
|
80904
|
+
plugins: "./plugins"
|
|
80905
|
+
},
|
|
80906
|
+
sync: {
|
|
80907
|
+
excludePostTypes: [],
|
|
80908
|
+
includedPostStatuses: ["publish", "draft"]
|
|
80909
|
+
},
|
|
80910
|
+
dev: {
|
|
80911
|
+
port: 8888,
|
|
80912
|
+
databasePort: 3306,
|
|
80913
|
+
phpVersion: "8.2",
|
|
80914
|
+
wordpressVersion: "latest",
|
|
80915
|
+
plugins: []
|
|
80916
|
+
}
|
|
80917
|
+
};
|
|
80900
80918
|
|
|
80901
80919
|
class ConfigManager {
|
|
80902
80920
|
static instance;
|
|
80903
80921
|
config = null;
|
|
80922
|
+
rawConfig = null;
|
|
80904
80923
|
configPath;
|
|
80905
80924
|
configDir;
|
|
80906
80925
|
envPath;
|
|
80926
|
+
runtimeDatabase = null;
|
|
80907
80927
|
constructor() {
|
|
80908
80928
|
this.configPath = path2.join(process.cwd(), "wordpress-flow.config.json");
|
|
80909
80929
|
this.configDir = path2.dirname(this.configPath);
|
|
@@ -80945,24 +80965,144 @@ class ConfigManager {
|
|
|
80945
80965
|
if (this.config) {
|
|
80946
80966
|
return this.config;
|
|
80947
80967
|
}
|
|
80948
|
-
|
|
80949
|
-
|
|
80968
|
+
let rawConfig = {};
|
|
80969
|
+
if (fs2.existsSync(this.configPath)) {
|
|
80970
|
+
try {
|
|
80971
|
+
const configContent = fs2.readFileSync(this.configPath, "utf8");
|
|
80972
|
+
rawConfig = JSON.parse(configContent);
|
|
80973
|
+
if (this.isLegacyConfig(rawConfig)) {
|
|
80974
|
+
rawConfig = this.migrateLegacyConfig(rawConfig);
|
|
80975
|
+
}
|
|
80976
|
+
} catch (error) {
|
|
80977
|
+
throw new Error(`Failed to load configuration: ${error.message}`);
|
|
80978
|
+
}
|
|
80950
80979
|
}
|
|
80951
|
-
|
|
80952
|
-
|
|
80953
|
-
|
|
80954
|
-
|
|
80955
|
-
|
|
80956
|
-
|
|
80957
|
-
|
|
80980
|
+
this.rawConfig = rawConfig;
|
|
80981
|
+
this.config = this.resolveConfig(rawConfig);
|
|
80982
|
+
return this.config;
|
|
80983
|
+
}
|
|
80984
|
+
isLegacyConfig(config) {
|
|
80985
|
+
return config.wordpress !== undefined || config.env !== undefined || config.build !== undefined;
|
|
80986
|
+
}
|
|
80987
|
+
migrateLegacyConfig(legacy) {
|
|
80988
|
+
const newConfig = {};
|
|
80989
|
+
if (legacy.env?.themeDir || legacy.paths?.mdxOutputDir || legacy.env?.pluginsDir) {
|
|
80990
|
+
newConfig.paths = {
|
|
80991
|
+
theme: legacy.env?.themeDir || legacy.build?.blocksDir?.replace("/blocks", "") || DEFAULTS.paths.theme,
|
|
80992
|
+
content: legacy.paths?.mdxOutputDir || DEFAULTS.paths.content,
|
|
80993
|
+
plugins: legacy.env?.pluginsDir || DEFAULTS.paths.plugins
|
|
80994
|
+
};
|
|
80995
|
+
}
|
|
80996
|
+
if (legacy.sync?.excludePostTypes || legacy.sync?.includedPostStatuses) {
|
|
80997
|
+
newConfig.sync = {
|
|
80998
|
+
excludePostTypes: legacy.sync?.excludePostTypes,
|
|
80999
|
+
includedPostStatuses: legacy.sync?.includedPostStatuses
|
|
81000
|
+
};
|
|
80958
81001
|
}
|
|
81002
|
+
if (legacy.env) {
|
|
81003
|
+
newConfig.dev = {
|
|
81004
|
+
port: legacy.env.port,
|
|
81005
|
+
databasePort: legacy.env.databasePort,
|
|
81006
|
+
phpVersion: legacy.env.phpVersion,
|
|
81007
|
+
wordpressVersion: legacy.env.wordpressVersion,
|
|
81008
|
+
plugins: legacy.env.plugins,
|
|
81009
|
+
sqlDump: legacy.env.sqlDump
|
|
81010
|
+
};
|
|
81011
|
+
}
|
|
81012
|
+
return newConfig;
|
|
81013
|
+
}
|
|
81014
|
+
resolveConfig(raw) {
|
|
81015
|
+
const theme = raw.paths?.theme || DEFAULTS.paths.theme;
|
|
81016
|
+
const content2 = raw.paths?.content || DEFAULTS.paths.content;
|
|
81017
|
+
const plugins = raw.paths?.plugins || DEFAULTS.paths.plugins;
|
|
81018
|
+
return {
|
|
81019
|
+
paths: {
|
|
81020
|
+
theme,
|
|
81021
|
+
content: content2,
|
|
81022
|
+
plugins,
|
|
81023
|
+
blocks: `${theme}/blocks`,
|
|
81024
|
+
dist: `${theme}/dist`,
|
|
81025
|
+
scripts: `${theme}/scripts`,
|
|
81026
|
+
templates: `${content2}/templates`,
|
|
81027
|
+
templateParts: `${content2}/parts`,
|
|
81028
|
+
templatesOutput: `${theme}/templates`,
|
|
81029
|
+
partsOutput: `${theme}/parts`
|
|
81030
|
+
},
|
|
81031
|
+
sync: {
|
|
81032
|
+
excludePostTypes: raw.sync?.excludePostTypes || DEFAULTS.sync.excludePostTypes,
|
|
81033
|
+
includedPostStatuses: raw.sync?.includedPostStatuses || DEFAULTS.sync.includedPostStatuses
|
|
81034
|
+
},
|
|
81035
|
+
dev: {
|
|
81036
|
+
port: raw.dev?.port || DEFAULTS.dev.port,
|
|
81037
|
+
databasePort: raw.dev?.databasePort || DEFAULTS.dev.databasePort,
|
|
81038
|
+
phpVersion: raw.dev?.phpVersion || DEFAULTS.dev.phpVersion,
|
|
81039
|
+
wordpressVersion: raw.dev?.wordpressVersion || DEFAULTS.dev.wordpressVersion,
|
|
81040
|
+
plugins: raw.dev?.plugins || DEFAULTS.dev.plugins,
|
|
81041
|
+
sqlDump: raw.dev?.sqlDump
|
|
81042
|
+
},
|
|
81043
|
+
database: this.runtimeDatabase || undefined
|
|
81044
|
+
};
|
|
80959
81045
|
}
|
|
80960
81046
|
async saveConfig(config) {
|
|
80961
|
-
const
|
|
80962
|
-
|
|
80963
|
-
|
|
80964
|
-
|
|
80965
|
-
|
|
81047
|
+
const minimalConfig = this.stripDefaults(config);
|
|
81048
|
+
fs2.writeFileSync(this.configPath, JSON.stringify(minimalConfig, null, 2));
|
|
81049
|
+
this.rawConfig = config;
|
|
81050
|
+
this.config = this.resolveConfig(config);
|
|
81051
|
+
}
|
|
81052
|
+
stripDefaults(config) {
|
|
81053
|
+
const result2 = {};
|
|
81054
|
+
if (config.paths) {
|
|
81055
|
+
const paths = {};
|
|
81056
|
+
if (config.paths.theme && config.paths.theme !== DEFAULTS.paths.theme) {
|
|
81057
|
+
paths.theme = config.paths.theme;
|
|
81058
|
+
}
|
|
81059
|
+
if (config.paths.content && config.paths.content !== DEFAULTS.paths.content) {
|
|
81060
|
+
paths.content = config.paths.content;
|
|
81061
|
+
}
|
|
81062
|
+
if (config.paths.plugins && config.paths.plugins !== DEFAULTS.paths.plugins) {
|
|
81063
|
+
paths.plugins = config.paths.plugins;
|
|
81064
|
+
}
|
|
81065
|
+
if (Object.keys(paths).length > 0) {
|
|
81066
|
+
result2.paths = paths;
|
|
81067
|
+
}
|
|
81068
|
+
}
|
|
81069
|
+
if (config.sync) {
|
|
81070
|
+
const sync = {};
|
|
81071
|
+
if (config.sync.excludePostTypes && config.sync.excludePostTypes.length > 0) {
|
|
81072
|
+
sync.excludePostTypes = config.sync.excludePostTypes;
|
|
81073
|
+
}
|
|
81074
|
+
if (config.sync.includedPostStatuses && JSON.stringify(config.sync.includedPostStatuses) !== JSON.stringify(DEFAULTS.sync.includedPostStatuses)) {
|
|
81075
|
+
sync.includedPostStatuses = config.sync.includedPostStatuses;
|
|
81076
|
+
}
|
|
81077
|
+
if (Object.keys(sync).length > 0) {
|
|
81078
|
+
result2.sync = sync;
|
|
81079
|
+
}
|
|
81080
|
+
}
|
|
81081
|
+
if (config.dev) {
|
|
81082
|
+
const dev = {};
|
|
81083
|
+
if (config.dev.port && config.dev.port !== DEFAULTS.dev.port) {
|
|
81084
|
+
dev.port = config.dev.port;
|
|
81085
|
+
}
|
|
81086
|
+
if (config.dev.databasePort && config.dev.databasePort !== DEFAULTS.dev.databasePort) {
|
|
81087
|
+
dev.databasePort = config.dev.databasePort;
|
|
81088
|
+
}
|
|
81089
|
+
if (config.dev.phpVersion && config.dev.phpVersion !== DEFAULTS.dev.phpVersion) {
|
|
81090
|
+
dev.phpVersion = config.dev.phpVersion;
|
|
81091
|
+
}
|
|
81092
|
+
if (config.dev.wordpressVersion && config.dev.wordpressVersion !== DEFAULTS.dev.wordpressVersion) {
|
|
81093
|
+
dev.wordpressVersion = config.dev.wordpressVersion;
|
|
81094
|
+
}
|
|
81095
|
+
if (config.dev.plugins && config.dev.plugins.length > 0) {
|
|
81096
|
+
dev.plugins = config.dev.plugins;
|
|
81097
|
+
}
|
|
81098
|
+
if (config.dev.sqlDump) {
|
|
81099
|
+
dev.sqlDump = config.dev.sqlDump;
|
|
81100
|
+
}
|
|
81101
|
+
if (Object.keys(dev).length > 0) {
|
|
81102
|
+
result2.dev = dev;
|
|
81103
|
+
}
|
|
81104
|
+
}
|
|
81105
|
+
return result2;
|
|
80966
81106
|
}
|
|
80967
81107
|
getConfig() {
|
|
80968
81108
|
if (!this.config) {
|
|
@@ -80973,11 +81113,18 @@ class ConfigManager {
|
|
|
80973
81113
|
hasConfig() {
|
|
80974
81114
|
return fs2.existsSync(this.configPath);
|
|
80975
81115
|
}
|
|
80976
|
-
|
|
80977
|
-
|
|
81116
|
+
setDatabaseConnection(connection) {
|
|
81117
|
+
this.runtimeDatabase = connection;
|
|
81118
|
+
if (this.config) {
|
|
81119
|
+
this.config.database = connection;
|
|
81120
|
+
}
|
|
80978
81121
|
}
|
|
80979
|
-
|
|
80980
|
-
return this.
|
|
81122
|
+
getDatabaseConnection() {
|
|
81123
|
+
return this.config?.database;
|
|
81124
|
+
}
|
|
81125
|
+
getWordPressUrl() {
|
|
81126
|
+
const port = this.config?.dev.port || DEFAULTS.dev.port;
|
|
81127
|
+
return `http://localhost:${port}`;
|
|
80981
81128
|
}
|
|
80982
81129
|
resolvePath(relativePath) {
|
|
80983
81130
|
if (path2.isAbsolute(relativePath)) {
|
|
@@ -80988,60 +81135,70 @@ class ConfigManager {
|
|
|
80988
81135
|
getConfigDir() {
|
|
80989
81136
|
return this.configDir;
|
|
80990
81137
|
}
|
|
80991
|
-
|
|
80992
|
-
const
|
|
80993
|
-
|
|
80994
|
-
|
|
80995
|
-
|
|
80996
|
-
|
|
80997
|
-
|
|
80998
|
-
|
|
80999
|
-
|
|
81000
|
-
|
|
81001
|
-
|
|
81138
|
+
getLegacyConfig() {
|
|
81139
|
+
const config = this.getConfig();
|
|
81140
|
+
const dbConnection = config.database || {
|
|
81141
|
+
host: "127.0.0.1",
|
|
81142
|
+
port: config.dev.databasePort,
|
|
81143
|
+
database: "wordpress",
|
|
81144
|
+
username: "wordpress",
|
|
81145
|
+
password: "wordpress"
|
|
81146
|
+
};
|
|
81147
|
+
return {
|
|
81148
|
+
wordpress: {
|
|
81149
|
+
type: "database",
|
|
81150
|
+
wordpressUrl: this.getWordPressUrl(),
|
|
81151
|
+
syncPath: config.paths.content,
|
|
81152
|
+
postTypes: ["post", "page"],
|
|
81153
|
+
database: dbConnection
|
|
81154
|
+
},
|
|
81155
|
+
paths: {
|
|
81156
|
+
mdxOutputDir: config.paths.content,
|
|
81157
|
+
postTypeMappings: {
|
|
81158
|
+
post: `${config.paths.content}/post`,
|
|
81159
|
+
page: `${config.paths.content}/page`
|
|
81160
|
+
}
|
|
81161
|
+
},
|
|
81162
|
+
sync: {
|
|
81163
|
+
watchForChanges: true,
|
|
81164
|
+
conflictResolution: "manual",
|
|
81165
|
+
excludePostTypes: config.sync.excludePostTypes,
|
|
81166
|
+
includedPostStatuses: config.sync.includedPostStatuses
|
|
81167
|
+
},
|
|
81168
|
+
build: {
|
|
81169
|
+
blocksDir: config.paths.blocks,
|
|
81170
|
+
outputDir: config.paths.dist,
|
|
81171
|
+
scriptsPath: config.paths.scripts
|
|
81172
|
+
},
|
|
81173
|
+
templates: {
|
|
81174
|
+
templatesDir: config.paths.templates,
|
|
81175
|
+
outputDir: config.paths.templatesOutput
|
|
81176
|
+
},
|
|
81177
|
+
templateParts: {
|
|
81178
|
+
partsDir: config.paths.templateParts,
|
|
81179
|
+
outputDir: config.paths.partsOutput
|
|
81180
|
+
},
|
|
81181
|
+
env: {
|
|
81182
|
+
port: config.dev.port,
|
|
81183
|
+
databasePort: config.dev.databasePort,
|
|
81184
|
+
phpVersion: config.dev.phpVersion,
|
|
81185
|
+
wordpressVersion: config.dev.wordpressVersion,
|
|
81186
|
+
themeDir: config.paths.theme,
|
|
81187
|
+
pluginsDir: config.paths.plugins,
|
|
81188
|
+
plugins: config.dev.plugins,
|
|
81189
|
+
sqlDump: config.dev.sqlDump,
|
|
81190
|
+
volumes: {
|
|
81191
|
+
database: true,
|
|
81192
|
+
uploads: true
|
|
81193
|
+
}
|
|
81002
81194
|
}
|
|
81003
|
-
}
|
|
81004
|
-
return mergedConfig;
|
|
81005
|
-
}
|
|
81006
|
-
stripSensitiveData(config) {
|
|
81007
|
-
const strippedConfig = JSON.parse(JSON.stringify(config));
|
|
81008
|
-
if (strippedConfig.wordpress.type === "rest-api") {
|
|
81009
|
-
delete strippedConfig.wordpress.applicationPassword;
|
|
81010
|
-
} else if (strippedConfig.wordpress.type === "database") {
|
|
81011
|
-
delete strippedConfig.wordpress.database.password;
|
|
81012
|
-
}
|
|
81013
|
-
return strippedConfig;
|
|
81195
|
+
};
|
|
81014
81196
|
}
|
|
81015
|
-
|
|
81016
|
-
|
|
81017
|
-
if (config.wordpress.type === "rest-api") {
|
|
81018
|
-
envVars.WP_APPLICATION_PASSWORD = config.wordpress.applicationPassword;
|
|
81019
|
-
} else if (config.wordpress.type === "database") {
|
|
81020
|
-
envVars.DB_PASSWORD = config.wordpress.database.password;
|
|
81021
|
-
}
|
|
81022
|
-
return envVars;
|
|
81197
|
+
getWordPressConfig() {
|
|
81198
|
+
return this.getLegacyConfig().wordpress;
|
|
81023
81199
|
}
|
|
81024
|
-
|
|
81025
|
-
|
|
81026
|
-
if (fs2.existsSync(this.envPath)) {
|
|
81027
|
-
envContent = fs2.readFileSync(this.envPath, "utf8");
|
|
81028
|
-
}
|
|
81029
|
-
const existingVars = {};
|
|
81030
|
-
envContent.split(`
|
|
81031
|
-
`).forEach((line) => {
|
|
81032
|
-
const trimmed = line.trim();
|
|
81033
|
-
if (trimmed && !trimmed.startsWith("#")) {
|
|
81034
|
-
const [key, ...valueParts] = trimmed.split("=");
|
|
81035
|
-
if (key && valueParts.length > 0) {
|
|
81036
|
-
existingVars[key.trim()] = valueParts.join("=");
|
|
81037
|
-
}
|
|
81038
|
-
}
|
|
81039
|
-
});
|
|
81040
|
-
const mergedVars = { ...existingVars, ...newVars };
|
|
81041
|
-
const newEnvContent = Object.entries(mergedVars).map(([key, value]) => `${key}=${value}`).join(`
|
|
81042
|
-
`) + `
|
|
81043
|
-
`;
|
|
81044
|
-
fs2.writeFileSync(this.envPath, newEnvContent);
|
|
81200
|
+
getSyncPaths() {
|
|
81201
|
+
return this.getLegacyConfig().paths;
|
|
81045
81202
|
}
|
|
81046
81203
|
}
|
|
81047
81204
|
// src/config/logger.ts
|
|
@@ -84776,8 +84933,7 @@ class DatabaseClient {
|
|
|
84776
84933
|
const perPage = params.per_page || 100;
|
|
84777
84934
|
const page = params.page || 1;
|
|
84778
84935
|
const offset = (page - 1) * perPage;
|
|
84779
|
-
query +=
|
|
84780
|
-
queryParams.push(perPage, offset);
|
|
84936
|
+
query += ` LIMIT ${Number(perPage)} OFFSET ${Number(offset)}`;
|
|
84781
84937
|
logger.debug(`Executing query: ${query}`);
|
|
84782
84938
|
logger.debug(`Query parameters: ${JSON.stringify(queryParams)}`);
|
|
84783
84939
|
const [rows] = await this.connection.execute(query, queryParams);
|
|
@@ -85636,7 +85792,8 @@ class PullCommand {
|
|
|
85636
85792
|
async execute(options) {
|
|
85637
85793
|
logger.progress("Starting pull operation...");
|
|
85638
85794
|
const config = this.configManager.getConfig();
|
|
85639
|
-
const
|
|
85795
|
+
const legacyConfig = this.configManager.getLegacyConfig();
|
|
85796
|
+
const connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
|
|
85640
85797
|
const result2 = {
|
|
85641
85798
|
success: false,
|
|
85642
85799
|
operation: {
|
|
@@ -85648,7 +85805,7 @@ class PullCommand {
|
|
|
85648
85805
|
},
|
|
85649
85806
|
target: {
|
|
85650
85807
|
type: "local",
|
|
85651
|
-
identifier: options.outputDir || config.paths.
|
|
85808
|
+
identifier: options.outputDir || config.paths.content,
|
|
85652
85809
|
lastModified: new Date
|
|
85653
85810
|
},
|
|
85654
85811
|
timestamp: new Date,
|
|
@@ -85658,8 +85815,8 @@ class PullCommand {
|
|
|
85658
85815
|
errors: []
|
|
85659
85816
|
};
|
|
85660
85817
|
try {
|
|
85661
|
-
const postTypes = options.postTypes ||
|
|
85662
|
-
const outputDir = options.outputDir || config.paths.
|
|
85818
|
+
const postTypes = options.postTypes || ["post", "page"];
|
|
85819
|
+
const outputDir = options.outputDir || config.paths.content;
|
|
85663
85820
|
fs3.mkdirSync(outputDir, { recursive: true });
|
|
85664
85821
|
let totalProcessed = 0;
|
|
85665
85822
|
for (const postType of postTypes) {
|
|
@@ -85734,13 +85891,7 @@ class PullCommand {
|
|
|
85734
85891
|
title: post.title.rendered,
|
|
85735
85892
|
slug: post.slug,
|
|
85736
85893
|
postId: post.id,
|
|
85737
|
-
status: post.status
|
|
85738
|
-
date: new Date(post.date).toISOString(),
|
|
85739
|
-
modified: new Date(post.modified).toISOString(),
|
|
85740
|
-
excerpt: post.excerpt.rendered || "",
|
|
85741
|
-
categories: post.categories || [],
|
|
85742
|
-
tags: post.tags || [],
|
|
85743
|
-
meta: post.meta || {}
|
|
85894
|
+
status: post.status
|
|
85744
85895
|
};
|
|
85745
85896
|
const mdxContent = this.generateMDX(blocks, frontmatter);
|
|
85746
85897
|
fs3.writeFileSync(filePath2, mdxContent, "utf8");
|
|
@@ -112907,7 +113058,7 @@ class PushCommand {
|
|
|
112907
113058
|
this.blockRegistry = blockRegistry;
|
|
112908
113059
|
} else {
|
|
112909
113060
|
const config = this.configManager.getConfig();
|
|
112910
|
-
const buildOutputDir = this.configManager.resolvePath(config.
|
|
113061
|
+
const buildOutputDir = this.configManager.resolvePath(config.paths.dist);
|
|
112911
113062
|
this.blockRegistry = new BlockRegistry(buildOutputDir);
|
|
112912
113063
|
}
|
|
112913
113064
|
}
|
|
@@ -112985,7 +113136,8 @@ class PushCommand {
|
|
|
112985
113136
|
logger.warn("Continuing with basic block rendering...");
|
|
112986
113137
|
}
|
|
112987
113138
|
const config = this.configManager.getConfig();
|
|
112988
|
-
const
|
|
113139
|
+
const legacyConfig = this.configManager.getLegacyConfig();
|
|
113140
|
+
const connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
|
|
112989
113141
|
const result2 = {
|
|
112990
113142
|
success: false,
|
|
112991
113143
|
operation: {
|
|
@@ -112997,7 +113149,7 @@ class PushCommand {
|
|
|
112997
113149
|
},
|
|
112998
113150
|
target: {
|
|
112999
113151
|
type: "wordpress",
|
|
113000
|
-
identifier:
|
|
113152
|
+
identifier: this.configManager.getWordPressUrl(),
|
|
113001
113153
|
lastModified: new Date
|
|
113002
113154
|
},
|
|
113003
113155
|
timestamp: new Date,
|
|
@@ -113008,7 +113160,7 @@ class PushCommand {
|
|
|
113008
113160
|
conflicts: []
|
|
113009
113161
|
};
|
|
113010
113162
|
try {
|
|
113011
|
-
const mdxFiles = await this.findMDXFiles(options.files, config.paths.
|
|
113163
|
+
const mdxFiles = await this.findMDXFiles(options.files, config.paths.content);
|
|
113012
113164
|
if (mdxFiles.length === 0) {
|
|
113013
113165
|
logger.warn("No MDX files found to push");
|
|
113014
113166
|
result2.operation.status = "completed";
|
|
@@ -113067,11 +113219,12 @@ class PushCommand {
|
|
|
113067
113219
|
await this.blockRegistry.loadBuiltBlocks();
|
|
113068
113220
|
} catch {}
|
|
113069
113221
|
const config = this.configManager.getConfig();
|
|
113222
|
+
const legacyConfig = this.configManager.getLegacyConfig();
|
|
113070
113223
|
let connection;
|
|
113071
113224
|
if (this.connectionManager.hasConnection()) {
|
|
113072
113225
|
connection = this.connectionManager.getConnection();
|
|
113073
113226
|
} else {
|
|
113074
|
-
connection = await this.connectionManager.createConnection(
|
|
113227
|
+
connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
|
|
113075
113228
|
}
|
|
113076
113229
|
const result2 = {
|
|
113077
113230
|
success: false,
|
|
@@ -113084,7 +113237,7 @@ class PushCommand {
|
|
|
113084
113237
|
},
|
|
113085
113238
|
target: {
|
|
113086
113239
|
type: "wordpress",
|
|
113087
|
-
identifier:
|
|
113240
|
+
identifier: this.configManager.getWordPressUrl(),
|
|
113088
113241
|
lastModified: new Date
|
|
113089
113242
|
},
|
|
113090
113243
|
timestamp: new Date,
|
|
@@ -113095,7 +113248,7 @@ class PushCommand {
|
|
|
113095
113248
|
conflicts: []
|
|
113096
113249
|
};
|
|
113097
113250
|
try {
|
|
113098
|
-
const mdxFiles = await this.findMDXFiles(options.files, config.paths.
|
|
113251
|
+
const mdxFiles = await this.findMDXFiles(options.files, config.paths.content);
|
|
113099
113252
|
if (mdxFiles.length === 0) {
|
|
113100
113253
|
result2.operation.status = "completed";
|
|
113101
113254
|
result2.success = true;
|
|
@@ -113242,20 +113395,6 @@ ${"=".repeat(80)}`);
|
|
|
113242
113395
|
conflictType: "missing-source"
|
|
113243
113396
|
};
|
|
113244
113397
|
}
|
|
113245
|
-
const wpModified = new Date(wpPost.modified);
|
|
113246
|
-
const lastPushed = mdxFile.frontmatter.lastPushed ? new Date(mdxFile.frontmatter.lastPushed) : null;
|
|
113247
|
-
if (lastPushed && wpModified > lastPushed) {
|
|
113248
|
-
const tolerance = 5000;
|
|
113249
|
-
if (wpModified.getTime() - lastPushed.getTime() > tolerance) {
|
|
113250
|
-
return {
|
|
113251
|
-
postId: mdxFile.frontmatter.postId,
|
|
113252
|
-
localPath: mdxFile.path,
|
|
113253
|
-
wordpressPost: wpPost,
|
|
113254
|
-
localFile: mdxFile,
|
|
113255
|
-
conflictType: "wordpress-newer"
|
|
113256
|
-
};
|
|
113257
|
-
}
|
|
113258
|
-
}
|
|
113259
113398
|
return null;
|
|
113260
113399
|
} catch (error) {
|
|
113261
113400
|
logger.warn(`Could not check for conflicts on post ${mdxFile.frontmatter.postId}: ${error.message}`);
|
|
@@ -113288,31 +113427,15 @@ ${"=".repeat(80)}`);
|
|
|
113288
113427
|
}
|
|
113289
113428
|
let frontmatter = frontmatterMatch[1];
|
|
113290
113429
|
const postId = wpPost.id;
|
|
113291
|
-
|
|
113292
|
-
const lastPushed = new Date().toISOString();
|
|
113293
|
-
if (frontmatter.includes("postId:")) {
|
|
113294
|
-
frontmatter = frontmatter.replace(/postId:\s*\d*/, `postId: ${postId}`);
|
|
113295
|
-
} else {
|
|
113430
|
+
if (!frontmatter.includes("postId:")) {
|
|
113296
113431
|
frontmatter = `${frontmatter}
|
|
113297
113432
|
postId: ${postId}`;
|
|
113298
|
-
|
|
113299
|
-
if (frontmatter.includes("modified:")) {
|
|
113300
|
-
frontmatter = frontmatter.replace(/modified:\s*"[^"]*"/, `modified: "${modified}"`);
|
|
113301
|
-
} else {
|
|
113302
|
-
frontmatter = `${frontmatter}
|
|
113303
|
-
modified: "${modified}"`;
|
|
113304
|
-
}
|
|
113305
|
-
if (frontmatter.includes("lastPushed:")) {
|
|
113306
|
-
frontmatter = frontmatter.replace(/lastPushed:\s*"[^"]*"/, `lastPushed: "${lastPushed}"`);
|
|
113307
|
-
} else {
|
|
113308
|
-
frontmatter = `${frontmatter}
|
|
113309
|
-
lastPushed: "${lastPushed}"`;
|
|
113310
|
-
}
|
|
113311
|
-
const updatedContent = content4.replace(/^---\n([\s\S]*?)\n---/, `---
|
|
113433
|
+
const updatedContent = content4.replace(/^---\n([\s\S]*?)\n---/, `---
|
|
113312
113434
|
${frontmatter}
|
|
113313
113435
|
---`);
|
|
113314
|
-
|
|
113315
|
-
|
|
113436
|
+
fs5.writeFileSync(filePath2, updatedContent, "utf8");
|
|
113437
|
+
logger.debug(`Added postId to ${filePath2}`);
|
|
113438
|
+
}
|
|
113316
113439
|
} catch (error) {
|
|
113317
113440
|
logger.warn(`Failed to update MDX file after push: ${error.message}`);
|
|
113318
113441
|
}
|
|
@@ -115799,20 +115922,7 @@ class DockerEnvManager {
|
|
|
115799
115922
|
constructor(options) {
|
|
115800
115923
|
this.projectName = this.sanitizeProjectName(options.projectName);
|
|
115801
115924
|
this.workspaceDir = options.workspaceDir;
|
|
115802
|
-
this.config =
|
|
115803
|
-
port: options.config.port ?? 8888,
|
|
115804
|
-
databasePort: options.config.databasePort,
|
|
115805
|
-
phpVersion: options.config.phpVersion ?? "8.2",
|
|
115806
|
-
wordpressVersion: options.config.wordpressVersion ?? "latest",
|
|
115807
|
-
themeDir: options.config.themeDir ?? "./theme",
|
|
115808
|
-
pluginsDir: options.config.pluginsDir,
|
|
115809
|
-
plugins: options.config.plugins ?? [],
|
|
115810
|
-
sqlDump: options.config.sqlDump ?? "",
|
|
115811
|
-
volumes: {
|
|
115812
|
-
database: options.config.volumes?.database ?? true,
|
|
115813
|
-
uploads: options.config.volumes?.uploads ?? true
|
|
115814
|
-
}
|
|
115815
|
-
};
|
|
115925
|
+
this.config = options.config;
|
|
115816
115926
|
this.containerNames = {
|
|
115817
115927
|
wordpress: `${this.projectName}-wordpress`,
|
|
115818
115928
|
mysql: `${this.projectName}-mysql`
|
|
@@ -115872,7 +115982,7 @@ class DockerEnvManager {
|
|
|
115872
115982
|
logger.info("\uD83D\uDC33 Docker containers already running");
|
|
115873
115983
|
}
|
|
115874
115984
|
await this.waitForWordPress();
|
|
115875
|
-
const wordpressUrl =
|
|
115985
|
+
const wordpressUrl = this.getWordPressUrl();
|
|
115876
115986
|
return { wordpressUrl, isFirstRun };
|
|
115877
115987
|
}
|
|
115878
115988
|
async createContainers() {
|
|
@@ -115881,31 +115991,29 @@ class DockerEnvManager {
|
|
|
115881
115991
|
stdio: "pipe"
|
|
115882
115992
|
});
|
|
115883
115993
|
} catch {}
|
|
115884
|
-
const themeDir = path16.resolve(this.workspaceDir, this.config.
|
|
115994
|
+
const themeDir = path16.resolve(this.workspaceDir, this.config.paths.theme);
|
|
115885
115995
|
const themeName = path16.basename(themeDir);
|
|
115886
115996
|
logger.info(" Starting MySQL...");
|
|
115887
|
-
const mysqlVolume =
|
|
115888
|
-
const mysqlPort = this.config.databasePort ? `-p ${this.config.databasePort}:3306` : "";
|
|
115997
|
+
const mysqlVolume = `-v ${this.projectName}-mysql-data:/var/lib/mysql`;
|
|
115998
|
+
const mysqlPort = this.config.dev.databasePort ? `-p ${this.config.dev.databasePort}:3306` : "";
|
|
115889
115999
|
execSync(`docker run -d --name ${this.containerNames.mysql} --network ${this.projectName}-network ${mysqlVolume} ${mysqlPort} -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=wordpress -e MYSQL_USER=wordpress -e MYSQL_PASSWORD=wordpress mysql:8.0`, { stdio: "pipe" });
|
|
115890
116000
|
await this.waitForMySQL();
|
|
115891
116001
|
logger.info(" Starting WordPress...");
|
|
115892
|
-
const uploadsVolume =
|
|
116002
|
+
const uploadsVolume = `-v ${this.projectName}-uploads:/var/www/html/wp-content/uploads`;
|
|
115893
116003
|
let pluginMounts = "";
|
|
115894
|
-
|
|
115895
|
-
|
|
115896
|
-
|
|
115897
|
-
|
|
115898
|
-
|
|
115899
|
-
|
|
115900
|
-
|
|
115901
|
-
|
|
115902
|
-
|
|
115903
|
-
logger.info(` Mounting ${pluginFolders.length} local plugin(s): ${pluginFolders.join(", ")}`);
|
|
115904
|
-
}
|
|
116004
|
+
const pluginsDir = path16.resolve(this.workspaceDir, this.config.paths.plugins);
|
|
116005
|
+
if (fs14.existsSync(pluginsDir)) {
|
|
116006
|
+
const pluginFolders = fs14.readdirSync(pluginsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
|
|
116007
|
+
for (const pluginName of pluginFolders) {
|
|
116008
|
+
const pluginPath = path16.join(pluginsDir, pluginName);
|
|
116009
|
+
pluginMounts += ` -v "${pluginPath}:/var/www/html/wp-content/plugins/${pluginName}"`;
|
|
116010
|
+
}
|
|
116011
|
+
if (pluginFolders.length > 0) {
|
|
116012
|
+
logger.info(` Mounting ${pluginFolders.length} local plugin(s): ${pluginFolders.join(", ")}`);
|
|
115905
116013
|
}
|
|
115906
116014
|
}
|
|
115907
|
-
const wpImage = this.config.wordpressVersion === "latest" ? `wordpress:php${this.config.phpVersion}` : `wordpress:${this.config.wordpressVersion}-php${this.config.phpVersion}`;
|
|
115908
|
-
execSync(`docker run -d --name ${this.containerNames.wordpress} --network ${this.projectName}-network -p ${this.config.port}:80 -v "${themeDir}:/var/www/html/wp-content/themes/${themeName}" ${pluginMounts} ${uploadsVolume} -e WORDPRESS_DB_HOST=${this.containerNames.mysql} -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress -e WORDPRESS_DB_NAME=wordpress ${wpImage}`, { stdio: "pipe" });
|
|
116015
|
+
const wpImage = this.config.dev.wordpressVersion === "latest" ? `wordpress:php${this.config.dev.phpVersion}` : `wordpress:${this.config.dev.wordpressVersion}-php${this.config.dev.phpVersion}`;
|
|
116016
|
+
execSync(`docker run -d --name ${this.containerNames.wordpress} --network ${this.projectName}-network -p ${this.config.dev.port}:80 -v "${themeDir}:/var/www/html/wp-content/themes/${themeName}" ${pluginMounts} ${uploadsVolume} -e WORDPRESS_DB_HOST=${this.containerNames.mysql} -e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress -e WORDPRESS_DB_NAME=wordpress ${wpImage}`, { stdio: "pipe" });
|
|
115909
116017
|
}
|
|
115910
116018
|
async startContainers() {
|
|
115911
116019
|
execSync(`docker start ${this.containerNames.mysql}`, { stdio: "pipe" });
|
|
@@ -115959,7 +116067,7 @@ class DockerEnvManager {
|
|
|
115959
116067
|
logger.info(" Waiting for WordPress...");
|
|
115960
116068
|
while (attempts < maxAttempts) {
|
|
115961
116069
|
try {
|
|
115962
|
-
const response = execSync(`curl -s -o /dev/null -w "%{http_code}" http://localhost:${this.config.port}`, { encoding: "utf8", stdio: "pipe" }).trim();
|
|
116070
|
+
const response = execSync(`curl -s -o /dev/null -w "%{http_code}" http://localhost:${this.config.dev.port}`, { encoding: "utf8", stdio: "pipe" }).trim();
|
|
115963
116071
|
if (response.length > 0) {
|
|
115964
116072
|
return;
|
|
115965
116073
|
}
|
|
@@ -115998,8 +116106,8 @@ class DockerEnvManager {
|
|
|
115998
116106
|
}
|
|
115999
116107
|
async installWordPress() {
|
|
116000
116108
|
logger.info(" Installing WordPress...");
|
|
116001
|
-
const siteUrl =
|
|
116002
|
-
const themeName = path16.basename(path16.resolve(this.workspaceDir, this.config.
|
|
116109
|
+
const siteUrl = this.getWordPressUrl();
|
|
116110
|
+
const themeName = path16.basename(path16.resolve(this.workspaceDir, this.config.paths.theme));
|
|
116003
116111
|
execSync(`docker exec ${this.containerNames.wordpress} wp core install --url="${siteUrl}" --title="Development Site" --admin_user=admin --admin_password=password --admin_email=admin@example.com --skip-email --allow-root`, { stdio: "pipe" });
|
|
116004
116112
|
logger.info(` Activating theme: ${themeName}...`);
|
|
116005
116113
|
try {
|
|
@@ -116010,10 +116118,10 @@ class DockerEnvManager {
|
|
|
116010
116118
|
execSync(`docker exec ${this.containerNames.wordpress} wp rewrite structure '/%postname%/' --allow-root`, { stdio: "pipe" });
|
|
116011
116119
|
}
|
|
116012
116120
|
async installPlugins() {
|
|
116013
|
-
if (this.config.plugins.length === 0)
|
|
116121
|
+
if (this.config.dev.plugins.length === 0)
|
|
116014
116122
|
return;
|
|
116015
116123
|
logger.info(" Installing plugins...");
|
|
116016
|
-
for (const plugin of this.config.plugins) {
|
|
116124
|
+
for (const plugin of this.config.dev.plugins) {
|
|
116017
116125
|
try {
|
|
116018
116126
|
if (plugin.startsWith("./") || plugin.startsWith("/")) {
|
|
116019
116127
|
const pluginPath = path16.resolve(this.workspaceDir, plugin);
|
|
@@ -116030,9 +116138,9 @@ class DockerEnvManager {
|
|
|
116030
116138
|
}
|
|
116031
116139
|
}
|
|
116032
116140
|
async importSqlDump() {
|
|
116033
|
-
if (!this.config.sqlDump)
|
|
116141
|
+
if (!this.config.dev.sqlDump)
|
|
116034
116142
|
return;
|
|
116035
|
-
const sqlPath = path16.resolve(this.workspaceDir, this.config.sqlDump);
|
|
116143
|
+
const sqlPath = path16.resolve(this.workspaceDir, this.config.dev.sqlDump);
|
|
116036
116144
|
if (!fs14.existsSync(sqlPath)) {
|
|
116037
116145
|
logger.warn(` SQL dump not found: ${sqlPath}`);
|
|
116038
116146
|
return;
|
|
@@ -116041,7 +116149,7 @@ class DockerEnvManager {
|
|
|
116041
116149
|
await this.waitForMySQLReady();
|
|
116042
116150
|
execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, { stdio: "pipe" });
|
|
116043
116151
|
execSync(`docker exec ${this.containerNames.mysql} sh -c "mysql -h 127.0.0.1 -u wordpress -pwordpress wordpress < /tmp/dump.sql"`, { stdio: "pipe" });
|
|
116044
|
-
const siteUrl =
|
|
116152
|
+
const siteUrl = this.getWordPressUrl();
|
|
116045
116153
|
execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116046
116154
|
execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116047
116155
|
await this.reactivatePlugins();
|
|
@@ -116093,14 +116201,12 @@ class DockerEnvManager {
|
|
|
116093
116201
|
}
|
|
116094
116202
|
logger.info(" Importing SQL dump...");
|
|
116095
116203
|
await this.waitForMySQLReady();
|
|
116096
|
-
execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, {
|
|
116097
|
-
stdio: "pipe"
|
|
116098
|
-
});
|
|
116204
|
+
execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, { stdio: "pipe" });
|
|
116099
116205
|
execSync(`docker exec ${this.containerNames.mysql} sh -c "mysql -h 127.0.0.1 -u wordpress -pwordpress wordpress < /tmp/dump.sql"`, { stdio: "pipe" });
|
|
116100
116206
|
if (!await this.hasWPCLI()) {
|
|
116101
116207
|
await this.installWPCLI();
|
|
116102
116208
|
}
|
|
116103
|
-
const siteUrl =
|
|
116209
|
+
const siteUrl = this.getWordPressUrl();
|
|
116104
116210
|
try {
|
|
116105
116211
|
execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
116106
116212
|
execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
|
|
@@ -116112,14 +116218,14 @@ class DockerEnvManager {
|
|
|
116112
116218
|
getDatabaseConfig() {
|
|
116113
116219
|
return {
|
|
116114
116220
|
host: "127.0.0.1",
|
|
116115
|
-
port: this.config.databasePort
|
|
116221
|
+
port: this.config.dev.databasePort,
|
|
116116
116222
|
database: "wordpress",
|
|
116117
116223
|
username: "wordpress",
|
|
116118
116224
|
password: "wordpress"
|
|
116119
116225
|
};
|
|
116120
116226
|
}
|
|
116121
116227
|
getWordPressUrl() {
|
|
116122
|
-
return `http://localhost:${this.config.port}`;
|
|
116228
|
+
return `http://localhost:${this.config.dev.port}`;
|
|
116123
116229
|
}
|
|
116124
116230
|
sleep(ms) {
|
|
116125
116231
|
return new Promise((resolve6) => setTimeout(resolve6, ms));
|
|
@@ -116139,27 +116245,23 @@ class DockerEnvManager {
|
|
|
116139
116245
|
stdio: "pipe"
|
|
116140
116246
|
});
|
|
116141
116247
|
} catch {}
|
|
116142
|
-
|
|
116143
|
-
|
|
116144
|
-
|
|
116145
|
-
|
|
116146
|
-
|
|
116147
|
-
|
|
116148
|
-
|
|
116149
|
-
|
|
116150
|
-
|
|
116151
|
-
|
|
116152
|
-
stdio: "pipe"
|
|
116153
|
-
});
|
|
116154
|
-
} catch {}
|
|
116155
|
-
}
|
|
116248
|
+
try {
|
|
116249
|
+
execSync(`docker volume rm ${this.projectName}-mysql-data`, {
|
|
116250
|
+
stdio: "pipe"
|
|
116251
|
+
});
|
|
116252
|
+
} catch {}
|
|
116253
|
+
try {
|
|
116254
|
+
execSync(`docker volume rm ${this.projectName}-uploads`, {
|
|
116255
|
+
stdio: "pipe"
|
|
116256
|
+
});
|
|
116257
|
+
} catch {}
|
|
116156
116258
|
logger.info(" ✓ Cleanup complete");
|
|
116157
116259
|
}
|
|
116158
116260
|
}
|
|
116159
116261
|
// package.json
|
|
116160
116262
|
var package_default = {
|
|
116161
116263
|
name: "@wordpress-flow/cli",
|
|
116162
|
-
version: "1.
|
|
116264
|
+
version: "1.2.0",
|
|
116163
116265
|
type: "module",
|
|
116164
116266
|
description: "TypeScript-based WordPress block creation system",
|
|
116165
116267
|
main: "dist/index.js",
|
|
@@ -116283,7 +116385,7 @@ class DevModeOrchestrator {
|
|
|
116283
116385
|
console.log("\uD83D\uDCCB Loading configuration...");
|
|
116284
116386
|
await this.initializeConfig();
|
|
116285
116387
|
const config = this.configManager.getConfig();
|
|
116286
|
-
if (
|
|
116388
|
+
if (!this.options.skipEnv) {
|
|
116287
116389
|
console.log("\uD83D\uDC33 Setting up Docker environment...");
|
|
116288
116390
|
await this.startDockerEnvironment();
|
|
116289
116391
|
}
|
|
@@ -116312,8 +116414,6 @@ class DevModeOrchestrator {
|
|
|
116312
116414
|
}
|
|
116313
116415
|
async startDockerEnvironment() {
|
|
116314
116416
|
const config = this.configManager.getConfig();
|
|
116315
|
-
if (!config.env)
|
|
116316
|
-
return;
|
|
116317
116417
|
const packageJsonPath = path17.join(this.configManager.getConfigDir(), "package.json");
|
|
116318
116418
|
let projectName = "wordpress-project";
|
|
116319
116419
|
if (fs15.existsSync(packageJsonPath)) {
|
|
@@ -116325,7 +116425,7 @@ class DevModeOrchestrator {
|
|
|
116325
116425
|
this.dockerEnvManager = new DockerEnvManager({
|
|
116326
116426
|
projectName,
|
|
116327
116427
|
workspaceDir: this.configManager.getConfigDir(),
|
|
116328
|
-
config
|
|
116428
|
+
config
|
|
116329
116429
|
});
|
|
116330
116430
|
try {
|
|
116331
116431
|
const { wordpressUrl, isFirstRun } = await this.dockerEnvManager.start();
|
|
@@ -116340,10 +116440,12 @@ class DevModeOrchestrator {
|
|
|
116340
116440
|
}
|
|
116341
116441
|
await this.dockerEnvManager.installPlugins();
|
|
116342
116442
|
}
|
|
116443
|
+
const dbConfig = this.dockerEnvManager.getDatabaseConfig();
|
|
116444
|
+
this.configManager.setDatabaseConnection(dbConfig);
|
|
116343
116445
|
logger.success(`WordPress running at ${wordpressUrl}`);
|
|
116344
116446
|
logger.info(` Admin: ${wordpressUrl}/wp-admin (admin / password)`);
|
|
116345
|
-
if (config.
|
|
116346
|
-
logger.info(` Database: 127.0.0.1:${config.
|
|
116447
|
+
if (config.dev.databasePort) {
|
|
116448
|
+
logger.info(` Database: 127.0.0.1:${config.dev.databasePort} (wordpress / wordpress)`);
|
|
116347
116449
|
}
|
|
116348
116450
|
} catch (error) {
|
|
116349
116451
|
const errorMessage = error.message;
|
|
@@ -116355,23 +116457,15 @@ class DevModeOrchestrator {
|
|
|
116355
116457
|
}
|
|
116356
116458
|
async initializeConfig() {
|
|
116357
116459
|
const config = this.configManager.getConfig();
|
|
116358
|
-
this.blocksDir = this.configManager.resolvePath(config.
|
|
116359
|
-
this.outputDir = this.configManager.resolvePath(config.
|
|
116360
|
-
|
|
116361
|
-
|
|
116362
|
-
|
|
116363
|
-
|
|
116364
|
-
|
|
116365
|
-
this.
|
|
116366
|
-
this.
|
|
116367
|
-
if (config.templates) {
|
|
116368
|
-
this.templatesDir = this.configManager.resolvePath(config.templates.templatesDir);
|
|
116369
|
-
this.templatesOutputDir = this.configManager.resolvePath(config.templates.outputDir);
|
|
116370
|
-
}
|
|
116371
|
-
if (config.templateParts) {
|
|
116372
|
-
this.templatePartsDir = this.configManager.resolvePath(config.templateParts.partsDir);
|
|
116373
|
-
this.templatePartsOutputDir = this.configManager.resolvePath(config.templateParts.outputDir);
|
|
116374
|
-
}
|
|
116460
|
+
this.blocksDir = this.configManager.resolvePath(config.paths.blocks);
|
|
116461
|
+
this.outputDir = this.configManager.resolvePath(config.paths.dist);
|
|
116462
|
+
this.webpackConfig = path17.join(__dirname2, "..", "webpack.config.cjs");
|
|
116463
|
+
this.scriptsPath = this.configManager.resolvePath(config.paths.scripts);
|
|
116464
|
+
this.contentDir = this.configManager.resolvePath(config.paths.content);
|
|
116465
|
+
this.templatesDir = this.configManager.resolvePath(config.paths.templates);
|
|
116466
|
+
this.templatesOutputDir = this.configManager.resolvePath(config.paths.templatesOutput);
|
|
116467
|
+
this.templatePartsDir = this.configManager.resolvePath(config.paths.templateParts);
|
|
116468
|
+
this.templatePartsOutputDir = this.configManager.resolvePath(config.paths.partsOutput);
|
|
116375
116469
|
if (!fs15.existsSync(this.outputDir)) {
|
|
116376
116470
|
fs15.mkdirSync(this.outputDir, { recursive: true });
|
|
116377
116471
|
}
|
|
@@ -116395,16 +116489,16 @@ class DevModeOrchestrator {
|
|
|
116395
116489
|
async connectWordPress() {
|
|
116396
116490
|
try {
|
|
116397
116491
|
const config = this.configManager.getConfig();
|
|
116398
|
-
|
|
116399
|
-
if (
|
|
116400
|
-
|
|
116401
|
-
wpConfig = {
|
|
116402
|
-
type: "database",
|
|
116403
|
-
wordpressUrl: `http://localhost:${config.env.port || 8888}`,
|
|
116404
|
-
database: dbConfig
|
|
116405
|
-
};
|
|
116406
|
-
logger.info(` Using Docker database: ${dbConfig.host}:${dbConfig.port}`);
|
|
116492
|
+
const dbConfig = config.database || this.dockerEnvManager?.getDatabaseConfig();
|
|
116493
|
+
if (!dbConfig) {
|
|
116494
|
+
throw new Error("No database connection available. Make sure Docker environment is running.");
|
|
116407
116495
|
}
|
|
116496
|
+
const wpConfig = {
|
|
116497
|
+
type: "database",
|
|
116498
|
+
wordpressUrl: this.configManager.getWordPressUrl(),
|
|
116499
|
+
database: dbConfig
|
|
116500
|
+
};
|
|
116501
|
+
logger.info(` Using database: ${dbConfig.host}:${dbConfig.port}`);
|
|
116408
116502
|
await this.connectionManager.createConnection(wpConfig);
|
|
116409
116503
|
this.pushCommand = new PushCommand(this.blockRegistry);
|
|
116410
116504
|
logger.success("WordPress connection established");
|
|
@@ -117631,17 +117725,15 @@ class BuildCommand {
|
|
|
117631
117725
|
logger.progress("Starting build operation...");
|
|
117632
117726
|
try {
|
|
117633
117727
|
const config = this.configManager.getConfig();
|
|
117634
|
-
const blocksDir = this.configManager.resolvePath(options.blocksDir || config.
|
|
117635
|
-
const outputDir = this.configManager.resolvePath(options.outputDir || config.
|
|
117728
|
+
const blocksDir = this.configManager.resolvePath(options.blocksDir || config.paths.blocks);
|
|
117729
|
+
const outputDir = this.configManager.resolvePath(options.outputDir || config.paths.dist);
|
|
117636
117730
|
let webpackConfig;
|
|
117637
117731
|
if (options.webpackConfig) {
|
|
117638
117732
|
webpackConfig = this.configManager.resolvePath(options.webpackConfig);
|
|
117639
|
-
} else if (config.build?.webpackConfig) {
|
|
117640
|
-
webpackConfig = this.configManager.resolvePath(config.build.webpackConfig);
|
|
117641
117733
|
} else {
|
|
117642
117734
|
webpackConfig = path22.join(__dirname3, "..", "webpack.config.cjs");
|
|
117643
117735
|
}
|
|
117644
|
-
const scriptsPath =
|
|
117736
|
+
const scriptsPath = this.configManager.resolvePath(config.paths.scripts);
|
|
117645
117737
|
logger.info(`Scanning blocks in: ${blocksDir}`);
|
|
117646
117738
|
logger.info(`Output directory: ${outputDir}`);
|
|
117647
117739
|
if (scriptsPath) {
|
|
@@ -117688,7 +117780,7 @@ class BuildCommand {
|
|
|
117688
117780
|
if (block.scripts && block.scripts.length > 0) {
|
|
117689
117781
|
const result2 = results.find((r) => r.blockName === block.name);
|
|
117690
117782
|
if (result2?.success) {
|
|
117691
|
-
const scriptPaths = block.scripts.map((script) => `scripts/${path22.basename(script).replace(/\.ts$/, ".js")}`);
|
|
117783
|
+
const scriptPaths = block.scripts.map((script) => `dist/scripts/${path22.basename(script).replace(/\.ts$/, ".js")}`);
|
|
117692
117784
|
this.blockScripts.set(block.name, scriptPaths);
|
|
117693
117785
|
}
|
|
117694
117786
|
}
|
|
@@ -117750,27 +117842,17 @@ class BuildTemplatesCommand {
|
|
|
117750
117842
|
async execute(options = {}) {
|
|
117751
117843
|
logger.progress("Starting template build operation...");
|
|
117752
117844
|
const config = this.configManager.getConfig();
|
|
117753
|
-
const
|
|
117754
|
-
|
|
117755
|
-
logger.error("Templates configuration not found in wordpress-flow.config.json");
|
|
117756
|
-
logger.info('Add a "templates" section to your config with "templatesDir" and "outputDir"');
|
|
117757
|
-
return;
|
|
117758
|
-
}
|
|
117759
|
-
const templatesDir = options.templatesDir || this.configManager.resolvePath(templatesConfig.templatesDir);
|
|
117760
|
-
const outputDir = options.outputDir || this.configManager.resolvePath(templatesConfig.outputDir);
|
|
117845
|
+
const templatesDir = options.templatesDir || this.configManager.resolvePath(config.paths.templates);
|
|
117846
|
+
const outputDir = options.outputDir || this.configManager.resolvePath(config.paths.templatesOutput);
|
|
117761
117847
|
if (!fs19.existsSync(templatesDir)) {
|
|
117762
117848
|
logger.error(`Templates directory not found: ${templatesDir}`);
|
|
117763
117849
|
return;
|
|
117764
117850
|
}
|
|
117765
117851
|
fs19.mkdirSync(outputDir, { recursive: true });
|
|
117766
|
-
const
|
|
117767
|
-
|
|
117768
|
-
|
|
117769
|
-
|
|
117770
|
-
blockRegistry = new BlockRegistry(blocksOutputDir);
|
|
117771
|
-
await blockRegistry.loadBuiltBlocks();
|
|
117772
|
-
logger.info(`Loaded ${blockRegistry.getAllComponentMappings().length} built blocks`);
|
|
117773
|
-
}
|
|
117852
|
+
const blocksOutputDir = this.configManager.resolvePath(config.paths.dist);
|
|
117853
|
+
const blockRegistry = new BlockRegistry(blocksOutputDir);
|
|
117854
|
+
await blockRegistry.loadBuiltBlocks();
|
|
117855
|
+
logger.info(`Loaded ${blockRegistry.getAllComponentMappings().length} built blocks`);
|
|
117774
117856
|
const renderer = new OfficialMDXRenderer({ blockRegistry });
|
|
117775
117857
|
renderer.initialize();
|
|
117776
117858
|
const templateFiles = this.findMDXFiles(templatesDir);
|
|
@@ -117841,9 +117923,6 @@ class EnvCommand {
|
|
|
117841
117923
|
}
|
|
117842
117924
|
getDockerEnvManager() {
|
|
117843
117925
|
const config = this.configManager.getConfig();
|
|
117844
|
-
if (!config.env) {
|
|
117845
|
-
throw new Error("No Docker environment configured. Add 'env' section to your config file.");
|
|
117846
|
-
}
|
|
117847
117926
|
const packageJsonPath = path24.join(this.configManager.getConfigDir(), "package.json");
|
|
117848
117927
|
let projectName = "wordpress-project";
|
|
117849
117928
|
if (fs20.existsSync(packageJsonPath)) {
|
|
@@ -117855,7 +117934,7 @@ class EnvCommand {
|
|
|
117855
117934
|
return new DockerEnvManager({
|
|
117856
117935
|
projectName,
|
|
117857
117936
|
workspaceDir: this.configManager.getConfigDir(),
|
|
117858
|
-
config
|
|
117937
|
+
config
|
|
117859
117938
|
});
|
|
117860
117939
|
}
|
|
117861
117940
|
async destroy() {
|
|
@@ -117870,7 +117949,7 @@ class EnvCommand {
|
|
|
117870
117949
|
}
|
|
117871
117950
|
async dbImport(filePath2) {
|
|
117872
117951
|
const config = this.configManager.getConfig();
|
|
117873
|
-
const inputPath = filePath2 || config.
|
|
117952
|
+
const inputPath = filePath2 || config.dev.sqlDump;
|
|
117874
117953
|
if (!inputPath) {
|
|
117875
117954
|
throw new Error("No SQL file specified. Use --file option or set 'sqlDump' in config.");
|
|
117876
117955
|
}
|
|
@@ -117885,7 +117964,7 @@ class EnvCommand {
|
|
|
117885
117964
|
}
|
|
117886
117965
|
async dbExport(filePath2) {
|
|
117887
117966
|
const config = this.configManager.getConfig();
|
|
117888
|
-
const outputPath = filePath2 || config.
|
|
117967
|
+
const outputPath = filePath2 || config.dev.sqlDump || "./db/dump.sql";
|
|
117889
117968
|
console.log(`
|
|
117890
117969
|
\uD83D\uDCE4 Exporting database to ${outputPath}...
|
|
117891
117970
|
`);
|