@rootnative/cli 0.0.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 RootNative
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,310 @@
1
+ # rootnative
2
+
3
+ CLI for adding [RootNative UI](https://github.com/rootnative/ui) components directly into your React Native or Expo project. Inspired by [shadcn/ui](https://ui.shadcn.com) — you own the code.
4
+
5
+ ## Quick start
6
+
7
+ Start a new project:
8
+
9
+ ```bash
10
+ npx rootnative create my-app
11
+ ```
12
+
13
+ Or add components to an existing project:
14
+
15
+ ```bash
16
+ npx rootnative init
17
+ npx rootnative add button card
18
+ ```
19
+
20
+ ## How it works
21
+
22
+ Instead of installing components as an npm package, the CLI copies the source files into your project. You get full ownership — customize styles, adjust behavior, or remove what you don't need.
23
+
24
+ The theme system (`@rootnative/core`) stays as an npm dependency so theme updates propagate automatically.
25
+
26
+ ## Requirements
27
+
28
+ - Node.js >= 18
29
+ - React Native >= 0.72 or Expo SDK >= 49
30
+ - TypeScript project (recommended)
31
+
32
+ ## Commands
33
+
34
+ ### `rootnative create [name]`
35
+
36
+ Scaffold a new Expo project with RootNative UI pre-configured (`ThemeProvider` wired up, example components included).
37
+
38
+ ```bash
39
+ npx rootnative create my-app
40
+ ```
41
+
42
+ It prompts for project name, display name, template, and package manager.
43
+
44
+ Options:
45
+
46
+ | Flag | Description |
47
+ |------|-------------|
48
+ | `-y, --yes` | Skip prompts and use defaults |
49
+ | `-t, --template <name>` | Template to use (`blank`, `with-router`) |
50
+ | `--package-manager <pm>` | Package manager to use (npm, yarn, pnpm, bun) |
51
+
52
+ Non-interactive mode for CI/automation:
53
+
54
+ ```bash
55
+ npx rootnative create my-app -y --template with-router --package-manager pnpm
56
+ ```
57
+
58
+ ### `rootnative init`
59
+
60
+ Initialize your project for RootNative UI.
61
+
62
+ ```bash
63
+ npx rootnative init
64
+ ```
65
+
66
+ This will:
67
+
68
+ 1. Detect your project type (Expo or bare React Native)
69
+ 2. Detect your package manager (npm, yarn, pnpm, bun)
70
+ 3. Detect path aliases from your `tsconfig.json`
71
+ 4. Prompt for component and utility output directories
72
+ 5. Install `@rootnative/core`
73
+ 6. Create an `rootnative.json` config file
74
+
75
+ Options:
76
+
77
+ | Flag | Description |
78
+ |------|-------------|
79
+ | `-y, --yes` | Skip all prompts and use detected defaults |
80
+ | `--components-alias <alias>` | Components install path (default: `@/components/ui`) |
81
+ | `--lib-alias <alias>` | Utility files path (default: `@/lib`) |
82
+ | `--package-manager <pm>` | Package manager to use (npm, yarn, pnpm, bun) |
83
+
84
+ Non-interactive mode for CI/automation:
85
+
86
+ ```bash
87
+ # Accept all defaults
88
+ npx rootnative init -y
89
+
90
+ # With custom paths
91
+ npx rootnative init -y --components-alias "~/ui" --lib-alias "~/utils"
92
+ ```
93
+
94
+ ### `rootnative add <components...>`
95
+
96
+ Add one or more components to your project.
97
+
98
+ ```bash
99
+ npx rootnative add button
100
+ npx rootnative add card chip text-field
101
+ npx rootnative add appbar # auto-adds icon-button + typography dependencies
102
+ ```
103
+
104
+ Options:
105
+
106
+ | Flag | Description |
107
+ |------|-------------|
108
+ | `-f, --force` | Overwrite existing components |
109
+ | `-d, --dry-run` | Preview what would be installed without writing files |
110
+ | `--package-manager <pm>` | Package manager to use (npm, yarn, pnpm, bun) |
111
+
112
+ The `add` command:
113
+
114
+ 1. Resolves the full dependency graph (e.g. `appbar` requires `icon-button` and `typography`)
115
+ 2. Shows a plan of components, utilities, and npm packages to install
116
+ 3. Copies component files with import paths rewritten to match your project
117
+ 4. Generates a utility barrel file (`rootnative-utils.ts`)
118
+ 5. Installs required npm dependencies
119
+
120
+ ### `rootnative update [components...]`
121
+
122
+ Update installed components to the latest version from the registry.
123
+
124
+ ```bash
125
+ npx rootnative update button # update specific components
126
+ npx rootnative update --all # update everything installed
127
+ npx rootnative update --all --dry-run # preview the diff first
128
+ ```
129
+
130
+ Options:
131
+
132
+ | Flag | Description |
133
+ |------|-------------|
134
+ | `-a, --all` | Update all installed components |
135
+ | `-d, --dry-run` | Show diff without applying changes |
136
+
137
+ Local modifications are detected by diffing against the registry source — review the diff with `--dry-run` before applying if you've customized component files.
138
+
139
+ ### `rootnative upgrade`
140
+
141
+ Upgrade `@rootnative/core` to the latest published version and install any new peer dependencies.
142
+
143
+ ```bash
144
+ npx rootnative upgrade
145
+ ```
146
+
147
+ Options:
148
+
149
+ | Flag | Description |
150
+ |------|-------------|
151
+ | `-y, --yes` | Skip confirmation prompt |
152
+ | `-a, --all` | Also update all installed component files |
153
+ | `--package-manager <pm>` | Package manager to use (npm, yarn, pnpm, bun) |
154
+
155
+ The `upgrade` command:
156
+
157
+ 1. Detects the installed `@rootnative/core` version from `node_modules`
158
+ 2. Fetches the latest version from the npm registry
159
+ 3. Compares peer dependencies between the installed and latest versions
160
+ 4. Shows a plan with the version bump, new required peer deps, changed ranges, and removed deps
161
+ 5. Upgrades `@rootnative/core` and installs any new required peer dependencies
162
+ 6. Reports optional peer deps that aren't installed (does not auto-install them)
163
+ 7. Lists peer deps that are no longer required so you can remove them manually
164
+
165
+ Non-interactive mode for CI/automation:
166
+
167
+ ```bash
168
+ npx rootnative upgrade -y
169
+ ```
170
+
171
+ ### `rootnative list`
172
+
173
+ Show all available components with their install status.
174
+
175
+ ```bash
176
+ npx rootnative list
177
+ ```
178
+
179
+ ### `rootnative doctor`
180
+
181
+ Check your project for common issues.
182
+
183
+ ```bash
184
+ npx rootnative doctor
185
+ ```
186
+
187
+ Checks include:
188
+
189
+ - `rootnative.json` exists and is valid
190
+ - `@rootnative/core` is installed
191
+ - React Native version compatibility
192
+ - Installed component file integrity
193
+ - Peer dependencies (`react-native-safe-area-context`, `@expo/vector-icons`)
194
+
195
+ ## Configuration
196
+
197
+ `rootnative init` creates an `rootnative.json` in your project root:
198
+
199
+ ```json
200
+ {
201
+ "$schema": "https://rootnative.github.io/ui/schema.json",
202
+ "aliases": {
203
+ "components": "@/components/ui",
204
+ "lib": "@/lib"
205
+ },
206
+ "registryUrl": "https://raw.githubusercontent.com/rootnative/ui",
207
+ "registryVersion": "main"
208
+ }
209
+ ```
210
+
211
+ | Field | Description |
212
+ |-------|-------------|
213
+ | `aliases.components` | Where component directories are created |
214
+ | `aliases.lib` | Where utility files are placed |
215
+ | `registryUrl` | Base URL for fetching component source files |
216
+ | `registryVersion` | Git ref to fetch from (branch, tag, or commit) |
217
+
218
+ ## Output structure
219
+
220
+ After running `npx rootnative add button appbar`:
221
+
222
+ ```
223
+ src/
224
+ components/
225
+ ui/
226
+ button/
227
+ Button.tsx
228
+ types.ts
229
+ styles.ts
230
+ index.ts
231
+ icon-button/ # auto-added (appbar dependency)
232
+ IconButton.tsx
233
+ types.ts
234
+ styles.ts
235
+ index.ts
236
+ typography/ # auto-added (appbar dependency)
237
+ Typography.tsx
238
+ types.ts
239
+ index.ts
240
+ appbar/
241
+ AppBar.tsx
242
+ types.ts
243
+ styles.ts
244
+ index.ts
245
+ lib/
246
+ color.ts
247
+ elevation.ts
248
+ icon.ts
249
+ rtl.ts
250
+ rootnative-utils.ts # generated barrel
251
+ ```
252
+
253
+ ## Available components
254
+
255
+ | Component | Description |
256
+ |-----------|-------------|
257
+ | `typography` | Text component with 15 MD3 type scale variants |
258
+ | `button` | 5 variants (filled, elevated, outlined, text, tonal) with icon support |
259
+ | `button-group` | Standard and connected button groups with single or multi-select toggle behavior |
260
+ | `icon-button` | 4 variants (filled, tonal, outlined, standard) with toggle support |
261
+ | `fab` | Floating action button with 4 color variants, 3 sizes, and optional extended label |
262
+ | `appbar` | Top app bar with 4 variants and SafeAreaView support |
263
+ | `avatar` | Circular avatar with image, icon, or text initials and 5 sizes |
264
+ | `card` | 3 variants (elevated, filled, outlined) with optional press handler |
265
+ | `chip` | 4 variants (assist, filter, input, suggestion) with icon/avatar support |
266
+ | `checkbox` | Binary selection control |
267
+ | `radio` | Single-choice selection control |
268
+ | `switch` | Toggle control with optional icons |
269
+ | `slider` | Single-thumb or range slider with continuous and discrete modes |
270
+ | `progress` | Linear and circular progress indicators (determinate and indeterminate) |
271
+ | `text-field` | Text input with animated floating label, 2 variants (filled, outlined) |
272
+ | `layout` | Layout primitives: Box, Row, Column, Grid, and SafeAreaView wrapper |
273
+ | `list` | List container with interactive items and dividers |
274
+ | `portal` | Render children into a host elsewhere in the tree (overlays, dialogs, sheets) |
275
+ | `keyboard-avoiding-wrapper` | Zero-config keyboard-aware wrapper for form layouts |
276
+
277
+ ## Import rewriting
278
+
279
+ The CLI rewrites imports so copied files work in your project:
280
+
281
+ | Original (library source) | Rewritten to |
282
+ |---------------------------|-------------|
283
+ | `@rootnative/core` | Unchanged (npm package) |
284
+ | `@rootnative/utils` | `@/lib/rootnative-utils` (local barrel) |
285
+ | `../icon-button` | `@/components/ui/icon-button` (alias path) |
286
+ | `./styles` | Unchanged (same directory) |
287
+
288
+ ## Usage after adding components
289
+
290
+ ```tsx
291
+ import { ThemeProvider } from '@rootnative/core'
292
+ import { Button } from '@/components/ui/button'
293
+ import { Card } from '@/components/ui/card'
294
+
295
+ export default function App() {
296
+ return (
297
+ <ThemeProvider>
298
+ <Card>
299
+ <Button variant="filled" onPress={() => {}}>
300
+ Press me
301
+ </Button>
302
+ </Card>
303
+ </ThemeProvider>
304
+ )
305
+ }
306
+ ```
307
+
308
+ ## License
309
+
310
+ MIT
@@ -0,0 +1,2 @@
1
+
2
+ export { }