@nuxtjs/router
Advanced tools
+23
| # Change Log | ||
| 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. | ||
| <a name="1.2.1"></a> | ||
| ## [1.2.1](https://github.com/nuxt-community/router-module/compare/v1.1.0...v1.2.1) (2019-02-11) | ||
| ### Bug Fixes | ||
| * **deps:** update babel ([38ac59f](https://github.com/nuxt-community/router-module/commit/38ac59f)) | ||
| * **module:** remove hook ([9625b91](https://github.com/nuxt-community/router-module/commit/9625b91)) | ||
| * **module:** return on disable `keepDefaultRouter` ([7374c65](https://github.com/nuxt-community/router-module/commit/7374c65)) | ||
| * **module:** run in build:before hook ([b4b7e2f](https://github.com/nuxt-community/router-module/commit/b4b7e2f)) | ||
| * **module:** simplify require modules ([6ee58ee](https://github.com/nuxt-community/router-module/commit/6ee58ee)) | ||
| * **module:** use `consola` instead of `throw` when router file not found ([ed63475](https://github.com/nuxt-community/router-module/commit/ed63475)) | ||
| * **plugin:** removed, no need ([ea3edfe](https://github.com/nuxt-community/router-module/commit/ea3edfe)) | ||
| * use a try catch to set defaultRouter ([d11dc18](https://github.com/nuxt-community/router-module/commit/d11dc18)) | ||
| ### Performance Improvements | ||
| * **module:** reduce complebility ([1ef401f](https://github.com/nuxt-community/router-module/commit/1ef401f)) |
+40
-42
@@ -5,53 +5,51 @@ const { resolve } = require('path') | ||
| function routerModule (moduleOptions) { | ||
| this.nuxt.hook('build:before', () => { | ||
| const defaultOptions = { | ||
| path: this.options.srcDir, | ||
| fileName: 'router.js', | ||
| keepDefaultRouter: false | ||
| } | ||
| function routerModule(moduleOptions) { | ||
| const defaultOptions = { | ||
| path: this.options.srcDir, | ||
| fileName: 'router.js', | ||
| keepDefaultRouter: false | ||
| } | ||
| const options = { | ||
| ...{}, | ||
| ...defaultOptions, | ||
| ...this.options.routerModule, | ||
| ...moduleOptions | ||
| } | ||
| const options = { | ||
| ...{}, | ||
| ...defaultOptions, | ||
| ...this.options.routerModule, | ||
| ...moduleOptions | ||
| } | ||
| const routerFilePath = resolve(options.path, options.fileName) | ||
| const routerFilePath = resolve(options.path, options.fileName) | ||
| // Check if router file path is defined | ||
| if (!existsSync(routerFilePath)) { | ||
| return consola.warn(`No \`${options.fileName}\` file found in \`${options.path}\`.`) | ||
| } | ||
| // Check if router file path is defined | ||
| if (!existsSync(routerFilePath)) { | ||
| return consola.warn(`No \`${options.fileName}\` file found in \`${options.path}\`.`) | ||
| } | ||
| // Add router file path as the main template for routing | ||
| this.addTemplate({ | ||
| fileName: 'router.js', | ||
| src: routerFilePath | ||
| }) | ||
| // Add router file path as the main template for routing | ||
| this.addTemplate({ | ||
| fileName: 'router.js', | ||
| src: routerFilePath | ||
| }) | ||
| // Disable parsing `pages/` | ||
| if (!options.keepDefaultRouter) { | ||
| this.nuxt.options.build.createRoutes = () => { | ||
| return [] | ||
| } | ||
| return | ||
| // Disable parsing `pages/` | ||
| if (!options.keepDefaultRouter) { | ||
| this.nuxt.options.build.createRoutes = () => { | ||
| return [] | ||
| } | ||
| // Put default router as .nuxt/defaultRouter.js | ||
| let defaultRouter | ||
| return | ||
| } | ||
| try { | ||
| defaultRouter = require.resolve('@nuxt/vue-app/template/router') | ||
| } catch (err) { | ||
| /* istanbul ignore next */ | ||
| defaultRouter = require.resolve('nuxt/lib/app/router') | ||
| } | ||
| // Put default router as .nuxt/defaultRouter.js | ||
| let defaultRouter | ||
| this.addTemplate({ | ||
| fileName: 'defaultRouter.js', | ||
| src: defaultRouter | ||
| }) | ||
| try { | ||
| defaultRouter = require.resolve('@nuxt/vue-app/template/router') | ||
| } catch (err) { | ||
| /* istanbul ignore next */ | ||
| defaultRouter = require.resolve('nuxt/lib/app/router') | ||
| } | ||
| this.addTemplate({ | ||
| fileName: 'defaultRouter.js', | ||
| src: defaultRouter | ||
| }) | ||
@@ -58,0 +56,0 @@ } |
+1
-1
| MIT License | ||
| Copyright (c) Sebastien Chopin <seb@chopin.io> | ||
| Copyright (c) Nuxt Community | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
+25
-50
| { | ||
| "name": "@nuxtjs/router", | ||
| "version": "1.2.0", | ||
| "version": "1.2.1", | ||
| "description": "Nuxt module to use router.js instead of pages/ directory", | ||
@@ -17,4 +17,4 @@ "license": "MIT", | ||
| "lint": "eslint lib test", | ||
| "test": "npm run lint && jest", | ||
| "release": "standard-version && git push --follow-tags && npm publish" | ||
| "test": "yarn lint && jest", | ||
| "release": "yarn test && standard-version && git push --follow-tags && npm publish" | ||
| }, | ||
@@ -24,30 +24,2 @@ "files": [ | ||
| ], | ||
| "babel": { | ||
| "presets": [ | ||
| [ | ||
| "@babel/preset-env", | ||
| { | ||
| "targets": { | ||
| "esmodules": true | ||
| } | ||
| } | ||
| ] | ||
| ] | ||
| }, | ||
| "jest": { | ||
| "testEnvironment": "node", | ||
| "collectCoverage": true, | ||
| "collectCoverageFrom": [ | ||
| "lib/**/*.js" | ||
| ], | ||
| "moduleNameMapper": { | ||
| "^~/(.*)$": "<rootDir>/lib/$1", | ||
| "^~~$": "<rootDir>", | ||
| "^@@$": "<rootDir>", | ||
| "^@/(.*)$": "<rootDir>/lib/$1" | ||
| }, | ||
| "transform": { | ||
| "^.+\\.js$": "babel-jest" | ||
| } | ||
| }, | ||
| "dependencies": { | ||
@@ -57,22 +29,25 @@ "consola": "^2.4.0" | ||
| "devDependencies": { | ||
| "@babel/core": "^7.2.2", | ||
| "@babel/preset-env": "^7.3.1", | ||
| "babel-core": "^7.0.0-bridge", | ||
| "babel-eslint": "^10.0.1", | ||
| "babel-jest": "^23.6.0", | ||
| "codecov": "^3.1.0", | ||
| "eslint": "^5.13.0", | ||
| "eslint-config-standard": "^12.0.0", | ||
| "eslint-plugin-import": "^2.16.0", | ||
| "eslint-plugin-jest": "^22.2.2", | ||
| "eslint-plugin-node": "^8.0.1", | ||
| "eslint-plugin-promise": "^4.0.1", | ||
| "eslint-plugin-standard": "^4.0.0", | ||
| "eslint-plugin-vue": "^5.1.0", | ||
| "jest": "^23.6.0", | ||
| "nuxt": "^2.4.2", | ||
| "request": "^2.88.0", | ||
| "request-promise-native": "^1.0.5", | ||
| "standard-version": "^4.4.0" | ||
| "@babel/core": "latest", | ||
| "@babel/preset-env": "latest", | ||
| "@commitlint/cli": "latest", | ||
| "@commitlint/config-conventional": "latest", | ||
| "@nuxtjs/eslint-config": "latest", | ||
| "babel-eslint": "latest", | ||
| "babel-jest": "latest", | ||
| "codecov": "latest", | ||
| "eslint": "latest", | ||
| "eslint-config-standard": "latest", | ||
| "eslint-plugin-import": "latest", | ||
| "eslint-plugin-jest": "latest", | ||
| "eslint-plugin-node": "latest", | ||
| "eslint-plugin-promise": "latest", | ||
| "eslint-plugin-standard": "latest", | ||
| "eslint-plugin-vue": "latest", | ||
| "husky": "latest", | ||
| "jest": "latest", | ||
| "nuxt": "latest", | ||
| "request": "latest", | ||
| "request-promise-native": "latest", | ||
| "standard-version": "latest" | ||
| } | ||
| } |
+25
-8
| # Nuxt Router Module | ||
| [](https://npmjs.com/package/@nuxtjs/router) | ||
| [](https://npmjs.com/package/@nuxtjs/router) | ||
| [](https://circleci.com/gh/nuxt-community/router-module) | ||
| [](https://codecov.io/gh/nuxt-community/router-module) | ||
| [](http://standardjs.com) | ||
| [![npm version][npm-version-src]][npm-version-href] | ||
| [![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
| [![Circle CI][circle-ci-src]][circle-ci-href] | ||
| [![Codecov][codecov-src]][codecov-href] | ||
| [![Dependencies][david-dm-src]][david-dm-href] | ||
| [![Standard JS][standard-js-src]][standard-js-href] | ||
@@ -19,4 +20,5 @@ > Nuxt module to use router.js instead of pages/ directory | ||
| 1. Install `@nuxtjs/router` dependency with `yarn` or `npm` into your project | ||
| 1. Add `@nuxtjs/router` dependency with `yarn` or `npm` into your project | ||
| 2. Add `@nuxtjs/router` to `modules` section of `nuxt.config.js`: | ||
| 3. Configure it: | ||
@@ -41,3 +43,3 @@ ```js | ||
| 3. If you are using SPA mode, add an index `/` route to `generate` section of `nuxt.config.js`: | ||
| If you are using SPA mode, add an index `/` route to `generate` section of `nuxt.config.js`: | ||
@@ -109,2 +111,3 @@ ```js | ||
| ### Customize Routes Directory or Filename | ||
| If you use the module with fileName `{fileName: 'my-router.js'}` and/or `{path: 'custom-dir'}` you can customize the location of you route files. | ||
@@ -116,2 +119,16 @@ | ||
| Copyright (c) Sebastien Chopin <seb@chopin.io> | ||
| Copyright (c) Nuxt Community | ||
| <!-- Badges --> | ||
| [npm-version-src]: https://img.shields.io/npm/dt/@nuxtjs/router.svg?style=flat-square | ||
| [npm-version-href]: https://npmjs.com/package/@nuxtjs/router | ||
| [npm-downloads-src]: https://img.shields.io/npm/v/@nuxtjs/router/latest.svg?style=flat-square | ||
| [npm-downloads-href]: https://npmjs.com/package/@nuxtjs/router | ||
| [circle-ci-src]: https://img.shields.io/circleci/project/github/nuxt-community/router-module.svg?style=flat-square | ||
| [circle-ci-href]: https://circleci.com/gh/nuxt-community/router-module | ||
| [codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/router-module.svg?style=flat-square | ||
| [codecov-href]: https://codecov.io/gh/nuxt-community/router-module | ||
| [david-dm-src]: https://david-dm.org/nuxt-community/router-module/status.svg?style=flat-square | ||
| [david-dm-href]: https://david-dm.org/nuxt-community/router-module | ||
| [standard-js-src]: https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square | ||
| [standard-js-href]: https://standardjs.com |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
8579
19.95%5
25%131
14.91%22
15.79%47
-4.08%