Skip to content

Commit

Permalink
feature #16 Autofill the.env file with the "composer --no-interaction…
Browse files Browse the repository at this point in the history
…" command (roukmoute)

This PR was merged into the master branch.

Discussion
----------

Autofill the.env file with the "composer --no-interaction" command

Currently, our production is runned without a .env.
All is in the current environment variables.

So in production mode, we do not want to run want to answer to questions, just copy it.

This is an example of the result:
```bash
▶ composer install --no-interaction
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update

> Companienv\Composer\ScriptHandler::run
It looks like you are missing some configuration (46 variables). I will help you to sort this out.
Automatically confirmed in non-interactive mode

> MySQL

Automatically returned "mysql" in non-interactive mode
Automatically returned "my_database" in non-interactive mode
Automatically returned "root" in non-interactive mode

> Mailer

Automatically returned "mailhog" in non-interactive mode
Automatically returned "1025" in non-interactive mode
Automatically returned "" in non-interactive mode
Automatically returned "" in non-interactive mode

> RabbitMQ

Automatically returned "rabbitmq" in non-interactive mode
Automatically returned "5672" in non-interactive mode
Automatically returned "guest" in non-interactive mode
Automatically returned "guest" in non-interactive mode
Automatically returned "/" in non-interactive mode

> JWT

Automatically returned "foobar" in non-interactive mode

> Google API key

Automatically returned "MyGoogleAPIKey" in non-interactive mode
…
```

Commits
-------

c5b41cb It copies automatically values with composer --no-interaction
  • Loading branch information
sroze committed Jul 19, 2018
2 parents d82a758 + c5b41cb commit 1d122bb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Companienv/Composer/InteractionViaComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ public function __construct(IOInterface $io)

public function askConfirmation(string $question): bool
{
if (!$this->io->isInteractive()) {
$this->writeln('Automatically confirmed in non-interactive mode');

return true;
}

return $this->io->askConfirmation($question);
}

public function ask(string $question, string $default = null): string
{
if (!$this->io->isInteractive()) {
$this->writeln(sprintf('Automatically returned "%s" in non-interactive mode', $default));

return $default;
}

return $this->io->ask($question, $default);
}

Expand Down

0 comments on commit 1d122bb

Please sign in to comment.