-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0e5c1bb
Showing
12 changed files
with
408 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "standard", | ||
"rules": { | ||
"comma-dangle": [2, "always-multiline"], | ||
"arrow-parens": [2, "as-needed"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- v4 | ||
|
||
cache: | ||
directories: | ||
- node_modules | ||
|
||
before_install: | ||
- npm install -g npm@3 | ||
install: | ||
- npm install | ||
|
||
after_success: | ||
- npm run coveralls | ||
- npm run semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Zoltan Kochan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<!--@h1([pkg.name])--> | ||
# shieldman | ||
<!--/@--> | ||
|
||
<!--@blockquote([pkg.description])--> | ||
> Badges creator | ||
<!--/@--> | ||
<!--@shields.flatSquare('npm', 'travis', 'coveralls')--> | ||
[](https://www.npmjs.com/package/shieldman) [](https://travis-ci.org/zkochan/shieldman) [](https://coveralls.io/r/zkochan/shieldman?branch=master) | ||
<!--/@--> | ||
|
||
## Installation | ||
|
||
```sh | ||
npm i -S shieldman | ||
``` | ||
|
||
## Usage | ||
|
||
<!--@example('example.js')--> | ||
```js | ||
'use strict' | ||
const shieldman = require('shieldman') | ||
|
||
const shield = shieldman('travis', { repo: 'zkochan/shieldman' }) | ||
|
||
console.log(shield) | ||
//> { text: 'Build Status', | ||
// link: 'https://travis-ci.org/zkochan/shieldman', | ||
// image: 'https://img.shields.io/travis/zkochan/shieldman.svg' } | ||
``` | ||
<!--/@--> | ||
|
||
## API | ||
|
||
`shieldman(service, [opts])` | ||
|
||
- `service` is a _String_ representing the service for which the shield will | ||
be created. | ||
- `opts.style` is the style of the shield. The available styles are: flat (the | ||
default one), flat-square and plastic. | ||
- `opts.repo` is the GitHub repo targeted by the shield. For the current repo | ||
the value would be `KenanY/shields`. | ||
- `opts.branch` is the branch name for which the shield is created. | ||
- `opts.npmName` is the npm name of the package for which the shield is | ||
created. This value is currently required only by the `npm` shield. | ||
|
||
The `shieldman` function returns an _Object_ `obj` which has three keys: | ||
|
||
- `obj.image` is a _String_ link to the SVG of the shield for _String_ | ||
`service` | ||
- `obj.link` is a _String_ link to the project page of `repo` on the website | ||
of `service` | ||
- `obj.text` is a _String_ label for the `service` | ||
|
||
## License | ||
|
||
[MIT](./LICENSE) © [Zoltan Kochan](http://kochan.io) | ||
|
||
* * * | ||
|
||
<!--@dependencies({ shield: 'flat-square' })--> | ||
## <a name="dependencies">Dependencies</a> [](https://david-dm.org/zkochan/shieldman/master) | ||
|
||
None | ||
<!--/@--> | ||
|
||
<!--@devDependencies({ shield: 'flat-square' })--> | ||
## <a name="dev-dependencies">Dev Dependencies</a> [](https://david-dm.org/zkochan/shieldman/master#info=devDependencies) | ||
|
||
- [chai](https://github.com/chaijs/chai): BDD/TDD assertion library for node.js and the browser. Test framework agnostic. | ||
- [cz-conventional-changelog](https://github.com/commitizen/cz-conventional-changelog): Commitizen adapter following the conventional-changelog format. | ||
- [eslint](https://github.com/eslint/eslint): An AST-based pattern checker for JavaScript. | ||
- [eslint-config-standard](https://github.com/feross/eslint-config-standard): JavaScript Standard Style - ESLint Shareable Config | ||
- [eslint-plugin-promise](https://github.com/xjamundx/eslint-plugin-promise): Enforce best practices for JavaScript promises | ||
- [eslint-plugin-standard](https://github.com/xjamundx/eslint-plugin-standard): ESlint Plugin for the Standard Linter | ||
- [ghooks](https://github.com/gtramontina/ghooks): Simple git hooks | ||
- [istanbul](https://github.com/gotwarlost/istanbul): Yet another JS code coverage tool that computes statement, line, function and branch coverage with module loader hooks to transparently add coverage when running tests. Supports all JS coverage use cases including unit tests, server side functional tests | ||
- [mocha](https://github.com/mochajs/mocha): simple, flexible, fun test framework | ||
- [mos](https://github.com/mosjs/mos): A pluggable module that injects content into your markdown files via hidden JavaScript snippets | ||
- [semantic-release](https://github.com/semantic-release/semantic-release): automated semver compliant package publishing | ||
- [validate-commit-msg](https://github.com/kentcdodds/validate-commit-msg): Script to validate a commit message follows the conventional changelog standard | ||
|
||
<!--/@--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict' | ||
const shieldman = require('.') | ||
|
||
const shield = shieldman('travis', { repo: 'zkochan/shieldman' }) | ||
|
||
console.log(shield) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict' | ||
module.exports = shieldman | ||
|
||
const shieldsList = require('./lib/shields-list') | ||
|
||
function shieldman (service, opts) { | ||
if (!service) { | ||
throw new TypeError('`service` is required') | ||
} | ||
|
||
opts = opts || {} | ||
|
||
const ext = opts.ext || 'svg' | ||
|
||
const shieldTemplate = shieldsList[service.toLowerCase()] | ||
|
||
if (!shieldTemplate) { | ||
return undefined | ||
} | ||
|
||
if (!shieldTemplate.hasBranchVersion) { | ||
delete opts.branch | ||
} | ||
|
||
const linkTemplate = opts.branch && shieldTemplate.branchLink || shieldTemplate.link | ||
|
||
return { | ||
text: shieldTemplate.text, | ||
link: format(linkTemplate, opts), | ||
image: getShieldImage(shieldTemplate.path), | ||
} | ||
|
||
function getShieldImage (imagePath) { | ||
const branchSuffix = opts.branch && ('/' + opts.branch) || '' | ||
return `https://img.shields.io/${format(imagePath, opts)}` + | ||
`${branchSuffix}.${ext}${opts.style ? `?style=${opts.style}` : ''}` | ||
} | ||
} | ||
|
||
function format (str, params) { | ||
return str.replace(/{([^{}]+)}/g, (str, match) => params[match]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
'use strict' | ||
const describe = require('mocha').describe | ||
const it = require('mocha').it | ||
const expect = require('chai').expect | ||
|
||
const shieldman = require('.') | ||
|
||
describe('shieldman', () => { | ||
it('travis', () => { | ||
const shield = shieldman('travis', { | ||
repo: 'zkochan/shieldman', | ||
}) | ||
expect(shield).to.eql({ | ||
text: 'Build Status', | ||
image: 'https://img.shields.io/travis/zkochan/shieldman.svg', | ||
link: 'https://travis-ci.org/zkochan/shieldman', | ||
}) | ||
}) | ||
|
||
it('coveralls for branch', () => { | ||
const shield = shieldman('coveralls', { | ||
repo: 'zkochan/shieldman', | ||
branch: 'dev', | ||
}) | ||
expect(shield).to.eql({ | ||
text: 'Coverage Status', | ||
image: 'https://img.shields.io/coveralls/zkochan/shieldman/dev.svg', | ||
link: 'https://coveralls.io/r/zkochan/shieldman?branch=dev', | ||
}) | ||
}) | ||
|
||
it('standard shield when branch shield not supported', () => { | ||
const shield = shieldman('npm', { | ||
npmName: 'shieldman', | ||
branch: 'dev', | ||
}) | ||
expect(shield).to.eql({ | ||
text: 'npm version', | ||
image: 'https://img.shields.io/npm/v/shieldman.svg', | ||
link: 'https://www.npmjs.com/package/shieldman', | ||
}) | ||
}) | ||
|
||
it('flat square styled travis', () => { | ||
const shield = shieldman('travis', { | ||
style: 'flat-square', | ||
repo: 'zkochan/shieldman', | ||
}) | ||
expect(shield).to.eql({ | ||
text: 'Build Status', | ||
image: 'https://img.shields.io/travis/zkochan/shieldman.svg?style=flat-square', | ||
link: 'https://travis-ci.org/zkochan/shieldman', | ||
}) | ||
}) | ||
|
||
it('gemnasium', () => { | ||
const shield = shieldman('gemnasium', { | ||
repo: 'zkochan/shieldman', | ||
}) | ||
expect(shield).to.eql({ | ||
text: 'Gemnasium', | ||
image: 'https://img.shields.io/gemnasium/zkochan/shieldman.svg', | ||
link: 'https://gemnasium.com/zkochan/shieldman', | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
npm: { | ||
text: 'npm version', | ||
path: 'npm/v/{npmName}', | ||
link: 'https://www.npmjs.com/package/{npmName}', | ||
}, | ||
travis: { | ||
text: 'Build Status', | ||
path: 'travis/{repo}', | ||
link: 'https://travis-ci.org/{repo}', | ||
hasBranchVersion: true, | ||
}, | ||
coveralls: { | ||
text: 'Coverage Status', | ||
path: 'coveralls/{repo}', | ||
link: 'https://coveralls.io/r/{repo}?branch=master', | ||
branchLink: 'https://coveralls.io/r/{repo}?branch={branch}', | ||
hasBranchVersion: true, | ||
}, | ||
climate: { | ||
text: 'Code Climate', | ||
path: 'codeclimate/github/{repo}', | ||
link: 'https://codeclimate.com/github/{repo}', | ||
}, | ||
deps: { | ||
text: 'dependency status', | ||
path: 'david/{repo}', | ||
link: 'https://david-dm.org/{repo}', | ||
branchLink: 'https://david-dm.org/{repo}/{branch}', | ||
hasBranchVersion: true, | ||
}, | ||
devdeps: { | ||
text: 'devDependency status', | ||
path: 'david/dev/{repo}', | ||
link: 'https://david-dm.org/{repo}#info=devDependencies', | ||
branchLink: 'https://david-dm.org/{repo}/{branch}#info=devDependencies', | ||
hasBranchVersion: true, | ||
}, | ||
peerdeps: { | ||
text: 'peerDependency status', | ||
path: 'david/peer/{repo}', | ||
link: 'https://david-dm.org/{repo}#info=peerDependencies', | ||
branchLink: 'https://david-dm.org/{repo}/{branch}#info=peerDependencies', | ||
hasBranchVersion: true, | ||
}, | ||
gemnasium: { | ||
text: 'Gemnasium', | ||
path: 'gemnasium/{repo}', | ||
link: 'https://gemnasium.com/{repo}', | ||
}, | ||
gitter: { | ||
text: 'Gitter', | ||
path: 'gitter/room/{repo}', | ||
link: 'https://gitter.im/{repo}', | ||
}, | ||
} |
Oops, something went wrong.