Skip to content

Commit

Permalink
Blueprints: Allow optional metadata (#1103)
Browse files Browse the repository at this point in the history
The Blueprints community space requires Blueprint to ship metadata such
as title, description, author name, etc. This PR adds those fields to
the Blueprint schema.

## Testing instructions

Go to

http://localhost:5400/website-server/?blueprint-url=https://raw.githubusercontent.com/adamziel/blueprints/trunk/v1-examples/latest-gutenberg/blueprint.json
and confirm the Blueprint was executed without schema validation errors
  • Loading branch information
adamziel authored Mar 12, 2024
1 parent a1308d5 commit 1dbe976
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 97 deletions.
289 changes: 192 additions & 97 deletions packages/playground/blueprints/public/blueprint-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,35 @@
},
"description": {
"type": "string",
"description": "Optional description. It doesn't do anything but is exposed as a courtesy to developers who may want to document which blueprint file does what."
"description": "Optional description. It doesn't do anything but is exposed as a courtesy to developers who may want to document which blueprint file does what.",
"deprecated": "Use meta.description instead."
},
"meta": {
"type": "object",
"properties": {
"title": {
"type": "string",
"description": "A clear and concise name for your Blueprint."
},
"description": {
"type": "string",
"description": "A brief explanation of what your Blueprint offers."
},
"author": {
"type": "string",
"description": "A GitHub username of the author of this Blueprint."
},
"categories": {
"type": "array",
"items": {
"type": "string"
},
"description": "Relevant categories to help users find your Blueprint in the future Blueprints section on WordPress.org."
}
},
"required": ["title", "author"],
"additionalProperties": false,
"description": "Optional metadata. Used by the Blueprints gallery at https://github.com/WordPress/blueprints"
},
"preferredVersions": {
"type": "object",
Expand Down Expand Up @@ -1171,46 +1199,125 @@
"$ref": "#/definitions/PHPRequestHeaders",
"description": "Request headers."
},
"files": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"size": {
"type": "number"
},
"type": {
"type": "string"
"body": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"BYTES_PER_ELEMENT": {
"type": "number"
},
"buffer": {
"type": "object",
"properties": {
"byteLength": {
"type": "number"
}
},
"required": ["byteLength"],
"additionalProperties": false
},
"byteLength": {
"type": "number"
},
"byteOffset": {
"type": "number"
},
"length": {
"type": "number"
}
},
"lastModified": {
"required": [
"BYTES_PER_ELEMENT",
"buffer",
"byteLength",
"byteOffset",
"length"
],
"additionalProperties": {
"type": "number"
},
"name": {
"type": "string"
},
"webkitRelativePath": {
"type": "string"
}
},
"required": [
"lastModified",
"name",
"size",
"type",
"webkitRelativePath"
],
"additionalProperties": false
},
"description": "Uploaded files"
},
"body": {
"type": "string",
"description": "Request body without the files."
},
"formData": {
"type": "object",
"additionalProperties": {},
"description": "Form data. If set, the request body will be ignored and the content-type header will be set to `application/x-www-form-urlencoded`."
{
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"BYTES_PER_ELEMENT": {
"type": "number"
},
"buffer": {
"type": "object",
"properties": {
"byteLength": {
"type": "number"
}
},
"required": ["byteLength"],
"additionalProperties": false
},
"byteLength": {
"type": "number"
},
"byteOffset": {
"type": "number"
},
"length": {
"type": "number"
}
},
"required": [
"BYTES_PER_ELEMENT",
"buffer",
"byteLength",
"byteOffset",
"length"
],
"additionalProperties": {
"type": "number"
}
},
{
"type": "object",
"properties": {
"size": {
"type": "number"
},
"type": {
"type": "string"
},
"lastModified": {
"type": "number"
},
"name": {
"type": "string"
},
"webkitRelativePath": {
"type": "string"
}
},
"required": [
"lastModified",
"name",
"size",
"type",
"webkitRelativePath"
],
"additionalProperties": false
}
]
}
}
],
"description": "Request body. If an object is given, the request will be encoded as multipart and sent with a `multipart/form-data` header."
}
},
"required": ["url"],
Expand Down Expand Up @@ -1250,78 +1357,66 @@
"description": "Request headers."
},
"body": {
"type": "string",
"description": "Request body without the files."
},
"fileInfos": {
"type": "array",
"items": {
"$ref": "#/definitions/FileInfo"
},
"description": "Uploaded files."
},
"code": {
"type": "string",
"description": "The code snippet to eval instead of a php file."
},
"throwOnError": {
"type": "boolean",
"description": "Whether to throw an error if the PHP process exits with a non-zero code or outputs to stderr."
}
},
"additionalProperties": false
},
"FileInfo": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"BYTES_PER_ELEMENT": {
"type": "number"
"anyOf": [
{
"type": "string"
},
"buffer": {
{
"type": "object",
"properties": {
"BYTES_PER_ELEMENT": {
"type": "number"
},
"buffer": {
"type": "object",
"properties": {
"byteLength": {
"type": "number"
}
},
"required": ["byteLength"],
"additionalProperties": false
},
"byteLength": {
"type": "number"
},
"byteOffset": {
"type": "number"
},
"length": {
"type": "number"
}
},
"required": ["byteLength"],
"additionalProperties": false
},
"byteLength": {
"type": "number"
},
"byteOffset": {
"type": "number"
},
"length": {
"type": "number"
"required": [
"BYTES_PER_ELEMENT",
"buffer",
"byteLength",
"byteOffset",
"length"
],
"additionalProperties": {
"type": "number"
}
}
},
"required": [
"BYTES_PER_ELEMENT",
"buffer",
"byteLength",
"byteOffset",
"length"
],
"description": "Request body."
},
"env": {
"type": "object",
"additionalProperties": {
"type": "number"
}
"type": "string"
},
"description": "Environment variables to set for this run."
},
"code": {
"type": "string",
"description": "The code snippet to eval instead of a php file."
},
"throwOnError": {
"type": "boolean",
"description": "Whether to throw an error if the PHP process exits with a non-zero code or outputs to stderr."
}
},
"required": ["key", "name", "type", "data"],
"additionalProperties": false
},
"WordPressInstallationOptions": {
Expand Down
23 changes: 23 additions & 0 deletions packages/playground/blueprints/src/lib/blueprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,31 @@ export interface Blueprint {
* Optional description. It doesn't do anything but is exposed as
* a courtesy to developers who may want to document which blueprint
* file does what.
*
* @deprecated Use meta.description instead.
*/
description?: string;
/**
* Optional metadata. Used by the Blueprints gallery at https://github.com/WordPress/blueprints
*/
meta?: {
/**
* A clear and concise name for your Blueprint.
*/
title: string;
/**
* A brief explanation of what your Blueprint offers.
*/
description?: string;
/**
* A GitHub username of the author of this Blueprint.
*/
author: string;
/**
* Relevant categories to help users find your Blueprint in the future Blueprints section on WordPress.org.
*/
categories?: string[];
};
/**
* The preferred PHP and WordPress versions to use.
*/
Expand Down

0 comments on commit 1dbe976

Please sign in to comment.