public ImplementationPackage(PackageContent content)
 {
     this.content            = content;
     this.implementations    = new List <ImplPkgImplementation>();
     this.implementationYaml = ImplPackageYaml.fromYaml(OneYaml.load(content.files.get("package.yaml")));
     this.implementations    = new List <ImplPkgImplementation>();
     foreach (var impl in this.implementationYaml.implements_ ?? new ImplPkgImplementation[0])
     {
         this.implementations.push(impl);
     }
     foreach (var include in this.implementationYaml.includes ?? new string[0])
     {
         var included = ImplPackageYaml.fromYaml(OneYaml.load(content.files.get(include)));
         foreach (var impl in included.implements_)
         {
             this.implementations.push(impl);
         }
     }
 }
Ejemplo n.º 2
0
        public async Task <PackageBundle> getAllCached()
        {
            var packages = new Dictionary <string, PackageContent> {
            };
            var allFiles = OneFile.listFiles(this.packagesDir, true);

            foreach (var fn in allFiles)
            {
                var pathParts = fn.split(new RegExp("/")).ToList();
                // [0]=implementations/interfaces, [1]=package-name, [2:]=path
                if (pathParts.length() < 3)
                {
                    continue;
                }
                var type   = pathParts.shift();
                var pkgDir = pathParts.shift();
                if (type != "implementations" && type != "interfaces")
                {
                    continue;
                }
                // skip e.g. bundle.json
                var pkgIdStr = $"{type}/{pkgDir}";
                var pkg      = packages.get(pkgIdStr);
                if (pkg == null)
                {
                    var pkgDirParts = pkgDir.split(new RegExp("-")).ToList();
                    var version     = pkgDirParts.pop().replace(new RegExp("^v"), "");
                    var pkgType     = type == "implementations" ? PackageType.Implementation : PackageType.Interface;
                    var pkgId       = new PackageId(pkgType, pkgDirParts.join("-"), version);
                    pkg = new PackageContent(pkgId, new Dictionary <string, string> {
                    }, true);
                    packages.set(pkgIdStr, pkg);
                }
                pkg.files.set(pathParts.join("/"), OneFile.readText($"{this.packagesDir}/{fn}"));
            }
            return(new PackageBundle(Object.values(packages)));
        }
 public InterfacePackage(PackageContent content)
 {
     this.content       = content;
     this.interfaceYaml = InterfaceYaml.fromYaml(OneYaml.load(content.files.get("interface.yaml")));
     this.definition    = content.files.get(this.interfaceYaml.definitionFile);
 }