Beispiel #1
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $this->logLine('Starting folder synchronization');
     $exclude = '';
     $include = '';
     if (isset($options['config-file'])) {
         $configDir = nbConfig::get('nb_plugins_dir') . '/nbFileSystemPlugin/config';
         $configFilename = $options['config-file'];
         $this->checkConfiguration($configDir, $configFilename);
     }
     if (isset($options['exclude-from']) && file_exists($options['exclude-from'])) {
         $exclude = ' --exclude-from \'' . $options['exclude-from'] . '\' ';
     }
     if (isset($options['include-from']) && file_exists($options['include-from'])) {
         $include = ' --include-from \'' . $options['include-from'] . '\' ';
     }
     $doit = isset($options['doit']) ? '' : '--dry-run';
     $delete = isset($options['delete']) ? '--delete' : '';
     // Trailing slash must be added after sanitize dir
     $sourceDir = nbFileSystem::sanitizeDir($arguments['source-dir']) . '/';
     $targetDir = nbFileSystem::sanitizeDir($arguments['target-dir']);
     $cmd = sprintf('rsync -rzChv %s %s %s %s %s %s', $doit, $include, $exclude, $delete, $sourceDir, $targetDir);
     $owner = isset($options['owner']) ? $options['owner'] : null;
     if ($owner) {
         $cmd = sprintf('sudo -u %s %s', $owner, $cmd);
     }
     if (!isset($options['doit'])) {
         $this->logLine('Executing command: ' . $cmd);
     }
     $this->executeShellCommand($cmd);
     $this->logLine('Folders synchronization completed');
     return true;
 }
Beispiel #2
0
 /**
  * Register a new plugin for autoloading.
  * 
  */
 private function addPlugin($pluginName)
 {
     //    nbLogger::getInstance()->logLine('Loading Plugin <comment>' . $pluginName . '</comment>...');
     if (key_exists($pluginName, $this->plugins)) {
         return true;
     }
     foreach ($this->pluginDirs as $dir) {
         $path = $dir . '/' . $pluginName;
         if (is_dir($path)) {
             $this->plugins[$pluginName] = $path;
         }
     }
     if (!key_exists($pluginName, $this->plugins)) {
         throw new Exception(sprintf('Plugin %s not found', $pluginName));
     }
     nbAutoload::getInstance()->addDirectory($this->plugins[$pluginName] . '/lib', '*.php', true);
     nbAutoload::getInstance()->addDirectory($this->plugins[$pluginName] . '/command', '*Command.php', true);
     nbAutoload::getInstance()->addDirectory($this->plugins[$pluginName] . '/vendor');
     self::$commandLoader->addCommandsFromDir($this->plugins[$pluginName] . '/command');
     if (is_dir($this->plugins[$pluginName] . '/test/unit')) {
         $testDirs = nbConfig::get('nb_plugin_test_dirs', array());
         $testDirs[] = $this->plugins[$pluginName] . '/test/unit';
         nbConfig::set('nb_plugin_test_dirs', array_unique($testDirs));
     }
     if (!file_exists($this->plugins[$pluginName] . '/config/config.yml')) {
         return true;
     }
     $yamlParser = new nbYamlConfigParser();
     $yamlParser->parseFile($this->plugins[$pluginName] . '/config/config.yml', '', true);
 }
Beispiel #3
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     if (nbConfig::has('project_type')) {
         $projectType = nbConfig::get('project_type');
         if ($projectType == "bee") {
             $unitTest = new nbBeeTestUnitCommand();
             $retUnit = $unitTest->run(new nbCommandLineParser(), '', true);
             $pluginsTest = new nbBeeTestPluginsCommand();
             $retPlugin = $pluginsTest->run(new nbCommandLineParser(), '', true);
             if ($retUnit == 0 or $retPlugin == 0) {
                 return 0;
             } else {
                 return 1;
             }
         } else {
             try {
                 $commandSet = $this->getApplication()->getCommands();
                 $testAllCmd = $commandSet->getCommand($projectType . ':test-all');
                 $testAllCmd->run(new nbCommandLineParser(), '', true);
                 return true;
             } catch (Exception $e) {
                 $this->logLine($e->getMessage(), nbLogger::ERROR);
                 return false;
             }
         }
     } else {
         throw new Exception('Project type not defined');
     }
 }
