@rogatio/cli 5.7.1 → 5.8.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/README.md CHANGED
@@ -36,7 +36,7 @@ rogatio <command> [options]
36
36
 
37
37
  | Command | Description |
38
38
  | --- | --- |
39
- | `rogatio edit [path]` | Launch the browser editor for `.rogatio.json`. |
39
+ | `rogatio edit [path]` | Launch the browser editor for `.rogatio.json`. `--port <n>` fixes the port; `--no-open` skips opening a browser. |
40
40
  | `rogatio verify [path]` | Validate a `.rogatio.json` file (schema + compiler). |
41
41
  | `rogatio test [path] [url...]` | Run offline dry-run tests against `.rogatio.json`. |
42
42
  | `rogatio ai <setup\|ls\|show\|delete\|test>` | AI provider configuration. `setup` interactive; `ls` list; `show` redacted; `delete` remove; `test` connection. |
@@ -22832,6 +22832,7 @@ Arguments:
22832
22832
 
22833
22833
  Options:
22834
22834
  --port <n> Fixed port for editor server (default: random)
22835
+ --no-open Start the editor server without opening a browser
22835
22836
  --help, -h Show this help
22836
22837
 
22837
22838
  The editor runs in your default browser and communicates with a local server
@@ -23115,7 +23116,6 @@ function redactKey(key) {
23115
23116
  import { resolve as resolve4 } from "node:path";
23116
23117
 
23117
23118
  // packages/cli/src/server/http.ts
23118
- import { randomInt } from "node:crypto";
23119
23119
  import {
23120
23120
  createServer as createHttpServer
23121
23121
  } from "node:http";
@@ -23141,6 +23141,16 @@ function createServer2(handler, options = {}) {
23141
23141
  });
23142
23142
  });
23143
23143
  }
23144
+ function boundPort() {
23145
+ const address = server.address();
23146
+ if (address === null || typeof address === "string") {
23147
+ throw new HttpServerError(
23148
+ "listen-failed",
23149
+ "Failed to resolve bound port after listen"
23150
+ );
23151
+ }
23152
+ return address.port;
23153
+ }
23144
23154
  return {
23145
23155
  get port() {
23146
23156
  if (port === null)
@@ -23163,32 +23173,18 @@ function createServer2(handler, options = {}) {
23163
23173
  );
23164
23174
  }
23165
23175
  }
23166
- const maxRetries = 8;
23167
- let lastError = null;
23168
- for (let attempt = 0; attempt < maxRetries; attempt++) {
23169
- const candidatePort = randomInt(1024, 65535);
23170
- try {
23171
- await listenOn(candidatePort);
23172
- port = candidatePort;
23173
- started = true;
23174
- return;
23175
- } catch (e) {
23176
- lastError = e;
23177
- const code = e.code;
23178
- if (code !== "EADDRINUSE" && code !== "EACCES") {
23179
- throw new HttpServerError(
23180
- "listen-failed",
23181
- `Failed to start server: ${e}`,
23182
- e
23183
- );
23184
- }
23185
- }
23176
+ try {
23177
+ await listenOn(0);
23178
+ port = boundPort();
23179
+ started = true;
23180
+ } catch (e) {
23181
+ if (e instanceof HttpServerError) throw e;
23182
+ throw new HttpServerError(
23183
+ "listen-failed",
23184
+ `Failed to start server: ${e}`,
23185
+ e
23186
+ );
23186
23187
  }
23187
- throw new HttpServerError(
23188
- "port-exhausted",
23189
- `Failed to bind to port after ${maxRetries} attempts`,
23190
- lastError ?? void 0
23191
- );
23192
23188
  },
23193
23189
  async stop() {
23194
23190
  if (!started) return;
@@ -24390,6 +24386,7 @@ async function editCommand(args, options = {}) {
24390
24386
  const storage = options.storage ?? createJsonFileProjectStorage();
24391
24387
  const positionalArgs = [];
24392
24388
  let port;
24389
+ let noOpen = false;
24393
24390
  for (let i = 0; i < args.length; i++) {
24394
24391
  const arg = args[i];
24395
24392
  if (arg === "--port" && i + 1 < args.length) {
@@ -24399,6 +24396,8 @@ async function editCommand(args, options = {}) {
24399
24396
  return { exitCode: Promise.resolve(2), shutdown: () => {
24400
24397
  } };
24401
24398
  }
24399
+ } else if (arg === "--no-open") {
24400
+ noOpen = true;
24402
24401
  } else if (!arg.startsWith("-")) {
24403
24402
  positionalArgs.push(arg);
24404
24403
  } else if (arg === "--help") {
@@ -24510,12 +24509,16 @@ async function editCommand(args, options = {}) {
24510
24509
  shutdownCalled = true;
24511
24510
  server.stop();
24512
24511
  }
24513
- const browserLaunched = await (customLaunchBrowser ?? launchBrowser)(
24514
- editorUrl
24515
- );
24516
- if (!browserLaunched) {
24512
+ if (!noOpen) {
24513
+ const browserLaunched = await (customLaunchBrowser ?? launchBrowser)(
24514
+ editorUrl
24515
+ );
24516
+ if (!browserLaunched) {
24517
+ console.log(`Editor available at: ${editorUrl}`);
24518
+ console.log("Open this URL in your browser to edit the project.");
24519
+ }
24520
+ } else {
24517
24521
  console.log(`Editor available at: ${editorUrl}`);
24518
- console.log("Open this URL in your browser to edit the project.");
24519
24522
  }
24520
24523
  const exitCodePromise = new Promise((resolve9) => {
24521
24524
  const checkShutdown = setInterval(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogatio/cli",
3
- "version": "5.7.1",
3
+ "version": "5.8.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Local-first browser request and response rules — editor host, file verification, test runner, and runtime dispatch.",