refactor: rename schema

This commit is contained in:
Kevin Franklin Kim 2025-09-19 11:37:06 +02:00
parent 3d66e427c9
commit 6bd3e40e5d
No known key found for this signature in database
3 changed files with 13 additions and 58 deletions

View File

@ -1,4 +1,4 @@
# yaml-language-server: $schema=config.schema.json
# yaml-language-server: $schema=posh.schema.json
version: '1.0'
# Prompt settings

View File

@ -19,13 +19,9 @@
"$ref": "#/$defs/Require"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"version",
"env",
"prompt",
"require"
"version"
]
},
"Env": {
@ -38,12 +34,7 @@
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"value"
]
"type": "object"
},
"type": "array"
},
@ -68,15 +59,7 @@
"type": "object"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"title",
"prefix",
"prefixGit",
"history",
"aliases"
]
"type": "object"
},
"PromptHistory": {
"properties": {
@ -90,13 +73,7 @@
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"limit",
"filename",
"lockFilename"
]
"type": "object"
},
"Require": {
"properties": {
@ -119,13 +96,7 @@
"type": "array"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"envs",
"scripts",
"packages"
]
"type": "object"
},
"RequireEnv": {
"properties": {
@ -136,12 +107,7 @@
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"help"
]
"type": "object"
},
"RequirePackage": {
"properties": {
@ -158,14 +124,7 @@
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"version",
"command",
"help"
]
"type": "object"
},
"RequireScript": {
"properties": {
@ -179,13 +138,7 @@
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name",
"command",
"help"
]
"type": "object"
}
}
}

View File

@ -26,7 +26,7 @@ type Config struct {
Require config.Require `json:"require"`
}
func TestConfig(t *testing.T) {
func TestSchema(t *testing.T) {
t.Parallel()
testingx.Tags(t, tagx.Short)
@ -34,12 +34,14 @@ func TestConfig(t *testing.T) {
require.NoError(t, err)
reflector := new(jsonschema.Reflector)
reflector.AllowAdditionalProperties = true
reflector.RequiredFromJSONSchemaTags = true
require.NoError(t, reflector.AddGoComments("github.com/foomo/posh", "./"))
schema := reflector.Reflect(&Config{})
actual, err := json.MarshalIndent(schema, "", " ")
require.NoError(t, err)
filename := path.Join(cwd, "config.schema.json")
filename := path.Join(cwd, "posh.schema.json")
expected, err := os.ReadFile(filename)
if !errors.Is(err, os.ErrNotExist) {
require.NoError(t, err)