Beispiel #4
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $message = $this->formatLine('Project configuration', nbLogger::COMMENT);
     $message .= "\n";
     if (isset($options['filter'])) {
         $params = nbConfig::get($options['filter']);
         $params = nbArrayUtils::getAssociative($params);
         $message .= $this->formatLine('Filter is: <info>' . $options['filter'] . '</info> ', nbLogger::COMMENT);
         $message .= "\n";
     } else {
         $params = nbConfig::getAll(true);
     }
     ksort($params);
     $max = 0;
     foreach ($params as $param => $value) {
         if ($max < strlen($param)) {
             $max = strlen($param);
         }
     }
     foreach ($params as $param => $value) {
         $message .= $this->format(sprintf(" %-{$max}s", $param), nbLogger::INFO);
         $message .= sprintf("  => %s\n", $this->format($value, nbLogger::COMMENT));
     }
     $this->log($message);
 }
Beispiel #5
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $testCmd = new nbBeeTestUnitCommand();
     $pluginTestDirs = nbConfig::get('nb_plugin_test_dirs');
     $options['dir'] = $pluginTestDirs;
     $options['exclude-project-folder'] = true;
     $ret = $testCmd->execute($arguments, $options);
     return $ret;
 }
Beispiel #6
0
    protected function configure()
    {
        $this->setName('bee:update')->setBriefDescription('Updates bee')->setDescription(<<<TXT
The <info>{$this->getFullName()}</info> command:

  <info>./bee {$this->getFullName()}</info>
TXT
);
        $this->setArguments(new nbArgumentSet(array(new nbArgument('source_dir', nbArgument::OPTIONAL, 'Sources directory', nbConfig::get('nb_bee_dir')))));
    }
function getBuildVersion($versionFile)
{
    if (file_exists($versionFile)) {
        $configParser = new nbYamlConfigParser();
        $configParser->parseFile($versionFile);
        $version = nbConfig::get('version');
        $arrayVersion = array();
        $arrayVersion = preg_split('/\\./', $version);
        return $arrayVersion[3];
    }
}
Beispiel #8
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $this->checkBeeProject();
     if (!nbConfig::has('project_repository_root-directory')) {
         throw new Exception('You must configure your project directory (absolute path!)');
     }
     $shell = new nbShell();
     if (!isset($options['force'])) {
         // git status
         $this->logLine("git status:", nbLogger::INFO);
         $command = 'git status';
         $shell->execute($command);
         // git tag
         $this->logLine("git tag", nbLogger::INFO);
         $command = 'git tag';
         $shell->execute($command);
         return 0;
     }
     if (!isset($arguments['message'])) {
         throw new Exception('You must write a commit message!');
     }
     $message = $arguments['message'];
     $repoDir = nbConfig::get('project_repository_root-directory');
     // git add <project repository directory>
     $command = sprintf('git add %s', $repoDir);
     $shell->execute($command);
     // git commit -m "<message>"
     $command = sprintf('git commit -m "%s"', $message);
     $shell->execute($command);
     // git pull
     $command = 'git pull';
     if (!$shell->execute($command)) {
         throw new Exception('There are conflicts. Resolve them and re-run this command.');
     }
     // test command
     if (!nbConfig::has('project_test-command')) {
         throw new Exception('You must configure your test command');
     }
     $command = nbConfig::get('project_test-command');
     if (!$shell->execute($command)) {
         throw new Exception('There are test failures. Fix them and re-run this command.');
     }
     if (isset($options['tag'])) {
         $tag = $options['tag'];
         $command = sprintf('git tag %s', $tag);
         $shell->execute($command);
         // git push with tags
         $command = 'git push origin master --tags';
     } else {
         // git push
         $command = 'git push';
     }
     $shell->execute($command);
 }
Beispiel #9
0
 protected function getAlias($command)
 {
     $aliases = nbConfig::get('project_shell_aliases');
     if (null !== $aliases && is_array($aliases) && array_key_exists($command, $aliases)) {
         $this->log('Alias found for ' . $command, nbLogger::COMMENT);
         $this->log("\n\n");
         return $aliases[$command];
     } else {
         return null;
     }
 }
