@runtypelabs/cli 0.2.4 → 0.2.5

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
@@ -158,6 +158,8 @@ init_cjs_shims();
158
158
  var import_commander20 = require("commander");
159
159
  var import_chalk24 = __toESM(require("chalk"));
160
160
  var import_dotenv = require("dotenv");
161
+ var import_fs7 = require("fs");
162
+ var import_path4 = require("path");
161
163
 
162
164
  // src/commands/auth.ts
163
165
  init_cjs_shims();
@@ -186,20 +188,19 @@ var CallbackServer = class {
186
188
  this.codeReject = reject;
187
189
  });
188
190
  this.app.get("/callback", (req, res) => {
189
- const { token, code, error } = req.query;
191
+ const { token, error } = req.query;
190
192
  if (error) {
191
193
  res.send(this.errorHTML(error));
192
194
  this.codeReject(new Error(error));
193
195
  return;
194
196
  }
195
- const authToken = token || code;
196
- if (!authToken) {
197
+ if (!token) {
197
198
  res.send(this.errorHTML("No authentication token received"));
198
199
  this.codeReject(new Error("No authentication token received"));
199
200
  return;
200
201
  }
201
202
  res.send(this.successHTML());
202
- this.codeResolve(authToken);
203
+ this.codeResolve(token);
203
204
  setTimeout(() => this.stop(), 1e3);
204
205
  });
205
206
  this.app.get("/health", (_req, res) => {
@@ -4498,8 +4499,17 @@ flowVersionsCommand.command("publish <flowId>").description("Publish a version")
4498
4499
  // src/index.ts
4499
4500
  init_credential_store();
4500
4501
  (0, import_dotenv.config)();
4502
+ function getPackageVersion() {
4503
+ try {
4504
+ const pkgPath = (0, import_path4.join)(__dirname, "..", "package.json");
4505
+ const pkg = JSON.parse((0, import_fs7.readFileSync)(pkgPath, "utf-8"));
4506
+ return pkg.version || "0.0.0";
4507
+ } catch {
4508
+ return "0.0.0";
4509
+ }
4510
+ }
4501
4511
  var program = new import_commander20.Command();
4502
- program.name("runtype").description("CLI for Runtype AI Platform").version("0.1.0").option("-v, --verbose", "Enable verbose output").option("--api-url <url>", "Override API URL").option("--json", "Output in JSON format");
4512
+ program.name("runtype").description("CLI for Runtype AI Platform").version(getPackageVersion()).option("-v, --verbose", "Enable verbose output").option("--api-url <url>", "Override API URL").option("--json", "Output in JSON format");
4503
4513
  program.addCommand(initCommand);
4504
4514
  program.addCommand(authCommand);
4505
4515
  program.addCommand(flowsCommand);
@@ -4536,7 +4546,7 @@ try {
4536
4546
  } else if (commanderError.code === "commander.unknownOption") {
4537
4547
  console.error(import_chalk24.default.red(`Error: ${commanderError.message}`));
4538
4548
  process.exit(1);
4539
- } else if (commanderError.code === "commander.help") {
4549
+ } else if (commanderError.code === "commander.help" || commanderError.code === "commander.version") {
4540
4550
  process.exit(0);
4541
4551
  } else {
4542
4552
  console.error(import_chalk24.default.red("An unexpected error occurred:"));