Skip to content

Commit 4c4ee8c

Browse files
committed
Remake setup
1 parent 8160159 commit 4c4ee8c

28 files changed

+1293
-54
lines changed

src/Commands/InstallCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class InstallCommand extends Command
99
{
10-
protected $signature = 'hook:install {name} {version?} {--enable}';
10+
protected $signature = 'hook:install {name} {version?} {--enable} {--without-migrating} {--without-seeding} {--without-publishing}';
1111

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

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

32-
$this->hooks->install($name, $this->argument('version'));
32+
$this->hooks->install(
33+
$name,
34+
$this->argument('version'),
35+
!$this->option('without-migrating'),
36+
!$this->option('without-seeding'),
37+
!$this->option('without-publishing')
38+
);
3339

3440
if ($this->option('enable')) {
3541
$this->hooks->enable($name);

src/Commands/UninstallCommand.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class UninstallCommand extends Command
99
{
10-
protected $signature = 'hook:uninstall {name} {--delete}';
10+
protected $signature = 'hook:uninstall {name} {--delete} {--without-unmigrating} {--without-unseeding} {--without-unpublishing}';
1111

1212
protected $description = 'Uninstall a hook';
1313

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

32-
$this->hooks->uninstall($name, $this->option('delete'));
32+
$this->hooks->uninstall(
33+
$name,
34+
$this->option('delete'),
35+
!$this->option('without-unmigrating'),
36+
!$this->option('without-unseeding'),
37+
!$this->option('without-unpublishing')
38+
);
3339

3440
$this->info("Hook [{$name}] have been uninstalled.");
3541
}

src/Commands/UpdateCommand.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class UpdateCommand extends Command
99
{
10-
protected $signature = 'hook:update {name} {version?}';
10+
protected $signature = 'hook:update {name} {version?} {--without-migrating} {--without-seeding} {--without-publishing} {--force-publish}';
1111

1212
protected $description = 'Update a hook';
1313

@@ -35,10 +35,17 @@ public function handle()
3535

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

38-
if ($this->hooks->update($name, $version)) {
39-
return $this->info("Hook [{$name}] have been updated!");
40-
}
41-
42-
return $this->info('Nothing to update.');
38+
$updated = $this->hooks->update(
39+
$name,
40+
$version,
41+
!$this->option('without-migrating'),
42+
!$this->option('without-seeding'),
43+
!$this->option('without-publishing'),
44+
$this->option('force-publish')
45+
);
46+
47+
return $updated
48+
? $this->info("Hook [{$name}] have been updated!")
49+
: $this->info('Nothing to update.');
4350
}
4451
}

src/Hook.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,18 @@ public function loadComposerJson()
6767
$this->composerJson = json_decode($this->getComposerJsonFile(), true);
6868
}
6969

70-
public function getComposerJsonFile()
70+
public function getPath()
7171
{
72-
$path = 'vendor/'.$this->name;
73-
7472
if ($this->isLocal()) {
75-
$path = 'hooks/'.$this->name;
73+
return base_path('hooks/'.$this->name);
7674
}
7775

78-
return $this->filesystem->get(base_path($path.'/composer.json'));
76+
return base_path('vendor/'.$this->name);
77+
}
78+
79+
public function getComposerJsonFile()
80+
{
81+
return $this->filesystem->get($this->getPath().'/composer.json');
7982
}
8083

8184
public function setLatest($latest)
@@ -106,7 +109,7 @@ public function update(array $parameters)
106109
public function outdated()
107110
{
108111
if (is_null($this->latest)) {
109-
$this->latest = app('hooks')->outdated($hook);
112+
$this->latest = app('hooks')->outdated($this->name);
110113
}
111114

112115
return $this->latest != $this->version;

0 commit comments

Comments
 (0)