Skip to content

Commit 1dbe976

Browse files
authored
Blueprints: Allow optional metadata (#1103)
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
1 parent a1308d5 commit 1dbe976

File tree

2 files changed

+215
-97
lines changed

2 files changed

+215
-97
lines changed

packages/playground/blueprints/public/blueprint-schema.json

Lines changed: 192 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,35 @@
1111
},
1212
"description": {
1313
"type": "string",
14-
"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."
14+
"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.",
15+
"deprecated": "Use meta.description instead."
16+
},
17+
"meta": {
18+
"type": "object",
19+
"properties": {
20+
"title": {
21+
"type": "string",
22+
"description": "A clear and concise name for your Blueprint."
23+
},
24+
"description": {
25+
"type": "string",
26+
"description": "A brief explanation of what your Blueprint offers."
27+
},
28+
"author": {
29+
"type": "string",
30+
"description": "A GitHub username of the author of this Blueprint."
31+
},
32+
"categories": {
33+
"type": "array",
34+
"items": {
35+
"type": "string"
36+
},
37+
"description": "Relevant categories to help users find your Blueprint in the future Blueprints section on WordPress.org."
38+
}
39+
},
40+
"required": ["title", "author"],
41+
"additionalProperties": false,
42+
"description": "Optional metadata. Used by the Blueprints gallery at https://github.com/WordPress/blueprints"
1543
},
1644
"preferredVersions": {
1745
"type": "object",
@@ -1171,46 +1199,125 @@
11711199
"$ref": "#/definitions/PHPRequestHeaders",
11721200
"description": "Request headers."
11731201
},
1174-
"files": {
1175-
"type": "object",
1176-
"additionalProperties": {
1177-
"type": "object",
1178-
"properties": {
1179-
"size": {
1180-
"type": "number"
1181-
},
1182-
"type": {
1183-
"type": "string"
1202+
"body": {
1203+
"anyOf": [
1204+
{
1205+
"type": "string"
1206+
},
1207+
{
1208+
"type": "object",
1209+
"properties": {
1210+
"BYTES_PER_ELEMENT": {
1211+
"type": "number"
1212+
},
1213+
"buffer": {
1214+
"type": "object",
1215+
"properties": {
1216+
"byteLength": {
1217+
"type": "number"
1218+
}
1219+
},
1220+
"required": ["byteLength"],
1221+
"additionalProperties": false
1222+
},
1223+
"byteLength": {
1224+
"type": "number"
1225+
},
1226+
"byteOffset": {
1227+
"type": "number"
1228+
},
1229+
"length": {
1230+
"type": "number"
1231+
}
11841232
},
1185-
"lastModified": {
1233+
"required": [
1234+
"BYTES_PER_ELEMENT",
1235+
"buffer",
1236+
"byteLength",
1237+
"byteOffset",
1238+
"length"
1239+
],
1240+
"additionalProperties": {
11861241
"type": "number"
1187-
},
1188-
"name": {
1189-
"type": "string"
1190-
},
1191-
"webkitRelativePath": {
1192-
"type": "string"
11931242
}
11941243
},
1195-
"required": [
1196-
"lastModified",
1197-
"name",
1198-
"size",
1199-
"type",
1200-
"webkitRelativePath"
1201-
],
1202-
"additionalProperties": false
1203-
},
1204-
"description": "Uploaded files"
1205-
},
1206-
"body": {
1207-
"type": "string",
1208-
"description": "Request body without the files."
1209-
},
1210-
"formData": {
1211-
"type": "object",
1212-
"additionalProperties": {},
1213-
"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`."
1244+
{
1245+
"type": "object",
1246+
"additionalProperties": {
1247+
"anyOf": [
1248+
{
1249+
"type": "string"
1250+
},
1251+
{
1252+
"type": "object",
1253+
"properties": {
1254+
"BYTES_PER_ELEMENT": {
1255+
"type": "number"
1256+
},
1257+
"buffer": {
1258+
"type": "object",
1259+
"properties": {
1260+
"byteLength": {
1261+
"type": "number"
1262+
}
1263+
},
1264+
"required": ["byteLength"],
1265+
"additionalProperties": false
1266+
},
1267+
"byteLength": {
1268+
"type": "number"
1269+
},
1270+
"byteOffset": {
1271+
"type": "number"
1272+
},
1273+
"length": {
1274+
"type": "number"
1275+
}
1276+
},
1277+
"required": [
1278+
"BYTES_PER_ELEMENT",
1279+
"buffer",
1280+
"byteLength",
1281+
"byteOffset",
1282+
"length"
1283+
],
1284+
"additionalProperties": {
1285+
"type": "number"
1286+
}
1287+
},
1288+
{
1289+
"type": "object",
1290+
"properties": {
1291+
"size": {
1292+
"type": "number"
1293+
},
1294+
"type": {
1295+
"type": "string"
1296+
},
1297+
"lastModified": {
1298+
"type": "number"
1299+
},
1300+
"name": {
1301+
"type": "string"
1302+
},
1303+
"webkitRelativePath": {
1304+
"type": "string"
1305+
}
1306+
},
1307+
"required": [
1308+
"lastModified",
1309+
"name",
1310+
"size",
1311+
"type",
1312+
"webkitRelativePath"
1313+
],
1314+
"additionalProperties": false
1315+
}
1316+
]
1317+
}
1318+
}
1319+
],
1320+
"description": "Request body. If an object is given, the request will be encoded as multipart and sent with a `multipart/form-data` header."
12141321
}
12151322
},
12161323
"required": ["url"],
@@ -1250,78 +1357,66 @@
12501357
"description": "Request headers."
12511358
},
12521359
"body": {
1253-
"type": "string",
1254-
"description": "Request body without the files."
1255-
},
1256-
"fileInfos": {
1257-
"type": "array",
1258-
"items": {
1259-
"$ref": "#/definitions/FileInfo"
1260-
},
1261-
"description": "Uploaded files."
1262-
},
1263-
"code": {
1264-
"type": "string",
1265-
"description": "The code snippet to eval instead of a php file."
1266-
},
1267-
"throwOnError": {
1268-
"type": "boolean",
1269-
"description": "Whether to throw an error if the PHP process exits with a non-zero code or outputs to stderr."
1270-
}
1271-
},
1272-
"additionalProperties": false
1273-
},
1274-
"FileInfo": {
1275-
"type": "object",
1276-
"properties": {
1277-
"key": {
1278-
"type": "string"
1279-
},
1280-
"name": {
1281-
"type": "string"
1282-
},
1283-
"type": {
1284-
"type": "string"
1285-
},
1286-
"data": {
1287-
"type": "object",
1288-
"properties": {
1289-
"BYTES_PER_ELEMENT": {
1290-
"type": "number"
1360+
"anyOf": [
1361+
{
1362+
"type": "string"
12911363
},
1292-
"buffer": {
1364+
{
12931365
"type": "object",
12941366
"properties": {
1367+
"BYTES_PER_ELEMENT": {
1368+
"type": "number"
1369+
},
1370+
"buffer": {
1371+
"type": "object",
1372+
"properties": {
1373+
"byteLength": {
1374+
"type": "number"
1375+
}
1376+
},
1377+
"required": ["byteLength"],
1378+
"additionalProperties": false
1379+
},
12951380
"byteLength": {
12961381
"type": "number"
1382+
},
1383+
"byteOffset": {
1384+
"type": "number"
1385+
},
1386+
"length": {
1387+
"type": "number"
12971388
}
12981389
},
1299-
"required": ["byteLength"],
1300-
"additionalProperties": false
1301-
},
1302-
"byteLength": {
1303-
"type": "number"
1304-
},
1305-
"byteOffset": {
1306-
"type": "number"
1307-
},
1308-
"length": {
1309-
"type": "number"
1390+
"required": [
1391+
"BYTES_PER_ELEMENT",
1392+
"buffer",
1393+
"byteLength",
1394+
"byteOffset",
1395+
"length"
1396+
],
1397+
"additionalProperties": {
1398+
"type": "number"
1399+
}
13101400
}
1311-
},
1312-
"required": [
1313-
"BYTES_PER_ELEMENT",
1314-
"buffer",
1315-
"byteLength",
1316-
"byteOffset",
1317-
"length"
13181401
],
1402+
"description": "Request body."
1403+
},
1404+
"env": {
1405+
"type": "object",
13191406
"additionalProperties": {
1320-
"type": "number"
1321-
}
1407+
"type": "string"
1408+
},
1409+
"description": "Environment variables to set for this run."
1410+
},
1411+
"code": {
1412+
"type": "string",
1413+
"description": "The code snippet to eval instead of a php file."
1414+
},
1415+
"throwOnError": {
1416+
"type": "boolean",
1417+
"description": "Whether to throw an error if the PHP process exits with a non-zero code or outputs to stderr."
13221418
}
13231419
},
1324-
"required": ["key", "name", "type", "data"],
13251420
"additionalProperties": false
13261421
},
13271422
"WordPressInstallationOptions": {

packages/playground/blueprints/src/lib/blueprint.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,31 @@ export interface Blueprint {
1414
* Optional description. It doesn't do anything but is exposed as
1515
* a courtesy to developers who may want to document which blueprint
1616
* file does what.
17+
*
18+
* @deprecated Use meta.description instead.
1719
*/
1820
description?: string;
21+
/**
22+
* Optional metadata. Used by the Blueprints gallery at https://github.com/WordPress/blueprints
23+
*/
24+
meta?: {
25+
/**
26+
* A clear and concise name for your Blueprint.
27+
*/
28+
title: string;
29+
/**
30+
* A brief explanation of what your Blueprint offers.
31+
*/
32+
description?: string;
33+
/**
34+
* A GitHub username of the author of this Blueprint.
35+
*/
36+
author: string;
37+
/**
38+
* Relevant categories to help users find your Blueprint in the future Blueprints section on WordPress.org.
39+
*/
40+
categories?: string[];
41+
};
1942
/**
2043
* The preferred PHP and WordPress versions to use.
2144
*/

0 commit comments

Comments
 (0)