"lint" command for flipper-pkg tool
Summary: Implemented json schema for flipper plugin package.json and used it for validation in "flipper-pkg lint" command. Nice thing about json schema is that it not only allows to validate json, but also can be referenced using "$schema" property in json so IDEs like VSCode can find it and use for code completion, validation and to show properties documentation. I'm going to deploy the schema as a part of documentation website so it can be referenced as https://fbflipper.com/schemas/plugin-package/v2.json. Also the "$schema" field can be used instead of "specVersion" to determine the specification according to which the plugin is defined. E.g., if specification version 3 would be created, it will be described in schema https://fbflipper.com/schemas/plugin-package/v3.json, etc. Reviewed By: passy Differential Revision: D21228294 fbshipit-source-id: f21351e584ef936a7d6b314436448489691f83a6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
01f8d80402
commit
21c574ac80
52
desktop/pkg/schemas/plugin-package-v2.json
Normal file
52
desktop/pkg/schemas/plugin-package-v2.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"allOf": [
|
||||
{"$ref": "https://schemastore.azurewebsites.net/schemas/json/package.json"}
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "The name of the package. Must start with \"flipper-plugin-\" prefix.",
|
||||
"type": "string",
|
||||
"maxLength": 214,
|
||||
"pattern": "^flipper-plugin-[a-z0-9-._~]*$",
|
||||
"errorMessage": "should start with \"flipper-plugin-\", e.g. \"flipper-plugin-example\""
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "Used as the plugin native identifier and must match the mobile plugin identifier. Also shown in the Flipper main sidebar if \"title\" property is omitted."
|
||||
},
|
||||
"flipperBundlerEntry": {
|
||||
"type": "string",
|
||||
"filePathExists": true,
|
||||
"description": "Points to the source entry point which will be used for the plugin code bundling. \"flipper-pkg\" takes the path specified in this property as source, transpiles and bundles it, and saves the output to the path specified in property \"main\"."
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"description": "Shown in the Flipper main sidebar as the human-readable name of the plugin. If omitted, \"id\" is used instead."
|
||||
},
|
||||
"icon": {
|
||||
"type": "string",
|
||||
"description": "Determines the plugin icon which is displayed in the main sidebar. The list of available icons is static for now and can be found in https://github.com/facebook/flipper/blob/master/desktop/static/icons.json."
|
||||
},
|
||||
"keywords": {
|
||||
"description": "This helps people discover your package as it's listed in 'npm search'. To make the plugin discoverable in Flipper, the property must contain \"flipper-plugin\" keyword.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"contains": {
|
||||
"type": "string",
|
||||
"pattern": "flipper-plugin"
|
||||
},
|
||||
"errorMessage": "should contain keyword \"flipper-plugin\""
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"version",
|
||||
"id",
|
||||
"main",
|
||||
"flipperBundlerEntry",
|
||||
"keywords"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user