This repository has been archived by the owner on Apr 6, 2024. It is now read-only.
generated from Muetze42/console-app-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
56 changed files
with
3,014 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/node_modules | ||
/vendor | ||
/.idea | ||
/.vs | ||
/.vscode | ||
/vendor | ||
composer.lock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,73 @@ | ||
# Console App Template | ||
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine/) | ||
|
||
Creating Console Applications with [Laravel Console Commands](https://laravel.com/docs/artisan) based on [Symfony Console Commands](https://symfony.com/doc/current/console.html). | ||
# Lura | ||
|
||
--- | ||
DONT FORGET TO RENAME `bin/app` TO YOUR APP COMMAND AND CHANGE IT `composer.json`: | ||
An command line installer and generator kit. | ||
**Currently still under development.** | ||
|
||
```json | ||
{ | ||
"bin": [ | ||
"bin/app" | ||
] | ||
} | ||
_Supported_ | ||
|
||
* :white_check_mark: Laravel | ||
* :white_check_mark: Laravel Breeze | ||
* :white_check_mark: Laravel Jetstream | ||
* :white_check_mark: Laravel Nova | ||
* :white_check_mark: Laravel Package | ||
* :black_square_button: (Illuminate) Standalone Packages _(In development)_<br>Current available: | ||
* [illuminate/cache](https://github.com/illuminate/cache) | ||
* [illuminate/database](https://github.com/illuminate/database) | ||
* [illuminate/filesystem](https://github.com/illuminate/filesystem) | ||
* [illuminate/support](https://github.com/illuminate/support) | ||
* [illuminate/validation](https://github.com/illuminate/validation) | ||
* [illuminate/view](https://github.com/illuminate/view) | ||
* :white_square_button: Statamic _(In planning)_ | ||
* :white_square_button: Symfony _(In planning)_ | ||
* :white_square_button: Pimcore _(In planning)_ | ||
* :white_square_button: CoreShop _(In planning)_ | ||
|
||
## Installation | ||
|
||
```bash | ||
composer global require norman-huth/lura | ||
``` | ||
|
||
## Usage | ||
|
||
### Create a app, package etc | ||
|
||
```bash | ||
lura create | ||
``` | ||
|
||
Alternative: | ||
|
||
```bash | ||
lura new | ||
``` | ||
|
||
### Install a (standalone) package | ||
|
||
```bash | ||
lura install | ||
``` | ||
|
||
### Show current config | ||
|
||
```bash | ||
lura config | ||
``` | ||
|
||
### Set config | ||
|
||
```bash | ||
lura config set custom-app-path /path-to-/folder | ||
``` | ||
|
||
Array | ||
|
||
```bash | ||
lura config set default-author.homepage https://huth.it | ||
``` | ||
|
||
## Documentation | ||
|
||
Still comes everything ;) 🙃 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<?php | ||
|
||
namespace create; | ||
|
||
use Illuminate\Support\Str; | ||
use Lura\Service\Creator; | ||
use function Symfony\Component\Translation\t; | ||
|
||
class LaravelPackage extends Creator | ||
{ | ||
protected string $vendorName; | ||
protected string $vendor; | ||
protected string $packageName; | ||
protected string $description; | ||
protected string $authorName; | ||
protected string $authorEmail; | ||
protected string $authorHomepage; | ||
protected string $authorRole; | ||
protected string $licence; | ||
protected string $namespace; | ||
|
||
/** | ||
* @throws \Exception | ||
*/ | ||
protected function executeLura(): int | ||
{ | ||
$this->packageName = static::askingForInformation('Package name'); | ||
$this->packageName = static::slug($this->packageName); | ||
if (!static::existCheck($this->packageName)) { | ||
return self::FAILURE; | ||
} | ||
static::setTargetDisk($this->packageName); | ||
|
||
$git = static::getGitConfig(); | ||
if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) { | ||
$defaultVendor = $_SERVER['COMPOSER_DEFAULT_VENDOR']; | ||
} elseif (isset($git['github.user'])) { | ||
$defaultVendor = $git['github.user']; | ||
} elseif (!empty($_SERVER['USERNAME'])) { | ||
$defaultVendor = $_SERVER['USERNAME']; | ||
} elseif (!empty($_SERVER['USER'])) { | ||
$defaultVendor = $_SERVER['USER']; | ||
} elseif (get_current_user()) { | ||
$defaultVendor = get_current_user(); | ||
} else { | ||
$defaultVendor = null; | ||
} | ||
|
||
if ($defaultVendor) { | ||
$defaultVendor = static::slug($defaultVendor); | ||
} | ||
|
||
$this->vendorName = static::askingForInformation('Vendor [<comment>'.(string)$defaultVendor.'</comment>]', true, $defaultVendor); | ||
|
||
$this->vendorName = static::slug($this->vendorName); | ||
|
||
$this->vendor = $this->vendorName.'/'.$this->packageName; | ||
static::$output->write('Vendor: <info>'.$this->vendor.'</info>'); | ||
|
||
$defaultNameSpace = Str::studly($this->vendorName).'\\'.Str::studly($this->packageName); | ||
$this->namespace = static::askingForInformation('Namespace [<comment>'.$defaultNameSpace.'</comment>]', true, $defaultNameSpace); | ||
|
||
$this->description = static::askingForInformation('Description', false); | ||
|
||
$defaultLicence = data_get(static::$luraConfig, 'default-licence'); | ||
if (!$defaultLicence && !empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) { | ||
$defaultLicence = $_SERVER['COMPOSER_DEFAULT_LICENSE']; | ||
} | ||
|
||
$this->licence = static::askingForInformation('Licence [<comment>'.$defaultLicence.'</comment>]', true, $defaultLicence); | ||
static::$output->write('Licence: <info>'.$this->licence.'</info>'); | ||
|
||
$defaultAuthorName = data_get(static::$luraConfig, 'default-author.name'); | ||
if (!$defaultAuthorName) { | ||
if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) { | ||
$defaultAuthorName = $_SERVER['COMPOSER_DEFAULT_AUTHOR']; | ||
} elseif (isset($git['user.name'])) { | ||
$defaultAuthorName = $git['user.name']; | ||
} else { | ||
$defaultAuthorName = null; | ||
} | ||
} | ||
|
||
$this->authorName = static::askingForInformation('Author Name [<comment>'.$defaultAuthorName.'</comment>]', false, $defaultAuthorName); | ||
|
||
if ($this->authorName) { | ||
$defaultAuthorEmail = data_get(static::$luraConfig, 'default-author.email'); | ||
if (!$defaultAuthorEmail) { | ||
if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) { | ||
$defaultAuthorEmail = $_SERVER['COMPOSER_DEFAULT_EMAIL']; | ||
} elseif (isset($git['user.email'])) { | ||
$defaultAuthorEmail = $git['user.email']; | ||
} | ||
} | ||
|
||
$this->authorEmail = static::askingForInformation('Author Email [<comment>'.$defaultAuthorEmail.'</comment>]', false, $defaultAuthorEmail); | ||
|
||
$defaultAuthorHomepage = data_get(static::$luraConfig, 'default-author.homepage'); | ||
if (!$defaultAuthorHomepage) { | ||
if (!empty($_SERVER['COMPOSER_DEFAULT_HOMEPAGE'])) { | ||
$defaultAuthorHomepage = $_SERVER['COMPOSER_DEFAULT_HOMEPAGE']; | ||
} elseif (isset($git['user.homepage'])) { | ||
$defaultAuthorHomepage = $git['user.homepage']; | ||
} elseif (isset($git['user.website'])) { | ||
$defaultAuthorHomepage = $git['user.website']; | ||
} elseif (isset($git['user.blog'])) { | ||
$defaultAuthorHomepage = $git['user.blog']; | ||
} | ||
} | ||
|
||
$this->authorHomepage = static::askingForInformation('Author Homepage [<comment>'.$defaultAuthorHomepage.'</comment>]', false, $defaultAuthorHomepage); | ||
|
||
$defaultRole = data_get(static::$luraConfig, 'default-author.role') ? data_get(static::$luraConfig, 'default-author.role') : null; | ||
$this->authorRole = static::askingForInformation('Author Role [<comment>'.$defaultRole.'</comment>]', false, $defaultRole); | ||
} | ||
|
||
$this->createPackage(); | ||
|
||
static::moveExistBack($this->packageName); | ||
|
||
return static::SUCCESS; | ||
} | ||
|
||
protected function createPackage() | ||
{ | ||
static::publishFolder('package', ''); | ||
$composerJson = json_decode(static::$targetDisk->get('composer.json'), true); | ||
data_set($composerJson, 'name', $this->vendor); | ||
|
||
if ($this->description) { | ||
data_set($composerJson, 'description', $this->description); | ||
} else { | ||
unset($composerJson['description']); | ||
} | ||
|
||
$author = null; | ||
if ($this->authorName) { | ||
$author['name'] = $this->authorName; | ||
|
||
if ($this->authorEmail) { | ||
$author['email'] = $this->authorEmail; | ||
} | ||
if ($this->authorHomepage) { | ||
$author['homepage'] = $this->authorHomepage; | ||
} | ||
if ($this->authorRole) { | ||
$author['role'] = $this->authorRole; | ||
} | ||
} | ||
if ($author) { | ||
data_set($composerJson, 'authors', [$author]); | ||
} else { | ||
unset($composerJson['authors']); | ||
} | ||
|
||
data_set($composerJson, 'autoload.psr-4', [$this->namespace.'\\' => 'src/']); | ||
data_set($composerJson, 'extra.laravel.providers', [$this->namespace.'\\ServiceProvider']); | ||
|
||
static::$targetDisk->put('composer.json', json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); | ||
static::$targetDisk->move('gitignore.txt', '.gitignore'); | ||
|
||
$file = 'src/ServiceProvider.php'; | ||
static::$targetDisk->put( | ||
$file, | ||
str_replace('Lura', $this->namespace, static::$targetDisk->get($file)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "norman-huth/lura", | ||
"description": "lura-description", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Lura\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Norman Huth", | ||
"email": "norman@example.com", | ||
"homepage": "https://huth.it", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.0", | ||
"laravel/framework": "^8.0|^9.0" | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Lura\\ServiceProvider" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/node_modules | ||
/public/build | ||
/public/hot | ||
/public/storage | ||
/storage/*.key | ||
/vendor | ||
.env | ||
.env.backup | ||
.phpunit.result.cache | ||
Homestead.json | ||
Homestead.yaml | ||
auth.json | ||
npm-debug.log | ||
yarn-error.log | ||
/.idea | ||
/.vscode |
28 changes: 28 additions & 0 deletions
28
app/create/laravel-package/package/src/ServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Lura; | ||
|
||
use Illuminate\Support\ServiceProvider as Provider; | ||
|
||
class ServiceProvider extends Provider | ||
{ | ||
/** | ||
* Bootstrap any package services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot(): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register(): void | ||
{ | ||
// | ||
} | ||
} |
Oops, something went wrong.