diff --git a/.travis.yml b/.travis.yml index b5b6731..12a9870 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ sudo: false language: "node_js" node_js: - - "0.10" - - "0.12" - - "iojs" + - "6" + - "7" before_script: - npm install standard - standard diff --git a/README.md b/README.md index aeba964..278c18b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![NPM version](https://badge.fury.io/js/thought.svg)](http://badge.fury.io/js/thought) [![Travis Build Status](https://travis-ci.org/nknapp/thought.svg?branch=master)](https://travis-ci.org/nknapp/thought) [![Coverage Status](https://img.shields.io/coveralls/nknapp/thought.svg)](https://coveralls.io/r/nknapp/thought) - +[![Greenkeeper badge](https://badges.greenkeeper.io/nknapp/thought.svg)](https://greenkeeper.io/) > A customizable documentation generator for github projects @@ -171,6 +171,7 @@ has the structure. │ ├─┬ badge │ │ ├── appveyor.md.hbs │ │ ├── coveralls.md.hbs +│ │ ├── greenkeeper.md.hbs │ │ ├── npm.md.hbs │ │ └── travis.md.hbs │ ├── badges.md.hbs diff --git a/handlebars/helpers.js b/handlebars/helpers.js index f30bd5b..66b8d36 100644 --- a/handlebars/helpers.js +++ b/handlebars/helpers.js @@ -240,21 +240,7 @@ module.exports = { * @param options * @returns {string=} the repository path within github.com (or null) */ - githubRepo: function (options) { - var url = null - try { - url = options.data.root.package.repository.url - var match = url.match(/.*?(:\/\/|@)github\.com[/:](.*?)(#.*?)?$/) - if (match) { - return match[2].replace(/\.git$/, '') - } else { - return null - } - } catch (e) { - console.log('Cannot find repository url') - url = null - } - }, + githubRepo: githubRepo, /** * Create a link to the npm-package of a package @@ -290,6 +276,14 @@ module.exports = { } return false }) + }, + + 'hasGreenkeeper': function hasGreenkeeper (options) { + var slug = githubRepo(options) + return require('request-promise')(`https://badges.greenkeeper.io/${slug}.svg`) + .then(function (response) { + return require('cheerio')(response).find('text').last().text() !== 'not found' + }) } } @@ -405,3 +399,19 @@ function githubUrl (filePath) { return url.replace(/^git\+/, '').replace(/\.git$/, '') + '/blob/v' + version + '/' + relativePath } } + +function githubRepo (options) { + var url = null + try { + url = options.data.root.package.repository.url + var match = url.match(/.*?(:\/\/|@)github\.com[/:](.*?)(#.*?)?$/) + if (match) { + return match[2].replace(/\.git$/, '') + } else { + return null + } + } catch (e) { + console.log('Cannot find repository url') + url = null + } +} diff --git a/handlebars/partials/badge/coveralls.md.hbs b/handlebars/partials/badge/coveralls.md.hbs index 7294a2c..9a89bed 100644 --- a/handlebars/partials/badge/coveralls.md.hbs +++ b/handlebars/partials/badge/coveralls.md.hbs @@ -1,4 +1,4 @@ {{#if (hasCoveralls)~}} [![Coverage Status](https://img.shields.io/coveralls/{{githubRepo}}.svg)](https://coveralls.io/r/{{githubRepo}}) -{{/if}} +{{~/if}} diff --git a/handlebars/partials/badge/greenkeeper.md.hbs b/handlebars/partials/badge/greenkeeper.md.hbs new file mode 100644 index 0000000..9058fac --- /dev/null +++ b/handlebars/partials/badge/greenkeeper.md.hbs @@ -0,0 +1,3 @@ +{{#if (hasGreenkeeper)~}} +[![Greenkeeper badge](https://badges.greenkeeper.io/{{githubRepo}}.svg)](https://greenkeeper.io/) +{{/if}} diff --git a/handlebars/partials/badges.md.hbs b/handlebars/partials/badges.md.hbs index 2c9df4e..9e04ea2 100644 --- a/handlebars/partials/badges.md.hbs +++ b/handlebars/partials/badges.md.hbs @@ -1,4 +1,5 @@ {{>badge/npm.md}} {{>badge/travis.md}} {{>badge/appveyor.md}} -{{>badge/coveralls.md}} \ No newline at end of file +{{>badge/coveralls.md}} +{{>badge/greenkeeper.md}} diff --git a/package.json b/package.json index 8455ecc..ad388b1 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "dependencies": { "archy": "^1.0.0", + "cheerio": "^0.22.0", "commander": "^2.8.1", "customize": "^1.0.0", "customize-engine-handlebars": "^1.0.0", @@ -48,6 +49,8 @@ "multilang-apidocs": "^0.2.1", "q": "^1.4.1", "q-deep": "^1.0.1", + "request": "^2.79.0", + "request-promise": "^4.1.1", "semver": "^5.0.0", "simple-git": "^1.43.0", "stream-collect": "^1.3.0", diff --git a/test/fixtures/scenarios/simple-project/expected/README.md b/test/fixtures/scenarios/simple-project/expected/README.md index 97e8811..a0e1417 100644 --- a/test/fixtures/scenarios/simple-project/expected/README.md +++ b/test/fixtures/scenarios/simple-project/expected/README.md @@ -1,11 +1,10 @@ # simple-project [![NPM version](https://badge.fury.io/js/simple-project.svg)](http://badge.fury.io/js/simple-project) -[![Travis Build Status](https://travis-ci.org/.svg?branch=master)](https://travis-ci.org/) -[![Coverage Status](https://img.shields.io/coveralls/.svg)](https://coveralls.io/r/) +[![Travis Build Status](https://travis-ci.org/unit-test/simple-project.svg?branch=master)](https://travis-ci.org/unit-test/simple-project) +[![Coverage Status](https://img.shields.io/coveralls/unit-test/simple-project.svg)](https://coveralls.io/r/unit-test/simple-project) - -> +> A simple description # Installation diff --git a/test/fixtures/scenarios/simple-project/expected/package.json b/test/fixtures/scenarios/simple-project/expected/package.json index 20368e4..99fd730 100644 --- a/test/fixtures/scenarios/simple-project/expected/package.json +++ b/test/fixtures/scenarios/simple-project/expected/package.json @@ -1,11 +1,15 @@ { "name": "simple-project", "version": "1.0.0", - "description": "", + "description": "A simple description", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, + "repository": { + "type": "git", + "url": "https://github.com/unit-test/simple-project.git" + }, "author": "", "license": "ISC", "devDependencies": { diff --git a/test/fixtures/scenarios/simple-project/input/package.json b/test/fixtures/scenarios/simple-project/input/package.json index 20368e4..99fd730 100644 --- a/test/fixtures/scenarios/simple-project/input/package.json +++ b/test/fixtures/scenarios/simple-project/input/package.json @@ -1,11 +1,15 @@ { "name": "simple-project", "version": "1.0.0", - "description": "", + "description": "A simple description", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, + "repository": { + "type": "git", + "url": "https://github.com/unit-test/simple-project.git" + }, "author": "", "license": "ISC", "devDependencies": { diff --git a/test/fixtures/scenarios/with-greenkeeper/expected/CONTRIBUTING.md b/test/fixtures/scenarios/with-greenkeeper/expected/CONTRIBUTING.md new file mode 100644 index 0000000..e259250 --- /dev/null +++ b/test/fixtures/scenarios/with-greenkeeper/expected/CONTRIBUTING.md @@ -0,0 +1,55 @@ +## Contributing + +Contributions and feedback are always welcome. The expected procedure is the following: + +### Bugs, Features and Feedback + +* Please, create github issues for **feature-requests**, **bug reports**. +* Feel free to open issues for **questions and problems you have**, even if they are not bugs + or feature requests. +* You may even open an issue just to say you like the project. +* For small changes, such as **typo and formatting corrections**, you can immediately + create a pull-request. You can use the github web-interface, but keep in mind that most of the documentation + is created with Thought, so you should change the template in the `.thought` directory or change the default + templates in [the thought project](https://github.com/nknapp/thought/tree/master/handlebars). +* If you have an idea for a **new feature** that you would like to implement, please **open an issue** first and ask + for feedback. Maybe someone else has a similar problem and different ideas. +* If you encounter a bug you can submit a **pull-request for a failing unit test**, you should then also open an issue + for the bug. +* Before making a pull-request, make sure that you commit corresponds to the coding-style. You can do this by + running `npm test`. + +**People submitting relevant contributions will be granted commit access to the repository.** + + +### Coding style + +[![standard][standard-image]][standard-url] + +This repository uses [`standard`][standard-url] to maintain code style and consistency, +and to avoid style arguments. You can run `npm run format` to apply the coding-style, but +you may need to fix some things manually. Make sure to use the latest version of `standard`. + + +### Installing & Testing + +You can fork and clone the repo from github. Run + +* Run `npm install` to install all the dependencies needed to build and run the project. +* Run `npm test` to run unit tests and validate the `standard` coding-style. + +It is intentional to don't have `standard`, `thought`, `istanbul` and `coveralls` in the devDependencies. +`standard` is a rather large package which you would not want to have copied into the `node_modules`-folder +of each of your projects. + +Instead, the `pretest`- and `preformat`-scripts ensure that `standard` and `thought` are installed globally. +If you are not allowed to install packages globally, please raise an issue, so that we can try to find a solution. + + +### About this text + +This text is part of the [Thought](https://github.com/nknapp/thought)-project. If you have any suggestions or wishes +to change the text, please raise an issue there for discussion. + +[standard-image]: https://cdn.rawgit.com/feross/standard/master/badge.svg +[standard-url]: https://github.com/feross/standard diff --git a/test/fixtures/scenarios/with-greenkeeper/expected/README.md b/test/fixtures/scenarios/with-greenkeeper/expected/README.md new file mode 100644 index 0000000..94e32a1 --- /dev/null +++ b/test/fixtures/scenarios/with-greenkeeper/expected/README.md @@ -0,0 +1,48 @@ +# simple-project + +[![NPM version](https://badge.fury.io/js/simple-project.svg)](http://badge.fury.io/js/simple-project) +[![Travis Build Status](https://travis-ci.org/bootprint/bootprint.svg?branch=master)](https://travis-ci.org/bootprint/bootprint) +[![Coverage Status](https://img.shields.io/coveralls/bootprint/bootprint.svg)](https://coveralls.io/r/bootprint/bootprint) +[![Greenkeeper badge](https://badges.greenkeeper.io/bootprint/bootprint.svg)](https://greenkeeper.io/) + +> + + +# Installation + +``` +npm install simple-project +``` + + +## API-reference + + + +## thought(options) +Execute Thought in the current directory + +**Kind**: global function +**Api**: public + +| Param | Type | Description | +| --- | --- | --- | +| options | object | | +| [options.cwd] | string | the working directory to use as project root | +| [options.addToGit] | boolean | add created files to git | + + + + +## License + +`simple-project` is published under the ISC-license. +See []() for details. + +## Release-Notes + +For release notes, see [CHANGELOG.md](CHANGELOG.md) + +## Contributing guidelines + +See [CONTRIBUTING.md](CONTRIBUTING.md). \ No newline at end of file diff --git a/test/fixtures/scenarios/with-greenkeeper/expected/package.json b/test/fixtures/scenarios/with-greenkeeper/expected/package.json new file mode 100644 index 0000000..0a3215d --- /dev/null +++ b/test/fixtures/scenarios/with-greenkeeper/expected/package.json @@ -0,0 +1,18 @@ +{ + "name": "simple-project", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/bootprint/bootprint.git" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "fs-walker": "^1.0.0" + } +} diff --git a/test/fixtures/scenarios/with-greenkeeper/input/package.json b/test/fixtures/scenarios/with-greenkeeper/input/package.json new file mode 100644 index 0000000..0a3215d --- /dev/null +++ b/test/fixtures/scenarios/with-greenkeeper/input/package.json @@ -0,0 +1,18 @@ +{ + "name": "simple-project", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/bootprint/bootprint.git" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "fs-walker": "^1.0.0" + } +} diff --git a/test/integration-test.js b/test/integration-test.js index 0c122c7..c9d68e2 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -67,6 +67,7 @@ function walk (baseDir, relativeDir, callback) { } describe('the integation test: ', function () { + this.timeout(10000) scenarios.forEach((scenario) => { describe(`In the scenario name "${scenario.name}",`, function () { before(function () {