@cookest/ui-cli 0.1.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 +21 -0
- package/README.md +244 -0
- package/dist/index.js +9438 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Cookest
|
|
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,244 @@
|
|
|
1
|
+
# @cookest/ui-cli
|
|
2
|
+
|
|
3
|
+
A command-line tool that adds [Cookest UI](https://github.com/Cookest/cookest-ui-components-library) components directly into your **React** or **Flutter** project — no package linking required.
|
|
4
|
+
|
|
5
|
+
Inspired by [shadcn/ui](https://ui.shadcn.com/): components are **copied into your project as source files** so you own them completely.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# React project
|
|
13
|
+
npx @cookest/ui-cli add button
|
|
14
|
+
|
|
15
|
+
# Flutter project (auto-detected via pubspec.yaml)
|
|
16
|
+
npx @cookest/ui-cli add button
|
|
17
|
+
|
|
18
|
+
# Force framework explicitly
|
|
19
|
+
npx @cookest/ui-cli add button --react
|
|
20
|
+
npx @cookest/ui-cli add button --flutter
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
**Use without installing (recommended):**
|
|
28
|
+
```bash
|
|
29
|
+
npx @cookest/ui-cli <command>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Install globally:**
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g @cookest/ui-cli
|
|
35
|
+
# or
|
|
36
|
+
bun add -g @cookest/ui-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Commands
|
|
42
|
+
|
|
43
|
+
### `init`
|
|
44
|
+
|
|
45
|
+
Detects your framework, locates the ui-components source, and creates a `.cookestrc` config file.
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
cookest-ui init
|
|
49
|
+
cookest-ui init --yes # skip all prompts
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`.cookestrc` example:
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"framework": "react",
|
|
56
|
+
"sourceRoot": "../ui-components",
|
|
57
|
+
"componentsDir": "src/components/ui"
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### `list`
|
|
64
|
+
|
|
65
|
+
Shows all 18 available components with React/Flutter availability.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cookest-ui list
|
|
69
|
+
|
|
70
|
+
# Filter by name, tag, or description
|
|
71
|
+
cookest-ui list --filter form
|
|
72
|
+
cookest-ui list --filter loading
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Output:
|
|
76
|
+
```
|
|
77
|
+
🌿 Cookest UI — Available Components
|
|
78
|
+
|
|
79
|
+
Name React Flutter Description
|
|
80
|
+
──────────────────────────────────────────────────────────────────────
|
|
81
|
+
button ✔ ✔ Pressable button with variants, loading state...
|
|
82
|
+
input ✔ ✔ Text input with label, error, helper text...
|
|
83
|
+
...
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### `add`
|
|
89
|
+
|
|
90
|
+
Copies component source files into your project and prints the import statement.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Add one component
|
|
94
|
+
cookest-ui add button
|
|
95
|
+
|
|
96
|
+
# Add multiple
|
|
97
|
+
cookest-ui add button input card badge
|
|
98
|
+
|
|
99
|
+
# Add all components at once
|
|
100
|
+
cookest-ui add --all
|
|
101
|
+
|
|
102
|
+
# Force React or Flutter
|
|
103
|
+
cookest-ui add tabs --react
|
|
104
|
+
cookest-ui add tabs --flutter
|
|
105
|
+
|
|
106
|
+
# Overwrite existing files
|
|
107
|
+
cookest-ui add button --overwrite
|
|
108
|
+
|
|
109
|
+
# Interactive picker (no args)
|
|
110
|
+
cookest-ui add
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**React output example:**
|
|
114
|
+
```
|
|
115
|
+
🌿 Adding 1 component (react)
|
|
116
|
+
|
|
117
|
+
Adding button...
|
|
118
|
+
✔ src/components/ui/Button.tsx
|
|
119
|
+
✔ src/components/ui/Button/index.ts
|
|
120
|
+
|
|
121
|
+
Run to install dependencies:
|
|
122
|
+
bun add framer-motion
|
|
123
|
+
|
|
124
|
+
Import in your project:
|
|
125
|
+
import { Button } from '@/components/ui/Button';
|
|
126
|
+
|
|
127
|
+
✔ Done!
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Flutter output example:**
|
|
131
|
+
```
|
|
132
|
+
🌿 Adding 1 component (flutter)
|
|
133
|
+
|
|
134
|
+
Adding button...
|
|
135
|
+
✔ lib/ui/ck_button.dart
|
|
136
|
+
|
|
137
|
+
Add to pubspec.yaml dependencies:
|
|
138
|
+
google_fonts: ^8.0.0
|
|
139
|
+
Then run: flutter pub get
|
|
140
|
+
|
|
141
|
+
Import in your Dart file:
|
|
142
|
+
import 'lib/ui/ck_button.dart';
|
|
143
|
+
|
|
144
|
+
✔ Done!
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### `diff`
|
|
150
|
+
|
|
151
|
+
Checks which locally installed components differ from the source registry (useful after upgrading).
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Check all installed components
|
|
155
|
+
cookest-ui diff
|
|
156
|
+
|
|
157
|
+
# Check specific ones
|
|
158
|
+
cookest-ui diff button card tabs
|
|
159
|
+
|
|
160
|
+
# Check Flutter widgets
|
|
161
|
+
cookest-ui diff --flutter
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Available Components
|
|
167
|
+
|
|
168
|
+
| Component | React | Flutter | Tags |
|
|
169
|
+
|---|---|---|---|
|
|
170
|
+
| `button` | ✅ | ✅ | action, form |
|
|
171
|
+
| `input` | ✅ | ✅ | form, text |
|
|
172
|
+
| `textarea` | ✅ | ✅ | form, multiline |
|
|
173
|
+
| `card` | ✅ | ✅ | layout, container |
|
|
174
|
+
| `badge` | ✅ | ✅ | label, status |
|
|
175
|
+
| `avatar` | ✅ | ✅ | user, profile |
|
|
176
|
+
| `modal` | ✅ | ✅ | overlay, dialog |
|
|
177
|
+
| `tooltip` | ✅ | ✅ | overlay, info |
|
|
178
|
+
| `toggle` | ✅ | ✅ | form, switch |
|
|
179
|
+
| `select` | ✅ | ✅ | form, dropdown |
|
|
180
|
+
| `skeleton` | ✅ | ✅ | loading, state |
|
|
181
|
+
| `alert` | ✅ | ✅ | feedback, banner |
|
|
182
|
+
| `divider` | ✅ | ✅ | layout |
|
|
183
|
+
| `slider` | ✅ | ✅ | form, range |
|
|
184
|
+
| `progress` | ✅ | ✅ | loading, feedback |
|
|
185
|
+
| `spinner` | ✅ | ✅ | loading, animation |
|
|
186
|
+
| `tabs` | ✅ | ✅ | navigation |
|
|
187
|
+
| `accordion` | ✅ | ✅ | layout, disclosure |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Framework Auto-detection
|
|
192
|
+
|
|
193
|
+
The CLI detects your framework automatically:
|
|
194
|
+
|
|
195
|
+
| Signal | Framework |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `pubspec.yaml` with `sdk: flutter` | Flutter |
|
|
198
|
+
| `package.json` with `react` or `next` dependency | React |
|
|
199
|
+
| `package.json` only | React (generic) |
|
|
200
|
+
|
|
201
|
+
Override with `--react` or `--flutter` flags on any command.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Using in a monorepo
|
|
206
|
+
|
|
207
|
+
If `ui-components/` is in the same monorepo, run `cookest-ui init` once — it auto-discovers the source by walking up the directory tree. The resulting `.cookestrc` pinpoints the path:
|
|
208
|
+
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"framework": "react",
|
|
212
|
+
"sourceRoot": "../../ui-components"
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Or set an env variable:
|
|
217
|
+
```bash
|
|
218
|
+
COOKEST_SOURCE_ROOT=/path/to/ui-components cookest-ui add button
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## How it works
|
|
224
|
+
|
|
225
|
+
1. **Registry** (`src/registry.ts`) maps each component name to its React `.tsx` and Flutter `.dart` source files.
|
|
226
|
+
2. **`add` command** resolves the source root, copies the files to your project with `fs.copyFile`.
|
|
227
|
+
3. **React**: adds missing `framer-motion` etc. to `package.json` and prints the install command.
|
|
228
|
+
4. **Flutter**: prints the `pubspec.yaml` snippet for any missing `pub.dev` dependencies.
|
|
229
|
+
5. **`diff` command** compares installed files byte-for-byte with the registry source.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Development
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
cd ui-components/cli
|
|
237
|
+
bun install
|
|
238
|
+
bun run dev # watch mode
|
|
239
|
+
bun run build # production build → dist/index.js
|
|
240
|
+
|
|
241
|
+
# Test locally
|
|
242
|
+
node dist/index.js list
|
|
243
|
+
node dist/index.js add button --react
|
|
244
|
+
```
|