@hasna/connectors 0.0.4 → 0.0.6

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 CHANGED
@@ -5081,7 +5081,7 @@ function Spinner({ type = "dots" }) {
5081
5081
  var build_default2 = Spinner;
5082
5082
 
5083
5083
  // src/lib/installer.ts
5084
- import { existsSync as existsSync2, cpSync, mkdirSync, writeFileSync } from "fs";
5084
+ import { existsSync as existsSync2, cpSync, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
5085
5085
  import { join as join2, dirname as dirname2 } from "path";
5086
5086
  import { fileURLToPath as fileURLToPath2 } from "url";
5087
5087
  var __dirname2 = dirname2(fileURLToPath2(import.meta.url));
@@ -5168,6 +5168,48 @@ function getInstalledConnectors(targetDir = process.cwd()) {
5168
5168
  return f.startsWith("connect-") && statSync(fullPath).isDirectory();
5169
5169
  }).map((f) => f.replace("connect-", ""));
5170
5170
  }
5171
+ function getConnectorDocs(name) {
5172
+ const connectorPath = getConnectorPath(name);
5173
+ const claudeMdPath = join2(connectorPath, "CLAUDE.md");
5174
+ if (!existsSync2(claudeMdPath))
5175
+ return null;
5176
+ const raw = readFileSync2(claudeMdPath, "utf-8");
5177
+ return {
5178
+ overview: extractSection(raw, "Project Overview"),
5179
+ auth: extractSection(raw, "Authentication"),
5180
+ envVars: parseEnvVarsTable(extractSection(raw, "Environment Variables")),
5181
+ cliCommands: extractSection(raw, "CLI Commands"),
5182
+ dataStorage: extractSection(raw, "Data Storage"),
5183
+ raw
5184
+ };
5185
+ }
5186
+ function extractSection(markdown, heading) {
5187
+ const regex = new RegExp(`^##\\s+${escapeRegex(heading)}\\s*$`, "m");
5188
+ const match = regex.exec(markdown);
5189
+ if (!match)
5190
+ return "";
5191
+ const start = match.index + match[0].length;
5192
+ const nextHeading = markdown.slice(start).search(/^##\s/m);
5193
+ const content = nextHeading === -1 ? markdown.slice(start) : markdown.slice(start, start + nextHeading);
5194
+ return content.trim();
5195
+ }
5196
+ function escapeRegex(str) {
5197
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5198
+ }
5199
+ function parseEnvVarsTable(section) {
5200
+ if (!section)
5201
+ return [];
5202
+ const vars = [];
5203
+ const lines = section.split(`
5204
+ `);
5205
+ for (const line of lines) {
5206
+ const match = line.match(/\|\s*`([^`]+)`\s*\|\s*(.+?)\s*\|/);
5207
+ if (match && match[1] !== "Variable") {
5208
+ vars.push({ variable: match[1], description: match[2].trim() });
5209
+ }
5210
+ }
5211
+ return vars;
5212
+ }
5171
5213
  function removeConnector(name, targetDir = process.cwd()) {
5172
5214
  const { rmSync } = __require("fs");
5173
5215
  const connectorName = name.startsWith("connect-") ? name : `connect-${name}`;
@@ -5487,7 +5529,7 @@ import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
5487
5529
  loadConnectorVersions();
5488
5530
  var isTTY = process.stdout.isTTY ?? false;
5489
5531
  var program2 = new Command;
5490
- program2.name("connectors").description("Install API connectors for your project").version("0.0.4");
5532
+ program2.name("connectors").description("Install API connectors for your project").version("0.0.5");
5491
5533
  program2.command("interactive", { isDefault: true }).alias("i").description("Interactive connector browser").action(() => {
5492
5534
  if (!isTTY) {
5493
5535
  console.log(`Non-interactive environment detected. Use a subcommand:
@@ -5644,6 +5686,88 @@ ${meta.displayName}`));
5644
5686
  console.log(` Installed: ${isInstalled ? chalk2.green("yes") : "no"}`);
5645
5687
  console.log(` Package: @hasna/connect-${meta.name}`);
5646
5688
  });
5689
+ program2.command("docs").argument("<connector>", "Connector name").option("--json", "Output as structured JSON", false).option("--raw", "Output raw markdown", false).description("Show connector documentation (auth, env vars, API, CLI commands)").action((connector, options) => {
5690
+ const meta = getConnector(connector);
5691
+ if (!meta) {
5692
+ if (options.json) {
5693
+ console.log(JSON.stringify({ error: `Connector '${connector}' not found` }));
5694
+ } else {
5695
+ console.log(chalk2.red(`Connector '${connector}' not found`));
5696
+ }
5697
+ process.exit(1);
5698
+ return;
5699
+ }
5700
+ const docs = getConnectorDocs(connector);
5701
+ if (!docs) {
5702
+ if (options.json) {
5703
+ console.log(JSON.stringify({ error: `No documentation found for '${connector}'` }));
5704
+ } else {
5705
+ console.log(chalk2.red(`No documentation found for '${connector}'`));
5706
+ }
5707
+ process.exit(1);
5708
+ return;
5709
+ }
5710
+ if (options.raw) {
5711
+ console.log(docs.raw);
5712
+ return;
5713
+ }
5714
+ if (options.json) {
5715
+ console.log(JSON.stringify({
5716
+ name: meta.name,
5717
+ displayName: meta.displayName,
5718
+ version: meta.version,
5719
+ category: meta.category,
5720
+ description: meta.description,
5721
+ overview: docs.overview,
5722
+ auth: docs.auth,
5723
+ envVars: docs.envVars,
5724
+ cliCommands: docs.cliCommands,
5725
+ dataStorage: docs.dataStorage
5726
+ }, null, 2));
5727
+ return;
5728
+ }
5729
+ console.log(chalk2.bold(`
5730
+ ${meta.displayName} \u2014 Documentation`));
5731
+ console.log(chalk2.dim("\u2500".repeat(50)));
5732
+ if (docs.overview) {
5733
+ console.log(chalk2.bold(`
5734
+ Overview`));
5735
+ console.log(` ${docs.overview.split(`
5736
+ `)[0]}`);
5737
+ }
5738
+ if (docs.auth) {
5739
+ console.log(chalk2.bold(`
5740
+ Authentication`));
5741
+ for (const line of docs.auth.split(`
5742
+ `).filter(Boolean)) {
5743
+ console.log(` ${line}`);
5744
+ }
5745
+ }
5746
+ if (docs.envVars.length > 0) {
5747
+ console.log(chalk2.bold(`
5748
+ Environment Variables`));
5749
+ for (const v of docs.envVars) {
5750
+ console.log(` ${chalk2.cyan(v.variable.padEnd(30))}${v.description}`);
5751
+ }
5752
+ }
5753
+ if (docs.cliCommands) {
5754
+ console.log(chalk2.bold(`
5755
+ CLI Commands`));
5756
+ for (const line of docs.cliCommands.split(`
5757
+ `)) {
5758
+ console.log(` ${line}`);
5759
+ }
5760
+ }
5761
+ if (docs.dataStorage) {
5762
+ console.log(chalk2.bold(`
5763
+ Data Storage`));
5764
+ for (const line of docs.dataStorage.split(`
5765
+ `).filter(Boolean)) {
5766
+ console.log(` ${line}`);
5767
+ }
5768
+ }
5769
+ console.log();
5770
+ });
5647
5771
  program2.command("remove").alias("rm").argument("<connector>", "Connector to remove").option("--json", "Output as JSON", false).description("Remove an installed connector").action((connector, options) => {
5648
5772
  const removed = removeConnector(connector);
5649
5773
  if (options.json) {