@superglue/cli 1.1.8 → 1.1.10

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.
Files changed (2) hide show
  1. package/dist/cli.js +101 -54
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -21934,7 +21934,7 @@ var import_node_util = require("util");
21934
21934
  // package.json
21935
21935
  var package_default = {
21936
21936
  name: "@superglue/cli",
21937
- version: "1.1.8",
21937
+ version: "1.1.10",
21938
21938
  bin: {
21939
21939
  sg: "./dist/cli.js"
21940
21940
  },
@@ -22459,61 +22459,92 @@ async function choose(message, options, defaultIndex = 0) {
22459
22459
 
22460
22460
  // src/commands/init.ts
22461
22461
  function registerInitCommand(program2) {
22462
- program2.command("init").description("Set up superglue CLI configuration").action(async () => {
22463
- banner();
22464
- console.log(` ${c.bold}Welcome to the superglue CLI setup!${c.reset}`);
22465
- console.log(` ${c.dim}Let's get you connected in a few steps.${c.reset}
22462
+ program2.command("init").description("Set up superglue CLI configuration").option("--api-key <key>", "API key (skips interactive prompt)").option("--endpoint <url>", "API endpoint", "https://api.superglue.cloud").option("--web-endpoint <url>", "Web endpoint for OAuth callbacks").option("--output-mode <mode>", "Output mode: stdout or stdout+file", "stdout").option("--output-dir <dir>", "Output directory for stdout+file mode", ".superglue/output").option("--global", "Save config globally (~/.superglue/) instead of locally").action(async (opts) => {
22463
+ const isNonInteractive = opts.apiKey || !process.stdin.isTTY;
22464
+ let apiKey;
22465
+ let endpoint;
22466
+ let webEndpoint;
22467
+ let outputMode;
22468
+ let outputDir;
22469
+ let preferLocal;
22470
+ if (isNonInteractive) {
22471
+ apiKey = opts.apiKey || process.env.SUPERGLUE_API_KEY;
22472
+ if (!apiKey) {
22473
+ error("API key is required (--api-key or SUPERGLUE_API_KEY)");
22474
+ process.exit(1);
22475
+ }
22476
+ endpoint = opts.endpoint;
22477
+ const defaultWeb = endpoint.replace(/:3002\b/, ":3001").replace(/api\.superglue/, "app.superglue");
22478
+ webEndpoint = opts.webEndpoint || defaultWeb;
22479
+ outputMode = opts.outputMode === "stdout+file" ? "stdout+file" : "stdout";
22480
+ outputDir = opts.outputDir;
22481
+ preferLocal = !opts.global;
22482
+ const spin = spinner("Verifying connection...");
22483
+ try {
22484
+ const client = new import_shared2.SuperglueClient({ apiKey, apiEndpoint: endpoint });
22485
+ await client.listSystems(1);
22486
+ spin.stop(`${c.green}\u2713${c.reset} Connected to ${c.bold}${endpoint}${c.reset}`);
22487
+ } catch (err) {
22488
+ spin.stop(`${c.red}\u2717${c.reset} Connection failed`);
22489
+ error(err.message);
22490
+ process.exit(1);
22491
+ }
22492
+ } else {
22493
+ banner();
22494
+ console.log(` ${c.bold}Welcome to the superglue CLI setup!${c.reset}`);
22495
+ console.log(` ${c.dim}Let's get you connected in a few steps.${c.reset}
22466
22496
  `);
22467
- heading("Authentication");
22468
- console.log(
22469
- ` ${c.dim}Get your API key at${c.reset} ${link("https://app.superglue.cloud/admin?view=api-keys")}`
22470
- );
22471
- console.log("");
22472
- const apiKey = await promptHidden(" API Key");
22473
- if (!apiKey) {
22474
- error("API key is required");
22475
- process.exit(1);
22476
- }
22477
- const endpoint = await prompt(" API Endpoint", "https://api.superglue.cloud");
22478
- const defaultWeb = endpoint.replace(/:3002\b/, ":3001").replace(/api\.superglue/, "app.superglue");
22479
- const webEndpoint = await prompt(" Web Endpoint (for OAuth callbacks)", defaultWeb);
22480
- const spin = spinner("Verifying connection...");
22481
- try {
22482
- const client = new import_shared2.SuperglueClient({ apiKey, apiEndpoint: endpoint });
22483
- await client.listSystems(1);
22484
- spin.stop(`${c.green}\u2713${c.reset} Connected to ${c.bold}${endpoint}${c.reset}`);
22485
- } catch (err) {
22486
- spin.stop(`${c.red}\u2717${c.reset} Connection failed`);
22487
- error(err.message);
22488
- process.exit(1);
22497
+ heading("Authentication");
22498
+ console.log(
22499
+ ` ${c.dim}Get your API key at${c.reset} ${link("https://app.superglue.cloud/admin?view=api-keys")}`
22500
+ );
22501
+ console.log("");
22502
+ apiKey = await promptHidden(" API Key");
22503
+ if (!apiKey) {
22504
+ error("API key is required");
22505
+ process.exit(1);
22506
+ }
22507
+ endpoint = await prompt(" API Endpoint", opts.endpoint);
22508
+ const defaultWeb = endpoint.replace(/:3002\b/, ":3001").replace(/api\.superglue/, "app.superglue");
22509
+ webEndpoint = await prompt(" Web Endpoint (for OAuth callbacks)", defaultWeb);
22510
+ const spin = spinner("Verifying connection...");
22511
+ try {
22512
+ const client = new import_shared2.SuperglueClient({ apiKey, apiEndpoint: endpoint });
22513
+ await client.listSystems(1);
22514
+ spin.stop(`${c.green}\u2713${c.reset} Connected to ${c.bold}${endpoint}${c.reset}`);
22515
+ } catch (err) {
22516
+ spin.stop(`${c.red}\u2717${c.reset} Connection failed`);
22517
+ error(err.message);
22518
+ process.exit(1);
22519
+ }
22520
+ heading("Output Preferences");
22521
+ const outputModeIdx = await choose(
22522
+ "Output mode",
22523
+ [
22524
+ "stdout only \u2014 print results to terminal",
22525
+ "stdout + file \u2014 also save results as JSON files"
22526
+ ],
22527
+ 0
22528
+ );
22529
+ outputMode = outputModeIdx === 1 ? "stdout+file" : "stdout";
22530
+ outputDir = ".superglue/output";
22531
+ if (outputMode === "stdout+file") {
22532
+ outputDir = await prompt(" Output directory", ".superglue/output");
22533
+ }
22534
+ heading("Config Location");
22535
+ const homeDir = os2.homedir();
22536
+ const localPath = path2.join(process.cwd(), ".superglue");
22537
+ const globalPath = path2.join(homeDir, ".superglue");
22538
+ const configLocationIdx = await choose(
22539
+ "Where to save config?",
22540
+ [
22541
+ `Project (${localPath}) \u2014 config stays with this project`,
22542
+ `Global (${globalPath}) \u2014 shared across all projects`
22543
+ ],
22544
+ 0
22545
+ );
22546
+ preferLocal = configLocationIdx === 0;
22489
22547
  }
22490
- heading("Output Preferences");
22491
- const outputModeIdx = await choose(
22492
- "Output mode",
22493
- [
22494
- "stdout only \u2014 print results to terminal",
22495
- "stdout + file \u2014 also save results as JSON files"
22496
- ],
22497
- 0
22498
- );
22499
- const outputMode = outputModeIdx === 1 ? "stdout+file" : "stdout";
22500
- let outputDir = ".superglue/output";
22501
- if (outputMode === "stdout+file") {
22502
- outputDir = await prompt(" Output directory", ".superglue/output");
22503
- }
22504
- heading("Config Location");
22505
- const homeDir = os2.homedir();
22506
- const localPath = path2.join(process.cwd(), ".superglue");
22507
- const globalPath = path2.join(homeDir, ".superglue");
22508
- const configLocationIdx = await choose(
22509
- "Where to save config?",
22510
- [
22511
- `Project (${localPath}) \u2014 config stays with this project`,
22512
- `Global (${globalPath}) \u2014 shared across all projects`
22513
- ],
22514
- 0
22515
- );
22516
- const preferLocal = configLocationIdx === 0;
22517
22548
  const config = {
22518
22549
  apiKey,
22519
22550
  endpoint,
@@ -23514,6 +23545,7 @@ function registerDocsCommand(parent, getContext2) {
23514
23545
 
23515
23546
  // src/commands/system/oauth.ts
23516
23547
  var import_node_child_process2 = require("child_process");
23548
+ var import_node_crypto = __toESM(require("crypto"));
23517
23549
  var import_shared9 = __toESM(require_dist2());
23518
23550
  function openBrowser(url) {
23519
23551
  const platform = process.platform;
@@ -23629,6 +23661,20 @@ function registerOAuthCommand(parent, getContext2) {
23629
23661
  process.exit(1);
23630
23662
  }
23631
23663
  const encryptedApiKey = (0, import_shared9.encryptCliApiKey)(config.apiKey, opts.systemId, encryptionSecret);
23664
+ let clientCredentialsUid;
23665
+ if (system.credentials?.client_secret && clientId) {
23666
+ clientCredentialsUid = import_node_crypto.default.randomUUID();
23667
+ try {
23668
+ await client.cacheOauthClientCredentials({
23669
+ clientCredentialsUid,
23670
+ clientId,
23671
+ clientSecret: system.credentials.client_secret
23672
+ });
23673
+ } catch (err) {
23674
+ error(`Failed to cache OAuth credentials: ${err.message}`);
23675
+ process.exit(1);
23676
+ }
23677
+ }
23632
23678
  const redirectUri = `${config.webEndpoint.replace(/\/$/, "")}/api/auth/callback`;
23633
23679
  const state = {
23634
23680
  systemId: opts.systemId,
@@ -23638,6 +23684,7 @@ function registerOAuthCommand(parent, getContext2) {
23638
23684
  token_url: tokenUrl,
23639
23685
  clientId,
23640
23686
  ...templateMatch ? { templateId: templateMatch.key } : {},
23687
+ ...clientCredentialsUid ? { client_credentials_uid: clientCredentialsUid } : {},
23641
23688
  scopes: opts.scopes,
23642
23689
  cliApiKey: encryptedApiKey
23643
23690
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superglue/cli",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "bin": {
5
5
  "sg": "./dist/cli.js"
6
6
  },