diff --git a/changelog.md b/changelog.md index e2678db..9c8d013 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,9 @@ All Notable changes to Packager will be documented in this file. - `packager:new` now also supports separating vendor and name with a forward slash. - `symlink` option is set to true as default for repositories in `composer.json` +### Fixed +- vendor-name and package-name not converted to StudlyCase with `packager:new` + ## Version 2.4 ### Added diff --git a/src/Commands/NewPackage.php b/src/Commands/NewPackage.php index 187b080..d3ecd22 100644 --- a/src/Commands/NewPackage.php +++ b/src/Commands/NewPackage.php @@ -114,8 +114,8 @@ public function handle() ':lc:vendor', ':lc:package', ], [ - $this->conveyor->vendor(), - $this->conveyor->package(), + $this->conveyor->vendorStudly(), + $this->conveyor->packageStudly(), strtolower($this->conveyor->vendor()), strtolower($this->conveyor->package()), ]); diff --git a/src/Conveyor.php b/src/Conveyor.php index ced08c4..779092f 100644 --- a/src/Conveyor.php +++ b/src/Conveyor.php @@ -42,6 +42,16 @@ public function vendor($vendor = null) return $this->vendor; } + /** + * Get the vendor name converted to StudlyCase. + * + * @return string|RuntimeException + */ + public function vendorStudly() + { + return Str::studly($this->vendor()); + } + /** * Set or get the package name. * @@ -61,6 +71,16 @@ public function package($package = null) return $this->package; } + /** + * Get the package name converted to StudlyCase. + * + * @return string|RuntimeException + */ + public function packageStudly() + { + return Str::studly($this->package()); + } + /** * Download the skeleton package. */ diff --git a/src/FileHandler.php b/src/FileHandler.php index ecd37f4..e2d2b03 100644 --- a/src/FileHandler.php +++ b/src/FileHandler.php @@ -169,7 +169,7 @@ public function renameFiles($manifest = null) { $bindings = [ [':uc:vendor', ':uc:package', ':lc:vendor', ':lc:package'], - [$this->vendor(), $this->package(), strtolower($this->vendor()), strtolower($this->package())], + [$this->vendorStudly(), $this->packageStudly(), strtolower($this->vendor()), strtolower($this->package())], ]; $rewrites = require ($manifest === null) ? [ diff --git a/tests/IntegratedTest.php b/tests/IntegratedTest.php index b5f09c0..af91764 100644 --- a/tests/IntegratedTest.php +++ b/tests/IntegratedTest.php @@ -23,6 +23,15 @@ public function test_new_package_is_installed() $this->assertStringContainsString('MyVendor/MyPackage', $composer); } + public function test_new_package_studly_install() + { + Artisan::call('packager:new', ['vendor' => 'my-vendor', 'name' => 'my-package']); + + $this->seeInConsoleOutput('Package created successfully!'); + $this->assertStringContainsString('my-vendor/my-package', file_get_contents(base_path('composer.json'))); + $this->assertTrue(is_file(base_path('packages/my-vendor/my-package/src/MyPackageServiceProvider.php'))); + } + public function test_new_package_is_installed_from_custom_skeleton() { Artisan::call('packager:new', [