@wordpress-flow/cli 1.0.1 → 1.0.4

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.
Files changed (2) hide show
  1. package/dist/index.js +103 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -117092,6 +117092,22 @@ declare global {
117092
117092
  interface MDXProvidedComponents {
117093
117093
  ${componentMappings.map((mapping) => ` ${mapping}`).join(`
117094
117094
  `)}
117095
+ /** WordPress FSE block wrapper - use for any WordPress core block */
117096
+ WP: React.ComponentType<{
117097
+ /** WordPress block name (without 'core/' prefix, e.g., 'post-title', 'site-title') */
117098
+ name: string;
117099
+ /** Additional props passed to the WordPress block */
117100
+ [key: string]: any;
117101
+ }>;
117102
+ /** WordPress shortcode wrapper */
117103
+ Shortcode: React.ComponentType<{
117104
+ /** Shortcode name (e.g., 'contact-form-7', 'gallery') */
117105
+ name: string;
117106
+ /** Shortcode content (for enclosing shortcodes) */
117107
+ children?: React.ReactNode;
117108
+ /** Shortcode attributes */
117109
+ [key: string]: any;
117110
+ }>;
117095
117111
  }
117096
117112
  }
117097
117113
 
@@ -117130,25 +117146,27 @@ export {};
117130
117146
  }
117131
117147
  convertSingleAttribute(attr) {
117132
117148
  const type = attr.type || "any";
117149
+ const optional = attr.default !== undefined;
117133
117150
  switch (type) {
117134
117151
  case "string":
117135
- return { type: "string" };
117152
+ return { type: "string", optional };
117136
117153
  case "number":
117137
- return { type: "number" };
117154
+ return { type: "number", optional };
117138
117155
  case "boolean":
117139
- return { type: "boolean" };
117156
+ return { type: "boolean", optional };
117140
117157
  case "array":
117141
- return { type: "any[]" };
117158
+ return { type: "any[]", optional };
117142
117159
  case "object":
117143
117160
  if (this.isMediaObject(attr)) {
117144
117161
  return {
117145
- type: "{ id: number; url: string; alt: string; width?: number; height?: number }",
117146
- description: "Media object with image details"
117162
+ type: "{ id?: number; url: string; alt?: string; width?: number; height?: number }",
117163
+ description: "Media object with image details",
117164
+ optional
117147
117165
  };
117148
117166
  }
117149
- return { type: "{ [key: string]: any }" };
117167
+ return { type: "{ [key: string]: any }", optional };
117150
117168
  default:
117151
- return { type: "any" };
117169
+ return { type: "any", optional };
117152
117170
  }
117153
117171
  }
