mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-21 06:12:17 +03:00
fix(cli): let restart honor PORT like serve and dashboard (#13327)
Same fix pattern #7049 already applied to `dashboard`: dropping the Commander default `20128` on `restart --port` lets `opts.port` stay undefined so `runServe()`s `opts.port ?? process.env.PORT ?? "20128"` fallback can actually reach `PORT`. 3 files, +36/-1. Thanks, @datrixlab — matching the existing precedent instead of inventing a new mechanism made this trivial to review. **Batch validation** — boarded with the other 10 PRs of your batch into one worktree cut from `release/v3.8.51`; every PR verified as an ancestor of the combined HEAD before validating. - Focused tests across all 11 PRs: **104/104 pass** on the combined tree. - Gates on the combined tree: `check-changelog-integrity` PASS, `check-complexity` PASS, `check-cognitive-complexity` PASS, `typecheck:core` PASS, `check:open-sse-typecheck` PASS. - `check-file-size` is red, but reproduces with byte-identical line counts on the pure `release/v3.8.51` tip (`open-sse/handlers/imageGeneration.ts` 3304, `open-sse/services/combo/roundRobinCombo.ts` 1221, `open-sse/utils/stream.ts` 3115). Inherited base-red, nothing added by this batch — it is also why this PR's "Fast Quality Gates" check was red.
This commit is contained in:
@@ -6,7 +6,8 @@ export function registerRestart(program) {
|
||||
program
|
||||
.command("restart")
|
||||
.description(t("restart.description"))
|
||||
.option("--port <port>", t("serve.port"), "20128")
|
||||
// No Commander default: runServe() falls back to PORT, then 20128 (#7049).
|
||||
.option("--port <port>", t("serve.port"))
|
||||
.action(async (opts) => {
|
||||
const exitCode = await runRestartCommand(opts);
|
||||
if (exitCode !== 0) process.exit(exitCode);
|
||||
|
||||
1
changelog.d/fixes/13327-cli-restart-honors-port.md
Normal file
1
changelog.d/fixes/13327-cli-restart-honors-port.md
Normal file
@@ -0,0 +1 @@
|
||||
- **fix(cli):** `omniroute restart` now comes back on the port set by `PORT` (shell or `<DATA_DIR>/.env`) instead of always 20128, like `serve` and `dashboard` ([#13327](https://github.com/diegosouzapw/OmniRoute/pull/13327))
|
||||
33
tests/unit/cli-restart-port.test.ts
Normal file
33
tests/unit/cli-restart-port.test.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* `omniroute restart` declared `--port` with a Commander default of "20128", so the
|
||||
* `opts.port ?? process.env.PORT` fallback in runServe() never reached PORT: a server
|
||||
* started on PORT=3000 (from the shell or <DATA_DIR>/.env) came back on 20128 after a
|
||||
* restart. #7049 fixed the same default on `dashboard`.
|
||||
*/
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { Command } from "commander";
|
||||
|
||||
async function parseRestart(args: string[]) {
|
||||
const { registerRestart } = await import("../../bin/cli/commands/restart.mjs");
|
||||
const program = new Command().exitOverride();
|
||||
registerRestart(program);
|
||||
let parsed: Record<string, unknown> | undefined;
|
||||
program.commands
|
||||
.find((cmd) => cmd.name() === "restart")!
|
||||
.action((opts: Record<string, unknown>) => {
|
||||
parsed = opts;
|
||||
});
|
||||
await program.parseAsync(["restart", ...args], { from: "user" });
|
||||
return parsed;
|
||||
}
|
||||
|
||||
test("restart without --port leaves the port to runServe's PORT fallback", async () => {
|
||||
const opts = await parseRestart([]);
|
||||
assert.equal(opts?.port, undefined);
|
||||
});
|
||||
|
||||
test("restart --port still passes the explicit port", async () => {
|
||||
const opts = await parseRestart(["--port", "3000"]);
|
||||
assert.equal(opts?.port, "3000");
|
||||
});
|
||||
Reference in New Issue
Block a user