@malloy-publisher/server 0.0.56 → 0.0.57
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/instrumentation.js +133 -48
- package/dist/server.js +36174 -35946
- package/package.json +3 -3
- package/src/cli.ts +88 -0
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloy-publisher/server",
|
|
3
3
|
"description": "Malloy Publisher Server",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.57",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"malloy-publisher": "dist/
|
|
7
|
+
"malloy-publisher": "dist/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "bun test ./**/*.spec.ts",
|
|
14
|
-
"build": "bun generate-api-types && NODE_ENV=production bun build src/server.ts src/instrumentation.ts --outdir dist --target bun && bun run build:app",
|
|
14
|
+
"build": "bun generate-api-types && NODE_ENV=production bun build src/cli.ts src/server.ts src/instrumentation.ts --outdir dist --target bun && bun run build:app && chmod +x dist/cli.js",
|
|
15
15
|
"start": "bun run ./dist/server.js",
|
|
16
16
|
"start:dev": "NODE_ENV=development bun --watch src/server.ts",
|
|
17
17
|
"start:instrumented": "bun run --preload ./dist/instrumentation.js ./dist/server.js",
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from "fs";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
|
|
6
|
+
function parseArgs() {
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const options: Record<string, string | number | boolean> = {};
|
|
9
|
+
|
|
10
|
+
for (let i = 0; i < args.length; i++) {
|
|
11
|
+
const arg = args[i];
|
|
12
|
+
if (arg.startsWith("--")) {
|
|
13
|
+
const key = arg.slice(2);
|
|
14
|
+
const value = args[i + 1];
|
|
15
|
+
if (value && !value.startsWith("--")) {
|
|
16
|
+
options[key] = value;
|
|
17
|
+
i++; // Skip next arg since we used it as value
|
|
18
|
+
} else {
|
|
19
|
+
options[key] = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return options;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function showHelp() {
|
|
28
|
+
const packageJsonPath = join(__dirname, "../package.json");
|
|
29
|
+
let version = "unknown";
|
|
30
|
+
try {
|
|
31
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
32
|
+
version = packageJson.version;
|
|
33
|
+
} catch {
|
|
34
|
+
// ignore
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log(`Malloy Publisher Server v${version}`);
|
|
38
|
+
console.log("");
|
|
39
|
+
console.log("Usage: malloy-publisher [options]");
|
|
40
|
+
console.log("");
|
|
41
|
+
console.log("Options:");
|
|
42
|
+
console.log(
|
|
43
|
+
" --port <number> Port to run the server on (default: 4000)",
|
|
44
|
+
);
|
|
45
|
+
console.log(
|
|
46
|
+
" --host <string> Host to bind the server to (default: localhost)",
|
|
47
|
+
);
|
|
48
|
+
console.log(
|
|
49
|
+
" --server_root <path> Root directory to serve files from (default: .)",
|
|
50
|
+
);
|
|
51
|
+
console.log(" --mcp_port <number> Port for MCP server (default: 4040)");
|
|
52
|
+
console.log(" --help, -h Show this help message");
|
|
53
|
+
console.log("");
|
|
54
|
+
console.log("Environment variables:");
|
|
55
|
+
console.log(" PUBLISHER_PORT Same as --port");
|
|
56
|
+
console.log(" PUBLISHER_HOST Same as --host");
|
|
57
|
+
console.log(" SERVER_ROOT Same as --server_root");
|
|
58
|
+
console.log(" MCP_PORT Same as --mcp_port");
|
|
59
|
+
console.log(' NODE_ENV Set to "development" for dev mode');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function main() {
|
|
63
|
+
const options = parseArgs();
|
|
64
|
+
|
|
65
|
+
if (options.help || options.h) {
|
|
66
|
+
showHelp();
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Set environment variables from CLI args
|
|
71
|
+
if (options.port) {
|
|
72
|
+
process.env.PUBLISHER_PORT = String(options.port);
|
|
73
|
+
}
|
|
74
|
+
if (options.host) {
|
|
75
|
+
process.env.PUBLISHER_HOST = String(options.host);
|
|
76
|
+
}
|
|
77
|
+
if (options.server_root) {
|
|
78
|
+
process.env.SERVER_ROOT = String(options.server_root);
|
|
79
|
+
}
|
|
80
|
+
if (options.mcp_port) {
|
|
81
|
+
process.env.MCP_PORT = String(options.mcp_port);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Import and start the server
|
|
85
|
+
await import("./server");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
main().catch(console.error);
|