Ejemplo n.º 1
0
        public string GetLatestVersion(bool ignorePrerelease)
        {
            IEnumerable <string> allVersions = null;

            if (DirectoryProxy.Exists(NugetSource))
            {
                var paketPrefix = "paket.";
                allVersions = DirectoryProxy.
                              EnumerateFiles(NugetSource, "paket.*.nupkg", SearchOption.TopDirectoryOnly).
                              Select(x => Path.GetFileNameWithoutExtension(x)).
                              // If the specified character isn't a digit, then the file
                              // likely contains the bootstrapper or paket.core
                              Where(x => x.Length > paketPrefix.Length && Char.IsDigit(x[paketPrefix.Length])).
                              Select(x => x.Substring(paketPrefix.Length));
            }
            else
            {
                var apiHelper         = new NugetApiHelper(PaketNugetPackageName, NugetSource);
                var versionRequestUrl = apiHelper.GetAllPackageVersions(!ignorePrerelease);
                var versions          = WebRequestProxy.DownloadString(versionRequestUrl);
                allVersions = versions.
                              Trim('[', ']').
                              Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).
                              Select(x => x.Trim('"'));
            }
            var latestVersion = allVersions.
                                Select(SemVer.Create).
                                Where(x => !ignorePrerelease || (x.PreRelease == null)).
                                OrderBy(x => x).
                                LastOrDefault(x => !String.IsNullOrWhiteSpace(x.Original));

            return(latestVersion != null ? latestVersion.Original : String.Empty);
        }
Ejemplo n.º 2
0
        public static void show_colorthemes(CharacterInstance ch)
        {
            ch.SendToPager("&Ythe following themes are available:\r\n");

            var proxy = new DirectoryProxy();
            var path  = SystemConstants.GetSystemDirectory(SystemDirectoryTypes.Color);

            var count = 0;
            var col   = 0;

            foreach (var file in proxy.GetFiles(path).ToList()
                     .Where(x => !x.EqualsIgnoreCase("cvs") && !x.StartsWith(".")))
            {
                ++count;
                ch.PagerPrintf("%s%-15.15s", color_str(ATTypes.AT_PLAIN, ch), file);
                if (++col % 6 == 0)
                {
                    ch.SendToPager("\r\n");
                }
            }

            if (count == 0)
            {
                ch.SendToPager("No themes defined yet.\r\n");
            }

            if (col % 6 != 0)
            {
                ch.SendToPager("\r\n");
            }
        }
