Skip to content

Commit

Permalink
chore(♻️): build 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeerickson committed Feb 3, 2020
1 parent 174cfe7 commit 8d3939e
Show file tree
Hide file tree
Showing 27 changed files with 1,077 additions and 35 deletions.
37 changes: 22 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,51 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.8.0] - 2019-10-01
## [1.8.0] - 2020-02-20

### Added

- Added support for crafting migrations based on `--foreign` short format
- `laravel-craftsman craft:migration create_members_table --foreign=member_id` will populate `ftable` and `fkey`
- Added `craft:command` command
- Added `craft:event` and `craft:listener` commands

## [1.7.2] - 2019-09-25

### Added

- Added support for crafting migrations based on `--foreign` short format
- `laravel-craftsman craft:migration create_members_table --foreign=member_id` will populate `ftable` and `fkey`
```php
$table->foreign('member_id')->references('id')->on('members');
```
- Added support for overriding defaults using pubished configuration file
- `laravel-craftsman publish`
- Added support for overriding defaults using published configuration file
- `laravel-craftsman publish`

## [1.7.0] - 2019-09-26

### Added

- Added `craft:api` command
- Code cleanup (based on phpinsights analysis)
- Added `craft:api` command
- Code cleanup (based on phpinsights analysis)

## [1.6.3] - 2019-08-28

### Fixed

- Fixed `craft:controller` to craft new controller in `App/Http/Controllers` directory when using `resource` flag
- Fixed test case to `CraftControllerTest::should_create_resource_controller` to cover correct resource creation related to `resource` flag (see above)
- Fixed `craft:controller` to craft new controller in `App/Http/Controllers` directory when using `resource` flag
- Fixed test case to `CraftControllerTest::should_create_resource_controller` to cover correct resource creation related to `resource` flag (see above)

### Modified

- Modified `craft:controller` shortcut for `resource` controller from `-u` to `-r`
- Modified npm tasks for running test, adding `test:all` task
- Modified `task:stress` to call `stress-test.sh` task so it will properly handle stress retries
- Modified `craft:controller` shortcut for `resource` controller from `-u` to `-r`
- Modified npm tasks for running test, adding `test:all` task
- Modified `task:stress` to call `stress-test.sh` task so it will properly handle stress retries

## [1.6.2] - 2019-08-14

### Added

- `craft` command alias for `interactive`
- `$ laravel-craftsman craft`
- `craft` command alias for `interactive`
- `$ laravel-craftsman craft`

## [1.6.1] - 2019-08-03

Expand All @@ -68,7 +75,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added artisan fallback when executing commands which dont exist in `craftsman`
- Added artisan fallback when executing commands which dont exist in `craftsman`
o For example, call `laravel-craftsman craft:observer TestObserver` the artiasn command `make:observer` will be executed

## [1.5.0] - 2019-07-12
Expand Down
57 changes: 47 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ In addition, you can create all assets with a single command, allowing you to qu

## Table Of Conents

