@corsair-dev/cli 0.1.11 → 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.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -4
- package/package.json +2 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
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";
|
|
@@ -2428,6 +2429,34 @@ function parseRunArgs(args) {
|
|
|
2428
2429
|
}
|
|
2429
2430
|
return { path: endpointPath, input, tenant };
|
|
2430
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
|
+
}
|
|
2431
2460
|
function parseScriptArgs(args) {
|
|
2432
2461
|
let code;
|
|
2433
2462
|
let tenant;
|
|
@@ -2459,6 +2488,7 @@ function printHelp() {
|
|
|
2459
2488
|
" `pnpm corsair list --type=webhooks` to see webhook plugins",
|
|
2460
2489
|
"pnpm corsair list [--plugin=<id>] [--type=api|webhooks|db] List endpoint paths (tip: pipe to grep to filter)",
|
|
2461
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)",
|
|
2462
2492
|
'pnpm corsair script --code "<js>" [--tenant=<id>]',
|
|
2463
2493
|
" corsair is injected; use return to output a value.",
|
|
2464
2494
|
" IMPORTANT: Always filter results inline \u2014 you are the consumer of the return value, so returning full list responses wastes tokens.",
|
|
@@ -2645,6 +2675,40 @@ async function main() {
|
|
|
2645
2675
|
}
|
|
2646
2676
|
return;
|
|
2647
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
|
+
}
|
|
2648
2712
|
if (command === "schema") {
|
|
2649
2713
|
const schemaPath = args[1];
|
|
2650
2714
|
if (!schemaPath) {
|
|
@@ -2668,7 +2732,18 @@ async function main() {
|
|
|
2668
2732
|
}
|
|
2669
2733
|
printHelp();
|
|
2670
2734
|
}
|
|
2671
|
-
|
|
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;
|
|
2672
2747
|
var init_index = __esm({
|
|
2673
2748
|
"index.ts"() {
|
|
2674
2749
|
init_get_tsconfig_info();
|
|
@@ -2733,8 +2808,7 @@ var init_index = __esm({
|
|
|
2733
2808
|
return Object.keys(object).length > 0;
|
|
2734
2809
|
};
|
|
2735
2810
|
SHOW_RUN = false;
|
|
2736
|
-
|
|
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.
|
|
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.
|
|
26
|
+
"corsair": "0.1.59"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/jest": "^29.5.14",
|