Skip to content

Commit

Permalink
Feat/basic command (#11)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Pierozi authored Jun 28, 2017
1 parent 08ae674 commit a1f0bec
Show file tree
Hide file tree
Showing 18 changed files with 988 additions and 11 deletions.
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/vendor/
composer.lock


.idea

### 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

38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
<img src="https://app.continuousphp.com/assets/logos/continuousphp.svg" alt="ContinuousPHP" width="250px" align="right"/>
<a href="http://continuous.lu">
<img src="https://app.continuousphp.com/assets/logos/continuousphp.svg" alt="ContinuousPHP" width="250px" align="right"/>
</a>

<p align="left">
<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>
<img src="https://img.shields.io/badge/version-alpha-red.svg" alt="Version" />
<a href="https://packagist.org/packages/continuousphp/cli"><img src="https://img.shields.io/packagist/dt/continuousphp/cli.svg" alt="Packagist" /></a>
<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>
</p>

<p align="left">
ContinuousPHP© is the first and only PHP-centric PaaS to build, package, test and deploy applications in the same workflow.
</p>

# 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
## 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
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.

## 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:
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:

20 changes: 20 additions & 0 deletions bin/continuousphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env php
<?php

$autoloaders = ['vendor', '../..'];

foreach ($autoloaders as $autoloader) {
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR .
$autoloader . DIRECTORY_SEPARATOR . 'autoload.php';

if (file_exists($path)) {
require_once $path;
break;
}
}

$app = new \Continuous\Cli\ApplicationFactory();
$app
->create()
->run()
;
30 changes: 30 additions & 0 deletions box.json
Original file line number Diff line number Diff line change
@@ -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-@[email protected]",
"stub": true
}
35 changes: 35 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "continuousphp/cli",
"description": "The command line interface to ContinuousPHP Platform",
"type": "library",
"license": "Apache-2.0",
"authors": [
{
"name": "Pierre Tomasina",
"email": "[email protected]"
}
],
"require": {
"continuousphp/sdk": "dev-feat/entities",
"symfony/console": "^3.3",
"hoa/console": "~3.0"
},
"autoload": {
"psr-4": {
"Continuous\\Cli\\": "src/"
},
"files": ["constants.php"]
},
"autoload-dev": {
"psr-4": {
"Continuous\\Cli\\Tests\\": "tests/"
}
},
"bin": ["bin/continuousphp"],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Pierozi/guzzle-services.git"
}
]
}
8 changes: 8 additions & 0 deletions constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

/**
* @version @git-version@
*/
namespace Continuous\Cli;

define(__NAMESPACE__ . '\\' . 'version', '@git-version@');
46 changes: 46 additions & 0 deletions cphp-gh-release-asset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

sign()
{
gpg --detach-sign $1
gpg --verify $1.sig $1
}

TAG=`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"

rm -rf .git
mkdocs build -d doc_dist

git clone "https://${GITHUB_TOKEN}@github.com/continuousphp/cli.git" cli-site
cd cli-site
git checkout gh-pages
rm -rf doc
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 "[email protected]"
git config user.name "${CPHP_BUILT_BY}"

git add -A doc
git add manifest.json

git commit -m "Update doc to tag $TAG"
git push origin gh-pages
38 changes: 38 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -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 a command line interface for the ContinuousPHP Platform.

## Installation

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 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 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 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

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 choose `default` as the profile name, the continuousphpcli will automatically use this credential.
Otherwise, you must specify the option `--profile myProfileName` on each command.
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
site_name: ContinuousPHP Cli
theme: 'material'
50 changes: 50 additions & 0 deletions src/ApplicationFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

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\ConfigureCommand;
use Continuous\Cli\Command\Project\ProjectListCommand;
use Continuous\Cli\Command\Repository\RepositoryListCommand;
use Symfony\Component\Console\Application;

/**
* Class ApplicationFactory
* @package Continuous\Cli
*/
final class ApplicationFactory
{
const NAME = 'ContinuousPHP Cli';

protected static $version;

/**
* @return Application
*/
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());
$application->add(new BuildListCommand());
$application->add(new BuildStartCommand());
$application->add(new BuildStopCommand());

return $application;
}

/**
* Return the current version of continuousphp cli.
*
* @return string
*/
public static function getVersion()
{
return constant(__NAMESPACE__ . '\\' . 'version');
}
}
Loading

0 comments on commit a1f0bec

Please sign in to comment.