Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

if (!function_exists('get_version_by_tag')) {
if (! function_exists('get_version_by_tag')) {
function get_version_by_tag(string $tag): string
{
return str_replace('v', '', $tag);
Expand Down
15 changes: 9 additions & 6 deletions src/Commands/GithubReleaseModuleCommand.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

/**
* JUZAWEB CMS - Laravel CMS for Your Project
*
* @package juzaweb/cms
* @author The Anh Dang
*
* @link https://juzaweb.com
*
* @license GNU V2
*/

Expand All @@ -28,7 +30,7 @@ public function handle(): void
$token = $this->getGithubToken();
$path = $this->argument('path');

if (!File::isDirectory($path)) {
if (! File::isDirectory($path)) {
$path = base_path($path);
}

Expand All @@ -38,18 +40,19 @@ public function handle(): void
$this->runCmd($path, 'git pull');

if (empty($lastTag)) {
$body = $this->runCmd($path, "git log --no-merges --pretty=format:\"* %s\" | uniq");
$body = $this->runCmd($path, 'git log --no-merges --pretty=format:"* %s" | uniq');
} else {
$body = $this->runCmd($path, "git log --no-merges --pretty=format:\"* %s\" {$lastTag}..HEAD | uniq");
}

if (empty($body)) {
$this->info('Nothing to release');

return;
}

$body = collect(explode("\n", $body))
->filter(fn ($item) => !empty($item) && !str_contains($item, ':construction:'))
->filter(fn ($item) => ! empty($item) && ! str_contains($item, ':construction:'))
->implode("\n");

$newTag = $this->getReleaseVersion($lastTag);
Expand Down Expand Up @@ -88,7 +91,7 @@ public function handle(): void
)
->throw();

$this->info('Released url: '. $release->json()['html_url']);
$this->info('Released url: '.$release->json()['html_url']);
}

protected function getLastTag(string $path): string
Expand Down Expand Up @@ -127,7 +130,7 @@ protected function getReleaseVersion(string $lastTag): string

$split = explode('.', $lastTag);
if (count($split) > 2) {
++$split[count($split) - 1];
$split[count($split) - 1]++;
$newTag = implode('.', $split);
} else {
$newTag = $lastTag.'.1';
Expand Down
8 changes: 3 additions & 5 deletions src/Commands/Modules/CommandMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class CommandMakeCommand extends GeneratorCommand

/**
* The name of argument name.
*
* @var string
*/
protected string $argumentName = 'name';

Expand Down Expand Up @@ -73,8 +71,8 @@ protected function getTemplateContents()

return (new Stub('/command.stub', [
'COMMAND_NAME' => $this->getCommandName(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
]))->render();
}

Expand All @@ -95,7 +93,7 @@ protected function getDestinationFilePath()

$commandPath = GenerateConfigReader::read('command');

return $path . $commandPath->getPath() . '/' . $this->getFileName() . '.php';
return $path.$commandPath->getPath().'/'.$this->getFileName().'.php';
}

/**
Expand Down
18 changes: 9 additions & 9 deletions src/Commands/Modules/ComponentClassMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class ComponentClassMakeCommand extends GeneratorCommand

/**
* The name of argument name.
*
* @var string
*/
protected string $argumentName = 'name';

Expand All @@ -42,14 +40,15 @@ public function handle(): int

return 0;
}

/**
* Write the view template for the component.
*
* @return void
*/
protected function writeComponentViewTemplate()
{
$this->call('module:make-component-view', ['name' => $this->argument('name') , 'module' => $this->argument('module')]);
$this->call('module:make-component-view', ['name' => $this->argument('name'), 'module' => $this->argument('module')]);
}

public function getDefaultNamespace(): string
Expand All @@ -71,6 +70,7 @@ protected function getArguments()
['module', InputArgument::OPTIONAL, 'The name of module will be used.'],
];
}

/**
* @return mixed
*/
Expand All @@ -79,10 +79,10 @@ protected function getTemplateContents()
$module = $this->laravel['modules']->findOrFail($this->getModuleName());

return (new Stub('/component-class.stub', [
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'COMPONENT_NAME' => 'components.' . Str::lower($this->argument('name')),
'NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getClass(),
'LOWER_NAME' => $module->getLowerName(),
'COMPONENT_NAME' => 'components.'.Str::lower($this->argument('name')),
]))->render();
}

Expand All @@ -94,14 +94,14 @@ protected function getDestinationFilePath()
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
$factoryPath = GenerateConfigReader::read('component-class');

