1 | <?php |
||
2 | |||
3 | namespace Blok\LaravelPackageGenerator\Commands; |
||
4 | |||
5 | use Blok\LaravelPackageGenerator\Commands\Traits\ChangesComposerJson; |
||
6 | use Blok\LaravelPackageGenerator\Commands\Traits\CopiesSkeleton; |
||
7 | use Blok\LaravelPackageGenerator\Commands\Traits\InteractsWithComposer; |
||
8 | use Blok\LaravelPackageGenerator\Commands\Traits\InteractsWithGit; |
||
9 | use Blok\LaravelPackageGenerator\Commands\Traits\ManipulatesPackageFolder; |
||
10 | use Exception; |
||
11 | use Illuminate\Console\Command; |
||
12 | |||
13 | class PackageNew extends Command |
||
14 | { |
||
15 | use ChangesComposerJson; |
||
16 | use ManipulatesPackageFolder; |
||
17 | use InteractsWithComposer; |
||
18 | use CopiesSkeleton; |
||
19 | use InteractsWithGit; |
||
20 | |||
21 | /** |
||
22 | * The name and signature of the console command. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $signature = 'package:new |
||
27 | {vendor : The vendor part of the namespace} |
||
28 | {package : The name of package for the namespace} |
||
29 | {--i|interactive : Interactive mode}'; |
||
30 | |||
31 | /** |
||
32 | * The console command description. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $description = 'Create a new package.'; |
||
37 | |||
38 | /** |
||
39 | * Execute the console command. |
||
40 | * |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function handle() |
||
44 | { |
||
45 | $vendor = $this->getVendor(); |
||
46 | $package = $this->getPackage(); |
||
47 | |||
48 | $vendorFolderName = $this->getVendorFolderName($vendor); |
||
49 | $packageFolderName = $this->getPackageFolderName($package); |
||
50 | |||
51 | $relPackagePath = "workbench/$vendorFolderName/$packageFolderName"; |
||
52 | $packagePath = base_path($relPackagePath); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
53 | |||
54 | try { |
||
55 | $this->createPackageFolder($packagePath); |
||
56 | $this->registerPackage($vendorFolderName, $packageFolderName, $relPackagePath); |
||
57 | $this->copySkeleton($packagePath, $vendor, $package, $vendorFolderName, $packageFolderName); |
||
58 | $this->initRepo($packagePath); |
||
59 | $this->composerUpdatePackage($vendorFolderName, $packageFolderName); |
||
60 | $this->composerDumpAutoload(); |
||
61 | |||
62 | $this->info('Finished. Are you ready to write an awesome package?'); |
||
63 | } catch (Exception $e) { |
||
64 | $this->error($e->getMessage()); |
||
65 | |||
66 | return -1; |
||
67 | } |
||
68 | |||
69 | return 0; |
||
70 | } |
||
71 | } |
||
72 |