mirror of
https://onedev.site.tesses.net/crosslang/crosslangdevstudio
synced 2026-02-08 09:15:45 +00:00
Get way further
This commit is contained in:
@@ -27,7 +27,7 @@ class CrossLangShell
|
||||
return ["https://cpkg.tesseslanguage.com/"];
|
||||
}
|
||||
public static string[] ProjectTypes { get; } = ["console", "lib", "webapp", "template", "compile_tool", "tool", "archive"];
|
||||
public static string[] ProjectProperTypes { get; } = ["Console Application","Library","Web Application","Template","Compile Tool","Tool","Archive"];
|
||||
public static string[] ProjectProperTypes { get; } = ["Console Application", "Library", "Web Application", "Template", "Compile Tool", "Tool", "Archive"];
|
||||
private static void EscapeBashElement(StringBuilder builder, string val)
|
||||
{
|
||||
builder.Append("\"");
|
||||
@@ -53,27 +53,27 @@ class CrossLangShell
|
||||
private static string EscapeBashCommand(string name, string[] args)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
EscapeBashElement(builder,name);
|
||||
EscapeBashElement(builder, name);
|
||||
foreach (var item in args)
|
||||
{
|
||||
builder.Append(' ');
|
||||
EscapeBashElement(builder,item);
|
||||
EscapeBashElement(builder, item);
|
||||
}
|
||||
builder.Append(" ; read -p \"Press Enter to close.\"");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static string EscapeMacBashCommand(string workDir, bool keepOpen,string name, string[] args)
|
||||
private static string EscapeMacBashCommand(string workDir, bool keepOpen, string name, string[] args)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append("cd ");
|
||||
EscapeBashElement(builder, workDir);
|
||||
builder.Append(" ; ");
|
||||
EscapeBashElement(builder,name);
|
||||
EscapeBashElement(builder, name);
|
||||
foreach (var item in args)
|
||||
{
|
||||
builder.Append(' ');
|
||||
EscapeBashElement(builder,item);
|
||||
EscapeBashElement(builder, item);
|
||||
}
|
||||
if (keepOpen)
|
||||
builder.Append(" ; read -p \"Press Enter to close.\"");
|
||||
@@ -96,7 +96,7 @@ class CrossLangShell
|
||||
settings = JsonConvert.DeserializeObject<CrossLangSettings>(File.ReadAllText(settingsFile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return settings is null ? settings = new CrossLangSettings() : settings;
|
||||
}
|
||||
}
|
||||
@@ -158,18 +158,18 @@ class CrossLangShell
|
||||
if (execDir is not null)
|
||||
{
|
||||
var dir = Path.GetDirectoryName(execDir);
|
||||
if(dir is not null)
|
||||
if (dir is not null)
|
||||
paths.Add(dir);
|
||||
}
|
||||
foreach (var item in paths)
|
||||
{
|
||||
var path = Path.Combine(item, exec);
|
||||
if (File.Exists(path)) return path;
|
||||
foreach (var ext in (Environment.GetEnvironmentVariable("PATHEXT") ?? "").Split(Path.PathSeparator))
|
||||
{
|
||||
var path = Path.Combine(item, exec);
|
||||
if (File.Exists(path)) return path;
|
||||
foreach (var ext in (Environment.GetEnvironmentVariable("PATHEXT") ?? "").Split(Path.PathSeparator))
|
||||
{
|
||||
if (File.Exists(path + ext)) return path + ext;
|
||||
}
|
||||
if (File.Exists(path + ext)) return path + ext;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -188,6 +188,10 @@ class CrossLangShell
|
||||
return !string.IsNullOrWhiteSpace(CrossLangPath);
|
||||
}
|
||||
}
|
||||
public static void PushProjectInFolder(string folder)
|
||||
{
|
||||
OpenTerminal(false, folder, CrossLangPath, "upload-package");
|
||||
}
|
||||
public static void BuildProjectInFolder(string folder)
|
||||
{
|
||||
OpenTerminal(false, folder, CrossLangPath, "build");
|
||||
@@ -252,7 +256,7 @@ class CrossLangShell
|
||||
}
|
||||
process.Start();
|
||||
}
|
||||
if (File.Exists(xfce_terminal))
|
||||
else if (File.Exists(xfce_terminal))
|
||||
{
|
||||
using Process process = new Process();
|
||||
process.StartInfo.WorkingDirectory = workingDirectory;
|
||||
@@ -435,11 +439,40 @@ class CrossLangShell
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task RunCommandAsync(string workingDirectory, string commandName, params string[] args)
|
||||
{
|
||||
using Process process = new();
|
||||
process.StartInfo.WorkingDirectory = workingDirectory;
|
||||
process.StartInfo.FileName = GetRealPath(commandName);
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
foreach (var arg in args)
|
||||
process.StartInfo.ArgumentList.Add(arg);
|
||||
|
||||
if (process.Start()) await process.WaitForExitAsync();
|
||||
}
|
||||
|
||||
private static string GetCrossLangDirectory()
|
||||
{
|
||||
|
||||
string path = CrossLangPath;
|
||||
if (string.IsNullOrWhiteSpace(path)) return "";
|
||||
using Process process0 = new Process();
|
||||
process0.StartInfo.ArgumentList.Add("configdir");
|
||||
process0.StartInfo.FileName = path;
|
||||
process0.StartInfo.CreateNoWindow = true;
|
||||
process0.StartInfo.RedirectStandardOutput = true;
|
||||
process0.StartInfo.UseShellExecute = false;
|
||||
process0.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
process0.StartInfo.RedirectStandardInput = true;
|
||||
if (process0.Start())
|
||||
{
|
||||
process0.StandardInput.WriteLine("y");
|
||||
process0.WaitForExit();
|
||||
var text = process0.StandardOutput.ReadToEnd();
|
||||
return (text ?? "").Replace("\n", "").Replace("\r", "");
|
||||
}
|
||||
using Process process = new Process();
|
||||
process.StartInfo.ArgumentList.Add("configdir");
|
||||
process.StartInfo.FileName = path;
|
||||
@@ -457,6 +490,29 @@ class CrossLangShell
|
||||
return "";
|
||||
}
|
||||
|
||||
public async Task<string> GetReferenceAsync()
|
||||
{
|
||||
await RunCommandAsync(Environment.CurrentDirectory, "crosslang", "docs", "--reference");
|
||||
string path = CrossLangPath;
|
||||
if (string.IsNullOrWhiteSpace(path)) return "";
|
||||
using Process process = new Process();
|
||||
process.StartInfo.ArgumentList.Add("docs");
|
||||
process.StartInfo.ArgumentList.Add("--reference-path");
|
||||
process.StartInfo.FileName = path;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
process.StartInfo.RedirectStandardOutput = true;
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
if (process.Start())
|
||||
{
|
||||
|
||||
process.WaitForExit();
|
||||
var text = process.StandardOutput.ReadToEnd();
|
||||
return (text ?? "").Replace("\n", "").Replace("\r", "");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
internal static bool CreateProject(string templateName, string path)
|
||||
{
|
||||
string cpath = CrossLangPath;
|
||||
@@ -478,6 +534,18 @@ class CrossLangShell
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static async Task PublishAsync(string project, string identifier, string prefix, string outputDir)
|
||||
{
|
||||
List<string> args = new List<string>();
|
||||
args.Add("publish");
|
||||
args.Add($"--runtime-package-prefix={prefix}");
|
||||
if (!string.IsNullOrWhiteSpace(outputDir))
|
||||
args.Add($"--out={outputDir}");
|
||||
args.Add(identifier);
|
||||
|
||||
await RunCommandAsync(project,"crosslang",args.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public class CrossLangSettings
|
||||
|
||||
Reference in New Issue
Block a user