Skip to content

Commit

Permalink
🎉 Primeiro commit
Browse files Browse the repository at this point in the history
  • Loading branch information
i9w3b committed May 12, 2020
0 parents commit 24db744
Show file tree
Hide file tree
Showing 6 changed files with 344 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Marcelo Sena

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# ThemeInstall

<p align="center" class="text-center" style="text-align:center;"><a href="https://i9w3b.github.io" target="_blank"><img src="https://i9w3b.github.io/i9w3b.png" width="200"></a></p>
<p align="center" class="text-center" style="text-align:center;">
<a href="https://github.com/i9w3b/theme-install/blob/master/LICENSE.md"><img src="https://img.shields.io/github/license/i9w3b/theme-install" alt="License"></a>
<a href="https://github.com/i9w3b/theme-install"><img src="https://img.shields.io/github/languages/count/i9w3b/theme-install" alt="GitHub Language Count"></a>
<a href="https://github.com/i9w3b/theme-install"><img src="https://img.shields.io/github/repo-size/i9w3b/theme-install" alt="GitHub Repo Size"></a>
<a href="https://github.com/i9w3b/theme-install/releases"><img src="https://img.shields.io/github/v/release/i9w3b/theme-install" alt="GitHub Release"></a>
<a href="https://github.com/i9w3b/theme-install"><img src="https://img.shields.io/github/downloads/i9w3b/theme-install/total" alt="Total Downloads"></a>
</p>

Instalar temas Laravel hospedados no GitHub

Cansou de digitar os comando abaixo só para criar as visualizações padrão em todos os projetos de desenvolvimento em Laravel?

```bash
$ composer require laravel/ui
$ php artisan ui bootstrap --auth
$ npm install && npm run dev
```

## Estrutura do tema padrão

```txt
layouts/
├── app.blade.php
└── shared/
└── css.blade.php
home.blade.php
welcome.blade.php
```

## Instalação

Execute o seguinte comando:

```bash
composer require i9w3b/theme-install --dev
```

## Como Usar

O comando abaixo, fornece uma estrutura básica de views padrão para iniciar um projeto.

```bash
php artisan theme:install https://github.com/i9w3b/theme-laravel.git
```

>- ## Observação de uso:
>- `theme:install` é o comando artisan que faz todo o trabalho
>- `https://github.com/i9w3b/theme-laravel.git` fica a sua escolha
Você pode alterar a url como no exemplo:

```bash
php artisan theme:install https://github.com/sua_conta/repositorio_do_tema.git
```

## Configuração

Execute:

```bash
php artisan vendor:publish --provider="I9W3b\ThemeInstall\ThemeInstallServiceProvider"
```

Agora você pode personalizar algumas variáveis no arquivo publicado `config/themeinstall.php`

## Dúvidas/Sugestões

Se encontrar erros ou tiver sugestões de melhorias, acesse: [issues](https://github.com/i9w3b/theme-install/issues/new)

## Licença

[MIT](https://github.com/i9w3b/theme-install/blob/master/LICENSE.md) © [i9W3b](https://github.com/i9w3b)
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "i9w3b/theme-install",
"description": "Instalar Temas em Projetos Laravel",
"keywords": ["i9w3b", "laravel", "package", "themes", "theme-install"],
"homepage": "https://github.com/i9w3b/theme-install",
"license": "MIT",
"authors": [{
"name": "Marcelo Sena",
"email": "[email protected]",
"homepage": "https://github.com/i9w3b",
"role": "Developer"
}],
"require": {
"php": ">=7.2"
},
"require-dev": {},
"extra": {
"laravel": {
"providers": [
"I9W3b\\ThemeInstall\\ThemeInstallServiceProvider"
],
"aliases": {},
"branch-alias": {}
}
},
"autoload": {
"psr-4": {
"I9W3b\\ThemeInstall\\": "src"
}
},
"autoload-dev": {
"psr-4": {}
},
"scripts": {},
"config": {
"sort-packages": true
}
}
51 changes: 51 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
*/
'name' => 'ThemeInstall',

/*
|--------------------------------------------------------------------------
| Messages
|--------------------------------------------------------------------------
*/
'msg_confirm' => 'Isso substituirá as views padrão. Deseja continuar?',
'msg_confirm_auth_v' => 'Incluir as views de autenticação?',
'msg_confirm_auth_i' => 'Instalar autenticação padrão?',
'msg_info_download' => 'Baixando tema do repositório GitHub Instalando tema ...',
'msg_info_install' => 'Instalando tema ...',
'msg_info_success' => 'Tema adicionado com sucesso!',
'msg_info_error' => 'Erro!, nada foi alterado!',
'msg_info_off' => 'Nada foi alterado!',

/*
|--------------------------------------------------------------------------
| Temporary storage clone
|--------------------------------------------------------------------------
*/
'tmp_storage_clone' => 'storage/app/tmp_i9theme',

/*
|--------------------------------------------------------------------------
| Del files
|--------------------------------------------------------------------------
*/
'del_file' => [
'/README.md','/LICENSE.md'
],

/*
|--------------------------------------------------------------------------
| Del dir
|--------------------------------------------------------------------------
*/
'del_dir' => [
'/pasta_teste'
],

];
107 changes: 107 additions & 0 deletions src/Console/ThemeInstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?php

