mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-12-18 20:11:33 +03:00
Add schema validation for specific subsystems
- Create validation for existing schemas - Validate only for subsystems with existing schemas - Also add schemas for nodejs and rust Co-authored-by: a-kenji <aks.kenji@protonmail.com>
This commit is contained in:
parent
877b83654f
commit
45101cccc4
15
src/specifications/subsystems/nodejs/dream-lock-schema.json
Normal file
15
src/specifications/subsystems/nodejs/dream-lock-schema.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"title": "manifest",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_subsystem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodejsVersion": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
53
src/specifications/subsystems/rust/dream-lock-schema.json
Normal file
53
src/specifications/subsystems/rust/dream-lock-schema.json
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema",
|
||||
"title": "manifest",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_subsystem": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"gitSources": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"url": {
|
||||
"type": "string"
|
||||
},
|
||||
"sha": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["url", "sha", "type", "value"],
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"relPathReplacements": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"^.*$": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"^.*$": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"^.*$": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -233,6 +233,18 @@ in
|
||||
--output pretty \
|
||||
${../specifications/dream-lock-schema.json}
|
||||
|
||||
# if applicable, validate subsystem portion against jsonschema
|
||||
subsystem=$(jq '._generic.subsystem' $dreamLockPath)
|
||||
subsystem=''${subsystem%\"}
|
||||
subsystem=''${subsystem#\"}
|
||||
schema=${../specifications/subsystems}/$subsystem/dream-lock-schema.json
|
||||
if [[ -f "$schema" ]]; then
|
||||
${python3.pkgs.jsonschema}/bin/jsonschema \
|
||||
--instance $dreamLockPath \
|
||||
--output pretty \
|
||||
$schema
|
||||
fi
|
||||
|
||||
# add dream-lock.json to git
|
||||
if git rev-parse --show-toplevel &>/dev/null; then
|
||||
echo "adding file to git: $dreamLockPath"
|
||||
|
Loading…
Reference in New Issue
Block a user