@burgan-tech/vnext-workflow-cli 1.0.1 → 1.0.3

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
@@ -53,18 +53,62 @@ npm link
53
53
 
54
54
  ---
55
55
 
56
+ ## 📄 vnext.config.json (Required)
57
+
58
+ Every vNext project must have a `vnext.config.json` file in the **project root**. This file defines the domain and component paths.
59
+
60
+ ### Example Configuration
61
+
62
+ ```json
63
+ {
64
+ "version": "1.0.0",
65
+ "domain": "core",
66
+ "paths": {
67
+ "componentsRoot": "core",
68
+ "tasks": "Tasks",
69
+ "views": "Views",
70
+ "functions": "Functions",
71
+ "extensions": "Extensions",
72
+ "workflows": "Workflows",
73
+ "schemas": "Schemas"
74
+ }
75
+ }
76
+ ```
77
+
78
+ ### Key Properties
79
+
80
+ | Property | Description |
81
+ |----------|-------------|
82
+ | `domain` | Domain name used for API calls (replaces config's API_DOMAIN) |
83
+ | `paths.componentsRoot` | Root folder where all components are located |
84
+ | `paths.tasks` | Tasks folder name under componentsRoot |
85
+ | `paths.workflows` | Workflows folder name under componentsRoot |
86
+ | `paths.schemas` | Schemas folder name under componentsRoot |
87
+ | `paths.views` | Views folder name under componentsRoot |
88
+ | `paths.functions` | Functions folder name under componentsRoot |
89
+ | `paths.extensions` | Extensions folder name under componentsRoot |
90
+
91
+ ### Component Discovery
92
+
93
+ The CLI scans `componentsRoot` recursively and:
94
+ - Includes all `.json` files in subfolders
95
+ - Ignores `.meta` folders
96
+ - Ignores `*.diagram.json` files
97
+ - Ignores `package*.json` and `*config*.json` files
98
+
99
+ ---
100
+
56
101
  ## ⚡ Quick Start
57
102
 
58
103
  ### Initial Configuration
59
104
 
60
- After installation, configure the CLI:
105
+ After installation, navigate to your vNext project and run:
61
106
 
62
107
  ```bash
63
- # Set project root path (REQUIRED)
64
- wf config set PROJECT_ROOT /path/to/your/vnext-project
108
+ # Go to your vNext project directory
109
+ cd /path/to/your/vnext-project
65
110
 
66
- # Database settings
67
- wf config set DB_PASSWORD postgres
111
+ # Database settings (if using Docker)
68
112
  wf config set USE_DOCKER true
69
113
  wf config set DOCKER_POSTGRES_CONTAINER vnext-postgres
70
114
 
@@ -72,6 +116,8 @@ wf config set DOCKER_POSTGRES_CONTAINER vnext-postgres
72
116
  wf check
73
117
  ```
74
118
 
119
+ **Note:** The CLI automatically uses the current working directory as the project root. Just `cd` into your project folder before running commands.
120
+
75
121
  ### Basic Usage
76
122
 
77
123
  ```bash
@@ -93,147 +139,426 @@ wf reset
93
139
  ## 📖 Commands
94
140
 
95
141
  ### `wf check`
96
- Checks system status (API, DB, folders).
97
142
 
98
- ### `wf config <action> [key] [value]`
99
- Configuration management:
143
+ **Purpose**: System health check
144
+
145
+ Checks and displays:
146
+ - vnext.config.json status and domain info
147
+ - API connection status
148
+ - Database connection status
149
+ - Component folders found
150
+
100
151
  ```bash
101
- wf config get # Show all settings
102
- wf config get PROJECT_ROOT # Show a specific setting
103
- wf config set DB_PASSWORD pass # Change a setting
152
+ wf check
104
153
  ```
105
154
 
106
- ### `wf csx [options]`
107
- Converts CSX files to Base64 and embeds them in JSON files.
155
+ ---
156
+
157
+ ### `wf sync`
158
+
159
+ **Purpose**: Add missing components to database (skip existing)
160
+
161
+ **What it does**:
162
+ 1. Scans all CSX files and updates JSON files with base64 encoded content
163
+ 2. For each component JSON file:
164
+ - Checks if it exists in DB (by key)
165
+ - If **exists** → Skip (already synced)
166
+ - If **not exists** → Publish to API
167
+ 3. Re-initializes the system
168
+
169
+ **Use when**: Initial setup, adding new components without affecting existing ones
170
+
108
171
  ```bash
109
- wf csx # Process changed files in Git
110
- wf csx --all # Process all CSX files
111
- wf csx --file x.csx # Process a single file
172
+ wf sync
112
173
  ```
113
174
 
175
+ ---
176
+
114
177
  ### `wf update [options]`
115
- Updates workflows (CSX is automatically updated!).
178
+
179
+ **Purpose**: Update changed components (delete + re-add)
180
+
181
+ **What it does**:
182
+ 1. Finds changed CSX files (Git) and updates JSON files
183
+ 2. For each component JSON file:
184
+ - Checks if it exists in DB (by key)
185
+ - If **exists** → Delete from DB, then publish to API
186
+ - If **not exists** → Publish to API
187
+ 3. Re-initializes the system
188
+
189
+ **Use when**: You modified existing components and want to update them
190
+
116
191
  ```bash
117
192
  wf update # Process changed files in Git (CSX + JSON)
118
193
  wf update --all # Update all (asks for confirmation)
119
194
  wf update --file x.json # Process a single file
120
195
  ```
121
196
 
122
- **Process steps:**
123
- 1. 📝 Converts changed CSX files to base64 and writes to JSON files
124
- 2. 🗑️ Deletes existing record from DB
125
- 3. 📤 POSTs to API
126
- 4. ✅ Activates the workflow
127
- 5. 🔄 Restarts the system
128
-
129
- ### `wf sync`
130
- Updates all CSX files and adds missing ones to the database.
131
- ```bash
132
- wf sync # Update all CSX files + add missing ones
133
- ```
197
+ ---
134
198
 
135
199
  ### `wf reset`
136
- Resets workflows with an interactive menu (even if there are no changes).
200
+
201
+ **Purpose**: Force reset components (always delete + re-add)
202
+
203
+ **What it does**:
204
+ 1. Shows interactive menu to select component type
205
+ 2. For each component JSON file:
206
+ - Checks if it exists in DB (by key)
207
+ - If **exists** → Delete from DB, then publish to API
208
+ - If **not exists** → Publish to API
209
+ 3. Re-initializes the system
210
+
211
+ **Use when**: You need to force reset components regardless of changes
212
+
137
213
  ```bash
138
- wf reset # Select folder from menu
214
+ wf reset # Select folder from interactive menu
139
215
  ```
140
216
 
141
- **Menu:**
217
+ **Menu Options**:
142
218
  ```
143
219
  ? Which folder should be reset?
144
- 🔵 Workflows (sys-flows)
145
- 📋 Tasks (sys-tasks)
146
- 📊 Schemas (sys-schemas)
147
- 👁️ Views (sys-views)
148
- ⚙️ Functions (sys-functions)
149
- 🔌 Extensions (sys-extensions)
220
+ tasks (Tasks/)
221
+ views (Views/)
222
+ functions (Functions/)
223
+ extensions (Extensions/)
224
+ workflows (Workflows/)
225
+ schemas (Schemas/)
150
226
  ──────────────
151
- 🔴 ALL (All folders)
227
+ TUMU (All folders)
152
228
  ```
153
229
 
154
230
  ---
155
231
 
156
- ## 💡 Usage Scenarios
232
+ ### `wf csx [options]`
157
233
 
158
- ### 1. Changing and Updating CSX File
159
- ```bash
160
- # Edit CSX file
161
- vim AddToCartMapping.csx
234
+ **Purpose**: Convert CSX files to Base64 and embed in JSON files
162
235
 
163
- # Update in one command (CSX + JSON automatic)
164
- wf update
165
- ```
236
+ **What it does**:
237
+ 1. Finds CSX files (changed or all)
238
+ 2. Converts to Base64
239
+ 3. Updates ALL JSON files that reference the CSX file
240
+ 4. Updates ALL matching `location` references in each JSON
241
+
242
+ **Use when**: You only want to update CSX content in JSONs without publishing to API
166
243
 
167
- ### 2. Updating Only CSX (Without Writing to DB)
168
244
  ```bash
169
- # Convert CSX files to base64 and write to JSON files
170
- wf csx
245
+ wf csx # Process changed files in Git
246
+ wf csx --all # Process all CSX files
247
+ wf csx --file x.csx # Process a single file
171
248
  ```
172
249
 
173
- ### 3. Initial Setup / Full Sync
250
+ ---
251
+
252
+ ### `wf config <action> [key] [value]`
253
+
254
+ **Purpose**: Configuration management
255
+
174
256
  ```bash
175
- # Update all CSX files + add missing ones
176
- wf sync
257
+ wf config get # Show all settings (active domain)
258
+ wf config get PROJECT_ROOT # Show a specific setting
259
+ wf config set DB_PASSWORD pass # Change a setting (on active domain)
177
260
  ```
178
261
 
179
- ### 4. Resetting Workflows (Delete from DB and Re-add)
262
+ **Note:** `config get` and `config set` always operate on the **active domain**. Use `wf domain use <name>` to switch domains.
263
+
264
+ ---
265
+
266
+ ### `wf domain [action] [name] [options]`
267
+
268
+ **Purpose**: Multidomain management
269
+
270
+ Manage multiple domain configurations. Switch between domains with a single command. All CLI commands automatically use the active domain's settings.
271
+
180
272
  ```bash
181
- # With interactive menu (RECOMMENDED)
182
- wf reset
273
+ # Show active domain name
274
+ wf domain active
183
275
 
184
- # Reset all
185
- wf update --all
276
+ # List all domains
277
+ wf domain list
278
+ wf domain --list
279
+
280
+ # Add a new domain
281
+ wf domain add staging --API_BASE_URL http://staging.example.com:4201 --DB_NAME vNext_StagingDb
186
282
 
187
- # Single file
188
- wf update --file /path/to/file.json
283
+ # Add a domain with multiple settings
284
+ wf domain add production \
285
+ --API_BASE_URL http://prod.example.com:4201 \
286
+ --DB_NAME vNext_ProdDb \
287
+ --DB_HOST prod-db.example.com \
288
+ --DB_USER prod_user \
289
+ --DB_PASSWORD prod_pass
290
+
291
+ # Switch active domain
292
+ wf domain use staging
293
+
294
+ # Remove a domain
295
+ wf domain remove staging
189
296
  ```
190
297
 
298
+ **Notes:**
299
+ - When adding a domain, any unspecified settings are inherited from the `default` domain.
300
+ - The `default` domain cannot be removed.
301
+ - If the active domain is removed, the CLI automatically switches to `default`.
302
+
191
303
  ---
192
304
 
193
- ## ⚙️ Configuration
305
+ ## ⚙️ Configuration Variables
194
306
 
195
307
  Config file location: `~/.config/vnext-workflow-cli/config.json`
196
308
 
197
- ### Important Settings
198
- ```bash
199
- # Project root path (REQUIRED)
200
- wf config set PROJECT_ROOT /path/to/project
309
+ ### Config File Format
310
+
311
+ The config file uses a domain-aware structure. Each domain has its own set of configuration values:
312
+
313
+ ```json
314
+ {
315
+ "ACTIVE_DOMAIN": "default",
316
+ "DOMAINS": [
317
+ {
318
+ "DOMAIN_NAME": "default",
319
+ "AUTO_DISCOVER": true,
320
+ "API_BASE_URL": "http://localhost:4201",
321
+ "API_VERSION": "v1",
322
+ "DB_HOST": "localhost",
323
+ "DB_PORT": 5432,
324
+ "DB_NAME": "vNext_WorkflowDb",
325
+ "DB_USER": "postgres",
326
+ "DB_PASSWORD": "postgres",
327
+ "USE_DOCKER": false,
328
+ "DOCKER_POSTGRES_CONTAINER": "vnext-postgres",
329
+ "DEBUG_MODE": false
330
+ }
331
+ ]
332
+ }
333
+ ```
334
+
335
+ ### All Available Settings (Per Domain)
336
+
337
+ | Variable | Default | Description |
338
+ |----------|---------|-------------|
339
+ | `PROJECT_ROOT` | `process.cwd()` | **Auto.** Always uses current working directory (cannot be changed) |
340
+ | `AUTO_DISCOVER` | `true` | Enable automatic component folder discovery |
341
+ | `API_BASE_URL` | `http://localhost:4201` | vNext API base URL |
342
+ | `API_VERSION` | `v1` | API version |
343
+ | `DB_HOST` | `localhost` | PostgreSQL host |
344
+ | `DB_PORT` | `5432` | PostgreSQL port |
345
+ | `DB_NAME` | `vNext_WorkflowDb` | PostgreSQL database name |
346
+ | `DB_USER` | `postgres` | PostgreSQL username |
347
+ | `DB_PASSWORD` | `postgres` | PostgreSQL password |
348
+ | `USE_DOCKER` | `false` | Use Docker for PostgreSQL connection |
349
+ | `DOCKER_POSTGRES_CONTAINER` | `vnext-postgres` | Docker container name for PostgreSQL |
350
+ | `DEBUG_MODE` | `false` | Enable debug logging |
351
+
352
+ **Note:** `PROJECT_ROOT` is always the current working directory (`process.cwd()`). Simply `cd` into your project folder before running any command.
353
+
354
+ ### Quick Setup Examples
201
355
 
202
- # API settings
356
+ ```bash
357
+ # API settings (applied to active domain)
203
358
  wf config set API_BASE_URL http://localhost:4201
204
359
  wf config set API_VERSION v1
205
360
 
206
- # Database settings
361
+ # Database settings (direct connection)
207
362
  wf config set DB_HOST localhost
208
363
  wf config set DB_PORT 5432
209
364
  wf config set DB_NAME vNext_WorkflowDb
210
365
  wf config set DB_USER postgres
211
366
  wf config set DB_PASSWORD your_password
367
+ wf config set USE_DOCKER false
212
368
 
213
- # Docker settings
369
+ # Database settings (Docker)
214
370
  wf config set USE_DOCKER true
215
371
  wf config set DOCKER_POSTGRES_CONTAINER vnext-postgres
216
372
 
217
- # Auto discovery
373
+ # Other settings
218
374
  wf config set AUTO_DISCOVER true
375
+ wf config set DEBUG_MODE false
219
376
  ```
220
377
 
221
378
  ---
222
379
 
380
+ ## 💡 Usage Scenarios
381
+
382
+ ### 1. First Time Setup
383
+ ```bash
384
+ # Go to your vNext project
385
+ cd /path/to/project
386
+
387
+ # Check system status
388
+ wf check
389
+
390
+ # Sync all components (add missing ones)
391
+ wf sync
392
+ ```
393
+
394
+ ### 2. Daily Development - Changed Files
395
+ ```bash
396
+ # Edit CSX or JSON files
397
+ vim MyTask.csx
398
+
399
+ # Update only changed components
400
+ wf update
401
+ ```
402
+
403
+ ### 3. Update All Components
404
+ ```bash
405
+ # Force update all components
406
+ wf update --all
407
+ ```
408
+
409
+ ### 4. Reset Specific Component Type
410
+ ```bash
411
+ # Interactive menu
412
+ wf reset
413
+ ```
414
+
415
+ ### 5. Only Update CSX in JSONs (No API)
416
+ ```bash
417
+ # Update CSX content in JSON files without publishing
418
+ wf csx
419
+ ```
420
+
421
+ ### 6. Multidomain Workflow
422
+ ```bash
423
+ # Add domains
424
+ wf domain add domain-a --API_BASE_URL http://localhost:4201 --DB_NAME vNext_DomainA
425
+ wf domain add domain-b --API_BASE_URL http://localhost:4221 --DB_NAME vNext_DomainB
426
+
427
+ # Work on Domain A
428
+ wf domain use domain-a
429
+ wf check
430
+ wf update
431
+
432
+ # Switch to Domain B - config is applied automatically
433
+ wf domain use domain-b
434
+ wf check
435
+ wf update
436
+
437
+ # See all domains
438
+ wf domain list
439
+ ```
440
+
441
+ ---
442
+
443
+ ## 🔄 Command Comparison
444
+
445
+ | Command | DB Check | Existing Action | New Action | Use Case |
446
+ |---------|----------|-----------------|------------|----------|
447
+ | `sync` | Yes | Skip | Publish | Add missing components |
448
+ | `update` | Yes | Delete + Publish | Publish | Update changed components |
449
+ | `reset` | Yes | Delete + Publish | Publish | Force reset components |
450
+ | `csx` | No | N/A | N/A | Only update CSX in JSONs |
451
+
452
+ ---
453
+
454
+ ## 🔀 Multidomain Support
455
+
456
+ ### Overview
457
+
458
+ The CLI supports managing multiple domain configurations. Each domain has its own `API_BASE_URL`, `DB_NAME`, and other settings. Switch between domains with a single command.
459
+
460
+ ### Backward Compatibility
461
+
462
+ - Existing single-domain configurations are automatically migrated to the new format.
463
+ - A `default` domain is created with your existing settings.
464
+ - If you don't use multidomain features, everything works exactly as before.
465
+ - All `wf config get/set` commands continue to work (they operate on the active domain).
466
+
467
+ ### Migration
468
+
469
+ When upgrading from an older version, the CLI automatically migrates the config file:
470
+
471
+ **Before (old flat format):**
472
+ ```json
473
+ {
474
+ "API_BASE_URL": "http://localhost:4201",
475
+ "DB_NAME": "vNext_WorkflowDb"
476
+ }
477
+ ```
478
+
479
+ **After (new domain-aware format):**
480
+ ```json
481
+ {
482
+ "ACTIVE_DOMAIN": "default",
483
+ "DOMAINS": [
484
+ {
485
+ "DOMAIN_NAME": "default",
486
+ "AUTO_DISCOVER": true,
487
+ "API_BASE_URL": "http://localhost:4201",
488
+ "API_VERSION": "v1",
489
+ "DB_HOST": "localhost",
490
+ "DB_PORT": 5432,
491
+ "DB_NAME": "vNext_WorkflowDb",
492
+ "DB_USER": "postgres",
493
+ "DB_PASSWORD": "postgres",
494
+ "USE_DOCKER": false,
495
+ "DOCKER_POSTGRES_CONTAINER": "vnext-postgres",
496
+ "DEBUG_MODE": false
497
+ }
498
+ ]
499
+ }
500
+ ```
501
+
502
+ Your existing values are preserved. Any missing keys are filled in from defaults (11 keys total).
503
+
504
+ No manual action is required. The migration happens automatically on first run.
505
+
506
+ ### Domain Commands
507
+
508
+ | Command | Description |
509
+ |---------|-------------|
510
+ | `wf domain active` | Show active domain name |
511
+ | `wf domain list` | List all domains with active indicator |
512
+ | `wf domain --list` | List all domains (shorthand) |
513
+ | `wf domain add <name> [options]` | Add a new domain |
514
+ | `wf domain use <name>` | Switch active domain |
515
+ | `wf domain remove <name>` | Remove a domain |
516
+
517
+ ### Available Options for `wf domain add`
518
+
519
+ | Option | Description |
520
+ |--------|-------------|
521
+ | `--API_BASE_URL <url>` | API base URL |
522
+ | `--API_VERSION <version>` | API version |
523
+ | `--DB_HOST <host>` | Database host |
524
+ | `--DB_PORT <port>` | Database port |
525
+ | `--DB_NAME <name>` | Database name |
526
+ | `--DB_USER <user>` | Database user |
527
+ | `--DB_PASSWORD <password>` | Database password |
528
+ | `--AUTO_DISCOVER <true/false>` | Auto discover components |
529
+ | `--USE_DOCKER <true/false>` | Use Docker for DB |
530
+ | `--DOCKER_POSTGRES_CONTAINER <name>` | Docker container name |
531
+ | `--DEBUG_MODE <true/false>` | Debug mode |
532
+
533
+ Unspecified options inherit from the `default` domain.
534
+
535
+ ---
536
+
223
537
  ## 🆘 Troubleshooting
224
538
 
225
- ### "Files not found" (When using on another PC)
539
+ ### "vnext.config.json not found"
226
540
  ```bash
227
- # Check current config
541
+ # Make sure you're in the correct directory
542
+ pwd
543
+
544
+ # Check if vnext.config.json exists
545
+ ls -la vnext.config.json
546
+
547
+ # Check current working directory
228
548
  wf config get PROJECT_ROOT
549
+ ```
229
550
 
230
- # Set new PC's path
231
- wf config set PROJECT_ROOT /Users/NewUser/path/to/project
551
+ ### "Files not found" (When using on another PC)
552
+ ```bash
553
+ # Just cd into the project directory
554
+ cd /Users/NewUser/path/to/project
232
555
 
233
556
  # Verify
234
557
  wf check
235
558
  ```
236
559
 
560
+ **Note:** No need to set PROJECT_ROOT - just `cd` into your project folder.
561
+
237
562
  ### "Cannot connect to API"
238
563
  ```bash
239
564
  # Check API
@@ -346,16 +671,18 @@ vnext-workflow-cli/
346
671
  │ │ ├── check.js
347
672
  │ │ ├── config.js
348
673
  │ │ ├── csx.js
674
+ │ │ ├── domain.js # Multidomain management
349
675
  │ │ ├── reset.js
350
676
  │ │ ├── sync.js
351
677
  │ │ └── update.js
352
678
  │ └── lib/ # Library modules
353
- │ ├── api.js
354
- │ ├── config.js
355
- │ ├── csx.js
356
- │ ├── db.js
357
- │ ├── discover.js
358
- └── workflow.js
679
+ │ ├── api.js # API client (publish, reinitialize)
680
+ │ ├── config.js # CLI configuration
681
+ │ ├── csx.js # CSX processing
682
+ │ ├── db.js # Database operations
683
+ │ ├── discover.js # Component discovery
684
+ ├── vnextConfig.js # vnext.config.json reader
685
+ │ └── workflow.js # Workflow processing
359
686
  ├── .github/
360
687
  │ └── workflows/ # GitHub Actions workflows
361
688
  │ ├── build-and-publish.yml
@@ -379,4 +706,10 @@ wf check
379
706
 
380
707
  # Run development
381
708
  npm run dev
382
- ```
709
+ ```
710
+
711
+ ---
712
+
713
+ ## 📝 License
714
+
715
+ MIT License - see [LICENSE](LICENSE) for details.