Merge branch 'master' of git://github.com/nim-lang/packages

Conflicts:
	packages.json
This commit is contained in:
Araq 2015-06-21 14:43:27 +02:00
commit 3c75d95d9a
4 changed files with 1185 additions and 78 deletions

23
.travis.yml Normal file
View File

@ -0,0 +1,23 @@
os:
- linux
language: c
install:
- |
wget http://nim-lang.org/download/nim-0.11.2.tar.xz
tar xf nim-0.11.2.tar.xz
cd nim-0.11.2
sh build.sh
cd ..
before_script:
- set -e
- set -x
- export PATH=`pwd`/nim-0.11.2/bin:$PATH
script:
- nim c -d:ssl -r package_scanner.nim
notifications:
email: false # noisy

View File

@ -1,8 +1,8 @@
# Nimrod packages
# Nim packages [![Build Status](https://travis-ci.org/nim-lang/packages.svg?branch=master)](https://travis-ci.org/nim-lang/packages)
This is a central listing of all packages for
[babel](https://github.com/nimrod-code/babel), a package manager for the
[Nimrod programming language](http://nimrod-lang.org).
[Nimble](https://github.com/nim-lang/nimble), a package manager for the
[Nim programming language](http://nim-lang.org).
## Adding your own package
To add your own package, fork this repository, edit
@ -11,9 +11,9 @@ To add your own package, fork this repository, edit
[Packages.json](packages.json) is a simple array of objects. Each package
object should have the following fields (unless the field is marked as
optional):
* name - The name of the package, this should match the name in the package's
babel file.
nimble file.
* url - The url from which to retrieve the package.
* method - The method that should be used to retrieve this package. Currently
"git" and "hg" is supported.
@ -26,4 +26,4 @@ optional):
Your packages may be removed if the url stops working. It goes without saying
that your pull request will not be accepted unless you fill out all of the
above required fields correctly, the package that ``url`` points to must also
contain a babel file, or else it will be rejected.
contain a .nimble file, or else it will be rejected.

121
package_scanner.nim Normal file
View File

@ -0,0 +1,121 @@
# A very simple Nim package scanner.
#
# Scans the package list from this repository.
#
# Check the packages for:
# * Missing name
# * Missing/unknown method
# * Missing/unreachable repository
# * Missing tags
# * Missing description
# * Missing/unknown license
#
# Usage: nim c -d:ssl -r package_scanner.nim
#
# Copyright 2015 Federico Ceratto <federico.ceratto@gmail.com>
# Released under GPLv3 License, see /usr/share/common-licenses/GPL-3
import httpclient
import net
import json
import os
const
LICENSES = @[
"Allegro 4 Giftware",
"BSD",
"BSD3",
"CC0",
"GPL",
"GPLv2",
"GPLv3",
"LGPLv2",
"LGPLv3",
"MIT",
"MS-PL",
"WTFPL",
"libpng",
"zlib"
]
VCS_TYPES = @["git", "hg"]
proc canFetchNimbleRepository(name: string, urlJson: JsonNode): bool =
# The fetch is a lie!
# TODO: Make this check the actual repo url and check if there is a
# nimble file in it
result = true
var url: string
if not urlJson.isNil:
url = urlJson.str
try:
discard getContent(url, timeout=1000)
except HttpRequestError, TimeoutError:
echo "E: ", name, ": unable to fetch repository ", url, " ",
getCurrentExceptionMsg()
result = false
except AssertionError:
echo "W: ", name, ": httpclient failed ", url, " ",
getCurrentExceptionMsg()
proc check(): int =
var
name: string
echo ""
let
pkg_list = parseJson(readFile(getCurrentDir() / "packages.json"))
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()
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.hasKey("url"):
echo "E: ", name, " has no URL"
result.inc()
elif not canFetchNimbleRepository(name, pdata["web"]):
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("license"):
echo "E: ", name, " has no license"
result.inc()
else:
# Other warnings should go here
if not (pdata["license"].str in LICENSES):
echo "W: ", name, " has an unexpected license: ", pdata["license"]
echo ""
echo "Problematic packages count: ", result
when isMainModule:
quit(check())

File diff suppressed because it is too large Load Diff