pejay-ui 1.2.2 → 1.3.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/package.json +1 -1
- package/registry.json +33 -1
- package/templates/notes/create-pejay.md +222 -0
- package/templates/notes/notes-v1.md +516 -0
- package/templates/notes/notes-v2.md +764 -0
- package/templates/notes/notes-v3.md +574 -0
- package/templates/notes/notes-v4.md +811 -0
- package/templates/notes/notes-v5.md +579 -0
- package/templates/notes/notes-vf+1.md +311 -0
- package/templates/notes/notes-vfinal.md +852 -0
- package/templates/scaffolds/axios/api/index.ts +40 -0
- package/templates/scaffolds/axios/api/one.api.ts +94 -0
- package/templates/scaffolds/axios/endpoints.ts +9 -0
- package/templates/scaffolds/axios/index.ts +26 -0
- package/templates/scaffolds/axios/interceptors.ts +103 -0
- package/templates/scaffolds/axios/request.ts +32 -0
- package/templates/scaffolds/react-router/hook/useRouterSearch.ts +8 -0
- package/templates/scaffolds/react-router/router/guards/private.route.tsx +1 -0
- package/templates/scaffolds/react-router/router/index.ts +26 -0
- package/templates/scaffolds/react-router/router/layouts/error.layout.tsx +1 -1
- package/templates/scaffolds/redux-store/middlewares.ts +0 -0
- package/templates/scaffolds/redux-store/reducers.ts +30 -0
- package/templates/scaffolds/redux-store/selector/one.selector.ts +43 -0
- package/templates/scaffolds/redux-store/selector/two.selector.ts +11 -0
- package/templates/scaffolds/redux-store/slices/one.slice.ts +202 -0
- package/templates/scaffolds/redux-store/slices/two.slice.ts +21 -0
- package/templates/scaffolds/redux-store/store.ts +38 -0
- package/templates/scaffolds/rtk-query/baseApi.ts +24 -0
- package/templates/scaffolds/rtk-query/baseQuery.ts +12 -0
- package/templates/scaffolds/rtk-query/endpoints/api.one.ts +82 -0
- package/templates/scaffolds/rtk-query/endpoints/index.ts +1 -0
- package/templates/scaffolds/rtk-query/middlewares.ts +11 -0
- package/templates/scaffolds/rtk-query/queryTags.ts +13 -0
- package/templates/scaffolds/tanstack-query/api-base.ts +68 -68
- package/templates/scaffolds/tanstack-query/api-queries.ts +0 -19
- package/templates/scaffolds/tanstack-query/client.ts +8 -0
- package/templates/scaffolds/tanstack-query/module/index.ts +12 -12
- package/templates/scaffolds/tanstack-query/module/keys.ts +17 -17
- package/templates/scaffolds/tanstack-query/module/mappers.ts +15 -15
- package/templates/scaffolds/tanstack-query/module/mutations.ts +59 -55
- package/templates/scaffolds/tanstack-query/module/queries.ts +145 -156
- package/templates/scaffolds/tanstack-query/module/services.ts +74 -66
- package/templates/scaffolds/tanstack-router/layout/404.layout.tsx +3 -0
- package/templates/scaffolds/tanstack-router/layout/app.layout.tsx +10 -0
- package/templates/scaffolds/tanstack-router/layout/auth.layout.tsx +10 -0
- package/templates/scaffolds/tanstack-router/layout/error.layout.tsx +3 -0
- package/templates/scaffolds/tanstack-router/page/auth/login.tsx +3 -0
- package/templates/scaffolds/tanstack-router/page/one/index.tsx +3 -0
- package/templates/scaffolds/tanstack-router/page/one/one-id.tsx +128 -0
- package/templates/scaffolds/tanstack-router/router.ts +90 -0
- package/templates/scaffolds/tanstack-router/routes/_404.tsx +0 -0
- package/templates/scaffolds/tanstack-router/routes/__root.tsx +9 -0
- package/templates/scaffolds/tanstack-router/routes/_app.tsx +6 -0
- package/templates/scaffolds/tanstack-router/routes/_auth.tsx +6 -0
- package/templates/scaffolds/tanstack-router/routes/_error.tsx +0 -0
- package/templates/scaffolds/tanstack-router/routes/auth/login.tsx +6 -0
- package/templates/scaffolds/tanstack-router/routes/one/$id.tsx +191 -0
- package/templates/scaffolds/tanstack-router/routes/one/index.tsx +6 -0
- package/templates/scripts/setup.bat +284 -0
- package/templates/scripts/setup.ps1 +318 -0
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -197,12 +197,44 @@
|
|
|
197
197
|
"files": ["templates/scaffolds/tanstack-query"],
|
|
198
198
|
"peerDependencies": ["@tanstack/react-query"]
|
|
199
199
|
},
|
|
200
|
-
|
|
200
|
+
"react-router-client": {
|
|
201
201
|
"name": "ReactRouterClient",
|
|
202
202
|
"category": "scaffold",
|
|
203
203
|
"subcategory": "react-router",
|
|
204
204
|
"targetDirName": "react-router",
|
|
205
205
|
"files": ["templates/scaffolds/react-router"],
|
|
206
206
|
"peerDependencies": ["react-router-dom"]
|
|
207
|
+
},
|
|
208
|
+
"tanstack-router-client": {
|
|
209
|
+
"name": "TanstackRouterClient",
|
|
210
|
+
"category": "scaffold",
|
|
211
|
+
"subcategory": "tanstack-router",
|
|
212
|
+
"targetDirName": "tanstack-router",
|
|
213
|
+
"files": ["templates/scaffolds/tanstack-router"],
|
|
214
|
+
"peerDependencies": ["@tanstack/react-router"]
|
|
215
|
+
},
|
|
216
|
+
"axios-client": {
|
|
217
|
+
"name": "AxiosClient",
|
|
218
|
+
"category": "scaffold",
|
|
219
|
+
"subcategory": "axios",
|
|
220
|
+
"targetDirName": "axios",
|
|
221
|
+
"files": ["templates/scaffolds/axios"],
|
|
222
|
+
"peerDependencies": ["axios"]
|
|
223
|
+
},
|
|
224
|
+
"redux-store-client": {
|
|
225
|
+
"name": "ReduxStoreClient",
|
|
226
|
+
"category": "scaffold",
|
|
227
|
+
"subcategory": "redux-store",
|
|
228
|
+
"targetDirName": "redux-store",
|
|
229
|
+
"files": ["templates/scaffolds/redux-store"],
|
|
230
|
+
"peerDependencies": ["@reduxjs/toolkit", "react-redux", "redux-persist"]
|
|
231
|
+
},
|
|
232
|
+
"rtk-query-client": {
|
|
233
|
+
"name": "RtkQueryClient",
|
|
234
|
+
"category": "scaffold",
|
|
235
|
+
"subcategory": "rtk-query",
|
|
236
|
+
"targetDirName": "rtk-query",
|
|
237
|
+
"files": ["templates/scaffolds/rtk-query"],
|
|
238
|
+
"peerDependencies": ["@reduxjs/toolkit", "react-redux"]
|
|
207
239
|
}
|
|
208
240
|
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# pejay-ui CLI — How It Works
|
|
2
|
+
|
|
3
|
+
`pejay-ui` is a published npm CLI package that lets you add React UI components
|
|
4
|
+
directly into your project source code — similar to how **shadcn/ui** works.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npx pejay-ui init
|
|
8
|
+
npx pejay-ui add button
|
|
9
|
+
npx pejay-ui remove button
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Architecture Overview
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
pejay-ui/
|
|
18
|
+
├── bin/
|
|
19
|
+
│ └── cli.js ← CLI entry point (commander + inquirer)
|
|
20
|
+
├── templates/
|
|
21
|
+
│ ├── button/ ← Component source files
|
|
22
|
+
│ ├── form/ ← Form component templates
|
|
23
|
+
│ ├── select-dropdown/ ← Dropdown templates
|
|
24
|
+
│ └── scaffolds/ ← Full feature scaffolds (router, query client)
|
|
25
|
+
│ ├── react-router/
|
|
26
|
+
│ └── tanstack-query/
|
|
27
|
+
├── utils/
|
|
28
|
+
│ └── cn.ts ← Shared utility (copied on first component install)
|
|
29
|
+
├── registry.json ← Component manifest / dependency graph
|
|
30
|
+
└── package.json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Key Dependencies
|
|
36
|
+
|
|
37
|
+
| Package | Role |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `commander` | Parses CLI commands (`init`, `add`, `remove`) and arguments |
|
|
40
|
+
| `inquirer` | Interactive y/n confirmation prompts (used during `remove`) |
|
|
41
|
+
| `fs-extra` | File copying, JSON read/write, directory creation |
|
|
42
|
+
| `@babel/core` + `@babel/preset-typescript` | Transpiles `.tsx/.ts` → `.jsx/.js` for non-TypeScript projects |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## How Each Command Works
|
|
47
|
+
|
|
48
|
+
### `npx pejay-ui init`
|
|
49
|
+
|
|
50
|
+
Creates a `pejay-ui.json` config file in your project root:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"baseDir": "src/pejay-ui",
|
|
55
|
+
"installed": {}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
All components will be copied into `src/pejay-ui/components/` and utils into `src/pejay-ui/utils/`.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
### `npx pejay-ui add <component>`
|
|
64
|
+
|
|
65
|
+
This is the core command. Here's what happens step by step:
|
|
66
|
+
|
|
67
|
+
#### 1. Dependency Resolution (Topological Sort)
|
|
68
|
+
```
|
|
69
|
+
add "form/checkbox-group"
|
|
70
|
+
→ registry says it depends on "form/checkbox"
|
|
71
|
+
→ installQueue = ["form/checkbox", "form/checkbox-group"]
|
|
72
|
+
```
|
|
73
|
+
Uses a recursive `resolveDependencies()` + `visited` Set to avoid duplicates and respect install order.
|
|
74
|
+
|
|
75
|
+
#### 2. Peer Dependency Check
|
|
76
|
+
Reads your project's `package.json` and checks if required npm packages are missing.
|
|
77
|
+
Auto-detects your package manager:
|
|
78
|
+
```
|
|
79
|
+
yarn.lock → yarn add ...
|
|
80
|
+
pnpm-lock.yaml → pnpm add ...
|
|
81
|
+
(default) → npm install ...
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### 3. Copy Utilities
|
|
85
|
+
Copies `utils/cn.ts` (or `.js` for JS projects) into `src/pejay-ui/utils/` — only if it doesn't already exist.
|
|
86
|
+
|
|
87
|
+
#### 4. Copy Component Files
|
|
88
|
+
- Reads template files from the `templates/` directory
|
|
89
|
+
- Rewrites `@/utils/cn` import paths to relative paths that work at the copy destination
|
|
90
|
+
- **TypeScript projects** → files are copied as-is (`.tsx` / `.ts`)
|
|
91
|
+
- **JavaScript projects** → files are transpiled via Babel to `.jsx` / `.js`
|
|
92
|
+
|
|
93
|
+
#### 5. Track Installation State
|
|
94
|
+
Updates `pejay-ui.json` with what was installed:
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"installed": {
|
|
98
|
+
"button": {
|
|
99
|
+
"files": ["components/button/Button.tsx", "components/button/tooltip.tsx"],
|
|
100
|
+
"utils": ["cn.ts"]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
### `npx pejay-ui remove <component>`
|
|
109
|
+
|
|
110
|
+
#### 1. Deletes Component Files
|
|
111
|
+
Reads the file list from `pejay-ui.json` and removes each tracked file.
|
|
112
|
+
|
|
113
|
+
#### 2. Smart Utility Cleanup
|
|
114
|
+
Counts how many other installed components use each utility.
|
|
115
|
+
If a utility is **only used by the removed component**, it prompts:
|
|
116
|
+
```
|
|
117
|
+
? Remove utility "cn.ts"? (y/N)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### 3. Smart Package Uninstall
|
|
121
|
+
Same logic for npm packages — if a `peerDependency` is no longer needed by any other component, it prompts:
|
|
122
|
+
```
|
|
123
|
+
? Uninstall unused packages: clsx, tailwind-merge? (y/N)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### 4. Updates `pejay-ui.json`
|
|
127
|
+
Removes the component's entry from `installed`.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## The Registry (`registry.json`)
|
|
132
|
+
|
|
133
|
+
Each entry defines a component's metadata:
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
"form/date-picker": {
|
|
137
|
+
"name": "DatePicker",
|
|
138
|
+
"category": "form",
|
|
139
|
+
"files": ["templates/form/date-picker.tsx"],
|
|
140
|
+
"utils": ["cn.ts"],
|
|
141
|
+
"peerDependencies": ["clsx", "tailwind-merge", "lucide-react", "@floating-ui/react"],
|
|
142
|
+
"dependencies": ["select-dropdown/select-input"]
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
| Field | Description |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `category` | Sub-folder under `components/` where files land |
|
|
149
|
+
| `files` | Template paths to copy (file or directory) |
|
|
150
|
+
| `utils` | Utility files from `utils/` to copy alongside |
|
|
151
|
+
| `peerDependencies` | npm packages that must be installed in the target project |
|
|
152
|
+
| `dependencies` | Other pejay-ui components that must be installed first |
|
|
153
|
+
|
|
154
|
+
**Special category — `scaffold`:** Instead of going into `src/pejay-ui/components/`,
|
|
155
|
+
scaffold components copy directly into `src/<targetDirName>/`:
|
|
156
|
+
```json
|
|
157
|
+
"tanstack-query-client": {
|
|
158
|
+
"category": "scaffold",
|
|
159
|
+
"targetDirName": "tanstack-query",
|
|
160
|
+
"files": ["templates/scaffolds/tanstack-query"]
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Available Components
|
|
167
|
+
|
|
168
|
+
### Form
|
|
169
|
+
| Command | Component |
|
|
170
|
+
|---|---|
|
|
171
|
+
| `add form/input` | Input |
|
|
172
|
+
| `add form/amount-input` | AmountInput |
|
|
173
|
+
| `add form/checkbox` | Checkbox |
|
|
174
|
+
| `add form/checkbox-group` | CheckboxGroup *(auto-installs Checkbox)* |
|
|
175
|
+
| `add form/date-picker` | DatePicker *(auto-installs SelectInput)* |
|
|
176
|
+
| `add form/date-range-picker` | DateRangePicker *(auto-installs SelectInput)* |
|
|
177
|
+
| `add form/email-input` | EmailInput |
|
|
178
|
+
| `add form/file-input` | FileInput |
|
|
179
|
+
| `add form/number-input` | NumberInput |
|
|
180
|
+
| `add form/password-input` | PasswordInput |
|
|
181
|
+
| `add form/phone-input` | PhoneInput |
|
|
182
|
+
| `add form/radio` | Radio |
|
|
183
|
+
| `add form/radio-group` | RadioGroup *(auto-installs Radio)* |
|
|
184
|
+
| `add form/range-slider` | RangeSlider |
|
|
185
|
+
| `add form/switch` | Switch |
|
|
186
|
+
| `add form/textarea` | Textarea |
|
|
187
|
+
| `add form/time-picker` | TimePicker *(auto-installs SelectInput)* |
|
|
188
|
+
| `add form/time-range-picker` | TimeRangePicker *(auto-installs SelectInput)* |
|
|
189
|
+
| `add form/url-input` | UrlInput |
|
|
190
|
+
|
|
191
|
+
### Dropdowns
|
|
192
|
+
| Command | Component |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `add dropdown/select-input` | SelectInput |
|
|
195
|
+
| `add dropdown/multiselect-input` | MultiselectInput |
|
|
196
|
+
|
|
197
|
+
### Button
|
|
198
|
+
| Command | Component |
|
|
199
|
+
|---|---|
|
|
200
|
+
| `add button` | Button + Tooltip |
|
|
201
|
+
|
|
202
|
+
### Scaffolds
|
|
203
|
+
| Command | What it does |
|
|
204
|
+
|---|---|
|
|
205
|
+
| `add tanstack-query-client` | Copies full TanStack Query setup into `src/tanstack-query/` |
|
|
206
|
+
| `add react-router-client` | Copies full React Router setup into `src/react-router/` |
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Publishing a New Version
|
|
211
|
+
|
|
212
|
+
```sh
|
|
213
|
+
# 1. Bump version
|
|
214
|
+
npm version patch # 1.2.2 → 1.2.3
|
|
215
|
+
npm version minor # 1.2.2 → 1.3.0
|
|
216
|
+
npm version major # 1.2.2 → 2.0.0
|
|
217
|
+
|
|
218
|
+
# 2. Publish
|
|
219
|
+
npm publish
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Live on npm: [npmjs.com/package/pejay-ui](https://www.npmjs.com/package/pejay-ui)
|