コード例 #1
0
ファイル: UpdateCommand.cs プロジェクト: yvesgoeleven/ripple
        public override bool Execute(UpdateInput input)
        {
            var solution = Solution.For(input);

            if (input.NugetFlag.IsNotEmpty() && !solution.Dependencies.Has(input.NugetFlag))
            {
                RippleAssert.Fail(input.NugetFlag + " is not a configured dependency");
                return(false);
            }

            if (input.PreviewFlag)
            {
                preview(input, solution);
                return(true);
            }

            return(RippleOperation
                   .For <UpdateInput>(input)
                   .Step <NugetOperation>()
                   .Step <DownloadMissingNugets>()
                   .Step <ExplodeDownloadedNugets>()
                   .Step <ProcessDirectives>()
                   .Step <FixReferences>()
                   .Execute());
        }
コード例 #2
0
        public void CreateSymbolsPackage(PackageParams ctx)
        {
            var symbolsBuilder = symbolsPackageBuilderFor(ctx.Spec, ctx.Version);

            // remove unnecessary files when building the symbols package
            ExcludeFilesForSymbolPackage(symbolsBuilder.Files);

            if (!symbolsBuilder.Files.Any())
            {
                RippleLog.Info("No symbols could be generated for {0} since no symbol files could be found. This is expected if this is a code only package".ToFormat(ctx.Spec.Name));
                return;
            }

            var nupkgSymbolsFileName = Path.Combine(ctx.OutputPath, "{0}.{1}.symbols.nupkg".ToFormat(ctx.Spec.Name, ctx.Version));

            var package = createPackage(symbolsBuilder, nupkgSymbolsFileName);

            var issues = package.Validate(Rules);

            if (issues.Any(x => x.Level == PackageIssueLevel.Error))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                issues.Each(issue => Console.WriteLine("[{0}] {1} - {2}", issue.Level, issue.Title, issue.Description));
                Console.ResetColor();

                RippleAssert.Fail("Symbols package failed validation");
            }
        }
コード例 #3
0
        public static BatchOperation Parse(Solution solution, string input)
        {
            var operation = new BatchOperation(solution);

            input.ReadLines(line =>
            {
                if (line.IsEmpty())
                {
                    return;
                }

                var tokens = line.Split(':');
                if (tokens.Length == 1)
                {
                    RippleAssert.Fail("expected \":\" - {0}", line);
                }
                else if (tokens.Length != 2)
                {
                    RippleAssert.Fail("unexpected \":\" - {0}", line);
                }

                var requests = parseLine(solution, tokens);
                operation._requests.AddRange(requests);
            });

            return(operation);
        }
コード例 #4
0
        public override bool Execute(PublishInput input)
        {
            var report = new PublishReport();

            input.EachSolution(solution =>
            {
                RippleLog.Info("Building nuget files for " + solution.Name);
                var artifactDirectory = solution.Directory.AppendPath(input.ArtifactsFlag);

                RippleLog.Info("Cleaning out any existing nuget files before continuing");
                new FileSystem().CleanDirectory(artifactDirectory);

                solution.Specifications.Each(nuget =>
                {
                    RippleLog.Info("Creating and publishing Nuget for " + nuget.Name);

                    var packageFile = solution.Package(new PackageParams(nuget, SemanticVersion.Parse(input.Version), artifactDirectory, input.CreateSymbolsFlag));
                    var detail      = solution.Publisher.PublishPackage(input.ServerFlag, packageFile, input.ApiKey);

                    report.Add(detail);
                });
            });

            RippleLog.InfoMessage(report);

            if (!report.IsSuccessful())
            {
                RippleAssert.Fail("Failure publishing packages");
            }

            return(true);
        }
コード例 #5
0
        public override bool Execute(BatchPublishInput input)
        {
            RippleLog.Info("Looking for *.nupkg files in " + input.Directory);

            var files = new FileSystem()
                        .FindFiles(input.Directory, new FileSet {
                Include = "*.nupkg"
            })
                        .ToArray();

            _index = 0;
            _count = files.Count();

            var publisher = PublishingService.Basic();
            var report    = new PublishReport();

            files.Each(file =>
            {
                _index++;
                RippleLog.Info("Trying to publish {0}, {1} or {2}".ToFormat(file, _index, _count));

                var detail = publisher.PublishPackage(input.ServerFlag, file, input.ApiKeyFlag);
                report.Add(detail);
            });

            RippleLog.InfoMessage(report);

            if (!report.IsSuccessful())
            {
                RippleAssert.Fail("Failure publishing packages");
            }

            return(true);
        }
