public bool Execute() { string src = SourceFile.GetMetadata("FullPath"); string dest = (DestinationFile?.GetMetadata("FullPath") ?? Path.Combine(Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode), "appsettings.json")); foreach (string path in JPath.Split(new char[] { ';', ',' }, System.StringSplitOptions.RemoveEmptyEntries)) { Json.CopyJsonProperty(src, dest, path); BuildEngine.Info($"Copied '{path}' property to '{Path.GetFileName(dest)}'"); } return(true); }
public bool Execute() { Enum.TryParse(OutputType, out FileType kind); var options = new TypescriptGeneratorSettings(Namespace, Prefix, Suffix, AsAbstract, (kind == FileType.KnockoutJs), References); if (_sourceFiles == null) { _sourceFiles = SourceFiles.Select(x => x.GetMetadata("FullPath")).ToArray(); } BuildEngine.Debug("Generating typescript models ..."); foreach (string filePath in _sourceFiles) { BuildEngine.Debug($"src: '{filePath}'"); } byte[] data; switch (kind) { default: case FileType.Model: data = TypescriptGenerator.Emit(options, _sourceFiles); break; case FileType.KnockoutJs: data = KnockoutJsGenerator.Emit(options, _sourceFiles); break; case FileType.Declaration: data = DeclarationFileGenerator.Emit(options, _sourceFiles); break; } if (string.IsNullOrEmpty(_outputFile)) { _outputFile = DestinationFile.GetMetadata("FullPath"); } string folder = Path.GetDirectoryName(_outputFile); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } File.WriteAllBytes(_outputFile, data); BuildEngine.Info($"Generated typescript file at '{_outputFile}'.", nameof(GenerateTypescriptModels)); return(true); }
public bool Execute() { NodeJS.Install((msg, _, __) => { BuildEngine.Info(msg); }); string projectFolder = Path.GetDirectoryName(BuildEngine.ProjectFileOfTaskNode); string configFilePath = (ConfigurationFile?.GetMetadata("FullPath") ?? Compiler.FindConfigurationFile(projectFolder)); var options = new Configuration.CompilerOptions( configFilePath, Minify, GenerateSourceMaps); CompilerResult result = Compiler.Run(options, projectFolder); foreach (CompilerError err in result.Errors) { Log(err); } Log(result); return(result.HasErrors == false); }