diff --git a/.travis.yml b/.travis.yml index ab71292..c9c9848 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,4 @@ +sudo: false language: node_js node_js: - '6' -before_install: - - 'npm install -g npm@latest && npm install -g codeclimate-test-reporter' -addons: - code_climate: - repo_token: f0f565a1f5fdf857ec35c946f6b189e8f29bbffe22518341c67d9a5f2794c1a4 -after_install: - - 'npm run coverage && cat coverage/lcov.info | codeclimate-test-reporter' diff --git a/README.md b/README.md index 97c90e0..98b3e22 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,117 @@ -knock-knock -=========== -An npm module that returns basic information about the current project. +# knock-knock -[![NPM version](https://badge.fury.io/js/knock-knock.svg)](http://badge.fury.io/js/knock-knock) [![Build Status](https://travis-ci.org/onmodulus/knock-knock.svg?branch=master)](https://travis-ci.org/onmodulus/knock-knock) +> basic information about the current project and environment + +[![npm][npm-image]][npm-url] +[![travis][travis-image]][travis-url] +[![coverage][coverage-image]][coverage-url] +[![standard][standard-image]][standard-url] + +## Table of Contents + +- [Install](#install) +- [Usage](#usage) +- [Contribute](#contribute) +- [License](#license) ## Install -`npm install knock-knock` + + npm install knock-knock ## Usage -##### Without options -``` -const KnockKnock = require('knock-knock'); -KnockKnock(function (err, results) { - if (err) throw err; - console.log(results); -}); -``` +### `KnockKnock([commands], callback)` -Logs: -``` -{ - name: 'some-name', - version: '1.2.3', - env: 'production', - node: 'v4.2.1', - npm: '3.3.3' -} -``` +- **commands** `Object` (Optional) + values are a command to execute, a trimmed `stdout` or `stderr` will be yielded +- **callback** `Function` + `(err, result) => {}` -##### With options -``` -const KnockKnock = require('knock-knock'); +#### default result -KnockKnock({ docker: 'docker -v' }, function (err, results) { - if (err) throw err; - console.log(results); -}); -``` +| key | value +| --- | --- +| name | derived from `package.json` +| version | derived from `package.json` +| env | `process.env.NODE_ENV` +| node | `node -v` +| npm | `npm -v` -Logs: -``` -{ - name: 'some-name', - version: '1.2.3', - env: 'production', - node: 'v4.2.1', - npm: '3.3.3', - docker: 'Docker version 1.6.2, build 7c8fca2' -} +### Examples + +#### using defaults + +```js +const KnockKnock = require('knock-knock') + +KnockKnock((err, results) => { + if (err) throw err + console.log(results) + /** { + name: 'some-name', + version: '1.2.3', + env: 'production', + node: 'v6.10.1', + npm: '4.5.0' + } **/ +}) ``` -### Examples -##### Hapi +#### passing custom command + +```js +const KnockKnock = require('knock-knock') + +KnockKnock({ docker: 'docker -v' }, (err, results) => { + if (err) throw err + console.log(results) + // { docker: 'Docker version 17.03.1-ce, build c6d412e', ... } +}) ``` -const Hapi = require('hapi'); -const KnockKnock = require('knock-knock'); -var server = new Hapi.Server(); +#### hapi endpoint + +```js +const Hapi = require('hapi') +const KnockKnock = require('knock-knock') -function ping(request, reply) { - KnockKnock(reply); -} +const server = new Hapi.Server() + +const ping = (request, reply) => KnockKnock(reply) server.route([ { method: 'GET', path: '/ping', handler: ping } -]); +]) ``` -##### Express -``` -var express = require('express'); -var knockKnock = require('knock-knock'); +#### Express endpoint + +```js +const Express = require('express') +const KnockKnock = require('knock-knock') -var app = express(); +const app = Express() -app.get('/ping', function (req, res) { - knockKnock(function (err, output) { - res.send(err || output); - }); -}); +const ping = (req, res) => KnockKnock((err, output) => res.send(err || output)) + +app.get('/ping', ping) ``` + +## Contribute + +PRs welcome! Please read the [contributing guidelines](contributing.md) and +the [code of conduct](code-of-conduct.md). + +## License + +[MIT © Jack Boberg.](LICENSE) + +[npm-image]: https://img.shields.io/npm/v/knock-knock.svg?style=flat-square +[npm-url]: https://www.npmjs.com/package/knock-knock +[travis-image]: https://img.shields.io/travis/jackboberg/knock-knock.svg?style=flat-square +[travis-url]: https://travis-ci.com/jackboberg/knock-knock +[coverage-image]: https://img.shields.io/coveralls/jackboberg/knock-knock.svg?style=flat-square +[coverage-url]: https://coveralls.io/github/jackboberg/knock-knock +[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square +[standard-url]: http://npm.im/standard + diff --git a/code-of-conduct.md b/code-of-conduct.md new file mode 100644 index 0000000..34a25bf --- /dev/null +++ b/code-of-conduct.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at hello@jackboberg.info. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..9f8896d --- /dev/null +++ b/contributing.md @@ -0,0 +1,47 @@ +# Contributing Guidelines + + Contributions welcome! + +**Before spending lots of time on something, ask for feedback on your idea first!** + +Please search issues and pull requests before adding something new to avoid duplicating efforts and conversations. + +This project welcomes non-code contributions, too! The following types of contributions are welcome: + +- **Ideas**: participate in an issue thread or start your own to have your voice heard. +- **Writing**: contribute your expertise in an area by helping expand the included content. +- **Copy editing**: fix typos, clarify language, and generally improve the quality of the content. +- **Formatting**: help keep content easy to read with consistent formatting. + +## Code Style + +[![standard][standard-image]][standard-url] + +This repository uses [`standard`][standard-url] to maintain code style and consistency and avoid style arguments. `npm test` runs `standard` so you don't have to! + +[standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg +[standard-url]: https://github.com/feross/standard + +## Project Governance + +**This is an [OPEN Open Source Project](http://openopensource.org/).** + +Individuals making significant and valuable contributions are given commit access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. + +## Rules + +There are a few basic ground rules for collaborators: + +1. **No `--force` pushes** or modifying the Git history in any way. +1. **Non-master branches** ought to be used for ongoing work. +1. **External API changes and significant modifications** ought to be subject to an **internal pull request** to solicit feedback from other contributors. +1. Internal pull requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor. +1. Contributors should attempt to adhere to the prevailing code style. + +## Releases + +Declaring formal releases remains the prerogative of the project maintainer. + +## Changes to this arrangement + +This is an experiment and feedback is welcome! This document may also be subject to pull requests or changes by contributors where you believe you have something valuable to add or change.