Provides a few utility commands for managing WordPress JSON files with schemas.
Initializes AJV-based JSON Schema validation for WordPress schemas for 'theme' or 'block' projects.
It supports schemas using both draft-04
and draft-07
JSON Schema metaschemas.
WARNING: This script will update your package.json file.
- If you do not have a package.json file yet, make sure to update the
author
,license
, andversion
fields to match your theme or plugin. - If you already have a package.json file, you may revert any changes made to the
dependencies
list. OnlydevDependencies
are installed, butnpm init
will add everything fromnode_modules
todependencies
ifnode_modules
already exists.
Node 20.10.0 or later and npm 10.2.3 or later. https://nodejs.org/en/download/
curl -O https://gist.githubusercontent.com/ajlende/dd52732f313f9c8abdd8245f41855957/raw/init-validation.sh
Validates block theme JSON files:
theme.json
styles/*.json
assets/fonts/*.json
bash -x init-validation.sh theme
Validates block plugin JSON files
blocks/**/block.json
bash -x init-validation.sh block
Updates the $schema
to use the given WordPress version for all WordPress files that support it in block themes and block plugins.
Only works on files that already declare a $schema
.
curl -O https://gist.githubusercontent.com/ajlende/dd52732f313f9c8abdd8245f41855957/raw/update-schema.sh
Updates block theme JSON files:
theme.json
styles/*.json
assets/fonts/*.json
bash -x update-schema.sh 6.6
Updates block theme JSON files:
blocks/**/block.json
bash -x update-schema.sh 6.6