diff --git a/composer.json b/composer.json index 987f050..7b0bf4a 100644 --- a/composer.json +++ b/composer.json @@ -13,9 +13,9 @@ "php": ">7.3", "illuminate/support": "^5.0|^6.0|^7.0", "illuminate/contracts": "^5.0|^6.0|^7.0", - "symfony/process": "^4.0", + "symfony/process": "^4.0|^5.0", "illuminate/filesystem": "^5.0|^6.0|^7.0", - "symfony/finder": "^4.0", + "symfony/finder": "^4.0|^5.0", "illuminate/console": "^5.0|^6.0|^7.0", "ext-json": "*", "ext-zip": "*" diff --git a/composer.lock b/composer.lock index e18d2ee..2afce89 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b62fdbaa28886b9927ed2b1e9b6050a5", + "content-hash": "e5700088d15492b1ecacb089f1592c04", "packages": [ { "name": "doctrine/inflector", - "version": "1.4.3", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "4650c8b30c753a76bf44fb2ed00117d6f367490c" + "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/4650c8b30c753a76bf44fb2ed00117d6f367490c", - "reference": "4650c8b30c753a76bf44fb2ed00117d6f367490c", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/9cf661f4eb38f7c881cac67c75ea9b00bf97b210", + "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210", "shasum": "" }, "require": { @@ -38,7 +38,6 @@ }, "autoload": { "psr-4": { - "Doctrine\\Common\\Inflector\\": "lib/Doctrine/Common/Inflector", "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" } }, @@ -96,37 +95,41 @@ "type": "tidelift" } ], - "time": "2020-05-29T07:19:59+00:00" + "time": "2020-05-29T15:13:26+00:00" }, { "name": "illuminate/console", - "version": "v5.7.28", + "version": "v6.18.37", "source": { "type": "git", "url": "https://github.com/illuminate/console.git", - "reference": "0d97b6ead0cbb09140b1e8317f5a9d9f69ff9ec6" + "reference": "b73fed91e5d21281d7a5b03f1cc85b8ee05e7a8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/console/zipball/0d97b6ead0cbb09140b1e8317f5a9d9f69ff9ec6", - "reference": "0d97b6ead0cbb09140b1e8317f5a9d9f69ff9ec6", + "url": "https://api.github.com/repos/illuminate/console/zipball/b73fed91e5d21281d7a5b03f1cc85b8ee05e7a8c", + "reference": "b73fed91e5d21281d7a5b03f1cc85b8ee05e7a8c", "shasum": "" }, "require": { - "illuminate/contracts": "5.7.*", - "illuminate/support": "5.7.*", - "php": "^7.1.3", - "symfony/console": "^4.1" + "illuminate/contracts": "^6.0", + "illuminate/support": "^6.0", + "php": "^7.2", + "symfony/console": "^4.3.4", + "symfony/process": "^4.3.4" }, "suggest": { - "dragonmantank/cron-expression": "Required to use scheduling component (^2.0).", - "guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.0).", - "symfony/process": "Required to use scheduling component (^4.1)." + "dragonmantank/cron-expression": "Required to use scheduler (^2.0).", + "guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.0|^7.0).", + "illuminate/bus": "Required to use the scheduled job dispatcher (^6.0)", + "illuminate/container": "Required to use the scheduler (^6.0)", + "illuminate/filesystem": "Required to use the generator command (^6.0)", + "illuminate/queue": "Required to use closures for scheduled jobs (^6.0)" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7-dev" + "dev-master": "6.x-dev" } }, "autoload": { @@ -146,31 +149,31 @@ ], "description": "The Illuminate Console package.", "homepage": "https://laravel.com", - "time": "2019-02-11T13:48:57+00:00" + "time": "2020-08-20T13:35:20+00:00" }, { "name": "illuminate/contracts", - "version": "v5.7.28", + "version": "v6.18.37", "source": { "type": "git", "url": "https://github.com/illuminate/contracts.git", - "reference": "b63324d349a8ae2156fbc2697c1ccc85879b3803" + "reference": "0a144c2ee0163f8debd62da1386036567b1ba6b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/contracts/zipball/b63324d349a8ae2156fbc2697c1ccc85879b3803", - "reference": "b63324d349a8ae2156fbc2697c1ccc85879b3803", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/0a144c2ee0163f8debd62da1386036567b1ba6b4", + "reference": "0a144c2ee0163f8debd62da1386036567b1ba6b4", "shasum": "" }, "require": { - "php": "^7.1.3", + "php": "^7.2", "psr/container": "^1.0", "psr/simple-cache": "^1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7-dev" + "dev-master": "6.x-dev" } }, "autoload": { @@ -190,39 +193,40 @@ ], "description": "The Illuminate Contracts package.", "homepage": "https://laravel.com", - "time": "2019-02-12T07:46:48+00:00" + "time": "2020-08-13T14:33:00+00:00" }, { "name": "illuminate/filesystem", - "version": "v5.7.28", + "version": "v6.18.37", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", - "reference": "ff853e678a93996b1d0a3ddc6fc56c10bae0de30" + "reference": "f5ad508938fa8130b28de8a1a22210a7be8401e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/ff853e678a93996b1d0a3ddc6fc56c10bae0de30", - "reference": "ff853e678a93996b1d0a3ddc6fc56c10bae0de30", + "url": "https://api.github.com/repos/illuminate/filesystem/zipball/f5ad508938fa8130b28de8a1a22210a7be8401e2", + "reference": "f5ad508938fa8130b28de8a1a22210a7be8401e2", "shasum": "" }, "require": { - "illuminate/contracts": "5.7.*", - "illuminate/support": "5.7.*", - "php": "^7.1.3", - "symfony/finder": "^4.1" + "illuminate/contracts": "^6.0", + "illuminate/support": "^6.0", + "php": "^7.2", + "symfony/finder": "^4.3.4" }, "suggest": { - "league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.0).", + "ext-ftp": "Required to use the Flysystem FTP driver.", + "league/flysystem": "Required to use the Flysystem local and FTP drivers (^1.0.34).", "league/flysystem-aws-s3-v3": "Required to use the Flysystem S3 driver (^1.0).", "league/flysystem-cached-adapter": "Required to use the Flysystem cache (^1.0).", - "league/flysystem-rackspace": "Required to use the Flysystem Rackspace driver (^1.0).", - "league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0)." + "league/flysystem-sftp": "Required to use the Flysystem SFTP driver (^1.0).", + "psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7-dev" + "dev-master": "6.x-dev" } }, "autoload": { @@ -242,43 +246,45 @@ ], "description": "The Illuminate Filesystem package.", "homepage": "https://laravel.com", - "time": "2019-02-11T13:48:57+00:00" + "time": "2020-08-13T14:33:00+00:00" }, { "name": "illuminate/support", - "version": "v5.7.28", + "version": "v6.18.37", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "3e2810145f37eb89fa11759781ee88ee1c1a5262" + "reference": "30e81a39fe96f145d807606900317f1dab96f456" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/3e2810145f37eb89fa11759781ee88ee1c1a5262", - "reference": "3e2810145f37eb89fa11759781ee88ee1c1a5262", + "url": "https://api.github.com/repos/illuminate/support/zipball/30e81a39fe96f145d807606900317f1dab96f456", + "reference": "30e81a39fe96f145d807606900317f1dab96f456", "shasum": "" }, "require": { - "doctrine/inflector": "^1.1", + "doctrine/inflector": "^1.4|^2.0", + "ext-json": "*", "ext-mbstring": "*", - "illuminate/contracts": "5.7.*", - "nesbot/carbon": "^1.26.3", - "php": "^7.1.3" + "illuminate/contracts": "^6.0", + "nesbot/carbon": "^2.0", + "php": "^7.2" }, "conflict": { "tightenco/collect": "<5.5.33" }, "suggest": { - "illuminate/filesystem": "Required to use the composer class (5.7.*).", + "illuminate/filesystem": "Required to use the composer class (^6.0).", "moontoast/math": "Required to use ordered UUIDs (^1.1).", "ramsey/uuid": "Required to use Str::uuid() (^3.7).", - "symfony/process": "Required to use the composer class (^4.1).", - "symfony/var-dumper": "Required to use the dd function (^4.1)." + "symfony/process": "Required to use the composer class (^4.3.4).", + "symfony/var-dumper": "Required to use the dd function (^4.3.4).", + "vlucas/phpdotenv": "Required to use the Env class and env helper (^3.3)." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7-dev" + "dev-master": "6.x-dev" } }, "autoload": { @@ -301,106 +307,61 @@ ], "description": "The Illuminate Support package.", "homepage": "https://laravel.com", - "time": "2019-02-12T07:57:07+00:00" - }, - { - "name": "kylekatarnls/update-helper", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/kylekatarnls/update-helper.git", - "reference": "429be50660ed8a196e0798e5939760f168ec8ce9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/kylekatarnls/update-helper/zipball/429be50660ed8a196e0798e5939760f168ec8ce9", - "reference": "429be50660ed8a196e0798e5939760f168ec8ce9", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.1.0 || ^2.0.0", - "php": ">=5.3.0" - }, - "require-dev": { - "codeclimate/php-test-reporter": "dev-master", - "composer/composer": "2.0.x-dev || ^2.0.0-dev", - "phpunit/phpunit": ">=4.8.35 <6.0" - }, - "type": "composer-plugin", - "extra": { - "class": "UpdateHelper\\ComposerPlugin" - }, - "autoload": { - "psr-0": { - "UpdateHelper\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Kyle", - "email": "kylekatarnls@gmail.com" - } - ], - "description": "Update helper", - "funding": [ - { - "url": "https://github.com/kylekatarnls", - "type": "github" - }, - { - "url": "https://opencollective.com/Carbon", - "type": "open_collective" - }, - { - "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", - "type": "tidelift" - } - ], - "time": "2020-04-07T20:44:10+00:00" + "time": "2020-08-17T13:32:39+00:00" }, { "name": "nesbot/carbon", - "version": "1.39.1", + "version": "2.39.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "4be0c005164249208ce1b5ca633cd57bdd42ff33" + "reference": "0a41ea7f7fedacf307b7a339800e10356a042918" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4be0c005164249208ce1b5ca633cd57bdd42ff33", - "reference": "4be0c005164249208ce1b5ca633cd57bdd42ff33", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/0a41ea7f7fedacf307b7a339800e10356a042918", + "reference": "0a41ea7f7fedacf307b7a339800e10356a042918", "shasum": "" }, "require": { - "kylekatarnls/update-helper": "^1.1", - "php": ">=5.3.9", - "symfony/translation": "~2.6 || ~3.0 || ~4.0" + "ext-json": "*", + "php": "^7.1.8 || ^8.0", + "symfony/polyfill-mbstring": "^1.0", + "symfony/translation": "^3.4 || ^4.0 || ^5.0" }, "require-dev": { - "composer/composer": "^1.2", - "friendsofphp/php-cs-fixer": "~2", - "phpunit/phpunit": "^4.8.35 || ^5.7" + "doctrine/orm": "^2.7", + "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", + "kylekatarnls/multi-tester": "^2.0", + "phpmd/phpmd": "^2.8", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.35", + "phpunit/phpunit": "^7.5 || ^8.0", + "squizlabs/php_codesniffer": "^3.4" }, "bin": [ - "bin/upgrade-carbon" + "bin/carbon" ], "type": "library", "extra": { - "update-helper": "Carbon\\Upgrade", + "branch-alias": { + "dev-master": "2.x-dev", + "dev-3.x": "3.x-dev" + }, "laravel": { "providers": [ "Carbon\\Laravel\\ServiceProvider" ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] } }, "autoload": { "psr-4": { - "": "src/" + "Carbon\\": "src/Carbon/" } }, "notification-url": "https://packagist.org/downloads/", @@ -412,16 +373,30 @@ "name": "Brian Nesbitt", "email": "brian@nesbot.com", "homepage": "http://nesbot.com" + }, + { + "name": "kylekatarnls", + "homepage": "http://github.com/kylekatarnls" } ], - "description": "A simple API extension for DateTime.", + "description": "An API extension for DateTime that supports 281 different languages.", "homepage": "http://carbon.nesbot.com", "keywords": [ "date", "datetime", "time" ], - "time": "2019-10-14T05:51:36+00:00" + "funding": [ + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2020-08-24T12:35:58+00:00" }, { "name": "psr/container", @@ -909,26 +884,25 @@ }, { "name": "symfony/process", - "version": "v5.1.3", + "version": "v4.4.11", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "1864216226af21eb76d9477f691e7cbf198e0402" + "reference": "65e70bab62f3da7089a8d4591fb23fbacacb3479" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/1864216226af21eb76d9477f691e7cbf198e0402", - "reference": "1864216226af21eb76d9477f691e7cbf198e0402", + "url": "https://api.github.com/repos/symfony/process/zipball/65e70bab62f3da7089a8d4591fb23fbacacb3479", + "reference": "65e70bab62f3da7089a8d4591fb23fbacacb3479", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.15" + "php": ">=7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-master": "4.4-dev" } }, "autoload": { @@ -969,7 +943,7 @@ "type": "tidelift" } ], - "time": "2020-07-23T08:36:24+00:00" + "time": "2020-07-23T08:31:43+00:00" }, { "name": "symfony/service-contracts", @@ -1049,42 +1023,44 @@ }, { "name": "symfony/translation", - "version": "v4.4.11", + "version": "v5.1.3", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "a8ea9d97353294eb6783f2894ef8cee99a045822" + "reference": "4b9bf719f0fa5b05253c37fc7b335337ec7ec427" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/a8ea9d97353294eb6783f2894ef8cee99a045822", - "reference": "a8ea9d97353294eb6783f2894ef8cee99a045822", + "url": "https://api.github.com/repos/symfony/translation/zipball/4b9bf719f0fa5b05253c37fc7b335337ec7ec427", + "reference": "4b9bf719f0fa5b05253c37fc7b335337ec7ec427", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", "symfony/polyfill-mbstring": "~1.0", - "symfony/translation-contracts": "^1.1.6|^2" + "symfony/polyfill-php80": "^1.15", + "symfony/translation-contracts": "^2" }, "conflict": { - "symfony/config": "<3.4", - "symfony/dependency-injection": "<3.4", - "symfony/http-kernel": "<4.4", - "symfony/yaml": "<3.4" + "symfony/config": "<4.4", + "symfony/dependency-injection": "<5.0", + "symfony/http-kernel": "<5.0", + "symfony/twig-bundle": "<5.0", + "symfony/yaml": "<4.4" }, "provide": { - "symfony/translation-implementation": "1.0" + "symfony/translation-implementation": "2.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "^3.4|^4.0|^5.0", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/dependency-injection": "^3.4|^4.0|^5.0", - "symfony/finder": "~2.8|~3.0|~4.0|^5.0", - "symfony/http-kernel": "^4.4", - "symfony/intl": "^3.4|^4.0|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/http-kernel": "^5.0", + "symfony/intl": "^4.4|^5.0", "symfony/service-contracts": "^1.1.2|^2", - "symfony/yaml": "^3.4|^4.0|^5.0" + "symfony/yaml": "^4.4|^5.0" }, "suggest": { "psr/log-implementation": "To use logging capability in translator", @@ -1094,7 +1070,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.4-dev" + "dev-master": "5.1-dev" } }, "autoload": { @@ -1135,7 +1111,7 @@ "type": "tidelift" } ], - "time": "2020-07-23T08:31:43+00:00" + "time": "2020-06-30T17:42:22+00:00" }, { "name": "symfony/translation-contracts", diff --git a/config/config.php b/config/config.php index 0a12a90..6174afd 100644 --- a/config/config.php +++ b/config/config.php @@ -4,57 +4,93 @@ return [ - 'mode' => 'local', // Local or CDN? CDN, will replace every item in the mix-manifest.json with the cdn-ified directory. - - 'cdn_url' => null, - 'compiler' => [ - 'package_manager' => 'npm', // Supports npm, yarn. - - 'script' => 'dev', // *package_manager* run *script* - - ], - - 'upload' => [ - - // Which disk shall we use? - 'disk' => 'cdn', - - // Which directory on the disk should we put files? - 'upload_assets_to' => Str::slug('lasso-' . env('APP_NAME','laravel')), - - // Which path to look at - 'public_path' => public_path(), - - // Files that shouldn't be included in the bundle. + /* + * Configure which command Lasso should run in its deployment + * phase. This will most likely be "npm run production" but + * you may choose what you would like to execute. + */ + 'script' => 'npm run production', + + /* + * If there any directories/files you would like to Lasso to + * exclude when uploading to the Filesystem, specify them below. + */ 'excluded_files' => [], - // Directories that shouldn't be included in the bundle 'excluded_directories' => [], - 'push_to_git' => true, // git add "lasso" && git commit -m"Lasso Assets 🐎" --author="Lasso" && git push - ], 'storage' => [ + /* + * Specify the filesystem Lasso should use to use to store + * and retrieve its files. + */ + 'disk' => 'assets', + + /* + * Specify the directory Lasso should store all of its + * files within. By default we will use "lasso-APP_NAME". + */ + 'upload_to' => sprintf('lasso-%s', Str::slug(env('APP_NAME','laravel'))), + + /* + * Lasso will also create a separate directory containing + * the environment the files will be stored in. Specify this + * here. + */ 'environment' => env('APP_ENV', 'production'), + /* + * After running "php artisan lasso:push", by default Lasso will + * create a "lasso-bundle.json" file and automatically commit it to + * Git. To disable this functionality, change the setting below or + * use "php artisan lasso:push --no-git". + */ + 'push_to_git' => true, + + /* + * When using Lasso with Git, you will be able to roll-back your + * commits, and Lasso will pull down an old bundle of assets. Choose + * how many you would like to keep. + */ 'bundles_to_keep' => 5, ], + /* + * Lasso will can also trigger Webhooks after its commands have been + * successfully executed. You may specify URLs that Lasso will POST + * to, for each of the commands. + */ 'webhooks' => [ - // Trigger webhooks for events that happen inside of Lasso - 'publish' => [ + /* + * Specify which webhooks should be triggered after a successful + * "php artisan lasso:push" command execution. + */ + 'push' => [ // ], - 'retrieve' => [ + /* + * Specify which webhooks should be triggered after a successful + * "php artisan lasso:pull" command execution. + */ + 'pull' => [ // - ], + ] + ], + /* + * Where are your assets stored? Most of the time, they will + * be stored within the /public directory in Laravel - but if + * you have changed this - please specify it below. + */ + 'public_path' => public_path(), + ]; diff --git a/src/Commands/FetchCommand.php b/src/Commands/PullCommand.php similarity index 94% rename from src/Commands/FetchCommand.php rename to src/Commands/PullCommand.php index e530b7d..2131136 100644 --- a/src/Commands/FetchCommand.php +++ b/src/Commands/PullCommand.php @@ -8,14 +8,14 @@ use Sammyjo20\Lasso\Helpers\ConfigValidator; use Sammyjo20\Lasso\Services\Fetcher; -class FetchCommand extends Command +class PullCommand extends Command { /** * The name and signature of the console command. * * @var string */ - protected $signature = 'lasso:fetch'; + protected $signature = 'lasso:pull'; /** * The console command description. diff --git a/src/Commands/PublishCommand.php b/src/Commands/PushCommand.php similarity index 92% rename from src/Commands/PublishCommand.php rename to src/Commands/PushCommand.php index cb68495..7cf991b 100644 --- a/src/Commands/PublishCommand.php +++ b/src/Commands/PushCommand.php @@ -7,14 +7,14 @@ use Sammyjo20\Lasso\Helpers\ConfigValidator; use Sammyjo20\Lasso\Services\Bundler; -class PublishCommand extends Command +class PushCommand extends Command { /** * The name and signature of the console command. * * @var string */ - protected $signature = 'lasso:publish {--no-git}'; + protected $signature = 'lasso:push {--no-git}'; /** * The console command description. diff --git a/src/Exceptions/FetchCommandException.php b/src/Exceptions/BaseException.php similarity index 55% rename from src/Exceptions/FetchCommandException.php rename to src/Exceptions/BaseException.php index 91af613..a7ad81b 100644 --- a/src/Exceptions/FetchCommandException.php +++ b/src/Exceptions/BaseException.php @@ -2,8 +2,13 @@ namespace Sammyjo20\Lasso\Exceptions; -class FetchCommandException extends \Exception +class BaseException extends \Exception { + /** + * @var string + */ + public static $event = 'An exception was thrown.'; + /** * @param string $reason * @return static @@ -11,7 +16,7 @@ class FetchCommandException extends \Exception public static function because(string $reason) { return new static(sprintf( - 'Failed to fetch the latest Lasso deployment. Reason: %s', $reason + '%s Reason: %s', static::$event, $reason )); } } diff --git a/src/Exceptions/CommitFailedException.php b/src/Exceptions/CommitFailedException.php deleted file mode 100644 index 617bd71..0000000 --- a/src/Exceptions/CommitFailedException.php +++ /dev/null @@ -1,17 +0,0 @@ -checkMode($this->get('mode'))) { - throw ConfigFailedValidation::because('The specified mode must be either "local" or "cdn".'); - } - - if ($this->get('mode') === 'cdn' && !$this->checkCdnUrl($this->get('cdn_url'))) { - throw ConfigFailedValidation::because('The specified CDN url is invalid.'); - } - - if (!$this->checkPackageManager($this->get('compiler.package_manager'))) { - throw ConfigFailedValidation::because('The specified package manager must be either "npm" or "yarn".'); + if (!$this->checkCompilerScript($this->get('compiler.script'))) { + throw ConfigFailedValidation::because('You must specify a script to run the compiler. (E.g: npm run production)'); } - if (!$this->checkIfPublicPathExists($this->get('upload.public_path'))) { - throw ConfigFailedValidation::because('The specified public directory is not a valid or accessible directory.'); - } - - if (!$this->checkDiskExists($this->get('upload.disk'))) { + if (!$this->checkDiskExists($this->get('storage.disk'))) { throw ConfigFailedValidation::because('The specified upload disk is not a valid disk.'); } @@ -126,5 +95,9 @@ public function validate(): void if (!$this->checkBundleToKeepCount($this->get('storage.bundles_to_keep'))) { throw ConfigFailedValidation::because('You must specify how many bundles should be kept. (Min: 1)'); } + + if (!$this->checkIfPublicPathExists($this->get('public_path'))) { + throw ConfigFailedValidation::because('The specified public directory is not a valid or accessible directory.'); + } } } diff --git a/src/LassoServiceProvider.php b/src/LassoServiceProvider.php index 25f83c5..4af1b8e 100644 --- a/src/LassoServiceProvider.php +++ b/src/LassoServiceProvider.php @@ -3,8 +3,8 @@ namespace Sammyjo20\Lasso; use Illuminate\Support\ServiceProvider as BaseServiceProvider; -use Sammyjo20\Lasso\Commands\PublishCommand; -use Sammyjo20\Lasso\Commands\FetchCommand; +use Sammyjo20\Lasso\Commands\PushCommand; +use Sammyjo20\Lasso\Commands\PullCommand; use Sammyjo20\Lasso\Container\Console; class LassoServiceProvider extends BaseServiceProvider @@ -19,8 +19,8 @@ public function boot() $this->app->instance(Console::class, new Console()); $this->commands([ - PublishCommand::class, - FetchCommand::class, + PushCommand::class, + PullCommand::class, ]); } } diff --git a/src/Services/Backup.php b/src/Services/Backup.php index 4a0c373..d646341 100644 --- a/src/Services/Backup.php +++ b/src/Services/Backup.php @@ -3,7 +3,7 @@ namespace Sammyjo20\Lasso\Services; use Illuminate\Filesystem\Filesystem; -use Sammyjo20\Lasso\Exceptions\BackupRestoreException; +use Sammyjo20\Lasso\Exceptions\RestoreFailed; class Backup { @@ -36,15 +36,15 @@ public function __construct(Filesystem $filesystem, string $destination) /** * @return bool - * @throws BackupRestoreException + * @throws RestoreFailed */ public function restoreBackup(): bool { if (!$this->filesystem->exists($this->destination)) { - throw new BackupRestoreException('Couldn\'t find backup file.'); + throw RestoreFailed::because('Couldn\'t find backup file.'); } - $public_path = config('lasso.upload.public_path'); + $public_path = config('lasso.public_path'); $this->filesystem->cleanDirectory($public_path); $this->filesystem->move($this->destination, $public_path); @@ -59,7 +59,7 @@ public function restoreBackup(): bool */ public function startBackup(): bool { - $public_path = config('lasso.upload.public_path'); + $public_path = config('lasso.public_path'); $backup_destination = $this->destination; $success = $this->filesystem->copyDirectory( diff --git a/src/Services/BundleCleaner.php b/src/Services/BundleCleaner.php index db7175b..2147a75 100644 --- a/src/Services/BundleCleaner.php +++ b/src/Services/BundleCleaner.php @@ -27,12 +27,12 @@ public function __construct() { $this->forbidden_files = array_merge( $this->forbidden_files, - config('lasso.upload.excluded_files') + config('lasso.compiler.excluded_files') ); $this->forbidden_directories = array_merge( $this->forbidden_directories, - config('lasso.upload.excluded_directories') + config('lasso.compiler.excluded_directories') ); } diff --git a/src/Services/Bundler.php b/src/Services/Bundler.php index 6693e6a..8e72e25 100644 --- a/src/Services/Bundler.php +++ b/src/Services/Bundler.php @@ -82,17 +82,16 @@ private function createZipArchiveFromBundle(string $bundle_directory): string */ private function sendWebhooks(array $data) { - $webhooks = config('lasso.webhooks.publish', []); + $webhooks = config('lasso.webhooks.push', []); foreach($webhooks as $webhook) { - Webhook::send($webhook, Webhook::PUBLISH, $data); + Webhook::send($webhook, Webhook::PUSH_EVENT, $data); } } public function execute(bool $use_git = true) { - $mode = config('lasso.mode'); - $public_path = config('lasso.upload.public_path'); + $public_path = config('lasso.public_path'); $this->compiler->buildAssets(); @@ -137,7 +136,7 @@ public function execute(bool $use_git = true) // Delete the .lasso folder $this->deleteLassoDirectory(); - $push_to_git = config('lasso.upload.push_to_git', false); + $push_to_git = config('lasso.storage.push_to_git', false); // If we're using git, commit the lasso-bundle file. if ($use_git === true && $push_to_git === true) { @@ -158,8 +157,8 @@ public function execute(bool $use_git = true) */ public function uploadFile(string $path, string $name) { - $disk = config('lasso.upload.disk'); - $directory = config('lasso.upload.upload_assets_to'); + $disk = config('lasso.storage.disk'); + $directory = config('lasso.storage.upload_to'); $upload_path = $directory . '/' . $this->environment . '/' . $name; diff --git a/src/Services/Committer.php b/src/Services/Committer.php index 233d1e2..44de836 100644 --- a/src/Services/Committer.php +++ b/src/Services/Committer.php @@ -3,7 +3,7 @@ namespace Sammyjo20\Lasso\Services; use Illuminate\Filesystem\Filesystem; -use Sammyjo20\Lasso\Exceptions\CommitFailedException; +use Sammyjo20\Lasso\Exceptions\CommittingFailed; use Sammyjo20\Lasso\Helpers\CommandHelper; class Committer @@ -22,14 +22,14 @@ public function __construct() } /** - * @throws CommitFailedException + * @throws CommittingFailed */ public function commitAndPushBundle() { $path = base_path('lasso-bundle.json'); if (!$this->filesystem->exists($path)) { - throw new CommitFailedException('The "lasso-bundle.json" could not be found.'); + throw new CommittingFailed('The "lasso-bundle.json" could not be found.'); } $command = "git add 'lasso-bundle.json' && git commit -m'Lasso Assets 🐎' --author='Lasso <>' && git push"; diff --git a/src/Services/Compiler.php b/src/Services/Compiler.php index 4ffcbbe..fdc071a 100644 --- a/src/Services/Compiler.php +++ b/src/Services/Compiler.php @@ -4,7 +4,7 @@ namespace Sammyjo20\Lasso\Services; use Sammyjo20\Lasso\Container\Console; -use Sammyjo20\Lasso\Exceptions\CompilerFailedException; +use Sammyjo20\Lasso\Exceptions\CompilerFailed; use Sammyjo20\Lasso\Helpers\CommandHelper; class Compiler @@ -24,11 +24,7 @@ public function __construct() public function buildAssets() { - $command = sprintf( - '%s run %s', - config('lasso.compiler.package_manager'), - config('lasso.compiler.script') - ); + $command = config('lasso.compiler.script'); $this->console->info('🔥 Compiling assets...'); diff --git a/src/Services/Fetcher.php b/src/Services/Fetcher.php index 951db01..496cbd4 100644 --- a/src/Services/Fetcher.php +++ b/src/Services/Fetcher.php @@ -4,8 +4,7 @@ use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Storage; -use Sammyjo20\Lasso\Exceptions\BackupRestoreException; -use Sammyjo20\Lasso\Exceptions\FetchCommandException; +use Sammyjo20\Lasso\Exceptions\FetchCommandFailed; use Sammyjo20\Lasso\Factories\ZipExtractor; use Sammyjo20\Lasso\Helpers\BundleIntegrityHelper; @@ -37,11 +36,11 @@ class Fetcher public function __construct() { $this->local_filesystem = new Filesystem(); - $this->lasso_disk = config('lasso.upload.disk'); + $this->lasso_disk = config('lasso.storage.disk'); $this->lasso_path = sprintf( '%s/%s', - rtrim(config('lasso.upload.upload_assets_to'), '/'), + rtrim(config('lasso.storage.upload_to'), '/'), config('lasso.storage.environment') ); @@ -67,7 +66,7 @@ private function cleanLassoDirectory(): void /** * @param \Exception $exception - * @throws BackupRestoreException + * @throws \Sammyjo20\Lasso\Exceptions\RestoreFailed */ private function rollBack(\Exception $exception) { @@ -79,7 +78,7 @@ private function rollBack(\Exception $exception) $this->deleteLassoDirectory(); - throw new BackupRestoreException($exception); + throw new $exception; } /** @@ -87,7 +86,7 @@ private function rollBack(\Exception $exception) * decode the data and give it to us as an array. * * @return array - * @throws FetchCommandException + * @throws FetchCommandFailed * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ private function retrieveLatestBundleMeta(): array @@ -117,7 +116,7 @@ private function retrieveLatestBundleMeta(): array // If we don't however. We need to throw an exception. if (!$filesystem->has($base_path . '/bundle-meta.json')) { - throw FetchCommandException::because('A valid "bundle-meta.json" file could not be found for the current environment.'); + throw FetchCommandFailed::because('A valid "bundle-meta.json" file could not be found for the current environment.'); } $file = $filesystem->get($base_path . '/bundle-meta.json'); @@ -128,7 +127,7 @@ private function retrieveLatestBundleMeta(): array * @param string $id * @param string $checksum * @return string - * @throws FetchCommandException + * @throws FetchCommandFailed * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ private function retrieveBundle(string $id, string $checksum): string @@ -140,13 +139,13 @@ private function retrieveBundle(string $id, string $checksum): string ->get($filesystem_path); if (!$zip) { - throw FetchCommandException::because('The bundle Zip could not be found or was inaccessible.'); + throw FetchCommandFailed::because('The bundle Zip could not be found or was inaccessible.'); } try { $this->local_filesystem->put($local_path, $zip); } catch (\Exception $ex) { - throw FetchCommandException::because('An error occurred while writing to the local path.'); + throw FetchCommandFailed::because('An error occurred while writing to the local path.'); } // Now we want to check if the integrity of the bundle is okay. @@ -154,7 +153,7 @@ private function retrieveBundle(string $id, string $checksum): string // incorrectly or tampered with! if (!BundleIntegrityHelper::verifyChecksum($local_path, $checksum)) { - throw FetchCommandException::because('The bundle Zip\'s checksum is incorrect.'); + throw FetchCommandFailed::because('The bundle Zip\'s checksum is incorrect.'); } return $local_path; @@ -170,7 +169,7 @@ public function execute() $bundle_info = $this->retrieveLatestBundleMeta(); if (!isset($bundle_info['id']) || !isset($bundle_info['checksum'])) { - throw FetchCommandException::because('The bundle info was missing the required data.'); + throw FetchCommandFailed::because('The bundle info was missing the required data.'); } // Grab the Zip. @@ -181,7 +180,7 @@ public function execute() try { if ($this->backup_service->startBackup()) { - $public_path = rtrim(config('lasso.upload.public_path'), '/'); + $public_path = rtrim(config('lasso.public_path'), '/'); // Now it's time to unzip! (new ZipExtractor($bundle)) diff --git a/src/Services/Webhook.php b/src/Services/Webhook.php index baf8ff6..e2b222f 100644 --- a/src/Services/Webhook.php +++ b/src/Services/Webhook.php @@ -6,9 +6,9 @@ class Webhook { - public const PUBLISH = 'publish'; + public const PUSH_EVENT = 'push'; - public const RETRIEVE = 'retrieve'; + public const PULL_EVENT = 'pull'; /** * @param string $url