From 0aad609814fdb66c76ceded20d717df98fb9829b Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 14 Jun 2017 18:01:24 +0200 Subject: [PATCH 01/22] feat(basic-command) Symfony Console CommandAbstraction --- .gitignore | 30 +++++++++++++++++++++++++ bin/continuousphp | 20 +++++++++++++++++ composer.json | 29 ++++++++++++++++++++++++ src/ApplicationFactory.php | 25 +++++++++++++++++++++ src/Command/CommandAbstract.php | 17 ++++++++++++++ src/Command/CompanyCommand.php | 40 +++++++++++++++++++++++++++++++++ 6 files changed, 161 insertions(+) create mode 100644 .gitignore create mode 100755 bin/continuousphp create mode 100644 composer.json create mode 100644 src/ApplicationFactory.php create mode 100644 src/Command/CommandAbstract.php create mode 100644 src/Command/CompanyCommand.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..acd94a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,30 @@ +/vendor/ +composer.lock + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + diff --git a/bin/continuousphp b/bin/continuousphp new file mode 100755 index 0000000..05e96a7 --- /dev/null +++ b/bin/continuousphp @@ -0,0 +1,20 @@ +#!/usr/bin/env php +create() + ->run() +; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..376b129 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "continuousphp/cli", + "description": "The command line interface to ContinuousPHP Platform", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Pierre Tomasina", + "email": "pierre.tomasina@continuousphp.com" + } + ], + "require": { + "continuousphp/sdk": "dev-feat/entities", + "symfony/console": "^3.3", + "hoa/console": "~3.0" + }, + "autoload-dev": { + "psr-4": { + "Continuous\\Cli\\": "src/" + } + }, + "bin": ["bin/continuousphp"], + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/Pierozi/guzzle-services.git" + } + ] +} diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php new file mode 100644 index 0000000..c0286b2 --- /dev/null +++ b/src/ApplicationFactory.php @@ -0,0 +1,25 @@ +add($companyCommand); + + return $application; + } +} \ No newline at end of file diff --git a/src/Command/CommandAbstract.php b/src/Command/CommandAbstract.php new file mode 100644 index 0000000..a2c68af --- /dev/null +++ b/src/Command/CommandAbstract.php @@ -0,0 +1,17 @@ +continuousClient = \Continuous\Sdk\Service::factory(); + } +} \ No newline at end of file diff --git a/src/Command/CompanyCommand.php b/src/Command/CompanyCommand.php new file mode 100644 index 0000000..0b4d213 --- /dev/null +++ b/src/Command/CompanyCommand.php @@ -0,0 +1,40 @@ +setName('company:list') + ->setDescription('List Companies.') + ->setHelp('This command related to companies declared on continuous.') + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $collection = $this->continuousClient->getCompanies(); + $rows = []; + + foreach ($collection as $id => $company) { + $rows[] = [$id, $company->get('name')]; + } + + $table = new Table($output); + $table + ->setHeaders(['ID', 'Name']) + ->setRows($rows) + ->render() + ; + } +} \ No newline at end of file From 4909eb675a1db5c8288f5b5e7c7448f8c46ebf1a Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 14 Jun 2017 19:44:34 +0200 Subject: [PATCH 02/22] feat(basic-command) Show Company list details with name filter --- .gitignore | 3 + composer.json | 8 ++- constants.php | 5 ++ src/ApplicationFactory.php | 25 ++++++-- src/Command/CommandAbstract.php | 46 +++++++++++++- src/Command/Company/CompanyListCommand.php | 71 ++++++++++++++++++++++ src/Command/CompanyCommand.php | 40 ------------ 7 files changed, 150 insertions(+), 48 deletions(-) create mode 100644 constants.php create mode 100644 src/Command/Company/CompanyListCommand.php delete mode 100644 src/Command/CompanyCommand.php diff --git a/.gitignore b/.gitignore index acd94a1..d3fcea6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ /vendor/ composer.lock + +.idea + ### OSX ### *.DS_Store .AppleDouble diff --git a/composer.json b/composer.json index 376b129..8cc0075 100644 --- a/composer.json +++ b/composer.json @@ -14,9 +14,15 @@ "symfony/console": "^3.3", "hoa/console": "~3.0" }, - "autoload-dev": { + "autoload": { "psr-4": { "Continuous\\Cli\\": "src/" + }, + "files": ["constants.php"] + }, + "autoload-dev": { + "psr-4": { + "Continuous\\Cli\\Tests\\": "tests/" } }, "bin": ["bin/continuousphp"], diff --git a/constants.php b/constants.php new file mode 100644 index 0000000..28b4788 --- /dev/null +++ b/constants.php @@ -0,0 +1,5 @@ +add($companyCommand); + $application = new Application(self::NAME, self::getVersion()); + $application->add(new CompanyListCommand()); return $application; } + + /** + * Return the current version of continuousphp cli. + * + * @return string + */ + public static function getVersion() + { + return constant(__NAMESPACE__ . '\\' . 'version'); + } } \ No newline at end of file diff --git a/src/Command/CommandAbstract.php b/src/Command/CommandAbstract.php index a2c68af..fcb613e 100644 --- a/src/Command/CommandAbstract.php +++ b/src/Command/CommandAbstract.php @@ -3,15 +3,59 @@ namespace Continuous\Cli\Command; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +/** + * Class CommandAbstract + * @package Continuous\Cli\Command + */ abstract class CommandAbstract extends Command { + /** + * @var \Continuous\Sdk\Client + */ protected $continuousClient; + /** + * CommandAbstract constructor. + * + * @param null $name + */ public function __construct($name = null) { parent::__construct($name); - $this->continuousClient = \Continuous\Sdk\Service::factory(); + $this->addTokenOption(); + } + + protected function addTokenOption() + { + $this + ->addOption( + 'token', + 't', + InputOption::VALUE_OPTIONAL, + 'The token of continuousphp user', + null + ); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $token = $input->getOption('token'); + + if (null === $token && false === ($token = getenv('CPHP_TOKEN'))) { + $output->writeln("WARNING : ContinuousPHP Token was not found"); + } + + $this->continuousClient = \Continuous\Sdk\Service::factory([ + 'token' => $token + ]); } } \ No newline at end of file diff --git a/src/Command/Company/CompanyListCommand.php b/src/Command/Company/CompanyListCommand.php new file mode 100644 index 0000000..7802197 --- /dev/null +++ b/src/Command/Company/CompanyListCommand.php @@ -0,0 +1,71 @@ +setName('company:list') + ->setDescription('List Companies.') + ->setHelp('This command related to companies declared on continuous.') + ; + + $this + ->addOption( + 'filter-name', + null, + InputOption::VALUE_OPTIONAL, + 'filter apply on name of companies result' + ); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + + $filterName = $input->getOption('filter-name'); + + $collection = $this->continuousClient->getCompanies(); + $rows = []; + + foreach ($collection as $id => $company) { + $name = $company->get('name'); + + if (null !== $filterName && false === strpos(strtolower($name), $filterName)) { + continue; + } + + $rows[] = [ + $id, + $name, + $company->get('website'), + $company->get('email'), + $company->get('vat'), + $company->get('currency'), + ]; + } + + $table = new Table($output); + $table + ->setHeaders(['ID', 'Name', 'Website', 'Email', 'Vat', 'Currency']) + ->setRows($rows) + ->render() + ; + } +} \ No newline at end of file diff --git a/src/Command/CompanyCommand.php b/src/Command/CompanyCommand.php deleted file mode 100644 index 0b4d213..0000000 --- a/src/Command/CompanyCommand.php +++ /dev/null @@ -1,40 +0,0 @@ -setName('company:list') - ->setDescription('List Companies.') - ->setHelp('This command related to companies declared on continuous.') - ; - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $collection = $this->continuousClient->getCompanies(); - $rows = []; - - foreach ($collection as $id => $company) { - $rows[] = [$id, $company->get('name')]; - } - - $table = new Table($output); - $table - ->setHeaders(['ID', 'Name']) - ->setRows($rows) - ->render() - ; - } -} \ No newline at end of file From 17d96da9c96fba8c8af1df82a3953967c7b6c37b Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 14 Jun 2017 20:02:30 +0200 Subject: [PATCH 03/22] feat(basic-command) RepositoryList command and loader --- src/ApplicationFactory.php | 2 + src/Command/CommandAbstract.php | 30 +++++++++ .../Repository/RepositoryListCommand.php | 66 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 src/Command/Repository/RepositoryListCommand.php diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php index 9271c72..1fea6e2 100644 --- a/src/ApplicationFactory.php +++ b/src/ApplicationFactory.php @@ -3,6 +3,7 @@ namespace Continuous\Cli; use Continuous\Cli\Command\Company\CompanyListCommand; +use Continuous\Cli\Command\Repository\RepositoryListCommand; use Symfony\Component\Console\Application; /** @@ -22,6 +23,7 @@ public function create() { $application = new Application(self::NAME, self::getVersion()); $application->add(new CompanyListCommand()); + $application->add(new RepositoryListCommand()); return $application; } diff --git a/src/Command/CommandAbstract.php b/src/Command/CommandAbstract.php index fcb613e..5a57d9b 100644 --- a/src/Command/CommandAbstract.php +++ b/src/Command/CommandAbstract.php @@ -3,6 +3,7 @@ namespace Continuous\Cli\Command; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -18,6 +19,11 @@ abstract class CommandAbstract extends Command */ protected $continuousClient; + /** + * @var ProgressBar + */ + protected $loader; + /** * CommandAbstract constructor. * @@ -58,4 +64,28 @@ protected function execute(InputInterface $input, OutputInterface $output) 'token' => $token ]); } + + protected function showLoader($output, $message = '') + { + $this->loader = new ProgressBar($output, 1); + + if ($message) { + $this->loader->setFormatDefinition('custom', ' %current%/%max% -- %message%'); + $this->loader->setFormat('custom'); + $this->loader->setMessage($message); + + $this->loader->start(); + $this->loader->advance(); + } else { + $this->loader->start(); + } + } + + protected function hideLoader($output) + { + $this->loader->finish(); + $this->loader = null; + + $output->writeln("\n"); + } } \ No newline at end of file diff --git a/src/Command/Repository/RepositoryListCommand.php b/src/Command/Repository/RepositoryListCommand.php new file mode 100644 index 0000000..9a6fe3d --- /dev/null +++ b/src/Command/Repository/RepositoryListCommand.php @@ -0,0 +1,66 @@ +setName('repo:list') + ->setDescription('List of repositories authorized on provider application.') + ->setHelp('This command help you to find the repository that continuousPHP have access and can be configured.') + ; + + $this + ->addOption( + 'filter-name', + null, + InputOption::VALUE_OPTIONAL, + 'filter apply on name of repositories result' + ); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + + $filterName = $input->getOption('filter-name'); + $this->showLoader($output, 'Loading repositories from providers (github, bitbucket, gitlab)...'); + + $collection = $this->continuousClient->getRepositories(); + $rows = []; + + $this->hideLoader($output); + + foreach ($collection as $id => $repository) { + $name = $repository->get('name'); + + if (null !== $filterName && false === strpos(strtolower($name), $filterName)) { + continue; + } + + $rows[] = [ + $id, + $name + ]; + } + + $table = new Table($output); + $table + ->setHeaders(['ID', 'Name']) + ->setRows($rows) + ->render() + ; + } +} \ No newline at end of file From 60c703bb654115782462c30a2337db2981e63605 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Thu, 15 Jun 2017 15:40:45 +0200 Subject: [PATCH 04/22] feat(basic-command) Repository list detailed --- src/Command/Repository/RepositoryListCommand.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Command/Repository/RepositoryListCommand.php b/src/Command/Repository/RepositoryListCommand.php index 9a6fe3d..d4bee46 100644 --- a/src/Command/Repository/RepositoryListCommand.php +++ b/src/Command/Repository/RepositoryListCommand.php @@ -3,6 +3,7 @@ namespace Continuous\Cli\Command\Repository; use Continuous\Cli\Command\CommandAbstract; +use Continuous\Sdk\Collection; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -14,8 +15,8 @@ protected function configure() { $this ->setName('repo:list') - ->setDescription('List of repositories authorized on provider application.') - ->setHelp('This command help you to find the repository that continuousPHP have access and can be configured.') + ->setDescription('List of repositories not yet configured.') + ->setHelp('This command help you to find the repository that you can configure on ContinuousPHP and has not yet be initialized.') ; $this @@ -38,6 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $filterName = $input->getOption('filter-name'); $this->showLoader($output, 'Loading repositories from providers (github, bitbucket, gitlab)...'); + /** @var Collection $collection */ $collection = $this->continuousClient->getRepositories(); $rows = []; @@ -51,14 +53,19 @@ protected function execute(InputInterface $input, OutputInterface $output) } $rows[] = [ + $repository->getProvider()->get('name'), + $repository->get('isPrivate') ? 'Yes' : "No", $id, - $name + $name, + $repository->get('owner'), + $repository->get('htmlUrl'), + $repository->get('description'), ]; } $table = new Table($output); $table - ->setHeaders(['ID', 'Name']) + ->setHeaders(['Provider', 'Private', 'ID', 'Name', 'Owner', 'Url', 'Description']) ->setRows($rows) ->render() ; From 5e3dd8e012a1b88ebac44c2af3aa6fffc01369d7 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Thu, 15 Jun 2017 16:23:29 +0200 Subject: [PATCH 05/22] feat(basic-command) ProjectList command --- src/ApplicationFactory.php | 2 + src/Command/Project/ProjectListCommand.php | 71 ++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/Command/Project/ProjectListCommand.php diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php index 1fea6e2..410cb06 100644 --- a/src/ApplicationFactory.php +++ b/src/ApplicationFactory.php @@ -3,6 +3,7 @@ namespace Continuous\Cli; use Continuous\Cli\Command\Company\CompanyListCommand; +use Continuous\Cli\Command\Project\ProjectListCommand; use Continuous\Cli\Command\Repository\RepositoryListCommand; use Symfony\Component\Console\Application; @@ -24,6 +25,7 @@ public function create() $application = new Application(self::NAME, self::getVersion()); $application->add(new CompanyListCommand()); $application->add(new RepositoryListCommand()); + $application->add(new ProjectListCommand()); return $application; } diff --git a/src/Command/Project/ProjectListCommand.php b/src/Command/Project/ProjectListCommand.php new file mode 100644 index 0000000..db227f0 --- /dev/null +++ b/src/Command/Project/ProjectListCommand.php @@ -0,0 +1,71 @@ +setName('project:list') + ->setDescription('List of project configured.') + ->setHelp('This command help you to find the repository already configured on ContinuousPHP.') + ; + + $this + ->addOption( + 'filter-name', + null, + InputOption::VALUE_OPTIONAL, + 'filter apply on name of repositories result' + ); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + + $filterName = $input->getOption('filter-name'); + $this->showLoader($output, 'Loading project from providers (github, bitbucket, gitlab)...'); + + /** @var Collection $collection */ + $collection = $this->continuousClient->getProjects(); + $rows = []; + + $this->hideLoader($output); + + foreach ($collection as $id => $project) { + $name = $project->get('name'); + + if (null !== $filterName && false === strpos(strtolower($name), $filterName)) { + continue; + } + + $rows[] = [ + $project->getProvider()->get('name'), + $name, + $project->get('canSeeSettings') ? 'Yes' : "No", + $project->get('canEditSettings') ? 'Yes' : "No", + $project->get('canBuild') ? 'Yes' : "No", + ]; + } + + $table = new Table($output); + $table + ->setHeaders(['Provider', 'Name', 'View settings', 'Edit settings', 'Run build']) + ->setRows($rows) + ->render() + ; + } +} \ No newline at end of file From 3bc9931a268420a83174b62591e3a5ba8936ac7c Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Fri, 16 Jun 2017 00:41:37 +0200 Subject: [PATCH 06/22] feat(basic-command) list build --- src/ApplicationFactory.php | 2 + src/Command/Build/BuildListCommand.php | 113 +++++++++++++++++++++++++ src/Command/CommandAbstract.php | 15 ++++ 3 files changed, 130 insertions(+) create mode 100644 src/Command/Build/BuildListCommand.php diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php index 410cb06..cca6ac8 100644 --- a/src/ApplicationFactory.php +++ b/src/ApplicationFactory.php @@ -2,6 +2,7 @@ namespace Continuous\Cli; +use Continuous\Cli\Command\Build\BuildListCommand; use Continuous\Cli\Command\Company\CompanyListCommand; use Continuous\Cli\Command\Project\ProjectListCommand; use Continuous\Cli\Command\Repository\RepositoryListCommand; @@ -26,6 +27,7 @@ public function create() $application->add(new CompanyListCommand()); $application->add(new RepositoryListCommand()); $application->add(new ProjectListCommand()); + $application->add(new BuildListCommand()); return $application; } diff --git a/src/Command/Build/BuildListCommand.php b/src/Command/Build/BuildListCommand.php new file mode 100644 index 0000000..4150c1d --- /dev/null +++ b/src/Command/Build/BuildListCommand.php @@ -0,0 +1,113 @@ +setName('build:list') + ->setDescription('List of builds for specific project.') + ->setHelp('This command help you to list the builds of specific project and pipeline.') + ->addArgument('provider', InputArgument::REQUIRED, 'The repository provider') + ->addArgument('repository', InputArgument::REQUIRED, 'The repository name') + ; + + $this + ->addOption( + 'ref', + 'r', + InputOption::VALUE_OPTIONAL, + 'the pipeline ref' + ) + ->addOption( + 'state', + 's', + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + 'the build status', + ['in-progress', 'complete', 'timeout'] + ) + ->addOption( + 'noPr', + null, + InputOption::VALUE_NONE, + 'remove the PullRequest of result' + ) + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + + $this->showLoader($output, 'Loading builds...'); + $ref = $input->getOption('ref'); + $state = $input->getOption('state'); + + $params = [ + 'provider' => static::mapProviderToSdk($input->getArgument('provider')), + 'repository' => $input->getArgument('repository'), + 'state' => $state, + ]; + + if ($ref) { + $params['pipeline_id'] = $ref; + } + + if (true === $input->getOption('noPr')) { + $params['exclude_pull_requests'] = '1'; + } + + /** @var Collection $collection */ + $collection = $this->continuousClient->getBuilds($params); + $rows = []; + + $this->hideLoader($output); + + foreach ($collection as $id => $build) { + + $created = \DateTimeImmutable::createFromFormat('Y-m-d*H:i:sP', $build->get('created')); + + $launchUser = $build->getLaunchUser(); + $result = $build->get('result'); + $resultOutput = "$result"; + + $successActivities = array_filter($build->get('activities'), function($item) { + return true === $item['result']; + }); + + $rows[] = [ + $id, + $build->get('ref'), + $build->get('pullRequestNumber') ? $build->get('pullRequestNumber') : "-", + $build->get('state'), + $resultOutput, + $build->getDuration()->format('%H:%I:%S'), + count($successActivities) . '/' . count($build->get('activities')), + round($build->get('codeCoverage')) . "%", + $launchUser->displayName(), + $created->format('d/m/Y H:i:s'), + ]; + } + + $table = new Table($output); + $table + ->setHeaders(['ID', 'Ref', 'PR', 'State', 'Result', 'Duration', 'Activities Success', 'Code Coverage', 'Launch by', 'date']) + ->setRows($rows) + ->render() + ; + } +} \ No newline at end of file diff --git a/src/Command/CommandAbstract.php b/src/Command/CommandAbstract.php index 5a57d9b..a107e72 100644 --- a/src/Command/CommandAbstract.php +++ b/src/Command/CommandAbstract.php @@ -36,6 +36,21 @@ public function __construct($name = null) $this->addTokenOption(); } + public static function mapProviderToSdk($provider) + { + if (in_array(strtolower(trim($provider)), ['github', 'git hub'])) + { + return 'git-hub'; + } + + if (in_array(strtolower(trim($provider)), ['bb'])) + { + return 'bitbucket'; + } + + return $provider; + } + protected function addTokenOption() { $this From 170d9bbd92b37507125b75ae5cc2b1feb0693a39 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Fri, 16 Jun 2017 01:37:48 +0200 Subject: [PATCH 07/22] feat(basic-command) Start and Stop build --- src/ApplicationFactory.php | 4 ++ src/Command/Build/BuildListCommand.php | 3 +- src/Command/Build/BuildStartCommand.php | 69 +++++++++++++++++++++++++ src/Command/Build/BuildStopCommand.php | 45 ++++++++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/Command/Build/BuildStartCommand.php create mode 100644 src/Command/Build/BuildStopCommand.php diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php index cca6ac8..b98a3b5 100644 --- a/src/ApplicationFactory.php +++ b/src/ApplicationFactory.php @@ -3,6 +3,8 @@ namespace Continuous\Cli; use Continuous\Cli\Command\Build\BuildListCommand; +use Continuous\Cli\Command\Build\BuildStartCommand; +use Continuous\Cli\Command\Build\BuildStopCommand; use Continuous\Cli\Command\Company\CompanyListCommand; use Continuous\Cli\Command\Project\ProjectListCommand; use Continuous\Cli\Command\Repository\RepositoryListCommand; @@ -28,6 +30,8 @@ public function create() $application->add(new RepositoryListCommand()); $application->add(new ProjectListCommand()); $application->add(new BuildListCommand()); + $application->add(new BuildStartCommand()); + $application->add(new BuildStopCommand()); return $application; } diff --git a/src/Command/Build/BuildListCommand.php b/src/Command/Build/BuildListCommand.php index 4150c1d..6258975 100644 --- a/src/Command/Build/BuildListCommand.php +++ b/src/Command/Build/BuildListCommand.php @@ -4,6 +4,7 @@ use Continuous\Cli\Command\CommandAbstract; use Continuous\Sdk\Collection; +use Continuous\Sdk\Entity\Build; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -34,7 +35,7 @@ protected function configure() 's', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'the build status', - ['in-progress', 'complete', 'timeout'] + Build::STATE ) ->addOption( 'noPr', diff --git a/src/Command/Build/BuildStartCommand.php b/src/Command/Build/BuildStartCommand.php new file mode 100644 index 0000000..ef68dab --- /dev/null +++ b/src/Command/Build/BuildStartCommand.php @@ -0,0 +1,69 @@ +setName('build:start') + ->setDescription('start a build for specific project.') + ->setHelp('This command help you to start build for specific pipeline project.') + ->addArgument('provider', InputArgument::REQUIRED, 'The repository provider') + ->addArgument('repository', InputArgument::REQUIRED, 'The repository name') + ->addArgument('ref', InputArgument::REQUIRED, 'The git reference') + ; + + $this + ->addOption( + 'pull-request', + 'pr', + InputOption::VALUE_OPTIONAL, + 'the PR id you want build' + ) + ; + + $this + ->addOption( + 'attach', + 'a', + InputOption::VALUE_NONE, + 'attach the log' + ) + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + + $this->showLoader($output, 'Starting builds...'); + + $params = [ + 'provider' => static::mapProviderToSdk($input->getArgument('provider')), + 'repository' => $input->getArgument('repository'), + 'ref' => $input->getArgument('ref'), + ]; + + if ($pr = $input->getOption('pull-request')) { + $params['pull_request'] = $pr; + } + + /** @var Build $build */ + $build = $this->continuousClient->startBuild($params); + + $output->writeln('Build start with ID ' . $build->get('buildId')); + } +} \ No newline at end of file diff --git a/src/Command/Build/BuildStopCommand.php b/src/Command/Build/BuildStopCommand.php new file mode 100644 index 0000000..4bd863d --- /dev/null +++ b/src/Command/Build/BuildStopCommand.php @@ -0,0 +1,45 @@ +setName('build:stop') + ->setDescription('stop a build.') + ->setHelp('This command help you to stop build for specific pipeline project.') + ->addArgument('provider', InputArgument::REQUIRED, 'The repository provider') + ->addArgument('repository', InputArgument::REQUIRED, 'The repository name') + ->addArgument('build-id', InputArgument::REQUIRED, 'The build id you want to stop') + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + + $this->showLoader($output, 'stopping builds...'); + + $params = [ + 'provider' => static::mapProviderToSdk($input->getArgument('provider')), + 'repository' => $input->getArgument('repository'), + 'buildId' => $input->getArgument('build-id'), + ]; + + $result = $this->continuousClient->cancelBuild($params); + var_dump($result); + + $output->writeln('Built has been cancelled.'); + } +} \ No newline at end of file From d37bae6bdac5b80e60972930e28f4b29c71c157f Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Fri, 16 Jun 2017 12:39:26 +0200 Subject: [PATCH 08/22] feat(basic-command) configure profile --- src/ApplicationFactory.php | 2 + src/Command/CommandAbstract.php | 18 +++- src/Command/ConfigureCommand.php | 136 +++++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 src/Command/ConfigureCommand.php diff --git a/src/ApplicationFactory.php b/src/ApplicationFactory.php index b98a3b5..d0485e4 100644 --- a/src/ApplicationFactory.php +++ b/src/ApplicationFactory.php @@ -6,6 +6,7 @@ use Continuous\Cli\Command\Build\BuildStartCommand; use Continuous\Cli\Command\Build\BuildStopCommand; use Continuous\Cli\Command\Company\CompanyListCommand; +use Continuous\Cli\Command\ConfigureCommand; use Continuous\Cli\Command\Project\ProjectListCommand; use Continuous\Cli\Command\Repository\RepositoryListCommand; use Symfony\Component\Console\Application; @@ -26,6 +27,7 @@ final class ApplicationFactory public function create() { $application = new Application(self::NAME, self::getVersion()); + $application->add(new ConfigureCommand()); $application->add(new CompanyListCommand()); $application->add(new RepositoryListCommand()); $application->add(new ProjectListCommand()); diff --git a/src/Command/CommandAbstract.php b/src/Command/CommandAbstract.php index a107e72..c343cd4 100644 --- a/src/Command/CommandAbstract.php +++ b/src/Command/CommandAbstract.php @@ -56,10 +56,17 @@ protected function addTokenOption() $this ->addOption( 'token', - 't', + null, InputOption::VALUE_OPTIONAL, 'The token of continuousphp user', null + ) + ->addOption( + 'profile', + null, + InputOption::VALUE_OPTIONAL, + 'The profile of configure credentials. See route configure', + null ); } @@ -70,9 +77,16 @@ protected function addTokenOption() protected function execute(InputInterface $input, OutputInterface $output) { $token = $input->getOption('token'); + $profile = $input->getOption('profile'); if (null === $token && false === ($token = getenv('CPHP_TOKEN'))) { - $output->writeln("WARNING : ContinuousPHP Token was not found"); + + $profile = empty($profile) ? 'default' : $profile; + $token = ConfigureCommand::getToken($profile); + + if (null === $token) { + $output->writeln("WARNING : ContinuousPHP Token was not found"); + } } $this->continuousClient = \Continuous\Sdk\Service::factory([ diff --git a/src/Command/ConfigureCommand.php b/src/Command/ConfigureCommand.php new file mode 100644 index 0000000..a4d1dc3 --- /dev/null +++ b/src/Command/ConfigureCommand.php @@ -0,0 +1,136 @@ +setName('configure') + ->setDescription('Configure cphp profile.') + ->setHelp('This command help you to create multiple profile corresponding to cphp user token. Can be found at https://app.continuousphp.com/credentials') + ; + + $this + ->addOption( + 'profile', + null, + InputOption::VALUE_OPTIONAL, + 'Profile name' + ); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + parent::execute($input, $output); + + $this->obtainProfileToken($input, $output, $profile, $token); + $path = $this->saveProfile($profile, $token); + + $output->writeln("Profile $profile saved in $path"); + } + + protected function obtainProfileToken(InputInterface $input, OutputInterface $output, & $profile, & $token) + { + $profile = $input->getOption('profile'); + $token = $input->getOption('token'); + + if (true === $input->getOption('no-interaction')) { + if (!$profile && !$token) { + $output->writeln( + "ERROR : no-interaction was specified, you must declare profile and token as option" + ); + } + + return; + } + + $helper = $this->getHelper('question'); + + if (null === $profile) { + $profile = $helper->ask( + $input, $output, + new Question('Profile name [default]: ', 'default') + ); + } + + if (null === $token) { + $token = $helper->ask( + $input, $output, + new Question('User Token: ') + ); + } + } + + protected function saveProfile($profile, $token) + { + $profiles = self::getProfiles(); + $profiles[$profile] = [ + 'token' => $token + ]; + + $path = static::getCredentialsPath(); + $pathDir = dirname($path); + + if (!file_exists($pathDir)) { + mkdir($pathDir); + } + + $handle = fopen($path, 'w+'); + + if (false === is_resource($handle)) { + throw new \Exception("Error during opening/creating credentials file at $path"); + } + + foreach ($profiles as $name => $profile) { + fwrite($handle, "[$name]\n"); + + foreach ($profile as $k => $v) { + fwrite($handle, "$k = $v\n"); + } + } + + fclose($handle); + + return $path; + } + + protected static function getCredentialsPath() + { + $home = getenv('HOME'); + + if (empty($home)) { + $home = '~'; + } + + return "{$home}/.continuousphp/credentials"; + } + + public static function getProfiles() + { + $path = static::getCredentialsPath(); + + if (false === file_exists($path)) { + return []; + } + + return parse_ini_file($path, true); + } + + public static function getToken($profile) + { + $profiles = static::getProfiles(); + + return !empty($profiles[$profile]) ? $profiles[$profile]['token'] : null; + } +} \ No newline at end of file From 64b5398c1df280a4713a98ffa68c95fbce86ff43 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Mon, 19 Jun 2017 13:59:49 +0200 Subject: [PATCH 09/22] build phar with box --- README.md | 6 +++++- box.json | 30 ++++++++++++++++++++++++++++++ constants.php | 5 ++++- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 box.json diff --git a/README.md b/README.md index 495109a..b0cce7a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -ContinuousPHP + + ContinuousPHP +

