Skip to content

Commit c3f046d

Browse files
author
Jad Joubran
committed
basic artisan ng:feature generator to create a new angular feature
1 parent 3dbfc83 commit c3f046d

File tree

7 files changed

+65
-3
lines changed

7 files changed

+65
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### v2.6.1
44
+ updated bower dependencies (angular material released 0.10.1)
5-
5+
+ added artisan generator for a new feature: **artisan ng:feature**
66

77
### v2.6.0
88
+ Update to [elixir 3.0](https://github.com/jadjoubran/laravel5-angular-material-starter/issues/20)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
7+
class AngularFeature extends Command{
8+
9+
/**
10+
* The name and signature of the console command.
11+
* @var string
12+
*/
13+
protected $signature = 'ng:feature {name}';
14+
15+
/**
16+
* The console command description.
17+
* @var string
18+
*/
19+
protected $description = 'Create a new feature folder with sample HTML, CSS & LESS inside the angular/app folder.';
20+
21+
/**
22+
* Create a new command instance.
23+
* @return void
24+
*/
25+
public function __construct(){
26+
parent::__construct();
27+
}
28+
29+
/**
30+
* Execute the console command.
31+
* @return mixed
32+
*/
33+
public function handle(){
34+
$name = $this->argument('name');
35+
36+
$html = file_get_contents(__DIR__ . '/Stubs/AngularFeature/feature.html.stub');
37+
$js = file_get_contents(__DIR__ . '/Stubs/AngularFeature/feature.js.stub');
38+
$less = file_get_contents(__DIR__ . '/Stubs/AngularFeature/feature.less.stub');
39+
40+
$folder = __DIR__ . '/../../../angular/app/' . $name;
41+
if (is_dir($folder)){
42+
$this->info('Folder already exists');
43+
44+
return false;
45+
}
46+
47+
//create folder
48+
\File::makeDirectory($folder, 0775, true);
49+
50+
//create view (.html)
51+
\File::put($folder . '/' . $name . '.html', $html);
52+
53+
//create controller (.js)
54+
\File::put($folder . '/' . $name . '.js', $js);
55+
56+
//create less file (.less)
57+
\File::put($folder . '/' . $name . '.less', $less);
58+
}
59+
}

app/Console/Commands/Stubs/AngularFeature/feature.html.stub

Whitespace-only changes.

app/Console/Commands/Stubs/AngularFeature/feature.js.stub

Whitespace-only changes.

app/Console/Commands/Stubs/AngularFeature/feature.less.stub

Whitespace-only changes.

app/Console/Kernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Kernel extends ConsoleKernel
1414
*/
1515
protected $commands = [
1616
'App\Console\Commands\Inspire',
17+
'App\Console\Commands\AngularFeature',
1718
];
1819

1920
/**

readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ Open a new issue, I'd love to help.
5353
<a name="planned_features"></a>
5454
## Planned features
5555

56-
- artisan generators
56+
- artisan generator
57+
- improve artisan generator (default controller, default classes, etc..) + update documentation
58+
- dialog artisan generators
5759
- Migrate to open source hosting
58-
- New demo pages: Toasts, Dialogs, Unsupported Browser, Elixir, Rest API, loading bar, debugbar, filters, JWT
60+
- New demo pages: Toasts, Dialogs, Unsupported Browser, generators, Elixir, Rest API, loading bar, debugbar, filters, JWT
5961
- make gulp --production part of the automated release
6062
- make readme more appealing
6163
- jwt auth example (with seed) + route authentication

0 commit comments

Comments
 (0)