Skip to content

Commit bd48c0b

Browse files
committed
Revert "refactor: add clerk guard to env development"
This reverts commit 0e15e1f.
1 parent 943a830 commit bd48c0b

File tree

3 files changed

+28
-92
lines changed

3 files changed

+28
-92
lines changed

src/Commands/InitCommand.php

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -80,27 +80,19 @@ public function handle(): void
8080
field: 'email of code owner / team lead',
8181
rules: 'required|email',
8282
);
83-
83+
8484
$this->appUrl = $this->ask('Please enter an application URL', "https://api.dev.{$kebabName}.com");
8585

8686
$envFile = (file_exists('.env')) ? '.env' : '.env.example';
8787

88-
$this->createOrUpdateConfigFile(
89-
separator: '=',
90-
data: [
91-
'APP_NAME' => $this->appName,
92-
],
93-
env: $envFile
94-
);
88+
$this->createOrUpdateConfigFile($envFile, '=', [
89+
'APP_NAME' => $this->appName,
90+
]);
9591

96-
$this->createOrUpdateConfigFile(
97-
separator: '=',
98-
data: [
99-
'APP_NAME' => $this->appName,
100-
'APP_URL' => $this->appUrl,
101-
],
102-
envDevelopment: '.env.development'
103-
);
92+
$this->createOrUpdateConfigFile('.env.development', '=', [
93+
'APP_NAME' => $this->appName,
94+
'APP_URL' => $this->appUrl,
95+
]);
10496

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

@@ -113,14 +105,9 @@ public function handle(): void
113105
if ($this->authType === AuthTypeEnum::Clerk) {
114106
$this->enableClerk();
115107

116-
$this->createOrUpdateConfigFile(
117-
separator: '=',
118-
data: [
119-
'AUTH_GUARD' => 'clerk',
120-
],
121-
envDevelopment: '.env.development',
122-
env: $envFile
123-
);
108+
$this->createOrUpdateConfigFile($envFile, '=', [
109+
'AUTH_GUARD' => 'clerk',
110+
]);
124111
}
125112

126113
if ($this->confirm('Do you want to generate an admin user?', true)) {
@@ -207,7 +194,7 @@ public function handle(): void
207194
protected function setAutoDocContactEmail(string $email): void
208195
{
209196
$config = ArrayFile::open(base_path('config/auto-doc.php'));
210-
197+
211198
$config->set('info.contact.email', $email);
212199

213200
$config->write();
@@ -309,9 +296,9 @@ protected function fillContacts(): void
309296

310297
$this->removeTag($filePart, $key);
311298
}
312-
299+
313300
$this->setReadmeValue($filePart, 'team_lead_link', $this->codeOwnerEmail);
314-
301+
315302
$this->updateReadmeFile($filePart);
316303
}
317304

@@ -401,31 +388,29 @@ protected function publishMigration(View $view, string $migrationName): void
401388
file_put_contents("database/migrations/{$migrationName}", "<?php\n\n{$data}");
402389
}
403390

404-
protected function createOrUpdateConfigFile(string $separator, array $data, ...$fileNames): void
391+
protected function createOrUpdateConfigFile(string $fileName, string $separator, array $data): void
405392
{
406-
foreach ($fileNames as $fileName) {
407-
$parsed = file_get_contents($fileName);
393+
$parsed = file_get_contents($fileName);
408394

409-
$lines = explode("\n", $parsed);
395+
$lines = explode("\n", $parsed);
410396

411-
foreach ($data as $key => $value) {
412-
$value = $this->addQuotes($value);
397+
foreach ($data as $key => $value) {
398+
$value = $this->addQuotes($value);
413399

414-
foreach ($lines as &$line) {
415-
if (Str::contains($line, $key)) {
416-
$line = "{$key}{$separator}{$value}";
400+
foreach ($lines as &$line) {
401+
if (Str::contains($line, $key)) {
402+
$line = "{$key}{$separator}{$value}";
417403

418-
continue 2;
419-
}
404+
continue 2;
420405
}
421-
422-
$lines[] = "\n{$key}{$separator}{$value}";
423406
}
424407

425-
$ymlSettings = implode("\n", $lines);
426-
427-
file_put_contents($fileName, $ymlSettings);
408+
$lines[] = "\n{$key}{$separator}{$value}";
428409
}
410+
411+
$ymlSettings = implode("\n", $lines);
412+
413+
file_put_contents($fileName, $ymlSettings);
429414
}
430415

431416
protected function loadReadmePart(string $fileName): string

tests/InitCommandTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,6 @@ public function testRunWithAdminAndDefaultReadmeCreation()
171171
'arguments' => ['config/auth.php'],
172172
'result' => $this->getFixture('auth.php'),
173173
],
174-
[
175-
'arguments' => ['.env.development'],
176-
'result' => $this->getFixture('env.development.yml'),
177-
],
178174
[
179175
'arguments' => ['.env.example'],
180176
'result' => $this->getFixture('env.example.yml'),
@@ -232,10 +228,6 @@ public function testRunWithAdminAndDefaultReadmeCreation()
232228
'database/migrations/2018_11_11_111111_users_add_clerk_id_field.php',
233229
$this->getFixture('users_add_clerk_id_field_migration.php'),
234230
],
235-
[
236-
'.env.development',
237-
$this->getFixture('env.development_clerk_guard_added.yml'),
238-
],
239231
[
240232
'.env.example',
241233
$this->getFixture('env.example_clerk_guard_added.yml'),

tests/fixtures/InitCommandTest/env.development_clerk_guard_added.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)