mirror of
https://github.com/foomo/posh.git
synced 2025-10-16 12:45:38 +00:00
refactor: rename schema
This commit is contained in:
parent
3d66e427c9
commit
6bd3e40e5d
@ -1,4 +1,4 @@
|
|||||||
# yaml-language-server: $schema=config.schema.json
|
# yaml-language-server: $schema=posh.schema.json
|
||||||
version: '1.0'
|
version: '1.0'
|
||||||
|
|
||||||
# Prompt settings
|
# Prompt settings
|
||||||
@ -19,13 +19,9 @@
|
|||||||
"$ref": "#/$defs/Require"
|
"$ref": "#/$defs/Require"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
"version",
|
"version"
|
||||||
"env",
|
|
||||||
"prompt",
|
|
||||||
"require"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Env": {
|
"Env": {
|
||||||
@ -38,12 +34,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"type": "object"
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"name",
|
|
||||||
"value"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
},
|
},
|
||||||
@ -68,15 +59,7 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"type": "object"
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"title",
|
|
||||||
"prefix",
|
|
||||||
"prefixGit",
|
|
||||||
"history",
|
|
||||||
"aliases"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"PromptHistory": {
|
"PromptHistory": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -90,13 +73,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"type": "object"
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"limit",
|
|
||||||
"filename",
|
|
||||||
"lockFilename"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"Require": {
|
"Require": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -119,13 +96,7 @@
|
|||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"type": "object"
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"envs",
|
|
||||||
"scripts",
|
|
||||||
"packages"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"RequireEnv": {
|
"RequireEnv": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -136,12 +107,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"type": "object"
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"name",
|
|
||||||
"help"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"RequirePackage": {
|
"RequirePackage": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -158,14 +124,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"type": "object"
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"name",
|
|
||||||
"version",
|
|
||||||
"command",
|
|
||||||
"help"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"RequireScript": {
|
"RequireScript": {
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -179,13 +138,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"type": "object"
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"name",
|
|
||||||
"command",
|
|
||||||
"help"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ type Config struct {
|
|||||||
Require config.Require `json:"require"`
|
Require config.Require `json:"require"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfig(t *testing.T) {
|
func TestSchema(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
testingx.Tags(t, tagx.Short)
|
testingx.Tags(t, tagx.Short)
|
||||||
|
|
||||||
@ -34,12 +34,14 @@ func TestConfig(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
reflector := new(jsonschema.Reflector)
|
reflector := new(jsonschema.Reflector)
|
||||||
|
reflector.AllowAdditionalProperties = true
|
||||||
|
reflector.RequiredFromJSONSchemaTags = true
|
||||||
require.NoError(t, reflector.AddGoComments("github.com/foomo/posh", "./"))
|
require.NoError(t, reflector.AddGoComments("github.com/foomo/posh", "./"))
|
||||||
schema := reflector.Reflect(&Config{})
|
schema := reflector.Reflect(&Config{})
|
||||||
actual, err := json.MarshalIndent(schema, "", " ")
|
actual, err := json.MarshalIndent(schema, "", " ")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
filename := path.Join(cwd, "config.schema.json")
|
filename := path.Join(cwd, "posh.schema.json")
|
||||||
expected, err := os.ReadFile(filename)
|
expected, err := os.ReadFile(filename)
|
||||||
if !errors.Is(err, os.ErrNotExist) {
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
Loading…
Reference in New Issue
Block a user