- [Installation](#installation)
- [Usage](#usage)
- [Commands](#commands)
- [Tips](#tips)
- [Custom Templates](#custom-templates)
- [License](#license)
- [Credits](#credits)
- [Installation](#installation)
- [Usage](#usage)
- [Commands](#commands)
- [Tips](#tips)
- [Custom Templates](#custom-templates)
- [License](#license)
- [Credits](#credits)

## Installation

Expand Down Expand Up @@ -62,6 +62,9 @@ or

> laravel-craftsman craft:controller PostController --model App/Models/Post

> laravel-craftsman craft:event ContactCreated
> laravel-craftsman craft:event ContactCreated --no-broadcast

> laravel-craftsman craft:factory PostFactory --model App/Models/Post

> laravel-craftsman craft:migration create_posts_table --tablename posts
Expand Down Expand Up @@ -98,7 +101,7 @@ laravel-craftsman craft:all Contact \
| **interactive** | | **Run Interactive Mode (uses wizard to craft resources** |
| | --silent, -s | Skips Wizard Instructions |
| **publish** | | **Publish templates to project diretory** |
| | | *==> all craft:xxx commands will use project template if it exists* |
| | | _==> all craft:xxx commands will use project template if it exists_ |
| | --skip-config, -c | Skip publishing craftsman configuration file |
| | --overwrite, -o | Overwrites published templates directory |
| **craft:api** | | **Craft API Resources (create model, controller, factory, migration, seed)** |
Expand Down Expand Up @@ -133,6 +136,12 @@ laravel-craftsman craft:all Contact \
| | --constructor, -c | Include constructor method |
| | --template, -t | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:command** | | **Creates Artisan Command class** |
| | **🚩 command name** | Command name |
| | --signature, -s | Command Signature |
| | --description, -d | Command Description |
| | --template, -t | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:controller** | | **Create controller using supplied options** |
| | **🚩 controller name** | Controller Name |
| | --model, -m | Path to model (eg App/Models/Post) |
Expand All @@ -143,13 +152,22 @@ laravel-craftsman craft:all Contact \
| | --resource, -r | Create resource controller |
| | --template, -t | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:event** | | **Creates event class** |
| | **🚩 event name** | Event Name |
| | --no-broadcast, -b | Skips broadcast code when event class created |
| | --overwrite, -w | Overwrite existing class |
| **craft:factory** | | **Creates factory using supplied options** |
| | **🚩 factory name** | Factory Name |
| | --model, -m | Path to model (eg App/Models/Post) |
| **craft:listener** | | **Creates listener class** |
| | **🚩 listener name** | Listener Name |
| | --event, -e | The event class be listener for |
| | --queued | Indicates the event listener should be queued |
| | --overwrite, -w | Overwrite existing class |
| **craft:migration** | | **Creates migration using supplied options** |
| | **🚩 migration name** | Migration Name (eg create_contacts_table) |
| | **🚩 migration name** | Migration Name (eg create\*contacts_table) |
| | --tablename, -t | Tablename used in database (will set \$tablename in Model) |
| | | _If not supplied, default table will be pluralized model name_ |
| | | \_If not supplied, default table will be pluralized model name\* |
| | --fields, -f | List of fields (option) _see syntax below_ |
| | | **🚨 If you have spaces separating fields, you must surround fields list in quotes** |
| | --foreign, -r | Add foreign key constraint (foreign info) _see syntax below_ |
Expand Down Expand Up @@ -202,7 +220,9 @@ This will create a class in the `App/Services` path, with filename `Sync.php`. D
The following commands support defining class path

- craft:class
- craft:event
- craft:factory
- craft:listener
- craft:model
- craft:seed
- craft:test
Expand Down Expand Up @@ -256,9 +276,26 @@ will be translated internally to use the full `--foreign` format
--foreign=post_id:id,posts
```

#### Automatic foreign key field creation

When using the `--foreign` flag, the appropriate field will be added automatically in migration file.
For example, if the `--foreign post_id` flag is supplied, the following will be added to new migration

```php
...
Schema::create('comments', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('post_id');
...
$table->foreign('post_id')->references('id')->on('posts');
});
...
```

### Field Option Syntax

When using the `--fields` option when building migrations, you should use the following syntax:
Note: If you have used teh `--foreign` flag as outlined above, the foreign key field will be added automatically

```bash
format:
Expand Down
59 changes: 59 additions & 0 deletions app/Commands/CraftCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Commands;

use App\CraftsmanFileSystem;
use LaravelZero\Framework\Commands\Command;

/**
* Class CraftClass
* @package App\Commands
*/
class CraftCommand extends Command
{
protected $signature = 'craft:command
{name : Command name}
{--s|signature= : Command Signature}
{--d|description= : Command Description}
{--t|template= : Template path (override configuration file)}
{--w|overwrite : Overwrite existing class}
';

protected $description = "Craft Laravel Command";

protected $help = 'Craft Command
<name> Command Name
--signature, -s Command Signature
--description, -d Command Description
--template, -t Path to custom template (override config file)
--overwrite, -w Overwrite existing class
';

public function __construct()
{
parent::__construct();

$this->fs = new CraftsmanFileSystem();

$this->setHelp($this->help);
}

public function handle()
{
$className = $this->argument('name');

$signature = $this->option('signature') ?: 'command:name';
$description = $this->option('description') ?: 'Command description';

$data = [
"name" => $className,
"signature" => $signature,
"description" => $description,
"template" => $this->option("template"),
"overwrite" => $this->option("overwrite"),
];

$this->fs->createFile('command', $className, $data);
}
}
53 changes: 53 additions & 0 deletions app/Commands/CraftEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Commands;

use App\CraftsmanFileSystem;
use LaravelZero\Framework\Commands\Command;

/**
* Class CraftClass
* @package App\Commands
*/
class CraftEvent extends Command
{
protected $signature = 'craft:event
{name : Event name}
{--b|no-broadcast : Skip broadcasting}
{--t|template= : Template path (override configuration file)}
{--w|overwrite : Overwrite existing class}
';

protected $description = "Craft Event Class";

protected $help = 'Craft Event
<name> Class Name
--no-broadcast, -b Skip broadcasting
--template, -t Path to custom template (override config file)
--overwrite, -w Overwrite existing class
';

public function __construct()
{
parent::__construct();

$this->fs = new CraftsmanFileSystem();

$this->setHelp($this->help);
}

public function handle()
{
$className = $this->argument('name');

$data = [
"name" => $className,
"no-broadcast" => $this->option("no-broadcast"),
"template" => $this->option("template"),
"overwrite" => $this->option("overwrite"),
];

$this->fs->createFile('event', $className, $data);
}
}
58 changes: 58 additions & 0 deletions app/Commands/CraftListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace App\Commands;

use App\CraftsmanFileSystem;
use LaravelZero\Framework\Commands\Command;

/**
* Class CraftClass
* @package App\Commands
*/
class CraftListener extends Command
{
protected $signature = 'craft:listener
{name : Listener name}
{--e|event= : The event class be listener for}
{--queued : Indicates the event listener should be queued}
{--t|template= : Template path (override configuration file)}
{--w|overwrite : Overwrite existing class}
';

protected $description = "Craft Listener Classes";

protected $help = 'Craft Listener
<name> Class Name
--event, -e The event class be listener for
--queued Indicates the event listener should be queued
--template, -t Path to custom template (override config file)
--overwrite, -w Overwrite existing class
';

public function __construct()
{
parent::__construct();

$this->fs = new CraftsmanFileSystem();

$this->setHelp($this->help);
}

public function handle()
{
$className = $this->argument('name');

$data = [
"name" => $className,
"event" => $this->option("event"),
"queued" => $this->option("queued"),
"template" => $this->option("template"),
"overwrite" => $this->option("overwrite"),
];

$data["useEvent"] = strlen($data["event"]) > 0;

$this->fs->createFile('listener', $className, $data);
}
}
Loading

0 comments on commit 8d3939e

Please sign in to comment.