public DepsReferenceSearchModel GetRefsFromDeps() { var notFoundInstall = new List <string>(); var resultInstallData = new List <InstallData>(); foreach (var dep in deps) { if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, dep.Name))) { ConsoleWriter.WriteError("Module " + dep.Name + " not found."); continue; } var depInstall = new InstallCollector(Path.Combine(workspace, dep.Name)).Get(dep.Configuration); if (!depInstall.Artifacts.Any()) { if (!Yaml.Exists(dep.Name) || !IsContentModuel(dep)) { notFoundInstall.Add(dep.Name); } } else { depInstall.ModuleName = dep.Name; depInstall.BuildFiles = depInstall.BuildFiles.Select(reference => reference.Replace('/', '\\')).ToList(); depInstall.Artifacts = depInstall.Artifacts.Select(reference => reference.Replace('/', '\\')).ToList(); depInstall.MainConfigBuildFiles = depInstall.MainConfigBuildFiles.Select(reference => reference.Replace('/', '\\')).ToList(); resultInstallData.Add(depInstall); } } return(new DepsReferenceSearchModel(resultInstallData, notFoundInstall)); }
public void NugetRestore(string moduleName, List <string> configurations, string nugetRunCommand) { if (Yaml.Exists(moduleName)) { var buildSections = configurations.SelectMany(c => Yaml.BuildParser(moduleName).Get(c)).ToList(); var targets = new HashSet <string>(); foreach (var buildSection in buildSections) { if (buildSection.Target == null || !buildSection.Target.EndsWith(".sln")) { continue; } if (buildSection.Tool.Name != "dotnet") { var target = Path.Combine(Helper.CurrentWorkspace, moduleName, buildSection.Target); targets.Add(target); } } foreach (var target in targets) { RunNugetRestore(target, nugetRunCommand); } } else { RunNugetRestore(Path.Combine(Helper.CurrentWorkspace, moduleName, "build.cmd"), nugetRunCommand); } }
private static void Dfs(Dep dep, Dictionary <Dep, List <Dep> > graph, HashSet <Dep> visitedConfigurations) { dep.UpdateConfigurationIfNull(); if (Yaml.Exists(dep.Name) && !Yaml.ConfigurationParser(dep.Name).ConfigurationExists(dep.Configuration)) { ConsoleWriter.WriteWarning($"Configuration '{dep.Configuration}' was not found in {dep.Name}. Will take full-build config"); dep.Configuration = "full-build"; } visitedConfigurations.Add(dep); graph[dep] = new List <Dep>(); if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, dep.Name))) { throw new CementBuildException("Failed to find module '" + dep.Name + "'"); } var currentDeps = new DepsParser(Path.Combine(Helper.CurrentWorkspace, dep.Name)).Get(dep.Configuration).Deps ?? new List <Dep>(); currentDeps = currentDeps.Select(d => new Dep(d.Name, null, d.Configuration)).ToList(); foreach (var d in currentDeps) { d.UpdateConfigurationIfNull(); graph[dep].Add(d); if (!visitedConfigurations.Contains(d)) { Dfs(d, graph, visitedConfigurations); } } }
private static void PrintSimpleLocalWithYaml() { var modules = Helper.GetModules(); var workspace = Helper.GetWorkspaceDirectory(Directory.GetCurrentDirectory()) ?? Directory.GetCurrentDirectory(); Helper.SetWorkspace(workspace); var local = modules.Where(m => Yaml.Exists(m.Name)); Console.WriteLine(string.Join("\n", local.Select(m => m.Name).OrderBy(x => x))); }
protected override int Execute() { var currentDirectory = Directory.GetCurrentDirectory(); var moduleName = ResolveModuleName(currentDirectory); var workspace = Helper.GetWorkspaceDirectory(currentDirectory); if (workspace == null) { throw new CementException("Cement workspace directory not found."); } if (moduleName == null) { throw new CementException("Specify module name, or use command inside module directory."); } if (!Helper.DirectoryContainsModule(workspace, moduleName)) { throw new CementException($"Module {moduleName} not found."); } Helper.SetWorkspace(workspace); if (!Yaml.Exists(moduleName)) { throw new CementException($"No module.yaml in {moduleName}."); } var configYamlParser = Yaml.ConfigurationParser(moduleName); var defaultConfig = configYamlParser.GetDefaultConfigurationName(); foreach (var config in configYamlParser.GetConfigurations()) { var sb = new StringBuilder(config); var parents = configYamlParser.GetParentConfigurations(config); if (parents != null && parents.Count > 0) { sb.Append(" > "); sb.Append(string.Join(", ", parents)); } if (config == defaultConfig) { sb.Append(" *default"); ConsoleWriter.Shared.PrintLn(sb.ToString(), ConsoleColor.Green); } else { ConsoleWriter.Shared.WriteLine(sb.ToString()); } } return(0); }
private static void AddEdge(Dep from, Dep to, List <string> result) { var edge = $"{from} -> {to}"; if (Yaml.Exists(from.Name)) { var names = GetOwerhead(from); if (names.Contains(to.Name)) { edge += " {color:red, weight:2}"; } } result.Add(edge); }
private void CheckHasInstall(Dep dep) { if (!Yaml.Exists(dep.Name)) { return; } var artifacts = Yaml.InstallParser(dep.Name).Get(dep.Configuration).Artifacts; foreach (var artifact in artifacts) { var fixedPath = Helper.FixPath(artifact); if (!File.Exists(Path.Combine(Helper.CurrentWorkspace, dep.Name, fixedPath))) { ConsoleWriter.WriteError($"{artifact} not found in {dep.Name}. Check install section."); log.Warn($"{artifact} not found in {dep.Name}"); } } }
public void NugetRestore(Dep dep) { if (Yaml.Exists(dep.Name)) { var buildSections = Yaml.BuildParser(dep.Name).Get(dep.Configuration); foreach (var buildSection in buildSections) { if (buildSection.Target == null || !buildSection.Target.EndsWith(".sln")) { continue; } var target = Path.Combine(Helper.CurrentWorkspace, dep.Name, buildSection.Target); RunNugetRestore(target); } } else { RunNugetRestore(Path.Combine(Helper.CurrentWorkspace, dep.Name, "build.cmd")); } }
private TokensList RefAddComplete() { var workspace = Helper.GetWorkspaceDirectory(Directory.GetCurrentDirectory()) ?? Directory.GetCurrentDirectory(); Helper.SetWorkspace(workspace); var local = modules; if (lastToken.Contains("/") && local.Contains(lastToken.Split('/')[0])) { var name = lastToken.Split('/')[0]; if (Yaml.Exists(name)) { local.AddRange( Yaml.ConfigurationParser(name).GetConfigurations().Select(c => $"{name}/{c}")); } } return(TokensList.Create(local, MoudleCsprojs)); }
private static void CheckAndUpdateDepConfiguration(Dep dep) { dep.UpdateConfigurationIfNull(); var key = dep.ToString(); if (!DepConfigurationExistsCache.ContainsKey(key)) { if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, dep.Name))) { throw new CementBuildException("Failed to find module '" + dep.Name + "'"); } DepConfigurationExistsCache[key] = !Yaml.Exists(dep.Name) || Yaml.ConfigurationParser(dep.Name).ConfigurationExists(dep.Configuration); } if (!DepConfigurationExistsCache[key]) { ConsoleWriter.WriteWarning( $"Configuration '{dep.Configuration}' was not found in {dep.Name}. Will take full-build config"); dep.Configuration = "full-build"; } }
public static bool InstallHooks(string moduleName) { if (!Yaml.Exists(moduleName)) { return(false); } var hooks = Yaml.HooksParser(moduleName).Get(); if (!hooks.Any()) { return(false); } var gitFolder = Path.Combine(Helper.CurrentWorkspace, moduleName, ".git"); var gitHooksFolder = Path.Combine(gitFolder, "hooks"); if (!GitFolderExists(moduleName, gitFolder)) { return(false); } if (!Directory.Exists(gitHooksFolder)) { Directory.CreateDirectory(gitHooksFolder); } CreateCementHook(gitHooksFolder); if (!IsUniqueHooks(moduleName, hooks)) { return(false); } var updated = false; foreach (var hook in hooks) { updated |= InstallHook(moduleName, hook, gitHooksFolder); } return(updated); }
private TokensList ConfigKeyWithConfigs() { var moduleDirectory = Helper.GetModuleDirectory(Directory.GetCurrentDirectory()); if (moduleDirectory == null) { return(null); } var moduleName = Path.GetFileName(moduleDirectory); Helper.SetWorkspace(Helper.GetWorkspaceDirectory(Directory.GetCurrentDirectory())); if (!Yaml.Exists(moduleName)) { return(null); } var configKey = new TokensList { { "-c", () => ModuleConfigs(moduleName) } }; return(configKey); }