syntaur 0.1.4 → 0.1.6
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/index.js
CHANGED
|
@@ -7221,6 +7221,9 @@ function createDashboardServer(options) {
|
|
|
7221
7221
|
// src/commands/dashboard.ts
|
|
7222
7222
|
init_paths();
|
|
7223
7223
|
init_fs();
|
|
7224
|
+
function didUserSpecifyDashboardPort(argv = process.argv) {
|
|
7225
|
+
return argv.some((arg) => arg === "--port" || arg.startsWith("--port="));
|
|
7226
|
+
}
|
|
7224
7227
|
function resolveDashboardMode(options) {
|
|
7225
7228
|
const devMode = Boolean(options.dev);
|
|
7226
7229
|
const serverOnly = Boolean(options.serverOnly || options.apiOnly);
|
|
@@ -7244,7 +7247,7 @@ async function isPortAvailable(port) {
|
|
|
7244
7247
|
tester.once("listening", () => {
|
|
7245
7248
|
tester.close(() => resolveAvailability(true));
|
|
7246
7249
|
});
|
|
7247
|
-
tester.listen(port
|
|
7250
|
+
tester.listen(port);
|
|
7248
7251
|
});
|
|
7249
7252
|
}
|
|
7250
7253
|
async function findAvailablePort(startPort, maxAttempts = 20) {
|
|
@@ -7262,11 +7265,24 @@ async function findAvailablePort(startPort, maxAttempts = 20) {
|
|
|
7262
7265
|
async function dashboardCommand(options) {
|
|
7263
7266
|
const config = await readConfig();
|
|
7264
7267
|
const missionsDir = config.defaultMissionDir;
|
|
7265
|
-
const
|
|
7266
|
-
if (isNaN(
|
|
7268
|
+
const requestedPort = parseInt(options.port, 10);
|
|
7269
|
+
if (isNaN(requestedPort) || requestedPort < 1 || requestedPort > 65535) {
|
|
7267
7270
|
throw new Error(`Invalid port "${options.port}". Must be a number between 1 and 65535.`);
|
|
7268
7271
|
}
|
|
7269
7272
|
const mode = resolveDashboardMode(options);
|
|
7273
|
+
let port = requestedPort;
|
|
7274
|
+
if (options.autoPort) {
|
|
7275
|
+
const availablePort = await findAvailablePort(requestedPort);
|
|
7276
|
+
if (availablePort === null) {
|
|
7277
|
+
throw new Error(
|
|
7278
|
+
`Could not find an available dashboard port starting at ${requestedPort}. Run "syntaur dashboard --port <number>" to choose one manually.`
|
|
7279
|
+
);
|
|
7280
|
+
}
|
|
7281
|
+
if (availablePort !== requestedPort) {
|
|
7282
|
+
console.log(`Port ${requestedPort} is busy. Launching the dashboard on port ${availablePort} instead.`);
|
|
7283
|
+
}
|
|
7284
|
+
port = availablePort;
|
|
7285
|
+
}
|
|
7270
7286
|
const server = createDashboardServer({
|
|
7271
7287
|
port,
|
|
7272
7288
|
missionsDir,
|
|
@@ -9437,7 +9453,11 @@ program.command("create-assignment").description("Create a new assignment within
|
|
|
9437
9453
|
});
|
|
9438
9454
|
program.command("dashboard").description("Start the local Syntaur dashboard web UI").option("--port <number>", "Port to run the dashboard on", "4800").option("--dev", "Run the dashboard with the Vite dev server", false).option("--server-only", "Run only the API server without any UI", false).option("--api-only", "Deprecated alias for --server-only", false).option("--no-open", "Do not automatically open the browser").action(async (options) => {
|
|
9439
9455
|
try {
|
|
9440
|
-
|
|
9456
|
+
const autoPort = !didUserSpecifyDashboardPort();
|
|
9457
|
+
await dashboardCommand({
|
|
9458
|
+
...options,
|
|
9459
|
+
autoPort
|
|
9460
|
+
});
|
|
9441
9461
|
} catch (error) {
|
|
9442
9462
|
console.error(
|
|
9443
9463
|
"Error:",
|