From 67e115705e4b81d7c9bb33d10771f8c5b45efd23 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Mon, 26 May 2025 13:10:46 -0500 Subject: [PATCH] Add json listing for crosslang new --- Templates/emptyweb/components/shell.tcrml | 14 -------- Templates/emptyweb/pages/index.tcrml | 7 ---- Templates/emptyweb/src/pages/index.tcross | 3 ++ Templates/web/components/counter.tcrml | 3 -- Templates/web/components/shell.tcrml | 36 ------------------- Templates/web/pages/about.tcrml | 28 --------------- Templates/web/pages/counter.tcrml | 29 --------------- Templates/web/pages/index.tcrml | 28 --------------- Templates/web/src/components/shell.tcross | 25 +++++++------ Templates/web/src/program.tcross | 23 +++++++++++- .../src/buildtool.tcross | 3 +- .../src/helpers.tcross | 22 ++++++++++++ Tesses.CrossLang.Shell/src/main.tcross | 26 ++++++++++++-- 13 files changed, 86 insertions(+), 161 deletions(-) delete mode 100644 Templates/emptyweb/components/shell.tcrml delete mode 100644 Templates/emptyweb/pages/index.tcrml delete mode 100644 Templates/web/components/counter.tcrml delete mode 100644 Templates/web/components/shell.tcrml delete mode 100644 Templates/web/pages/about.tcrml delete mode 100644 Templates/web/pages/counter.tcrml delete mode 100644 Templates/web/pages/index.tcrml diff --git a/Templates/emptyweb/components/shell.tcrml b/Templates/emptyweb/components/shell.tcrml deleted file mode 100644 index 2e8d60a..0000000 --- a/Templates/emptyweb/components/shell.tcrml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - Hello, world - - - - - - - \ No newline at end of file diff --git a/Templates/emptyweb/pages/index.tcrml b/Templates/emptyweb/pages/index.tcrml deleted file mode 100644 index 206adec..0000000 --- a/Templates/emptyweb/pages/index.tcrml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Templates/emptyweb/src/pages/index.tcross b/Templates/emptyweb/src/pages/index.tcross index 7695d73..894abfa 100644 --- a/Templates/emptyweb/src/pages/index.tcross +++ b/Templates/emptyweb/src/pages/index.tcross @@ -2,8 +2,11 @@ var count = 0; func Pages.Index() { + //use null when you wan't to use multiple tags but not emit a div or anything like that return Components.Shell( +

Hello, world

Views: {++count} +
); } \ No newline at end of file diff --git a/Templates/web/components/counter.tcrml b/Templates/web/components/counter.tcrml deleted file mode 100644 index 1b4fca4..0000000 --- a/Templates/web/components/counter.tcrml +++ /dev/null @@ -1,3 +0,0 @@ - -

Count is

- \ No newline at end of file diff --git a/Templates/web/components/shell.tcrml b/Templates/web/components/shell.tcrml deleted file mode 100644 index cc7c1ff..0000000 --- a/Templates/web/components/shell.tcrml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - %PROJECT_NAME% - <?expr Net.Http.HtmlEncode(title) ?> - - - -
-

%PROJECT_NAME%

- -
-

- - - - - - \ No newline at end of file diff --git a/Templates/web/pages/about.tcrml b/Templates/web/pages/about.tcrml deleted file mode 100644 index a80bec2..0000000 --- a/Templates/web/pages/about.tcrml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

Lorem ipsum dolor sit amet consectetur adipisicing elit. Laboriosam possimus nisi ab nobis magni, error minus vero neque iusto beatae, quasi nostrum. Ut repudiandae expedita reprehenderit tenetur. Sunt, adipisci cumque!

- - - diff --git a/Templates/web/pages/counter.tcrml b/Templates/web/pages/counter.tcrml deleted file mode 100644 index 3db6f57..0000000 --- a/Templates/web/pages/counter.tcrml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - diff --git a/Templates/web/pages/index.tcrml b/Templates/web/pages/index.tcrml deleted file mode 100644 index 64a70c2..0000000 --- a/Templates/web/pages/index.tcrml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - -

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.

- - - diff --git a/Templates/web/src/components/shell.tcross b/Templates/web/src/components/shell.tcross index 9ae86c3..a2a9032 100644 --- a/Templates/web/src/components/shell.tcross +++ b/Templates/web/src/components/shell.tcross @@ -13,20 +13,23 @@ func Components.Shell(title,pages,body)

%PROJECT_NAME%

-

- - +

{title}

