@hlfbkd/berry 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.
Files changed (2) hide show
  1. package/bin/berry.js +54 -0
  2. package/package.json +21 -0
package/bin/berry.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ const { execFileSync } = require("child_process");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ const platform = process.platform;
7
+ const arch = process.arch;
8
+
9
+ // Map Node.js arch names to package names
10
+ const archMap = { x64: "x64", arm64: "arm64" };
11
+ const osMap = { darwin: "darwin", linux: "linux", win32: "windows" };
12
+
13
+ const mappedOs = osMap[platform];
14
+ const mappedArch = archMap[arch];
15
+
16
+ if (!mappedOs || !mappedArch) {
17
+ console.error(`Unsupported platform: ${platform}-${arch}`);
18
+ process.exit(1);
19
+ }
20
+
21
+ // Try to find the platform-specific package
22
+ const variants = [
23
+ `@hlfbkd/berry-${mappedOs}-${mappedArch}`,
24
+ `@hlfbkd/berry-${mappedOs}-${mappedArch}-baseline`,
25
+ ];
26
+
27
+ let binaryPath = null;
28
+
29
+ for (const variant of variants) {
30
+ try {
31
+ const pkgPath = require.resolve(`${variant}/package.json`);
32
+ const pkgDir = path.dirname(pkgPath);
33
+ const candidate = path.join(pkgDir, "bin", "berry");
34
+ if (fs.existsSync(candidate)) {
35
+ binaryPath = candidate;
36
+ break;
37
+ }
38
+ } catch {
39
+ // Package not installed, try next variant
40
+ }
41
+ }
42
+
43
+ if (!binaryPath) {
44
+ console.error(`Could not find berry binary for ${platform}-${arch}`);
45
+ console.error("Please try reinstalling: npm install -g @hlfbkd/berry");
46
+ process.exit(1);
47
+ }
48
+
49
+ // Execute the binary with all arguments
50
+ try {
51
+ execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
52
+ } catch (error) {
53
+ process.exit(error.status || 1);
54
+ }
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@hlfbkd/berry",
3
+ "version": "0.1.0",
4
+ "description": "Berry CLI - A tool for managing your development environment",
5
+ "bin": {
6
+ "berry": "./bin/berry.js"
7
+ },
8
+ "optionalDependencies": {
9
+ "@hlfbkd/berry-darwin-arm64": "0.1.0",
10
+ "@hlfbkd/berry-darwin-x64": "0.1.0",
11
+ "@hlfbkd/berry-darwin-x64-baseline": "0.1.0"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/geoffjay/berry.git"
16
+ },
17
+ "license": "MIT",
18
+ "engines": {
19
+ "node": ">=18"
20
+ }
21
+ }