parent
fc4a1761a5
commit
79a4452e1d
1 changed files with 4 additions and 20 deletions
|
|
@ -25,7 +25,6 @@ import sets
|
||||||
import strutils
|
import strutils
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
||||||
LICENSES = @[
|
LICENSES = @[
|
||||||
"Allegro 4 Giftware",
|
"Allegro 4 Giftware",
|
||||||
"Apache License 2.0",
|
"Apache License 2.0",
|
||||||
|
|
@ -47,7 +46,6 @@ const
|
||||||
"ISC",
|
"ISC",
|
||||||
"Unlicense"
|
"Unlicense"
|
||||||
]
|
]
|
||||||
|
|
||||||
VCS_TYPES = @["git", "hg"]
|
VCS_TYPES = @["git", "hg"]
|
||||||
|
|
||||||
proc canFetchNimbleRepository(name: string, urlJson: JsonNode): bool =
|
proc canFetchNimbleRepository(name: string, urlJson: JsonNode): bool =
|
||||||
|
|
@ -80,57 +78,43 @@ proc verifyAlias(pdata: JsonNode, result: var int) =
|
||||||
# TODO: Verify that 'alias' points to a known package.
|
# TODO: Verify that 'alias' points to a known package.
|
||||||
|
|
||||||
proc check(): int =
|
proc check(): int =
|
||||||
var
|
var name: string
|
||||||
name: string
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
let pkg_list = parseJson(readFile(getCurrentDir() / "packages.json"))
|
||||||
let
|
|
||||||
pkg_list = parseJson(readFile(getCurrentDir() / "packages.json"))
|
|
||||||
|
|
||||||
var names = initSet[string]()
|
var names = initSet[string]()
|
||||||
|
|
||||||
for pdata in pkg_list:
|
for pdata in pkg_list:
|
||||||
name = if pdata.hasKey("name"): pdata["name"].str else: nil
|
name = if pdata.hasKey("name"): pdata["name"].str else: ""
|
||||||
|
|
||||||
if pdata.hasKey("alias"):
|
if pdata.hasKey("alias"):
|
||||||
verifyAlias(pdata, result)
|
verifyAlias(pdata, result)
|
||||||
else:
|
else:
|
||||||
if name.isNil:
|
if name == "":
|
||||||
echo "E: missing package name"
|
echo "E: missing package name"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif not pdata.hasKey("method"):
|
elif not pdata.hasKey("method"):
|
||||||
echo "E: ", name, " has no method"
|
echo "E: ", name, " has no method"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif not (pdata["method"].str in VCS_TYPES):
|
elif not (pdata["method"].str in VCS_TYPES):
|
||||||
echo "E: ", name, " has an unknown method: ", pdata["method"].str
|
echo "E: ", name, " has an unknown method: ", pdata["method"].str
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif not pdata.hasKey("url"):
|
elif not pdata.hasKey("url"):
|
||||||
echo "E: ", name, " has no URL"
|
echo "E: ", name, " has no URL"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif pdata.hasKey("web") and not canFetchNimbleRepository(name, pdata["web"]):
|
elif pdata.hasKey("web") and not canFetchNimbleRepository(name, pdata["web"]):
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif not pdata.hasKey("tags"):
|
elif not pdata.hasKey("tags"):
|
||||||
echo "E: ", name, " has no tags"
|
echo "E: ", name, " has no tags"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif not pdata.hasKey("description"):
|
elif not pdata.hasKey("description"):
|
||||||
echo "E: ", name, " has no description"
|
echo "E: ", name, " has no description"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif not pdata.hasKey("license"):
|
elif not pdata.hasKey("license"):
|
||||||
echo "E: ", name, " has no license"
|
echo "E: ", name, " has no license"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
elif pdata["url"].str.normalize.startsWith("git://github.com/"):
|
elif pdata["url"].str.normalize.startsWith("git://github.com/"):
|
||||||
echo "E: ", name, " has an insecure git:// URL instead of https://"
|
echo "E: ", name, " has an insecure git:// URL instead of https://"
|
||||||
result.inc()
|
result.inc()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Other warnings should go here
|
# Other warnings should go here
|
||||||
if not (pdata["license"].str in LICENSES):
|
if not (pdata["license"].str in LICENSES):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue