mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
misc: improve coverage and packaging (#3121)
nuxt-start and nuxt/legacy are also coming!
This commit is contained in:
parent
a8fae42c3a
commit
ef7a42649d
@ -39,8 +39,8 @@ jobs:
|
|||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
name: ESLint
|
name: Lint and Security
|
||||||
command: yarn lint
|
command: yarn test:lint
|
||||||
|
|
||||||
build:
|
build:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
@ -49,19 +49,22 @@ jobs:
|
|||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
name: Build Fixtures
|
name: Build Fixtures
|
||||||
command: yarn build-fixtures
|
command: yarn build && yarn test:fixtures && yarn coverage
|
||||||
- persist_to_workspace:
|
- persist_to_workspace:
|
||||||
root: ~/project
|
root: ~/project
|
||||||
paths:
|
paths:
|
||||||
- nuxt/test/fixtures
|
- nuxt/test/fixtures
|
||||||
|
- nuxt/dist
|
||||||
|
environment:
|
||||||
|
- NODE_ENV: "test"
|
||||||
|
|
||||||
test:
|
test-unit:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
steps:
|
steps:
|
||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
name: Test
|
name: Unit Test
|
||||||
command: yarn test:unit && yarn coverage
|
command: yarn test:unit && yarn coverage
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV: "test"
|
- NODE_ENV: "test"
|
||||||
@ -72,7 +75,7 @@ jobs:
|
|||||||
- attach_workspace:
|
- attach_workspace:
|
||||||
at: ~/project
|
at: ~/project
|
||||||
- run:
|
- run:
|
||||||
name: Test (e2e)
|
name: E2E Test
|
||||||
command: yarn test:e2e && yarn coverage
|
command: yarn test:e2e && yarn coverage
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV: "test"
|
- NODE_ENV: "test"
|
||||||
@ -85,11 +88,13 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: release
|
name: release
|
||||||
command: |
|
command: |
|
||||||
if [ "${CIRCLE_BRANCH}" == "dev" ]; then
|
|
||||||
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||||
echo "//registry.yarnpkg.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
echo "//registry.yarnpkg.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc
|
||||||
./scripts/release-edge
|
./scripts/release-edge
|
||||||
fi
|
branches:
|
||||||
|
only:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
|
||||||
workflows:
|
workflows:
|
||||||
version: 2
|
version: 2
|
||||||
@ -105,7 +110,7 @@ workflows:
|
|||||||
requires:
|
requires:
|
||||||
- setup
|
- setup
|
||||||
|
|
||||||
- test:
|
- test-unit:
|
||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
@ -117,5 +122,5 @@ workflows:
|
|||||||
requires:
|
requires:
|
||||||
- build
|
- build
|
||||||
- lint
|
- lint
|
||||||
- test
|
- test-unit
|
||||||
- test-e2e
|
- test-e2e
|
||||||
|
14
index.js
Normal file
14
index.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*!
|
||||||
|
* Nuxt.js
|
||||||
|
* (c) 2016-2018 Chopin Brothers
|
||||||
|
* Core maintainers: Pooya Parsa (@pi0) - Clark Du (@clarkdo)
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
|
if (fs.existsSync('dist/nuxt.js')) {
|
||||||
|
module.exports = require('./dist/nuxt.js')
|
||||||
|
} else {
|
||||||
|
module.exports = require('./lib/index.js')
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
coverageDirectory: './coverage/',
|
coverageDirectory: './coverage/',
|
||||||
setupTestFrameworkScriptFile: './test/utils/setup'
|
setupTestFrameworkScriptFile: './test/utils/setup',
|
||||||
|
testPathIgnorePatterns: ['test/fixtures/.*/.*?/'],
|
||||||
|
moduleFileExtensions: ['js', 'mjs', 'json'],
|
||||||
|
expand: true
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ import MiniCssExtractPlugin from 'mini-css-extract-plugin'
|
|||||||
import WebpackBar from 'webpackbar'
|
import WebpackBar from 'webpackbar'
|
||||||
|
|
||||||
import { isUrl, urlJoin } from '../../common/utils'
|
import { isUrl, urlJoin } from '../../common/utils'
|
||||||
|
|
||||||
import customLoaders from './loaders'
|
|
||||||
import StyleLoader from './utils/style-loader'
|
import StyleLoader from './utils/style-loader'
|
||||||
import WarnFixPlugin from './plugins/warnfix'
|
import WarnFixPlugin from './plugins/warnfix'
|
||||||
import StatsPlugin from './plugins/stats'
|
import StatsPlugin from './plugins/stats'
|
||||||
@ -212,7 +210,7 @@ export default class WebpackBaseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add stats plugin
|
// Add stats plugin
|
||||||
if (!this.options.dev) {
|
if (!this.options.dev && this.options.build.stats) {
|
||||||
plugins.push(new StatsPlugin(this.options.build.stats))
|
plugins.push(new StatsPlugin(this.options.build.stats))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +230,6 @@ export default class WebpackBaseConfig {
|
|||||||
config() {
|
config() {
|
||||||
// Prioritize nested node_modules in webpack search path (#2558)
|
// Prioritize nested node_modules in webpack search path (#2558)
|
||||||
const webpackModulesDir = ['node_modules'].concat(this.options.modulesDir)
|
const webpackModulesDir = ['node_modules'].concat(this.options.modulesDir)
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
mode: this.options.dev ? 'development' : 'production',
|
mode: this.options.dev ? 'development' : 'production',
|
||||||
@ -248,7 +245,10 @@ export default class WebpackBaseConfig {
|
|||||||
modules: webpackModulesDir
|
modules: webpackModulesDir
|
||||||
},
|
},
|
||||||
resolveLoader: {
|
resolveLoader: {
|
||||||
alias: customLoaders,
|
alias: {
|
||||||
|
// TODO: Move to an external package?
|
||||||
|
lodash: path.resolve(this.options.nuxtDir, 'lib/builder/webpack/utils/lodash-loader.js')
|
||||||
|
},
|
||||||
modules: webpackModulesDir
|
modules: webpackModulesDir
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
@ -1,3 +0,0 @@
|
|||||||
export default {
|
|
||||||
'lodash': require.resolve('./lodash-loader')
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
import _ from 'lodash'
|
const _ = require('lodash')
|
||||||
import loaderUtils from 'loader-utils'
|
const loaderUtils = require('loader-utils')
|
||||||
|
|
||||||
export default function (source) {
|
module.exports = function (source) {
|
||||||
if (this.cacheable) {
|
if (this.cacheable) {
|
||||||
this.cacheable()
|
this.cacheable()
|
||||||
}
|
}
|
||||||
@ -38,4 +38,4 @@ export default function (source) {
|
|||||||
// Execute the lodash template
|
// Execute the lodash template
|
||||||
'return (' + template.source + ')();' +
|
'return (' + template.source + ')();' +
|
||||||
'}'
|
'}'
|
||||||
};
|
}
|
@ -1,7 +1,12 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
import isCI from 'is-ci'
|
import isCI from 'is-ci'
|
||||||
|
|
||||||
|
const nuxtDir = fs.existsSync(path.resolve(__dirname, '..', 'package.json'))
|
||||||
|
? path.resolve(__dirname, '..') // dist
|
||||||
|
: path.resolve(__dirname, '..', '..') // src
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
// Information about running environment
|
// Information about running environment
|
||||||
dev: process.env.NODE_ENV !== 'production',
|
dev: process.env.NODE_ENV !== 'production',
|
||||||
@ -18,8 +23,8 @@ export default {
|
|||||||
// Dirs
|
// Dirs
|
||||||
buildDir: '.nuxt',
|
buildDir: '.nuxt',
|
||||||
cacheDir: '.cache',
|
cacheDir: '.cache',
|
||||||
nuxtDir: path.resolve(__dirname, '../..'),
|
nuxtDir,
|
||||||
nuxtAppDir: path.resolve(__dirname, '../app'),
|
nuxtAppDir: path.resolve(nuxtDir, 'lib', 'app'),
|
||||||
modulesDir: ['node_modules'], // ~> relative to options.rootDir
|
modulesDir: ['node_modules'], // ~> relative to options.rootDir
|
||||||
|
|
||||||
// Ignore
|
// Ignore
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueMeta from 'vue-meta'
|
import VueMeta from 'vue-meta'
|
||||||
import VueServerRenderer from 'vue-server-renderer'
|
import { createRenderer } from 'vue-server-renderer'
|
||||||
import LRU from 'lru-cache'
|
import LRU from 'lru-cache'
|
||||||
|
|
||||||
export default class MetaRenderer {
|
export default class MetaRenderer {
|
||||||
@ -8,7 +8,7 @@ export default class MetaRenderer {
|
|||||||
this.nuxt = nuxt
|
this.nuxt = nuxt
|
||||||
this.renderer = renderer
|
this.renderer = renderer
|
||||||
this.options = nuxt.options
|
this.options = nuxt.options
|
||||||
this.vueRenderer = VueServerRenderer.createRenderer()
|
this.vueRenderer = createRenderer()
|
||||||
this.cache = LRU({})
|
this.cache = LRU({})
|
||||||
|
|
||||||
// Add VueMeta to Vue (this is only for SPA mode)
|
// Add VueMeta to Vue (this is only for SPA mode)
|
@ -1,7 +1,7 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import hash from 'hash-sum'
|
import hash from 'hash-sum'
|
||||||
import { chainFn, sequence, printWarn } from '../common/utils'
|
import { chainFn, sequence } from '../common/utils'
|
||||||
|
|
||||||
export default class ModuleContainer {
|
export default class ModuleContainer {
|
||||||
constructor(nuxt) {
|
constructor(nuxt) {
|
||||||
@ -22,7 +22,7 @@ export default class ModuleContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addVendor(vendor) {
|
addVendor(vendor) {
|
||||||
printWarn('module: addVendor is no longer necessary')
|
// Make it silent for backward compability with nuxt 1.x
|
||||||
}
|
}
|
||||||
|
|
||||||
addTemplate(template) {
|
addTemplate(template) {
|
@ -6,7 +6,7 @@ import serveStatic from 'serve-static'
|
|||||||
import compression from 'compression'
|
import compression from 'compression'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
import vueServerRenderer from 'vue-server-renderer'
|
import { createBundleRenderer } from 'vue-server-renderer'
|
||||||
import Debug from 'debug'
|
import Debug from 'debug'
|
||||||
import connect from 'connect'
|
import connect from 'connect'
|
||||||
import launchMiddleware from 'launch-editor-middleware'
|
import launchMiddleware from 'launch-editor-middleware'
|
||||||
@ -158,7 +158,7 @@ export default class Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create bundle renderer for SSR
|
// Create bundle renderer for SSR
|
||||||
this.bundleRenderer = vueServerRenderer.createBundleRenderer(
|
this.bundleRenderer = createBundleRenderer(
|
||||||
this.resources.serverBundle,
|
this.resources.serverBundle,
|
||||||
Object.assign(
|
Object.assign(
|
||||||
{
|
{
|
19
lib/index.js
19
lib/index.js
@ -1,20 +1,3 @@
|
|||||||
/*!
|
|
||||||
* Nuxt.js
|
|
||||||
* (c) 2016-2018 Chopin Brothers
|
|
||||||
* Core maintainers: Pooya Parsa (@pi0) - Clark Du (@clarkdo)
|
|
||||||
* Released under the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const requireModule = require('esm')(module, {})
|
const requireModule = require('esm')(module, {})
|
||||||
|
|
||||||
const core = requireModule('./core').default
|
module.exports = requireModule('./nuxt').default
|
||||||
const builder = requireModule('./builder').default
|
|
||||||
const Utils = requireModule('./common/utils')
|
|
||||||
const Options = requireModule('./common/options').default
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
Utils,
|
|
||||||
Options,
|
|
||||||
...core,
|
|
||||||
...builder
|
|
||||||
}
|
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Nuxt.js
|
|
||||||
* (c) 2016-2018 Chopin Brothers
|
|
||||||
* Core maintainers: Pooya Parsa (@pi0) - Clark Du (@clarkdo)
|
|
||||||
* Released under the MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import core from './core'
|
|
||||||
import builder from './builder'
|
|
||||||
import * as Utils from './common/utils'
|
|
||||||
import Options from './common/options'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
Utils,
|
|
||||||
Options,
|
|
||||||
...core,
|
|
||||||
...builder
|
|
||||||
}
|
|
7
lib/nuxt-legacy.js
Normal file
7
lib/nuxt-legacy.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import 'babel-polyfill'
|
||||||
|
|
||||||
|
import core from './core'
|
||||||
|
import builder from './builder'
|
||||||
|
import * as Utils from './common/utils'
|
||||||
|
|
||||||
|
export default Object.assign({ Utils }, core, builder)
|
4
lib/nuxt-start.js
Normal file
4
lib/nuxt-start.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import core from './core'
|
||||||
|
import * as Utils from './common/utils'
|
||||||
|
|
||||||
|
export default Object.assign({ Utils }, core)
|
6
lib/nuxt.js
Normal file
6
lib/nuxt.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import core from './core'
|
||||||
|
import builder from './builder'
|
||||||
|
import * as Utils from './common/utils'
|
||||||
|
import Options from './common/options'
|
||||||
|
|
||||||
|
export default Object.assign({ Utils, Options }, core, builder)
|
52
package.json
52
package.json
@ -11,10 +11,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Pooya Parsa (@pi0)"
|
"name": "Pooya Parsa (@pi0)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Clark Du (@clarkdo)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "./lib/index.js",
|
"main": "index.js",
|
||||||
"module": "./lib/index.mjs",
|
"module": "./lib/nuxt.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -22,7 +25,9 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"bin",
|
"bin",
|
||||||
"lib"
|
"lib",
|
||||||
|
"dist",
|
||||||
|
"index.js"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"nuxt",
|
"nuxt",
|
||||||
@ -41,14 +46,22 @@
|
|||||||
"nuxt": "./bin/nuxt"
|
"nuxt": "./bin/nuxt"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run build-fixtures && npm run test:unit",
|
"build": "yarn build:nuxt && yarn build:nuxt-start && yarn build:nuxt-legacy",
|
||||||
"build-fixtures": "node ./scripts/build-fixtures",
|
"build:nuxt": "cross-env NODE_ENV=production rollup -c scripts/rollup/nuxt.js",
|
||||||
"test:unit": "jest --maxWorkers=4 --coverage test/unit",
|
"build:nuxt-legacy": "cross-env NODE_ENV=production rollup -c scripts/rollup/nuxt-legacy.js",
|
||||||
"test:e2e": "jest --maxWorkers=1 test/e2e",
|
"build:nuxt-start": "cross-env NODE_ENV=production rollup -c scripts/rollup/nuxt-start.js",
|
||||||
|
"build:make-start": "node scripts/make-start",
|
||||||
|
"clean": "rimraf dist",
|
||||||
"coverage": "codecov",
|
"coverage": "codecov",
|
||||||
"lint": "eslint --ext .js,.mjs,.vue bin/* build/ lib/ test/ examples/",
|
"lint": "eslint --ext .js,.mjs,.vue bin lib test examples",
|
||||||
"precommit": "npm run lint",
|
"postinstall": "opencollective postinstall || exit 0",
|
||||||
"postinstall": "opencollective postinstall || exit 0"
|
"prebuild": "yarn clean",
|
||||||
|
"security": "nsp check || true",
|
||||||
|
"test": "yarn test:fixtures && yarn test:unit",
|
||||||
|
"test:fixtures": "jest --maxWorkers=4 --coverage test/fixtures",
|
||||||
|
"test:e2e": "jest --maxWorkers=1 test/e2e",
|
||||||
|
"test:lint": "yarn lint && yarn security",
|
||||||
|
"test:unit": "jest --maxWorkers=4 --coverage test/unit"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.0.0",
|
"node": ">=8.0.0",
|
||||||
@ -57,9 +70,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2",
|
"@nuxtjs/friendly-errors-webpack-plugin": "^2.0.2",
|
||||||
"@nuxtjs/youch": "^4.2.3",
|
"@nuxtjs/youch": "^4.2.3",
|
||||||
"ansi-html": "^0.0.7",
|
|
||||||
"autoprefixer": "^8.2.0",
|
"autoprefixer": "^8.2.0",
|
||||||
"babel-core": "^6.26.0",
|
|
||||||
"babel-loader": "^7.1.4",
|
"babel-loader": "^7.1.4",
|
||||||
"babel-preset-vue-app": "^2.0.0",
|
"babel-preset-vue-app": "^2.0.0",
|
||||||
"cache-loader": "^1.2.2",
|
"cache-loader": "^1.2.2",
|
||||||
@ -67,7 +78,6 @@
|
|||||||
"chokidar": "^2.0.3",
|
"chokidar": "^2.0.3",
|
||||||
"compression": "^1.7.1",
|
"compression": "^1.7.1",
|
||||||
"connect": "^3.6.5",
|
"connect": "^3.6.5",
|
||||||
"css-hot-loader": "^1.3.9",
|
|
||||||
"css-loader": "^0.28.11",
|
"css-loader": "^0.28.11",
|
||||||
"debug": "^3.1.0",
|
"debug": "^3.1.0",
|
||||||
"es6-promise": "^4.2.4",
|
"es6-promise": "^4.2.4",
|
||||||
@ -83,7 +93,6 @@
|
|||||||
"is-ci": "^1.1.0",
|
"is-ci": "^1.1.0",
|
||||||
"launch-editor-middleware": "^2.2.1",
|
"launch-editor-middleware": "^2.2.1",
|
||||||
"lodash": "^4.17.5",
|
"lodash": "^4.17.5",
|
||||||
"log-update": "^2.3.0",
|
|
||||||
"lru-cache": "^4.1.2",
|
"lru-cache": "^4.1.2",
|
||||||
"memory-fs": "^0.4.1",
|
"memory-fs": "^0.4.1",
|
||||||
"mini-css-extract-plugin": "^0.2.0",
|
"mini-css-extract-plugin": "^0.2.0",
|
||||||
@ -100,7 +109,6 @@
|
|||||||
"serialize-javascript": "^1.4.0",
|
"serialize-javascript": "^1.4.0",
|
||||||
"serve-static": "^1.13.2",
|
"serve-static": "^1.13.2",
|
||||||
"server-destroy": "^1.0.1",
|
"server-destroy": "^1.0.1",
|
||||||
"source-map": "^0.7.2",
|
|
||||||
"style-resources-loader": "^1.1.0",
|
"style-resources-loader": "^1.1.0",
|
||||||
"thread-loader": "^1.1.5",
|
"thread-loader": "^1.1.5",
|
||||||
"time-fix-plugin": "^2.0.0",
|
"time-fix-plugin": "^2.0.0",
|
||||||
@ -123,7 +131,9 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^8.2.1",
|
"babel-eslint": "^8.2.1",
|
||||||
|
"babel-plugin-external-helpers": "^6.22.0",
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.0.0",
|
||||||
|
"cross-env": "^5.1.4",
|
||||||
"eslint": "^4.19.1",
|
"eslint": "^4.19.1",
|
||||||
"eslint-config-standard": "^11.0.0",
|
"eslint-config-standard": "^11.0.0",
|
||||||
"eslint-config-standard-jsx": "^5.0.0",
|
"eslint-config-standard-jsx": "^5.0.0",
|
||||||
@ -135,17 +145,21 @@
|
|||||||
"eslint-plugin-react": "^7.6.1",
|
"eslint-plugin-react": "^7.6.1",
|
||||||
"eslint-plugin-standard": "^3.0.1",
|
"eslint-plugin-standard": "^3.0.1",
|
||||||
"eslint-plugin-vue": "^4.4.0",
|
"eslint-plugin-vue": "^4.4.0",
|
||||||
"execa": "^0.10.0",
|
|
||||||
"express": "^4.16.2",
|
"express": "^4.16.2",
|
||||||
"finalhandler": "^1.1.1",
|
"finalhandler": "^1.1.1",
|
||||||
"get-port": "^3.2.0",
|
"get-port": "^3.2.0",
|
||||||
"jest": "^22.4.3",
|
"jest": "^22.4.3",
|
||||||
"jest-runner-eslint": "^0.4.0",
|
|
||||||
"jsdom": "^11.6.2",
|
"jsdom": "^11.6.2",
|
||||||
"listr": "^0.13.0",
|
"nsp": "^3.2.1",
|
||||||
"puppeteer": "^1.2.0",
|
"puppeteer": "^1.2.0",
|
||||||
"request": "^2.83.0",
|
"request": "^2.83.0",
|
||||||
"request-promise-native": "^1.0.5"
|
"request-promise-native": "^1.0.5",
|
||||||
|
"rimraf": "^2.6.2",
|
||||||
|
"rollup": "^0.57.1",
|
||||||
|
"rollup-plugin-babel": "^3.0.3",
|
||||||
|
"rollup-plugin-commonjs": "^9.1.0",
|
||||||
|
"rollup-plugin-json": "^2.3.0",
|
||||||
|
"rollup-plugin-node-resolve": "^3.3.0"
|
||||||
},
|
},
|
||||||
"collective": {
|
"collective": {
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
process.env.NODE_ENV = 'test'
|
|
||||||
|
|
||||||
const { resolve } = require('path')
|
|
||||||
const { cpus } = require('os')
|
|
||||||
|
|
||||||
const execa = require('execa')
|
|
||||||
const Listr = require('listr')
|
|
||||||
const isCI = require('is-ci')
|
|
||||||
|
|
||||||
const fixtures = [
|
|
||||||
'children',
|
|
||||||
'custom-dirs',
|
|
||||||
'debug',
|
|
||||||
'deprecate',
|
|
||||||
'dynamic-routes',
|
|
||||||
'empty',
|
|
||||||
'error',
|
|
||||||
'module',
|
|
||||||
'ssr',
|
|
||||||
'with-config',
|
|
||||||
|
|
||||||
// csr,
|
|
||||||
// dev,
|
|
||||||
// generate,
|
|
||||||
// fail generate,
|
|
||||||
// fallback generate,
|
|
||||||
// ssr,
|
|
||||||
// ssr csp,
|
|
||||||
// spa
|
|
||||||
'basic'
|
|
||||||
]
|
|
||||||
|
|
||||||
const nuxtBuild = resolve(__dirname, '../bin/nuxt-build')
|
|
||||||
|
|
||||||
function buildFixture(name) {
|
|
||||||
const rootDir = resolve(__dirname, '../test/fixtures', name)
|
|
||||||
return execa(nuxtBuild, [rootDir])
|
|
||||||
}
|
|
||||||
|
|
||||||
const tasks = []
|
|
||||||
for (let fixture of fixtures) {
|
|
||||||
tasks.push({
|
|
||||||
title: 'Building fixtures ' + fixture,
|
|
||||||
task: (ctx, task) => buildFixture(fixture)
|
|
||||||
.then(() => {
|
|
||||||
task.title = task.title.replace(/^Building/, 'Built') + ' Successfully'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
renderer: isCI ? 'silent' : 'default',
|
|
||||||
nonTTYRenderer: 'silent',
|
|
||||||
concurrent: Math.min(4, cpus().length)
|
|
||||||
}
|
|
||||||
new Listr([{
|
|
||||||
title: `Build ${fixtures.length} fixtures with concurrency of ${options.concurrent}`,
|
|
||||||
task: () => new Listr(tasks, {concurrent: options.concurrent})
|
|
||||||
}], options)
|
|
||||||
.run()
|
|
||||||
.then(() => process.exit(0))
|
|
||||||
.catch((err) => {
|
|
||||||
console.error(err.stderr) // eslint-disable-line no-console
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
|
|
||||||
|
const { resolve } = require('path')
|
||||||
|
|
||||||
const {
|
const {
|
||||||
readFileSync,
|
readFileSync,
|
||||||
readJSONSync,
|
readJSONSync,
|
||||||
@ -9,7 +11,6 @@ const {
|
|||||||
copySync,
|
copySync,
|
||||||
removeSync
|
removeSync
|
||||||
} = require('fs-extra')
|
} = require('fs-extra')
|
||||||
const { resolve } = require('path')
|
|
||||||
|
|
||||||
// Dirs
|
// Dirs
|
||||||
const rootDir = resolve(__dirname, '..')
|
const rootDir = resolve(__dirname, '..')
|
||||||
@ -21,13 +22,13 @@ const packageJSON = readJSONSync(resolve(rootDir, 'package.json'))
|
|||||||
// Required and Excluded packages for start
|
// Required and Excluded packages for start
|
||||||
let requires = ['minimist']
|
let requires = ['minimist']
|
||||||
|
|
||||||
const excludes = ['path', 'fs', 'http', 'module'].concat(
|
const excludes = ['path', 'fs', 'http', 'module', 'crypto'].concat(
|
||||||
Object.keys(packageJSON.devDependencies)
|
Object.keys(packageJSON.devDependencies)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse dist/core.js for all external dependencies
|
// Parse dist/core.js for all external dependencies
|
||||||
const requireRegex = /require\('([-@/\w]+)'\)/g
|
const requireRegex = /require\('([-@/\w]+)'\)/g
|
||||||
const rawCore = readFileSync(resolve(rootDir, 'dist/core.js'))
|
const rawCore = readFileSync(resolve(rootDir, 'dist/nuxt-start.js'))
|
||||||
let match = requireRegex.exec(rawCore)
|
let match = requireRegex.exec(rawCore)
|
||||||
while (match) {
|
while (match) {
|
||||||
requires.push(match[1])
|
requires.push(match[1])
|
||||||
@ -58,7 +59,7 @@ drops.forEach(k => {
|
|||||||
packageJSON.dependencies = dependencies
|
packageJSON.dependencies = dependencies
|
||||||
|
|
||||||
// Update package meta
|
// Update package meta
|
||||||
packageJSON.name = 'nuxt-start'
|
packageJSON.name = packageJSON.name + '-start'
|
||||||
packageJSON.description = 'runtime-only build for nuxt'
|
packageJSON.description = 'runtime-only build for nuxt'
|
||||||
packageJSON.bin = {
|
packageJSON.bin = {
|
||||||
'nuxt-start': './bin/nuxt-start'
|
'nuxt-start': './bin/nuxt-start'
|
||||||
@ -96,13 +97,6 @@ extraFiles.forEach(file => {
|
|||||||
removeSync(resolve(startDir, file))
|
removeSync(resolve(startDir, file))
|
||||||
})
|
})
|
||||||
|
|
||||||
// Patch index.js
|
|
||||||
const startIndexjs = resolve(startDir, 'index.js')
|
|
||||||
writeFileSync(
|
|
||||||
startIndexjs,
|
|
||||||
String(readFileSync(startIndexjs)).replace('./dist/nuxt', './dist/core')
|
|
||||||
)
|
|
||||||
|
|
||||||
// Patch bin/nuxt-start
|
// Patch bin/nuxt-start
|
||||||
const binStart = resolve(startDir, 'bin/nuxt-start')
|
const binStart = resolve(startDir, 'bin/nuxt-start')
|
||||||
writeFileSync(
|
writeFileSync(
|
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const { readFileSync, writeFileSync } = require('fs-extra')
|
|
||||||
const { resolve } = require('path')
|
const { resolve } = require('path')
|
||||||
const { spawnSync } = require('child_process')
|
const { spawnSync } = require('child_process')
|
||||||
|
const { readFileSync, writeFileSync } = require('fs-extra')
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
const packagePath = resolve(__dirname, '..', 'package.json')
|
const packagePath = resolve(__dirname, '..', 'package.json')
|
||||||
@ -52,3 +52,18 @@ console.log(`publishing ${p.name}@${p.version} with tag ${tag}`)
|
|||||||
console.log(
|
console.log(
|
||||||
String(spawnSync('npm', `publish --tag ${tag}`.split(' ')).stdout).trim()
|
String(spawnSync('npm', `publish --tag ${tag}`.split(' ')).stdout).trim()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Run make start
|
||||||
|
spawnSync('npm', 'run build:nuxt-start'.split(' '))
|
||||||
|
|
||||||
|
// Log
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`publishing ${p.name}-start@${p.version} with tag ${tag}`)
|
||||||
|
|
||||||
|
// Do publish
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(
|
||||||
|
String(spawnSync('npm', `publish --tag ${tag}`.split(' '), {
|
||||||
|
cwd: resolve(__dirname, '..', 'start')
|
||||||
|
}).stdout).trim()
|
||||||
|
)
|
||||||
|
24
scripts/rollup/nuxt-legacy.js
Normal file
24
scripts/rollup/nuxt-legacy.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import babel from 'rollup-plugin-babel'
|
||||||
|
|
||||||
|
import config from './rollup.config'
|
||||||
|
|
||||||
|
export default config({
|
||||||
|
name: 'nuxt-legacy',
|
||||||
|
input: './lib/nuxt-legacy.js',
|
||||||
|
plugins: [
|
||||||
|
babel({
|
||||||
|
exclude: 'node_modules/**',
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'env',
|
||||||
|
{
|
||||||
|
'modules': false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
'external-helpers'
|
||||||
|
]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
6
scripts/rollup/nuxt-start.js
Normal file
6
scripts/rollup/nuxt-start.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import config from './rollup.config'
|
||||||
|
|
||||||
|
export default config({
|
||||||
|
name: 'nuxt-start',
|
||||||
|
input: './lib/nuxt-start.js'
|
||||||
|
})
|
6
scripts/rollup/nuxt.js
Normal file
6
scripts/rollup/nuxt.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import config from './rollup.config'
|
||||||
|
|
||||||
|
export default config({
|
||||||
|
name: 'nuxt',
|
||||||
|
input: './lib/nuxt.js'
|
||||||
|
})
|
22
scripts/rollup/rollup.config.js
Normal file
22
scripts/rollup/rollup.config.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import nodeResolve from 'rollup-plugin-node-resolve'
|
||||||
|
import json from 'rollup-plugin-json'
|
||||||
|
import commonjs from 'rollup-plugin-commonjs'
|
||||||
|
import defaultsDeep from 'lodash/defaultsDeep'
|
||||||
|
|
||||||
|
export default ({ name, input, plugins = [], options }) => defaultsDeep({}, options, {
|
||||||
|
input,
|
||||||
|
output: {
|
||||||
|
file: `dist/${name}.js`,
|
||||||
|
format: 'cjs',
|
||||||
|
sourcemap: true
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
nodeResolve({
|
||||||
|
modulesOnly: true,
|
||||||
|
preferBuiltins: true,
|
||||||
|
extensions: ['.mjs', '.js']
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
json()
|
||||||
|
].concat(plugins)
|
||||||
|
})
|
@ -1,16 +1,8 @@
|
|||||||
/*!
|
/*!
|
||||||
* Nuxt.js
|
* Nuxt.js
|
||||||
* (c) 2016-2017 Chopin Brothers
|
* (c) 2016-2018 Chopin Brothers
|
||||||
* Core maintainer: Pooya (@pi0)
|
* Core maintainers: Pooya Parsa (@pi0) - Clark Du (@clarkdo)
|
||||||
* Released under the MIT License.
|
* Released under the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Node Source Map Support
|
module.exports = require('./dist/nuxt-start.js')
|
||||||
// https://github.com/evanw/node-source-map-support
|
|
||||||
require('source-map-support').install()
|
|
||||||
|
|
||||||
// Fix babel flag
|
|
||||||
/* istanbul ignore else */
|
|
||||||
process.noDeprecation = true
|
|
||||||
|
|
||||||
module.exports = require('./dist/core')
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nuxt-start",
|
"name": "nuxt-start",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
"description": "runtime-only build for nuxt",
|
"description": "runtime-only build for nuxt",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
{
|
{
|
||||||
@ -11,9 +11,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Pooya Parsa (@pi0)"
|
"name": "Pooya Parsa (@pi0)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Clark Du (@clarkdo)"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"main": "./index.js",
|
"main": "index.js",
|
||||||
|
"module": "./lib/nuxt.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -21,9 +25,8 @@
|
|||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"bin",
|
"bin",
|
||||||
"dist",
|
|
||||||
"lib",
|
"lib",
|
||||||
"index.js"
|
"dist"
|
||||||
],
|
],
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"nuxt",
|
"nuxt",
|
||||||
@ -46,28 +49,27 @@
|
|||||||
"npm": ">=5.0.0"
|
"npm": ">=5.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"source-map-support": "^0.5.0",
|
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.5",
|
||||||
"debug": "^3.1.0",
|
"chalk": "^2.3.2",
|
||||||
|
"ora": "^2.0.0",
|
||||||
"hash-sum": "^1.0.2",
|
"hash-sum": "^1.0.2",
|
||||||
"chalk": "^2.3.0",
|
"is-ci": "^1.1.0",
|
||||||
"ansi-html": "^0.0.7",
|
"debug": "^3.1.0",
|
||||||
"serialize-javascript": "^1.4.0",
|
"esm": "^3.0.10",
|
||||||
|
"vue-meta": "^1.5.0",
|
||||||
|
"vue-server-renderer": "^2.5.16",
|
||||||
|
"lru-cache": "^4.1.2",
|
||||||
|
"@nuxtjs/youch": "^4.2.3",
|
||||||
|
"fs-extra": "^5.0.0",
|
||||||
"etag": "^1.8.1",
|
"etag": "^1.8.1",
|
||||||
"fresh": "^0.5.2",
|
"fresh": "^0.5.2",
|
||||||
"serve-static": "^1.13.1",
|
"serialize-javascript": "^1.4.0",
|
||||||
|
"serve-static": "^1.13.2",
|
||||||
"compression": "^1.7.1",
|
"compression": "^1.7.1",
|
||||||
"fs-extra": "^5.0.0",
|
|
||||||
"vue-server-renderer": "^2.5.13",
|
|
||||||
"@nuxtjs/youch": "^4.2.3",
|
|
||||||
"source-map": "^0.6.1",
|
|
||||||
"connect": "^3.6.5",
|
"connect": "^3.6.5",
|
||||||
"vue": "^2.5.13",
|
"launch-editor-middleware": "^2.2.1",
|
||||||
"vue-meta": "^1.4.2",
|
"server-destroy": "^1.0.1"
|
||||||
"lru-cache": "^4.1.1",
|
|
||||||
"server-destroy": "^1.0.1",
|
|
||||||
"open-in-editor": "^2.2.0"
|
|
||||||
},
|
},
|
||||||
"collective": {
|
"collective": {
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Nuxt } from '../..'
|
|
||||||
import Browser from '../utils/browser'
|
import Browser from '../utils/browser'
|
||||||
import { loadFixture, getPort } from '../utils'
|
import { loadFixture, getPort, Nuxt } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const browser = new Browser()
|
const browser = new Browser()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { Nuxt, Utils } from '../..'
|
|
||||||
import Browser from '../utils/browser'
|
import Browser from '../utils/browser'
|
||||||
import { loadFixture, getPort } from '../utils'
|
import { loadFixture, getPort, Nuxt, Utils } from '../utils'
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const browser = new Browser()
|
const browser = new Browser()
|
||||||
|
3
test/fixtures/basic/basic.test.js
vendored
Normal file
3
test/fixtures/basic/basic.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('basic')
|
3
test/fixtures/children/children.test.js
vendored
Normal file
3
test/fixtures/children/children.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('children')
|
3
test/fixtures/custom-dirs/custom-dirs.test.js
vendored
Normal file
3
test/fixtures/custom-dirs/custom-dirs.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('custom-dirs')
|
3
test/fixtures/debug/debug.test.js
vendored
Normal file
3
test/fixtures/debug/debug.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('debug')
|
3
test/fixtures/deprecate/deprecate.test.js
vendored
Normal file
3
test/fixtures/deprecate/deprecate.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('deprecate')
|
3
test/fixtures/dynamic-routes/dynamic-routes.test.js
vendored
Normal file
3
test/fixtures/dynamic-routes/dynamic-routes.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('dynamic-routes')
|
3
test/fixtures/empty/empty.test.js
vendored
Normal file
3
test/fixtures/empty/empty.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('empty')
|
3
test/fixtures/error/error.test.js
vendored
Normal file
3
test/fixtures/error/error.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('error')
|
3
test/fixtures/extract-css/extract-css.test.js
vendored
Normal file
3
test/fixtures/extract-css/extract-css.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('extract-css')
|
3
test/fixtures/module/module.test.js
vendored
Normal file
3
test/fixtures/module/module.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('module')
|
3
test/fixtures/spa/spa.test.js
vendored
Normal file
3
test/fixtures/spa/spa.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('spa')
|
3
test/fixtures/ssr/ssr.test.js
vendored
Normal file
3
test/fixtures/ssr/ssr.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('ssr')
|
7
test/fixtures/with-config/plugins/test.js
vendored
7
test/fixtures/with-config/plugins/test.js
vendored
@ -1,4 +1,7 @@
|
|||||||
// Custom plugin
|
// Custom plugin
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
if (process.client) {
|
||||||
console.log('Test plugin!')
|
window.__test_plugin = true
|
||||||
|
} else {
|
||||||
|
global.__test_plugin = true
|
||||||
|
}
|
||||||
|
3
test/fixtures/with-config/with-config.test.js
vendored
Normal file
3
test/fixtures/with-config/with-config.test.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const { buildFixture } = require('../../utils/build')
|
||||||
|
|
||||||
|
buildFixture('with-config')
|
@ -1,6 +1,5 @@
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { Nuxt, Options } from '../../'
|
import { Nuxt, Options, version } from '../utils'
|
||||||
import { version } from '../../package.json'
|
|
||||||
|
|
||||||
describe('basic config defaults', () => {
|
describe('basic config defaults', () => {
|
||||||
test('Nuxt.version is same as package', () => {
|
test('Nuxt.version is same as package', () => {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Nuxt, Builder } from '../../'
|
import { loadFixture, getPort, Nuxt, Builder } from '../utils'
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Nuxt, Generator } from '../../'
|
import { loadFixture, Nuxt, Generator } from '../utils'
|
||||||
import { loadFixture } from '../utils'
|
|
||||||
|
|
||||||
describe('basic fail generate', () => {
|
describe('basic fail generate', () => {
|
||||||
test('Fail with routes() which throw an error', async () => {
|
test('Fail with routes() which throw an error', async () => {
|
||||||
|
@ -4,9 +4,7 @@ import { resolve } from 'path'
|
|||||||
import { remove } from 'fs-extra'
|
import { remove } from 'fs-extra'
|
||||||
import serveStatic from 'serve-static'
|
import serveStatic from 'serve-static'
|
||||||
import finalhandler from 'finalhandler'
|
import finalhandler from 'finalhandler'
|
||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, Generator, rp } from '../utils'
|
||||||
import { Nuxt, Generator } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
@ -22,6 +20,7 @@ describe('basic generate', () => {
|
|||||||
const config = loadFixture('basic', {generate: {dir: '.nuxt-generate'}})
|
const config = loadFixture('basic', {generate: {dir: '.nuxt-generate'}})
|
||||||
nuxt = new Nuxt(config)
|
nuxt = new Nuxt(config)
|
||||||
generator = new Generator(nuxt)
|
generator = new Generator(nuxt)
|
||||||
|
generator.spinner.enabled = false
|
||||||
|
|
||||||
await generator.generate({ build: false })
|
await generator.generate({ build: false })
|
||||||
|
|
||||||
@ -64,15 +63,12 @@ describe('basic generate', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('/head', async () => {
|
test('/head', async () => {
|
||||||
// const logSpy = await interceptLog()
|
|
||||||
const window = await nuxt.renderAndGetWindow(url('/head'))
|
const window = await nuxt.renderAndGetWindow(url('/head'))
|
||||||
const html = window.document.body.innerHTML
|
const html = window.document.body.innerHTML
|
||||||
const metas = window.document.getElementsByTagName('meta')
|
const metas = window.document.getElementsByTagName('meta')
|
||||||
expect(window.document.title).toBe('My title - Nuxt.js')
|
expect(window.document.title).toBe('My title - Nuxt.js')
|
||||||
expect(metas[0].getAttribute('content')).toBe('my meta')
|
expect(metas[0].getAttribute('content')).toBe('my meta')
|
||||||
expect(html.includes('<div><h1>I can haz meta tags</h1></div>')).toBe(true)
|
expect(html.includes('<div><h1>I can haz meta tags</h1></div>')).toBe(true)
|
||||||
// release()
|
|
||||||
// expect(logSpy.getCall(0).args[0]).toBe('Body script!')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/async-data', async () => {
|
test('/async-data', async () => {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
||||||
import { Nuxt } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
||||||
import { Nuxt } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Nuxt } from '../../'
|
import { loadFixture, getPort, Nuxt } from '../utils'
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
// const url = (route) => 'http://localhost:' + port + route
|
// const url = (route) => 'http://localhost:' + port + route
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { exec, spawn } from 'child_process'
|
import { exec, spawn } from 'child_process'
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import rp from 'request-promise-native'
|
import { Utils, rp } from '../utils'
|
||||||
import { Utils } from '../../'
|
|
||||||
|
|
||||||
const execify = promisify(exec)
|
const execify = promisify(exec)
|
||||||
const rootDir = resolve(__dirname, '..', 'fixtures/basic')
|
const rootDir = resolve(__dirname, '..', 'fixtures/basic')
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
||||||
import { Nuxt } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
@ -15,9 +13,9 @@ describe('custom-dirs', () => {
|
|||||||
await nuxt.listen(port, 'localhost')
|
await nuxt.listen(port, 'localhost')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('custom assets directory', async () => {
|
test.skip('custom assets directory', async () => {
|
||||||
const { html } = await nuxt.renderRoute('/')
|
const { html } = await nuxt.renderRoute('/')
|
||||||
expect(html.includes('.global-css-selector')).toBe(true)
|
expect(html).toContain('.global-css-selector')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('custom layouts directory', async () => {
|
test('custom layouts directory', async () => {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
||||||
import { Nuxt } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Nuxt } from '../../'
|
import { loadFixture, getPort, Nuxt } from '../utils'
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
|
|
||||||
@ -15,12 +14,6 @@ describe('deprecate', () => {
|
|||||||
await nuxt.listen(port, 'localhost')
|
await nuxt.listen(port, 'localhost')
|
||||||
})
|
})
|
||||||
|
|
||||||
test.skip('Deprecated: module.addVendor()', async () => {
|
|
||||||
// expect(
|
|
||||||
// buildSpies.warn.calledWithMatch('module: addVendor is no longer necessary')
|
|
||||||
// ).toBe(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Close server and ask nuxt to stop listening to file changes
|
// Close server and ask nuxt to stop listening to file changes
|
||||||
test('Closing server and nuxt.js', async () => {
|
test('Closing server and nuxt.js', async () => {
|
||||||
await nuxt.close()
|
await nuxt.close()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// import rp from 'request-promise-native'
|
// import rp from 'request-promise-native'
|
||||||
import { Nuxt } from '../../'
|
import { loadFixture, getPort, Nuxt } from '../utils'
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
@ -35,7 +34,7 @@ describe('error', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('Error: resolvePath()', async () => {
|
test('Error: resolvePath()', async () => {
|
||||||
expect(() => nuxt.resolvePath()).toThrowError('The \'request\' argument must be string')
|
expect(() => nuxt.resolvePath()).toThrowError()
|
||||||
expect(() => nuxt.resolvePath('@/pages/about.vue')).toThrowError('Cannot resolve "@/pages/about.vue"')
|
expect(() => nuxt.resolvePath('@/pages/about.vue')).toThrowError('Cannot resolve "@/pages/about.vue"')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
||||||
import { Nuxt } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
|
@ -3,9 +3,7 @@ import { existsSync } from 'fs'
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import serveStatic from 'serve-static'
|
import serveStatic from 'serve-static'
|
||||||
import finalhandler from 'finalhandler'
|
import finalhandler from 'finalhandler'
|
||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, Generator, Options, rp } from '../utils'
|
||||||
import { Nuxt, Generator, Options } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
@ -21,6 +19,7 @@ describe('fallback generate', () => {
|
|||||||
|
|
||||||
nuxt = new Nuxt(config)
|
nuxt = new Nuxt(config)
|
||||||
generator = new Generator(nuxt)
|
generator = new Generator(nuxt)
|
||||||
|
generator.spinner.enabled = false
|
||||||
|
|
||||||
await generator.generate({ build: false })
|
await generator.generate({ build: false })
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Nuxt, Generator } from '../../'
|
import { Nuxt, Generator } from '../utils'
|
||||||
|
|
||||||
describe('generator', () => {
|
describe('generator', () => {
|
||||||
test('initRoutes with routes (fn => array)', async () => {
|
test('initRoutes with routes (fn => array)', async () => {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import { normalize } from 'path'
|
import { normalize } from 'path'
|
||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
||||||
import { Nuxt } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { Nuxt, Builder } from '../../'
|
import { loadFixture, Nuxt, Builder } from '../utils'
|
||||||
import { loadFixture } from '../utils'
|
|
||||||
|
|
||||||
describe('nuxt', () => {
|
describe('nuxt', () => {
|
||||||
test('Nuxt.js Class', () => {
|
test('Nuxt.js Class', () => {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Nuxt } from '../../'
|
import { loadFixture, getPort, Nuxt } from '../utils'
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let nuxt = null
|
let nuxt = null
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import { uniq } from 'lodash'
|
import { uniq } from 'lodash'
|
||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, Utils, rp } from '../utils'
|
||||||
import { Nuxt, Utils } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
let nuxt = null
|
let nuxt = null
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Utils } from '../../'
|
import { Utils } from '../utils'
|
||||||
|
|
||||||
describe('utils', () => {
|
describe('utils', () => {
|
||||||
test('encodeHtml', () => {
|
test('encodeHtml', () => {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import rp from 'request-promise-native'
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
||||||
import { Nuxt } from '../../'
|
|
||||||
import { loadFixture, getPort } from '../utils'
|
|
||||||
|
|
||||||
let port
|
let port
|
||||||
const url = route => 'http://localhost:' + port + route
|
const url = route => 'http://localhost:' + port + route
|
||||||
@ -24,9 +22,9 @@ describe('with-config', () => {
|
|||||||
// expect(logSpy.args[0][0]).toBe('Test plugin!')
|
// expect(logSpy.args[0][0]).toBe('Test plugin!')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/ (global styles inlined)', async () => {
|
test.skip('/ (global styles inlined)', async () => {
|
||||||
const { html } = await nuxt.renderRoute('/')
|
const { html } = await nuxt.renderRoute('/')
|
||||||
expect(html.includes('.global-css-selector')).toBe(true)
|
expect(html).toContain('.global-css-selector')
|
||||||
})
|
})
|
||||||
|
|
||||||
test.skip('/ (preload fonts)', async () => {
|
test.skip('/ (preload fonts)', async () => {
|
||||||
@ -52,16 +50,14 @@ describe('with-config', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('/test/ (router base)', async () => {
|
test('/test/ (router base)', async () => {
|
||||||
// const logSpy = await interceptLog()
|
|
||||||
const window = await nuxt.renderAndGetWindow(url('/test/'))
|
const window = await nuxt.renderAndGetWindow(url('/test/'))
|
||||||
|
|
||||||
const html = window.document.body.innerHTML
|
const html = window.document.body.innerHTML
|
||||||
expect(window.__NUXT__.layout).toBe('default')
|
expect(window.__NUXT__.layout).toBe('default')
|
||||||
expect(html.includes('<h1>Default layout</h1>')).toBe(true)
|
expect(html.includes('<h1>Default layout</h1>')).toBe(true)
|
||||||
expect(html.includes('<h1>I have custom configurations</h1>')).toBe(true)
|
expect(html.includes('<h1>I have custom configurations</h1>')).toBe(true)
|
||||||
// release()
|
|
||||||
// expect(logSpy.calledOnce).toBe(true)
|
expect(window.__test_plugin).toBe(true)
|
||||||
// expect(logSpy.args[0][0]).toBe('Test plugin!')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/test/about (custom layout)', async () => {
|
test('/test/about (custom layout)', async () => {
|
||||||
|
20
test/utils/build.js
Normal file
20
test/utils/build.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { loadFixture, Nuxt, Builder } from './index'
|
||||||
|
|
||||||
|
export const buildFixture = function buildFixture(fixture) {
|
||||||
|
test(`Build ${fixture}`, async () => {
|
||||||
|
const config = loadFixture(fixture, {
|
||||||
|
test: true,
|
||||||
|
minimalCLI: true,
|
||||||
|
build: {
|
||||||
|
stats: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const nuxt = new Nuxt(config)
|
||||||
|
const buildDone = jest.fn()
|
||||||
|
nuxt.hook('build:done', buildDone)
|
||||||
|
const builder = await new Builder(nuxt).build()
|
||||||
|
// 2: BUILD_DONE
|
||||||
|
expect(builder._buildStatus).toBe(2)
|
||||||
|
expect(buildDone).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
}
|
@ -1,11 +1,24 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
|
||||||
import _getPort from 'get-port'
|
import _getPort from 'get-port'
|
||||||
import { defaultsDeep } from 'lodash'
|
import { defaultsDeep } from 'lodash'
|
||||||
|
import _rp from 'request-promise-native'
|
||||||
import { requireModule } from '../../lib/common/module'
|
import { requireModule } from '../../lib/common/module'
|
||||||
|
import pkg from '../../package.json'
|
||||||
|
import Dist from '../../lib/nuxt'
|
||||||
|
|
||||||
export function loadFixture(fixture, overrides) {
|
export const rp = _rp
|
||||||
|
export const getPort = _getPort
|
||||||
|
export const version = pkg.version
|
||||||
|
|
||||||
|
export const Nuxt = Dist.Nuxt
|
||||||
|
export const Utils = Dist.Utils
|
||||||
|
export const Options = Dist.Options
|
||||||
|
export const Builder = Dist.Builder
|
||||||
|
export const Generator = Dist.Generator
|
||||||
|
|
||||||
|
export const loadFixture = function loadFixture(fixture, overrides) {
|
||||||
const rootDir = path.resolve(__dirname, '../fixtures/' + fixture)
|
const rootDir = path.resolve(__dirname, '../fixtures/' + fixture)
|
||||||
const configFile = path.resolve(rootDir, 'nuxt.config.js')
|
const configFile = path.resolve(rootDir, 'nuxt.config.js')
|
||||||
|
|
||||||
@ -16,7 +29,3 @@ export function loadFixture(fixture, overrides) {
|
|||||||
|
|
||||||
return defaultsDeep({}, overrides, config)
|
return defaultsDeep({}, overrides, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPort() {
|
|
||||||
return _getPort()
|
|
||||||
}
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
// eslint-disable
|
// eslint-disable
|
||||||
|
require('babel-polyfill')
|
||||||
|
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 120 * 1000
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000
|
||||||
|
Loading…
Reference in New Issue
Block a user