@onexapis/cli 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1,330 +1,313 @@
1
- # @duongthiu/onex-cli
1
+ # @onexapis/cli
2
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.
3
+ CLI tool for OneX theme development scaffold, build, validate, and deploy themes using `@onexapis/core`.
6
4
 
7
5
  ## Installation
8
6
 
9
7
  ```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
8
+ # Install globally
9
+ npm install -g @onexapis/cli
15
10
 
16
- # Or use via npx
17
- npx @duongthiu/onex-cli <command>
11
+ # Or within the monorepo
12
+ cd packages/cli
13
+ pnpm build
14
+ npm install -g .
18
15
  ```
19
16
 
20
- ## Commands
17
+ Requires Node.js >= 18.
21
18
 
22
- ### `onex init [theme-name]`
19
+ ## Quick Start
23
20
 
24
- Initialize a new OneX theme with complete structure.
21
+ ```bash
22
+ # Create a new theme project
23
+ onex init my-theme
25
24
 
26
- **Options:**
25
+ # List all themes, sections, blocks, and components
26
+ onex list
27
27
 
28
- - `-t, --template <template>` - Template to use (default, minimal)
28
+ # Create a section in a theme
29
+ onex create:section hero --theme simple
29
30
 
30
- **Example:**
31
+ # Validate theme structure
32
+ onex validate --theme simple
31
33
 
32
- ```bash
33
- onex init my-theme
34
- onex init my-store -t ecommerce
35
- ```
34
+ # Build a theme
35
+ onex build --theme simple
36
36
 
37
- **Generated structure:**
37
+ # Upload to S3
38
+ onex upload --theme simple --bucket my-bucket
38
39
 
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
40
+ # Clone a theme from S3
41
+ onex clone simple --bucket my-bucket
49
42
  ```
50
43
 
51
- ### `onex create:section <name>` (alias: `cs`)
44
+ ## Commands
52
45
 
53
- Create a new section with schema and template files.
46
+ ### `onex init [project-name]`
54
47
 
55
- **Options:**
48
+ Create a new OneX theme project from a template.
56
49
 
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
50
+ | Option | Description |
51
+ |---|---|
52
+ | `-t, --template <template>` | Template to use (`default`, `minimal`) |
53
+ | `--no-install` | Skip installing dependencies |
54
+ | `--git` | Initialize a git repository |
55
+ | `-y, --yes` | Skip prompts and use defaults |
60
56
 
61
- **Example:**
57
+ ### `onex create:section <name>` (alias: `cs`)
62
58
 
63
- ```bash
64
- onex create:section hero -t my-theme -c heroes
65
- onex cs featured-products -t my-store -c ecommerce
66
- ```
59
+ Scaffold a new section inside a theme.
67
60
 
68
- **Generated files:**
61
+ | Option | Description |
62
+ |---|---|
63
+ | `-t, --theme <theme>` | Target theme |
64
+ | `-c, --category <category>` | Section category (`headers`, `content`, `footers`) |
65
+ | `--template <template>` | Initial template variant (`default`, `minimal`) |
69
66
 
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
67
+ ```bash
68
+ onex create:section hero -t my-theme -c heroes
69
+ onex cs featured-products -t my-store
75
70
  ```
76
71
 
77
72
  ### `onex create:block <name>` (alias: `cb`)
78
73
 
79
- Create a new block component (shared or theme-specific).
80
-
81
- **Options:**
74
+ Scaffold a new block.
82
75
 
83
- - `-t, --theme <theme>` - Theme to create block in (optional, defaults to shared)
84
-
85
- **Example:**
76
+ | Option | Description |
77
+ |---|---|
78
+ | `-t, --theme <theme>` | Target theme (optional) |
86
79
 
87
80
  ```bash
88
81
  onex create:block product-card
89
82
  onex cb testimonial-item -t my-theme
90
83
  ```
91
84
 
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
85
  ### `onex create:component <name>` (alias: `cc`)
