@superglue/cli 1.1.8 → 1.1.9
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/cli.js +102 -54
- 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.
|
|
21937
|
+
version: "1.1.9",
|
|
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
|
-
|
|
22464
|
-
|
|
22465
|
-
|
|
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
|
-
|
|
22468
|
-
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
|
|
22482
|
-
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22486
|
-
|
|
22487
|
-
|
|
22488
|
-
|
|
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,21 @@ 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
|
+
const usingTemplate = Boolean(templateMatch?.key);
|
|
23665
|
+
let clientCredentialsUid;
|
|
23666
|
+
if (!usingTemplate && system.credentials?.client_secret && clientId) {
|
|
23667
|
+
clientCredentialsUid = import_node_crypto.default.randomUUID();
|
|
23668
|
+
try {
|
|
23669
|
+
await client.cacheOauthClientCredentials({
|
|
23670
|
+
clientCredentialsUid,
|
|
23671
|
+
clientId,
|
|
23672
|
+
clientSecret: system.credentials.client_secret
|
|
23673
|
+
});
|
|
23674
|
+
} catch (err) {
|
|
23675
|
+
error(`Failed to cache OAuth credentials: ${err.message}`);
|
|
23676
|
+
process.exit(1);
|
|
23677
|
+
}
|
|
23678
|
+
}
|
|
23632
23679
|
const redirectUri = `${config.webEndpoint.replace(/\/$/, "")}/api/auth/callback`;
|
|
23633
23680
|
const state = {
|
|
23634
23681
|
systemId: opts.systemId,
|
|
@@ -23638,6 +23685,7 @@ function registerOAuthCommand(parent, getContext2) {
|
|
|
23638
23685
|
token_url: tokenUrl,
|
|
23639
23686
|
clientId,
|
|
23640
23687
|
...templateMatch ? { templateId: templateMatch.key } : {},
|
|
23688
|
+
...clientCredentialsUid ? { client_credentials_uid: clientCredentialsUid } : {},
|
|
23641
23689
|
scopes: opts.scopes,
|
|
23642
23690
|
cliApiKey: encryptedApiKey
|
|
23643
23691
|
};
|