Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Schemas Package #35927

Closed
mkaz opened this issue Oct 25, 2021 · 2 comments · Fixed by #35998
Closed

Create a Schemas Package #35927

mkaz opened this issue Oct 25, 2021 · 2 comments · Fixed by #35998
Assignees
Labels
Developer Experience Ideas about improving block and theme developer experience [Feature] Block API API that allows to express the block paradigm. Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Code Quality Issues or PRs that relate to code quality

Comments

@mkaz
Copy link
Member

mkaz commented Oct 25, 2021

What problem does this address?

Recently schema definitions for theme.json and block.json were uploaded to the SchemaStore.org (theme.json, and block.json).

Using JSON schemas makes it easier for development. Supported editors can show tooltips, autocomplete, and validation issues. Documenation on using schemas were added in: #35835 #35739

The SchemaStore.org is a global open collection of JSON schemas, plus includes good documentation on using schemas. So it is still worthwhile to list our schemas there, as developers may look there to use them as it gets popular.

@gziolo brought up in #35902 (comment) and #35843 (comment) that we should have a definitive source in the Gutenberg repo, which could also be used for validation during the build processs.

What is your proposed solution?

We should create a "schemas" package at "@wordpress/schemas" to hold the definitive schemas definitions, these can by copied to the SchemaStore to keep in-sync. Another benefit of having the schemas in the Gutenberg repo is they would also get versioned with tags/branches related to the releases, for example the WP 5.8 could be:
https://github.com/WordPress/gutenberg/tree/wp/5.8/packages/schemas/block.json

Questions

The schema store has three directories, js, ,css, and json and the schemas are nested there.

@gziolo mentions in #35902 (comment) that there are i18n configs that could find a home in the schemas package.

So what directory structure should we use in the package?

My suggestion for flexibility to create: a json/ directory to start and store them there.

@mkaz mkaz added the [Type] Code Quality Issues or PRs that relate to code quality label Oct 25, 2021
@gziolo gziolo added the Developer Experience Ideas about improving block and theme developer experience label Oct 27, 2021
@gziolo
Copy link
Member

gziolo commented Oct 27, 2021

My suggestion for flexibility to create: a json/ directory to start and store them there.

Sounds good 👍🏻

The steps required to create a new WordPress package are documented in https://github.com/WordPress/gutenberg/tree/trunk/packages#creating-a-new-package.

@gziolo gziolo added [Feature] Block API API that allows to express the block paradigm. Good First Issue An issue that's suitable for someone looking to contribute for the first time labels Oct 27, 2021
mkaz added a commit that referenced this issue Oct 27, 2021
Creates a new package to hold the block.json and theme.json files that
can then be synced to the SchemaStore. We want a package within
Gutenberg so we can use the schemas internally to validate package files
such as blocks in the block-library as well as generate documentation.

Closes #35927
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 27, 2021
@ryanwelcher
Copy link
Contributor

Wanted to mention that the current block validator plugin ( https://wordpress.org/plugins/developers/block-plugin-validator ) incorrectly flags items that are actually valid.
block-validator
If we can use this package to also keep that tool up to date, we'll avoid a lot of frustration and confusion for developers.

mkaz added a commit that referenced this issue Nov 1, 2021
* Add schemas package

Creates a new package to hold the block.json and theme.json files that
can then be synced to the SchemaStore. We want a package within
Gutenberg so we can use the schemas internally to validate package files
such as blocks in the block-library as well as generate documentation.

Closes #35927

* Add schema package doc entry

* Update CHANGELOG.md

* Update packages/schemas/package.json

* Update packages/schemas/package.json

* Remove category from 'required' list

* Move schemas out of packages to top-level

* .npmrc and package.json not needed for non-npm package

* No installation necessary

* Remove package docs

Co-authored-by: Greg Ziółkowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Ideas about improving block and theme developer experience [Feature] Block API API that allows to express the block paradigm. Good First Issue An issue that's suitable for someone looking to contribute for the first time [Status] In Progress Tracking issues with work in progress [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants