@magentrix-corp/magentrix-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +471 -0
  3. package/actions/autopublish.js +283 -0
  4. package/actions/autopublish.old.js +293 -0
  5. package/actions/autopublish.v2.js +447 -0
  6. package/actions/create.js +329 -0
  7. package/actions/help.js +165 -0
  8. package/actions/main.js +81 -0
  9. package/actions/publish.js +567 -0
  10. package/actions/pull.js +139 -0
  11. package/actions/setup.js +61 -0
  12. package/actions/status.js +17 -0
  13. package/bin/magentrix.js +159 -0
  14. package/package.json +61 -0
  15. package/utils/cacher.js +112 -0
  16. package/utils/cli/checkInstanceUrl.js +29 -0
  17. package/utils/cli/helpers/compare.js +281 -0
  18. package/utils/cli/helpers/ensureApiKey.js +57 -0
  19. package/utils/cli/helpers/ensureCredentials.js +60 -0
  20. package/utils/cli/helpers/ensureInstanceUrl.js +63 -0
  21. package/utils/cli/writeRecords.js +223 -0
  22. package/utils/compare.js +135 -0
  23. package/utils/compress.js +18 -0
  24. package/utils/config.js +451 -0
  25. package/utils/diff.js +49 -0
  26. package/utils/downloadAssets.js +75 -0
  27. package/utils/filetag.js +115 -0
  28. package/utils/hash.js +14 -0
  29. package/utils/magentrix/api/assets.js +145 -0
  30. package/utils/magentrix/api/auth.js +56 -0
  31. package/utils/magentrix/api/createEntity.js +61 -0
  32. package/utils/magentrix/api/deleteEntity.js +55 -0
  33. package/utils/magentrix/api/meqlQuery.js +31 -0
  34. package/utils/magentrix/api/retrieveEntity.js +32 -0
  35. package/utils/magentrix/api/updateEntity.js +66 -0
  36. package/utils/magentrix/fetch.js +154 -0
  37. package/utils/merge.js +22 -0
  38. package/utils/preferences.js +40 -0
  39. package/utils/spinner.js +43 -0
  40. package/utils/template.js +52 -0
  41. package/utils/updateFileBase.js +103 -0
  42. package/vars/config.js +1 -0
  43. package/vars/global.js +33 -0
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2025 Magentrix Corporation
2
+
3
+ All rights reserved.
4
+
5
+ This software and associated documentation files (the "Software") are the
6
+ proprietary and confidential information of Magentrix Corporation.
7
+
8
+ Permission is hereby granted to use this Software solely for the purpose of
9
+ interacting with Magentrix services and platforms.
10
+
11
+ RESTRICTIONS:
12
+ - You may NOT redistribute, sublicense, or sell copies of the Software
13
+ - You may NOT modify, merge, or create derivative works from the Software
14
+ - You may NOT use the Software for any purpose other than interacting with
15
+ Magentrix services
16
+ - The Software may only be installed and used in accordance with Magentrix's
17
+ terms of service
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,471 @@
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
+
16
+ ---
17
+
18
+ ## Prerequisites
19
+
20
+ Before you start, make sure you have:
21
+
22
+ 1. **Node.js installed** (version 20 or higher)
23
+ - Download from [nodejs.org](https://nodejs.org/)
24
+ - Verify installation: `node --version`
25
+
26
+ 2. **Access to a Magentrix instance**
27
+ - You need the URL (e.g., `https://yourcompany.magentrixcloud.com`)
28
+
29
+ 3. **API Key from Magentrix**
30
+ - Get this from your Magentrix administrator or system settings
31
+ - It looks like a long string of characters
32
+
33
+ ---
34
+
35
+ ## Installation
36
+
37
+ ### Global Installation (Recommended)
38
+ Install the package globally so you can use it from anywhere:
39
+
40
+ ```bash
41
+ npm install -g @magentrix-corp/magentrix-cli
42
+ ```
43
+
44
+ ### Local Installation (Alternative)
45
+ If you prefer to install it locally in your project:
46
+
47
+ ```bash
48
+ npm install @magentrix-corp/magentrix-cli
49
+ ```
50
+
51
+ Then run commands using:
52
+ ```bash
53
+ npx magentrix <command>
54
+ ```
55
+
56
+ ### Verify Installation
57
+ Check that the installation worked:
58
+ ```bash
59
+ magentrix --version
60
+ ```
61
+
62
+ You should see the version number displayed.
63
+
64
+ ---
65
+
66
+ ## First Time Setup
67
+
68
+ ### Step 1: Configure Your Credentials
69
+ Run this command to set up your connection to Magentrix:
70
+
71
+ ```bash
72
+ magentrix setup
73
+ ```
74
+
75
+ You'll be prompted for:
76
+ - **API Key**: Paste your Magentrix API key
77
+ - **Instance URL**: Enter your Magentrix URL (like `https://yourcompany.magentrixcloud.com`)
78
+
79
+ 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).
80
+
81
+ ### Editor Support
82
+ - **VS Code (Recommended)**: The tool automatically sets up syntax highlighting for all Magentrix file types during setup
83
+ - **Other Editors**: The tool works with any text editor (Sublime Text, Atom, Vim, etc.) but you'll need to configure syntax highlighting manually
84
+ - **Terminal Only**: You can use the tool entirely from the command line without any editor
85
+
86
+ ### Step 2: Download Your Files
87
+ Pull all your existing files from Magentrix:
88
+
89
+ ```bash
90
+ magentrix pull
91
+ ```
92
+
93
+ This creates a `src` folder with all your files organized into:
94
+ - `Classes/` - Your utility classes (`.ac` files)
95
+ - `Controllers/` - Your controllers (`.ctrl` files)
96
+ - `Triggers/` - Your trigger code (`.trigger` files)
97
+ - `Pages/` - Your ASPX pages (`.aspx` files)
98
+ - `Templates/` - Your templates (`.aspx` files)
99
+
100
+ ---
101
+
102
+ ## Daily Usage
103
+
104
+ ### Check Connection Status
105
+ ```bash
106
+ magentrix
107
+ ```
108
+ **What it does**: Displays your current connection status, API key (masked), and Magentrix instance URL.
109
+ **When to use**: Quick check to verify you're properly authenticated and connected to the right instance.
110
+
111
+ ### Download Latest Files from Server
112
+ ```bash
113
+ magentrix pull
114
+ ```
115
+ **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.
116
+ **When to use**:
117
+ - Start of your workday to get latest changes
118
+ - Before making major changes to avoid conflicts
119
+ - When teammates have made server changes you need
120
+
121
+ ### Check Status and Conflicts
122
+ ```bash
123
+ magentrix status
124
+ ```
125
+ **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.
126
+ **When to use**:
127
+ - Before running `publish` to see what will be uploaded
128
+ - To check for conflicts without downloading anything
129
+ - To verify your local workspace is in sync with server
130
+
131
+ ### Upload Your Changes to Server
132
+ ```bash
133
+ magentrix publish
134
+ ```
135
+ **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.
136
+ **When to use**:
137
+ - After you've finished making changes and want to deploy them
138
+ - At the end of your work session
139
+ - When you want to share your changes with teammates
140
+
141
+ ### Real-Time Development Mode
142
+ ```bash
143
+ magentrix autopublish
144
+ ```
145
+ **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. Can take some time to sync each file.
146
+ **When to use**:
147
+ - During active development when you want immediate feedback
148
+ - When testing changes and want to see results right away
149
+ - For iterative development where you're making frequent small changes
150
+ **Note**: Best for real-time development but slower than batch publishing. Press Ctrl+C to stop.
151
+
152
+ ---
153
+
154
+ ## Creating New Files
155
+
156
+ ### Interactive File Creation
157
+ ```bash
158
+ magentrix create
159
+ ```
160
+
161
+ This starts an interactive wizard:
162
+
163
+ 1. **Choose what to create:**
164
+ - ActiveClass (for Controllers, Classes, or Triggers)
165
+ - ActivePage (for Pages or Templates)
166
+
167
+ 2. **For Classes/Controllers/Triggers:**
168
+ - Select the type (Controller, Class, or Trigger)
169
+ - Enter the name
170
+ - Add optional description
171
+ - For Triggers: Search and select the target entity
172
+
173
+ 3. **For Pages/Templates:**
174
+ - Choose Page or Template
175
+ - Enter the name
176
+ - Add optional description
177
+
178
+ The tool creates the file both locally and on your Magentrix server with proper templates.
179
+
180
+ ---
181
+
182
+ ## Working with Files
183
+
184
+ ### File Organization
185
+ Your files are organized like this:
186
+ ```
187
+ src/
188
+ ├── Classes/ # Utility classes (*.ac files)
189
+ ├── Controllers/ # Controllers (*.ctrl files)
190
+ ├── Triggers/ # Trigger code (*.trigger files)
191
+ ├── Pages/ # ASPX pages (*.aspx files)
192
+ └── Templates/ # Templates (*.aspx files)
193
+ ```
194
+
195
+ ### File Extensions
196
+ - `.ac` - Classes
197
+ - `.ctrl` - Controllers
198
+ - `.trigger` - Triggers
199
+ - `.aspx` - Pages and Templates
200
+
201
+ ### Editing Files
202
+ 1. Open any file in your favorite editor (VS Code, Sublime, etc.)
203
+ 2. Make your changes
204
+ 3. Save the file
205
+ 4. Run `magentrix publish` to upload changes
206
+ - Or use `magentrix autopublish` for automatic uploads
207
+
208
+ ---
209
+
210
+ ## Handling Conflicts
211
+
212
+ When files have changed both locally and on the server, you'll see conflict options:
213
+
214
+ ### Option 1: Overwrite Local
215
+ Replaces your local files with server versions (you lose local changes).
216
+
217
+ ### Option 2: Skip Conflicts
218
+ Keeps your local files, ignores server changes.
219
+
220
+ ### Option 3: Manual Review
221
+ Review each conflict individually and choose what to keep.
222
+
223
+ **Tip**: Always run `magentrix pull` before making changes to avoid conflicts.
224
+
225
+ ---
226
+
227
+ ## Common Workflows
228
+
229
+ ### Starting Your Day
230
+ ```bash
231
+ magentrix pull # Get latest files
232
+ magentrix status # Check what's different
233
+ # Work on your files...
234
+ magentrix publish # Upload your changes
235
+ ```
236
+
237
+ ### Real-Time Development
238
+ ```bash
239
+ magentrix pull # Get latest
240
+ magentrix autopublish # Start auto-sync
241
+ # Edit files - they upload automatically when saved
242
+ # Press Ctrl+C to stop auto-sync
243
+ ```
244
+
245
+ ### Creating New Features
246
+ ```bash
247
+ magentrix create # Create new files with wizard
248
+ # Edit the created files...
249
+ magentrix publish # Upload when ready
250
+ ```
251
+
252
+ ### Before Going Home
253
+ ```bash
254
+ magentrix publish # Make sure all changes are uploaded
255
+ magentrix status # Verify everything is in sync
256
+ ```
257
+
258
+ ---
259
+
260
+ ## Using Git Alongside MagentrixCLI
261
+
262
+ ### Important: Separate Systems
263
+ MagentrixCLI and Git are **completely separate** tools that don't integrate with each other. Here's how to use them together effectively:
264
+
265
+ ### What Each Tool Does
266
+ - **MagentrixCLI**: Syncs your local files with your Magentrix server (for deployment and compilation)
267
+ - **Git**: Tracks your code changes and syncs with your source control repository (for version control and collaboration)
268
+
269
+ ### Recommended Workflow
270
+
271
+ #### 1. Set Up Both Systems
272
+ ```bash
273
+ # Initialize git repository (if not already done)
274
+ git init
275
+ git remote add origin <your-repo-url>
276
+
277
+ # Set up MagentrixCLI
278
+ magentrix setup
279
+ magentrix pull
280
+ ```
281
+
282
+ #### 2. Daily Development Flow
283
+ ```bash
284
+ # Start of day - get latest from both systems
285
+ git pull # Get latest code from repository
286
+ magentrix pull # Get latest files from Magentrix server
287
+
288
+ # Work on your files...
289
+ # Save changes in editor
290
+
291
+ # Commit to git first (for version control)
292
+ git add .
293
+ git commit -m "Your commit message"
294
+ git push # Share with team via git
295
+
296
+ # Then deploy to Magentrix server
297
+ magentrix publish # Deploy to server for testing/production
298
+ ```
299
+
300
+ #### 3. Git Repository Setup
301
+ Add these to your `.gitignore` file:
302
+ ```
303
+ # MagentrixCLI cache files - don't commit these
304
+ .magentrix/
305
+ node_modules/
306
+ ```
307
+
308
+ But **DO commit**:
309
+ ```
310
+ src/ # Your actual code files
311
+ package.json # If you have one
312
+ README.md # Documentation
313
+ ```
314
+
315
+ ### Best Practices
316
+
317
+ #### Use Git for Version Control
318
+ - **Commit often**: Commit logical chunks of work with meaningful messages
319
+ - **Branch for features**: Create branches for new features or major changes
320
+ - **Code reviews**: Use pull requests for team collaboration
321
+
322
+ #### Use MagentrixCLI for Deployment
323
+ - **Test locally first**: Make sure your code works before deploying
324
+ - **Deploy after committing**: Always commit to git before deploying to Magentrix
325
+ - **Use status**: Check `magentrix status` before deploying
326
+
327
+ ### Example Team Workflow
328
+
329
+ #### Developer A
330
+ ```bash
331
+ git checkout -b feature/new-controller
332
+ # Make changes to files
333
+ git add .
334
+ git commit -m "Add new customer controller"
335
+ git push origin feature/new-controller
336
+ # Create pull request
337
+
338
+ # After PR approval and merge:
339
+ git checkout main
340
+ git pull
341
+ magentrix publish # Deploy merged changes
342
+ ```
343
+
344
+ #### Developer B
345
+ ```bash
346
+ git pull # Get A's changes
347
+ magentrix pull # Get any server changes
348
+ # Continue working with latest code
349
+ ```
350
+
351
+ ### Conflict Resolution
352
+
353
+ #### Git Conflicts (Code Level)
354
+ - Resolve using git merge tools
355
+ - Coordinate with teammates
356
+ - Use standard git conflict resolution
357
+
358
+ #### Magentrix Conflicts (Server Level)
359
+ - Use `magentrix status` to identify conflicts
360
+ - Choose resolution strategy (overwrite, skip, manual)
361
+ - Independent of git - handled by MagentrixCLI
362
+
363
+ ### Why Keep Them Separate
364
+ - **Git**: Permanent history, branching, collaboration, code reviews
365
+ - **MagentrixCLI**: Live server deployment, compilation, testing
366
+ - **Different purposes**: Version control vs deployment
367
+ - **Different timing**: Git for development process, MagentrixCLI for deployment
368
+
369
+ This separation gives you the best of both worlds - robust version control AND seamless deployment!
370
+
371
+ ---
372
+
373
+ ## Troubleshooting
374
+
375
+ ### "Authentication failed"
376
+ - Check your API key is correct
377
+ - Verify your instance URL is right
378
+ - Run `magentrix setup` again
379
+
380
+ ### "No files found" or empty src folder
381
+ - Run `magentrix pull` to download files
382
+ - Check you have permission to access the Magentrix instance
383
+
384
+ ### Files not uploading
385
+ - Check file permissions
386
+ - Ensure you're in the right directory (where `src` folder is)
387
+ - Try `magentrix status` to see what's different
388
+
389
+ ### "File is currently compiling" message
390
+ - Wait for the current upload to finish
391
+ - The tool prevents conflicts by processing one file at a time
392
+
393
+ ### Lost connection during autopublish
394
+ - Press Ctrl+C to stop autopublish
395
+ - Run `magentrix publish` to upload any remaining changes
396
+ - Restart with `magentrix autopublish`
397
+
398
+ ---
399
+
400
+ ## Tips & Best Practices
401
+
402
+ ### 1. Always Pull First
403
+ Run `magentrix pull` before starting work to get the latest files.
404
+
405
+ ### 2. Check Status Before Publishing
406
+ Use `magentrix status` to see what will change before running `magentrix publish`.
407
+
408
+ ### 3. Use Autopublish for Active Development
409
+ When actively coding, `magentrix autopublish` saves time by auto-uploading changes.
410
+
411
+ ### 4. Backup Important Work
412
+ The tool is reliable, but always have backups of critical code.
413
+
414
+ ### 5. Organize Your Workspace
415
+ Keep your project folder clean and organized. The tool works best with the standard file structure.
416
+
417
+ ### 6. Use Descriptive Names
418
+ When creating new files, use clear, descriptive names that follow your team's naming conventions.
419
+
420
+ ---
421
+
422
+ ## Configuration Files
423
+
424
+ The tool creates these configuration files (you normally don't need to edit them):
425
+
426
+ ### Global Settings
427
+ - **Location**: `~/.config/magentrix/` (Mac/Linux) or `%APPDATA%/magentrix/` (Windows)
428
+ - **Contains**: Your API credentials and connection settings
429
+
430
+ ### Project Settings
431
+ - **Location**: `.magentrix/` folder in your project
432
+ - **Contains**: File mappings, sync status, and local cache
433
+
434
+ **Note**: These folders are created automatically. Don't delete them unless you want to reconfigure everything.
435
+
436
+ ---
437
+
438
+ ## Getting Help
439
+
440
+ ### Built-in Help
441
+ ```bash
442
+ magentrix --help # Show all commands
443
+ magentrix pull --help # Help for specific command
444
+ ```
445
+
446
+ ### Check Your Setup
447
+ ```bash
448
+ magentrix # Shows connection status
449
+ magentrix status # Shows sync status
450
+ ```
451
+
452
+ ### Common Commands Summary
453
+ - `magentrix setup` - Configure credentials
454
+ - `magentrix pull` - Download files from server
455
+ - `magentrix publish` - Upload local changes
456
+ - `magentrix create` - Create new files
457
+ - `magentrix status` - Check sync status
458
+ - `magentrix autopublish` - Auto-sync mode
459
+
460
+ ---
461
+
462
+ ## What's Next?
463
+
464
+ Once you're comfortable with basic usage:
465
+
466
+ 1. **Set up your preferred editor** with syntax highlighting for your file types
467
+ 2. **Learn the autopublish workflow** for faster development
468
+ 3. **Explore conflict resolution** if you work in a team
469
+ 4. **Check out templates** created by the `create` command to understand best practices
470
+
471
+ Happy coding with MagentrixCLI! 🚀