diff --git a/composer.json b/composer.json index 954f37d2..8f273bcf 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ } ], "require": { - "php": ">=5.5.9" + "php": ">=5.5.9", + "laravel/installer": ">=1.3.1" }, "bin": [ "lambo" diff --git a/composer.lock b/composer.lock index 4db2244e..401a1491 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,615 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "47cddee7fc5f056cff5f45e8d3d65717", - "content-hash": "2fab733ae8db7d0ffbe394f2f5b4286b", - "packages": [], + "content-hash": "d3419ba50be1e5470384168e44ba01e0", + "packages": [ + { + "name": "guzzlehttp/guzzle", + "version": "6.3.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699", + "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.0 || ^5.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.2-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2017-06-22T18:50:49+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2017-03-20T17:10:46+00:00" + }, + { + "name": "laravel/installer", + "version": "v1.3.7", + "source": { + "type": "git", + "url": "https://github.com/laravel/installer.git", + "reference": "bbd6171b9e9cce41c3e5538ffacc7ca50954e7ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/installer/zipball/bbd6171b9e9cce41c3e5538ffacc7ca50954e7ac", + "reference": "bbd6171b9e9cce41c3e5538ffacc7ca50954e7ac", + "shasum": "" + }, + "require": { + "ext-zip": "*", + "guzzlehttp/guzzle": "~4.0|~5.0|~6.0", + "symfony/console": "~2.3|~3.0", + "symfony/filesystem": "~2.3|~3.0", + "symfony/process": "~2.3|~3.0" + }, + "bin": [ + "laravel" + ], + "type": "library", + "autoload": { + "psr-4": { + "Laravel\\Installer\\Console\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "description": "Laravel application installer.", + "keywords": [ + "laravel" + ], + "time": "2017-07-10T13:32:52+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "symfony/console", + "version": "v3.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "a97e45d98c59510f085fa05225a1acb74dfe0546" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/a97e45d98c59510f085fa05225a1acb74dfe0546", + "reference": "a97e45d98c59510f085fa05225a1acb74dfe0546", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/debug": "~2.8|~3.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3", + "symfony/dependency-injection": "~3.3", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/filesystem": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/filesystem": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2017-07-03T13:19:36+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "63b85a968486d95ff9542228dc2e4247f16f9743" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/63b85a968486d95ff9542228dc2e4247f16f9743", + "reference": "63b85a968486d95ff9542228dc2e4247f16f9743", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2017-07-05T13:02:37+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v3.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "311fa718389efbd8b627c272b9324a62437018cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/311fa718389efbd8b627c272b9324a62437018cc", + "reference": "311fa718389efbd8b627c272b9324a62437018cc", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2017-06-24T09:29:48+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "f29dca382a6485c3cbe6379f0c61230167681937" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", + "reference": "f29dca382a6485c3cbe6379f0c61230167681937", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2017-06-09T14:24:12+00:00" + }, + { + "name": "symfony/process", + "version": "v3.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/5ab8949b682b1bf9d4511a228b5e045c96758c30", + "reference": "5ab8949b682b1bf9d4511a228b5e045c96758c30", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.3-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Process\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "https://symfony.com", + "time": "2017-07-03T08:12:02+00:00" + } + ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", diff --git a/lambo b/lambo index de1a034c..58fcaf98 100755 --- a/lambo +++ b/lambo @@ -6,6 +6,9 @@ green=$(tput setaf 2) orange=$(tput setaf 3) reset=$(tput sgr0) +## Terminal Editors +TERMINAL_EDITORS=("vim" "vi" "nano" "pico" "ed" "emacs" "nvim") + ## Init functions showhelp() { @@ -16,17 +19,123 @@ showhelp() echo "${orange}Usage:" echo "${reset} lambo myApplication [arguments]" echo " " - echo "${orange}Options:" - echo "${green} -h, --help${reset} Show brief help" - echo "${green} -e, --editor EDITOR${reset} Specify an editor to run '${green}EDITOR .${reset}' with after" - echo "${green} -m, --message \"message\"${reset} Customize the initial commit message" - echo "${green} -p, --path PATH${reset} Customize the path in which the new project will be created" - echo "${green} -d, --dev${reset} Use Composer to install on the develop branch" - echo "${green} -a, --auth${reset} Use Artisan to scaffold all of the routes and views you need for authentication" - echo "${green} -n, --node${reset} Runs '${green}yarn${reset}' if installed, otherwise runs '${green}npm install${reset}' after creating the project" + echo "${orange}Commands (lambo COMMANDNAME):" + echo " " + echo "${green} make-config${reset} Generate config file" + echo "${green} edit-config${reset} Edit config file" + echo " " + echo "${green} make-after${reset} Generate after file" + echo "${green} edit-after${reset} Edit after file" + echo " " + echo "${orange}Options (lambo myApplication OPTIONS):" + echo "${green} -h, --help${reset} Show brief help" + echo "${green} -e, --editor EDITOR${reset} Specify an editor to run '${green}EDITOR .${reset}' with after" + echo "${green} -m, --message \"message\"${reset} Customize the initial commit message" + echo "${green} -p, --path PATH${reset} Customize the path in which the new project will be created" + echo "${green} -d, --dev${reset} Use Composer to install on the develop branch" + echo "${green} -a, --auth${reset} Use Artisan to scaffold all of the routes and views you need for authentication" + echo "${green} -n, --node${reset} Runs '${green}yarn${reset}' if installed, otherwise runs '${green}npm install${reset}' after creating the project" + echo "${green} -b, --browser \"browser path\"${reset} Opens site in specified browser" + echo "${green} -l, --link${reset} Creates a Valet link to the project directory" quit } +isterminaleditor () { + for EDITOR in $TERMINAL_EDITORS; do [[ "$EDITOR" == "$CODEEDITOR" ]] && return 0; done + return 1 +} + +editconfig() +{ + if [[ ! -f ~/.lambo/config ]]; then + echo "Config does not exist; creating." + + makeconfig + return + fi + + edit ~/.lambo/config +} + +makeconfig() +{ + if [[ -f ~/.lambo/config ]]; then + echo "Config already exists." + quit + fi + + if [[ ! -d ~/.lambo ]]; then + mkdir ~/.lambo + fi + + echo '#!/usr/bin/env bash + +PROJECTPATH="." +MESSAGE="Initial commit." +DEVELOP=false +AUTH=false +NODE=false +CODEEDITOR="" +BROWSER="" +LINK=false' > ~/.lambo/config + + edit ~/.lambo/config +} + +editafter() +{ + if [[ ! -f ~/.lambo/after ]]; then + echo "after file does not exist; creating." + + makeafter + return + fi + + edit ~/.lambo/after +} + +makeafter() +{ + if [[ -f ~/.lambo/after ]]; then + echo "after file already exists." + quit + fi + + if [[ ! -d ~/.lambo ]]; then + mkdir ~/.lambo + fi + + echo '#!/usr/bin/env bash + +# Install additional composer dependencies as you would from the command line. +# echo "Installing Composer Dependencies" +# composer require tightenco/mailthief tightenco/quicksand + +# To copy standard files to new lambo project place them in ~/.lambo/includes directory. +# echo "Copying Include Files" +# cp -R ~/.lambo/includes/ $PROJECTPATH + +# To add a git commit after given modifications +# echo "Committing after modifications to Git" +# git add . +# git commit -am "Initialize Composer dependencies and additional files." +' > ~/.lambo/after + + edit ~/.lambo/after +} + +edit() +{ + ## Open with best editor + if [[ $CODEEDITOR ]]; then + $CODEEDITOR $1 + elif [[ $EDITOR ]]; then + $EDITOR $1 + else + vim $1 + fi +} + abort() { echo >&2 ' @@ -44,6 +153,8 @@ quit() exit 0 } + + ## Set up error handling trap 'abort' 0 @@ -55,14 +166,43 @@ MESSAGE="Initial commit." DEVELOP=false AUTH=false NODE=false -EDITOR="" +CODEEDITOR="" +BROWSER="" TLD=$(php -r "echo json_decode(file_get_contents('$HOME/.valet/config.json'))->domain;") +LINK=false + +### Load config if it exists +if [[ -f ~/.lambo/config ]]; then + source ~/.lambo/config +fi ### Check for project name argument; if none passed, show help if [[ $# -eq 0 ]]; then showhelp fi +### Check if user wants to set up a config file. +if [[ $1 == "make-config" ]]; then + makeconfig + quit +fi + +if [[ $1 == "edit-config" ]]; then + editconfig + quit +fi + +### Check if user wants to set up a after file. +if [[ $1 == "make-after" ]]; then + makeafter + quit +fi + +if [[ $1 == "edit-after" ]]; then + editafter + quit +fi + ### Handle arguments while [[ $# -gt 0 ]]; do key="$1" @@ -80,7 +220,11 @@ while [[ $# -gt 0 ]]; do shift ;; -e|--editor) - EDITOR="$2" + CODEEDITOR="$2" + shift + ;; + -b|--browser) + BROWSER="$2" shift ;; -d|--develop|--dev) @@ -92,6 +236,9 @@ while [[ $# -gt 0 ]]; do -n|--node) NODE=true ;; + -l|--link) + LINK=true + ;; *) ;; esac @@ -99,14 +246,35 @@ while [[ $# -gt 0 ]]; do shift done + +if [ -d "$PROJECTPATH/$PROJECTNAME" ]; then + echo "${red}Project directory $PROJECTPATH/$PROJECTNAME already exists.${reset}" + quit +fi + +if ! hash php 2>/dev/null; then + echo "${red}PHP is not installed.${reset}" + quit +fi + +if ! hash laravel 2>/dev/null; then + echo "${red}Laravel installer not installed.${reset}" + quit +fi + +if ! hash git 2>/dev/null; then + echo "${red}Git not installed.${reset}" + quit +fi + +cd "$PROJECTPATH" || exit + echo " *********************************************** Creating new Laravel app ${green}$PROJECTNAME${reset} *********************************************** " -cd "$PROJECTPATH" || exit - if [[ "$DEVELOP" = true ]]; then laravel new "$PROJECTNAME" --dev else @@ -115,6 +283,12 @@ fi cd "$PROJECTNAME" || exit +if [[ "$CODEEDITOR" != "" ]]; then + if ! isterminaleditor; then + $CODEEDITOR . + fi +fi + if [[ "$NODE" = true ]]; then # check if yarn is executable, otherwise use npm if hash yarn 2>/dev/null; then @@ -132,12 +306,11 @@ git init git add . git commit -m "$MESSAGE" -if [[ "$EDITOR" != "" ]]; then - $EDITOR . -fi - # Update .env to point to this database with `root` username and blank pw, # like Mac MySQL defaults, and appropriate domain +if [ ! -f .env ]; then + cp .env.example .env +fi PROJECTURL="http://$PROJECTNAME.$TLD" perlCommands=( "s/(DB_DATABASE=)(.*)/\1$PROJECTNAME/g" @@ -146,12 +319,20 @@ perlCommands=( "s/(APP_URL=)(.*)/\1$PROJECTNAME\.$TLD/g" ) +if [[ "$LINK" = true ]]; then + valet link "$PROJECTNAME" +fi + for perlCommand in "${perlCommands[@]}"; do perl -pi -e "$perlCommand" ".env" - done +done if [[ "$(uname)" == "Darwin" ]]; then - open "$PROJECTURL" + if [[ "$BROWSER" != "" ]]; then + open -a "$BROWSER" "$PROJECTURL" + else + open "$PROJECTURL" + fi elif [[ "$(expr substr $(uname -s) 1 5)" == "Linux" ]]; then xdg-open "$PROJECTURL" fi @@ -161,6 +342,18 @@ case $PROJECTPATH in *) prettyPath="$PROJECTPATH/$PROJECTNAME" ;; esac +### Load after file if it exists +if [[ -f ~/.lambo/after ]]; then + echo "${green}Running additional commands...${reset}" + source ~/.lambo/after +fi + +if [[ "$CODEEDITOR" != "" ]]; then + if isterminaleditor; then + $CODEEDITOR . + fi +fi + if [[ "$SHELL" != "" ]]; then exec "$SHELL" @@ -177,5 +370,7 @@ else You're ready to go! Remember to cd into '${green}$prettyPath${reset}' before you start editing." fi + + # End script; disable error handling trap : 0 diff --git a/readme.md b/readme.md index db847159..214b1739 100644 --- a/readme.md +++ b/readme.md @@ -40,6 +40,8 @@ This will `laravel new superApplication`, change into that directory, make an in - Replace the `.env` `APP_URL` with `$PROJECTNAME.$YOURVALETTLD` - Open `$PROJECTNAME.$YOURVALETTLD` in your browser +There are also a few optional behaviors based on the parameters you pass (or define in your config file). + ### Optional Arguments - `-h` or `--help` to get the help dialog @@ -48,23 +50,23 @@ This will `laravel new superApplication`, change into that directory, make an in lambo --help ``` -- `-p` or `--path` to specify where to install the application. +- `-e` or `--editor` to define your editor command. Whatever is passed here will be run as `$EDITOR .` after creating the project. ```bash - lambo superApplication -p ~/Sites + # runs "subl ." in the project directory after creating the project + lambo superApplication --editor subl ``` - `-m` or `--message` to set the first commit message. ```bash - lambo superApplication -m "This lambo runs fast!" + lambo superApplication --message "This lambo runs fast!" ``` -- `-e` or `--editor` to define your editor command. Whatever is passed here will be run as `$EDITOR .` after creating the project. +- `-p` or `--path` to specify where to install the application. ```bash - # runs "subl ." in the project directory after creating the project - lambo superApplication -e subl + lambo superApplication --path ~/Sites ``` - `-d` or `--dev` to choose the `develop` branch instead of `master`, getting the beta install @@ -85,6 +87,78 @@ This will `laravel new superApplication`, change into that directory, make an in lambo superApplication --node ``` +- `-b` or `--browser` to define which browser you want to open the project in. + + ```bash + lambo superApplication --browser "/Applications/Google Chrome Canary.app" + ``` + +- `-l` or `--link` to create a Valet link to the project directory. + + ```bash + lambo superApplication --link + ``` + +### Commands + +- `make-config` creates a config file so you don't have to pass the parameters every time you use Lambo + + ```bash + lambo make-config + ``` + +- `edit-config` edits your config file + + ```bash + lambo edit-config + ``` + +- `make-after` creates an "after" file so you can run additional commands after Lambo finishes + + ```bash + lambo make-after + ``` + +- `edit-after` edits your after file + + ```bash + lambo edit-after + ``` + +### Config + +You can create a config file at `~/.lambo/config` rather than pass the same arguments each time you create a new project. + +```bash +lambo make-config +``` + +### After File + +You can create an after file at `~/.lambo/after` to run additional commands after you create a new project. + +```bash +lambo make-after +``` + +The after file is a bash script so you can include any commands here such as installing additional composer dependencies + +```bash +# Install additional composer dependencies as you would from the command line. +echo "Installing Composer Dependencies" +composer require tightenco/mailthief tightenco/quicksand +``` + +or copying additional files to your new project. + +```bash +# To copy standard files to new lambo project place them in ~/.lambo/includes directory. +echo "Copying Include Files" +cp -R ~/.lambo/includes/ $PROJECTPATH +``` + +You also have access to variables from your config file such as `$PROJECTPATH` and `$CODEEDITOR`. + ## Requirements - Mac or Ubuntu.