diff --git a/.env.example b/.env.example index cd880fa..d3f13b3 100644 --- a/.env.example +++ b/.env.example @@ -9,8 +9,6 @@ APP_URL=http://localhost LOG_CHANNEL=stack -CACHE_BUST= - BS_HOST=localhost DB_CONNECTION=mysql diff --git a/app/Utilities/Version.php b/app/Utilities/Version.php new file mode 100644 index 0000000..74c7665 --- /dev/null +++ b/app/Utilities/Version.php @@ -0,0 +1,30 @@ + Intervention\Image\Facades\Image::class, 'Language' => App\Utilities\Language::class, + 'Version' => App\Utilities\Version::class, ] diff --git a/gulpfile.js b/gulpfile.js index 77d4b5b..22856c3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,9 @@ const gulp = require("gulp"), log = require("fancy-log"), insert = require("gulp-insert"), plumber = require("gulp-plumber"), - concat = require("gulp-concat"); + concat = require("gulp-concat"), + fs = require("fs"), + crypto = require("crypto"); // Sass and CSS packages const sass = require("gulp-sass"), @@ -176,6 +178,17 @@ function processJavaScript(outputFilename, inputFiles, es6) { return javascript.pipe(gulp.dest("public/js/")); } +// Update the version string +function updateVersion() { + crypto.randomBytes(16, (err, buf) => { + if (err) { throw err; } + + return fs.writeFile("storage/app/__version.txt", buf.toString("hex"), (err) => { + if (err) { throw err; } + }); + }); +} + // Task for error page styles gulp.task("sass-error", () => { return processSass("error"); @@ -225,9 +238,16 @@ gulp.task("fonts", (done) => { done(); }); +// Task to update the cache-bust version +gulp.task("version", (done) => { + updateVersion(); + done(); +}); + // Task to watch files and run respective tasks when changes occur gulp.task("watch", () => { const browserSyncReload = (done) => { + updateVersion(); browserSync.reload(); done(); }; @@ -260,5 +280,6 @@ gulp.task("default", gulp.parallel( "js-public-libs", "js-dashboard", "js-dashboard-libs", - "fonts" + "fonts", + "version" )); diff --git a/init.sh b/init.sh index 9c820ce..29600fd 100755 --- a/init.sh +++ b/init.sh @@ -81,14 +81,6 @@ php artisan route:clear msg "Running: ${c_m}php artisan view:clear" php artisan view:clear -grep -qe '^CACHE_BUST=' .env || { - msg "Adding the ${c_y}CACHE_BUST$c_w variable" - printf '\n%s\n' 'CACHE_BUST=' >> .env -} - -msg "Updating ${c_y}CACHE_BUST$c_w variable" -sed -i 's|^CACHE_BUST=.*|CACHE_BUST='"$(LC_CTYPE=C LANG=C tr -dc A-Za-z0-9 - - - + + + @yield('page-includes') @@ -50,7 +50,7 @@ @if(Config::get('app.debug') && Config::get('app.env') === 'local') @endif diff --git a/resources/views/templates/dashboard.blade.php b/resources/views/templates/dashboard.blade.php index e8d92fb..3d17625 100644 --- a/resources/views/templates/dashboard.blade.php +++ b/resources/views/templates/dashboard.blade.php @@ -2,10 +2,10 @@ @set('current_page', preg_replace([ '/https?:\/\//', '/^[^\/]*\/[^\/]*\//', '/\/.*/' ], [ '', '', '' ], Request::url())) @section('page-includes') - - - - + + + + @endsection @section('page-top') diff --git a/resources/views/templates/error.blade.php b/resources/views/templates/error.blade.php index 2fb9335..7065f22 100644 --- a/resources/views/templates/error.blade.php +++ b/resources/views/templates/error.blade.php @@ -1,7 +1,7 @@ @extends('templates.base') @section('page-includes') - + @endsection @section('page-content') diff --git a/resources/views/templates/public.blade.php b/resources/views/templates/public.blade.php index 3c08d74..e7318f1 100644 --- a/resources/views/templates/public.blade.php +++ b/resources/views/templates/public.blade.php @@ -1,8 +1,8 @@ @extends('templates.base') @section('page-includes') - - + + + @endsection