2.0.3 ā€¢ Published 5 years ago

@ollelauribostrom/hindex v2.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

hindex šŸ—‚

Build Status Coverage Status Known Vulnerabilities npm version

Wrap your reports in an index.html file with a single command using hindex. Subfolders containing different reports (with an index.html file) can quickly be linked together. Have a look at an example of how hindex was used to wrap and present reports during a Google Summer of Code project at Mozilla.

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. The following options are available.

OptionDescriptionTypeDefault
baseDirThe folder containing the subfolders you want to wrapStringprocess.cwd()
excludeArray of subfolder you want to exclude when wrappingArray['.git']
categoriesArray of categories to createArray[]
titleThe title used in the generated index.htmlString'hindex'
categoryPrefixCategory name prefix to removeString''
categoryPostfixCategory name postfix to removeString''
hideCategoryNamesRemove category names in the generated index.htmlBooleanfalse

Example hindex.config.json

{
  "baseDir": "./reports",
  "exclude": ["some-folder", ".git"],
  "categories": ["coverage"],
  "title": "Coverage reports",
  "categoryPostfix": "-",
  "hideCategoryNames": true
}

Usage

NOTE: Make sure you have created a configuration file called hindex.config.json.

From the command line

A global installation of hindex can be used directly from the command line.

# Generate index.html wrapper
hindex

# Specify a custom path to your hindex config
hindex -c=./config/hindex.config.json
hindex --config=./config/hindex.config.json

# Run in debug mode
hindex -d
hindex --debug

# Print version
hindex -v
hindex --version

From your package.json

A local installation of hindex can be used from your project's package.json.

"scripts": {
  "hindex": "hindex"
},
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

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.

Report folder structure

ā”œā”€ā”€ .git
ā”œā”€ā”€ coverage-2018-05-12
    ā”œā”€ā”€ index.html
ā”œā”€ā”€ mutation-2018-05-14
    ā”œā”€ā”€ index.html
ā”œā”€ā”€ webpack-stats-2018-05-31
    ā”œā”€ā”€ index.html
ā”œā”€ā”€ hindex.config.json
ā”œā”€ā”€ package.json

Setup

package.json

"scripts": {
  "hindex": "hindex"
},
...

hindex.config.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 Example

Running your own local development copy

# 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.

Support

Please open an issue for support.

License

MIT