mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-08 09:05:46 +00:00
Add docs, turn args and buildessentials non classes into classes
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
/^ Entrypoint used only when building the shell ^/
|
||||
func main(args)
|
||||
{
|
||||
var pm = Tesses.CrossLang.PackageManager();
|
||||
//pm.Offline=true;
|
||||
//Console.WriteLine(pm.GetLatest("MyPackage"));
|
||||
//Console.WriteLine(Json.Encode(pm.ParseFileName("BeautifulApp-John-1.0.0.0-prod.crvm")));
|
||||
|
||||
var tool = Tesses.CrossLang.BuildTool(pm);
|
||||
tool.BuildProject(args[1]);
|
||||
var pm = new Tesses.CrossLang.PackageManager();
|
||||
|
||||
var tool = new Tesses.CrossLang.BuildTool(pm);
|
||||
tool.BuildProject(args[1]);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,21 @@
|
||||
func Tesses.CrossLang.PackageManager()
|
||||
/^ The CrossLang Package Manager Client ^/
|
||||
class Tesses.CrossLang.PackageManager
|
||||
{
|
||||
func ParseFileName(name)
|
||||
private configRoot;
|
||||
private packageCache;
|
||||
/^ Work offline (defaults to false) ^/
|
||||
public Offline = false;
|
||||
|
||||
/^ Construct the Package Manager ^/
|
||||
public PackageManager()
|
||||
{
|
||||
this.configRoot = Env.CrossLangConfig;
|
||||
this.packageCache = configRoot / "PackageCache";
|
||||
|
||||
FS.Local.CreateDirectory(packageCache);
|
||||
}
|
||||
/^ Parse package filename ^/
|
||||
public ParseFileName(name)
|
||||
{
|
||||
|
||||
var index = name.LastIndexOf('.');
|
||||
@@ -28,26 +43,21 @@ func Tesses.CrossLang.PackageManager()
|
||||
};
|
||||
}
|
||||
}
|
||||
var configRoot = Env.CrossLangConfig;
|
||||
var packageCache = configRoot / "PackageCache";
|
||||
FS.Local.CreateDirectory(packageCache);
|
||||
|
||||
return {
|
||||
Offline = false,
|
||||
ParseFileName,
|
||||
GetPackageServers = ()=>{
|
||||
var packageConfigFile = configRoot / "package_servers.json";
|
||||
/^ Get package servers list ^/
|
||||
public GetPackageServers()
|
||||
{
|
||||
var packageConfigFile = configRoot / "package_servers.json";
|
||||
|
||||
if(FS.Local.RegularFileExists(packageConfigFile))
|
||||
{
|
||||
return Json.Decode(FS.ReadAllText(FS.Local, packageConfigFile));
|
||||
}
|
||||
return ["https://cpkg.tesseslanguage.com/"];
|
||||
},
|
||||
GetPackage = (this,name, version) =>
|
||||
if(FS.Local.RegularFileExists(packageConfigFile))
|
||||
{
|
||||
|
||||
var v = Version.Parse(version);
|
||||
return Json.Decode(FS.ReadAllText(FS.Local, packageConfigFile));
|
||||
}
|
||||
return ["https://cpkg.tesseslanguage.com/"];
|
||||
}
|
||||
/^ Get a package (returns bytearray of package data or null if not found), use GetLatest to get the latest version ^/
|
||||
public GetPackage(name, version)
|
||||
{
|
||||
var v = Version.Parse(version);
|
||||
var useCache = v.Stage != "dev";
|
||||
var pkgFile = packageCache / name / v.ToString();
|
||||
if(useCache && FS.Local.RegularFileExists(pkgFile))
|
||||
@@ -81,9 +91,11 @@ func Tesses.CrossLang.PackageManager()
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
GetLatest = (this,name) => {
|
||||
var pkgServers = this.GetPackageServers();
|
||||
}
|
||||
/^ Get the latest version of a package ^/
|
||||
public GetLatest(name)
|
||||
{
|
||||
var pkgServers = this.GetPackageServers();
|
||||
if(this.Offline || pkgServers.Count == 0)
|
||||
{
|
||||
//user has declared they are offline or don't have packageServers look through packages locally
|
||||
@@ -121,6 +133,6 @@ func Tesses.CrossLang.PackageManager()
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
func Tesses.CrossLang.BuildTool(pm)
|
||||
/^ The CrossLang BuildTool (use the function BuildProject) ^/
|
||||
class Tesses.CrossLang.BuildTool
|
||||
{
|
||||
func copyFile(src,dest)
|
||||
/^ Construct the build tool with Package Manager ^/
|
||||
public BuildTool(pm)
|
||||
{
|
||||
this.PacakgeManager = pm;
|
||||
}
|
||||
|
||||
private copyFile(src,dest)
|
||||
{
|
||||
var src = FS.Local.OpenFile(src,"rb");
|
||||
var dest = FS.Local.OpenFile(dest, "wb");
|
||||
@@ -8,11 +15,14 @@ func Tesses.CrossLang.BuildTool(pm)
|
||||
src.Close();
|
||||
dest.Close();
|
||||
}
|
||||
|
||||
return {
|
||||
DirectoriesCompiled = [],
|
||||
GetPackageDependencies = (this,name,version,dir)=>{
|
||||
var dep = pm.GetPackage(name,version);
|
||||
/^ Package Manager Object ^/
|
||||
public PackageManager;
|
||||
/^ Directories compiled ^/
|
||||
public DirectoriesCompiled = [];
|
||||
/^ Get the dependencies (don't use this directly unless you know what you are doing) ^/
|
||||
public GetPackageDependencies(name, version, dir)
|
||||
{
|
||||
var dep = PackageManager.GetPackage(name,version);
|
||||
if(TypeOf(dep) == "Null") throw $"Package {name} with version {version} does not exist";
|
||||
|
||||
var pkgPath = dir / $"{name}-{version}.crvm";
|
||||
@@ -45,9 +55,11 @@ func Tesses.CrossLang.BuildTool(pm)
|
||||
Dependencies = deps,
|
||||
Output = pkgPath
|
||||
};
|
||||
},
|
||||
BuildProject = (this,projectDirectory)=>{
|
||||
var dir = FS.MakeFull(projectDirectory);
|
||||
}
|
||||
/^ Build the project in the directory projectDirectory ^/
|
||||
public BuildProject(projectDirectory)
|
||||
{
|
||||
var dir = FS.MakeFull(projectDirectory);
|
||||
var dirStr = dir.ToString();
|
||||
|
||||
|
||||
@@ -366,6 +378,7 @@ func Tesses.CrossLang.BuildTool(pm)
|
||||
return myData;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/^ Get the name and description from executable ^/
|
||||
func Tesses.CrossLang.GetNameAndDescription(name)
|
||||
{
|
||||
var strm = FS.Local.OpenFile(name,"rb");
|
||||
@@ -15,6 +16,7 @@ func Tesses.CrossLang.GetNameAndDescription(name)
|
||||
|
||||
return $"{name}: {description}";
|
||||
}
|
||||
/^ Get the name and description from executable (as json object) ^/
|
||||
func Tesses.CrossLang.GetNameAndDescriptionJson(name)
|
||||
{
|
||||
var strm = FS.Local.OpenFile(name,"rb");
|
||||
|
||||
Reference in New Issue
Block a user