@hasna/connectors 0.0.3 → 0.0.4
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/bin/index.js +100 -10
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -4418,6 +4418,9 @@ function searchConnectors(query) {
|
|
|
4418
4418
|
const q = query.toLowerCase();
|
|
4419
4419
|
return CONNECTORS.filter((c) => c.name.toLowerCase().includes(q) || c.displayName.toLowerCase().includes(q) || c.description.toLowerCase().includes(q) || c.tags.some((t) => t.includes(q)));
|
|
4420
4420
|
}
|
|
4421
|
+
function getConnector(name) {
|
|
4422
|
+
return CONNECTORS.find((c) => c.name === name);
|
|
4423
|
+
}
|
|
4421
4424
|
var versionsLoaded = false;
|
|
4422
4425
|
function loadConnectorVersions() {
|
|
4423
4426
|
if (versionsLoaded)
|
|
@@ -5482,33 +5485,62 @@ function App({ initialConnectors, overwrite = false }) {
|
|
|
5482
5485
|
// src/cli/index.tsx
|
|
5483
5486
|
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
5484
5487
|
loadConnectorVersions();
|
|
5488
|
+
var isTTY = process.stdout.isTTY ?? false;
|
|
5485
5489
|
var program2 = new Command;
|
|
5486
|
-
program2.name("connectors").description("Install API connectors for your project").version("0.0.
|
|
5490
|
+
program2.name("connectors").description("Install API connectors for your project").version("0.0.4");
|
|
5487
5491
|
program2.command("interactive", { isDefault: true }).alias("i").description("Interactive connector browser").action(() => {
|
|
5492
|
+
if (!isTTY) {
|
|
5493
|
+
console.log(`Non-interactive environment detected. Use a subcommand:
|
|
5494
|
+
`);
|
|
5495
|
+
console.log(" connectors list List all available connectors");
|
|
5496
|
+
console.log(" connectors list --json List as JSON (for AI agents)");
|
|
5497
|
+
console.log(" connectors search <query> Search connectors");
|
|
5498
|
+
console.log(" connectors install <names...> Install connectors");
|
|
5499
|
+
console.log(" connectors remove <name> Remove a connector");
|
|
5500
|
+
console.log(" connectors info <name> Show connector details");
|
|
5501
|
+
console.log(" connectors categories List categories");
|
|
5502
|
+
console.log(`
|
|
5503
|
+
Run 'connectors --help' for full usage.`);
|
|
5504
|
+
process.exit(0);
|
|
5505
|
+
}
|
|
5488
5506
|
render(/* @__PURE__ */ jsxDEV7(App, {}, undefined, false, undefined, this));
|
|
5489
5507
|
});
|
|
5490
|
-
program2.command("install").alias("add").argument("[connectors...]", "Connectors to install").option("-o, --overwrite", "Overwrite existing connectors", false).description("Install one or more connectors").action((connectors, options) => {
|
|
5508
|
+
program2.command("install").alias("add").argument("[connectors...]", "Connectors to install").option("-o, --overwrite", "Overwrite existing connectors", false).option("--json", "Output results as JSON", false).description("Install one or more connectors").action((connectors, options) => {
|
|
5491
5509
|
if (connectors.length === 0) {
|
|
5510
|
+
if (!isTTY) {
|
|
5511
|
+
console.error("Error: specify connectors to install. Example: connectors install figma stripe");
|
|
5512
|
+
process.exit(1);
|
|
5513
|
+
}
|
|
5492
5514
|
render(/* @__PURE__ */ jsxDEV7(App, {}, undefined, false, undefined, this));
|
|
5493
5515
|
return;
|
|
5494
5516
|
}
|
|
5517
|
+
const results = connectors.map((name) => installConnector(name, { overwrite: options.overwrite }));
|
|
5518
|
+
if (options.json) {
|
|
5519
|
+
console.log(JSON.stringify(results, null, 2));
|
|
5520
|
+
process.exit(results.every((r) => r.success) ? 0 : 1);
|
|
5521
|
+
return;
|
|
5522
|
+
}
|
|
5495
5523
|
console.log(chalk2.bold(`
|
|
5496
5524
|
Installing connectors...
|
|
5497
5525
|
`));
|
|
5498
|
-
for (const
|
|
5499
|
-
const result = installConnector(name, { overwrite: options.overwrite });
|
|
5526
|
+
for (const result of results) {
|
|
5500
5527
|
if (result.success) {
|
|
5501
|
-
console.log(chalk2.green(`\u2713 ${
|
|
5528
|
+
console.log(chalk2.green(`\u2713 ${result.connector}`));
|
|
5502
5529
|
} else {
|
|
5503
|
-
console.log(chalk2.red(`\u2717 ${
|
|
5530
|
+
console.log(chalk2.red(`\u2717 ${result.connector}: ${result.error}`));
|
|
5504
5531
|
}
|
|
5505
5532
|
}
|
|
5506
5533
|
console.log(chalk2.dim(`
|
|
5507
5534
|
Connectors installed to .connectors/`));
|
|
5535
|
+
process.exit(results.every((r) => r.success) ? 0 : 1);
|
|
5508
5536
|
});
|
|
5509
|
-
program2.command("list").alias("ls").option("-c, --category <category>", "Filter by category").option("-a, --all", "Show all available connectors", false).option("-i, --installed", "Show only installed connectors", false).description("List available or installed connectors").action((options) => {
|
|
5537
|
+
program2.command("list").alias("ls").option("-c, --category <category>", "Filter by category").option("-a, --all", "Show all available connectors", false).option("-i, --installed", "Show only installed connectors", false).option("--json", "Output as JSON", false).description("List available or installed connectors").action((options) => {
|
|
5510
5538
|
if (options.installed) {
|
|
5511
5539
|
const installed = getInstalledConnectors();
|
|
5540
|
+
if (options.json) {
|
|
5541
|
+
console.log(JSON.stringify(installed));
|
|
5542
|
+
return;
|
|
5543
|
+
}
|
|
5512
5544
|
if (installed.length === 0) {
|
|
5513
5545
|
console.log(chalk2.dim("No connectors installed"));
|
|
5514
5546
|
return;
|
|
@@ -5524,11 +5556,19 @@ Installed connectors (${installed.length}):
|
|
|
5524
5556
|
if (options.category) {
|
|
5525
5557
|
const category = CATEGORIES.find((c) => c.toLowerCase() === options.category.toLowerCase());
|
|
5526
5558
|
if (!category) {
|
|
5559
|
+
if (options.json) {
|
|
5560
|
+
console.log(JSON.stringify({ error: `Unknown category: ${options.category}` }));
|
|
5561
|
+
process.exit(1);
|
|
5562
|
+
}
|
|
5527
5563
|
console.log(chalk2.red(`Unknown category: ${options.category}`));
|
|
5528
5564
|
console.log(chalk2.dim(`Available: ${CATEGORIES.join(", ")}`));
|
|
5529
5565
|
return;
|
|
5530
5566
|
}
|
|
5531
5567
|
const connectors = getConnectorsByCategory(category);
|
|
5568
|
+
if (options.json) {
|
|
5569
|
+
console.log(JSON.stringify(connectors));
|
|
5570
|
+
return;
|
|
5571
|
+
}
|
|
5532
5572
|
console.log(chalk2.bold(`
|
|
5533
5573
|
${category} (${connectors.length}):
|
|
5534
5574
|
`));
|
|
@@ -5539,6 +5579,10 @@ ${category} (${connectors.length}):
|
|
|
5539
5579
|
}
|
|
5540
5580
|
return;
|
|
5541
5581
|
}
|
|
5582
|
+
if (options.json) {
|
|
5583
|
+
console.log(JSON.stringify(CONNECTORS));
|
|
5584
|
+
return;
|
|
5585
|
+
}
|
|
5542
5586
|
console.log(chalk2.bold(`
|
|
5543
5587
|
Available connectors (${CONNECTORS.length}):
|
|
5544
5588
|
`));
|
|
@@ -5553,8 +5597,12 @@ Available connectors (${CONNECTORS.length}):
|
|
|
5553
5597
|
console.log();
|
|
5554
5598
|
}
|
|
5555
5599
|
});
|
|
5556
|
-
program2.command("search").argument("<query>", "Search term").description("Search for connectors").action((query) => {
|
|
5600
|
+
program2.command("search").argument("<query>", "Search term").option("--json", "Output as JSON", false).description("Search for connectors").action((query, options) => {
|
|
5557
5601
|
const results = searchConnectors(query);
|
|
5602
|
+
if (options.json) {
|
|
5603
|
+
console.log(JSON.stringify(results));
|
|
5604
|
+
return;
|
|
5605
|
+
}
|
|
5558
5606
|
if (results.length === 0) {
|
|
5559
5607
|
console.log(chalk2.dim(`No connectors found for "${query}"`));
|
|
5560
5608
|
return;
|
|
@@ -5568,15 +5616,57 @@ Found ${results.length} connector(s):
|
|
|
5568
5616
|
console.log(` ${chalk2.cyan(c.name.padEnd(20))}${chalk2.dim((c.version || "-").padEnd(10))}${chalk2.dim(c.category.padEnd(20))}${c.description}`);
|
|
5569
5617
|
}
|
|
5570
5618
|
});
|
|
5571
|
-
program2.command("
|
|
5619
|
+
program2.command("info").argument("<connector>", "Connector name").option("--json", "Output as JSON", false).description("Show detailed info about a connector").action((connector, options) => {
|
|
5620
|
+
const meta = getConnector(connector);
|
|
5621
|
+
if (!meta) {
|
|
5622
|
+
if (options.json) {
|
|
5623
|
+
console.log(JSON.stringify({ error: `Connector '${connector}' not found` }));
|
|
5624
|
+
process.exit(1);
|
|
5625
|
+
}
|
|
5626
|
+
console.log(chalk2.red(`Connector '${connector}' not found`));
|
|
5627
|
+
process.exit(1);
|
|
5628
|
+
return;
|
|
5629
|
+
}
|
|
5630
|
+
const installed = getInstalledConnectors();
|
|
5631
|
+
const isInstalled = installed.includes(meta.name);
|
|
5632
|
+
if (options.json) {
|
|
5633
|
+
console.log(JSON.stringify({ ...meta, installed: isInstalled }));
|
|
5634
|
+
return;
|
|
5635
|
+
}
|
|
5636
|
+
console.log(chalk2.bold(`
|
|
5637
|
+
${meta.displayName}`));
|
|
5638
|
+
console.log(chalk2.dim(`${"\u2500".repeat(40)}`));
|
|
5639
|
+
console.log(` Name: ${chalk2.cyan(meta.name)}`);
|
|
5640
|
+
console.log(` Version: ${meta.version || "-"}`);
|
|
5641
|
+
console.log(` Category: ${meta.category}`);
|
|
5642
|
+
console.log(` Description: ${meta.description}`);
|
|
5643
|
+
console.log(` Tags: ${meta.tags.join(", ")}`);
|
|
5644
|
+
console.log(` Installed: ${isInstalled ? chalk2.green("yes") : "no"}`);
|
|
5645
|
+
console.log(` Package: @hasna/connect-${meta.name}`);
|
|
5646
|
+
});
|
|
5647
|
+
program2.command("remove").alias("rm").argument("<connector>", "Connector to remove").option("--json", "Output as JSON", false).description("Remove an installed connector").action((connector, options) => {
|
|
5572
5648
|
const removed = removeConnector(connector);
|
|
5649
|
+
if (options.json) {
|
|
5650
|
+
console.log(JSON.stringify({ connector, removed }));
|
|
5651
|
+
process.exit(removed ? 0 : 1);
|
|
5652
|
+
return;
|
|
5653
|
+
}
|
|
5573
5654
|
if (removed) {
|
|
5574
5655
|
console.log(chalk2.green(`\u2713 Removed ${connector}`));
|
|
5575
5656
|
} else {
|
|
5576
5657
|
console.log(chalk2.red(`\u2717 ${connector} is not installed`));
|
|
5658
|
+
process.exit(1);
|
|
5577
5659
|
}
|
|
5578
5660
|
});
|
|
5579
|
-
program2.command("categories").description("List all categories").action(() => {
|
|
5661
|
+
program2.command("categories").option("--json", "Output as JSON", false).description("List all categories").action((options) => {
|
|
5662
|
+
if (options.json) {
|
|
5663
|
+
const data = CATEGORIES.map((category) => ({
|
|
5664
|
+
name: category,
|
|
5665
|
+
count: getConnectorsByCategory(category).length
|
|
5666
|
+
}));
|
|
5667
|
+
console.log(JSON.stringify(data));
|
|
5668
|
+
return;
|
|
5669
|
+
}
|
|
5580
5670
|
console.log(chalk2.bold(`
|
|
5581
5671
|
Categories:
|
|
5582
5672
|
`));
|