102
86
 
103
- Create a new UI component.
104
-
105
- **Options:**
106
-
107
- - `-t, --type <type>` - Component type (ui, form, layout, content)
87
+ Scaffold a new UI component.
108
88
 
109
- **Example:**
89
+ | Option | Description |
90
+ |---|---|
91
+ | `-t, --type <type>` | Component type (`ui`, `layout`, `form`) |
110
92
 
111
93
  ```bash
112
94
  onex create:component icon-badge
113
95
  onex cc custom-input -t form
114
96
  ```
115
97
 
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
98
  ### `onex list`
126
99
 
127
- Display project inventory (themes, sections, blocks, components).
100
+ List available themes, sections, blocks, and components in the project.
128
101
 
129
- **Options:**
102
+ | Option | Description |
103
+ |---|---|
104
+ | `-s, --sections` | List sections only |
105
+ | `-b, --blocks` | List blocks only |
106
+ | `-c, --components` | List components only |
107
+ | `-t, --theme <theme>` | Filter by theme |
130
108
 
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
109
+ ### `onex validate`
135
110
 
136
- **Example:**
111
+ Validate theme structure and files.
137
112
 
138
- ```bash
139
- onex list
140
- onex list -s -t my-theme
141
- onex list --blocks
142
- ```
113
+ | Option | Description |
114
+ |---|---|
115
+ | `-t, --theme <theme>` | Theme to validate |
116
+ | `-f, --fix` | Auto-fix issues (not yet implemented) |
143
117
 
144
- ## Features
118
+ ### `onex build`
145
119
 
146
- ### Interactive Prompts
120
+ Build a theme for production. Runs type-check, lint, and compilation.
147
121
 
148
- All commands feature interactive prompts for missing options:
122
+ | Option | Description |
123
+ |---|---|
124
+ | `-t, --theme <theme>` | Theme to build |
125
+ | `-p, --production` | Production build with optimizations |
126
+ | `-w, --watch` | Watch mode for development |
149
127
 
150
- - Theme selection from available themes
151
- - Category selection with validation
152
- - Display names and descriptions
153
- - Template preferences
128
+ > **Note:** The theme's `package.json` must have `type-check` and `lint` scripts for the build to pass. Example:
129
+ > ```json
130
+ > { "scripts": { "type-check": "tsc --noEmit", "lint": "eslint src" } }
131
+ > ```
154
132
 
155
- ### Validation
133
+ ### `onex package`
156
134
 
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
135
+ Compile and package a theme as a distributable zip file.
161
136
 
162
- ### Smart Templates
137
+ | Option | Description |
138
+ |---|---|
139
+ | `-t, --theme <theme>` | Theme to package |
140
+ | `-o, --output <dir>` | Output directory |
141
+ | `-n, --name <name>` | Custom package name |
142
+ | `-m, --minify` | Minify compiled output |
143
+ | `--skip-build` | Skip compilation, use existing compiled theme |
163
144
 
164
- Generated files include:
145
+ ### `onex deploy`
165
146
 
166
- - Proper TypeScript types from `@onex/core`
167
- - Best practice component structure
168
- - Commented TODOs for customization
169
- - Responsive design patterns
170
- - Accessibility considerations
147
+ Upload a theme package to the API server.
171
148
 
172
- ### Beautiful Output
149
+ | Option | Description |
150
+ |---|---|
151
+ | `-t, --theme <theme>` | Theme to deploy |
152
+ | `-p, --package <file>` | Specific package file to upload |
153
+ | `--api-url <url>` | API server URL (default: `http://localhost:3001`) |
154
+ | `-k, --api-key <key>` | API key for authentication |
155
+ | `-e, --environment <env>` | Environment (`production`, `staging`, `development`) |
173
156
 
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
157
+ ### `onex upload`
178
158
 
179
- ## Usage in Project
159
+ Upload compiled theme to S3 as `bundle.zip` + `source.zip`.
180
160
 
