@anonymous-dev/0x0-server 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 0x0
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/bin/0x0-server ADDED
@@ -0,0 +1,109 @@
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 envPath = process.env.ZEROXZERO_SERVER_BIN_PATH
21
+ if (envPath) {
22
+ run(envPath)
23
+ }
24
+
25
+ const scriptPath = fs.realpathSync(__filename)
26
+ const scriptDir = path.dirname(scriptPath)
27
+
28
+ const platformMap = {
29
+ darwin: "darwin",
30
+ linux: "linux",
31
+ win32: "windows",
32
+ }
33
+ const archMap = {
34
+ x64: "x64",
35
+ arm64: "arm64",
36
+ arm: "arm",
37
+ }
38
+
39
+ let platform = platformMap[os.platform()]
40
+ if (!platform) {
41
+ platform = os.platform()
42
+ }
43
+ let arch = archMap[os.arch()]
44
+ if (!arch) {
45
+ arch = os.arch()
46
+ }
47
+ const base = "0x0-server-" + platform + "-" + arch
48
+ const binary = platform === "windows" ? "0x0-server.exe" : "0x0-server"
49
+ const scope = process.env.ZEROXZERO_NPM_SCOPE || "@anonymous-dev"
50
+
51
+ function findBinary(startDir) {
52
+ try {
53
+ const scoped = require.resolve(scope + "/" + base + "/package.json")
54
+ const candidate = path.join(path.dirname(scoped), "bin", binary)
55
+ if (fs.existsSync(candidate)) {
56
+ return candidate
57
+ }
58
+ } catch {}
59
+ let current = startDir
60
+ for (;;) {
61
+ const modules = path.join(current, "node_modules")
62
+ if (fs.existsSync(modules)) {
63
+ const entries = fs.readdirSync(modules)
64
+ for (const entry of entries) {
65
+ if (entry.startsWith("@")) {
66
+ const scoped = path.join(modules, entry)
67
+ if (!fs.existsSync(scoped)) {
68
+ continue
69
+ }
70
+ const items = fs.readdirSync(scoped)
71
+ for (const item of items) {
72
+ if (!item.startsWith(base)) {
73
+ continue
74
+ }
75
+ const candidate = path.join(scoped, item, "bin", binary)
76
+ if (fs.existsSync(candidate)) {
77
+ return candidate
78
+ }
79
+ }
80
+ continue
81
+ }
82
+ if (!entry.startsWith(base)) {
83
+ continue
84
+ }
85
+ const candidate = path.join(modules, entry, "bin", binary)
86
+ if (fs.existsSync(candidate)) {
87
+ return candidate
88
+ }
89
+ }
90
+ }
91
+ const parent = path.dirname(current)
92
+ if (parent === current) {
93
+ return
94
+ }
95
+ current = parent
96
+ }
97
+ }
98
+
99
+ const resolved = findBinary(scriptDir)
100
+ if (!resolved) {
101
+ console.error(
102
+ 'It seems that your package manager failed to install the right version of the 0x0-server CLI for your platform. You can try manually installing the "' +
103
+ base +
104
+ '" package',
105
+ )
106
+ process.exit(1)
107
+ }
108
+
109
+ run(resolved)
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@anonymous-dev/0x0-server",
3
+ "bin": {
4
+ "0x0-server": "./bin/0x0-server"
5
+ },
6
+ "scripts": {
7
+ "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
+ },
9
+ "version": "1.0.0",
10
+ "license": "MIT",
11
+ "optionalDependencies": {
12
+ "@anonymous-dev/0x0-server-darwin-x64": "1.0.0",
13
+ "@anonymous-dev/0x0-server-linux-arm64-musl": "1.0.0",
14
+ "@anonymous-dev/0x0-server-linux-arm64": "1.0.0",
15
+ "@anonymous-dev/0x0-server-linux-x64": "1.0.0",
16
+ "@anonymous-dev/0x0-server-windows-x64-baseline": "1.0.0",
17
+ "@anonymous-dev/0x0-server-linux-x64-musl": "1.0.0",
18
+ "@anonymous-dev/0x0-server-windows-x64": "1.0.0",
19
+ "@anonymous-dev/0x0-server-darwin-x64-baseline": "1.0.0",
20
+ "@anonymous-dev/0x0-server-darwin-arm64": "1.0.0",
21
+ "@anonymous-dev/0x0-server-linux-x64-baseline": "1.0.0",
22
+ "@anonymous-dev/0x0-server-linux-x64-baseline-musl": "1.0.0"
23
+ }
24
+ }
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import os from "os"
6
+ import { fileURLToPath } from "url"
7
+ import { createRequire } from "module"
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
+ const require = createRequire(import.meta.url)
11
+
12
+ function detectPlatformAndArch() {
13
+ let platform
14
+ switch (os.platform()) {
15
+ case "darwin":
16
+ platform = "darwin"
17
+ break
18
+ case "linux":
19
+ platform = "linux"
20
+ break
21
+ case "win32":
22
+ platform = "windows"
23
+ break
24
+ default:
25
+ platform = os.platform()
26
+ break
27
+ }
28
+
29
+ let arch
30
+ switch (os.arch()) {
31
+ case "x64":
32
+ arch = "x64"
33
+ break
34
+ case "arm64":
35
+ arch = "arm64"
36
+ break
37
+ case "arm":
38
+ arch = "arm"
39
+ break
40
+ default:
41
+ arch = os.arch()
42
+ break
43
+ }
44
+
45
+ return { platform, arch }
46
+ }
47
+
48
+ function findBinary() {
49
+ const { platform, arch } = detectPlatformAndArch()
50
+ const binaryName = platform === "windows" ? "0x0-server.exe" : "0x0-server"
51
+ const scope = process.env.ZEROXZERO_NPM_SCOPE || "@anonymous-dev"
52
+ const names = [`${scope}/0x0-server-${platform}-${arch}`, `0x0-server-${platform}-${arch}`]
53
+
54
+ for (const packageName of names) {
55
+ try {
56
+ const packageJsonPath = require.resolve(`${packageName}/package.json`)
57
+ const packageDir = path.dirname(packageJsonPath)
58
+ const binaryPath = path.join(packageDir, "bin", binaryName)
59
+ if (!fs.existsSync(binaryPath)) {
60
+ continue
61
+ }
62
+ return { binaryPath, binaryName }
63
+ } catch {
64
+ continue
65
+ }
66
+ }
67
+
68
+ throw new Error(`Could not find platform package for 0x0-server-${platform}-${arch}`)
69
+ }
70
+
71
+ async function main() {
72
+ try {
73
+ if (os.platform() === "win32") {
74
+ console.log("Windows detected: binary setup not needed (using packaged .exe)")
75
+ return
76
+ }
77
+
78
+ const { binaryPath } = findBinary()
79
+ console.log(`Platform binary verified at: ${binaryPath}`)
80
+ console.log("Wrapper script will handle binary execution")
81
+ } catch (error) {
82
+ console.error("Failed to setup 0x0-server binary:", error.message)
83
+ process.exit(1)
84
+ }
85
+ }
86
+
87
+ try {
88
+ main()
89
+ } catch (error) {
90
+ console.error("Postinstall script error:", error.message)
91
+ process.exit(0)
92
+ }