Skip to content

Commit

Permalink
feat: upgrade nuxt to 1.0.0 (#17)
Browse files Browse the repository at this point in the history
* feat: upgrade nuxt to 1.0.0

* fix: bulma custom-properties warning

* test: update snapshot for nuxt1.0.0

* fix: lint issue
  • Loading branch information
clarkdo authored and atinux committed Jan 10, 2018
1 parent fd2772e commit 9c7b3c0
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 61 deletions.
2 changes: 1 addition & 1 deletion sao.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = {
moveFramework(answers.ui, nuxtDir),
answers.server === 'adonis' ? {
'server/index-*.js': 'server.js',
'nuxt/nuxt.config.js': 'config/nuxt.js',
'nuxt/nuxt.config.js': 'config/nuxt.js'
} : null
)
},
Expand Down
5 changes: 4 additions & 1 deletion template/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ module.exports = {
}
],
},
globals: {}
globals: {<% if (server === 'adonis') { %>
use: true,
make: true<% } %>
}
}
3 changes: 2 additions & 1 deletion template/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"precommit": "npm run lint"<% } %>
},
"dependencies": {
"nuxt": "^1.0.0-rc11"<% if (server === 'express') { %>,
"nuxt": "^1.0.0"<% if (server === 'express') { %>,
"express": "^4.15.3"<% } else if (server === 'koa') { %>,
"koa": "^2.3.0"<% } else if (server === 'hapi') { %>,
"hapi-nuxt": "^0.6.0"<% } else if (server === 'micro') { %>,
Expand Down Expand Up @@ -46,6 +46,7 @@
"cross-env": "^5.0.1"<% if (eslint === 'yes') { %>,
"babel-eslint": "^7.2.3",
"eslint": "^4.3.0",
"eslint-loader": "^1.9.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-html": "^3.1.1",
"eslint-plugin-import": "^2.7.0",
Expand Down
8 changes: 3 additions & 5 deletions template/frameworks/adonis/app/Commands/NuxtBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ const Config = use('Config')
const { Nuxt, Builder } = require('nuxt')

class NuxtBuild extends Command {

/**
* signature defines the requirements and name
* of command.
*
* @return {String}
*/
static get signature () {
static get signature() {
return 'nuxtbuild'
}

Expand All @@ -22,7 +21,7 @@ class NuxtBuild extends Command {
*
* @return {String}
*/
static get description () {
static get description() {
return 'Build for production the nuxt.js application.'
}

Expand All @@ -33,14 +32,13 @@ class NuxtBuild extends Command {
* @param {Object} args [description]
* @param {Object} options [description]
*/
async handle (args, options) {
async handle(args, options) {
let config = Config.get('nuxt')
config.dev = false
this.nuxt = new Nuxt(config)
this.info('Building nuxt.js application...')
await new Builder(this.nuxt).build()
}

}

module.exports = NuxtBuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const Config = use('Config')
const { Nuxt, Builder } = require('nuxt')

class NuxtController {

constructor () {
constructor() {
let config = Config.get('nuxt')
config.dev = Env.get('NODE_ENV') === 'development'
this.nuxt = new Nuxt(config)
Expand All @@ -16,7 +15,7 @@ class NuxtController {
}
}

async render ({request : { request: req }, response: { response: res }}) {
async render({request: { request: req }, response: { response: res }}) {
await new Promise((resolve, reject) => {
this.nuxt.render(req, res, promise => {
promise.then(resolve).catch(reject)
Expand Down
4 changes: 2 additions & 2 deletions template/frameworks/adonis/app/Models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const Model = use('Model')

class User extends Model {
static boot () {
static boot() {
super.boot()

/**
Expand All @@ -26,7 +26,7 @@ class User extends Model {
*
* @return {Object}
*/
tokens () {
tokens() {
return this.hasMany('App/Models/Token')
}
}
Expand Down
2 changes: 1 addition & 1 deletion template/frameworks/vuetify/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<script>
export default {
data () {
data() {
return {
clipped: false,
drawer: true,
Expand Down
11 changes: 10 additions & 1 deletion template/nuxt/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ module.exports = {
/*
** Build configuration
*/
build: {
build: {<% if (ui === 'bulma') { %>
postcss: {
plugins: {
'postcss-cssnext': {
features: {
customProperties: false
}
}
}
},<% } %>
/*
** You can extend webpack config here
*/
Expand Down
29 changes: 15 additions & 14 deletions template/server/index-express.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

const express = require('express')
const { Nuxt, Builder } = require('nuxt')


const app = express()
const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || 3000
Expand All @@ -13,18 +11,21 @@ app.set('port', port)
let config = require('../nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')

// Init Nuxt.js
const nuxt = new Nuxt(config)
async function start() {
// Init Nuxt.js
const nuxt = new Nuxt(config)

// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
builder.build()
}
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
}

// Give nuxt middleware to express
app.use(nuxt.render)
// Give nuxt middleware to express
app.use(nuxt.render)

// Listen the server
app.listen(port, host)
console.log('Server listening on http://' + host + ':' + port) // eslint-disable-line no-console
// Listen the server
app.listen(port, host)
console.log('Server listening on http://' + host + ':' + port) // eslint-disable-line no-console
}
start()
49 changes: 25 additions & 24 deletions template/server/index-koa.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,31 @@ const port = process.env.PORT || 3000
let config = require('../nuxt.config.js')
config.dev = !(app.env === 'production')

// Instantiate nuxt.js
const nuxt = new Nuxt(config)

// Build in development
if (config.dev) {
const builder = new Builder(nuxt)
builder.build().catch(e => {
console.error(e) // eslint-disable-line no-console
process.exit(1)
})
}

app.use(ctx => {
ctx.status = 200 // koa defaults to 404 when it sees that status is unset

return new Promise((resolve, reject) => {
ctx.res.on('close', resolve)
ctx.res.on('finish', resolve)
nuxt.render(ctx.req, ctx.res, promise => {
// nuxt.render passes a rejected promise into callback on error.
promise.then(resolve).catch(reject)
async function start() {
// Instantiate nuxt.js
const nuxt = new Nuxt(config)

// Build in development
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
}

app.use(ctx => {
ctx.status = 200 // koa defaults to 404 when it sees that status is unset

return new Promise((resolve, reject) => {
ctx.res.on('close', resolve)
ctx.res.on('finish', resolve)
nuxt.render(ctx.req, ctx.res, promise => {
// nuxt.render passes a rejected promise into callback on error.
promise.then(resolve).catch(reject)
})
})
})
})

app.listen(port, host)
console.log('Server listening on http://' + host + ':' + port) // eslint-disable-line no-console
app.listen(port, host)
console.log('Server listening on http://' + host + ':' + port) // eslint-disable-line no-console
}

start()
17 changes: 9 additions & 8 deletions test/snapshots/index.test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Generated by [AVA](https://ava.li).
{
dependencies: {
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'cross-env': '^5.0.1',
Expand Down Expand Up @@ -75,7 +75,7 @@ Generated by [AVA](https://ava.li).
{
dependencies: {
'@nuxtjs/axios': '^4.4.0',
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'cross-env': '^5.0.1',
Expand Down Expand Up @@ -118,13 +118,14 @@ Generated by [AVA](https://ava.li).
{
dependencies: {
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'babel-eslint': '^7.2.3',
'cross-env': '^5.0.1',
eslint: '^4.3.0',
'eslint-config-standard': '^10.2.1',
'eslint-loader': '^1.9.0',
'eslint-plugin-html': '^3.1.1',
'eslint-plugin-import': '^2.7.0',
'eslint-plugin-node': '^5.1.1',
Expand Down Expand Up @@ -172,7 +173,7 @@ Generated by [AVA](https://ava.li).
{
dependencies: {
express: '^4.15.3',
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'cross-env': '^5.0.1',
Expand Down Expand Up @@ -222,7 +223,7 @@ Generated by [AVA](https://ava.li).
dependencies: {
feathers: '^2.0.3',
'feathers-configuration': '^0.3.3',
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'cross-env': '^5.0.1',
Expand Down Expand Up @@ -267,7 +268,7 @@ Generated by [AVA](https://ava.li).
{
dependencies: {
'hapi-nuxt': '^0.6.0',
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'cross-env': '^5.0.1',
Expand Down Expand Up @@ -312,7 +313,7 @@ Generated by [AVA](https://ava.li).
{
dependencies: {
koa: '^2.3.0',
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'cross-env': '^5.0.1',
Expand Down Expand Up @@ -359,7 +360,7 @@ Generated by [AVA](https://ava.li).
dependencies: {
micro: '^9.0.0',
'micro-route': '^2.4.0',
nuxt: '^1.0.0-rc11',
nuxt: '^1.0.0',
},
devDependencies: {
'cross-env': '^5.0.1',
Expand Down
Binary file modified test/snapshots/index.test.js.snap
Binary file not shown.

0 comments on commit 9c7b3c0

Please sign in to comment.