Esempio n. 1
0
        private static JObject CreateSaveObject(UnpkgJsonEntry entry)
        {
            var jEntry = new JObject
            {
                ["version"] = ExtractVersion(entry.Version),
                ["files"]   = JArray.FromObject(entry.Files.Select(f =>
                                                                   new { file = f.Path, cdn = f.CdnUrl, local = f.LocalPath, integrity = f.Integrity }))
            };

            return(jEntry);
        }
Esempio n. 2
0
        public static UnpkgJsonEntry Create(string packageName, DistFile file)
        {
            var entry = new UnpkgJsonEntry
            {
                PackageName = packageName,
                Version     = file.BaseUrl,
                Files       = new List <UnpkgJsonFile>()
            };

            AddFiles(entry.Files, file.Files);
            return(entry);
        }
Esempio n. 3
0
        private static async Task <UnpkgJsonEntry> AddPackage(string package)
        {
            var distFile = await Dist.Get(package);

            if (distFile == null)
            {
                return(null);
            }

            var distDirectory = distFile.Files.FirstOrDefault(f =>
                                                              f.Type.Equals("directory", StringComparison.OrdinalIgnoreCase) && f.Path.Equals("/dist", StringComparison.OrdinalIgnoreCase));

            if (distDirectory != null)
            {
                distDirectory.BaseUrl = distFile.BaseUrl;
                distFile = distDirectory;
            }

            await DownloadPackage(package, distFile.BaseUrl, distFile.Files);

            return(UnpkgJsonEntry.Create(package, distFile));
        }
Esempio n. 4
0
 private static async Task <(UnpkgJsonEntry, DistFile)> GetDistFile(UnpkgJsonEntry entry)
 {
     return(entry, await Dist.Get(entry.PackageName));
 }