Skip to content

Commit bc7cef4

Browse files
authored
Merge pull request #68 from RonasIT/configure-env-development-fields-initialization
feat: configure new fields in env.development on initialization process
2 parents 64f6afe + 2b340dc commit bc7cef4

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

src/Commands/InitCommand.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ public function handle(): void
102102

103103
$envFile = (file_exists('.env')) ? '.env' : '.env.example';
104104

105-
$this->updateEnvFile($envFile, [
105+
$envConfig = [
106106
'APP_NAME' => $this->appName,
107107
'DB_CONNECTION' => $this->dbConnection,
108108
'DB_HOST' => $this->dbHost,
109109
'DB_PORT' => $this->dbPort,
110110
'DB_DATABASE' => $this->dbName,
111111
'DB_USERNAME' => $this->dbUserName,
112112
'DB_PASSWORD' => '',
113-
]);
113+
];
114+
115+
$this->updateEnvFile($envFile, $envConfig);
114116

115117
if (!file_exists('.env.development')) {
116118
copy('.env.example', '.env.development');
@@ -124,6 +126,11 @@ public function handle(): void
124126
'QUEUE_CONNECTION' => 'redis',
125127
'SESSION_DRIVER' => 'redis',
126128
'DB_CONNECTION' => $this->dbConnection,
129+
'DB_HOST' => '',
130+
'DB_PORT' => '',
131+
'DB_DATABASE' => '',
132+
'DB_USERNAME' => '',
133+
'DB_PASSWORD' => '',
127134
]);
128135

129136
$this->info('Project initialized successfully!');

tests/InitCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ public function testRunWithAdminAndDefaultReadmeCreation()
210210
'\Winter\LaravelConfigWriter',
211211
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
212212
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
213-
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_clerk_credentials_added.yml'),
214-
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_clerk_credentials_added.yml'),
213+
$this->changeEnvFileCall('.env.development', 'env.development_app_name_not_pascal_case.yml', 'env.development_clerk_credentials_added.yml'),
214+
$this->changeEnvFileCall('.env.example', 'env.example_app_name_not_pascal_case.yml', 'env.example_clerk_credentials_added.yml'),
215215
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
216216
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
217217
);
@@ -698,8 +698,8 @@ public function testRunWithClerkMobileAppWithPintInstalled(): void
698698
'\Winter\LaravelConfigWriter',
699699
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_app_name_not_pascal_case.yml'),
700700
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_app_name_not_pascal_case.yml'),
701-
$this->changeEnvFileCall('.env.development', 'env.development.yml', 'env.development_clerk_credentials_added_mobile_app.yml'),
702-
$this->changeEnvFileCall('.env.example', 'env.example.yml', 'env.example_clerk_credentials_added_mobile_app.yml'),
701+
$this->changeEnvFileCall('.env.development', 'env.development_app_name_not_pascal_case.yml', 'env.development_clerk_credentials_added_mobile_app.yml'),
702+
$this->changeEnvFileCall('.env.example', 'env.example_app_name_not_pascal_case.yml', 'env.example_clerk_credentials_added_mobile_app.yml'),
703703
$this->callFilePutContent(base_path('config/telescope.php'), $this->getFixture('telescope_config_after_initialization.php')),
704704
$this->callFilePutContent(base_path('config/auto-doc.php'), $this->getFixture('auto_doc_after_changes.php')),
705705
);

tests/fixtures/InitCommandTest/env.development.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ APP_DEBUG=true
55
APP_LOG_LEVEL=debug
66
APP_URL=https://mysite.com
77

8-
DB_CONNECTION=pgsql
9-
DB_HOST=
10-
DB_PORT=
11-
DB_DATABASE=
12-
DB_USERNAME=
13-
DB_PASSWORD=
8+
DB_CONNECTION=mysql
9+
DB_HOST=127.0.0.1
10+
DB_PORT=3306
11+
DB_DATABASE=my_database
12+
DB_USERNAME=my_user
13+
DB_PASSWORD=my_secret_password
1414

1515
BROADCAST_DRIVER=log
1616
CACHE_DRIVER=file

tests/fixtures/InitCommandTest/env.development_clerk_credentials_added.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ FRONTEND_URL=
3838

3939
JWT_SHOW_BLACKLIST_EXCEPTION=true
4040

41+
APP_MAINTENANCE_DRIVER="cache"
42+
CACHE_STORE="redis"
43+
4144
AUTH_GUARD="clerk"
4245
CLERK_ALLOWED_ISSUER=""
4346
CLERK_SECRET_KEY=""

tests/fixtures/InitCommandTest/env.development_clerk_credentials_added_mobile_app.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ FRONTEND_URL=
3838

3939
JWT_SHOW_BLACKLIST_EXCEPTION=true
4040

41+
APP_MAINTENANCE_DRIVER="cache"
42+
CACHE_STORE="redis"
43+
4144
AUTH_GUARD="clerk"
4245
CLERK_ALLOWED_ISSUER=""
4346
CLERK_SECRET_KEY=""

0 commit comments

Comments
 (0)