Skip to content

Commit

Permalink
Add command to list projects
Browse files Browse the repository at this point in the history
  • Loading branch information
kaarejoergensen committed Dec 9, 2021
1 parent afe4aaa commit 0f779f6
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
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

0 comments on commit 0f779f6

Please sign in to comment.