Beispiel #10
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $project = isset($options['test']) ? nbConfig::get('project_test') : nbConfig::get('project_core');
     $configuration = $arguments['configuration'];
     $incremental = isset($options['incremental']) ? '/rebuild' : '';
     $this->logLine(sprintf('Building project "%s" (target: %s'), $project, $configuration);
     $info = "[info]: ";
     $warning = "[warning]: ";
     $error = "[error]: ";
     $command = sprintf('vcbuild /nondefmsbuild /nologo /info:"%s" /warning:"%s" /error:"%s" %s "%s" "%s"', $info, $warning, $error, $incremental, $project, $configuration);
     $this->executeShellCommand($command);
 }
Beispiel #11
0
 public function getPublishCmdLine($local = false)
 {
     $props = parse_ini_file(nbConfig::get('nb_ivy_properties'));
     $command = 'java -jar "' . nbConfig::get('nb_ivy_executable') . '" ';
     $command .= '-settings "' . $this->settings . '" ';
     $command .= '-publish ';
     if ($local) {
         $command .= 'local';
     } else {
         $command .= 'shared';
     }
     return $command;
 }
Beispiel #12
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $this->logLine('Running tests', nbLogger::COMMENT);
     $command = '"' . $arguments['testapp'] . '" ';
     if (isset($options['output'])) {
         $command .= '--gtest_output=xml:' . $options['output'] . ' ';
         $testResultDir = dirname(nbConfig::get('project_testresult'));
         nbFileSystem::rmdir($testResultDir, true);
         nbFileSystem::mkdir($testResultDir, true);
     }
     //    if(isset($options['nocolor']))
     //      $command .= '--gtest_color=no ';
     $this->executeShellCommand($command);
 }
Beispiel #13
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $allPluginsDir = nbConfig::get('nb_plugins_dir');
     $pluginName = $arguments['plugin-name'];
     $projectDir = $arguments['project-dir'];
     $configDir = $projectDir . '/.bee';
     $beeConfig = $configDir . '/bee.yml';
     $force = isset($options['force']);
     $pluginPath = $allPluginsDir . '/' . $pluginName;
     $verbose = isset($options['verbose']);
     if (!file_exists($pluginPath)) {
         throw new Exception('plugin ' . $pluginName . ' not found in ' . nbConfig::get('nb_plugins_dir'));
     }
     if (!file_exists($beeConfig)) {
         throw new Exception($beeConfig . ' not found');
     }
     $configParser = sfYaml::load($beeConfig);
     $plugins = $configParser['project']['bee']['enabled_plugins'];
     $plugins = isset($configParser['project']['bee']['enabled_plugins']) ? $configParser['project']['bee']['enabled_plugins'] : array();
     if (!is_array($plugins)) {
         $plugins = array();
     }
     if (!in_array($pluginName, $plugins)) {
         array_push($plugins, $pluginName);
         $configParser['project']['bee']['enabled_plugins'] = $plugins;
         $yml = sfYaml::dump($configParser, 99);
         file_put_contents($beeConfig, $yml);
         $this->logLine('Installing plugin ' . $pluginName);
     } else {
         $this->logLine('Plugin ' . $pluginName . ' already installed');
     }
     // Configuration will not generated
     if (isset($options['no-configuration'])) {
         return true;
     }
     // Configure plugin
     $pluginConfigDir = sprintf('%s/%s/config', $allPluginsDir, $pluginName);
     $files = nbFileFinder::create('file')->add('*.template.yml')->in($pluginConfigDir);
     $generator = new nbConfigurationGenerator();
     $this->getFileSystem()->mkdir($configDir, true);
     foreach ($files as $file) {
         $target = sprintf('%s/%s', $configDir, str_replace('.template.yml', '.yml', basename($file)));
         $generator->generate($file, $target, $force);
         if ($verbose) {
             $this->logLine('file+: ' . $target, nbLogger::INFO);
         }
     }
     return true;
 }
Beispiel #14
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     if (nbConfig::has('project_android_test_build-file')) {
         $buildFile = nbConfig::get('project_android_test_build-file');
     } else {
         throw new Exception('"project_android_test_build-file" not set');
     }
     if (nbConfig::has('project_type') && nbConfig::get('project_type') == 'android') {
         $cmd = sprintf('ant -f %s test', $buildFile);
         $this->executeShellCommand($cmd);
         return true;
     } else {
         throw new Exception('This isn\'t a android project');
     }
 }
 protected function execute(array $arguments = array(), array $options = array())
 {
     $versionFile = $arguments['version-file'];
     if (!file_exists($versionFile)) {
         throw new Exception('Version file: ' . $versionFile . ' does not exist');
     }
     $configParser = new nbYamlConfigParser();
     $configParser->parseFile($versionFile);
     $initialVersion = nbConfig::get('version');
     $arrayVersion = array();
     $arrayVersion = preg_split('/\\./', $initialVersion);
     $arrayVersion[3]++;
     $finalVersion = join('.', $arrayVersion);
     nbFileSystem::replaceTokens($initialVersion, $finalVersion, $versionFile);
     return true;
 }
Beispiel #16
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $this->checkBeeProject();
     $doit = isset($options['doit']);
     $verbose = isset($options['verbose']) || !$doit;
     // Loads configuration
     $configDir = nbConfig::get('nb_plugins_dir') . '/nbWebsitePlugin/config/';
     $configFilename = isset($options['config-file']) ? $options['config-file'] : '.bee/website-deploy.yml';
     $this->loadConfiguration($configDir, $configFilename);
     // Variables from config
     $websiteName = nbConfig::get('website_name');
     //    $deployDir = nbConfig::get('deploy_dir');
     $excludeList = nbConfig::get('exclude_list');
     $includeList = nbConfig::get('include_list');
     $backupSources = nbConfig::get('backup_sources');
     $backupDestination = nbConfig::get('backup_destination');
     $webSourceDir = nbConfig::get('web_source_dir');
     $webProdDir = nbConfig::get('web_prod_dir');
     $webUser = nbConfig::get('web_user');
     //    $webGroup = nbConfig::get('web_group');
     $dbName = nbConfig::get('db_name');
     $dbUser = nbConfig::get('db_user');
     $dbPass = nbConfig::get('db_pass');
     $this->logLine('Deploying website', nbLogger::INFO);
     // Archive site directory
     if (!isset($options['no-backup'])) {
         $cmd = new nbArchiveCommand();
         $cmdLine = sprintf('%s/%s.tgz %s --add-timestamp --force', $backupDestination, $websiteName, implode(' ', $backupSources));
         $this->executeCommand($cmd, $cmdLine, $doit, $verbose);
     }
     // Dump database
     if ($dbName && $dbUser && $dbPass && !isset($options['no-dump'])) {
         $cmd = new nbMysqlDumpCommand();
         $cmdLine = sprintf('%s %s %s %s', $dbName, $backupDestination, $dbUser, $dbPass);
         $this->executeCommand($cmd, $cmdLine, $doit, $verbose);
     }
     // Sync web directory
     $cmd = new nbDirTransferCommand();
     $delete = isset($options['delete']) ? '--delete' : '';
     $cmdLine = sprintf('%s %s --owner=%s --exclude-from=%s --include-from=%s %s %s', $webSourceDir, $webProdDir, $webUser, $excludeList, $includeList, $doit ? '--doit' : '', $delete);
     $this->executeCommand($cmd, $cmdLine, true, $verbose);
     $this->logLine('Website deployed successfully', nbLogger::INFO);
     return true;
 }
Beispiel #17
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $pluginName = $arguments['plugin_name'];
     $targetDir = isset($options['directory']) ? $options['directory'] : nbConfig::get('nb_plugins_dir');
     $pluginDir = $targetDir . '/' . $pluginName;
     $fs = $this->getFileSystem();
     if (isset($options['force'])) {
         $fs->rmdir($pluginDir, true);
     }
     $fs->mkdir($pluginDir, true);
     $fs->mkdir($pluginDir . '/command');
     $fs->mkdir($pluginDir . '/config');
     $fs->mkdir($pluginDir . '/lib');
     $fs->mkdir($pluginDir . '/lib/vendor');
     $fs->mkdir($pluginDir . '/test');
     $fs->mkdir($pluginDir . '/test/bootstrap');
     $fs->mkdir($pluginDir . '/test/data');
     $fs->mkdir($pluginDir . '/test/data/config');
     $fs->mkdir($pluginDir . '/test/unit');
 }
