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

Add block.json schema to generated file #35843

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/create-block/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
## Unreleased

### New Features

- Add passing local directories to --template. ([#35645](https://github.com/WordPress/gutenberg/pull/35645))
- Add `slugPascalCase` to the list of variables that can be used in templates ([#35462](https://github.com/WordPress/gutenberg/pull/35462))

- Add $schema definition to generated `block.json` file.

## 2.5.0 (2021-07-21)

### Enhancements
Expand Down
1 change: 1 addition & 0 deletions packages/create-block/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module.exports = {

The following configurable variables are used with the template files. Template authors can change default values to use when users don't provide their data:

- `$schema` (default: `https://json.schemastore.org/block.json`)
- `apiVersion` (default: `2`) - see https://make.wordpress.org/core/2020/11/18/block-api-version-2/.
- `slug` (no default)
- `namespace` (default: `'create-block'`)
Expand Down
2 changes: 2 additions & 0 deletions packages/create-block/lib/init-block-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const { writeFile } = require( 'fs' ).promises;
const { info } = require( './log' );

module.exports = async ( {
$schema,
apiVersion,
slug,
namespace,
Expand All @@ -34,6 +35,7 @@ module.exports = async ( {
JSON.stringify(
omitBy(
{
$schema,
apiVersion,
name: namespace + '/' + slug,
version,
Expand Down
2 changes: 2 additions & 0 deletions packages/create-block/lib/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const { code, info, success } = require( './log' );
module.exports = async (
blockTemplate,
{
$schema,
apiVersion,
namespace,
slug,
Expand Down Expand Up @@ -48,6 +49,7 @@ module.exports = async (

const { outputTemplates, outputAssets } = blockTemplate;
const view = {
$schema,
apiVersion,
namespace,
namespaceSnakeCase: snakeCase( namespace ),
Expand Down
1 change: 1 addition & 0 deletions packages/create-block/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const getBlockTemplate = async ( templateName ) => {

const getDefaultValues = ( blockTemplate ) => {
return {
$schema: 'https://json.schemastore.org/block.json',
apiVersion: 2,
namespace: 'create-block',
category: 'widgets',
Expand Down