honotan 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +372 -0
  3. package/dist/index.mjs +8597 -0
  4. package/package.json +48 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 rifkyputra
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,372 @@
1
+ # Honotan CLI
2
+
3
+ A CLI tool for generating boilerplate code with different architectural patterns and frameworks for both API and client development.
4
+
5
+ ## Features
6
+
7
+ ### API Generation
8
+
9
+ - **Architecture Patterns**
10
+ - Hexagonal (Ports & Adapters)
11
+ - Vertical Slice
12
+
13
+ - **Frameworks**
14
+ - Hono
15
+ - Express _(coming soon)_
16
+ - Fastify _(coming soon)_
17
+
18
+ - **Adapters**
19
+ - **Inbound**: HTTP, WebSocket
20
+ - **Outbound**: In-Memory Repository, Database, Cache
21
+
22
+ ### Client Generation
23
+
24
+ - **Framework**: TanStack Router (file-based routing for React)
25
+ - **State Management**: TanStack Store for global state
26
+ - **Examples**: Counter UI and /hello fetch demo
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ npm install -g honotan-cli
32
+ # or
33
+ bun add -g honotan-cli
34
+ ```
35
+
36
+ ## Local Development
37
+
38
+ To install and work on this project locally:
39
+
40
+ ### 1. Clone the Repository
41
+
42
+ ```bash
43
+ git clone https://github.com/rifkyputra/honotan-cli.git
44
+ cd honotan-cli
45
+ ```
46
+
47
+ ### 2. Install Dependencies
48
+
49
+ Using Bun (recommended):
50
+
51
+ ```bash
52
+ bun install
53
+ ```
54
+
55
+ Or using npm:
56
+
57
+ ```bash
58
+ npm install
59
+ ```
60
+
61
+ ### 3. Build the Project
62
+
63
+ ```bash
64
+ bun run build
65
+ # or
66
+ npm run build
67
+ ```
68
+
69
+ ### 4. Link Locally for Testing
70
+
71
+ To use the CLI globally during development:
72
+
73
+ ```bash
74
+ npm link
75
+ # or
76
+ bun link
77
+ ```
78
+
79
+ Now you can run `honotan` from anywhere on your system.
80
+
81
+ ### 5. Development Mode
82
+
83
+ Run the CLI in watch mode (auto-reloads on changes):
84
+
85
+ ```bash
86
+ bun run dev
87
+ # or
88
+ npm run dev
89
+ ```
90
+
91
+ ### 6. Type Checking
92
+
93
+ ```bash
94
+ bun run check-types
95
+ # or
96
+ npm run check-types
97
+ ```
98
+
99
+ ### 7. Running Tests
100
+
101
+ ```bash
102
+ bun test
103
+ # or
104
+ npm test
105
+ ```
106
+
107
+ ### Project Structure
108
+
109
+ ```
110
+ honotan-cli/
111
+ ├── src/
112
+ │ ├── commands/ # CLI command implementations
113
+ │ │ ├── generate.ts # Code generation logic
114
+ │ │ ├── prompts.ts # Interactive prompts
115
+ │ │ └── detect-resource.ts
116
+ │ ├── templates/ # Code templates
117
+ │ │ ├── hexagonal/ # Hexagonal architecture templates
118
+ │ │ └── vertical-slice/ # Vertical slice templates
119
+ │ ├── utils/ # Utility functions
120
+ │ ├── types.ts # TypeScript type definitions
121
+ │ └── index.ts # CLI entry point
122
+ ├── dist/ # Built files
123
+ ├── package.json
124
+ └── tsconfig.json
125
+ ```
126
+
127
+ ## Usage
128
+
129
+ ### Generate a New API Resource
130
+
131
+ ```bash
132
+ honotan generate api
133
+ ```
134
+
135
+ Follow the interactive prompts to:
136
+
137
+ 1. Choose an architecture pattern (Hexagonal or Vertical Slice)
138
+ 2. Select an API framework (currently Hono only; Express and Fastify coming soon)
139
+ 3. Enter a resource name (e.g., "product", "user")
140
+ 4. Select inbound and outbound adapters
141
+ 5. Specify output directory
142
+
143
+ ### Generate a Client Project
144
+
145
+ ```bash
146
+ honotan generate client
147
+ ```
148
+
149
+ Generate a **complete, ready-to-run** TanStack Router + React project:
150
+
151
+ 1. Enter a resource/project name
152
+ 2. Specify output directory (default: "apps/<resource-name>")
153
+ 3. Get a fully configured project ready to run
154
+
155
+ **What You Get:**
156
+
157
+ - ✅ Complete Vite + React + TypeScript setup
158
+ - ✅ TanStack Router with file-based routing
159
+ - ✅ TanStack Query for server data fetching
160
+ - ✅ TanStack Store for client-side state management
161
+ - ✅ Tailwind CSS for styling
162
+ - ✅ Headless UI components
163
+ - ✅ Heroicons for beautiful icons
164
+ - ✅ Counter example (TanStack Store)
165
+ - ✅ Fetch /hello example (TanStack Query)
166
+ - ✅ All configuration files
167
+ - ✅ Ready to run with `npm install && npm run dev`
168
+
169
+ ### Client Structure (TanStack Router + Query + Store)
170
+
171
+ Following the official TanStack Router conventions:
172
+
173
+ ```
174
+ apps/<resource-name>/
175
+ ├── package.json
176
+ ├── vite.config.ts
177
+ ├── tailwind.config.js # Tailwind CSS configuration
178
+ ├── postcss.config.js # PostCSS configuration
179
+ ├── tsconfig.json
180
+ ├── index.html
181
+ └── src/
182
+ ├── main.tsx # App entry point
183
+ ├── index.css # Tailwind CSS imports
184
+ ├── routeTree.gen.ts # Auto-generated by TanStack Router
185
+ ├── lib/
186
+ │ ├── query-client.ts # TanStack Query client
187
+ │ └── counter-store.ts # TanStack Store state
188
+ └── routes/
189
+ ├── __root.tsx # Root layout with Headless UI navigation
190
+ ├── index.tsx # Home with counter & fetch examples
191
+ └── about.tsx # About page
192
+ ```
193
+
194
+ **Key Features:**
195
+
196
+ - **File-based routing**: Routes automatically mapped from file structure
197
+ - **Server data fetching**: TanStack Query for caching, background updates, and optimistic UI
198
+ - **Client-side state**: TanStack Store for simple global state management
199
+ - **Modern UI**: Tailwind CSS + Headless UI for accessible, beautiful components
200
+ - **Icons**: Heroicons for scalable SVG icons
201
+ - **Counter example**: Inc/dec/reset demonstrating TanStack Store with Headless UI buttons
202
+ - **Fetch example**: Call /hello endpoint demonstrating TanStack Query
203
+ - **Clean structure**: Minimal setup, easy to understand
204
+
205
+ **Generated Files:**
206
+
207
+ **Project Configuration:**
208
+
209
+ - `package.json` - Dependencies (React, TanStack Router, TanStack Query, TanStack Store, Tailwind CSS, Headless UI, Heroicons)
210
+ - `vite.config.ts` - Vite with TanStack Router plugin
211
+ - `tailwind.config.js` - Tailwind CSS configuration
212
+ - `postcss.config.js` - PostCSS with Tailwind and Autoprefixer
213
+ - `tsconfig.json` - TypeScript configuration
214
+ - `index.html` - Entry HTML
215
+ - `.gitignore` - Git ignore patterns
216
+
217
+ **Application Code:**
218
+
219
+ - `src/main.tsx` - App entry point with router setup
220
+ - `src/index.css` - Tailwind CSS imports
221
+ - `src/lib/query-client.ts` - TanStack Query client configuration
222
+ - `src/lib/counter-store.ts` - Global counter state with TanStack Store
223
+
224
+ **Routes:**
225
+
226
+ - `src/routes/__root.tsx` - Root layout with QueryClientProvider and Headless UI navigation
227
+ - `src/routes/index.tsx` - Home page with counter (Store) and fetch (Query) examples using Headless UI
228
+ - `src/routes/about.tsx` - About page with styled components
229
+
230
+ ### Add Adapters to Existing Resource
231
+
232
+ ```bash
233
+ honotan add-adapter
234
+ ```
235
+
236
+ Select an existing API resource and add new inbound or outbound adapters.
237
+
238
+ ### Utility Commands
239
+
240
+ #### clean
241
+
242
+ Deeply cleans the project by removing build artifacts and dependencies (`node_modules`, `dist`, `.turbo`, etc.) across the monorepo.
243
+
244
+ ```bash
245
+ honotan util clean
246
+ ```
247
+
248
+ Use this when you need a fresh start or are experiencing dependency/caching issues.
249
+
250
+ ## Examples
251
+
252
+ ### Generate an API Product Resource (Hexagonal)
253
+
254
+ ```bash
255
+ $ honotan generate api
256
+
257
+ ? What would you like to do? Create a new resource
258
+ ? Architecture pattern: Hexagonal (Ports & Adapters)
259
+ ? API Framework: Hono
260
+ ? Resource name: product
261
+ ? Select inbound adapters: HTTP
262
+ ? Select outbound adapters: In-Memory Repository, Database
263
+ ? Output directory: src
264
+ ```
265
+
266
+ This generates a complete product API module with:
267
+
268
+ - Domain entities and ports
269
+ - Use case implementation with tests
270
+ - HTTP routes and controllers
271
+ - In-memory and database repositories
272
+ - Zod validation schemas
273
+
274
+ ### Generate a Client Project Example
275
+
276
+ ```bash
277
+ $ honotan generate client
278
+
279
+ ? Output directory: my-app
280
+
281
+ ✅ TanStack Router project generated: my-app
282
+
283
+ 📁 Project structure:
284
+ my-app/
285
+ ├── package.json
286
+ ├── vite.config.ts
287
+ ├── tsconfig.json
288
+ ├── index.html
289
+ └── src/
290
+ ├── main.tsx
291
+ ├── routeTree.gen.ts (auto-generated)
292
+ ├── lib/counter-store.ts
293
+ └── routes/
294
+ ├── __root.tsx
295
+ ├── index.tsx
296
+ └── about.tsx
297
+
298
+ 📦 Next steps:
299
+ 1. cd my-app
300
+ 2. npm install (or bun install)
301
+ 3. npm run dev (or bun run dev)
302
+ 4. Open http://localhost:3000
303
+
304
+ 💡 Features:
305
+ - Counter with TanStack Store state management
306
+ - /hello fetch example
307
+ - File-based routing with TanStack Router
308
+ ```
309
+
310
+ **What you get:**
311
+
312
+ - Complete React + TypeScript + Vite project
313
+ - TanStack Router for routing
314
+ - TanStack Store for state management
315
+ - Counter and fetch examples
316
+ - Ready to run immediately
317
+
318
+ ## Technologies Used
319
+
320
+ - **API Frameworks**: Hono (Express and Fastify coming soon)
321
+ - **Client**: TanStack Router + TanStack Query + TanStack Store (React)
322
+ - **UI**: Tailwind CSS + Headless UI + Heroicons
323
+ - **Validation**: Zod
324
+ - **Testing**: Vitest
325
+ - **TypeScript**: Full type safety
326
+
327
+ ## Architecture Patterns
328
+
329
+ ### API Patterns
330
+
331
+ #### Hexagonal (Ports & Adapters)
332
+
333
+ Clean separation between domain, application, and infrastructure layers:
334
+
335
+ - **Domain**: Business entities and port interfaces
336
+ - **Application**: Use cases implementing business logic
337
+ - **Adapters**: Framework-specific implementations (routes, repositories)
338
+
339
+ #### Vertical Slice
340
+
341
+ Feature-oriented structure where all code for a feature lives together:
342
+
343
+ - Entity, service, routes, and tests in one directory
344
+ - Faster navigation and easier understanding
345
+ - Better encapsulation of feature logic
346
+
347
+ ### Client Pattern
348
+
349
+ The client generation follows the **official TanStack Router pattern**:
350
+
351
+ - **File-based routing**: Routes in `src/routes/` map directly to URLs
352
+ - **Simple state**: TanStack Store for global state management
353
+ - **Type safety**: Full TypeScript support throughout
354
+ - **Minimal setup**: Counter and fetch examples to get started quickly
355
+
356
+ ## Contributing
357
+
358
+ Contributions are welcome! Please open an issue or submit a pull request.
359
+
360
+ ## Publishing
361
+
362
+ This project uses GitHub Actions to automate publishing to NPM.
363
+
364
+ 1. **Update Version**: Bump the version in `package.json` (e.g., `npm version patch`).
365
+ 2. **Push Changes**: Push your changes to the `main` branch.
366
+ 3. **Automated Publish**: The GitHub Action will run tests and publish the new version to NPM automatically.
367
+
368
+ **Note**: You must add your `NPM_TOKEN` to the repository secrets for this to work.
369
+
370
+ ## License
371
+
372
+ MIT