namespace I9W3b\ThemeInstall\Console;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class ThemeInstallCommand extends Command
{
protected $name = 'theme:install';
protected $description = 'Instala temas de repositórios GitHub';

public function __construct()
{
parent::__construct();
}

public function handle()
{

// url do repositório do dos arquivos a serem instalados
$urlGitHub = $this->argument('$urlGitHub');
$pathInstallTmp=config('themeinstall.tmp_storage_clone');

// confirmar a instalação
if ($this->confirm(config('themeinstall.msg_confirm'))) {

$commandLine='git clone '. $urlGitHub . ' ' . $pathInstallTmp . $this->listDel() . ' && cp -rf ' . $pathInstallTmp . '/* resources/views/ && rm -rf ' . $pathInstallTmp;

// confirmar a instalação de autenticação
if ($this->confirm(config('themeinstall.msg_confirm_auth_i'))) {
$commandLine='composer require laravel/ui && php artisan ui:controllers && php artisan ui:auth --force && '.$commandLine;
}

$this->info(config('themeinstall.msg_info_download'));
$this->info('');
$this->info(config('themeinstall.msg_info_install'));
$this->info('');

// $process = Process::fromShellCommandline("$commandLine");
// $process->run();

dd($commandLine);
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}

$process->getOutput();

$this->info(config('themeinstall.msg_info_success'));

} else {
$this->info(config('themeinstall.msg_info_error'));
}
}

/**
* Listar arquivos e diretórios para excluir.
*
* @return string
*/
protected function listDel()
{
$returnCommand='';

if (count(config('themeinstall.del_file')) >= 1) {
foreach (config('themeinstall.del_file') as $vfile) {
$returnCommand.=" && rm -f " . config('themeinstall.tmp_storage_clone') . $vfile;
}
}

if (count(config('themeinstall.del_dir')) >= 1) {
foreach (config('themeinstall.del_dir') as $dfile) {
$returnCommand.=" && rm -rf " . config('themeinstall.tmp_storage_clone') . $dfile;
}
}

return $returnCommand;
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['$urlGitHub', InputArgument::REQUIRED, 'Argumento Url GitHub.'],
];
}

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
['options', null, InputOption::VALUE_OPTIONAL, 'Opção de donwload.', null],
];
}
}
52 changes: 52 additions & 0 deletions src/ThemeInstallServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace I9W3b\ThemeInstall;

use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use I9W3b\ThemeInstall\Console\ThemeInstallCommand;

/**
* Class ThemeInstallServiceProvider
*
* @package I9W3b\ThemeInstall
* @author I9W3b <[email protected]>
*/
class ThemeInstallServiceProvider extends ServiceProvider
{

/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerConfig();
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->commands(ThemeInstallCommand::class);
}

/**
* Register config.
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
__DIR__.'/../config/config.php' => config_path('themeinstall.php'),
], 'themeinstall');
$this->mergeConfigFrom(
__DIR__.'/../config/config.php', 'themeinstall'
);
}
}

0 comments on commit 24db744

Please sign in to comment.