-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Muetze42/development
Add `custom-assets:after-composer-update` command
- Loading branch information
Showing
5 changed files
with
94 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace NormanHuth\NovaAssetsChanger\Console\Commands; | ||
|
||
use Laravel\Nova\Nova; | ||
|
||
class AfterComposerUpdateCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'custom-assets:after-composer-update'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'run command only if a Nova update is detected (or the package has no version saved)'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle(): int | ||
{ | ||
$currentNovaVersion = Nova::version(); | ||
$changerVersion = null; | ||
if ($this->storage->exists($this->memoryFile)) { | ||
$content = json_decode($this->storage->get($this->memoryFile), true); | ||
if (!empty($content[$this->lastUseNovaVersionKey])) { | ||
$changerVersion = $content[$this->lastUseNovaVersionKey]; | ||
} | ||
} | ||
|
||
if ($currentNovaVersion != $changerVersion) { | ||
$this->info('Run `nova:custom-assets` command'); | ||
$this->call('nova:custom-assets'); | ||
return 0; | ||
} | ||
|
||
$this->alert('No Nova Update detected. Don’t run `nova:custom-assets` command'); | ||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters