Ejemplo n.º 1
0
        private static void Cleanup()
        {
            WriteHeader("Cleaning up");
            Cli.WriteLine("Searching...");
            var fsos = new List<FileSystemInfo>();

            if (_currentRelease.Cleanup.FilePatterns != null && _currentRelease.Cleanup.FilePatterns.Any())
            {
                fsos.AddRange(
                    outputDir
                        .GetFiles("*", SearchOption.AllDirectories)
                        .Where(x => _currentRelease.Cleanup.FilePatterns.Any(y => Regex.IsMatch(x.FullName, y))));
            }

            if (_currentRelease.Cleanup.Files != null && _currentRelease.Cleanup.Files.Any())
            {
                fsos.AddRange(_currentRelease.Cleanup.Files.Select(x => new FileInfo(Path.Combine(outputDir.FullName, x))));
            }

            if (_currentRelease.Cleanup.Directories != null && _currentRelease.Cleanup.Directories.Any())
            {
                fsos.AddRange(_currentRelease.Cleanup.Directories.Select(x => outputDir.Combine(x)));
            }

            Cli.WriteLine("~Cyan~{0}~R~ files and directories found", fsos.Count);
            Cli.WriteLine();
            WriteProgressHeader("Deleting");

            var progress = new CliProgressBar(fsos.Count);
            progress.Write();

            fsos.Iter(x =>
            {
                if (!x.Exists)
                {
                    progress.Value++;
                    progress.Write();
                    return;
                }

                var dir = x as DirectoryInfo;

                if (dir != null)
                {
                    dir.Delete(true);
                }
                else
                {
                    x.Delete();
                }

                progress.Value++;
                progress.Write();
            });
            Cli.WriteLine();
            Cli.WriteLine();
        }
Ejemplo n.º 2
0
        public void Process <TElement>(IEnumerable <TElement> collection, Action <TElement> action)
        {
            IsProcessing = true;
            var progress = new CliProgressBar(collection.Count());

            progress.Write();

            foreach (var element in collection)
            {
                action(element);
                progress.IncrementAndWrite();
            }

            Cli.WriteLine();
            IsProcessing = false;
        }
Ejemplo n.º 3
0
        private static void CopyBinaries()
        {
            WriteHeader("Copying binaries");
            var mainProject = GetMainProject(_currentRelease.Projects);
            outputDir = new DirectoryInfo(_currentRelease.Output)
                .Combine(mainProject.GetVersion().ToString());

            if (outputDir.Exists)
            {
                Cli.WriteLine("Deleting ~Yellow~{0}~R~", outputDir.FullName);
                outputDir.Delete(true);
            }

            Cli.WriteLine();
            WriteProgressHeader("Copying");

            var progress = new CliProgressBar(_currentRelease.Projects.Length);
            progress.Write();

            _currentRelease.Projects
                .Iter(x =>
                {
                    new DirectoryInfo(x.OutputPath).CopyTo(outputDir.FullName, true);
                    progress.Value++;
                    progress.Write();
                });

            Cli.WriteLine();
            Cli.WriteLine();
        }
        static void Main(string[] args)
        {
            WriteHeader("Loading release settings");
            var script = "PhpVH.alx";
            Cli.WriteLine("Executing ~Cyan~{0}~R~", script);
            var interpreter = new AphidInterpreter();
            interpreter.InterpretFile(script);
            _currentRelease = interpreter.GetReturnValue().ConvertTo<Release>();
            var projects = _currentRelease.Projects;
            Cli.WriteLine();

            WriteHeader("Copying binaries");

            var outputDir = new DirectoryInfo(_currentRelease.Output)
                .Combine(GetReleaseVersion(projects).ToString());

            if (outputDir.Exists)
            {
                Cli.WriteLine("Deleting ~Yellow~{0}~R~", outputDir.FullName);
                outputDir.Delete(true);
            }

            Cli.WriteLine();
            WriteProgressHeader("Copying");

            var progress = new CliProgressBar(projects.Length);
            progress.Write();

            projects
                .Iter(x =>
                {
                    new DirectoryInfo(x.OutputPath).CopyTo(outputDir.FullName, true);
                    progress.Value++;
                    progress.Write();
                });

            Cli.WriteLine();
            Cli.WriteLine();
            WriteHeader("Cleaning up");
            Cli.WriteLine("Searching...");
            var fsos = new List<FileSystemInfo>();

            if (_currentRelease.Cleanup.FilePatterns != null && _currentRelease.Cleanup.FilePatterns.Any())
            {
                fsos.AddRange(
                    outputDir
                        .GetFiles("*", SearchOption.AllDirectories)
                        .Where(x => _currentRelease.Cleanup.FilePatterns.Any(y => Regex.IsMatch(x.FullName, y))));
            }

            if (_currentRelease.Cleanup.Files != null && _currentRelease.Cleanup.Files.Any())
            {
                fsos.AddRange(_currentRelease.Cleanup.Files.Select(x => new FileInfo(Path.Combine(outputDir.FullName, x))));
            }

            if (_currentRelease.Cleanup.Directories != null && _currentRelease.Cleanup.Directories.Any())
            {
                fsos.AddRange(_currentRelease.Cleanup.Directories.Select(x => outputDir.Combine(x)));
            }

            Cli.WriteLine("~Cyan~{0}~R~ files and directories found", fsos.Count);
            Cli.WriteLine();
            WriteProgressHeader("Deleting");

            progress = new CliProgressBar(fsos.Count);
            progress.Write();

            fsos.Iter(x =>
            {
                var dir = x as DirectoryInfo;

                if (dir != null)
                {
                    dir.Delete(true);
                }
                else
                {
                    x.Delete();
                }

                progress.Value++;
                progress.Write();
            });
        }