Skip to content
Merged
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
67 changes: 42 additions & 25 deletions src/Console/MakeModuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Modular\Modular\Console;

use Illuminate\Support\Str;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Artisan;

class MakeModuleCommand extends Command
{
Expand All @@ -18,27 +20,30 @@ public function handle(): ?int
{
$this->setModuleName();

$this->comment('Creating Module '.$this->moduleName);
$this->comment('Creating Module ' . $this->moduleName);

if ($this->createModuleDirectoryStructure()) {
$this->createServiceProvider();

$this->createModuleDirectoryStructure();
$this->createServiceProvider();
$params = [
'moduleName' => $this->moduleName,
'resourceName' => $this->moduleName,
];

$params = [
'moduleName' => $this->moduleName,
'resourceName' => $this->moduleName,
];
$this->call('modular:make-controller', $params);
$this->call('modular:make-validate', $params);
$this->call('modular:make-model', $params);
$this->call('modular:make-route', $params);

$this->call('modular:make-controller', $params);
$this->call('modular:make-validate', $params);
$this->call('modular:make-model', $params);
$this->call('modular:make-route', $params);
$this->call('modular:make-migration', ['moduleName' => $this->moduleName, 'migrationName' => "create{$this->moduleName}s_table"]);

$this->call('modular:make-migration', ['moduleName' => $this->moduleName, 'migrationName' => "create{$this->moduleName}s_table"]);
$this->call('modular:make-page', $params);
$this->call('modular:make-test', $params);

$this->call('modular:make-page', $params);
$this->call('modular:make-test', $params);
return self::SUCCESS;
}

return self::SUCCESS;
return false;
}

private function setModulename(): void
Expand All @@ -48,7 +53,7 @@ private function setModulename(): void

private function createServiceProvider(): void
{
$stub = file_get_contents(__DIR__.'/../../stubs/module-stub/modules/ModuleServiceProvider.stub');
$stub = file_get_contents(__DIR__ . '/../../stubs/module-stub/modules/ModuleServiceProvider.stub');

$stub = str_replace('{{ moduleName }}', $this->moduleName, $stub);
$stub = str_replace('{{ resourceName }}', Str::camel($this->moduleName), $stub);
Expand All @@ -58,14 +63,26 @@ private function createServiceProvider(): void
file_put_contents($path, $stub);
}

private function createModuleDirectoryStructure(): void
private function createModuleDirectoryStructure(): bool
{
(new Filesystem)->makeDirectory(base_path("modules/{$this->moduleName}"));
(new Filesystem)->makeDirectory(base_path("modules/{$this->moduleName}/Http/Controllers"), 0755, true);
(new Filesystem)->makeDirectory(base_path("modules/{$this->moduleName}/Http/Requests"));
(new Filesystem)->makeDirectory(base_path("modules/{$this->moduleName}/Models"));
(new Filesystem)->makeDirectory(base_path("modules/{$this->moduleName}/routes"));
(new Filesystem)->makeDirectory(base_path("modules/{$this->moduleName}/Tests"));
(new Filesystem)->makeDirectory(base_path("modules/{$this->moduleName}/Database/Migrations"), 0755, true);
$modulePath = base_path("modules/{$this->moduleName}");

// Check if the module directory already exists
if (File::exists($modulePath)) {
// Output an error message to the console
$this->info("Module {$this->moduleName} already exists. SKIPPING");
return false;
}

// Create the necessary directories
(new Filesystem)->makeDirectory($modulePath);
(new Filesystem)->makeDirectory("{$modulePath}/Http/Controllers", 0755, true);
(new Filesystem)->makeDirectory("{$modulePath}/Http/Requests");
(new Filesystem)->makeDirectory("{$modulePath}/Models");
(new Filesystem)->makeDirectory("{$modulePath}/routes");
(new Filesystem)->makeDirectory("{$modulePath}/Tests");
(new Filesystem)->makeDirectory("{$modulePath}/Database/Migrations", 0755, true);

return true;
}
}
2 changes: 1 addition & 1 deletion stubs/page-stub/Index.stub
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<AppDataTableData>
<!-- edit {{ resourceName }} -->
<AppTooltip text="Edit {{ ResourceName }}" class="mr-3">
<AppTooltip text="Edit {{ ResourceName }}" class="mr-2">
<AppButton
class="btn btn-icon btn-primary"
@click="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<td class="whitespace-nowrap px-6 py-4 font-medium">
<td class="whitespace-nowrap px-4 py-2 font-medium">
<slot></slot>
</td>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<th
v-for="header in headers"
:key="header"
class="border-b border-skin-neutral-6 bg-skin-neutral-3 px-6 py-3"
class="border-b border-skin-neutral-5 bg-skin-neutral-5 px-4 py-2"
>
{{ header }}
</th>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<tr class="border-b border-b-skin-neutral-6 hover:bg-skin-neutral-3">
<tr class="border border-skin-neutral-4 hover:bg-skin-neutral-3">
<slot></slot>
</tr>
</template>
4 changes: 2 additions & 2 deletions stubs/resources/js/Components/DataTable/AppPaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<template v-for="(link, index) in links" :key="index">
<div
v-if="link.url === null"
class="mb-1 mr-1 rounded border px-4 py-3 text-sm leading-4 opacity-30"
class="mb-1 mr-1 rounded border px-3 py-2 text-sm leading-4 opacity-30"
v-html="link.label"
/>
<Link
v-else
class="mb-1 mr-1 rounded border px-4 py-3 text-sm leading-4 hover:bg-skin-primary-10 hover:text-skin-primary-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2"
class="mb-1 mr-1 rounded border px-3 py-2 text-sm leading-4 hover:bg-skin-primary-10 hover:text-skin-primary-1 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2"
:class="{
'bg-skin-primary-9 text-skin-primary-2': link.active
}"
Expand Down
4 changes: 2 additions & 2 deletions stubs/resources/js/Components/Misc/AppButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const emit = defineEmits(['click'])

