Get more done on packageserver

This commit is contained in:
2025-07-12 03:33:37 -05:00
parent 3ccb517aed
commit 35960d5db0
15 changed files with 441 additions and 78 deletions

View File

@@ -15,6 +15,7 @@ func main(args)
else if(commandName == "build")
{
var offline=false;
var allowFullCompTime=false;
var buildPath = ".";
if(dd.Arguments.Count > 1)
{
@@ -26,12 +27,17 @@ func main(args)
{
offline = true;
}
if(flag == "allow-insecure-comptime")
{
allowFullCompTime=true;
}
if(flag == "help")
{
Console.WriteLine("USAGE: crosslang build [build-flags-and-options]");
Console.WriteLine("FLAGS:");
Console.WriteLine("offline: build with no internet (don't fetch files)");
Console.WriteLine("help: this help");
Console.WriteLine("offline: build with no internet (don't fetch files)");
Console.WriteLine("help: this help");
Console.WriteLine("allow-insecure-comptime: Allow full comptime");
Console.WriteLine();
Console.WriteLine("OPTIONS:");
Console.WriteLine("conf=CONFIGSTRING: specify a conf string for compile_tool(s), is the property Config");
@@ -50,6 +56,7 @@ func main(args)
pm.Offline = offline;
var bt = Tesses.CrossLang.BuildTool(pm);
bt.Config = conf;
bt.AllowFullCompTime = allowFullCompTime;
bt.BuildProject(buildPath);
}
else if(commandName == "run")
@@ -57,6 +64,7 @@ func main(args)
var offline=false;
var buildPath = ".";
var nobuild=false;
var allowFullCompTime=false;
var output="";
each(var flag : dd.Flags)
{
@@ -64,14 +72,19 @@ func main(args)
{
offline = true;
}
else if(flag == "allow-insecure-comptime")
{
allowFullCompTime=true;
}
else if(flag == "help")
{
Console.WriteLine("USAGE: crosslang run [run-flags-and-options] program-arguments...");
Console.WriteLine("USAGE: crosslang run [run-flags-and-options] -- program-arguments-and-options...");
Console.WriteLine("FLAGS:");
Console.WriteLine("offline: build with no internet (don't fetch files)");
Console.WriteLine("help: this help");
Console.WriteLine("nobuild: don't build, just run");
Console.WriteLine("offline: build with no internet (don't fetch files)");
Console.WriteLine("allow-insecure-comptime: Allow full comptime");
Console.WriteLine("nobuild: don't build, just run");
Console.WriteLine("help: this help");
Console.WriteLine();
Console.WriteLine("OPTIONS:");
Console.WriteLine("conf=CONFIGSTRING: specify a conf string for compile_tool(s), is the property Config");
@@ -116,6 +129,7 @@ func main(args)
pm.Offline = offline;
var bt = Tesses.CrossLang.BuildTool(pm);
bt.Config = conf;
bt.AllowFullCompTime = allowFullCompTime;
output = bt.BuildProject(buildPath).Output;
}
var env = VM.CreateEnvironment({});
@@ -465,7 +479,7 @@ func main(args)
}
else if(commandName == "install-console")
{
//crosslang install-console
//crosslang install-console ConsoleApp --version=1.0.0.0-prod [--outdir=DIR]
}
else if(commandName == "install-app")
{
@@ -606,6 +620,10 @@ func main(args)
{
//crosslang console myfavoriteapp
}
else if(commandName == "app")
{
Tesses.CrossLang.Shell.App(dd);
}
else if(commandName == "tool")
{
@@ -750,13 +768,141 @@ func main(args)
}
else if(commandName == "upload-package")
{
//crosslang upload-package [PACKAGE_NAME]
//crosslang upload-package [--host=HOST --token=TOKEN] [--session=NAME] [PACKAGE_FILE]
var host=null;
var token=null;
var session=null;
var package=null;
var nobuild=false;
each(var option : dd.Options)
{
if(option.Key == "host")
{
host = option.Value;
}
if(option.Key == "token")
{
token = option.Value;
}
if(option.Key == "session")
{
session = option.Value;
}
}
if(dd.Arguments.Length > 1)
{
package = dd.Arguments[1];
}
else {
if(nobuild)
{
throw {Type="NotImplementedException", Message="nobuild on upload-package is not implemented",ToString=(this)=>$"{this.Type} on line: {this.Line}: {this.Message}"};
}
else {
var pm = Tesses.CrossLang.PackageManager();
pm.Offline = false;
var bt = Tesses.CrossLang.BuildTool(pm);
bt.Config = "";
bt.AllowFullCompTime = false;
package = bt.BuildProject(".").Output;
}
}
if(TypeOf(host) != "String" || TypeOf(token) != "String")
{
if(FS.Local.FileExists(Env.CrossLangConfig / "auth.json"))
{
var json = Json.Decode(FS.ReadAllText(FS.Local,Env.CrossLangConfig / "auth.json"));
if(json.Length == 0)
{
Console.WriteLine("The auth.json file is empty, use crosslang login to login");
return 1;
}
else if(json.Length == 1)
{
host = json[0].host;
token = json[0].token;
}
else {
if(TypeOf(session) != "String")
{
Console.WriteLine("Multiple entries in auth.json file, session is ambiguous.");
Console.WriteLine("Sessions:");
each(var item : json)
{
Console.WriteLine($"{item.name}: {item.host}");
}
return 1;
}
else {
var found=false;
each(var item : json)
{
if(item.name == session)
{
found=true;
host = item.host;
token = item.token;
break;
}
}
if(!found) {
Console.WriteLine($"Could not find session with name: {session}");
return 1;
}
}
}
}
else { Console.WriteLine("No auth.json file, use crosslang login to login"); return 1;}
}
if(TypeOf(host) != "String" || TypeOf(token) != "String")
{
Console.WriteLine("You are not logged in, use crosslang login to login");
return 1;
}
var strm = FS.Local.OpenFile(package,"rb");
if(strm == null)
{
Console.WriteLine("Could not open file");
return 1;
}
var req = {
Method="PUT",
RequestHeaders = [
{Key= "Authorization",Value=$"Bearer {token}"}
],
Body = Net.Http.StreamHttpRequestBody(strm,"application/crvm")
};
var http = Net.Http.MakeRequest($"{host.TrimEnd('/')}/api/v1/upload",req);
if(http.StatusCode == 204)
{
Console.WriteLine("Uploaded package successfully");
}
else if(http.ResponseHeaders.TryGetFirst("Content-Type") == "application/json")
{
var json = Json.Decode(http.ReadAsString());
Console.WriteLine($"Failed to upload package, {json.reason.TrimEnd('.')}.");
}
else {
Console.WriteLine($"Failed to upload package.");
}
strm.Close();
}
else if(commandName == "login")
{
//crosslang login local https://cpkg.tesseslanguage.com/
//crosslang login [NAME] [HOST] [TOKEN]
}
else if(commandName == "configdir")
{
Console.WriteLine(Env.CrossLangConfig);
}
}
else
{