Esempio n. 1
0
 protected function readPackage($path)
 {
     $jsonLoader = new Package\Util\JSON\Loader(new Package\Util\Loader());
     $package = null;
     if (file_exists($path . DIRECTORY_SEPARATOR . 'composer.json')) {
         $package = $jsonLoader->load($path . DIRECTORY_SEPARATOR . 'composer.json');
     }
     if (null === $package && $this->noConvert) {
         throw new \RuntimeException('XML package are not supported. Please convert it before install');
     }
     if (null === $package) {
         try {
             $loader = new Package\PHP\Util\XML\Loader(new Package\Util\Loader());
             $pkgXml = new PackageXml($path);
             $pkgXml->dump();
             $jsonPath = $pkgXml->getJsonPath();
             $package = $jsonLoader->load($jsonPath);
         } catch (Exception $e) {
             /* pass for now, be compatible */
         }
     }
     if (null == $package) {
         /* Just ensure it's correct, */
         throw new \Exception("Couldn't read package info at '{$path}'");
     }
     $package->setRootDir(realpath($path));
     (new Header\Version($package))->updateJSON();
     return $package;
 }
Esempio n. 2
0
 protected function readPackage($path)
 {
     $jsonLoader = new Package\Util\JSON\Loader(new Package\Util\Loader());
     $package = null;
     if (file_exists($path . DIRECTORY_SEPARATOR . 'composer.json')) {
         $package = $jsonLoader->load($path . DIRECTORY_SEPARATOR . 'composer.json');
     }
     if (null === $package && $this->noConvert) {
         throw new \RuntimeException('XML package are not supported. Please convert it before install');
     }
     if (null === $package) {
         try {
             $loader = new Package\PHP\Util\XML\Loader(new Package\Util\Loader());
             $pkgXml = new PackageXml($path);
             $pkgXml->dump();
             $jsonPath = $pkgXml->getJsonPath();
             $package = $jsonLoader->load($jsonPath);
         } catch (Exception $e) {
             /* pass for now, be compatible */
         }
     }
     if (null == $package) {
         /* Just ensure it's correct, */
         throw new \Exception("Couldn't read package info at '{$path}'");
     }
     $package->setRootDir(realpath($path));
     /* We're not adding any versions into the composer.json for the source release.
        Instead we just set the package version and that's it. The version is to be
        contained in the extension sources, so no need to maintain it more than once.
        */
     $version = new Header\Version($package);
     $package->replaceVersion((new VersionParser())->normalize($version), $version);
     return $package;
 }
Esempio n. 3
0
 protected function readPackage($path)
 {
     $jsonLoader = new Package\Util\JSON\Loader(new Package\Util\Loader());
     $package = null;
     if (file_exists($path . DIRECTORY_SEPARATOR . 'composer.json')) {
         $package = $jsonLoader->load($path . DIRECTORY_SEPARATOR . 'composer.json');
     }
     if (null === $package && $this->noConvert) {
         throw new \RuntimeException('XML package are not supported. Please convert it before install');
     }
     if (null === $package) {
         try {
             $loader = new Package\PHP\Util\XML\Loader(new Package\Util\Loader());
             $pkgXml = new PackageXml($path);
             $pkgXml->dump();
             $jsonPath = $pkgXml->getJsonPath();
             $package = $jsonLoader->load($jsonPath);
         } catch (Exception $e) {
             /* pass for now, be compatible */
         }
     }
     if (null == $package) {
         /* Just ensure it's correct, */
         throw new \Exception("Couldn't read package info at '{$path}'");
     }
     $package->setRootDir(realpath($path));
     $this->composerJsonBak($package);
     /* For the binary release, json badly need the version informatio
        to show the meta info. If there's ever a binary release support
        for other platforms, this will need to be done, probably. */
     (new Header\Version($package))->updateJSON();
     return $package;
 }