Ejemplo n.º 3
0
        private string GetLatestVersionInCache(bool ignorePrerelease)
        {
            DirectoryProxy.CreateDirectory(_paketCacheDir);
            var zero = new SemVer();

            return(DirectoryProxy.GetDirectories(_paketCacheDir)
                   .Select(Path.GetFileName)
                   .OrderByDescending(x =>
            {
                try
                {
                    var version = SemVer.Create(x);

                    if (ignorePrerelease && version.PreRelease != null)
                    {
                        return zero;
                    }
                    else
                    {
                        return version;
                    }
                }
                catch (Exception)
                {
                    return zero;
                }
            })
                   .FirstOrDefault() ?? "0");
        }
        public void Load()
        {
            var dirProxy = new DirectoryProxy();
            var files    = dirProxy.GetFiles(Directory);

            var validLines = new List <string> {
                "level", "roomrange", "mobrange", "objrange"
            };

            foreach (var file in files.Where(x => !x.Equals(".")))
            {
                using (var proxy = new TextReaderProxy(new StreamReader(Directory + file)))
                {
                    IEnumerable <string> lines = proxy.ReadIntoList();

                    int low = 0, hi = 0, rlow = 0, rhi = 0, mlow, mhi, olow, ohi;
                    var badFile = false;

                    foreach (var line in lines)
                    {
                        string[] words;
                        switch (line.ToLower())
                        {
                        case "level":
                            if (low < LevelConstants.ImmortalLevel)
                            {
                                LogManager.Instance.Bug("God file {0} with level {1} < {2}", file, low,
                                                        LevelConstants.ImmortalLevel);
                                badFile = true;
                            }
                            break;

                        case "roomrange":
                            words = line.Split();
                            rlow  = low = words[1].ToInt32();
                            rhi   = hi = words[2].ToInt32();
                            break;

                        case "mobrange":
                            words = line.Split();
                            rlow  = low = words[1].ToInt32();
                            rhi   = hi = words[2].ToInt32();
                            break;

                        case "objrange":
                            words = line.Split();
                            rlow  = low = words[1].ToInt32();
                            rhi   = hi = words[2].ToInt32();
                            break;
                        }
                    }

                    if (rlow > 0 && rhi > 0 && !badFile)
                    {
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void DownloadVersion(string latestVersion, string target)
        {
            var apiHelper = new NugetApiHelper(PaketNugetPackageName, NugetSource);

            const string paketNupkgFile         = "paket.latest.nupkg";
            const string paketNupkgFileTemplate = "paket.{0}.nupkg";

            var paketDownloadUrl = apiHelper.GetLatestPackage();
            var paketFile        = paketNupkgFile;

            if (!String.IsNullOrWhiteSpace(latestVersion))
            {
                paketDownloadUrl = apiHelper.GetSpecificPackageVersion(latestVersion);
                paketFile        = String.Format(paketNupkgFileTemplate, latestVersion);
            }

            var randomFullPath = Path.Combine(Folder, Path.GetRandomFileName());

            DirectoryProxy.CreateDirectory(randomFullPath);
            var paketPackageFile = Path.Combine(randomFullPath, paketFile);

            if (DirectoryProxy.Exists(NugetSource))
            {
                if (String.IsNullOrWhiteSpace(latestVersion))
                {
                    latestVersion = GetLatestVersion(false);
                }
                var sourcePath = Path.Combine(NugetSource, String.Format(paketNupkgFileTemplate, latestVersion));

                ConsoleImpl.WriteDebug("Starting download from {0}", sourcePath);

                FileProxy.Copy(sourcePath, paketPackageFile);
            }
            else
            {
                ConsoleImpl.WriteDebug("Starting download from {0}", paketDownloadUrl);

                WebRequestProxy.DownloadFile(paketDownloadUrl, paketPackageFile);
            }

            FileProxy.ExtractToDirectory(paketPackageFile, randomFullPath);
            var paketSourceFile = Path.Combine(randomFullPath, "tools", "paket.exe");

            FileProxy.Copy(paketSourceFile, target, true);
            DirectoryProxy.Delete(randomFullPath, true);
        }
Ejemplo n.º 6
0
        public void DownloadVersion(string latestVersion, string target)
        {
            var cached = Path.Combine(_paketCacheDir, latestVersion, "paket.exe");

            if (!FileProxy.Exists(cached))
            {
                ConsoleImpl.WriteDebug("Version {0} not found in cache.", latestVersion);

                EffectiveStrategy.DownloadVersion(latestVersion, target);
                DirectoryProxy.CreateDirectory(Path.GetDirectoryName(cached));
                FileProxy.Copy(target, cached);
            }
            else
            {
                ConsoleImpl.WriteDebug("Copying version {0} from cache.", latestVersion);

                FileProxy.Copy(cached, target, true);
            }
        }
Ejemplo n.º 7
0
        public void SelfUpdate(string latestVersion)
        {
            string target       = Assembly.GetExecutingAssembly().Location;
            var    localVersion = FileProxy.GetLocalFileVersion(target);

            if (localVersion.StartsWith(latestVersion))
            {
                ConsoleImpl.WriteDebug("Bootstrapper is up to date. Nothing to do.");
                return;
            }
            var apiHelper = new NugetApiHelper(PaketBootstrapperNugetPackageName, NugetSource);

            const string paketNupkgFile         = "paket.bootstrapper.latest.nupkg";
            const string paketNupkgFileTemplate = "paket.bootstrapper.{0}.nupkg";
            var          getLatestFromNugetUrl  = apiHelper.GetLatestPackage();

            var paketDownloadUrl = getLatestFromNugetUrl;
            var paketFile        = paketNupkgFile;

            if (!String.IsNullOrWhiteSpace(latestVersion))
            {
                paketDownloadUrl = apiHelper.GetSpecificPackageVersion(latestVersion);
                paketFile        = String.Format(paketNupkgFileTemplate, latestVersion);
            }

            var randomFullPath = Path.Combine(Folder, Path.GetRandomFileName());

            DirectoryProxy.CreateDirectory(randomFullPath);
            var paketPackageFile = Path.Combine(randomFullPath, paketFile);

            if (DirectoryProxy.Exists(NugetSource))
            {
                if (String.IsNullOrWhiteSpace(latestVersion))
                {
                    latestVersion = GetLatestVersion(false);
                }
                var sourcePath = Path.Combine(NugetSource, String.Format(paketNupkgFileTemplate, latestVersion));

                ConsoleImpl.WriteDebug("Starting download from {0}", sourcePath);

                FileProxy.Copy(sourcePath, paketPackageFile);
            }
            else
            {
                ConsoleImpl.WriteDebug("Starting download from {0}", paketDownloadUrl);

                WebRequestProxy.DownloadFile(paketDownloadUrl, paketPackageFile);
            }

            FileProxy.ExtractToDirectory(paketPackageFile, randomFullPath);

            var paketSourceFile = Path.Combine(randomFullPath, "tools", "paket.bootstrapper.exe");
            var renamedPath     = BootstrapperHelper.GetTempFile("oldBootstrapper");

            try
            {
                FileProxy.FileMove(target, renamedPath);
                FileProxy.FileMove(paketSourceFile, target);
                ConsoleImpl.WriteDebug("Self update of bootstrapper was successful.");
            }
            catch (Exception)
            {
                ConsoleImpl.WriteDebug("Self update failed. Resetting bootstrapper.");
                FileProxy.FileMove(renamedPath, target);
                throw;
            }
            DirectoryProxy.Delete(randomFullPath, true);
        }
Ejemplo n.º 8
0
        public static void make_wizlist()
        {
            var wizList   = new List <WizardData>();
            var directory = SystemConstants.GetSystemDirectory(SystemDirectoryTypes.God);
            var files     = new DirectoryProxy().GetFiles(directory);

            foreach (var file in files.Where(x => !x.StartsWithIgnoreCase(".")))
            {
                using (var proxy = new TextReaderProxy(new StreamReader(file)))
                {
                    var wizard = new WizardData {
                        Name = file
                    };
                    wizard.Level = wizard.Load(proxy.ReadIntoList());
                    wizList.Add(wizard);
                }
            }

            var buffer = $" Masters of the {GameManager.Instance.SystemData.MudTitle}!";

            var iLevel = 65535;

            foreach (var wiz in wizList)
            {
                if (wiz.Level < iLevel)
                {
                    if (!string.IsNullOrEmpty(buffer))
                    {
                        towizfile(buffer);
                        buffer = string.Empty;
                    }
                    towizfile(string.Empty);
                    iLevel = wiz.Level;
                    if (iLevel == LevelConstants.MaxLevel)
                    {
                        towizfile(" Supreme Entity");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 1)
                    {
                        towizfile(" Infinite");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 2)
                    {
                        towizfile(" Eternal");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 3)
                    {
                        towizfile(" Ancient");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 4)
                    {
                        towizfile(" Exalted Gods");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 5)
                    {
                        towizfile(" Ascendant Gods");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 6)
                    {
                        towizfile(" Greater Gods");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 7)
                    {
                        towizfile(" Gods");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 8)
                    {
                        towizfile(" Lesser Gods");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 9)
                    {
                        towizfile(" Immortals");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 10)
                    {
                        towizfile(" Demi Gods");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 11)
                    {
                        towizfile(" Saviors");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 12)
                    {
                        towizfile(" Creators");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 13)
                    {
                        towizfile(" Acolytes");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 14)
                    {
                        towizfile(" Neophytes");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 15)
                    {
                        towizfile(" Retired");
                    }
                    else if (iLevel == LevelConstants.MaxLevel - 16)
                    {
                        towizfile(" Guests");
                    }
                    else
                    {
                        towizfile(" Servants");
                    }
                }

                if (buffer.Length + wiz.Name.Length > 76)
                {
                    towizfile(buffer);
                    buffer = string.Empty;
                }
                buffer += " " + wiz.Name;
                if (buffer.Length > 70)
                {
                    towizfile(buffer);
                    buffer = string.Empty;
                }
            }

            if (!string.IsNullOrEmpty(buffer))
            {
                towizfile(buffer);
            }
        }