From 8f2cc3b00c83e1a11ea00285046db909ac2f6a7e Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Fri, 17 Mar 2017 12:15:29 +0100 Subject: [PATCH] BREAKING: Do not resolve "directories"-property in preprocessor Prior to this commit, the files in the directories referenced in the directories-property of the package.json, would be read and included into an object structure. This is not necessary anymore, since there are now (for a long time already) promise-based helpers that can read files. --- handlebars/partials/license.md.hbs | 8 ++- handlebars/preprocessor.js | 13 ----- .../project-with-example/expected/README.md | 6 +- .../expected/CONTRIBUTING.md | 55 +++++++++++++++++++ .../project-with-license/expected/LICENSE.md | 1 + .../project-with-license/expected/README.md | 42 ++++++++++++++ .../expected/examples/example.js | 1 + .../project-with-license/expected/index.js | 7 +++ .../expected/package.json | 18 ++++++ .../project-with-license/input/LICENSE.md | 1 + .../input/examples/example.js | 1 + .../project-with-license/input/index.js | 7 +++ .../project-with-license/input/package.json | 18 ++++++ .../simple-project/expected/README.md | 6 +- .../with-greenkeeper/expected/README.md | 6 +- 15 files changed, 170 insertions(+), 20 deletions(-) create mode 100644 test/fixtures/scenarios/project-with-license/expected/CONTRIBUTING.md create mode 100644 test/fixtures/scenarios/project-with-license/expected/LICENSE.md create mode 100644 test/fixtures/scenarios/project-with-license/expected/README.md create mode 100644 test/fixtures/scenarios/project-with-license/expected/examples/example.js create mode 100644 test/fixtures/scenarios/project-with-license/expected/index.js create mode 100644 test/fixtures/scenarios/project-with-license/expected/package.json create mode 100644 test/fixtures/scenarios/project-with-license/input/LICENSE.md create mode 100644 test/fixtures/scenarios/project-with-license/input/examples/example.js create mode 100644 test/fixtures/scenarios/project-with-license/input/index.js create mode 100644 test/fixtures/scenarios/project-with-license/input/package.json diff --git a/handlebars/partials/license.md.hbs b/handlebars/partials/license.md.hbs index 30205e0..bf2b974 100644 --- a/handlebars/partials/license.md.hbs +++ b/handlebars/partials/license.md.hbs @@ -1,4 +1,10 @@ ## License -`{{{package.name}}}` is published under the {{{package.license}}}-license. +`{{{package.name}}}` is published under the {{{package.license}}}-license. + +{{#if licenseFile}} See [{{{licenseFile.filename}}}]({{{licenseFile.filename}}}) for details. +{{else}} +No file "LICENSE*" found +{{/if}} + diff --git a/handlebars/preprocessor.js b/handlebars/preprocessor.js index 59eab12..f3ae912 100644 --- a/handlebars/preprocessor.js +++ b/handlebars/preprocessor.js @@ -13,19 +13,6 @@ var debug = require('debug')('thought:preprocessor') */ module.exports = function (data) { data = _.cloneDeep(data) - var exampleDir = data.package.directories && data.package.directories.example - if (exampleDir) { - // Resolve - data.directories = qfs.list(exampleDir) - .then(function (list) { - return list.map(function (filename) { - return { - path: path.join(exampleDir, filename), - filename: filename - } - }) - }) - } // Detect license file and read contents debug('workingdir', data.workingDir) diff --git a/test/fixtures/scenarios/project-with-example/expected/README.md b/test/fixtures/scenarios/project-with-example/expected/README.md index aa799e1..9d195f6 100644 --- a/test/fixtures/scenarios/project-with-example/expected/README.md +++ b/test/fixtures/scenarios/project-with-example/expected/README.md @@ -31,8 +31,10 @@ This is the example output 123 ## License -`simple-project` is published under the ISC-license. -See []() for details. +`simple-project` is published under the ISC-license. + +No file "LICENSE*" found + ## Contributing guidelines diff --git a/test/fixtures/scenarios/project-with-license/expected/CONTRIBUTING.md b/test/fixtures/scenarios/project-with-license/expected/CONTRIBUTING.md new file mode 100644 index 0000000..e259250 --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/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/project-with-license/expected/LICENSE.md b/test/fixtures/scenarios/project-with-license/expected/LICENSE.md new file mode 100644 index 0000000..ed39d61 --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/expected/LICENSE.md @@ -0,0 +1 @@ +This is the license \ No newline at end of file diff --git a/test/fixtures/scenarios/project-with-license/expected/README.md b/test/fixtures/scenarios/project-with-license/expected/README.md new file mode 100644 index 0000000..6615fbb --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/expected/README.md @@ -0,0 +1,42 @@ +# simple-project + +[![NPM version](https://badge.fury.io/js/simple-project.svg)](http://badge.fury.io/js/simple-project) + + +> A simple description + + +# Installation + +``` +npm install simple-project +``` + + +## Usage + +The following example demonstrates how to use this module: + +```js +console.log("This is the example output 123") +``` + +This will generate the following output + +``` +This is the example output 123 +``` + + + +## License + +`simple-project` is published under the ISC-license. + +See [LICENSE.md](LICENSE.md) for details. + + + +## Contributing guidelines + +See [CONTRIBUTING.md](CONTRIBUTING.md). \ No newline at end of file diff --git a/test/fixtures/scenarios/project-with-license/expected/examples/example.js b/test/fixtures/scenarios/project-with-license/expected/examples/example.js new file mode 100644 index 0000000..973e16c --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/expected/examples/example.js @@ -0,0 +1 @@ +console.log("This is the example output 123") diff --git a/test/fixtures/scenarios/project-with-license/expected/index.js b/test/fixtures/scenarios/project-with-license/expected/index.js new file mode 100644 index 0000000..7d3c40d --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/expected/index.js @@ -0,0 +1,7 @@ +/** + * Beschreibung + * @param {string=} param + */ +function abc(param) { + +} diff --git a/test/fixtures/scenarios/project-with-license/expected/package.json b/test/fixtures/scenarios/project-with-license/expected/package.json new file mode 100644 index 0000000..c099d8c --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/expected/package.json @@ -0,0 +1,18 @@ +{ + "name": "simple-project", + "version": "1.0.0", + "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/project-with-example.git" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "fs-walker": "^1.0.0" + } +} diff --git a/test/fixtures/scenarios/project-with-license/input/LICENSE.md b/test/fixtures/scenarios/project-with-license/input/LICENSE.md new file mode 100644 index 0000000..ed39d61 --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/input/LICENSE.md @@ -0,0 +1 @@ +This is the license \ No newline at end of file diff --git a/test/fixtures/scenarios/project-with-license/input/examples/example.js b/test/fixtures/scenarios/project-with-license/input/examples/example.js new file mode 100644 index 0000000..973e16c --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/input/examples/example.js @@ -0,0 +1 @@ +console.log("This is the example output 123") diff --git a/test/fixtures/scenarios/project-with-license/input/index.js b/test/fixtures/scenarios/project-with-license/input/index.js new file mode 100644 index 0000000..7d3c40d --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/input/index.js @@ -0,0 +1,7 @@ +/** + * Beschreibung + * @param {string=} param + */ +function abc(param) { + +} diff --git a/test/fixtures/scenarios/project-with-license/input/package.json b/test/fixtures/scenarios/project-with-license/input/package.json new file mode 100644 index 0000000..c099d8c --- /dev/null +++ b/test/fixtures/scenarios/project-with-license/input/package.json @@ -0,0 +1,18 @@ +{ + "name": "simple-project", + "version": "1.0.0", + "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/project-with-example.git" + }, + "author": "", + "license": "ISC", + "devDependencies": { + "fs-walker": "^1.0.0" + } +} diff --git a/test/fixtures/scenarios/simple-project/expected/README.md b/test/fixtures/scenarios/simple-project/expected/README.md index 914019a..dc2feb5 100644 --- a/test/fixtures/scenarios/simple-project/expected/README.md +++ b/test/fixtures/scenarios/simple-project/expected/README.md @@ -17,8 +17,10 @@ npm install simple-project ## License -`simple-project` is published under the ISC-license. -See []() for details. +`simple-project` is published under the ISC-license. + +No file "LICENSE*" found + ## Contributing guidelines diff --git a/test/fixtures/scenarios/with-greenkeeper/expected/README.md b/test/fixtures/scenarios/with-greenkeeper/expected/README.md index 45db5e0..6421792 100644 --- a/test/fixtures/scenarios/with-greenkeeper/expected/README.md +++ b/test/fixtures/scenarios/with-greenkeeper/expected/README.md @@ -18,8 +18,10 @@ npm install simple-project ## License -`simple-project` is published under the ISC-license. -See []() for details. +`simple-project` is published under the ISC-license. + +No file "LICENSE*" found + ## Contributing guidelines