dslop 1.0.0 → 1.0.2
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/README.md +48 -22
- package/dist/index.js +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -2,23 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
**D**etect **S**imilar/**L**ines **O**f **P**rogramming - A fast duplicate code detector.
|
|
4
4
|
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
Run instantly with npx (no install required):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx dslop .
|
|
11
|
+
```
|
|
12
|
+
|
|
5
13
|
## Installation
|
|
6
14
|
|
|
7
15
|
```bash
|
|
8
|
-
|
|
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
|
|
9
23
|
```
|
|
10
24
|
|
|
11
25
|
## Usage
|
|
12
26
|
|
|
13
27
|
```bash
|
|
14
28
|
# Scan current directory
|
|
15
|
-
|
|
29
|
+
dslop .
|
|
16
30
|
|
|
17
31
|
# Scan specific directory with options
|
|
18
|
-
|
|
32
|
+
dslop ./src -m 6 -s 80
|
|
33
|
+
|
|
34
|
+
# Only show duplicates across packages (great for monorepos)
|
|
35
|
+
dslop . --cross-package
|
|
19
36
|
|
|
20
37
|
# Output as JSON
|
|
21
|
-
|
|
38
|
+
dslop . --json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or run without installing:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx dslop .
|
|
45
|
+
bunx dslop .
|
|
46
|
+
pnpm dlx dslop .
|
|
22
47
|
```
|
|
23
48
|
|
|
24
49
|
## Options
|
|
@@ -43,26 +68,16 @@ bun run index.ts . --json
|
|
|
43
68
|
5. **Similarity Matching**: Uses Jaccard similarity on line sets for near-duplicates
|
|
44
69
|
6. **Filtering**: Removes overlapping blocks and deduplicates groups
|
|
45
70
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
All detection parameters are configurable in `src/constants.ts`:
|
|
71
|
+
## Monorepo Mode
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
// Block extraction
|
|
52
|
-
MAX_BLOCK_SIZE = 100 // Maximum lines per block
|
|
53
|
-
BLOCK_SIZE_MULTIPLIER = 1.5 // Growth factor for multi-size extraction
|
|
54
|
-
MIN_MEANINGFUL_LINE_RATIO = 0.6 // Skip blocks with too many comments/whitespace
|
|
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:
|
|
55
74
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
MAX_BLOCKS_FOR_SIMILARITY = 10000 // Skip similarity for large codebases
|
|
59
|
-
GROUP_OVERLAP_THRESHOLD = 0.5 // Dedup threshold
|
|
60
|
-
|
|
61
|
-
// Output
|
|
62
|
-
MAX_GROUPS_DETAILED = 20 // Max groups to show in detail
|
|
63
|
-
MAX_MATCHES_IN_SUMMARY = 5 // Max file matches per group
|
|
75
|
+
```bash
|
|
76
|
+
dslop . --cross-package
|
|
64
77
|
```
|
|
65
78
|
|
|
79
|
+
This filters results to only show duplicates where occurrences are in different `apps/`, `packages/`, or `libs/` directories.
|
|
80
|
+
|
|
66
81
|
## Example Output
|
|
67
82
|
|
|
68
83
|
```
|
|
@@ -101,11 +116,22 @@ SUMMARY
|
|
|
101
116
|
Average similarity: 95%
|
|
102
117
|
```
|
|
103
118
|
|
|
104
|
-
##
|
|
119
|
+
## Development
|
|
105
120
|
|
|
106
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
|
+
|
|
107
133
|
# Create standalone binary
|
|
108
|
-
bun build
|
|
134
|
+
bun run build:binary
|
|
109
135
|
```
|
|
110
136
|
|
|
111
137
|
## License
|
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 = "1.0.
|
|
6562
|
+
var VERSION = process.env.npm_package_version || "1.0.2";
|
|
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.
|
|
3
|
+
"version": "1.0.2",
|
|
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",
|
|
@@ -13,9 +13,12 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"dev": "bun run --watch index.ts",
|
|
15
15
|
"start": "bun run index.ts",
|
|
16
|
-
"build": "bun build ./index.ts --outdir ./dist --target node --format esm && sed -i '' '1,3d' ./dist/index.js && echo '#!/usr/bin/env node\n' | cat - ./dist/index.js > temp && mv temp ./dist/index.js && chmod +x ./dist/index.js",
|
|
16
|
+
"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",
|
|
17
17
|
"build:binary": "bun build --compile ./index.ts --outfile dslop",
|
|
18
|
-
"prepublishOnly": "bun run build"
|
|
18
|
+
"prepublishOnly": "bun run build",
|
|
19
|
+
"release": "npm version patch && git push && git push --tags && npm publish",
|
|
20
|
+
"release:minor": "npm version minor && git push && git push --tags && npm publish",
|
|
21
|
+
"release:major": "npm version major && git push && git push --tags && npm publish"
|
|
19
22
|
},
|
|
20
23
|
"keywords": [
|
|
21
24
|
"duplicate",
|