@onexapis/cli 1.0.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 (33) hide show
  1. package/README.md +332 -0
  2. package/bin/onex.js +4 -0
  3. package/dist/cli.d.mts +1 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +2507 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/cli.mjs +2492 -0
  8. package/dist/cli.mjs.map +1 -0
  9. package/dist/index.d.mts +167 -0
  10. package/dist/index.d.ts +167 -0
  11. package/dist/index.js +2104 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/index.mjs +2063 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/package.json +80 -0
  16. package/templates/default/README.md.ejs +129 -0
  17. package/templates/default/esbuild.config.js +81 -0
  18. package/templates/default/package.json.ejs +30 -0
  19. package/templates/default/src/config.ts.ejs +98 -0
  20. package/templates/default/src/index.ts.ejs +11 -0
  21. package/templates/default/src/layout.ts +23 -0
  22. package/templates/default/src/manifest.ts.ejs +47 -0
  23. package/templates/default/src/pages/home.ts.ejs +37 -0
  24. package/templates/default/src/sections/footer/footer-default.tsx +28 -0
  25. package/templates/default/src/sections/footer/footer.schema.ts +45 -0
  26. package/templates/default/src/sections/footer/index.ts +2 -0
  27. package/templates/default/src/sections/header/header-default.tsx +61 -0
  28. package/templates/default/src/sections/header/header.schema.ts +46 -0
  29. package/templates/default/src/sections/header/index.ts +2 -0
  30. package/templates/default/src/sections/hero/hero-default.tsx +52 -0
  31. package/templates/default/src/sections/hero/hero.schema.ts +52 -0
  32. package/templates/default/src/sections/hero/index.ts +2 -0
  33. package/templates/default/tsconfig.json +18 -0
