public static async Task <TypeScriptProject> Create(string directory) { return(await Task.Run(() => { TypeScriptProject result = new TypeScriptProject(); var projectName = new DirectoryInfo(directory).Name; //Create new project with default name and extension var projectFileLocation = Path.Combine(directory, projectName + $".{result.Extension}"); result.Location = projectFileLocation; //Create Main.TS file var indexFileLocation = Path.Combine(directory, "main.ts"); if (!System.IO.File.Exists(indexFileLocation)) { System.IO.File.WriteAllText(indexFileLocation, @" class Program { static main() { console.log(""Hello, World!""); } } Program.main(); "); } //Create TypeScript project file var tsProjectFileLocation = Path.Combine(directory, "tsconfig.json"); if (!System.IO.File.Exists(tsProjectFileLocation)) { System.IO.File.WriteAllText(tsProjectFileLocation, @" { ""compilerOptions"": { ""target"": ""es5"", ""module"": ""commonjs"", ""sourceMap"": true } } "); } result.Save(); return result; })); }
public virtual async Task <IProject> Generate(ISolution solution, string name) { var location = Path.Combine(solution.CurrentDirectory, name); Directory.CreateDirectory(location); IProject project = await TypeScriptProject.Create(solution, location); project = solution.AddProject(project); if (solution.StartupProject == null) { solution.StartupProject = project; } return(project); }