Skip to content

Commit

Permalink
Merge pull request #113 from sebastienheyd/studly
Browse files Browse the repository at this point in the history
Fix vendor-name package-name not converted to studly case
  • Loading branch information
Jeroen-G authored Sep 2, 2020
2 parents 2548282 + 2c6a7b0 commit 557c600
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/NewPackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
]);
Expand Down
20 changes: 20 additions & 0 deletions src/Conveyor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/FileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) ? [
Expand Down
9 changes: 9 additions & 0 deletions tests/IntegratedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down

0 comments on commit 557c600

Please sign in to comment.