Skip to content

Commit

Permalink
refactor: update to be comply with module-template
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Pennec committed Apr 14, 2018
1 parent 95928aa commit cc8af0a
Show file tree
Hide file tree
Showing 9 changed files with 2,878 additions and 2,080 deletions.
14 changes: 6 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ jobs:
paths:
- "node_modules"

# Build
# - run:
# name: Build
# command: |
# mkdir -p dist
# yarn build

# Test
- run:
name: Tests
command: yarn test && yarn codecov
command: yarn test

# Coverage
- run:
name: Coverage
command: yarn codecov
31 changes: 30 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
module.exports = require('nuxt-module-builder/eslint')
module.exports = {
root: true,
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
node: true,
jest: true
},
extends: 'standard',
plugins: [
'jest',
'vue'
],
rules: {
// Allow paren-less arrow functions
'arrow-parens': 0,
// Allow async-await
'generator-star-spacing': 0,
// Allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
// Do not allow console.logs etc...
'no-console': 2
},
globals: {
'jest/globals': true,
jasmine: true
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ node_modules
.vscode
.DS_STORE
coverage
dist
dist
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
[![CircleCI](https://img.shields.io/circleci/project/github/nuxt-community/sitemap-module.svg?style=flat-square)](https://circleci.com/gh/nuxt-community/sitemap-module)
[![Codecov](https://img.shields.io/codecov/c/github/nuxt-community/sitemap-module.svg?style=flat-square)](https://codecov.io/gh/nuxt-community/sitemap-module)
[![Dependencies](https://david-dm.org/nuxt-community/sitemap-module/status.svg?style=flat-square)](https://david-dm.org/nuxt-community/sitemap-module)


[![js-standard-style](https://cdn.rawgit.com/standard/standard/master/badge.svg)](http://standardjs.com)
[![js-standard-style](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com)

> Automatically generate or serve dynamic [sitemap.xml](https://www.sitemaps.org/protocol.html) for Nuxt.js projects!
Expand Down
43 changes: 20 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,21 @@
"name": "Pooya Parsa"
}
],
"main": "dist/index.js",
"main": "src/index.js",
"repository": "https://github.com/nuxt-community/sitemap-module",
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "nuxt-module",
"watch": "nuxt-module --watch",
"lint": "eslint lib src test",
"lint-fix": "eslint --fix lib src test",
"test": "NODE_ENV=test npm run build && npm run lint && jest",
"release": "standard-version && git push --follow-tags && npm publish",
"prepare": "npm run test && npm run build"
"dev": "nuxt test/fixture",
"lint": "eslint src test",
"test": "npm run lint && jest",
"release": "standard-version && git push --follow-tags && npm publish"
},
"eslintIgnore": [
"*.template.*"
],
"files": [
"lib",
"src",
"dist"
],
"files": ["src"],
"jest": {
"testEnvironment": "node",
"coverageDirectory": "./coverage/",
"collectCoverage": true,
"collectCoverageFrom": [
"lib",
"src"
]
"collectCoverage": true
},
"dependencies": {
"async-cache": "^1.1.0",
Expand All @@ -52,6 +37,18 @@
"sitemap": "^1.13.0"
},
"devDependencies": {
"nuxt-module-builder": "^0.0.2"
"nuxt": "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",
"jest": "latest",
"jsdom": "latest",
"standard-version": "latest"
}
}
7 changes: 4 additions & 3 deletions test/fixture/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const { resolve } = require('path')

module.exports = {
rootDir: resolve(__dirname, '../..'),
srcDir: __dirname,
dev: false,
render: {
resourceHints: false
},
modules: [
['~/../..', {}]
]
modules: ['@@']
}
2 changes: 1 addition & 1 deletion test/fixture/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
export default {
}
</script>
</script>
23 changes: 9 additions & 14 deletions test/module.test.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000
process.env.PORT = process.env.PORT || 5060
process.env.NODE_ENV = 'production'

const { Nuxt, Builder } = require('nuxt')
const request = require('request-promise-native')

const config = require('./fixture/nuxt.config')

const url = path => `http://localhost:${process.env.PORT}${path}`
const url = path => `http://localhost:3000${path}`
const get = path => request(url(path))

describe('Module', () => {
describe('ssr', () => {
let nuxt

beforeAll(async () => {
config.modules.unshift(function () {
// Add test specific test only hooks on nuxt life cycle
})

// Build a fresh nuxt
nuxt = new Nuxt(config)
await new Builder(nuxt).build()
await nuxt.listen(process.env.PORT)
})
await nuxt.listen(3000)
}, 60000)

afterAll(async () => {
// Close all opened resources
await nuxt.close()
})

test('render', async () => {
let html = await get('/')
expect(html).toContain('Works!')
})

test('sitemap', async () => {
let xml = await get('/sitemap.xml')
expect(xml).toContain('<loc>http://localhost:3000/</loc>')
})
})
Loading

0 comments on commit cc8af0a

Please sign in to comment.