Пример #1
0
 /**
  * The brains of the command
  *
  * @access public
  * @return void
  * @author Aziz Light
  **/
 public function run()
 {
     $codeigniter_sample_project_path = BASE_PATH . DIRECTORY_SEPARATOR . 'codeigniter';
     if (is_dir($codeigniter_sample_project_path)) {
         ApplicationHelpers::delete_dir($codeigniter_sample_project_path);
     }
     fwrite(STDOUT, 'Bootstrapping Fire...' . PHP_EOL);
     if (GithubHelpers::git_clone($this->get_github_repo_link(), $codeigniter_sample_project_path) === FALSE) {
         throw new RuntimeException("Unable to clone the sample CodeIgniter project from Github");
     } else {
         if (php_uname("s") === "Windows NT") {
             $message = "\tFire Bootstrapped" . PHP_EOL;
         } else {
             $message = "\t" . ApplicationHelpers::colorize('Fire', 'green') . '  Bootstrapped' . PHP_EOL;
         }
         fwrite(STDOUT, $message);
     }
 }
Пример #2
0
 /**
  * Create a migration file
  *
  * @access private
  * @return void
  * @author Aziz Light
  **/
 private function migration()
 {
     $location = $this->args['location'] . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR;
     if (!is_dir($location)) {
         mkdir($location);
     }
     $backtrace = debug_backtrace();
     $calling_function = $backtrace[1]['function'];
     if ($calling_function === "model") {
         $args = array('class_name' => 'Migration_Add_' . Inflector::pluralize($this->args['name']), 'table_name' => Inflector::pluralize(strtolower($this->args['name'])), 'filename' => 'add_' . Inflector::pluralize(ApplicationHelpers::underscorify($this->args['name'])) . '.php', 'application_folder' => $this->args['application_folder'], 'parent_class' => $this->args['parent_migration'], 'extra' => $this->extra);
         $template_name = 'migration';
     } else {
         $args = array('class_name' => 'Migration_' . $this->args['name'], 'table_name' => $this->get_table_name_out_of_migration_name(), 'filename' => $this->args['filename'], 'application_folder' => $this->args['application_folder'], 'parent_class' => $this->args['parent_migration'], 'extra' => $this->extra);
         $template_name = 'empty_migration';
     }
     $template = new TemplateScanner($template_name, $args);
     $migration = $template->parse();
     $migration_number = MigrationHelpers::get_migration_number($this->args['location']);
     $filename = $location . $migration_number . '_' . $args['filename'];
     $potential_duplicate_migration_filename = MigrationHelpers::decrement_migration_number($migration_number) . '_' . $args['filename'];
     $potential_duplicate_migration = $location . $potential_duplicate_migration_filename;
     $message = "\t";
     if (file_exists($potential_duplicate_migration)) {
         $message .= 'Migration already exists : ';
         if (php_uname("s") !== "Windows NT") {
             $message = ApplicationHelpers::colorize($message, 'light_blue');
         }
         $message .= $this->args['application_folder'] . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR . $potential_duplicate_migration_filename;
     } else {
         if (file_put_contents($filename, $migration) && MigrationHelpers::add_migration_number_to_config_file($this->args['location'], $migration_number)) {
             $message .= 'Created Migration: ';
             if (php_uname("s") !== "Windows NT") {
                 $message = ApplicationHelpers::colorize($message, 'green');
             }
             $message .= $this->args['application_folder'] . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR . $migration_number . '_' . $args['filename'];
         } else {
             $message .= 'Unable to create migration: ';
             if (php_uname("s") !== "Windows NT") {
                 $message = ApplicationHelpers::colorize($message, 'red');
             }
             $message .= $this->args['application_folder'] . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR . $migration_number . '_' . $this->args['filename'];
         }
     }
     fwrite(STDOUT, $message . PHP_EOL);
     return;
 }
