@wordpress-flow/cli 1.1.4 → 1.2.1

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.
@@ -1837,7 +1837,7 @@ import * as fs from "fs";
1837
1837
  import * as esbuild from "esbuild";
1838
1838
  import { execSync } from "child_process";
1839
1839
  async function buildBlock() {
1840
- const { block, outputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
1840
+ const { block, outputDir, scriptsOutputDir, webpackConfigPath, scriptsPath, tempDir } = workerData;
1841
1841
  try {
1842
1842
  fs.mkdirSync(tempDir, { recursive: true });
1843
1843
  const entryPoint = await generateEntryPoint(block, tempDir);
@@ -1845,7 +1845,7 @@ async function buildBlock() {
1845
1845
  fs.mkdirSync(blockOutputDir, { recursive: true });
1846
1846
  let scriptPaths = [];
1847
1847
  if (block.scripts && block.scripts.length > 0 && scriptsPath) {
1848
- scriptPaths = await buildBlockScripts(block.scripts, scriptsPath, outputDir);
1848
+ scriptPaths = await buildBlockScripts(block.scripts, scriptsPath, scriptsOutputDir);
1849
1849
  }
1850
1850
  await generateBlockJson(block, blockOutputDir, tempDir);
1851
1851
  await generateSSRVersion(block, blockOutputDir);
@@ -1889,8 +1889,7 @@ if (document.readyState === 'loading') {
1889
1889
  fs.writeFileSync(entryPath, entryContent, "utf8");
1890
1890
  return entryPath;
1891
1891
  }
1892
- async function buildBlockScripts(scripts, scriptsPath, outputDir) {
1893
- const scriptsOutputDir = path.join(path.dirname(outputDir), "scripts");
1892
+ async function buildBlockScripts(scripts, scriptsPath, scriptsOutputDir) {
1894
1893
  fs.mkdirSync(scriptsOutputDir, { recursive: true });
1895
1894
  const outputPaths = [];
1896
1895
  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,147 @@ class ConfigManager {
80945
80965
  if (this.config) {
80946
80966
  return this.config;
80947
80967
  }
80948
- if (!fs2.existsSync(this.configPath)) {
80949
- throw new Error(`Configuration file not found at ${this.configPath}. Please run the setup wizard first.`);
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
- try {
80952
- const configContent = fs2.readFileSync(this.configPath, "utf8");
80953
- const config = JSON.parse(configContent);
80954
- this.config = this.mergeWithEnvCredentials(config);
80955
- return this.config;
80956
- } catch (error) {
80957
- throw new Error(`Failed to load configuration: ${error.message}`);
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
+ const dist = `${theme}/dist`;
81019
+ return {
81020
+ paths: {
81021
+ theme,
81022
+ content: content2,
81023
+ plugins,
81024
+ blocks: `${theme}/blocks`,
81025
+ dist,
81026
+ blocksDist: `${dist}/blocks`,
81027
+ scriptsDist: `${dist}/scripts`,
81028
+ scripts: `${theme}/scripts`,
81029
+ templates: `${content2}/templates`,
81030
+ templateParts: `${content2}/parts`,
81031
+ templatesOutput: `${theme}/templates`,
81032
+ partsOutput: `${theme}/parts`
81033
+ },
81034
+ sync: {
81035
+ excludePostTypes: raw.sync?.excludePostTypes || DEFAULTS.sync.excludePostTypes,
81036
+ includedPostStatuses: raw.sync?.includedPostStatuses || DEFAULTS.sync.includedPostStatuses
81037
+ },
81038
+ dev: {
81039
+ port: raw.dev?.port || DEFAULTS.dev.port,
81040
+ databasePort: raw.dev?.databasePort || DEFAULTS.dev.databasePort,
81041
+ phpVersion: raw.dev?.phpVersion || DEFAULTS.dev.phpVersion,
81042
+ wordpressVersion: raw.dev?.wordpressVersion || DEFAULTS.dev.wordpressVersion,
81043
+ plugins: raw.dev?.plugins || DEFAULTS.dev.plugins,
81044
+ sqlDump: raw.dev?.sqlDump
81045
+ },
81046
+ database: this.runtimeDatabase || undefined
81047
+ };
80959
81048
  }
80960
81049
  async saveConfig(config) {
80961
- const publicConfig = this.stripSensitiveData(config);
80962
- const envVars = this.extractEnvVars(config);
80963
- fs2.writeFileSync(this.configPath, JSON.stringify(publicConfig, null, 2));
80964
- await this.updateEnvFile(envVars);
80965
- this.config = config;
81050
+ const minimalConfig = this.stripDefaults(config);
81051
+ fs2.writeFileSync(this.configPath, JSON.stringify(minimalConfig, null, 2));
81052
+ this.rawConfig = config;
81053
+ this.config = this.resolveConfig(config);
81054
+ }
81055
+ stripDefaults(config) {
81056
+ const result2 = {};
81057
+ if (config.paths) {
81058
+ const paths = {};
81059
+ if (config.paths.theme && config.paths.theme !== DEFAULTS.paths.theme) {
81060
+ paths.theme = config.paths.theme;
81061
+ }
81062
+ if (config.paths.content && config.paths.content !== DEFAULTS.paths.content) {
81063
+ paths.content = config.paths.content;
81064
+ }
81065
+ if (config.paths.plugins && config.paths.plugins !== DEFAULTS.paths.plugins) {
81066
+ paths.plugins = config.paths.plugins;
81067
+ }
81068
+ if (Object.keys(paths).length > 0) {
81069
+ result2.paths = paths;
81070
+ }
81071
+ }
81072
+ if (config.sync) {
81073
+ const sync = {};
81074
+ if (config.sync.excludePostTypes && config.sync.excludePostTypes.length > 0) {
81075
+ sync.excludePostTypes = config.sync.excludePostTypes;
81076
+ }
81077
+ if (config.sync.includedPostStatuses && JSON.stringify(config.sync.includedPostStatuses) !== JSON.stringify(DEFAULTS.sync.includedPostStatuses)) {
81078
+ sync.includedPostStatuses = config.sync.includedPostStatuses;
81079
+ }
81080
+ if (Object.keys(sync).length > 0) {
81081
+ result2.sync = sync;
81082
+ }
81083
+ }
81084
+ if (config.dev) {
81085
+ const dev = {};
81086
+ if (config.dev.port && config.dev.port !== DEFAULTS.dev.port) {
81087
+ dev.port = config.dev.port;
81088
+ }
81089
+ if (config.dev.databasePort && config.dev.databasePort !== DEFAULTS.dev.databasePort) {
81090
+ dev.databasePort = config.dev.databasePort;
81091
+ }
81092
+ if (config.dev.phpVersion && config.dev.phpVersion !== DEFAULTS.dev.phpVersion) {
81093
+ dev.phpVersion = config.dev.phpVersion;
81094
+ }
81095
+ if (config.dev.wordpressVersion && config.dev.wordpressVersion !== DEFAULTS.dev.wordpressVersion) {
81096
+ dev.wordpressVersion = config.dev.wordpressVersion;
81097
+ }
81098
+ if (config.dev.plugins && config.dev.plugins.length > 0) {
81099
+ dev.plugins = config.dev.plugins;
81100
+ }
81101
+ if (config.dev.sqlDump) {
81102
+ dev.sqlDump = config.dev.sqlDump;
81103
+ }
81104
+ if (Object.keys(dev).length > 0) {
81105
+ result2.dev = dev;
81106
+ }
81107
+ }
81108
+ return result2;
80966
81109
  }
80967
81110
  getConfig() {
80968
81111
  if (!this.config) {
@@ -80973,11 +81116,18 @@ class ConfigManager {
80973
81116
  hasConfig() {
80974
81117
  return fs2.existsSync(this.configPath);
80975
81118
  }
80976
- getWordPressConfig() {
80977
- return this.getConfig().wordpress;
81119
+ setDatabaseConnection(connection) {
81120
+ this.runtimeDatabase = connection;
81121
+ if (this.config) {
81122
+ this.config.database = connection;
81123
+ }
80978
81124
  }
80979
- getSyncPaths() {
80980
- return this.getConfig().paths;
81125
+ getDatabaseConnection() {
81126
+ return this.config?.database;
81127
+ }
81128
+ getWordPressUrl() {
81129
+ const port = this.config?.dev.port || DEFAULTS.dev.port;
81130
+ return `http://localhost:${port}`;
80981
81131
  }
80982
81132
  resolvePath(relativePath) {
80983
81133
  if (path2.isAbsolute(relativePath)) {
@@ -80988,60 +81138,70 @@ class ConfigManager {
80988
81138
  getConfigDir() {
80989
81139
  return this.configDir;
80990
81140
  }
80991
- mergeWithEnvCredentials(config) {
80992
- const mergedConfig = { ...config };
80993
- if (mergedConfig.wordpress.type === "rest-api") {
80994
- const password = process.env.WP_APPLICATION_PASSWORD;
80995
- if (password && password !== "undefined") {
80996
- mergedConfig.wordpress.applicationPassword = password;
80997
- }
80998
- } else if (mergedConfig.wordpress.type === "database") {
80999
- const password = process.env.DB_PASSWORD;
81000
- if (password && password !== "undefined") {
81001
- mergedConfig.wordpress.database.password = password;
81141
+ getLegacyConfig() {
81142
+ const config = this.getConfig();
81143
+ const dbConnection = config.database || {
81144
+ host: "127.0.0.1",
81145
+ port: config.dev.databasePort,
81146
+ database: "wordpress",
81147
+ username: "wordpress",
81148
+ password: "wordpress"
81149
+ };
81150
+ return {
81151
+ wordpress: {
81152
+ type: "database",
81153
+ wordpressUrl: this.getWordPressUrl(),
81154
+ syncPath: config.paths.content,
81155
+ postTypes: ["post", "page"],
81156
+ database: dbConnection
81157
+ },
81158
+ paths: {
81159
+ mdxOutputDir: config.paths.content,
81160
+ postTypeMappings: {
81161
+ post: `${config.paths.content}/post`,
81162
+ page: `${config.paths.content}/page`
81163
+ }
81164
+ },
81165
+ sync: {
81166
+ watchForChanges: true,
81167
+ conflictResolution: "manual",
81168
+ excludePostTypes: config.sync.excludePostTypes,
81169
+ includedPostStatuses: config.sync.includedPostStatuses
81170
+ },
81171
+ build: {
81172
+ blocksDir: config.paths.blocks,
81173
+ outputDir: config.paths.dist,
81174
+ scriptsPath: config.paths.scripts
81175
+ },
81176
+ templates: {
81177
+ templatesDir: config.paths.templates,
81178
+ outputDir: config.paths.templatesOutput
81179
+ },
81180
+ templateParts: {
81181
+ partsDir: config.paths.templateParts,
81182
+ outputDir: config.paths.partsOutput
81183
+ },
81184
+ env: {
81185
+ port: config.dev.port,
81186
+ databasePort: config.dev.databasePort,
81187
+ phpVersion: config.dev.phpVersion,
81188
+ wordpressVersion: config.dev.wordpressVersion,
81189
+ themeDir: config.paths.theme,
81190
+ pluginsDir: config.paths.plugins,
81191
+ plugins: config.dev.plugins,
81192
+ sqlDump: config.dev.sqlDump,
81193
+ volumes: {
81194
+ database: true,
81195
+ uploads: true
81196
+ }
81002
81197
  }
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;
81198
+ };
81014
81199
  }
81015
- extractEnvVars(config) {
81016
- const envVars = {};
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;
81200
+ getWordPressConfig() {
81201
+ return this.getLegacyConfig().wordpress;
81023
81202
  }
81024
- async updateEnvFile(newVars) {
81025
- let envContent = "";
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);
81203
+ getSyncPaths() {
81204
+ return this.getLegacyConfig().paths;
81045
81205
  }
81046
81206
  }
81047
81207
  // src/config/logger.ts
@@ -84776,8 +84936,7 @@ class DatabaseClient {
84776
84936
  const perPage = params.per_page || 100;
84777
84937
  const page = params.page || 1;
84778
84938
  const offset = (page - 1) * perPage;
84779
- query += " LIMIT ? OFFSET ?";
84780
- queryParams.push(perPage, offset);
84939
+ query += ` LIMIT ${Number(perPage)} OFFSET ${Number(offset)}`;
84781
84940
  logger.debug(`Executing query: ${query}`);
84782
84941
  logger.debug(`Query parameters: ${JSON.stringify(queryParams)}`);
84783
84942
  const [rows] = await this.connection.execute(query, queryParams);
@@ -85636,7 +85795,8 @@ class PullCommand {
85636
85795
  async execute(options) {
85637
85796
  logger.progress("Starting pull operation...");
85638
85797
  const config = this.configManager.getConfig();
85639
- const connection = await this.connectionManager.createConnection(config.wordpress);
85798
+ const legacyConfig = this.configManager.getLegacyConfig();
85799
+ const connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
85640
85800
  const result2 = {
85641
85801
  success: false,
85642
85802
  operation: {
@@ -85648,7 +85808,7 @@ class PullCommand {
85648
85808
  },
85649
85809
  target: {
85650
85810
  type: "local",
85651
- identifier: options.outputDir || config.paths.mdxOutputDir,
85811
+ identifier: options.outputDir || config.paths.content,
85652
85812
  lastModified: new Date
85653
85813
  },
85654
85814
  timestamp: new Date,
@@ -85658,8 +85818,8 @@ class PullCommand {
85658
85818
  errors: []
85659
85819
  };
85660
85820
  try {
85661
- const postTypes = options.postTypes || config.wordpress.postTypes || ["post", "page"];
85662
- const outputDir = options.outputDir || config.paths.mdxOutputDir;
85821
+ const postTypes = options.postTypes || ["post", "page"];
85822
+ const outputDir = options.outputDir || config.paths.content;
85663
85823
  fs3.mkdirSync(outputDir, { recursive: true });
85664
85824
  let totalProcessed = 0;
85665
85825
  for (const postType of postTypes) {
@@ -85734,13 +85894,7 @@ class PullCommand {
85734
85894
  title: post.title.rendered,
85735
85895
  slug: post.slug,
85736
85896
  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 || {}
85897
+ status: post.status
85744
85898
  };
85745
85899
  const mdxContent = this.generateMDX(blocks, frontmatter);
85746
85900
  fs3.writeFileSync(filePath2, mdxContent, "utf8");
@@ -112907,7 +113061,7 @@ class PushCommand {
112907
113061
  this.blockRegistry = blockRegistry;
112908
113062
  } else {
112909
113063
  const config = this.configManager.getConfig();
112910
- const buildOutputDir = this.configManager.resolvePath(config.build?.outputDir || "./theme/dist");
113064
+ const buildOutputDir = this.configManager.resolvePath(config.paths.dist);
112911
113065
  this.blockRegistry = new BlockRegistry(buildOutputDir);
112912
113066
  }
112913
113067
  }
@@ -112985,7 +113139,8 @@ class PushCommand {
112985
113139
  logger.warn("Continuing with basic block rendering...");
112986
113140
  }
112987
113141
  const config = this.configManager.getConfig();
112988
- const connection = await this.connectionManager.createConnection(config.wordpress);
113142
+ const legacyConfig = this.configManager.getLegacyConfig();
113143
+ const connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
112989
113144
  const result2 = {
112990
113145
  success: false,
112991
113146
  operation: {
@@ -112997,7 +113152,7 @@ class PushCommand {
112997
113152
  },
112998
113153
  target: {
112999
113154
  type: "wordpress",
113000
- identifier: config.wordpress.wordpressUrl,
113155
+ identifier: this.configManager.getWordPressUrl(),
113001
113156
  lastModified: new Date
113002
113157
  },
113003
113158
  timestamp: new Date,
@@ -113008,7 +113163,7 @@ class PushCommand {
113008
113163
  conflicts: []
113009
113164
  };
113010
113165
  try {
113011
- const mdxFiles = await this.findMDXFiles(options.files, config.paths.mdxOutputDir);
113166
+ const mdxFiles = await this.findMDXFiles(options.files, config.paths.content);
113012
113167
  if (mdxFiles.length === 0) {
113013
113168
  logger.warn("No MDX files found to push");
113014
113169
  result2.operation.status = "completed";
@@ -113067,11 +113222,12 @@ class PushCommand {
113067
113222
  await this.blockRegistry.loadBuiltBlocks();
113068
113223
  } catch {}
113069
113224
  const config = this.configManager.getConfig();
113225
+ const legacyConfig = this.configManager.getLegacyConfig();
113070
113226
  let connection;
113071
113227
  if (this.connectionManager.hasConnection()) {
113072
113228
  connection = this.connectionManager.getConnection();
113073
113229
  } else {
113074
- connection = await this.connectionManager.createConnection(config.wordpress);
113230
+ connection = await this.connectionManager.createConnection(legacyConfig.wordpress);
113075
113231
  }
113076
113232
  const result2 = {
113077
113233
  success: false,
@@ -113084,7 +113240,7 @@ class PushCommand {
113084
113240
  },
113085
113241
  target: {
113086
113242
  type: "wordpress",
113087
- identifier: config.wordpress.wordpressUrl,
113243
+ identifier: this.configManager.getWordPressUrl(),
113088
113244
  lastModified: new Date
113089
113245
  },
113090
113246
  timestamp: new Date,
@@ -113095,7 +113251,7 @@ class PushCommand {
113095
113251
  conflicts: []
113096
113252
  };
113097
113253
  try {
113098
- const mdxFiles = await this.findMDXFiles(options.files, config.paths.mdxOutputDir);
113254
+ const mdxFiles = await this.findMDXFiles(options.files, config.paths.content);
113099
113255
  if (mdxFiles.length === 0) {
113100
113256
  result2.operation.status = "completed";
113101
113257
  result2.success = true;
@@ -113242,20 +113398,6 @@ ${"=".repeat(80)}`);
113242
113398
  conflictType: "missing-source"
113243
113399
  };
113244
113400
  }
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
113401
  return null;
113260
113402
  } catch (error) {
113261
113403
  logger.warn(`Could not check for conflicts on post ${mdxFile.frontmatter.postId}: ${error.message}`);
@@ -113288,31 +113430,15 @@ ${"=".repeat(80)}`);
113288
113430
  }
113289
113431
  let frontmatter = frontmatterMatch[1];
113290
113432
  const postId = wpPost.id;
113291
- const modified = wpPost.modified || new Date().toISOString();
113292
- const lastPushed = new Date().toISOString();
113293
- if (frontmatter.includes("postId:")) {
113294
- frontmatter = frontmatter.replace(/postId:\s*\d*/, `postId: ${postId}`);
113295
- } else {
113433
+ if (!frontmatter.includes("postId:")) {
113296
113434
  frontmatter = `${frontmatter}
113297
113435
  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---/, `---
113436
+ const updatedContent = content4.replace(/^---\n([\s\S]*?)\n---/, `---
113312
113437
  ${frontmatter}
113313
113438
  ---`);
113314
- fs5.writeFileSync(filePath2, updatedContent, "utf8");
113315
- logger.debug(`Updated ${filePath2} with sync timestamps`);
113439
+ fs5.writeFileSync(filePath2, updatedContent, "utf8");
113440
+ logger.debug(`Added postId to ${filePath2}`);
113441
+ }
113316
113442
  } catch (error) {
113317
113443
  logger.warn(`Failed to update MDX file after push: ${error.message}`);
113318
113444
  }
@@ -115799,20 +115925,7 @@ class DockerEnvManager {
115799
115925
  constructor(options) {
115800
115926
  this.projectName = this.sanitizeProjectName(options.projectName);
115801
115927
  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
- };
115928
+ this.config = options.config;
115816
115929
  this.containerNames = {
115817
115930
  wordpress: `${this.projectName}-wordpress`,
115818
115931
  mysql: `${this.projectName}-mysql`
@@ -115872,7 +115985,7 @@ class DockerEnvManager {
115872
115985
  logger.info("\uD83D\uDC33 Docker containers already running");
115873
115986
  }
115874
115987
  await this.waitForWordPress();
115875
- const wordpressUrl = `http://localhost:${this.config.port}`;
115988
+ const wordpressUrl = this.getWordPressUrl();
115876
115989
  return { wordpressUrl, isFirstRun };
115877
115990
  }
115878
115991
  async createContainers() {
@@ -115881,31 +115994,29 @@ class DockerEnvManager {
115881
115994
  stdio: "pipe"
115882
115995
  });
115883
115996
  } catch {}
115884
- const themeDir = path16.resolve(this.workspaceDir, this.config.themeDir);
115997
+ const themeDir = path16.resolve(this.workspaceDir, this.config.paths.theme);
115885
115998
  const themeName = path16.basename(themeDir);
115886
115999
  logger.info(" Starting MySQL...");
115887
- const mysqlVolume = this.config.volumes.database ? `-v ${this.projectName}-mysql-data:/var/lib/mysql` : "";
115888
- const mysqlPort = this.config.databasePort ? `-p ${this.config.databasePort}:3306` : "";
116000
+ const mysqlVolume = `-v ${this.projectName}-mysql-data:/var/lib/mysql`;
116001
+ const mysqlPort = this.config.dev.databasePort ? `-p ${this.config.dev.databasePort}:3306` : "";
115889
116002
  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
116003
  await this.waitForMySQL();
115891
116004
  logger.info(" Starting WordPress...");
115892
- const uploadsVolume = this.config.volumes.uploads ? `-v ${this.projectName}-uploads:/var/www/html/wp-content/uploads` : "";
116005
+ const uploadsVolume = `-v ${this.projectName}-uploads:/var/www/html/wp-content/uploads`;
115893
116006
  let pluginMounts = "";
115894
- if (this.config.pluginsDir) {
115895
- const pluginsDir = path16.resolve(this.workspaceDir, this.config.pluginsDir);
115896
- if (fs14.existsSync(pluginsDir)) {
115897
- const pluginFolders = fs14.readdirSync(pluginsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
115898
- for (const pluginName of pluginFolders) {
115899
- const pluginPath = path16.join(pluginsDir, pluginName);
115900
- pluginMounts += ` -v "${pluginPath}:/var/www/html/wp-content/plugins/${pluginName}"`;
115901
- }
115902
- if (pluginFolders.length > 0) {
115903
- logger.info(` Mounting ${pluginFolders.length} local plugin(s): ${pluginFolders.join(", ")}`);
115904
- }
116007
+ const pluginsDir = path16.resolve(this.workspaceDir, this.config.paths.plugins);
116008
+ if (fs14.existsSync(pluginsDir)) {
116009
+ const pluginFolders = fs14.readdirSync(pluginsDir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
116010
+ for (const pluginName of pluginFolders) {
116011
+ const pluginPath = path16.join(pluginsDir, pluginName);
116012
+ pluginMounts += ` -v "${pluginPath}:/var/www/html/wp-content/plugins/${pluginName}"`;
116013
+ }
116014
+ if (pluginFolders.length > 0) {
116015
+ logger.info(` Mounting ${pluginFolders.length} local plugin(s): ${pluginFolders.join(", ")}`);
115905
116016
  }
115906
116017
  }
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" });
116018
+ const wpImage = this.config.dev.wordpressVersion === "latest" ? `wordpress:php${this.config.dev.phpVersion}` : `wordpress:${this.config.dev.wordpressVersion}-php${this.config.dev.phpVersion}`;
116019
+ 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
116020
  }
115910
116021
  async startContainers() {
115911
116022
  execSync(`docker start ${this.containerNames.mysql}`, { stdio: "pipe" });
@@ -115959,7 +116070,7 @@ class DockerEnvManager {
115959
116070
  logger.info(" Waiting for WordPress...");
115960
116071
  while (attempts < maxAttempts) {
115961
116072
  try {
115962
- const response = execSync(`curl -s -o /dev/null -w "%{http_code}" http://localhost:${this.config.port}`, { encoding: "utf8", stdio: "pipe" }).trim();
116073
+ const response = execSync(`curl -s -o /dev/null -w "%{http_code}" http://localhost:${this.config.dev.port}`, { encoding: "utf8", stdio: "pipe" }).trim();
115963
116074
  if (response.length > 0) {
115964
116075
  return;
115965
116076
  }
@@ -115998,8 +116109,8 @@ class DockerEnvManager {
115998
116109
  }
115999
116110
  async installWordPress() {
116000
116111
  logger.info(" Installing WordPress...");
116001
- const siteUrl = `http://localhost:${this.config.port}`;
116002
- const themeName = path16.basename(path16.resolve(this.workspaceDir, this.config.themeDir));
116112
+ const siteUrl = this.getWordPressUrl();
116113
+ const themeName = path16.basename(path16.resolve(this.workspaceDir, this.config.paths.theme));
116003
116114
  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
116115
  logger.info(` Activating theme: ${themeName}...`);
116005
116116
  try {
@@ -116010,10 +116121,10 @@ class DockerEnvManager {
116010
116121
  execSync(`docker exec ${this.containerNames.wordpress} wp rewrite structure '/%postname%/' --allow-root`, { stdio: "pipe" });
116011
116122
  }
116012
116123
  async installPlugins() {
116013
- if (this.config.plugins.length === 0)
116124
+ if (this.config.dev.plugins.length === 0)
116014
116125
  return;
116015
116126
  logger.info(" Installing plugins...");
116016
- for (const plugin of this.config.plugins) {
116127
+ for (const plugin of this.config.dev.plugins) {
116017
116128
  try {
116018
116129
  if (plugin.startsWith("./") || plugin.startsWith("/")) {
116019
116130
  const pluginPath = path16.resolve(this.workspaceDir, plugin);
@@ -116030,9 +116141,9 @@ class DockerEnvManager {
116030
116141
  }
116031
116142
  }
116032
116143
  async importSqlDump() {
116033
- if (!this.config.sqlDump)
116144
+ if (!this.config.dev.sqlDump)
116034
116145
  return;
116035
- const sqlPath = path16.resolve(this.workspaceDir, this.config.sqlDump);
116146
+ const sqlPath = path16.resolve(this.workspaceDir, this.config.dev.sqlDump);
116036
116147
  if (!fs14.existsSync(sqlPath)) {
116037
116148
  logger.warn(` SQL dump not found: ${sqlPath}`);
116038
116149
  return;
@@ -116041,7 +116152,7 @@ class DockerEnvManager {
116041
116152
  await this.waitForMySQLReady();
116042
116153
  execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, { stdio: "pipe" });
116043
116154
  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 = `http://localhost:${this.config.port}`;
116155
+ const siteUrl = this.getWordPressUrl();
116045
116156
  execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
116046
116157
  execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
116047
116158
  await this.reactivatePlugins();
@@ -116093,14 +116204,12 @@ class DockerEnvManager {
116093
116204
  }
116094
116205
  logger.info(" Importing SQL dump...");
116095
116206
  await this.waitForMySQLReady();
116096
- execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, {
116097
- stdio: "pipe"
116098
- });
116207
+ execSync(`docker cp "${sqlPath}" ${this.containerNames.mysql}:/tmp/dump.sql`, { stdio: "pipe" });
116099
116208
  execSync(`docker exec ${this.containerNames.mysql} sh -c "mysql -h 127.0.0.1 -u wordpress -pwordpress wordpress < /tmp/dump.sql"`, { stdio: "pipe" });
116100
116209
  if (!await this.hasWPCLI()) {
116101
116210
  await this.installWPCLI();
116102
116211
  }
116103
- const siteUrl = `http://localhost:${this.config.port}`;
116212
+ const siteUrl = this.getWordPressUrl();
116104
116213
  try {
116105
116214
  execSync(`docker exec ${this.containerNames.wordpress} wp option update siteurl "${siteUrl}" --allow-root`, { stdio: "pipe" });
116106
116215
  execSync(`docker exec ${this.containerNames.wordpress} wp option update home "${siteUrl}" --allow-root`, { stdio: "pipe" });
@@ -116112,14 +116221,14 @@ class DockerEnvManager {
116112
116221
  getDatabaseConfig() {
116113
116222
  return {
116114
116223
  host: "127.0.0.1",
116115
- port: this.config.databasePort ?? 3306,
116224
+ port: this.config.dev.databasePort,
116116
116225
  database: "wordpress",
116117
116226
  username: "wordpress",
116118
116227
  password: "wordpress"
116119
116228
  };
116120
116229
  }
116121
116230
  getWordPressUrl() {
116122
- return `http://localhost:${this.config.port}`;
116231
+ return `http://localhost:${this.config.dev.port}`;
116123
116232
  }
116124
116233
  sleep(ms) {
116125
116234
  return new Promise((resolve6) => setTimeout(resolve6, ms));
@@ -116139,27 +116248,23 @@ class DockerEnvManager {
116139
116248
  stdio: "pipe"
116140
116249
  });
116141
116250
  } catch {}
116142
- if (this.config.volumes.database) {
116143
- try {
116144
- execSync(`docker volume rm ${this.projectName}-mysql-data`, {
116145
- stdio: "pipe"
116146
- });
116147
- } catch {}
116148
- }
116149
- if (this.config.volumes.uploads) {
116150
- try {
116151
- execSync(`docker volume rm ${this.projectName}-uploads`, {
116152
- stdio: "pipe"
116153
- });
116154
- } catch {}
116155
- }
116251
+ try {
116252
+ execSync(`docker volume rm ${this.projectName}-mysql-data`, {
116253
+ stdio: "pipe"
116254
+ });
116255
+ } catch {}
116256
+ try {
116257
+ execSync(`docker volume rm ${this.projectName}-uploads`, {
116258
+ stdio: "pipe"
116259
+ });
116260
+ } catch {}
116156
116261
  logger.info(" ✓ Cleanup complete");
116157
116262
  }
116158
116263
  }
116159
116264
  // package.json
116160
116265
  var package_default = {
116161
116266
  name: "@wordpress-flow/cli",
116162
- version: "1.1.4",
116267
+ version: "1.2.1",
116163
116268
  type: "module",
116164
116269
  description: "TypeScript-based WordPress block creation system",
116165
116270
  main: "dist/index.js",
@@ -116283,7 +116388,7 @@ class DevModeOrchestrator {
116283
116388
  console.log("\uD83D\uDCCB Loading configuration...");
116284
116389
  await this.initializeConfig();
116285
116390
  const config = this.configManager.getConfig();
116286
- if (config.env && !this.options.skipEnv) {
116391
+ if (!this.options.skipEnv) {
116287
116392
  console.log("\uD83D\uDC33 Setting up Docker environment...");
116288
116393
  await this.startDockerEnvironment();
116289
116394
  }
@@ -116312,8 +116417,6 @@ class DevModeOrchestrator {
116312
116417
  }
116313
116418
  async startDockerEnvironment() {
116314
116419
  const config = this.configManager.getConfig();
116315
- if (!config.env)
116316
- return;
116317
116420
  const packageJsonPath = path17.join(this.configManager.getConfigDir(), "package.json");
116318
116421
  let projectName = "wordpress-project";
116319
116422
  if (fs15.existsSync(packageJsonPath)) {
@@ -116325,7 +116428,7 @@ class DevModeOrchestrator {
116325
116428
  this.dockerEnvManager = new DockerEnvManager({
116326
116429
  projectName,
116327
116430
  workspaceDir: this.configManager.getConfigDir(),
116328
- config: config.env
116431
+ config
116329
116432
  });
116330
116433
  try {
116331
116434
  const { wordpressUrl, isFirstRun } = await this.dockerEnvManager.start();
@@ -116340,10 +116443,12 @@ class DevModeOrchestrator {
116340
116443
  }
116341
116444
  await this.dockerEnvManager.installPlugins();
116342
116445
  }
116446
+ const dbConfig = this.dockerEnvManager.getDatabaseConfig();
116447
+ this.configManager.setDatabaseConnection(dbConfig);
116343
116448
  logger.success(`WordPress running at ${wordpressUrl}`);
116344
116449
  logger.info(` Admin: ${wordpressUrl}/wp-admin (admin / password)`);
116345
- if (config.env.databasePort) {
116346
- logger.info(` Database: 127.0.0.1:${config.env.databasePort} (wordpress / wordpress)`);
116450
+ if (config.dev.databasePort) {
116451
+ logger.info(` Database: 127.0.0.1:${config.dev.databasePort} (wordpress / wordpress)`);
116347
116452
  }
116348
116453
  } catch (error) {
116349
116454
  const errorMessage = error.message;
@@ -116355,23 +116460,15 @@ class DevModeOrchestrator {
116355
116460
  }
116356
116461
  async initializeConfig() {
116357
116462
  const config = this.configManager.getConfig();
116358
- this.blocksDir = this.configManager.resolvePath(config.build?.blocksDir || "./theme/blocks");
116359
- this.outputDir = this.configManager.resolvePath(config.build?.outputDir || "./theme/dist");
116360
- if (config.build?.webpackConfig) {
116361
- this.webpackConfig = this.configManager.resolvePath(config.build.webpackConfig);
116362
- } else {
116363
- this.webpackConfig = path17.join(__dirname2, "..", "webpack.config.cjs");
116364
- }
116365
- this.scriptsPath = config.build?.scriptsPath ? this.configManager.resolvePath(config.build.scriptsPath) : undefined;
116366
- this.contentDir = this.configManager.resolvePath(config.paths.mdxOutputDir);
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
- }
116463
+ this.blocksDir = this.configManager.resolvePath(config.paths.blocks);
116464
+ this.outputDir = this.configManager.resolvePath(config.paths.dist);
116465
+ this.webpackConfig = path17.join(__dirname2, "..", "webpack.config.cjs");
116466
+ this.scriptsPath = this.configManager.resolvePath(config.paths.scripts);
116467
+ this.contentDir = this.configManager.resolvePath(config.paths.content);
116468
+ this.templatesDir = this.configManager.resolvePath(config.paths.templates);
116469
+ this.templatesOutputDir = this.configManager.resolvePath(config.paths.templatesOutput);
116470
+ this.templatePartsDir = this.configManager.resolvePath(config.paths.templateParts);
116471
+ this.templatePartsOutputDir = this.configManager.resolvePath(config.paths.partsOutput);
116375
116472
  if (!fs15.existsSync(this.outputDir)) {
116376
116473
  fs15.mkdirSync(this.outputDir, { recursive: true });
116377
116474
  }
@@ -116395,16 +116492,16 @@ class DevModeOrchestrator {
116395
116492
  async connectWordPress() {
116396
116493
  try {
116397
116494
  const config = this.configManager.getConfig();
116398
- let wpConfig = config.wordpress;
116399
- if (this.dockerEnvManager && config.env?.databasePort) {
116400
- const dbConfig = this.dockerEnvManager.getDatabaseConfig();
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}`);
116495
+ const dbConfig = config.database || this.dockerEnvManager?.getDatabaseConfig();
116496
+ if (!dbConfig) {
116497
+ throw new Error("No database connection available. Make sure Docker environment is running.");
116407
116498
  }
116499
+ const wpConfig = {
116500
+ type: "database",
116501
+ wordpressUrl: this.configManager.getWordPressUrl(),
116502
+ database: dbConfig
116503
+ };
116504
+ logger.info(` Using database: ${dbConfig.host}:${dbConfig.port}`);
116408
116505
  await this.connectionManager.createConnection(wpConfig);
116409
116506
  this.pushCommand = new PushCommand(this.blockRegistry);
116410
116507
  logger.success("WordPress connection established");
@@ -117516,12 +117613,14 @@ import * as os2 from "os";
117516
117613
  class WorkerPool {
117517
117614
  concurrency;
117518
117615
  outputDir;
117616
+ scriptsOutputDir;
117519
117617
  webpackConfigPath;
117520
117618
  scriptsPath;
117521
117619
  workerPath;
117522
117620
  constructor(options) {
117523
117621
  this.concurrency = options.concurrency ?? Math.max(1, os2.cpus().length - 1);
117524
117622
  this.outputDir = options.outputDir;
117623
+ this.scriptsOutputDir = options.scriptsOutputDir;
117525
117624
  this.webpackConfigPath = options.webpackConfigPath;
117526
117625
  this.scriptsPath = options.scriptsPath;
117527
117626
  this.workerPath = path21.join(import.meta.dirname, "build", "block-build-worker.js");
@@ -117579,6 +117678,7 @@ class WorkerPool {
117579
117678
  scripts: block.scripts
117580
117679
  },
117581
117680
  outputDir: this.outputDir,
117681
+ scriptsOutputDir: this.scriptsOutputDir,
117582
117682
  webpackConfigPath: this.webpackConfigPath,
117583
117683
  scriptsPath: this.scriptsPath,
117584
117684
  tempDir
@@ -117631,17 +117731,15 @@ class BuildCommand {
117631
117731
  logger.progress("Starting build operation...");
117632
117732
  try {
117633
117733
  const config = this.configManager.getConfig();
117634
- const blocksDir = this.configManager.resolvePath(options.blocksDir || config.build?.blocksDir || "./theme/blocks");
117635
- const outputDir = this.configManager.resolvePath(options.outputDir || config.build?.outputDir || "./theme/dist");
117734
+ const blocksDir = this.configManager.resolvePath(options.blocksDir || config.paths.blocks);
117735
+ const outputDir = this.configManager.resolvePath(options.outputDir || config.paths.blocksDist);
117636
117736
  let webpackConfig;
117637
117737
  if (options.webpackConfig) {
117638
117738
  webpackConfig = this.configManager.resolvePath(options.webpackConfig);
117639
- } else if (config.build?.webpackConfig) {
117640
- webpackConfig = this.configManager.resolvePath(config.build.webpackConfig);
117641
117739
  } else {
117642
117740
  webpackConfig = path22.join(__dirname3, "..", "webpack.config.cjs");
117643
117741
  }
117644
- const scriptsPath = config.build?.scriptsPath ? this.configManager.resolvePath(config.build.scriptsPath) : undefined;
117742
+ const scriptsPath = this.configManager.resolvePath(config.paths.scripts);
117645
117743
  logger.info(`Scanning blocks in: ${blocksDir}`);
117646
117744
  logger.info(`Output directory: ${outputDir}`);
117647
117745
  if (scriptsPath) {
@@ -117671,9 +117769,11 @@ class BuildCommand {
117671
117769
  } else {
117672
117770
  logger.info(`Found ${blocks.length} block(s): ${blocks.map((b) => b.name).join(", ")}`);
117673
117771
  }
117772
+ const scriptsOutputDir = this.configManager.resolvePath(config.paths.scriptsDist);
117674
117773
  const workerPool = new WorkerPool({
117675
117774
  concurrency: options.concurrency,
117676
117775
  outputDir,
117776
+ scriptsOutputDir,
117677
117777
  webpackConfigPath: webpackConfig,
117678
117778
  scriptsPath
117679
117779
  });
@@ -117688,7 +117788,7 @@ class BuildCommand {
117688
117788
  if (block.scripts && block.scripts.length > 0) {
117689
117789
  const result2 = results.find((r) => r.blockName === block.name);
117690
117790
  if (result2?.success) {
117691
- const scriptPaths = block.scripts.map((script) => `scripts/${path22.basename(script).replace(/\.ts$/, ".js")}`);
117791
+ const scriptPaths = block.scripts.map((script) => `dist/scripts/${path22.basename(script).replace(/\.ts$/, ".js")}`);
117692
117792
  this.blockScripts.set(block.name, scriptPaths);
117693
117793
  }
117694
117794
  }
@@ -117750,27 +117850,17 @@ class BuildTemplatesCommand {
117750
117850
  async execute(options = {}) {
117751
117851
  logger.progress("Starting template build operation...");
117752
117852
  const config = this.configManager.getConfig();
117753
- const templatesConfig = config.templates;
117754
- if (!templatesConfig) {
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);
117853
+ const templatesDir = options.templatesDir || this.configManager.resolvePath(config.paths.templates);
117854
+ const outputDir = options.outputDir || this.configManager.resolvePath(config.paths.templatesOutput);
117761
117855
  if (!fs19.existsSync(templatesDir)) {
117762
117856
  logger.error(`Templates directory not found: ${templatesDir}`);
117763
117857
  return;
117764
117858
  }
117765
117859
  fs19.mkdirSync(outputDir, { recursive: true });
117766
- const buildConfig = config.build;
117767
- let blockRegistry;
117768
- if (buildConfig) {
117769
- const blocksOutputDir = this.configManager.resolvePath(buildConfig.outputDir);
117770
- blockRegistry = new BlockRegistry(blocksOutputDir);
117771
- await blockRegistry.loadBuiltBlocks();
117772
- logger.info(`Loaded ${blockRegistry.getAllComponentMappings().length} built blocks`);
117773
- }
117860
+ const blocksOutputDir = this.configManager.resolvePath(config.paths.dist);
117861
+ const blockRegistry = new BlockRegistry(blocksOutputDir);
117862
+ await blockRegistry.loadBuiltBlocks();
117863
+ logger.info(`Loaded ${blockRegistry.getAllComponentMappings().length} built blocks`);
117774
117864
  const renderer = new OfficialMDXRenderer({ blockRegistry });
117775
117865
  renderer.initialize();
117776
117866
  const templateFiles = this.findMDXFiles(templatesDir);
@@ -117841,9 +117931,6 @@ class EnvCommand {
117841
117931
  }
117842
117932
  getDockerEnvManager() {
117843
117933
  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
117934
  const packageJsonPath = path24.join(this.configManager.getConfigDir(), "package.json");
117848
117935
  let projectName = "wordpress-project";
117849
117936
  if (fs20.existsSync(packageJsonPath)) {
@@ -117855,7 +117942,7 @@ class EnvCommand {
117855
117942
  return new DockerEnvManager({
117856
117943
  projectName,
117857
117944
  workspaceDir: this.configManager.getConfigDir(),
117858
- config: config.env
117945
+ config
117859
117946
  });
117860
117947
  }
117861
117948
  async destroy() {
@@ -117870,7 +117957,7 @@ class EnvCommand {
117870
117957
  }
117871
117958
  async dbImport(filePath2) {
117872
117959
  const config = this.configManager.getConfig();
117873
- const inputPath = filePath2 || config.env?.sqlDump;
117960
+ const inputPath = filePath2 || config.dev.sqlDump;
117874
117961
  if (!inputPath) {
117875
117962
  throw new Error("No SQL file specified. Use --file option or set 'sqlDump' in config.");
117876
117963
  }
@@ -117885,7 +117972,7 @@ class EnvCommand {
117885
117972
  }
117886
117973
  async dbExport(filePath2) {
117887
117974
  const config = this.configManager.getConfig();
117888
- const outputPath = filePath2 || config.env?.sqlDump || "./db/dump.sql";
117975
+ const outputPath = filePath2 || config.dev.sqlDump || "./db/dump.sql";
117889
117976
  console.log(`
117890
117977
  \uD83D\uDCE4 Exporting database to ${outputPath}...
117891
117978
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.1.4",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",