What is spdx-license-list?
The spdx-license-list npm package provides a list of SPDX license identifiers and their associated metadata. It is useful for validating, listing, and retrieving information about software licenses in a standardized format.
What are spdx-license-list's main functionalities?
List all SPDX license identifiers
This feature allows you to retrieve and list all available SPDX license identifiers. The code sample demonstrates how to import the package and log all license identifiers to the console.
const spdxLicenseList = require('spdx-license-list');
console.log(Object.keys(spdxLicenseList));
Get license details by identifier
This feature allows you to get detailed information about a specific license by its identifier. The code sample shows how to retrieve and log details for the 'MIT' license.
const spdxLicenseList = require('spdx-license-list');
const licenseDetails = spdxLicenseList['MIT'];
console.log(licenseDetails);
Check if a license identifier is valid
This feature allows you to check if a given license identifier is valid according to the SPDX license list. The code sample demonstrates how to check if 'MIT' is a valid license identifier.
const spdxLicenseList = require('spdx-license-list');
const isValid = 'MIT' in spdxLicenseList;
console.log(isValid);
Other packages similar to spdx-license-list
spdx-correct
The spdx-correct package helps correct common misspellings and variations of SPDX license identifiers. It is useful for ensuring that license identifiers conform to the SPDX standard, but it does not provide detailed license metadata like spdx-license-list.
spdx-expression-parse
The spdx-expression-parse package parses SPDX license expressions into a structured format. It is useful for analyzing complex license expressions, but it does not provide a list of licenses or their metadata like spdx-license-list.
spdx-satisfies
The spdx-satisfies package checks if a given license expression satisfies another license expression. It is useful for license compatibility checks, but it does not provide a list of licenses or their metadata like spdx-license-list.
spdx-license-list
List of SPDX licenses
The lists of licenses are just JSON files and can be used wherever.
Using SPDX License List version 3.3 (2018-10-24)
Install
$ npm install spdx-license-list
Usage
const fs = require('fs');
const spdxLicenseList = require('spdx-license-list');
console.log(spdxLicenseList.MIT);
const mitLicense = require('spdx-license-list/licenses/MIT');
console.log(mitLicense.licenseText);
You can also get a version with the licence text included:
const spdxLicenseList = require('spdx-license-list/full');
console.log(spdxLicenseList.MIT);
Or just the license IDs as a Set
:
const spdxLicenseList = require('spdx-license-list/simple');
console.log(spdxLicenseList);
API
spdxLicenseList
Type: Object
The licenses are indexed by their identifier and contains a name
property with the full name of the license, url
with the URL to the license, and osiApproved
boolean for whether the license is OSI Approved.
License
CC0-1.0