New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non interactive koel:init #886
Changes from 3 commits
6866663
5ee2009
3ea4bc7
5b9c034
cca03c5
397b8ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,10 @@ public function handle(): void | |
$this->comment('Remember, you can always install/upgrade manually following the guide here:'); | ||
$this->info('📙 '.config('koel.misc.docs_url').PHP_EOL); | ||
|
||
if ($this->inNoInteractionMode()) { | ||
$this->info('Running in --no-interaction mode'); | ||
} | ||
|
||
$this->maybeGenerateAppKey(); | ||
$this->maybeGenerateJwtSecret(); | ||
$this->maybeSetUpDatabase(); | ||
|
@@ -121,22 +125,33 @@ private function setUpDatabase(): void | |
]); | ||
} | ||
|
||
private function inNoInteractionMode(): bool | ||
{ | ||
return (bool) $this->option('no-interaction'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's |
||
} | ||
|
||
private function setUpAdminAccount(): void | ||
{ | ||
$this->info("Let's create the admin account."); | ||
$name = $this->ask('Your name'); | ||
$email = $this->ask('Your email address'); | ||
$passwordConfirmed = false; | ||
$password = null; | ||
|
||
while (!$passwordConfirmed) { | ||
$password = $this->secret('Your desired password'); | ||
$confirmation = $this->secret('Again, just to make sure'); | ||
|
||
if ($confirmation !== $password) { | ||
$this->error('That doesn\'t match. Let\'s try again.'); | ||
} else { | ||
$passwordConfirmed = true; | ||
if ($this->inNoInteractionMode()) { | ||
$name = config('koel.admin.name'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't align variable assignments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, undoing in next commit |
||
$email = config('koel.admin.email'); | ||
$password = config('koel.admin.password'); | ||
} else { | ||
$name = $this->ask('Your name'); | ||
$email = $this->ask('Your email address'); | ||
$passwordConfirmed = false; | ||
$password = null; | ||
|
||
while (!$passwordConfirmed) { | ||
$password = $this->secret('Your desired password'); | ||
$confirmation = $this->secret('Again, just to make sure'); | ||
|
||
if ($confirmation !== $password) { | ||
$this->error('That doesn\'t match. Let\'s try again.'); | ||
} else { | ||
$passwordConfirmed = true; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -154,22 +169,34 @@ private function maybeSetMediaPath(): void | |
return; | ||
} | ||
|
||
$this->info('The absolute path to your media directory. If this is skipped (left blank) now, you can set it later via the web interface.'); | ||
|
||
while (true) { | ||
$path = $this->ask('Media path', false); | ||
|
||
if ($path === false) { | ||
return; | ||
} | ||
if ($this->inNoInteractionMode()) { | ||
$path = config('koel.media_path'); | ||
|
||
if (is_dir($path) && is_readable($path)) { | ||
Setting::set('media_path', $path); | ||
|
||
return; | ||
} | ||
|
||
$this->error('The path does not exist or not readable. Try again.'); | ||
$this->error('The path '.$path.' does not exist or not readable. Skipping.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can return early here :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just added a |
||
|
||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, you don't need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I finally saw why it didn't required an |
||
|
||
$this->info('The absolute path to your media directory. If this is skipped (left blank) now, you can set it later via the web interface.'); | ||
|
||
while (true) { | ||
$path = $this->ask('Media path', false); | ||
|
||
if ($path === false) { | ||
return; | ||
} | ||
|
||
if (is_dir($path) && is_readable($path)) { | ||
Setting::set('media_path', $path); | ||
return; | ||
} | ||
|
||
$this->error('The path does not exist or not readable. Try again.'); | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
Running in no-interaction mode
(without the double hyphen)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, modifying in next commit