Skip to content

Commit 9c4bf8a

Browse files
stevekwon211claude
andcommitted
feat(cli): v0.34.0 — cargo-native installer (no Node required)
Answers the most-requested distribution gap (Reddit: "not everyone has npm… isn't there a way via cargo?"). The registry is plain static JSON with the Slint source embedded — the CLI is just transport — so a second front-end is cheap and the two are interchangeable over one source of truth. - New standalone `slintcn` crate at cli/ (ureq + serde, no async, no Node). `cargo install slintcn` ships two bins: `slintcn` and `cargo-slintcn` (so `cargo slintcn add …` works as a subcommand). - Commands init/add/list/view. `add` fetches /r/<name>.json, resolves registryDependencies recursively + dedupes, writes verbatim — the default ui/slintcn/ layout makes registry relative imports resolve with no rewriting. - base-color: buildRegistryItem inlines palette zinc/slate/stone as a `variants` map so the cargo CLI (and the npm remote-install path, which ignored base-color before) can pick a palette without a second request. - 11 Rust tests via an injected Fetcher (no network/disk); `make verify` now gates cli (cargo test + clippy -D warnings). - Docs install tabs gain a cargo pill (default); /create page gets a cargo/npm toggle; landing get-started leads with cargo. README + ROADMAP present npm and cargo as equal options. npm CLI unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a207f2a commit 9c4bf8a

18 files changed

Lines changed: 1591 additions & 26 deletions

File tree

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.PHONY: verify test build clippy clean snapshot snapshot-previews
1+
.PHONY: verify test build clippy cli clean snapshot snapshot-previews
22

33
# Single command for local pre-commit hygiene.
4-
verify: test build clippy
4+
verify: test build clippy cli
55

66
test:
77
npm test
@@ -12,6 +12,11 @@ build:
1212
clippy:
1313
cd examples/showcase && cargo clippy --quiet -- -D warnings
1414

15+
# The cargo-native CLI: build, test, and lint the installer crate.
16+
cli:
17+
cd cli && cargo test --quiet
18+
cd cli && cargo clippy --quiet --all-targets -- -D warnings
19+
1520
# Headless render the showcase to docs/img/snapshots/ via Slint's
1621
# SoftwareRenderer (no display server required).
1722
snapshot:

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# slintcn
22

33
[![Pages](https://github.com/stevekwon211/slintcn/actions/workflows/pages.yml/badge.svg)](https://github.com/stevekwon211/slintcn/actions/workflows/pages.yml)
4+
[![crates.io](https://img.shields.io/crates/v/slintcn?color=white&label=crates.io)](https://crates.io/crates/slintcn)
45
[![npm](https://img.shields.io/npm/v/slintcn?color=white)](https://www.npmjs.com/package/slintcn)
56
[![License: MIT](https://img.shields.io/badge/License-MIT-white.svg)](LICENSE)
67

78
**shadcn/ui-style copy-paste components for Slint native apps.**
89

9-
[Live docs](https://stevekwon211.github.io/slintcn/docs/) · [Live demo](https://stevekwon211.github.io/slintcn) · [npm](https://www.npmjs.com/package/slintcn)
10+
[Live docs](https://stevekwon211.github.io/slintcn/docs/) · [Live demo](https://stevekwon211.github.io/slintcn) · [crates.io](https://crates.io/crates/slintcn) · [npm](https://www.npmjs.com/package/slintcn)
1011

1112
56 UI components, 8 installable blocks, a theme system, and a static registry you can host yourself.
1213

@@ -18,6 +19,22 @@
1819

1920
## Install
2021

22+
Two interchangeable CLIs install the **same files** from the **same hosted
23+
registry** — pick whichever runtime you already have.
24+
25+
**cargo** (no Node required — if you build Slint apps, you already have this):
26+
27+
```bash
28+
cargo install slintcn
29+
30+
cd your-slint-app
31+
slintcn init --base-color zinc
32+
slintcn add button card input dialog
33+
# also available as a cargo subcommand: `cargo slintcn add data-table`
34+
```
35+
36+
**npm:**
37+
2138
```bash
2239
cd your-slint-app
2340
npx slintcn@latest init
@@ -26,7 +43,12 @@ npx slintcn@latest add button card input dialog
2643

2744
Files land in `ui/slintcn/`**you own them**. Change colors in
2845
`ui/slintcn/theme/tokens.slint`, tweak `button.slint` for your product, or host
29-
your own registry.
46+
your own registry. A project initialized by either CLI works with the other —
47+
they share the `slintcn.json` config and lockfile.
48+
49+
> The npm CLI carries the full adoption toolkit (`diff`, `export`,
50+
> `--external-tokens`, `--import-map`, …). The cargo CLI covers the core
51+
> install path — `init` / `add` / `list` / `view` — for the zero-Node case.
3052
3153
## Why it exists
3254

@@ -93,14 +115,16 @@ node /path/to/slintcn/bin/slintcn.mjs add button card input dialog
93115
| **v0.31** | **MCP server**`slintcn-mcp` bin exposes the registry to MCP-capable AI agents (Claude Desktop, Cursor, Windsurf). Tools: `list_components`, `list_blocks`, `view_component`, `install_command` ||
94116
| **v0.32** | **Directory page**`/docs/directory` lists community + official registries; entries land via PR to `registry/directory.json` (ecosystem discovery surface) ||
95117
| **v0.33** | **Discovery + completion** — per-component snapshot pipeline (64 PNGs via `--previews`), `/create` preset page (pick components → copy install command), gallery + README hero refresh ||
118+
| **v0.34** | **cargo-native installer**`cargo install slintcn` (+ `cargo slintcn` subcommand) installs from the hosted registry with no Node; base-color palette variants inlined into the registry so any client can pick them ||
96119

97120
SaaS-first is a **wedge**, not a ceiling. Once tokens + motion + hover semantics
98121
exist, a second registry (`registry/game/`) is just more `.slint` files.
99122

100123
## Prerequisites
101124

102125
- **Rust** with Slint 1.16 (for the showcase or your Slint app)
103-
- **Node 20+** (the CLI runtime)
126+
- A CLI runtime — **either** `cargo` (via `cargo install slintcn`, no Node) **or**
127+
**Node 20+** (via `npx slintcn`). You almost certainly already have cargo.
104128

105129
```slint
106130
import { Button, ButtonVariant, ButtonSize } from "slintcn/components/button.slint";

bin/slintcn.mjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,19 @@ export async function buildRegistryItem(name, registry, readSource) {
6060
if (!item) throw new Error(`Unknown item: ${name}`);
6161
const files = [];
6262
for (const rel of item.files) {
63-
files.push({ path: rel, content: await readSource(rel), type: "text/slint" });
63+
const file = { path: rel, content: await readSource(rel), type: "text/slint" };
64+
// Inline base-color palette alternates so any client (cargo CLI, remote
65+
// install) can swap them without a second request or local registry copy.
66+
if (rel === "theme/palette.slint") {
67+
const variants = {};
68+
for (const color of ["zinc", "slate", "stone"]) {
69+
try {
70+
variants[color] = await readSource(`theme/palette-${color}.slint`);
71+
} catch { /* variant not present — skip */ }
72+
}
73+
if (Object.keys(variants).length > 0) file.variants = variants;
74+
}
75+
files.push(file);
6476
}
6577
return {
6678
name,

0 commit comments

Comments
 (0)