fallow 0.1.0 → 0.1.4
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 +73 -0
- package/bin/fallow +20 -13
- package/package.json +21 -8
- package/scripts/postinstall.js +26 -12
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# fallow
|
|
2
|
+
|
|
3
|
+
Find dead code in JavaScript and TypeScript projects. Written in Rust.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/BartWaardenburg/fallow/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/fallow)
|
|
7
|
+
[](https://github.com/bartwaardenburg/fallow/blob/main/LICENSE)
|
|
8
|
+
|
|
9
|
+
Fallow detects unused files, exports, dependencies, types, enum members, and class members across your codebase. It is a drop-in alternative to [knip](https://knip.dev) that runs **25-50x faster** on real-world projects by using the [Oxc](https://oxc.rs) parser instead of the TypeScript compiler.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g fallow
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Analyze your project
|
|
21
|
+
fallow check
|
|
22
|
+
|
|
23
|
+
# Watch mode
|
|
24
|
+
fallow watch
|
|
25
|
+
|
|
26
|
+
# Auto-fix unused exports and dependencies
|
|
27
|
+
fallow fix --dry-run
|
|
28
|
+
fallow fix
|
|
29
|
+
|
|
30
|
+
# JSON output for CI
|
|
31
|
+
fallow check --format json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## What it finds
|
|
35
|
+
|
|
36
|
+
1. **Unused files** - files not imported anywhere
|
|
37
|
+
2. **Unused exports** - exported symbols nobody imports
|
|
38
|
+
3. **Unused types** - exported type aliases and interfaces
|
|
39
|
+
4. **Unused dependencies** - packages in package.json not imported
|
|
40
|
+
5. **Unused devDependencies** - dev packages not referenced
|
|
41
|
+
6. **Unused enum members** - enum variants never accessed
|
|
42
|
+
7. **Unused class members** - methods/properties never used
|
|
43
|
+
8. **Unresolved imports** - imports that don't resolve to a file
|
|
44
|
+
9. **Unlisted dependencies** - imported packages not in package.json
|
|
45
|
+
10. **Duplicate exports** - same symbol exported from multiple files
|
|
46
|
+
|
|
47
|
+
## Framework support
|
|
48
|
+
|
|
49
|
+
Auto-detects and configures entry points for: Next.js, Vite, Vitest, Jest, Storybook, Remix, Astro, Nuxt, Angular, Playwright, Prisma, ESLint, TypeScript, Webpack, Tailwind, GraphQL Codegen, React Router.
|
|
50
|
+
|
|
51
|
+
## Configuration
|
|
52
|
+
|
|
53
|
+
Create a `fallow.toml` in your project root:
|
|
54
|
+
|
|
55
|
+
```toml
|
|
56
|
+
[entry]
|
|
57
|
+
patterns = ["src/index.ts", "src/main.ts"]
|
|
58
|
+
|
|
59
|
+
[ignore]
|
|
60
|
+
files = ["**/*.test.ts", "**/*.spec.ts"]
|
|
61
|
+
exports = ["src/public-api.ts"]
|
|
62
|
+
dependencies = ["@types/*"]
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Or generate one: `fallow init`
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
Full documentation at [github.com/bartwaardenburg/fallow](https://github.com/bartwaardenburg/fallow).
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|
package/bin/fallow
CHANGED
|
@@ -4,26 +4,33 @@ const { execFileSync } = require('child_process');
|
|
|
4
4
|
const { join } = require('path');
|
|
5
5
|
const { existsSync } = require('fs');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'linux-x64': '@nicholasgasior/fallow-linux-x64-gnu',
|
|
11
|
-
'linux-arm64': '@nicholasgasior/fallow-linux-arm64-gnu',
|
|
12
|
-
'win32-x64': '@nicholasgasior/fallow-win32-x64-msvc',
|
|
13
|
-
};
|
|
7
|
+
function getPlatformPackage() {
|
|
8
|
+
const platform = process.platform;
|
|
9
|
+
const arch = process.arch;
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
if (platform === 'win32' && arch === 'x64') {
|
|
12
|
+
return '@fallow-cli/win32-x64-msvc';
|
|
13
|
+
}
|
|
14
|
+
if (platform === 'darwin') {
|
|
15
|
+
return `@fallow-cli/darwin-${arch}`;
|
|
16
|
+
}
|
|
17
|
+
if (platform === 'linux') {
|
|
18
|
+
const { familySync } = require('detect-libc');
|
|
19
|
+
const libc = familySync() === 'musl' ? 'musl' : 'gnu';
|
|
20
|
+
return `@fallow-cli/linux-${arch}-${libc}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const pkg = getPlatformPackage();
|
|
17
27
|
|
|
18
28
|
if (!pkg) {
|
|
19
|
-
console.error(`Unsupported platform: ${
|
|
20
|
-
console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(', ')}`);
|
|
29
|
+
console.error(`Unsupported platform: ${process.platform}-${process.arch}`);
|
|
21
30
|
process.exit(1);
|
|
22
31
|
}
|
|
23
32
|
|
|
24
33
|
let binaryPath;
|
|
25
|
-
|
|
26
|
-
// Try to find the binary in node_modules
|
|
27
34
|
try {
|
|
28
35
|
const pkgDir = require.resolve(`${pkg}/package.json`);
|
|
29
36
|
const binaryName = process.platform === 'win32' ? 'fallow.exe' : 'fallow';
|
package/package.json
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fallow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Find unused files, exports, and dependencies in JavaScript/TypeScript projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/
|
|
8
|
+
"url": "git+https://github.com/BartWaardenburg/fallow.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/BartWaardenburg/fallow",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/BartWaardenburg/fallow/issues"
|
|
9
13
|
},
|
|
10
14
|
"keywords": [
|
|
11
15
|
"dead-code",
|
|
@@ -17,21 +21,30 @@
|
|
|
17
21
|
"typescript",
|
|
18
22
|
"javascript"
|
|
19
23
|
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=16"
|
|
26
|
+
},
|
|
20
27
|
"bin": {
|
|
21
28
|
"fallow": "bin/fallow"
|
|
22
29
|
},
|
|
23
30
|
"files": [
|
|
24
31
|
"bin",
|
|
25
|
-
"scripts"
|
|
32
|
+
"scripts",
|
|
33
|
+
"README.md"
|
|
26
34
|
],
|
|
27
35
|
"scripts": {
|
|
28
36
|
"postinstall": "node scripts/postinstall.js"
|
|
29
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"detect-libc": "^2.0.0"
|
|
40
|
+
},
|
|
30
41
|
"optionalDependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
42
|
+
"@fallow-cli/darwin-arm64": "0.1.4",
|
|
43
|
+
"@fallow-cli/darwin-x64": "0.1.4",
|
|
44
|
+
"@fallow-cli/linux-x64-gnu": "0.1.4",
|
|
45
|
+
"@fallow-cli/linux-arm64-gnu": "0.1.4",
|
|
46
|
+
"@fallow-cli/linux-x64-musl": "0.1.4",
|
|
47
|
+
"@fallow-cli/linux-arm64-musl": "0.1.4",
|
|
48
|
+
"@fallow-cli/win32-x64-msvc": "0.1.4"
|
|
36
49
|
}
|
|
37
50
|
}
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
// Verify the correct platform-specific package was installed
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
'linux-x64': '@nicholasgasior/fallow-linux-x64-gnu',
|
|
6
|
-
'linux-arm64': '@nicholasgasior/fallow-linux-arm64-gnu',
|
|
7
|
-
'win32-x64': '@nicholasgasior/fallow-win32-x64-msvc',
|
|
8
|
-
};
|
|
2
|
+
function getPlatformPackage() {
|
|
3
|
+
const platform = process.platform;
|
|
4
|
+
const arch = process.arch;
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
if (platform === 'win32' && arch === 'x64') {
|
|
7
|
+
return '@fallow-cli/win32-x64-msvc';
|
|
8
|
+
}
|
|
9
|
+
if (platform === 'darwin') {
|
|
10
|
+
return `@fallow-cli/darwin-${arch}`;
|
|
11
|
+
}
|
|
12
|
+
if (platform === 'linux') {
|
|
13
|
+
try {
|
|
14
|
+
const { familySync } = require('detect-libc');
|
|
15
|
+
const libc = familySync() === 'musl' ? 'musl' : 'gnu';
|
|
16
|
+
return `@fallow-cli/linux-${arch}-${libc}`;
|
|
17
|
+
} catch {
|
|
18
|
+
return `@fallow-cli/linux-${arch}-gnu`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const pkg = getPlatformPackage();
|
|
12
26
|
|
|
13
27
|
if (!pkg) {
|
|
14
28
|
console.warn(
|
|
15
|
-
`fallow: No prebuilt binary for ${
|
|
16
|
-
`You can build from source: https://github.com/
|
|
29
|
+
`fallow: No prebuilt binary for ${process.platform}-${process.arch}. ` +
|
|
30
|
+
`You can build from source: https://github.com/bartwaardenburg/fallow`
|
|
17
31
|
);
|
|
18
32
|
process.exit(0);
|
|
19
33
|
}
|
|
@@ -24,6 +38,6 @@ try {
|
|
|
24
38
|
console.warn(
|
|
25
39
|
`fallow: Platform package ${pkg} not installed. ` +
|
|
26
40
|
`This may happen if you used --no-optional. ` +
|
|
27
|
-
`Run 'npm install
|
|
41
|
+
`Run 'npm install' to fix.`
|
|
28
42
|
);
|
|
29
43
|
}
|