1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Blok\LaravelPackageGenerator\Commands; |
4
|
|
|
|
5
|
|
|
use Blok\LaravelPackageGenerator\Commands\Traits\ChangesComposerJson; |
6
|
|
|
use Blok\LaravelPackageGenerator\Commands\Traits\InteractsWithComposer; |
7
|
|
|
use Blok\LaravelPackageGenerator\Commands\Traits\InteractsWithUser; |
8
|
|
|
use Blok\LaravelPackageGenerator\Commands\Traits\ManipulatesPackageFolder; |
9
|
|
|
use Exception; |
10
|
|
|
use Illuminate\Console\Command; |
11
|
|
|
|
12
|
|
|
class PackageRemove extends Command |
13
|
|
|
{ |
14
|
|
|
use ChangesComposerJson; |
15
|
|
|
use ManipulatesPackageFolder; |
16
|
|
|
use InteractsWithUser; |
17
|
|
|
use InteractsWithComposer; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The name and signature of the console command. |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $signature = 'package:remove |
25
|
|
|
{vendor : The vendor part of the namespace} |
26
|
|
|
{package : The name of package for the namespace} |
27
|
|
|
{--i|interactive : Interactive mode}'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The console command description. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $description = 'Remove the existing package.'; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Execute the console command. |
38
|
|
|
* |
39
|
|
|
* @return mixed |
40
|
|
|
*/ |
41
|
|
|
public function handle() |
42
|
|
|
{ |
43
|
|
|
$vendor = $this->getVendor(); |
44
|
|
|
$package = $this->getPackage(); |
45
|
|
|
|
46
|
|
|
$vendorFolderName = $this->getVendorFolderName($vendor); |
47
|
|
|
$packageFolderName = $this->getPackageFolderName($package); |
48
|
|
|
|
49
|
|
|
$relPackagePath = "workbench/$vendorFolderName/$packageFolderName"; |
50
|
|
|
$packagePath = base_path($relPackagePath); |
|
|
|
|
51
|
|
|
|
52
|
|
|
try { |
53
|
|
|
$this->composerRemovePackage($vendorFolderName, $packageFolderName); |
54
|
|
|
$this->removePackageFolder($packagePath); |
55
|
|
|
$this->unregisterPackage($vendor, $package, "workbench/$vendorFolderName/$packageFolderName"); |
56
|
|
|
$this->composerDumpAutoload(); |
57
|
|
|
} catch (Exception $e) { |
58
|
|
|
$this->error($e->getMessage()); |
59
|
|
|
|
60
|
|
|
return -1; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|