Beispiel #18
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $projectDir = $arguments['project-dir'];
     $this->logLine(sprintf('Generating bee project in %s', $projectDir));
     $fs = $this->getFileSystem();
     $configDir = $fs->sanitizeDir($projectDir) . '/.bee';
     $force = isset($options['force']) ? true : false;
     $projectType = isset($options['type']) ? $options['type'] : '';
     $repositoryType = isset($options['repository-type']) ? $options['repository-type'] : '';
     $fs->mkdir($configDir, true);
     $fs->copy(nbConfig::get('nb_bee_dir') . '/data/config/bee.yml', $configDir . '/bee.yml', $force);
     $fs->copy(nbConfig::get('nb_bee_dir') . '/data/config/config.yml', $configDir . '/config.yml', $force);
     $beeConfig = $configDir . '/bee.yml';
     $configParser = sfYaml::load($beeConfig);
     // add project type
     if ($projectType != '') {
         if (!file_exists($beeConfig)) {
             throw new Exception($beeConfig . ' not found');
         }
         $configParser['project']['type'] = $projectType;
         if ($projectType == 'symfony') {
             $configParser['project']['symfony']['exec-path'] = nbConfig::get('symfony_defaults_exec-path');
             $configParser['project']['symfony']['test-enviroment'] = nbConfig::get('symfony_defaults_test-enviroment');
         }
         if ($projectType == 'android') {
             $configParser['project']['android']['test']['build-file'] = nbConfig::get('android_defaults_test_build-file');
         }
     }
     if ($repositoryType != '') {
         $configParser['project']['repository']['type'] = $repositoryType;
         if ($repositoryType == 'git') {
             $configParser['project']['repository']['root-directory'] = $projectDir;
         }
     }
     $yml = sfYaml::dump($configParser, 99);
     file_put_contents($beeConfig, $yml);
     $this->logLine('bee project generated!');
     return true;
 }
Beispiel #19
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $this->logLine('Unit testing bee');
     $files = array();
     $dirs = isset($options['dir']) ? $options['dir'] : array();
     if (!isset($options['exclude-project-folder'])) {
         $dirs[] = nbConfig::get('nb_test_dir', 'test/unit');
     }
     if (count($arguments['name'])) {
         foreach ($dirs as $dir) {
             foreach ($arguments['name'] as $name) {
                 $finder = nbFileFinder::create('file')->followLink()->add(basename($name) . 'Test.php');
                 $files = array_merge($files, $finder->in($dir . '/' . dirname($name)));
             }
         }
     } else {
         // filter and register unit tests
         $finder = nbFileFinder::create('file')->add('*Test.php');
         $files = $finder->in($dirs);
     }
     if (count($files) == 0) {
         $this->log('no tests found', nbLogger::ERROR);
         return false;
     }
     $h = new lime_harness();
     $h->register($files);
     $ret = $h->run(isset($options['showall']));
     // print output to file
     if (isset($options['output'])) {
         $fileName = $options['output'];
         $fh = fopen($fileName, 'w');
         if ($fh === false) {
             return $ret;
         }
         fwrite($fh, isset($options['xml']) ? $h->to_xml() : '');
         fclose($fh);
     }
     return $ret;
 }
Beispiel #20
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     if (nbConfig::has('project_type') and nbConfig::get('project_type') == 'symfony') {
         $symfonyExecutable = sprintf('%s/%s', nbFileSystem::sanitizeDir(nbConfig::get('project_symfony_exec-path')), 'symfony');
         $symfonyTestEnviroment = nbConfig::get('project_symfony_test-enviroment');
         $this->logLine(sprintf('Launching all test for %s enviroment', $symfonyTestEnviroment));
         if ($symfonyTestEnviroment == 'lime') {
             $cmd = sprintf('php %s test:all', $symfonyExecutable);
             $this->executeShellCommand($cmd);
         } else {
             if ($symfonyTestEnviroment == 'phpunit') {
                 $cmd = sprintf('php %s phpunit:test-all', $symfonyExecutable);
                 $this->executeShellCommand($cmd);
             } else {
                 return false;
             }
         }
         return true;
     } else {
         throw new Exception('This isn\'t a symfony project');
     }
 }
