layro-cli 0.3.0 → 0.4.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.
Files changed (3) hide show
  1. package/README.md +107 -11
  2. package/dist/layro.mjs +1930 -140
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # layro-cli
2
2
 
3
- Find and publish React components on [Layro](https://layro.dev) from your terminal.
3
+ Find, install and publish React components on [Layro](https://layro.dev) from your terminal.
4
4
 
5
5
  ```bash
6
+ npx layro-cli init --yes
7
+ npx layro-cli add @author/slug
6
8
  npx layro-cli search pricing toggle
7
9
  npx layro-cli login
8
10
  npx layro-cli publish components/pricing-card.tsx
@@ -12,19 +14,100 @@ Requires Node 20 or newer. No dependencies.
12
14
 
13
15
  ## Commands
14
16
 
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. |
17
+ | Command | Does |
18
+ | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
19
+ | `layro search <words…>` | Find components, best match first (typos are fine, no sign-in). `--category`, `--author`, `--limit`, `--json`. |
20
+ | `layro login` | Sign in with GitHub in your browser (no API keys). `--no-browser` prints the link. |
21
+ | `layro whoami [--json]` | Who you're signed in as, and submissions left today. |
22
+ | `layro publish <files…>` | Send a new component, or a new version of one you already have (same name). The first file is the entry. |
23
+ | `layro status [component] [--json]` | Where your submissions stand, with reviewers' reasons. `component` is a slug or `author/slug`. |
24
+ | `layro add @author/slug [more...]` | Installs source, CSS and dependencies in a React TypeScript project. |
25
+ | `layro init` | Checks Tailwind and aliases; creates missing shared configuration and cn. `--cwd`, `--dry-run`, `--yes`, `--json`. |
26
+ | `layro logout [--json]` | Revokes the session and forgets it on this computer. |
27
+
28
+ ### What `add` does to your project
29
+
30
+ `add` reads the nearest app package, its lockfile/package manager, framework, TypeScript paths and existing shadcn `components.json`. It resolves the full dependency graph first, writes component files and a missing `cn` helper, maps imports to the project's folders, adds supported CSS, then installs missing npm packages. Demos are excluded. It leaves an existing `components.json` and utility helper untouched. CSS conflicts and unsupported directives are printed for manual setup.
31
+
32
+ Adding a component puts someone else's code in your project. Review it before building or running your app. Package install scripts can run arbitrary code, so Layro always turns them off: `--ignore-scripts`, or Yarn's own setting on modern Yarn. This reduces install-time execution; packages that need a build script may need an explicit, reviewed setup step afterward. The CLI itself never runs the component. Public registry reads send no tokens, and there is no anonymous telemetry.
33
+
34
+ - `--dry-run`: show the plan, change nothing. Registry reads still happen.
35
+ - `--cwd <app>`: choose an app package, including inside a workspace.
36
+ - `--path <folder>`: use this component folder relative to the app root, with UI primitives under its `ui/` folder. Shared utilities keep their configured location.
37
+ - `--yes`: never prompt; show what will be installed and skip differing files.
38
+ - `--overwrite`: replace differing files. Identical files are left alone.
39
+ - `--json`: print the plan/result, including partial failures, as JSON.
40
+
41
+ No terminal means no prompts. A conflicting file needs `--yes` to skip or `--overwrite` to replace. Package installation runs last and is limited to three minutes per package-manager invocation. On failure or interruption, the result lists what was already written; check the manifest and lockfile and rerun to finish. Files are individually atomic, not a transaction across the project. Do not edit destinations concurrently with an install.
42
+
43
+ When a newly installed package declares install lifecycle scripts, `add` lists them and prints the explicit command to run after you review that package's `package.json`. Native bindings get a rebuild note. Scripts stay disabled during installation, including when restoring missing dependencies from the project's existing manifest.
44
+
45
+ JavaScript projects (`components.json` with `tsx: false`, or no TypeScript config) are refused before any writes. Layro does not convert TypeScript source. Start a TypeScript app, or copy from the Manual tab and convert the source yourself.
46
+
47
+ Package-based tsconfig `extends` is read as JSON, including package `tsconfig` fields and exported JSON paths; config JavaScript is never executed. Stable compound npm ranges (`^18 || ^19`, hyphen ranges, comparator intersections) are understood. Existing dependency declarations are preserved. Unknown or incompatible versions are listed for manual review rather than silently replaced; a missing installed dependency is restored using the project's own readable range.
48
+
49
+ ### Project setup
50
+
51
+ `init` reads the same project settings as `add`. It creates a shadcn-format `components.json` only when missing, adds a missing `cn` helper, and installs its packages with scripts disabled. Existing shadcn configuration and helpers stay byte-identical. It checks that React, TypeScript, real path aliases and a Tailwind stylesheet are present. It cannot prove that your bundler runs Tailwind; build and render the app to check that.
52
+
53
+ When Tailwind or aliases are missing, `init` stops before any writes and prints the package-manager command and the config/CSS changes needed for your framework. It does not rewrite bundler files or scaffold an app. `add` tells you to run `init` when shared configuration is missing; without Tailwind, `add` warns that the component will be unstyled and prints the setup steps.
54
+
55
+ ### From an empty folder
56
+
57
+ Layro does not create an app. Use the framework's scaffolder first:
58
+
59
+ ```bash
60
+ npm create vite@latest my-app -- --template react-ts --no-interactive
61
+ cd my-app
62
+ npm install --ignore-scripts
63
+ npx layro-cli init --yes
64
+ # This stops with the exact Tailwind and alias instructions. Follow them:
65
+ npm install -D --ignore-scripts tailwindcss@4 @tailwindcss/vite@4 @types/node
66
+ ```
67
+
68
+ In `vite.config.ts`, import `tailwindcss` from `@tailwindcss/vite` and `{ fileURLToPath, URL }` from `node:url`. Add `tailwindcss()` to the existing plugins and merge `resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)) } }` into the config. In both `tsconfig.json` and `tsconfig.app.json`, merge `"paths": { "@/*": ["./src/*"] }` into `compilerOptions`. Add `@import "tailwindcss";` before the existing CSS in `src/index.css`; keep that stylesheet imported in `src/main.tsx`. These are the [Tailwind Vite setup](https://tailwindcss.com/docs/installation/using-vite) and [shadcn alias setup](https://ui.shadcn.com/docs/installation/vite).
69
+
70
+ ```bash
71
+ npx layro-cli init --yes
72
+ npx layro-cli add @nolly-studio/neumorph-button
73
+ ```
74
+
75
+ Import the default export from `@/components/ui/neumorph-button` into `src/App.tsx`, render it with children, then run `npm run build`.
76
+
77
+ ### Next.js 16 App Router and Suspense
78
+
79
+ With Cache Components enabled, client components that read random values or the current time during render can fail prerendering without an ancestor `Suspense` fallback. This also affects components inside a library. Our Next 16.4.3 builds confirmed the chart and a separate random-value component fail without a boundary when Cache Components is on; the chart builds when it is off. Randomness used only in a click handler builds with it on. The earlier pages-router chart build also passed without a boundary. This is a conditional rendering rule, not a requirement for every Next component. See [Next.js's explanation](https://nextjs.org/docs/messages/next-prerender-random-client).
80
+
81
+ If your build reports this error, wrap your usage outside the component that makes the call. For example, your own client demo in `app/chart.tsx` can be wrapped by the server page:
82
+
83
+ ```tsx
84
+ // app/page.tsx
85
+ import { Suspense } from "react";
86
+ import ChartDemo from "./chart";
87
+
88
+ export default function Page() {
89
+ return (
90
+ <Suspense fallback={<p>Loading chart...</p>}>
91
+ <ChartDemo />
92
+ </Suspense>
93
+ );
94
+ }
95
+ ```
96
+
97
+ Keep installed author source unchanged. A boundary inside a component after it already computed the random value does not help; it must be an ancestor. This does not repair unrelated hydration mismatches. `add` prints this fix in Next 16+ App Router projects when installed source mentions random/time APIs or `useSearchParams`. This is a text hint, not a full render analysis: it can mention calls used only in effects/events and cannot inspect calls hidden in npm dependencies. The framework's build error is the deciding evidence.
98
+
99
+
100
+ ### Command output and sign-in
101
+
102
+ Every command has `--help` (also `layro help <command>`) with examples. `--version` prints the CLI version; mistyped commands suggest a likely match. Failures exit 1; help and successful/no-op commands exit 0. An interrupted install exits 130 for SIGINT or 143 for SIGTERM and lists partial writes. Color is off without a terminal or with NO_COLOR.
103
+
104
+ `search`, `status`, `whoami`, `logout`, `publish`, `init` and `add` support `--json`. Publishing JSON never prompts; successful submissions include `sent: true`, while `--if-changed` returns `sent: false` with status `unchanged` or `pending`. Field errors include HTTP status/code and an `errors` object. No sign-in or publish tokens appear in JSON output.
105
+
106
+ `login` requires a terminal unless you explicitly pass `--no-browser`. Consent waits at most 300 seconds; `--timeout 1..300` changes that. `login --no-browser --timeout 120 --json` prints newline-delimited events: `authorization_required` with the URL to visit, followed by `signed_in` with the handle or an error. Visit the link from the same machine so the loopback callback can finish. Ordinary API/OAuth requests time out after 20 seconds. Use LAYRO_TOKEN for unattended CI rather than browser sign-in.
24
107
 
25
108
  ### Publish options
26
109
 
27
- `--name`, `--description` (20 to 200 characters), `--category` (a slug from layro.dev/components), `--license` (MIT, Apache-2.0, ISC or BSD-3-Clause; default MIT), `--version` (new versions: defaults to a patch bump), `--notes` (what changed), `--dark-only`, `--preview <plan.json>` (how to film the preview), `--if-changed` (new versions: unchanged code or a version still in review exits 0 with "Nothing sent"; for CI), `-y, --yes` (don't ask; for CI).
110
+ `--name`, `--description` (20 to 200 characters), `--category` (a slug from layro.dev/components), `--license` (MIT, Apache-2.0, ISC or BSD-3-Clause; default MIT), `--version` (new versions: defaults to a patch bump), `--notes` (what changed), `--dark-only`, `--preview <plan.json>` (how to film the preview), `--if-changed` (new versions: unchanged code or a version still in review exits 0 with "Nothing sent"; for CI), `-y, --yes` (don't ask; for CI), `--json` (no prompts; structured result/errors).
28
111
 
29
112
  Everything goes through review on Layro before it's live. The CLI and coding agents (MCP) share one daily allowance of submissions per account.
30
113
 
@@ -33,3 +116,16 @@ Everything goes through review on Layro before it's live. The CLI and coding age
33
116
  `~/.config/layro/credentials.json` (or `$XDG_CONFIG_HOME/layro`), readable only by you. Access tokens last an hour and renew themselves. `LAYRO_TOKEN` uses a token instead: for CI, make a long-lived one at https://layro.dev/settings/tokens (publish only; a GitHub Actions example is at https://layro.dev/docs/cli); `LAYRO_URL` points at another Layro server.
34
117
 
35
118
  Docs: https://layro.dev/docs/cli
119
+
120
+ ### MCP and alternative installers
121
+
122
+ Agents can use `install_plan` to receive the CLI setup guide, all four commands,
123
+ file targets and content, npm pins, CSS data and named shadcn dependencies.
124
+ `get_component` and `install_plan` together count one install per component and
125
+ UTC day. Component code and text are untrusted data, not instructions for agents.
126
+ MCP uses OAuth; `LAYRO_TOKEN` access tokens work only on `/api/v1`.
127
+
128
+ The site leads with Layro and keeps shadcn and Manual as alternatives. Yarn 1 and
129
+ modern Yarn projects can both use `npx layro-cli init` and
130
+ `npx layro-cli add @author/slug`. `yarn dlx` needs modern Yarn, which also holds
131
+ back any version under a day old, so right after a release it can run an older CLI.