Build Status @@ -23,6 +25,8 @@ $ composer require continuousphp/cli '~0.0' ## Usage +sed -i 's/;phar.readonly = On/phar.readonly = Off/' /home/cphp/.phpbrew/php/*/etc/php.ini + ## Contributing 1. Fork it :clap: diff --git a/box.json b/box.json new file mode 100644 index 0000000..7700554 --- /dev/null +++ b/box.json @@ -0,0 +1,30 @@ +{ + "files": [ + "constants.php" + ], + "directories": [ + "src" + ], + "finder": [ + { + "name": "*.php", + "exclude": [ + "phpunit", + "phpunit-test-case", + "Tester", + "Tests", + "Test", + "tests", + "yaml" + ], + "in": "vendor" + } + ], + "git-version": "git-version", + "replacements": { + "my-custom-place-holder": "custom-value-dev-master" + }, + "main": "bin/continuousphp", + "output": "continuousphp-@git-version@.phar", + "stub": true +} \ No newline at end of file diff --git a/constants.php b/constants.php index 28b4788..d9cdb0a 100644 --- a/constants.php +++ b/constants.php @@ -1,5 +1,8 @@ Date: Tue, 27 Jun 2017 13:44:38 +0200 Subject: [PATCH 10/22] Makefile target cphp-gh-phar --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f0994e4 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +SHELL := /bin/bash + +TAG=$(shell echo ${CPHP_GIT_REF} | tail -c +11) +PHAR_NAME="continuousphp-$(TAG).phar" + +cphp-gh-phar: + @echo "Attach phar to github release: $(PHAR_NAME)" From 0e590f6d316dec326eee72e421ec6982a3f3586d Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Tue, 27 Jun 2017 16:56:31 +0200 Subject: [PATCH 11/22] script for publish asset on github release --- Makefile | 7 ------- cphp-gh-release-asset.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) delete mode 100644 Makefile create mode 100755 cphp-gh-release-asset.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index f0994e4..0000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -SHELL := /bin/bash - -TAG=$(shell echo ${CPHP_GIT_REF} | tail -c +11) -PHAR_NAME="continuousphp-$(TAG).phar" - -cphp-gh-phar: - @echo "Attach phar to github release: $(PHAR_NAME)" diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh new file mode 100755 index 0000000..ae63b41 --- /dev/null +++ b/cphp-gh-release-asset.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +sign() +{ + gpg --detach-sign $1 + gpg --verify $1.sig $1 +} + +TAG=$(shell echo ${CPHP_GIT_REF} | tail -c +11) +PHAR_NAME="continuousphp-$TAG.phar" + +if [ -z ${CONTINUOUSPHP} ]; +then + echo "Your are not on ContinuousPHP environment" + exit 1 +fi + +sign $PHAR_NAME + +upload_url=`curl -sS -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/continuousphp/cli/releases/tags/$TAG | jq --compact-output '.upload_url' | sed 's/{?name,label}//g' | sed 's/"//g'` + +echo "Attach phar to github release: $PHAR_NAME" +echo "Upload to $upload_url" + +curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" --upload-file $PHAR_NAME "$upload_url?name=continuousphpcli.phar" +curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" --upload-file "$PHAR_NAME.sig" "$upload_url?name=continuousphpcli.sig" + From d12aad7977a93c005d68b865475082debfcebbcf Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Tue, 27 Jun 2017 18:34:41 +0200 Subject: [PATCH 12/22] fix deploy script --- cphp-gh-release-asset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index ae63b41..47935af 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -6,7 +6,7 @@ sign() gpg --verify $1.sig $1 } -TAG=$(shell echo ${CPHP_GIT_REF} | tail -c +11) +TAG=`echo ${CPHP_GIT_REF} | tail -c +11` PHAR_NAME="continuousphp-$TAG.phar" if [ -z ${CONTINUOUSPHP} ]; From 4af823be867954893e5ec9aedeae992fde661576 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 13:47:09 +0200 Subject: [PATCH 13/22] mkDoc with installation guide and auto deployment doc --- README.md | 12 ++++++------ cphp-gh-release-asset.sh | 18 ++++++++++++++++++ docs/index.md | 38 ++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 2 ++ 4 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 docs/index.md create mode 100644 mkdocs.yml diff --git a/README.md b/README.md index b0cce7a..ed2a5ee 100644 --- a/README.md +++ b/README.md @@ -15,17 +15,17 @@ CLI for ContinuousPHP platform. Manage project and build easily from your favorite terminal. -## Installation +## Installation as Phar ( Recommended ) -With [Composer](https://getcomposer.org/), to include this library into your dependencies, you need to require [`continuousphp/cli`](https://packagist.org/packages/continuousphp/cli): +Download the latest version of continuousphpcli as a Phar: ```sh -$ composer require continuousphp/cli '~0.0' +$ curl -LSs https://continuousphp.github.io/cli/phar-installer.php | php ``` -## Usage - -sed -i 's/;phar.readonly = On/phar.readonly = Off/' /home/cphp/.phpbrew/php/*/etc/php.ini +The command will check your PHP settings, warn you of any issues, and the download it to the current directory. +From there, you may place it anywhere that will make it easier for you to access (such as `/usr/local/bin`) and chmod it to 755. +You can even rename it to just `continuousphpcli` to avoid having to type the .phar extension every time. ## Contributing diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index 47935af..389eec8 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -25,3 +25,21 @@ echo "Upload to $upload_url" curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" --upload-file $PHAR_NAME "$upload_url?name=continuousphpcli.phar" curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" --upload-file "$PHAR_NAME.sig" "$upload_url?name=continuousphpcli.sig" +rm -rf .git +mkdocs build -d doc_dist +git clone git@github.com:continuousphp/cli.git cli-site +cd cli-site +git checkout gh-pages +rm -rf doc +mv ../doc_dist doc + +TAG="v0.1.2" +PHAR_NAME="continuousphp-$TAG.phar" + +php -r '$x = json_decode(file_get_contents("manifest.json"), true); $x["'$TAG'"] = ["name"=>"continuousphpcli.phar","sha1"=>sha1_file("../'$PHAR_NAME'"),"url"=>"https://github.com/continuousphp/cli/releases/download/'$TAG'/continuousphpcli.phar","version"=>substr("'$TAG'",1)]; file_put_contents("manifest.json", json_encode($x)); print_r($x);' + +git add -A doc +git add manifest.json + +git ci -m "Update doc to tag $TAG" +git push origin gh-pages \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..f579460 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,38 @@ +# What is ContinuousPHP + +ContinuousPHP is the first and only PHP-centric PaaS to build, package, test and deploy applications in the same workflow. + +The ContinuousPHP CLI is command line interface for ContinuousPHP Platform. + +## Installation + +We recommand to use the php installer script to install latest version +of continuousphpcli PHAR. + + $ curl -LSs https://continuousphp.github.io/cli/phar-installer.php | php + # Move the phar in your user bin directory + $ mv continuousphpcli.phar /usr/local/bin/continuousphpcli + +The command will check your PHP settings, warn you of any issues, and the download it to the current directory. +From there, you may place it anywhere that will make it easier for you to access (such as `/usr/local/bin`) and chmod it to 755. +You can even rename it to just `continuousphpcli` to avoid having to type the .phar extension every time. + +## Configuration + +By default, some of continuousphp api request do not require to be authenticate. +But you will certeinly need it for command that required permission, like start or stop build. + +The cli implement a system of profile, to be able to use easily different continuousphp account. + +each profile must be configured with the continuousphp user token, you can find a personal token + on your credentials page at https://app.continuousphp.com/credentials + +Configure new profile in interactive mode with this command + $ continuousphpcli configure + > Profile name [default]: myProfileName + > User Token: XXXXXXXXXX + < Profile myUserAccount saved in /home/user/.continuousphp/credentials + +If you let profile name at `default`, the continuousphpcli will automatically use this credential. +Otherwise, you must specify the option `--profile myProfileName` on each command. + diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..d72fa8c --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,2 @@ +site_name: ContinuousPHP Cli +theme: 'material' From 83560be4edcd3a71148405d3deb1f09fe404cf2c Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 13:51:31 +0200 Subject: [PATCH 14/22] CS --- docs/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/index.md b/docs/index.md index f579460..911647c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -28,6 +28,7 @@ each profile must be configured with the continuousphp user token, you can find on your credentials page at https://app.continuousphp.com/credentials Configure new profile in interactive mode with this command + $ continuousphpcli configure > Profile name [default]: myProfileName > User Token: XXXXXXXXXX From 28d2674146aa0c7354956d27288a32b8d956f958 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 15:00:25 +0200 Subject: [PATCH 15/22] fix deploy doc --- cphp-gh-release-asset.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index 389eec8..cc0f41e 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -27,8 +27,10 @@ curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application rm -rf .git mkdocs build -d doc_dist -git clone git@github.com:continuousphp/cli.git cli-site +mkdir cli-site cd cli-site +git init +git pull "https://${GITHUB_TOKEN}@github.com:continuousphp/cli.git" git checkout gh-pages rm -rf doc mv ../doc_dist doc @@ -42,4 +44,4 @@ git add -A doc git add manifest.json git ci -m "Update doc to tag $TAG" -git push origin gh-pages \ No newline at end of file +git push "https://${GITHUB_TOKEN}@github.com:continuousphp/cli.git" gh-pages \ No newline at end of file From b671d825b371a6b0392998275b645621e18fba3c Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 15:24:11 +0200 Subject: [PATCH 16/22] fix deploy doc --- cphp-gh-release-asset.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index cc0f41e..f67014f 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -30,8 +30,7 @@ mkdocs build -d doc_dist mkdir cli-site cd cli-site git init -git pull "https://${GITHUB_TOKEN}@github.com:continuousphp/cli.git" -git checkout gh-pages +git pull "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" gh-pages rm -rf doc mv ../doc_dist doc @@ -43,5 +42,5 @@ php -r '$x = json_decode(file_get_contents("manifest.json"), true); $x["'$TAG'"] git add -A doc git add manifest.json -git ci -m "Update doc to tag $TAG" +git commit -m "Update doc to tag $TAG" git push "https://${GITHUB_TOKEN}@github.com:continuousphp/cli.git" gh-pages \ No newline at end of file From b9845f13d68668a1f92fcf620545067352611ad1 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 15:24:59 +0200 Subject: [PATCH 17/22] fix deploy doc --- cphp-gh-release-asset.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index f67014f..6fd016e 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -43,4 +43,4 @@ git add -A doc git add manifest.json git commit -m "Update doc to tag $TAG" -git push "https://${GITHUB_TOKEN}@github.com:continuousphp/cli.git" gh-pages \ No newline at end of file +git push "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" gh-pages \ No newline at end of file From d8d099d47c94cf3133f139fdf28a43982f61a585 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 15:35:24 +0200 Subject: [PATCH 18/22] fix deploy doc --- cphp-gh-release-asset.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index 6fd016e..5900296 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -34,13 +34,13 @@ git pull "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" gh-pages rm -rf doc mv ../doc_dist doc -TAG="v0.1.2" -PHAR_NAME="continuousphp-$TAG.phar" - php -r '$x = json_decode(file_get_contents("manifest.json"), true); $x["'$TAG'"] = ["name"=>"continuousphpcli.phar","sha1"=>sha1_file("../'$PHAR_NAME'"),"url"=>"https://github.com/continuousphp/cli/releases/download/'$TAG'/continuousphpcli.phar","version"=>substr("'$TAG'",1)]; file_put_contents("manifest.json", json_encode($x)); print_r($x);' git add -A doc git add manifest.json +git config user.email "info@continuousphp.com" +git config user.name "${CPHP_BUILT_BY}" + git commit -m "Update doc to tag $TAG" -git push "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" gh-pages \ No newline at end of file +git push "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" \ No newline at end of file From a0ed0f35feb5020cd86a82806bffc61281f350d3 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 15:46:38 +0200 Subject: [PATCH 19/22] fix deploy doc --- cphp-gh-release-asset.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index 5900296..c188d49 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -27,10 +27,13 @@ curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application rm -rf .git mkdocs build -d doc_dist -mkdir cli-site + +git config user.email "info@continuousphp.com" +git config user.name "${CPHP_BUILT_BY}" + +git clone "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" cli-site cd cli-site -git init -git pull "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" gh-pages +git checkout gh-pages rm -rf doc mv ../doc_dist doc @@ -39,8 +42,5 @@ php -r '$x = json_decode(file_get_contents("manifest.json"), true); $x["'$TAG'"] git add -A doc git add manifest.json -git config user.email "info@continuousphp.com" -git config user.name "${CPHP_BUILT_BY}" - git commit -m "Update doc to tag $TAG" -git push "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" \ No newline at end of file +git push origin gh-pages \ No newline at end of file From c87a40f018e5084ba80f65cd2f5e3fac64b49e38 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 15:52:15 +0200 Subject: [PATCH 20/22] fix deploy doc --- cphp-gh-release-asset.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cphp-gh-release-asset.sh b/cphp-gh-release-asset.sh index c188d49..2dc9f59 100755 --- a/cphp-gh-release-asset.sh +++ b/cphp-gh-release-asset.sh @@ -28,9 +28,6 @@ curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application rm -rf .git mkdocs build -d doc_dist -git config user.email "info@continuousphp.com" -git config user.name "${CPHP_BUILT_BY}" - git clone "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" cli-site cd cli-site git checkout gh-pages @@ -39,6 +36,9 @@ mv ../doc_dist doc php -r '$x = json_decode(file_get_contents("manifest.json"), true); $x["'$TAG'"] = ["name"=>"continuousphpcli.phar","sha1"=>sha1_file("../'$PHAR_NAME'"),"url"=>"https://github.com/continuousphp/cli/releases/download/'$TAG'/continuousphpcli.phar","version"=>substr("'$TAG'",1)]; file_put_contents("manifest.json", json_encode($x)); print_r($x);' +git config user.email "info@continuousphp.com" +git config user.name "${CPHP_BUILT_BY}" + git add -A doc git add manifest.json From d6c85c11fb991dac0107bfb7c7a69b5e5c7a2df5 Mon Sep 17 00:00:00 2001 From: Pascal Paulis Date: Wed, 28 Jun 2017 17:21:43 +0200 Subject: [PATCH 21/22] fixed typos (#10) --- README.md | 10 ++++----- docs/index.md | 25 +++++++++++----------- src/Command/Build/BuildStartCommand.php | 2 +- src/Command/Build/BuildStopCommand.php | 2 +- src/Command/CommandAbstract.php | 4 ++-- src/Command/ConfigureCommand.php | 2 +- src/Command/Project/ProjectListCommand.php | 2 +- 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index ed2a5ee..856ec5b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ # ContinuousPHP\Cli -CLI for ContinuousPHP platform. Manage project and build easily from your favorite terminal. +CLI for the ContinuousPHP platform. Manage projects and build easily from your favorite terminal. ## Installation as Phar ( Recommended ) @@ -23,17 +23,17 @@ Download the latest version of continuousphpcli as a Phar: $ curl -LSs https://continuousphp.github.io/cli/phar-installer.php | php ``` -The command will check your PHP settings, warn you of any issues, and the download it to the current directory. -From there, you may place it anywhere that will make it easier for you to access (such as `/usr/local/bin`) and chmod it to 755. +The command will check your PHP settings, warn you of any issues, and then download it to the current directory. +From there, you may place it anywhere you want to make it easier to access (such as `/usr/local/bin`) and chmod it to 755. You can even rename it to just `continuousphpcli` to avoid having to type the .phar extension every time. ## Contributing 1. Fork it :clap: 2. Create your feature branch: `git checkout -b feat/my-new-feature` -3. Write your Unit and Functional testing +3. Write your Unit and Functional tests 4. Commit your changes: `git commit -am 'Add some feature'` 5. Push to the branch: `git push origin feat/my-new-feature` -6. Submit a pull request with the detail of your implementation +6. Submit a pull request with the details of your implementation 7. Take a drink during our review and merge :beers: diff --git a/docs/index.md b/docs/index.md index 911647c..b043f72 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,38 +2,37 @@ ContinuousPHP is the first and only PHP-centric PaaS to build, package, test and deploy applications in the same workflow. -The ContinuousPHP CLI is command line interface for ContinuousPHP Platform. +The ContinuousPHP CLI is a command line interface for the ContinuousPHP Platform. ## Installation -We recommand to use the php installer script to install latest version +We recommend using the php installer script to install the latest version of continuousphpcli PHAR. $ curl -LSs https://continuousphp.github.io/cli/phar-installer.php | php # Move the phar in your user bin directory $ mv continuousphpcli.phar /usr/local/bin/continuousphpcli -The command will check your PHP settings, warn you of any issues, and the download it to the current directory. -From there, you may place it anywhere that will make it easier for you to access (such as `/usr/local/bin`) and chmod it to 755. +The command will check your PHP settings, warn you of any issues, and then download it to the current directory. +From there, you may place it anywhere you want to make it easier to access (such as `/usr/local/bin`) and chmod it to 755. You can even rename it to just `continuousphpcli` to avoid having to type the .phar extension every time. ## Configuration -By default, some of continuousphp api request do not require to be authenticate. -But you will certeinly need it for command that required permission, like start or stop build. +By default, some of the continuousphp API requests do not require to be authenticated. +But you will certainly need to authenticate for commands that require permissions, like starting or stopping a build. -The cli implement a system of profile, to be able to use easily different continuousphp account. +The cli implements a profile system to easily use different continuousphp accounts. -each profile must be configured with the continuousphp user token, you can find a personal token - on your credentials page at https://app.continuousphp.com/credentials +Each profile must be configured with the continuousphp user token. You can find a personal token +on your credentials page at https://app.continuousphp.com/credentials -Configure new profile in interactive mode with this command +Configure a new profile in interactive mode with this command: $ continuousphpcli configure > Profile name [default]: myProfileName > User Token: XXXXXXXXXX < Profile myUserAccount saved in /home/user/.continuousphp/credentials -If you let profile name at `default`, the continuousphpcli will automatically use this credential. -Otherwise, you must specify the option `--profile myProfileName` on each command. - +If you choose `default` as the profile name, the continuousphpcli will automatically use this credential. +Otherwise, you must specify the option `--profile myProfileName` on each command. \ No newline at end of file diff --git a/src/Command/Build/BuildStartCommand.php b/src/Command/Build/BuildStartCommand.php index ef68dab..9ef8113 100644 --- a/src/Command/Build/BuildStartCommand.php +++ b/src/Command/Build/BuildStartCommand.php @@ -64,6 +64,6 @@ protected function execute(InputInterface $input, OutputInterface $output) /** @var Build $build */ $build = $this->continuousClient->startBuild($params); - $output->writeln('Build start with ID ' . $build->get('buildId')); + $output->writeln('Build started with ID ' . $build->get('buildId')); } } \ No newline at end of file diff --git a/src/Command/Build/BuildStopCommand.php b/src/Command/Build/BuildStopCommand.php index 4bd863d..b62695e 100644 --- a/src/Command/Build/BuildStopCommand.php +++ b/src/Command/Build/BuildStopCommand.php @@ -40,6 +40,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $result = $this->continuousClient->cancelBuild($params); var_dump($result); - $output->writeln('Built has been cancelled.'); + $output->writeln('Build has been cancelled.'); } } \ No newline at end of file diff --git a/src/Command/CommandAbstract.php b/src/Command/CommandAbstract.php index c343cd4..a8b7193 100644 --- a/src/Command/CommandAbstract.php +++ b/src/Command/CommandAbstract.php @@ -58,14 +58,14 @@ protected function addTokenOption() 'token', null, InputOption::VALUE_OPTIONAL, - 'The token of continuousphp user', + 'The token of the continuousphp user', null ) ->addOption( 'profile', null, InputOption::VALUE_OPTIONAL, - 'The profile of configure credentials. See route configure', + 'The profile of the configured credentials. See route configure', null ); } diff --git a/src/Command/ConfigureCommand.php b/src/Command/ConfigureCommand.php index a4d1dc3..e68b8ce 100644 --- a/src/Command/ConfigureCommand.php +++ b/src/Command/ConfigureCommand.php @@ -48,7 +48,7 @@ protected function obtainProfileToken(InputInterface $input, OutputInterface $ou if (true === $input->getOption('no-interaction')) { if (!$profile && !$token) { $output->writeln( - "ERROR : no-interaction was specified, you must declare profile and token as option" + "ERROR : no-interaction was specified. You must declare profile and token as option" ); } diff --git a/src/Command/Project/ProjectListCommand.php b/src/Command/Project/ProjectListCommand.php index db227f0..05eca41 100644 --- a/src/Command/Project/ProjectListCommand.php +++ b/src/Command/Project/ProjectListCommand.php @@ -37,7 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output) parent::execute($input, $output); $filterName = $input->getOption('filter-name'); - $this->showLoader($output, 'Loading project from providers (github, bitbucket, gitlab)...'); + $this->showLoader($output, 'Loading projects from providers (github, bitbucket, gitlab)...'); /** @var Collection $collection */ $collection = $this->continuousClient->getProjects(); From d4d45040e2ca1294a4446866683e56abededa5e2 Mon Sep 17 00:00:00 2001 From: Pierre Tomasina Date: Wed, 28 Jun 2017 17:43:41 +0200 Subject: [PATCH 22/22] Update Readme --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 856ec5b..c872a89 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,9 @@

- Build Status - Version - Packagist + Build Status

+

ContinuousPHP© is the first and only PHP-centric PaaS to build, package, test and deploy applications in the same workflow.

@@ -27,6 +26,19 @@ The command will check your PHP settings, warn you of any issues, and then downl From there, you may place it anywhere you want to make it easier to access (such as `/usr/local/bin`) and chmod it to 755. You can even rename it to just `continuousphpcli` to avoid having to type the .phar extension every time. +## Documentation + +You can find Markdown documentation into `docs` subfolder or on web version at https://continuousphp.github.io/cli/doc +Thanks to open an issue if you see something missing in our documentation. + +## Credit + +This project was made based on Open-Source project, thanks to them! + + * [Box](https://github.com/box-project/box2) - PHAR builder + * [Symfony\Console](https://github.com/symfony/console) - PHP Console Service + * [Hoa\Console](https://github.com/hoaproject/Console) - PHP Console library + ## Contributing 1. Fork it :clap: