From c52059d98f792f097e8d57d8c44d4862b4ce1655 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Wed, 28 Dec 2016 13:47:56 +0900 Subject: [PATCH] :star: new: support covrage service selecting --- meta.js | 16 +++++++++++++--- template/README.md | 2 ++ template/circle.yml | 5 +++++ template/config/karma.cover.conf.js | 7 +++---- template/package.json | 11 +++++++---- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/meta.js b/meta.js index 46ad84c..7b8b622 100644 --- a/meta.js +++ b/meta.js @@ -41,9 +41,19 @@ module.exports = { type: 'confirm', message: 'Setup e2e tests?' }, - coveralls: { + coverage: { type: 'confirm', - message: 'Setup coveralls?' + message: 'Setup coverage services?' + }, + coverageConfig: { + when: 'coverage', + type: 'list', + message: 'Choice a coverage service', + choices: [ + 'coveralls', + 'codecov' + ], + default: ['codecov'] }, sauce: { type: 'confirm', @@ -102,7 +112,7 @@ module.exports = { "test/e2e/**/*": 'e2e', ".travis.yml": "ciConfig === 'travis'", "circl.yml": "ciConfig === 'circlci'", - "config/karma.coveralls.conf.js": 'coveralls', + "config/karma.coveralls.conf.js": "coverageConfig === 'coveralls'", ".flowconfig": 'flow', "decls/*": 'flow', "gitbook/**/**": 'gitbook', diff --git a/template/README.md b/template/README.md index 071732b..b4097c3 100644 --- a/template/README.md +++ b/template/README.md @@ -1,5 +1,7 @@ # {{ name }} +{{#if_eq coverageConfig "coveralls"}}[![Coverage Status](https://coveralls.io/repos/github/{{ githubAccount }}/{{ name }}/badge.svg?branch={{ branch }})](https://coveralls.io/github/{{ githubAccount }}/{{ name }}?branch={{ branch }}){{/if_eq}} +{{#if_eq coverageConfig "codecov"}}[![codecov](https://codecov.io/gh/{{ githubAccount }}/{{ name }}/branch/{{ branch }}/graph/badge.svg)](https://codecov.io/gh/{{ githubAccount }}/{{ branch }}){{/if_eq}} [![npm](https://img.shields.io/npm/v/{{ name }}.svg)](https://www.npmjs.com/package/{{ name }}) [![vue2](https://img.shields.io/badge/vue-2.x-brightgreen.svg)](https://vuejs.org/) diff --git a/template/circle.yml b/template/circle.yml index b00026e..b3bd800 100644 --- a/template/circle.yml +++ b/template/circle.yml @@ -1,3 +1,8 @@ machine: node: version: 6 +{{#if_eq coverageConfig "codecov"}} +test: + post: + - npm run coverage && bash <(curl -s https://codecov.io/bash) +{{/if_eq}} diff --git a/template/config/karma.cover.conf.js b/template/config/karma.cover.conf.js index 70d6b3c..c44cb11 100644 --- a/template/config/karma.cover.conf.js +++ b/template/config/karma.cover.conf.js @@ -5,10 +5,9 @@ module.exports = config => { browsers: ['PhantomJS'], reporters: ['mocha', 'coverage'], coverageReporter: { - reporters: [{ - type: 'lcov', dir: '../coverage' - }, { - type: 'text-summary', dir: '../coverage' + reporters: [ + { type: 'lcov', dir: '../coverage', subdir: '.' }, + { type: 'text-summary', dir: '../coverage', subdir: '.' } }] }, singleRun: true diff --git a/template/package.json b/template/package.json index 812d68f..fba91d6 100644 --- a/template/package.json +++ b/template/package.json @@ -42,9 +42,9 @@ "karma": "^1.1.0", "karma-chrome-launcher": "^2.0.0", "karma-coverage": "^1.0.0", - {{#coveralls}} + {{#if_eq coverageConfig "coveralls"}} "karma-coveralls": "^1.1.2", - {{/coveralls}} + {{/if_eq}} "karma-firefox-launcher": "^1.0.0", "karma-jasmine": "^1.0.2", "karma-mocha-reporter": "^2.0.4", @@ -109,6 +109,9 @@ "release": "conventional-github-releaser {{#unless_eq conventionalConfig "none"}}-p {{ conventionalConfig }}{{/unless_eq}}{{#if_eq conventionalConfig "none"}}-n ./config/convention.js{{/if_eq}}", {{/conventional}} "clean": "rm -rf coverage && rm -rf dist/*.js* && rm ./*.log", + {{#if_eq coverageConfig "codecov"}} + "coverage": "cat ./coverage/lcov.info", + {{/if_eq}} "dev": "webpack-dev-server --quiet --config config/webpack.dev.conf.js --host 0.0.0.0", {{#gitbook}} "docs": "gitbook serve ./gitbook ./docs", @@ -127,9 +130,9 @@ {{/sauce}} "test": "npm run lint && {{#flow}}npm run flow && {{/flow}}npm run test:cover{{#e2e}} && npm run test:e2e -- --env phantomjs{{/e2e}}", "test:cover": "karma start config/karma.cover.conf.js", - {{#coveralls}} + {{#if_eq coverageConfig "coveralls"}} "test:coveralls": "karma start config/karma.coveralls.conf.js", - {{/coveralls}} + {{/if_eq}} {{#e2e}} "test:e2e": "npm run build && node test/e2e/runner.js", {{/e2e}}