Skip to content

Commit 12c9936

Browse files
committed
updates
1 parent 3e9b65b commit 12c9936

19 files changed

+143
-64
lines changed

composer.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,12 @@
2424
},
2525
"autoload": {
2626
"psr-4": {
27-
"Akaunting\\Module\\": "./src"
27+
"Akaunting\\Module\\": "src"
2828
},
2929
"files": [
3030
"src/helpers.php"
3131
]
3232
},
33-
"autoload-dev": {
34-
"psr-4": {
35-
"Akaunting\\Module\\Tests\\": "tests",
36-
"Modules\\Recipe\\": "tests/stubs/valid/Recipe"
37-
}
38-
},
3933
"extra": {
4034
"laravel": {
4135
"providers": [

src/Commands/GeneratorCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public function handle()
4343
$contents = $this->getTemplateContents();
4444

4545
try {
46-
with(new FileGenerator($path, $contents))->generate();
46+
$overwrite_file = $this->hasOption('force') ? $this->option('force') : false;
47+
(new FileGenerator($path, $contents))->withFileOverwrite($overwrite_file)->generate();
4748

4849
$this->info("Created : {$path}");
4950
} catch (FileAlreadyExistException $e) {

src/Commands/MigrateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function handle()
6060
*/
6161
protected function migrate(Module $module)
6262
{
63-
$path = str_replace(base_path(), '', (new Migrator($module))->getPath());
63+
$path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath());
6464

6565
if ($this->option('subpath')) {
6666
$path = $path . "/" . $this->option("subpath");

src/Commands/MigrateResetCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function reset($module)
6464
$module = $this->module->findOrFail($module);
6565
}
6666

67-
$migrator = new Migrator($module);
67+
$migrator = new Migrator($module, $this->getLaravel());
6868

6969
$database = $this->option('database');
7070

src/Commands/MigrateRollbackCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function rollback($module)
6464
$module = $this->module->findOrFail($module);
6565
}
6666

67-
$migrator = new Migrator($module);
67+
$migrator = new Migrator($module, $this->getLaravel());
6868

6969
$database = $this->option('database');
7070

src/Commands/MigrateStatusCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function handle()
5959
*/
6060
protected function migrateStatus(Module $module)
6161
{
62-
$path = str_replace(base_path(), '', (new Migrator($module))->getPath());
62+
$path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath());
6363

6464
$this->call('migrate:status', [
6565
'--path' => $path,

src/Commands/PublishMigrationCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function handle()
4848
*/
4949
public function publish($module)
5050
{
51-
with(new MigrationPublisher(new Migrator($module)))
51+
with(new MigrationPublisher(new Migrator($module, $this->getLaravel())))
5252
->setRepository($this->laravel['module'])
5353
->setConsole($this)
5454
->publish();

src/Commands/RouteProviderMakeCommand.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Akaunting\Module\Support\Stub;
77
use Akaunting\Module\Traits\ModuleCommandTrait;
88
use Symfony\Component\Console\Input\InputArgument;
9+
use Symfony\Component\Console\Input\InputOption;
910

1011
class RouteProviderMakeCommand extends GeneratorCommand
1112
{
@@ -39,6 +40,13 @@ protected function getArguments()
3940
];
4041
}
4142

43+
protected function getOptions()
44+
{
45+
return [
46+
['force', null, InputOption::VALUE_NONE, 'Force the operation to run when the file already exists.'],
47+
];
48+
}
49+
4250
/**
4351
* Get template contents.
4452
*
@@ -86,15 +94,15 @@ protected function getDestinationFilePath()
8694
*/
8795
protected function getWebRoutesPath()
8896
{
89-
return '/' . $this->laravel['config']->get('stubs.files.routes', 'Routes/web.php');
97+
return '/' . $this->laravel['modules']->config('stubs.files.routes/web', 'Routes/web.php');
9098
}
9199

92100
/**
93101
* @return mixed
94102
*/
95103
protected function getApiRoutesPath()
96104
{
97-
return '/' . $this->laravel['config']->get('stubs.files.routes', 'Routes/api.php');
105+
return '/' . $this->laravel['modules']->config('stubs.files.routes/api', 'Routes/api.php');
98106
}
99107

100108
public function getDefaultNamespace() : string

src/Commands/stubs/route-provider.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ class $CLASS$ extends ServiceProvider
6464
Route::prefix('api')
6565
->middleware('api')
6666
->namespace($this->moduleNamespace)
67-
->group(__DIR__ . '/../Routes/api.php');
67+
->group(__DIR__ . '/..$API_ROUTES_PATH$');
6868
}
6969
}

src/Commands/stubs/scaffold/provider.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class $CLASS$ extends ServiceProvider
9090
*/
9191
public function registerFactories()
9292
{
93-
if (!app()->environment('production')) {
93+
if (!app()->environment('production') && $this->app->runningInConsole()) {
9494
app(Factory::class)->load(__DIR__ . '/../$FACTORIES_PATH$');
9595
}
9696
}

0 commit comments

Comments
 (0)