mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-08 17:15:45 +00:00
Finish CLI
This commit is contained in:
@@ -7,11 +7,11 @@
|
|||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"template_name": "compiletool",
|
"short_name": "compiletool",
|
||||||
"template_info": {
|
"template_info": {
|
||||||
"type": "compile_tool"
|
"type": "compile_tool"
|
||||||
},
|
},
|
||||||
"template_name_pretty": "Compile Tool",
|
"short_name_pretty": "Compile Tool",
|
||||||
"template_ignored_files": ["bin","obj"],
|
"template_ignored_files": ["bin","obj"],
|
||||||
"description": "A tool that can be a dependency to a project (including libraries) that runs at compile time"
|
"description": "A tool that can be a dependency to a project (including libraries) that runs at compile time"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,14 @@
|
|||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"template_name": "console",
|
"short_name": "console",
|
||||||
"template_info": {
|
"template_info": {
|
||||||
"type": "console"
|
"type": "console",
|
||||||
|
"short_name": "changeme",
|
||||||
|
"short_name_pretty": "Change Me",
|
||||||
|
"description": "Change Me"
|
||||||
},
|
},
|
||||||
"template_name_pretty": "Console Application",
|
"short_name_pretty": "Console Application",
|
||||||
"template_ignored_files": ["bin","obj"],
|
"template_ignored_files": ["bin","obj"],
|
||||||
"description": "A console application"
|
"description": "A console application"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"template_name": "emptyweb",
|
"short_name": "emptyweb",
|
||||||
"description": "An empty website",
|
"description": "An empty website",
|
||||||
"template_info": {
|
"template_info": {
|
||||||
"type": "console"
|
"type": "console"
|
||||||
},
|
},
|
||||||
"template_name_pretty": "Empty Website",
|
"short_name_pretty": "Empty Website",
|
||||||
"template_extra_text_ftles": [],
|
"template_extra_text_ftles": [],
|
||||||
"template_ignored_files": ["bin","obj"]
|
"template_ignored_files": ["bin","obj"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"template_name": "lib",
|
"short_name": "lib",
|
||||||
"template_info": {
|
"template_info": {
|
||||||
"type": "lib"
|
"type": "lib"
|
||||||
},
|
},
|
||||||
"template_ignored_files": ["bin","obj"],
|
"template_ignored_files": ["bin","obj"],
|
||||||
"description": "A crosslang library",
|
"description": "A crosslang library",
|
||||||
"template_name_pretty": "Library"
|
"short_name_pretty": "Library"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,12 @@
|
|||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"template_name": "template",
|
"short_name": "template",
|
||||||
"description": "A template for a project",
|
"description": "A template for a project",
|
||||||
"template_info": {
|
"template_info": {
|
||||||
"type": "template",
|
"type": "template",
|
||||||
"template_name": "mytemplate",
|
"short_name": "mytemplate",
|
||||||
|
"short_name_pretty": "My Template",
|
||||||
"template_project_dependencies": [],
|
"template_project_dependencies": [],
|
||||||
"template_extra_text_ftles": [],
|
"template_extra_text_ftles": [],
|
||||||
"template_info": {
|
"template_info": {
|
||||||
@@ -22,6 +23,6 @@
|
|||||||
"template_project_dependencies": [],
|
"template_project_dependencies": [],
|
||||||
"template_extra_text_ftles": [],
|
"template_extra_text_ftles": [],
|
||||||
"template_ignored_files": ["bin","obj"],
|
"template_ignored_files": ["bin","obj"],
|
||||||
"template_name_pretty": "Template"
|
"short_name_pretty": "Template"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,18 +8,19 @@
|
|||||||
"template_info": {
|
"template_info": {
|
||||||
"type": "tool",
|
"type": "tool",
|
||||||
"description": "This is my tool",
|
"description": "This is my tool",
|
||||||
"toolname": "changeme"
|
"short_name": "changeme",
|
||||||
|
"short_name_pretty": "Change Me"
|
||||||
},
|
},
|
||||||
"template_extra_text_ftles": [],
|
"template_extra_text_ftles": [],
|
||||||
"template_project_dependencies": [],
|
"template_project_dependencies": [],
|
||||||
"template_name": "tool",
|
"short_name": "tool",
|
||||||
"description": "A crosslang tool that you can run via crosslang tool",
|
"description": "A crosslang tool that you can run via crosslang tool",
|
||||||
"type": "template",
|
"type": "template",
|
||||||
"maintainer": "Mike Nolan",
|
"maintainer": "Mike Nolan",
|
||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"template_name_pretty": "Tool"
|
"short_name_pretty": "Tool"
|
||||||
},
|
},
|
||||||
"version": "1.0.0.0-prod",
|
"version": "1.0.0.0-prod",
|
||||||
"name": "Tesses.CrossLang.Template.Tool"
|
"name": "Tesses.CrossLang.Template.Tool"
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"template_name": "web",
|
"short_name": "web",
|
||||||
"description": "A Simple.CSS Website with my template engine",
|
"description": "A Simple.CSS Website with my template engine",
|
||||||
"template_info": {
|
"template_info": {
|
||||||
"type": "console"
|
"type": "console"
|
||||||
},
|
},
|
||||||
"template_ignored_files": ["bin","obj"],
|
"template_ignored_files": ["bin","obj"],
|
||||||
"template_name_pretty": "WebSite"
|
"short_name_pretty": "WebSite"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "webapp",
|
"type": "webapp",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"template_name": "webapp",
|
"short_name": "webapp",
|
||||||
"template_name_pretty": "Web Application",
|
"short_name_pretty": "Web Application",
|
||||||
"template_project_dependencies": [
|
"template_project_dependencies": [
|
||||||
],
|
],
|
||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
|
|||||||
@@ -10,3 +10,7 @@ func WebAppMain(args)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
func main(args)
|
||||||
|
{
|
||||||
|
Console.WriteLine("use crosslang webapp-test to test");
|
||||||
|
}
|
||||||
@@ -10,10 +10,8 @@ func Tesses.CrossLang.GetNameAndDescription(name)
|
|||||||
var j = Json.Decode(file.Info);
|
var j = Json.Decode(file.Info);
|
||||||
var description = TypeOf(j.description) == "String" ? j.description : "";
|
var description = TypeOf(j.description) == "String" ? j.description : "";
|
||||||
|
|
||||||
if(j.type == "template")
|
name = TypeOf(j.short_name) == "String" ? j.short_name : name;
|
||||||
name = TypeOf(j.template_name) == "String" ? j.template_name : name;
|
|
||||||
else if(j.type == "tool")
|
|
||||||
name = TypeOf(j.toolname) == "String" ? j.toolname : name;
|
|
||||||
|
|
||||||
return $"{name}: {description}";
|
return $"{name}: {description}";
|
||||||
}
|
}
|
||||||
@@ -29,10 +27,8 @@ func Tesses.CrossLang.GetNameAndDescriptionJson(name)
|
|||||||
var j = Json.Decode(file.Info);
|
var j = Json.Decode(file.Info);
|
||||||
var description = TypeOf(j.description) == "String" ? j.description : "";
|
var description = TypeOf(j.description) == "String" ? j.description : "";
|
||||||
|
|
||||||
if(j.type == "template")
|
|
||||||
name = TypeOf(j.template_name) == "String" ? j.template_name : name;
|
name = TypeOf(j.short_name) == "String" ? j.short_name : name;
|
||||||
else if(j.type == "tool")
|
|
||||||
name = TypeOf(j.toolname) == "String" ? j.toolname : name;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ func Pages.Package(ctx,name)
|
|||||||
case "console":
|
case "console":
|
||||||
installCmd = $"crosslang install-console {name} --version={package[0].version}";
|
installCmd = $"crosslang install-console {name} --version={package[0].version}";
|
||||||
break;
|
break;
|
||||||
case "app":
|
case "webapp":
|
||||||
installCmd = $"crosslang install-app {name} --version={package[0].version}";
|
installCmd = $"crosslang install-webapp {name} --version={package[0].version}";
|
||||||
break;
|
break;
|
||||||
case "tool":
|
case "tool":
|
||||||
installCmd = $"crosslang install-tool {name} --version={package[0].version}";
|
installCmd = $"crosslang install-tool {name} --version={package[0].version}";
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "Tesses.CrossLang.Shell",
|
"name": "Tesses.CrossLang.Shell",
|
||||||
"version": "1.0.0.0-prod",
|
"version": "1.0.0.0-prod",
|
||||||
"info": {
|
"dependencies": [],
|
||||||
"maintainer": "Mike Nolan",
|
"info": {
|
||||||
"type": "console",
|
"maintainer": "Mike Nolan",
|
||||||
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
"type": "console",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"license": "LGPLv3"
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
},
|
"license": "LGPLv3"
|
||||||
"project_dependencies": [
|
},
|
||||||
"../Tesses.CrossLang.BuildEssentials",
|
"project_dependencies": [
|
||||||
"../Tesses.CrossLang.Args"
|
"../Tesses.CrossLang.BuildEssentials",
|
||||||
]
|
"../Tesses.CrossLang.Args"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
41
Tesses.CrossLang.Shell/src/console.tcross
Normal file
41
Tesses.CrossLang.Shell/src/console.tcross
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
func Tesses.CrossLang.Shell.Console(dd)
|
||||||
|
{
|
||||||
|
var dir = Env.CrossLangConfig / "ConsoleApps";
|
||||||
|
if(dd.Arguments.Length == 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine("List of console applications:");
|
||||||
|
if(FS.Local.DirectoryExists(dir))
|
||||||
|
each(var item : FS.Local.EnumeratePaths(dir))
|
||||||
|
{
|
||||||
|
Console.WriteLine(Tesses.CrossLang.GetNameAndDescription(item / item.GetFileName() + ".crvm"));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(dd.Arguments.Length >= 2)
|
||||||
|
{
|
||||||
|
var consolename = dd.Arguments[1];
|
||||||
|
var consolepath = dir / consolename / consolename + ".crvm";
|
||||||
|
|
||||||
|
if(FS.Local.FileExists(consolepath))
|
||||||
|
{
|
||||||
|
|
||||||
|
var env = VM.CreateEnvironment({});
|
||||||
|
env.RegisterEverything();
|
||||||
|
env.LockRegister();
|
||||||
|
|
||||||
|
env.LoadFileWithDependencies(FS.Local,consolepath);
|
||||||
|
var myArgs = [];
|
||||||
|
myArgs.Add(consolepath.ToString());
|
||||||
|
for(var i = 2; i < dd.Arguments.Count; i++)
|
||||||
|
{
|
||||||
|
myArgs.Add(dd.Arguments[i]);
|
||||||
|
}
|
||||||
|
return env.GetDictionary().main(myArgs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Console.WriteLine($"Could not find console application with name {consolename}.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -16,6 +16,21 @@ func Tesses.CrossLang.Shell.Default(dd)
|
|||||||
Console.WriteLine("new: create new project");
|
Console.WriteLine("new: create new project");
|
||||||
Console.WriteLine("build: build a project");
|
Console.WriteLine("build: build a project");
|
||||||
Console.WriteLine("run: run a project");
|
Console.WriteLine("run: run a project");
|
||||||
|
Console.WriteLine("debug: debug a project");
|
||||||
|
Console.WriteLine("install-console: install a console application");
|
||||||
|
Console.WriteLine("install-template: install a project template");
|
||||||
|
Console.WriteLine("install-tool: install a tool");
|
||||||
|
Console.WriteLine("install-webapp: install a web application");
|
||||||
|
Console.WriteLine("console: run or list installed console applications");
|
||||||
|
Console.WriteLine("webapp: run or list installed web applications");
|
||||||
|
Console.WriteLine("webapp-test: test a web application in place");
|
||||||
|
Console.WriteLine("tool: run or list installed tools");
|
||||||
|
Console.WriteLine("tool-test: test a tool in place");
|
||||||
|
Console.WriteLine("add-project: add project as a dependency");
|
||||||
|
Console.WriteLine("add-dependency: add package as dependency");
|
||||||
|
Console.WriteLine("upload-package: upload package to cpkg");
|
||||||
|
Console.WriteLine("login: login to cpkg");
|
||||||
|
Console.WriteLine("logout: logout from cpkg");
|
||||||
Console.WriteLine("configdir: print the config directory");
|
Console.WriteLine("configdir: print the config directory");
|
||||||
Console.WriteLine("update-shell: update the shell"); //this command is handled by runtime so we don't have to implement it here
|
Console.WriteLine("update-shell: update the shell"); //this command is handled by runtime so we don't have to implement it here
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
204
Tesses.CrossLang.Shell/src/install-console.tcross
Normal file
204
Tesses.CrossLang.Shell/src/install-console.tcross
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
func Tesses.CrossLang.Shell.InstallConsole(dd)
|
||||||
|
{
|
||||||
|
//crosslang install-console Tesses.CrossLang.Console.SomeConsole --version=1.0.0.0-prod
|
||||||
|
var consoleDir = Env.CrossLangConfig / "ConsoleApps";
|
||||||
|
|
||||||
|
var offline=false;
|
||||||
|
var buildPath = ".";
|
||||||
|
var nobuild=false;
|
||||||
|
var output=.;
|
||||||
|
each(var flag : dd.Flags)
|
||||||
|
{
|
||||||
|
if(flag == "offline")
|
||||||
|
{
|
||||||
|
offline = true;
|
||||||
|
}
|
||||||
|
else if(flag == "help")
|
||||||
|
{
|
||||||
|
Console.WriteLine("USAGE: crosslang install-console [flags-and-options]");
|
||||||
|
Console.WriteLine("USAGE: crosslang install-console [PackageName] [flags-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 install (irrelevant if you specify a PackageName)");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("OPTIONS:");
|
||||||
|
Console.WriteLine("conf=CONFIGSTRING: specify a conf string for compile_tool(s), is the property Config (irrelevant if you specify a PackageName)");
|
||||||
|
Console.WriteLine("version=1.0.0.0-prod: specify the package version (irrelevant if you don't specify a PackageName)");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("ARGUMENTS:");
|
||||||
|
Console.WriteLine("PackageName: the package name of a console application you want to download and install, if not specified we install the console application from the current directory");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(flag == "nobuild")
|
||||||
|
{
|
||||||
|
nobuild=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(dd.Arguments.Length == 2)
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = offline;
|
||||||
|
var name = dd.Arguments[1];
|
||||||
|
var version = null;
|
||||||
|
each(var opt : dd.Options)
|
||||||
|
{
|
||||||
|
if(opt.Key == "version")
|
||||||
|
version = opt.Value;
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
version = pm.GetLatest(name);
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Could not get version");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
var ba = pm.GetPackage(name, version);
|
||||||
|
ms.WriteBlock(ba,0,ba.Length);
|
||||||
|
ms.Seek(0,0);
|
||||||
|
var exec = VM.LoadExecutable(ms);
|
||||||
|
var info = Json.Decode(exec.Info);
|
||||||
|
if(info.type != "console")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The project is not a console application");
|
||||||
|
ms.Close();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TypeOf(info.short_name) == "String")
|
||||||
|
{
|
||||||
|
var dir = consoleDir / info.short_name;
|
||||||
|
if(FS.Local.DirectoryExists(dir))
|
||||||
|
{
|
||||||
|
each(var item : FS.Local.EnumeratePaths(dir))
|
||||||
|
{
|
||||||
|
if(FS.Local.FileExists(item) && item.GetExtension() == ".crvm")
|
||||||
|
{
|
||||||
|
FS.Local.DeleteFile(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FS.Local.CreateDirectory(dir);
|
||||||
|
|
||||||
|
FS.WriteAllBytes(FS.Local, dir / info.short_name + ".crvm", ba);
|
||||||
|
|
||||||
|
func downloadDependency(_name, _version)
|
||||||
|
{
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
var ba = pm.GetPackage(name, version);
|
||||||
|
ms.WriteBlock(ba,0,ba.Length);
|
||||||
|
ms.Seek(0,0);
|
||||||
|
var exec = VM.LoadExecutable(ms);
|
||||||
|
var execPath = dir / $"{_name}-{_version}.crvm";
|
||||||
|
|
||||||
|
if(!FS.Local.FileExists(execPath))
|
||||||
|
FS.WriteAllBytes(FS.Local, execPath , ba);
|
||||||
|
|
||||||
|
each(var item : exec.Dependencies)
|
||||||
|
downloadDependency(item.Name, item.Version);
|
||||||
|
ms.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
each(var item : exec.Dependencies)
|
||||||
|
downloadDependency(item.Name, item.Version);
|
||||||
|
Console.WriteLine($"Installed console application {info.short_name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
ms.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(dd.Arguments.Length == 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
var conf = "";
|
||||||
|
each(var option : dd.Options)
|
||||||
|
{
|
||||||
|
if(option.Key == "conf")
|
||||||
|
{
|
||||||
|
conf = option.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FS.Local.FileExists("cross.json"))
|
||||||
|
{
|
||||||
|
var proj = Json.Decode(FS.ReadAllText(FS.Local,"cross.json"));
|
||||||
|
var name = proj.info.short_name;
|
||||||
|
|
||||||
|
if(proj.info.type != "console")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The project is not a console application");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(TypeOf(name) != "String")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The console application does not have a name");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var consoleDir2 = consoleDir / name;
|
||||||
|
FS.Local.CreateDirectory(consoleDir2);
|
||||||
|
var consoleFile = consoleDir2 / name + ".crvm";
|
||||||
|
|
||||||
|
if(nobuild)
|
||||||
|
{
|
||||||
|
var nameVer = $"{proj.name}-{proj.version}.crvm";
|
||||||
|
var buildDir = TypeOf(proj.bin_directory) == "String" ? proj.bin_directory : "bin";
|
||||||
|
|
||||||
|
output = ./buildDir/nameVer;
|
||||||
|
if(!FS.Local.FileExists(output))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"ERROR: file {output} does not exist.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = offline;
|
||||||
|
var bt = Tesses.CrossLang.BuildTool(pm);
|
||||||
|
bt.Config = conf;
|
||||||
|
output = bt.BuildProject(buildPath).Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
func CopyCRVM(src,dest)
|
||||||
|
{
|
||||||
|
func copyFile(src,dest)
|
||||||
|
{
|
||||||
|
var _src = FS.Local.OpenFile(src,"rb");
|
||||||
|
var _dest = FS.Local.OpenFile(dest, "wb");
|
||||||
|
_src.CopyTo(_dest);
|
||||||
|
_src.Close();
|
||||||
|
_dest.Close();
|
||||||
|
Console.WriteLine($"{src} -> {dest}");
|
||||||
|
}
|
||||||
|
if(FS.Local.FileExists(dest)) return;
|
||||||
|
copyFile(src,dest);
|
||||||
|
|
||||||
|
|
||||||
|
var srcStrm = FS.Local.OpenFile(src,"rb");
|
||||||
|
var crvm = VM.LoadExecutable(srcStrm);
|
||||||
|
|
||||||
|
srcStrm.Close();
|
||||||
|
each(var dep : crvm.Dependencies)
|
||||||
|
{
|
||||||
|
var name = $"{dep.Name}-{dep.Version.ToString()}.crvm";
|
||||||
|
CopyCRVM(src.GetParent()/name, dest.GetParent()/name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CopyCRVM(output,consoleFile);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine("The current directory does not have a project");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
156
Tesses.CrossLang.Shell/src/install-template.tcross
Normal file
156
Tesses.CrossLang.Shell/src/install-template.tcross
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
func Tesses.CrossLang.Shell.InstallTemplate(dd)
|
||||||
|
{
|
||||||
|
//crosslang install-template Tesses.CrossLang.Tool.Template --version=1.0.0.0-prod
|
||||||
|
var templatesDir = Env.CrossLangConfig / "Templates";
|
||||||
|
|
||||||
|
var offline=false;
|
||||||
|
var buildPath = ".";
|
||||||
|
var nobuild=false;
|
||||||
|
var output=.;
|
||||||
|
each(var flag : dd.Flags)
|
||||||
|
{
|
||||||
|
if(flag == "offline")
|
||||||
|
{
|
||||||
|
offline = true;
|
||||||
|
}
|
||||||
|
else if(flag == "help")
|
||||||
|
{
|
||||||
|
Console.WriteLine("USAGE: crosslang install-template [flags-and-options]");
|
||||||
|
Console.WriteLine("USAGE: crosslang install-template [PackageName] [flags-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 install (irrelevant if you specify a PackageName)");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("OPTIONS:");
|
||||||
|
Console.WriteLine("conf=CONFIGSTRING: specify a conf string for compile_tool(s), is the property Config (irrelevant if you specify a PackageName)");
|
||||||
|
Console.WriteLine("version=1.0.0.0-prod: specify the package version (irrelevant if you don't specify a PackageName)");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("ARGUMENTS:");
|
||||||
|
Console.WriteLine("PackageName: the package name of a template you want to download and install, if not specified we install the template from the current directory");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(flag == "nobuild")
|
||||||
|
{
|
||||||
|
nobuild=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(dd.Arguments.Length == 2)
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = offline;
|
||||||
|
var name = dd.Arguments[1];
|
||||||
|
var version = null;
|
||||||
|
each(var opt : dd.Options)
|
||||||
|
{
|
||||||
|
if(opt.Key == "version")
|
||||||
|
version = opt.Value;
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
version = pm.GetLatest(name);
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Could not get version");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
var ba = pm.GetPackage(name, version);
|
||||||
|
ms.WriteBlock(ba,0,ba.Length);
|
||||||
|
ms.Seek(0,0);
|
||||||
|
var exec = VM.LoadExecutable(ms);
|
||||||
|
var info = Json.Decode(exec.Info);
|
||||||
|
if(info.type != "template")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The project is not a template");
|
||||||
|
ms.Close();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TypeOf(info.short_name) == "String")
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FS.WriteAllBytes(FS.Local, templatesDir / info.short_name + ".crvm", ba);
|
||||||
|
|
||||||
|
Console.WriteLine($"Installed template {info.short_name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
ms.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(dd.Arguments.Length == 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
var conf = "";
|
||||||
|
each(var option : dd.Options)
|
||||||
|
{
|
||||||
|
if(option.Key == "conf")
|
||||||
|
{
|
||||||
|
conf = option.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FS.Local.FileExists("cross.json"))
|
||||||
|
{
|
||||||
|
var proj = Json.Decode(FS.ReadAllText(FS.Local,"cross.json"));
|
||||||
|
var name = proj.info.short_name;
|
||||||
|
|
||||||
|
if(proj.info.type != "template")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The project is not a template");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(TypeOf(name) != "String")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The tool does not have a name");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
FS.Local.CreateDirectory(templatesDir);
|
||||||
|
var templateFile = templatesDir / name + ".crvm";
|
||||||
|
|
||||||
|
if(nobuild)
|
||||||
|
{
|
||||||
|
var nameVer = $"{proj.name}-{proj.version}.crvm";
|
||||||
|
var buildDir = TypeOf(proj.bin_directory) == "String" ? proj.bin_directory : "bin";
|
||||||
|
output = ./buildDir/nameVer;
|
||||||
|
if(!FS.Local.FileExists(output))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"ERROR: file {output} does not exist.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = offline;
|
||||||
|
var bt = Tesses.CrossLang.BuildTool(pm);
|
||||||
|
bt.Config = conf;
|
||||||
|
output = bt.BuildProject(buildPath).Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyFile(src,dest)
|
||||||
|
{
|
||||||
|
var _src = FS.Local.OpenFile(src,"rb");
|
||||||
|
var _dest = FS.Local.OpenFile(dest, "wb");
|
||||||
|
_src.CopyTo(_dest);
|
||||||
|
_src.Close();
|
||||||
|
_dest.Close();
|
||||||
|
Console.WriteLine($"{src} -> {dest}");
|
||||||
|
}
|
||||||
|
copyFile(output,toolFile);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine("The current directory does not have a project");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -35,8 +35,84 @@ func Tesses.CrossLang.Shell.InstallTool(dd)
|
|||||||
nobuild=true;
|
nobuild=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(dd.Arguments.Length == 2)
|
||||||
if(dd.Arguments.Length == 1)
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = offline;
|
||||||
|
var name = dd.Arguments[1];
|
||||||
|
var version = null;
|
||||||
|
each(var opt : dd.Options)
|
||||||
|
{
|
||||||
|
if(opt.Key == "version")
|
||||||
|
version = opt.Value;
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
version = pm.GetLatest(name);
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Could not get version");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
var ba = pm.GetPackage(name, version);
|
||||||
|
ms.WriteBlock(ba,0,ba.Length);
|
||||||
|
ms.Seek(0,0);
|
||||||
|
var exec = VM.LoadExecutable(ms);
|
||||||
|
var info = Json.Decode(exec.Info);
|
||||||
|
if(info.type != "tool")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The project is not a tool");
|
||||||
|
ms.Close();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TypeOf(info.short_name) == "String")
|
||||||
|
{
|
||||||
|
var dir = toolsDir / info.short_name;
|
||||||
|
if(FS.Local.DirectoryExists(dir))
|
||||||
|
{
|
||||||
|
each(var item : FS.Local.EnumeratePaths(dir))
|
||||||
|
{
|
||||||
|
if(FS.Local.FileExists(item) && item.GetExtension() == ".crvm")
|
||||||
|
{
|
||||||
|
FS.Local.DeleteFile(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FS.Local.CreateDirectory(dir);
|
||||||
|
|
||||||
|
FS.WriteAllBytes(FS.Local, dir / info.short_name + ".crvm", ba);
|
||||||
|
|
||||||
|
func downloadDependency(_name, _version)
|
||||||
|
{
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
var ba = pm.GetPackage(name, version);
|
||||||
|
ms.WriteBlock(ba,0,ba.Length);
|
||||||
|
ms.Seek(0,0);
|
||||||
|
var exec = VM.LoadExecutable(ms);
|
||||||
|
var execPath = dir / $"{_name}-{_version}.crvm";
|
||||||
|
|
||||||
|
if(!FS.Local.FileExists(execPath))
|
||||||
|
FS.WriteAllBytes(FS.Local, execPath , ba);
|
||||||
|
|
||||||
|
each(var item : exec.Dependencies)
|
||||||
|
downloadDependency(item.Name, item.Version);
|
||||||
|
ms.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
each(var item : exec.Dependencies)
|
||||||
|
downloadDependency(item.Name, item.Version);
|
||||||
|
Console.WriteLine($"Installed tool {info.short_name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
ms.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(dd.Arguments.Length == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
var conf = "";
|
var conf = "";
|
||||||
@@ -51,7 +127,7 @@ func Tesses.CrossLang.Shell.InstallTool(dd)
|
|||||||
if(FS.Local.FileExists("cross.json"))
|
if(FS.Local.FileExists("cross.json"))
|
||||||
{
|
{
|
||||||
var proj = Json.Decode(FS.ReadAllText(FS.Local,"cross.json"));
|
var proj = Json.Decode(FS.ReadAllText(FS.Local,"cross.json"));
|
||||||
var name = TypeOf(proj.info.toolname) == "String" ? proj.info.toolname : proj.name;
|
var name = proj.info.short_name;
|
||||||
|
|
||||||
if(proj.info.type != "tool")
|
if(proj.info.type != "tool")
|
||||||
{
|
{
|
||||||
@@ -78,7 +154,7 @@ func Tesses.CrossLang.Shell.InstallTool(dd)
|
|||||||
Console.WriteLine($"ERROR: file {output} does not exist.");
|
Console.WriteLine($"ERROR: file {output} does not exist.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
204
Tesses.CrossLang.Shell/src/install-webapp.tcross
Normal file
204
Tesses.CrossLang.Shell/src/install-webapp.tcross
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
func Tesses.CrossLang.Shell.InstallWebApp(dd)
|
||||||
|
{
|
||||||
|
//crosslang install-webapp Tesses.CrossLang.WebApp.SomeWebApp --version=1.0.0.0-prod
|
||||||
|
var toolsDir = Env.CrossLangConfig / "WebApps";
|
||||||
|
|
||||||
|
var offline=false;
|
||||||
|
var buildPath = ".";
|
||||||
|
var nobuild=false;
|
||||||
|
var output=.;
|
||||||
|
each(var flag : dd.Flags)
|
||||||
|
{
|
||||||
|
if(flag == "offline")
|
||||||
|
{
|
||||||
|
offline = true;
|
||||||
|
}
|
||||||
|
else if(flag == "help")
|
||||||
|
{
|
||||||
|
Console.WriteLine("USAGE: crosslang install-webapp [flags-and-options]");
|
||||||
|
Console.WriteLine("USAGE: crosslang install-webapp [PackageName] [flags-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 install (irrelevant if you specify a PackageName)");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("OPTIONS:");
|
||||||
|
Console.WriteLine("conf=CONFIGSTRING: specify a conf string for compile_tool(s), is the property Config (irrelevant if you specify a PackageName)");
|
||||||
|
Console.WriteLine("version=1.0.0.0-prod: specify the package version (irrelevant if you don't specify a PackageName)");
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("ARGUMENTS:");
|
||||||
|
Console.WriteLine("PackageName: the package name of a web application you want to download and install, if not specified we install the web application from the current directory");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(flag == "nobuild")
|
||||||
|
{
|
||||||
|
nobuild=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(dd.Arguments.Length == 2)
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = offline;
|
||||||
|
var name = dd.Arguments[1];
|
||||||
|
var version = null;
|
||||||
|
each(var opt : dd.Options)
|
||||||
|
{
|
||||||
|
if(opt.Key == "version")
|
||||||
|
version = opt.Value;
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
version = pm.GetLatest(name);
|
||||||
|
}
|
||||||
|
if(version == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Could not get version");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
var ba = pm.GetPackage(name, version);
|
||||||
|
ms.WriteBlock(ba,0,ba.Length);
|
||||||
|
ms.Seek(0,0);
|
||||||
|
var exec = VM.LoadExecutable(ms);
|
||||||
|
var info = Json.Decode(exec.Info);
|
||||||
|
if(info.type != "webapp")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The project is not a web application");
|
||||||
|
ms.Close();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TypeOf(info.short_name) == "String")
|
||||||
|
{
|
||||||
|
var dir = toolsDir / info.short_name;
|
||||||
|
if(FS.Local.DirectoryExists(dir))
|
||||||
|
{
|
||||||
|
each(var item : FS.Local.EnumeratePaths(dir))
|
||||||
|
{
|
||||||
|
if(FS.Local.FileExists(item) && item.GetExtension() == ".crvm")
|
||||||
|
{
|
||||||
|
FS.Local.DeleteFile(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FS.Local.CreateDirectory(dir);
|
||||||
|
|
||||||
|
FS.WriteAllBytes(FS.Local, dir / info.short_name + ".crvm", ba);
|
||||||
|
|
||||||
|
func downloadDependency(_name, _version)
|
||||||
|
{
|
||||||
|
var ms = new MemoryStream(true);
|
||||||
|
var ba = pm.GetPackage(name, version);
|
||||||
|
ms.WriteBlock(ba,0,ba.Length);
|
||||||
|
ms.Seek(0,0);
|
||||||
|
var exec = VM.LoadExecutable(ms);
|
||||||
|
var execPath = dir / $"{_name}-{_version}.crvm";
|
||||||
|
|
||||||
|
if(!FS.Local.FileExists(execPath))
|
||||||
|
FS.WriteAllBytes(FS.Local, execPath , ba);
|
||||||
|
|
||||||
|
each(var item : exec.Dependencies)
|
||||||
|
downloadDependency(item.Name, item.Version);
|
||||||
|
ms.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
each(var item : exec.Dependencies)
|
||||||
|
downloadDependency(item.Name, item.Version);
|
||||||
|
Console.WriteLine($"Installed web application {info.short_name}");
|
||||||
|
}
|
||||||
|
|
||||||
|
ms.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(dd.Arguments.Length == 1)
|
||||||
|
{
|
||||||
|
|
||||||
|
var conf = "";
|
||||||
|
each(var option : dd.Options)
|
||||||
|
{
|
||||||
|
if(option.Key == "conf")
|
||||||
|
{
|
||||||
|
conf = option.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FS.Local.FileExists("cross.json"))
|
||||||
|
{
|
||||||
|
var proj = Json.Decode(FS.ReadAllText(FS.Local,"cross.json"));
|
||||||
|
var name = proj.info.short_name;
|
||||||
|
|
||||||
|
if(proj.info.type != "webapp")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The project is not a web application");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if(TypeOf(name) != "String")
|
||||||
|
{
|
||||||
|
Console.WriteLine("The web application does not have a name");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
var toolDir = toolsDir / name;
|
||||||
|
FS.Local.CreateDirectory(toolDir);
|
||||||
|
var toolFile = toolDir / name + ".crvm";
|
||||||
|
|
||||||
|
if(nobuild)
|
||||||
|
{
|
||||||
|
var nameVer = $"{proj.name}-{proj.version}.crvm";
|
||||||
|
var buildDir = TypeOf(proj.bin_directory) == "String" ? proj.bin_directory : "bin";
|
||||||
|
|
||||||
|
output = ./buildDir/nameVer;
|
||||||
|
if(!FS.Local.FileExists(output))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"ERROR: file {output} does not exist.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = offline;
|
||||||
|
var bt = Tesses.CrossLang.BuildTool(pm);
|
||||||
|
bt.Config = conf;
|
||||||
|
output = bt.BuildProject(buildPath).Output;
|
||||||
|
}
|
||||||
|
|
||||||
|
func CopyCRVM(src,dest)
|
||||||
|
{
|
||||||
|
func copyFile(src,dest)
|
||||||
|
{
|
||||||
|
var _src = FS.Local.OpenFile(src,"rb");
|
||||||
|
var _dest = FS.Local.OpenFile(dest, "wb");
|
||||||
|
_src.CopyTo(_dest);
|
||||||
|
_src.Close();
|
||||||
|
_dest.Close();
|
||||||
|
Console.WriteLine($"{src} -> {dest}");
|
||||||
|
}
|
||||||
|
if(FS.Local.FileExists(dest)) return;
|
||||||
|
copyFile(src,dest);
|
||||||
|
|
||||||
|
|
||||||
|
var srcStrm = FS.Local.OpenFile(src,"rb");
|
||||||
|
var crvm = VM.LoadExecutable(srcStrm);
|
||||||
|
|
||||||
|
srcStrm.Close();
|
||||||
|
each(var dep : crvm.Dependencies)
|
||||||
|
{
|
||||||
|
var name = $"{dep.Name}-{dep.Version.ToString()}.crvm";
|
||||||
|
CopyCRVM(src.GetParent()/name, dest.GetParent()/name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CopyCRVM(output,toolFile);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine("The current directory does not have a project");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -36,15 +36,23 @@ func main(args)
|
|||||||
case "install-tool":
|
case "install-tool":
|
||||||
return Tesses.CrossLang.Shell.InstallTool(dd);
|
return Tesses.CrossLang.Shell.InstallTool(dd);
|
||||||
break;
|
break;
|
||||||
|
case "install-webapp":
|
||||||
|
return Tesses.CrossLang.Shell.InstallWebApp(dd);
|
||||||
|
break;
|
||||||
case "console":
|
case "console":
|
||||||
return Tesses.CrossLang.Shell.Console(dd);
|
return Tesses.CrossLang.Shell.Console(dd);
|
||||||
break;
|
break;
|
||||||
case "tool":
|
case "tool":
|
||||||
return Tesses.CrossLang.Shell.Tool(dd);
|
return Tesses.CrossLang.Shell.Tool(dd);
|
||||||
break;
|
break;
|
||||||
|
case "webapp":
|
||||||
|
return Tesses.CrossLang.Shell.WebApp(dd);
|
||||||
case "tool-test":
|
case "tool-test":
|
||||||
return Tesses.CrossLang.Shell.ToolTest(dd);
|
return Tesses.CrossLang.Shell.ToolTest(dd);
|
||||||
break;
|
break;
|
||||||
|
case "webapp-test":
|
||||||
|
return Tesses.CrossLang.Shell.WebAppTest(dd);
|
||||||
|
break;
|
||||||
case "add-project":
|
case "add-project":
|
||||||
return Tesses.CrossLang.Shell.AddProject(dd);
|
return Tesses.CrossLang.Shell.AddProject(dd);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
else if(commandName == "install-console")
|
|
||||||
{
|
|
||||||
//crosslang install-console ConsoleApp --version=1.0.0.0-prod [--outdir=DIR]
|
|
||||||
}
|
|
||||||
else if(commandName == "install-app")
|
|
||||||
{
|
|
||||||
//crosslang install-app
|
|
||||||
}
|
|
||||||
else if(commandName == "install-template")
|
|
||||||
{
|
|
||||||
//crosslang install-template Tesses.CrossLang.Template.Console --version=1.0.0.0-prod
|
|
||||||
}
|
|
||||||
|
|
||||||
if(commandName == "install-tool")
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(commandName == "console")
|
|
||||||
{
|
|
||||||
//crosslang console myfavoriteapp
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ func Tesses.CrossLang.Shell.ToolTest(dd)
|
|||||||
Arguments=myArgs,
|
Arguments=myArgs,
|
||||||
Options = dd.Options,
|
Options = dd.Options,
|
||||||
Flags = dd.Flags,
|
Flags = dd.Flags,
|
||||||
ToolName = proj.Info.toolname
|
ToolName = proj.Info.short_name
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,42 @@ func Tesses.CrossLang.Shell.Tool(dd)
|
|||||||
if(dd.Arguments.Length == 1)
|
if(dd.Arguments.Length == 1)
|
||||||
{
|
{
|
||||||
Console.WriteLine("List of tools:");
|
Console.WriteLine("List of tools:");
|
||||||
|
if(FS.Local.DirectoryExists(dir))
|
||||||
each(var item : FS.Local.EnumeratePaths(dir))
|
each(var item : FS.Local.EnumeratePaths(dir))
|
||||||
{
|
{
|
||||||
Console.WriteLine(Tesses.CrossLang.GetNameAndDescription(item / item.GetFileName() + ".crvm"));
|
Console.WriteLine(Tesses.CrossLang.GetNameAndDescription(item / item.GetFileName() + ".crvm"));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if(dd.Arguments.Length >= 2)
|
||||||
|
{
|
||||||
|
var toolname = dd.Arguments[1];
|
||||||
|
var toolpath = dir / toolname / toolname + ".crvm";
|
||||||
|
|
||||||
|
if(FS.Local.FileExists(toolpath))
|
||||||
|
{
|
||||||
|
|
||||||
|
var env = VM.CreateEnvironment({});
|
||||||
|
env.RegisterEverything();
|
||||||
|
env.LockRegister();
|
||||||
|
|
||||||
|
env.LoadFileWithDependencies(FS.Local,toolpath);
|
||||||
|
var myArgs = [];
|
||||||
|
for(var i = 2; i < dd.Arguments.Count; i++)
|
||||||
|
{
|
||||||
|
myArgs.Add(dd.Arguments[i]);
|
||||||
|
}
|
||||||
|
return env.GetDictionary().RunTool({
|
||||||
|
Arguments=myArgs,
|
||||||
|
Options = dd.Options,
|
||||||
|
Flags = dd.Flags,
|
||||||
|
ToolName = toolname
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Console.WriteLine($"Could not find tool with name {toolname}.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
38
Tesses.CrossLang.Shell/src/webapp-test.tcross
Normal file
38
Tesses.CrossLang.Shell/src/webapp-test.tcross
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
func Tesses.CrossLang.Shell.WebAppTest(dd)
|
||||||
|
{
|
||||||
|
var port = 4206;
|
||||||
|
|
||||||
|
each(var item : dd.Options)
|
||||||
|
{
|
||||||
|
if(item.Key == "port")
|
||||||
|
{
|
||||||
|
var thePort = ParseLong(item.Value);
|
||||||
|
if(TypeOf(thePort) == "Long") port = thePort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var pm = Tesses.CrossLang.PackageManager();
|
||||||
|
pm.Offline = false;
|
||||||
|
var bt = Tesses.CrossLang.BuildTool(pm);
|
||||||
|
|
||||||
|
|
||||||
|
var proj=bt.BuildProject(".");
|
||||||
|
|
||||||
|
var output = proj.Output;
|
||||||
|
|
||||||
|
var env = VM.CreateEnvironment({});
|
||||||
|
env.RegisterEverything();
|
||||||
|
env.LockRegister();
|
||||||
|
|
||||||
|
env.LoadFileWithDependencies(FS.Local,output);
|
||||||
|
var myArgs = [output.ToString()];
|
||||||
|
for(var i = 1; i < dd.Arguments.Count; i++)
|
||||||
|
{
|
||||||
|
myArgs.Add(dd.Arguments[i]);
|
||||||
|
}
|
||||||
|
var res = env.GetDictionary().WebAppMain(myArgs);
|
||||||
|
|
||||||
|
|
||||||
|
Net.Http.ListenSimpleWithLoop(res, port);
|
||||||
|
}
|
||||||
54
Tesses.CrossLang.Shell/src/webapp.tcross
Normal file
54
Tesses.CrossLang.Shell/src/webapp.tcross
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
func Tesses.CrossLang.Shell.WebApp(dd)
|
||||||
|
{
|
||||||
|
var dir = Env.CrossLangConfig / "WebApps";
|
||||||
|
if(dd.Arguments.Length == 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine("List of web applications:");
|
||||||
|
Console.WriteLine("Use --port=PORT to set port");
|
||||||
|
|
||||||
|
if(FS.Local.DirectoryExists(dir))
|
||||||
|
each(var item : FS.Local.EnumeratePaths(dir))
|
||||||
|
{
|
||||||
|
Console.WriteLine(Tesses.CrossLang.GetNameAndDescription(item / item.GetFileName() + ".crvm"));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(dd.Arguments.Length >= 2)
|
||||||
|
{
|
||||||
|
var webappname = dd.Arguments[1];
|
||||||
|
var webapppath = dir / webappname / webappname + ".crvm";
|
||||||
|
var port = 4206;
|
||||||
|
each(var item : dd.Options)
|
||||||
|
{
|
||||||
|
if(item.Key == "port")
|
||||||
|
{
|
||||||
|
var thePort = ParseLong(item.Value);
|
||||||
|
if(TypeOf(thePort) == "Long") port = thePort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FS.Local.FileExists(webapppath))
|
||||||
|
{
|
||||||
|
|
||||||
|
var env = VM.CreateEnvironment({});
|
||||||
|
env.RegisterEverything();
|
||||||
|
env.LockRegister();
|
||||||
|
|
||||||
|
env.LoadFileWithDependencies(FS.Local,webapppath);
|
||||||
|
var myArgs = [webapppath.ToString()];
|
||||||
|
for(var i = 2; i < dd.Arguments.Count; i++)
|
||||||
|
{
|
||||||
|
myArgs.Add(dd.Arguments[i]);
|
||||||
|
}
|
||||||
|
var res = env.GetDictionary().WebAppMain(myArgs);
|
||||||
|
|
||||||
|
|
||||||
|
Net.Http.ListenSimpleWithLoop(res, port);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Console.WriteLine($"Could not find web application with name {toolname}.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user