Beispiel #21
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $commandName = $arguments['command-name'];
     if (strpos($commandName, ':') > 0) {
         list($namespace, $commandName) = explode(':', $commandName);
     } else {
         $namespace = '';
     }
     $className = $arguments['class-name'];
     if (isset($options['directory'])) {
         $targetDir = $options['directory'];
     }
     if (isset($options['plugin'])) {
         $targetDir = nbConfig::get('nb_plugins_dir') . '/' . $options['plugin'] . '/command';
     }
     if (!isset($options['plugin']) && !isset($options['directory'])) {
         $targetDir = nbConfig::get('nb_command_dir');
     }
     $path = $targetDir . '/' . $namespace;
     $this->log('Creating folder ' . $path, nbLogger::COMMENT);
     $this->log("\n");
     try {
         $this->getFileSystem()->mkdir($path);
     } catch (Exception $e) {
         $this->logLine('mkdir: the folder already exists ... skipping', nbLogger::INFO);
         $this->log("\n");
     }
     $file = $path . '/' . $className . '.php';
     $this->logLine(sprintf('Copying %s/beeCommand.tpl in %s', nbConfig::get('nb_template_dir'), $file));
     $force = isset($options['force']) ? true : false;
     try {
         $this->getFileSystem()->copy(nbConfig::get('nb_template_dir') . '/beeCommand.tpl', $file, $force);
     } catch (Exception $e) {
         $this->log($e->getMessage(), nbLogger::ERROR);
     }
     $search = array('%%CLASSNAME%%', '%%NAMESPACE%%', '%%NAME%%');
     $replace = array($className, $namespace, $commandName);
     $this->getFileSystem()->replaceTokens($search, $replace, $file);
 }
 protected function execute(array $arguments = array(), array $options = array())
 {
     $filename = isset($options['filename']) ? $options['filename'] : null;
     $printer = new nbConfigurationPrinter();
     $printer->addConfiguration(nbConfig::getAll());
     if ($filename) {
         $this->logLine(sprintf('bee configuration (file: %s)', $filename), nbLogger::COMMENT);
         $printer->addConfigurationFile($filename);
     } else {
         $dirs = array('./', nbConfig::get('nb_config_dir'));
         $this->logLine(sprintf('bee configuration (dirs: %s)', implode(', ', $dirs)), nbLogger::COMMENT);
         $finder = nbFileFinder::create('file')->add('*.yml')->maxdepth(0);
         foreach ($dirs as $dir) {
             $files = $finder->in($dir);
             foreach ($files as $file) {
                 $this->logLine('Adding ' . $file, nbLogger::COMMENT);
                 $printer->addConfigurationFile($file);
             }
         }
     }
     $this->logLine($printer->printAll());
     return true;
 }
Beispiel #23
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     nbFileSystem::rmdir(nbConfig::get('project_dependencies'), true);
     $client = new nbIvyClient();
     $this->logLine('Retrieving dependencies...', nbLogger::COMMENT);
     $command = $client->getRetrieveCmdLine();
     $this->executeShellCommand($command);
     $finder = nbFileFinder::create('file');
     $files = $finder->add('*-api.zip')->in(nbConfig::get('project_dependencies'));
     $zip = new ZipArchive();
     foreach ($files as $file) {
         if ($zip->open($file, ZIPARCHIVE::CHECKCONS) !== true) {
             throw new Exception('Error opening zip file ' . $file);
         }
         $zip->extractTo(dirname($file));
         $zip->close();
         $this->logLine(sprintf('Unzipping %s', $file), nbLogger::COMMENT);
     }
     $files = $finder->add('*.zip')->in(nbConfig::get('project_dependencies'));
     foreach ($files as $file) {
         nbFileSystem::delete($file);
     }
 }
Beispiel #24
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $pluginName = $arguments['plugin-name'];
     $force = isset($options['force']);
     $destination = isset($options['config-dir']) ? $options['config-dir'] : nbConfig::get('nb_config_dir');
     $pluginsDir = nbConfig::get('nb_plugins_dir');
     $pluginDir = sprintf('%s/%s', $pluginsDir, $pluginName);
     $this->logLine('Configuring plugin: ' . $pluginName, nbLogger::COMMENT);
     if (!is_dir($pluginDir)) {
         throw new LogicException('Plugin ' . $pluginName . ' not found in ' . $pluginsDir);
     }
     $source = sprintf('%s/%s/config', $pluginsDir, $pluginName);
     //TODO: copy all files in config (?)
     $files = nbFileFinder::create('file')->add('*.template.yml')->remove('.')->remove('..')->in($source);
     $generator = new nbConfigurationGenerator();
     $this->getFileSystem()->mkdir($destination, true);
     foreach ($files as $file) {
         $target = sprintf('%s/%s', $destination, str_replace('.template.yml', '.yml', basename($file)));
         $generator->generate($file, $target, $force);
         $this->logLine('file+: ' . $target, nbLogger::INFO);
     }
     $this->logLine(sprintf('Plugin %s successully configured in %s', $pluginName, $destination), nbLogger::COMMENT);
     return true;
 }
