internal static void DoCreateTasks(ILog log, FsPath workDir) { Domain.VsTasks.VsTaskRoot Tasks = VsTaskFactory.CreateTasks(); FsPath file = workDir.Combine(".vscode\\tasks.json"); file.SerializeJson(Tasks, log); }
public bool TryLoadAndValidateConfig(out Config?config) { config = null; if (!_configfile.IsExisting) { _log.Info("No bookgen.json config found."); return(false); } config = _configfile.DeserializeJson <Config>(_log); if (config == null) { _log.Critical("bookgen.json deserialize error. Invalid config file"); return(false); } if (config.Version < Program.CurrentState.ConfigVersion) { _configfile.CreateBackup(_log); config.UpgradeTo(Program.CurrentState.ConfigVersion); _configfile.SerializeJson(config, _log, true); _log.Info("Configuration file migrated to new version."); _log.Info("Review configuration then run program again"); return(false); } ConfigValidator validator = new ConfigValidator(config, _workdir); validator.Validate(); if (!validator.IsValid) { _log.Warning("Errors found in configuration: "); foreach (var error in validator.Errors) { _log.Warning(error); } return(false); } return(true); }
public static void DoCreateConfig(ILog log, FsPath ConfigFile, bool createdmdFiles, bool extractedTemplate, bool createdScript) { Config configuration = Config.CreateDefault(Program.CurrentState.ConfigVersion); if (createdmdFiles) { configuration.Index = "index.md"; configuration.TOCFile = "summary.md"; } if (createdScript) { configuration.ScriptsDirectory = "Scripts"; } if (extractedTemplate) { configuration.TargetEpub.TemplateFile = EpubTemplateLocation; configuration.TargetPrint.TemplateFile = PrintTemplateLocation; configuration.TargetWeb.TemplateFile = WebTemplate; configuration.TargetWeb.TemplateAssets = new List <Asset> { new Asset { Source = "Templates\\Assets\\prism.css", Target = "Assets\\prism.css" }, new Asset { Source = "Templates\\Assets\\prism.js", Target = "Assets\\prism.js" } }; } log.Info("Creating config file: {0}", ConfigFile.ToString()); ConfigFile.SerializeJson(configuration, log); }