@magentrix-corp/magentrix-cli 1.3.16 → 1.3.17

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 (68) hide show
  1. package/LICENSE +25 -25
  2. package/README.md +1166 -1166
  3. package/actions/autopublish.old.js +293 -293
  4. package/actions/config.js +182 -182
  5. package/actions/create.js +466 -466
  6. package/actions/help.js +164 -164
  7. package/actions/iris/buildStage.js +874 -874
  8. package/actions/iris/delete.js +256 -256
  9. package/actions/iris/dev.js +391 -391
  10. package/actions/iris/index.js +6 -6
  11. package/actions/iris/link.js +375 -375
  12. package/actions/iris/recover.js +268 -268
  13. package/actions/main.js +80 -80
  14. package/actions/publish.js +1420 -1420
  15. package/actions/pull.js +684 -684
  16. package/actions/setup.js +148 -148
  17. package/actions/status.js +17 -17
  18. package/actions/update.js +248 -248
  19. package/bin/magentrix.js +393 -393
  20. package/package.json +55 -55
  21. package/utils/assetPaths.js +158 -158
  22. package/utils/autopublishLock.js +77 -77
  23. package/utils/cacher.js +206 -206
  24. package/utils/cli/checkInstanceUrl.js +76 -74
  25. package/utils/cli/helpers/compare.js +282 -282
  26. package/utils/cli/helpers/ensureApiKey.js +63 -63
  27. package/utils/cli/helpers/ensureCredentials.js +68 -68
  28. package/utils/cli/helpers/ensureInstanceUrl.js +75 -75
  29. package/utils/cli/writeRecords.js +262 -262
  30. package/utils/compare.js +135 -135
  31. package/utils/compress.js +17 -17
  32. package/utils/config.js +527 -527
  33. package/utils/debug.js +144 -144
  34. package/utils/diagnostics/testPublishLogic.js +96 -96
  35. package/utils/diff.js +49 -49
  36. package/utils/downloadAssets.js +291 -291
  37. package/utils/filetag.js +115 -115
  38. package/utils/hash.js +14 -14
  39. package/utils/iris/backup.js +411 -411
  40. package/utils/iris/builder.js +541 -541
  41. package/utils/iris/config-reader.js +664 -664
  42. package/utils/iris/deleteHelper.js +150 -150
  43. package/utils/iris/errors.js +537 -537
  44. package/utils/iris/linker.js +601 -601
  45. package/utils/iris/lock.js +360 -360
  46. package/utils/iris/validation.js +360 -360
  47. package/utils/iris/validator.js +281 -281
  48. package/utils/iris/zipper.js +248 -248
  49. package/utils/logger.js +291 -291
  50. package/utils/magentrix/api/assets.js +220 -220
  51. package/utils/magentrix/api/auth.js +107 -107
  52. package/utils/magentrix/api/createEntity.js +61 -61
  53. package/utils/magentrix/api/deleteEntity.js +55 -55
  54. package/utils/magentrix/api/iris.js +251 -251
  55. package/utils/magentrix/api/meqlQuery.js +36 -36
  56. package/utils/magentrix/api/retrieveEntity.js +86 -86
  57. package/utils/magentrix/api/updateEntity.js +66 -66
  58. package/utils/magentrix/fetch.js +168 -168
  59. package/utils/merge.js +22 -22
  60. package/utils/permissionError.js +70 -70
  61. package/utils/preferences.js +40 -40
  62. package/utils/progress.js +469 -469
  63. package/utils/spinner.js +43 -43
  64. package/utils/template.js +52 -52
  65. package/utils/updateFileBase.js +121 -121
  66. package/utils/workspaces.js +108 -108
  67. package/vars/config.js +11 -11
  68. package/vars/global.js +50 -50
