@dnlup/vue-cli-plugin-unit-ava
Advanced tools
Comparing version 1.0.0-beta.7 to 1.0.0-rc.1
@@ -5,2 +5,32 @@ # Changelog | ||
## [1.0.0-rc.1](https://github.com/dnlup/vue-cli-plugin-unit-ava/compare/v1.0.0-beta.7...v1.0.0-rc.1) (2019-08-27) | ||
### Bug Fixes | ||
* **ci:** avoid travis_wait ([51c49f6](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/51c49f6)) | ||
* **ci:** fix builds timing out ([69cb59f](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/69cb59f)) | ||
* **ci:** install bash on macOS ([417e744](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/417e744)) | ||
* **ci:** remove addons step ([4b45888](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/4b45888)) | ||
* **ci:** use travis_wait ([a595e00](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/a595e00)) | ||
* **eslint:** add node_modules to .eslintignore ([e8774cb](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/e8774cb)) | ||
* **generator:** remove vuetify missing module import ([c274605](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/c274605)) | ||
* **tests:** fix ava running tests on wrong files ([8999406](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/8999406)) | ||
* **tests:** generator tests failing when updating deps ([cc29a0b](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/cc29a0b)), closes [#19](https://github.com/dnlup/vue-cli-plugin-unit-ava/issues/19) | ||
* **tests:** remove delay ([a6fce86](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/a6fce86)) | ||
* **tests:** remove test cases ([53cf091](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/53cf091)) | ||
### Features | ||
* **generator:** add possibility to choose if to load styles ([230eb6c](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/230eb6c)) | ||
* **generator:** use style loaders only if selected ([79fef8a](https://github.com/dnlup/vue-cli-plugin-unit-ava/commit/79fef8a)), closes [#20](https://github.com/dnlup/vue-cli-plugin-unit-ava/issues/20) | ||
### BREAKING CHANGES | ||
* **generator:** style loaders are not automatically injected anymore | ||
## [1.0.0-beta.7](https://github.com/dnlup/vue-cli-plugin-unit-ava/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2019-05-22) | ||
@@ -7,0 +37,0 @@ |
@@ -28,13 +28,15 @@ /** | ||
/** | ||
* Add a babel plugin avoiding duplicates | ||
* @param {Array[]} plugins | ||
* @param {Array} plugin | ||
* Add a babel list entry avoiding duplicates | ||
* @param {Array} list - the option list | ||
* @param {Array} entry - the entry | ||
* @retun {Array[]} | ||
*/ | ||
function addBabelPlugin (plugins, plugin) { | ||
const index = plugins.findIndex(p => p[0] === plugin[0]) | ||
function addBabeListEntry (list, entry) { | ||
const index = list.findIndex(i => { | ||
return Array.isArray(i) ? i[0] === entry[0] : i === entry[0] | ||
}) | ||
if (index === -1) { | ||
plugins.push(plugin) | ||
list.push(entry) | ||
} | ||
return plugins | ||
return list | ||
} | ||
@@ -87,5 +89,8 @@ | ||
avaConfigLocation, | ||
uiFramework | ||
uiFramework, | ||
styles | ||
} = options | ||
const hasTS = api.hasPlugin('typescript') | ||
const hasBabel = api.hasPlugin('babel') | ||
const isBabelProject = !hasTS && hasBabel | ||
const babelPluginModuleResolver = [ | ||
@@ -106,3 +111,5 @@ 'module-resolver', | ||
// Configure ava | ||
if (hasTS) { | ||
// Add Typescript configuration to ava | ||
injectedAvaConfig.compileEnhancements = false | ||
@@ -115,6 +122,20 @@ injectedAvaConfig.files = [ | ||
] | ||
} else { | ||
// Inject Typescript dependencies | ||
api.extendPackage({ | ||
devDependencies: { | ||
'ts-node': injectedPackageDevDeps['ts-node'], | ||
'tsconfig-paths': injectedPackageDevDeps['tsconfig-paths'] | ||
} | ||
}) | ||
} else if (hasBabel) { | ||
injectedAvaConfig.files = [ | ||
'tests/unit/**/*.spec.js' | ||
] | ||
} else if (!hasBabel) { | ||
injectedAvaConfig.babel = false | ||
injectedAvaConfig.compileEnhancements = false | ||
injectedAvaConfig.files = [ | ||
'tests/unit/**/*.spec.js' | ||
] | ||
} | ||
@@ -149,3 +170,4 @@ | ||
if (!hasTS) { | ||
// Configure babel.config.js | ||
if (isBabelProject) { | ||
api.render(files => { | ||
@@ -162,3 +184,12 @@ let config = {} | ||
config.env.test.plugins = config.env.test.plugins || [] | ||
config.env.test.plugins = addBabelPlugin( | ||
config.env.test.presets = config.env.test.presets || [] | ||
config.env.test.presets = addBabeListEntry(config.env.test.presets, [ | ||
'@vue/app', | ||
{ | ||
targets: { | ||
node: 'current' | ||
} | ||
} | ||
]) | ||
config.env.test.plugins = addBabeListEntry( | ||
config.env.test.plugins, | ||
@@ -179,15 +210,11 @@ babelPluginModuleResolver | ||
// Add Typescript dependencies | ||
if (hasTS) { | ||
// Add style loaders | ||
if (styles && styles.length) { | ||
api.extendPackage({ | ||
devDependencies: { | ||
'ts-node': injectedPackageDevDeps['ts-node'], | ||
'tsconfig-paths': injectedPackageDevDeps['tsconfig-paths'] | ||
'css-modules-require-hook': | ||
injectedPackageDevDeps['css-modules-require-hook'] | ||
} | ||
}) | ||
} | ||
// Add UI Frameowrk specific dependencies | ||
switch (uiFramework) { | ||
case 'Vuetify': | ||
if (styles.includes('stylus')) { | ||
api.extendPackage({ | ||
@@ -198,9 +225,14 @@ devDependencies: { | ||
}) | ||
} | ||
} | ||
// generate assets | ||
api.render('./template', { | ||
hasTS, | ||
uiFramework | ||
hasBabel, | ||
uiFramework, | ||
styles | ||
}) | ||
// add common dependencies and scripts | ||
api.extendPackage({ | ||
@@ -217,5 +249,3 @@ devDependencies: { | ||
'require-extension-hooks-vue': | ||
injectedPackageDevDeps['require-extension-hooks-vue'], | ||
'css-modules-require-hook': | ||
injectedPackageDevDeps['css-modules-require-hook'] | ||
injectedPackageDevDeps['require-extension-hooks-vue'] | ||
}, | ||
@@ -222,0 +252,0 @@ scripts: { |
require('browser-env')() | ||
const webpackConfig = require.resolve('@vue/cli-service/webpack.config.js') | ||
const hooks = require('require-extension-hooks') | ||
<%_ if (styles && styles.length) { _%> | ||
const css = require('css-modules-require-hook') | ||
<%_ } _%> | ||
<%_ if (styles && styles.includes('stylus')) { _%> | ||
const stylus = require('stylus') | ||
<%_ } _%> | ||
const Vue = require('vue') | ||
<%_ if (uiFramework === 'Vuetify') { _%> | ||
const Vuetify = require('vuetify') | ||
const stylus = require('stylus') | ||
<%_ } _%> | ||
@@ -23,2 +27,4 @@ <%_ if (hasTS) { _%> | ||
}) | ||
require('tsconfig-paths/register') | ||
<%_ } _%> | ||
@@ -32,3 +38,6 @@ | ||
<%_ if (hasTS) { _%> | ||
// Setup vue files to be processed by `require-extension-hooks-vue` | ||
hooks('vue').plugin('vue').push() | ||
<%_ if (hasTS && hasBabel) { _%> | ||
hooks('ts').push(({filename, content}) => { | ||
@@ -41,9 +50,14 @@ content = ts.compile(content, filename) | ||
}) | ||
require('tsconfig-paths/register') | ||
<%_ } _%> | ||
// Setup vue files to be processed by `require-extension-hooks-vue` | ||
hooks('vue').plugin('vue').push() | ||
<%_ if (!hasTS) { _%> | ||
<%_ if (hasTS && !hasBabel) { _%> | ||
// Setup vue and ts files to be processed by `ts-node` | ||
hooks(['vue', 'ts']).push(({filename, content}) => { | ||
content = ts.compile(content, filename) | ||
return { | ||
content, | ||
filename | ||
} | ||
}) | ||
<%_ } _%> | ||
<%_ if (!hasTS && hasBabel) { _%> | ||
// Setup vue and js files to be processed by `require-extension-hooks-babel` | ||
@@ -56,9 +70,8 @@ hooks(['vue', 'js']).exclude(({ filename }) => { | ||
}).plugin('babel').push() | ||
<%_ } _%> | ||
// Setup css to be processed by `css-require-extension-hook` | ||
css({}) | ||
<%_ if (!styles || !styles.length || !styles.includes('css')) { _%> | ||
// Setup mocking of static assets | ||
hooks([ | ||
'.css', | ||
'.png', | ||
@@ -72,4 +85,19 @@ '.jpg', | ||
]).push(() => '') | ||
<%_ } _%> | ||
<%_ if (styles && styles.includes('css')) { _%> | ||
// Setup mocking of static assets | ||
hooks([ | ||
'.png', | ||
'.jpg', | ||
'.jpeg', | ||
'.woff', | ||
'.ico', | ||
'.ico', | ||
'.svg' | ||
]).push(() => '') | ||
<%_ if (uiFramework === 'Vuetify') { _%> | ||
// Setup css to be processed by `css-require-extension-hook` | ||
css({}) | ||
<%_ } _%> | ||
<%_ if (styles && styles.includes('stylus')) { _%> | ||
// Setup styl files to be processed by `css-require-extension-hook` | ||
@@ -82,5 +110,5 @@ css({ | ||
}) | ||
<%_ } _%> | ||
require('vuetify/src/stylus/app.styl') | ||
<%_ if (uiFramework === 'Vuetify') { _%> | ||
Vue.use(Vuetify, { | ||
@@ -87,0 +115,0 @@ iconfont: 'md' |
<%_ if (!hasTS) { _%> | ||
<%_ if (hasBabel) { _%> | ||
import test from 'ava' | ||
@@ -20,1 +21,21 @@ import { shallowMount } from '@vue/test-utils' | ||
<%_ } _%> | ||
<%_ if (!hasBabel) { _%> | ||
const test = require('ava') | ||
const { shallowMount } = require('@vue/test-utils') | ||
<%_ if (!rootOptions.bare) { _%> | ||
const HelloWorld = require('../../src/components/HelloWorld.vue') | ||
test('HelloWorld.vue should render', t => { | ||
const wrapper = shallowMount(HelloWorld) | ||
t.is(wrapper.constructor.name, 'VueWrapper') | ||
}) | ||
<%_ } else { _%> | ||
import App from '@/App.vue' | ||
test('App should render', t => { | ||
const wrapper = shallowMount(App) | ||
t.is(wrapper.constructor.name, 'VueWrapper') | ||
}) | ||
<%_ } _%> | ||
<%_ } _%> | ||
<%_ } _%> |
{ | ||
"name": "@dnlup/vue-cli-plugin-unit-ava", | ||
"version": "1.0.0-beta.7", | ||
"version": "1.0.0-rc.1", | ||
"description": "@vue/cli plugin to run unit tests with ava", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "ava", | ||
"test": "nyc --reporter=lcov --reporter=text-summary ava", | ||
"lint": "eslint ./ --fix", | ||
"cz": "git-cz", | ||
"release": "standard-version", | ||
"gh:release": "conventional-github-releaser -p angular" | ||
"release": "HUSKY_SKIP_HOOKS=1 standard-version", | ||
"postrelease": "git push --follow-tags origin master && conventional-github-releaser -p angular" | ||
}, | ||
@@ -19,3 +18,5 @@ "keywords": [ | ||
"vue-cli-plugin", | ||
"@vue/cli" | ||
"@vue/cli", | ||
"vuejs", | ||
"testing" | ||
], | ||
@@ -42,23 +43,25 @@ "repository": { | ||
"devDependencies": { | ||
"@vue/cli": "^3.7.0", | ||
"@vue/cli-service": "^3.7.0", | ||
"@vue/cli-test-utils": "^3.5.1", | ||
"@vue/babel-preset-app": "^3.8.0", | ||
"@vue/cli": "^3.8.4", | ||
"@vue/cli-service": "^3.8.4", | ||
"@vue/cli-test-utils": "^3.8.0", | ||
"@vue/test-utils": "^1.0.0-beta.29", | ||
"ava": "^1.4.1", | ||
"ava": "^2.1.0", | ||
"babel-plugin-module-resolver": "^3.2.0", | ||
"browser-env": "^3.2.6", | ||
"commitizen": "^3.1.1", | ||
"conventional-github-releaser": "^3.1.2", | ||
"conventional-github-releaser": "^3.1.3", | ||
"css-modules-require-hook": "^4.2.3", | ||
"cz-conventional-changelog": "^2.1.0", | ||
"eslint": "^5.15.1", | ||
"eslint": "^6.0.1", | ||
"eslint-config-standard": "^12.0.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"eslint-plugin-node": "^9.0.1", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-import": "^2.18.0", | ||
"eslint-plugin-node": "^9.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"husky": "^2.3.0", | ||
"husky": "^3.0.4", | ||
"is-ci": "^2.0.0", | ||
"lint-staged": "^8.1.5", | ||
"nanoid": "^2.0.2", | ||
"lint-staged": "^8.2.1", | ||
"nanoid": "^2.0.3", | ||
"nyc": "^14.1.1", | ||
"require-extension-hooks": "^0.3.3", | ||
@@ -70,3 +73,3 @@ "require-extension-hooks-babel": "^1.0.0", | ||
"stylus": "^0.54.5", | ||
"ts-node": "^8.1.0", | ||
"ts-node": "^8.3.0", | ||
"tsconfig-paths": "^3.8.0", | ||
@@ -77,2 +80,3 @@ "vue-cli-plugin-vuetify": "^0.5.0" | ||
"hooks": { | ||
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true", | ||
"pre-commit": "lint-staged" | ||
@@ -79,0 +83,0 @@ } |
@@ -21,17 +21,13 @@ module.exports = [ | ||
default: 'No' | ||
}, | ||
{ | ||
name: 'styles', | ||
type: 'checkbox', | ||
message: 'Select the type of style files you would like to load, if any', | ||
choices: [ | ||
'css', | ||
'stylus' | ||
], | ||
default: [] | ||
} | ||
// TODO: Manage style processors options | ||
// { | ||
// name: 'cssProcessors', | ||
// type: 'list', | ||
// message: 'Do you want to use a CSS processor', | ||
// choices: [ | ||
// 'No', | ||
// 'Sass', | ||
// 'Less', | ||
// 'Stylus' | ||
// ], | ||
// default: 'No', | ||
// when: ({ uiFramework }) => uiFramework === 'No' | ||
// } | ||
] |
@@ -0,1 +1,2 @@ | ||
[![npm version](https://badge.fury.io/js/%40dnlup%2Fvue-cli-plugin-unit-ava.svg)](https://badge.fury.io/js/%40dnlup%2Fvue-cli-plugin-unit-ava) | ||
[![Build Status](https://travis-ci.com/dnlup/vue-cli-plugin-unit-ava.svg?token=zu3SxXGFaq3y1hcTQfC6&branch=master)](https://travis-ci.com/dnlup/vue-cli-plugin-unit-ava) [![Greenkeeper badge](https://badges.greenkeeper.io/dnlup/vue-cli-plugin-unit-ava.svg?token=afd39f2e241ccb41748b27d5b16c32d4a8922b23319dbd178352c5a12aa4c967&ts=1552668377939)](https://greenkeeper.io/) | ||
@@ -62,5 +63,10 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/24a9748c22097d1f5cf8/maintainability)](https://codeclimate.com/github/dnlup/vue-cli-plugin-unit-ava/maintainability) | ||
![prompt_3](./assets/prompt_3.png) | ||
Will ask if you want to add style loaders. | ||
### Contributing | ||
* Make your changes | ||
* Test them with `npm test` | ||
* Add them | ||
@@ -72,3 +78,7 @@ ```bash | ||
```bash | ||
$ npm run cz | ||
$ git commit | ||
``` | ||
#### Note | ||
Tests now are a bit heavy because I am actually creating a considerable amount of projects in parallel to test different configurations. | ||
All configurations cannot be tested, it would be too expensive. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
425784
28
1196
83
32
2