@betegon/sentry 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/sentry +76 -0
  2. package/package.json +23 -0
package/bin/sentry ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+
3
+ const childProcess = require("child_process")
4
+ const fs = require("fs")
5
+ const path = require("path")
6
+ const os = require("os")
7
+
8
+ function run(target) {
9
+ const result = childProcess.spawnSync(target, process.argv.slice(2), {
10
+ stdio: "inherit",
11
+ })
12
+ if (result.error) {
13
+ console.error(result.error.message)
14
+ process.exit(1)
15
+ }
16
+ const code = typeof result.status === "number" ? result.status : 0
17
+ process.exit(code)
18
+ }
19
+
20
+ const platformMap = {
21
+ darwin: "darwin",
22
+ linux: "linux",
23
+ win32: "windows",
24
+ }
25
+
26
+ const archMap = {
27
+ x64: "x64",
28
+ arm64: "arm64",
29
+ }
30
+
31
+ let platform = platformMap[os.platform()]
32
+ if (!platform) {
33
+ console.error(`Unsupported platform: ${os.platform()}`)
34
+ process.exit(1)
35
+ }
36
+
37
+ let arch = archMap[os.arch()]
38
+ if (!arch) {
39
+ console.error(`Unsupported architecture: ${os.arch()}`)
40
+ process.exit(1)
41
+ }
42
+
43
+ const packageName = `sentry-${platform}-${arch}`
44
+ const binaryName = platform === "windows" ? "sentry.exe" : "sentry"
45
+
46
+ function findBinary(startDir) {
47
+ let current = startDir
48
+ for (;;) {
49
+ const modules = path.join(current, "node_modules")
50
+ if (fs.existsSync(modules)) {
51
+ const candidate = path.join(modules, packageName, "bin", binaryName)
52
+ if (fs.existsSync(candidate)) {
53
+ return candidate
54
+ }
55
+ }
56
+ const parent = path.dirname(current)
57
+ if (parent === current) {
58
+ return null
59
+ }
60
+ current = parent
61
+ }
62
+ }
63
+
64
+ const scriptDir = path.dirname(fs.realpathSync(__filename))
65
+ const resolved = findBinary(scriptDir)
66
+
67
+ if (!resolved) {
68
+ console.error(
69
+ `Could not find the sentry binary for your platform.\n` +
70
+ `Expected package: ${packageName}\n` +
71
+ `You can try manually installing it: npm install ${packageName}`
72
+ )
73
+ process.exit(1)
74
+ }
75
+
76
+ run(resolved)
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@betegon/sentry",
3
+ "version": "0.1.0",
4
+ "description": "A gh-like CLI for Sentry",
5
+ "bin": {
6
+ "sentry": "./bin/sentry"
7
+ },
8
+ "optionalDependencies": {
9
+ "sentry-darwin-arm64": "0.1.0",
10
+ "sentry-darwin-x64": "0.1.0",
11
+ "sentry-linux-arm64": "0.1.0",
12
+ "sentry-linux-x64": "0.1.0",
13
+ "sentry-windows-x64": "0.1.0"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/betegon/sentry-cli-next"
18
+ },
19
+ "license": "MIT",
20
+ "engines": {
21
+ "node": ">=18"
22
+ }
23
+ }