layro-cli 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # layro-cli
2
2
 
3
- Publish React components to [Layro](https://layro.dev) from your terminal.
3
+ Find and publish React components on [Layro](https://layro.dev) from your terminal.
4
4
 
5
5
  ```bash
6
+ npx layro-cli search pricing toggle
6
7
  npx layro-cli login
7
8
  npx layro-cli publish components/pricing-card.tsx
8
9
  ```
@@ -11,14 +12,15 @@ Requires Node 20 or newer. No dependencies.
11
12
 
12
13
  ## Commands
13
14
 
14
- | Command | Does |
15
- | -------------------------- | -------------------------------------------------------------------------------------------------------- |
16
- | `layro login` | Sign in with GitHub in your browser (no API keys). `--no-browser` prints the link. |
17
- | `layro whoami` | Who you're signed in as, and submissions left today. |
18
- | `layro publish <files…>` | Send a new component, or a new version of one you already have (same name). The first file is the entry. |
19
- | `layro status [component]` | Where your submissions stand, with reviewers' reasons. `component` is a slug or `author/slug`. |
20
- | `layro add <author/slug>` | Prints the shadcn command that installs a component. |
21
- | `layro logout` | Revokes the session and forgets it on this computer. |
15
+ | Command | Does |
16
+ | -------------------------- | -------------------------------------------------------------------------------------------------------------- |
17
+ | `layro search <words…>` | Find components, best match first (typos are fine, no sign-in). `--category`, `--author`, `--limit`, `--json`. |
18
+ | `layro login` | Sign in with GitHub in your browser (no API keys). `--no-browser` prints the link. |
19
+ | `layro whoami` | Who you're signed in as, and submissions left today. |
20
+ | `layro publish <files…>` | Send a new component, or a new version of one you already have (same name). The first file is the entry. |
21
+ | `layro status [component]` | Where your submissions stand, with reviewers' reasons. `component` is a slug or `author/slug`. |
22
+ | `layro add <author/slug>` | Prints the shadcn command that installs a component. |
23
+ | `layro logout` | Revokes the session and forgets it on this computer. |
22
24
 
23
25
  ### Publish options
24
26
 
package/dist/layro.mjs CHANGED
@@ -340,7 +340,7 @@ async function logout(server2) {
340
340
  }
341
341
 
342
342
  // src/api.ts
343
- var VERSION = true ? "0.1.0" : "dev";
343
+ var VERSION = true ? "0.2.0" : "dev";
344
344
  var ApiFailure = class extends CliError {
345
345
  constructor(detail) {
346
346
  super(detail.error);
@@ -520,6 +520,36 @@ async function publish(server2, paths, flags) {
520
520
  say(dim(` Submissions left today: ${result.submissionsLeftToday}`));
521
521
  }
522
522
 
523
+ // src/search.ts
524
+ async function search(server2, words, flags) {
525
+ const q = words.join(" ").trim();
526
+ if (!q) throw new CliError("Give some words: layro search <words\u2026>");
527
+ const params = new URLSearchParams({ q });
528
+ if (flags.category) params.set("category", flags.category);
529
+ if (flags.author) params.set("author", flags.author);
530
+ if (flags.limit) params.set("limit", flags.limit);
531
+ const found = await api(server2, `/search?${params}`, { auth: false });
532
+ if (flags.json) return say(JSON.stringify(found, null, 2));
533
+ if (found.results.length === 0) {
534
+ say(`Nothing matches "${q}".`);
535
+ if (found.suggestion)
536
+ say(
537
+ `The closest category is ${bold(found.suggestion.name)}: ${found.suggestion.url}`
538
+ );
539
+ return;
540
+ }
541
+ for (const c of found.results) {
542
+ say(`${bold(c.name)} ${dim(c.id)}`);
543
+ say(` ${c.description}`);
544
+ say(dim(` ${c.install}`));
545
+ }
546
+ say(
547
+ dim(
548
+ `${found.results.length} ${found.results.length === 1 ? "result" : "results"}. Install one with the command under it.`
549
+ )
550
+ );
551
+ }
552
+
523
553
  // src/status.ts
524
554
  var LABEL = {
525
555
  live: "live",
@@ -574,9 +604,10 @@ async function status(server2, target) {
574
604
  }
575
605
 
576
606
  // src/index.ts
577
- var HELP = `${bold("layro")} ${dim(VERSION)}: publish React components to Layro
607
+ var HELP = `${bold("layro")} ${dim(VERSION)}: find and publish React components on Layro
578
608
 
579
609
  Usage
610
+ layro search <words\u2026> Find components (typos are fine; no sign-in needed)
580
611
  layro login Sign in with GitHub in your browser
581
612
  layro whoami Who you're signed in as
582
613
  layro publish <files\u2026> Send a new component, or a new version of yours
@@ -595,6 +626,12 @@ Publish options
595
626
  --preview <plan.json> How to film its preview (see the docs)
596
627
  -y, --yes Don't ask; send what's given (for CI)
597
628
 
629
+ Search options
630
+ --category <slug> Only this category
631
+ --author <handle> Only this author's components
632
+ --limit <n> 1 to 50 (default 20)
633
+ --json Print the API's JSON
634
+
598
635
  Login options
599
636
  --no-browser Print the sign-in link instead of opening it
600
637
 
@@ -671,6 +708,20 @@ async function main(argv) {
671
708
  });
672
709
  return;
673
710
  }
711
+ case "search": {
712
+ const { values, positionals } = parseArgs({
713
+ args: rest,
714
+ allowPositionals: true,
715
+ options: {
716
+ category: { type: "string" },
717
+ author: { type: "string" },
718
+ limit: { type: "string" },
719
+ json: { type: "boolean" }
720
+ }
721
+ });
722
+ await search(server, positionals, values);
723
+ return;
724
+ }
674
725
  case "status": {
675
726
  const { positionals } = parseArgs({ args: rest, allowPositionals: true });
676
727
  await status(server, positionals[0]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "layro-cli",
3
- "version": "0.1.0",
4
- "description": "Publish React components to Layro (layro.dev) from your terminal.",
3
+ "version": "0.2.0",
4
+ "description": "Find and publish React components on Layro (layro.dev) from your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {