@wipcomputer/wip-license-guard 1.9.14 → 1.9.15
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/SKILL.md +23 -3
- package/cli.mjs +22 -2
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -29,17 +29,37 @@ metadata:
|
|
|
29
29
|
|
|
30
30
|
# wip-license-guard
|
|
31
31
|
|
|
32
|
-
License compliance for your own repos.
|
|
32
|
+
License compliance for your own repos. Ensures correct copyright, dual-license blocks, LICENSE files, and README license sections.
|
|
33
33
|
|
|
34
34
|
## When to Use This Skill
|
|
35
35
|
|
|
36
36
|
- Before a release, to verify all files have correct license headers
|
|
37
37
|
- After adding new source files to a repo
|
|
38
38
|
- To enforce the MIT/AGPL dual-license pattern
|
|
39
|
+
- To standardize README license sections across all your repos
|
|
39
40
|
|
|
40
41
|
## CLI
|
|
41
42
|
|
|
42
43
|
```bash
|
|
43
|
-
wip-license-guard
|
|
44
|
-
wip-license-guard
|
|
44
|
+
wip-license-guard check [path] # audit repo against config
|
|
45
|
+
wip-license-guard check --fix [path] # auto-fix LICENSE, CLA, copyright issues
|
|
46
|
+
wip-license-guard init [path] # interactive setup
|
|
47
|
+
wip-license-guard init --from-standard # apply WIP Computer defaults (no prompts)
|
|
48
|
+
wip-license-guard readme-license [path] # audit README license sections
|
|
49
|
+
wip-license-guard readme-license --dry-run # preview what would change
|
|
50
|
+
wip-license-guard readme-license --fix # apply standard block to all READMEs
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### readme-license
|
|
54
|
+
|
|
55
|
+
Scans all repos for README license sections. Three modes:
|
|
56
|
+
|
|
57
|
+
- **No flags**: audit only. Reports non-standard, missing, and sub-tool READMEs that shouldn't have license sections.
|
|
58
|
+
- **--dry-run**: preview. Shows what each README has now and what would change. No files touched.
|
|
59
|
+
- **--fix**: apply. Replaces non-standard sections with the standard dual MIT/AGPLv3 block. Removes license sections from sub-tool READMEs.
|
|
60
|
+
|
|
61
|
+
Works on a single repo or a directory of repos:
|
|
62
|
+
```bash
|
|
63
|
+
wip-license-guard readme-license /path/to/one-repo
|
|
64
|
+
wip-license-guard readme-license /path/to/directory-of-repos
|
|
45
65
|
```
|
package/cli.mjs
CHANGED
|
@@ -13,6 +13,7 @@ const HELP_FLAGS = ['--help', '-h', 'help'];
|
|
|
13
13
|
const command = HELP_FLAGS.some(f => args.includes(f)) ? 'help' : (args.find(a => !a.startsWith('--')) || 'check');
|
|
14
14
|
const target = args.find((a, i) => i > 0 && !a.startsWith('--')) || '.';
|
|
15
15
|
const FIX = args.includes('--fix');
|
|
16
|
+
const DRY_RUN = args.includes('--dry-run');
|
|
16
17
|
const QUIET = args.includes('--quiet');
|
|
17
18
|
const FROM_STANDARD = args.includes('--from-standard');
|
|
18
19
|
|
|
@@ -321,7 +322,8 @@ async function check(repoPath) {
|
|
|
321
322
|
}
|
|
322
323
|
|
|
323
324
|
async function readmeLicense(targetPath) {
|
|
324
|
-
|
|
325
|
+
const mode = FIX ? '--fix' : DRY_RUN ? '--dry-run' : '';
|
|
326
|
+
log(`\n wip-license-guard readme-license${mode ? ' ' + mode : ''}\n`);
|
|
325
327
|
|
|
326
328
|
// Detect if targetPath is a single repo or a directory of repos
|
|
327
329
|
const repos = [];
|
|
@@ -376,6 +378,14 @@ async function readmeLicense(targetPath) {
|
|
|
376
378
|
} else if (content.includes('## License')) {
|
|
377
379
|
warn(`${repoName}/README.md ... non-standard license section`);
|
|
378
380
|
totalIssues++;
|
|
381
|
+
if (DRY_RUN) {
|
|
382
|
+
// Extract current license section for preview
|
|
383
|
+
const match = content.match(/## License[\s\S]*?(?=\n## [^#]|$)/);
|
|
384
|
+
if (match) {
|
|
385
|
+
log(` current: ${match[0].split('\n').slice(0, 3).join(' | ').substring(0, 80)}...`);
|
|
386
|
+
}
|
|
387
|
+
log(` would replace with: standard dual MIT/AGPLv3 block`);
|
|
388
|
+
}
|
|
379
389
|
if (FIX) {
|
|
380
390
|
const updated = replaceReadmeLicenseSection(content, config);
|
|
381
391
|
writeFileSync(readmePath, updated);
|
|
@@ -385,6 +395,9 @@ async function readmeLicense(targetPath) {
|
|
|
385
395
|
} else {
|
|
386
396
|
warn(`${repoName}/README.md ... missing ## License`);
|
|
387
397
|
totalIssues++;
|
|
398
|
+
if (DRY_RUN) {
|
|
399
|
+
log(` would add: standard dual MIT/AGPLv3 block at end of README`);
|
|
400
|
+
}
|
|
388
401
|
if (FIX) {
|
|
389
402
|
const updated = replaceReadmeLicenseSection(content, config);
|
|
390
403
|
writeFileSync(readmePath, updated);
|
|
@@ -410,6 +423,9 @@ async function readmeLicense(targetPath) {
|
|
|
410
423
|
if (subContent.includes('## License')) {
|
|
411
424
|
warn(`${repoName}/tools/${tool.name}/README.md ... has license section (should be removed)`);
|
|
412
425
|
totalIssues++;
|
|
426
|
+
if (DRY_RUN) {
|
|
427
|
+
log(` would remove: ## License section from sub-tool README`);
|
|
428
|
+
}
|
|
413
429
|
if (FIX) {
|
|
414
430
|
const cleaned = removeReadmeLicenseSection(subContent);
|
|
415
431
|
writeFileSync(subReadme, cleaned);
|
|
@@ -425,8 +441,11 @@ async function readmeLicense(targetPath) {
|
|
|
425
441
|
log('');
|
|
426
442
|
if (totalIssues === 0) {
|
|
427
443
|
log(' All README license sections are correct.\n');
|
|
444
|
+
} else if (DRY_RUN) {
|
|
445
|
+
log(` ${totalIssues} issue(s) found. Dry run complete. No changes made.`);
|
|
446
|
+
log(` Run with --fix to apply changes.\n`);
|
|
428
447
|
} else {
|
|
429
|
-
log(` ${totalIssues} issue(s) found. Run with --fix to
|
|
448
|
+
log(` ${totalIssues} issue(s) found. Run with --dry-run to preview or --fix to apply.\n`);
|
|
430
449
|
}
|
|
431
450
|
|
|
432
451
|
return totalIssues;
|
|
@@ -453,6 +472,7 @@ if (command === 'init') {
|
|
|
453
472
|
check [path] Audit repo against saved config. Exit 1 if issues found.
|
|
454
473
|
check --fix [path] Auto-fix issues (update LICENSE files, wrong copyright).
|
|
455
474
|
readme-license [path] Scan README license sections. Works on one repo or a directory of repos.
|
|
475
|
+
readme-license --dry-run Preview what would change. Shows current vs standard for each README.
|
|
456
476
|
readme-license --fix Apply standard license block to all READMEs. Remove from sub-tools.
|
|
457
477
|
help Show this help.
|
|
458
478
|
|
package/package.json
CHANGED