From 4f8b467967665caf93154aa8a39016c391c8ca4f Mon Sep 17 00:00:00 2001 From: JeroenG Date: Wed, 10 Jun 2015 21:27:02 +0200 Subject: [PATCH] Tweaked documentation --- composer.json | 5 ++-- contributing.md | 2 +- readme.md | 12 ++++++++-- src/PackagerGetCommand.php | 7 ++++++ src/PackagerHelper.php | 48 ++++++++++++++++++++++++++++++++++---- src/PackagerNewCommand.php | 11 +++++++++ 6 files changed, 76 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 9524343..ec0b853 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/contributing.md b/contributing.md index f791a89..2792e8d 100644 --- a/contributing.md +++ b/contributing.md @@ -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). diff --git a/readme.md b/readme.md index 7672050..0153b6d 100644 --- a/readme.md +++ b/readme.md @@ -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) @@ -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 diff --git a/src/PackagerGetCommand.php b/src/PackagerGetCommand.php index ad0bbb7..3d7172d 100644 --- a/src/PackagerGetCommand.php +++ b/src/PackagerGetCommand.php @@ -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 { /** diff --git a/src/PackagerHelper.php b/src/PackagerHelper.php index 3c77e22..f43006f 100644 --- a/src/PackagerHelper.php +++ b/src/PackagerHelper.php @@ -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 @@ -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 ; @@ -41,6 +69,13 @@ 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)){ @@ -48,6 +83,11 @@ public function checkExistingPackage($path, $vendor, $name) } } + /** + * 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)) { @@ -56,7 +96,7 @@ public function makeDir($path) } /** - * Generate a random temporary filename. + * Generate a random temporary filename for the package zipfile * * @return string */ @@ -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 @@ -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 @@ -95,7 +135,7 @@ public function extract($zipFile, $directory) } /** - * Clean-up the Zip file. + * Clean-up the Zip file * * @param string $zipFile * @return $this diff --git a/src/PackagerNewCommand.php b/src/PackagerNewCommand.php index e16a0de..bca2fe8 100644 --- a/src/PackagerNewCommand.php +++ b/src/PackagerNewCommand.php @@ -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 { /** @@ -21,6 +28,10 @@ class PackagerNewCommand extends Command */ protected $description = 'Create a new package.'; + /** + * Packager helper class + * @var object + */ protected $helper; /**