117154
117172
  isMediaObject(attr) {
@@ -117414,12 +117432,30 @@ class BuildCommand {
117414
117432
  if (scriptsPath) {
117415
117433
  logger.info(`Scripts directory: ${scriptsPath}`);
117416
117434
  }
117417
- const blocks = await this.blockScanner.scanBlocks(blocksDir);
117435
+ let blocks = await this.blockScanner.scanBlocks(blocksDir);
117418
117436
  if (blocks.length === 0) {
117419
117437
  logger.warn("No blocks found in the specified directory");
117420
117438
  return;
117421
117439
  }
117422
- logger.info(`Found ${blocks.length} block(s): ${blocks.map((b) => b.name).join(", ")}`);
117440
+ if (options.blocks && options.blocks.length > 0) {
117441
+ const requestedBlocks = options.blocks;
117442
+ const allBlockNames = blocks.map((b) => b.name);
117443
+ const filteredBlocks = blocks.filter((block) => requestedBlocks.includes(block.name));
117444
+ const foundBlockNames = filteredBlocks.map((b) => b.name);
117445
+ const notFoundBlocks = requestedBlocks.filter((name2) => !foundBlockNames.includes(name2));
117446
+ if (notFoundBlocks.length > 0) {
117447
+ logger.warn(`Requested blocks not found: ${notFoundBlocks.join(", ")}`);
117448
+ logger.info(`Available blocks: ${allBlockNames.join(", ")}`);
117449
+ }
117450
+ if (filteredBlocks.length === 0) {
117451
+ logger.warn("No matching blocks found to build");
117452
+ return;
117453
+ }
117454
+ blocks = filteredBlocks;
117455
+ logger.info(`Building ${blocks.length} specified block(s): ${blocks.map((b) => b.name).join(", ")}`);
117456
+ } else {
117457
+ logger.info(`Found ${blocks.length} block(s): ${blocks.map((b) => b.name).join(", ")}`);
117458
+ }
117423
117459
  for (let i2 = 0;i2 < blocks.length; i2++) {
117424
117460
  const block = blocks[i2];
117425
117461
  logger.step(i2 + 1, blocks.length, `Building block: ${block.name}`);
@@ -117970,10 +118006,63 @@ class BuildTemplatesCommand {
117970
118006
  return content4.replace(frontmatterRegex, "").trim();
117971
118007
  }
117972
118008
  }
118009
+ // package.json
118010
+ var package_default = {
118011
+ name: "@wordpress-flow/cli",
118012
+ version: "1.0.4",
118013
+ type: "module",
118014
+ description: "TypeScript-based WordPress block creation system",
118015
+ main: "dist/index.js",
118016
+ bin: {
118017
+ "wordpress-flow": "./dist/index.js"
118018
+ },
118019
+ scripts: {
118020
+ build: "bun build ./src/index.ts --outdir ./dist --target node"
118021
+ },
118022
+ dependencies: {
118023
+ "@babel/core": "^7.28.4",
118024
+ "@babel/preset-react": "^7.27.1",
118025
+ "@mdx-js/mdx": "^3.1.1",
118026
+ "@mdx-js/react": "^3.1.1",
118027
+ "@types/react": "^18.3.24",
118028
+ "@types/wordpress__block-editor": "^11.5.17",
118029
+ "@wordpress/block-editor": "^15.4.0",
118030
+ "@wordpress/block-serialization-default-parser": "^5.33.0",
118031
+ "@wordpress/blocks": "^15.6.0",
118032
+ "@wordpress/element": "^6.33.0",
118033
+ ajv: "^8.17.1",
118034
+ axios: "^1.12.2",
118035
+ chalk: "^4.1.2",
118036
+ chokidar: "^3.5.3",
118037
+ commander: "^11.0.0",
118038
+ dotenv: "^17.2.3",
118039
+ esbuild: "^0.19.0",
118040
+ glob: "^11.0.3",
118041
+ mysql2: "^3.15.2",
118042
+ react: "^18.3.1",
118043
+ "react-dom": "^18.3.1"
118044
+ },
118045
+ devDependencies: {
118046
+ "@types/glob": "^9.0.0",
118047
+ "@types/mysql": "^2.15.27",
118048
+ "@types/node": "^20.0.0",
118049
+ "@wordpress/scripts": "^30.24.0",
118050
+ typescript: "^5.0.0",
118051
+ "webpack-cli": "^6.0.1"
118052
+ },
118053
+ keywords: [
118054
+ "wordpress",
118055
+ "blocks",
118056
+ "cli",
118057
+ "typescript"
118058
+ ],
118059
+ author: "Przemysław Krasiński",
118060
+ license: "MIT"
118061
+ };
117973
118062
 
117974
118063
  // src/index.ts
117975
118064
  var program2 = new Command;
117976
- program2.name("wordpress-flow").description("Build WordPress sites with React, TypeScript, and MDX - A content-first development framework").version("0.0.1");
118065
+ program2.name("wordpress-flow").description("Build WordPress sites with React, TypeScript, and MDX - A content-first development framework").version(package_default.version);
117977
118066
  program2.option("-v, --verbose", "Enable verbose logging").option("-q, --quiet", "Suppress non-error output").hook("preAction", (thisCommand) => {
117978
118067
  const opts = thisCommand.opts();
117979
118068
  if (opts.verbose) {
@@ -117991,7 +118080,7 @@ program2.command("setup").description("Run the configuration wizard").action(asy
117991
118080
  process.exit(1);
117992
118081
  }
117993
118082
  });
117994
- program2.command("build").description("Build WordPress blocks for Gutenberg").option("--blocks-dir <dir>", "Source directory for blocks").option("--output-dir <dir>", "Output directory for built blocks").option("--webpack-config <path>", "Path to webpack config file").option("--watch", "Watch mode for development").action(async (options) => {
118083
+ program2.command("build").description("Build WordPress blocks for Gutenberg").option("--blocks-dir <dir>", "Source directory for blocks").option("--output-dir <dir>", "Output directory for built blocks").option("--webpack-config <path>", "Path to webpack config file").option("--watch", "Watch mode for development").option("-b, --blocks <names...>", "Specific block names to build").action(async (options) => {
117995
118084
  try {
117996
118085
  await ensureConfiguration();
117997
118086
  const command = new BuildCommand;
@@ -117999,7 +118088,8 @@ program2.command("build").description("Build WordPress blocks for Gutenberg").op
117999
118088
  blocksDir: options.blocksDir,
118000
118089
  outputDir: options.outputDir,
118001
118090
  webpackConfig: options.webpackConfig,
118002
- watch: options.watch || false
118091
+ watch: options.watch || false,
118092
+ blocks: options.blocks
118003
118093
  });
118004
118094
  logger.info("Build command completed successfully");
118005
118095
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress-flow/cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "description": "TypeScript-based WordPress block creation system",
6
6
  "main": "dist/index.js",