Exemplo n.º 1
0
        public void copying_the_request_sets_the_parent()
        {
            var request = new NugetPlanRequest
            {
                Dependency = new Dependency("FubuCore"),
                ForceUpdates = true,
                Operation = OperationType.Update,
            };

            request.CopyFor(new Dependency("Bottles")).Parent.ShouldEqual(request);
        }
Exemplo n.º 2
0
        public void copying_the_request_marks_as_transitive()
        {
            var request = new NugetPlanRequest
            {
                Dependency = new Dependency("FubuCore"),
                ForceUpdates = true,
                Operation = OperationType.Update,
            };

            request.CopyFor(new Dependency("Bottles")).IsTransitive().ShouldBeTrue();
        }
Exemplo n.º 3
0
        private NugetPlan buildPlan(NugetPlanRequest request, Dependency parent = null)
        {
            var plan     = new NugetPlan();
            var target   = request.Dependency;
            var solution = request.Solution;

            var key = target.Copy();

            if (key.IsFloat())
            {
                key = target.AsFloat();
            }

            if (_planCache.Has(key))
            {
                return(_planCache[key]);
            }

            _planCache.Fill(key, plan);

            RippleLog.Info("* Analyzing " + target);

            if (target.Version.IsEmpty())
            {
                var remote = solution.FeedService.NugetFor(target);
                target.Version = remote.Version.ToString();
            }

            if (request.UpdatesCurrentDependency())
            {
                updateDependency(plan, request);
            }
            else if (!solution.Dependencies.Has(target.Name))
            {
                plan.AddStep(new InstallSolutionDependency(target));
            }

            projectInstallations(plan, parent, request);

            var nugetDependencies = solution.FeedService.DependenciesFor(target, target.Mode);

            nugetDependencies.Each(x =>
            {
                var childPlan = buildPlan(request.CopyFor(x), target);
                plan.Import(childPlan);
            });

            return(plan);
        }
Exemplo n.º 4
0
        private NugetPlan buildPlan(NugetPlanRequest request, Dependency parent = null)
        {
            var plan = new NugetPlan();
            var target = request.Dependency;
            var solution = request.Solution;

            var key = target.Copy();
            if (key.IsFloat())
            {
                key = target.AsFloat();
            }

            if (_planCache.Has(key))
            {
                return _planCache[key];
            }

            _planCache.Fill(key, plan);

            RippleLog.Info("* Analyzing " + target);

            if (target.Version.IsEmpty())
            {
                var remote = solution.FeedService.NugetFor(target);
                target.Version = remote.Version.ToString();
            }

            if (request.UpdatesCurrentDependency())
            {
                updateDependency(plan, request);
            }
            else if(!solution.Dependencies.Has(target.Name))
            {
                plan.AddStep(new InstallSolutionDependency(target));
            }

            projectInstallations(plan, parent, request);

            var nugetDependencies = solution.FeedService.DependenciesFor(target, target.Mode);
            nugetDependencies.Each(x =>
            {
                var childPlan = buildPlan(request.CopyFor(x), target);
                plan.Import(childPlan);
            });

            return plan;
        }
Exemplo n.º 5
0
        public void copy_for_dependency()
        {
            var solution = new Solution();
            var request = new NugetPlanRequest
            {
                Dependency = new Dependency("FubuCore"),
                ForceUpdates = true,
                Operation = OperationType.Update,
                Solution = solution
            };

            var copied = request.CopyFor(new Dependency("Bottles"));
            copied.Dependency.Name.ShouldEqual("Bottles");
            copied.ForceUpdates.ShouldEqual(request.ForceUpdates);
            copied.Operation.ShouldEqual(request.Operation);
            copied.Solution.ShouldEqual(request.Solution);
        }
Exemplo n.º 6
0
        private NugetPlan buildPlan(NugetPlanRequest request, Dependency parent = null)
        {
            var plan     = new NugetPlan();
            var target   = request.Dependency;
            var solution = request.Solution;

            var dependencyKey = target.Copy();

            if (dependencyKey.IsFloat())
            {
                dependencyKey = target.AsFloat();
            }

            var key = new PlanKey(dependencyKey, request.Project);

            if (_planCache.Has(key))
            {
                return(_planCache[key]);
            }

            _planCache.Fill(key, plan);

            RippleLog.Info("* Analyzing " + target);

            if (target.Version.IsEmpty())
            {
                string version = null;
                var    local   = solution.LocalDependencies();

                if (request.Operation == OperationType.Install && solution.LocalDependencies().Has(target))
                {
                    var localNuget = local.Get(target);
                    version = localNuget.Version.ToString();
                }
                else
                {
                    if (!RippleEnvironment.Connected())
                    {
                        RippleAssert.Fail("Cannot update in offline mode");
                    }

                    var task = solution.FeedService.NugetFor(target);
                    task.Wait();

                    if (!task.Result.Found)
                    {
                        RippleAssert.Fail("Could not find " + request.Dependency);
                    }
                    var remote = task.Result.Nuget;
                    version = remote.Version.ToString();
                }

                target.Version = version;
            }

            if (request.UpdatesCurrentDependency())
            {
                updateDependency(plan, request);
            }
            else if (!solution.Dependencies.Has(target.Name))
            {
                plan.AddStep(new InstallSolutionDependency(target));
            }

            projectInstallations(plan, parent, request);

            var location = request.Operation == OperationType.Install ? SearchLocation.Local : SearchLocation.Remote;

            var nugetDependencies = solution.FeedService.DependenciesFor(target, target.Mode, location);

            nugetDependencies.Each(x =>
            {
                var transitiveDep = request.CopyFor(x);
                var childPlan     = buildPlan(transitiveDep, target);
                plan.Import(childPlan);
            });

            return(plan);
        }