コード例 #6
0
        public string CreatePackage(PackageParams ctx)
        {
            var builder = packageBuilderFor(ctx.Spec, ctx.Version);

            if (ctx.CreateSymbols)
            {
                ExcludeFilesForLibPackage(builder.Files);
                if (!builder.Files.Any())
                {
                    throw new CreateNugetException(builder.Id);
                }
            }

            var nupkgFileName = Path.Combine(ctx.OutputPath, "{0}.{1}.nupkg".ToFormat(ctx.Spec.Name, ctx.Version));

            var package = createPackage(builder, nupkgFileName);

            if (ctx.CreateSymbols)
            {
                CreateSymbolsPackage(ctx);
            }
            var issues = package.Validate(Rules);

            if (issues.Any(x => x.Level == PackageIssueLevel.Error))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                issues.Each(issue => Console.WriteLine("[{0}] {1} - {2}", issue.Level, issue.Title, issue.Description));
                Console.ResetColor();

                RippleAssert.Fail("Package failed validation");
            }

            return(nupkgFileName);
        }
コード例 #7
0
        public void CreateSymbolsPackage(PackageParams ctx)
        {
            var symbolsBuilder = symbolsPackageBuilderFor(ctx.Spec, ctx.Version);

            // remove unnecessary files when building the symbols package
            ExcludeFilesForSymbolPackage(symbolsBuilder.Files);

            if (!symbolsBuilder.Files.Any())
            {
                throw new CreateNugetException(symbolsBuilder.Id, true);
            }

            var nupkgSymbolsFileName = Path.Combine(ctx.OutputPath, "{0}.{1}.symbols.nupkg".ToFormat(ctx.Spec.Name, ctx.Version));

            var package = createPackage(symbolsBuilder, nupkgSymbolsFileName);

            var issues = package.Validate(Rules);

            if (issues.Any(x => x.Level == PackageIssueLevel.Error))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                issues.Each(issue => Console.WriteLine("[{0}] {1} - {2}", issue.Level, issue.Title, issue.Description));
                Console.ResetColor();

                RippleAssert.Fail("Symbols package failed validation");
            }
        }
コード例 #8
0
        public void AssertIsValid()
        {
            var element = findNugetElement("id");

            if (element == null)
            {
                RippleAssert.Fail("Invalid nuspec document");
            }
        }
コード例 #9
0
        private ISolutionLoader findLoader()
        {
            var solutionLoader = Loaders.FirstOrDefault(x => x.Condition.Matches(_fileSystem, RootDir));

            if (solutionLoader == null)
            {
                RippleAssert.Fail("Unable to determine ripple mode. See the log for further details or use the --verbose option.");
            }

            return(solutionLoader);
        }
コード例 #10
0
ファイル: FeedService.cs プロジェクト: johnsimons/ripple
        private IRemoteNuget nugetFor(Dependency dependency, bool retrying = false)
        {
            IRemoteNuget nuget = null;
            var          feeds = _connectivity.FeedsFor(_solution);

            foreach (var feed in feeds)
            {
                _connectivity.IfOnline(feed, x => nuget = getLatestFromFloatingFeed(x, dependency));
                if (nuget != null)
                {
                    break;
                }

                if (dependency.IsFloat() || dependency.Version.IsEmpty())
                {
                    _connectivity.IfOnline(feed, x => nuget = x.FindLatest(dependency));
                    if (nuget != null && dependency.Version.IsNotEmpty() && nuget.Version < dependency.SemanticVersion())
                    {
                        nuget = null;
                        continue;
                    }

                    if (nuget != null)
                    {
                        break;
                    }
                }

                _connectivity.IfOnline(feed, x => nuget = x.Find(dependency));
                if (nuget != null)
                {
                    break;
                }
            }



            if (nuget == null)
            {
                if (_connectivity.AllOffline(feeds) && !retrying)
                {
                    return(nugetFor(dependency, true));
                }

                feeds.OfType <FloatingFileSystemNugetFeed>()
                .Each(files => files.DumpLatest());

                RippleAssert.Fail("Could not find " + dependency);
            }

            return(remoteOrCached(nuget));
        }
