public function run(array $arguments) { $json = $this->deps->nearestJson(); $package = new Package(dirname($json)); $porcelain = count($arguments) && $arguments[0] == 'porcelain'; if (!$porcelain) { Terminal::info("From {$json}\n\n"); Terminal::bold("* project name: " . $package->getName() . "\n"); } $dependencies = $package->getDependencies(); if ($porcelain) { echo implode(':', $dependencies) . "\n"; } else { if ($dependencies) { Terminal::bold("* dependencies:\n"); foreach ($dependencies as $dep) { echo " - {$dep} "; if ($this->deps->hasPackage($dep)) { Terminal::success("(installed)"); } else { Terminal::warning("(not installed)"); } echo "\n"; } } else { Terminal::bold("* no dependencies\n"); } } }
public function run(array $arguments) { $remotes = $this->deps->getRemotes(); $current = $remotes->getCurrent(); Terminal::info("Remotes:\n"); foreach ($remotes->getRemotes() as $remote => $addr) { if ($remote == $current) { Terminal::success("* {$remote} ({$addr})\n"); } else { Terminal::bold("* {$remote} ({$addr})\n"); } } }
public function run(array $arguments) { if ($arguments) { foreach ($arguments as $dep) { $this->deps->install($dep); } } else { $json = $this->deps->nearestJson(); $package = new Package(dirname($json)); $dependencies = $package->getDependencies(); if ($dependencies) { foreach ($dependencies as $dep) { $this->deps->install($dep); } } else { Terminal::success("Nothing to do!\n"); } } return true; }
public function printStatus(Package $package) { $dir = $package->getDirectory(); $name = $package->getName(); $result = `cd {$dir}; LANG=en_US.UTF-8 git status`; $errors = array(); $warnings = array(); $messages = array(); if (strstr($result, 'Changes not staged for commit:') !== false) { $errors[] = 'Unstaged changes'; } if (strstr($result, 'Changes to be committed:') !== false) { $errors[] = 'Changes to commit'; } if (strstr($result, 'Your branch is ahead of') !== false) { $errors[] = 'Not pushed changes'; } if (strstr($result, 'Your branch is behind') !== false) { $warnings[] = 'Branch is behind origin'; } if (strstr($result, 'Untracked files:') !== false) { $warnings[] = 'Untracked files'; } $messages = implode(', ', array_merge($errors, $warnings, $messages)); if ($messages) { $messages = '(' . $messages . ')'; } $branch = $package->getBranch(); if (count($errors)) { Terminal::error("* [{$branch}] {$name}: ERROR {$messages}\n"); } else { if (count($warnings)) { Terminal::warning("* [{$branch}] {$name}: WARNING {$messages}\n"); } else { Terminal::success("* [{$branch}] {$name}: OK {$messages}\n"); } } }
public function update(Remotes $remotes) { $branch = $this->getBranch(); $this->updateRemotes($remotes); $current = $remotes->getCurrent(); if (OS::run('cd ' . OS::bashize($this->directory) . ";git pull {$current} {$branch}") != 0) { throw new \Exception('Update of ' . $this->getName() . ' failed'); } else { Terminal::success('Updated ' . $this->getName() . "\n"); } OS::run('cd ' . OS::bashize($this->directory) . ";git branch -u {$current}/{$branch}"); $this->readConfig(); }