This repository has been archived by the owner on Nov 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 1225a73
Showing
12 changed files
with
391 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,80 @@ | ||
<!--@'# ' + package.name--> | ||
# mos-plugin-shields | ||
<!--/@--> | ||
|
||
<!--@'> ' + package.description--> | ||
> A mos plugin for creating markdown shields | ||
<!--/@--> | ||
<!--@shields.flatSquare('npm', 'travis', 'coveralls')--> | ||
[](https://www.npmjs.com/package/mos-plugin-shields) | ||
[](https://travis-ci.org/zkochan/mos-plugin-shields) | ||
[](https://coveralls.io/r/zkochan/mos-plugin-shields?branch=master) | ||
<!--/@--> | ||
|
||
<!--@installation()--> | ||
## Installation | ||
|
||
This module is installed via npm: | ||
|
||
``` sh | ||
npm install mos-plugin-shields --save | ||
``` | ||
<!--/@--> | ||
|
||
## Usage | ||
|
||
Add this code snippet to your `README.md` | ||
|
||
```md | ||
<!--@shields('travis', 'dependencies')--> | ||
<!--/@--> | ||
``` | ||
|
||
Run `mos` in the terminal. | ||
|
||
You'll get the travis and david shields in your readme via [shield.io](http://shields.io/). | ||
|
||
## API | ||
|
||
- `shields(...shields)` | ||
- `shields.flat(...shields)` | ||
- `shields.flatSquare(...shields)` | ||
- `shields.plastic(...shields)` | ||
|
||
The currently supported shields are: travis, coveralls, npm, deps, devDeps, peerDeps, gemnasium, climate. | ||
|
||
**NOTE:** The shields will be created for the master branch. | ||
|
||
<!--@license()--> | ||
## License | ||
|
||
[MIT](./LICENSE) © [Zoltan Kochan](http://kochan.io) | ||
<!--/@--> | ||
|
||
* * * | ||
|
||
<!--@dependencies({ shield: 'flat-square' })--> | ||
## Dependencies [](https://david-dm.org/zkochan/mos-plugin-shields/master) | ||
|
||
- [shields](https://github.com/kenany/shields): Generate shields for your current project's README | ||
|
||
<!--/@--> | ||
|
||
<!--@devDependencies({ shield: 'flat-square' })--> | ||
## Dev Dependencies [](https://david-dm.org/zkochan/mos-plugin-shields/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/zkochan/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,17 @@ | ||
'use strict' | ||
module.exports = plugin | ||
|
||
const createShieldsRenderer = require('./lib/create-shields-renderer') | ||
|
||
function plugin (markdown) { | ||
if (!markdown.repo || markdown.repo.host !== 'github.com') { | ||
throw new Error('The shields plugin only works for github repos') | ||
} | ||
|
||
return { | ||
shields: createShieldsRenderer({ | ||
github: markdown.repo, | ||
pkg: markdown.pkg, | ||
}), | ||
} | ||
} |
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,13 @@ | ||
'use strict' | ||
const describe = require('mocha').describe | ||
const it = require('mocha').it | ||
const expect = require('chai').expect | ||
|
||
const mosPluginShields = require('.') | ||
|
||
describe('mosPluginShields', () => { | ||
it('should throw error when package hosted not on GitHub', () => { | ||
expect(() => mosPluginShields({ repo: { host: 'gitlab' } })) | ||
.to.throw(Error, 'The shields plugin only works for github repos') | ||
}) | ||
}) |
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' | ||
const shielder = require('shields') | ||
|
||
const slice = Array.prototype.slice | ||
|
||
module.exports = opts => { | ||
const github = opts.github | ||
const pkg = opts.pkg | ||
|
||
const shields = styledShield('flat') | ||
shields.flat = styledShield('flat') | ||
shields.flatSquare = styledShield('flat-square') | ||
shields.plastic = styledShield('plastic') | ||
|
||
return shields | ||
|
||
function styledShield (style) { | ||
const getShieldProps = shielder({ style }) | ||
const shieldOpts = { | ||
repo: `${github.user}/${github.repo}`, | ||
npmName: pkg.name, | ||
branch: 'master', | ||
} | ||
return function () { | ||
const shields = slice.call(arguments) | ||
return shields | ||
.map(shieldName => { | ||
const shieldProps = getShieldProps(shieldName, shieldOpts) | ||
if (!shieldProps) { | ||
throw new Error('`' + shieldName + '` shield is not supported') | ||
} | ||
return shieldProps | ||
}) | ||
.map(renderShield) | ||
.join('\n') | ||
} | ||
} | ||
} | ||
|
||
function renderShield (shieldProps) { | ||
return `[](${shieldProps.link})` | ||
} |
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,89 @@ | ||
'use strict' | ||
const describe = require('mocha').describe | ||
const it = require('mocha').it | ||
const expect = require('chai').expect | ||
const createShieldsRenderer = require('./create-shields-renderer') | ||
|
||
describe('createShieldsRenderer', () => { | ||
it('should create flat shield by default', () => { | ||
const shields = createShieldsRenderer({ | ||
github: { | ||
user: 'zkochan', | ||
repo: 'mos', | ||
}, | ||
pkg: { | ||
name: 'mos', | ||
}, | ||
}) | ||
expect(shields('travis')).to.eq('[](https://travis-ci.org/zkochan/mos)') | ||
}) | ||
|
||
it('should create flat travis shield', () => { | ||
const shields = createShieldsRenderer({ | ||
github: { | ||
user: 'zkochan', | ||
repo: 'mos', | ||
}, | ||
pkg: { | ||
name: 'mos', | ||
}, | ||
}) | ||
expect(shields.flat('travis')).to.eq('[](https://travis-ci.org/zkochan/mos)') | ||
}) | ||
|
||
it('should create flat square travis shield', () => { | ||
const shields = createShieldsRenderer({ | ||
github: { | ||
user: 'zkochan', | ||
repo: 'mos', | ||
}, | ||
pkg: { | ||
name: 'mos', | ||
}, | ||
}) | ||
expect(shields.flatSquare('travis')).to.eq('[](https://travis-ci.org/zkochan/mos)') | ||
}) | ||
|
||
it('should create plastic travis shield', () => { | ||
const shields = createShieldsRenderer({ | ||
github: { | ||
user: 'zkochan', | ||
repo: 'mos', | ||
}, | ||
pkg: { | ||
name: 'mos', | ||
}, | ||
}) | ||
expect(shields.plastic('travis')).to.eq('[](https://travis-ci.org/zkochan/mos)') | ||
}) | ||
|
||
it('should create several shields', () => { | ||
const shields = createShieldsRenderer({ | ||
github: { | ||
user: 'zkochan', | ||
repo: 'mos', | ||
}, | ||
pkg: { | ||
name: 'mos', | ||
}, | ||
}) | ||
expect(shields.plastic('travis', 'npm')).to.eq([ | ||
'[](https://travis-ci.org/zkochan/mos)', | ||
'[](https://www.npmjs.com/package/mos)', | ||
].join('\n')) | ||
}) | ||
|
||
it('should throw exception if shield not supported', () => { | ||
const shields = createShieldsRenderer({ | ||
github: { | ||
user: 'zkochan', | ||
repo: 'mos', | ||
}, | ||
pkg: { | ||
name: 'mos', | ||
}, | ||
}) | ||
expect(() => shields('no-such-shield')) | ||
.to.throw(Error, '`no-such-shield` shield is not supported') | ||
}) | ||
}) |
Oops, something went wrong.