Skip to content

Commit

Permalink
0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
esokullu committed Apr 25, 2020
1 parent 55d70ae commit 1f5a2f6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
New design
Less functions
Build: also generates kernel and REST server
Init: will generate a folder structure
Init: will generate a folder structure


## 0.2 to 0.3
Can now init custom projects
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.3.0
38 changes: 28 additions & 10 deletions src/Pho/Cli/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
$this->app_name = $this->io->ask('App Name (no dashes or spaces)');
$this->app_name = $this->io->ask('App Name (no dashes or spaces)', null, function ($response) {
if (empty($response)) {
throw new \RuntimeException('App Name cannot be empty.');
}

return $response;
});
//error_log($this->app_name);
$desc = $this->io->ask('Describe the app in a short sentence');
$type = $this->io->choice('App Template', ['blank', 'basic', 'graphjs', 'twitter-simple', 'twitter-full', 'facebook', 'custom']);

$root = dirname(dirname(dirname(__DIR__)));

$source = $this->getSkeletonDir();

Expand Down Expand Up @@ -106,6 +110,7 @@ protected function createEnvFile(string $source, string $destination): void
*/
protected function getSkeletonDir(): string
{
$root = dirname(dirname(dirname(__DIR__)));
$phar = \Phar::running();
if(empty($phar))
return $root . DIRECTORY_SEPARATOR . "data" . DIRECTORY_SEPARATOR . "skeleton";
Expand Down Expand Up @@ -133,8 +138,20 @@ protected function setEnvFileParams(string $type, string $destination): void
{
$env_file = $destination . DIRECTORY_SEPARATOR . ".env";
$contents = file_get_contents($env_file);
$username = $this->io->ask('Founder Username', "admin");
$password = $this->io->ask('Founder Password');
$username = $this->io->ask('Founder Username', "admin", function ($response) {
if (empty($response)) {
throw new \RuntimeException('Username cannot be empty.');
}

return $response;
});
$password = $this->io->askHidden('Founder Password', function ($response) {
if (empty($response)) {
throw new \RuntimeException('Password cannot be empty.');
}

return $response;
});
$email = "";
$params = "{$username}::{$password}";
$graph_class = "";
Expand All @@ -159,9 +176,9 @@ protected function setEnvFileParams(string $type, string $destination): void
case "custom":
$email = $this->io->ask('Founder Email');
$contents = $this->dot_phocli;
$contents = str_replace("{username}", $username);
$contents = str_replace("{password}", $password);
$contents = str_replace("{email}", $email);
$contents = str_replace("{username}", $username, $contents);
$contents = str_replace("{password}", $password, $contents);
$contents = str_replace("{email}", $email, $contents);
file_put_contents($env_file, "\n\n".$contents, LOCK_EX|FILE_APPEND);
return; // DO NOT CONTINUE
}
Expand Down Expand Up @@ -208,7 +225,8 @@ protected function downloadRecipe(string $type): void
break;
case "custom":
$tarball = $this->io->ask('Custom Project\'s Path or Github URL');
if(preg_match('/^https\:\/\/github\.com\/[^/]+\/[^/]+\/archive\/master\.zip', $tarball)) {
if(preg_match('/^https\:\/\/github\.com\/[^\/]+\/[^\/]+/', $tarball)) {
$tarball .= "/archive/master.zip";
$this->downloadAndExtract($tarball);
}
elseif(file_exists($tarball)) {
Expand Down Expand Up @@ -300,7 +318,7 @@ protected function downloadAndExtract(string $urlToDownload): void
// Download file to our app
file_put_contents($fileDestination, fopen($urlToDownload, 'r'));


$this->extract($fileDestination);

}

Expand Down

0 comments on commit 1f5a2f6

Please sign in to comment.