mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor(plugin): ♻️ Move plugin manifests to json file, add JSON schema
This commit is contained in:
parent
3bcb7225bf
commit
f623f2c1a0
7 changed files with 111 additions and 1 deletions
6
packages/plugin-kit/json-schema.ts
Normal file
6
packages/plugin-kit/json-schema.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
import { manifestSchema } from "./schema";
|
||||
|
||||
const jsonSchema = zodToJsonSchema(manifestSchema);
|
||||
|
||||
console.write(`${JSON.stringify(jsonSchema, null, 4)}\n`);
|
||||
84
packages/plugin-kit/manifest.schema.json
Normal file
84
packages/plugin-kit/manifest.schema.json
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 3,
|
||||
"maxLength": 100
|
||||
},
|
||||
"version": {
|
||||
"type": "string",
|
||||
"pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 4096
|
||||
},
|
||||
"authors": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"maxLength": 100
|
||||
},
|
||||
"email": {
|
||||
"type": "string",
|
||||
"format": "email"
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"required": ["name"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"git",
|
||||
"svn",
|
||||
"mercurial",
|
||||
"bzr",
|
||||
"darcs",
|
||||
"mtn",
|
||||
"cvs",
|
||||
"fossil",
|
||||
"bazaar",
|
||||
"arch",
|
||||
"tla",
|
||||
"archie",
|
||||
"monotone",
|
||||
"perforce",
|
||||
"sourcevault",
|
||||
"plastic",
|
||||
"clearcase",
|
||||
"accurev",
|
||||
"surroundscm",
|
||||
"bitkeeper",
|
||||
"other"
|
||||
]
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"format": "uri"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"required": ["name", "version", "description"],
|
||||
"additionalProperties": false,
|
||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
"dependencies": {
|
||||
"mitt": "^3.0.1",
|
||||
"zod": "^3.23.8",
|
||||
"zod-to-json-schema": "^3.23.3",
|
||||
"zod-validation-error": "^3.3.0"
|
||||
},
|
||||
"exports": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import { z } from "zod";
|
||||
|
||||
export const manifestSchema = z.object({
|
||||
// biome-ignore lint/style/useNamingConvention: <explanation>
|
||||
$schema: z.string().optional(),
|
||||
name: z.string().min(3).max(100),
|
||||
version: z
|
||||
.string()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue