Skip to content

Commit

Permalink
Merge pull request #30 from larapack/improve-setup-flow
Browse files Browse the repository at this point in the history
Improve setup flow
  • Loading branch information
marktopper authored Jan 21, 2018
2 parents 8160159 + 018bd65 commit c60bf1c
Show file tree
Hide file tree
Showing 30 changed files with 1,312 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ before_script:
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist

script:
- vendor/bin/phpunit --stop-on-failure
- vendor/bin/phpunit
10 changes: 8 additions & 2 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class InstallCommand extends Command
{
protected $signature = 'hook:install {name} {version?} {--enable}';
protected $signature = 'hook:install {name} {version?} {--enable} {--no-migrate} {--no-seed} {--no-publish}';

protected $description = 'Download and install a hook from remote https://larapack.io';

Expand All @@ -29,7 +29,13 @@ public function handle()
{
$name = $this->argument('name');

$this->hooks->install($name, $this->argument('version'));
$this->hooks->install(
$name,
$this->argument('version'),
!$this->option('no-migrate'),
!$this->option('no-seed'),
!$this->option('no-publish')
);

if ($this->option('enable')) {
$this->hooks->enable($name);
Expand Down
10 changes: 8 additions & 2 deletions src/Commands/UninstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class UninstallCommand extends Command
{
protected $signature = 'hook:uninstall {name} {--delete}';
protected $signature = 'hook:uninstall {name} {--delete} {--no-unmigrate} {--no-unseed} {--no-unpublish}';

protected $description = 'Uninstall a hook';

Expand All @@ -29,7 +29,13 @@ public function handle()
{
$name = $this->argument('name');

$this->hooks->uninstall($name, $this->option('delete'));
$this->hooks->uninstall(
$name,
$this->option('delete'),
!$this->option('no-unmigrate'),
!$this->option('no-unseed'),
!$this->option('no-unpublish')
);

$this->info("Hook [{$name}] have been uninstalled.");
}
Expand Down
19 changes: 13 additions & 6 deletions src/Commands/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class UpdateCommand extends Command
{
protected $signature = 'hook:update {name} {version?}';
protected $signature = 'hook:update {name} {version?} {--no-migrate} {--no-seed} {--no-publish} {--force}';

protected $description = 'Update a hook';

Expand Down Expand Up @@ -35,10 +35,17 @@ public function handle()

$hook = $hooks->where('name', $name)->first();

if ($this->hooks->update($name, $version)) {
return $this->info("Hook [{$name}] have been updated!");
}

return $this->info('Nothing to update.');
$updated = $this->hooks->update(
$name,
$version,
!$this->option('no-migrate'),
!$this->option('no-seed'),
!$this->option('no-publish'),
$this->option('force')
);

return $updated
? $this->info("Hook [{$name}] have been updated!")
: $this->info('Nothing to update.');
}
}
15 changes: 9 additions & 6 deletions src/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,18 @@ public function loadComposerJson()
$this->composerJson = json_decode($this->getComposerJsonFile(), true);
}

public function getComposerJsonFile()
public function getPath()
{
$path = 'vendor/'.$this->name;

if ($this->isLocal()) {
$path = 'hooks/'.$this->name;
return base_path('hooks/'.$this->name);
}

return $this->filesystem->get(base_path($path.'/composer.json'));
return base_path('vendor/'.$this->name);
}

public function getComposerJsonFile()
{
return $this->filesystem->get($this->getPath().'/composer.json');
}

public function setLatest($latest)
Expand Down Expand Up @@ -106,7 +109,7 @@ public function update(array $parameters)
public function outdated()
{
if (is_null($this->latest)) {
$this->latest = app('hooks')->outdated($hook);
$this->latest = app('hooks')->outdated($this->name);
}

return $this->latest != $this->version;
Expand Down
Loading

0 comments on commit c60bf1c

Please sign in to comment.