@eclipse-dash/nodejs-wrapper

中文文档
0.0.1发布于 2024/01/29EPL-2.0零依赖近 30 天下载 2.4万

Node.js wrapper for dash-licenses, that makes it easier to perform license checks for JS/TS Eclipse Foundation projects

原始使用文档
文档目录6 节
  1. Runtime requirements
  2. How to install and use
  3. configuration file
  4. Fine-tuning results: exclusions file
  5. GitHub workflow
  6. Acknowledgements

Eclipse dash-licenses nodejs-wrapper

This wrapper makes it easy to integrate and run the Eclipse Dash Licenses Tool in Eclipse Foundation project repositories, both locally and during CI on GitHub (i.e. on Pull Requests). Doing so is the best way to catch early, any 3PP components that has incompatible or have unclear licenses. Optionally, dash-licenses can be run in automatic IP review mode, to automatically create IP Check tickets, on the Eclipse Foundation Gitlab instance, one for each 3PP component that fails the check, for further scrutiny. These tickets can often be approved automatically in minutes.

Runtime requirements

  • called using bash
  • node.js is installed and node executable is in the path
  • on Linux (tested), probably works on mac and Windows using the Windows Subsystem for Linux (WSL)
  • to run dash-licenses: JDK or JRE 11 or later is installed and the java executable is in the path
  • to run dash-licenses in automatic review mode:
    • a PAT (Personal Access Token) generated on the Eclipse Foundation Gitlab by an Eclipse project committer
    • local run: the PAT needs to be set in environment variable DASH_TOKEN. e.g. export DASH_TOKEN=<PAT>
    • GitHub workflow run: the PAT needs to be set as a GitHub Secret, and then used in the GitHub workflow to define environment variable DASH_TOKEN. Note: GitHub secrets are not available for PRs that originate from a fork. This means that "automatic IP review mode" can't be used on GitHub for PRs from non-committers or PRs from committers that originate from a branch in their fork.

How to install and use

The npm package produced from this repository contains the dash-licenses-wrapper.js script that uses dash-licenses under-the-hood, an example GitHub workflow that uses the wrapper and some example configuration files.

To install this package as a "devDependency" in your project, use one of the following commands from the root of your project, according to the project's npm client:

# yarn:
# note: if prompted to do so, you may need to add option "--ignore-workspace-root-check"
yarn add @eclipse-dash/nodejs-wrapper --dev

# npm:
npm install @eclipse-dash/nodejs-wrapper --save-dev

Once installed, you can run a license check, from the repo root, with the following command:

  # using yarn lock file as input (default)
  npx dash-licenses-wrapper

  # using npm lock file as input
  npx dash-licenses-wrapper --inputFile=./package-lock.json

To get help about using the wrapper, do:

  npx dash-licenses-wrapper --help

Optionally you may add one or more scripts entries in the project's root package.json, that call the wrapper, with the wanted arguments. For example:

