@objectql/cli 1.6.0 → 1.7.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/CHANGELOG.md +22 -0
- package/IMPLEMENTATION_SUMMARY.md +437 -0
- package/README.md +385 -7
- package/USAGE_EXAMPLES.md +804 -0
- package/__tests__/commands.test.ts +153 -0
- package/dist/commands/i18n.d.ts +27 -0
- package/dist/commands/i18n.js +280 -0
- package/dist/commands/i18n.js.map +1 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.js +202 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/migrate.d.ts +26 -0
- package/dist/commands/migrate.js +301 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/new.d.ts +7 -0
- package/dist/commands/new.js +279 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/studio.js +70 -9
- package/dist/commands/studio.js.map +1 -1
- package/dist/index.js +130 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/commands/i18n.ts +303 -0
- package/src/commands/init.ts +191 -0
- package/src/commands/migrate.ts +314 -0
- package/src/commands/new.ts +268 -0
- package/src/commands/studio.ts +75 -10
- package/src/index.ts +131 -2
- package/tsconfig.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @objectql/cli
|
|
2
2
|
|
|
3
|
-
Command Line Interface for ObjectQL.
|
|
3
|
+
Command Line Interface for ObjectQL - A comprehensive toolkit for building, managing, and deploying ObjectQL applications.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -12,15 +12,223 @@ pnpm add -D @objectql/cli
|
|
|
12
12
|
|
|
13
13
|
## Commands
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Project Initialization
|
|
16
|
+
|
|
17
|
+
#### `init`
|
|
18
|
+
|
|
19
|
+
Create a new ObjectQL project from a template.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Interactive mode (prompts for options)
|
|
23
|
+
objectql init
|
|
24
|
+
|
|
25
|
+
# With options
|
|
26
|
+
objectql init --template basic --name my-project
|
|
27
|
+
|
|
28
|
+
# Available templates: basic, express-api, enterprise
|
|
29
|
+
objectql init -t express-api -n my-api-server
|
|
30
|
+
|
|
31
|
+
# Skip automatic dependency installation
|
|
32
|
+
objectql init --skip-install
|
|
33
|
+
|
|
34
|
+
# Skip git initialization
|
|
35
|
+
objectql init --skip-git
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Options:**
|
|
39
|
+
- `-t, --template <template>` - Template to use (basic, express-api, enterprise) [default: "basic"]
|
|
40
|
+
- `-n, --name <name>` - Project name
|
|
41
|
+
- `-d, --dir <path>` - Target directory
|
|
42
|
+
- `--skip-install` - Skip dependency installation
|
|
43
|
+
- `--skip-git` - Skip git initialization
|
|
44
|
+
|
|
45
|
+
**Templates:**
|
|
46
|
+
- **basic** - Minimal setup with basic examples
|
|
47
|
+
- **express-api** - Express.js server with REST API
|
|
48
|
+
- **enterprise** - Full-featured enterprise application structure
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
### Metadata Generation
|
|
53
|
+
|
|
54
|
+
#### `new <type> <name>`
|
|
55
|
+
|
|
56
|
+
Generate a new metadata file with boilerplate code.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Create a new object definition
|
|
60
|
+
objectql new object users
|
|
61
|
+
|
|
62
|
+
# Create a view
|
|
63
|
+
objectql new view user_list
|
|
64
|
+
|
|
65
|
+
# Create a form
|
|
66
|
+
objectql new form user_edit
|
|
67
|
+
|
|
68
|
+
# Create in a specific directory
|
|
69
|
+
objectql new object products --dir ./src/modules/catalog
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Supported Types:**
|
|
73
|
+
- `object` - Object/Entity definition
|
|
74
|
+
- `view` - Data view configuration
|
|
75
|
+
- `form` - Form layout
|
|
76
|
+
- `page` - Page definition
|
|
77
|
+
- `action` - Custom action (generates .yml + .ts)
|
|
78
|
+
- `hook` - Lifecycle hook (generates .yml + .ts)
|
|
79
|
+
- `permission` - Permission rules
|
|
80
|
+
- `validation` - Validation rules
|
|
81
|
+
- `workflow` - Workflow automation
|
|
82
|
+
- `report` - Report definition
|
|
83
|
+
- `menu` - Menu configuration
|
|
84
|
+
- `data` - Sample data
|
|
85
|
+
|
|
86
|
+
**Options:**
|
|
87
|
+
- `-d, --dir <path>` - Output directory [default: "."]
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### TypeScript Code Generation
|
|
92
|
+
|
|
93
|
+
#### `generate` (alias: `g`)
|
|
16
94
|
|
|
17
95
|
Generate TypeScript interfaces from your `object.yml` definitions.
|
|
18
96
|
|
|
19
97
|
```bash
|
|
98
|
+
# Generate types from current directory
|
|
99
|
+
objectql generate
|
|
100
|
+
|
|
101
|
+
# Specify source and output directories
|
|
20
102
|
objectql generate -s src -o src/generated
|
|
103
|
+
|
|
104
|
+
# Generate from specific path
|
|
105
|
+
objectql generate --source ./metadata --output ./types
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Options:**
|
|
109
|
+
- `-s, --source <path>` - Source directory containing *.object.yml [default: "."]
|
|
110
|
+
- `-o, --output <path>` - Output directory for generated types [default: "./src/generated"]
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### Internationalization (i18n)
|
|
115
|
+
|
|
116
|
+
#### `i18n extract`
|
|
117
|
+
|
|
118
|
+
Extract translatable strings from metadata files and create translation files.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Extract to default location (./src/i18n/en)
|
|
122
|
+
objectql i18n extract
|
|
123
|
+
|
|
124
|
+
# Extract for specific language
|
|
125
|
+
objectql i18n extract --lang zh-CN
|
|
126
|
+
|
|
127
|
+
# Custom source and output directories
|
|
128
|
+
objectql i18n extract -s ./metadata -o ./translations --lang fr
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Options:**
|
|
132
|
+
- `-s, --source <path>` - Source directory [default: "."]
|
|
133
|
+
- `-o, --output <path>` - Output directory [default: "./src/i18n"]
|
|
134
|
+
- `-l, --lang <lang>` - Language code [default: "en"]
|
|
135
|
+
|
|
136
|
+
#### `i18n init <lang>`
|
|
137
|
+
|
|
138
|
+
Initialize i18n structure for a new language.
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Initialize for Chinese (Simplified)
|
|
142
|
+
objectql i18n init zh-CN
|
|
143
|
+
|
|
144
|
+
# Initialize for French
|
|
145
|
+
objectql i18n init fr
|
|
146
|
+
|
|
147
|
+
# Custom base directory
|
|
148
|
+
objectql i18n init es --base-dir ./translations
|
|
21
149
|
```
|
|
22
150
|
|
|
23
|
-
|
|
151
|
+
**Options:**
|
|
152
|
+
- `-b, --base-dir <path>` - Base i18n directory [default: "./src/i18n"]
|
|
153
|
+
|
|
154
|
+
#### `i18n validate <lang>`
|
|
155
|
+
|
|
156
|
+
Validate translation completeness against base language.
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Validate Chinese translations against English
|
|
160
|
+
objectql i18n validate zh-CN
|
|
161
|
+
|
|
162
|
+
# Use custom base language
|
|
163
|
+
objectql i18n validate fr --base-lang en
|
|
164
|
+
|
|
165
|
+
# Custom directory
|
|
166
|
+
objectql i18n validate es --base-dir ./translations
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Options:**
|
|
170
|
+
- `-b, --base-dir <path>` - Base i18n directory [default: "./src/i18n"]
|
|
171
|
+
- `--base-lang <lang>` - Base language to compare against [default: "en"]
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
### Database Migrations
|
|
176
|
+
|
|
177
|
+
#### `migrate`
|
|
178
|
+
|
|
179
|
+
Run pending database migrations.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Run all pending migrations
|
|
183
|
+
objectql migrate
|
|
184
|
+
|
|
185
|
+
# Specify custom config file
|
|
186
|
+
objectql migrate --config ./config/objectql.config.ts
|
|
187
|
+
|
|
188
|
+
# Custom migrations directory
|
|
189
|
+
objectql migrate --dir ./db/migrations
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
**Options:**
|
|
193
|
+
- `-c, --config <path>` - Path to objectql.config.ts/js
|
|
194
|
+
- `-d, --dir <path>` - Migrations directory [default: "./migrations"]
|
|
195
|
+
|
|
196
|
+
#### `migrate create <name>`
|
|
197
|
+
|
|
198
|
+
Create a new migration file.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Create a new migration
|
|
202
|
+
objectql migrate create add_status_field
|
|
203
|
+
|
|
204
|
+
# Custom directory
|
|
205
|
+
objectql migrate create init_schema --dir ./db/migrations
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Options:**
|
|
209
|
+
- `-d, --dir <path>` - Migrations directory [default: "./migrations"]
|
|
210
|
+
|
|
211
|
+
#### `migrate status`
|
|
212
|
+
|
|
213
|
+
Show migration status (pending vs. completed).
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Show migration status
|
|
217
|
+
objectql migrate status
|
|
218
|
+
|
|
219
|
+
# With custom config
|
|
220
|
+
objectql migrate status --config ./config/objectql.config.ts
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Options:**
|
|
224
|
+
- `-c, --config <path>` - Path to objectql.config.ts/js
|
|
225
|
+
- `-d, --dir <path>` - Migrations directory [default: "./migrations"]
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
### Development Tools
|
|
230
|
+
|
|
231
|
+
#### `serve` (alias: `s`)
|
|
24
232
|
|
|
25
233
|
Start a lightweight development server with an in-memory database. Perfect for rapid prototyping without setting up a backend project.
|
|
26
234
|
|
|
@@ -33,14 +241,184 @@ objectql serve --dir ./src/schema --port 8080
|
|
|
33
241
|
```
|
|
34
242
|
|
|
35
243
|
The server exposes:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
244
|
+
- **Web Console (Swagger UI)**: `http://localhost:<port>/swagger` (GET) - Interactive API explorer
|
|
245
|
+
- **JSON API Endpoint**: `http://localhost:<port>/` (POST)
|
|
246
|
+
- **OpenAPI Spec**: `http://localhost:<port>/openapi.json` (GET)
|
|
247
|
+
|
|
248
|
+
**Options:**
|
|
249
|
+
- `-p, --port <number>` - Port to listen on [default: "3000"]
|
|
250
|
+
- `-d, --dir <path>` - Directory containing schema [default: "."]
|
|
39
251
|
|
|
40
|
-
|
|
252
|
+
#### `repl` (alias: `r`)
|
|
41
253
|
|
|
42
254
|
Start an interactive shell to query your data.
|
|
43
255
|
|
|
44
256
|
```bash
|
|
257
|
+
# Start REPL
|
|
45
258
|
objectql repl
|
|
259
|
+
|
|
260
|
+
# Use custom config
|
|
261
|
+
objectql repl --config ./objectql.config.ts
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Options:**
|
|
265
|
+
- `-c, --config <path>` - Path to objectql.config.ts/js
|
|
266
|
+
|
|
267
|
+
**Example REPL session:**
|
|
268
|
+
```javascript
|
|
269
|
+
objectql> await tasks.find()
|
|
270
|
+
objectql> await tasks.insert({ name: 'New Task', status: 'open' })
|
|
271
|
+
objectql> await tasks.update({ _id: '123' }, { status: 'completed' })
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
#### `studio` (alias: `ui`)
|
|
275
|
+
|
|
276
|
+
Start the ObjectQL Studio - a web-based admin interface.
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Start studio
|
|
280
|
+
objectql studio
|
|
281
|
+
|
|
282
|
+
# Custom port and directory
|
|
283
|
+
objectql studio --port 8080 --dir ./src
|
|
284
|
+
|
|
285
|
+
# Don't open browser automatically
|
|
286
|
+
objectql studio --no-open
|
|
46
287
|
```
|
|
288
|
+
|
|
289
|
+
**Options:**
|
|
290
|
+
- `-p, --port <number>` - Port to listen on [default: "3000"]
|
|
291
|
+
- `-d, --dir <path>` - Directory containing schema [default: "."]
|
|
292
|
+
- `--no-open` - Do not open browser automatically
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## Typical Workflows
|
|
297
|
+
|
|
298
|
+
### Starting a New Project
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# 1. Create project from template
|
|
302
|
+
objectql init -t basic -n my-app
|
|
303
|
+
|
|
304
|
+
# 2. Navigate to project
|
|
305
|
+
cd my-app
|
|
306
|
+
|
|
307
|
+
# 3. Install dependencies (if skipped)
|
|
308
|
+
pnpm install
|
|
309
|
+
|
|
310
|
+
# 4. Start development
|
|
311
|
+
objectql studio
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Adding New Functionality
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# 1. Create object definition
|
|
318
|
+
objectql new object products
|
|
319
|
+
|
|
320
|
+
# 2. Edit the generated file: products.object.yml
|
|
321
|
+
|
|
322
|
+
# 3. Generate TypeScript types
|
|
323
|
+
objectql generate
|
|
324
|
+
|
|
325
|
+
# 4. Add translations
|
|
326
|
+
objectql i18n extract --lang en
|
|
327
|
+
objectql i18n init zh-CN
|
|
328
|
+
objectql i18n extract --lang zh-CN
|
|
329
|
+
|
|
330
|
+
# 5. Test in REPL
|
|
331
|
+
objectql repl
|
|
332
|
+
> await products.find()
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Managing Translations
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
# 1. Initialize new language
|
|
339
|
+
objectql i18n init zh-CN
|
|
340
|
+
|
|
341
|
+
# 2. Extract all translatable strings
|
|
342
|
+
objectql i18n extract --lang zh-CN
|
|
343
|
+
|
|
344
|
+
# 3. Translate the JSON files in src/i18n/zh-CN/
|
|
345
|
+
|
|
346
|
+
# 4. Validate completeness
|
|
347
|
+
objectql i18n validate zh-CN
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Database Migrations
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# 1. Create migration
|
|
354
|
+
objectql migrate create add_priority_field
|
|
355
|
+
|
|
356
|
+
# 2. Edit migration file in migrations/
|
|
357
|
+
|
|
358
|
+
# 3. Check status
|
|
359
|
+
objectql migrate status
|
|
360
|
+
|
|
361
|
+
# 4. Run migrations
|
|
362
|
+
objectql migrate
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Configuration File
|
|
368
|
+
|
|
369
|
+
Most commands expect an `objectql.config.ts` or `objectql.config.js` file in your project root:
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
// objectql.config.ts
|
|
373
|
+
import { ObjectQL } from '@objectql/core';
|
|
374
|
+
import { KnexDriver } from '@objectql/driver-sql';
|
|
375
|
+
import { ObjectLoader } from '@objectql/platform-node';
|
|
376
|
+
import * as path from 'path';
|
|
377
|
+
|
|
378
|
+
const app = new ObjectQL({
|
|
379
|
+
datasources: {
|
|
380
|
+
default: new KnexDriver({
|
|
381
|
+
client: 'sqlite3',
|
|
382
|
+
connection: {
|
|
383
|
+
filename: path.join(__dirname, 'dev.sqlite3')
|
|
384
|
+
},
|
|
385
|
+
useNullAsDefault: true
|
|
386
|
+
})
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
const loader = new ObjectLoader(app.metadata);
|
|
391
|
+
loader.load(path.join(__dirname, 'src'));
|
|
392
|
+
|
|
393
|
+
export default app;
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Environment Variables
|
|
399
|
+
|
|
400
|
+
Some commands support environment variables for configuration:
|
|
401
|
+
|
|
402
|
+
- `OBJECTQL_CONFIG` - Path to config file
|
|
403
|
+
- `OBJECTQL_PORT` - Default port for serve/studio commands
|
|
404
|
+
- `OBJECTQL_DB_URL` - Database connection string
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## Getting Help
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
# Show all commands
|
|
412
|
+
objectql --help
|
|
413
|
+
|
|
414
|
+
# Show help for specific command
|
|
415
|
+
objectql init --help
|
|
416
|
+
objectql i18n extract --help
|
|
417
|
+
objectql migrate --help
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## License
|
|
423
|
+
|
|
424
|
+
MIT
|