Skip to content

Build step for merging json schema files - #146

Merged
ashfame merged 9 commits into
trunkfrom
build_merge_json_schema
Dec 10, 2024
Merged

Build step for merging json schema files#146
ashfame merged 9 commits into
trunkfrom
build_merge_json_schema

Conversation

@ashfame

@ashfame ashfame commented Dec 9, 2024

Copy link
Copy Markdown
Member

Added a custom webpack plugin EmitMergedJsonPlugin that:

  • Reads all JSON files from a specified source directory
  • Merges them into a single JSON object
  • Outputs the merged schema to multiple locations:
    • Build directory
    • WordPress plugin src dir

Next, we need to figure out the output paths, but that can happen in the PR which starts using the generated schema file.

closes #144


Output sample:

cat build/firefox/schema.json
{
  "page": {
    "title": "Page",
    "fields": {
      "title": "String",
      "content": "String"
    }
  },
  "post": {
    "title": "Blog Post",
    "fields": {
      "date": {
        "type": "Date",
        "description": "date of the post",
        "required": true
      },
      "author": "String",
      "title": "String",
      "content": "String"
    }
  },
  "product": {
    "title": "Product",
    "fields": {
      "title": "ProductString",
      "description": "String",
      "price": "currency"
    }
  }
}

  - Reads all JSON files from a specified source directory
  - Merges them into a single JSON object
  - Outputs the merged schema to multiple locations:
    - Build directory (webpack output)
    - Configured output paths (dist/config, public/config)
@ashfame ashfame self-assigned this Dec 9, 2024
@ashfame
ashfame requested a review from psrpinto December 9, 2024 15:44

@psrpinto psrpinto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for working on this!

Comment thread webpack.config.cjs Outdated
Comment thread webpack.config.cjs Outdated
Comment thread webpack.config.cjs Outdated
@ashfame
ashfame requested a review from psrpinto December 9, 2024 16:32

@psrpinto psrpinto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment thread webpack.config.cjs Outdated
Comment thread webpack.config.cjs Outdated
ashfame and others added 2 commits December 9, 2024 20:50
Co-authored-by: Paulo Pinto <paulo.pinto@automattic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a build process for JSON Schemas

2 participants