-
-
Save ibilon/74e5d8ed46cc25b95056 to your computer and use it in GitHub Desktop.
Haxelib API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Haxelib | |
{ | |
public static var rootFolder : String; | |
public static var proxy : Proxy; | |
public static var version : SemVer; | |
public static var libraries : Array<Library>; | |
public static var server : Server; | |
public static var flat : Bool; | |
public static var always : Bool; | |
public static var debug : Bool; | |
public static var never : Bool; | |
public static var global : Bool; | |
public static var cwd : Bool; | |
public static var noTimeout : Bool; | |
public static function resolveLibrary (name:String) : Library; | |
} | |
Server | |
{ | |
public var host : String; | |
public var port : Int; | |
public var subdir : String; | |
public function search( word : String ) : List<{ id : Int, name : String }>; | |
public function infos( project : String ) : ProjectInfos; | |
public function user( name : String ) : UserInfos; | |
public function register( name : String, pass : String, mail : String, fullname : String ) : Bool; | |
public function isNewUser( name : String ) : Bool; | |
public function checkDeveloper( prj : String, user : String ) : Void; | |
public function checkPassword( user : String, pass : String ) : Bool; | |
public function getSubmitId() : String; | |
public function processSubmit( id : String, user : String, pass : String ) : String; | |
public function postInstall( project : String, version : String):Void; | |
} | |
Proxy | |
{ | |
public var host : String; | |
public var port : Int; | |
public var user : String; | |
public var pass : String; | |
} | |
Library | |
{ | |
public var name : String; | |
public var currentVersion : Version; | |
public var versions : Array<Version>; | |
public function getAllVersions (server:Server) : Void; | |
public function resolveVersion (version:SemVer) : Version; | |
public function setCurrentVersion (version:Version) : Void; | |
public function setDevVersion (?path:String) : Void; | |
public function update() : Bool; | |
} | |
Version | |
{ | |
public var version : SemVer; | |
public var dev : Bool; | |
public var manualInstall : Bool; | |
public var provider : Class<DownloadProvider>; | |
public var path : String; | |
public function remove () : Void; | |
} | |
Provider | |
{ | |
public static function resolve (uri:String) : Class<DownloadProvider>; | |
abstract public static function install (uri:String) : Void; | |
} | |
HaxelibProvider extends Provider { } | |
GitProvider extends Provider { } | |
HgProvider extends Provider { } | |
HttpProvider extends Provider { } | |
FileProvider extends Provider { } | |
LocalProvider extends Provider { } | |
HxmlProvider extends Provider { } | |
HaxelibJson | |
{ | |
var name : ProjectName; | |
@:optional var url : String; | |
@:optional var description : String; | |
var license : License; | |
var version : SemVer; | |
@:optional var classPath : String; | |
var releasenote : String; | |
@:requires('Specify at least one contributor' => _.length > 0) | |
var contributors : Array<String>; | |
@:optional var tags : Array<String>; | |
@:optional var dependencies : Dependencies; | |
@:optional var main:String; | |
public static function fromXml (filename:String) : HaxelibJson; | |
public function toString () : String; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function install (args:Array<String) | |
{ | |
for (uri in args) | |
{ | |
var p = Provider.resolve(uri); | |
if (p == null) | |
{ | |
// unrecognized uri | |
} | |
else | |
{ | |
Type.createEmptyInstance(p).install(uri); | |
} | |
} | |
} | |
function upgrade () | |
{ | |
for (library in Haxelib.libraries) | |
{ | |
library.update(); | |
} | |
} | |
function update (name:String) | |
{ | |
var l = Haxelib.resolveLibrary(name); | |
if (l == null) | |
{ | |
// library doesn't exists | |
} | |
else | |
{ | |
l.update(); | |
} | |
} | |
function remove (name:String, ?version:SemVer) | |
{ | |
var l = Haxelib.resolveLibrary(name); | |
if (l == null) | |
{ | |
// library doesn't exists | |
} | |
else | |
{ | |
var v = l.resolveVersion(version); | |
if (v == null) | |
{ | |
// version isn't installed | |
} | |
else | |
{ | |
v.remove(); | |
} | |
} | |
} | |
function list (?filter:String) | |
{ | |
for (library in Haxelib.libraries) | |
{ | |
if (filter == null || match(filter, library.name)) | |
{ | |
print(library.name); | |
for (version in library.versions) | |
{ | |
print(version.version.toString()); | |
} | |
} | |
} | |
} | |
function set (name:String, version:SemVer) | |
{ | |
var l = Haxelib.resolveLibrary(name); | |
if (l == null) | |
{ | |
// library isn't installed, ask to | |
} | |
else | |
{ | |
var v = l.resolveVersion(version); | |
if (v == null) | |
{ | |
// version isn't installed, ask to | |
} | |
else | |
{ | |
l.setCurrentVersion(v); | |
} | |
} | |
} | |
function search (word:String) | |
{ | |
for (library in Haxelib.server.search(word)) | |
{ | |
print(library.name); | |
} | |
} | |
function info (name:String) | |
{ | |
var json = Haxelib.server.getLibInfo(name); | |
print(json.name); | |
... | |
} | |
function user (username:String); | |
{ | |
var u = Haxelib.server.getUserInfo(username); | |
print(u.username); | |
... | |
} | |
function config () | |
{ | |
print(Haxelib.rootFolder); | |
} | |
function path (args:Array<String) | |
{ | |
for (arg in args) | |
{ | |
var name, version = arg.split(":"); | |
var l = Haxelib.resolveLibrary(name); | |
if (l == null) | |
{ | |
// library isn't installed | |
} | |
else | |
{ | |
if (version == null) | |
{ | |
version = l.currentVersion; | |
} | |
var v = l.resolveVersion(version); | |
if (v == null) | |
{ | |
// version isn't installed | |
} | |
else | |
{ | |
print(v.path); | |
... | |
} | |
} | |
} | |
} | |
function version () | |
{ | |
print(Haxelib.version.toString()); | |
} | |
function submit (filename:String) | |
{ | |
} | |
function register (username:String, email:String fullname:String, password:String, passwordConfirm:String) | |
{ | |
if (password != passwordConfirm) | |
{ | |
// both passwords aren't identical | |
} | |
else | |
{ | |
if (Haxelib.server.register(username, email, fullname, password)) | |
{ | |
// ok | |
} | |
else | |
{ | |
// username already taken | |
} | |
} | |
function local (filename:String) | |
{ | |
FileProvider.install(filename); | |
} | |
function dev (name:String, ?path) | |
{ | |
var l = Haxelib.resolveLibrary(name); | |
if (l == null) | |
{ | |
// library wasn't installed before | |
l = new Library(name); | |
} | |
if (sys.FileSystem.exists(path) && sys.FileSystem.isDirectory(path)) | |
{ | |
l.setDevVersion(path); | |
} | |
else | |
{ | |
// wrong info | |
} | |
} | |
function git (name:String, url:String, ?branch:String, ?subDir:String, ?version:String) | |
{ | |
var uri = // make uri | |
GitProvider.install(uri); | |
} | |
function hg (name:String, url:String, ?branch:String, ?subDir:String, ?version:String) | |
{ | |
var uri = // make uri | |
HgProvider.install(uri); | |
} | |
function setup (?path) | |
{ | |
if (path == null) | |
{ | |
path = ask("Path [/usr/lib/haxe/lib]"); | |
if (path == ""); | |
{ | |
path = // default value | |
} | |
} | |
Haxelib.rootFolder = path; | |
} | |
function newrepo () { } | |
function deleterepo () { } | |
function selfupdate () | |
{ | |
var l = Haxelib.resolveLibrary("haxelib_client"); | |
l.update(); | |
} | |
function convertxml () | |
{ | |
if (sys.FileSystem.exists("haxelib.xml")) | |
{ | |
var hj = HaxelibJson.fromXml(sys.io.File.getContent("haxelib.xml")); | |
sys.io.File.saveContent("haxelib.json", hj.toString()); | |
} | |
} | |
function run (name:String, ?version:SemVer) | |
{ | |
var l = Haxelib.resolveLibrary(name); | |
if (l == null) | |
{ | |
// library is not installed | |
} | |
else | |
{ | |
if (version == null) | |
{ | |
version = l.currentVersion; | |
} | |
var v = l.resolveVersion(version); | |
if (sys.FileSystem.exists(v.path + "run.n")) | |
{ | |
Sys.command("neko", [v.path + "run.n" // and other args | |
} | |
else | |
{ | |
// lib has no run script | |
} | |
} | |
} | |
function proxy (?host:String, ?port:String, ?username:String, ?password:String) | |
{ | |
if (host == null) | |
{ | |
Haxelib.proxy = null; | |
} | |
else | |
{ | |
Haxelib.proxy = new Proxy(host, port, username, password); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment