reelforge 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.
@@ -44,10 +44,19 @@ async function browserOAuthFlow(serverUrl) {
44
44
  const token = url.searchParams.get("token");
45
45
  const errCode = url.searchParams.get("error");
46
46
  const finish = (statusCode, title, body, outcome) => {
47
- res.writeHead(statusCode, { "Content-Type": "text/html; charset=utf-8" }).end(`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><title>ReelForge CLI</title><style>body{font-family:-apple-system,system-ui,"Segoe UI",sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0;background:#fafaf7;color:#222}div{text-align:center;max-width:24rem;padding:1.5rem}h1{font-size:1.5rem;margin:0 0 .5rem;font-weight:600}p{color:#666;font-size:.875rem;line-height:1.5}</style></head><body><div><h1>${title}</h1><p>${body}</p></div><script>setTimeout(()=>window.close?.(),2000)</script></body></html>`);
47
+ res.writeHead(statusCode, {
48
+ "Content-Type": "text/html; charset=utf-8",
49
+ // Tell the browser to drop the socket — otherwise Node's event
50
+ // loop is held open by lingering keep-alive connections and the
51
+ // CLI hangs after a successful login.
52
+ Connection: "close",
53
+ }).end(`<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><title>ReelForge CLI</title><style>body{font-family:-apple-system,system-ui,"Segoe UI",sans-serif;display:flex;align-items:center;justify-content:center;min-height:100vh;margin:0;background:#fafaf7;color:#222}div{text-align:center;max-width:24rem;padding:1.5rem}h1{font-size:1.5rem;margin:0 0 .5rem;font-weight:600}p{color:#666;font-size:.875rem;line-height:1.5}</style></head><body><div><h1>${title}</h1><p>${body}</p></div><script>setTimeout(()=>window.close?.(),2000)</script></body></html>`);
48
54
  if (timer)
49
55
  clearTimeout(timer);
50
56
  server.close();
57
+ // Force-drop any remaining keep-alive sockets so the process can exit
58
+ // immediately (Node 18.2+).
59
+ server.closeAllConnections?.();
51
60
  if (outcome.ok)
52
61
  resolve(outcome.token);
53
62
  else
package/dist/index.js CHANGED
@@ -4,9 +4,14 @@
4
4
  * Every leaf command supports `--help`. Sub-groups (e.g. `reelforge llm`) print
5
5
  * a list of their sub-commands when invoked without arguments OR with `--help`.
6
6
  */
7
+ import { readFileSync } from "node:fs";
8
+ import { fileURLToPath } from "node:url";
9
+ import path from "node:path";
7
10
  import { Command } from "commander";
8
11
  import { setServer, setApiKey } from "./client.js";
9
12
  import { setOutputOptions } from "./utils/output.js";
13
+ const pkgPath = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "package.json");
14
+ const pkgVersion = JSON.parse(readFileSync(pkgPath, "utf-8")).version;
10
15
  import { registerAuth } from "./commands/auth.js";
11
16
  import { registerCreate } from "./commands/create.js";
12
17
  import { registerLlm } from "./commands/llm.js";
@@ -39,7 +44,7 @@ program
39
44
  "",
40
45
  "Run `reelforge <command> --help` for sub-command details, e.g. `reelforge llm chat --help`.",
41
46
  ].join("\n"))
42
- .version("0.1.0", "-v, --version", "show CLI version")
47
+ .version(pkgVersion, "-v, --version", "show CLI version")
43
48
  .helpOption("-h, --help", "show help")
44
49
  .addHelpCommand("help [command]", "show help for a command")
45
50
  .showHelpAfterError("(use `reelforge <command> --help` to see usage)")
@@ -94,6 +99,10 @@ registerHealth(program);
94
99
  async function main() {
95
100
  try {
96
101
  await program.parseAsync(process.argv);
102
+ // Explicit exit so any lingering handles (e.g. the OAuth local server's
103
+ // already-closed keep-alive sockets) don't keep the event loop alive
104
+ // after the command logically finished.
105
+ process.exit(0);
97
106
  }
98
107
  catch (err) {
99
108
  if (err instanceof ApiCallError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reelforge",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "CLI for ReelForge Studio — AI video engine. Every REST API exposed as a command, with --help on every level.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",