@corsair-dev/cli 0.1.10 → 0.1.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAsLA;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQhE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,kBAAkB,CAAC,EACxC,GAAG,EACH,UAAU,EACV,kBAA0B,GAC1B,EAAE;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B,eAqLA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAuLA;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQhE;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,kBAAkB,CAAC,EACxC,GAAG,EACH,UAAU,EACV,kBAA0B,GAC1B,EAAE;IACF,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B,eAqLA"}
package/dist/index.js CHANGED
@@ -2069,8 +2069,9 @@ var init_auth = __esm({
2069
2069
  });
2070
2070
 
2071
2071
  // index.ts
2072
- import fs2, { existsSync } from "fs";
2072
+ import fs2, { existsSync, realpathSync } from "fs";
2073
2073
  import path2 from "path";
2074
+ import { fileURLToPath } from "url";
2074
2075
  import babelPresetReact from "@babel/preset-react";
2075
2076
  import babelPresetTypeScript from "@babel/preset-typescript";
2076
2077
  import { loadConfig } from "c12";
@@ -2390,11 +2391,12 @@ function parseSetupArgs(args) {
2390
2391
  currentPlugin = null;
2391
2392
  continue;
2392
2393
  }
2394
+ if (arg.startsWith("--plugin=")) {
2395
+ currentPlugin = arg.slice("--plugin=".length);
2396
+ if (!credentials[currentPlugin]) credentials[currentPlugin] = {};
2397
+ continue;
2398
+ }
2393
2399
  if (arg.startsWith("--")) {
2394
- const name = arg.slice(2);
2395
- if (RESERVED_FLAGS.has(name)) continue;
2396
- currentPlugin = name;
2397
- credentials[currentPlugin] = {};
2398
2400
  continue;
2399
2401
  }
2400
2402
  if (currentPlugin && arg.includes("=")) {
@@ -2427,6 +2429,34 @@ function parseRunArgs(args) {
2427
2429
  }
2428
2430
  return { path: endpointPath, input, tenant };
2429
2431
  }
