Skip to content

Commit e796f07

Browse files
committed
Creating a normal module build command
1 parent b5a093d commit e796f07

File tree

88 files changed

+166
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+166
-4
lines changed

.gitignore

100644100755
File mode changed.

LICENSE.md

100644100755
File mode changed.

README.md

100644100755
File mode changed.

config/laravel-modules.php

100644100755
File mode changed.

docs/_config.yml

100644100755
File mode changed.

docs/disable-module.md

100644100755
File mode changed.

docs/enable-module.md

100644100755
File mode changed.

docs/index.md

100644100755
File mode changed.

docs/make-config.md

100644100755
File mode changed.

docs/make-controller.md

100644100755
File mode changed.

docs/make-event.md

100644100755
File mode changed.

docs/make-helper.md

100644100755
File mode changed.

docs/make-job.md

100644100755
File mode changed.

docs/make-language.md

100644100755
File mode changed.

docs/make-listener.md

100644100755
File mode changed.

docs/make-mail.md

100644100755
File mode changed.

docs/make-middleware.md

100644100755
File mode changed.

docs/make-migration.md

100644100755
File mode changed.

docs/make-model.md

100644100755
File mode changed.

docs/make-module.md

100644100755
File mode changed.

docs/make-notification.md

100644100755
File mode changed.

docs/make-observer.md

100644100755
File mode changed.

docs/make-policy.md

100644100755
File mode changed.

docs/make-provider.md

100644100755
File mode changed.

docs/make-request.md

100644100755
File mode changed.

docs/make-router.md

100644100755
File mode changed.

docs/make-test.md

100644100755
File mode changed.

docs/migrate-module.md

100644100755
File mode changed.

docs/migrate-refresh-module.md

100644100755
File mode changed.

docs/migrate-reset-module.md

100644100755
File mode changed.

docs/migrate-rollback-module.md

100644100755
File mode changed.

docs/module-list.md

100644100755
File mode changed.

docs/module-optimize.md

100644100755
File mode changed.

docs/nova/how-to-active-nova.md

100644100755
File mode changed.

docs/nova/make-action.md

100644100755
File mode changed.

docs/nova/make-card.md

100644100755
File mode changed.

docs/nova/make-dashboard.md

100644100755
File mode changed.

docs/nova/make-field.md

100644100755
File mode changed.

docs/nova/make-filter.md

100644100755
File mode changed.

docs/nova/make-lens.md

100644100755
File mode changed.

docs/nova/make-partition.md

100644100755
File mode changed.

docs/nova/make-resource.md

100644100755
File mode changed.

docs/nova/make-value.md

100644100755
File mode changed.

docs/register-blade.md

100644100755
File mode changed.

docs/register-storage-disk.md

100644100755
File mode changed.

src/Console/Commands/ModuleMigrateRefreshCommand.php

100644100755
File mode changed.

src/Console/Commands/ModuleMigrateResetCommand.php

100644100755
File mode changed.

src/Console/Commands/ModuleMigrateRollbackCommand.php

100644100755
File mode changed.

src/Console/Generators/MakeBladeDirectoryCommand.php

100644100755
File mode changed.

src/Console/Generators/MakeConfigCommand.php

100644100755
File mode changed.

src/Console/Generators/MakeHelperCommand.php

100644100755
File mode changed.

src/Console/Generators/MakeLanguageCommand.php

100644100755
File mode changed.

src/Console/Generators/MakeModuleCommand.php

+41-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Console\Command;
66
use Illuminate\Filesystem\Filesystem;
77
use Illuminate\Support\Str;
8+
use Symfony\Component\Console\Input\InputOption;
89
use Symfony\Component\Console\Helper\ProgressBar;
910

1011
class MakeModuleCommand extends Command
@@ -14,7 +15,9 @@ class MakeModuleCommand extends Command
1415
*
1516
* @var string
1617
*/
17-
protected $signature = 'make:module {slug : The slug of the module}';
18+
protected $signature = 'make:module
19+
{slug : The slug of the module}
20+
{--normal : Generate a normal module}';
1821

