This commit is contained in:
2022-07-21 03:28:35 +00:00
parent d7c883d6df
commit 51b34b0e1d
30103 changed files with 4152204 additions and 23 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Nuxt Community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Generated Vendored Executable
+56
View File
@@ -0,0 +1,56 @@
[![@nuxtjs/axios](https://axios.nuxtjs.org/preview.png)](https://axios.nuxtjs.org)
# @nuxtjs/axios
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
[![Codecov][codecov-src]][codecov-href]
[![License][license-src]][license-href]
> Secure and easy [Axios](https://github.com/axios/axios) integration for [Nuxt](https://nuxtjs.org).
- [✨  Release Notes](https://axios.nuxtjs.org/releases)
- [📖  Documentation](https://axios.nuxtjs.org)
## Features
- Automatically set base URL for client & server side
- Exposes `setToken` function to `$axios` so we can easily and globally set authentication tokens
- Automatically enables `withCredentials` when requesting to base URL
- Proxy request headers in SSR
- Fetch Style requests
- Integrated with Nuxt progress bar
- Integrated with Proxy Module
- Auto retry requests with axios-retry
[📖  Read more](https://axios.nuxtjs.org)
## Contributing
1. Clone this repository
2. Install dependencies using `yarn install` or `npm install`
3. Start development server using `npm run dev`
## 📑 License
[MIT License](./LICENSE)
Copyright (c) Nuxt Community
<!-- Badges -->
<!-- Badges -->
[npm-version-src]: https://flat.badgen.net/npm/v/@nuxtjs/axios
[npm-version-href]: https://npmjs.com/package/@nuxtjs/axios
[npm-downloads-src]: https://flat.badgen.net/npm/dm/@nuxtjs/axios
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/axios
[github-actions-ci-src]: https://github.com/nuxt-community/axios-module/workflows/ci/badge.svg
[github-actions-ci-href]: https://github.com/nuxt-community/axios-module/actions?query=workflow%3Aci
[codecov-src]: https://flat.badgen.net/codecov/c/github/nuxt-community/axios-module
[codecov-href]: https://codecov.io/gh/nuxt-community/axios-module
[license-src]: https://img.shields.io/npm/l/@nuxtjs/axios.svg
[license-href]: https://npmjs.com/package/@nuxtjs/axios
Generated Vendored Executable
+155
View File
@@ -0,0 +1,155 @@
const path = require('path')
const consola = require('consola')
const defu = require('defu')
const logger = consola.withScope('nuxt:axios')
function axiosModule (_moduleOptions) {
const { nuxt } = this
// Combine options
const moduleOptions = {
...nuxt.options.axios,
..._moduleOptions,
...(nuxt.options.runtimeConfig && nuxt.options.runtimeConfig.axios)
}
// Default port
const defaultPort =
process.env.API_PORT ||
moduleOptions.port ||
process.env.PORT ||
process.env.npm_package_config_nuxt_port ||
(this.options.server && this.options.server.port) ||
3000
// Default host
let defaultHost =
process.env.API_HOST ||
moduleOptions.host ||
process.env.HOST ||
process.env.npm_package_config_nuxt_host ||
(this.options.server && this.options.server.host) ||
'localhost'
/* istanbul ignore if */
if (defaultHost === '0.0.0.0') {
defaultHost = 'localhost'
}
// Transpile defu (IE11)
if (nuxt.options.build.transpile /* nuxt 1 */) {
nuxt.options.build.transpile.push(({ isClient }) => isClient && 'defu')
}
// Default prefix
const prefix = process.env.API_PREFIX || moduleOptions.prefix || '/'
// HTTPS
const https = Boolean(this.options.server && this.options.server.https)
// Headers
const headers = {
common: {
Accept: 'application/json, text/plain, */*'
},
delete: {},
get: {},
head: {},
post: {},
put: {},
patch: {}
}
// Support baseUrl alternative
if (moduleOptions.baseUrl) {
moduleOptions.baseURL = moduleOptions.baseUrl
delete moduleOptions.baseUrl
}
if (moduleOptions.browserBaseUrl) {
moduleOptions.browserBaseURL = moduleOptions.browserBaseUrl
delete moduleOptions.browserBaseUrl
}
// Apply defaults
const options = defu(moduleOptions, {
baseURL: `http://${defaultHost}:${defaultPort}${prefix}`,
browserBaseURL: undefined,
credentials: false,
debug: false,
progress: true,
proxyHeaders: true,
proxyHeadersIgnore: [
'accept',
'cf-connecting-ip',
'cf-ray',
'content-length',
'content-md5',
'content-type',
'host',
'x-forwarded-host',
'x-forwarded-port',
'x-forwarded-proto'
],
proxy: false,
retry: false,
https,
headers
})
// ENV overrides
/* istanbul ignore if */
if (process.env.API_URL) {
options.baseURL = process.env.API_URL
}
/* istanbul ignore if */
if (process.env.API_URL_BROWSER) {
options.browserBaseURL = process.env.API_URL_BROWSER
}
// Default browserBaseURL
if (typeof options.browserBaseURL === 'undefined') {
options.browserBaseURL = options.proxy ? prefix : options.baseURL
}
// Normalize options
if (options.retry === true) {
options.retry = {}
}
// Convert http:// to https:// if https option is on
if (options.https === true) {
const https = s => s.replace('http://', 'https://')
options.baseURL = https(options.baseURL)
options.browserBaseURL = https(options.browserBaseURL)
}
// globalName
options.globalName = this.nuxt.options.globalName || 'nuxt'
// Register plugin
this.addPlugin({
src: path.resolve(__dirname, 'plugin.js'),
fileName: 'axios.js',
options
})
// Proxy integration
if (options.proxy) {
this.requireModule([
'@nuxtjs/proxy',
typeof options.proxy === 'object' ? options.proxy : {}
])
}
// Set _AXIOS_BASE_URL_ for dynamic SSR baseURL
process.env._AXIOS_BASE_URL_ = options.baseURL
logger.debug(`baseURL: ${options.baseURL}`)
logger.debug(`browserBaseURL: ${options.browserBaseURL}`)
}
module.exports = axiosModule
module.exports.meta = require('../package.json')
+231
View File
@@ -0,0 +1,231 @@
import Axios from 'axios'
import defu from 'defu'
<% if (options.retry) { %>import axiosRetry from 'axios-retry'<% } %>
// Axios.prototype cannot be modified
const axiosExtra = {
setBaseURL (baseURL) {
this.defaults.baseURL = baseURL
},
setHeader (name, value, scopes = 'common') {
for (const scope of Array.isArray(scopes) ? scopes : [ scopes ]) {
if (!value) {
delete this.defaults.headers[scope][name];
continue
}
this.defaults.headers[scope][name] = value
}
},
setToken (token, type, scopes = 'common') {
const value = !token ? null : (type ? type + ' ' : '') + token
this.setHeader('Authorization', value, scopes)
},
onRequest(fn) {
this.interceptors.request.use(config => fn(config) || config)
},
onResponse(fn) {
this.interceptors.response.use(response => fn(response) || response)
},
onRequestError(fn) {
this.interceptors.request.use(undefined, error => fn(error) || Promise.reject(error))
},
onResponseError(fn) {
this.interceptors.response.use(undefined, error => fn(error) || Promise.reject(error))
},
onError(fn) {
this.onRequestError(fn)
this.onResponseError(fn)
},
create(options) {
return createAxiosInstance(defu(options, this.defaults))
}
}
// Request helpers ($get, $post, ...)
for (const method of ['request', 'delete', 'get', 'head', 'options', 'post', 'put', 'patch']) {
axiosExtra['$' + method] = function () { return this[method].apply(this, arguments).then(res => res && res.data) }
}
const extendAxiosInstance = axios => {
for (const key in axiosExtra) {
axios[key] = axiosExtra[key].bind(axios)
}
}
const createAxiosInstance = axiosOptions => {
// Create new axios instance
const axios = Axios.create(axiosOptions)
axios.CancelToken = Axios.CancelToken
axios.isCancel = Axios.isCancel
// Extend axios proto
extendAxiosInstance(axios)
// Intercept to apply default headers
axios.onRequest((config) => {
config.headers = { ...axios.defaults.headers.common, ...config.headers }
})
// Setup interceptors
<% if (options.debug) { %>setupDebugInterceptor(axios) <% } %>
<% if (options.credentials) { %>setupCredentialsInterceptor(axios) <% } %>
<% if (options.progress) { %>setupProgress(axios) <% } %>
<% if (options.retry) { %>axiosRetry(axios, <%= serialize(options.retry) %>) <% } %>
return axios
}
<% if (options.debug) { %>
const log = (level, ...messages) => console[level]('[Axios]', ...messages)
const setupDebugInterceptor = axios => {
// request
axios.onRequestError(error => {
log('error', 'Request error:', error)
})
// response
axios.onResponseError(error => {
log('error', 'Response error:', error)
})
axios.onResponse(res => {
log(
'info',
'[' + (res.status + ' ' + res.statusText) + ']',
'[' + res.config.method.toUpperCase() + ']',
res.config.url)
if (process.browser) {
console.log(res)
} else {
console.log(JSON.stringify(res.data, undefined, 2))
}
return res
})
}<% } %>
<% if (options.credentials) { %>
const setupCredentialsInterceptor = axios => {
// Send credentials only to relative and API Backend requests
axios.onRequest(config => {
if (config.withCredentials === undefined) {
if (!/^https?:\/\//i.test(config.url) || config.url.indexOf(config.baseURL) === 0) {
config.withCredentials = true
}
}
})
}<% } %>
<% if (options.progress) { %>
const setupProgress = (axios) => {
if (process.server) {
return
}
// A noop loading inteterface for when $nuxt is not yet ready
const noopLoading = {
finish: () => { },
start: () => { },
fail: () => { },
set: () => { }
}
const $loading = () => {
const $nuxt = typeof window !== 'undefined' && window['$<%= options.globalName %>']
return ($nuxt && $nuxt.$loading && $nuxt.$loading.set) ? $nuxt.$loading : noopLoading
}
let currentRequests = 0
axios.onRequest(config => {
if (config && config.progress === false) {
return
}
currentRequests++
})
axios.onResponse(response => {
if (response && response.config && response.config.progress === false) {
return
}
currentRequests--
if (currentRequests <= 0) {
currentRequests = 0
$loading().finish()
}
})
axios.onError(error => {
if (error && error.config && error.config.progress === false) {
return
}
currentRequests--
if (Axios.isCancel(error)) {
if (currentRequests <= 0) {
currentRequests = 0
$loading().finish()
}
return
}
$loading().fail()
$loading().finish()
})
const onProgress = e => {
if (!currentRequests || !e.total) {
return
}
const progress = ((e.loaded * 100) / (e.total * currentRequests))
$loading().set(Math.min(100, progress))
}
axios.defaults.onUploadProgress = onProgress
axios.defaults.onDownloadProgress = onProgress
}<% } %>
export default (ctx, inject) => {
// runtimeConfig
const runtimeConfig = ctx.$config && ctx.$config.axios || {}
// baseURL
const baseURL = process.browser
? (runtimeConfig.browserBaseURL || runtimeConfig.browserBaseUrl || runtimeConfig.baseURL || runtimeConfig.baseUrl || '<%= options.browserBaseURL || '' %>')
: (runtimeConfig.baseURL || runtimeConfig.baseUrl || process.env._AXIOS_BASE_URL_ || '<%= options.baseURL || '' %>')
// Create fresh objects for all default header scopes
// Axios creates only one which is shared across SSR requests!
// https://github.com/mzabriskie/axios/blob/master/lib/defaults.js
const headers = <%= JSON.stringify(options.headers, null, 4) %>
const axiosOptions = {
baseURL,
headers
}
<% if (options.proxyHeaders) { %>
// Proxy SSR request headers headers
if (process.server && ctx.req && ctx.req.headers) {
const reqHeaders = { ...ctx.req.headers }
for (const h of <%= serialize(options.proxyHeadersIgnore) %>) {
delete reqHeaders[h]
}
axiosOptions.headers.common = { ...reqHeaders, ...axiosOptions.headers.common }
}
<% } %>
if (process.server) {
// Don't accept brotli encoding because Node can't parse it
axiosOptions.headers.common['accept-encoding'] = 'gzip, deflate'
}
const axios = createAxiosInstance(axiosOptions)
// Inject axios to the context as $axios
ctx.$axios = axios
inject('axios', axios)
}
+80
View File
@@ -0,0 +1,80 @@
{
"_args": [
[
"@nuxtjs/axios@5.13.6",
"/home/node/nuxt"
]
],
"_from": "@nuxtjs/axios@5.13.6",
"_id": "@nuxtjs/axios@5.13.6",
"_inBundle": false,
"_integrity": "sha512-XS+pOE0xsDODs1zAIbo95A0LKlilvJi8YW0NoXYuq3/jjxGgWDxizZ6Yx0AIIjZOoGsXJOPc0/BcnSEUQ2mFBA==",
"_location": "/@nuxtjs/axios",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/axios@5.13.6",
"name": "@nuxtjs/axios",
"escapedName": "@nuxtjs%2faxios",
"scope": "@nuxtjs",
"rawSpec": "5.13.6",
"saveSpec": null,
"fetchSpec": "5.13.6"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/axios/-/axios-5.13.6.tgz",
"_spec": "5.13.6",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt-community/axios-module/issues"
},
"contributors": [
{
"name": "Pooya Parsa",
"email": "pooya@pi0.ir"
}
],
"dependencies": {
"@nuxtjs/proxy": "^2.1.0",
"axios": "^0.21.1",
"axios-retry": "^3.1.9",
"consola": "^2.15.3",
"defu": "^5.0.0"
},
"description": "Secure and easy Axios integration with Nuxt.js",
"devDependencies": {
"@babel/core": "latest",
"@babel/preset-env": "latest",
"@nuxtjs/eslint-config": "latest",
"babel-eslint": "latest",
"babel-jest": "latest",
"codecov": "latest",
"eslint": "latest",
"jest": "latest",
"nuxt-edge": "latest",
"standard-version": "latest"
},
"files": [
"lib",
"types/*.d.ts"
],
"homepage": "https://github.com/nuxt-community/axios-module#readme",
"license": "MIT",
"main": "lib/module.js",
"name": "@nuxtjs/axios",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt-community/axios-module.git"
},
"scripts": {
"dev": "nuxt test/fixture",
"lint": "eslint lib test",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
},
"types": "types/index.d.ts",
"version": "5.13.6"
}
+88
View File
@@ -0,0 +1,88 @@
import { AxiosError, AxiosRequestConfig, AxiosResponse, AxiosStatic } from 'axios'
import { IAxiosRetryConfig } from 'axios-retry'
import Vue from 'vue'
import './vuex'
interface NuxtAxiosInstance extends AxiosStatic {
$request<T = any>(config: AxiosRequestConfig): Promise<T>
$get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
$delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
$head<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
$options<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>
$post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>
$put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>
$patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>
setBaseURL(baseURL: string): void
setHeader(name: string, value?: string | false, scopes?: string | string[]): void
setToken(token: string | false, type?: string, scopes?: string | string[]): void
onRequest(callback: (config: AxiosRequestConfig) => void | AxiosRequestConfig | Promise<AxiosRequestConfig>): void
onResponse<T = any>(callback: (response: AxiosResponse<T>) => void | AxiosResponse<T> | Promise<AxiosResponse<T>> ): void
onError(callback: (error: AxiosError) => any): void
onRequestError(callback: (error: AxiosError) => any): void
onResponseError(callback: (error: AxiosError) => any): void
create(options?: AxiosRequestConfig): NuxtAxiosInstance
}
interface AxiosOptions {
baseURL?: string,
browserBaseURL?: string,
credentials?: boolean,
debug?: boolean,
host?: string,
prefix?: string,
progress?: boolean,
proxyHeaders?: boolean,
proxyHeadersIgnore?: string[],
proxy?: boolean,
port?: string | number,
retry?: boolean | IAxiosRetryConfig,
https?: boolean,
headers?: {
common?: Record<string, string>,
delete?: Record<string, string>,
get?: Record<string, string>,
head?: Record<string, string>,
post?: Record<string, string>,
put?: Record<string, string>,
patch?: Record<string, string>,
},
}
declare module 'axios' {
interface AxiosRequestConfig {
progress?: boolean;
}
}
declare module '@nuxt/vue-app' {
interface Context {
$axios: NuxtAxiosInstance
}
interface NuxtAppOptions {
$axios: NuxtAxiosInstance
}
}
// Nuxt 2.9+
declare module '@nuxt/types' {
interface Context {
$axios: NuxtAxiosInstance
}
interface NuxtAppOptions {
$axios: NuxtAxiosInstance
}
interface Configuration {
axios?: AxiosOptions
}
}
declare module 'vue/types/vue' {
interface Vue {
$axios: NuxtAxiosInstance
}
}
+7
View File
@@ -0,0 +1,7 @@
import { NuxtAxiosInstance } from '.'
declare module 'vuex/types/index' {
interface Store<S> {
$axios: NuxtAxiosInstance,
}
}
+64
View File
@@ -0,0 +1,64 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.0.0](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config-typescript@1.0.2...@nuxtjs/eslint-config-typescript@2.0.0) (2020-05-12)
**Note:** Version bump only for package @nuxtjs/eslint-config-typescript
## [1.0.2](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config-typescript@1.0.1...@nuxtjs/eslint-config-typescript@1.0.2) (2020-02-09)
**Note:** Version bump only for package @nuxtjs/eslint-config-typescript
## [1.0.1](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config-typescript@1.0.0...@nuxtjs/eslint-config-typescript@1.0.1) (2020-02-09)
**Note:** Version bump only for package @nuxtjs/eslint-config-typescript
# [1.0.0](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config-typescript@0.1.3...@nuxtjs/eslint-config-typescript@1.0.0) (2019-11-26)
**Note:** Version bump only for package @nuxtjs/eslint-config-typescript
## [0.1.3](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config-typescript@0.1.2...@nuxtjs/eslint-config-typescript@0.1.3) (2019-09-11)
**Note:** Version bump only for package @nuxtjs/eslint-config-typescript
## 0.1.2 (2019-08-10)
**Note:** Version bump only for package @nuxtjs/eslint-config-typescript
## [0.1.1](https://github.com/nuxt/eslint-config/compare/@nuxtjs/typescript-eslint-config@0.1.0...@nuxtjs/typescript-eslint-config@0.1.1) (2019-08-10)
**Note:** Version bump only for package @nuxtjs/typescript-eslint-config
# 0.1.0 (2019-08-10)
* Initial release ([#54](https://github.com/nuxt/eslint-config/pull/54))
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Nuxt.js
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+12
View File
@@ -0,0 +1,12 @@
module.exports = {
extends: [
'@nuxtjs'
],
plugins: ['@typescript-eslint'],
parserOptions: {
parser: '@typescript-eslint/parser'
},
rules: {
'@typescript-eslint/no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }]
}
}
+62
View File
@@ -0,0 +1,62 @@
{
"_args": [
[
"@nuxtjs/eslint-config-typescript@2.0.0",
"/home/node/nuxt"
]
],
"_development": true,
"_from": "@nuxtjs/eslint-config-typescript@2.0.0",
"_id": "@nuxtjs/eslint-config-typescript@2.0.0",
"_inBundle": false,
"_integrity": "sha512-qqSt9E62QmBE+zRr7e9dTuf2zTYBFd608Bz611y80RfnjhViZlKFHwrjKAejY5UrjKKUoIWUcIVjozWWQzDm3A==",
"_location": "/@nuxtjs/eslint-config-typescript",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/eslint-config-typescript@2.0.0",
"name": "@nuxtjs/eslint-config-typescript",
"escapedName": "@nuxtjs%2feslint-config-typescript",
"scope": "@nuxtjs",
"rawSpec": "2.0.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/eslint-config-typescript/-/eslint-config-typescript-2.0.0.tgz",
"_spec": "2.0.0",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt/eslint-config/issues"
},
"contributors": [
{
"name": "Kevin Marrec",
"email": "kevin@marrec.io"
}
],
"dependencies": {
"@nuxtjs/eslint-config": "3.0.0",
"@typescript-eslint/eslint-plugin": "^2.32.0",
"@typescript-eslint/parser": "^2.32.0"
},
"description": "Nuxt.js eslint typescript config",
"files": [
"index.js"
],
"gitHead": "173b586031f3ebd8d9b52c0bf369078ebaa598f7",
"homepage": "https://github.com/nuxt/eslint-config/tree/master/packages/eslint-config-typescript",
"license": "MIT",
"name": "@nuxtjs/eslint-config-typescript",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/eslint-config.git"
},
"version": "2.0.0"
}
+97
View File
@@ -0,0 +1,97 @@
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [3.0.0](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config@2.0.2...@nuxtjs/eslint-config@3.0.0) (2020-05-12)
### Bug Fixes
* eslint-plugin-import ordering errors in windows ([39ad2b4](https://github.com/nuxt/eslint-config/commit/39ad2b46da470198f71ba111ee23d9b037a49a75))
## [2.0.2](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config@2.0.1...@nuxtjs/eslint-config@2.0.2) (2020-02-09)
### Bug Fixes
* eslint-plugin-import ordering errors in windows ([4f6f4a9](https://github.com/nuxt/eslint-config/commit/4f6f4a9566149e438bfdf9046f82151e050d7ce7))
## [2.0.1](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config@2.0.0...@nuxtjs/eslint-config@2.0.1) (2020-02-09)
**Note:** Version bump only for package @nuxtjs/eslint-config
# [2.0.0](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config@1.1.2...@nuxtjs/eslint-config@2.0.0) (2019-11-26)
### Features
* update eslint config packages ([a3bb0bf](https://github.com/nuxt/eslint-config/commit/a3bb0bfb923f18fd11447e048a29d11f29a3aa75))
## [1.1.2](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config@1.1.1...@nuxtjs/eslint-config@1.1.2) (2019-08-10)
**Note:** Version bump only for package @nuxtjs/eslint-config
## [1.1.1](https://github.com/nuxt/eslint-config/compare/@nuxtjs/eslint-config@1.1.0...@nuxtjs/eslint-config@1.1.1) (2019-08-10)
**Note:** Version bump only for package @nuxtjs/eslint-config
# 1.1.0 (2019-08-10)
## Features
* warn console and debugger in dev ([#56](https://github.com/nuxt/eslint-config/issues/56))
### [1.0.1](https://github.com/nuxt/eslint-config/compare/v1.0.0...v1.0.1) (2019-07-07)
### Bug Fixes
* move eslint plugins from peerDeps to deps ([4e8d231](https://github.com/nuxt/eslint-config/commit/4e8d231))
<a name="1.0.0"></a>
# [1.0.0](https://github.com/nuxt/eslint-config/compare/v0.0.1...v1.0.0) (2019-07-07)
### Bug Fixes
* avoid changing basic StandardJS rules ([#25](https://github.com/nuxt/eslint-config/issues/25)) ([38e3582](https://github.com/nuxt/eslint-config/commit/38e3582))
### Features
* add eslint-plugin-unicorn rules ([#35](https://github.com/nuxt/eslint-config/issues/35)) ([03bb05f](https://github.com/nuxt/eslint-config/commit/03bb05f))
* conditional no-console based on env ([#2](https://github.com/nuxt/eslint-config/issues/2)) ([60826b7](https://github.com/nuxt/eslint-config/commit/60826b7))
* force object shorthand ([#29](https://github.com/nuxt/eslint-config/issues/29)) ([b149bc2](https://github.com/nuxt/eslint-config/commit/b149bc2))
* prohibit useless renaming ([#28](https://github.com/nuxt/eslint-config/issues/28)) ([79c9de7](https://github.com/nuxt/eslint-config/commit/79c9de7))
<a name="0.0.1"></a>
## 0.0.1 (2018-10-12)
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Nuxt.js
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+132
View File
@@ -0,0 +1,132 @@
module.exports = {
env: {
browser: true,
node: true,
'jest/globals': true
},
extends: [
'standard',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:vue/recommended'
],
plugins: [
'jest',
'unicorn',
'vue'
],
settings: {
'import/resolver': {
node: { extensions: ['.js', '.mjs'] }
}
},
rules: {
/**********************/
/* General Code Rules */
/**********************/
// Enforce import order
'import/order': 'error',
// Imports should come first
'import/first': 'error',
// Other import rules
'import/no-mutable-exports': 'error',
// Allow unresolved imports
'import/no-unresolved': 'off',
// Allow paren-less arrow functions only when there's no braces
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
// Allow async-await
'generator-star-spacing': 'off',
// Allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
// Prefer const over let
'prefer-const': ['error', {
destructuring: 'any',
ignoreReadBeforeAssign: false
}],
// No single if in an "else" block
'no-lonely-if': 'error',
// Force curly braces for control flow,
// including if blocks with a single statement
curly: ['error', 'all'],
// No async function without await
'require-await': 'error',
// Force dot notation when possible
'dot-notation': 'error',
'no-var': 'error',
// Force object shorthand where possible
'object-shorthand': 'error',
// No useless destructuring/importing/exporting renames
'no-useless-rename': 'error',
/**********************/
/* Unicorn Rules */
/**********************/
// Pass error message when throwing errors
'unicorn/error-message': 'error',
// Uppercase regex escapes
'unicorn/escape-case': 'error',
// Array.isArray instead of instanceof
'unicorn/no-array-instanceof': 'error',
// Prevent deprecated `new Buffer()`
'unicorn/no-new-buffer': 'error',
// Keep regex literals safe!
'unicorn/no-unsafe-regex': 'off',
// Lowercase number formatting for octal, hex, binary (0x12 instead of 0X12)
'unicorn/number-literal-case': 'error',
// ** instead of Math.pow()
'unicorn/prefer-exponentiation-operator': 'error',
// includes over indexOf when checking for existence
'unicorn/prefer-includes': 'error',
// String methods startsWith/endsWith instead of more complicated stuff
'unicorn/prefer-starts-ends-with': 'error',
// textContent instead of innerText
'unicorn/prefer-text-content': 'error',
// Enforce throwing type error when throwing error while checking typeof
'unicorn/prefer-type-error': 'error',
// Use new when throwing error
'unicorn/throw-new-error': 'error',
/**********************/
/* Vue Rules */
/**********************/
// Disable template errors regarding invalid end tags
'vue/no-parsing-error': ['error', {
'x-invalid-end-tag': false
}],
// Maximum 5 attributes per line instead of one
'vue/max-attributes-per-line': ['error', {
singleline: 5
}]
}
}
+71
View File
@@ -0,0 +1,71 @@
{
"_args": [
[
"@nuxtjs/eslint-config@3.0.0",
"/home/node/nuxt"
]
],
"_development": true,
"_from": "@nuxtjs/eslint-config@3.0.0",
"_id": "@nuxtjs/eslint-config@3.0.0",
"_inBundle": false,
"_integrity": "sha512-sjAyE0jSuk20Q1jalJ1TwUDJXDunmT4jBZe22cVYE9H2zeKcA8CAhEOvbl9713fJXkRrXDIJDOIHVvT8aWMgyw==",
"_location": "/@nuxtjs/eslint-config",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/eslint-config@3.0.0",
"name": "@nuxtjs/eslint-config",
"escapedName": "@nuxtjs%2feslint-config",
"scope": "@nuxtjs",
"rawSpec": "3.0.0",
"saveSpec": null,
"fetchSpec": "3.0.0"
},
"_requiredBy": [
"#DEV:/",
"/@nuxtjs/eslint-config-typescript"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/eslint-config/-/eslint-config-3.0.0.tgz",
"_spec": "3.0.0",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt/eslint-config/issues"
},
"contributors": [
{
"name": "Alexander Lichter",
"email": "npm@lichter.io"
}
],
"dependencies": {
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "2.19.1",
"eslint-plugin-jest": "^23.10.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-unicorn": "^19.0.1",
"eslint-plugin-vue": "^6.2.2"
},
"description": "Nuxt.js eslint config",
"files": [
"index.js"
],
"gitHead": "173b586031f3ebd8d9b52c0bf369078ebaa598f7",
"homepage": "https://github.com/nuxt/eslint-config/tree/master/packages/eslint-config",
"license": "MIT",
"name": "@nuxtjs/eslint-config",
"peerDependencies": {
"eslint": "^7.0.0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/eslint-config.git"
},
"version": "3.0.0"
}
+61
View File
@@ -0,0 +1,61 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [2.0.0](https://github.com/nuxt-community/eslint-module/compare/v1.2.0...v2.0.0) (2020-05-05)
### ⚠ BREAKING CHANGES
* drop support for eslint 5 ([28f7ce5](https://github.com/nuxt-community/eslint-module/commit/28f7ce5fb570c5a7bf8bc8093387bb967328f70a))
## [1.2.0](https://github.com/nuxt-community/eslint-module/compare/v1.1.0...v1.2.0) (2020-04-24)
### Features
* new option `extensions` ([#17](https://github.com/nuxt-community/eslint-module/issues/17)) ([4093800](https://github.com/nuxt-community/eslint-module/commit/40938001c0d61bad3a1d16afd15c4eb114bda803))
## [1.1.0](https://github.com/nuxt-community/eslint-module/compare/v1.0.0...v1.1.0) (2019-09-13)
## [1.0.0](https://github.com/nuxt-community/eslint-module/compare/v0.2.1...v1.0.0) (2019-07-26)
### [0.2.1](https://github.com/nuxt-community/eslint-module/compare/v0.2.0...v0.2.1) (2019-07-01)
### Bug Fixes
* add `eslint` in `peerDependencies` ([a17990d](https://github.com/nuxt-community/eslint-module/commit/a17990d))
## [0.2.0](https://github.com/nuxt-community/eslint-module/compare/v0.1.0...v0.2.0) (2019-06-27)
### Features
* watch config file ([1d8fa16](https://github.com/nuxt-community/eslint-module/commit/1d8fa16))
## [0.1.0](https://github.com/nuxt-community/eslint-module/compare/v0.0.1...v0.1.0) (2019-06-27)
### Features
* add options ([f1c9ebd](https://github.com/nuxt-community/eslint-module/commit/f1c9ebd))
* check if `eslint` is available ([#4](https://github.com/nuxt-community/eslint-module/issues/4)) ([5b8ef02](https://github.com/nuxt-community/eslint-module/commit/5b8ef02))
### Tests
* split tests in files ([55dc81b](https://github.com/nuxt-community/eslint-module/commit/55dc81b))
* **module:** move `example` to `test/fixture` ([b98ec30](https://github.com/nuxt-community/eslint-module/commit/b98ec30))
* **module:** use `get-port` ([ca93060](https://github.com/nuxt-community/eslint-module/commit/ca93060))
<a name="0.0.1"></a>
## 0.0.1 (2019-02-12)
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Nuxt Community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+179
View File
@@ -0,0 +1,179 @@
# @nuxtjs/eslint-module
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Github Actions CI][github-actions-ci-src]][github-actions-ci-href]
[![Codecov][codecov-src]][codecov-href]
[![License][license-src]][license-href]
> ESLint module for Nuxt.js
[📖 **Release Notes**](./CHANGELOG.md)
## Requirements
You need to ensure that you have `eslint` installed:
```bash
yarn add --dev eslint # or npm install --save-dev eslint
```
## Setup
1. Add `@nuxtjs/eslint-module` dependency to your project
```bash
yarn add --dev @nuxtjs/eslint-module # or npm install --save-dev @nuxtjs/eslint-module
```
2. Add `@nuxtjs/eslint-module` to the `buildModules` section of `nuxt.config.js`
```js
export default {
buildModules: [
// Simple usage
'@nuxtjs/eslint-module',
// With options
['@nuxtjs/eslint-module', { /* module options */ }]
]
}
```
:warning: If you are using Nuxt **< v2.9** you have to install the module as a `dependency` (No `--dev` or `--save-dev` flags) and use `modules` section in `nuxt.config.js` instead of `buildModules`.
### Using top level options
```js
export default {
buildModules: [
'@nuxtjs/eslint-module'
],
eslint: {
/* module options */
}
}
```
## Options
You can pass [eslint options](http://eslint.org/docs/developer-guide/nodejs-api#cliengine).
**Note**: That the config option you provide will be passed to the `CLIEngine`. This is a different set of options than what you'd specify in `package.json` or `.eslintrc`. See the [eslint docs](http://eslint.org/docs/developer-guide/nodejs-api#cliengine) for more detail.
### `cache`
- Type: `Boolean|String`
- Default: `false`
This option will enable caching of the linting results into a file. This is particularly useful in reducing linting time when doing a full build.
This can either be a `boolean` value or the cache directory path(ex: `'./.eslint-loader-cache'`).
If `cache: true` is used, the cache is written to the `./node_modules/.cache/eslint-loader` directory. This is the recommended usage.
### `eslintPath`
- Type: `String`
- Default: `eslint`
Path to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. Now you dont have to install `eslint`.
### `extensions`
- Type: `Array[String]`
- Default: `['ts', 'js', 'vue']`
Extensions that will be used by the loader.
### `fix`
- Type: `Boolean`
- Default: `false`
This option will enable [ESLint autofix feature](http://eslint.org/docs/user-guide/command-line-interface#fix).
**Be careful: this option will change source files.**
### `formatter`
- Type: `String|Function`
- Default: `stylish`
This option accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
### Errors and Warning
**By default the loader will auto adjust error reporting depending on eslint errors/warnings counts.** You can still force this behavior by using `emitError` **or** `emitWarning` options:
#### `emitError`
- Type: `Boolean`
- Default: `false`
Will always return errors, if this option is set to `true`.
#### `emitWarning`
- Type: `Boolean`
- Default: `false`
Will always return warnings, if option is set to `true`.
#### `failOnError`
- Type: `Boolean`
- Default: `false`
Will cause the module build to fail if there are any errors, if option is set to `true`.
#### `failOnWarning`
- Type: `Boolean`
- Default: `false`
Will cause the module build to fail if there are any warnings, if option is set to `true`.
#### `quiet`
- Type: `Boolean`
- Default: `false`
Will process and report errors only and ignore warnings, if this option is set to `true`.
#### `outputReport`
- Type: `Boolean|Object`
- Default: `false`
Write the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI.
The `filePath` is an absolute path or relative to the webpack config: `output.path`. You can pass in a different `formatter` for the output file, if none is passed in the default/configured formatter will be used.
## Development
1. Clone this repository
2. Install dependencies using `yarn install` or `npm install`
3. Start development server using `npm run dev`
## License
[MIT License](./LICENSE)
Copyright (c) Nuxt Community
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/eslint-module/latest.svg
[npm-version-href]: https://npmjs.com/package/@nuxtjs/eslint-module
[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/eslint-module.svg
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/eslint-module
[github-actions-ci-src]: https://github.com/nuxt-community/eslint-module/workflows/ci/badge.svg
[github-actions-ci-href]: https://github.com/nuxt-community/eslint-module/actions?query=workflow%3Aci
[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/eslint-module.svg
[codecov-href]: https://codecov.io/gh/nuxt-community/eslint-module
[license-src]: https://img.shields.io/npm/l/@nuxtjs/eslint-module.svg
[license-href]: https://npmjs.com/package/@nuxtjs/eslint-module
+3
View File
@@ -0,0 +1,3 @@
const consola = require('consola')
module.exports = consola.withScope('nuxt:eslint')
+45
View File
@@ -0,0 +1,45 @@
const { resolve } = require('path')
const logger = require('./logger')
const { moduleExists } = require('./utils')
module.exports = function (moduleOptions) {
if (!moduleExists('eslint')) {
logger.warn(
'The dependency `eslint` not found.',
'Please run `yarn add eslint --dev` or `npm install eslint --save-dev`'
)
return
}
const options = {
extensions: ['ts', 'js', 'vue'],
...this.options.eslint,
...moduleOptions
}
const filesToWatch = [
'.eslintrc',
'.eslintrc.json',
'.eslintrc.yaml',
'.eslintrc.yml',
'.eslintrc.js'
]
this.options.watch.push(
...filesToWatch.map(file => resolve(this.options.rootDir, file))
)
this.extendBuild((config, { isDev, isClient }) => {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: RegExp(`\\.(${options.extensions.join('|')})$`),
loader: 'eslint-loader',
exclude: /(node_modules)/,
options
})
}
})
}
module.exports.meta = require('../package.json')
+11
View File
@@ -0,0 +1,11 @@
const moduleExists = (name) => {
try {
return require.resolve(name)
} catch (e) /* istanbul ignore next */ {
return false
}
}
module.exports = {
moduleExists
}
+81
View File
@@ -0,0 +1,81 @@
{
"_args": [
[
"@nuxtjs/eslint-module@2.0.0",
"/home/node/nuxt"
]
],
"_development": true,
"_from": "@nuxtjs/eslint-module@2.0.0",
"_id": "@nuxtjs/eslint-module@2.0.0",
"_inBundle": false,
"_integrity": "sha512-uL3prMRwSBcxy583O11nMiUtfA2fxF7lZgCCUCsq4FNCqv320euJ7XE3KNZT6IVs/QJ1vaUNLC8tL4SZS99Tjw==",
"_location": "/@nuxtjs/eslint-module",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/eslint-module@2.0.0",
"name": "@nuxtjs/eslint-module",
"escapedName": "@nuxtjs%2feslint-module",
"scope": "@nuxtjs",
"rawSpec": "2.0.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
},
"_requiredBy": [
"#DEV:/"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/eslint-module/-/eslint-module-2.0.0.tgz",
"_spec": "2.0.0",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt-community/eslint-module/issues"
},
"contributors": [
{
"name": "Ricardo Gobbo de Souza",
"email": "ricardogobbosouza@yahoo.com.br"
}
],
"dependencies": {
"consola": "^2.11.3",
"eslint-loader": "^4.0.2"
},
"description": "ESLint module for Nuxt.js",
"devDependencies": {
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@nuxtjs/eslint-config": "latest",
"@nuxtjs/module-test-utils": "latest",
"eslint": "latest",
"husky": "latest",
"jest": "latest",
"nuxt-edge": "latest",
"standard-version": "latest"
},
"files": [
"lib"
],
"homepage": "https://github.com/nuxt-community/eslint-module#readme",
"license": "MIT",
"main": "lib/module.js",
"name": "@nuxtjs/eslint-module",
"peerDependencies": {
"eslint": ">=6"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt-community/eslint-module.git"
},
"scripts": {
"dev": "nuxt test/fixture",
"lint": "eslint --ext .js,.vue .",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
},
"version": "2.0.0"
}
+150
View File
@@ -0,0 +1,150 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [2.1.0](https://github.com/nuxt-community/proxy-module/compare/v2.0.1...v2.1.0) (2020-12-14)
### Features
* update module (typescript rewrite) ([c9dad3c](https://github.com/nuxt-community/proxy-module/commit/c9dad3c547759ca05413b6d85087e80e468297a5))
### [2.0.1](https://github.com/nuxt-community/proxy-module/compare/v2.0.0...v2.0.1) (2020-07-16)
### Bug Fixes
* skip module for nuxt build (fixes [#74](https://github.com/nuxt-community/proxy-module/issues/74)) ([50db85e](https://github.com/nuxt-community/proxy-module/commit/50db85eb5dd76dd20fe146b282cc082de721663f))
## [2.0.0](https://github.com/nuxt-community/proxy-module/compare/v1.3.3...v2.0.0) (2020-06-03)
### ⚠ BREAKING CHANGES
* Bumping major version as http-proxy-middleware may introduce some usage regressions
### Features
* bump to 2.x ([57eb492](https://github.com/nuxt-community/proxy-module/commit/57eb492c42cea6b6e90e4348065da308274fbc8a))
* upgrade to `http-proxy-middleware` 1.0.1 ([0277f6d](https://github.com/nuxt-community/proxy-module/commit/0277f6d0c753a73b2b4ab15223c1a5f9da0085ca))
### Bug Fixes
* **module:** use logger ([#40](https://github.com/nuxt-community/proxy-module/issues/40)) ([6bfbcad](https://github.com/nuxt-community/proxy-module/commit/6bfbcade52c364647c26084eb66a16ff6a7c7e11))
## [1.3.3](https://github.com/nuxt-community/proxy-module/compare/v1.3.2...v1.3.3) (2019-03-02)
### Bug Fixes
* **module:** generate warn if not SPA and increase coverage ([#31](https://github.com/nuxt-community/proxy-module/issues/31)) ([8baafc9](https://github.com/nuxt-community/proxy-module/commit/8baafc9))
## [1.3.2](https://github.com/nuxt-community/proxy-module/compare/v1.3.1...v1.3.2) (2019-02-18)
### Bug Fixes
* skip generate warn for now because of SPA ([7b23097](https://github.com/nuxt-community/proxy-module/commit/7b23097))
<a name="1.3.1"></a>
## [1.3.1](https://github.com/nuxt-community/proxy-module/compare/v1.3.0...v1.3.1) (2018-10-30)
### Bug Fixes
* add hint for "universal" mode only ([#10](https://github.com/nuxt-community/proxy-module/issues/10)) ([c78b122](https://github.com/nuxt-community/proxy-module/commit/c78b122))
<a name="1.3.0"></a>
# [1.3.0](https://github.com/nuxt-community/proxy-module/compare/v1.2.4...v1.3.0) (2018-10-29)
### Features
* upgrade dependencies ([331fa23](https://github.com/nuxt-community/proxy-module/commit/331fa23))
<a name="1.2.4"></a>
## [1.2.4](https://github.com/nuxt-community/proxy-module/compare/v1.2.3...v1.2.4) (2018-03-31)
<a name="1.2.3"></a>
## [1.2.3](https://github.com/nuxt-community/proxy-module/compare/v1.2.2...v1.2.3) (2018-03-31)
### Bug Fixes
* hide debug logs ([66c1905](https://github.com/nuxt-community/proxy-module/commit/66c1905))
<a name="1.2.2"></a>
## [1.2.2](https://github.com/nuxt-community/proxy-module/compare/v1.2.1...v1.2.2) (2018-03-31)
<a name="1.2.1"></a>
## [1.2.1](https://github.com/nuxt-community/proxy-module/compare/v1.2.0...v1.2.1) (2018-03-31)
<a name="1.2.0"></a>
# [1.2.0](https://github.com/nuxt-community/proxy-module/compare/v1.1.4...v1.2.0) (2018-03-31)
<a name="1.1.4"></a>
## 1.1.4 (2018-01-28)
<a name="1.1.3"></a>
## [1.1.3](https://github.com/nuxt/modules/compare/@nuxtjs/proxy@1.1.2...@nuxtjs/proxy@1.1.3) (2017-11-20)
**Note:** Version bump only for package @nuxtjs/proxy
<a name="1.1.2"></a>
## [1.1.2](https://github.com/nuxt/modules/compare/@nuxtjs/proxy@1.1.1...@nuxtjs/proxy@1.1.2) (2017-09-05)
### Bug Fixes
* **proxy:** disable prefix ([3e2e70f](https://github.com/nuxt/modules/commit/3e2e70f))
<a name="1.1.1"></a>
## [1.1.1](https://github.com/nuxt/modules/compare/@nuxtjs/proxy@1.1.0...@nuxtjs/proxy@1.1.1) (2017-06-09)
### Bug Fixes
* **plugin:** normalize array alternative form path ([811b5a9](https://github.com/nuxt/modules/commit/811b5a9))
<a name="1.1.0"></a>
# 1.1.0 (2017-06-07)
### Bug Fixes
* **proxy:** normalize target in object mode ([e9d4026](https://github.com/nuxt/modules/commit/e9d4026))
### Features
* proxy module ([6dfca4d](https://github.com/nuxt/modules/commit/6dfca4d))
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Nuxt Community
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Generated Vendored Executable
+126
View File
@@ -0,0 +1,126 @@
# @nuxtjs/proxy
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![codecov][codecov-src]][codecov-href]
[![license][license-src]][license-href]
> Proxy support for nuxt server
[📖 **Release Notes**](./CHANGELOG.md)
## Features
✓ Path rewrites
✓ Host based router (useful for staging/test)
✓ Logs / Proxy Events
✓ WebSockets
✓ Auth / Cookie
✓ ...See [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware) docs
⚠ Does not work in generated/static mode!
## Setup
1. Add `@nuxtjs/proxy` dependency to your project
```bash
yarn add @nuxtjs/proxy # or npm install @nuxtjs/proxy
```
2. Add `@nuxtjs/proxy` to the `modules` section of `nuxt.config.js`
```js
{
modules: [
// Simple usage
'@nuxtjs/proxy',
// With options
['@nuxtjs/proxy', { pathRewrite: { '^/api' : '/api/v1' } }]
]
}
```
- Define as many as proxy middleware you want in `proxy` section of `nuxt.config.js` (See [proxy](#proxy) section below)
## Options
- `changeOrigin` and `ws` options are enabled by default.
[optional] You can provide default options to all proxy targets by passing options to module options.
## `proxy`
You can provide proxy config using either object or array.
### Array Config
You can use [shorthand syntax](https://github.com/chimurai/http-proxy-middleware#shorthand) to configure proxy:
```js
{
proxy: [
// Proxies /foo to http://example.com/foo
'http://example.com/foo',
// Proxies /api/books/*/**.json to http://example.com:8000
'http://example.com:8000/api/books/*/**.json',
// You can also pass more options
[ 'http://example.com/foo', { ws: false } ]
]
}
```
### Object Config
Keys are [context](https://github.com/chimurai/http-proxy-middleware#context-matching)
```js
{
proxy: {
// Simple proxy
'/api': 'http://example.com',
// With options
'/api2': { target: 'http://example.com', ws: false },
// Proxy to backend unix socket
'/api3': {
changeOrigin: false,
target: { socketPath: '/var/run/http-sockets/backend.sock' }
}
}
}
```
## Development
1. Clone this repository
2. Install dependencies using `yarn install` or `npm install`
3. Start development server using `npm run dev`
## License
[MIT License](./LICENSE)
Copyright (c) Nuxt Community
<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/proxy/latest.svg?style=flat-square
[npm-version-href]: https://npmjs.com/package/@nuxtjs/proxy
[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/proxy.svg?style=flat-square
[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/proxy
[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/proxy-module.svg?style=flat-square
[codecov-href]: https://codecov.io/gh/nuxt-community/proxy-module
[license-src]: https://img.shields.io/npm/l/@nuxtjs/proxy.svg?style=flat-square
[license-href]: https://npmjs.com/package/@nuxtjs/proxy
+18
View File
@@ -0,0 +1,18 @@
import { Module } from '@nuxt/types';
import { Options, Filter } from 'http-proxy-middleware';
declare type ProxyContext = Filter | Options;
declare type ProxyOptionsObject = {
[target: string]: Options;
};
declare type ProxyOptionsArray = Array<[ProxyContext, Options?] | Options | string>;
declare type NuxtProxyOptions = ProxyOptionsObject | ProxyOptionsArray;
declare module '@nuxt/types' {
interface Configuration {
proxy?: NuxtProxyOptions;
}
}
declare const proxyModule: Module<Options>;
export default proxyModule;
+57
View File
@@ -0,0 +1,57 @@
'use strict';
const httpProxyMiddleware = require('http-proxy-middleware');
function getProxyEntries(proxyOptions, defaults) {
const applyDefaults = (opts) => ({...defaults, ...opts});
const normalizeTarget = (input) => typeof input === "object" ? input : {target: input};
const proxyEntries = [];
if (!proxyOptions) {
return proxyEntries;
}
if (!Array.isArray(proxyOptions)) {
for (const key in proxyOptions) {
proxyEntries.push({
context: key,
options: applyDefaults(normalizeTarget(proxyOptions[key]))
});
}
return proxyEntries;
}
for (const input of proxyOptions) {
if (Array.isArray(input)) {
proxyEntries.push({
context: input[0],
options: applyDefaults(normalizeTarget(input[1]))
});
} else {
proxyEntries.push({
context: input,
options: applyDefaults()
});
}
}
return proxyEntries;
}
const proxyModule = function(options2) {
const nuxt = this.nuxt;
if (!nuxt.options.server || !nuxt.options.proxy) {
return;
}
const defaults = {
changeOrigin: true,
ws: true,
...options2
};
const proxyEntries = getProxyEntries(nuxt.options.proxy, defaults);
for (const proxyEntry of proxyEntries) {
this.addServerMiddleware({
prefix: false,
handler: httpProxyMiddleware.createProxyMiddleware(proxyEntry.context, proxyEntry.options)
});
}
};
proxyModule.meta = require("../package.json");
module.exports = proxyModule;
+72
View File
@@ -0,0 +1,72 @@
{
"_args": [
[
"@nuxtjs/proxy@2.1.0",
"/home/node/nuxt"
]
],
"_from": "@nuxtjs/proxy@2.1.0",
"_id": "@nuxtjs/proxy@2.1.0",
"_inBundle": false,
"_integrity": "sha512-/qtoeqXgZ4Mg6LRg/gDUZQrFpOlOdHrol/vQYMnKu3aN3bP90UfOUB3QSDghUUK7OISAJ0xp8Ld78aHyCTcKCQ==",
"_location": "/@nuxtjs/proxy",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/proxy@2.1.0",
"name": "@nuxtjs/proxy",
"escapedName": "@nuxtjs%2fproxy",
"scope": "@nuxtjs",
"rawSpec": "2.1.0",
"saveSpec": null,
"fetchSpec": "2.1.0"
},
"_requiredBy": [
"/@nuxtjs/axios"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/proxy/-/proxy-2.1.0.tgz",
"_spec": "2.1.0",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt-community/proxy-module/issues"
},
"dependencies": {
"http-proxy-middleware": "^1.0.6"
},
"description": "proxy support for nuxt server",
"devDependencies": {
"@babel/preset-typescript": "^7.12.7",
"@nuxt/test-utils": "latest",
"@nuxt/types": "latest",
"@nuxtjs/eslint-config-typescript": "latest",
"eslint": "latest",
"jest": "latest",
"nuxt": "^2.14.11",
"siroc": "latest",
"standard-version": "latest"
},
"files": [
"dist"
],
"homepage": "https://github.com/nuxt-community/proxy-module#readme",
"license": "MIT",
"main": "dist/index.js",
"name": "@nuxtjs/proxy",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt-community/proxy-module.git"
},
"scripts": {
"build": "siroc build",
"dev": "nuxt test/fixture",
"lint": "eslint --ext .js,.vue,.ts .",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
},
"types": "dist/index.d.ts",
"version": "2.1.0"
}
+432
View File
@@ -0,0 +1,432 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [1.11.2](https://github.com/nuxt-community/vuetify-module/compare/v1.11.1...v1.11.2) (2020-04-26)
### [1.11.1](https://github.com/nuxt-community/vuetify-module/compare/v1.11.0...v1.11.1) (2020-04-26)
### Bug Fixes
* check if preset is in presetsCDN ([#291](https://github.com/nuxt-community/vuetify-module/issues/291)) ([57a0ceb](https://github.com/nuxt-community/vuetify-module/commit/57a0ceb74551c20ca9fccf53b5083ad805e500a8))
## [1.11.0](https://github.com/nuxt-community/vuetify-module/compare/v1.10.3...v1.11.0) (2020-02-17)
### Features
* allow for list of custom fonts ([#269](https://github.com/nuxt-community/vuetify-module/issues/269)) ([3644437](https://github.com/nuxt-community/vuetify-module/commit/3644437cb01630b43aaa1898bfa352469b8faa91))
### [1.10.3](https://github.com/nuxt-community/vuetify-module/compare/v1.10.2...v1.10.3) (2020-01-30)
### Bug Fixes
* fix VuetifyLoaderOptions match type ([#273](https://github.com/nuxt-community/vuetify-module/issues/273)) ([2923943](https://github.com/nuxt-community/vuetify-module/commit/2923943a05b3940b31277ab64234535eda4c3ceb))
* use minimal vuetify import ([#267](https://github.com/nuxt-community/vuetify-module/issues/267)) ([1dffcbb](https://github.com/nuxt-community/vuetify-module/commit/1dffcbbd4fcce8bae3f9b03d6b83cf0434588790))
### [1.10.2](https://github.com/nuxt-community/vuetify-module/compare/v1.10.1...v1.10.2) (2020-01-17)
### [1.10.1](https://github.com/nuxt-community/vuetify-module/compare/v1.10.0...v1.10.1) (2020-01-15)
### Bug Fixes
* update devDependencies & fix code ([7f37ef6](https://github.com/nuxt-community/vuetify-module/commit/7f37ef64f9fc7d23fcb3a84a9ba7cfe963f3f3ca)), closes [#251](https://github.com/nuxt-community/vuetify-module/issues/251)
## [1.10.0](https://github.com/nuxt-community/vuetify-module/compare/v1.9.1...v1.10.0) (2020-01-13)
### Features
* add preset support ([#247](https://github.com/nuxt-community/vuetify-module/issues/247)) ([25d9813](https://github.com/nuxt-community/vuetify-module/commit/25d98137ded1296d1ddab9a7c4854102021bce66))
### Bug Fixes
* **deps:** bump vuetify version to latest and fix type path ([#237](https://github.com/nuxt-community/vuetify-module/issues/237)) ([b30f5db](https://github.com/nuxt-community/vuetify-module/commit/b30f5db447e74fed1871d59584eb98bbc15dceb6))
### [1.9.1](https://github.com/nuxt-community/vuetify-module/compare/v1.9.0...v1.9.1) (2019-12-05)
## [1.9.0](https://github.com/nuxt-community/vuetify-module/compare/v1.8.6...v1.9.0) (2019-10-02)
### Notes
* **Vuetify** has been bumped to **2.1 (Vanguard)**, check their [**Release notes**](https://togithub.com/vuetifyjs/vuetify/releases/v2.1.0) ! We highly recommend you to check the new [Skeleton Loader](https://vuetifyjs.com/en/components/skeleton-loaders) component 🤩
* **`dart-sass`** has been bumped to **1.23.0**, check their [**Release notes**](https://github.com/sass/dart-sass/releases/1.23.0) ! It includes the new launch of the new **Sass** module system 🤩
### [1.8.6](https://github.com/nuxt-community/vuetify-module/compare/v1.8.5...v1.8.6) (2019-09-28)
### Bug Fixes
* also prepend customVariables in scss files ([75823af](https://github.com/nuxt-community/vuetify-module/commit/75823af))
### [1.8.5](https://github.com/nuxt-community/vuetify-module/compare/v1.8.4...v1.8.5) (2019-09-17)
### [1.8.4](https://github.com/nuxt-community/vuetify-module/compare/v1.8.3...v1.8.4) (2019-09-16)
### [1.8.3](https://github.com/nuxt-community/vuetify-module/compare/v1.8.2...v1.8.3) (2019-09-10)
### Bug Fixes
* fix treeshake types for manual imports ([0b8e274](https://github.com/nuxt-community/vuetify-module/commit/0b8e274)), closes [#160](https://github.com/nuxt-community/vuetify-module/issues/160)
### [1.8.2](https://github.com/nuxt-community/vuetify-module/compare/v1.8.1...v1.8.2) (2019-09-09)
### [1.8.1](https://github.com/nuxt-community/vuetify-module/compare/v1.8.0...v1.8.1) (2019-09-09)
### Bug Fixes
* properly use indentedSyntax for sass files ([d8b7b5a](https://github.com/nuxt-community/vuetify-module/commit/d8b7b5a)), closes [#159](https://github.com/nuxt-community/vuetify-module/issues/159)
## [1.8.0](https://github.com/nuxt-community/vuetify-module/compare/v1.7.3...v1.8.0) (2019-09-08)
### Features
* seamless automatic fonts ([#157](https://github.com/nuxt-community/vuetify-module/issues/157)) ([334a343](https://github.com/nuxt-community/vuetify-module/commit/334a343))
### [1.7.3](https://github.com/nuxt-community/vuetify-module/compare/v1.7.2...v1.7.3) (2019-09-08)
### [1.7.2](https://github.com/nuxt-community/vuetify-module/compare/v1.7.1...v1.7.2) (2019-09-08)
### [1.7.1](https://github.com/nuxt-community/vuetify-module/compare/v1.7.0...v1.7.1) (2019-09-08)
### Bug Fixes
* fix templates location and publish them ([0b930e2](https://github.com/nuxt-community/vuetify-module/commit/0b930e2))
## [1.7.0](https://github.com/nuxt-community/vuetify-module/compare/v1.6.3...v1.7.0) (2019-09-08)
### [1.6.3](https://github.com/nuxt-community/vuetify-module/compare/v1.6.2...v1.6.3) (2019-09-05)
### [1.6.2](https://github.com/nuxt-community/vuetify-module/compare/v1.6.1...v1.6.2) (2019-09-03)
### Bug Fixes
* **types:** vuetify@2.0.12 types update ([#146](https://github.com/nuxt-community/vuetify-module/issues/146)) ([89c59a4](https://github.com/nuxt-community/vuetify-module/commit/89c59a4))
### [1.6.1](https://github.com/nuxt-community/vuetify-module/compare/v1.6.0...v1.6.1) (2019-08-30)
### Bug Fixes
* fix indentedSyntax issue around scss files ([9aaad72](https://github.com/nuxt-community/vuetify-module/commit/9aaad72))
## [1.6.0](https://github.com/nuxt-community/vuetify-module/compare/v1.5.0...v1.6.0) (2019-08-29)
### Notable changes
* update dependency sass-loader to v8 ([#139](https://github.com/nuxt-community/vuetify-module/pull/139)) ([08bff6a](https://github.com/nuxt-community/vuetify-module/commit/08bff6a))
### Bug Fixes
* remove duplicate import of main.sass ([259e0ee](https://github.com/nuxt-community/vuetify-module/commit/259e0ee))
## [1.5.0](https://github.com/nuxt-community/vuetify-module/compare/v1.4.0...v1.5.0) (2019-08-27)
### Bug Fixes
* fix missing comma for manual imports ([#132](https://github.com/nuxt-community/vuetify-module/issues/132)) ([069566b](https://github.com/nuxt-community/vuetify-module/commit/069566b)), closes [#130](https://github.com/nuxt-community/vuetify-module/issues/130) [/github.com/nuxt-community/vuetify-module/pull/132#discussion_r318289697](https://github.com/nuxt-community//github.com/nuxt-community/vuetify-module/pull/132/issues/discussion_r318289697)
### Features
* vuetify-loader options ([#134](https://github.com/nuxt-community/vuetify-module/issues/134)) ([22e82c5](https://github.com/nuxt-community/vuetify-module/commit/22e82c5))
## [1.4.0](https://github.com/nuxt-community/vuetify-module/compare/v1.3.3...v1.4.0) (2019-08-24)
### Features
* manual import of components ([#125](https://github.com/nuxt-community/vuetify-module/issues/125)) ([71c63f5](https://github.com/nuxt-community/vuetify-module/commit/71c63f5)), closes [#110](https://github.com/nuxt-community/vuetify-module/issues/110)
### [1.3.3](https://github.com/nuxt-community/vuetify-module/compare/v1.3.2...v1.3.3) (2019-08-23)
### [1.3.2](https://github.com/nuxt-community/vuetify-module/compare/v1.3.1...v1.3.2) (2019-08-21)
### [1.3.1](https://github.com/nuxt-community/vuetify-module/compare/v1.3.0...v1.3.1) (2019-08-20)
## [1.3.0](https://github.com/nuxt-community/vuetify-module/compare/v1.2.1...v1.3.0) (2019-08-20)
### Features
* **types:** provide nuxt 2.9 compatible types ([#119](https://github.com/nuxt-community/vuetify-module/issues/119)) ([1587e0f](https://github.com/nuxt-community/vuetify-module/commit/1587e0f))
### [1.2.2](https://github.com/nuxt-community/vuetify-module/compare/v1.2.1...v1.2.2) (2019-08-15)
### [1.2.1](https://github.com/nuxt-community/vuetify-module/compare/v1.2.0...v1.2.1) (2019-08-06)
## [1.2.0](https://github.com/nuxt-community/vuetify-module/compare/v1.1.2...v1.2.0) (2019-08-05)
### Features
* optionsPath + function behavior ([#99](https://github.com/nuxt-community/vuetify-module/issues/99)) ([96177a4](https://github.com/nuxt-community/vuetify-module/commit/96177a4))
### [1.1.2](https://github.com/nuxt-community/vuetify-module/compare/v1.1.1...v1.1.2) (2019-08-05)
### Bug Fixes
* fix vuetify transpilation ([#98](https://github.com/nuxt-community/vuetify-module/issues/98)) ([8075afb](https://github.com/nuxt-community/vuetify-module/commit/8075afb))
### [1.1.1](https://github.com/nuxt-community/vuetify-module/compare/v1.1.0...v1.1.1) (2019-08-01)
## [1.1.0](https://github.com/nuxt-community/vuetify-module/compare/v1.0.2...v1.1.0) (2019-07-30)
### Features
* defaultAssets.icons all icons providers support ([#85](https://github.com/nuxt-community/vuetify-module/issues/85)) ([d285b3b](https://github.com/nuxt-community/vuetify-module/commit/d285b3b))
* vuetifyOptions through options file ([#86](https://github.com/nuxt-community/vuetify-module/issues/86)) ([78495a3](https://github.com/nuxt-community/vuetify-module/commit/78495a3))
### [1.0.2](https://github.com/nuxt-community/vuetify-module/compare/v1.0.1...v1.0.2) (2019-07-29)
### [1.0.1](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0...v1.0.1) (2019-07-25)
## [1.0.0](https://github.com/nuxt-community/vuetify-module/compare/v0.5.7...v1.0.0) (2019-07-23)
### Features
- Upgrade to [Vuetify 2](https://github.com/vuetifyjs/vuetify/releases/tag/v2.0.0)
- Implements `ctx.$vuetify`
- Custom SASS variables
- TypeScript typings
### BREAKING CHANGES
Nuxt Module for Vuetify 2 brings lot of breaking changes
Overall you'll need to follow [Vuetify 2 Upgrade guide](https://github.com/vuetifyjs/vuetify/releases/tag/v2.0.0#user-content-upgrade-guide) to correctly update your layouts, pages & components that were related to Vuetify in your project.
Around the Nuxt module itself, it still passes options to Vuetify, but the custom options that change the behavior of what does the module for you have changed, you can find the new options in the **README** file.
## [1.0.0-beta.8](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2019-07-22)
## [1.0.0-beta.7](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2019-07-18)
## [1.0.0-beta.6](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2019-07-11)
## [1.0.0-beta.5](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2019-07-03)
## [1.0.0-beta.4](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2019-06-26)
## [1.0.0-beta.3](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2019-06-19)
## [1.0.0-beta.2](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2019-06-11)
## [1.0.0-beta.1](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-beta.0...v1.0.0-beta.1) (2019-06-06)
## [1.0.0-beta.0](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-alpha.6...v1.0.0-beta.0) (2019-06-04)
### Bug Fixes
* apply vuetify vars only for sass files ([#25](https://github.com/nuxt-community/vuetify-module/issues/25)) ([f8f0392](https://github.com/nuxt-community/vuetify-module/commit/f8f0392))
* don't override sassLoader data ([3c1c1e6](https://github.com/nuxt-community/vuetify-module/commit/3c1c1e6))
* fix tooltip activator behavior ([feeacd8](https://github.com/nuxt-community/vuetify-module/commit/feeacd8))
* use theme primary color for toolbar ([3bc02cc](https://github.com/nuxt-community/vuetify-module/commit/3bc02cc))
### Features
* customVariables ([d2b3b8a](https://github.com/nuxt-community/vuetify-module/commit/d2b3b8a))
* roboto font display swap ([feac192](https://github.com/nuxt-community/vuetify-module/commit/feac192))
# [1.0.0-alpha.6](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2019-05-18)
# [1.0.0-alpha.5](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2019-05-02)
# [1.0.0-alpha.4](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2019-04-18)
### Bug Fixes
* always setup sass loader options ([1709f2b](https://github.com/nuxt-community/vuetify-module/commit/1709f2b))
# [1.0.0-alpha.3](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2019-04-18)
### Bug Fixes
* hotfix when module options is not set in config ([4cfa0ab](https://github.com/nuxt-community/vuetify-module/commit/4cfa0ab))
# [1.0.0-alpha.2](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2019-04-18)
# [1.0.0-alpha.1](https://github.com/nuxt-community/vuetify-module/compare/v1.0.0-alpha.0...v1.0.0-alpha.1) (2019-04-17)
# [1.0.0-alpha.0](https://github.com/nuxt-community/vuetify-module/compare/v0.5.5...v1.0.0-alpha.0) (2019-04-10)
### Features
* upgrade to new vuetify 2 spec ([6ff1910](https://github.com/nuxt-community/vuetify-module/commit/6ff1910))
### BREAKING CHANGES
* Removed `css`, implemented `assets` option
### [0.5.7](https://github.com/nuxt-community/vuetify-module/compare/v0.5.6...v0.5.7) (2019-07-22)
### [0.5.6](https://github.com/nuxt-community/vuetify-module/compare/v0.5.5...v0.5.6) (2019-06-04)
<a name="0.5.5"></a>
## [0.5.5](https://github.com/nuxt-community/vuetify-module/compare/v0.5.4...v0.5.5) (2019-02-14)
<a name="0.0.1"></a>
## 0.0.1 (2019-02-08)
### Bug Fixes
* **readme:** Typo ([5496ade](https://github.com/nuxt-community/vuetify-module/commit/5496ade))
* run module in build:before hook ([4676a34](https://github.com/nuxt-community/vuetify-module/commit/4676a34)), closes [#1](https://github.com/nuxt-community/vuetify-module/issues/1)
<a name="0.5.0"></a>
# [0.5.0](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.4.3...@nuxtjs/vuetify@0.5.0) (2018-12-19)
### Bug Fixes
* **deps:** update all non-major dependencies ([#231](https://github.com/nuxt/modules/issues/231)) ([345418b](https://github.com/nuxt/modules/commit/345418b))
### Features
* **vuetify:** add tree-shaking option ([#242](https://github.com/nuxt/modules/issues/242)) ([3e25477](https://github.com/nuxt/modules/commit/3e25477))
<a name="0.4.3"></a>
## [0.4.3](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.4.2...@nuxtjs/vuetify@0.4.3) (2018-10-01)
**Note:** Version bump only for package @nuxtjs/vuetify
<a name="0.4.2"></a>
## [0.4.2](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.4.1...@nuxtjs/vuetify@0.4.2) (2018-04-27)
**Note:** Version bump only for package @nuxtjs/vuetify
<a name="0.4.1"></a>
## [0.4.1](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.4.0...@nuxtjs/vuetify@0.4.1) (2018-03-05)
**Note:** Version bump only for package @nuxtjs/vuetify
<a name="0.4.0"></a>
# [0.4.0](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.3.1...@nuxtjs/vuetify@0.4.0) (2017-12-07)
### Features
* **vuetify:** bump vuetify version to 1.0.0-alpha ([#175](https://github.com/nuxt/modules/issues/175)) ([f2b948a](https://github.com/nuxt/modules/commit/f2b948a))
<a name="0.3.1"></a>
## [0.3.1](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.3.0...@nuxtjs/vuetify@0.3.1) (2017-11-24)
**Note:** Version bump only for package @nuxtjs/vuetify
<a name="0.3.0"></a>
# [0.3.0](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.2.0...@nuxtjs/vuetify@0.3.0) (2017-11-24)
### Features
* **vuetify:** allow passing options to vuetify plugin ([f0826f1](https://github.com/nuxt/modules/commit/f0826f1))
<a name="0.2.0"></a>
# [0.2.0](https://github.com/nuxt/modules/compare/@nuxtjs/vuetify@0.1.1...@nuxtjs/vuetify@0.2.0) (2017-11-20)
### Features
* upgrade dependencies ([52f3572](https://github.com/nuxt/modules/commit/52f3572))
<a name="0.1.1"></a>
## 0.1.1 (2017-10-05)
<a name="1.0.1"></a>
## 1.0.1 (2017-06-07)
+23
View File
@@ -0,0 +1,23 @@
MIT License
Copyright (c) Nuxt Community
- Pooya Parsa ([@pi0](https://github.com/pi0))
- Kevin Marrec ([@kevinmarrec](https://github.com/kevinmarrec))
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Generated Vendored Executable
+240
View File
@@ -0,0 +1,240 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/904724/59509947-c14eca80-8eb2-11e9-807c-14e7cc72eecc.png" alt="nuxt-tailwindcss" width="500"/>
</p>
<p align="center">
<a href="https://npmjs.com/package/@nuxtjs/vuetify"><img src="https://img.shields.io/npm/v/@nuxtjs/vuetify.svg?style=flat-square" alt="npm downloads"></a>
<a href="https://npmjs.com/package/@nuxtjs/vuetify"><img src="https://img.shields.io/npm/dt/@nuxtjs/vuetify.svg?style=flat-square" alt="npm version"></a>
<a href="https://circleci.com/gh/nuxt-community/vuetify-module"><img src="https://img.shields.io/circleci/project/github/nuxt-community/vuetify-module.svg?style=flat-square" alt="circle ci"></a>
<a href="https://codecov.io/gh/nuxt-community/vuetify-module"><img src="https://img.shields.io/codecov/c/github/nuxt-community/vuetify-module.svg?style=flat-square" alt="coverage"></a>
<a href="https://www.npmjs.com/package/@nuxtjs/vuetify"><img src="https://img.shields.io/npm/l/@nuxtjs/vuetify.svg?style=flat-square" alt="License"></a>
</p>
> [Vuetify 2](https://vuetifyjs.com) module for [Nuxt.js](https://nuxtjs.org)
## Infos
- [📖 **Release Notes**](./CHANGELOG.md)
- [🏀 **Online playground**](https://codesandbox.io/s/nuxtjs-vuetify-v0k7i)
- [🛠 **Migration guide from Vuetify 1.5.x**](./MIGRATION_GUIDE.md)
- [🏷 **Module for Vuetify 1.5.x**](https://github.com/nuxt-community/vuetify-module/tree/0.x)
## Setup
1. Add `@nuxtjs/vuetify` dependency to your project
```bash
yarn add --dev @nuxtjs/vuetify # or npm install --save-dev @nuxtjs/vuetify
```
2. Add `@nuxtjs/vuetify` to the `buildModules` section of `nuxt.config.js`
:warning: If you are using Nuxt `< 2.9.0`, use `modules` instead.
```js
{
buildModules: [
// Simple usage
'@nuxtjs/vuetify',
// With options
['@nuxtjs/vuetify', { /* module options */ }]
]
}
```
### Using top level options
```js
{
buildModules: [
'@nuxtjs/vuetify'
],
vuetify: {
/* module options */
}
}
```
## Options
### `customVariables`
- Type: `Array`
- Items: `String`
- Default: `[]`
Provide a way to customize Vuetify SASS variables.
**Only works with [tree-shaking](#treeShake).**
Usage example :
```scss
// assets/variables.scss
// Variables you want to modify
$btn-border-radius: 0px;
// If you need to extend Vuetify SASS lists
$material-light: ( cards: blue );
@import '~vuetify/src/styles/styles.sass';
```
```js
// nuxt.config.js
export default {
vuetify: {
customVariables: ['~/assets/variables.scss']
}
}
```
> The list of customizable variables can be found by looking at the files [here](https://github.com/vuetifyjs/vuetify/tree/master/packages/vuetify/src/styles/settings).
### `defaultAssets`
- Type: `Object` or `Boolean`
- Default:
```js
{
font: {
family: 'Roboto'
},
icons: 'mdi'
}
```
By default, automatically handle **Roboto** font & **Material Design Icons**.
These assets are handled automatically by default to provide a zero-configuration which let you play directly with Vuetify.
`defaultAssets.font.family` automatically adds the specified font (default **Roboto**) stylesheet from official google fonts to load the font with `font-display: swap`.
If you have [nuxt-webfontloader](https://github.com/Developmint/nuxt-webfontloader) in your `modules`, it will use it automatically.
`defaultAssets.font.size` allows you to specify the root font size in your application.
:warning: If you choose a custom font family (i.e. not **Roboto**), it will automatically override Vuetify SASS variables (`$body-font-family` & `font-size-root`), but you will need [tree-shaking](#treeShake) to be enabled to have them correctly applied.
`defaultAssets.icons` automatically adds the icons stylesheet from a CDN to load all the icons (**not optimized for production**).
Here are the accepted values for this option :
| Value | Icons |
|-------|-------|
| `'mdi'` (default) | [Material Designs Icons](https://materialdesignicons.com/) ([CDN](https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css))
| `'md'` | [Material Icons](https://material.io/resources/icons/) ([CDN](https://fonts.googleapis.com/css?family=Material+Icons))
| `'fa'` | [Font Awesome 5](https://fontawesome.com/icons) ([CDN](https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css))
| `'fa4'` | [Font Awesome 4](https://fontawesome.com/v4.7.0/icons/) ([CDN](https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css))
| `false` | Disable auto add of the icons stylesheet
> This option (if not set to `false`) will automatically override `icons.iconfont` Vuetify option so that Vuetify components use these icons.
Please refer to [Vuetify Icons documentation](https://vuetifyjs.com/en/customization/icons) for more information about icons, notably for using only bunch of SVG icons instead of including all icons in your app.
You can also set the whole `defaultAssets` option to `false` to prevent any automatic add of these two assets.
You can read more about adding your own assets in the [Offline applications](https://github.com/nuxt-community/vuetify-module#offline-applications) section.
### `optionsPath`
- Type: `String`
Location of the Vuetify options that will be passed to Vuetify.
This file will be compiled by **webpack**, which means you'll benefit fast hot reload when changing these options, but also be able to use TypeScript without being forced to use TypeScript runtime.
```js
// nuxt.config.js
export default {
vuetify: {
optionsPath: './vuetify.options.js'
}
}
```
> Note that you can also use [Directory Aliases](https://nuxtjs.org/guide/directory-structure#aliases) like `'~/path/to/option.js'`
All vuetify options are supported, it includes :
- [**Breakpoints**](https://vuetifyjs.com/en/customization/breakpoints)
- [**Icons**](https://vuetifyjs.com/en/customization/icons)
- [**Internationalization (i18n)**](https://vuetifyjs.com/en/customization/internationalization)
- [**RTL (bidirectionality)**](https://vuetifyjs.com/en/customization/rtl)
- [**Theme**](https://vuetifyjs.com/en/customization/theme)
```js
// vuetify.options.js
export default {
breakpoint: {},
icons: {},
lang: {},
rtl: true,
theme: {}
}
```
> Notice that passing the Vuetify options directly to Module options is still supported, but it will trigger Nuxt entire rebuild if options are changed.
If you need to access Nuxt context within the options file, you need to export a function instead :
```js
// vuetify.options.js
export default function ({ app }) {
return {
lang: {
t: (key, ...params) => app.i18n.t(key, params)
}
}
}
```
### `treeShake`
- Type: `Boolean`
- Default: `process.env.NODE_ENV === 'production'`
Uses [vuetify-loader](https://github.com/vuetifyjs/vuetify-loader) to enable automatic [tree-shaking](https://vuetifyjs.com/en/customization/a-la-carte).
Enabled only for production by default.
## TypeScript
If you're using TypeScript, you'll need to add `@nuxtjs/vuetify` in your `compilerOptions` of your `tsconfig.json` :
```json
{
"compilerOptions": {
"types": [
"@types/node",
"@nuxt/vue-app",
"@nuxtjs/vuetify"
]
}
}
```
You'll then be able to have autocompletion in Context (`ctx.$vuetify`) and Vue instances (`this.$vuetify`).
## Offline applications
If you're building an application that will need to work offline (more likely a [**PWA**](https://pwa.nuxtjs.org/)), you will need to bundle your fonts and icons in your app instead of using online resources.
It means you must set [`defaultAssets`](#defaultAssets) option to `false`.
For fonts, you may leverage CSS [**@font-face**](https://www.w3schools.com/cssref/css3_pr_font-face_rule.asp) rule with local path of your fonts. You may find the [google webfonts helper](https://google-webfonts-helper.herokuapp.com/fonts/roboto?subsets=latin) site useful for generating **@font-face** rules and sourcing replacement files for the default CDNs.
For icons, you can either use the same way than above, or leverage tree-shaken SVG libraries like [**Material Design Icons SVG**](https://github.com/Templarian/MaterialDesign-JS) or [**Font Awesome 5 SVG**](https://fontawesome.com/how-to-use/on-the-web/advanced/svg-javascript-core).
## Migration Guide from Vuetify 1.5.x
You'll find a step by step guide to upgrade from 1.5.x to 2.x [here](./MIGRATION_GUIDE.md)
## Development
- Clone this repository
- Install dependencies using `yarn install` or `npm install`
- Start development server using `yarn dev` or `npm run dev`
## License
[MIT License](./LICENSE)
Copyright (c) Nuxt Community
+3
View File
@@ -0,0 +1,3 @@
import { ModuleThis } from '@nuxt/types/config/module';
import { Options } from './options';
export default function setupBuild(this: ModuleThis, options: Options): void;
+42
View File
@@ -0,0 +1,42 @@
import path from 'path';
import fs from 'fs';
export default function setupBuild(options) {
if (!options.treeShake) {
this.options.css.push('vuetify/dist/vuetify.css');
}
// Enable tree-shaking with VuetifyLoader (https://github.com/vuetifyjs/vuetify-loader)
if (options.treeShake) {
const VuetifyLoaderPlugin = this.nuxt.resolver.requireModule('vuetify-loader/lib/plugin');
this.options.build.transpile.push('vuetify/lib');
this.extendBuild((config) => {
config.plugins.push(new VuetifyLoaderPlugin(typeof options.treeShake === 'object' ? options.treeShake.loaderOptions : {}));
});
}
// Remove module options
const vuetifyOptions = { ...options };
delete vuetifyOptions.customVariables;
delete vuetifyOptions.defaultAssets;
delete vuetifyOptions.optionsPath;
delete vuetifyOptions.preset;
delete vuetifyOptions.treeShake;
let optionsPath = this.nuxt.resolver.resolveAlias(options.optionsPath ||
path.join(this.options.dir.app || 'app', 'vuetify', 'options.js'));
optionsPath = fs.existsSync(optionsPath) ? optionsPath : null;
// Register options template
this.addTemplate({
fileName: `vuetify/options.${optionsPath && optionsPath.endsWith('ts') ? 'ts' : 'js'}`,
src: optionsPath || path.resolve(__dirname, '../templates', 'options.js'),
options: vuetifyOptions
});
// Register plugin
this.addPlugin({
fileName: 'vuetify/plugin.js',
src: path.resolve(__dirname, '../templates', 'plugin.js'),
options: {
defaultIconPreset: options.defaultAssets && options.defaultAssets.icons,
preset: options.preset,
treeShake: options.treeShake
}
});
}
//# sourceMappingURL=build.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AAInB,MAAM,CAAC,OAAO,UAAU,UAAU,CAAoB,OAAgB;IACpE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;QACtB,IAAI,CAAC,OAAO,CAAC,GAAI,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;KACnD;IAED,uFAAuF;IACvF,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAExF;QAAC,IAAI,CAAC,OAAO,CAAC,KAAM,CAAC,SAAuB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAEjE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1B,MAAM,CAAC,OAAQ,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QAC7H,CAAC,CAAC,CAAA;KACH;IAED,wBAAwB;IACxB,MAAM,cAAc,GAAG,EAAE,GAAG,OAAO,EAAE,CAAA;IACrC,OAAO,cAAc,CAAC,eAAe,CAAA;IACrC,OAAO,cAAc,CAAC,aAAa,CAAA;IACnC,OAAO,cAAc,CAAC,WAAW,CAAA;IACjC,OAAO,cAAc,CAAC,MAAM,CAAA;IAC5B,OAAO,cAAc,CAAC,SAAS,CAAA;IAE/B,IAAI,WAAW,GAAkB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW;QAChF,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAI,CAAC,GAAG,IAAI,KAAK,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAA;IAEvE,WAAW,GAAG,EAAE,CAAC,UAAU,CAAC,WAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAA;IAE9D,4BAA4B;IAC5B,IAAI,CAAC,WAAW,CAAC;QACf,QAAQ,EAAE,mBAAmB,WAAW,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;QACtF,GAAG,EAAE,WAAW,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,EAAE,YAAY,CAAC;QACzE,OAAO,EAAE,cAAc;KACxB,CAAC,CAAA;IAEF,kBAAkB;IAClB,IAAI,CAAC,SAAS,CAAC;QACb,QAAQ,EAAE,mBAAmB;QAC7B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,EAAE,WAAW,CAAC;QACzD,OAAO,EAAE;YACP,iBAAiB,EAAE,OAAO,CAAC,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,KAAK;YACvE,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B;KACF,CAAC,CAAA;AACJ,CAAC"}
+6
View File
@@ -0,0 +1,6 @@
import { ModuleThis } from '@nuxt/types/config/module';
export interface FontOptions {
family?: string | string[];
size?: number;
}
export default function setupFont(this: ModuleThis, options: FontOptions): void;
+28
View File
@@ -0,0 +1,28 @@
export default function setupFont(options) {
const family = `${options.family}:100,300,400,500,700,900&display=swap`;
if (this.options.modules.some(mod => mod === 'nuxt-webfontloader')) {
this.options.webfontloader = this.options.webfontloader || {};
this.options.webfontloader.google = this.options.webfontloader.google || {};
this.options.webfontloader.google.families = [...this.options.webfontloader.google.families || [], family];
}
else {
this.options.head.link.push({
rel: 'stylesheet',
type: 'text/css',
href: `https://fonts.googleapis.com/css?family=${family}`
});
}
const sass = this.options.build.loaders.sass;
// Add font-family custom variable (only if not Roboto, cause already default in Vuetify styles)
if (options.family !== 'Roboto') {
const userFontFamily = Array.isArray(options.family)
? options.family.map(x => `'${x}'`).join(', ')
: `'${options.family}'`;
sass.prependData = [`$body-font-family: ${userFontFamily}, sans-serif`, sass.prependData].join('\n');
}
// Add font-size custom variable
if (options.size) {
sass.prependData = [`$font-size-root: ${options.size}px`, sass.prependData].join('\n');
}
}
//# sourceMappingURL=font.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"font.js","sourceRoot":"","sources":["../src/font.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAoB,OAAoB;IACvE,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,uCAAuC,CAAA;IAEvE,IAAI,IAAI,CAAC,OAAO,CAAC,OAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,oBAAoB,CAAC,EAAE;QACnE,IAAI,CAAC,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAA;QAC7D,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,IAAI,EAAE,CAAA;QAC3E,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;KAC3G;SAAM;QACL,IAAI,CAAC,OAAO,CAAC,IAAK,CAAC,IAAK,CAAC,IAAI,CAAC;YAC5B,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,2CAA2C,MAAM,EAAE;SAC1D,CAAC,CAAA;KACH;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAM,CAAC,OAAQ,CAAC,IAAK,CAAA;IAE/C,gGAAgG;IAChG,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE;QAC/B,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YAClD,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9C,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAA;QACzB,IAAI,CAAC,WAAW,GAAG,CAAC,sBAAsB,cAAc,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACrG;IAED,gCAAgC;IAChC,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,IAAI,CAAC,WAAW,GAAG,CAAC,oBAAoB,OAAO,CAAC,IAAI,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACvF;AACH,CAAC"}
+10
View File
@@ -0,0 +1,10 @@
import { ModuleThis } from '@nuxt/types/config/module';
declare const presetsCDN: {
mdi: string;
md: string;
fa: string;
fa4: string;
};
export declare type IconPreset = keyof typeof presetsCDN;
export default function setupIcons(this: ModuleThis, preset: IconPreset): void;
export {};
+17
View File
@@ -0,0 +1,17 @@
const presetsCDN = {
mdi: 'https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css',
md: 'https://fonts.googleapis.com/css?family=Material+Icons',
fa: 'https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css',
fa4: 'https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css'
};
export default function setupIcons(preset) {
// istanbul ignore else
if (presetsCDN[preset]) {
this.options.head.link.push({
rel: 'stylesheet',
type: 'text/css',
href: presetsCDN[preset]
});
}
}
//# sourceMappingURL=icons.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG;IACjB,GAAG,EAAE,+EAA+E;IACpF,EAAE,EAAE,wDAAwD;IAC5D,EAAE,EAAE,mFAAmF;IACvF,GAAG,EAAE,0EAA0E;CAChF,CAAA;AAID,MAAM,CAAC,OAAO,UAAU,UAAU,CAAoB,MAAkB;IACtE,uBAAuB;IACvB,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE;QACtB,IAAI,CAAC,OAAO,CAAC,IAAK,CAAC,IAAK,CAAC,IAAI,CAAC;YAC5B,GAAG,EAAE,YAAY;YACjB,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;SACzB,CAAC,CAAA;KACH;AACH,CAAC"}
+14
View File
@@ -0,0 +1,14 @@
import { Module } from '@nuxt/types';
import { Framework } from 'vuetify';
import { Options, TreeShakeOptions, VuetifyLoaderOptions } from './options';
declare module '@nuxt/types' {
interface Configuration {
vuetify?: Options;
}
interface Context {
$vuetify: Framework;
}
}
declare const vuetifyModule: Module<Options>;
export { Options, TreeShakeOptions, VuetifyLoaderOptions };
export default vuetifyModule;
+18
View File
@@ -0,0 +1,18 @@
import initOptions from './options';
import setupBuild from './build';
import setupFont from './font';
import setupIcons from './icons';
import setupSass from './sass';
const vuetifyModule = function (moduleOptions) {
this.nuxt.hook('build:before', () => {
const options = initOptions.call(this, moduleOptions);
if (typeof options.defaultAssets === 'object') {
options.defaultAssets.font && setupFont.call(this, options.defaultAssets.font);
options.defaultAssets.icons && setupIcons.call(this, options.defaultAssets.icons);
}
setupSass.call(this, options.customVariables);
setupBuild.call(this, options);
});
};
export default vuetifyModule;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,WAAgE,MAAM,WAAW,CAAA;AACxF,OAAO,UAAU,MAAM,SAAS,CAAA;AAChC,OAAO,SAAS,MAAM,QAAQ,CAAA;AAC9B,OAAO,UAAU,MAAM,SAAS,CAAA;AAChC,OAAO,SAAS,MAAM,QAAQ,CAAA;AAY9B,MAAM,aAAa,GAAoB,UAAU,aAAa;IAC5D,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;QAClC,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;QAErD,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,EAAE;YAC7C,OAAO,CAAC,aAAa,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;YAC9E,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;SAClF;QAED,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;QAC7C,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAQD,eAAe,aAAa,CAAA"}
+41
View File
@@ -0,0 +1,41 @@
import { SFCDescriptor } from 'vue-template-compiler';
import { VuetifyPreset } from 'vuetify/types/services/presets';
import { ModuleThis } from '@nuxt/types/config/module';
import { FontOptions } from './font';
import { IconPreset } from './icons';
export interface TreeShakeOptions {
components?: string[];
directives?: string[];
loaderOptions?: VuetifyLoaderOptions;
transitions?: string[];
}
export interface VuetifyLoaderOptions {
match?(originalTag: string, context: {
kebabTag: string;
camelTag: string;
path: string;
component: SFCDescriptor;
}): [string, string] | undefined;
}
export interface Options extends Partial<VuetifyPreset> {
customVariables?: string[];
defaultAssets?: {
font?: FontOptions;
icons?: IconPreset | false;
} | false;
optionsPath?: string;
preset?: string;
treeShake?: boolean | TreeShakeOptions;
}
export declare const defaults: {
customVariables: never[];
defaultAssets: {
font: {
family: string;
};
icons: "mdi" | "md" | "fa" | "fa4";
};
optionsPath: undefined;
treeShake: boolean;
};
export default function initOptions(this: ModuleThis, moduleOptions?: Options): Required<Options>;
+21
View File
@@ -0,0 +1,21 @@
import merge from 'deepmerge';
export const defaults = {
customVariables: [],
defaultAssets: {
font: {
family: 'Roboto'
},
icons: 'mdi'
},
optionsPath: undefined,
treeShake: process.env.NODE_ENV === 'production'
};
export default function initOptions(moduleOptions) {
const options = merge.all([
defaults,
this.options.vuetify || {},
moduleOptions || {}
]);
return options;
}
//# sourceMappingURL=options.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,WAAW,CAAA;AAoC7B,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,eAAe,EAAE,EAAE;IACnB,aAAa,EAAE;QACb,IAAI,EAAE;YACJ,MAAM,EAAE,QAAQ;SACjB;QACD,KAAK,EAAE,KAAmB;KAC3B;IACD,WAAW,EAAE,SAAS;IACtB,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;CACjD,CAAA;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAoB,aAAuB;IAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC;QACxB,QAAQ;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE;QAC1B,aAAa,IAAI,EAAE;KACpB,CAAsB,CAAA;IAEvB,OAAO,OAAO,CAAA;AAChB,CAAC"}
+3
View File
@@ -0,0 +1,3 @@
import { ModuleThis } from '@nuxt/types/config/module';
import { Options } from './options';
export default function setupSass(this: ModuleThis, customVariables: Options['customVariables']): void;
+21
View File
@@ -0,0 +1,21 @@
import dartSass from 'sass';
export default function setupSass(customVariables) {
const { sass, scss } = this.options.build.loaders;
// Use Dart Sass
sass.implementation = scss.implementation = dartSass;
// Ensure compatibility with Nuxt < 2.10 (i.e. before https://github.com/nuxt/nuxt.js/pull/6460)
if (!sass.sassOptions) {
delete sass.indentedSyntax;
sass.sassOptions = {
indentedSyntax: true
};
}
// Custom variables
if (customVariables && customVariables.length > 0) {
const sassImports = customVariables.map(path => `@import '${path}'`).join('\n');
sass.prependData = [sass.prependData, sassImports].join('\n');
const scssImports = customVariables.map(path => `@import '${path}';`).join('\n');
scss.prependData = [scss.prependData, scssImports].join('\n');
}
}
//# sourceMappingURL=sass.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"sass.js","sourceRoot":"","sources":["../src/sass.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,MAAM,CAAA;AAG3B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAoB,eAA2C;IAC9F,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,KAAM,CAAC,OAAoE,CAAA;IAE/G,gBAAgB;IAChB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAA;IAEpD,gGAAgG;IAChG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACrB,OAAO,IAAI,CAAC,cAAc,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG;YACjB,cAAc,EAAE,IAAI;SACrB,CAAA;KACF;IAED,mBAAmB;IACnB,IAAI,eAAe,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;QACjD,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/E,IAAI,CAAC,WAAW,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC7D,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAChF,IAAI,CAAC,WAAW,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KAC9D;AACH,CAAC"}
+95
View File
@@ -0,0 +1,95 @@
{
"_args": [
[
"@nuxtjs/vuetify@1.11.2",
"/home/node/nuxt"
]
],
"_from": "@nuxtjs/vuetify@1.11.2",
"_id": "@nuxtjs/vuetify@1.11.2",
"_inBundle": false,
"_integrity": "sha512-8+k/PQG37OAoXvXgKE+BkBQXaoBCz9odK8oPYA4lwmxQ0ekHnh4PFrU/6Fr+OeVHbQbynbuMZnkF9aWxDsTqug==",
"_location": "/@nuxtjs/vuetify",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/vuetify@1.11.2",
"name": "@nuxtjs/vuetify",
"escapedName": "@nuxtjs%2fvuetify",
"scope": "@nuxtjs",
"rawSpec": "1.11.2",
"saveSpec": null,
"fetchSpec": "1.11.2"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/vuetify/-/vuetify-1.11.2.tgz",
"_spec": "1.11.2",
"_where": "/home/node/nuxt",
"bugs": {
"url": "https://github.com/nuxt-community/vuetify-module/issues"
},
"contributors": [
{
"name": "Pooya Parsa",
"url": "@pi0"
},
{
"name": "Kevin Marrec",
"url": "@kevinmarrec"
}
],
"dependencies": {
"deepmerge": "^4.2.2",
"fibers": "^4.0.3",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"vuetify": "^2",
"vuetify-loader": "^1.4.3"
},
"description": "Vuetify Module for Nuxt.js",
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@nuxt/typescript-build": "^0.6.6",
"@nuxt/typescript-runtime": "^0.4.6",
"@nuxtjs/eslint-config-typescript": "^1.0.2",
"@types/jest": "^25.2.1",
"@types/sass": "^1.16.0",
"codecov": "^3.6.5",
"eslint": "^6.8.0",
"husky": "^4.2.5",
"jest": "^25.4.0",
"nuxt-edge": "2.11.1-26375059.fd5fefe",
"nuxt-webfontloader": "^1.1.0",
"standard-version": "^7.1.0",
"ts-jest": "^25.4.0",
"typescript": "~3.8"
},
"files": [
"dist",
"templates"
],
"homepage": "https://github.com/nuxt-community/vuetify-module#readme",
"license": "MIT",
"main": "dist/index.js",
"name": "@nuxtjs/vuetify",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt-community/vuetify-module.git"
},
"scripts": {
"build": "tsc",
"dev": "tsc && nuxt-ts test/fixture",
"lint": "eslint --ext .ts,.js,.vue .",
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
},
"typings": "dist/index.d.ts",
"version": "1.11.2"
}
+1
View File
@@ -0,0 +1 @@
export default <%= serializeFunction(options) %>
+49
View File
@@ -0,0 +1,49 @@
import Vue from 'vue'
import Vuetify from '<%= options.treeShake ? 'vuetify/lib/framework' : 'vuetify' %>'
<% if (options.preset) { %>
import { preset } from '<%= options.preset %>'
<% } %>
<%
const libImports = [
{ key: 'components', location: 'vuetify/lib'},
{ key: 'transitions', location: 'vuetify/lib'},
{ key: 'directives', location: 'vuetify/lib/directives'}
]
if (options.treeShake) {
for (const lib of libImports) {
if (options.treeShake[lib.key] && options.treeShake[lib.key].length > 0) {
%>
import { <%= options.treeShake[lib.key].join(', ') %> } from '<%= lib.location %>'
<%
}
}
}
%>
import options from './options'
Vue.use(Vuetify, {
<% if (options.treeShake) { %>
<%= libImports.filter(lib => options.treeShake[lib.key] && options.treeShake[lib.key].length > 0)
.map(lib => ` ${lib.key}: { ${options.treeShake[lib.key].join(', ')} }`)
.join(',\n') %>
<% } %>
})
export default (ctx) => {
const vuetifyOptions = typeof options === 'function' ? options(ctx) : options
<% if (options.defaultIconPreset) { %>
vuetifyOptions.icons = vuetifyOptions.icons || {}
vuetifyOptions.icons.iconfont = '<%= options.defaultIconPreset %>'
<% } %>
<% if (options.preset) { %>
vuetifyOptions.preset = preset
<% } %>
const vuetify = new Vuetify(vuetifyOptions)
ctx.app.vuetify = vuetify
ctx.$vuetify = vuetify.framework
}
+60
View File
@@ -0,0 +1,60 @@
<a name="2.0.5"></a>
## [2.0.5](https://github.com/poppinss/youch/compare/v2.0.4...v2.0.5) (2017-06-13)
### Bug Fixes
* **template:** improve css for smaller screens ([b07c77d](https://github.com/poppinss/youch/commit/b07c77d))
<a name="2.0.4"></a>
## [2.0.4](https://github.com/poppinss/youch/compare/v2.0.3...v2.0.4) (2017-01-31)
### Bug Fixes
* **test:** use mocha instead of japa ([8bf7039](https://github.com/poppinss/youch/commit/8bf7039))
<a name="2.0.3"></a>
## [2.0.3](https://github.com/poppinss/youch/compare/v2.0.2...v2.0.3) (2017-01-30)
### Bug Fixes
* **regex:** use plain regex over path.sep ([db3e2dc](https://github.com/poppinss/youch/commit/db3e2dc))
<a name="2.0.2"></a>
## [2.0.2](https://github.com/poppinss/youch/compare/v2.0.0...v2.0.2) (2017-01-27)
### Bug Fixes
* **package:** fix path to main file ([5ad3b4a](https://github.com/poppinss/youch/commit/5ad3b4a))
<a name="2.0.1"></a>
## [2.0.1](https://github.com/poppinss/youch/compare/v2.0.0...v2.0.1) (2017-01-26)
### Bug Fixes
* **package:** fix path to main file ([5ad3b4a](https://github.com/poppinss/youch/commit/5ad3b4a))
<a name="2.0.0"></a>
# 2.0.0 (2017-01-26)
### Features
* initial implementation ([aba222a](https://github.com/poppinss/youch/commit/aba222a))
+6
View File
@@ -0,0 +1,6 @@
# Contributing
In favor of active development we accept contributions from everyone. You can contribute by submitting a bug, creating pull requests or even by improving documentation.
Below is the guide to be followed strictly before submitting your pull requests.
http://adonisjs.com/docs/contributing
+89
View File
@@ -0,0 +1,89 @@
# Youch!
> Pretty error reporting for Node.js 🚀 (Modified for Nuxt.js & SSR Bundles)
<br />
<p>
<img src="https://user-images.githubusercontent.com/5158436/28990900-0a4766f8-7997-11e7-9f0b-4336fa2e2e0b.png" style="width: 600px;" />
</p>
<br />
---
<br />
[![NPM Version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Downloads Stats][npm-downloads]][npm-url]
[![Appveyor][appveyor-image]][appveyor-url]
[![Gitter Channel][gitter-image]][gitter-url]
[![Trello][trello-image]][trello-url]
[![Patreon][patreon-image]][patreon-url]
Youch is inspired by [Whoops](https://filp.github.io/whoops) but with a modern design. Reading stack trace of the console slows you down from active development. Instead **Youch** print those errors in structured HTML to the browser.
## Features
1. HTML reporter
2. JSON reporter, if request accepts a json instead of text/html.
3. Sorted frames of error stack.
## Installation
```bash
npm i --save @nuxtjs/youch
```
## Basic Usage
Youch is used by [AdonisJs](http://adonisjs.com) and [Nuxt.js](https://nuxtjs.org), but it can be used by express or raw HTTP server as well.
```javascript
const Youch = require('@nuxtjs/youch')
const http = require('http')
http.createServer(function (req, res) {
// PERFORM SOME ACTION
if (error) {
const youch = new Youch(error, req)
youch
.toHTML()
.then((html) => {
res.writeHead(200, {'content-type': 'text/html'})
res.write(html)
res.end()
})
}
}).listen(8000)
```
## Release History
Checkout [CHANGELOG.md](CHANGELOG.md) file for release history.
## Meta
Checkout [LICENSE.txt](LICENSE.txt) for license information
Harminder Virk (Aman) - [https://github.com/thetutlage](https://github.com/thetutlage)
[appveyor-image]: https://ci.appveyor.com/api/projects/status/github/nuxt/youch?branch=master&svg=true&passingText=Passing%20On%20Windows
[appveyor-url]: https://ci.appveyor.com/project/nuxt/youch
[npm-image]: https://img.shields.io/npm/v/@nuxtjs/youch.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@nuxtjs/youch
[travis-image]: https://img.shields.io/travis/nuxt/youch/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/nuxt/youch
[gitter-url]: https://gitter.im/adonisjs/adonis-framework
[gitter-image]: https://img.shields.io/badge/gitter-join%20us-1DCE73.svg?style=flat-square
[trello-url]: https://trello.com/b/yzpqCgdl/adonis-for-humans
[trello-image]: https://img.shields.io/badge/trello-roadmap-89609E.svg?style=flat-square
[patreon-url]: https://www.patreon.com/adonisframework
[patreon-image]: https://img.shields.io/badge/patreon-support%20AdonisJs-brightgreen.svg?style=flat-square
[npm-downloads]: https://img.shields.io/npm/dm/@nuxtjs/youch.svg?style=flat-square
+21
View File
@@ -0,0 +1,21 @@
environment:
matrix:
- nodejs_version: 'Stable'
init:
git config --global core.autocrlf true
install:
- ps: Install-Product node $env:nodejs_version
- npm install
test_script:
- node --version
- npm --version
- npm run test:win
build: off
clone_depth: 1
matrix:
fast_finish: true
+40
View File
@@ -0,0 +1,40 @@
'use strict'
const http = require('http')
const Youch = require('../src/Youch')
class HttpException extends Error {
constructor (...args) {
super(...args)
this.name = this.constructor.name
}
}
function foo () {
const error = new HttpException('Some weird error')
error.status = 503
throw error
}
http.createServer((req, res) => {
let youch = null
try {
foo()
} catch (e) {
youch = new Youch(e, req)
}
youch
.toHTML()
.then((response) => {
res.writeHead(200, {'content-type': 'text/html'})
res.write(response)
res.end()
}).catch((error) => {
res.writeHead(500)
res.write(error.message)
res.end()
})
}).listen(8000, () => {
console.log('listening to port 8000')
})
+80
View File
@@ -0,0 +1,80 @@
{
"_args": [
[
"@nuxtjs/youch@4.2.3",
"/home/node/nuxt"
]
],
"_from": "@nuxtjs/youch@4.2.3",
"_id": "@nuxtjs/youch@4.2.3",
"_inBundle": false,
"_integrity": "sha512-XiTWdadTwtmL/IGkNqbVe+dOlT+IMvcBu7TvKI7plWhVQeBCQ9iKhk3jgvVWFyiwL2yHJDlEwOM5v9oVES5Xmw==",
"_location": "/@nuxtjs/youch",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@nuxtjs/youch@4.2.3",
"name": "@nuxtjs/youch",
"escapedName": "@nuxtjs%2fyouch",
"scope": "@nuxtjs",
"rawSpec": "4.2.3",
"saveSpec": null,
"fetchSpec": "4.2.3"
},
"_requiredBy": [
"/@nuxt/server"
],
"_resolved": "https://registry.npmjs.org/@nuxtjs/youch/-/youch-4.2.3.tgz",
"_spec": "4.2.3",
"_where": "/home/node/nuxt",
"author": {
"name": "amanvirk"
},
"bugs": {
"url": "https://github.com/poppinss/nuxt/issues"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {
"cookie": "^0.3.1",
"mustache": "^2.3.0",
"stack-trace": "0.0.10"
},
"description": "Pretty error reporting for Node.js 🚀 (Modified for Nuxt.js & SSR Bundles)",
"devDependencies": {
"cz-conventional-changelog": "^2.0.0",
"japa": "^1.0.3",
"japa-cli": "^1.0.1",
"standard": "^10.0.2",
"supertest": "^3.0.0"
},
"directories": {
"example": "examples"
},
"homepage": "https://github.com/poppinss/nuxt#readme",
"keywords": [
"errors",
"error-reporting",
"whoops"
],
"license": "MIT",
"main": "src/Youch/index.js",
"name": "@nuxtjs/youch",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/youch.git"
},
"scripts": {
"lint": "standard",
"test": "japa",
"test:win": "node ./node_modules/japa-cli/index.js"
},
"version": "4.2.3"
}
+349
View File
@@ -0,0 +1,349 @@
'use strict'
/*
* youch
*
* (c) Harminder Virk <virk@adonisjs.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
const Mustache = require('mustache')
const path = require('path')
const stackTrace = require('stack-trace')
const fs = require('fs')
const cookie = require('cookie')
const VIEW_PATH = '../resources/error.mustache'
const startingSlashRegex = /\\|\//
const viewTemplate = fs.readFileSync(path.join(__dirname, VIEW_PATH), 'utf-8')
class Youch {
constructor (error, request, readSource, baseURL, addCol) {
this.error = error
this.request = request
this.readSource = typeof readSource === 'function' ? readSource : this._readSource
this.baseURL = baseURL || '/'
this.addCol = addCol === undefined ? true : Boolean(addCol)
this.codeContext = 5
this._filterHeaders = ['cookie', 'connection']
this._filterFrames = [
/regenerator-runtime/,
/babel-runtime/,
/core-js\/library/
]
}
/**
* Reads the source code for a given frame into frame.contents
*
* @param {String} path
* @return {Promise}
*/
_readSource (frame) {
return new Promise((resolve, reject) => {
if(!frame.fileName) {
return resolve()
}
fs.readFile(frame.fileName, 'utf-8', (error, contents) => {
if (!error && contents) {
frame.contents = contents
}
resolve()
})
})
}
/**
* Returns source code for a given frame.
*
* @param {Object} frame
* @return {Promise}
*/
_getFrameSource (frame) {
return this.readSource(frame).then(()=> {
if (!frame.contents) {
return
}
const lines = frame.contents.split(/\r?\n/)
const lineNumber = frame.getLineNumber()
return {
pre: lines.slice(Math.max(0, lineNumber - (this.codeContext + 1)), lineNumber - 1),
line: lines[lineNumber - 1],
post: lines.slice(lineNumber, lineNumber + this.codeContext)
}
})
}
/**
* Parses the error stack and returns serialized
* frames out of it.
*
* @return {Object}
*/
_parseError () {
const stack = stackTrace.parse(this.error)
return Promise.all(stack.map((frame) => {
if (this._isNode(frame)) {
return Promise.resolve(frame)
}
return this._getFrameSource(frame).then((context) => {
frame.context = context
return frame
})
}))
.then(stack => stack.filter(this._isVisible.bind(this)))
.then(stack => {
let hasInternal = false
for (let frame of stack) {
if (!this._isApp(frame) && !this._isNode(frame)) {
hasInternal = true
break
}
}
return {stack, hasInternal}
})
}
/**
* Returns the context with code for a given
* frame.
*
* @param {Object}
* @return {Object}
*/
_getContext (frame) {
if (!frame.context) {
return {}
}
return {
start: frame.getLineNumber() - (frame.context.pre || []).length,
pre: frame.context.pre.join('\n'),
line: frame.context.line,
post: frame.context.post.join('\n'),
}
}
/**
* Returns classes to be used inside HTML when
* displaying the frames list.
*
* @param {Object}
* @param {Number}
*
* @return {String}
*/
_getDisplayClasses (frame, index) {
const classes = []
if (index === 0) {
classes.push('active')
}
if (!this._isApp(frame)) {
classes.push('native-frame')
}
return classes.join(' ')
}
/**
* Compiles the view using HTML
*
* @param {String}
* @param {Object}
*
* @return {String}
*/
_compileView (view, data) {
return Mustache.render(view, data)
}
/**
* Serializes frame to a usable error object.
*
* @param {Object}
*
* @return {Object}
*/
_serializeFrame (frame) {
const relativeFileName = frame.getFileName().indexOf(process.cwd()) > -1
? frame.getFileName().replace(process.cwd(), '').replace(startingSlashRegex, '')
: frame.getFileName()
return {
file: relativeFileName,
method: frame.getFunctionName(),
line: frame.getLineNumber(),
column: frame.getColumnNumber(),
context: this._getContext(frame),
lang: this._getLang(frame),
open: this._openURL(frame)
}
}
_openURL(frame) {
if (!frame.fullPath) {
return
}
return this.baseURL + '__open-in-editor' +
'?file=' + encodeURI(frame.fullPath || frame.fileName) +
':' + (frame.getLineNumber() || 0) +
(this.addCol ? (':' + (frame.getColumnNumber() || 0)) : '')
}
/**
* Returns whether frame belongs to nodejs
* or not.
*
* @return {Boolean} [description]
*/
_isNode (frame) {
if (frame.isNative()) {
return true
}
// const filename = frame.getFileName() || ''
// return !path.isAbsolute(filename) && filename[0] !== '.'
return false
}
/**
* Returns whether code belongs to the app
* or not.
*
* @return {Boolean} [description]
*/
_isApp (frame) {
if (this._isNode(frame)) {
return false
}
return !~(frame.getFileName() || '').indexOf('node_modules' + path.sep)
}
/**
* Returns whether frame should be visible
* or not.
*
* @return {Boolean} [description]
*/
_isVisible (frame) {
return this._filterFrames.every(f => !f.test(frame.getFileName()))
}
_getLang(frame) {
let name = frame.getFileName() || ''
let lang = 'js'
if(name.indexOf('.vue') !== -1) {
lang = 'html'
}
return lang
}
/**
* Serializes stack to Mustache friendly object to
* be used within the view. Optionally can pass
* a callback to customize the frames output.
*
* @param {Object}
* @param {Function} [callback]
*
* @return {Object}
*/
_serializeData (stack, callback) {
callback = callback || this._serializeFrame.bind(this)
return {
message: this.error.message,
name: this.error.name,
status: this.error.status,
frames: stack instanceof Array === true ? stack.filter((frame) => frame.getFileName()).map(callback) : []
}
}
/**
* Returns a serialized object with important
* information.
*
* @return {Object}
*/
_serializeRequest () {
const headers = []
Object.keys(this.request.headers).forEach((key) => {
if (this._filterHeaders.indexOf(key) > -1) {
return
}
headers.push({
key: key.toUpperCase(),
value: this.request.headers[key]
})
})
const parsedCookies = cookie.parse(this.request.headers.cookie || '')
const cookies = Object.keys(parsedCookies).map((key) => {
return {key, value: parsedCookies[key]}
})
return {
url: this.request.url,
httpVersion: this.request.httpVersion,
method: this.request.method,
connection: this.request.headers.connection,
headers: headers,
cookies: cookies
}
}
/**
* Returns error stack as JSON.
*
* @return {Promise}
*/
toJSON () {
return new Promise((resolve, reject) => {
this
._parseError()
.then(({ stack, hasInternal }) => {
resolve({
error: this._serializeData(stack),
hasInternal
})
})
.catch(reject)
})
}
/**
* Returns HTML representation of the error stack
* by parsing the stack into frames and getting
* important info out of it.
*
* @return {Promise}
*/
toHTML () {
return new Promise((resolve, reject) => {
this
._parseError()
.then(({ stack, hasInternal }) => {
const data = this._serializeData(stack, (frame, index) => {
const serializedFrame = this._serializeFrame(frame)
serializedFrame.classes = this._getDisplayClasses(frame, index)
return serializedFrame
})
const request = this._serializeRequest()
data.request = request
data.hasInternal = hasInternal
resolve(this._compileView(viewTemplate, data))
})
.catch(reject)
})
}
}
module.exports = Youch
File diff suppressed because one or more lines are too long
+1359
View File
File diff suppressed because it is too large Load Diff