@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 +197 -214
- package/dist/cli.js +423 -183
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +422 -184
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +418 -184
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +416 -186
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,330 +1,313 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @onexapis/cli
|
|
2
2
|
|
|
3
|
-
CLI tool for OneX theme development
|
|
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
|
|
11
|
-
npm install -
|
|
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
|
|
17
|
-
|
|
11
|
+
# Or within the monorepo
|
|
12
|
+
cd packages/cli
|
|
13
|
+
pnpm build
|
|
14
|
+
npm install -g .
|
|
18
15
|
```
|
|
19
16
|
|
|
20
|
-
|
|
17
|
+
Requires Node.js >= 18.
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
## Quick Start
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
```bash
|
|
22
|
+
# Create a new theme project
|
|
23
|
+
onex init my-theme
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
# List all themes, sections, blocks, and components
|
|
26
|
+
onex list
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
# Create a section in a theme
|
|
29
|
+
onex create:section hero --theme simple
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
# Validate theme structure
|
|
32
|
+
onex validate --theme simple
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
onex
|
|
34
|
-
onex init my-store -t ecommerce
|
|
35
|
-
```
|
|
34
|
+
# Build a theme
|
|
35
|
+
onex build --theme simple
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
# Upload to S3
|
|
38
|
+
onex upload --theme simple --bucket my-bucket
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
44
|
+
## Commands
|
|
52
45
|
|
|
53
|
-
|
|
46
|
+
### `onex init [project-name]`
|
|
54
47
|
|
|
55
|
-
|
|
48
|
+
Create a new OneX theme project from a template.
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
57
|
+
### `onex create:section <name>` (alias: `cs`)
|
|
62
58
|
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
**Options:**
|
|
74
|
+
Scaffold a new block.
|
|
82
75
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
104
|
-
|
|
105
|
-
**Options:**
|
|
106
|
-
|
|
107
|
-
- `-t, --type <type>` - Component type (ui, form, layout, content)
|
|
87
|
+
Scaffold a new UI component.
|
|
108
88
|
|
|
109
|
-
|
|
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
|
-
|
|
100
|
+
List available themes, sections, blocks, and components in the project.
|
|
128
101
|
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
|
|
111
|
+
Validate theme structure and files.
|
|
137
112
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
```
|
|
113
|
+
| Option | Description |
|
|
114
|
+
|---|---|
|
|
115
|
+
| `-t, --theme <theme>` | Theme to validate |
|
|
116
|
+
| `-f, --fix` | Auto-fix issues (not yet implemented) |
|
|
143
117
|
|
|
144
|
-
|
|
118
|
+
### `onex build`
|
|
145
119
|
|
|
146
|
-
|
|
120
|
+
Build a theme for production. Runs type-check, lint, and compilation.
|
|
147
121
|
|
|
148
|
-
|
|
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
|
-
-
|
|
151
|
-
|
|
152
|
-
-
|
|
153
|
-
|
|
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
|
-
###
|
|
133
|
+
### `onex package`
|
|
156
134
|
|
|
157
|
-
|
|
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
|
-
|
|
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
|
-
|
|
145
|
+
### `onex deploy`
|
|
165
146
|
|
|
166
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
+
Upload compiled theme to S3 as `bundle.zip` + `source.zip`.
|
|
180
160
|
|
|
181
|
-
|
|
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
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
175
|
+
# Upload to staging
|
|
176
|
+
onex upload --theme simple --bucket my-bucket
|
|
194
177
|
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
###
|
|
182
|
+
### `onex download`
|
|
201
183
|
|
|
202
|
-
|
|
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
|
-
|
|
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
|
-
|
|
210
|
-
npm install -g @duongthiu/onex-cli
|
|
211
|
-
onex list
|
|
212
|
-
onex create:section hero
|
|
213
|
-
```
|
|
194
|
+
### `onex clone <theme-name>`
|
|
214
195
|
|
|
215
|
-
|
|
196
|
+
Clone theme source code from S3.
|
|
216
197
|
|
|
217
|
-
|
|
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
|
-
|
|
221
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
234
|
+
## Theme Structure
|
|
233
235
|
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
258
|
+
## Project Detection
|
|
239
259
|
|
|
240
|
-
|
|
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
|
-
│ │
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
309
|
-
|
|
310
|
-
onex create:block product-grid
|
|
297
|
+
# Build
|
|
298
|
+
pnpm build
|
|
311
299
|
|
|
312
|
-
#
|
|
313
|
-
|
|
314
|
-
onex create:component add-to-cart -t ui
|
|
300
|
+
# Watch mode
|
|
301
|
+
pnpm dev
|
|
315
302
|
|
|
316
|
-
#
|
|
317
|
-
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
### Quick section creation
|
|
303
|
+
# Type check
|
|
304
|
+
pnpm type-check
|
|
321
305
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
onex cs testimonials -t my-theme -c testimonials
|
|
306
|
+
# Lint
|
|
307
|
+
pnpm lint
|
|
325
308
|
|
|
326
|
-
#
|
|
327
|
-
|
|
309
|
+
# Install globally after building
|
|
310
|
+
npm install -g . --force
|
|
328
311
|
```
|
|
329
312
|
|
|
330
313
|
## License
|