Skip to content

Commit

Permalink
Added composer.json normalize support (#95)
Browse files Browse the repository at this point in the history
* Added composer.json normalize support

* Apply CS Fixer

---------

Co-authored-by: StyleCI <[email protected]>
  • Loading branch information
zds-s and kanyxmo authored Jun 17, 2024
1 parent 046a931 commit 5ac3c6b
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 21 deletions.
20 changes: 11 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "xmo/mine-generator",
"type": "library",
"license": "Apache-2.0",
"description": "MineAdmin Code Generator",
"license": "Apache-2.0",
"type": "library",
"keywords": [
"MineAdmin","Hyperf","admin",
"MineAdmin",
"Hyperf",
"admin",
"generator-code"
],
"authors": [
Expand All @@ -19,21 +21,21 @@
"role": "Developer"
}
],
"require": {
"php": ">=8.1"
},
"autoload": {
"psr-4": {
"Mine\\Generator\\": "src"
}
},
"require": {
"php": ">=8.1"
"config": {
"optimize-autoloader": true,
"sort-packages": true
},
"extra": {
"hyperf": {
"config": "Mine\\Generator\\GeneratorConfigProvider"
}
},
"config": {
"optimize-autoloader": true,
"sort-packages": true
}
}
6 changes: 3 additions & 3 deletions publish/generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
return [
'dto' => [
'namespace' => 'App\\Dto',
'namespace' => 'App\Dto',
'path' => BASE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Dto',
'type' => [
'mapping' => [
Expand All @@ -26,11 +26,11 @@
],
],
'mapper' => [
'namespace' => 'App\\Mapper',
'namespace' => 'App\Mapper',
'path' => BASE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Mapper',
],
'service' => [
'namespace' => 'App\\Service',
'namespace' => 'App\Service',
'path' => BASE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Service',
'impl' => 'Impl',
],
Expand Down
4 changes: 2 additions & 2 deletions src/ControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected function getReplaceContent(): array
*/
protected function initNamespace(): string
{
$namespace = $this->getNamespace() . '\\Controller';
$namespace = $this->getNamespace() . '\Controller';
if (! empty($this->tablesContract->getPackageName())) {
return $namespace . '\\' . Str::title($this->tablesContract->getPackageName());
}
Expand Down Expand Up @@ -325,7 +325,7 @@ protected function getMethodRoute(string $route): string
protected function getDtoClass(): string
{
return sprintf(
'\\%s\\Dto\\%s::class',
'\%s\Dto\%s::class',
$this->tablesContract->getNamespace(),
$this->getBusinessName() . 'Dto'
);
Expand Down
2 changes: 1 addition & 1 deletion src/DtoGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function getReplaceContent(): array
*/
protected function initNamespace(): string
{
return $this->getNamespace() . '\\Dto';
return $this->getNamespace() . '\Dto';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/MapperGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected function getReplaceContent(): array
*/
protected function initNamespace(): string
{
return $this->getNamespace() . '\\Mapper';
return $this->getNamespace() . '\Mapper';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ModelGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ protected function getReplaceContent(): array
*/
protected function initNamespace(): string
{
return $this->getNamespace() . '\\Model';
return $this->getNamespace() . '\Model';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/RequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected function getReplaceContent(): array
*/
protected function initNamespace(): string
{
return $this->getNamespace() . '\\Request';
return $this->getNamespace() . '\Request';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected function getReplaceContent(): array
*/
protected function initNamespace(): string
{
return $this->getNamespace() . '\\Service';
return $this->getNamespace() . '\Service';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/VueIndexGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ protected function jsonFormat(array $data, bool $removeValueQuotes = false): str
{
$data = str_replace(' ', ' ', json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
$data = str_replace(['"true"', '"false"', '\\'], [true, false, ''], $data);
$data = preg_replace('/(\s+)\"(.+)\":/', '\\1\\2:', $data);
$data = preg_replace('/(\s+)\"(.+)\":/', '\1\2:', $data);
if ($removeValueQuotes) {
$data = preg_replace('/(:\s)\"(.+)\"/', '\\1\\2', $data);
$data = preg_replace('/(:\s)\"(.+)\"/', '\1\2', $data);
}
return $data;
}
Expand Down

0 comments on commit 5ac3c6b

Please sign in to comment.