druxt
Advanced tools
Comparing version 0.17.0 to 0.18.0
@@ -12,3 +12,3 @@ import chalk from 'chalk'; | ||
var name = "druxt"; | ||
var version = "0.17.0"; | ||
var version = "0.18.0"; | ||
var description = "The Fully Decoupled Drupal Framework for Nuxt.js."; | ||
@@ -51,4 +51,4 @@ var keywords = [ | ||
var dependencies = { | ||
"@nuxtjs/axios": "^5.13.6", | ||
"@nuxtjs/proxy": "^2.1.0", | ||
axios: "^0.21.1", | ||
chalk: "^4.1.2", | ||
@@ -65,2 +65,3 @@ deepmerge: "^4.2.2", | ||
var peerDependencies = { | ||
axios: "*", | ||
consola: "*" | ||
@@ -130,2 +131,10 @@ }; | ||
} | ||
if (!options.axios) { | ||
this.options.axios = { | ||
baseURL: options.baseUrl, | ||
proxy: !!this.options.proxy, | ||
...this.options.axios | ||
}; | ||
this.addModule("@nuxtjs/axios"); | ||
} | ||
this.nuxt.hook("components:dirs", (dirs) => { | ||
@@ -142,6 +151,9 @@ dirs.push({ path: join(__dirname, "components") }); | ||
plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins; | ||
const index = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`); | ||
const plugin = plugins[index]; | ||
plugins.splice(index, 1); | ||
plugins.unshift(plugin); | ||
const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`); | ||
const axiosPlugin = plugins[axiosIndex]; | ||
plugins.splice(axiosIndex, 1); | ||
const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`); | ||
const druxtPlugin = plugins[druxtIndex]; | ||
plugins.splice(druxtIndex, 1); | ||
plugins = [axiosPlugin, druxtPlugin, ...plugins]; | ||
return plugins; | ||
@@ -173,10 +185,11 @@ }; | ||
} | ||
let axiosSettings = {}; | ||
if (baseUrl && !(options.proxy || {}).api) { | ||
axiosSettings.baseURL = baseUrl; | ||
this.axios = {}; | ||
if (typeof options.axios === "function") { | ||
this.axios = options.axios; | ||
} else { | ||
this.axios = axios.create({ | ||
...options.axios || {}, | ||
baseURL: baseUrl | ||
}); | ||
} | ||
if (typeof options.axios === "object") { | ||
axiosSettings = Object.assign(axiosSettings, options.axios); | ||
} | ||
this.axios = axios.create(axiosSettings); | ||
if (options.debug) { | ||
@@ -183,0 +196,0 @@ const log = this.log; |
@@ -25,3 +25,3 @@ 'use strict'; | ||
var name = "druxt"; | ||
var version = "0.17.0"; | ||
var version = "0.18.0"; | ||
var description = "The Fully Decoupled Drupal Framework for Nuxt.js."; | ||
@@ -64,4 +64,4 @@ var keywords = [ | ||
var dependencies = { | ||
"@nuxtjs/axios": "^5.13.6", | ||
"@nuxtjs/proxy": "^2.1.0", | ||
axios: "^0.21.1", | ||
chalk: "^4.1.2", | ||
@@ -78,2 +78,3 @@ deepmerge: "^4.2.2", | ||
var peerDependencies = { | ||
axios: "*", | ||
consola: "*" | ||
@@ -143,2 +144,10 @@ }; | ||
} | ||
if (!options.axios) { | ||
this.options.axios = { | ||
baseURL: options.baseUrl, | ||
proxy: !!this.options.proxy, | ||
...this.options.axios | ||
}; | ||
this.addModule("@nuxtjs/axios"); | ||
} | ||
this.nuxt.hook("components:dirs", (dirs) => { | ||
@@ -155,6 +164,9 @@ dirs.push({ path: path.join(__dirname, "components") }); | ||
plugins = typeof extendPlugins === "function" ? extendPlugins(plugins) : plugins; | ||
const index = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`); | ||
const plugin = plugins[index]; | ||
plugins.splice(index, 1); | ||
plugins.unshift(plugin); | ||
const axiosIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/axios.js`); | ||
const axiosPlugin = plugins[axiosIndex]; | ||
plugins.splice(axiosIndex, 1); | ||
const druxtIndex = plugins.findIndex(({ src }) => src === `${this.options.buildDir}/druxt.js`); | ||
const druxtPlugin = plugins[druxtIndex]; | ||
plugins.splice(druxtIndex, 1); | ||
plugins = [axiosPlugin, druxtPlugin, ...plugins]; | ||
return plugins; | ||
@@ -186,10 +198,11 @@ }; | ||
} | ||
let axiosSettings = {}; | ||
if (baseUrl && !(options.proxy || {}).api) { | ||
axiosSettings.baseURL = baseUrl; | ||
this.axios = {}; | ||
if (typeof options.axios === "function") { | ||
this.axios = options.axios; | ||
} else { | ||
this.axios = axios__default['default'].create({ | ||
...options.axios || {}, | ||
baseURL: baseUrl | ||
}); | ||
} | ||
if (typeof options.axios === "object") { | ||
axiosSettings = Object.assign(axiosSettings, options.axios); | ||
} | ||
this.axios = axios__default['default'].create(axiosSettings); | ||
if (options.debug) { | ||
@@ -196,0 +209,0 @@ const log = this.log; |
{ | ||
"name": "druxt", | ||
"version": "0.17.0", | ||
"version": "0.18.0", | ||
"description": "The Fully Decoupled Drupal Framework for Nuxt.js.", | ||
@@ -41,4 +41,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@nuxtjs/axios": "^5.13.6", | ||
"@nuxtjs/proxy": "^2.1.0", | ||
"axios": "^0.21.1", | ||
"chalk": "^4.1.2", | ||
@@ -55,2 +55,3 @@ "deepmerge": "^4.2.2", | ||
"peerDependencies": { | ||
"axios": "*", | ||
"consola": "*" | ||
@@ -57,0 +58,0 @@ }, |
import { DruxtClient } from 'druxt' | ||
export default (context, inject) => { | ||
export default ({ app }, inject) => { | ||
const options = <%= JSON.stringify(options) %> | ||
@@ -11,2 +11,11 @@ | ||
<% if (typeof options.axios === 'object') { %> | ||
// Axios settings. | ||
console.warn('[druxt] Axios instance settings are deprecated, use @nuxtjs/axios module configuration instead.') | ||
options.axios = <%= JSON.stringify(options.axios) %> | ||
<% } else { %> | ||
// Use the @nuxtjs/axios module Axios instance. | ||
options.axios = app.$axios | ||
<% } %> | ||
const druxt = new DruxtClient(options.baseUrl, options) | ||
@@ -13,0 +22,0 @@ druxt.settings = options |
72287
1283
13
+ Added@nuxtjs/axios@^5.13.6
+ Added@babel/runtime@7.24.7(transitive)
+ Added@nuxtjs/axios@5.13.6(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.7.2(transitive)
+ Addedaxios-retry@3.9.1(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedconsola@2.15.3(transitive)
+ Addeddefu@5.0.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.0(transitive)
+ Addedis-retry-allowed@2.2.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removedaxios@^0.21.1