Exemplo n.º 1
0
        protected override int Execute()
        {
            var currentModuleDirectory = Helper.GetModuleDirectory(Directory.GetCurrentDirectory());
            var currentModule = Path.GetFileName(currentModuleDirectory);

            if (!File.Exists(project))
            {
                var all = Yaml.GetCsprojsList(currentModule);
                var maybe = all.FirstOrDefault(f =>
                    string.Equals(Path.GetFileName(f), project, StringComparison.CurrentCultureIgnoreCase));
                if (maybe != null)
                    project = maybe;
            }

            if (!File.Exists(project))
            {
                ConsoleWriter.WriteError($"Project file '{project}' does not exist.");
                return -1;
            }

            var moduleToInsert = Helper.TryFixModuleCase(dep.Name);
            dep = new Dep(moduleToInsert, dep.Treeish, dep.Configuration);
            var configuration = dep.Configuration;

            if (!Helper.HasModule(moduleToInsert))
            {
                ConsoleWriter.WriteError($"Can't find module '{moduleToInsert}'");
                return -1;
            }

            if (!Directory.Exists(Path.Combine(Helper.CurrentWorkspace, moduleToInsert)))
                GetAndBuild(dep);

            Log.Debug(
                $"{moduleToInsert + (configuration == null ? "" : Helper.ConfigurationDelimiter + configuration)} -> {project}");

            CheckBranch();

            Log.Info("Getting install data for " + moduleToInsert + Helper.ConfigurationDelimiter + configuration);
            var installData = InstallParser.Get(moduleToInsert, configuration);
            if (!installData.BuildFiles.Any())
            {
                ConsoleWriter.WriteWarning($"No install files found in '{moduleToInsert}'");
                return 0;
            }

            AddModuleToCsproj(installData);
            if (testReplaces)
                return hasReplaces ? -1 : 0;

            if (!File.Exists(Path.Combine(currentModuleDirectory, Helper.YamlSpecFile)))
                throw new CementException(
                    "No module.yaml file. You should patch deps file manually or convert old spec to module.yaml (cm convert-spec)");
            DepsPatcherProject.PatchDepsForProject(currentModuleDirectory, dep, project);
            return 0;
        }
Exemplo n.º 2
0
        private TokensList MoudleCsprojs()
        {
            var moduleDirectory = Helper.GetModuleDirectory(Directory.GetCurrentDirectory());

            if (moduleDirectory == null)
            {
                return(null);
            }

            var moduleName = Path.GetFileName(moduleDirectory);
            var files      = Yaml.GetCsprojsList(moduleName);

            return(TokensList.Create(CsprojsToShortFormat(files)));
        }