-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/laravel/vapor-cli
- Loading branch information
Showing
10 changed files
with
249 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
namespace Laravel\VaporCli\Commands; | ||
|
||
use Laravel\VaporCli\Helpers; | ||
use Laravel\VaporCli\Manifest; | ||
use RuntimeException; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class EnvDescribeCommand extends Command | ||
{ | ||
const DEFAULT_FORMAT = '[<comment>%attribute-key%</comment>] <info>%attribute-value%</info>'; | ||
|
||
/** | ||
* Configure the command options. | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('env:describe') | ||
->addArgument('environment', InputArgument::REQUIRED, 'The environment name') | ||
->addArgument('attribute', null, 'The environment attribute you would like to retrieve') | ||
->addOption('list', 'l', InputOption::VALUE_NONE, 'Indicate that all attributes should be listed') | ||
->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'The list format string') | ||
->setDescription('Describe an environment'); | ||
} | ||
|
||
/** | ||
* Execute the command. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
Helpers::ensure_api_token_is_available(); | ||
|
||
$environment = $this->vapor->environmentNamed( | ||
Manifest::id(), | ||
$this->argument('environment') | ||
); | ||
|
||
$domains = $environment['latest_deployment']['root_domains'] ?: []; | ||
|
||
$domain = count($domains) ? $domains[0] : null; | ||
|
||
$description = [ | ||
'project_id' => $environment['project_id'], | ||
'uuid' => $environment['uuid'], | ||
'id' => $environment['id'], | ||
'name' => $environment['name'], | ||
'vanity_domain' => $environment['vanity_domain'], | ||
'latest_deployment_id' => $environment['latest_deployment_id'], | ||
'latest_deployment_status' => $environment['latest_deployment']['status'], | ||
'latest_deployment_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'].'/deployments/'.$environment['latest_deployment_id'], | ||
'deployment_status' => $environment['deployment_status'], | ||
'domains' => $domains, | ||
'domain' => $domain, | ||
'management_url' => 'https://vapor.laravel.com/app/projects/'.$environment['project_id'].'/environments/'.$environment['name'], | ||
'vanity_url' => 'https://'.$environment['vanity_domain'], | ||
'custom_url' => $domain ? 'https://'.$domain : null, | ||
]; | ||
|
||
if ($this->option('list')) { | ||
$format = $this->option('format') ?: static::DEFAULT_FORMAT; | ||
|
||
foreach ($description as $settingKey => $settingValue) { | ||
if (is_bool($settingValue)) { | ||
$settingValue = var_export($settingValue, true); | ||
} | ||
|
||
if (is_array($settingValue)) { | ||
$settingValue = implode(',', $settingValue); | ||
} | ||
|
||
Helpers::line(str_replace( | ||
['%attribute-key%', '%attribute-value%'], | ||
[$settingKey, $settingValue], | ||
$format | ||
)); | ||
} | ||
|
||
return; | ||
} | ||
|
||
$settingKey = $this->argument('attribute'); | ||
|
||
if (! $settingKey || ! is_string($settingKey)) { | ||
return; | ||
} | ||
|
||
if (! array_key_exists($settingKey, $description)) { | ||
throw new RuntimeException($settingKey.' is not defined'); | ||
} | ||
|
||
$settingValue = $description[$settingKey]; | ||
|
||
if (is_bool($settingValue)) { | ||
$settingValue = var_export($settingValue, true); | ||
} | ||
|
||
Helpers::line($settingValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace Laravel\VaporCli\Commands; | ||
|
||
use Laravel\VaporCli\Path; | ||
use Laravel\VaporCli\Helpers; | ||
use Laravel\VaporCli\Manifest; | ||
use RuntimeException; | ||
use Symfony\Component\Console\Input\InputOption; | ||
|
||
class ProjectDescribeCommand extends Command | ||
{ | ||
const DEFAULT_FORMAT = '[<comment>%attribute-key%</comment>] <info>%attribute-value%</info>'; | ||
|
||
/** | ||
* Configure the command options. | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() | ||
{ | ||
$this | ||
->setName('project:describe') | ||
->addArgument('attribute', null, 'The project attribute you would like to retrieve') | ||
->addOption('list', 'l', InputOption::VALUE_NONE, 'Indicate that all attributes should be listed') | ||
->addOption('format', 'f', InputOption::VALUE_REQUIRED, 'The list format string') | ||
->setDescription('Describe the project'); | ||
} | ||
|
||
/** | ||
* Execute the command. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
Helpers::ensure_api_token_is_available(); | ||
|
||
$settingKey = $this->argument('attribute'); | ||
|
||
if ($settingKey && $settingKey === 'id') { | ||
// If we want the ID, we can just get it. | ||
Helpers::line(Manifest::id()); | ||
|
||
return; | ||
} | ||
|
||
$project = $this->vapor->project(Manifest::id()); | ||
|
||
$description = [ | ||
'id' => $project['id'], | ||
'name' => $project['name'], | ||
'team_id' => $project['team_id'], | ||
'team_name' => $project['team']['name'], | ||
'region' => $project['region'], | ||
'github_repository' => $project['github_repository'], | ||
'management_url' => 'https://vapor.laravel.com/app/projects/' . $project['id'], | ||
]; | ||
|
||
if ($this->option('list')) { | ||
$format = $this->option('format') ?: static::DEFAULT_FORMAT; | ||
|
||
foreach ($description as $settingKey => $settingValue) { | ||
if (is_bool($settingValue)) { | ||
$settingValue = var_export($settingValue, true); | ||
} | ||
|
||
Helpers::line(str_replace( | ||
['%attribute-key%', '%attribute-value%'], | ||
[$settingKey, $settingValue], | ||
$format | ||
)); | ||
} | ||
|
||
return; | ||
} | ||
|
||
if (! $settingKey || ! is_string($settingKey)) { | ||
return; | ||
} | ||
|
||
if (! array_key_exists($settingKey, $description)) { | ||
throw new RuntimeException($settingKey.' is not defined'); | ||
} | ||
|
||
$settingValue = $description[$settingKey]; | ||
|
||
if (is_bool($settingValue)) { | ||
$settingValue = var_export($settingValue, true); | ||
} | ||
|
||
Helpers::line($settingValue); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters