Commit c77e1c6d authored by ntdinh1987's avatar ntdinh1987

add database

parent 9a4bba2f
......@@ -94,16 +94,31 @@ class NewCommand extends Command
$this->moveAllFile($directory . '/app/app.git/', $directory . '/app/');
$this->rrmdir($directory . '/app/app.git/');
/**
* Download Database
*/
$output->writeln('<info>Download database...</info>');
//Download app
$this->downloadDatabase($zipFile = $this->makeFilename())
->extract($zipFile, $directory . '/database')
->cleanUp($zipFile);
$this->moveAllFile($directory . '/database/database.git/', $directory . '/database/');
$this->rrmdir($directory . '/database/database.git/');
}
$composer = $this->findComposer();
$database_composer = $this->findComposer('database');
$commands = [
$composer . ' install --no-scripts',
$composer . ' run-script post-root-package-install',
//$composer . ' run-script post-install-cmd',
//$composer . ' run-script post-create-project-cmd',
//Database
$database_composer . ' install --no-scripts',
];
if ($input->getOption('no-ansi')) {
......@@ -178,6 +193,21 @@ class NewCommand extends Command
return $this;
}
/**
* Download the temporary Zip to the given file.
*
* @param string $zipFile
* @param string $version
* @return $this
*/
protected function downloadDatabase($zipFile)
{
$response = (new Client)->get('http://gitlab.hoidap.vn/vnp-framework/database/repository/archive.zip?ref=master');
file_put_contents($zipFile, $response->getBody());
return $this;
}
/**
* Extract the Zip file into the given directory.
*
......@@ -287,9 +317,9 @@ class NewCommand extends Command
*
* @return string
*/
protected function findComposer()
protected function findComposer($dir = null)
{
if (file_exists(getcwd() . '/composer.phar')) {
if (file_exists(getcwd() . ($dir ? ('/' . $dir) : '') . '/composer.phar')) {
return '"' . PHP_BINARY . '" composer.phar';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment