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

Add command to list projects #162

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/Commands/ProjectListCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace Laravel\VaporCli\Commands;

use Laravel\VaporCli\Helpers;

class ProjectListCommand extends Command
{
/**
* Configure the command options.
*
* @return void
*/
protected function configure()
{
$this
->setName('project:list')
->setDescription('List the projects that belong to the current team');
}

/**
* Execute the command.
*
* @return void
*/
public function handle()
{
Helpers::ensure_api_token_is_available();

$this->table([
'ID', 'Provider', 'Name', 'Region',
], collect($this->vapor->projects())->map(function ($project) {
return [
$project['id'],
$project['cloud_provider']['name'],
$project['name'],
$project['region'],
];
})->all());
}
}
10 changes: 10 additions & 0 deletions src/ConsoleVaporClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,16 @@ public function project($projectId)
return $this->request('get', '/api/projects/'.$projectId);
}

/**
* Get the projects that belong to the account.
*
* @return array
*/
public function projects()
{
return $this->request('get', 'api/teams/'.Helpers::config('team').'/projects');
}

/**
* Create a new project.
*
Expand Down
1 change: 1 addition & 0 deletions vapor
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ $app->add(new Commands\InitCommand);
$app->add(new Commands\UiCommand);
$app->add(new Commands\ProjectDeleteCommand);
$app->add(new Commands\ProjectDescribeCommand);
$app->add(new Commands\ProjectListCommand);

// Environments...
$app->add(new Commands\EnvListCommand);
Expand Down