From 005b44dab4a374b964e0ba9b045c425c86e7b015 Mon Sep 17 00:00:00 2001 From: Michael Mano Date: Thu, 25 Oct 2018 23:33:17 +1000 Subject: [PATCH] [5.7] Tidy up for artisan preset command (#26244) * [5.7] Update vue version to 2.5.17 * [5.7] Fix for preset none command still requiring bootstrap --- .../Foundation/Console/Presets/None.php | 1 + .../Foundation/Console/Presets/Vue.php | 2 +- .../Console/Presets/none-stubs/bootstrap.js | 43 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/Illuminate/Foundation/Console/Presets/none-stubs/bootstrap.js diff --git a/src/Illuminate/Foundation/Console/Presets/None.php b/src/Illuminate/Foundation/Console/Presets/None.php index 901471aa709f..bc93a2a9c951 100644 --- a/src/Illuminate/Foundation/Console/Presets/None.php +++ b/src/Illuminate/Foundation/Console/Presets/None.php @@ -55,5 +55,6 @@ protected static function updateBootstrapping() { file_put_contents(resource_path('sass/app.scss'), ''.PHP_EOL); copy(__DIR__.'/none-stubs/app.js', resource_path('js/app.js')); + copy(__DIR__.'/none-stubs/bootstrap.js', resource_path('js/bootstrap.js')); } } diff --git a/src/Illuminate/Foundation/Console/Presets/Vue.php b/src/Illuminate/Foundation/Console/Presets/Vue.php index 2b3aaf61c61a..d25ffb8dd141 100644 --- a/src/Illuminate/Foundation/Console/Presets/Vue.php +++ b/src/Illuminate/Foundation/Console/Presets/Vue.php @@ -30,7 +30,7 @@ public static function install() */ protected static function updatePackageArray(array $packages) { - return ['vue' => '^2.5.7'] + Arr::except($packages, [ + return ['vue' => '^2.5.17'] + Arr::except($packages, [ 'babel-preset-react', 'react', 'react-dom', diff --git a/src/Illuminate/Foundation/Console/Presets/none-stubs/bootstrap.js b/src/Illuminate/Foundation/Console/Presets/none-stubs/bootstrap.js new file mode 100644 index 000000000000..372bf25459b7 --- /dev/null +++ b/src/Illuminate/Foundation/Console/Presets/none-stubs/bootstrap.js @@ -0,0 +1,43 @@ + +window._ = require('lodash'); + +/** + * We'll load the axios HTTP library which allows us to easily issue requests + * to our Laravel back-end. This library automatically handles sending the + * CSRF token as a header based on the value of the "XSRF" token cookie. + */ + +window.axios = require('axios'); + +window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; + +/** + * Next we will register the CSRF Token as a common header with Axios so that + * all outgoing HTTP requests automatically have it attached. This is just + * a simple convenience so we don't have to attach every token manually. + */ + +let token = document.head.querySelector('meta[name="csrf-token"]'); + +if (token) { + window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; +} else { + console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token'); +} + +/** + * Echo exposes an expressive API for subscribing to channels and listening + * for events that are broadcast by Laravel. Echo and event broadcasting + * allows your team to easily build robust real-time web applications. + */ + +// import Echo from 'laravel-echo' + +// window.Pusher = require('pusher-js'); + +// window.Echo = new Echo({ +// broadcaster: 'pusher', +// key: process.env.MIX_PUSHER_APP_KEY, +// cluster: process.env.MIX_PUSHER_APP_CLUSTER, +// encrypted: true +// });