Skip to content

Commit a1f0bec

Browse files
authored
Feat/basic command (#11)
* feat(basic-command) Symfony Console CommandAbstraction * feat(basic-command) Show Company list details with name filter * feat(basic-command) RepositoryList command and loader * feat(basic-command) Repository list detailed * feat(basic-command) ProjectList command * feat(basic-command) list build * feat(basic-command) Start and Stop build * feat(basic-command) configure profile * build phar with box * Makefile target cphp-gh-phar * script for publish asset on github release * fix deploy script * mkDoc with installation guide and auto deployment doc * CS * fix deploy doc * fixed typos (#10) * Update Readme
1 parent 08ae674 commit a1f0bec

18 files changed

+988
-11
lines changed

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/vendor/
2+
composer.lock
3+
4+
5+
.idea
6+
7+
### OSX ###
8+
*.DS_Store
9+
.AppleDouble
10+
.LSOverride
11+
12+
# Icon must end with two \r
13+
Icon
14+
15+
# Thumbnails
16+
._*
17+
18+
# Files that might appear in the root of a volume
19+
.DocumentRevisions-V100
20+
.fseventsd
21+
.Spotlight-V100
22+
.TemporaryItems
23+
.Trashes
24+
.VolumeIcon.icns
25+
.com.apple.timemachine.donotpresent
26+
27+
# Directories potentially created on remote AFP share
28+
.AppleDB
29+
.AppleDesktop
30+
Network Trash Folder
31+
Temporary Items
32+
.apdisk
33+

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,51 @@
1-
<img src="https://app.continuousphp.com/assets/logos/continuousphp.svg" alt="ContinuousPHP" width="250px" align="right"/>
1+
<a href="http://continuous.lu">
2+
<img src="https://app.continuousphp.com/assets/logos/continuousphp.svg" alt="ContinuousPHP" width="250px" align="right"/>
3+
</a>
24

35
<p align="left">
4-
<a href="https://continuousphp.com/git-hub/continuousphp/cli"><img alt="Build Status" src="https://status.continuousphp.com/git-hub/continuousphp/cli?token=9800bb61-98f2-447d-a331-025f0b9af298" /></a>
5-
<img src="https://img.shields.io/badge/version-alpha-red.svg" alt="Version" />
6-
<a href="https://packagist.org/packages/continuousphp/cli"><img src="https://img.shields.io/packagist/dt/continuousphp/cli.svg" alt="Packagist" /></a>
6+
<a href="https://continuousphp.com/git-hub/continuousphp/cli"><img alt="Build Status" src="https://status.continuousphp.com/git-hub/continuousphp/cli?token=8eb1b41e-343a-41b5-b68f-179fb1ce1ffe&branch=master" /></a>
77
</p>
8+
89
<p align="left">
910
ContinuousPHP© is the first and only PHP-centric PaaS to build, package, test and deploy applications in the same workflow.
1011
</p>
1112

1213
# ContinuousPHP\Cli
1314

14-
CLI for ContinuousPHP platform. Manage project and build easily from your favorite terminal.
15+
CLI for the ContinuousPHP platform. Manage projects and build easily from your favorite terminal.
1516

16-
## Installation
17+
## Installation as Phar ( Recommended )
1718

18-
With [Composer](https://getcomposer.org/), to include this library into your dependencies, you need to require [`continuousphp/cli`](https://packagist.org/packages/continuousphp/cli):
19+
Download the latest version of continuousphpcli as a Phar:
1920

2021
```sh
21-
$ composer require continuousphp/cli '~0.0'
22+
$ curl -LSs https://continuousphp.github.io/cli/phar-installer.php | php
2223
```
2324

24-
## Usage
25+
The command will check your PHP settings, warn you of any issues, and then download it to the current directory.
26+
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.
27+
You can even rename it to just `continuousphpcli` to avoid having to type the .phar extension every time.
28+
29+
## Documentation
30+
31+
You can find Markdown documentation into `docs` subfolder or on web version at https://continuousphp.github.io/cli/doc
32+
Thanks to open an issue if you see something missing in our documentation.
33+
34+
## Credit
35+
36+
This project was made based on Open-Source project, thanks to them!
37+
38+
* [Box](https://github.com/box-project/box2) - PHAR builder
39+
* [Symfony\Console](https://github.com/symfony/console) - PHP Console Service
40+
* [Hoa\Console](https://github.com/hoaproject/Console) - PHP Console library
2541

2642
## Contributing
2743

2844
1. Fork it :clap:
2945
2. Create your feature branch: `git checkout -b feat/my-new-feature`
30-
3. Write your Unit and Functional testing
46+
3. Write your Unit and Functional tests
3147
4. Commit your changes: `git commit -am 'Add some feature'`
3248
5. Push to the branch: `git push origin feat/my-new-feature`
33-
6. Submit a pull request with the detail of your implementation
49+
6. Submit a pull request with the details of your implementation
3450
7. Take a drink during our review and merge :beers:
3551

bin/continuousphp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$autoloaders = ['vendor', '../..'];
5+
6+
foreach ($autoloaders as $autoloader) {
7+
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR .
8+
$autoloader . DIRECTORY_SEPARATOR . 'autoload.php';
9+
10+
if (file_exists($path)) {
11+
require_once $path;
12+
break;
13+
}
14+
}
15+
16+
$app = new \Continuous\Cli\ApplicationFactory();
17+
$app
18+
->create()
19+
->run()
20+
;

box.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"files": [
3+
"constants.php"
4+
],
5+
"directories": [
6+
"src"
7+
],
8+
"finder": [
9+
{
10+
"name": "*.php",
11+
"exclude": [
12+
"phpunit",
13+
"phpunit-test-case",
14+
"Tester",
15+
"Tests",
16+
"Test",
17+
"tests",
18+
"yaml"
19+
],
20+
"in": "vendor"
21+
}
22+
],
23+
"git-version": "git-version",
24+
"replacements": {
25+
"my-custom-place-holder": "custom-value-dev-master"
26+
},
27+
"main": "bin/continuousphp",
28+
"output": "continuousphp-@git-version@.phar",
29+
"stub": true
30+
}

composer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "continuousphp/cli",
3+
"description": "The command line interface to ContinuousPHP Platform",
4+
"type": "library",
5+
"license": "Apache-2.0",
6+
"authors": [
7+
{
8+
"name": "Pierre Tomasina",
9+
"email": "pierre.tomasina@continuousphp.com"
10+
}
11+
],
12+
"require": {
13+
"continuousphp/sdk": "dev-feat/entities",
14+
"symfony/console": "^3.3",
15+
"hoa/console": "~3.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Continuous\\Cli\\": "src/"
20+
},
21+
"files": ["constants.php"]
22+
},
23+
"autoload-dev": {
24+
"psr-4": {
25+
"Continuous\\Cli\\Tests\\": "tests/"
26+
}
27+
},
28+
"bin": ["bin/continuousphp"],
29+
"repositories": [
30+
{
31+
"type": "vcs",
32+
"url": "https://github.com/Pierozi/guzzle-services.git"
33+
}
34+
]
35+
}

constants.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
/**
4+
* @version @git-version@
5+
*/
6+
namespace Continuous\Cli;
7+
8+
define(__NAMESPACE__ . '\\' . 'version', '@git-version@');

cphp-gh-release-asset.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
sign()
4+
{
5+
gpg --detach-sign $1
6+
gpg --verify $1.sig $1
7+
}
8+
9+
TAG=`echo ${CPHP_GIT_REF} | tail -c +11`
10+
PHAR_NAME="continuousphp-$TAG.phar"
11+
12+
if [ -z ${CONTINUOUSPHP} ];
13+
then
14+
echo "Your are not on ContinuousPHP environment"
15+
exit 1
16+
fi
17+
18+
sign $PHAR_NAME
19+
20+
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'`
21+
22+
echo "Attach phar to github release: $PHAR_NAME"
23+
echo "Upload to $upload_url"
24+
25+
curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" --upload-file $PHAR_NAME "$upload_url?name=continuousphpcli.phar"
26+
curl -sS -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" --upload-file "$PHAR_NAME.sig" "$upload_url?name=continuousphpcli.sig"
27+
28+
rm -rf .git
29+
mkdocs build -d doc_dist
30+
31+
git clone "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" cli-site
32+
cd cli-site
33+
git checkout gh-pages
34+
rm -rf doc
35+
mv ../doc_dist doc
36+
37+
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);'
38+
39+
git config user.email "info@continuousphp.com"
40+
git config user.name "${CPHP_BUILT_BY}"
41+
42+
git add -A doc
43+
git add manifest.json
44+
45+
git commit -m "Update doc to tag $TAG"
46+
git push origin gh-pages

docs/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# What is ContinuousPHP
2+
3+
ContinuousPHP is the first and only PHP-centric PaaS to build, package, test and deploy applications in the same workflow.
4+
5+
The ContinuousPHP CLI is a command line interface for the ContinuousPHP Platform.
6+
7+
## Installation
8+
9+
We recommend using the php installer script to install the latest version
10+
of continuousphpcli PHAR.
11+
12+
$ curl -LSs https://continuousphp.github.io/cli/phar-installer.php | php
13+
# Move the phar in your user bin directory
14+
$ mv continuousphpcli.phar /usr/local/bin/continuousphpcli
15+
16+
The command will check your PHP settings, warn you of any issues, and then download it to the current directory.
17+
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.
18+
You can even rename it to just `continuousphpcli` to avoid having to type the .phar extension every time.
19+
20+
## Configuration
21+
22+
By default, some of the continuousphp API requests do not require to be authenticated.
23+
But you will certainly need to authenticate for commands that require permissions, like starting or stopping a build.
24+
25+
The cli implements a profile system to easily use different continuousphp accounts.
26+
27+
Each profile must be configured with the continuousphp user token. You can find a personal token
28+
on your credentials page at https://app.continuousphp.com/credentials
29+
30+
Configure a new profile in interactive mode with this command:
31+
32+
$ continuousphpcli configure
33+
> Profile name [default]: myProfileName
34+
> User Token: XXXXXXXXXX
35+
< Profile myUserAccount saved in /home/user/.continuousphp/credentials
36+
37+
If you choose `default` as the profile name, the continuousphpcli will automatically use this credential.
38+
Otherwise, you must specify the option `--profile myProfileName` on each command.

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
site_name: ContinuousPHP Cli
2+
theme: 'material'

src/ApplicationFactory.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace Continuous\Cli;
4+
5+
use Continuous\Cli\Command\Build\BuildListCommand;
6+
use Continuous\Cli\Command\Build\BuildStartCommand;
7+
use Continuous\Cli\Command\Build\BuildStopCommand;
8+
use Continuous\Cli\Command\Company\CompanyListCommand;
9+
use Continuous\Cli\Command\ConfigureCommand;
10+
use Continuous\Cli\Command\Project\ProjectListCommand;
11+
use Continuous\Cli\Command\Repository\RepositoryListCommand;
12+
use Symfony\Component\Console\Application;
13+
14+
/**
15+
* Class ApplicationFactory
16+
* @package Continuous\Cli
17+
*/
18+
final class ApplicationFactory
19+
{
20+
const NAME = 'ContinuousPHP Cli';
21+
22+
protected static $version;
23+
24+
/**
25+
* @return Application
26+
*/
27+
public function create()
28+
{
29+
$application = new Application(self::NAME, self::getVersion());
30+
$application->add(new ConfigureCommand());
31+
$application->add(new CompanyListCommand());
32+
$application->add(new RepositoryListCommand());
33+
$application->add(new ProjectListCommand());
34+
$application->add(new BuildListCommand());
35+
$application->add(new BuildStartCommand());
36+
$application->add(new BuildStopCommand());
37+
38+
return $application;
39+
}
40+
41+
/**
42+
* Return the current version of continuousphp cli.
43+
*
44+
* @return string
45+
*/
46+
public static function getVersion()
47+
{
48+
return constant(__NAMESPACE__ . '\\' . 'version');
49+
}
50+
}

0 commit comments

Comments
 (0)