Ejemplo n.º 1
0
        private void UpdateDns(PackageBundler packageBundler)
        {
            var cfapi     = new CloudFlare(Context);
            var apiResult = cfapi.GetDnsRecords(Context.CloudFlareZoneId);

            if (apiResult == null)
            {
                L.Error("No results from the CloudFlare api");
                return;
            }

            var entry = $"{packageBundler.ProjectKey}-{Radiant.DnsVersion}.{Context.CloudFlareRootDomain}";

            var record = apiResult.result.FirstOrDefault(x =>
                                                         string.Equals(x.name, entry, StringComparison.OrdinalIgnoreCase) &&
                                                         string.Equals(x.type, "TXT", StringComparison.OrdinalIgnoreCase));

            if (record == null)
            {
                L.Error("Cannot find TXT record for " + entry + "");
                return;
            }

            var updated = cfapi.UpdateDnsRecord(record.zone_id, record.id, record.type, record.name, packageBundler.Hash, 120);

            if (!updated.success)
            {
                L.Error("Unable to update TXT record for " + entry + "");
            }

            L.Info("Updated DNS record '" + entry + "' with hash: " + packageBundler.Hash);
        }
Ejemplo n.º 2
0
        private void Add(IpFsApi api, PackageBundler packageBundler)
        {
            if (!packageBundler.Files.Any())
            {
                return;
            }

            try
            {
                var config = Task.Run(async() => await api.GetAddresses()).GetAwaiter().GetResult();
                IpFsPeerId = config["Identity"]["PeerID"].ToString();
            }catch { }

            Task.Run(async delegate
            {
                L.Info("Addding " + packageBundler.Packed.Count + " packages for " + packageBundler.ProjectKey + " to IPFS");

                var dir = packageBundler.PublishProjectDirectory;

                var hash = await api.Add(dir, true);

                L.Info("Pinned: " + packageBundler.ProjectKey + " " + hash);

                return(packageBundler.Hash = hash);
            }).GetAwaiter().GetResult();
        }
Ejemplo n.º 3
0
 public Package CreateMod(PackageBundler packageBundler, int mod6, List <Package> alreadyDone)
 {
     return(packageBundler.CreatePackage("mod-" + mod6, files =>
     {
         var result = Except(alreadyDone, new List <FileInfo>(files));
         result.RemoveAll(x => Math.Abs(x.Name.GetHashCode()) % 6 != mod6);
         return result;
     }));
 }
Ejemplo n.º 4
0
        public PackageBundler Fill(PackageBundler packageBundler)
        {
            _publishManager.L.Info("Packaging: " + packageBundler.ProjectKey);

            var packages = new List <Package>();

            packages.Add(packageBundler.CreatePackage("core", files =>
            {
                var result = new List <FileInfo>();
                result.AddRange(files.Where(x => x.Name.StartsWith("prime", StringComparison.OrdinalIgnoreCase)));
                result.AddRange(files.Where(x => x.Name.StartsWith("radiant", StringComparison.OrdinalIgnoreCase)));
                result.AddRange(files.Where(x => x.Name.StartsWith("spark", StringComparison.OrdinalIgnoreCase)));
                return(result);
            }));

            packages.Add(packageBundler.CreatePackage("ext-ipfsnative", files =>
            {
                var result = new List <FileInfo>(files.Where(x => x.Name.StartsWith("ipfs-x") && x.Name.EndsWith(".exe")));
                return(result);
            }));

            packages.Add(packageBundler.CreatePackage("ext-7znative", files =>
            {
                var result = new List <FileInfo>(files.Where(x => x.Name.StartsWith("7z-x") && x.Name.EndsWith(".dll")));
                return(result);
            }));

            packages.Add(packageBundler.CreatePackage("ext-ms", files =>
            {
                var result = Except(packages, new List <FileInfo>(files));
                result.RemoveAll(x => !(x.Name.StartsWith("common.", StringComparison.OrdinalIgnoreCase) ||
                                        x.Name.StartsWith("system.", StringComparison.OrdinalIgnoreCase) ||
                                        x.Name.StartsWith("microsoft.", StringComparison.OrdinalIgnoreCase)));
                return(result);
            }));

            packages.Add(CreateMod(packageBundler, 0, packages));
            packages.Add(CreateMod(packageBundler, 1, packages));
            packages.Add(CreateMod(packageBundler, 2, packages));
            packages.Add(CreateMod(packageBundler, 3, packages));
            packages.Add(CreateMod(packageBundler, 4, packages));
            packages.Add(CreateMod(packageBundler, 5, packages));

            return(packageBundler);
        }