181
- ### Option 1: Via pnpm scripts
161
+ | Option | Description |
162
+ |---|---|
163
+ | `-t, --theme <theme>` | Theme to upload |
164
+ | `-b, --bucket <name>` | S3 bucket name |
165
+ | `-v, --version <version>` | Theme version |
166
+ | `-e, --environment <env>` | Environment (`staging` or `production`) |
167
+ | `--dry-run` | Show what would be uploaded without uploading |
168
+ | `--skip-source` | Skip uploading `source.zip` |
169
+ | `--source-dir <dir>` | Source directory path |
182
170
 
183
- Add to `package.json`:
184
-
185
- ```json
186
- {
187
- "scripts": {
188
- "onex": "node packages/cli/bin/onex.js"
189
- }
190
- }
191
- ```
171
+ ```bash
172
+ # Dry run first
173
+ onex upload --theme simple --bucket my-bucket --dry-run
192
174
 
193
- Then use:
175
+ # Upload to staging
176
+ onex upload --theme simple --bucket my-bucket
194
177
 
195
- ```bash
196
- pnpm onex list
197
- pnpm onex create:section hero -t my-theme
178
+ # Upload to production
179
+ onex upload --theme simple --bucket my-bucket -e production
198
180
  ```
199
181
 
200
- ### Option 2: Direct execution
182
+ ### `onex download`
201
183
 
202
- ```bash
203
- node packages/cli/bin/onex.js list
204
- node packages/cli/bin/onex.js create:section hero
205
- ```
184
+ Download a compiled theme from S3.
206
185
 
207
- ### Option 3: Global installation
186
+ | Option | Description |
187
+ |---|---|
188
+ | `-t, --theme-id <id>` | Theme ID to download |
189
+ | `-v, --version <version>` | Theme version (default: `latest`) |
190
+ | `-b, --bucket <name>` | S3 bucket name |
191
+ | `-e, --environment <env>` | Environment (`staging` or `production`) |
192
+ | `-o, --output <dir>` | Output directory (default: `./active-theme`) |
208
193
 
209
- ```bash
210
- npm install -g @duongthiu/onex-cli
211
- onex list
212
- onex create:section hero
213
- ```
194
+ ### `onex clone <theme-name>`
214
195
 
215
- ## Development
196
+ Clone theme source code from S3.
216
197
 
217
- ### Building the CLI
198
+ | Option | Description |
199
+ |---|---|
200
+ | `-v, --version <version>` | Theme version (default: `latest`) |
201
+ | `-o, --output <dir>` | Output directory |
202
+ | `-b, --bucket <name>` | S3 bucket name |
203
+ | `-e, --environment <env>` | Environment (`staging` or `production`) |
204
+ | `--no-install` | Skip running `pnpm install` after clone |
218
205
 
219
206
  ```bash
220
- cd packages/cli
221
- pnpm build
207
+ onex clone simple --bucket my-bucket
208
+ onex clone simple -v 1.0.0 -o ./my-clone --no-install
222
209
  ```
223
210
 
224
- ### Testing locally
211
+ ## S3 Configuration
212
+
213
+ The `upload`, `download`, and `clone` commands use S3 for storage. Configure via environment variables:
225
214
 
226
215
  ```bash
