Ejemplo n.º 1
0
 private function warn_if_outdated()
 {
     if ($source_version_data = $this->outdated()) {
         Spark_utils::warning("Your installed version of spark is outdated (current version: {$source_version_data->spark_manager})");
         Spark_utils::warning("To upgrade now, use `tools/spark upgrade-system`");
     }
 }
Ejemplo n.º 2
0
 private function warn_if_outdated()
 {
     if ($this->outdated()) {
         Spark_utils::warning("Your installed version of spark is outdated (current version: " . $this->outdated() . " / latest: " . $this->version . ")");
         Spark_utils::warning("To upgrade now, use `php tools/spark upgrade-system`");
     }
 }
 function test_install_with_invalid_spark_version()
 {
     $clines = $this->capture_buffer_lines(function ($cli) {
         $cli->execute('install', array('v9.4', 'example-spark'));
     });
     $success = (bool) (strpos(reset($clines), chr(27) . '[1;31m[ ERROR ]' . chr(27) . '[0m Uh-oh!') === 0);
     Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
     $this->assertEquals(true, $success);
 }
Ejemplo n.º 4
0
 function retrieve()
 {
     `hg clone -r{$this->tag} {$this->base_location} {$this->temp_path}`;
     // remove the mercurial directory
     Spark_utils::remove_full_directory("{$this->temp_path}/.hg");
     if (!file_exists($this->temp_path)) {
         throw new Spark_exception('Failed to retrieve the spark ;(');
     }
     return true;
 }
 function test_remove_with_invalid_version()
 {
     $clines = $this->capture_buffer_lines(function ($cli) {
         $cli->execute('install', array('-v1.0', 'example-spark'));
         // Spark needs installed first
         $cli->execute('remove', array('-v9.4', 'example-spark'));
     });
     $success = (bool) (strpos(end($clines), chr(27) . '[1;36m[ SPARK ]' . chr(27) . '[0m Looks like that spark isn\'t installed') === 0 && is_dir(SPARK_PATH . '/example-spark'));
     $this->assertEquals(true, $success);
     Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
 }
 function retrieve()
 {
     // check out the right tag
     `git clone --recursive {$this->base_location} {$this->temp_path}`;
     `cd {$this->temp_path}; git checkout {$this->tag} -b {$this->temp_token}`;
     // remove the git directory
     Spark_utils::remove_full_directory("{$this->temp_path}/.git");
     if (!file_exists($this->temp_path)) {
         throw new Spark_exception('Failed to retrieve the spark ;(');
     }
     return true;
 }
Ejemplo n.º 7
0
 private function install($args)
 {
     list($flats, $flags) = $this->prep_args($args);
     if (count($flats) != 1) {
         return $this->failtown('format: `spark install -v1.0.0 name`');
     }
     $spark_name = $flats[0];
     $version = array_key_exists('v', $flags) ? $flags['v'] : 'HEAD';
     // retrieve the spark details
     foreach ($this->spark_sources as $source) {
         Spark_utils::notice("Retrieving spark detail from " . $source->get_url());
         $spark = $source->get_spark_detail($spark_name, $version);
         if ($spark != null) {
             break;
         }
     }
     // did we find the details?
     if ($spark == null) {
         throw new Spark_exception("Unable to find spark: {$spark_name} ({$version}) in any sources");
     }
     // verify the spark, and put out warnings if needed
     $spark->verify();
     // retrieve the spark
     Spark_utils::notice("From Downtown! Retrieving spark from " . $spark->location_detail());
     $spark->retrieve();
     // Install it
     $spark->install();
     Spark_utils::notice('Spark installed to ' . $spark->installed_path() . ' - You\'re on fire!');
 }
Ejemplo n.º 8
0
 function verify($break_on_already_installed = true)
 {
     // see if this is deactivated
     if ($this->data->is_deactivated) {
         $msg = 'Woah there - it seems the spark you want has been deactivated';
         if ($this->data->spark_home) {
             $msg .= "\nLook for different versions at: " . $this->data->spark_home;
         }
         throw new Spark_exception($msg);
     }
     // see if this is unsupported
     if ($this->data->is_unsupported) {
         Spark_utils::warning('This spark is no longer supported.');
         Spark_utils::warning('You can keep using it, or look for an alternate');
     }
     // tell the user if its already installed and throw an error
     $this->installation_path = SPARK_PATH . "/{$this->name}/{$this->version}";
     if (is_dir($this->installation_path)) {
         if ($break_on_already_installed) {
             throw new Spark_exception("Already installed.  Try `php tools/spark reinstall {$this->name}`");
         }
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 9
0
 function tearDown()
 {
     if (is_dir(SPARK_PATH . '/example-spark')) {
         Spark_utils::remove_full_directory(SPARK_PATH . '/example-spark');
     }
 }
Ejemplo n.º 10
0
 static function buffer()
 {
     self::$buffer = true;
 }