public bool IsCleanRepo(ISourceRepo repo) { (_, string expectedPublishDir) = GetProjectFileAndPublishDir(repo); return(!repo.DirExists(expectedPublishDir)); }
/// <inheritdoc/> public bool IsCleanRepo(ISourceRepo repo) { // TODO: support venvs return(!repo.DirExists(PythonConstants.DefaultTargetPackageDirectory)); }
/// <summary> /// Checks whether or not the given repository is a Hugo application. /// </summary> /// <param name="sourceRepo">Source repo for the application.</param> /// <param name="environment">Environment abstraction.</param> /// <returns>True if the app is a Hugo app, false otherwise.</returns> public static bool IsHugoApp(ISourceRepo sourceRepo, IEnvironment environment) { // Check for Hugo environment variables var environmentVariables = environment.GetEnvironmentVariables(); foreach (var key in environmentVariables?.Keys) { if (key.ToString().StartsWith(HugoEnvironmentVariablePrefix)) { return(true); } } // Hugo configuration variables: https://gohugo.io/getting-started/configuration/#all-configuration-settings var tomlFilePaths = new List <string>(); var yamlFilePaths = new List <string>(); var jsonFilePaths = new List <string>(); // Search for config.toml if (sourceRepo.FileExists(NodeConstants.HugoTomlFileName)) { tomlFilePaths.Add(Path.Combine(sourceRepo.RootPath, NodeConstants.HugoTomlFileName)); } // Search for config.yaml if (sourceRepo.FileExists(NodeConstants.HugoYamlFileName)) { yamlFilePaths.Add(Path.Combine(sourceRepo.RootPath, NodeConstants.HugoYamlFileName)); } // Search for config.json if (sourceRepo.FileExists(NodeConstants.HugoJsonFileName)) { jsonFilePaths.Add(Path.Combine(sourceRepo.RootPath, NodeConstants.HugoJsonFileName)); } if (sourceRepo.DirExists(NodeConstants.HugoConfigFolderName)) { var configSourceRepo = new LocalSourceRepo(Path.Combine(sourceRepo.RootPath, NodeConstants.HugoConfigFolderName)); // Search for config/*.toml tomlFilePaths.AddRange(configSourceRepo.EnumerateFiles("*.toml", true)); // Search for config/*.yaml yamlFilePaths.AddRange(configSourceRepo.EnumerateFiles("*.yaml", true)); // Search for config/*.json jsonFilePaths.AddRange(configSourceRepo.EnumerateFiles("*.json", true)); } foreach (var path in tomlFilePaths) { var tomlTable = ParserHelper.ParseTomlFile(sourceRepo, path); if (tomlTable.Keys .Any(k => HugoConfigurationVariables.Contains(k, StringComparer.OrdinalIgnoreCase))) { return(true); } } foreach (var path in yamlFilePaths) { var yamlNode = ParserHelper.ParseYamlFile(sourceRepo, path); if (yamlNode.Children.Keys .Select(k => k.ToString()) .Any(k => HugoConfigurationVariables.Contains(k, StringComparer.OrdinalIgnoreCase))) { return(true); } } foreach (var path in jsonFilePaths) { var jObject = ParserHelper.ParseJsonFile(sourceRepo, path); if (jObject.Children() .Select(c => c.Path) .Any(c => HugoConfigurationVariables.Contains(c, StringComparer.OrdinalIgnoreCase))) { return(true); } } return(false); }
/// <inheritdoc/> public bool IsCleanRepo(ISourceRepo repo) { return(!repo.DirExists(NodeConstants.NodeModulesDirName)); }
private bool IsHugoApp(ISourceRepo sourceRepo, out string appDirectory) { // Hugo configuration variables: // https://gohugo.io/getting-started/configuration/#all-configuration-settings appDirectory = string.Empty; // Search for config.toml if (sourceRepo.FileExists(HugoConstants.TomlFileName) && IsHugoTomlFile(sourceRepo, HugoConstants.TomlFileName)) { return(true); } // Search for config.yml if (sourceRepo.FileExists(HugoConstants.YmlFileName) && IsHugoYamlFile(sourceRepo, HugoConstants.YmlFileName)) { return(true); } // Search for config.yaml if (sourceRepo.FileExists(HugoConstants.YamlFileName) && IsHugoYamlFile(sourceRepo, HugoConstants.YamlFileName)) { return(true); } // Search for config.json if (sourceRepo.FileExists(HugoConstants.JsonFileName) && IsHugoYamlFile(sourceRepo, HugoConstants.JsonFileName)) { return(true); } // NOTE: we do NOT disable looking up into the 'config' folder because it is a special folder // from perspective of Hugo where users can have configuration files. if (sourceRepo.DirExists(HugoConstants.ConfigFolderName)) { // Search for config/**/*.toml var tomlFiles = sourceRepo.EnumerateFiles( "*.toml", searchSubDirectories: true, subDirectoryToSearchUnder: HugoConstants.ConfigFolderName); foreach (var tomlFile in tomlFiles) { if (IsHugoTomlFile(sourceRepo, tomlFile)) { return(true); } } // Search for config/**/*.yaml and config/**/*.yml var yamlFiles = sourceRepo.EnumerateFiles( "*.yaml", searchSubDirectories: true, subDirectoryToSearchUnder: HugoConstants.ConfigFolderName); foreach (var yamlFile in yamlFiles) { if (IsHugoYamlFile(sourceRepo, yamlFile)) { return(true); } } var ymlFiles = sourceRepo.EnumerateFiles( "*.yml", searchSubDirectories: true, subDirectoryToSearchUnder: HugoConstants.ConfigFolderName); foreach (var ymlFile in ymlFiles) { if (IsHugoYamlFile(sourceRepo, ymlFile)) { return(true); } } // Search for config/**/*.json var jsonFiles = sourceRepo.EnumerateFiles( "*.json", searchSubDirectories: true, subDirectoryToSearchUnder: HugoConstants.ConfigFolderName); foreach (var jsonFile in jsonFiles) { if (IsHugoJsonFile(sourceRepo, jsonFile)) { return(true); } } } return(false); }