fallow 0.1.1 → 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 ADDED
@@ -0,0 +1,73 @@
1
+ # fallow
2
+
3
+ Find dead code in JavaScript and TypeScript projects. Written in Rust.
4
+
5
+ [![CI](https://github.com/BartWaardenburg/fallow/actions/workflows/ci.yml/badge.svg)](https://github.com/BartWaardenburg/fallow/actions/workflows/ci.yml)
6
+ [![npm](https://img.shields.io/npm/v/fallow.svg)](https://www.npmjs.com/package/fallow)
7
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](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,42 +4,44 @@ const { execFileSync } = require('child_process');
4
4
  const { join } = require('path');
5
5
  const { existsSync } = require('fs');
6
6
 
7
- const PLATFORMS = {
8
- 'darwin-arm64': ['@fallow-cli/darwin-arm64'],
9
- 'darwin-x64': ['@fallow-cli/darwin-x64'],
10
- 'linux-x64': ['@fallow-cli/linux-x64-gnu', '@fallow-cli/linux-x64-musl'],
11
- 'linux-arm64': ['@fallow-cli/linux-arm64-gnu', '@fallow-cli/linux-arm64-musl'],
12
- 'win32-x64': ['@fallow-cli/win32-x64-msvc'],
13
- };
14
-
15
- const platformKey = `${process.platform}-${process.arch}`;
16
- const candidates = PLATFORMS[platformKey];
17
-
18
- if (!candidates) {
19
- console.error(`Unsupported platform: ${platformKey}`);
20
- console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(', ')}`);
7
+ function getPlatformPackage() {
8
+ const platform = process.platform;
9
+ const arch = process.arch;
10
+
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();
27
+
28
+ if (!pkg) {
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 each candidate package (gnu first, then musl fallback)
27
- for (const pkg of candidates) {
28
- try {
29
- const pkgDir = require.resolve(`${pkg}/package.json`);
30
- const binaryName = process.platform === 'win32' ? 'fallow.exe' : 'fallow';
31
- const candidate = join(pkgDir, '..', binaryName);
32
- if (existsSync(candidate)) {
33
- binaryPath = candidate;
34
- break;
35
- }
36
- } catch {
37
- // Package not installed, try next candidate
38
- }
34
+ try {
35
+ const pkgDir = require.resolve(`${pkg}/package.json`);
36
+ const binaryName = process.platform === 'win32' ? 'fallow.exe' : 'fallow';
37
+ binaryPath = join(pkgDir, '..', binaryName);
38
+ } catch {
39
+ console.error(`Could not find ${pkg}. Run 'npm install' to install platform-specific binary.`);
40
+ process.exit(1);
39
41
  }
40
42
 
41
- if (!binaryPath) {
42
- console.error(`Could not find fallow binary for ${platformKey}. Run 'npm install' to install platform-specific binary.`);
43
+ if (!existsSync(binaryPath)) {
44
+ console.error(`Binary not found at ${binaryPath}`);
43
45
  process.exit(1);
44
46
  }
45
47
 
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "fallow",
3
- "version": "0.1.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/bartwaardenburg/fallow"
8
+ "url": "git+https://github.com/BartWaardenburg/fallow.git"
9
9
  },
10
- "homepage": "https://github.com/bartwaardenburg/fallow",
10
+ "homepage": "https://github.com/BartWaardenburg/fallow",
11
11
  "bugs": {
12
- "url": "https://github.com/bartwaardenburg/fallow/issues"
12
+ "url": "https://github.com/BartWaardenburg/fallow/issues"
13
13
  },
14
14
  "keywords": [
15
15
  "dead-code",
@@ -29,18 +29,22 @@
29
29
  },
30
30
  "files": [
31
31
  "bin",
32
- "scripts"
32
+ "scripts",
33
+ "README.md"
33
34
  ],
34
35
  "scripts": {
35
36
  "postinstall": "node scripts/postinstall.js"
36
37
  },
38
+ "dependencies": {
39
+ "detect-libc": "^2.0.0"
40
+ },
37
41
  "optionalDependencies": {
38
- "@fallow-cli/darwin-arm64": "0.1.0",
39
- "@fallow-cli/darwin-x64": "0.1.0",
40
- "@fallow-cli/linux-x64-gnu": "0.1.0",
41
- "@fallow-cli/linux-arm64-gnu": "0.1.0",
42
- "@fallow-cli/linux-x64-musl": "0.1.0",
43
- "@fallow-cli/linux-arm64-musl": "0.1.0",
44
- "@fallow-cli/win32-x64-msvc": "0.1.0"
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"
45
49
  }
46
50
  }
@@ -1,35 +1,42 @@
1
1
  // Verify the correct platform-specific package was installed
2
- const PLATFORMS = {
3
- 'darwin-arm64': ['@fallow-cli/darwin-arm64'],
4
- 'darwin-x64': ['@fallow-cli/darwin-x64'],
5
- 'linux-x64': ['@fallow-cli/linux-x64-gnu', '@fallow-cli/linux-x64-musl'],
6
- 'linux-arm64': ['@fallow-cli/linux-arm64-gnu', '@fallow-cli/linux-arm64-musl'],
7
- 'win32-x64': ['@fallow-cli/win32-x64-msvc'],
8
- };
2
+ function getPlatformPackage() {
3
+ const platform = process.platform;
4
+ const arch = process.arch;
9
5
 
10
- const platformKey = `${process.platform}-${process.arch}`;
11
- const candidates = PLATFORMS[platformKey];
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
- if (!candidates) {
27
+ if (!pkg) {
14
28
  console.warn(
15
- `fallow: No prebuilt binary for ${platformKey}. ` +
29
+ `fallow: No prebuilt binary for ${process.platform}-${process.arch}. ` +
16
30
  `You can build from source: https://github.com/bartwaardenburg/fallow`
17
31
  );
18
32
  process.exit(0);
19
33
  }
20
34
 
21
- const found = candidates.some((pkg) => {
22
- try {
23
- require.resolve(`${pkg}/package.json`);
24
- return true;
25
- } catch {
26
- return false;
27
- }
28
- });
29
-
30
- if (!found) {
35
+ try {
36
+ require.resolve(pkg);
37
+ } catch {
31
38
  console.warn(
32
- `fallow: No platform package installed for ${platformKey}. ` +
39
+ `fallow: Platform package ${pkg} not installed. ` +
33
40
  `This may happen if you used --no-optional. ` +
34
41
  `Run 'npm install' to fix.`
35
42
  );