aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-22 17:48:58 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-10-21 13:30:51 -0300
commite184a7a138ce887fffd96b27c8d9d445c11f9483 (patch)
tree7363ff1aa440a0f8381acd5dddd52a08c4a322e4
parentb1c4b476795916db41cd99b4301c0e3c633bc25e (diff)
downloadluarocks-e184a7a138ce887fffd96b27c8d9d445c11f9483.tar.gz
luarocks-e184a7a138ce887fffd96b27c8d9d445c11f9483.tar.bz2
luarocks-e184a7a138ce887fffd96b27c8d9d445c11f9483.zip
Teal: convert luarocks.type.manifest
-rw-r--r--src/luarocks/type/manifest.tl106
1 files changed, 59 insertions, 47 deletions
diff --git a/src/luarocks/type/manifest.tl b/src/luarocks/type/manifest.tl
index 043366ea..11bdc566 100644
--- a/src/luarocks/type/manifest.tl
+++ b/src/luarocks/type/manifest.tl
@@ -1,58 +1,71 @@
1local type_manifest = {} 1local record type_manifest
2end
3
4local type Manifest = require("luarocks.core.types.manifest").Manifest
2 5
3local type_check = require("luarocks.type_check") 6local type_check = require("luarocks.type_check")
4 7
5local manifest_formats = type_check.declare_schemas({ 8local manifest_formats = type_check.declare_schemas({
6 ["3.0"] = { 9 ["3.0"] = {
7 repository = { 10 fields = {
8 _mandatory = true, 11 repository = {
9 -- packages 12 _mandatory = true,
10 _any = { 13 -- packages
11 -- versions
12 _any = { 14 _any = {
13 -- items 15 -- versions
14 _any = { 16 _any = {
15 arch = { _type = "string", _mandatory = true }, 17 -- items
16 modules = { _any = { _type = "string" } }, 18 _any = {
17 commands = { _any = { _type = "string" } }, 19 fields = {
18 dependencies = { _any = { _type = "string" } }, 20 arch = { _type = "string", _mandatory = true },
19 -- TODO: to be extended with more metadata. 21 modules = { _any = { _type = "string" } },
22 commands = { _any = { _type = "string" } },
23 dependencies = { _any = { _type = "string" } },
24 -- TODO: to be extended with more metadata.
25 }
26 }
20 } 27 }
21 } 28 }
22 } 29 },
23 }, 30 modules = {
24 modules = { 31 _mandatory = true,
25 _mandatory = true, 32 -- modules
26 -- modules 33 _any = {
27 _any = { 34 -- providers
28 -- providers 35 _any = { _type = "string" }
29 _any = { _type = "string" } 36 }
30 } 37 },
31 }, 38 commands = {
32 commands = { 39 _mandatory = true,
33 _mandatory = true, 40 -- modules
34 -- modules 41 _any = {
35 _any = { 42 -- commands
36 -- commands 43 _any = { _type = "string" }
37 _any = { _type = "string" } 44 }
38 } 45 },
39 }, 46 dependencies = {
40 dependencies = { 47 -- each module
41 -- each module
42 _any = {
43 -- each version
44 _any = { 48 _any = {
45 -- each dependency 49 -- each version
46 _any = { 50 _any = {
47 name = { _type = "string" }, 51 -- each dependency
48 namespace = { _type = "string" }, 52 _any = {
49 constraints = { 53 fields = {
50 _any = { 54 name = { _type = "string" },
51 no_upgrade = { _type = "boolean" }, 55 namespace = { _type = "string" },
52 op = { _type = "string" }, 56 constraints = {
53 version = { 57 _any = {
54 string = { _type = "string" }, 58 fields = {
55 _any = { _type = "number" }, 59 no_upgrade = { _type = "boolean" },
60 op = { _type = "string" },
61 version = {
62 fields = {
63 string = { _type = "string" },
64 },
65 _any = { _type = "number" },
66 }
67 }
68 }
56 } 69 }
57 } 70 }
58 } 71 }
@@ -69,12 +82,11 @@ local manifest_formats = type_check.declare_schemas({
69-- mismatches. 82-- mismatches.
70-- @return boolean or (nil, string): true if type checking 83-- @return boolean or (nil, string): true if type checking
71-- succeeded, or nil and an error message if it failed. 84-- succeeded, or nil and an error message if it failed.
72function type_manifest.check(manifest, globals) 85function type_manifest.check(manifest: Manifest, globals: {string: any}): boolean, string --!
73 assert(type(manifest) == "table")
74 local format = manifest_formats["3.0"] 86 local format = manifest_formats["3.0"]
75 local ok, err = type_check.check_undeclared_globals(globals, format) 87 local ok, err = type_check.check_undeclared_globals(globals, format)
76 if not ok then return nil, err end 88 if not ok then return nil, err end
77 return type_check.type_check_table("3.0", manifest, format, "") 89 return type_check.type_check_table("3.0", manifest as {any: any}, format, "")
78end 90end
79 91
80return type_manifest 92return type_manifest