1922
/**
2023
* The console command description.
@@ -62,6 +65,10 @@ public function handle()
6265

6366
$this->container['location'] = config('laravel-modules.modulesPath');
6467
$this->container['provider'] = "{$name}ServiceProvider";
68+
$this->container['controller'] = "{$name}Controller";
69+
$this->container['entity'] = $name;
70+
$this->container['table'] = Str::pluralStudly($this->container['slug']);
71+
$this->container['migration'] = now()->format('Y_m_d_his') . '_create_' . $this->container['table'] . '_table';
6572

6673

6774
$this->displayHeader('make_module_introduction');
@@ -164,9 +171,16 @@ protected function generateModule()
164171
}
165172

166173
$directory = "{$location}/{$folderName}";
167-
$source = __DIR__ . "/../../../structure";
168174

169-
if (!$this->files->isDirectory($directory)) {
175+
$structure = 'base';
176+
177+
if($this->option('normal')) :
178+
$structure = 'normal';
179+
endif;
180+
181+
$source = __DIR__ . "/../../../structure/{$structure}";
182+
183+
if (! $this->files->isDirectory($directory)) {
170184

171185
$this->files->makeDirectory($directory);
172186

@@ -177,11 +191,16 @@ protected function generateModule()
177191
$contents = $this->replacePlaceholders($file->getContents());
178192
$subPath = $file->getRelativePathname();
179193

180-
181194
$filePath = $directory . '/' . $subPath;
182195

183196
if ($file->getFilename() === 'ServiceProvider.php') {
184197
$filePath = str_replace('ServiceProvider', $this->container['provider'], $filePath);
198+
} else if($file->getFilename() === 'ModuleController.php') {
199+
$filePath = str_replace('ModuleController', $this->container['provider'], $filePath);
200+
} else if($file->getFilename() === "Entity.php") {
201+
$filePath = str_replace('Entity', $this->container['entity'], $filePath);
202+
} else if($file->getFilename() === "migration.php") {
203+
$filePath = str_replace('migration.php', $this->container['migration'] . ".php" , $filePath);
185204
}
186205

187206
$dir = dirname($filePath);
@@ -208,6 +227,9 @@ protected function replacePlaceholders($contents)
208227
'DummyDescription',
209228
'DummyLocation',
210229
'DummyProvider',
230+
'DummyController',
231+
'DummyEntity',
232+
'DummyTable',
211233
];
212234

213235
$replace = [
@@ -220,11 +242,26 @@ protected function replacePlaceholders($contents)
220242
$this->container['description'],
221243
$this->container['location'],
222244
$this->container['provider'],
245+
$this->container['controller'],
246+
$this->container['entity'],
247+
$this->container['table'],
223248
];
224249

225250
return str_replace($find, $replace, $contents);
226251
}
227252

253+
/**
254+
* Get the console command options.
255+
*
256+
* @return array
257+
*/
258+
protected function getOptions()
259+
{
260+
return [
261+
['normal', 'n', InputOption::VALUE_NONE, 'Normal Module'],
262+
];
263+
}
264+
228265
/**
229266
* Reset module cache of enabled and disabled modules.
230267
*/

src/Console/Generators/Nova/MakeActionCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakeCardCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakeDashboardCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakeFieldCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakeFilterCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakeLensCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakePartitionCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakeResourceCommand.php

100644100755
File mode changed.

src/Console/Generators/Nova/MakeValueCommand.php

100644100755
File mode changed.

src/CoreServiceProvider.php

100644100755
File mode changed.

src/Traits/NovaSupport.php

100644100755
File mode changed.
File renamed without changes.

structure/normal/config/.gitkeep

Whitespace-only changes.

structure/normal/database/migrations/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('DummyTable', function (Blueprint $table) {
17+
$table->id();
18+
$table->timestamps();
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*
25+
* @return void
26+
*/
27+
public function down()
28+
{
29+
Schema::dropIfExists('DummyTable');
30+
}
31+
};

structure/normal/info.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name" : "DummyName",
3+
"slug" : "DummySlug",
4+
"version" : "DummyVersion",
5+
"order" : "DummyOrder",
6+
"enabled" : true,
7+
"description" : "DummyDescription"
8+
}

structure/normal/languages/en.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<html>
2+
3+
</html>

structure/normal/routes/web.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Route;
4+
use App\DummyName\Http\Controllers\DummyController;
5+
6+
Route::get('DummySlug' , [DummyController::class , 'index']);
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace DummyNamespace\Entities;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class DummyEntity extends Model
8+
{
9+
/**
10+
* The attributes that are mass assignable.
11+
*
12+
* @var array
13+
*/
14+
protected $fillable = [];
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace DummyNamespace\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
use App\Http\Controllers\Controller;
7+
use DummyNamespace\Entities\DummyEntity;
8+
9+
class DummyController extends Controller
10+
{
11+
/**
12+
* Display a listing of the resource.
13+
*
14+
* @return \Illuminate\Http\Response
15+
*/
16+
public function index(Request $request)
17+
{
18+
$list = DummyEntity::all();
19+
20+
return view("DummySlug::index" , compact('list'));
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace DummyNamespace\Providers;
4+
5+
use Idel\Modular\CoreServiceProvider as ServiceProvider;
6+
7+
class DummyProvider extends ServiceProvider
8+
{
9+
/**
10+
* @var string $moduleName
11+
*/
12+
protected $moduleName = "DummySlug";
13+
14+
/**
15+
* Register the service provider.
16+
*
17+
* @return void
18+
*/
19+
public function register()
20+
{
21+
$this->registerStorageDisk('DummySlug');
22+
}
23+
24+
/**
25+
* Bootstrap the module services.
26+
*
27+
* @return void
28+
*/
29+
public function boot()
30+
{
31+
$this->registerConfig();
32+
$this->registerWebRoute();
33+
$this->registerJsonTranslations();
34+
$this->registerViews();
35+
$this->registerMigrations();
36+
}
37+
}

stubs/emptyJson.stub

100644100755
File mode changed.

stubs/emptyPhp.stub

100644100755
File mode changed.

stubs/nova/novaAction.stub

100644100755
File mode changed.

stubs/nova/novaCard.stub

100644100755
File mode changed.

stubs/nova/novaDashboard.stub

100644100755
File mode changed.

stubs/nova/novaField.stub

100644100755
File mode changed.

stubs/nova/novaFilter.stub

100644100755
File mode changed.

stubs/nova/novaLens.stub

100644100755
File mode changed.

stubs/nova/novaPartition.stub

100644100755
File mode changed.

stubs/nova/novaResource.stub

100644100755
File mode changed.

stubs/nova/novaTrend.stub

100644100755
File mode changed.

stubs/nova/novaValue.stub

100644100755
File mode changed.

0 commit comments

Comments
 (0)