Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 protected function handleOptions(array $options)
 {
     $logger = nbLogger::getInstance();
     if (isset($options['verbose'])) {
         $this->verbose = true;
     }
     if (isset($options['trace'])) {
         $this->verbose = true;
         $this->trace = true;
     }
     if (isset($options['version'])) {
         $logger->log(($this->verbose ? $this->getName() . ' version ' : '') . $this->getVersion());
         return true;
     }
     if (isset($options['help'])) {
         $logger->log($this->formatHelp($this->arguments, $this->options));
         return true;
     }
     if (isset($options['config'])) {
         foreach ($options['config'] as $option) {
             $property = preg_split('/[\\s]*=[\\s]*/', $option, 2);
             nbConfig::set($property[0], $property[1]);
         }
     }
     if (isset($options['enable-plugin'])) {
         $this->serviceContainer->pluginLoader->loadPlugins($options['enable-plugin']);
     }
     if (isset($options['enable-all-plugins'])) {
         $this->serviceContainer->pluginLoader->loadAllPlugins();
     }
     return false;
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
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');
     }
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
Archivo: unit.php Proyecto: nubee/bee
function checkMysql()
{
    if (nbConfig::has('mysql_admin-username')) {
        return true;
    }
    $t = new lime_test(0);
    return false;
}
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
 public function parse($yaml, $prefix = '', $replaceTokens = false)
 {
     $values = sfYaml::load($yaml);
     if ($this->configuration) {
         $this->configuration->add($values, $prefix, $replaceTokens);
     } else {
         nbConfig::add($values, $prefix, $replaceTokens);
     }
 }
Ejemplo n.º 9
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')))));
    }
Ejemplo n.º 10
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;
     }
 }
Ejemplo n.º 11
0
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];
    }
}
Ejemplo n.º 12
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);
 }
Ejemplo n.º 13
0
 public function checkConfigFile($templateFile, $configFile, $addGlobalConfiguration = false)
 {
     if (!file_exists($configFile)) {
         throw new Exception(sprintf('Filename %s does not exist', $configFile));
     }
     $configuration = new nbConfiguration();
     if ($addGlobalConfiguration) {
         $configuration->add(nbConfig::getAll());
     }
     $configuration->add(sfYaml::load($configFile), '', true);
     return $this->check($templateFile, $configuration);
 }
Ejemplo n.º 14
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);
 }
Ejemplo n.º 15
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;
 }
Ejemplo n.º 16
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);
 }
Ejemplo n.º 17
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;
 }
Ejemplo n.º 18
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');
     }
 }
Ejemplo n.º 19
0
 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;
 }
Ejemplo n.º 20
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;
 }
Ejemplo n.º 21
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');
 }
Ejemplo n.º 22
0
 protected function execute(array $arguments = array(), array $options = array())
 {
     $listFile = $arguments['list-file'];
     $doit = isset($options['doit']);
     $configuration = new nbConfiguration();
     $configuration->add(nbConfig::getAll());
     $configuration->add(sfYaml::load($listFile), '', true);
     foreach ($configuration->get('filesystem_multi-change-mode') as $item) {
         $directory = $item['directory'];
         $dirMode = $item['dir-mode'];
         $fileMode = $item['file-mode'];
         $this->logLine(sprintf('Changing directory mode in %s for %s', $dirMode, $directory));
         $command = sprintf('find %s -type d -exec chmod %s {} \\;', $directory, $dirMode);
         $this->executeShellCommand($command, $doit);
         $this->logLine(sprintf('Changing file mode in %s for files in %s', $fileMode, $directory));
         $command = sprintf('find %s -type f -exec chmod %s {} \\;', $directory, $fileMode);
         $this->executeShellCommand($command, $doit);
     }
     $this->logLine('Mode changed successfully!');
     return true;
 }
Ejemplo n.º 23
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);
 }
Ejemplo n.º 24
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;
 }
Ejemplo n.º 25
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;
 }
Ejemplo n.º 26
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');
     }
 }
Ejemplo n.º 27
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);
     }
 }
Ejemplo n.º 28
0
 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;
 }
Ejemplo n.º 29
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;
 }
Ejemplo n.º 30
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');
}