+ diff --git a/Templates/web/src/program.tcross b/Templates/web/src/program.tcross index 460701f..671f65f 100644 --- a/Templates/web/src/program.tcross +++ b/Templates/web/src/program.tcross @@ -7,7 +7,27 @@ func main(args) ctx.WithMimeType("text/html").SendText(Pages.Index()); return true; } - else if(ctx.Path == "/simple.min.css") + else if(ctx.Path == "/counter") + { + ctx.WithMimeType("text/html").SendText(Pages.Counter()); + return true; + } + else if(ctx.Path == "/about") + { + ctx.WithMimeType("text/html").SendText(Pages.Index()); + return true; + } + else if(ctx.Path == "/echo") + { + ctx.WithMimeType("text/html").SendText(Pages.Echo(ctx.QueryParams.TryGetFirst("text"))); + return true; + } + else if(ctx.Path == "/image.png") + { + ctx.WithMimeType("image/png").SendBytes(embed("image.png")); + return true; + } + else if(ctx.Path == "/css/simple.min.css") { ctx.WithMimeType("text/css").SendBytes(embed("simple.min.css")); return true; @@ -17,5 +37,6 @@ func main(args) ctx.WithMimeType("image/x-icon").SendBytes(embed("favicon.ico")); return true; } + return false; },4206); } \ No newline at end of file diff --git a/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross b/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross index 86dadb9..48f1e82 100644 --- a/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross +++ b/Tesses.CrossLang.BuildEssentials/src/buildtool.tcross @@ -196,6 +196,7 @@ func Tesses.CrossLang.BuildTool(pm) } else if(dep.Info.type == "compile_tool") { + file_tools.Add({ Name = dep.Name, Version = dep.Version @@ -208,7 +209,7 @@ func Tesses.CrossLang.BuildTool(pm) { each(var file : FS.Local.EnumeratePaths(sourceDir)) { - if(FS.Local.RegularFileExists(file)) + if(FS.Local.RegularFileExists(file) && file.GetExtension()==".tcross") { var src = { FileName = file.ToString(), diff --git a/Tesses.CrossLang.BuildEssentials/src/helpers.tcross b/Tesses.CrossLang.BuildEssentials/src/helpers.tcross index 5dc88a8..86c05ba 100644 --- a/Tesses.CrossLang.BuildEssentials/src/helpers.tcross +++ b/Tesses.CrossLang.BuildEssentials/src/helpers.tcross @@ -16,4 +16,26 @@ func Tesses.CrossLang.GetNameAndDescription(name) name = TypeOf(j.toolname) == "String" ? j.toolname : name; return $"{name}: {description}"; +} +func Tesses.CrossLang.GetNameAndDescriptionJson(name) +{ + var strm = FS.Local.OpenFile(name,"rb"); + var file = VM.LoadExecutable(strm); + + strm.Close(); + + var name = file.Name; + + var j = Json.Decode(file.Info); + var description = TypeOf(j.description) == "String" ? j.description : ""; + + if(j.type == "template") + 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 + }; } \ No newline at end of file diff --git a/Tesses.CrossLang.Shell/src/main.tcross b/Tesses.CrossLang.Shell/src/main.tcross index 68b50dd..6752117 100644 --- a/Tesses.CrossLang.Shell/src/main.tcross +++ b/Tesses.CrossLang.Shell/src/main.tcross @@ -335,6 +335,7 @@ func main(args) Console.WriteLine("FLAGS"); Console.WriteLine("--help: Shows this help"); Console.WriteLine("--list: Lists all templates"); + Console.WriteLine("--list-json: List all templates (as json)"); 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"); @@ -352,6 +353,16 @@ func main(args) } return 0; } + else if(flag == "list-json") + { + var items = []; + each(var item : FS.Local.EnumeratePaths(dir)) + { + items.Add(Tesses.CrossLang.GetNameAndDescriptionJson(item)); + } + Console.WriteLine(items); + return 0; + } else if(flag == "help") { newHelp(); @@ -409,13 +420,21 @@ func main(args) if(TypeOf(filesToMutate) == "Undefined") filesToMutate = []; - each(var f : projectDir.EnumeratePaths(srcDir)) + func mutateDir(dir) { - if(projectDir.RegularFileExists(f) && f.GetExtension() == ".tcross") + each(var f : projectDir.EnumeratePaths(dir)) { - filesToMutate.Add(f); + if(projectDir.RegularFileExists(f) && f.GetExtension() == ".tcross") + { + filesToMutate.Add(f); + } + else if(projectDir.DirectoryExists(f)) + { + mutateDir(f); + } } } + mutateDir(srcDir); each(var ent : filesToMutate) { @@ -429,6 +448,7 @@ func main(args) FS.WriteAllText(projectDir, ent, src); } + } FS.WriteAllText(projectDir, "/cross.json", Json.Encode(proj,true));