@ganglion/xacpx-relay 0.2.0 → 0.2.2
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/dist/cli.d.ts +7 -2
- package/dist/cli.js +5 -9
- package/package.json +1 -1
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
export interface RelayCliIo {
|
|
2
3
|
print(line: string): void;
|
|
3
4
|
}
|
|
@@ -6,9 +7,13 @@ export declare function defaultDbPath(): string;
|
|
|
6
7
|
/**
|
|
7
8
|
* Locates the bundled relay-web dashboard relative to the compiled cli.js.
|
|
8
9
|
* Returns the path only if `index.html` is present there; otherwise undefined.
|
|
9
|
-
*
|
|
10
|
+
*
|
|
11
|
+
* Resolves against this module's own URL (import.meta.url), NOT process.argv[1]:
|
|
12
|
+
* when invoked via the global `xacpx-relay` bin symlink, argv[1] is the symlink
|
|
13
|
+
* path (…/bin/xacpx-relay), not the real cli.js, so an argv-based path would
|
|
14
|
+
* mis-resolve. The `cliJsPath` param exists only for tests.
|
|
10
15
|
*/
|
|
11
|
-
export declare function resolveBundledWebRoot(): string | undefined;
|
|
16
|
+
export declare function resolveBundledWebRoot(cliJsPath?: string): string | undefined;
|
|
12
17
|
export interface StartOptions {
|
|
13
18
|
dbPath: string;
|
|
14
19
|
httpPort: number;
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
4
|
|
|
@@ -6,6 +7,7 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
6
7
|
import { existsSync } from "node:fs";
|
|
7
8
|
import { homedir } from "node:os";
|
|
8
9
|
import { dirname as dirname2, join, resolve } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
9
11
|
|
|
10
12
|
// packages/relay/src/server.ts
|
|
11
13
|
import { serve } from "@hono/node-server";
|
|
@@ -1041,13 +1043,8 @@ function parseCookie(header) {
|
|
|
1041
1043
|
function defaultDbPath() {
|
|
1042
1044
|
return join(homedir(), ".xacpx-relay", "relay.db");
|
|
1043
1045
|
}
|
|
1044
|
-
function resolveBundledWebRoot() {
|
|
1045
|
-
const
|
|
1046
|
-
if (!argv1)
|
|
1047
|
-
return;
|
|
1048
|
-
if (!argv1.endsWith("cli.js"))
|
|
1049
|
-
return;
|
|
1050
|
-
const here = dirname2(argv1);
|
|
1046
|
+
function resolveBundledWebRoot(cliJsPath = fileURLToPath(import.meta.url)) {
|
|
1047
|
+
const here = dirname2(cliJsPath);
|
|
1051
1048
|
const embedded = resolve(here, "relay-web");
|
|
1052
1049
|
if (existsSync(join(embedded, "index.html")))
|
|
1053
1050
|
return embedded;
|
|
@@ -1169,8 +1166,7 @@ async function runRelayCli(args, io) {
|
|
|
1169
1166
|
io.print(USAGE);
|
|
1170
1167
|
return 1;
|
|
1171
1168
|
}
|
|
1172
|
-
|
|
1173
|
-
if (isMain) {
|
|
1169
|
+
if (__require.main == __require.module) {
|
|
1174
1170
|
runRelayCli(process.argv.slice(2), { print: (line) => console.log(line) }).then((code) => process.exit(code), (error) => {
|
|
1175
1171
|
console.error(error instanceof Error ? error.message : String(error));
|
|
1176
1172
|
process.exit(1);
|