Skip to content

Commit

Permalink
make:structure to init:structure (#27)
Browse files Browse the repository at this point in the history
* make:structure to init:structure

* update docs
  • Loading branch information
shavonn committed Dec 28, 2023
1 parent d430925 commit 64d00e5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 58 deletions.
20 changes: 10 additions & 10 deletions docs/additional-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ outline: deep

Additional, custom artisan commands provided by this package.

## make:enum
## init:structure

```shell
artisan make:enum [name]
```bash
artisan init:structure
```

Default dir in config: `app/Enums`
Generates full directory structure defined in the Laraca config file.

## make:structure
## make:enum

```shell
artisan make:structure [name]
```bash
artisan make:enum [name]
```

Generates full directory structure defined in the Laraca config file.
Default dir in config: `app/Enums`

## make:value

```shell
```bash
artisan make:value [name]
```

Default dir in config: `Data\Values`
Default dir in config: `Data/Values`
64 changes: 28 additions & 36 deletions docs/artisan-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Caveats:

## arti:migration

```shell
```bash
artisan arti:migration [name]
```

Expand All @@ -22,7 +22,7 @@ Default dir in config: `database/migrations`

## make:cast

```shell
```bash
artisan make:cast [name]
```

Expand All @@ -32,7 +32,7 @@ Default dir in config: `app/Data/Casts`

## make:channel

```shell
```bash
artisan make:channel [name]
```

Expand All @@ -42,7 +42,7 @@ Default dir in config: `app/Broadcasting`

## make:command

```shell
```bash
artisan make:command [name]
```

Expand All @@ -52,7 +52,7 @@ Default dir in config: `app/Console/Commands`

## make:component

```shell
```bash
artisan make:component [name]
```

Expand All @@ -66,7 +66,7 @@ Default dir in config: `app/View/Components`

## make:controller

```shell
```bash
artisan make:controller [name]
```

Expand All @@ -76,15 +76,15 @@ Default dir in config: `app/Http/Controllers`

## make:enum

```shell
```bash
artisan make:enum [name]
```

Default dir in config: `app/Enums`

## make:event

```shell
```bash
artisan make:event [name]
```

Expand All @@ -94,7 +94,7 @@ Default dir in config: `app/Events`

## make:exception

```shell
```bash
artisan make:exception [name]
```

Expand All @@ -104,7 +104,7 @@ Default dir in config: `app/Exceptions`

## make:factory

```shell
```bash
artisan make:factory [name]
```

Expand All @@ -114,7 +114,7 @@ Default dir in config: `database/factories`

## make:job

```shell
```bash
artisan make:job [name]
```

Expand All @@ -124,7 +124,7 @@ Default dir in config: `app/Jobs`

## make:listener

```shell
```bash
artisan make:listener [name]
```

Expand All @@ -134,7 +134,7 @@ Default dir in config: `app/Listeners`

## make:mail

```shell
```bash
artisan make:mail [name]
```

Expand All @@ -144,7 +144,7 @@ Default dir in config: `app/Mail`

## make:middleware

```shell
```bash
artisan make:middleware [name]
```

Expand All @@ -154,7 +154,7 @@ Default dir in config: `app/Http/Middlewares`

## make:model

```shell
```bash
artisan make:model [name]
```

Expand All @@ -174,7 +174,7 @@ Default dir in config: `app/Data/Models`

## make:notification

```shell
```bash
artisan make:notification [name]
```

Expand All @@ -184,7 +184,7 @@ Default dir in config: `app/Notifications`

## make:observer

```shell
```bash
artisan make:observer [name]
```

Expand All @@ -194,7 +194,7 @@ Default dir in config: `app/Data/Observers`

## make:policy

```shell
```bash
artisan make:policy [name]
```

Expand All @@ -204,7 +204,7 @@ Default dir in config: `app/Policies`

## make:provider

```shell
```bash
artisan make:provider [name]
```

Expand All @@ -214,7 +214,7 @@ Default dir in config: `app/Providers`

## make:request

```shell
```bash
artisan make:request [name]
```

Expand All @@ -224,7 +224,7 @@ Default dir in config: `app/Http/Requests`

## make:resource

```shell
```bash
artisan make:resource [name]
```

Expand All @@ -234,7 +234,7 @@ Default dir in config: `app/Http/Resources`

## make:rule

```shell
```bash
artisan make:rule [name]
```

Expand All @@ -244,7 +244,7 @@ Default dir in config: `app/Rules`

## make:scope

```shell
```bash
artisan make:scope [name]
```

Expand All @@ -254,25 +254,17 @@ Default dir in config: `app/Data/Models/Scopes`

## make:seeder

```shell
```bash
artisan make:seeder [name]
```

Extends `artisan make:seeder`

Default dir in config: `database/seeders`

## make:structure

```shell
artisan make:structure [name]
```

Generates full directory structure defined in the Laraca config file.

## make:test

```shell
```bash
artisan make:test [name]
```

Expand All @@ -282,15 +274,15 @@ Default dir in config: `tests`

## make:value

```shell
```bash
artisan make:value [name]
```

Default dir in config: `Data\Values`
Default dir in config: `app/Data/Values`

## make:view

```shell
```bash
artisan make:view [name]
```

Expand Down
4 changes: 2 additions & 2 deletions docs/package-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

Install the package via composer:

```shell
```bash
composer require handsomebrown/laraca-arch
```

## Config file

If you want to depart from the default structure in this package, which I imagine many will, publish the config file with:

```shell
```bash
php artisan vendor:publish --tag="laraca-config"
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Illuminate\Support\Facades\Config;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'make:structure')]
class MakeStructureCommand extends Command
#[AsCommand(name: 'init:structure')]
class InitStructureCommand extends Command
{
use LaracaCommand;

Expand All @@ -17,7 +17,7 @@ class MakeStructureCommand extends Command
*
* @var string
*/
protected $name = 'make:structure';
protected $name = 'init:structure';

/**
* The console command description.
Expand Down
4 changes: 2 additions & 2 deletions src/LaracaServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace HandsomeBrown\Laraca;

use HandsomeBrown\Laraca\Commands\ArtiMigrationCommand;
use HandsomeBrown\Laraca\Commands\InitStructureCommand;
use HandsomeBrown\Laraca\Commands\MakeCastCommand;
use HandsomeBrown\Laraca\Commands\MakeChannelCommand;
use HandsomeBrown\Laraca\Commands\MakeCommandCommand;
Expand All @@ -26,7 +27,6 @@
use HandsomeBrown\Laraca\Commands\MakeRuleCommand;
use HandsomeBrown\Laraca\Commands\MakeScopeCommand;
use HandsomeBrown\Laraca\Commands\MakeSeederCommand;
use HandsomeBrown\Laraca\Commands\MakeStructureCommand;
use HandsomeBrown\Laraca\Commands\MakeTestCommand;
use HandsomeBrown\Laraca\Commands\MakeValueCommand;
use HandsomeBrown\Laraca\Commands\MakeViewCommand;
Expand Down Expand Up @@ -76,7 +76,7 @@ class LaracaServiceProvider extends ServiceProvider
'MakeRule' => MakeRuleCommand::class,
'MakeScope' => MakeScopeCommand::class,
'MakeSeeder' => MakeSeederCommand::class,
'MakeStructure' => MakeStructureCommand::class,
'MakeStructure' => InitStructureCommand::class,
'MakeTest' => MakeTestCommand::class,
'MakeValue' => MakeValueCommand::class,
'MakeView' => MakeViewCommand::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;

describe('make:structure', function () {
describe('init:structure', function () {
it('should create directory Structure from config', function () {
Config::set('laraca.structure.database.path', 'test/database');
Config::set('laraca.structure.cast.path', 'Test/Data/Casts');
Expand All @@ -32,7 +32,7 @@
Config::set('laraca.structure.test.path', 'test/tests');
Config::set('laraca.structure.value.path', 'Test/Data/Values');
Config::set('laraca.structure.view.path', 'test/resources/views');
expect($this->artisan('make:structure'))
expect($this->artisan('init:structure'))
->toBe(0);

$paths = [
Expand Down Expand Up @@ -82,21 +82,21 @@
Config::set('laraca.structure.empty_key', []);
Config::set('laraca.structure.command.parent', 'empty_key');

$this->artisan('make:structure');
$this->artisan('init:structure');

})->with('classes')->throws(MissingPathNamespaceKeyException::class);

it('throws an InvalidConfigKeyException when a parent key does not exist in the config', function () {
Config::set('laraca.structure.model.parent', 'nonexistent_key');

$this->artisan('make:structure');
$this->artisan('init:structure');

})->with('classes')->throws(InvalidConfigKeyException::class);

it('throws a MissingRootPathException when a tree does not lead to a base or app parent', function () {
Config::set('laraca.structure.model.parent', '');

$this->artisan('make:structure');
$this->artisan('init:structure');

})->with('classes')->throws(MissingRootPathException::class);
});

0 comments on commit 64d00e5

Please sign in to comment.