Beispiel #25
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$mode = '644';
$folder = nbConfig::get('nb_sandbox_dir') . '/folder';
$fs = nbFileSystem::getInstance();
if (php_uname('s') == 'Linux') {
    $fs->mkdir($folder);
    $t = new lime_test(1);
    $cmd = new nbChangeModeCommand();
    $commandLine = sprintf('%s %s', $folder, $mode);
    $t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'Folder mode changed successfully');
    $fs->rmdir($folder);
} else {
    $t = new lime_test(0);
    $t->comment('No tests under Windows');
}
//Setup
try {
    $cmd = new nbMysqlDropCommand();
    $commandLine = sprintf('%s %s %s', $dbName, $adminUsername, $adminPassword);
    $cmd->run(new nbCommandLineParser(), $commandLine);
} catch (Exception $e) {
    $t->comment('Drop database: ' . $e->getMessage());
}
try {
    $cmd = new nbMysqlCreateCommand();
    $commandLine = sprintf('%s %s %s', $dbName, $adminUsername, $adminPassword);
    $cmd->run(new nbCommandLineParser(), $commandLine);
} catch (Exception $e) {
    $t->comment('Create database: ' . $e->getMessage());
}
$cmd = new nbSymfonyDeployCommand();
$parser = new nbCommandLineParser();
$parser->setDefaultConfigurationDirs(array(dirname(__FILE__) . '/../data/config'));
$t->comment('Symfony Deploy dry run');
$commandLine = '--config-file ';
$t->ok($cmd->run($parser, $commandLine), 'Symfony project deployed successfully');
$cmd = new nbSymfonyDeployCommand();
$parser = new nbCommandLineParser();
$parser->setDefaultConfigurationDirs(array(dirname(__FILE__) . '/../data/config'));
$t->comment('Symfony Deploy');
$commandLine = '--config-file --doit';
$t->ok($cmd->run($parser, $commandLine), 'Symfony project deployed successfully');
$fileSystem->rmdir($logDir, true, true);
$fileSystem->rmdir($cacheDir, true, true);
$fileSystem->rmdir(nbConfig::get('archive_archive-dir_destination-dir'), true);
Beispiel #27
0
<?php

require_once dirname(__FILE__) . '/../../../../test/bootstrap/unit.php';
nbConfig::set('nb_command_dir', nbConfig::get('nb_sandbox_dir'));
$projectDir = nbConfig::get('nb_sandbox_dir');
$configDir = nbConfig::get('nb_sandbox_dir') . '/.bee';
$beeConfig = $configDir . '/bee.yml';
$config = $configDir . '/config.yml';
$fileSystemConfig = $configDir . '/filesystem-plugin.yml';
$multiChangeModeConfig = $configDir . '/filesystem-multi-change-mode.yml';
$dirTransferConfig = $configDir . '/filesystem-dir-transfer.yml';
function isPluginEnabled($beeConfig, $plugin)
{
    if (!file_exists($beeConfig)) {
        throw new Exception('bee config file not found');
    }
    $parser = sfYaml::load($beeConfig);
    $plugins = isset($parser['project']['bee']['enabled_plugins']) ? $parser['project']['bee']['enabled_plugins'] : array();
    return in_array($plugin, $plugins);
}
$t = new lime_test(12);
$cmd = new nbGenerateProjectCommand();
$t->ok($cmd->run(new nbCommandLineParser(), $projectDir), 'Command nbGenerateProjectCommand called successfully');
$t->ok(file_exists($beeConfig), 'bee.yml added to the destination dir :' . $beeConfig);
$t->ok(file_exists($config), 'config.yml added to the destination dir :' . $config);
$t->comment('enabling nbDummyPlugin');
$plugin = 'nbDummyPlugin';
$t->ok(!isPluginEnabled($beeConfig, $plugin), $plugin . ' not found');
$cmd = new nbEnablePluginCommand();
$t->ok($cmd->run(new nbCommandLineParser(), $plugin . ' ' . $projectDir), 'Plugin enabled successfully');
$t->ok(isPluginEnabled($beeConfig, $plugin), $plugin . ' found');
Beispiel #28
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $this->log(nbDummyLib::toUpper('Hello ' . nbConfig::get('nbDummy_happy') . " World!!!!\n"), nbLogger::COMMENT);
     $this->log(nbDummyLib::toLower('Hello ' . nbConfig::get('nbDummy_angry') . " World!!!!\n"), nbLogger::COMMENT);
     $this->log('Hello ' . nbConfig::get('nbDummy_fool') . " World!!!!\n", nbLogger::COMMENT);
 }
