Skip to content

Commit d6b855e

Browse files
authored
Merge pull request #7 from hzoo/patch-1
Create 0000-license-check.md
2 parents cfd70d3 + ca3af4b commit d6b855e

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

text/text/0000-license-check.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
- Start Date: 2016-10-12
2+
- RFC PR:
3+
- Yarn Issue:
4+
5+
# Summary
6+
7+
Original issue: https://github.com/yarnpkg/yarn/issues/904
8+
9+
From tweet: https://twitter.com/rstacruz/status/786052262841896960
10+
11+
Integrate a license checker as a yarn command.
12+
13+
> I have published a standalone package that does this: https://github.com/behance/license-to-fail
14+
15+
Yarn has `yarn licenses ls`. It would also be useful to know if certain packages
16+
don't satify your license (or other similar files) requirements rather than just a list of them.
17+
18+
```bash
19+
$ yarn licenses check
20+
yarn licenses v0.14.0
21+
Disallowed Licenses
22+
23+
│ ├─ License: not-allowed-license
24+
│ └─ URL: git+https://github.com/pkg/here.git
25+
# error
26+
```
27+
28+
# Motivation
29+
30+
Most apps/projects have certain assumptions about the kinds of dependencies they bring in.
31+
Even if you check each new dependency, the dependencies of those dependencies may have issues.
32+
There's isn't an easy/manual way to do this outside of checking the license of all dependencies.
33+
34+
It's most likely that there aren't issues but having an command to do so would allow running it on CI
35+
just like a linter. Issues can be caught automatically and with confidence.
36+
37+
This solves the problem of checking the license of a new dependency brought in through a new PR
38+
or of an existing package updating it's license (whether it's a direct dependency or indirect dependency).
39+
40+
The outcome is that users could run the command to notify which packages are disallowed.
41+
42+
# Detailed design
43+
44+
The basic idea is straightforward: Given an array of packages and their licenses, match that against an array of
45+
licenses that are disallowed. If any match, error and print them out.
46+
47+
It would be useful to have a way to make a list of exceptions for when you want to whitelist a properitary pacakage.
48+
49+
In reality you will probably need to make a lot of exceptions for packages since not all projects have a license
50+
or the program to check what license a project is doesn't always work.
51+
52+
## Exceptions/What to do with packages that have an "unknown" license
53+
54+
- the license checker isn't able to figure out the license
55+
- license is in the readme or some other form (not in package.json)
56+
- the license is correctly updated in master on git but not published (not maintained)
57+
- future version of the package has a license but it's an indirect dependency
58+
59+
The way license-to-fail does it is let you pass in a config file.
60+
61+
```bash
62+
$ ./node_modules/.bin/license-to-fail ./path-to-config.js
63+
```
64+
65+
The config file is just an object with a list of `allowedPackages` and a list of `allowedLicenses`.
66+
67+
```js
68+
module.exports = {
69+
allowedPackages: [
70+
{
71+
"name": "allowed-package-name-here",
72+
"extraFieldsForDocumentation": "hello!", // optional
73+
"date": "date added", // optional
74+
"reason": "reason for allowing" // optional
75+
}
76+
],
77+
allowedLicenses: [
78+
"MIT",
79+
"Apache",
80+
"ISC",
81+
"WTF"
82+
],
83+
warnOnUnknown: true
84+
};
85+
```
86+
87+
# Alternatives
88+
89+
Just use a separate package rather than making it built-in like https://github.com/behance/license-to-fail already is (and others).
90+
91+
# Unresolved questions
92+
93+
How do users specify the allowed licenses and exceptions (differences for apps/libraries)?
94+
95+
- use package.json config
96+
- infer from the package's own license which licenses would be acceptable
97+
- use an yarnrc config
98+
- use cli arguments for options
99+
100+
Should it warn or error with unknown licenses?

0 commit comments

Comments
 (0)