mirror of
https://onedev.site.tesses.net/crosslang/crosslangextras
synced 2026-02-09 01:25:46 +00:00
Change to onedev
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
bin
|
bin
|
||||||
bin-tmp
|
bin-tmp
|
||||||
obj
|
obj
|
||||||
Tesses.CrossLang.CrossShellInstaller/res
|
shell_archive
|
||||||
|
*.crvm
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"maintainer": "Mike Nolan",
|
"maintainer": "Mike Nolan",
|
||||||
"type": "lib",
|
"type": "lib",
|
||||||
"repo": "https://gitea.site.tesses.net/tesses50/crosslang/crosslang-libs",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "LGPLv3"
|
"license": "LGPLv3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func Tesses.CrossLang.Args(args)
|
|||||||
Options = options,
|
Options = options,
|
||||||
FileName = filename,
|
FileName = filename,
|
||||||
Flags = flags,
|
Flags = flags,
|
||||||
Arguments = pos
|
Arguments = pos,
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"maintainer": "Mike Nolan",
|
"maintainer": "Mike Nolan",
|
||||||
"type": "lib",
|
"type": "lib",
|
||||||
"repo": "https://gitea.site.tesses.net/tesses50/crosslang/crosslang-libs",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "LGPLv3"
|
"license": "LGPLv3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,16 +23,18 @@ func Tesses.CrossLang.BuildTool(pm)
|
|||||||
GetPackageDependencies = (this,name,version,dir)=>{
|
GetPackageDependencies = (this,name,version,dir)=>{
|
||||||
var dep = pm.GetPackage(name,version);
|
var dep = pm.GetPackage(name,version);
|
||||||
if(TypeOf(dep) == "Null") throw $"Package {name} with version {version} does not exist";
|
if(TypeOf(dep) == "Null") throw $"Package {name} with version {version} does not exist";
|
||||||
|
|
||||||
var pkgPath = dir / $"{name}-{version}.crvm";
|
var pkgPath = dir / $"{name}-{version}.crvm";
|
||||||
|
|
||||||
var strm = FS.Local.OpenFile(pkgPath,"wb");
|
var strm = FS.Local.OpenFile(pkgPath,"wb");
|
||||||
|
|
||||||
strm.WriteBlock(dep,0,dep.Count);
|
strm.WriteBlock(dep,0,dep.Count);
|
||||||
strm.Close();
|
strm.Close();
|
||||||
var ms = MemoryStream(true);
|
var strm = FS.Local.OpenFile(pkgPath,"rb");
|
||||||
ms.WriteBlock(dep,0,dep.Count);
|
|
||||||
ms.Seek(0,0);
|
|
||||||
var package = Tesses.CrossLang.CrossVMFile();
|
var package = Tesses.CrossLang.CrossVMFile();
|
||||||
package.Load(ms);
|
package.Read(strm);
|
||||||
ms.Close();
|
strm.Close();
|
||||||
|
|
||||||
var deps = [];
|
var deps = [];
|
||||||
|
|
||||||
@@ -41,11 +43,10 @@ func Tesses.CrossLang.BuildTool(pm)
|
|||||||
deps.Add(this.GetPackageDependencies(dep.Name, dep.Version, dir));
|
deps.Add(this.GetPackageDependencies(dep.Name, dep.Version, dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
Name = name,
|
Name = name,
|
||||||
Version = version,
|
Version = version,
|
||||||
Info = package.Info,
|
Info = Json.Decode(package.Info),
|
||||||
Dependencies = deps,
|
Dependencies = deps,
|
||||||
Output = pkgPath
|
Output = pkgPath
|
||||||
};
|
};
|
||||||
@@ -87,8 +88,32 @@ func Tesses.CrossLang.BuildTool(pm)
|
|||||||
if(TypeOf(configData.info) != "Undefined")
|
if(TypeOf(configData.info) != "Undefined")
|
||||||
info = configData.info;
|
info = configData.info;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FS.Local.CreateDirectory(dir / outputDir);
|
FS.Local.CreateDirectory(dir / outputDir);
|
||||||
|
|
||||||
|
if(TypeOf(info.type) == "String" && info.type == "template")
|
||||||
|
{
|
||||||
|
//vfs, strm, name, version, info
|
||||||
|
var subdir = FS.SubdirFilesystem(FS.Local,dir);
|
||||||
|
var output = $"{name}-{version}.crvm";
|
||||||
|
var outFile = FS.Local.OpenFile(dir / outputDir / output,"wb");
|
||||||
|
|
||||||
|
if(TypeOf(info.template_ignored_files) != "Undefined")
|
||||||
|
{
|
||||||
|
var ignored = "";
|
||||||
|
each(var item : info.template_ignored_files)
|
||||||
|
{
|
||||||
|
ignored += $"{item}\n";
|
||||||
|
}
|
||||||
|
FS.WriteAllText(FS.Local, dir / ".crossarchiveignore", ignored);
|
||||||
|
}
|
||||||
|
FS.CreateArchive(subdir, outFile, name, version, Json.Encode(info));
|
||||||
|
outFile.Close();
|
||||||
|
subdir.Close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
FS.Local.CreateDirectory(dir / objDir / "packages");
|
FS.Local.CreateDirectory(dir / objDir / "packages");
|
||||||
|
|
||||||
FS.Local.CreateDirectory(dir/resDir);
|
FS.Local.CreateDirectory(dir/resDir);
|
||||||
@@ -101,7 +126,6 @@ func Tesses.CrossLang.BuildTool(pm)
|
|||||||
if(Path.FromString(dep).IsRelative())
|
if(Path.FromString(dep).IsRelative())
|
||||||
{
|
{
|
||||||
dependencies.Add(this.BuildProject((dir / dep)));
|
dependencies.Add(this.BuildProject((dir / dep)));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dependencies.Add(this.BuildProject(dep));
|
dependencies.Add(this.BuildProject(dep));
|
||||||
@@ -112,7 +136,7 @@ func Tesses.CrossLang.BuildTool(pm)
|
|||||||
{
|
{
|
||||||
each(var dep : configData.dependencies)
|
each(var dep : configData.dependencies)
|
||||||
{
|
{
|
||||||
dependencies.Add(this.GetPackageDependencies(dep.Name,dep.Version,dir / objDir / "packages"));
|
dependencies.Add(this.GetPackageDependencies(dep.name,dep.version,dir / objDir / "packages"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"maintainer": "Mike Nolan",
|
"maintainer": "Mike Nolan",
|
||||||
"type": "compile_tool",
|
"type": "compile_tool",
|
||||||
"repo": "https://gitea.site.tesses.net/tesses50/crosslang/crosslang-libs",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "LGPLv3"
|
"license": "LGPLv3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -292,6 +292,8 @@ func crossmarkupparser(tokens)
|
|||||||
}
|
}
|
||||||
|
|
||||||
EnsureTokenType("ExitSpecial");
|
EnsureTokenType("ExitSpecial");
|
||||||
|
|
||||||
|
Console.WriteLine($"Creating page: {route}");
|
||||||
while(NotEnd())
|
while(NotEnd())
|
||||||
{
|
{
|
||||||
nodes.Add(parse_node());
|
nodes.Add(parse_node());
|
||||||
@@ -352,6 +354,7 @@ func crossmarkupparser(tokens)
|
|||||||
throw "Not an identifier";
|
throw "Not an identifier";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Console.WriteLine($"Creating component: {name}");
|
||||||
|
|
||||||
EnsureTokenType("ExitSpecial");
|
EnsureTokenType("ExitSpecial");
|
||||||
while(NotEnd())
|
while(NotEnd())
|
||||||
@@ -590,9 +593,31 @@ func crossmarkupgen(ast)
|
|||||||
}
|
}
|
||||||
page_functions.Add({
|
page_functions.Add({
|
||||||
Key = name,
|
Key = name,
|
||||||
Value = code
|
Value = code,
|
||||||
|
Embeds = ""
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
func add_to_embeds(name, embeddata)
|
||||||
|
{
|
||||||
|
each(var item : page_functions)
|
||||||
|
{
|
||||||
|
if(item.Key == name)
|
||||||
|
{
|
||||||
|
if(item.Embeds.Count > 0)
|
||||||
|
{
|
||||||
|
item.Embeds += "else ";
|
||||||
|
}
|
||||||
|
item.Embeds += embeddata;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page_functions.Add({
|
||||||
|
Key = name,
|
||||||
|
Value = "",
|
||||||
|
Embeds = embeddata
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func generate_node(node)
|
func generate_node(node)
|
||||||
{
|
{
|
||||||
@@ -626,28 +651,29 @@ func crossmarkupgen(ast)
|
|||||||
}
|
}
|
||||||
if(node.Type == "PageNode")
|
if(node.Type == "PageNode")
|
||||||
{
|
{
|
||||||
var code = $"if(ctx.Path == \"{node.Route}\")";
|
var codea = $"if(ctx.Path == \"{node.Route}\")";
|
||||||
code += "{__writer = ctx.OpenResponseStream(); ";
|
codea += "{__writer = ctx.OpenResponseStream(); ";
|
||||||
each(var a : node.Arguments)
|
each(var a : node.Arguments)
|
||||||
{
|
{
|
||||||
code += $"var {a} = ctx.QueryParams.TryGetFirst(\"{a}\");";
|
codea += $"var {a} = ctx.QueryParams.TryGetFirst(\"{a}\");";
|
||||||
}
|
}
|
||||||
each(var item : node.Nodes)
|
each(var item : node.Nodes)
|
||||||
{
|
{
|
||||||
code += generate_node(item);
|
codea += generate_node(item);
|
||||||
}
|
}
|
||||||
code += " __writer.Close(); return true;}";
|
codea += " __writer.Close(); return true;}";
|
||||||
|
|
||||||
add_to_page(node.RouterFunction,code);
|
add_to_page(node.RouterFunction,codea);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
else if(node.Type == "EmbedNode")
|
else if(node.Type == "EmbedNode")
|
||||||
{
|
{
|
||||||
var code = $"if(ctx.Path == \"{node.Route}\")";
|
var codea = $"if(ctx.Path == \"{node.Route}\")";
|
||||||
code += "{";
|
codea += "{";
|
||||||
code += $"ctx.WithMimeType(Net.Http.MimeType(\"{node.Name}\")).SendBytes(embed(\"{node.Name}\"));";
|
codea += $"ctx.WithMimeType(Net.Http.MimeType(\"{node.Name}\")).SendBytes(embed(\"{node.Name}\"));";
|
||||||
code += "return true;";
|
codea += "return true;";
|
||||||
code += "}";
|
codea += "}";
|
||||||
|
add_to_embeds(node.RouterFunction, codea);
|
||||||
}
|
}
|
||||||
else if(node.Type == "TextNode")
|
else if(node.Type == "TextNode")
|
||||||
{
|
{
|
||||||
@@ -655,12 +681,12 @@ func crossmarkupgen(ast)
|
|||||||
}
|
}
|
||||||
else if(node.Type == "ExprNode")
|
else if(node.Type == "ExprNode")
|
||||||
{
|
{
|
||||||
var code = "write(";
|
var code = "write((";
|
||||||
each(var item : node.Nodes)
|
each(var item : node.Nodes)
|
||||||
{
|
{
|
||||||
code += generate_node(item);
|
code += generate_node(item);
|
||||||
}
|
}
|
||||||
code += ");";
|
code += ").ToString());";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
else if(node.Type == "CodeNode")
|
else if(node.Type == "CodeNode")
|
||||||
@@ -761,14 +787,24 @@ func crossmarkupgen(ast)
|
|||||||
each(var pg : page_functions)
|
each(var pg : page_functions)
|
||||||
{
|
{
|
||||||
code += $"func {pg.Key}(ctx)";
|
code += $"func {pg.Key}(ctx)";
|
||||||
code += "{ ctx.WithMimeType(\"text/html\");";
|
code += "{";
|
||||||
|
if(pg.Embeds.Count > 0)
|
||||||
|
{
|
||||||
|
code += pg.Embeds + "else{";
|
||||||
|
}
|
||||||
|
code += "ctx.WithMimeType(\"text/html\");";
|
||||||
code += "var __writer = null;";
|
code += "var __writer = null;";
|
||||||
|
|
||||||
code += "func write(__text){ __writer.WriteText(__text); }";
|
code += "func write(__text){ __writer.WriteText(__text); }";
|
||||||
|
|
||||||
code += pg.Value;
|
code += pg.Value;
|
||||||
|
|
||||||
code += "__writer.Close(); return false;}";
|
code += "__writer.Close(); ";
|
||||||
|
if(pg.Embeds.Count > 0)
|
||||||
|
{
|
||||||
|
code += "}";
|
||||||
|
}
|
||||||
|
code += " return false;}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
@@ -788,6 +824,7 @@ func EnumerateFiles(cfg,path)
|
|||||||
{
|
{
|
||||||
if(cfg.Project.RegularFileExists(file))
|
if(cfg.Project.RegularFileExists(file))
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Creating markup for: {file}");
|
||||||
var f = cfg.Project.OpenFile(file, "rb");
|
var f = cfg.Project.OpenFile(file, "rb");
|
||||||
var ms = FS.MemoryStream(true);
|
var ms = FS.MemoryStream(true);
|
||||||
f.CopyTo(ms);
|
f.CopyTo(ms);
|
||||||
@@ -806,13 +843,16 @@ func EnumerateFiles(cfg,path)
|
|||||||
func RunTool(cfg)
|
func RunTool(cfg)
|
||||||
{
|
{
|
||||||
var text = "";
|
var text = "";
|
||||||
|
|
||||||
text += EnumerateFiles(cfg, "/components");
|
text += EnumerateFiles(cfg, "/components");
|
||||||
text += EnumerateFiles(cfg, "/pages");
|
text += EnumerateFiles(cfg, "/pages");
|
||||||
var c = crossmarkuplexer(text);
|
var c = crossmarkuplexer(text);
|
||||||
|
Console.WriteLine("Lexed");
|
||||||
|
|
||||||
var r = crossmarkupparser(c);
|
var r = crossmarkupparser(c);
|
||||||
|
Console.WriteLine("Parsed");
|
||||||
|
|
||||||
var src = crossmarkupgen(r);
|
var src = crossmarkupgen(r);
|
||||||
|
Console.WriteLine("Gened");
|
||||||
cfg.GeneratedSource.Add({Source = src, FileName="markup.tcross"});
|
cfg.GeneratedSource.Add({Source = src, FileName="markup.tcross"});
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "Tesses.CrossLang.PackageServer",
|
"project_dependencies": ["../Tesses.CrossLang.Markup"],
|
||||||
"version": "1.0.0.0-prod",
|
|
||||||
"project_dependencies": [
|
|
||||||
"./Tesses.CrossLang.Markup"
|
|
||||||
],
|
|
||||||
"info": {
|
"info": {
|
||||||
"type": "console"
|
"type": "console"
|
||||||
}
|
},
|
||||||
|
"version": "1.0.0.0-prod",
|
||||||
|
"name": "Tesses.CrossLang.PackageServer"
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,28 @@
|
|||||||
<?page() route="/" ?>
|
<?page() route="/" ?>
|
||||||
<h1>Welcome to the package server</h1>
|
<?code
|
||||||
|
var pages = [
|
||||||
|
{
|
||||||
|
active = true,
|
||||||
|
route = "/",
|
||||||
|
text = "Home"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/counter",
|
||||||
|
text = "Counter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/about",
|
||||||
|
text = "About"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
?>
|
||||||
|
<?Shell?>
|
||||||
|
<?arg "Main Page" ?>
|
||||||
|
<?arg pages ?>
|
||||||
|
<?arg_component() ?>
|
||||||
|
<p>1 John 4:4: You, dear children, are from God and have overcome them, because the one who is in you is greater than the one who is in the world.</p>
|
||||||
|
<?end?>
|
||||||
|
<?end?>
|
||||||
<?end?>
|
<?end?>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
|
var count = 0;
|
||||||
func main(args)
|
func main(args)
|
||||||
{
|
{
|
||||||
Net.Http.ListenSimpleWithLoop(Router,4200);
|
Net.Http.ListenSimpleWithLoop(Router,4206);
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"maintainer": "Mike Nolan",
|
"maintainer": "Mike Nolan",
|
||||||
"type": "console",
|
"type": "console",
|
||||||
"repo": "https://gitea.site.tesses.net/tesses50/crosslang/crosslang-libs",
|
"repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras",
|
||||||
"homepage": "https://crosslang.tesseslanguage.com/",
|
"homepage": "https://crosslang.tesseslanguage.com/",
|
||||||
"license": "LGPLv3"
|
"license": "LGPLv3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
func main(args)
|
func main(args)
|
||||||
{
|
{
|
||||||
var dd = Tesses.CrossLang.Args(args);
|
var dd = Tesses.CrossLang.Args(args);
|
||||||
if(dd.Arguments.Count > 0)
|
|
||||||
|
if(dd.Arguments.Count > 0)
|
||||||
{
|
{
|
||||||
var commandName = dd.Arguments[0];
|
var commandName = dd.Arguments[0];
|
||||||
|
|
||||||
if(commandName == "args")
|
if(commandName == "args")
|
||||||
{
|
{
|
||||||
each(var arg : dd.Arguments)
|
each(var arg : dd.Arguments)
|
||||||
@@ -11,7 +13,7 @@ func main(args)
|
|||||||
Console.WriteLine(arg);
|
Console.WriteLine(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(commandName == "build")
|
else if(commandName == "build")
|
||||||
{
|
{
|
||||||
var offline=false;
|
var offline=false;
|
||||||
var buildPath = ".";
|
var buildPath = ".";
|
||||||
@@ -53,12 +55,148 @@ func main(args)
|
|||||||
env.LockRegister();
|
env.LockRegister();
|
||||||
|
|
||||||
env.LoadFileWithDependencies(FS.Local,output);
|
env.LoadFileWithDependencies(FS.Local,output);
|
||||||
var myArgs = [];
|
var myArgs = [output];
|
||||||
for(var i = 1; i < dd.Arguments.Count; i++)
|
for(var i = 1; i < dd.Arguments.Count; i++)
|
||||||
{
|
{
|
||||||
myArgs.Add(dd.Arguments[i]);
|
myArgs.Add(dd.Arguments[i]);
|
||||||
}
|
}
|
||||||
return env.GetDictionary().main(myArgs);
|
return env.GetDictionary().main(myArgs);
|
||||||
}
|
}
|
||||||
|
else if(commandName == "new")
|
||||||
|
{
|
||||||
|
func newHelp()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"{dd.FileName} new [FLAGS] <template_name> [directory_for_project]");
|
||||||
|
Console.WriteLine("FLAGS");
|
||||||
|
Console.WriteLine("--help: Shows this help");
|
||||||
|
Console.WriteLine("--list: Lists all templates");
|
||||||
|
Console.WriteLine("ARGUMENTS:");
|
||||||
|
Console.WriteLine("template_name: The name of the template");
|
||||||
|
Console.WriteLine("directory_for_project: The directory for the project, defaults to current directory");
|
||||||
|
}
|
||||||
|
var dir = FS.MakeFull(Env.Config) / "Tesses" / "CrossLang" / "Templates";
|
||||||
|
|
||||||
|
each(var flag : dd.Flags)
|
||||||
|
{
|
||||||
|
if(flag == "list")
|
||||||
|
{
|
||||||
|
Console.WriteLine("List of templates:");
|
||||||
|
each(var item : FS.Local.EnumeratePaths(dir))
|
||||||
|
{
|
||||||
|
Console.WriteLine(item.ChangeExtension().GetFileName());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(flag == "help")
|
||||||
|
{
|
||||||
|
newHelp();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dd.Arguments.Count < 2)
|
||||||
|
{
|
||||||
|
newHelp();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var templateFile = dir / $"{dd.Arguments[1]}.crvm";
|
||||||
|
if(FS.Local.RegularFileExists(templateFile))
|
||||||
|
{
|
||||||
|
var projectPath = ".";
|
||||||
|
if(dd.Arguments.Count > 2) projectPath = dd.Arguments[2];
|
||||||
|
|
||||||
|
projectPath = FS.MakeFull(projectPath);
|
||||||
|
|
||||||
|
FS.Local.CreateDirectory(projectPath);
|
||||||
|
|
||||||
|
var projectDir = FS.SubdirFilesystem(FS.Local, projectPath);
|
||||||
|
|
||||||
|
|
||||||
|
var strm = FS.Local.OpenFile(templateFile,"rb");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var res = FS.ExtractArchive(strm,projectDir);
|
||||||
|
|
||||||
|
|
||||||
|
strm.Close();
|
||||||
|
|
||||||
|
if(!projectDir.RegularFileExists("/cross.json"))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Could not find /cross.json in template");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var jsonText = FS.ReadAllText(projectDir, "/cross.json");
|
||||||
|
var proj = Json.Decode(jsonText);
|
||||||
|
|
||||||
|
proj.name = projectPath.GetFileName();
|
||||||
|
proj.version = "1.0.0.0-prod";
|
||||||
|
var old_info = proj.info;
|
||||||
|
proj.info = old_info.template_info;
|
||||||
|
proj.dependencies = old_info.template_project_dependencies;
|
||||||
|
var srcDir = proj.source_directory;
|
||||||
|
if(TypeOf(srcDir) == "Undefined") srcDir = "/src";
|
||||||
|
|
||||||
|
var filesToMutate = old_info.template_extra_text_ftles;
|
||||||
|
|
||||||
|
if(TypeOf(filesToMutate) == "Undefined") filesToMutate = [];
|
||||||
|
|
||||||
|
each(var f : projectDir.EnumeratePaths(srcDir))
|
||||||
|
{
|
||||||
|
if(projectDir.RegularFileExists(f) && f.GetExtension() == ".tcross")
|
||||||
|
{
|
||||||
|
filesToMutate.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
each(var ent : filesToMutate)
|
||||||
|
{
|
||||||
|
if(projectDir.RegularFileExists(ent))
|
||||||
|
{
|
||||||
|
var src = FS.ReadAllText(projectDir, ent);
|
||||||
|
|
||||||
|
var src = src.Replace("%PROJECT_NAME%",projectPath.GetFileName());
|
||||||
|
|
||||||
|
var src = src.Replace("%TEMPLATE_PROJECT_NAME%","%PROJECT_NAME");
|
||||||
|
|
||||||
|
FS.WriteAllText(projectDir, ent, src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FS.WriteAllText(projectDir, "/cross.json", Json.Encode(proj,true));
|
||||||
|
|
||||||
|
projectDir.Close();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error could not find template {templateFile}");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(commandName == "install-template")
|
||||||
|
{
|
||||||
|
//crosslang install-template Tesses.CrossLang.Template.Console --version=1.0.0.0-prod
|
||||||
|
}
|
||||||
|
else if(commandName == "install-tool")
|
||||||
|
{
|
||||||
|
//crosslang install-tool Tesses.CrossLang.Tool.SomeTool --version=1.0.0.0-prod
|
||||||
|
}
|
||||||
|
else if(commandName == "add-project")
|
||||||
|
{
|
||||||
|
//crosslang add-project /path/to/project
|
||||||
|
}
|
||||||
|
else if(commandName == "add-dependency")
|
||||||
|
{
|
||||||
|
//crosslang add-dependency Tesses.CrossLang.Markup --version=1.0.0.0-prod
|
||||||
|
}
|
||||||
|
else if(commandName == "upload-package")
|
||||||
|
{
|
||||||
|
//crosslang upload-package [PACKAGE_NAME]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
3
Tesses.CrossLang.WebSite/components/counter.tcrml
Normal file
3
Tesses.CrossLang.WebSite/components/counter.tcrml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<?component() name="Counter" ?>
|
||||||
|
<p>Count is <?expr count++ ?></p>
|
||||||
|
<?end?>
|
||||||
36
Tesses.CrossLang.WebSite/components/shell.tcrml
Normal file
36
Tesses.CrossLang.WebSite/components/shell.tcrml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?resource name="simple.min.css" route="/css/simple.min.css" ?>
|
||||||
|
<?resource name="favicon.ico" route="/favicon.ico" ?>
|
||||||
|
<?component(title,pages,body) name="Shell" ?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>CrossLang - <?expr Net.Http.HtmlEncode(title) ?></title>
|
||||||
|
<link rel="stylesheet" href="./css/simple.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>CrossLang</h1>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<?code
|
||||||
|
each(var item : pages)
|
||||||
|
{
|
||||||
|
?>
|
||||||
|
<li><a <?code if(item.active) { ?> aria-current="page" <?code } ?> href="<?expr Net.Http.UrlPathEncode(item.route) ?>"><?expr Net.Http.HtmlEncode(item.text) ?></a></li>
|
||||||
|
<?code
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<h1><?expr Net.Http.HtmlEncode(title) ?></h1>
|
||||||
|
<?body?>
|
||||||
|
<?end?>
|
||||||
|
<footer>
|
||||||
|
<p>Created using <a href="https://crosslang.tesseslanguage.com/">CrossLang</a> and <a href="https://simplecss.org/">SimpleCSS</a></p>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<?end?>
|
||||||
8
Tesses.CrossLang.WebSite/cross.json
Normal file
8
Tesses.CrossLang.WebSite/cross.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"project_dependencies": ["../Tesses.CrossLang.Markup"],
|
||||||
|
"info": {
|
||||||
|
"type": "console"
|
||||||
|
},
|
||||||
|
"version": "1.0.0.0-prod",
|
||||||
|
"name": "Tesses.CrossLang.WebSite"
|
||||||
|
}
|
||||||
35
Tesses.CrossLang.WebSite/pages/downloads.tcrml
Normal file
35
Tesses.CrossLang.WebSite/pages/downloads.tcrml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?page() route="/downloads" ?>
|
||||||
|
<?code
|
||||||
|
var pages = [
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/",
|
||||||
|
text = "Home"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = true,
|
||||||
|
route = "/downloads",
|
||||||
|
text = "Downloads"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
?>
|
||||||
|
<?Shell?>
|
||||||
|
<?arg "Downloads" ?>
|
||||||
|
<?arg pages ?>
|
||||||
|
<?arg_component() ?>
|
||||||
|
<h2>Source Code</h2>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://onedev.site.tesses.net/crosslang">CrossLang</a></li>
|
||||||
|
<li><a href="https://onedev.site.tesses.net/crosslang/crosslangextras">CrossLang Essentials</a></li>
|
||||||
|
</ul>
|
||||||
|
<h2>Binaries</h2>
|
||||||
|
<!--<ul>
|
||||||
|
<li><a href="./downloads/windows">Windows</a></li>
|
||||||
|
<li><a href="./downloads/mac">Mac</a></li>
|
||||||
|
<li><a href="./downloads/linux">Linux</a></li>
|
||||||
|
<li><a href="./downloads/wii">Wii</a></li>
|
||||||
|
<li><a href="./downloads/iso">ISO (Burn to Disc)</a></li>
|
||||||
|
</ul>-->
|
||||||
|
<?end?>
|
||||||
|
<?end?>
|
||||||
|
<?end?>
|
||||||
24
Tesses.CrossLang.WebSite/pages/index.tcrml
Normal file
24
Tesses.CrossLang.WebSite/pages/index.tcrml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?page() route="/" ?>
|
||||||
|
<?code
|
||||||
|
var pages = [
|
||||||
|
{
|
||||||
|
active = true,
|
||||||
|
route = "/",
|
||||||
|
text = "Home"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
active = false,
|
||||||
|
route = "/downloads",
|
||||||
|
text = "Downloads"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
?>
|
||||||
|
<?Shell?>
|
||||||
|
<?arg "Home" ?>
|
||||||
|
<?arg pages ?>
|
||||||
|
<?arg_component() ?>
|
||||||
|
<p>This is the website for my programming language</p>
|
||||||
|
<p>1 John 4:4: You, dear children, are from God and have overcome them, because the one who is in you is greater than the one who is in the world.</p>
|
||||||
|
<?end?>
|
||||||
|
<?end?>
|
||||||
|
<?end?>
|
||||||
BIN
Tesses.CrossLang.WebSite/res/favicon.ico
Normal file
BIN
Tesses.CrossLang.WebSite/res/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
1
Tesses.CrossLang.WebSite/res/simple.min.css
vendored
Normal file
1
Tesses.CrossLang.WebSite/res/simple.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
5
Tesses.CrossLang.WebSite/src/program.tcross
Normal file
5
Tesses.CrossLang.WebSite/src/program.tcross
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
var count = 0;
|
||||||
|
func main(args)
|
||||||
|
{
|
||||||
|
Net.Http.ListenSimpleWithLoop(Router,4206);
|
||||||
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
func downloadPackage(name,version,path)
|
|
||||||
{
|
|
||||||
var uri = $"https://cpkg.tesseslanguage.com/api/v1/download?name={Net.Http.UrlEncode(name)}&version={Net.Http.UrlEncode(version)}";
|
|
||||||
var req = Net.Http.MakeRequest(uri);
|
|
||||||
if(req.StatusCode == 200)
|
|
||||||
{
|
|
||||||
var strm = FS.MemoryStream(true);
|
|
||||||
req.CopyToStream(strm);
|
|
||||||
|
|
||||||
var f = FS.Local.OpenFile(path,"wb");
|
|
||||||
strm.Seek(0,0);
|
|
||||||
strm.CopyTo(f);
|
|
||||||
f.Close();
|
|
||||||
|
|
||||||
strm.Close();
|
|
||||||
req.Close();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw $"Error when downloading package {name} with version {version}";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var shellDir = Path.FromString(Env.Config) / "Tesses" / "CrossLang" / "Shell";
|
|
||||||
FS.Local.CreateDirectory(shellDir);
|
|
||||||
|
|
||||||
downloadPackage("Tesses.CrossLang.Shell", "1.0.0.0-prod", shellDir / "Shell.crvm");
|
|
||||||
downloadPackage("Tesses.CrossLang.Args", "1.0.0.0-prod", shellDir / "Tesses.CrossLang.Args-1.0.0.0-prod.crvm");
|
|
||||||
downloadPackage("Tesses.CrossLang.BuildEssentials", "1.0.0.0-prod", shellDir / "Tesses.CrossLang.BuildEssentials-1.0.0.0-prod.crvm");
|
|
||||||
@@ -1 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
bash ./script.sh
|
||||||
|
crossvm crosslang_shell_archive_maker/bin/crosslang_shell_archive_maker-1.0.0.0-prod.crvm install
|
||||||
@@ -2,4 +2,10 @@
|
|||||||
cd Tesses.CrossLang.BuildEssentials && crossc -o ./bin-tmp -n Tesses.CrossLang.BuildEssentials -v 1.0.0.0-prod main.tcross src/*.tcross && cd ..
|
cd Tesses.CrossLang.BuildEssentials && crossc -o ./bin-tmp -n Tesses.CrossLang.BuildEssentials -v 1.0.0.0-prod main.tcross src/*.tcross && cd ..
|
||||||
crossvm ./Tesses.CrossLang.BuildEssentials/bin-tmp/Tesses.CrossLang.BuildEssentials-1.0.0.0-prod.crvm Tesses.CrossLang.Shell
|
crossvm ./Tesses.CrossLang.BuildEssentials/bin-tmp/Tesses.CrossLang.BuildEssentials-1.0.0.0-prod.crvm Tesses.CrossLang.Shell
|
||||||
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.PackageServer
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.PackageServer
|
||||||
#crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.Website
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Templates/console
|
||||||
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Templates/web
|
||||||
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Templates/template
|
||||||
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Templates/lib
|
||||||
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Templates/compiletool
|
||||||
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build crosslang_shell_archive_maker
|
||||||
|
crossvm ./Tesses.CrossLang.Shell/bin/Tesses.CrossLang.Shell-1.0.0.0-prod.crvm build Tesses.CrossLang.Website
|
||||||
|
|||||||
Reference in New Issue
Block a user