dslop 1.0.5 → 1.0.7

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 ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## v1.0.7
4
+
5
+ ## v1.0.6
6
+
7
+ - Initial release
package/README.md CHANGED
@@ -1,138 +1,35 @@
1
1
  # dslop
2
2
 
3
- **D**etect **S**imilar/**L**ines **O**f **P**rogramming - A fast duplicate code detector.
4
-
5
- ## Quick Start
6
-
7
- Run instantly with npx (no install required):
3
+ Find duplicate code in your codebase.
8
4
 
9
5
  ```bash
10
6
  npx dslop .
11
7
  ```
12
8
 
13
- ## Installation
9
+ ## Install
14
10
 
15
11
  ```bash
16
- # Install globally
17
- npm install -g dslop
18
-
19
- # Or with other package managers
20
- pnpm add -g dslop
21
- bun add -g dslop
22
- yarn global add dslop
12
+ npm i -g dslop
23
13
  ```
24
14
 
25
15
  ## Usage
26
16
 
27
17
  ```bash
28
- # Scan current directory
29
- dslop .
30
-
31
- # Scan specific directory with options
32
- dslop ./src -m 6 -s 80
33
-
34
- # Only show duplicates across packages (great for monorepos)
35
- dslop . --cross-package
36
-
37
- # Output as JSON
38
- dslop . --json
39
- ```
40
-
41
- Or run without installing:
42
-
43
- ```bash
44
- npx dslop .
45
- bunx dslop .
46
- pnpm dlx dslop .
18
+ dslop . # scan current directory
19
+ dslop ./src -m 6 -s 80 # 6 line min, 80% similarity
20
+ dslop . --cross-package # only cross-package dupes (monorepos)
21
+ dslop . --json # json output
47
22
  ```
48
23
 
49
24
  ## Options
50
25
 
51
- | Option | Short | Default | Description |
52
- |--------|-------|---------|-------------|
53
- | `--min-lines` | `-m` | 4 | Minimum block size in lines |
54
- | `--similarity` | `-s` | 70 | Minimum similarity threshold (0-100) |
55
- | `--extensions` | `-e` | ts,tsx,js,jsx | File extensions to scan |
56
- | `--ignore` | `-i` | node_modules,dist,... | Patterns to ignore |
57
- | `--no-normalize` | | | Disable string/number normalization |
58
- | `--json` | | | Output as JSON |
59
- | `--help` | `-h` | | Show help |
60
- | `--version` | `-v` | | Show version |
61
-
62
- ## How It Works
63
-
64
- 1. **Scanning**: Recursively scans files matching the specified extensions
65
- 2. **Block Extraction**: Extracts code blocks using a sliding window approach at multiple granularities
66
- 3. **Normalization**: Replaces string literals, numbers, and colors with placeholders for structural comparison
67
- 4. **Hash Grouping**: Groups exact duplicates by hash for fast matching
68
- 5. **Similarity Matching**: Uses Jaccard similarity on line sets for near-duplicates
69
- 6. **Filtering**: Removes overlapping blocks and deduplicates groups
70
-
71
- ## Monorepo Mode
72
-
73
- Use `--cross-package` to find duplicates that span across different packages/apps - perfect for identifying code that should be moved to a shared library:
74
-
75
- ```bash
76
- dslop . --cross-package
77
- ```
78
-
79
- This filters results to only show duplicates where occurrences are in different `apps/`, `packages/`, or `libs/` directories.
80
-
81
- ## Example Output
82
-
83
- ```
84
- Scanning ./src...
85
- Extensions: ts, tsx, js, jsx
86
- Min block size: 4 lines
87
- Similarity threshold: 70%
88
- Normalization: enabled
89
-
90
- Scanned 81 files (15,672 lines) in 129ms
91
- Extracted 13,920 code blocks
92
-
93
- Found 500 duplicate groups in 51ms
94
-
95
- ────────────────────────────────────────────────────────────────────────────────
96
- DUPLICATE CODE DETECTED
97
- ────────────────────────────────────────────────────────────────────────────────
98
-
99
- Group 1 │ EXACT │ 28 lines × 2 occurrences = 56 lines of duplication
100
-
101
- ├─ QuarterlyWinnerMessagePreview.tsx:197-224
102
- ├─ CoachEnteredMessagePreview.tsx:113-140
103
-
104
- Code preview:
105
- │ <View style={{
106
- │ backgroundColor: "white",
107
- │ ...
108
-
109
- SUMMARY
110
- ────────────────────────────────────────────────────────────────────────────────
111
- Total duplicate groups: 500
112
- Exact matches: 450
113
- Similar matches: 50
114
- Files affected: 65
115
- Total duplicate lines: 12,340
116
- Average similarity: 95%
117
- ```
118
-
119
- ## Development
120
-
121
- ```bash
122
- # Clone and install
123
- git clone https://github.com/turf-sports/dslop.git
124
- cd dslop
125
- bun install
126
-
127
- # Run in dev mode
128
- bun run dev
129
-
130
- # Build for npm
131
- bun run build
132
-
133
- # Create standalone binary
134
- bun run build:binary
135
- ```
26
+ | Flag | Default | Description |
27
+ |------|---------|-------------|
28
+ | `-m, --min-lines` | 4 | min lines per block |
29
+ | `-s, --similarity` | 70 | similarity threshold (0-100) |
30
+ | `-e, --extensions` | ts,tsx,js,jsx | file extensions |
31
+ | `--cross-package` | | only show dupes across packages |
32
+ | `--json` | | json output |
136
33
 
137
34
  ## License
138
35
 
package/dist/index.js CHANGED
@@ -6559,7 +6559,7 @@ async function scanDirectory(targetPath, options) {
6559
6559
  }
6560
6560
 
6561
6561
  // index.ts
6562
- var VERSION = process.env.npm_package_version || "1.0.5";
6562
+ var VERSION = process.env.npm_package_version || "1.0.7";
6563
6563
  function showHelp() {
6564
6564
  console.log(`
6565
6565
  dslop - Detect Similar/Duplicate Lines Of Programming
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dslop",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Detect Similar/Duplicate Lines Of Programming - Find code duplication in your codebase",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,7 +9,8 @@
9
9
  },
10
10
  "files": [
11
11
  "dist",
12
- "README.md"
12
+ "README.md",
13
+ "CHANGELOG.md"
13
14
  ],
14
15
  "scripts": {
15
16
  "dev": "bun run --watch index.ts",
@@ -17,9 +18,10 @@
17
18
  "build": "bun build ./index.ts --outdir ./dist --target node --format esm && VERSION=$(node -p \"require('./package.json').version\") && sed -i '' '1,3d' ./dist/index.js && sed -i '' \"s/__INJECT_VERSION__/$VERSION/g\" ./dist/index.js && echo '#!/usr/bin/env node\n' | cat - ./dist/index.js > temp && mv temp ./dist/index.js && chmod +x ./dist/index.js",
18
19
  "build:binary": "bun build --compile ./index.ts --outfile dslop",
19
20
  "prepublishOnly": "bun run build",
20
- "release": "npm version patch && git push && git push --tags && npm publish",
21
- "release:minor": "npm version minor && git push && git push --tags && npm publish",
22
- "release:major": "npm version major && git push && git push --tags && npm publish"
21
+ "changelog": "bunx changelogen --output CHANGELOG.md",
22
+ "release": "bunx changelogen --release --push && npm publish",
23
+ "release:minor": "bunx changelogen --release --minor --push && npm publish",
24
+ "release:major": "bunx changelogen --release --major --push && npm publish"
23
25
  },
24
26
  "keywords": [
25
27
  "duplicate",
@@ -42,7 +44,8 @@
42
44
  "node": ">=18"
43
45
  },
44
46
  "devDependencies": {
45
- "@types/bun": "latest"
47
+ "@types/bun": "latest",
48
+ "changelogen": "^0.6.2"
46
49
  },
47
50
  "peerDependencies": {
48
51
  "typescript": "^5"