Skip to content
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

Create install command #4

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Further WIP
  • Loading branch information
bennothommo committed Sep 11, 2020
commit d5a3054827f824e152c5182c9c135c3fb6efa742
70 changes: 50 additions & 20 deletions src/Commands/Install/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$this->getAppSettings($input, $output);
$this->getDbSettings($input, $output);

print_r([
'appName' => $this->appName,
'appUrl' => $this->appUrl,
'dbType' => $this->dbType,
'dbHost' => $this->dbHost,
'dbPort' => $this->dbPort,
'dbName' => $this->dbName,
'dbUser' => $this->dbUser,
'dbPass' => $this->dbPass,
]);
die();
$this->getAdminSettings($input, $output);

// switch ($mode) {
// case 'easy':
Expand All @@ -231,6 +220,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
// $this->doContributorInstall($input, $output, $path);
// break;
// }

print_r([
'appName' => $this->appName,
'appUrl' => $this->appUrl,
'dbType' => $this->dbType,
'dbHost' => $this->dbHost,
'dbPort' => $this->dbPort,
'dbName' => $this->dbName,
'dbUser' => $this->dbUser,
'dbPass' => $this->dbPass,
]);
die();
}

/**
Expand Down Expand Up @@ -318,9 +319,9 @@ protected function getDbSettings(InputInterface $input, OutputInterface $output)

$dbTypes = [
'mysql',
'postgres',
'pgsql',
'sqlite',
'sqlserver'
'sqlsrv'
];

if (is_null($input->getOption('db-type')) || !in_array($input->getOption('db-type'), $dbTypes)) {
Expand All @@ -331,9 +332,9 @@ protected function getDbSettings(InputInterface $input, OutputInterface $output)
'<comment>Please select the database type you wish to use.</comment>' . PHP_EOL . PHP_EOL .
' - <bold>mysql:</bold> (default) MySQL / MariaDB' .
' marketplace.' . PHP_EOL .
' - <bold>postgres:</bold> PostgreSQL.' . PHP_EOL .
' - <bold>pgsql:</bold> PostgreSQL.' . PHP_EOL .
' - <bold>sqlite:</bold> SQLite' . PHP_EOL .
' - <bold>sqlserver:</bold> Microsoft SQL Server' . PHP_EOL,
' - <bold>sqlsrv:</bold> Microsoft SQL Server' . PHP_EOL,
$dbTypes,
'mysql'
);
Expand All @@ -344,13 +345,13 @@ protected function getDbSettings(InputInterface $input, OutputInterface $output)
case 'mysql':
$this->getMysqlSettings($input, $output);
break;
case 'postgres':
case 'pgsql':
$this->getPostgresSettings($input, $output);
break;
case 'sqlite':
$this->getSqliteSettings($input, $output);
break;
case 'sqlserver':
case 'sqlsrv':
$this->getSqlServerSettings($input, $output);
break;
}
Expand Down Expand Up @@ -386,12 +387,41 @@ protected function getPostgresSettings(InputInterface $input, OutputInterface $o
$this->dbName = $input->getOption('db-name') ?? $this->prompt('Database name?', $this->dbName);

// Database username
$this->dbName = $input->getOption('db-user') ?? $this->prompt('PostgreSQL username?', $this->dbName);
$this->dbUser = $input->getOption('db-user') ?? $this->prompt('PostgreSQL username?', $this->dbUser);

// Database password
$this->dbName = $input->getOption('db-pass') ?? $this->prompt('PostgreSQL password?', $this->dbName, true);
$this->dbPass = $input->getOption('db-pass') ?? $this->prompt('PostgreSQL password?', $this->dbPass, true);
}

protected function getSqliteSettings(InputInterface $input, OutputInterface $output)
{
// Database path
$this->dbName = $input->getOption('db-name') ?? $this->prompt(
'SQLite database path?',
'storage/database.sqlite',
);
}

protected function getSqlServerSettings(InputInterface $input, OutputInterface $output)
{
// Database host
$this->dbHost = $input->getOption('db-host') ?? $this->prompt(
'SQL Server host address?',
'192.168.0.1\\SQLEXPRESS'
);

// Database port
$this->dbPort = $input->getOption('db-port') ?? $this->promptInt('SQL Server port', 1433);

// Database name
$this->dbName = $input->getOption('db-name') ?? $this->prompt('Database name?', $this->dbName);

// Database username
$this->dbUser = $input->getOption('db-user') ?? $this->prompt('SQL Server username?', $this->dbUser);

// Database password
$this->dbPass = $input->getOption('db-pass') ?? $this->prompt('SQL Server password?', $this->dbPass, true);
}

protected function runCommand(InputInterface $input, OutputInterface $output, string $command): Process
{
Expand Down