2432
+ function parseUiArgs(args) {
2433
+ let port;
2434
+ let open;
2435
+ for (let i = 0; i < args.length; i++) {
2436
+ const arg = args[i];
2437
+ if (arg === "--no-open") {
2438
+ open = false;
2439
+ continue;
2440
+ }
2441
+ if (arg === "--open") {
2442
+ open = true;
2443
+ continue;
2444
+ }
2445
+ if (arg === "--port" && args[i + 1]) {
2446
+ const next = args[++i];
2447
+ if (next) {
2448
+ const parsed = Number.parseInt(next, 10);
2449
+ if (Number.isFinite(parsed)) port = parsed;
2450
+ }
2451
+ continue;
2452
+ }
2453
+ if (arg.startsWith("--port=")) {
2454
+ const parsed = Number.parseInt(arg.slice("--port=".length), 10);
2455
+ if (Number.isFinite(parsed)) port = parsed;
2456
+ }
2457
+ }
2458
+ return { port, open };
2459
+ }
2430
2460
  function parseScriptArgs(args) {
2431
2461
  let code;
2432
2462
  let tenant;
@@ -2449,7 +2479,7 @@ function printHelp() {
2449
2479
  "Corsair CLI",
2450
2480
  "",
2451
2481
  "pnpm corsair setup Init (add -backfill to seed data)",
2452
- "pnpm corsair setup --<plugin> <field>=VALUE Set plugin credentials",
2482
+ "pnpm corsair setup --plugin=<id> <field>=VALUE Set plugin credentials",
2453
2483
  "pnpm corsair auth --plugin=<id> Start OAuth flow",
2454
2484
  "pnpm corsair auth --plugin=<id> --code=<code> Exchange OAuth code for tokens",
2455
2485
  "pnpm corsair auth --plugin=<id> --agent Run this if you are an agent (specific instructions to handle pending process)",
@@ -2458,6 +2488,7 @@ function printHelp() {
2458
2488
  " `pnpm corsair list --type=webhooks` to see webhook plugins",
2459
2489
  "pnpm corsair list [--plugin=<id>] [--type=api|webhooks|db] List endpoint paths (tip: pipe to grep to filter)",
2460
2490
  "pnpm corsair schema <path> Show schema for an endpoint/webhook/DB entity",
2491
+ "pnpm corsair ui [--port=4317] [--no-open] Open the Corsair Studio dashboard (requires @corsair-dev/studio)",
2461
2492
  'pnpm corsair script --code "<js>" [--tenant=<id>]',
2462
2493
  " corsair is injected; use return to output a value.",
2463
2494
  " IMPORTANT: Always filter results inline \u2014 you are the consumer of the return value, so returning full list responses wastes tokens.",
@@ -2644,6 +2675,40 @@ async function main() {
2644
2675
  }
2645
2676
  return;
2646
2677
  }
2678
+ if (command === "ui" || command === "studio") {
2679
+ const { port, open } = parseUiArgs(args.slice(1));
2680
+ let startStudio;
2681
+ try {
2682
+ const { createRequire } = await import("module");
2683
+ const { pathToFileURL } = await import("url");
2684
+ const req = createRequire(path2.join(cwd, "package.json"));
2685
+ const resolvedPath = req.resolve("@corsair-dev/studio/server");
2686
+ const mod = await import(pathToFileURL(resolvedPath).href);
2687
+ const candidate = mod.start ?? mod.startStudio;
2688
+ if (!candidate) {
2689
+ throw new Error("@corsair-dev/studio/server did not export `start`.");
2690
+ }
2691
+ startStudio = candidate;
2692
+ } catch (err) {
2693
+ const msg = err instanceof Error ? err.message : String(err);
2694
+ if (msg.includes("Cannot find package") || msg.includes("Cannot find module") || msg.includes("ERR_MODULE_NOT_FOUND") || msg.includes("MODULE_NOT_FOUND")) {
2695
+ console.error("[#corsair]: Corsair Studio is not installed.");
2696
+ console.error("[#corsair]: Install it with:");
2697
+ console.error("");
2698
+ console.error(" pnpm add -D @corsair-dev/studio");
2699
+ console.error("");
2700
+ process.exit(1);
2701
+ }
2702
+ throw err;
2703
+ }
2704
+ await startStudio({ cwd, port, open });
2705
+ await new Promise((resolve) => {
2706
+ const shutdown = () => resolve();
2707
+ process.once("SIGINT", shutdown);
2708
+ process.once("SIGTERM", shutdown);
2709
+ });
2710
+ return;
2711
+ }
2647
2712
  if (command === "schema") {
2648
2713
  const schemaPath = args[1];
2649
2714
  if (!schemaPath) {
@@ -2667,7 +2732,18 @@ async function main() {
2667
2732
  }
2668
2733
  printHelp();
2669
2734
  }
2670
- var possiblePaths, jitiOptions, isCorsairInstance, RESERVED_FLAGS, SHOW_RUN, isMainModule;
2735
+ function detectIsMainModule() {
2736
+ const argv1 = process.argv[1];
2737
+ if (!argv1) return false;
2738
+ try {
2739
+ const argvResolved = realpathSync(argv1);
2740
+ const selfResolved = realpathSync(fileURLToPath(import.meta.url));
2741
+ return argvResolved === selfResolved;
2742
+ } catch {
2743
+ return import.meta.url === `file://${argv1.replace(/\\/g, "/")}`;
2744
+ }
2745
+ }
2746
+ var possiblePaths, jitiOptions, isCorsairInstance, SHOW_RUN;
2671
2747
  var init_index = __esm({
2672
2748
  "index.ts"() {
2673
2749
  init_get_tsconfig_info();
@@ -2731,10 +2807,8 @@ var init_index = __esm({
2731
2807
  }
2732
2808
  return Object.keys(object).length > 0;
2733
2809
  };
2734
- RESERVED_FLAGS = /* @__PURE__ */ new Set(["backfill", "help", "h"]);
2735
2810
  SHOW_RUN = false;
2736
- isMainModule = import.meta.url === `file://${process.argv[1]?.replace(/\\/g, "/")}` || process.argv[1]?.includes("index.ts") || process.argv[1]?.includes("index.js") || import.meta.url.endsWith("/index.ts") || import.meta.url.endsWith("/index.js");
2737
- if (isMainModule) {
2811
+ if (detectIsMainModule()) {
2738
2812
  main().then(() => process.exit(0)).catch((e) => {
2739
2813
  console.error(e);
2740
2814
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/cli",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "@clack/prompts": "^1.0.0",
24
24
  "c12": "^3.3.3",
25
25
  "zod": "^3.25.76",
26
- "corsair": "0.1.56"
26
+ "corsair": "0.1.59"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/jest": "^29.5.14",
@@ -31,7 +31,7 @@
31
31
  "dotenv": "^17.2.3",
32
32
  "jest": "^29.7.0",
33
33
  "jiti": "^2.6.1",
34
- "ts-jest": "^29.1.1",
34
+ "ts-jest": "^29.4.9",
35
35
  "ts-node": "^10.9.2",
36
36
  "tsup": "^8.0.1",
37
37
  "tsx": "^4.20.6",