Beispiel #29
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(32);
$fs = nbFileSystem::getInstance();
$sourceDir = nbConfig::get('filesystem_dir-transfer_source-dir');
$targetDir = nbFileSystem::sanitizeDir(nbConfig::get('filesystem_dir-transfer_target-dir'));
$fileToSync = $targetDir . '/' . nbConfig::get('filesystem_test_file-to-sync');
$folderToExclude = $targetDir . '/' . nbConfig::get('filesystem_test_folder-to-exclude');
$fileToExclude = $targetDir . '/' . nbConfig::get('filesystem_test_file-to-exclude');
$fileToInclude = $targetDir . '/' . nbConfig::get('filesystem_test_file-to-include');
$otherFileToSync = $targetDir . '/' . nbConfig::get('filesystem_test_other-file-to-sync');
$fileToDelete = $targetDir . '/fileToDelete';
$excludeFile = nbConfig::get('filesystem_dir-transfer_exclude-from');
$includeFile = nbConfig::get('filesystem_dir-transfer_include-from');
$cmd = new nbDirTransferCommand();
$fs->touch($fileToDelete);
$commandLine = sprintf('--delete %s %s', $sourceDir, $targetDir);
$t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'Command nbDirTransfer called successfully dry run');
$t->ok(!file_exists($fileToSync), 'fileToSync wasn\'t synchronized in the target site because doit option was not set');
$t->ok(!file_exists($otherFileToSync), 'otherFileToSyn wasn\'t synchronized in the target folder');
$t->ok(!file_exists($folderToExclude), 'folderToExclude wasn\'t synchronized in the target folder');
$t->ok(!file_exists($fileToExclude), 'fileToExclude wasn\'t synchronized in the target folder');
$t->ok(!file_exists($fileToInclude), 'fileToInclude wasn\'t synchronized in the target folder');
$t->ok(file_exists($fileToDelete), 'fileToDelete wasn\'t deleted in the target folder');
$t->ok($cmd->run(new nbCommandLineParser(), '--doit ' . $commandLine), 'Command nbDirTransfer called successfully doit option set');
$t->ok(file_exists($fileToSync), 'fileToSync was synchronized in the target folder');
$t->ok(file_exists($otherFileToSync), 'otherFileToSync was synchronized in the target folder');
$t->ok(file_exists($folderToExclude), 'folderToExclude was synchronized in the target folder');
$t->ok(file_exists($fileToExclude), 'fileToEclude was synchronized in the target folder');
$t->ok(file_exists($fileToInclude), 'fileToInclude was synchronized in the target folder');
Beispiel #30
0
<?php

require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
sfServiceContainerAutoloader::register();
$t = new lime_test(6);
$t->comment('nbPluginLoader - Testing loadPlugins()');
$loader = $serviceContainer->pluginLoader;
$loader->addDir(nbConfig::get('nb_test_plugins_dir'));
$loader->loadPlugins(array('FirstPlugin'));
$t->ok(class_exists('FirstPluginLibClass'), '->loadPlugin() adds plugin/lib to autoload');
$t->ok(class_exists('FirstCommand'), '->loadPlugin() adds plugin/command to autoload');
$t->ok(!class_exists('SecondCommand'), '->loadPlugin() adds plugin/command to autoload');
$t->ok(key_exists('FirstPlugin', $loader->getPlugins()), '->getPlugins() returns an array of loaded plugin names');
$loader->loadAllPlugins();
$t->ok(class_exists('SecondPluginLibClass'), '->loadAllPlugins() loads all plugins');
$t->ok(class_exists('VendorClass'), '->loadPlugin() adds plugin/vendor to autoload');