Graph(ProduceWorkspace workspace) { Guard.NotNull(workspace, nameof(workspace)); Workspace = workspace; Targets = new HashSet <Target>(); Dependencies = new HashSet <Dependency>(); }
GenerateProgramWrappers(ProduceWorkspace workspace) { Guard.NotNull(workspace, nameof(workspace)); var scripts = new HashSet <string>( workspace.FindRepositories() .Select(r => r.DotProducePath) .Where(p => File.Exists(p)) .Select(p => new DotProduce(p)) .Where(dp => dp != null) .SelectMany(dp => dp.Programs) .Select(path => Path.GetFileNameWithoutExtension(path)), StringComparer.OrdinalIgnoreCase); var orphans = Directory.GetFiles(workspace.GetBinDirectory()) .Where(file => !scripts.Contains(Path.GetFileNameWithoutExtension(file))) .ToList(); if (orphans.Count > 0) { using (LogicalOperation.Start("Deleting orphan program wrapper scripts")) { foreach (var file in orphans) { Trace.WriteLine(file); File.Delete(file); } } } }
ProduceRepository(ProduceWorkspace workspace, GitRepositoryName name) : base( IOPath.Combine( Guard.NotNull(workspace, nameof(workspace)).Path, Guard.NotNull(name, nameof(name)))) { Workspace = workspace; DotProducePath = IOPath.Combine(Path, ".produce"); WorkDirectory = IOPath.Combine(Workspace.GetProduceDirectory(), Name); }
PostWorkspace(ProduceWorkspace workspace, string command) { Guard.NotNull(workspace, nameof(workspace)); Guard.Required(command, nameof(command)); if (command != "programs") { return; } GenerateProgramWrappers(workspace); }
FindCurrentWorkspaceAndRepository() { var gitRepo = GitRepository.FindContainingRepository(Environment.CurrentDirectory); if (gitRepo != null) { CurrentWorkspace = new ProduceWorkspace(Path.GetDirectoryName(gitRepo.Path)); CurrentRepository = CurrentWorkspace.GetRepository(new GitRepositoryName(Path.GetFileName(gitRepo.Path))); } else { CurrentWorkspace = new ProduceWorkspace(Path.GetFullPath(Environment.CurrentDirectory)); CurrentRepository = null; } }
RunCommands(ProduceWorkspace workspace, IList <string> commands) { foreach (var command in commands) { foreach (var module in Modules) { module.PreWorkspace(workspace, command); } } foreach (var repository in workspace.FindRepositories()) { RunCommands(repository, commands); } foreach (var command in commands) { foreach (var module in Modules) { module.PostWorkspace(workspace, command); } } }
PostWorkspace(ProduceWorkspace workspace, string command) { }