Exemplo n.º 7
0
        private NugetPlan buildPlan(NugetPlanRequest request, Dependency parent = null)
        {
            var plan = new NugetPlan();
            var target = request.Dependency;
            var solution = request.Solution;

            var dependencyKey = target.Copy();
            if (dependencyKey.IsFloat())
            {
                dependencyKey = target.AsFloat();
            }

            var key = new PlanKey(dependencyKey, request.Project);
            if (_planCache.Has(key))
            {
                return _planCache[key];
            }

            _planCache.Fill(key, plan);

            RippleLog.Info("* Analyzing " + target);

            if (target.Version.IsEmpty())
            {
                string version = null;
                var local = solution.LocalDependencies();

                if (request.Operation == OperationType.Install && solution.LocalDependencies().Has(target))
                {
                    var localNuget = local.Get(target);
                    version = localNuget.Version.ToString();
                }
                else
                {
                    if (!RippleEnvironment.Connected())
                    {
                        RippleAssert.Fail("Cannot update in offline mode");
                    }

                    var task = solution.FeedService.NugetFor(target);
                    task.Wait();

                    if (!task.Result.Found)
                    {
                        RippleAssert.Fail("Could not find " + request.Dependency);
                    }
                    var remote = task.Result.Nuget;
                    version = remote.Version.ToString();
                }

                target.Version = version;
            }

            if (request.UpdatesCurrentDependency())
            {
                updateDependency(plan, request);
            }
            else if (!solution.Dependencies.Has(target.Name))
            {
                plan.AddStep(new InstallSolutionDependency(target));
            }

            projectInstallations(plan, parent, request);

            var location = request.Operation == OperationType.Install ? SearchLocation.Local : SearchLocation.Remote;

            var nugetDependencies = solution.FeedService.DependenciesFor(target, target.Mode, location);
            nugetDependencies.Each(x =>
            {
                var transitiveDep = request.CopyFor(x);
                var childPlan = buildPlan(transitiveDep, target);
                plan.Import(childPlan);
            });

            return plan;
        }
Exemplo n.º 8
0
        private NugetPlan buildPlan(NugetPlanRequest request, Dependency parent = null, int depth = 0)
        {
            var plan = new NugetPlan();
            var target = request.Dependency;
            var solution = request.Solution;

            var key = target.Copy();
            if (key.IsFloat())
            {
                key = target.AsFloat();
            }

            if (_planCache.Has(key))
            {
                return _planCache[key];
            }

            _planCache.Fill(key, plan);

            RippleLog.Info("* Analyzing " + target);

            if (target.Version.IsEmpty())
            {
                var remote = solution.FeedService.NugetFor(solution, target);
                target.Version = remote.Version.ToString();
            }

            if (request.UpdatesCurrentDependency())
            {
                var configured = solution.Dependencies.Find(target.Name);
                var shouldUpdate = (depth != 0 || request.Operation == OperationType.Update) && (request.ForceUpdates || configured.IsFloat());
                if (shouldUpdate)
                {
                    plan.AddStep(new UpdateDependency(target));
                }
                else
                {
                    RippleLog.Info("Warning: This operation requires {0} to be updated to {1} but it is marked as fixed. Use the force option to correct this.".ToFormat(target.Name, target.Version));
                }
            }
            else if(!solution.Dependencies.Has(target.Name))
            {
                plan.AddStep(new InstallSolutionDependency(target));
            }

            projectInstallations(plan, parent, request);

            var nugetDependencies = solution.FeedService.DependenciesFor(solution, target, target.Mode);
            nugetDependencies.Each(x =>
            {
                var childPlan = buildPlan(request.CopyFor(x), target, depth + 1);
                plan.Import(childPlan);
            });

            return plan;
        }
Exemplo n.º 9
0
        public void should_update_forced_transitive_install()
        {
            var request = new NugetPlanRequest
            {
                Dependency = new Dependency("FubuCore"),
                ForceUpdates = true,
                Operation = OperationType.Install,
            };

            request.CopyFor(new Dependency("Bottles", "1.0.0.0", UpdateMode.Fixed)).ShouldUpdate(new Dependency("Bottles")).ShouldBeTrue();
        }
Exemplo n.º 10
0
        public void should_not_force_update_for_the_original_dependency_when_batched()
        {
            var request = new NugetPlanRequest
            {
                Dependency = new Dependency("FubuCore"),
                ForceUpdates = false,
                Batched = true,
                Operation = OperationType.Install,
            };

            request.CopyFor(new Dependency("Bottles"))
                   .CopyFor(new Dependency("Something"))
                   .ShouldForce(request.Dependency)
                   .ShouldBeFalse();
        }
Exemplo n.º 11
0
        public void original_dependency_recursive()
        {
            var request = new NugetPlanRequest
            {
                Dependency = new Dependency("FubuCore"),
                ForceUpdates = false,
                Operation = OperationType.Install,
            };

            request.CopyFor(new Dependency("Bottles"))
                   .CopyFor(new Dependency("Something"))
                   .Origin()
                   .ShouldEqual(request.Dependency);
        }