"scripts": {
  "license:check": "npm run dash-licenses-wrapper --inputFile=./package-lock.json",
  "license:check:review": "npm run dash-licenses-wrapper --inputFile=./package-lock.json --review --project=ecd.cdt-cloud",

It's possible to use a configuration file instead of adding all wanted options on the CLI or scripts entry. See section below for the details about configuration files.

npx dash-licenses-wrapper --configFile=./configs/license-check-config.json

configuration file

A configuration file can be used. Values defined therein will override wrapper defaults, and can themselves be overridden by CLI.

dashLicensesConfig.json:

{
    "project": "ecd.theia",
    "review": true,
    "inputFile": "./package-lock.json",
    "batch": "50",
    "timeout": "240",
    "exclusionsFile": "configs/license-check-exclusions.json",
    "summaryFile": "dash-licenses-summary.txt"
}

A configuration file can be used like so:

 npx dash-licenses-wrapper --configFile=configs/dashLicensesConfig.json

Fine-tuning results: exclusions file

dash-licenses is meant to help Eclipse Foundation projects manage the license aspect of their 3PPs, rather than being the absolute "arbitror of truth". As such, a project may want some dependencies, reported as requiring more scrutiny, to be momentarily "ignored". This means that dash-licenses will still process these but the wrapper will not count them as having failed the check. If only excluded 3PPs are reported by dash-licenses as requiring further scrutiny, the wrapper will return a success status code.

The exclusions file contains one dependency per line, with an optional comment, that can be used to track the justification for excluding the dependency, from failing the license check. This can be useful for example with dependencies that are under review but believed to have a compatible license.

{
  "<3PP as reported by dash-licenses>": "<comment>",
  "<another 3PP>": "<comment>"
}

Example scenario: an important Pull Request (PR) adds a 3PP dependency, whose license is believed by the project to be compatible, but for which dash-licenses disagrees (e.g. because of a low score). The dependency is submitted the IP team for further analysis but can't be automatically approved, quickly. In the meantime, to avoid delaying merging the important PR or merging and having the "License Check" CI job fail until the dependency is officially approved, it may be added to the exclusions file:

Let's say the project's exclusion file is configs/license-check-exclusions.json

The following entry is added: the first field is the 3PP as reported by dash-licenses and the second field is an optional comment, that can be used to track the reason for excluding the dependency from failing the license check. e.g.:

"npm/npmjs/-/<some dependency>/1.2.3": "We believe this dependency is license-compatible. Under review by the IP team to confirm: https://gitlab.eclipse.org/eclipsefdn/emo-team/iplab/-/issues/555555",

And then the wrapper can be called with CLI parameter --exclusions pointing to the exclusions file, like so:

npx dash-licenses-wrapper --inputFile=./package-lock.json --exclusions=configs/license-check-exclusions.json

Exclusion file: <repo_root>/dependency-check-baseline.json

GitHub workflow

An example workflow, that runs the license check, is provided in directory examples (by default under node_modules/@eclipse-dash/nodejs-wrapper/examples/license-check-workflow.yml). It can be copied to a GitHub project's directory <repo root>/.github/workflows and adapted for the given project.

If the project has added a scripts entry in the root package.json to run the license check, that may be used instead of npx dash-licenses-wrapper [...]. E.g. yarn license:check [...].

It can be very efficient to run dash-licenses in review mode during CI, to automatically create IP Check tickets, one for each 3PP component that fails the check. To do this, a committer (user with write access to the repo) needs to set a GitHub secret that contains an Eclipse Foundation Gitlab PAT, and use it in the workflow so that environment variable DASH_TOKEN is set with it. Note that for security reasons, GitHub only permits the secret to be used when the PR author is a committer. When that's not the case, the wrapper will fall-back to not using review mode, and IP tickets should be open manually, as needed.

Acknowledgements

This work is based on work contributed to the Eclipse Theia main git repository, by Ericsson and others. Mainly script check_3pp_licenses.js.

版本与发布记录

@eclipse-dash/nodejs-wrapper 共发布 1 个版本,首次发布于 2024/01/29;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.1latest2024/01/292 年前

关于 @eclipse-dash/nodejs-wrapper 的常见问题

@eclipse-dash/nodejs-wrapper 是什么?

Node.js wrapper for dash-licenses, that makes it easier to perform license checks for JS/TS Eclipse Foundation projects

如何安装 @eclipse-dash/nodejs-wrapper?

在项目目录运行 npm install @eclipse-dash/nodejs-wrapper,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 dash-licenses-wrapper,可以用 npx dash-licenses-wrapper 直接运行。

@eclipse-dash/nodejs-wrapper 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/eclipse-dash__nodejs-wrapper 是否存在。

@eclipse-dash/nodejs-wrapper 可以商用吗?

@eclipse-dash/nodejs-wrapper 使用 EPL-2.0 许可。声明的许可为 EPL-2.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@eclipse-dash/nodejs-wrapper 的下载量有多少?

根据 npm 官方下载统计,@eclipse-dash/nodejs-wrapper 在 2026/10/13 – 2026/11/11 这 30 天内被下载 23,890 次,日均约 796 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eclipse-dash/nodejs-wrapper 还在维护吗?

最新版本 0.0.1 发布于 2024/01/29(2 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/01/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。