コード例 #11
0
        public void AssertIsValid()
        {
            var result = Validate();

            if (result.IsValid())
            {
                return;
            }
            ;

            RippleLog.InfoMessage(result);
            RippleAssert.Fail("Validation failed");
        }
コード例 #12
0
        public void AssertNoLockedFiles()
        {
            if (!HasLockedFiles())
            {
                return;
            }

            if (Process.GetProcessesByName("devenv.exe").Any())
            {
                RippleAssert.Fail("Detected locked files. Do you have Visual Studio open?");
                return;
            }

            RippleAssert.Fail("Detected locked files. Exiting.");
        }
コード例 #13
0
 private PackageBuilder packageBuilderFor(NugetSpec spec, SemanticVersion version)
 {
     try
     {
         return(new PackageBuilder(spec.Filename, NullPropertyProvider.Instance, true)
         {
             Version = version
         });
     }
     catch (Exception exc)
     {
         RippleAssert.Fail("Error creating package: " + exc.Message);
         return(null);
     }
 }
コード例 #14
0
        protected override void execute(FloatInput input, IRippleStepRunner runner)
        {
            var dependency = Solution.Dependencies.Find(input.Name);

            if (dependency == null)
            {
                RippleAssert.Fail("Could not find " + input.Name);
                return;
            }

            dependency.Float();

            if (input.MinVersionFlag.IsNotEmpty())
            {
                dependency.Version = input.MinVersionFlag;
            }
        }
コード例 #15
0
        public static void Live()
        {
            _canDetect     = () => Directory.Exists(GitDirectory);
            _detectCurrent = () =>
            {
                if (!_canDetect())
                {
                    RippleAssert.Fail("Cannot use branch detection when not in a git repository");
                }

                var head = File.ReadAllText(Path.Combine(GitDirectory, "HEAD"));

                return(head.Substring(head.LastIndexOf("/") + 1).Trim());
            };

            reset();
        }
コード例 #16
0
ファイル: BranchDetector.cs プロジェクト: yvesgoeleven/ripple
        public static void Live()
        {
            _canDetect     = () => detectBranch().ExitCode == 0;
            _detectCurrent = () =>
            {
                var returnValue = detectBranch();
                if (returnValue.ExitCode != 0)
                {
                    RippleAssert.Fail("Cannot use branch detection when not in a git repository");
                }

                var output = returnValue.OutputText;
                return(output.Substring(output.LastIndexOf('/') + 1).Replace("\n", string.Empty).Replace("\r", string.Empty).Trim());
            };

            reset();
        }
コード例 #17
0
        public override bool Execute(InitInput input)
        {
            var rippleConfigDirectory = RippleFileSystem.FindSolutionDirectory(false);

            if (rippleConfigDirectory.IsNotEmpty())
            {
                RippleAssert.Fail(ExistingSolution.ToFormat(rippleConfigDirectory));
                return(false);
            }

            var builder  = NewSolutionBuilder(input.ToSolution());
            var solution = builder.Build();

            solution.Save(true);

            return(true);
        }
コード例 #18
0
        public void Execute(RippleInput input, IRippleStepRunner runner)
        {
            var feeds = Solution.Feeds.ToArray();

            if (input is IOverrideFeeds)
            {
                var overrides = input.As <IOverrideFeeds>().Feeds();
                if (overrides.Any())
                {
                    Solution.ClearFeeds();
                    Solution.AddFeeds(overrides);
                }
            }

            if (input is IAllowExplicitBranch)
            {
                var branchingInput = input.As <IAllowExplicitBranch>();
                if (branchingInput.BranchFlag.IsNotEmpty())
                {
                    BranchDetector.SetBranch(branchingInput.BranchFlag);
                }
            }

            var missing = Solution.MissingNugets().ToList();
            var nugets  = new List <INugetFile>();
            var report  = new MissingNugetReport();

            if (missing.Any())
            {
                var tasks = missing.Select(x => restore(x, Solution, report, nugets)).ToArray();
                Task.WaitAll(tasks);
            }

            Solution.ClearFeeds();
            Solution.AddFeeds(feeds);

            if (!report.IsValid())
            {
                RippleLog.InfoMessage(report);
                RippleAssert.Fail("Could not restore dependencies");
            }

            runner.Set(new DownloadedNugets(nugets));
        }
