Skip to content

Commit

Permalink
Tweaked documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen-G committed Jun 10, 2015
1 parent c236db1 commit 4f8b467
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 9 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "jeroen-g/packager",
"description": "A cli tool for creating packages.",
"description": "A cli tool for creating Laravel packages.",
"keywords": [
"Packager",
"Laravel",
"package",
"skeleton"
"skeleton",
"Github"
],
"homepage": "https://github.com/Jeroen-G/packager",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

Contributions are **welcome** via Pull Requests on [Github](https://github.com/Jeroen-G/laravel-photo-gallery).
Contributions are **welcome** via Pull Requests on [Github](https://github.com/Jeroen-G/Packager).

An interesting read is [Contributing to a Github Project](http://jasonlewis.me/article/contributing-to-a-github-project).

Expand Down
12 changes: 10 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Packager

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Jeroen-G/packager/badges/quality-score.png)](https://scrutinizer-ci.com/g/Jeroen-G//)
[![Latest Version](https://img.shields.io/github/release/jeroen-g/packager.svg?style=flat)](https://github.com/jeroen-g/packager/releases)
[![License](https://img.shields.io/badge/License-EUPL--1.1-blue.svg?style=flat)](license.md)

Expand All @@ -18,11 +17,20 @@ Then add the service provider in `config/app.php`:

## Usage

### New package
The command will handle practically everything for you. It will create a packages directory, creates the vendor and package directory in it, pulls in a skeleton package, sets up composer.json, creates a service provider, registers the package in config/app.php and the app's composer.json. So you can start right away with only this command:
``` bash
$ artisan packager:new MyVendor MyPackage
```

If you would like to use [league/skeleton](https://github.com/thephpleague/skeleton), add the `--skeleton` flag to it.
The new package will be based on [league/skeleton](https://github.com/thephpleague/skeleton), plus a Laravel service provider.

### Existing package
If you already have your package on Github, it is possible to download that:
``` bash
$ artisan packager:get https://github.com/author/repository
```
This will too register the package in config/app.php and the app's composer.json file.

## Contributing

Expand Down
7 changes: 7 additions & 0 deletions src/PackagerGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
use Illuminate\Console\Command;
use JeroenG\Packager\PackagerHelper;

/**
* Get an existing package from a remote Github repository.
*
* @package Packager
* @author JeroenG
*
**/
class PackagerGetCommand extends Command
{
/**
Expand Down
48 changes: 44 additions & 4 deletions src/PackagerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,35 @@
use GuzzleHttp\Client;
use Illuminate\Filesystem\Filesystem;

/**
* Helper functions for the Packager commands.
*
* @package Packager
* @author JeroenG
*
**/
class PackagerHelper
{
/**
* The filesystem handler
* @var object
*/
protected $files;

/**
* Create a new instance
* @param Illuminate\Filesystem\Filesystem $files
*/
public function __construct(Filesystem $files)
{
$this->files = $files;
}

/**
* Setting custom formatting for the progress bar
* @param object $bar Symfony ProgressBar instance
* @return object $bar Symfony ProgressBar instance
*/
public function barSetup($bar)
{
// the finished part of the bar
Expand All @@ -33,6 +53,14 @@ public function barSetup($bar)
return $bar;
}

/**
* Open haystack, find and replace needles, save haystack
* @param string $oldFile The haystack
* @param mixed $search String or array to look for (the needles)
* @param mixed $replace What to replace the needles for?
* @param string $newFile Where to save, defaults to $oldFile
* @return void
*/
public function replaceAndSave($oldFile, $search, $replace, $newFile = null)
{
$newFile = ($newFile == null) ? $oldFile : $newFile ;
Expand All @@ -41,13 +69,25 @@ public function replaceAndSave($oldFile, $search, $replace, $newFile = null)
$this->files->put($newFile, $replacing);
}

/**
* Check if the package already exists
* @param string $path Path to the package directory
* @param string $vendor The vendor
* @param string $name Name of the package
* @return void Throws error if package exists, aborts process
*/
public function checkExistingPackage($path, $vendor, $name)
{
if(is_dir($path.$vendor.'/'.$name)){
throw new RuntimeException('Package already exists');
}
}

/**
* Create a directory if it doesn't exist
* @param string $path Path of the directory to make
* @return void
*/
public function makeDir($path)
{
if(!is_dir($path)) {
Expand All @@ -56,7 +96,7 @@ public function makeDir($path)
}

/**
* Generate a random temporary filename.
* Generate a random temporary filename for the package zipfile
*
* @return string
*/
Expand All @@ -66,7 +106,7 @@ public function makeFilename()
}

/**
* Download the temporary Zip to the given file.
* Download the temporary Zip to the given file
*
* @param string $zipFile
* @return $this
Expand All @@ -79,7 +119,7 @@ public function download($zipFile, $source)
}

/**
* Extract the zip file into the given directory.
* Extract the zip file into the given directory
*
* @param string $zipFile
* @param string $directory
Expand All @@ -95,7 +135,7 @@ public function extract($zipFile, $directory)
}

/**
* Clean-up the Zip file.
* Clean-up the Zip file
*
* @param string $zipFile
* @return $this
Expand Down
11 changes: 11 additions & 0 deletions src/PackagerNewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
use Illuminate\Console\Command;
use JeroenG\Packager\PackagerHelper;

/**
* Create a brand new package.
*
* @package Packager
* @author JeroenG
*
**/
class PackagerNewCommand extends Command
{
/**
Expand All @@ -21,6 +28,10 @@ class PackagerNewCommand extends Command
*/
protected $description = 'Create a new package.';

/**
* Packager helper class
* @var object
*/
protected $helper;

/**
Expand Down

0 comments on commit 4f8b467

Please sign in to comment.