Skip to content

Commit

Permalink
chore: build 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeerickson committed Apr 18, 2019
1 parent 94c568d commit 16d2b75
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ 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.1.0] - 2019-04-17

### Added

- Added new `template` option which allows passing a one off template to be used instead of using either default templates, or user defined templates in constants.

## [1.0.10] - 2019-04-06

### Added
Expand Down
66 changes: 63 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ laravel-craftsman craft:all Contact \
| | --no-views, -e | Do not create seed |
| **craft:class** | **class name** | **Creates empty class** |
| | --constructor, -c | Include constructor method |
| | --template, -t | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:controller** | **controller name** | **Create controller using supplied options** |
| | --model, -m | Path to model (eg App/Models/Post) |
| | --validation, -l | Create validation blocks where appropriate |
| | --api, -a | Create API controller (skips create and update methods) |
| | --empty, -e | Create empty controller |
| | --template, -t | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:factory** | **factory name** | **Creates factory using supplied options** |
| | --model, -m | Path to model (eg App/Models/Post) |
| **craft:migration** | **migration name** | **Creates migration using supplied options** |
Expand All @@ -101,12 +105,19 @@ laravel-craftsman craft:all Contact \
| | | _If not supplied, default table will be pluralized model name_ |
| | --fields, -f | List of fields (option) _see syntax below_ |
| | --down, -d | Include down methods (skipped by default) |
| | --template, -t | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:model** | **model name** | **Creates model using supplied options** |
| | | _See below about defining alternate model path_ |
| | --tablename, -t | Tablename used in database (will set $tablename in Model) |
| | | _If not supplied, default table will be pluralized model name_ |
| | --template, -m | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:seed** | **base seed name** | **Creates seed file using supplied options** |
| | --model, -m | Path to model (eg App/Models/Post) |
| | --rows, -r | Number of rows to use in factory call (Optional) |
| | --template, -t | Path to custom template (override config file) |
| | --overwrite, -w | Overwrite existing class |
| **craft:views** | **base resource** | **Creates view files** |
| | --extends, -x | Includes extends block using supplied layout |
| | --section, -s | Includes section block using supplied name |
Expand All @@ -115,6 +126,33 @@ laravel-craftsman craft:all Contact \
| | --no-index, -i | Exclude index view |
| | --no-show, -w | Exclude show view |

#### Defining Class Path

When crafting resources which are not automatically created in their assigned directories, you can define the location to the path where asset is created as follows:

```bash
> laravel-craftsman craft:class App/Services/Sync ...
```

This will create a class in the `App/Services` path, with filename `Sync.php`. Directories (including nested directories) will be created if they do not already exists.

##### Supported Commands:
The following commands support defining class path

- craft:class
- craft:factory
- craft:model
- craft:seed
- craft:test

#### Single Use Template

In addition to the standard templates, you may also define a single use template which is only used during command execution. Single use templates are designed to reference project specific templates, and you use the `<projet>` keyword when executing the desire command.

```bash
> laravel-craftsman craft:class App/Services/SyncService --template <project>/templates/service.mustache ...
```

#### Field Option Syntax
When using the `--fields` option when building migrations, you should use the following syntax:

Expand All @@ -140,6 +178,8 @@ email:string@80:nullable:unique
```

## Tips

### Boolean Option Shortcut
When executing any of the `laravel-craftsman` commands, if you wish to apply one or more switches (those options which do not require a corresponding value), you can use the standard CLI shorthands (this tip can be used in any CLI based tool, not just `laravel-craftsman` (well assuming the CLI actually supports shorthand).

For example:
Expand All @@ -148,20 +188,28 @@ Lets assume you wish to wish to create `views`, you can use the following comman

```bash
> laravel-craftsman craft:views --extends layouts.app --section content -cdw
```

is same as

```bash
> laravel-craftsman craft:views --extends layouts.app --section content --no-create --no-edit --no-show
or

> laravel-craftsman craft:views --extends layouts.app --section content -c -d -w
```

### Defining Nested Paths
Any command can store assets within tested folders within default path by separating `name` argument with forward slash
For example, the following command will define the path for model asset in the `App/Models/<name>` path

```bash
> laravel-craftsman App/Models/Customer ...
```

## Custom Templates
Laravel Craftsman provides support for creating custom templates if you wish to change the syntax to match your personal style. The default templates use the standard Laravel syntax, but we like to allow ou have your own flair.

### Customizing Templates
### User Customized Templates
If you wish to create derivatives of the supported templates, you can customize the `config.php` located in the `laravel-craftsman` directory.
By default, this will be `~/.composer/vendor/codedungeon/laravel-craftsman`, but may be different depending on the method you chose to install laravel-craftsman.

Expand All @@ -182,7 +230,19 @@ By default, this will be `~/.composer/vendor/codedungeon/laravel-craftsman`, but
],
```

### List of available variables
### Single Use Template

In addition to creating templates and configuring the `config.php` file, you may optionally supply a template to be used as single use (not stored) from all command execution
For example, if you wish to create a standard class asset, you can use a single use template as follows:

```bash

> laravel-craftsman craft:class App/Services/Syncronize --template <project>/templates/service.mustache`
```
### Template Variables
The following variables can be used in any of the supported templates (review the `templates` directory for a basis of how to create custom templates)

| Variable Name | Templates which variable is used |
Expand Down
Binary file modified builds/laravel-craftsman
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "laravel-craftsman",
"version": "1.1.1",
"build": "128",
"build": "129",
"description": "Laravel Craftsman",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 16d2b75

Please sign in to comment.