aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@gmail.com>2017-07-11 00:02:17 +0100
committerDominik Picheta <dominikpicheta@gmail.com>2017-07-11 00:02:17 +0100
commite7ca6b455666b6c1a0082ef93e5525e834eea49b (patch)
treeac346296bc29255f939c2d2b03fa88d443d4e0ba
parent31390d2009ae2040b654d04aad82a56eaa411c46 (diff)
downloadpackages-e7ca6b455666b6c1a0082ef93e5525e834eea49b.tar.gz
packages-e7ca6b455666b6c1a0082ef93e5525e834eea49b.zip
Add support for aliases to package scanner.
-rw-r--r--package_scanner.nim69
1 files changed, 39 insertions, 30 deletions
diff --git a/package_scanner.nim b/package_scanner.nim
index 7d16e0b..828bcc9 100644
--- a/package_scanner.nim
+++ b/package_scanner.nim
@@ -73,6 +73,12 @@ proc canFetchNimbleRepository(name: string, urlJson: JsonNode): bool =
echo "W: Another error attempting to request: ", url
echo " Error was: ", getCurrentExceptionMsg()
+proc verifyAlias(pdata: JsonNode, result: var int) =
+ if not pdata.hasKey("name"):
+ echo "E: missing alias' package name"
+ result.inc()
+
+ # TODO: Verify that 'alias' points to a known package.
proc check(): int =
var
@@ -88,45 +94,48 @@ proc check(): int =
for pdata in pkg_list:
name = if pdata.hasKey("name"): pdata["name"].str else: nil
- if name.isNil:
- echo "E: missing package name"
- result.inc()
+ if pdata.hasKey("alias"):
+ verifyAlias(pdata, result)
+ else:
+ if name.isNil:
+ echo "E: missing package name"
+ result.inc()
- elif not pdata.hasKey("method"):
- echo "E: ", name, " has no method"
- result.inc()
+ elif not pdata.hasKey("method"):
+ echo "E: ", name, " has no method"
+ result.inc()
- elif not (pdata["method"].str in VCS_TYPES):
- echo "E: ", name, " has an unknown method: ", pdata["method"].str
- result.inc()
+ elif not (pdata["method"].str in VCS_TYPES):
+ echo "E: ", name, " has an unknown method: ", pdata["method"].str
+ result.inc()
- elif not pdata.hasKey("url"):
- echo "E: ", name, " has no URL"
- result.inc()
+ elif not pdata.hasKey("url"):
+ echo "E: ", name, " has no URL"
+ result.inc()
- elif pdata.hasKey("web") and not canFetchNimbleRepository(name, pdata["web"]):
- result.inc()
+ elif pdata.hasKey("web") and not canFetchNimbleRepository(name, pdata["web"]):
+ result.inc()
- elif not pdata.hasKey("tags"):
- echo "E: ", name, " has no tags"
- result.inc()
+ elif not pdata.hasKey("tags"):
+ echo "E: ", name, " has no tags"
+ result.inc()
- elif not pdata.hasKey("description"):
- echo "E: ", name, " has no description"
- result.inc()
+ elif not pdata.hasKey("description"):
+ echo "E: ", name, " has no description"
+ result.inc()
- elif not pdata.hasKey("license"):
- echo "E: ", name, " has no license"
- result.inc()
+ elif not pdata.hasKey("license"):
+ echo "E: ", name, " has no license"
+ result.inc()
- elif pdata["url"].str.normalize.startsWith("git://github.com/"):
- echo "E: ", name, " has an insecure git:// URL instead of https://"
- result.inc()
+ elif pdata["url"].str.normalize.startsWith("git://github.com/"):
+ echo "E: ", name, " has an insecure git:// URL instead of https://"
+ result.inc()
- else:
- # Other warnings should go here
- if not (pdata["license"].str in LICENSES):
- echo "W: ", name, " has an unexpected license: ", pdata["license"]
+ else:
+ # Other warnings should go here
+ if not (pdata["license"].str in LICENSES):
+ echo "W: ", name, " has an unexpected license: ", pdata["license"]
if name.normalize notin names:
names.incl(name.normalize)