Skip to content

Commit

Permalink
Improving documentation + general improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ollelauribostrom committed Sep 7, 2018
1 parent 5248e16 commit d7e0e71
Show file tree
Hide file tree
Showing 8 changed files with 685 additions and 8,615 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ npm-debug.log

# Coverage directory
coverage
.nyc_output
.coveralls.yml

# Dependency directories
node_modules
Expand Down
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
src
test
.idea
hindex-*.tgz
.github
.babelrc
.editorconfig
.eslintrc.js
.npmignore
.travis.yml
158 changes: 156 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,159 @@
# hindex (WIP)
Generate a index.html listing all subdirectories containing index.html files - The perfect wrapper for coverage reports
# hindex 🗂
[![Build Status](https://travis-ci.org/ollelauribostrom/hindex.svg?branch=master)](https://travis-ci.org/ollelauribostrom/hindex) [![Coverage Status](https://coveralls.io/repos/github/ollelauribostrom/hindex/badge.svg?branch=master)](https://coveralls.io/github/ollelauribostrom/hindex?branch=master) [![Known Vulnerabilities](https://snyk.io/test/github/ollelauribostrom/hindex/badge.svg?targetFile=package.json)](https://snyk.io/test/github/ollelauribostrom/hindex?targetFile=package.json) [![npm version](https://badge.fury.io/js/%40ollelauribostrom%2Fhindex.svg)](https://badge.fury.io/js/%40ollelauribostrom%2Fhindex)

_TODO_

Installation
-------
`yarn add hindex` _or_
`yarn global add hindex` _or_
`npm install hindex` _or_
`npm install hindex -g`

Configuration
-------------
Before you can use **hindex**, you need to create a configuration file called `hindex.config.json` in the root of your project. The following options are available.

| Option | Description | Type | Default |
| ------------------|-------------------------------------------------------| ---------|--------------------|
| baseDir | The folder containing the subfolders you want to wrap | String | `process.cwd() ` |
| exclude | Array of subfolder you want to exclude when wrapping | Array | `['.git'] ` |
| categories | Array of categories to create | Array | `[] ` |
| title | The title used in the generated index.html | String | `'hindex' ` |
| categoryPrefix | Category name prefix to remove | String | `'' ` |
| categoryPostfix | Category name postfix to remove | String | `'' ` |
| hideCategoryNames | Remove category names in the generated index.html | Boolean | `false ` |

#### Example `hindex.config.json`
```json
{
"baseDir": "./reports",
"exclude": ["some-folder", ".git"],
"categories": ["coverage"],
"title": "Coverage reports",
"categoryPostfix": "-",
"hideCategoryNames": true
}
```

Usage
-----
> NOTE: Make sure you have a configuration file called `hindex.config.json` in the root of your project.
### From the command line
A global installation of **hindex** can be used directly from the command line.
```sh
# Generate index.html wrapper
hindex

# Print version
hindex -v
hindex --version
```

### From your package.json
A local installation of **hindex** can be used from your project's `package.json`.
```json
"scripts": {
"hindex": "hindex"
},
```
```sh
yarn hindex
```

### From your code
It's also possible to import **hindex** in your code. The hindex function takes an optional object with the properties described in the [Configuration section](https://github.com/ollelauribostrom/hindex#configuration)
```js
import hindex from '@ollelauribostrom/hindex';

const config = {
baseDir: '/reports'
title: 'Reports',
categories: ['coverage', 'webpack']
};

const result = hindex(config);
// result.dir => reports
// result.index => file:///some/path/reports/index.html
```

Example
-------
This package was originally created to quickly be able to wrap and present different reports that where generated during my [Google Summer of Code project at Mozilla](https://summerofcode.withgoogle.com/projects/#6051875044982784).

#### Setup
Each generated report was copied in to a seperate git repo resulting in the following folder structure.
```sh
.
├── .git
├── coverage-2018-05-12
├── coverage-2018-05-27
├── mutation-2018-05-14
├── mutation-2018-05-27
├── webpack-stats-2018-05-31
├── hindex.config.json
├── package.json
```

#### Installation
hindex was locally installed and added as an npm script.
```json
"scripts": {
"hindex": "hindex"
},
```

#### Config
hindex was configured in the following way.
```json
{
"exclude": [".git"],
"categories": ["coverage", "mutation", "webpack-stats"],
"title": "Reports"
}
```

#### Wrapping
Each time a new report folder was added, a new wrapping index.html could quickly be generated.
```
yarn hindex
```

#### Result
[Live example](https://ollelauribostrom.github.io/gsoc/)
![Example](example.png)


Running your own local development copy
---------------------------------------
```sh
# Install dependencies
yarn

# Create a symbolic link
yarn link

# Start babel in watch mode
yarn start

# Run your development copy
hindex
```

Running the tests
-----------------
`yarn test`
`yarn coverage`
`yarn lint`

Contributing
------------
All contributions are very much welcome. Please get familiar with the [contributing guide](https://github.com/ollelauribostrom/hindex/blob/master/.github/CONTRIBUTING.md).

Support
-------
Please [open an issue](https://github.com/ollelauribostrom/hindex/issues/new) for support.

License
-------
Expand Down
Binary file added example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d7e0e71

Please sign in to comment.