コード例 #19
0
ファイル: IPublishingService.cs プロジェクト: ventaur/ripple
        public string CreatePackage(NugetSpec spec, SemanticVersion version, string outputPath)
        {
            var builder       = packageBuilderFor(spec, version);
            var nupkgFileName = Path.Combine(outputPath, "{0}.{1}.nupkg".ToFormat(spec.Name, version));

            var package = createPackage(builder, nupkgFileName);
            var issues  = package.Validate(Rules);

            if (issues.Any(x => x.Level == PackageIssueLevel.Error))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                issues.Each(issue => Console.WriteLine("[{0}] {1} - {2}", issue.Level, issue.Title, issue.Description));
                Console.ResetColor();

                RippleAssert.Fail("Package failed validation");
            }

            return(nupkgFileName);
        }
コード例 #20
0
        public override bool Execute(InstallInput input)
        {
            var solution = Solution.For(input);

            if (input.ProjectFlag.IsNotEmpty())
            {
                var project = solution.FindProject(input.ProjectFlag);
                if (project == null)
                {
                    RippleAssert.Fail("Project " + input.ProjectFlag + " does not exist");
                    return(false);
                }

                if (project.Dependencies.Has(input.Package))
                {
                    RippleAssert.Fail(input.Package + " already exists in Project " + input.ProjectFlag);
                    return(false);
                }
            }
            else if (solution.Dependencies.Has(input.Package))
            {
                RippleAssert.Fail(input.Package + " already exists in solution");
                return(false);
            }

            if (input.PreviewFlag)
            {
                preview(input, solution);
                return(true);
            }

            return(RippleOperation
                   .For <InstallInput>(input)
                   .Step <NugetOperation>()
                   .Step <DownloadMissingNugets>()
                   .Step <ExplodeDownloadedNugets>()
                   .Step <FixReferences>()
                   .Execute());
        }
コード例 #21
0
        private IPackage createPackage(PackageBuilder builder, string outputPath)
        {
            bool isExistingPackage = File.Exists(outputPath);

            try
            {
                using (Stream stream = File.Create(outputPath))
                {
                    builder.Save(stream);
                }
            }
            catch (Exception exc)
            {
                if (!isExistingPackage && File.Exists(outputPath))
                {
                    File.Delete(outputPath);
                }

                RippleAssert.Fail("Error creating package: " + exc.Message);
            }

            RippleLog.Info("Created nuget at: " + outputPath);
            return(new OptimizedZipPackage(outputPath));
        }
コード例 #22
0
ファイル: InitCommand.cs プロジェクト: coinmaketcap/ripple-2
        public override bool Execute(InitInput input)
        {
            var rippleConfigDirectory = RippleFileSystem.FindSolutionDirectory(false);

            if (rippleConfigDirectory.IsNotEmpty())
            {
                RippleAssert.Fail(ExistingSolution.ToFormat(rippleConfigDirectory));
                return(false);
            }

            SolutionFiles.AddLoader(new NuGetSolutionLoader());

            var builder  = Builder();
            var solution = builder.Build();

            solution.Save(true);

            new CleanCommand().Execute(new CleanInput());
            new RestoreCommand().Execute(new RestoreInput {
                FixReferencesFlag = true
            });

            return(true);
        }
コード例 #23
0
        private IEnumerable <Dependency> findDependenciesFor(Dependency dependency, UpdateMode mode, SearchLocation location)
        {
            var dependencies = new List <Dependency>();
            var task         = findDependenciesFor(dependency, mode, 0, location, dependencies);

            try
            {
                task.Wait();
                if (!task.Result.Found)
                {
                    RippleAssert.Fail("Could not find " + dependency.Name);
                }
            }
            catch (AggregateException ex)
            {
                var flat = ex.Flatten();
                if (flat.InnerException != null)
                {
                    RippleLog.Debug(flat.InnerException.Message);
                }
            }

            return(dependencies.OrderBy(x => x.Name));
        }
コード例 #24
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);
        }