Skip to content

Commit

Permalink
Removed some commands
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthaksavvy committed Oct 9, 2018
1 parent 8e232f4 commit e68f060
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 38 deletions.
22 changes: 5 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Laravel Packer was created by, and is maintained by [Sarthak Shrivastava](https:
Install via composer.

```bash
composer global require bitfumes/laravel-packer dev-master --prefer-dist
composer global require bitfumes/laravel-packer --prefer-dist
```

## Creating new Package Scaffolding
Expand All @@ -30,26 +30,12 @@ composer global require bitfumes/laravel-packer dev-master --prefer-dist
packer new your-package-name {vendor} {author} {author_email}
```

![new](https://user-images.githubusercontent.com/41295276/46673797-38331580-cbf8-11e8-88e6-5d6b0dc18b93.gif)

With the above command it will create package scaffoldig for you.

Optional fields like 'vendor', 'author' and 'author_email' can also be given via command line interface if you are not willing to provide on command.

## Set default values

Another great feature is that you can set your default values for 'Vendor', 'author and 'author_email'

```bash
packer set:user author_name
```

```bash
packar set:vendor vendor_name
```

```bash
packar set:email author_name
```

## Same as Artisan commands

With this CLI, you will have access to all artisan commands you are familier on Laravel.
Expand All @@ -60,4 +46,6 @@ You can create controller just like you do with `php artisan`
packer make:controller controller_name
```

![make](https://user-images.githubusercontent.com/41295276/46673800-38cbac00-cbf8-11e8-9a1b-c02e91da8563.gif)

Explore all commands, just run `packer` on your command line.
14 changes: 6 additions & 8 deletions app/Commands/Package/email.php → app/Commands/Author.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?php

namespace App\Commands\Package;
namespace App\Commands;

use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;

class Email extends Command
class Author extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'set:email {value}';
protected $signature = 'set:author {value}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'It can set package author email on packer config';
protected $description = 'It can set package author name on Packer config';

/**
* Execute the console command.
Expand All @@ -29,11 +29,9 @@ class Email extends Command
public function handle()
{
$app_config = file_get_contents(config_path('package.php'));
$last_section = '];';

$to_replace = '"email" => "' . $this->argument('value') . '",
];';
$content = str_replace($last_section, $to_replace, $app_config);
$to_replace = "'author' =>'" . $this->argument('value') . "',";
$content = preg_replace('/\'author\'.+\=\>.+,/', $to_replace, $app_config);

file_put_contents(config_path('package.php'), $content);
}
Expand Down
60 changes: 60 additions & 0 deletions app/Commands/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App\Commands;

use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;

class Config extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'check:config';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'Gives you information (if) you have saved for packer.';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if (config('package.author')) {
$this->info('Your have set author name as: ' . config('package.author'));
} else {
$this->error('No value author name, try to use packer set:author {author_name}');
}

if (config('package.email')) {
$this->info('Your have set author email as: ' . config('package.email'));
} else {
$this->error('No value author email, try to use packer set:email {email_address}');
}

if (config('package.vendor')) {
$this->info('Your have set vendor name as: ' . config('package.vendor'));
} else {
$this->error('No value vendor name, try to use packer set:vendor {vendor_name}');
}
}

/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule): void
{
// $schedule->command(static::class)->everyMinute();
}
}
14 changes: 6 additions & 8 deletions app/Commands/Package/user.php → app/Commands/Email.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php

namespace App\Commands\Package;
namespace App\Commands;

use LaravelZero\Framework\Commands\Command;

class User extends Command
class Email extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'set:user {value}';
protected $signature = 'set:email {value}';

/**
* The description of the command.
*
* @var string
*/
protected $description = 'It can set package author name on Packer config';
protected $description = 'It can set package author email on packer config';

/**
* Execute the console command.
Expand All @@ -28,11 +28,9 @@ class User extends Command
public function handle()
{
$app_config = file_get_contents(config_path('package.php'));
$last_section = '];';

$to_replace = '"user" => "' . $this->argument('value') . '",
];';
$content = str_replace($last_section, $to_replace, $app_config);
$to_replace = "'email' => '" . $this->argument('value') . "',";
$content = preg_replace('/\'email\'.+\=\>.+,?/', $to_replace, $app_config);

file_put_contents(config_path('package.php'), $content);
}
Expand Down
20 changes: 15 additions & 5 deletions app/Commands/Package/vendor.php → app/Commands/Vendor.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace App\Commands\Package;
namespace App\Commands;

use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;

class Vendor extends Command
Expand All @@ -28,12 +29,21 @@ class Vendor extends Command
public function handle()
{
$app_config = file_get_contents(config_path('package.php'));
$last_section = '];';

$to_replace = '"vendor" => "' . $this->argument('value') . '",
];';
$content = str_replace($last_section, $to_replace, $app_config);
$to_replace = "'vendor' => '" . $this->argument('value') . "',";
$content = preg_replace('/\'vendor\'.+\=\>.+,/', $to_replace, $app_config);

file_put_contents(config_path('package.php'), $content);
}

/**
* Define the command's schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
public function schedule(Schedule $schedule): void
{
// $schedule->command(static::class)->everyMinute();
}
}
Binary file modified builds/packer
Binary file not shown.
Binary file modified builds/packer.phar
Binary file not shown.
5 changes: 5 additions & 0 deletions config/commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
App\Commands\TestDir\FeatureTest::class,
App\Commands\TestDir\Testcase::class,
App\Commands\TestDir\UnitTest::class,

App\Commands\Author::class,
App\Commands\Email::class,
App\Commands\Vendor::class,
App\Commands\Config::class,
],

/*
Expand Down
3 changes: 3 additions & 0 deletions config/package.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

return [
'author' => null,
'vendor' => null,
'email' => null,
];

0 comments on commit e68f060

Please sign in to comment.