return $path . $factoryPath->getPath() . '/' . $this->getFileName();
return $path.$factoryPath->getPath().'/'.$this->getFileName();
}

/**
* @return string
*/
private function getFileName()
{
return Str::studly($this->argument('name')) . '.php';
return Str::studly($this->argument('name')).'.php';
}
}
8 changes: 3 additions & 5 deletions src/Commands/Modules/ComponentViewMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class ComponentViewMakeCommand extends GeneratorCommand

/**
* The name of argument name.
*
* @var string
*/
protected string $argumentName = 'name';

Expand Down Expand Up @@ -52,7 +50,7 @@ protected function getArguments()
*/
protected function getTemplateContents()
{
return (new Stub('/component-view.stub', ['QUOTE'=> Inspiring::quote()]))->render();
return (new Stub('/component-view.stub', ['QUOTE' => Inspiring::quote()]))->render();
}

/**
Expand All @@ -63,14 +61,14 @@ protected function getDestinationFilePath()
$path = $this->laravel['modules']->getModulePath($this->getModuleName());
$factoryPath = GenerateConfigReader::read('component-view');

return $path . $factoryPath->getPath() . '/' . $this->getFileName();
return $path.$factoryPath->getPath().'/'.$this->getFileName();
}

/**
* @return string
*/
private function getFileName()
{
return Str::lower($this->argument('name')) . '.blade.php';
return Str::lower($this->argument('name')).'.blade.php';
}
}
43 changes: 14 additions & 29 deletions src/Commands/Modules/ControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Juzaweb\DevTool\Commands\Modules;

use Illuminate\Support\Str;
use Juzaweb\Modules\Core\Facades\Module;
use Juzaweb\Modules\Core\Modules\FileRepository;
use Juzaweb\Modules\Core\Modules\Support\Config\GenerateConfigReader;
use Juzaweb\Modules\Core\Modules\Support\Stub;
Expand All @@ -16,8 +17,6 @@ class ControllerMakeCommand extends GeneratorCommand

/**
* The name of argument being used.
*
* @var string
*/
protected string $argumentName = 'controller';

Expand All @@ -37,43 +36,36 @@ class ControllerMakeCommand extends GeneratorCommand

/**
* Get controller name.
*
* @return string
*/
public function getDestinationFilePath(): string
{
$path = \Juzaweb\Modules\Core\Facades\Module::getModulePath($this->getModuleName());
$path = Module::getModulePath($this->getModuleName());

$controllerPath = GenerateConfigReader::read('controller');

return $path . $controllerPath->getPath() . '/' . $this->getControllerName() . '.php';
return $path.$controllerPath->getPath().'/'.$this->getControllerName().'.php';
}

/**
* @return string
*/
protected function getTemplateContents(): string
{
$module = \Juzaweb\Modules\Core\Facades\Module::findOrFail($this->getModuleName());
$module = Module::findOrFail($this->getModuleName());

return (new Stub($this->getStubName(), [
'MODULENAME' => $module->getStudlyName(),
'CONTROLLERNAME' => $this->getControllerName(),
'NAMESPACE' => $module->getStudlyName(),
'CLASS_NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getControllerNameWithoutNamespace(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getModuleName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => \Juzaweb\Modules\Core\Facades\Module::config('namespace'),
'MODULENAME' => $module->getStudlyName(),
'CONTROLLERNAME' => $this->getControllerName(),
'NAMESPACE' => $module->getStudlyName(),
'CLASS_NAMESPACE' => $this->getClassNamespace($module),
'CLASS' => $this->getControllerNameWithoutNamespace(),
'LOWER_NAME' => $module->getLowerName(),
'MODULE' => $this->getModuleName(),
'NAME' => $this->getModuleName(),
'STUDLY_NAME' => $module->getStudlyName(),
'MODULE_NAMESPACE' => Module::config('namespace'),
]))->render();
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments(): array
{
Expand All @@ -83,9 +75,6 @@ protected function getArguments(): array
];
}

/**
* @return array
*/
protected function getOptions(): array
{
return [
Expand Down Expand Up @@ -115,7 +104,6 @@ public function getDefaultNamespace(): string

/**
* Get the stub file name based on the options
* @return string
*/
protected function getStubName(): string
{
Expand All @@ -130,9 +118,6 @@ protected function getStubName(): string
return $stub;
}

/**
* @return array|string
*/
private function getControllerNameWithoutNamespace(): array|string
{
return class_basename($this->getControllerName());
Expand Down
Loading
Loading