/** * {@inheritdoc} */ public function install(PackageInterface $package) { $tmpFileName = $this->config->getCacheDir() . '/tmp/' . $package->getName(); if ($this->zipArchive->open($tmpFileName) !== true) { throw new RuntimeException(sprintf('Unable to open zip file %s.', $tmpFileName)); } $dirName = trim($this->zipArchive->getNameIndex(0), '/'); $info = $package->getInfo(); $files = $this->filterZipFiles($this->zipArchive, isset($info['ignore']) ? $info['ignore'] : array(), isset($info['main']) ? (array) $info['main'] : array()); foreach ($files as $i => $file) { $stat = $this->zipArchive->statIndex($i); $fileName = $this->config->getInstallDir() . '/' . str_replace($dirName, $package->getName(), $file); if (substr($fileName, -1) != '/') { $fileContent = $this->zipArchive->getStream($file); $this->filesystem->write($fileName, $fileContent); $this->filesystem->touch($fileName, $stat['mtime']); } } // adjust timestamp for directories foreach ($files as $i => $file) { $stat = $this->zipArchive->statIndex($i); $fileName = $this->config->getInstallDir() . '/' . str_replace($dirName, $package->getName(), $file); if (is_dir($fileName) && substr($fileName, -1) == '/') { $this->filesystem->touch($fileName, $stat['mtime']); } } $this->zipArchive->close(); // create .bower.json metadata file // XXX we still need to add some other info $dotBowerContent = array_merge($package->getInfo(), array('version' => $package->getVersion())); $dotBowerJson = str_replace('\\/', '/', Json::encode($dotBowerContent)); $this->filesystem->write($this->config->getInstallDir() . '/' . $package->getName() . '/.bower.json', $dotBowerJson); }
/** * writelnListPackage * * @param PackageInterface $package */ public function writelnListPackage(PackageInterface $package, Bowerphp $bowerphp) { $this->output->writeln(sprintf('%s#%s<info>%s</info>', $package->getName(), $package->getVersion(), $bowerphp->isPackageExtraneous($package) ? ' extraneous' : '')); }