licenseguard-cli 2.1.0 → 2.2.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/CHANGELOG.md +285 -0
- package/CODE_OF_CONDUCT.md +43 -0
- package/CONTRIBUTING.md +68 -0
- package/README.md +48 -10
- package/bin/licenseguard.js +26 -0
- package/lib/commands/init-fast.js +1 -1
- package/lib/commands/init.js +7 -1
- package/lib/commands/scan.js +264 -5
- package/lib/formatters/html-generator.js +232 -0
- package/lib/scanner/color-mapper.js +87 -0
- package/lib/scanner/coverage-reporter.js +84 -0
- package/lib/scanner/deep-scan.js +138 -0
- package/lib/scanner/index.js +27 -4
- package/lib/scanner/license-detector.js +1 -1
- package/lib/scanner/path-tracer.js +81 -0
- package/lib/scanner/plugins/cpp.js +9 -1
- package/lib/scanner/plugins/go.js +9 -2
- package/lib/scanner/plugins/node.js +68 -34
- package/lib/scanner/plugins/python.js +93 -4
- package/lib/scanner/plugins/rust.js +9 -1
- package/lib/utils/update-notifier.js +141 -0
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.2.0] - 2025-11-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Friction-Free Adoption (Dual-Mode Init)** - `scan` command now adapts to environment
|
|
13
|
+
- **Interactive Mode**: Prompts user to initialize configuration when missing (TTY)
|
|
14
|
+
- **CI/CD Mode**: Auto-detects project license from package manager files (no TTY or CI env)
|
|
15
|
+
- **Multi-Ecosystem Auto-Detection**: Supports Node.js, Rust, Python, Go, and C++
|
|
16
|
+
- **Graceful Fallback**: Clear error messages with setup instructions when auto-detect fails
|
|
17
|
+
- License auto-detection functions: `autoDetectLicense()`, `detectNodeLicense()`, `detectRustLicense()`, `detectPythonLicense()`, `detectGoLicense()`, `detectCppLicense()`
|
|
18
|
+
- `isInteractive()` helper to detect TTY vs CI/CD environments
|
|
19
|
+
- `isValidLicense()` validator to check for valid license strings (excludes UNLICENSED and empty)
|
|
20
|
+
|
|
21
|
+
- **Deep Scan Engine** - Complete dependency visibility for Node.js projects
|
|
22
|
+
- Parses `package-lock.json` to find ALL packages including transitive dependencies
|
|
23
|
+
- Supports lockfile v1 (npm 5-6), v2 (npm 7-8), v3 (npm 9+)
|
|
24
|
+
- Automatically detects lockfile version and uses appropriate parser
|
|
25
|
+
- Graceful fallback to flat scan when lockfile missing or corrupt
|
|
26
|
+
- **30x improvement** in package discovery: Typical React project goes from 50 packages (flat) → 1500+ packages (deep)
|
|
27
|
+
- **~99% coverage** with deep scan vs ~15% with flat scan
|
|
28
|
+
- Zero configuration required - works automatically when lockfile present
|
|
29
|
+
|
|
30
|
+
- **Dependency Path Visualization** - Shows exact dependency chains for license conflicts
|
|
31
|
+
- Automatically traces paths for GPL conflicts: "app → @facebook/folly → liburing"
|
|
32
|
+
- Uses npm's built-in `npm explain` command (npm 7+ required)
|
|
33
|
+
- Lazy evaluation: Only traces paths when conflicts detected (performance optimized)
|
|
34
|
+
- Caching to avoid duplicate subprocess calls (5 second timeout per package)
|
|
35
|
+
- Graceful fallback: Displays conflicts without paths when npm explain unavailable
|
|
36
|
+
- Answers the key question: "Where did this GPL package come from?"
|
|
37
|
+
- Enables instant decision-making: Remove direct dependency or find alternative
|
|
38
|
+
|
|
39
|
+
- **Coverage Report** - Automatic scan transparency for trust building
|
|
40
|
+
- Shows "X/Y packages identified (Z%)" after every scan
|
|
41
|
+
- Visual indicators: ✅ (90%+ excellent), ⚠️ (70-89% good), ❌ (<70% needs attention)
|
|
42
|
+
- Percentage formatted to 1 decimal place for precision
|
|
43
|
+
- Always displayed by default (no flag needed)
|
|
44
|
+
- Educational tip shown when coverage < 80%: "💡 Tip: Some packages may need manual LICENSE file inspection"
|
|
45
|
+
- Displays BEFORE conflict report in `init` command
|
|
46
|
+
- Displays at end of output in `scan` command
|
|
47
|
+
- Builds user trust through transparency about scan completeness
|
|
48
|
+
|
|
49
|
+
- **HTML Attribution Generator** - Mobile-ready CREDITS.html for App Store compliance
|
|
50
|
+
- New `--format html` flag on `scan` command generates attribution file
|
|
51
|
+
- Mobile-optimized responsive design (max-width 800px desktop, full-width mobile)
|
|
52
|
+
- System fonts for instant loading: `-apple-system, BlinkMacSystemFont, Segoe UI, Roboto`
|
|
53
|
+
- Touch-friendly: 44px minimum touch targets (iOS accessibility guideline)
|
|
54
|
+
- Dark mode support: Automatic light/dark theme adaptation
|
|
55
|
+
- Expandable license text: Click "Show license text" to view full license
|
|
56
|
+
- Alphabetical sorting: Packages sorted by name for easy navigation
|
|
57
|
+
- XSS safe: All user content properly escaped (prevents script injection)
|
|
58
|
+
- Single file: Inline CSS and JavaScript (no external dependencies)
|
|
59
|
+
- Ready to bundle: Works with iOS (Xcode + WKWebView) and Android (assets + WebView)
|
|
60
|
+
- Meets App Store requirements: iOS App Store and Google Play Store attribution compliance
|
|
61
|
+
- Zero configuration: `licenseguard scan --format html` generates `CREDITS.html`
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
- **`scan` command behavior**: Now checks for `.licenseguardrc` before requiring license specification
|
|
65
|
+
- Interactive mode offers to run `init` instead of throwing error
|
|
66
|
+
- CI/CD mode attempts auto-detection before erroring out
|
|
67
|
+
- Scan command continues seamlessly after interactive init completes
|
|
68
|
+
- Node.js scanner now uses deep scan (lockfile parsing) by default when lockfile available
|
|
69
|
+
- Flat scan preserved as fallback for projects without lockfiles
|
|
70
|
+
- Scan output now includes coverage statistics by default
|
|
71
|
+
- Coverage report appears in both `init` and `scan` commands automatically
|
|
72
|
+
- Significantly improved dependency discovery accuracy for Node.js projects
|
|
73
|
+
|
|
74
|
+
### Technical Details
|
|
75
|
+
- New module: `lib/scanner/deep-scan.js` - Lockfile parser (v1/v2/v3 support)
|
|
76
|
+
- New module: `lib/scanner/path-tracer.js` - npm explain adapter for dependency paths
|
|
77
|
+
- Modified: `lib/scanner/plugins/node.js` - Integrated deep scan with fallback logic
|
|
78
|
+
- Modified: `lib/scanner/index.js` - displayConflictReport now async, traces paths for conflicts
|
|
79
|
+
- Modified: `lib/commands/scan.js` - Awaits displayConflictReport for path tracing
|
|
80
|
+
- Test coverage: 100% for deep-scan.js and path-tracer.js modules
|
|
81
|
+
- All 762 tests passing with zero regressions
|
|
82
|
+
|
|
83
|
+
## [2.1.1] - 2025-11-25
|
|
84
|
+
|
|
85
|
+
### Added
|
|
86
|
+
- **Color-coded License Output** - Visual safety hierarchy for quick risk assessment
|
|
87
|
+
- Green (🟢): Permissive licenses (MIT, Apache-2.0, BSD-*, ISC)
|
|
88
|
+
- Yellow (⚠️): Weak copyleft (MPL-2.0, LGPL-*)
|
|
89
|
+
- Red (❌): Strong copyleft (GPL-*, AGPL-*)
|
|
90
|
+
- Gray (❔): Unknown licenses (requires manual review)
|
|
91
|
+
- Emojis as secondary indicators for accessibility (colorblind-friendly)
|
|
92
|
+
- Works in both light and dark terminal themes
|
|
93
|
+
- **Update Notifier** - Automatic update notifications
|
|
94
|
+
- Checks npm registry once per 24 hours
|
|
95
|
+
- Displays banner when newer version available
|
|
96
|
+
- Non-blocking (doesn't slow down CLI startup)
|
|
97
|
+
- Fails silently if network unavailable
|
|
98
|
+
- Cache stored in OS temp directory
|
|
99
|
+
|
|
100
|
+
### Changed
|
|
101
|
+
- All license output now color-coded in `init` command
|
|
102
|
+
- Conflict reports now show visual safety indicators
|
|
103
|
+
|
|
104
|
+
## [2.1.0] - 2025-11-23
|
|
105
|
+
|
|
106
|
+
### Added
|
|
107
|
+
|
|
108
|
+
#### Multi-Ecosystem Dependency Scanning
|
|
109
|
+
- **C/C++ (Conan) Support**
|
|
110
|
+
- Scans Conan 2.x and 1.x projects
|
|
111
|
+
- Auto-detects `conanfile.txt` and `conanfile.py`
|
|
112
|
+
- Tested with Facebook's folly library (23 dependencies, found 3 real GPL conflicts)
|
|
113
|
+
- Prevents GPL contamination in MIT/Apache projects
|
|
114
|
+
- **Rust (Cargo) Support**
|
|
115
|
+
- Scans Cargo projects via `cargo metadata --format-version 1`
|
|
116
|
+
- Auto-detects `Cargo.toml`
|
|
117
|
+
- 100% test coverage
|
|
118
|
+
- **Python (pip/pipenv/poetry) Support**
|
|
119
|
+
- **Native Python scanner** using `importlib.metadata` (IPC Bridge approach)
|
|
120
|
+
- **98.6% detection rate** (342/347 packages) vs 9.2% with pip show parsing
|
|
121
|
+
- Auto-detects `requirements.txt`, `Pipfile`, `pyproject.toml`
|
|
122
|
+
- Priority: poetry > pipenv > pip
|
|
123
|
+
- 37 license normalizations for Python ecosystem quirks
|
|
124
|
+
- Batch optimization (30x faster than individual calls)
|
|
125
|
+
- **Go (modules) Support**
|
|
126
|
+
- Scans Go modules with streaming NDJSON for large projects
|
|
127
|
+
- Dynamic cache detection via `go env GOMODCACHE`
|
|
128
|
+
- Auto-detects `go.mod`
|
|
129
|
+
- Jaccard Index matching for LICENSE files (no package metadata fallback)
|
|
130
|
+
|
|
131
|
+
- **Authoritative Source Citations (--explain)**
|
|
132
|
+
- Added `--explain` flag to `init` and `scan` commands
|
|
133
|
+
- Shows citations from FSF, OSI, and Mozilla for compatibility decisions
|
|
134
|
+
- Provides direct URLs to license text and compatibility matrices
|
|
135
|
+
- Helps developers verify "Why is this a conflict?" with legal backing
|
|
136
|
+
|
|
137
|
+
#### Advanced License Detection
|
|
138
|
+
- **Jaccard Index License Detector** (5-layer multi-strategy detection)
|
|
139
|
+
- Layer 1: SPDX-License-Identifier headers (fastest)
|
|
140
|
+
- Layer 2: License header/title detection (for full license texts)
|
|
141
|
+
- Layer 3: Dual-license pattern detection
|
|
142
|
+
- Layer 4: Key phrase patterns (distinctive phrases)
|
|
143
|
+
- Layer 5: Jaccard similarity matching (edge cases)
|
|
144
|
+
- Reduced Go scan warnings from 27 to 7
|
|
145
|
+
- Handles BSD-2-Clause vs BSD-3-Clause differentiation
|
|
146
|
+
- Universal detector usable across all ecosystems
|
|
147
|
+
- **GPL Contamination Prevention**
|
|
148
|
+
- Detects copyleft licenses in transitive dependency trees
|
|
149
|
+
- Real-world validation: Found 3 GPL conflicts in folly's 23-dependency tree
|
|
150
|
+
- Business value: Prevents license violations before production
|
|
151
|
+
|
|
152
|
+
### Changed
|
|
153
|
+
|
|
154
|
+
#### Architecture
|
|
155
|
+
- **Plugin Architecture** - Refactored from monolithic to pluggable ecosystem plugins
|
|
156
|
+
- `lib/scanner/plugins/node.js` - Node.js scanner (extracted from monolithic v2.0)
|
|
157
|
+
- `lib/scanner/plugins/cpp.js` - C/C++ Conan scanner
|
|
158
|
+
- `lib/scanner/plugins/rust.js` - Rust Cargo scanner
|
|
159
|
+
- `lib/scanner/plugins/python.js` - Python scanner with IPC bridge
|
|
160
|
+
- `lib/scanner/plugins/go.js` - Go modules scanner
|
|
161
|
+
- **Auto-detection** - Scanner now auto-detects project type (Node > C++ > Rust > Python > Go priority)
|
|
162
|
+
- **Node.js Scanner** - Backward compatible, all Epic 2 tests still passing
|
|
163
|
+
|
|
164
|
+
### Technical
|
|
165
|
+
|
|
166
|
+
#### New Files
|
|
167
|
+
- `lib/scanner/plugins/cpp.js` - Conan plugin (87% coverage)
|
|
168
|
+
- `lib/scanner/plugins/rust.js` - Cargo plugin (100% coverage)
|
|
169
|
+
- `lib/scanner/plugins/python.js` - Python plugin with IPC bridge (98% coverage)
|
|
170
|
+
- `lib/scanner/plugins/python-license-scanner.py` - Native Python scanner script
|
|
171
|
+
- `lib/scanner/plugins/go.js` - Go modules plugin (92% coverage)
|
|
172
|
+
- `lib/scanner/plugins/node.js` - Refactored Node.js scanner (100% coverage)
|
|
173
|
+
- `lib/scanner/license-detector.js` - Jaccard Index multi-strategy detector (85% coverage)
|
|
174
|
+
|
|
175
|
+
#### Test Growth
|
|
176
|
+
- **635 tests** (was 132 in v2.0.0) - **+503 tests, +381% growth**
|
|
177
|
+
- **19 test suites** (was ~10 in v2.0.0)
|
|
178
|
+
- **0 regressions** - All Epic 2 tests passing
|
|
179
|
+
- **Coverage:**
|
|
180
|
+
- Plugins: 94.37% (target: >80%)
|
|
181
|
+
- License detector: 85.41% (target: >80%)
|
|
182
|
+
- Overall: 84.46% statements, 75.95% branches
|
|
183
|
+
|
|
184
|
+
#### Dependencies
|
|
185
|
+
- No new npm dependencies added (uses child_process for ecosystem tools)
|
|
186
|
+
|
|
187
|
+
#### Performance
|
|
188
|
+
- Node.js: <1s for 1500 packages
|
|
189
|
+
- Python: ~1-2s for 347 packages (IPC Bridge overhead)
|
|
190
|
+
- C++: <1s for 23 packages (Conan metadata parsing)
|
|
191
|
+
- Rust: <1s for typical project
|
|
192
|
+
- Go: <1s for typical project
|
|
193
|
+
|
|
194
|
+
### Breaking Changes
|
|
195
|
+
None - Fully backward compatible with v2.0.0
|
|
196
|
+
|
|
197
|
+
### Known Limitations
|
|
198
|
+
- Mixed-language projects not yet supported (auto-detection picks first match)
|
|
199
|
+
- Python requires Python 3.7+ installed
|
|
200
|
+
- C++ requires Conan 1.x or 2.x installed
|
|
201
|
+
- Rust requires Cargo installed
|
|
202
|
+
- Go requires Go installed
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
**Epic 3 Completed:** Multi-Ecosystem Scanner Support
|
|
207
|
+
**Stories Completed:** 3.0 (Plugin Architecture), 3.1 (C++), 3.2 (Rust), 3.3 (Python), 3.4 (Go), plus 2 hotfixes (compat-checker, license-detector)
|
|
208
|
+
|
|
209
|
+
## [2.0.0] - 2025-11-18
|
|
210
|
+
|
|
211
|
+
### BREAKING CHANGES
|
|
212
|
+
|
|
213
|
+
#### CLI Architecture Migration
|
|
214
|
+
- **Migrated from flag-based to subcommand-based routing**
|
|
215
|
+
- Old: `licenseguard --init` → New: `licenseguard init`
|
|
216
|
+
- Old: `licenseguard --ls` → New: `licenseguard ls`
|
|
217
|
+
- Old: `licenseguard --setup` → New: `licenseguard setup`
|
|
218
|
+
- **Rationale:** Subcommands provide better CLI semantics and enable future extensibility
|
|
219
|
+
- **Migration:** Update all scripts and documentation to use new syntax
|
|
220
|
+
- **Backward compatibility:** Use `--noscan` flag for v1.x behavior without dependency scanning
|
|
221
|
+
|
|
222
|
+
### Added
|
|
223
|
+
|
|
224
|
+
#### License Compliance Guard
|
|
225
|
+
- **Dependency license scanning during init**
|
|
226
|
+
- Scans all npm dependencies for license conflicts
|
|
227
|
+
- Reads `package.json` and `node_modules/*/package.json`
|
|
228
|
+
- Displays scan summary with compatible/incompatible/unknown counts
|
|
229
|
+
- **SPDX license compatibility checking**
|
|
230
|
+
- Uses `spdx-satisfies` for industry-standard compatibility rules
|
|
231
|
+
- Checks copyleft vs permissive conflicts (e.g., GPL-3.0 incompatible with MIT)
|
|
232
|
+
- Supports complex license expressions (e.g., "MIT OR Apache-2.0")
|
|
233
|
+
- **Conflict detection with blocking**
|
|
234
|
+
- LICENSE creation blocked if incompatible licenses detected
|
|
235
|
+
- Exits with code 1 and error message
|
|
236
|
+
- Shows detailed conflict report with package names, licenses, and reasons
|
|
237
|
+
- **scanResult persistence to .licenseguardrc**
|
|
238
|
+
- Optional field to save scan results for transparency
|
|
239
|
+
- Includes timestamp, counts, and issues array
|
|
240
|
+
- Acts as compliance badge (like CI or coverage badges)
|
|
241
|
+
- Prompt with smart defaults: YES for clean scans, NO for conflicts
|
|
242
|
+
- **--force flag to override blocking**
|
|
243
|
+
- Creates LICENSE despite conflicts when user explicitly accepts risks
|
|
244
|
+
- Shows warnings but allows proceeding
|
|
245
|
+
- Useful for false positives or acceptable conflicts
|
|
246
|
+
- **--noscan flag for v1.x compatibility**
|
|
247
|
+
- Skips dependency scanning entirely
|
|
248
|
+
- Maintains v1.x behavior for non-JavaScript projects
|
|
249
|
+
- No scanResult generated or saved
|
|
250
|
+
|
|
251
|
+
### Changed
|
|
252
|
+
|
|
253
|
+
- **Help text improved** - Now shows subcommands with descriptions
|
|
254
|
+
- **Error messages enhanced** - More actionable feedback for common issues
|
|
255
|
+
- **CLI routing refactored** - Cleaner subcommand architecture
|
|
256
|
+
- **Init command enhanced** - Integrated scanning after license selection, before file creation
|
|
257
|
+
- **Init-fast command enhanced** - Auto-saves clean scan results, skips saving on conflicts
|
|
258
|
+
- **Configuration format extended** - `.licenseguardrc` now supports optional `scanResult` field
|
|
259
|
+
|
|
260
|
+
### Technical
|
|
261
|
+
|
|
262
|
+
#### New Dependencies
|
|
263
|
+
- `spdx-satisfies@5.x` - SPDX license compatibility checking
|
|
264
|
+
- `spdx-expression-parse@4.x` - Parse SPDX license expressions
|
|
265
|
+
|
|
266
|
+
#### New Modules
|
|
267
|
+
- `lib/scanner/index.js` - Dependency scanner with conflict detection
|
|
268
|
+
- `lib/compat/rules.js` - License compatibility rules engine
|
|
269
|
+
|
|
270
|
+
#### Test Coverage
|
|
271
|
+
- Added scanner unit tests
|
|
272
|
+
- Added file-ops scanResult handling tests
|
|
273
|
+
- Maintained 86%+ coverage target
|
|
274
|
+
|
|
275
|
+
## [1.1.0] - 2025-11-17
|
|
276
|
+
|
|
277
|
+
### Added
|
|
278
|
+
- Initial public release (Epic 1)
|
|
279
|
+
- Interactive license setup (`init` command)
|
|
280
|
+
- Fast mode for CI/CD (`init --fast`)
|
|
281
|
+
- 6 embedded license templates (MIT, Apache 2.0, GPL 3.0, BSD 3-Clause, ISC, WTFPL)
|
|
282
|
+
- Git hooks for license notifications (post-checkout, pre-commit)
|
|
283
|
+
- Global hooks installation via npm postinstall
|
|
284
|
+
- `.licenseguardrc` configuration file
|
|
285
|
+
- Cross-platform support (Linux, macOS, Windows)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## The "No Elitism" Clause
|
|
10
|
+
|
|
11
|
+
LicenseGuard was built by a solo developer learning the ropes. We value **grit** and **learning** over certificates and titles.
|
|
12
|
+
|
|
13
|
+
* **No Gatekeeping:** Do not belittle contributors for "bad code" or "being junior." Teach, don't preach.
|
|
14
|
+
* **Practicality over Purity:** We prefer code that works and is readable over "clever" one-liners that no one understands.
|
|
15
|
+
* **Respect the Craft:** Take pride in what you ship. Code is communication.
|
|
16
|
+
|
|
17
|
+
## Our Standards
|
|
18
|
+
|
|
19
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
20
|
+
|
|
21
|
+
* Demonstrating empathy and kindness toward other people
|
|
22
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
23
|
+
* Giving and gracefully accepting constructive feedback
|
|
24
|
+
* Accepting responsibility and apologizing to those affected by our mistakes
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
26
|
+
|
|
27
|
+
Examples of unacceptable behavior include:
|
|
28
|
+
|
|
29
|
+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
|
30
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
31
|
+
* Public or private harassment
|
|
32
|
+
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
|
33
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
34
|
+
|
|
35
|
+
## Enforcement Responsibilities
|
|
36
|
+
|
|
37
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
38
|
+
|
|
39
|
+
## Attribution
|
|
40
|
+
|
|
41
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at https://www.contributor-covenant.org/version/2/1/code_of_conduct.html.
|
|
42
|
+
|
|
43
|
+
[homepage]: https://www.contributor-covenant.org
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Contributing to LicenseGuard
|
|
2
|
+
|
|
3
|
+
First off, thank you for considering contributing to LicenseGuard. This project is built on the belief that license compliance should be **fast, free, and accessible** to every developer.
|
|
4
|
+
|
|
5
|
+
## The LicenseGuard Philosophy
|
|
6
|
+
|
|
7
|
+
Before you write a single line of code, please understand the core values that built this tool:
|
|
8
|
+
|
|
9
|
+
1. **Zero Bloat Policy** 🚀
|
|
10
|
+
* We prefer native Node.js APIs (`fs`, `child_process`, `path`) over adding heavy dependencies.
|
|
11
|
+
* Current dependencies are minimal (chalk, commander, inquirer). Keep it that way.
|
|
12
|
+
* If you can write it in 20 lines of utility code, don't install a 5MB library.
|
|
13
|
+
|
|
14
|
+
2. **Ecosystem Native** 🧠
|
|
15
|
+
* Don't force one logic on all languages.
|
|
16
|
+
* **Node.js** uses file parsing (`package.json`) because it's fast.
|
|
17
|
+
* **Python** uses IPC bridge (`python-license-scanner.py`) because pip is chaotic.
|
|
18
|
+
* **Go/Rust** uses CLI tools (`go list`, `cargo metadata`) because they are authoritative.
|
|
19
|
+
* *Rule:* Research the ecosystem's standard first. Don't guess.
|
|
20
|
+
|
|
21
|
+
3. **Fail-Safe Architecture** 🛡️
|
|
22
|
+
* This is a polyglot tool. If the user doesn't have `conan` installed, the C++ scanner should fail silently with a warning. It MUST NOT crash the Node.js scan.
|
|
23
|
+
* Always wrap plugin execution in `try-catch`.
|
|
24
|
+
|
|
25
|
+
4. **"Feel Code"** ✍️
|
|
26
|
+
* Understand what you are parsing. Don't just regex blindly.
|
|
27
|
+
* Read the lockfiles. Understand the graph.
|
|
28
|
+
|
|
29
|
+
## Development Setup
|
|
30
|
+
|
|
31
|
+
1. **Clone and Install:**
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/rfxlamia/licenseguard.git
|
|
34
|
+
cd licenseguard
|
|
35
|
+
npm install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. **Run Tests:**
|
|
39
|
+
We take testing seriously.
|
|
40
|
+
```bash
|
|
41
|
+
npm test
|
|
42
|
+
```
|
|
43
|
+
*Current Benchmark:* 635+ tests passing in ~3 seconds. Do not make it slower.
|
|
44
|
+
|
|
45
|
+
3. **Manual Testing:**
|
|
46
|
+
Automated tests are not enough. Verify your changes against real projects.
|
|
47
|
+
See `manual-test/` directory for reference projects (Node, C++, Python).
|
|
48
|
+
|
|
49
|
+
## Pull Request Guidelines
|
|
50
|
+
|
|
51
|
+
* **Branch Naming:** `feat/feature-name` or `fix/bug-name`.
|
|
52
|
+
* **Commit Messages:** Follow [Conventional Commits](https://www.conventionalcommits.org/) (e.g., `feat: add ruby support`, `fix: handle corrupt lockfile`).
|
|
53
|
+
* **Tests:** Every PR **MUST** include unit tests. Code coverage should not drop below 90%.
|
|
54
|
+
* **Documentation:** Update `README.md` if you add a new feature or flag.
|
|
55
|
+
|
|
56
|
+
## Adding a New Ecosystem Plugin
|
|
57
|
+
|
|
58
|
+
Want to add support for Ruby, PHP, or Java?
|
|
59
|
+
1. Create `lib/scanner/plugins/language.js`.
|
|
60
|
+
2. Implement the standard interface:
|
|
61
|
+
* `detect()`: Boolean
|
|
62
|
+
* `scanDependencies(projectLicense)`: Promise<Result>
|
|
63
|
+
3. Register it in `lib/scanner/index.js`.
|
|
64
|
+
4. Add comprehensive unit tests in `tests/unit/scanner-language.test.js`.
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
By contributing, you agree that your contributions will be licensed under its MIT License.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
> License setup & compliance guard for developers
|
|
7
7
|
|
|
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
|
|
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 across ecosystems (Node.js, Python, Rust, Go, C++).
|
|
9
9
|
|
|
10
10
|
## Key Features
|
|
11
11
|
|
|
@@ -15,7 +15,6 @@ LicenseGuard helps you set up open source licenses and protects your project fro
|
|
|
15
15
|
- **Scan Results** - Save scan results to `.licenseguardrc` for transparency
|
|
16
16
|
- **Automatic Notifications** - See license info immediately after `git clone`
|
|
17
17
|
- **Zero Effort** - Global hooks install once, work forever
|
|
18
|
-
- **Language Agnostic** - Works for Python, Rust, Go, Ruby, any project
|
|
19
18
|
- **Offline** - All license templates bundled, no internet required
|
|
20
19
|
|
|
21
20
|
---
|
|
@@ -189,7 +188,7 @@ Fix conflicts or use --force to proceed anyway:
|
|
|
189
188
|
licenseguard init --force
|
|
190
189
|
```
|
|
191
190
|
|
|
192
|
-
|
|
191
|
+
### `init --explain` - With Explanation
|
|
193
192
|
```bash
|
|
194
193
|
licenseguard init --explain
|
|
195
194
|
# ...
|
|
@@ -269,7 +268,8 @@ Reads existing `.licenseguardrc` and installs hooks. Used in npm prepare scripts
|
|
|
269
268
|
|
|
270
269
|
---
|
|
271
270
|
|
|
272
|
-
## Supported
|
|
271
|
+
## Supported License Setup
|
|
272
|
+
|
|
273
273
|
|
|
274
274
|
| Key | Name | Description |
|
|
275
275
|
|-----|------|-------------|
|
|
@@ -469,12 +469,46 @@ Yes! Fully cross-platform (Linux, macOS, Windows).
|
|
|
469
469
|
## Contributing
|
|
470
470
|
|
|
471
471
|
Contributions welcome!
|
|
472
|
+
**We need your help to make LicenseGuard better.**
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
### How to Contribute
|
|
477
|
+
|
|
478
|
+
1. Read [CONTRIBUTING.md](CONTRIBUTING.md) - Philosophy and guidelines
|
|
479
|
+
2. Check [GitHub Issues](https://github.com/rfxlamia/licenseguard-development/issues) for "good first issue" label
|
|
480
|
+
3. Fork repository
|
|
481
|
+
4. Create branch: `git checkout -b feat/license-mpl2`
|
|
482
|
+
5. Write tests (90%+ coverage required)
|
|
483
|
+
6. Submit Pull Request
|
|
484
|
+
|
|
485
|
+
**Philosophy:**
|
|
486
|
+
- **Zero Bloat** - Prefer native APIs over dependencies
|
|
487
|
+
- **Ecosystem Native** - Research the right tool, don't guess
|
|
488
|
+
- **Fail-Safe** - Plugins fail gracefully, never crash
|
|
489
|
+
- **Feel Code** - Understand what you parse
|
|
490
|
+
|
|
491
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
|
|
492
|
+
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## Code of Conduct
|
|
496
|
+
|
|
497
|
+
We're committed to an inclusive community. Read our [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
498
|
+
|
|
499
|
+
**Key principles:**
|
|
500
|
+
- **No Elitism** - Grit and learning > credentials
|
|
501
|
+
- **No Gatekeeping** - Teach, don't preach
|
|
502
|
+
- **Practicality > Purity** - Readable > clever
|
|
503
|
+
- **Respect the Craft** - Code is communication
|
|
472
504
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## Documentation
|
|
508
|
+
|
|
509
|
+
- **[QUICK-USE.md](QUICK-USE.md)** - Complete command reference and examples
|
|
510
|
+
- **[CONTRIBUTING.md](CONTRIBUTING.md)** - How to contribute
|
|
511
|
+
- **[CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)** - Community standards
|
|
478
512
|
|
|
479
513
|
---
|
|
480
514
|
|
|
@@ -487,5 +521,9 @@ MIT License - see [LICENSE](LICENSE) file.
|
|
|
487
521
|
## Links
|
|
488
522
|
|
|
489
523
|
- [npm Package](https://www.npmjs.com/package/licenseguard-cli)
|
|
524
|
+
- [GitHub Repository](https://github.com/rfxlamia/licenseguard)
|
|
525
|
+
- [Quick Use Guide](QUICK-USE.md)
|
|
526
|
+
- [Contributing Guide](CONTRIBUTING.md)
|
|
490
527
|
- [Choose a License](https://choosealicense.com)
|
|
491
|
-
- [
|
|
528
|
+
- [SPDX License List](https://spdx.org/licenses/)
|
|
529
|
+
|
package/bin/licenseguard.js
CHANGED
|
@@ -6,7 +6,14 @@ const { version } = require('../package.json')
|
|
|
6
6
|
const { runList } = require('../lib/commands/list')
|
|
7
7
|
const { runInit } = require('../lib/commands/init')
|
|
8
8
|
const { runInitFast } = require('../lib/commands/init-fast')
|
|
9
|
+
const { runScan } = require('../lib/commands/scan')
|
|
9
10
|
const { setupCommand } = require('../lib/commands/setup')
|
|
11
|
+
const { checkForUpdates } = require('../lib/utils/update-notifier')
|
|
12
|
+
|
|
13
|
+
// Check for updates (non-blocking, silent failure)
|
|
14
|
+
checkForUpdates(version).catch(() => {
|
|
15
|
+
// Silent failure - don't block user
|
|
16
|
+
})
|
|
10
17
|
|
|
11
18
|
program
|
|
12
19
|
.version(version)
|
|
@@ -37,6 +44,25 @@ program
|
|
|
37
44
|
}
|
|
38
45
|
})
|
|
39
46
|
|
|
47
|
+
// Scan command
|
|
48
|
+
program
|
|
49
|
+
.command('scan')
|
|
50
|
+
.description('Scan dependencies for license conflicts')
|
|
51
|
+
.option('--license <type>', 'Specify project license (if not auto-detected)')
|
|
52
|
+
.option('--allow', 'Allow conflicts (exit 0 even if conflicts found)')
|
|
53
|
+
.option('--fail-on-unknown', 'Fail if unknown licenses detected')
|
|
54
|
+
.option('--explain', 'Show authoritative source citations for license compatibility decisions')
|
|
55
|
+
.option('--format <type>', 'Output format (html) - generates CREDITS.html for mobile apps')
|
|
56
|
+
.option('--cwd <path>', 'Working directory to scan')
|
|
57
|
+
.action(async (options) => {
|
|
58
|
+
try {
|
|
59
|
+
await runScan(options)
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error(chalk.red('✗ Error:'), error.message)
|
|
62
|
+
process.exit(1)
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
|
|
40
66
|
// List command
|
|
41
67
|
program
|
|
42
68
|
.command('ls')
|
|
@@ -74,7 +74,7 @@ async function runInitFast(options) {
|
|
|
74
74
|
console.log(chalk.blue('🔍 Scanning dependencies for license conflicts...\n'))
|
|
75
75
|
|
|
76
76
|
scanResult = await scanDependencies(spdxLicense)
|
|
77
|
-
const hasConflicts = displayConflictReport(scanResult, spdxLicense)
|
|
77
|
+
const hasConflicts = await displayConflictReport(scanResult, spdxLicense)
|
|
78
78
|
|
|
79
79
|
if (hasConflicts && !options.force) {
|
|
80
80
|
// Block LICENSE creation due to conflicts
|
package/lib/commands/init.js
CHANGED
|
@@ -5,6 +5,7 @@ const { writeLicenseFile, writeConfig } = require('../utils/file-ops')
|
|
|
5
5
|
const { isGitRepo, initGitRepo, installHooks } = require('../utils/git-helpers')
|
|
6
6
|
const { scanDependencies, displayConflictReport } = require('../scanner')
|
|
7
7
|
const { toSPDX } = require('../utils/license-mapper')
|
|
8
|
+
const { calculateCoverage, displayCoverage } = require('../scanner/coverage-reporter')
|
|
8
9
|
|
|
9
10
|
async function runInit(options = {}) {
|
|
10
11
|
try {
|
|
@@ -59,7 +60,12 @@ async function runInit(options = {}) {
|
|
|
59
60
|
console.log(chalk.blue('\n🔍 Scanning dependencies for license conflicts...\n'))
|
|
60
61
|
|
|
61
62
|
scanResult = await scanDependencies(spdxLicense)
|
|
62
|
-
|
|
63
|
+
|
|
64
|
+
// Display coverage BEFORE conflict report (AC #3)
|
|
65
|
+
const coverage = calculateCoverage(scanResult)
|
|
66
|
+
displayCoverage(coverage)
|
|
67
|
+
|
|
68
|
+
const hasConflicts = await displayConflictReport(scanResult, spdxLicense, { explain: options.explain })
|
|
63
69
|
|
|
64
70
|
if (hasConflicts && !options.force) {
|
|
65
71
|
// Block LICENSE creation due to conflicts
|