Пример #3
0
 /**
  * Installs WebFire
  *
  * @access private
  * @return void
  * @author Aziz Light
  **/
 private function install()
 {
     if ($this->is_webfire_installed()) {
         throw new RuntimeException('WebFire seems to be installed already!');
     }
     if (!$this->create_directories()) {
         throw new RuntimeException('Unable to create WebFire directories');
     }
     $application_folder = explode(DIRECTORY_SEPARATOR, $this->location);
     $application_folder = array_pop($application_folder);
     foreach ($this->files as $file) {
         $source = BASE_PATH . DIRECTORY_SEPARATOR . 'WebFire' . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR . $file;
         $destination = $this->location . DIRECTORY_SEPARATOR . $file;
         $relative_location = $application_folder . DIRECTORY_SEPARATOR . $file;
         $subject = '';
         $message = '';
         if (preg_match('/templates/', $file) === 1) {
             $subject = 'template';
         } else {
             $subject = explode('/', $file);
             $subject = array_shift($subject);
             $subject = rtrim($subject, 's');
         }
         if (copy($source, $destination)) {
             $message = "\tCreated {$subject}: ";
             if (php_uname("s") !== "Windows NT") {
                 $message = ApplicationHelpers::colorize($message, 'green');
             }
             $message .= $relative_location;
         } else {
             $message = "\tFailed to create {$subject}: ";
             if (php_uname("s") !== "Windows NT") {
                 $message = ApplicationHelpers::colorize($message, 'red');
             }
             $message .= $relative_location;
         }
         fwrite(STDOUT, $message . PHP_EOL);
         unset($source, $destination, $relative_location, $subject);
     }
     foreach ($this->assets as $asset) {
         $source = BASE_PATH . DIRECTORY_SEPARATOR . 'WebFire' . DIRECTORY_SEPARATOR . $asset;
         $location = explode(DIRECTORY_SEPARATOR, $this->location);
         array_pop($location);
         $location = join(DIRECTORY_SEPARATOR, $location);
         $destination = $location . DIRECTORY_SEPARATOR . $asset;
         $subject = '';
         $message = '';
         if (copy($source, $destination)) {
             $message = "\tCreated asset: ";
             if (php_uname("s") !== "Windows NT") {
                 $message = ApplicationHelpers::colorize($message, 'green');
             }
             $message .= $asset;
         } else {
             $message = "\tFailed to create asset: ";
             if (php_uname("s") !== "Windows NT") {
                 $message = ApplicationHelpers::colorize($message, 'red');
             }
             $message .= $asset;
         }
         fwrite(STDOUT, $message . PHP_EOL);
         unset($source, $location, $destination, $subject, $message);
     }
 }
 /**
  * The brains of the command
  *
  * @access public
  * @return void
  * @author Aziz Light
  **/
 public function run()
 {
     if ($this->is_fire_bootstrapped() && $this->force_clone === FALSE) {
         if ($this->copy_codeigniter_sample_project($this->location, BASE_PATH . DIRECTORY_SEPARATOR . 'codeigniter')) {
             if (php_uname("s") !== "Windows NT") {
                 $message = "\t" . ApplicationHelpers::colorize('CodeIgniter project created', 'green') . ' ' . $this->name . PHP_EOL;
             } else {
                 $message = "\tCodeIgniter project created " . $this->name . PHP_EOL;
             }
             fwrite(STDOUT, $message);
         } else {
             throw new RuntimeException("Unable to create a new CodeIgniter Project");
         }
     } else {
         fwrite(STDOUT, 'Cloning CodeIgniter...' . PHP_EOL);
         // First let's download CodeIgniter
         if (GithubHelpers::git_clone($this->repo, $this->location, $this->tag_or_branch) === FALSE) {
             throw new RuntimeException("Unable to clone CodeIgniter from Github");
         } else {
             if (php_uname("s") !== "Windows NT") {
                 $message = "\t" . ApplicationHelpers::colorize('CodeIgniter project created', 'green') . ' ' . $this->name . PHP_EOL;
             } else {
                 $message = "\tCodeIgniter project created " . $this->name . PHP_EOL;
             }
             fwrite(STDOUT, $message);
         }
     }
 }