package/README.md CHANGED
@@ -1,1166 +1,1166 @@
1
- # MagentrixCLI User Guide
2
-
3
- A complete guide to installing and using MagentrixCLI for syncing your local development files with Magentrix cloud platform.
4
-
5
- ---
6
-
7
- ## What is MagentrixCLI?
8
-
9
- MagentrixCLI is a command-line tool that lets you:
10
- - Download your Magentrix code files to work on them locally
11
- - Upload your local changes back to Magentrix
12
- - Create new files with proper templates
13
- - Keep everything synchronized automatically
14
- - Work with your favorite code editor instead of the web interface
15
- - Deploy Vue.js (Iris) applications to your Magentrix instance
16
-
17
- ---
18
-
19
- ## Prerequisites
20
-
21
- Before you start, make sure you have:
22
-
23
- 1. **Node.js installed** (version 20 or higher)
24
- - Download from [nodejs.org](https://nodejs.org/)
25
- - Verify installation: `node --version`
26
-
27
- 2. **Access to a Magentrix instance**
28
- - You need the URL (e.g., `https://yourcompany.magentrix.com`)
29
-
30
- 3. **API Key from Magentrix**
31
- - Get this from your Magentrix administrator or system settings
32
- - It looks like a long string of characters
33
-
34
- ---
35
-
36
- ## Installation
37
-
38
- ### Global Installation (Recommended)
39
- Install the package globally so you can use it from anywhere:
40
-
41
- ```bash
42
- npm install -g @magentrix-corp/magentrix-cli
43
- ```
44
-
45
- ### Local Installation (Alternative)
46
- If you prefer to install it locally in your project:
47
-
48
- ```bash
49
- npm install @magentrix-corp/magentrix-cli
50
- ```
51
-
52
- Then run commands using:
53
- ```bash
54
- npx magentrix <command>
55
- ```
56
-
57
- ### Verify Installation
58
- Check that the installation worked:
59
- ```bash
60
- magentrix --version
61
- ```
62
-
63
- You should see the version number displayed.
64
-
65
- ---
66
-
67
- ## Updating the Package
68
-
69
- To update MagentrixCLI to the latest version:
70
-
71
- ### Global Installation Update
72
- If you installed globally (recommended):
73
-
74
- ```bash
75
- npm update -g @magentrix-corp/magentrix-cli
76
- ```
77
-
78
- Or to ensure you get the absolute latest version:
79
-
80
- ```bash
81
- npm install -g @magentrix-corp/magentrix-cli@latest
82
- ```
83
-
84
- ### Local Installation Update
85
- If you installed locally in your project:
86
-
87
- ```bash
88
- npm update @magentrix-corp/magentrix-cli
89
- ```
90
-
91
- Or for the latest version:
92
-
93
- ```bash
94
- npm install @magentrix-corp/magentrix-cli@latest
95
- ```
96
-
97
- ### Check for Updates
98
- To see if you're running the latest version:
99
-
100
- ```bash
101
- # Check your current version
102
- magentrix --version
103
-
104
- # Check the latest available version on npm
105
- npm view @magentrix-corp/magentrix-cli version
106
- ```
107
-
108
- ### After Updating
109
- Your configuration and local files are preserved during updates. You don't need to run `magentrix setup` again unless there are breaking changes (which will be noted in release notes).
110
-
111
- **Note**: It's a good practice to check for updates periodically to get the latest features, bug fixes, and performance improvements.
112
-
113
- ---
114
-
115
- ## Multi-Instance Setup
116
-
117
- ### Working with Multiple Magentrix Instances
118
-
119
- MagentrixCLI supports managing multiple Magentrix instances simultaneously by storing credentials per-folder. This means you can have different folders for different instances, and the CLI will automatically use the correct credentials based on which folder you're in.
120
-
121
- #### How It Works
122
-
123
- The CLI uses a folder hash to associate credentials with each project directory. When you run `magentrix setup` in a folder, the API key and instance URL are stored globally but linked to that specific folder location.
124
-
125
- #### Setting Up Multiple Instances
126
-
127
- **Example**: Managing both Production and Development instances
128
-
129
- ```bash
130
- # Set up Production instance
131
- mkdir ~/magentrix-production
132
- cd ~/magentrix-production
133
- magentrix setup
134
- # Enter production API key and URL
135
- magentrix pull
136
-
137
- # Set up Development instance
138
- mkdir ~/magentrix-development
139
- cd ~/magentrix-development
140
- magentrix setup
141
- # Enter development API key and URL
142
- magentrix pull
143
- ```
144
-
145
- Now you can work on both instances independently:
146
-
147
- ```bash
148
- # Work on production
149
- cd ~/magentrix-production
150
- magentrix publish # Publishes to production instance
151
-
152
- # Work on development
153
- cd ~/magentrix-development
154
- magentrix publish # Publishes to development instance
155
- ```
156
-
157
- #### Important Notes
158
-
159
- - Each folder maintains its own independent configuration
160
- - Credentials are stored securely in your system's config directory
161
- - Moving or renaming project folders will require running `magentrix setup` again
162
- - You can verify which instance you're connected to by running `magentrix` or `magentrix config`
163
-
164
- ---
165
-
166
- ## First Time Setup
167
-
168
- ### Step 1: Configure Your Credentials
169
-
170
- #### Interactive Setup
171
- Run this command to set up your connection to Magentrix:
172
-
173
- ```bash
174
- magentrix setup
175
- ```
176
-
177
- You'll be prompted for:
178
- - **API Key**: Paste your Magentrix API key
179
- - **Instance URL**: Enter your Magentrix instance URL (like `https://yourcompany.magentrix.com` or any custom domain)
180
-
181
- #### Non-Interactive Setup
182
- For automation or CI/CD, you can provide credentials via command-line flags:
183
-
184
- ```bash
185
- magentrix setup --api-key YOUR_API_KEY --instance-url https://yourcompany.magentrix.com
186
- ```
187
-
188
- **Available flags:**
189
- - `--api-key <apiKey>` - Your Magentrix API key
190
- - `--instance-url <instanceUrl>` - Your Magentrix instance URL
191
-
192
- The tool will test your credentials and save them securely. It will also automatically configure VS Code file associations for syntax highlighting of Magentrix file types (.ac, .ctrl, .trigger, .aspx files).
193
-
194
- ### Editor Support
195
- - **VS Code (Recommended)**: The tool automatically sets up syntax highlighting for all Magentrix file types during setup
196
- - **Other Editors**: The tool works with any text editor (Sublime Text, Atom, Vim, etc.) but you'll need to configure syntax highlighting manually
197
- - **Terminal Only**: You can use the tool entirely from the command line without any editor
198
-
199
- ### Step 2: Download Your Files
200
- Pull all your existing files from Magentrix:
201
-
202
- ```bash
203
- magentrix pull
204
- ```
205
-
206
- This creates a `src` folder with all your files organized into:
207
- - `Classes/` - Your utility classes (`.ac` files)
208
- - `Controllers/` - Your controllers (`.ctrl` files)
209
- - `Triggers/` - Your trigger code (`.trigger` files)
210
- - `Pages/` - Your ASPX pages (`.aspx` files)
211
- - `Templates/` - Your templates (`.aspx` files)
212
- - `Assets/` - Your static assets (images, CSS, JavaScript, etc.)
213
- - `iris-apps/` - Your Iris Vue.js applications
214
-
215
- ---
216
-
217
- ## Daily Usage
218
-
219
- ### Check Connection Status
220
- ```bash
221
- magentrix
222
- ```
223
- **What it does**: Displays your current connection status, API key (masked), and Magentrix instance URL.
224
- **When to use**: Quick check to verify you're properly authenticated and connected to the right instance.
225
-
226
- ### Configure CLI Settings
227
- ```bash
228
- magentrix config
229
- ```
230
- **What it does**: Opens an interactive configuration wizard where you can manage CLI settings such as:
231
- - **Log File Settings**: Enable or disable detailed operation logs
232
- - **View All Settings**: See your current configuration including API key (masked) and instance URL
233
-
234
- **When to use**:
235
- - To enable or disable operation logs for debugging
236
- - To verify your current settings and credentials
237
- - To manage CLI preferences without re-running setup
238
-
239
- ### Download Latest Files from Server
240
- ```bash
241
- magentrix pull
242
- ```
243
- **What it does**: Downloads all ActiveClass and ActivePage records from your Magentrix server to your local `src/` folder. Detects conflicts if files have been changed both locally and remotely, and prompts you to resolve them. Progress tracking shows separate steps for code entities and static assets.
244
- **When to use**:
245
- - Start of your workday to get latest changes
246
- - Before making major changes to avoid conflicts
247
- - When teammates have made server changes you need
248
-
249
- **Note**: If this is your first time running `magentrix pull` in a project with many files, you may be prompted about saving operation logs. This is a one-time setup that helps with debugging.
250
-
251
- ### Check Status and Conflicts
252
- ```bash
253
- magentrix status
254
- ```
255
- **What it does**: Compares your local files with the server versions and shows you exactly what's different - which files have conflicts, what's been added, modified, or deleted. Does NOT make any changes.
256
- **When to use**:
257
- - Before running `publish` to see what will be uploaded
258
- - To check for conflicts without downloading anything
259
- - To verify your local workspace is in sync with server
260
-
261
- ### Upload Your Changes to Server
262
- ```bash
263
- magentrix publish
264
- ```
265
- **What it does**: Sends all unpublished changes from your local machine to the Magentrix server and compiles them. Shows you exactly what will be created, updated, or deleted before doing it. Processes all changes in parallel for speed. Works with both code files and static assets. Features comprehensive progress tracking with timing diagnostics for large projects.
266
- **When to use**:
267
- - After you've finished making changes and want to deploy them
268
- - At the end of your work session
269
- - When you want to share your changes with teammates
270
-
271
- **Performance Note**: The CLI uses optimized algorithms for large projects. Even with 20,000+ files, initial scanning completes in under 2 seconds.
272
-
273
- ### Real-Time Development Mode
274
- ```bash
275
- magentrix autopublish
276
- ```
277
- **What it does**: Watches your files for changes and automatically uploads and compiles them on the server whenever you save a file. Shows compilation status and any errors in the terminal in real-time. Works with both code files and static assets. Can take some time to sync each file.
278
- **When to use**:
279
- - During active development when you want immediate feedback
280
- - When testing changes and want to see results right away
281
- - For iterative development where you're making frequent small changes
282
- **Note**: Best for real-time development but slower than batch publishing. Press Ctrl+C to stop.
283
-
284
- ---
285
-
286
- ## Creating New Files
287
-
288
- ### Interactive File Creation
289
- ```bash
290
- magentrix create
291
- ```
292
-
293
- This starts an interactive wizard:
294
-
295
- 1. **Choose what to create:**
296
- - ActiveClass (for Controllers, Classes, or Triggers)
297
- - ActivePage (for Pages or Templates)
298
-
299
- 2. **For Classes/Controllers/Triggers:**
300
- - Select the type (Controller, Class, or Trigger)
301
- - Enter the name
302
- - Add optional description
303
- - For Triggers: Search and select the target entity
304
-
305
- 3. **For Pages/Templates:**
306
- - Choose Page or Template
307
- - Enter the name
308
- - Add optional description
309
-
310
- The tool creates the file both locally and on your Magentrix server with proper templates.
311
-
312
- ### Non-Interactive File Creation
313
- For automation or scripting, you can provide all parameters via command-line flags:
314
-
315
- #### Create a Controller
316
- ```bash
317
- magentrix create --type class --class-type controller --name UserController --description "Handles user operations"
318
- ```
319
-
320
- #### Create a Utility Class
321
- ```bash
322
- magentrix create --type class --class-type utility --name EmailHelper --description "Email utility functions"
323
- ```
324
-
325
- #### Create a Trigger
326
- ```bash
327
- magentrix create --type class --class-type trigger --entity-id ENTITY_ID --name AccountTrigger --description "Account trigger logic"
328
- ```
329
-
330
- #### Create a Page
331
- ```bash
332
- magentrix create --type page --name Dashboard --description "Main dashboard page"
333
- ```
334
-
335
- #### Create a Template
336
- ```bash
337
- magentrix create --type template --name EmailTemplate --description "Email notification template"
338
- ```
339
-
340
- **Available flags:**
341
- - `--type <type>` - Entity type: `class`, `page`, or `template`
342
- - `--class-type <classType>` - For classes: `controller`, `utility`, or `trigger`
343
- - `--name <name>` - Name of the file to create
344
- - `--description <description>` - Optional description
345
- - `--entity-id <entityId>` - Required for triggers: the entity ID to attach the trigger to
346
-
347
- **Tip**: You can mix interactive and non-interactive modes. For example, provide just the `--name` flag and the tool will prompt you for the rest.
348
-
349
- ---
350
-
351
- ## Working with Files
352
-
353
- ### File Organization
354
- Your files are organized like this:
355
- ```
356
- src/
357
- ├── Classes/ # Utility classes (*.ac files)
358
- ├── Controllers/ # Controllers (*.ctrl files)
359
- ├── Triggers/ # Trigger code (*.trigger files)
360
- ├── Pages/ # ASPX pages (*.aspx files)
361
- ├── Templates/ # Templates (*.aspx files)
362
- ├── Contents/
363
- │ └── Assets/ # Static assets (images, CSS, JS, etc.)
364
- └── iris-apps/ # Vue.js Iris applications (see warning below)
365
- └── <app-slug>/ # Each app in its own folder
366
- ```
367
-
368
- > **⚠️ IMPORTANT: Deleting Iris Apps**
369
- >
370
- > **NEVER manually delete folders from `src/iris-apps/`!** Always use the `magentrix iris-app-delete` command to remove Iris apps. Manual deletion will cause:
371
- > - No recovery backup created (you cannot restore the app)
372
- > - App remains on the Magentrix server (orphaned)
373
- > - Cache becomes out of sync (causes errors on next publish)
374
- > - Linked Vue project not properly unlinked
375
- >
376
- > **Correct way to delete an Iris app:**
377
- > ```bash
378
- > magentrix iris-app-delete
379
- > ```
380
-
381
- ### File Extensions
382
- - `.ac` - Classes
383
- - `.ctrl` - Controllers
384
- - `.trigger` - Triggers
385
- - `.aspx` - Pages and Templates
386
-
387
- ### Editing Files
388
- 1. Open any file in your favorite editor (VS Code, Sublime, etc.)
389
- 2. Make your changes
390
- 3. Save the file
391
- 4. Run `magentrix publish` to upload changes
392
- - Or use `magentrix autopublish` for automatic uploads
393
-
394
- ---
395
-
396
- ## Working with Static Assets
397
-
398
- ### What Are Static Assets?
399
- Static assets are non-code files like images, CSS stylesheets, JavaScript files, and other resources that your Magentrix application uses.
400
-
401
- ### Asset Organization
402
- All static assets are stored in the `src/Contents/Assets/` directory. You can organize them into subfolders:
403
-
404
- ```
405
- src/Contents/Assets/
406
- ├── images/
407
- │ ├── logo.png
408
- │ └── banner.jpg
409
- ├── css/
410
- │ └── custom-styles.css
411
- └── js/
412
- └── helpers.js
413
- ```
414
-
415
- ### Working with Assets
416
-
417
- #### Downloading Assets
418
- ```bash
419
- magentrix pull
420
- ```
421
- Downloads all static assets from the server along with your code files. The folder structure is preserved.
422
-
423
- #### Adding New Assets
424
- 1. Place your files in `src/Contents/Assets/` (or a subfolder)
425
- 2. Run `magentrix publish` to upload them
426
- - Or use `magentrix autopublish` for automatic uploads
427
-
428
- #### Updating Assets
429
- 1. Edit or replace the file locally in `src/Contents/Assets/`
430
- 2. Run `magentrix publish` to upload the updated version
431
- - Or use `magentrix autopublish` for automatic uploads
432
-
433
- #### Deleting Assets
434
- 1. Delete the file from `src/Contents/Assets/`
435
- 2. Run `magentrix publish` to remove it from the server
436
-
437
- ### Supported File Types
438
- The tool supports all file types including:
439
- - Images: `.png`, `.jpg`, `.jpeg`, `.gif`, `.svg`, `.ico`
440
- - Stylesheets: `.css`
441
- - Scripts: `.js`
442
- - Documents: `.pdf`, `.txt`, `.json`
443
- - Any other file type you need
444
-
445
- ### Important Notes
446
- - Assets are synced alongside code files
447
- - Folder structures are preserved when syncing
448
- - Large files are handled efficiently using batch operations
449
- - Binary files (like images) are fully supported
450
-
451
- ---
452
-
453
- ## Deploying Vue.js (Iris) Apps
454
-
455
- MagentrixCLI supports deploying Vue.js applications (Iris apps) to your Magentrix instance. These apps are built with Vue.js and Module Federation, allowing you to create custom frontend experiences.
456
-
457
- > **⚠️ CRITICAL: Always use `magentrix iris-app-delete` to remove Iris apps!**
458
- >
459
- > Never manually delete folders from `src/iris-apps/`. Manual deletion bypasses backups, leaves orphaned apps on the server, and corrupts the cache. See [Deleting an Iris app](#delete-an-iris-app) for proper deletion.
460
-
461
- ### Overview
462
-
463
- The Iris deployment workflow:
464
- 1. **Link** your Vue project to the CLI
465
- 2. **Build and stage** the project to the CLI workspace
466
- 3. **Publish** to Magentrix (automatically handled by `magentrix publish`)
467
-
468
- ### Commands
469
-
470
- #### Link a Vue Project
471
- ```bash
472
- magentrix iris-app-link
473
- ```
474
- **What it does**: Opens an interactive menu to manage linked Vue.js projects. Projects are stored globally so they persist across Magentrix workspaces.
475
-
476
- **Options:**
477
- - `--path <dir>` - Specify Vue project path directly
478
- - `--unlink` - Remove a linked project
479
- - `--list` - Show all linked projects
480
- - `--cleanup` - Remove invalid (non-existent) linked projects
481
-
482
- **Menu options:**
483
- - Link a Vue project
484
- - View all linked projects
485
- - Unlink a project
486
- - Cleanup invalid projects
487
-
488
- #### Build and Stage
489
- ```bash
490
- magentrix vue-run-build
491
- ```
492
- **What it does**: Builds a linked Vue project and copies the output to `src/iris-apps/<slug>/` for publishing.
493
-
494
- **Two modes of operation:**
495
-
496
- 1. **From Magentrix workspace**: Prompts for which Vue project to build, stages to current workspace
497
- 2. **From Vue project directory**: Prompts for which Magentrix workspace to stage into
498
-
499
- **Options:**
500
- - `--path <dir>` - Specify Vue project path directly
501
- - `--skip-build` - Use existing `dist/` folder without rebuilding
502
- - `--workspace <dir>` - Specify Magentrix workspace path directly (when running from Vue project)
503
-
504
- **Process:**
505
- 1. Select from linked projects or enter path manually
506
- 2. Run `npm run build` in the Vue project
507
- 3. Validate the build output
508
- 4. Copy to workspace `src/iris-apps/<app-slug>/` (excludes index.html, favicon.ico)
509
- 5. Check sync status and prompt to pull if needed (required before publishing)
510
- 6. Prompt to publish to Magentrix
511
-
512
- #### Vue Development Server
513
- ```bash
514
- magentrix vue-run-dev
515
- ```
516
- **What it does**: Starts the Vue development server with platform assets (CSS, fonts) automatically injected from your Magentrix instance.
517
-
518
- **Authentication**: Uses `VITE_REFRESH_TOKEN` from `.env.development` (no CLI authentication required). This command can be run inside the Vue project directory.
519
-
520
- **Options:**
521
- - `--path <dir>` - Specify Vue project path
522
- - `--no-inject` - Skip asset injection, just run dev server
523
-
524
- **Process:**
525
- 1. Fetch platform assets from Magentrix using `.env.development` credentials
526
- 2. Update `VITE_ASSETS` in `.env.development` (changes are kept)
527
- 3. Run `npm run dev`
528
-
529
- #### Delete an Iris App
530
- ```bash
531
- magentrix iris-app-delete
532
- ```
533
- **What it does**: Safely delete a published Iris app with automatic recovery backup.
534
-
535
- **Process:**
536
- 1. Select app from list of published apps
537
- 2. Show destructive warning
538
- 3. Confirm by typing exact app slug
539
- 4. Ask if you want to unlink the Vue project
540
- 5. Create recovery backup in `.magentrix/iris-backups/`
541
- 6. Delete from server and local files
542
- 7. Update cache
543
-
544
- **Safety features:**
545
- - Automatic backup before deletion
546
- - Must type slug name to confirm
547
- - Recovery possible with `iris-app-recover`
548
-
549
- #### Recover a Deleted App
550
- ```bash
551
- magentrix iris-app-recover
552
- ```
553
- **What it does**: Restore a deleted Iris app from automatic backup.
554
-
555
- **Options:**
556
- - `--list` - Show all available recovery backups
557
-
558
- **Process:**
559
- 1. Select backup to restore (sorted by deletion time)
560
- 2. Check if linked Vue project still exists
561
- 3. Restore files to `src/iris-apps/<slug>/`
562
- 4. Re-link Vue project (if path exists)
563
- 5. Show warnings for edge cases
564
- 6. Optionally delete backup after recovery
565
- 7. Run `magentrix publish` to sync to server
566
-
567
- ### Vue Project Requirements
568
-
569
- Your Vue project needs two configuration files:
570
-
571
- **1. `config.ts`** - App metadata (required):
572
-
573
- ```typescript
574
- // src/config.ts
575
- export const config = {
576
- appSlug: "my-app", // Required: App identifier (folder name on server)
577
- appName: "My Application", // Required: Display name in navigation menu
578
- appDescription: "", // Optional: App description
579
- appIconId: "", // Optional: App icon ID
580
- }
581
- ```
582
-
583
- **2. `.env.development`** - Environment variables:
584
-
585
- ```bash
586
- VITE_SITE_URL = https://yourinstance.magentrix.com
587
- VITE_REFRESH_TOKEN = your-api-key
588
- VITE_ASSETS = '[]' # Injected automatically by vue-run-dev
589
- ```
590
-
591
- **Accepted field names in config.ts:**
592
- - Slug: `appSlug`, `slug`, or `app_slug`
593
- - Name: `appName`, `app_name`, or `name`
594
- - Description: `appDescription` or `app_description`
595
- - Icon: `appIconId` or `app_icon_id`
596
-
597
- #### Changing an App Slug
598
-
599
- > **⚠️ Important:** Changing the `appSlug`/`slug` in `config.ts` creates a **new** Iris app on Magentrix. The old app is **not** automatically deleted.
600
-
601
- If you simply change the slug and run `vue-run-build`, you'll end up with two apps on the server - the old one becomes orphaned.
602
-
603
- **Recommended workflow for changing an app slug:**
604
-
605
- ```bash
606
- # 1. Delete the old app first (from Magentrix workspace)
607
- cd ~/magentrix-workspace
608
- magentrix iris-app-delete # Select the old app, confirm deletion
609
- # This removes it from server, local files, and cache
610
- # Optionally unlink the Vue project when prompted
611
-
612
- # 2. Change the slug in your Vue project
613
- cd ~/my-vue-app
614
- # Edit config.ts: change appSlug from "old-slug" to "new-slug"
615
-
616
- # 3. Re-link the project with the new slug
617
- magentrix iris-app-link # Updates the linked project with new slug
618
-
619
- # 4. Build, stage, and publish
620
- magentrix vue-run-build # Stages to new folder: src/iris-apps/new-slug/
621
- # When prompted, choose to publish
622
- ```
623
-
624
- **What happens if you don't follow this workflow:**
625
- - Both `old-slug` and `new-slug` apps will exist on the server
626
- - The old app remains in `src/iris-apps/old-slug/` locally
627
- - You'll need to manually delete the old app using `magentrix iris-app-delete`
628
-
629
- ### Command Availability
630
-
631
- **In Vue project directories** (detected by presence of `config.ts`):
632
- - ✓ `magentrix iris-app-link` - Link project to CLI
633
- - ✓ `magentrix vue-run-build` - Build and stage (prompts for target workspace)
634
- - ✓ `magentrix vue-run-dev` - Start dev server (uses `.env.development` credentials)
635
- - ✓ `magentrix update` - Update CLI to latest version
636
-
637
- **In Magentrix workspace directories** (has `.magentrix/` folder):
638
- - ✓ All standard commands (`setup`, `pull`, `publish`, etc.)
639
- - ✓ All Iris commands (`vue-run-build`, `iris-app-delete`, `iris-app-recover`, etc.)
640
-
641
- **Note**: The `setup` command cannot be run inside a Vue project directory - run it from your Magentrix workspace. Commands like `pull`, `publish`, `autopublish` require a Magentrix workspace.
642
-
643
- ### Typical Development Workflow
644
-
645
- ```bash
646
- # First time setup
647
- magentrix iris-app-link # Link your Vue project
648
-
649
- # Development (run from Vue project folder)
650
- cd ~/my-vue-app # Work from your Vue project
651
- magentrix vue-run-dev # Start dev server with platform assets
652
- # Make changes, test locally
653
- # Press Ctrl+C to stop
654
-
655
- # Deployment - Option A (from Vue project folder)
656
- cd ~/my-vue-app # Work from your Vue project
657
- magentrix vue-run-build # Build and select workspace to stage into
658
- # Prompted: "Do you want to publish to Magentrix now?" → Yes/No
659
-
660
- # Deployment - Option B (from Magentrix workspace)
661
- cd ~/magentrix-workspace # Navigate to Magentrix workspace
662
- magentrix vue-run-build --path ~/my-vue-app # Build and stage
663
- # Prompted: "Do you want to publish to Magentrix now?" → Yes/No
664
- # If autopublish is running, it auto-deploys instead
665
-
666
- # Deleting an app (from workspace)
667
- magentrix iris-app-delete # Select app, confirm, auto-backup created
668
- magentrix publish # Sync deletion to server
669
-
670
- # Recovering a deleted app (from workspace)
671
- magentrix iris-app-recover # Select backup, restore files
672
- magentrix publish # Sync recovery to server
673
- ```
674
-
675
- ### Real-Time Deployment
676
-
677
- For automatic deployment during development:
678
-
679
- ```bash
680
- # Terminal 1: Run autopublish
681
- magentrix autopublish
682
-
683
- # Terminal 2: Build and stage after making changes
684
- magentrix vue-run-build
685
- # Autopublish will detect the changes and upload automatically
686
- ```
687
-
688
- ### Troubleshooting Iris Apps
689
-
690
- #### Running vue-run-build from different locations
691
-
692
- The `vue-run-build` command works from both locations:
693
-
694
- **From Vue project directory:**
695
- ```bash
696
- cd ~/my-vue-app
697
- magentrix vue-run-build # Prompts for which workspace to stage into
698
- ```
699
-
700
- **From Magentrix workspace:**
701
- ```bash
702
- cd ~/magentrix-workspace
703
- magentrix vue-run-build # Prompts for which Vue project to build
704
- # Or with path: magentrix vue-run-build --path ~/my-vue-app
705
- ```
706
-
707
- #### "No Magentrix workspaces found"
708
- When running from a Vue project, the command looks for registered workspaces in the global config. To register a workspace:
709
- 1. Navigate to your Magentrix workspace
710
- 2. Run `magentrix setup` (this automatically registers it)
711
- 3. Or specify workspace manually: `magentrix vue-run-build --workspace /path/to/workspace`
712
-
713
- **Note**: Existing workspaces are auto-registered when you run any command from them.
714
-
715
- #### "Publishing Iris apps from an out-of-sync workspace is not allowed"
716
- When running `vue-run-build` from a Vue project, the CLI checks if the target workspace is in sync with the server. If there are pending remote changes, you must pull first.
717
-
718
- **Why this is required:**
719
- - Prevents deployment conflicts
720
- - Ensures your app is deployed alongside the latest server state
721
- - Avoids overwriting changes made by other team members
722
-
723
- **To resolve:**
724
- 1. Navigate to the workspace: `cd /path/to/workspace`
725
- 2. Pull latest changes: `magentrix pull`
726
- 3. Re-run `vue-run-build` from your Vue project
727
-
728
- #### "Missing required field in config.ts: slug (appSlug)"
729
- Your Vue project's `config.ts` is missing the app identifier. Add an `appSlug` or `slug` field.
730
-
731
- #### "Missing required field in config.ts: appName"
732
- Your Vue project's `config.ts` is missing the display name. Add an `appName` field.
733
-
734
- #### "VITE_SITE_URL not set in .env.development"
735
- Create a `.env.development` file in your Vue project with `VITE_SITE_URL = https://yourinstance.magentrix.com`.
736
-
737
- #### "No .env.development file found"
738
- The CLI requires a `.env.development` file for environment variables. Create one with:
739
- ```bash
740
- VITE_SITE_URL = https://yourinstance.magentrix.com
741
- VITE_REFRESH_TOKEN = your-api-key
742
- VITE_ASSETS = '[]'
743
- ```
744
-
745
- #### "No config.ts found"
746
- The CLI looks for config in these locations:
747
- - `src/config.ts`
748
- - `config.ts`
749
- - `src/iris-config.ts`
750
- - `iris-config.ts`
751
-
752
- #### Deleting an Iris app
753
- To remove an Iris app:
754
- ```bash
755
- magentrix iris-app-delete
756
- ```
757
- This creates an automatic recovery backup before deletion. You can restore using `magentrix iris-app-recover`.
758
-
759
- **Permission errors:**
760
- If you get "Permission Denied" when deleting local files:
761
- - The app is still deleted from the server and cache
762
- - Delete the local folder manually with: `rm -rf src/iris-apps/<app-slug>`
763
- - Or use sudo: `sudo rm -rf src/iris-apps/<app-slug>`
764
-
765
- #### Recovering a deleted app
766
- To restore a deleted Iris app:
767
- ```bash
768
- magentrix iris-app-recover --list # See all available backups
769
- magentrix iris-app-recover # Select and restore a backup
770
- magentrix publish # Sync to server
771
- ```
772
-
773
- **Important**: After recovery, you must run `magentrix publish` to sync the app back to the Magentrix server.
774
-
775
- #### Changes not detected after vue-run-build
776
- The CLI uses content hash tracking to detect changes. If you rebuild without changes, `magentrix publish` will show "All files are in sync — nothing to publish!" This is expected behavior and saves unnecessary uploads.
777
-
778
- #### Duplicate apps after changing slug
779
- If you changed the `appSlug`/`slug` in `config.ts` and now have two apps on the server:
780
- 1. The old app is orphaned and needs manual cleanup
781
- 2. Run `magentrix iris-app-delete` and select the old app to remove it
782
- 3. See [Changing an App Slug](#changing-an-app-slug) for the proper workflow
783
-
784
- ---
785
-
786
- ## Handling Conflicts
787
-
788
- When files have changed both locally and on the server, you'll see conflict options:
789
-
790
- ### Option 1: Overwrite Local
791
- Replaces your local files with server versions (you lose local changes).
792
-
793
- ### Option 2: Skip Conflicts
794
- Keeps your local files, ignores server changes.
795
-
796
- ### Option 3: Manual Review
797
- Review each conflict individually and choose what to keep.
798
-
799
- **Tip**: Always run `magentrix pull` before making changes to avoid conflicts.
800
-
801
- ---
802
-
803
- ## Common Workflows
804
-
805
- ### Starting Your Day
806
- ```bash
807
- magentrix pull # Get latest files
808
- magentrix status # Check what's different
809
- # Work on your files...
810
- magentrix publish # Upload your changes
811
- ```
812
-
813
- ### Real-Time Development
814
- ```bash
815
- magentrix pull # Get latest
816
- magentrix autopublish # Start auto-sync
817
- # Edit files - they upload automatically when saved
818
- # Press Ctrl+C to stop auto-sync
819
- ```
820
-
821
- ### Creating New Features
822
- ```bash
823
- magentrix create # Create new files with wizard
824
- # Edit the created files...
825
- magentrix publish # Upload when ready
826
- ```
827
-
828
- ### Before Going Home
829
- ```bash
830
- magentrix publish # Make sure all changes are uploaded
831
- magentrix status # Verify everything is in sync
832
- ```
833
-
834
- ### Deploying a Vue.js App
835
-
836
- **Option A: From Vue project folder**
837
- ```bash
838
- cd ~/my-vue-app # Navigate to your Vue project
839
- magentrix iris-app-link # Link project (first time only)
840
- magentrix vue-run-build # Build and select workspace to stage into
841
- # Prompted: "Do you want to publish to Magentrix now?" → Yes/No
842
- ```
843
-
844
- **Option B: From Magentrix workspace**
845
- ```bash
846
- cd ~/magentrix-workspace # Navigate to Magentrix workspace
847
- magentrix iris-app-link --path ~/my-vue-app # Link project (first time only)
848
- magentrix vue-run-build --path ~/my-vue-app # Build and stage
849
- # Prompted: "Do you want to publish to Magentrix now?" (unless autopublish is running)
850
- ```
851
-
852
- **Note:** When running from a Vue project, the command prompts you to select a registered workspace. Workspaces are auto-registered when you run any command from them.
853
-
854
- ### Deleting and Recovering Apps
855
- ```bash
856
- # Delete an app (creates automatic backup)
857
- magentrix iris-app-delete # Select app, confirm deletion
858
-
859
- # View available backups
860
- magentrix iris-app-recover --list
861
-
862
- # Recover a deleted app
863
- magentrix iris-app-recover # Select backup, restore
864
- magentrix publish # Sync recovery to server
865
- ```
866
-
867
- ---
868
-
869
- ## Using Git Alongside MagentrixCLI
870
-
871
- ### Important: Separate Systems
872
- MagentrixCLI and Git are **completely separate** tools that don't integrate with each other. Here's how to use them together effectively:
873
-
874
- ### What Each Tool Does
875
- - **MagentrixCLI**: Syncs your local files with your Magentrix server (for deployment and compilation)
876
- - **Git**: Tracks your code changes and syncs with your source control repository (for version control and collaboration)
877
-
878
- ### Recommended Workflow
879
-
880
- #### 1. Set Up Both Systems
881
- ```bash
882
- # Initialize git repository (if not already done)
883
- git init
884
- git remote add origin <your-repo-url>
885
-
886
- # Set up MagentrixCLI
887
- magentrix setup
888
- magentrix pull
889
- ```
890
-
891
- #### 2. Daily Development Flow
892
- ```bash
893
- # Start of day - get latest from both systems
894
- git pull # Get latest code from repository
895
- magentrix pull # Get latest files from Magentrix server
896
-
897
- # Work on your files...
898
- # Save changes in editor
899
-
900
- # Commit to git first (for version control)
901
- git add .
902
- git commit -m "Your commit message"
903
- git push # Share with team via git
904
-
905
- # Then deploy to Magentrix server
906
- magentrix publish # Deploy to server for testing/production
907
- ```
908
-
909
- #### 3. Git Repository Setup
910
- Add these to your `.gitignore` file:
911
- ```
912
- # MagentrixCLI cache files - don't commit these
913
- .magentrix/
914
- node_modules/
915
- ```
916
-
917
- But **DO commit**:
918
- ```
919
- src/ # Your actual code files
920
- package.json # If you have one
921
- README.md # Documentation
922
- ```
923
-
924
- ### Best Practices
925
-
926
- #### Use Git for Version Control
927
- - **Commit often**: Commit logical chunks of work with meaningful messages
928
- - **Branch for features**: Create branches for new features or major changes
929
- - **Code reviews**: Use pull requests for team collaboration
930
-
931
- #### Use MagentrixCLI for Deployment
932
- - **Test locally first**: Make sure your code works before deploying
933
- - **Deploy after committing**: Always commit to git before deploying to Magentrix
934
- - **Use status**: Check `magentrix status` before deploying
935
-
936
- ### Example Team Workflow
937
-
938
- #### Developer A
939
- ```bash
940
- git checkout -b feature/new-controller
941
- # Make changes to files
942
- git add .
943
- git commit -m "Add new customer controller"
944
- git push origin feature/new-controller
945
- # Create pull request
946
-
947
- # After PR approval and merge:
948
- git checkout main
949
- git pull
950
- magentrix publish # Deploy merged changes
951
- ```
952
-
953
- #### Developer B
954
- ```bash
955
- git pull # Get A's changes
956
- magentrix pull # Get any server changes
957
- # Continue working with latest code
958
- ```
959
-
960
- ### Conflict Resolution
961
-
962
- #### Git Conflicts (Code Level)
963
- - Resolve using git merge tools
964
- - Coordinate with teammates
965
- - Use standard git conflict resolution
966
-
967
- #### Magentrix Conflicts (Server Level)
968
- - Use `magentrix status` to identify conflicts
969
- - Choose resolution strategy (overwrite, skip, manual)
970
- - Independent of git - handled by MagentrixCLI
971
-
972
- ### Why Keep Them Separate
973
- - **Git**: Permanent history, branching, collaboration, code reviews
974
- - **MagentrixCLI**: Live server deployment, compilation, testing
975
- - **Different purposes**: Version control vs deployment
976
- - **Different timing**: Git for development process, MagentrixCLI for deployment
977
-
978
- This separation gives you the best of both worlds - robust version control AND seamless deployment!
979
-
980
- ---
981
-
982
- ## Operation Logs
983
-
984
- ### About Logs
985
-
986
- MagentrixCLI can save detailed operation logs to help with debugging and troubleshooting. This is particularly useful when dealing with large projects or investigating sync issues.
987
-
988
- ### Enabling/Disabling Logs
989
-
990
- #### First Time Prompt
991
- The first time you run an operation like `magentrix pull` or `magentrix publish`, you'll be asked:
992
-
993
- ```
994
- 📋 Log File Settings
995
- Magentrix CLI can save detailed operation logs for debugging.
996
-
997
- ? Would you like to save operation logs to files? (Y/n)
998
- ```
999
-
1000
- Your choice is saved globally and applies to all future operations.
1001
-
1002
- #### Change Settings Later
1003
- You can change your logging preference at any time:
1004
-
1005
- ```bash
1006
- magentrix config
1007
- ```
1008
-
1009
- Then select "Log File Settings" from the menu to enable or disable logs.
1010
-
1011
- ### Log File Location
1012
-
1013
- When enabled, logs are saved to `.magentrix/logs/` in your project folder:
1014
-
1015
- ```
1016
- .magentrix/
1017
- └── logs/
1018
- ├── pull-2025-01-15T14-30-45.log
1019
- ├── publish-2025-01-15T15-12-30.log
1020
- └── autopublish-2025-01-15T16-00-00.log
1021
- ```
1022
-
1023
- ### What Gets Logged
1024
-
1025
- Operation logs include:
1026
- - Detailed timestamps for each operation
1027
- - Warnings about unknown file types or edge cases
1028
- - Errors with full stack traces
1029
- - Information about files being processed
1030
- - API calls and responses
1031
-
1032
- ### Viewing Logs
1033
-
1034
- To view a log file:
1035
-
1036
- ```bash
1037
- cat .magentrix/logs/pull-2025-01-15T14-30-45.log
1038
- ```
1039
-
1040
- Or open it in your text editor.
1041
-
1042
- ### Log Cleanup
1043
-
1044
- The CLI automatically keeps only the 10 most recent log files per operation type to prevent disk space issues. Older logs are automatically deleted.
1045
-
1046
- ---
1047
-
1048
- ## Troubleshooting
1049
-
1050
- ### "Authentication failed"
1051
- - Check your API key is correct
1052
- - Verify your instance URL is right
1053
- - Run `magentrix setup` again
1054
-
1055
- ### "No files found" or empty src folder
1056
- - Run `magentrix pull` to download files
1057
- - Check you have permission to access the Magentrix instance
1058
-
1059
- ### Files not uploading
1060
- - Check file permissions
1061
- - Ensure you're in the right directory (where `src` folder is)
1062
- - Try `magentrix status` to see what's different
1063
-
1064
- ### "File is currently compiling" message
1065
- - Wait for the current upload to finish
1066
- - The tool prevents conflicts by processing one file at a time
1067
-
1068
- ### Lost connection during autopublish
1069
- - Press Ctrl+C to stop autopublish
1070
- - Run `magentrix publish` to upload any remaining changes
1071
- - Restart with `magentrix autopublish`
1072
-
1073
- ### Need More Debugging Information
1074
- - Enable operation logs via `magentrix config`
1075
- - Run the failing operation again
1076
- - Check `.magentrix/logs/` for detailed error information
1077
- - Share log files with your team or support for help
1078
-
1079
- ---
1080
-
1081
- ## Tips & Best Practices
1082
-
1083
- ### 1. Always Pull First
1084
- Run `magentrix pull` before starting work to get the latest files.
1085
-
1086
- ### 2. Check Status Before Publishing
1087
- Use `magentrix status` to see what will change before running `magentrix publish`.
1088
-
1089
- ### 3. Use Autopublish for Active Development
1090
- When actively coding, `magentrix autopublish` saves time by auto-uploading changes.
1091
-
1092
- ### 4. Backup Important Work
1093
- The tool is reliable, but always have backups of critical code.
1094
-
1095
- ### 5. Organize Your Workspace
1096
- Keep your project folder clean and organized. The tool works best with the standard file structure.
1097
-
1098
- ### 6. Use Descriptive Names
1099
- When creating new files, use clear, descriptive names that follow your team's naming conventions.
1100
-
1101
- ---
1102
-
1103
- ## Configuration Files
1104
-
1105
- The tool creates these configuration files (you normally don't need to edit them):
1106
-
1107
- ### Global Settings
1108
- - **Location**: `~/.config/magentrix/` (Mac/Linux) or `%APPDATA%/magentrix/` (Windows)
1109
- - **Contains**:
1110
- - API credentials and connection settings (namespaced by folder hash)
1111
- - Global preferences like log settings
1112
- - Multiple instance credentials (each folder has its own credentials)
1113
-
1114
- ### Project Settings
1115
- - **Location**: `.magentrix/` folder in your project
1116
- - **Contains**:
1117
- - File mappings and sync status
1118
- - Local cache and operation logs (if enabled)
1119
- - Base file snapshots for conflict detection
1120
-
1121
- **Note**: These folders are created automatically. Don't delete them unless you want to reconfigure everything. The global config supports multiple instances by storing credentials per-project folder.
1122
-
1123
- ---
1124
-
1125
- ## Getting Help
1126
-
1127
- ### Built-in Help
1128
- ```bash
1129
- magentrix --help # Show all commands
1130
- magentrix pull --help # Help for specific command
1131
- ```
1132
-
1133
- ### Check Your Setup
1134
- ```bash
1135
- magentrix # Shows connection status
1136
- magentrix status # Shows sync status
1137
- ```
1138
-
1139
- ### Common Commands Summary
1140
- - `magentrix setup` - Configure credentials
1141
- - `magentrix config` - Manage CLI settings
1142
- - `magentrix pull` - Download files from server
1143
- - `magentrix publish` - Upload local changes
1144
- - `magentrix create` - Create new files
1145
- - `magentrix status` - Check sync status
1146
- - `magentrix autopublish` - Auto-sync mode
1147
- - `magentrix update` - Update to latest version
1148
- - `magentrix iris-app-link` - Link Vue.js projects for deployment
1149
- - `magentrix vue-run-build` - Build and stage Vue.js apps
1150
- - `magentrix vue-run-dev` - Start Vue dev server with platform assets
1151
- - `magentrix iris-app-delete` - Delete an Iris app with recovery backup
1152
- - `magentrix iris-app-recover` - Recover a deleted Iris app
1153
-
1154
- ---
1155
-
1156
- ## What's Next?
1157
-
1158
- Once you're comfortable with basic usage:
1159
-
1160
- 1. **Set up your preferred editor** with syntax highlighting for your file types
1161
- 2. **Learn the autopublish workflow** for faster development
1162
- 3. **Explore conflict resolution** if you work in a team
1163
- 4. **Check out templates** created by the `create` command to understand best practices
1164
- 5. **Deploy Vue.js apps** using `iris-app-link`, `vue-run-build`, and `vue-run-dev` commands
1165
-
1166
- Happy coding with MagentrixCLI! 🚀
1
+ # MagentrixCLI User Guide
2
+
3
+ A complete guide to installing and using MagentrixCLI for syncing your local development files with Magentrix cloud platform.
4
+
5
+ ---
6
+
7
+ ## What is MagentrixCLI?
8
+
9
+ MagentrixCLI is a command-line tool that lets you:
10
+ - Download your Magentrix code files to work on them locally
11
+ - Upload your local changes back to Magentrix
12
+ - Create new files with proper templates
13
+ - Keep everything synchronized automatically
14
+ - Work with your favorite code editor instead of the web interface
15
+ - Deploy Vue.js (Iris) applications to your Magentrix instance
16
+
17
+ ---
18
+
19
+ ## Prerequisites
20
+
21
+ Before you start, make sure you have:
22
+
23
+ 1. **Node.js installed** (version 20 or higher)
24
+ - Download from [nodejs.org](https://nodejs.org/)
25
+ - Verify installation: `node --version`
26
+
27
+ 2. **Access to a Magentrix instance**
28
+ - You need the URL (e.g., `https://yourcompany.magentrix.com`)
29
+
30
+ 3. **API Key from Magentrix**
31
+ - Get this from your Magentrix administrator or system settings
32
+ - It looks like a long string of characters
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ ### Global Installation (Recommended)
39
+ Install the package globally so you can use it from anywhere:
40
+
41
+ ```bash
42
+ npm install -g @magentrix-corp/magentrix-cli
43
+ ```
44
+
45
+ ### Local Installation (Alternative)
46
+ If you prefer to install it locally in your project:
47
+
48
+ ```bash
49
+ npm install @magentrix-corp/magentrix-cli
50
+ ```
51
+
52
+ Then run commands using:
53
+ ```bash
54
+ npx magentrix <command>
55
+ ```
56
+
57
+ ### Verify Installation
58
+ Check that the installation worked:
59
+ ```bash
60
+ magentrix --version
61
+ ```
62
+
63
+ You should see the version number displayed.
64
+
65
+ ---
66
+
67
+ ## Updating the Package
68
+
69
+ To update MagentrixCLI to the latest version:
70
+
71
+ ### Global Installation Update
72
+ If you installed globally (recommended):
73
+
74
+ ```bash
75
+ npm update -g @magentrix-corp/magentrix-cli
76
+ ```
77
+
78
+ Or to ensure you get the absolute latest version:
79
+
80
+ ```bash
81
+ npm install -g @magentrix-corp/magentrix-cli@latest
82
+ ```
83
+
84
+ ### Local Installation Update
85
+ If you installed locally in your project:
86
+
87
+ ```bash
88
+ npm update @magentrix-corp/magentrix-cli
89
+ ```
90
+
91
+ Or for the latest version:
92
+
93
+ ```bash
94
+ npm install @magentrix-corp/magentrix-cli@latest
95
+ ```
96
+
97
+ ### Check for Updates
98
+ To see if you're running the latest version:
99
+
100
+ ```bash
101
+ # Check your current version
102
+ magentrix --version
103
+
104
+ # Check the latest available version on npm
105
+ npm view @magentrix-corp/magentrix-cli version
106
+ ```
107
+
108
+ ### After Updating
109
+ Your configuration and local files are preserved during updates. You don't need to run `magentrix setup` again unless there are breaking changes (which will be noted in release notes).
110
+
111
+ **Note**: It's a good practice to check for updates periodically to get the latest features, bug fixes, and performance improvements.
112
+
113
+ ---
114
+
115
+ ## Multi-Instance Setup
116
+
117
+ ### Working with Multiple Magentrix Instances
118
+
119
+ MagentrixCLI supports managing multiple Magentrix instances simultaneously by storing credentials per-folder. This means you can have different folders for different instances, and the CLI will automatically use the correct credentials based on which folder you're in.
120
+
121
+ #### How It Works
122
+
123
+ The CLI uses a folder hash to associate credentials with each project directory. When you run `magentrix setup` in a folder, the API key and instance URL are stored globally but linked to that specific folder location.
124
+
125
+ #### Setting Up Multiple Instances
126
+
127
+ **Example**: Managing both Production and Development instances
128
+
129
+ ```bash
130
+ # Set up Production instance
131
+ mkdir ~/magentrix-production
132
+ cd ~/magentrix-production
133
+ magentrix setup
134
+ # Enter production API key and URL
135
+ magentrix pull
136
+
137
+ # Set up Development instance
138
+ mkdir ~/magentrix-development
139
+ cd ~/magentrix-development
140
+ magentrix setup
141
+ # Enter development API key and URL
142
+ magentrix pull
143
+ ```
144
+
145
+ Now you can work on both instances independently:
146
+
147
+ ```bash
148
+ # Work on production
149
+ cd ~/magentrix-production
150
+ magentrix publish # Publishes to production instance
151
+
152
+ # Work on development
153
+ cd ~/magentrix-development
154
+ magentrix publish # Publishes to development instance
155
+ ```
156
+
157
+ #### Important Notes
158
+
159
+ - Each folder maintains its own independent configuration
160
+ - Credentials are stored securely in your system's config directory
161
+ - Moving or renaming project folders will require running `magentrix setup` again
162
+ - You can verify which instance you're connected to by running `magentrix` or `magentrix config`
163
+
164
+ ---
165
+
166
+ ## First Time Setup
167
+
168
+ ### Step 1: Configure Your Credentials
169
+
170
+ #### Interactive Setup
171
+ Run this command to set up your connection to Magentrix:
172
+
173
+ ```bash
174
+ magentrix setup
175
+ ```
176
+
177
+ You'll be prompted for:
178
+ - **API Key**: Paste your Magentrix API key
179
+ - **Instance URL**: Enter your Magentrix instance URL (like `https://yourcompany.magentrix.com` or any custom domain)
180
+
181
+ #### Non-Interactive Setup
182
+ For automation or CI/CD, you can provide credentials via command-line flags:
183
+
184
+ ```bash
185
+ magentrix setup --api-key YOUR_API_KEY --instance-url https://yourcompany.magentrix.com
186
+ ```
187
+
188
+ **Available flags:**
189
+ - `--api-key <apiKey>` - Your Magentrix API key
190
+ - `--instance-url <instanceUrl>` - Your Magentrix instance URL
191
+
192
+ The tool will test your credentials and save them securely. It will also automatically configure VS Code file associations for syntax highlighting of Magentrix file types (.ac, .ctrl, .trigger, .aspx files).
193
+
194
+ ### Editor Support
195
+ - **VS Code (Recommended)**: The tool automatically sets up syntax highlighting for all Magentrix file types during setup
196
+ - **Other Editors**: The tool works with any text editor (Sublime Text, Atom, Vim, etc.) but you'll need to configure syntax highlighting manually
197
+ - **Terminal Only**: You can use the tool entirely from the command line without any editor
198
+
199
+ ### Step 2: Download Your Files
200
+ Pull all your existing files from Magentrix:
201
+
202
+ ```bash
203
+ magentrix pull
204
+ ```
205
+
206
+ This creates a `src` folder with all your files organized into:
207
+ - `Classes/` - Your utility classes (`.ac` files)
208
+ - `Controllers/` - Your controllers (`.ctrl` files)
209
+ - `Triggers/` - Your trigger code (`.trigger` files)
210
+ - `Pages/` - Your ASPX pages (`.aspx` files)
211
+ - `Templates/` - Your templates (`.aspx` files)
212
+ - `Assets/` - Your static assets (images, CSS, JavaScript, etc.)
213
+ - `iris-apps/` - Your Iris Vue.js applications
214
+
215
+ ---
216
+
217
+ ## Daily Usage
218
+
219
+ ### Check Connection Status
220
+ ```bash
221
+ magentrix
222
+ ```
223
+ **What it does**: Displays your current connection status, API key (masked), and Magentrix instance URL.
224
+ **When to use**: Quick check to verify you're properly authenticated and connected to the right instance.
225
+
226
+ ### Configure CLI Settings
227
+ ```bash
228
+ magentrix config
229
+ ```
230
+ **What it does**: Opens an interactive configuration wizard where you can manage CLI settings such as:
231
+ - **Log File Settings**: Enable or disable detailed operation logs
232
+ - **View All Settings**: See your current configuration including API key (masked) and instance URL
233
+
234
+ **When to use**:
235
+ - To enable or disable operation logs for debugging
236
+ - To verify your current settings and credentials
237
+ - To manage CLI preferences without re-running setup
238
+
239
+ ### Download Latest Files from Server
240
+ ```bash
241
+ magentrix pull
242
+ ```
243
+ **What it does**: Downloads all ActiveClass and ActivePage records from your Magentrix server to your local `src/` folder. Detects conflicts if files have been changed both locally and remotely, and prompts you to resolve them. Progress tracking shows separate steps for code entities and static assets.
244
+ **When to use**:
245
+ - Start of your workday to get latest changes
246
+ - Before making major changes to avoid conflicts
247
+ - When teammates have made server changes you need
248
+
249
+ **Note**: If this is your first time running `magentrix pull` in a project with many files, you may be prompted about saving operation logs. This is a one-time setup that helps with debugging.
250
+
251
+ ### Check Status and Conflicts
252
+ ```bash
253
+ magentrix status
254
+ ```
255
+ **What it does**: Compares your local files with the server versions and shows you exactly what's different - which files have conflicts, what's been added, modified, or deleted. Does NOT make any changes.
256
+ **When to use**:
257
+ - Before running `publish` to see what will be uploaded
258
+ - To check for conflicts without downloading anything
259
+ - To verify your local workspace is in sync with server
260
+
261
+ ### Upload Your Changes to Server
262
+ ```bash
263
+ magentrix publish
264
+ ```
265
+ **What it does**: Sends all unpublished changes from your local machine to the Magentrix server and compiles them. Shows you exactly what will be created, updated, or deleted before doing it. Processes all changes in parallel for speed. Works with both code files and static assets. Features comprehensive progress tracking with timing diagnostics for large projects.
266
+ **When to use**:
267
+ - After you've finished making changes and want to deploy them
268
+ - At the end of your work session
269
+ - When you want to share your changes with teammates
270
+
271
+ **Performance Note**: The CLI uses optimized algorithms for large projects. Even with 20,000+ files, initial scanning completes in under 2 seconds.
272
+
273
+ ### Real-Time Development Mode
274
+ ```bash
275
+ magentrix autopublish
276
+ ```
277
+ **What it does**: Watches your files for changes and automatically uploads and compiles them on the server whenever you save a file. Shows compilation status and any errors in the terminal in real-time. Works with both code files and static assets. Can take some time to sync each file.
278
+ **When to use**:
279
+ - During active development when you want immediate feedback
280
+ - When testing changes and want to see results right away
281
+ - For iterative development where you're making frequent small changes
282
+ **Note**: Best for real-time development but slower than batch publishing. Press Ctrl+C to stop.
283
+
284
+ ---
285
+
286
+ ## Creating New Files
287
+
288
+ ### Interactive File Creation
289
+ ```bash
290
+ magentrix create
291
+ ```
292
+
293
+ This starts an interactive wizard:
294
+
295
+ 1. **Choose what to create:**
296
+ - ActiveClass (for Controllers, Classes, or Triggers)
297
+ - ActivePage (for Pages or Templates)
298
+
299
+ 2. **For Classes/Controllers/Triggers:**
300
+ - Select the type (Controller, Class, or Trigger)
301
+ - Enter the name
302
+ - Add optional description
303
+ - For Triggers: Search and select the target entity
304
+
305
+ 3. **For Pages/Templates:**
306
+ - Choose Page or Template
307
+ - Enter the name
308
+ - Add optional description
309
+
310
+ The tool creates the file both locally and on your Magentrix server with proper templates.
311
+
312
+ ### Non-Interactive File Creation
313
+ For automation or scripting, you can provide all parameters via command-line flags:
314
+
315
+ #### Create a Controller
316
+ ```bash
317
+ magentrix create --type class --class-type controller --name UserController --description "Handles user operations"
318
+ ```
319
+
320
+ #### Create a Utility Class
321
+ ```bash
322
+ magentrix create --type class --class-type utility --name EmailHelper --description "Email utility functions"
323
+ ```
324
+
325
+ #### Create a Trigger
326
+ ```bash
327
+ magentrix create --type class --class-type trigger --entity-id ENTITY_ID --name AccountTrigger --description "Account trigger logic"
328
+ ```
329
+
330
+ #### Create a Page
331
+ ```bash
332
+ magentrix create --type page --name Dashboard --description "Main dashboard page"
333
+ ```
334
+
335
+ #### Create a Template
336
+ ```bash
337
+ magentrix create --type template --name EmailTemplate --description "Email notification template"
338
+ ```
339
+
340
+ **Available flags:**
341
+ - `--type <type>` - Entity type: `class`, `page`, or `template`
342
+ - `--class-type <classType>` - For classes: `controller`, `utility`, or `trigger`
343
+ - `--name <name>` - Name of the file to create
344
+ - `--description <description>` - Optional description
345
+ - `--entity-id <entityId>` - Required for triggers: the entity ID to attach the trigger to
346
+
347
+ **Tip**: You can mix interactive and non-interactive modes. For example, provide just the `--name` flag and the tool will prompt you for the rest.
348
+
349
+ ---
350
+
351
+ ## Working with Files
352
+
353
+ ### File Organization
354
+ Your files are organized like this:
355
+ ```
356
+ src/
357
+ ├── Classes/ # Utility classes (*.ac files)
358
+ ├── Controllers/ # Controllers (*.ctrl files)
359
+ ├── Triggers/ # Trigger code (*.trigger files)
360
+ ├── Pages/ # ASPX pages (*.aspx files)
361
+ ├── Templates/ # Templates (*.aspx files)
362
+ ├── Contents/
363
+ │ └── Assets/ # Static assets (images, CSS, JS, etc.)
364
+ └── iris-apps/ # Vue.js Iris applications (see warning below)
365
+ └── <app-slug>/ # Each app in its own folder
366
+ ```
367
+
368
+ > **⚠️ IMPORTANT: Deleting Iris Apps**
369
+ >
370
+ > **NEVER manually delete folders from `src/iris-apps/`!** Always use the `magentrix iris-app-delete` command to remove Iris apps. Manual deletion will cause:
371
+ > - No recovery backup created (you cannot restore the app)
372
+ > - App remains on the Magentrix server (orphaned)
373
+ > - Cache becomes out of sync (causes errors on next publish)
374
+ > - Linked Vue project not properly unlinked
375
+ >
376
+ > **Correct way to delete an Iris app:**
377
+ > ```bash
378
+ > magentrix iris-app-delete
379
+ > ```
380
+
381
+ ### File Extensions
382
+ - `.ac` - Classes
383
+ - `.ctrl` - Controllers
384
+ - `.trigger` - Triggers
385
+ - `.aspx` - Pages and Templates
386
+
387
+ ### Editing Files
388
+ 1. Open any file in your favorite editor (VS Code, Sublime, etc.)
389
+ 2. Make your changes
390
+ 3. Save the file
391
+ 4. Run `magentrix publish` to upload changes
392
+ - Or use `magentrix autopublish` for automatic uploads
393
+
394
+ ---
395
+
396
+ ## Working with Static Assets
397
+
398
+ ### What Are Static Assets?
399
+ Static assets are non-code files like images, CSS stylesheets, JavaScript files, and other resources that your Magentrix application uses.
400
+
401
+ ### Asset Organization
402
+ All static assets are stored in the `src/Contents/Assets/` directory. You can organize them into subfolders:
403
+
404
+ ```
405
+ src/Contents/Assets/
406
+ ├── images/
407
+ │ ├── logo.png
408
+ │ └── banner.jpg
409
+ ├── css/
410
+ │ └── custom-styles.css
411
+ └── js/
412
+ └── helpers.js
413
+ ```
414
+
415
+ ### Working with Assets
416
+
417
+ #### Downloading Assets
418
+ ```bash
419
+ magentrix pull
420
+ ```
421
+ Downloads all static assets from the server along with your code files. The folder structure is preserved.
422
+
423
+ #### Adding New Assets
424
+ 1. Place your files in `src/Contents/Assets/` (or a subfolder)
425
+ 2. Run `magentrix publish` to upload them
426
+ - Or use `magentrix autopublish` for automatic uploads
427
+
428
+ #### Updating Assets
429
+ 1. Edit or replace the file locally in `src/Contents/Assets/`
430
+ 2. Run `magentrix publish` to upload the updated version
431
+ - Or use `magentrix autopublish` for automatic uploads
432
+
433
+ #### Deleting Assets
434
+ 1. Delete the file from `src/Contents/Assets/`
435
+ 2. Run `magentrix publish` to remove it from the server
436
+
437
+ ### Supported File Types
438
+ The tool supports all file types including:
439
+ - Images: `.png`, `.jpg`, `.jpeg`, `.gif`, `.svg`, `.ico`
440
+ - Stylesheets: `.css`
441
+ - Scripts: `.js`
442
+ - Documents: `.pdf`, `.txt`, `.json`
443
+ - Any other file type you need
444
+
445
+ ### Important Notes
446
+ - Assets are synced alongside code files
447
+ - Folder structures are preserved when syncing
448
+ - Large files are handled efficiently using batch operations
449
+ - Binary files (like images) are fully supported
450
+
451
+ ---
452
+
453
+ ## Deploying Vue.js (Iris) Apps
454
+
455
+ MagentrixCLI supports deploying Vue.js applications (Iris apps) to your Magentrix instance. These apps are built with Vue.js and Module Federation, allowing you to create custom frontend experiences.
456
+
457
+ > **⚠️ CRITICAL: Always use `magentrix iris-app-delete` to remove Iris apps!**
458
+ >
459
+ > Never manually delete folders from `src/iris-apps/`. Manual deletion bypasses backups, leaves orphaned apps on the server, and corrupts the cache. See [Deleting an Iris app](#delete-an-iris-app) for proper deletion.
460
+
461
+ ### Overview
462
+
463
+ The Iris deployment workflow:
464
+ 1. **Link** your Vue project to the CLI
465
+ 2. **Build and stage** the project to the CLI workspace
466
+ 3. **Publish** to Magentrix (automatically handled by `magentrix publish`)
467
+
468
+ ### Commands
469
+
470
+ #### Link a Vue Project
471
+ ```bash
472
+ magentrix iris-app-link
473
+ ```
474
+ **What it does**: Opens an interactive menu to manage linked Vue.js projects. Projects are stored globally so they persist across Magentrix workspaces.
475
+
476
+ **Options:**
477
+ - `--path <dir>` - Specify Vue project path directly
478
+ - `--unlink` - Remove a linked project
479
+ - `--list` - Show all linked projects
480
+ - `--cleanup` - Remove invalid (non-existent) linked projects
481
+
482
+ **Menu options:**
483
+ - Link a Vue project
484
+ - View all linked projects
485
+ - Unlink a project
486
+ - Cleanup invalid projects
487
+
488
+ #### Build and Stage
489
+ ```bash
490
+ magentrix vue-run-build
491
+ ```
492
+ **What it does**: Builds a linked Vue project and copies the output to `src/iris-apps/<slug>/` for publishing.
493
+
494
+ **Two modes of operation:**
495
+
496
+ 1. **From Magentrix workspace**: Prompts for which Vue project to build, stages to current workspace
497
+ 2. **From Vue project directory**: Prompts for which Magentrix workspace to stage into
498
+
499
+ **Options:**
500
+ - `--path <dir>` - Specify Vue project path directly
501
+ - `--skip-build` - Use existing `dist/` folder without rebuilding
502
+ - `--workspace <dir>` - Specify Magentrix workspace path directly (when running from Vue project)
503
+
504
+ **Process:**
505
+ 1. Select from linked projects or enter path manually
506
+ 2. Run `npm run build` in the Vue project
507
+ 3. Validate the build output
508
+ 4. Copy to workspace `src/iris-apps/<app-slug>/` (excludes index.html, favicon.ico)
509
+ 5. Check sync status and prompt to pull if needed (required before publishing)
510
+ 6. Prompt to publish to Magentrix
511
+
512
+ #### Vue Development Server
513
+ ```bash
514
+ magentrix vue-run-dev
515
+ ```
516
+ **What it does**: Starts the Vue development server with platform assets (CSS, fonts) automatically injected from your Magentrix instance.
517
+
518
+ **Authentication**: Uses `VITE_REFRESH_TOKEN` from `.env.development` (no CLI authentication required). This command can be run inside the Vue project directory.
519
+
520
+ **Options:**
521
+ - `--path <dir>` - Specify Vue project path
522
+ - `--no-inject` - Skip asset injection, just run dev server
523
+
524
+ **Process:**
525
+ 1. Fetch platform assets from Magentrix using `.env.development` credentials
526
+ 2. Update `VITE_ASSETS` in `.env.development` (changes are kept)
527
+ 3. Run `npm run dev`
528
+
529
+ #### Delete an Iris App
530
+ ```bash
531
+ magentrix iris-app-delete
532
+ ```
533
+ **What it does**: Safely delete a published Iris app with automatic recovery backup.
534
+
535
+ **Process:**
536
+ 1. Select app from list of published apps
537
+ 2. Show destructive warning
538
+ 3. Confirm by typing exact app slug
539
+ 4. Ask if you want to unlink the Vue project
540
+ 5. Create recovery backup in `.magentrix/iris-backups/`
541
+ 6. Delete from server and local files
542
+ 7. Update cache
543
+
544
+ **Safety features:**
545
+ - Automatic backup before deletion
546
+ - Must type slug name to confirm
547
+ - Recovery possible with `iris-app-recover`
548
+
549
+ #### Recover a Deleted App
550
+ ```bash
551
+ magentrix iris-app-recover
552
+ ```
553
+ **What it does**: Restore a deleted Iris app from automatic backup.
554
+
555
+ **Options:**
556
+ - `--list` - Show all available recovery backups
557
+
558
+ **Process:**
559
+ 1. Select backup to restore (sorted by deletion time)
560
+ 2. Check if linked Vue project still exists
561
+ 3. Restore files to `src/iris-apps/<slug>/`
562
+ 4. Re-link Vue project (if path exists)
563
+ 5. Show warnings for edge cases
564
+ 6. Optionally delete backup after recovery
565
+ 7. Run `magentrix publish` to sync to server
566
+
567
+ ### Vue Project Requirements
568
+
569
+ Your Vue project needs two configuration files:
570
+
571
+ **1. `config.ts`** - App metadata (required):
572
+
573
+ ```typescript
574
+ // src/config.ts
575
+ export const config = {
576
+ appSlug: "my-app", // Required: App identifier (folder name on server)
577
+ appName: "My Application", // Required: Display name in navigation menu
578
+ appDescription: "", // Optional: App description
579
+ appIconId: "", // Optional: App icon ID
580
+ }
581
+ ```
582
+
583
+ **2. `.env.development`** - Environment variables:
584
+
585
+ ```bash
586
+ VITE_SITE_URL = https://yourinstance.magentrix.com
587
+ VITE_REFRESH_TOKEN = your-api-key
588
+ VITE_ASSETS = '[]' # Injected automatically by vue-run-dev
589
+ ```
590
+
591
+ **Accepted field names in config.ts:**
592
+ - Slug: `appSlug`, `slug`, or `app_slug`
593
+ - Name: `appName`, `app_name`, or `name`
594
+ - Description: `appDescription` or `app_description`
595
+ - Icon: `appIconId` or `app_icon_id`
596
+
597
+ #### Changing an App Slug
598
+
599
+ > **⚠️ Important:** Changing the `appSlug`/`slug` in `config.ts` creates a **new** Iris app on Magentrix. The old app is **not** automatically deleted.
600
+
601
+ If you simply change the slug and run `vue-run-build`, you'll end up with two apps on the server - the old one becomes orphaned.
602
+
603
+ **Recommended workflow for changing an app slug:**
604
+
605
+ ```bash
606
+ # 1. Delete the old app first (from Magentrix workspace)
607
+ cd ~/magentrix-workspace
608
+ magentrix iris-app-delete # Select the old app, confirm deletion
609
+ # This removes it from server, local files, and cache
610
+ # Optionally unlink the Vue project when prompted
611
+
612
+ # 2. Change the slug in your Vue project
613
+ cd ~/my-vue-app
614
+ # Edit config.ts: change appSlug from "old-slug" to "new-slug"
615
+
616
+ # 3. Re-link the project with the new slug
617
+ magentrix iris-app-link # Updates the linked project with new slug
618
+
619
+ # 4. Build, stage, and publish
620
+ magentrix vue-run-build # Stages to new folder: src/iris-apps/new-slug/
621
+ # When prompted, choose to publish
622
+ ```
623
+
624
+ **What happens if you don't follow this workflow:**
625
+ - Both `old-slug` and `new-slug` apps will exist on the server
626
+ - The old app remains in `src/iris-apps/old-slug/` locally
627
+ - You'll need to manually delete the old app using `magentrix iris-app-delete`
628
+
629
+ ### Command Availability
630
+
631
+ **In Vue project directories** (detected by presence of `config.ts`):
632
+ - ✓ `magentrix iris-app-link` - Link project to CLI
633
+ - ✓ `magentrix vue-run-build` - Build and stage (prompts for target workspace)
634
+ - ✓ `magentrix vue-run-dev` - Start dev server (uses `.env.development` credentials)
635
+ - ✓ `magentrix update` - Update CLI to latest version
636
+
637
+ **In Magentrix workspace directories** (has `.magentrix/` folder):
638
+ - ✓ All standard commands (`setup`, `pull`, `publish`, etc.)
639
+ - ✓ All Iris commands (`vue-run-build`, `iris-app-delete`, `iris-app-recover`, etc.)
640
+
641
+ **Note**: The `setup` command cannot be run inside a Vue project directory - run it from your Magentrix workspace. Commands like `pull`, `publish`, `autopublish` require a Magentrix workspace.
642
+
643
+ ### Typical Development Workflow
644
+
645
+ ```bash
646
+ # First time setup
647
+ magentrix iris-app-link # Link your Vue project
648
+
649
+ # Development (run from Vue project folder)
650
+ cd ~/my-vue-app # Work from your Vue project
651
+ magentrix vue-run-dev # Start dev server with platform assets
652
+ # Make changes, test locally
653
+ # Press Ctrl+C to stop
654
+
655
+ # Deployment - Option A (from Vue project folder)
656
+ cd ~/my-vue-app # Work from your Vue project
657
+ magentrix vue-run-build # Build and select workspace to stage into
658
+ # Prompted: "Do you want to publish to Magentrix now?" → Yes/No
659
+
660
+ # Deployment - Option B (from Magentrix workspace)
661
+ cd ~/magentrix-workspace # Navigate to Magentrix workspace
662
+ magentrix vue-run-build --path ~/my-vue-app # Build and stage
663
+ # Prompted: "Do you want to publish to Magentrix now?" → Yes/No
664
+ # If autopublish is running, it auto-deploys instead
665
+
666
+ # Deleting an app (from workspace)
667
+ magentrix iris-app-delete # Select app, confirm, auto-backup created
668
+ magentrix publish # Sync deletion to server
669
+
670
+ # Recovering a deleted app (from workspace)
671
+ magentrix iris-app-recover # Select backup, restore files
672
+ magentrix publish # Sync recovery to server
673
+ ```
674
+
675
+ ### Real-Time Deployment
676
+
677
+ For automatic deployment during development:
678
+
679
+ ```bash
680
+ # Terminal 1: Run autopublish
681
+ magentrix autopublish
682
+
683
+ # Terminal 2: Build and stage after making changes
684
+ magentrix vue-run-build
685
+ # Autopublish will detect the changes and upload automatically
686
+ ```
687
+
688
+ ### Troubleshooting Iris Apps
689
+
690
+ #### Running vue-run-build from different locations
691
+
692
+ The `vue-run-build` command works from both locations:
693
+
694
+ **From Vue project directory:**
695
+ ```bash
696
+ cd ~/my-vue-app
697
+ magentrix vue-run-build # Prompts for which workspace to stage into
698
+ ```
699
+
700
+ **From Magentrix workspace:**
701
+ ```bash
702
+ cd ~/magentrix-workspace
703
+ magentrix vue-run-build # Prompts for which Vue project to build
704
+ # Or with path: magentrix vue-run-build --path ~/my-vue-app
705
+ ```
706
+
707
+ #### "No Magentrix workspaces found"
708
+ When running from a Vue project, the command looks for registered workspaces in the global config. To register a workspace:
709
+ 1. Navigate to your Magentrix workspace
710
+ 2. Run `magentrix setup` (this automatically registers it)
711
+ 3. Or specify workspace manually: `magentrix vue-run-build --workspace /path/to/workspace`
712
+
713
+ **Note**: Existing workspaces are auto-registered when you run any command from them.
714
+
715
+ #### "Publishing Iris apps from an out-of-sync workspace is not allowed"
716
+ When running `vue-run-build` from a Vue project, the CLI checks if the target workspace is in sync with the server. If there are pending remote changes, you must pull first.
717
+
718
+ **Why this is required:**
719
+ - Prevents deployment conflicts
720
+ - Ensures your app is deployed alongside the latest server state
721
+ - Avoids overwriting changes made by other team members
722
+
723
+ **To resolve:**
724
+ 1. Navigate to the workspace: `cd /path/to/workspace`
725
+ 2. Pull latest changes: `magentrix pull`
726
+ 3. Re-run `vue-run-build` from your Vue project
727
+
728
+ #### "Missing required field in config.ts: slug (appSlug)"
729
+ Your Vue project's `config.ts` is missing the app identifier. Add an `appSlug` or `slug` field.
730
+
731
+ #### "Missing required field in config.ts: appName"
732
+ Your Vue project's `config.ts` is missing the display name. Add an `appName` field.
733
+
734
+ #### "VITE_SITE_URL not set in .env.development"
735
+ Create a `.env.development` file in your Vue project with `VITE_SITE_URL = https://yourinstance.magentrix.com`.
736
+
737
+ #### "No .env.development file found"
738
+ The CLI requires a `.env.development` file for environment variables. Create one with:
739
+ ```bash
740
+ VITE_SITE_URL = https://yourinstance.magentrix.com
741
+ VITE_REFRESH_TOKEN = your-api-key
742
+ VITE_ASSETS = '[]'
743
+ ```
744
+
745
+ #### "No config.ts found"
746
+ The CLI looks for config in these locations:
747
+ - `src/config.ts`
748
+ - `config.ts`
749
+ - `src/iris-config.ts`
750
+ - `iris-config.ts`
751
+
752
+ #### Deleting an Iris app
753
+ To remove an Iris app:
754
+ ```bash
755
+ magentrix iris-app-delete
756
+ ```
757
+ This creates an automatic recovery backup before deletion. You can restore using `magentrix iris-app-recover`.
758
+
759
+ **Permission errors:**
760
+ If you get "Permission Denied" when deleting local files:
761
+ - The app is still deleted from the server and cache
762
+ - Delete the local folder manually with: `rm -rf src/iris-apps/<app-slug>`
763
+ - Or use sudo: `sudo rm -rf src/iris-apps/<app-slug>`
764
+
765
+ #### Recovering a deleted app
766
+ To restore a deleted Iris app:
767
+ ```bash
768
+ magentrix iris-app-recover --list # See all available backups
769
+ magentrix iris-app-recover # Select and restore a backup
770
+ magentrix publish # Sync to server
771
+ ```
772
+
773
+ **Important**: After recovery, you must run `magentrix publish` to sync the app back to the Magentrix server.
774
+
775
+ #### Changes not detected after vue-run-build
776
+ The CLI uses content hash tracking to detect changes. If you rebuild without changes, `magentrix publish` will show "All files are in sync — nothing to publish!" This is expected behavior and saves unnecessary uploads.
777
+
778
+ #### Duplicate apps after changing slug
779
+ If you changed the `appSlug`/`slug` in `config.ts` and now have two apps on the server:
780
+ 1. The old app is orphaned and needs manual cleanup
781
+ 2. Run `magentrix iris-app-delete` and select the old app to remove it
782
+ 3. See [Changing an App Slug](#changing-an-app-slug) for the proper workflow
783
+
784
+ ---
785
+
786
+ ## Handling Conflicts
787
+
788
+ When files have changed both locally and on the server, you'll see conflict options:
789
+
790
+ ### Option 1: Overwrite Local
791
+ Replaces your local files with server versions (you lose local changes).
792
+
793
+ ### Option 2: Skip Conflicts
794
+ Keeps your local files, ignores server changes.
795
+
796
+ ### Option 3: Manual Review
797
+ Review each conflict individually and choose what to keep.
798
+
799
+ **Tip**: Always run `magentrix pull` before making changes to avoid conflicts.
800
+
801
+ ---
802
+
803
+ ## Common Workflows
804
+
805
+ ### Starting Your Day
806
+ ```bash
807
+ magentrix pull # Get latest files
808
+ magentrix status # Check what's different
809
+ # Work on your files...
810
+ magentrix publish # Upload your changes
811
+ ```
812
+
813
+ ### Real-Time Development
814
+ ```bash
815
+ magentrix pull # Get latest
816
+ magentrix autopublish # Start auto-sync
817
+ # Edit files - they upload automatically when saved
818
+ # Press Ctrl+C to stop auto-sync
819
+ ```
820
+
821
+ ### Creating New Features
822
+ ```bash
823
+ magentrix create # Create new files with wizard
824
+ # Edit the created files...
825
+ magentrix publish # Upload when ready
826
+ ```
827
+
828
+ ### Before Going Home
829
+ ```bash
830
+ magentrix publish # Make sure all changes are uploaded
831
+ magentrix status # Verify everything is in sync
832
+ ```
833
+
834
+ ### Deploying a Vue.js App
835
+
836
+ **Option A: From Vue project folder**
837
+ ```bash
838
+ cd ~/my-vue-app # Navigate to your Vue project
839
+ magentrix iris-app-link # Link project (first time only)
840
+ magentrix vue-run-build # Build and select workspace to stage into
841
+ # Prompted: "Do you want to publish to Magentrix now?" → Yes/No
842
+ ```
843
+
844
+ **Option B: From Magentrix workspace**
845
+ ```bash
846
+ cd ~/magentrix-workspace # Navigate to Magentrix workspace
847
+ magentrix iris-app-link --path ~/my-vue-app # Link project (first time only)
848
+ magentrix vue-run-build --path ~/my-vue-app # Build and stage
849
+ # Prompted: "Do you want to publish to Magentrix now?" (unless autopublish is running)
850
+ ```
851
+
852
+ **Note:** When running from a Vue project, the command prompts you to select a registered workspace. Workspaces are auto-registered when you run any command from them.
853
+
854
+ ### Deleting and Recovering Apps
855
+ ```bash
856
+ # Delete an app (creates automatic backup)
857
+ magentrix iris-app-delete # Select app, confirm deletion
858
+
859
+ # View available backups
860
+ magentrix iris-app-recover --list
861
+
862
+ # Recover a deleted app
863
+ magentrix iris-app-recover # Select backup, restore
864
+ magentrix publish # Sync recovery to server
865
+ ```
866
+
867
+ ---
868
+
869
+ ## Using Git Alongside MagentrixCLI
870
+
871
+ ### Important: Separate Systems
872
+ MagentrixCLI and Git are **completely separate** tools that don't integrate with each other. Here's how to use them together effectively:
873
+
874
+ ### What Each Tool Does
875
+ - **MagentrixCLI**: Syncs your local files with your Magentrix server (for deployment and compilation)
876
+ - **Git**: Tracks your code changes and syncs with your source control repository (for version control and collaboration)
877
+
878
+ ### Recommended Workflow
879
+
880
+ #### 1. Set Up Both Systems
881
+ ```bash
882
+ # Initialize git repository (if not already done)
883
+ git init
884
+ git remote add origin <your-repo-url>
885
+
886
+ # Set up MagentrixCLI
887
+ magentrix setup
888
+ magentrix pull
889
+ ```
890
+
891
+ #### 2. Daily Development Flow
892
+ ```bash
893
+ # Start of day - get latest from both systems
894
+ git pull # Get latest code from repository
895
+ magentrix pull # Get latest files from Magentrix server
896
+
897
+ # Work on your files...
898
+ # Save changes in editor
899
+
900
+ # Commit to git first (for version control)
901
+ git add .
902
+ git commit -m "Your commit message"
903
+ git push # Share with team via git
904
+
905
+ # Then deploy to Magentrix server
906
+ magentrix publish # Deploy to server for testing/production
907
+ ```
908
+
909
+ #### 3. Git Repository Setup
910
+ Add these to your `.gitignore` file:
911
+ ```
912
+ # MagentrixCLI cache files - don't commit these
913
+ .magentrix/
914
+ node_modules/
915
+ ```
916
+
917
+ But **DO commit**:
918
+ ```
919
+ src/ # Your actual code files
920
+ package.json # If you have one
921
+ README.md # Documentation
922
+ ```
923
+
924
+ ### Best Practices
925
+
926
+ #### Use Git for Version Control
927
+ - **Commit often**: Commit logical chunks of work with meaningful messages
928
+ - **Branch for features**: Create branches for new features or major changes
929
+ - **Code reviews**: Use pull requests for team collaboration
930
+
931
+ #### Use MagentrixCLI for Deployment
932
+ - **Test locally first**: Make sure your code works before deploying
933
+ - **Deploy after committing**: Always commit to git before deploying to Magentrix
934
+ - **Use status**: Check `magentrix status` before deploying
935
+
936
+ ### Example Team Workflow
937
+
938
+ #### Developer A
939
+ ```bash
940
+ git checkout -b feature/new-controller
941
+ # Make changes to files
942
+ git add .
943
+ git commit -m "Add new customer controller"
944
+ git push origin feature/new-controller
945
+ # Create pull request
946
+
947
+ # After PR approval and merge:
948
+ git checkout main
949
+ git pull
950
+ magentrix publish # Deploy merged changes
951
+ ```
952
+
953
+ #### Developer B
954
+ ```bash
955
+ git pull # Get A's changes
956
+ magentrix pull # Get any server changes
957
+ # Continue working with latest code
958
+ ```
959
+
960
+ ### Conflict Resolution
961
+
962
+ #### Git Conflicts (Code Level)
963
+ - Resolve using git merge tools
964
+ - Coordinate with teammates
965
+ - Use standard git conflict resolution
966
+
967
+ #### Magentrix Conflicts (Server Level)
968
+ - Use `magentrix status` to identify conflicts
969
+ - Choose resolution strategy (overwrite, skip, manual)
970
+ - Independent of git - handled by MagentrixCLI
971
+
972
+ ### Why Keep Them Separate
973
+ - **Git**: Permanent history, branching, collaboration, code reviews
974
+ - **MagentrixCLI**: Live server deployment, compilation, testing
975
+ - **Different purposes**: Version control vs deployment
976
+ - **Different timing**: Git for development process, MagentrixCLI for deployment
977
+
978
+ This separation gives you the best of both worlds - robust version control AND seamless deployment!
979
+
980
+ ---
981
+
982
+ ## Operation Logs
983
+
984
+ ### About Logs
985
+
986
+ MagentrixCLI can save detailed operation logs to help with debugging and troubleshooting. This is particularly useful when dealing with large projects or investigating sync issues.
987
+
988
+ ### Enabling/Disabling Logs
989
+
990
+ #### First Time Prompt
991
+ The first time you run an operation like `magentrix pull` or `magentrix publish`, you'll be asked:
992
+
993
+ ```
994
+ 📋 Log File Settings
995
+ Magentrix CLI can save detailed operation logs for debugging.
996
+
997
+ ? Would you like to save operation logs to files? (Y/n)
998
+ ```
999
+
1000
+ Your choice is saved globally and applies to all future operations.
1001
+
1002
+ #### Change Settings Later
1003
+ You can change your logging preference at any time:
1004
+
1005
+ ```bash
1006
+ magentrix config
1007
+ ```
1008
+
1009
+ Then select "Log File Settings" from the menu to enable or disable logs.
1010
+
1011
+ ### Log File Location
1012
+
1013
+ When enabled, logs are saved to `.magentrix/logs/` in your project folder:
1014
+
1015
+ ```
1016
+ .magentrix/
1017
+ └── logs/
1018
+ ├── pull-2025-01-15T14-30-45.log
1019
+ ├── publish-2025-01-15T15-12-30.log
1020
+ └── autopublish-2025-01-15T16-00-00.log
1021
+ ```
1022
+
1023
+ ### What Gets Logged
1024
+
1025
+ Operation logs include:
1026
+ - Detailed timestamps for each operation
1027
+ - Warnings about unknown file types or edge cases
1028
+ - Errors with full stack traces
1029
+ - Information about files being processed
1030
+ - API calls and responses
1031
+
1032
+ ### Viewing Logs
1033
+
1034
+ To view a log file:
1035
+
1036
+ ```bash
1037
+ cat .magentrix/logs/pull-2025-01-15T14-30-45.log
1038
+ ```
1039
+
1040
+ Or open it in your text editor.
1041
+
1042
+ ### Log Cleanup
1043
+
1044
+ The CLI automatically keeps only the 10 most recent log files per operation type to prevent disk space issues. Older logs are automatically deleted.
1045
+
1046
+ ---
1047
+
1048
+ ## Troubleshooting
1049
+
1050
+ ### "Authentication failed"
1051
+ - Check your API key is correct
1052
+ - Verify your instance URL is right
1053
+ - Run `magentrix setup` again
1054
+
1055
+ ### "No files found" or empty src folder
1056
+ - Run `magentrix pull` to download files
1057
+ - Check you have permission to access the Magentrix instance
1058
+
1059
+ ### Files not uploading
1060
+ - Check file permissions
1061
+ - Ensure you're in the right directory (where `src` folder is)
1062
+ - Try `magentrix status` to see what's different
1063
+
1064
+ ### "File is currently compiling" message
1065
+ - Wait for the current upload to finish
1066
+ - The tool prevents conflicts by processing one file at a time
1067
+
1068
+ ### Lost connection during autopublish
1069
+ - Press Ctrl+C to stop autopublish
1070
+ - Run `magentrix publish` to upload any remaining changes
1071
+ - Restart with `magentrix autopublish`
1072
+
1073
+ ### Need More Debugging Information
1074
+ - Enable operation logs via `magentrix config`
1075
+ - Run the failing operation again
1076
+ - Check `.magentrix/logs/` for detailed error information
1077
+ - Share log files with your team or support for help
1078
+
1079
+ ---
1080
+
1081
+ ## Tips & Best Practices
1082
+
1083
+ ### 1. Always Pull First
1084
+ Run `magentrix pull` before starting work to get the latest files.
1085
+
1086
+ ### 2. Check Status Before Publishing
1087
+ Use `magentrix status` to see what will change before running `magentrix publish`.
1088
+
1089
+ ### 3. Use Autopublish for Active Development
1090
+ When actively coding, `magentrix autopublish` saves time by auto-uploading changes.
1091
+
1092
+ ### 4. Backup Important Work
1093
+ The tool is reliable, but always have backups of critical code.
1094
+
1095
+ ### 5. Organize Your Workspace
1096
+ Keep your project folder clean and organized. The tool works best with the standard file structure.
1097
+
1098
+ ### 6. Use Descriptive Names
1099
+ When creating new files, use clear, descriptive names that follow your team's naming conventions.
1100
+
1101
+ ---
1102
+
1103
+ ## Configuration Files
1104
+
1105
+ The tool creates these configuration files (you normally don't need to edit them):
1106
+
1107
+ ### Global Settings
1108
+ - **Location**: `~/.config/magentrix/` (Mac/Linux) or `%APPDATA%/magentrix/` (Windows)
1109
+ - **Contains**:
1110
+ - API credentials and connection settings (namespaced by folder hash)
1111
+ - Global preferences like log settings
1112
+ - Multiple instance credentials (each folder has its own credentials)
1113
+
1114
+ ### Project Settings
1115
+ - **Location**: `.magentrix/` folder in your project
1116
+ - **Contains**:
1117
+ - File mappings and sync status
1118
+ - Local cache and operation logs (if enabled)
1119
+ - Base file snapshots for conflict detection
1120
+
1121
+ **Note**: These folders are created automatically. Don't delete them unless you want to reconfigure everything. The global config supports multiple instances by storing credentials per-project folder.
1122
+
1123
+ ---
1124
+
1125
+ ## Getting Help
1126
+
1127
+ ### Built-in Help
1128
+ ```bash
1129
+ magentrix --help # Show all commands
1130
+ magentrix pull --help # Help for specific command
1131
+ ```
1132
+
1133
+ ### Check Your Setup
1134
+ ```bash
1135
+ magentrix # Shows connection status
1136
+ magentrix status # Shows sync status
1137
+ ```
1138
+
1139
+ ### Common Commands Summary
1140
+ - `magentrix setup` - Configure credentials
1141
+ - `magentrix config` - Manage CLI settings
1142
+ - `magentrix pull` - Download files from server
1143
+ - `magentrix publish` - Upload local changes
1144
+ - `magentrix create` - Create new files
1145
+ - `magentrix status` - Check sync status
1146
+ - `magentrix autopublish` - Auto-sync mode
1147
+ - `magentrix update` - Update to latest version
1148
+ - `magentrix iris-app-link` - Link Vue.js projects for deployment
1149
+ - `magentrix vue-run-build` - Build and stage Vue.js apps
1150
+ - `magentrix vue-run-dev` - Start Vue dev server with platform assets
1151
+ - `magentrix iris-app-delete` - Delete an Iris app with recovery backup
1152
+ - `magentrix iris-app-recover` - Recover a deleted Iris app
1153
+
1154
+ ---
1155
+
1156
+ ## What's Next?
1157
+
1158
+ Once you're comfortable with basic usage:
1159
+
1160
+ 1. **Set up your preferred editor** with syntax highlighting for your file types
1161
+ 2. **Learn the autopublish workflow** for faster development
1162
+ 3. **Explore conflict resolution** if you work in a team
1163
+ 4. **Check out templates** created by the `create` command to understand best practices
1164
+ 5. **Deploy Vue.js apps** using `iris-app-link`, `vue-run-build`, and `vue-run-dev` commands
1165
+
1166
+ Happy coding with MagentrixCLI! 🚀