package/README.md ADDED
@@ -0,0 +1,332 @@
1
+ # @duongthiu/onex-cli
2
+
3
+ CLI tool for OneX theme development - scaffold themes, sections, blocks, and components with ease.
4
+
5
+ Uses `@duongthiu/onex-core` for the core theme system.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # Install in your OneX project
11
+ npm install -D @duongthiu/onex-cli
12
+
13
+ # Or use globally
14
+ npm install -g @duongthiu/onex-cli
15
+
16
+ # Or use via npx
17
+ npx @duongthiu/onex-cli <command>
18
+ ```
19
+
20
+ ## Commands
21
+
22
+ ### `onex init [theme-name]`
23
+
24
+ Initialize a new OneX theme with complete structure.
25
+
26
+ **Options:**
27
+
28
+ - `-t, --template <template>` - Template to use (default, minimal)
29
+
30
+ **Example:**
31
+
32
+ ```bash
33
+ onex init my-theme
34
+ onex init my-store -t ecommerce
35
+ ```
36
+
37
+ **Generated structure:**
38
+
39
+ ```
40
+ src/themes/my-theme/
41
+ ├── manifest.ts # Theme metadata and exports
42
+ ├── theme.config.ts # Design tokens (colors, typography, spacing)
43
+ ├── theme.layout.ts # Header/footer configuration
44
+ ├── index.ts # Main exports
45
+ ├── sections/ # Theme-specific sections
46
+ ├── blocks/ # Theme-specific blocks
47
+ └── pages/
48
+ └── home.ts # Default home page config
49
+ ```
50
+
51
+ ### `onex create:section <name>` (alias: `cs`)
52
+
53
+ Create a new section with schema and template files.
54
+
55
+ **Options:**
56
+
57
+ - `-t, --theme <theme>` - Theme to create section in
58
+ - `-c, --category <category>` - Section category (headers, content, footers, etc.)
59
+ - `--template <template>` - Initial template variant
60
+
61
+ **Example:**
62
+
63
+ ```bash
64
+ onex create:section hero -t my-theme -c heroes
65
+ onex cs featured-products -t my-store -c ecommerce
66
+ ```
67
+
68
+ **Generated files:**
69
+
70
+ ```
71
+ src/themes/my-theme/sections/hero/
72
+ ├── hero.schema.ts # Section schema with settings
73
+ ├── hero-default.tsx # Default template component
74
+ └── index.ts # Exports
75
+ ```
76
+
77
+ ### `onex create:block <name>` (alias: `cb`)
78
+
79
+ Create a new block component (shared or theme-specific).
80
+
81
+ **Options:**
82
+
83
+ - `-t, --theme <theme>` - Theme to create block in (optional, defaults to shared)
84
+
85
+ **Example:**
86
+
87
+ ```bash
88
+ onex create:block product-card
89
+ onex cb testimonial-item -t my-theme
90
+ ```
91
+
92
+ **Generated files:**
93
+
94
+ ```
95
+ src/features/blocks/product-card/
96
+ ├── product-card.schema.ts # Block schema with settings
97
+ ├── product-card.tsx # Block component
98
+ └── index.ts # Exports
99
+ ```
100
+
101
+ ### `onex create:component <name>` (alias: `cc`)
102
+
103
+ Create a new UI component.
104
+
105
+ **Options:**
106
+
107
+ - `-t, --type <type>` - Component type (ui, form, layout, content)
108
+
109
+ **Example:**
110
+
111
+ ```bash
112
+ onex create:component icon-badge
113
+ onex cc custom-input -t form
114
+ ```
115
+
116
+ **Generated files:**
117
+
118
+ ```
119
+ src/features/components/icon-badge/
120
+ ├── icon-badge.schema.ts # Component schema with content/style fields
121
+ ├── icon-badge.tsx # Component implementation
122
+ └── index.ts # Exports
123
+ ```
124
+
125
+ ### `onex list`
126
+
127
+ Display project inventory (themes, sections, blocks, components).
128
+
129
+ **Options:**
130
+
131
+ - `-s, --sections` - List sections only
132
+ - `-b, --blocks` - List blocks only
133
+ - `-c, --components` - List components only
134
+ - `-t, --theme <theme>` - Filter by theme
135
+
136
+ **Example:**
137
+
138
+ ```bash
139
+ onex list
140
+ onex list -s -t my-theme
141
+ onex list --blocks
142
+ ```
143
+
144
+ ## Features
145
+
146
+ ### Interactive Prompts
147
+
148
+ All commands feature interactive prompts for missing options:
149
+
150
+ - Theme selection from available themes
151
+ - Category selection with validation
152
+ - Display names and descriptions
153
+ - Template preferences
154
+
155
+ ### Validation
156
+
157
+ - **Name Validation**: Ensures kebab-case format (e.g., `my-section`, `product-card`)
158
+ - **Theme Validation**: Checks theme existence before creating sections/blocks
159
+ - **Category Validation**: Validates against predefined categories
160
+ - **Project Detection**: Ensures commands run within a OneX project
161
+
162
+ ### Smart Templates
163
+
164
+ Generated files include:
165
+
166
+ - Proper TypeScript types from `@onex/core`
167
+ - Best practice component structure
168
+ - Commented TODOs for customization
169
+ - Responsive design patterns
170
+ - Accessibility considerations
171
+
172
+ ### Beautiful Output
173
+
174
+ - Color-coded messages (success, error, warning, info)
175
+ - Loading spinners for file operations
176
+ - Clear next steps after each command
177
+ - Relative file paths for easy navigation
178
+
179
+ ## Usage in Project
180
+
181
+ ### Option 1: Via pnpm scripts
182
+
183
+ Add to `package.json`:
184
+
185
+ ```json
186
+ {
187
+ "scripts": {
188
+ "onex": "node packages/cli/bin/onex.js"
189
+ }
190
+ }
191
+ ```
192
+
193
+ Then use:
194
+
195
+ ```bash
196
+ pnpm onex list
197
+ pnpm onex create:section hero -t my-theme
198
+ ```
199
+
200
+ ### Option 2: Direct execution
201
+
202
+ ```bash
203
+ node packages/cli/bin/onex.js list
204
+ node packages/cli/bin/onex.js create:section hero
205
+ ```
206
+
207
+ ### Option 3: Global installation
208
+
209
+ ```bash
210
+ npm install -g @duongthiu/onex-cli
211
+ onex list
212
+ onex create:section hero
213
+ ```
214
+
215
+ ## Development
216
+
217
+ ### Building the CLI
218
+
219
+ ```bash
220
+ cd packages/cli
221
+ pnpm build
222
+ ```
223
+
224
+ ### Testing locally
225
+
226
+ ```bash
227
+ # From project root
228
+ node packages/cli/bin/onex.js --help
229
+ node packages/cli/bin/onex.js list
230
+ ```
231
+
232
+ ### Type Checking
233
+
234
+ ```bash
235
+ pnpm type-check
236
+ ```
237
+
238
+ ### Linting
239
+
240
+ ```bash
241
+ pnpm lint
242
+ ```
243
+
244
+ ## Architecture
245
+
246
+ ### File Structure
247
+
248
+ ```
249
+ packages/cli/
250
+ ├── src/
251
+ │ ├── cli.ts # Main CLI entry point
252
+ │ ├── index.ts # Programmatic API
253
+ │ ├── commands/
254
+ │ │ ├── init.ts # Theme initialization
255
+ │ │ ├── create-section.ts # Section scaffolding
256
+ │ │ ├── create-block.ts # Block scaffolding
257
+ │ │ ├── create-component.ts # Component scaffolding
258
+ │ │ └── list.ts # Project inventory
259
+ │ └── utils/
260
+ │ ├── logger.ts # Console output utilities
261
+ │ ├── file-helpers.ts # File operations
262
+ │ └── validators.ts # Input validation
263
+ ├── bin/
264
+ │ └── onex.js # Executable entry point
265
+ └── package.json
266
+ ```
267
+
268
+ ### Dependencies
269
+
270
+ - **commander**: CLI framework and command parsing
271
+ - **inquirer**: Interactive prompts
272
+ - **chalk**: Terminal string styling
273
+ - **ora**: Elegant terminal spinners
274
+ - **fs-extra**: Enhanced file system operations
275
+ - **ejs**: Template rendering (for future template system)
276
+ - **glob**: File pattern matching
277
+
278
+ ## Next Steps
279
+
280
+ After generating files:
281
+
282
+ 1. **Sections**:
283
+ - Customize `section.schema.ts` with your settings
284
+ - Implement template component in `section-default.tsx`
285
+ - Register in theme `manifest.ts`
286
+
287
+ 2. **Blocks**:
288
+ - Define settings in `block.schema.ts`
289
+ - Implement component in `block.tsx`
290
+ - Register in `src/lib/registry/block-registry.ts`
291
+
292
+ 3. **Components**:
293
+ - Customize content/style fields in `component.schema.ts`
294
+ - Implement component in `component.tsx`
295
+ - Register in `src/lib/registry/component-registry.ts`
296
+
297
+ ## Examples
298
+
299
+ ### Creating a complete feature section
300
+
301
+ ```bash
302
+ # 1. Create theme
303
+ onex init ecommerce-theme
304
+
305
+ # 2. Create hero section
306
+ onex create:section hero -t ecommerce-theme -c heroes
307
+
308
+ # 3. Create product blocks
309
+ onex create:block product-card
310
+ onex create:block product-grid
311
+
312
+ # 4. Create components
313
+ onex create:component price-tag -t ui
314
+ onex create:component add-to-cart -t ui
315
+
316
+ # 5. Check inventory
317
+ onex list -t ecommerce-theme
318
+ ```
319
+
320
+ ### Quick section creation
321
+
322
+ ```bash
323
+ # Create with all options
324
+ onex cs testimonials -t my-theme -c testimonials
325
+
326
+ # Interactive mode (prompts for options)
327
+ onex cs testimonials
328
+ ```
329
+
330
+ ## License
331
+
332
+ MIT
package/bin/onex.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Load the compiled CLI
4
+ require("../dist/cli.js");
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node