Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

license-report

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

license-report - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

defaultHtmlStyle.css

13

lib/config.js
var rc = require('rc')
var path = require('path')

@@ -8,3 +9,3 @@ var config = module.exports = rc('license-report', {

json || table || csv
json || table || csv || html
*/

@@ -14,2 +15,12 @@ output: 'json',

/*
if output is html
*/
html: {
cssFile: path.resolve(__dirname, '..', 'defaultHtmlStyle.css'),
// passed directly to tableify (see: https://github.com/kessler/node-tableify)
tableify: {}
},
/*
if output is csv

@@ -16,0 +27,0 @@ */

const _ = require('lodash')
const table = require('text-table')
const tableify = require('@kessler/tableify')
const fs = require('fs')

@@ -63,2 +65,12 @@ module.exports = getFormatter

/**
* Formats package information as html.
* @param dataAsArray - array of objects with information about dependencies / devdependencies in package.json
* @param config - global configuration object
* @returns dataAsArray formatted as html
*/
function formatAsHTML(dataAsArray, config) {
return tableify.htmlDoc(dataAsArray, config.html.tableify, fs.readFileSync(config.html.cssFile))
}
/**
* Gets the formatter function for the style given.

@@ -84,2 +96,5 @@ * Allowed styles: 'json', 'table', 'csc'.

break
case 'html':
formatter = formatAsHTML
break
default:

@@ -86,0 +101,0 @@ throw new Error('invalid output format in config')

3

package.json
{
"name": "license-report",
"version": "4.2.0",
"version": "4.3.0",
"description": "creates a short report about project's dependencies (license, url etc)",

@@ -23,2 +23,3 @@ "main": "index.js",

"dependencies": {
"@kessler/tableify": "^1.0.2",
"async": "^3.2.0",

@@ -25,0 +26,0 @@ "debug": "^4.1.1",

@@ -10,3 +10,4 @@ # license report tool

### usage
simple:
#### simple:
```

@@ -24,19 +25,24 @@ cd your/project/

```
explicit package.json:
#### explicit package.json:
```
license-report --package=/path/to/package.json
```
customize a field's label:
#### customize a field's label:
```
license-report --report.label.department=division
```
customize a default value (only applicable for some fields):
#### customize a default value (only applicable for some fields):
```
license-report --department.label=division --department.value=ninjaSquad
```
another registry:
#### another registry:
```
license-report --registry=https://myregistry.com/
```
different outputs:
#### different outputs:
```

@@ -46,2 +52,3 @@ license-report --output=table

license-report --output=csv
license-report --output=html

@@ -53,4 +60,11 @@ # replace default ',' separator with something else

license-report --output=csv --csvHeaders
# use custom stylesheet for html output
license-report --output=html --html.cssFile=/a/b/c.css
# see the output immediately in your browser, use hcat (npm i -g hcat)
license-report --output=html | hcat
```
exclude:
#### exclude:
```

@@ -60,4 +74,24 @@ license-report --exclude=async --exclude=rc

### screenshots
![screenshot](screenshot.png)
![screenshot1](html.png)
### available fields
Fields with data of the installed packages:
| fieldname | column title | data source |
|---|---|---|
| name | name | name of the package |
| licenseType | license type | type of the license of the package (e.g. MIT) |
| link | link | link to the repository of the package |
| comment | comment | latest available version of the package (can be different from the installed version) |
Fields with data set in the configuration of license-report:
| fieldname | column title | set value |
|--|---|---|
| department | department | --department.value=kessler |
| relatedTo | related to | --relatedTo.value=stuff |
| licensePeriod | license period | --licensePeriod.value=perpetual |
| material | material / not material | --material.value=material |
### debug

@@ -72,5 +106,2 @@ ```

### TODO
Requires a serious refactor!
![ironSource logo](ironsource.png)

@@ -5,2 +5,3 @@ var cp = require('child_process')

var assert = require('assert')
var fs = require('fs')

@@ -22,3 +23,3 @@ var scriptPath = path

var result = JSON.parse(stdout)
assert.deepStrictEqual(result, EXPECTED_JSON_RESULT)

@@ -56,5 +57,31 @@ done()

})
it('produce an html report', function(done) {
this.timeout(50000)
cp.exec('node ' + scriptPath + ' --output=html', function(err, stdout, stderr) {
if (err) {
console.error(stderr)
return done(err)
}
assert.strictEqual(stdout, fs.readFileSync(path.join(__dirname, 'expectedOutput.html'), 'utf8'))
done()
})
})
})
var EXPECTED_JSON_RESULT = [{
author: 'Dan VerWeire, Yaniv Kessler',
comment: '1.0.2',
department: 'kessler',
installedVersion: '1.0.2',
licensePeriod: 'perpetual',
licenseType: 'MIT',
link: 'git+https://github.com/kessler/node-tableify.git',
material: 'material',
name: '@kessler/tableify',
relatedTo: 'stuff'
},
{
author: 'Caolan McMahon',

@@ -194,2 +221,3 @@ department: 'kessler',

---------- ---------- ---- -------------- ----------------------- ------------ ---- ------- ----------------- ------
kessler stuff @kessler/tableify perpetual material MIT git+https://github.com/kessler/node-tableify.git 1.0.2 1.0.2 Dan VerWeire, Yaniv Kessler
kessler stuff async perpetual material MIT git+https://github.com/caolan/async.git 3.2.0 3.2.0 Caolan McMahon

@@ -210,2 +238,3 @@ kessler stuff debug perpetual material MIT git://github.com/visionmedia/debug.git 4.3.0 4.1.1 TJ Holowaychuk

var EXPECTED_CSV_RESULT = `department,relatedTo,name,licensePeriod,material,licenseType,link,comment,installedVersion,author
kessler,stuff,@kessler/tableify,perpetual,material,MIT,git+https://github.com/kessler/node-tableify.git,1.0.2,1.0.2,Dan VerWeire, Yaniv Kessler
kessler,stuff,async,perpetual,material,MIT,git+https://github.com/caolan/async.git,3.2.0,3.2.0,Caolan McMahon

@@ -222,2 +251,2 @@ kessler,stuff,debug,perpetual,material,MIT,git://github.com/visionmedia/debug.git,4.3.0,4.1.1,TJ Holowaychuk

kessler,stuff,mocha,perpetual,material,MIT,git+https://github.com/mochajs/mocha.git,8.1.3,8.1.3,TJ Holowaychuk
`;
`;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc