Ejemplo n.º 1
0
 /**
  * Any specific processing we want to do here. Return a string of html.
  * @param array $scriptProperties
  *      'namespace'
  *      'f' 
  */
 public function process(array $scriptProperties = array())
 {
     $namespace = $this->modx->getOption('namespace', $scriptProperties);
     $function = $this->modx->getOption('f', $scriptProperties);
     $response = array();
     $response['msg'] = '';
     $response['success'] = true;
     try {
         $dir = Repoman::get_dir(MODX_BASE_PATH . $this->modx->getOption('repoman.dir'));
         $pkg_root_dir = $dir . '/' . $namespace;
         $config = Repoman::load_config($pkg_root_dir);
         $Repoman = new Repoman($this->modx, $config);
         switch ($function) {
             case 'update':
                 $Repoman->update($pkg_root_dir);
                 $response['msg'] = $config['package_name'] . ' updated successfully to version ' . $config['version'] . '-' . $config['release'];
                 break;
             case 'install':
                 $Repoman->install($pkg_root_dir);
                 $response['msg'] = $config['package_name'] . ' installed successfully!';
                 break;
             case 'uninstall':
                 $Repoman->uninstall($pkg_root_dir);
                 $response['msg'] = $config['package_name'] . ' uninstalled successfully!';
                 break;
             case 'build':
                 $Repoman->build($pkg_root_dir);
                 $response['msg'] = $config['package_name'] . ' should have been built successfully.  Look inside the core/packages/ directory for the file. Please use the command line tool if you need to monitor the error log troubleshoot this process.';
                 break;
                 break;
             default:
                 $response['success'] = false;
                 $response['msg'] = 'Unknown function: ' . $function;
         }
     } catch (Exception $e) {
         $response['success'] = false;
         $response['msg'] = $e->getMessage();
     }
     return json_encode($response);
 }
Ejemplo n.º 2
0
 /**
  *
  */
 public function testBuild()
 {
     $namespace = $this->_get_rand_name();
     // Generate random version number
     $ver = rand(0, 100) . '.' . rand(0, 100) . '.' . rand(0, 100);
     $release = 'beta';
     $pkg_root_dir = dirname(__FILE__) . '/repos/pkg8/';
     $config = Repoman::load_config($pkg_root_dir);
     $config['namespace'] = $namespace;
     $config['package_name'] = $namespace;
     $config['version'] = $ver;
     $config['release'] = $release;
     $Repoman = new Repoman(self::$modx, $config);
     $Repoman->build($pkg_root_dir);
     $pkg = MODX_CORE_PATH . 'packages/' . $namespace . '-' . $ver . '-' . $release;
     $this->assertTrue(file_exists($pkg . '.transport.zip'), 'Building should have created a package: ' . $pkg . '.transport.zip');
     $this->assertTrue(is_dir($pkg), 'Building should have created a package directory: ' . $pkg);
     // Check the manifest
     $this->assertTrue(file_exists($pkg . '/manifest.php'), 'Building should have created a manifest: ' . $pkg . '/manifest.php');
     Repoman::rrmdir($pkg);
     unlink($pkg . '.transport.zip');
 }