mirror of
https://github.com/bitinflow/bunny-cli.git
synced 2026-03-13 13:45:54 +00:00
Change env storage
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Commands\Env;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
|
||||
class EnvBackupCommand extends Command
|
||||
@@ -28,10 +29,9 @@ class EnvBackupCommand extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$envFilePath = App::environmentFilePath();
|
||||
$this->info(sprintf("The following environment file is used: '%s'", $envFilePath));
|
||||
$this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath()));
|
||||
|
||||
file_put_contents($this->argument('file'), file_get_contents($envFilePath));
|
||||
Storage::put($this->argument('file'), Storage::get('.env'));
|
||||
|
||||
$this->info('The environment file was successfully backed up.');
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Commands\Env;
|
||||
|
||||
use Dotenv\Dotenv;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
|
||||
class EnvListCommand extends Command
|
||||
@@ -29,18 +30,17 @@ class EnvListCommand extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$envFilePath = App::environmentFilePath();
|
||||
$this->info(sprintf("The following environment file is used: '%s'", $envFilePath));
|
||||
$this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath()));
|
||||
|
||||
if (file_exists($envFilePath)) {
|
||||
$env = Dotenv::parse(file_get_contents($envFilePath));
|
||||
if (Storage::exists('.env')) {
|
||||
$env = Dotenv::parse(Storage::get('.env'));
|
||||
} else {
|
||||
$this->warn('The environment file does not exist.');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(empty($env)) {
|
||||
if (empty($env)) {
|
||||
$this->warn('The environment file is empty.');
|
||||
|
||||
return 2;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Commands\Env;
|
||||
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
|
||||
class EnvRestoreCommand extends Command
|
||||
@@ -28,10 +29,9 @@ class EnvRestoreCommand extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$envFilePath = App::environmentFilePath();
|
||||
$this->info(sprintf("The following environment file is used: '%s'", $envFilePath));
|
||||
$this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath()));
|
||||
|
||||
file_put_contents($envFilePath, file_get_contents($this->argument('file')));
|
||||
Storage::put('.env', Storage::get($this->argument('file')));
|
||||
|
||||
$this->info('The environment file was successfully restored.');
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Commands\Env;
|
||||
|
||||
use Dotenv\Dotenv;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
|
||||
class EnvSetCommand extends Command
|
||||
@@ -31,11 +32,10 @@ class EnvSetCommand extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$envFilePath = App::environmentFilePath();
|
||||
$this->info(sprintf("The following environment file is used: '%s'", $envFilePath));
|
||||
$this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath()));
|
||||
|
||||
if (file_exists($envFilePath)) {
|
||||
$env = Dotenv::parse(file_get_contents($envFilePath));
|
||||
if (Storage::exists('.env')) {
|
||||
$env = Dotenv::parse(Storage::get('.env'));
|
||||
} else {
|
||||
$this->warn('The environment file does not exist. Creating a new one...');
|
||||
$env = [];
|
||||
@@ -43,7 +43,7 @@ class EnvSetCommand extends Command
|
||||
|
||||
$env[strtoupper($this->argument('key'))] = $this->argument('value');
|
||||
|
||||
file_put_contents($envFilePath, self::updateEnv($env));
|
||||
Storage::put('.env', self::updateEnv($env));
|
||||
|
||||
$this->info('The environment file was successfully updated.');
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Commands\Env\EnvSetCommand;
|
||||
use Dotenv\Dotenv;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use LaravelZero\Framework\Commands\Command;
|
||||
|
||||
class InitCommand extends Command
|
||||
@@ -36,11 +37,10 @@ class InitCommand extends Command
|
||||
*/
|
||||
public function handle(Client $client): int
|
||||
{
|
||||
$envFilePath = App::environmentFilePath();
|
||||
$this->info(sprintf("The following environment file is used: '%s'", $envFilePath));
|
||||
$this->info(sprintf("The following environment file is used: '%s'", App::environmentFilePath()));
|
||||
|
||||
if (file_exists($envFilePath)) {
|
||||
$env = Dotenv::parse(file_get_contents($envFilePath));
|
||||
if (Storage::exists('.env')) {
|
||||
$env = Dotenv::parse(Storage::get('.env'));
|
||||
} else {
|
||||
$this->warn('The environment file does not exist. Creating a new one...');
|
||||
$env = [];
|
||||
@@ -102,7 +102,7 @@ class InitCommand extends Command
|
||||
$this->warn('No pull zone was specified, therefore no pull zone is flushed during deployment.');
|
||||
}
|
||||
|
||||
file_put_contents($envFilePath, EnvSetCommand::updateEnv($env));
|
||||
Storage::put('.env', EnvSetCommand::updateEnv($env));
|
||||
|
||||
$this->info('The environment file was successfully updated.');
|
||||
|
||||
|
||||
@@ -16,9 +16,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Storage::extend('ftp', function ($app, $config) {
|
||||
return new Filesystem(new FtpAdapter($config));
|
||||
});
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,21 @@ $app = new LaravelZero\Framework\Application(
|
||||
dirname(__DIR__)
|
||||
);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Set the correct path for the environment file
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If the current directory has a .env file then we will use that instead
|
||||
| of the global one, otherwise the one under the user homepage.
|
||||
|
|
||||
*/
|
||||
|
||||
if (!file_exists(dirname(__DIR__) . DIRECTORY_SEPARATOR . '.env')) {
|
||||
$app->useEnvironmentPath(getenv('HOME') . DIRECTORY_SEPARATOR . '.bunny-cli');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Bind Important Interfaces
|
||||
|
||||
BIN
builds/bunny
BIN
builds/bunny
Binary file not shown.
11
config/filesystems.php
Normal file
11
config/filesystems.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'default' => 'local',
|
||||
'disks' => [
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => getenv('HOME') . DIRECTORY_SEPARATOR . '.bunny-cli',
|
||||
],
|
||||
],
|
||||
];
|
||||
Reference in New Issue
Block a user