fallow 0.1.0

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/bin/fallow ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require('child_process');
4
+ const { join } = require('path');
5
+ const { existsSync } = require('fs');
6
+
7
+ const PLATFORMS = {
8
+ 'darwin-arm64': '@nicholasgasior/fallow-darwin-arm64',
9
+ 'darwin-x64': '@nicholasgasior/fallow-darwin-x64',
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
+ };
14
+
15
+ const platformKey = `${process.platform}-${process.arch}`;
16
+ const pkg = PLATFORMS[platformKey];
17
+
18
+ if (!pkg) {
19
+ console.error(`Unsupported platform: ${platformKey}`);
20
+ console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(', ')}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ let binaryPath;
25
+
26
+ // Try to find the binary in node_modules
27
+ try {
28
+ const pkgDir = require.resolve(`${pkg}/package.json`);
29
+ const binaryName = process.platform === 'win32' ? 'fallow.exe' : 'fallow';
30
+ binaryPath = join(pkgDir, '..', binaryName);
31
+ } catch {
32
+ console.error(`Could not find ${pkg}. Run 'npm install' to install platform-specific binary.`);
33
+ process.exit(1);
34
+ }
35
+
36
+ if (!existsSync(binaryPath)) {
37
+ console.error(`Binary not found at ${binaryPath}`);
38
+ process.exit(1);
39
+ }
40
+
41
+ try {
42
+ execFileSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
43
+ } catch (e) {
44
+ if (e.status !== undefined) {
45
+ process.exit(e.status);
46
+ }
47
+ throw e;
48
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "fallow",
3
+ "version": "0.1.0",
4
+ "description": "Find unused files, exports, and dependencies in JavaScript/TypeScript projects",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nicholasgasior/fallow"
9
+ },
10
+ "keywords": [
11
+ "dead-code",
12
+ "unused",
13
+ "exports",
14
+ "dependencies",
15
+ "lint",
16
+ "analyzer",
17
+ "typescript",
18
+ "javascript"
19
+ ],
20
+ "bin": {
21
+ "fallow": "bin/fallow"
22
+ },
23
+ "files": [
24
+ "bin",
25
+ "scripts"
26
+ ],
27
+ "scripts": {
28
+ "postinstall": "node scripts/postinstall.js"
29
+ },
30
+ "optionalDependencies": {
31
+ "@nicholasgasior/fallow-darwin-arm64": "0.1.0",
32
+ "@nicholasgasior/fallow-darwin-x64": "0.1.0",
33
+ "@nicholasgasior/fallow-linux-x64-gnu": "0.1.0",
34
+ "@nicholasgasior/fallow-linux-arm64-gnu": "0.1.0",
35
+ "@nicholasgasior/fallow-win32-x64-msvc": "0.1.0"
36
+ }
37
+ }
@@ -0,0 +1,29 @@
1
+ // Verify the correct platform-specific package was installed
2
+ const PLATFORMS = {
3
+ 'darwin-arm64': '@nicholasgasior/fallow-darwin-arm64',
4
+ 'darwin-x64': '@nicholasgasior/fallow-darwin-x64',
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
+ };
9
+
10
+ const platformKey = `${process.platform}-${process.arch}`;
11
+ const pkg = PLATFORMS[platformKey];
12
+
13
+ if (!pkg) {
14
+ console.warn(
15
+ `fallow: No prebuilt binary for ${platformKey}. ` +
16
+ `You can build from source: https://github.com/nicholasgasior/fallow`
17
+ );
18
+ process.exit(0);
19
+ }
20
+
21
+ try {
22
+ require.resolve(pkg);
23
+ } catch {
24
+ console.warn(
25
+ `fallow: Platform package ${pkg} not installed. ` +
26
+ `This may happen if you used --no-optional. ` +
27
+ `Run 'npm install ${pkg}' to fix.`
28
+ );
29
+ }