licenseguard-cli 1.2.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +355 -157
- package/bin/licenseguard.js +53 -34
- package/lib/commands/init-fast.js +62 -3
- package/lib/commands/init.js +74 -4
- package/lib/commands/scan.js +121 -0
- package/lib/scanner/compat-checker.js +433 -0
- package/lib/scanner/index.js +131 -0
- package/lib/scanner/license-compatibility-matrix.json +338 -0
- package/lib/scanner/license-detector.js +847 -0
- package/lib/scanner/license-normalizer.js +357 -0
- package/lib/scanner/plugins/cpp.js +267 -0
- package/lib/scanner/plugins/go.js +421 -0
- package/lib/scanner/plugins/node.js +149 -0
- package/lib/scanner/plugins/python-license-scanner.py +173 -0
- package/lib/scanner/plugins/python.js +336 -0
- package/lib/scanner/plugins/rust.js +196 -0
- package/lib/scanner/progress.js +22 -0
- package/lib/utils/file-ops.js +18 -1
- package/lib/utils/license-mapper.js +28 -0
- package/package.json +21 -5
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
4
|
-
|
|
3
|
+
Copyright (c) 2025 v
|
|
4
|
+
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,66 +1,148 @@
|
|
|
1
1
|
# LicenseGuard
|
|
2
2
|
|
|
3
|
-
[](https://
|
|
4
|
-
[](https://github.com/your-username/licenseguard/actions)
|
|
5
|
-
[](https://codecov.io/gh/your-username/licenseguard)
|
|
3
|
+
[](https://www.npmjs.com/package/licenseguard-cli)
|
|
6
4
|
[](https://opensource.org/licenses/MIT)
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
> License setup & compliance guard for developers
|
|
9
7
|
|
|
10
|
-
LicenseGuard
|
|
8
|
+
LicenseGuard helps you set up open source licenses and protects your project from license conflicts. It scans your dependencies for incompatible licenses and automatically notifies developers about licensing requirements - works with any language (Node.js, Python, Rust, Go, etc.).
|
|
9
|
+
|
|
10
|
+
## Key Features
|
|
11
|
+
|
|
12
|
+
- **Multi-Ecosystem Scanning** - Scans dependencies across 5 ecosystems (Node.js, C++, Rust, Python, Go)
|
|
13
|
+
- **Conflict Detection** - Detects incompatible licenses (e.g., GPL vs MIT) and blocks creation
|
|
14
|
+
- **SPDX Compatibility** - Industry-standard license compatibility checking
|
|
15
|
+
- **Scan Results** - Save scan results to `.licenseguardrc` for transparency
|
|
16
|
+
- **Automatic Notifications** - See license info immediately after `git clone`
|
|
17
|
+
- **Zero Effort** - Global hooks install once, work forever
|
|
18
|
+
- **Language Agnostic** - Works for Python, Rust, Go, Ruby, any project
|
|
19
|
+
- **Offline** - All license templates bundled, no internet required
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Supported Ecosystems
|
|
24
|
+
|
|
25
|
+
LicenseGuard scans dependencies across multiple languages and package managers:
|
|
26
|
+
|
|
27
|
+
- **Node.js** - npm packages (`package.json`)
|
|
28
|
+
- **C/C++** - Conan packages (`conanfile.txt`, `conanfile.py`)
|
|
29
|
+
- **Rust** - Cargo crates (`Cargo.toml`)
|
|
30
|
+
- **Python** - pip/pipenv/poetry packages (`requirements.txt`, `Pipfile`, `pyproject.toml`)
|
|
31
|
+
- **Go** - Go modules (`go.mod`)
|
|
32
|
+
|
|
33
|
+
Each ecosystem uses optimized detection strategies for maximum accuracy.
|
|
34
|
+
|
|
35
|
+
---
|
|
11
36
|
|
|
12
37
|
## Quick Start
|
|
13
38
|
|
|
39
|
+
### For Developers (One-time Setup)
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install -g licenseguard-cli
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
That's it! Now every time you clone a repo with `.licenseguardrc`, you'll see:
|
|
46
|
+
|
|
14
47
|
```bash
|
|
15
|
-
|
|
16
|
-
|
|
48
|
+
git clone https://github.com/some/project
|
|
49
|
+
# 📜 This project uses MIT License by ProjectOwner
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### For Project Owners
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
cd your-project
|
|
56
|
+
licenseguard init
|
|
57
|
+
```
|
|
17
58
|
|
|
18
|
-
|
|
59
|
+
Follow the prompts, then commit:
|
|
19
60
|
|
|
20
|
-
|
|
61
|
+
```bash
|
|
62
|
+
git add LICENSE .licenseguardrc
|
|
63
|
+
git commit -m "Add license"
|
|
64
|
+
git push
|
|
21
65
|
```
|
|
22
66
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
67
|
+
Anyone who has LicenseGuard installed globally will now see your license info when they clone.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## How It Works
|
|
72
|
+
|
|
73
|
+
### Automatic Global Hooks
|
|
74
|
+
|
|
75
|
+
When you install LicenseGuard globally, it automatically:
|
|
76
|
+
|
|
77
|
+
1. Creates git template directory at `~/.git-templates/hooks/`
|
|
78
|
+
2. Installs self-contained hooks (only needs Node.js, not LicenseGuard)
|
|
79
|
+
3. Configures git: `git config --global init.templateDir ~/.git-templates`
|
|
27
80
|
|
|
28
|
-
|
|
81
|
+
Now **every** `git clone` or `git init` copies these hooks automatically.
|
|
82
|
+
|
|
83
|
+
The hooks check for `.licenseguardrc` and display license info if found:
|
|
29
84
|
|
|
30
|
-
### Using npx (Recommended)
|
|
31
85
|
```bash
|
|
32
|
-
|
|
86
|
+
git clone <any-repo>
|
|
87
|
+
# If .licenseguardrc exists:
|
|
88
|
+
# 📜 This project uses MIT License by OwnerName
|
|
89
|
+
|
|
90
|
+
git checkout feature-branch
|
|
91
|
+
# 📜 This project uses MIT License by OwnerName
|
|
92
|
+
|
|
93
|
+
git commit -m "changes"
|
|
94
|
+
# ℹ️ Reminder: This project is licensed under MIT
|
|
33
95
|
```
|
|
34
96
|
|
|
35
|
-
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Installation Options
|
|
100
|
+
|
|
101
|
+
### Global (Recommended)
|
|
102
|
+
|
|
36
103
|
```bash
|
|
37
104
|
npm install -g licenseguard-cli
|
|
38
|
-
licenseguard --init
|
|
39
105
|
```
|
|
40
106
|
|
|
41
|
-
|
|
107
|
+
Enables automatic license notifications for all git operations.
|
|
108
|
+
|
|
109
|
+
### Using npx (No install)
|
|
110
|
+
|
|
42
111
|
```bash
|
|
43
|
-
|
|
44
|
-
npx licenseguard-cli --init
|
|
112
|
+
npx licenseguard-cli init
|
|
45
113
|
```
|
|
46
114
|
|
|
47
|
-
|
|
115
|
+
One-time use without global install (no automatic notifications).
|
|
48
116
|
|
|
49
|
-
###
|
|
117
|
+
### Local Development Dependency
|
|
50
118
|
|
|
51
119
|
```bash
|
|
52
|
-
|
|
120
|
+
npm install --save-dev licenseguard-cli
|
|
53
121
|
```
|
|
54
122
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
123
|
+
For use in npm scripts (see Advanced Usage).
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Commands
|
|
128
|
+
|
|
129
|
+
### `init` - Interactive Setup
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
licenseguard init
|
|
133
|
+
```
|
|
62
134
|
|
|
63
|
-
|
|
135
|
+
Guides you through:
|
|
136
|
+
1. Selecting license type (MIT, Apache 2.0, GPL 3.0, etc.)
|
|
137
|
+
2. Copyright owner name
|
|
138
|
+
3. Copyright year (defaults to current)
|
|
139
|
+
4. Project URL (optional)
|
|
140
|
+
5. Dependency scanning for license conflicts
|
|
141
|
+
6. Option to save scan results
|
|
142
|
+
7. Git initialization (if needed)
|
|
143
|
+
8. Git hooks installation
|
|
144
|
+
|
|
145
|
+
Example (with clean dependencies):
|
|
64
146
|
```
|
|
65
147
|
📜 LicenseGuard - Interactive License Setup
|
|
66
148
|
|
|
@@ -69,46 +151,103 @@ This command guides you through:
|
|
|
69
151
|
? Copyright year: 2025
|
|
70
152
|
? Project URL (optional): https://github.com/you/project
|
|
71
153
|
|
|
154
|
+
🔍 Scanning dependencies for license conflicts...
|
|
155
|
+
|
|
156
|
+
✓ Scan complete - 150 dependencies checked
|
|
157
|
+
✓ 150 compatible
|
|
158
|
+
✓ 0 incompatible
|
|
159
|
+
✓ 0 unknown
|
|
160
|
+
|
|
161
|
+
? Save scan results to .licenseguardrc? Yes
|
|
162
|
+
|
|
72
163
|
✓ LICENSE file created
|
|
164
|
+
✓ Scan results saved to .licenseguardrc
|
|
73
165
|
✓ Configuration saved to .licenseguardrc
|
|
74
166
|
✓ Git hooks installed
|
|
75
167
|
|
|
76
168
|
📄 Your project is now licensed under MIT
|
|
77
169
|
```
|
|
78
170
|
|
|
79
|
-
|
|
171
|
+
Example (with conflicts):
|
|
172
|
+
```
|
|
173
|
+
🔍 Scanning dependencies for license conflicts...
|
|
174
|
+
|
|
175
|
+
✗ Scan complete - 150 dependencies checked
|
|
176
|
+
✓ 147 compatible
|
|
177
|
+
❌ 2 incompatible
|
|
178
|
+
⚠️ 1 unknown
|
|
179
|
+
|
|
180
|
+
⚠️ CONFLICTS DETECTED:
|
|
181
|
+
|
|
182
|
+
❌ some-gpl-lib@2.0.0 (GPL-3.0)
|
|
183
|
+
Conflict: Copyleft incompatible with MIT
|
|
184
|
+
Location: node_modules/some-gpl-lib/package.json
|
|
185
|
+
|
|
186
|
+
✗ LICENSE NOT created due to license conflicts.
|
|
187
|
+
|
|
188
|
+
Fix conflicts or use --force to proceed anyway:
|
|
189
|
+
licenseguard init --force
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**With Explanation (`--explain`):**
|
|
193
|
+
```bash
|
|
194
|
+
licenseguard init --explain
|
|
195
|
+
# ...
|
|
196
|
+
# ❌ libdwarf@0.9.1 (LGPL-2.1-only)
|
|
197
|
+
# Conflict: Copyleft incompatible with MIT
|
|
198
|
+
# ────────────────────────
|
|
199
|
+
# 📚 FSF: MIT license is permissive and GPL-compatible
|
|
200
|
+
# 🔗 https://www.gnu.org/licenses/license-list.html#Expat
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Flags:**
|
|
204
|
+
- `--force` - Create LICENSE despite conflicts (shows warnings)
|
|
205
|
+
- `--noscan` - Skip dependency scanning
|
|
206
|
+
- `--explain` - Show authoritative source citations (FSF/OSI links) for conflicts
|
|
207
|
+
|
|
208
|
+
### `init --fast` - Non-Interactive Setup
|
|
80
209
|
|
|
81
210
|
```bash
|
|
82
|
-
licenseguard --
|
|
211
|
+
licenseguard init --fast --license mit --owner "Your Name"
|
|
83
212
|
```
|
|
84
213
|
|
|
85
|
-
|
|
214
|
+
Perfect for CI/CD or scripting. Automatically scans dependencies and auto-saves clean results.
|
|
215
|
+
|
|
216
|
+
**Flags:**
|
|
217
|
+
- `--fast` - Enable non-interactive mode
|
|
218
|
+
- `--license <type>` (required) - License type
|
|
219
|
+
- `--owner <name>` (optional) - Auto-detects from git config
|
|
220
|
+
- `--year <year>` (optional) - Defaults to current year
|
|
221
|
+
- `--url <url>` (optional) - Auto-detects from git remote
|
|
222
|
+
- `--force` - Create LICENSE despite conflicts
|
|
223
|
+
- `--noscan` - Skip dependency scanning
|
|
86
224
|
|
|
87
|
-
**
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
- `--year <year>` (optional) - Copyright year (defaults to current year)
|
|
91
|
-
- `--url <url>` (optional) - Project URL (auto-detects from git remote)
|
|
225
|
+
**Auto-save behavior in fast mode:**
|
|
226
|
+
- Clean scan (no conflicts) → Automatically saves `scanResult`
|
|
227
|
+
- Conflicts detected → Does not save `scanResult`
|
|
92
228
|
|
|
93
|
-
|
|
229
|
+
Examples:
|
|
94
230
|
```bash
|
|
95
|
-
# Minimal
|
|
96
|
-
licenseguard --
|
|
231
|
+
# Minimal
|
|
232
|
+
licenseguard init --fast --license mit
|
|
97
233
|
|
|
98
|
-
#
|
|
99
|
-
licenseguard --
|
|
234
|
+
# Skip scanning
|
|
235
|
+
licenseguard init --fast --license mit --noscan
|
|
236
|
+
|
|
237
|
+
# Force creation despite conflicts
|
|
238
|
+
licenseguard init --fast --license mit --force
|
|
100
239
|
|
|
101
|
-
#
|
|
102
|
-
licenseguard --
|
|
240
|
+
# Full specification
|
|
241
|
+
licenseguard init --fast --license apache2_0 --owner "Apache Corp" --year 2025
|
|
103
242
|
```
|
|
104
243
|
|
|
105
|
-
### List Available Licenses
|
|
244
|
+
### `ls` - List Available Licenses
|
|
106
245
|
|
|
107
246
|
```bash
|
|
108
|
-
licenseguard
|
|
247
|
+
licenseguard ls
|
|
109
248
|
```
|
|
110
249
|
|
|
111
|
-
|
|
250
|
+
Output:
|
|
112
251
|
```
|
|
113
252
|
Available License Templates:
|
|
114
253
|
|
|
@@ -120,23 +259,36 @@ Available License Templates:
|
|
|
120
259
|
✓ WTFPL - Do What The F*ck You Want To Public License (ultra-permissive)
|
|
121
260
|
```
|
|
122
261
|
|
|
123
|
-
|
|
262
|
+
### `setup` - Setup Hooks Only
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
licenseguard setup
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Reads existing `.licenseguardrc` and installs hooks. Used in npm prepare scripts.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Supported Licenses
|
|
124
273
|
|
|
125
|
-
|
|
|
126
|
-
|
|
127
|
-
| `mit` | MIT |
|
|
128
|
-
| `apache2_0` | Apache 2.0 |
|
|
129
|
-
| `gpl3_0` | GPL 3.0 |
|
|
130
|
-
| `bsd3clause` | BSD 3-Clause |
|
|
131
|
-
| `isc` | ISC |
|
|
132
|
-
| `wtfpl` | WTFPL |
|
|
274
|
+
| Key | Name | Description |
|
|
275
|
+
|-----|------|-------------|
|
|
276
|
+
| `mit` | MIT | Permissive, widely used |
|
|
277
|
+
| `apache2_0` | Apache 2.0 | Permissive with patent grant |
|
|
278
|
+
| `gpl3_0` | GPL 3.0 | Copyleft |
|
|
279
|
+
| `bsd3clause` | BSD 3-Clause | Permissive with attribution |
|
|
280
|
+
| `isc` | ISC | Simpler MIT alternative |
|
|
281
|
+
| `wtfpl` | WTFPL | Ultra-permissive |
|
|
133
282
|
|
|
134
|
-
Not sure which
|
|
283
|
+
Not sure which to choose? Visit [choosealicense.com](https://choosealicense.com).
|
|
284
|
+
|
|
285
|
+
---
|
|
135
286
|
|
|
136
287
|
## Configuration
|
|
137
288
|
|
|
138
|
-
LicenseGuard creates
|
|
289
|
+
LicenseGuard creates `.licenseguardrc` in your project root.
|
|
139
290
|
|
|
291
|
+
**Basic format:**
|
|
140
292
|
```json
|
|
141
293
|
{
|
|
142
294
|
"license": "mit",
|
|
@@ -146,148 +298,194 @@ LicenseGuard creates a `.licenseguardrc` file in your project root:
|
|
|
146
298
|
}
|
|
147
299
|
```
|
|
148
300
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
301
|
+
**With scan results (optional):**
|
|
302
|
+
```json
|
|
303
|
+
{
|
|
304
|
+
"license": "mit",
|
|
305
|
+
"owner": "Your Name",
|
|
306
|
+
"year": "2025",
|
|
307
|
+
"url": "https://github.com/you/project",
|
|
308
|
+
"scanResult": {
|
|
309
|
+
"timestamp": "2025-11-18T10:30:00.000Z",
|
|
310
|
+
"totalDependencies": 150,
|
|
311
|
+
"compatible": 150,
|
|
312
|
+
"incompatible": 0,
|
|
313
|
+
"unknown": 0,
|
|
314
|
+
"issues": []
|
|
315
|
+
}
|
|
316
|
+
}
|
|
159
317
|
```
|
|
160
318
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
319
|
+
**Why save scan results?**
|
|
320
|
+
- **Transparency badge** - Shows your project has validated license compliance
|
|
321
|
+
- **Trust signal** - Like CI badges or test coverage badges
|
|
322
|
+
- **Audit trail** - Documents when dependencies were last checked
|
|
323
|
+
- **Open source best practice** - Demonstrates license awareness
|
|
324
|
+
|
|
325
|
+
This file **must be committed** to your repository so others can see your license info.
|
|
166
326
|
|
|
167
|
-
|
|
168
|
-
- Hooks are **educational only** - they never block git operations
|
|
169
|
-
- Hooks always exit with code 0 (success)
|
|
170
|
-
- If `.licenseguardrc` is missing, hooks silently exit
|
|
327
|
+
---
|
|
171
328
|
|
|
172
|
-
|
|
329
|
+
## Advanced Usage
|
|
173
330
|
|
|
174
|
-
|
|
331
|
+
### For npm Projects (Alternative to Global Install)
|
|
175
332
|
|
|
176
|
-
|
|
333
|
+
If you can't rely on developers having LicenseGuard installed globally, use npm prepare script:
|
|
177
334
|
|
|
178
|
-
**Add to your package.json:**
|
|
179
335
|
```json
|
|
180
336
|
{
|
|
181
337
|
"devDependencies": {
|
|
182
|
-
"licenseguard-cli": "^
|
|
338
|
+
"licenseguard-cli": "^2.0.0"
|
|
183
339
|
},
|
|
184
340
|
"scripts": {
|
|
185
|
-
"prepare": "licenseguard
|
|
341
|
+
"prepare": "licenseguard setup || true"
|
|
186
342
|
}
|
|
187
343
|
}
|
|
188
344
|
```
|
|
189
345
|
|
|
190
|
-
|
|
191
|
-
```bash
|
|
192
|
-
git clone <your-repo> # Gets code + .licenseguardrc
|
|
193
|
-
npm install # AUTOMATICALLY:
|
|
194
|
-
# 📜 "This project uses MIT License by Your Name"
|
|
195
|
-
# ✓ Git hooks installed
|
|
196
|
-
git checkout feature # Notification appears (hooks active)
|
|
197
|
-
git commit # Reminder appears (hooks active)
|
|
198
|
-
```
|
|
346
|
+
When developers run `npm install`, hooks are set up automatically.
|
|
199
347
|
|
|
200
|
-
|
|
201
|
-
- Reads `.licenseguardrc` and displays license notification
|
|
202
|
-
- Installs git hooks automatically
|
|
203
|
-
- Always exits 0 (never breaks `npm install`)
|
|
204
|
-
- Safe to run multiple times (idempotent)
|
|
348
|
+
### Existing Git Hooks
|
|
205
349
|
|
|
206
|
-
|
|
350
|
+
LicenseGuard **never overwrites** existing hooks. If conflicts exist:
|
|
207
351
|
|
|
208
|
-
|
|
209
|
-
-
|
|
210
|
-
- `.git/hooks/licenseguard-post-checkout`
|
|
352
|
+
- Creates `licenseguard-post-checkout` and `licenseguard-pre-commit`
|
|
353
|
+
- Shows warning with merge instructions
|
|
211
354
|
|
|
212
|
-
|
|
355
|
+
### Non-Git Projects
|
|
213
356
|
|
|
214
|
-
|
|
357
|
+
LicenseGuard works without git:
|
|
358
|
+
- `init` offers to run `git init`
|
|
359
|
+
- `init --fast` creates LICENSE file only
|
|
360
|
+
- Hooks are skipped with warning
|
|
215
361
|
|
|
216
|
-
|
|
217
|
-
- Interactive mode (`--init`) will offer to run `git init`
|
|
218
|
-
- Fast mode (`--init-fast`) will skip hooks and warn you
|
|
219
|
-
- `--setup` command will skip hooks with a warning
|
|
220
|
-
- LICENSE file is always created regardless of git status
|
|
362
|
+
---
|
|
221
363
|
|
|
222
364
|
## FAQ
|
|
223
365
|
|
|
224
|
-
###
|
|
225
|
-
Yes! LicenseGuard is completely offline. All license templates are bundled with the package.
|
|
226
|
-
|
|
227
|
-
### Can I use custom licenses?
|
|
228
|
-
Currently, LicenseGuard supports the 6 most common open source licenses. Custom license support may be added in future versions.
|
|
366
|
+
### What licenses are checked during scanning?
|
|
229
367
|
|
|
230
|
-
|
|
231
|
-
|
|
368
|
+
LicenseGuard **auto-detects your project type** and scans the appropriate ecosystem:
|
|
369
|
+
- **Node.js**: Reads `package.json` and `node_modules/*/package.json`
|
|
370
|
+
- **C/C++**: Reads Conan metadata via `conan graph info`
|
|
371
|
+
- **Rust**: Reads `cargo metadata` JSON output
|
|
372
|
+
- **Python**: Uses native Python `importlib.metadata` (98.6% detection rate)
|
|
373
|
+
- **Go**: Reads `go.mod` and scans `GOMODCACHE` with streaming NDJSON
|
|
232
374
|
|
|
233
|
-
|
|
234
|
-
|
|
375
|
+
All ecosystems check:
|
|
376
|
+
- SPDX license identifiers (MIT, Apache-2.0, GPL-3.0, BSD-3-Clause, ISC, etc.)
|
|
377
|
+
- License compatibility using industry-standard rules
|
|
378
|
+
- Copyleft vs permissive conflicts (e.g., GPL incompatible with MIT)
|
|
379
|
+
- Multi-strategy detection including Jaccard Index similarity matching
|
|
235
380
|
|
|
236
|
-
|
|
237
|
-
Run `licenseguard --init` again and it will regenerate your LICENSE file.
|
|
381
|
+
Mixed-language projects are not yet supported. Use `--noscan` flag if detection is incorrect.
|
|
238
382
|
|
|
239
|
-
###
|
|
240
|
-
The hooks are informational only and don't block anything. If you don't want them, simply delete the hook files from `.git/hooks/`.
|
|
383
|
+
### How does SPDX compatibility work?
|
|
241
384
|
|
|
242
|
-
|
|
243
|
-
|
|
385
|
+
LicenseGuard uses [spdx-satisfies](https://www.npmjs.com/package/spdx-satisfies) for compatibility checking:
|
|
386
|
+
- **Permissive licenses** (MIT, Apache, BSD, ISC) - Compatible with most licenses
|
|
387
|
+
- **Copyleft licenses** (GPL-3.0) - Incompatible with permissive project licenses
|
|
388
|
+
- **Unknown licenses** - Generates warnings but doesn't block
|
|
389
|
+
- **Custom rules** - Fallback for non-SPDX licenses (WTFPL, proprietary)
|
|
244
390
|
|
|
245
|
-
|
|
391
|
+
### What is the scanResult for?
|
|
246
392
|
|
|
247
|
-
|
|
393
|
+
`scanResult` is optional transparency data you can commit to show:
|
|
394
|
+
1. Your project has validated license compliance
|
|
395
|
+
2. When dependencies were last scanned
|
|
396
|
+
3. What conflicts (if any) were detected
|
|
397
|
+
4. Trust signal for users and contributors (like CI badges)
|
|
248
398
|
|
|
249
|
-
|
|
250
|
-
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
251
|
-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
|
252
|
-
4. Push to the branch (`git push origin feature/amazing-feature`)
|
|
253
|
-
5. Open a Pull Request
|
|
399
|
+
You choose whether to save it after each scan. Clean scans default to YES, conflicts default to NO.
|
|
254
400
|
|
|
255
|
-
|
|
401
|
+
### Can I skip dependency scanning?
|
|
256
402
|
|
|
403
|
+
Yes! Use the `--noscan` flag:
|
|
257
404
|
```bash
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
405
|
+
licenseguard init --noscan
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
This is useful for:
|
|
409
|
+
- Non-JavaScript projects
|
|
410
|
+
- Projects without dependencies
|
|
411
|
+
- When you want manual license management
|
|
412
|
+
|
|
413
|
+
### Does this work for non-JavaScript projects?
|
|
414
|
+
|
|
415
|
+
**Yes!** LicenseGuard natively supports 5 ecosystems:
|
|
416
|
+
- **Node.js** - Full dependency scanning
|
|
417
|
+
- **C/C++** - Conan package scanning (requires Conan 2.x or 1.x installed)
|
|
418
|
+
- **Rust** - Cargo crate scanning (requires Cargo installed)
|
|
419
|
+
- **Python** - Native package scanning with 98.6% accuracy (requires Python 3.7+)
|
|
420
|
+
- **Go** - Go module scanning (requires Go installed)
|
|
421
|
+
|
|
422
|
+
For other languages (Ruby, PHP, etc.), the LICENSE file and git hooks still work, but dependency scanning is not yet available. Use `--noscan` flag for those projects.
|
|
423
|
+
|
|
424
|
+
The hooks only need Node.js installed (which most developers have).
|
|
425
|
+
|
|
426
|
+
### Do my contributors need to install LicenseGuard?
|
|
261
427
|
|
|
262
|
-
|
|
263
|
-
npm install
|
|
428
|
+
For automatic notifications: **Yes**, they need `npm install -g licenseguard-cli` once.
|
|
264
429
|
|
|
265
|
-
|
|
266
|
-
npm test
|
|
430
|
+
Alternative: Use npm prepare script (see Advanced Usage) - then only project owner installs.
|
|
267
431
|
|
|
268
|
-
|
|
269
|
-
|
|
432
|
+
### Does this work offline?
|
|
433
|
+
|
|
434
|
+
Yes! All license templates are bundled. No internet required.
|
|
270
435
|
|
|
271
|
-
|
|
272
|
-
npm run lint
|
|
436
|
+
### Can I disable notifications?
|
|
273
437
|
|
|
274
|
-
|
|
275
|
-
|
|
438
|
+
Delete hooks from `.git/hooks/`:
|
|
439
|
+
```bash
|
|
440
|
+
rm .git/hooks/post-checkout .git/hooks/pre-commit
|
|
441
|
+
```
|
|
276
442
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
443
|
+
Or remove global hooks:
|
|
444
|
+
```bash
|
|
445
|
+
rm -rf ~/.git-templates/hooks/
|
|
446
|
+
git config --global --unset init.templateDir
|
|
281
447
|
```
|
|
282
448
|
|
|
449
|
+
### What Node.js versions work?
|
|
450
|
+
|
|
451
|
+
Node.js 18.x or 20.x (LTS versions).
|
|
452
|
+
|
|
453
|
+
### Does it work on Windows?
|
|
454
|
+
|
|
455
|
+
Yes! Fully cross-platform (Linux, macOS, Windows).
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
## Why LicenseGuard?
|
|
460
|
+
|
|
461
|
+
- **Not enforcing** - Unlike license scanners, we inform and educate
|
|
462
|
+
- **Zero friction** - One global install, automatic forever
|
|
463
|
+
- **Universal** - Works with any language/framework
|
|
464
|
+
- **Educational** - Raises awareness without blocking workflows
|
|
465
|
+
- **Open source** - MIT licensed, free forever
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## Contributing
|
|
470
|
+
|
|
471
|
+
Contributions welcome!
|
|
472
|
+
|
|
473
|
+
1. Fork the repository
|
|
474
|
+
2. Create feature branch: `git checkout -b feature/amazing`
|
|
475
|
+
3. Commit changes: `git commit -m 'Add feature'`
|
|
476
|
+
4. Push: `git push origin feature/amazing`
|
|
477
|
+
5. Open Pull Request
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
283
481
|
## License
|
|
284
482
|
|
|
285
|
-
|
|
483
|
+
MIT License - see [LICENSE](LICENSE) file.
|
|
286
484
|
|
|
287
485
|
---
|
|
288
486
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
- [
|
|
292
|
-
- [
|
|
293
|
-
- [
|
|
487
|
+
## Links
|
|
488
|
+
|
|
489
|
+
- [npm Package](https://www.npmjs.com/package/licenseguard-cli)
|
|
490
|
+
- [Choose a License](https://choosealicense.com)
|
|
491
|
+
- [Open Source Initiative](https://opensource.org/licenses)
|