Permalink
Browse files

Basic project

  • Loading branch information...
0 parents commit bdd74e1f7b10a342271c0982d4f9ad5b7c870086 @cristiancmello committed Jan 9, 2017
@@ -0,0 +1,3 @@
+/vendor/
+.idea/
+composer.lock
@@ -0,0 +1,32 @@
+{
+ "name": "cristiancmello/mecenas",
+ "description": "Laravel Mecenas (for Laravel 5.3)",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Cristian Mello",
+ "email": "cristianc.mello@gmail.com"
+ }
+ ],
+ "require": {},
+ "require-dev": {
+ "phpunit/phpunit": "^5.7",
+ "graham-campbell/testbench": "^3.2"
+ },
+ "autoload":{
+ "psr-4": {
+ "CristianMello\\Mecenas\\": "src/",
+ "CristianMello\\Mecenas\\Generators\\": "src/Generator/"
+ }
+ },
+ "autoload-dev":{
+ "psr-4":{
+ "CristianMello\\Mecenas\\Tests\\": "tests/"
+ }
+ },
+ "config": {
+ "preferred-install": "dist"
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true
+}
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ bootstrap="vendor/autoload.php"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+>
+ <testsuites>
+ <testsuite name="Laravel Mecenas Test Suite">
+ <directory suffix="Test.php">./tests</directory>
+ </testsuite>
+ </testsuites>
+</phpunit>
@@ -0,0 +1,8 @@
+# Laravel Mecenas
+
+<p align="center">
+ <img src="https://cdn.rawgit.com/cristiancmello/art/master/laravel-mecenas/laravel-mecenas-logo-plain-opt-animated.svg"/>
+</p>
+
+## Intro
+Laravel Mecenas is a REST package factory.
@@ -0,0 +1,24 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| Prettus Repository Config
+|--------------------------------------------------------------------------
+|
+|
+*/
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Generator Config
+ |--------------------------------------------------------------------------
+ |
+ */
+ 'generator' => [
+ 'basePath' => __DIR__.'/../../',
+ 'rootNamespace' => 'App\\',
+ 'paths' => [
+ 'stubsOverridePath' => __DIR__
+ ]
+ ]
+];
@@ -0,0 +1,70 @@
+<?php
+
+namespace CristianMello\Mecenas\Console\Commands;
+
+use CristianMello\Mecenas\Generators\PackageGenerator;
+use CristianMello\Mecenas\Generators\ComposerGenerator;
+use CristianMello\Mecenas\Generators\FileAlreadyExistsException;
+use Illuminate\Support\Collection;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\File;
+
+class MecenasCreate extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'mecenas:create {package}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Create a package';
+
+ /**
+ * The type of object being generated.
+ *
+ * @var string
+ */
+ protected $type = 'Package';
+
+ /**
+ * @var Collection
+ */
+ protected $generators = null;
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ try {
+
+ (new PackageGenerator([
+ 'package' => $this->argument('package')
+ ]))->run();
+
+ $this->info($this->type." '".$this->argument('package')."' created successfully.");
+ } catch (FileAlreadyExistsException $e) {
+ $this->error($this->type." '".$this->argument('package')."' already exists!");
+ return false;
+ }
+
+ $this->generators = new Collection();
+
+ $this->generators->push(new ComposerGenerator([
+ 'package' => $this->argument('package')
+ ]));
+
+ foreach ($this->generators as $generator)
+ {
+ $generator->run();
+ }
+ }
+}
@@ -0,0 +1,57 @@
+<?php
+
+namespace CristianMello\Mecenas\Generators;
+
+use Illuminate\Support\Str;
+
+class ComposerGenerator extends Generator
+{
+ /**
+ * Get stub name.
+ *
+ * @var string
+ */
+ protected $stub = 'Composer/composer.json';
+
+ /**
+ * Get destination path for generated file.
+ *
+ * @return string
+ */
+ public function getPath()
+ {
+ return $this->getBasePath() . '/' . $this->getPackagePath() . '/' . $this->getFileName();
+ }
+
+ /**
+ * Get base path of destination file.
+ *
+ * @return string
+ */
+ public function getBasePath()
+ {
+ return config('mecenas.generator.basePath', __DIR__.'/../../');
+ }
+
+ /**
+ * Get name input.
+ *
+ * @return string
+ */
+ public function getFileName()
+ {
+ return 'composer.json';
+ }
+
+ public function getPackagePath()
+ {
+ return $this->package;
+ }
+
+ public function getReplacements()
+ {
+ return [
+ 'PACKAGE' => $this->getPackagePath()
+ ];
+ }
+}
@@ -0,0 +1,14 @@
+<?php
+
+namespace CristianMello\Mecenas\Generators;
+
+use Exception;
+
+/**
+ * Class FileAlreadyExistsException
+ * @package CristianMello\Mecenas\Generators
+ */
+class FileAlreadyExistsException extends Exception
+{
+ //
+}
Oops, something went wrong.

0 comments on commit bdd74e1

Please sign in to comment.