/**
  * 
  */
 public function testSavePreventsReplacementOfEmptyProperties()
 {
     $tmpFile = tempnam(sys_get_temp_dir(), '');
     copy(__DIR__ . '/testdata/empty.json', $tmpFile);
     $this->helper->setComposerFile($tmpFile);
     $this->helper->setVersion(new \Liip\RMT\Version('1.2.3'));
     $contents = file_get_contents($tmpFile);
     $this->assertNotContains('_empty_', $contents);
 }
Example #2
0
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $helper = new ComposerConfig();
     $file = $this->getApplication()->getProjectRootDir() . '/composer.json';
     $helper->setComposerFile($file);
     $config = $helper->getRMTConfigSection();
     if (!$config) {
         return;
     }
     $this->writeBigTitle('Current: ' . $helper->getProjectName() . ' ' . $helper->getCurrentVersion());
     $this->writeEmptyLine();
 }
Example #3
0
 /**
  * Context factory method.
  * 
  * @param \Liip\RMT\Application $application
  * @return \Liip\RMT\Context
  */
 public static function create(Application $application)
 {
     $rootDir = $application->getProjectRootDir();
     $helper = new Helpers\ComposerConfig();
     $helper->setComposerFile($rootDir . '/composer.json');
     $config = $helper->getRMTConfigSection();
     $context = new Context();
     $builder = new Helpers\ServiceBuilder($context);
     /*
      * The following services are config-dependent
      */
     if ($config !== null) {
         if ($config->getVcs()) {
             $context->setService('vcs', $builder->getService($config->getVcs(), 'vcs'));
         }
         // Store the config for latter usage
         $context->setParameter('config', $config);
         /*
          * populate version persister
          */
         $context->setService("version-persister", $builder->getService($config->getVersionPersister(), 'versionPersister'));
         $context->setService("version-detector", $builder->getService($config->getVersionDetector(), 'versionDetector'));
         /*
          * popluate lists
          */
         foreach (array("prerequisites", self::PRERELEASE_LIST, "postReleaseActions") as $listName) {
             $context->createEmptyList($listName);
             foreach ($config->{$listName} as $service) {
                 $context->addToList($listName, $builder->getService($service, $listName));
             }
         }
     }
     // Provide the root dir as a context parameter
     $context->setParameter('project-root', $rootDir);
     return $context;
 }
Example #4
0
 /**
  * Returns the configuration.
  * 
  * @return object
  * @throws NoConfigurationException
  */
 public function getConfig()
 {
     $helper = new Helpers\ComposerConfig();
     $file = $this->getProjectRootDir() . '/composer.json';
     $helper->setComposerFile($file);
     $config = $helper->getRMTConfigSection();
     if ($config === null) {
         throw new NoConfigurationException("Impossible to locate the extra/rmt config section in {$file}. If it's the first time you\n                are using this tool, you need to setup your project using the [RMT init] command");
     }
     return $config;
 }