Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (is_dir($path)) {
         throw new \Exception("The directory already exists.");
     }
     mkdir($path);
     $dialog = $this->getHelperSet()->get('dialog');
     $title = $input->getOption('title');
     $description = $input->getOption('description');
     if (empty($title)) {
         $title = $dialog->ask($output, '<question>Enter the title of the profile:</question> ');
     }
     if (empty($description)) {
         $description = $dialog->ask($output, '<question>Enter the description of the profile</question>');
     }
     $name = basename($path);
     $twig = $this->getTwig();
     // What's the latest release of NS Core?
     $fetcher = new DrupalReleaseFetcher();
     $release = $fetcher->getReleaseInfo('ns_core', '7.x')->currentRelease();
     $version = "{$release['major']}.{$release['patch']}";
     if (!empty($release['extra'])) {
         $version .= "-{$release['extra']}";
     }
     $projects = array('ns_core' => array('name' => 'ns_core', 'type' => 'module', 'version' => $version, 'subdir' => 'contrib'));
     $variables = array('profile' => $name, 'title' => $title, 'description' => $description, 'projects' => $projects);
     file_put_contents($path . '/' . $name . '.profile', $twig->render('profile/profile.profile', $variables));
     file_put_contents($path . '/' . $name . '.install', $twig->render('profile/profile.install', $variables));
     file_put_contents($path . '/' . $name . '.info', $twig->render('profile/profile.info', $variables));
     file_put_contents($path . '/' . $name . '.make', $twig->render('profile/profile.make', $variables));
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (is_dir($path)) {
         throw new \Exception("The directory already exists.");
     }
     mkdir($path);
     $dialog = $this->getHelperSet()->get('dialog');
     $twig = $this->getTwig();
     $name = basename($path);
     // Fetch Drupal.
     $returnVal = 1;
     $output->writeln("Fetching Drupal");
     $fetcher = new DrupalReleaseFetcher();
     $api = $input->getOption('api');
     $release = $fetcher->getReleaseInfo('drupal', $api)->currentRelease();
     $drupalIdentifier = "drupal-{$release['version']}";
     passthru("drush dl {$drupalIdentifier} --destination={$path}", $returnVal);
     if ($returnVal) {
         throw new \Exception("Could not download Drupal.");
     }
     passthru("mv {$path}/{$drupalIdentifier} {$path}/web");
     if ($api == '7.x' && ($input->getOption('create-profile') || $dialog->askConfirmation($output, '<question>Do you want to create an installation profile?</question> '))) {
         $arguments = array('command' => 'create-profile');
         $profile_name = $input->getOption('profile-name');
         if (empty($profile_name)) {
             $profile_name = $dialog->ask($output, '<question>Enter the name of the profile:</question> ');
         }
         $arguments['path'] = $profile_path = $path . '/web/profiles/' . $profile_name;
         $command = $this->getApplication()->find('create-profile');
         $cmdInput = new ArrayInput($arguments);
         $returnCode = $command->run($cmdInput, $output);
         if ($input->getOption('build-profile') || $dialog->askConfirmation($output, '<question>Do you want to build your profile now?</question> ')) {
             $output->writeln("Building installation profile...");
             passthru("drush make -y --no-core --contrib-destination={$profile_path} {$profile_path}/{$profile_name}.make");
         }
     }
     $variables = array('core_version' => '7.15');
     file_put_contents($path . '/' . 'platform.make', $twig->render('project/platform.make', $variables));
     file_put_contents($path . '/' . '.gitignore', $twig->render('project/gitignore', $variables));
     file_put_contents($path . '/' . 'build', $twig->render('project/build', $variables));
     exec('chmod +x ' . $path . '/' . 'build');
     if ($input->getOption('use-vagrant') || $dialog->askConfirmation($output, '<question>Do you want to use vagrant for this project?</question> ')) {
         $command = $this->getApplication()->find('vagrantify');
         $arguments = array('command' => 'create-profile', '--path' => $path);
         $input = new ArrayInput($arguments);
         $returnCode = $command->run($input, $output);
     }
 }