@ callstack/ 许可证
API软件包,揭示Node.js项目中对许可证进行程序扫描的功能。 它被人们使用 license-kit CLI 工具并可以直接用于您的节点.js脚本.
特征
- 从您的项目依赖性中扫描和汇总许可证信息
- QQ 以选择的格式生成许可证报告( JSON, Markdown, 原始文本, AboutLibraries - 兼容的 JSON 元数据)
- 对直接依赖和过渡依赖的支持
安装
npm install @callstack/licenses
程序用途
你用得着 @callstack/licenses 在您的节点.js应用程序中。 以下是如何使用它的基本例子:
import {
Types,
generateAboutLibrariesNPMOutput,
generateLicensePlistNPMOutput,
renderLicenseExpression,
scanDependencies,
} from '@callstack/licenses';
import * as md from 'ts-markdown-builder';
// apart from dependencies, also include devDependencies, but only from the root package.json;
// also, include all transitive dependencies & optional dependencies
const optionsFactory: Types.ScanPackageOptionsFactory = ({ isRoot }) => ({
includeDevDependencies: isRoot,
includeTransitiveDependencies: true,
includeOptionalDependencies: true,
});
// scan dependencies of a package
const licenses = scanDependencies(packageJsonPath, optionsFactory);
// generate AboutLibraries-compatible JSON metadata
const aboutLibrariesCompatibleReport = generateAboutLibrariesNPMOutput(licenses);
// generate LicensePlist-compatible metadata
const licensePlistReport = generateLicensePlistNPMOutput(licenses, iosProjectPath);
// generate a Markdown report
const markdownString = md
.joinBlocks(
Object.entries(licenses)
.flatMap(([packageKey, { name: packageName, version, author, description, license, licenseFiles, url }]) => [
md.heading(packageName, { level: 2 }),
'\n',
`Version: ${version}<br/>\n`,
url ? `URL: ${url}<br/>\n` : '',
author ? `Author: ${author}<br/>\n\n` : '',
licenseFiles.map(({ licenseId, file, content }) => `${licenseId ?? file}:\n\n${content}`).join('\n\n'),
'\n',
description ? `Description: ${description}\n` : '',
`License: ${renderLicenseExpression(license)}`,
'\n',
md.horizontalRule,
])
.join('\n'),
)
.toString();
API 文档
API文件发表于: https://callstackincubator.github.io/反应-本土-法律-api/。 。 。 .
捐款
这个软件包被单体中的其他软件包通过它的构建输出来消耗,所以每次修改的时候,都需要重建软件包. 这可以通过运行完成 yarn build,或运行 yarn dev 要运行 tsc 在监视模式中。 所有这一切都在 贡献指南。 。 。 .