cherrypulp /
laravel-package-generator
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Cherrypulp\LaravelPackageGenerator\Commands; |
||||
| 4 | |||||
| 5 | use Exception; |
||||
| 6 | use Illuminate\Console\Command; |
||||
| 7 | use Cherrypulp\LaravelPackageGenerator\Commands\Traits\CopiesSkeleton; |
||||
| 8 | use Cherrypulp\LaravelPackageGenerator\Commands\Traits\InteractsWithGit; |
||||
| 9 | use Cherrypulp\LaravelPackageGenerator\Commands\Traits\ChangesComposerJson; |
||||
| 10 | use Cherrypulp\LaravelPackageGenerator\Commands\Traits\InteractsWithComposer; |
||||
| 11 | use Cherrypulp\LaravelPackageGenerator\Commands\Traits\ManipulatesPackageFolder; |
||||
| 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 = config("laravel-package-generator.packages_dir", "workbench")."/$vendorFolderName/$packageFolderName"; |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 52 | $packagePath = base_path($relPackagePath); |
||||
|
0 ignored issues
–
show
The function
base_path was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 53 | |||||
| 54 | if (getcwd() !== base_path()) { |
||||
| 55 | $packagePath = getcwd()."/".$relPackagePath; |
||||
| 56 | chdir(getcwd()); |
||||
| 57 | define("LARAVEL_PACKAGE_CLI_MODE", getcwd()); |
||||
| 58 | } |
||||
| 59 | |||||
| 60 | try { |
||||
| 61 | $this->createPackageFolder($packagePath); |
||||
| 62 | $this->registerPackage($vendorFolderName, $packageFolderName, $relPackagePath); |
||||
| 63 | $this->copySkeleton($packagePath, $vendor, $package, $vendorFolderName, $packageFolderName); |
||||
| 64 | $this->initRepo($packagePath); |
||||
| 65 | $this->composerUpdatePackage($vendorFolderName, $packageFolderName); |
||||
| 66 | $this->composerDumpAutoload(); |
||||
| 67 | |||||
| 68 | $this->info('Finished. Are you ready to write awesome package?'); |
||||
| 69 | |||||
| 70 | return 0; |
||||
| 71 | } catch (Exception $e) { |
||||
| 72 | $this->error($e->getMessage()); |
||||
| 73 | |||||
| 74 | return -1; |
||||
| 75 | } |
||||
| 76 | } |
||||
| 77 | } |
||||
| 78 |