227
- # From project root
228
- node packages/cli/bin/onex.js --help
229
- node packages/cli/bin/onex.js list
216
+ # AWS (default)
217
+ AWS_REGION=ap-southeast-1
218
+ AWS_ACCESS_KEY_ID=...
219
+ AWS_SECRET_ACCESS_KEY=...
220
+
221
+ # MinIO (set ADAPTER_MODE=vps)
222
+ ADAPTER_MODE=vps
223
+ MINIO_ENDPOINT=localhost:9000
224
+ MINIO_ACCESS_KEY=minioadmin
225
+ MINIO_SECRET_KEY=minioadmin
226
+
227
+ # LocalStack (set ADAPTER_MODE=local)
228
+ ADAPTER_MODE=local
229
+
230
+ # Override bucket name directly
231
+ BUCKET_NAME=my-bucket
230
232
  ```
231
233
 
232
- ### Type Checking
234
+ ## Theme Structure
233
235
 
234
- ```bash
235
- pnpm type-check
236
+ Themes live in the `themes/` directory at the project root:
237
+
238
+ ```
239
+ themes/
240
+ my-theme/
241
+ theme.config.ts # Theme metadata (name, version, description)
242
+ bundle-entry.ts # Build entry point
243
+ index.ts # Theme exports
244
+ sections-registry.ts # Section registry
245
+ theme.layout.ts # Layout definition
246
+ package.json
247
+ tsconfig.json
248
+ sections/ # Section components
249
+ hero/
250
+ features/
251
+ ...
252
+ pages/ # Page configurations
253
+ home.ts
254
+ about.ts
255
+ ...
236
256
  ```
237
257
 
238
- ### Linting
258
+ ## Project Detection
239
259
 
240
- ```bash
241
- pnpm lint
242
- ```
260
+ The CLI detects a OneX project by looking for a `themes/` directory (or legacy `src/themes/`) from the project root. Within themes, it recognizes any directory containing `theme.config.ts`, `bundle-entry.ts`, or `manifest.ts` as a valid theme.
243
261
 
244
262
  ## Architecture
245
263
 
246
- ### File Structure
247
-
248
264
  ```
249
265
  packages/cli/
250
266
  ├── src/
251
267
  │ ├── cli.ts # Main CLI entry point
252
- │ ├── index.ts # Programmatic API
268
+ │ ├── index.ts # Programmatic API exports
253
269
  │ ├── commands/
254
270
  │ │ ├── init.ts # Theme initialization
255
271
  │ │ ├── create-section.ts # Section scaffolding
256
272
  │ │ ├── create-block.ts # Block scaffolding
257
273
  │ │ ├── create-component.ts # Component scaffolding
258
- │ │ └── list.ts # Project inventory
274
+ │ │ ├── list.ts # Project inventory
275
+ │ │ ├── validate.ts # Theme validation
276
+ │ │ ├── build.ts # Theme build
277
+ │ │ ├── package.ts # Theme packaging
278
+ │ │ ├── deploy.ts # Deploy to API server
279
+ │ │ ├── upload.ts # Upload to S3
280
+ │ │ ├── download.ts # Download from S3
281
+ │ │ └── clone.ts # Clone source from S3
259
282
  │ └── utils/
260
283
  │ ├── logger.ts # Console output utilities
261
- │ ├── file-helpers.ts # File operations
284
+ │ ├── file-helpers.ts # File operations & project detection
262
285
  │ └── validators.ts # Input validation
263
286
  ├── bin/
264
287
  │ └── onex.js # Executable entry point
288
+ ├── templates/ # Scaffolding templates
265
289
  └── package.json
266
290
  ```
267
291
 
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
292
+ ## Development
300
293
 
301
294
  ```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
295
+ cd packages/cli
307
296
 
308
- # 3. Create product blocks
309
- onex create:block product-card
310
- onex create:block product-grid
297
+ # Build
298
+ pnpm build
311
299
 
312
- # 4. Create components
313
- onex create:component price-tag -t ui
314
- onex create:component add-to-cart -t ui
300
+ # Watch mode
301
+ pnpm dev
315
302
 
316
- # 5. Check inventory
317
- onex list -t ecommerce-theme
318
- ```
319
-
320
- ### Quick section creation
303
+ # Type check
304
+ pnpm type-check
321
305
 
322
- ```bash
323
- # Create with all options
324
- onex cs testimonials -t my-theme -c testimonials
306
+ # Lint
307
+ pnpm lint
325
308
 
326
- # Interactive mode (prompts for options)
327
- onex cs testimonials
309
+ # Install globally after building
310
+ npm install -g . --force
328
311
  ```
329
312
 
330
313
  ## License