-
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.
Initial commit
- Loading branch information
0 parents
commit df37e87
Showing
22 changed files
with
1,720 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/vendor | ||
/recipes | ||
/.idea | ||
composer.lock | ||
phpunit.xml | ||
.phpunit.result.cache | ||
.DS_Store |
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,19 @@ | ||
filter: | ||
excluded_paths: [tests/*] | ||
|
||
checks: | ||
php: | ||
remove_extra_empty_lines: true | ||
remove_php_closing_tag: true | ||
remove_trailing_whitespace: true | ||
fix_use_statements: | ||
remove_unused: true | ||
preserve_multiple: false | ||
preserve_blanklines: true | ||
order_alphabetically: true | ||
fix_php_opening_tag: true | ||
fix_linefeed: true | ||
fix_line_ending: true | ||
fix_identation_4spaces: true | ||
fix_doc_comments: true | ||
|
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,17 @@ | ||
language: php | ||
|
||
php: | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
|
||
env: | ||
matrix: | ||
- COMPOSER_FLAGS="" | ||
|
||
before_script: | ||
- travis_retry composer self-update | ||
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source | ||
|
||
script: | ||
- composer test |
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,55 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
Please read and understand the contribution guide before creating an issue or pull request. | ||
|
||
## Etiquette | ||
|
||
This project is open source, and as such, the maintainers give their free time to build and maintain the source code | ||
held within. They make the code freely available in the hope that it will be of use to other developers. It would be | ||
extremely unfair for them to suffer abuse or anger for their hard work. | ||
|
||
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the | ||
world that developers are civilized and selfless people. | ||
|
||
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient | ||
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. | ||
|
||
## Viability | ||
|
||
When requesting or submitting new features, first consider whether it might be useful to others. Open | ||
source projects are used by many developers, who may have entirely different needs to your own. Think about | ||
whether or not your feature is likely to be used by other users of the project. | ||
|
||
## Procedure | ||
|
||
Before filing an issue: | ||
|
||
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. | ||
- Check to make sure your feature suggestion isn't already present within the project. | ||
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. | ||
- Check the pull requests tab to ensure that the feature isn't already in progress. | ||
|
||
Before submitting a pull request: | ||
|
||
- Check the codebase to ensure that your feature doesn't already exist. | ||
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. | ||
|
||
## Requirements | ||
|
||
If the project maintainer has any additional requirements, you will find them listed here. | ||
|
||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). | ||
|
||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
|
||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. | ||
|
||
**Happy coding**! |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 synga-nl | ||
|
||
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. |
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,39 @@ | ||
# Advanced laravel installer | ||
Installs Laravel with additional packages specified in recipes. | ||
|
||
## Composer | ||
|
||
Run `composer global require synga/advanced-laravel-installer` | ||
|
||
## Commands | ||
|
||
When the composer bin directory is in your PATH you can call the following command everywhere: | ||
|
||
`advanced-laravel new` You can use this command to create a new laravel project in the current directory | ||
`advanced-laravel recipe` Create/Edit a recipe. You can add (development) packages and commands. | ||
`advanced-laravel recipe:list` List all the available recipes and their filenames | ||
`advanced-laravel recipe:open` Opens a recipe or the recipe directory in the file manager. | ||
|
||
## Improvements | ||
- [ ] Better console menu handling (Menustack), maybe | ||
- [ ] Composer command is used to search for packages. This needs to be improved because it causes bugs. | ||
- [ ] Save recipes in the cloud so you can use them anywhere, only access to your account is needed. | ||
- [ ] Include other recipes so you can composer recipes from other recipes. | ||
|
||
## Testing | ||
You can run the tests with: | ||
|
||
`composer test` | ||
|
||
## Contributing | ||
Since I'm getting some questions about this I want these things to be perfectly clear: | ||
|
||
This is a safe haven for contributions, every (positive) contributon matters! | ||
You are free (and encouraged) to use anything of this package for your own ideas. | ||
You can always ask for help or email me directly for any questions. | ||
|
||
## Security | ||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. | ||
|
||
## License | ||
The MIT License (MIT). Please see License File for more information. |
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,54 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
use Synga\Installer\Console\Command\ListRecipesCommand; | ||
use Synga\Installer\Console\Command\NewCommand; | ||
use Synga\Installer\Console\Command\OpenRecipeInFileManagerCommand; | ||
use Synga\Installer\Console\Command\RecipeCommand; | ||
|
||
if (file_exists(__DIR__ . '/../../../autoload.php')) { | ||
require __DIR__ . '/../../../autoload.php'; | ||
} else { | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
} | ||
|
||
// Copied from composer/composer. | ||
if (function_exists('ini_set')) { | ||
@ini_set('display_errors', 1); | ||
|
||
$memoryInBytes = function ($value) { | ||
$unit = strtolower(substr($value, -1, 1)); | ||
$value = (int) $value; | ||
switch($unit) { | ||
case 'g': | ||
$value *= 1024; | ||
// no break (cumulative multiplier) | ||
case 'm': | ||
$value *= 1024; | ||
// no break (cumulative multiplier) | ||
case 'k': | ||
$value *= 1024; | ||
} | ||
|
||
return $value; | ||
}; | ||
|
||
$memoryLimit = trim(ini_get('memory_limit')); | ||
// Increase memory_limit if it is lower than 1.5GB | ||
if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) { | ||
@ini_set('memory_limit', '1536M'); | ||
} | ||
// Set user defined memory limit | ||
if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) { | ||
@ini_set('memory_limit', $memoryLimit); | ||
} | ||
unset($memoryInBytes, $memoryLimit); | ||
} | ||
|
||
$app = new Symfony\Component\Console\Application('Advanced Laravel Installer', '1.0.0'); | ||
$app->add(new NewCommand()); | ||
$app->add(new RecipeCommand()); | ||
$app->add(new OpenRecipeInFileManagerCommand()); | ||
$app->add(new ListRecipesCommand()); | ||
|
||
$app->run(); |
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,52 @@ | ||
{ | ||
"name": "synga/advanced-laravel-installer", | ||
"description": "Can install a laravel application with preconfigured packages via recipes", | ||
"type": "library", | ||
"require": { | ||
"php": "^7.2.9", | ||
"ext-zip": "*", | ||
"ext-json": "*", | ||
"composer/composer": "^1.10", | ||
"guzzlehttp/guzzle": "^6.0", | ||
"illuminate/console": "^7.1", | ||
"symfony/filesystem": "^4.0|^5.0", | ||
"symfony/process": "^4.2|^5.0", | ||
"geekdevs/cli-highlighter": "^1.0", | ||
"tivie/php-os-detector": "^1.1" | ||
}, | ||
"bin": [ | ||
"bin/advanced-laravel" | ||
], | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.0|^9.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Synga\\Installer\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Laravel\\Installer\\Tests\\": "tests/" | ||
} | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Roy Pouls", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"scripts": { | ||
"test-coverage": [ | ||
"vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover" | ||
], | ||
"test": [ | ||
"vendor/bin/phpunit" | ||
] | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "stable" | ||
} |
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,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Laravel Installer Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,66 @@ | ||
<?php | ||
|
||
namespace Synga\Installer; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Synga\Installer\Recipes\Recipe; | ||
use Synga\Installer\Recipes\RecipeCollection; | ||
|
||
class AdvancedInstaller | ||
{ | ||
/** | ||
* @param Command $command | ||
*/ | ||
public static function configure(Command $command): void | ||
{ | ||
$command | ||
->addOption('recipe-path', null, InputOption::VALUE_REQUIRED, 'Path to recipe json.') | ||
->addOption('recipe-name', null, InputOption::VALUE_REQUIRED, 'Name of recipe.') | ||
->addOption('recipe', '-r', InputOption::VALUE_NONE, 'Choose recipe interactively.'); | ||
} | ||
|
||
/** | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* | ||
* @return Recipe | ||
*/ | ||
public static function getRecipe(InputInterface $input, OutputInterface $output): ?Recipe | ||
{ | ||
if (empty(array_diff( | ||
['recipe-path', 'recipe-name', 'recipe'], | ||
array_keys(array_filter($input->getOptions())) | ||
))) { | ||
return null; | ||
} | ||
|
||
$recipeOption = $input->getOption('recipe-path'); | ||
|
||
if (!empty($recipeOption)) { | ||
$recipe = Recipe::creatByFilePath($recipeOption); | ||
|
||
if ($recipe instanceof Recipe) { | ||
return $recipe; | ||
} | ||
} | ||
|
||
$recipeCollection = RecipeCollection::collect(__DIR__ . '/../recipes'); | ||
|
||
$recipeOption = $input->getOption('recipe-name'); | ||
|
||
if (!empty($recipeOption)) { | ||
$recipe = $recipeCollection->search($recipeOption); | ||
|
||
if (empty($recipe)) { | ||
$recipe = $recipeCollection->consoleSelect($input, $output); | ||
} | ||
|
||
return $recipe; | ||
} | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.