<style scoped>
.btn {
@apply z-0 rounded-md px-5 py-2.5 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2;
@apply z-0 flex items-center rounded-md px-4 py-2 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2;
}

.btn-primary {
Expand Down Expand Up @@ -38,6 +38,6 @@ const emit = defineEmits(['click'])
}

.btn-icon {
@apply h-10 w-10 rounded-md px-2.5 py-2.5;
@apply h-8 rounded-md px-3;
}
</style>
2 changes: 1 addition & 1 deletion stubs/resources/js/Pages/AclPermission/PermissionIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<AppDataTableData>
<!-- edit permission -->
<AppTooltip :text="__('Edit Permission')" class="mr-3">
<AppTooltip :text="__('Edit Permission')" class="mr-2">
<AppButton
class="btn btn-icon btn-primary"
@click="
Expand Down
4 changes: 2 additions & 2 deletions stubs/resources/js/Pages/AclRole/RoleIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<AppDataTableData>
<!-- role permissions -->
<AppTooltip :text="__('Role Permissions')" class="mr-3">
<AppTooltip :text="__('Role Permissions')" class="mr-2">
<AppButton
class="btn btn-icon btn-primary"
@click="
Expand All @@ -44,7 +44,7 @@
</AppTooltip>

<!-- edit role -->
<AppTooltip :text="__('Edit Role')" class="mr-3">
<AppTooltip :text="__('Edit Role')" class="mr-2">
<AppButton
class="btn btn-icon btn-primary"
@click="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
name="permission"
:value="permission"
/>
<AppLabel :for="permission.name" class="ml-3">
<AppLabel :for="permission.name" class="ml-2">
{{ permission.name }}
</AppLabel>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
name="permission"
:value="permission"
/>
<AppLabel :for="permission.name" class="ml-3">
<AppLabel :for="permission.name" class="ml-2">
{{ permission.name }}
</AppLabel>
</div>
Expand Down
2 changes: 1 addition & 1 deletion stubs/resources/js/Pages/AclUserRole/UserRoleForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
name="role"
:value="role"
/>
<AppLabel :for="role.name" class="ml-3">
<AppLabel :for="role.name" class="ml-2">
{{ role.name }}
</AppLabel>
</div>
Expand Down
6 changes: 3 additions & 3 deletions stubs/resources/js/Pages/User/UserIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

<AppDataTableData>
<!-- edit user roles -->
<AppTooltip :text="__('User Roles')" class="mr-3">
<AppTooltip :text="__('User Roles')" class="mr-2">
<AppButton
class="btn btn-icon btn-primary"
@click="
Expand All @@ -48,7 +48,7 @@
</AppTooltip>

<!-- edit user permissions -->
<AppTooltip :text="__('User Permissions')" class="mr-3">
<AppTooltip :text="__('User Permissions')" class="mr-2">
<AppButton
class="btn btn-icon btn-primary"
@click="
Expand All @@ -62,7 +62,7 @@
</AppTooltip>

<!-- edit user -->
<AppTooltip :text="__('Edit User')" class="mr-3">
<AppTooltip :text="__('Edit User')" class="mr-2">
<AppButton
class="btn btn-icon btn-primary"
@click="
Expand Down