mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
refactor(plugin): ♻️ Move plugin manifests to json file, add JSON schema
This commit is contained in:
parent
3bcb7225bf
commit
f623f2c1a0
|
|
@ -37,7 +37,7 @@
|
||||||
"wc": "find server database *.ts docs packages types utils drizzle tests -type f -print0 | wc -m --files0-from=-",
|
"wc": "find server database *.ts docs packages types utils drizzle tests -type f -print0 | wc -m --files0-from=-",
|
||||||
"cli": "bun run cli/index.ts",
|
"cli": "bun run cli/index.ts",
|
||||||
"prune": "ts-prune | grep -v server/ | grep -v dist/ | grep -v '(used in module)'",
|
"prune": "ts-prune | grep -v server/ | grep -v dist/ | grep -v '(used in module)'",
|
||||||
"schema:generate": "bun run packages/config-manager/json-schema.ts > config/config.schema.json",
|
"schema:generate": "bun run packages/config-manager/json-schema.ts > config/config.schema.json && bun run packages/plugin-kit/json-schema.ts > packages/plugin-kit/manifest.schema.json",
|
||||||
"check": "bunx tsc -p ."
|
"check": "bunx tsc -p ."
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": [
|
||||||
|
|
|
||||||
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": {
|
"dependencies": {
|
||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"zod": "^3.23.8",
|
"zod": "^3.23.8",
|
||||||
|
"zod-to-json-schema": "^3.23.3",
|
||||||
"zod-validation-error": "^3.3.0"
|
"zod-validation-error": "^3.3.0"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const manifestSchema = z.object({
|
export const manifestSchema = z.object({
|
||||||
|
// biome-ignore lint/style/useNamingConvention: <explanation>
|
||||||
|
$schema: z.string().optional(),
|
||||||
name: z.string().min(3).max(100),
|
name: z.string().min(3).max(100),
|
||||||
version: z
|
version: z
|
||||||
.string()
|
.string()
|
||||||
|
|
|
||||||
17
plugins/openid/manifest.json
Normal file
17
plugins/openid/manifest.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"$schema": "../../packages/plugin-kit/manifest.schema.json",
|
||||||
|
"name": "@versia/openid",
|
||||||
|
"description": "OpenID authentication.",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jesse Wierzbinski",
|
||||||
|
"email": "contact@cpluspatch.com",
|
||||||
|
"url": "https://cpluspatch.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/versia-pub/server.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue