@magentrix-corp/magentrix-cli 1.3.5 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/actions/iris/buildStage.js +97 -6
- package/package.json +1 -1
- package/utils/iris/builder.js +11 -2
package/README.md
CHANGED
|
@@ -621,7 +621,7 @@ magentrix run-dev # Start dev server with platform assets
|
|
|
621
621
|
# Deployment - Option A (from Vue project folder)
|
|
622
622
|
cd ~/my-vue-app # Work from your Vue project
|
|
623
623
|
magentrix vue-build-stage # Build and select workspace to stage into
|
|
624
|
-
#
|
|
624
|
+
# Prompted: "Do you want to publish to Magentrix now?" → Yes/No
|
|
625
625
|
|
|
626
626
|
# Deployment - Option B (from Magentrix workspace)
|
|
627
627
|
cd ~/magentrix-workspace # Navigate to Magentrix workspace
|
|
@@ -785,7 +785,7 @@ magentrix status # Verify everything is in sync
|
|
|
785
785
|
cd ~/my-vue-app # Navigate to your Vue project
|
|
786
786
|
magentrix iris-link # Link project (first time only)
|
|
787
787
|
magentrix vue-build-stage # Build and select workspace to stage into
|
|
788
|
-
#
|
|
788
|
+
# Prompted: "Do you want to publish to Magentrix now?" → Yes/No
|
|
789
789
|
```
|
|
790
790
|
|
|
791
791
|
**Option B: From Magentrix workspace**
|
|
@@ -419,6 +419,50 @@ async function buildFromVueProject(options) {
|
|
|
419
419
|
console.log(chalk.gray(`Staged to: ${stageResult.stagedPath}`));
|
|
420
420
|
console.log();
|
|
421
421
|
|
|
422
|
+
// Check if workspace might be out of sync and offer to pull first
|
|
423
|
+
console.log(chalk.gray('Checking workspace sync status...'));
|
|
424
|
+
const syncStatus = await checkWorkspaceSyncStatus(workspacePath);
|
|
425
|
+
|
|
426
|
+
if (syncStatus.needsPull) {
|
|
427
|
+
console.log();
|
|
428
|
+
console.log(chalk.yellow('⚠ Your workspace may be out of sync with the server.'));
|
|
429
|
+
|
|
430
|
+
const shouldPull = await confirm({
|
|
431
|
+
message: 'Would you like to pull latest changes first?',
|
|
432
|
+
default: true
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
if (shouldPull) {
|
|
436
|
+
console.log();
|
|
437
|
+
console.log(chalk.blue('Running pull from workspace...'));
|
|
438
|
+
console.log();
|
|
439
|
+
|
|
440
|
+
const pullSuccess = await runCommandFromWorkspace(workspacePath, 'pull');
|
|
441
|
+
|
|
442
|
+
if (!pullSuccess) {
|
|
443
|
+
console.log();
|
|
444
|
+
console.log(chalk.yellow('Pull encountered issues. You may want to resolve them manually.'));
|
|
445
|
+
|
|
446
|
+
const continueAnyway = await confirm({
|
|
447
|
+
message: 'Do you still want to continue with publishing?',
|
|
448
|
+
default: false
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
if (!continueAnyway) {
|
|
452
|
+
console.log();
|
|
453
|
+
console.log(chalk.cyan('To continue manually:'));
|
|
454
|
+
console.log(chalk.white(` 1. Navigate to workspace: ${chalk.yellow(`cd "${workspacePath}"`)}`));
|
|
455
|
+
console.log(chalk.white(` 2. Run ${chalk.yellow('magentrix pull')} to resolve conflicts`));
|
|
456
|
+
console.log(chalk.white(` 3. Run ${chalk.yellow('magentrix publish')} to deploy`));
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
console.log();
|
|
461
|
+
}
|
|
462
|
+
} else if (syncStatus.checked) {
|
|
463
|
+
console.log(chalk.green('✓ Workspace is in sync'));
|
|
464
|
+
}
|
|
465
|
+
|
|
422
466
|
// Ask if they want to publish now
|
|
423
467
|
const shouldPublish = await confirm({
|
|
424
468
|
message: 'Do you want to publish to Magentrix now?',
|
|
@@ -430,7 +474,7 @@ async function buildFromVueProject(options) {
|
|
|
430
474
|
console.log(chalk.blue('Running publish from workspace...'));
|
|
431
475
|
console.log();
|
|
432
476
|
|
|
433
|
-
const publishSuccess = await
|
|
477
|
+
const publishSuccess = await runCommandFromWorkspace(workspacePath, 'publish');
|
|
434
478
|
|
|
435
479
|
if (!publishSuccess) {
|
|
436
480
|
console.log();
|
|
@@ -448,17 +492,64 @@ async function buildFromVueProject(options) {
|
|
|
448
492
|
}
|
|
449
493
|
|
|
450
494
|
/**
|
|
451
|
-
*
|
|
495
|
+
* Check if a workspace needs to pull (has remote changes or conflicts).
|
|
496
|
+
*
|
|
497
|
+
* @param {string} workspacePath - Path to the Magentrix workspace
|
|
498
|
+
* @returns {Promise<{checked: boolean, needsPull: boolean}>}
|
|
499
|
+
*/
|
|
500
|
+
async function checkWorkspaceSyncStatus(workspacePath) {
|
|
501
|
+
return new Promise((resolvePromise) => {
|
|
502
|
+
const isWindows = process.platform === 'win32';
|
|
503
|
+
const npmCmd = isWindows ? 'npx.cmd' : 'npx';
|
|
504
|
+
|
|
505
|
+
let output = '';
|
|
506
|
+
|
|
507
|
+
const child = spawn(npmCmd, ['magentrix', 'status'], {
|
|
508
|
+
cwd: workspacePath,
|
|
509
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
510
|
+
shell: isWindows
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
child.stdout.on('data', (data) => {
|
|
514
|
+
output += data.toString();
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
child.stderr.on('data', (data) => {
|
|
518
|
+
output += data.toString();
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
child.on('close', (code) => {
|
|
522
|
+
// Check output for signs of remote changes or conflicts
|
|
523
|
+
const lowerOutput = output.toLowerCase();
|
|
524
|
+
const needsPull = lowerOutput.includes('conflict') ||
|
|
525
|
+
lowerOutput.includes('remote') ||
|
|
526
|
+
lowerOutput.includes('server has changes') ||
|
|
527
|
+
lowerOutput.includes('out of sync') ||
|
|
528
|
+
lowerOutput.includes('modified on server');
|
|
529
|
+
|
|
530
|
+
resolvePromise({ checked: code === 0, needsPull });
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
child.on('error', () => {
|
|
534
|
+
// If we can't check, assume it's fine and let them proceed
|
|
535
|
+
resolvePromise({ checked: false, needsPull: false });
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Run a magentrix command from a specific workspace directory.
|
|
452
542
|
*
|
|
453
543
|
* @param {string} workspacePath - Path to the Magentrix workspace
|
|
454
|
-
* @
|
|
544
|
+
* @param {string} command - The magentrix command to run (e.g., 'pull', 'publish')
|
|
545
|
+
* @returns {Promise<boolean>} - True if command succeeded
|
|
455
546
|
*/
|
|
456
|
-
async function
|
|
547
|
+
async function runCommandFromWorkspace(workspacePath, command) {
|
|
457
548
|
return new Promise((resolvePromise) => {
|
|
458
549
|
const isWindows = process.platform === 'win32';
|
|
459
550
|
const npmCmd = isWindows ? 'npx.cmd' : 'npx';
|
|
460
551
|
|
|
461
|
-
const child = spawn(npmCmd, ['magentrix',
|
|
552
|
+
const child = spawn(npmCmd, ['magentrix', command], {
|
|
462
553
|
cwd: workspacePath,
|
|
463
554
|
stdio: 'inherit',
|
|
464
555
|
shell: isWindows
|
|
@@ -469,7 +560,7 @@ async function runPublishFromWorkspace(workspacePath) {
|
|
|
469
560
|
});
|
|
470
561
|
|
|
471
562
|
child.on('error', (err) => {
|
|
472
|
-
console.log(chalk.yellow(`Warning: Could not run
|
|
563
|
+
console.log(chalk.yellow(`Warning: Could not run ${command}: ${err.message}`));
|
|
473
564
|
resolvePromise(false);
|
|
474
565
|
});
|
|
475
566
|
});
|
package/package.json
CHANGED
package/utils/iris/builder.js
CHANGED
|
@@ -176,9 +176,18 @@ export function stageToWorkspace(distPath, slug, workspacePath = process.cwd())
|
|
|
176
176
|
rmSync(targetDir, { recursive: true, force: true });
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
-
//
|
|
179
|
+
// Files to exclude from staging (not needed for Iris apps)
|
|
180
|
+
const excludeFiles = new Set(['index.html', 'favicon.ico']);
|
|
181
|
+
|
|
182
|
+
// Copy dist contents to target, excluding unnecessary files
|
|
180
183
|
try {
|
|
181
|
-
cpSync(resolvedDistPath, targetDir, {
|
|
184
|
+
cpSync(resolvedDistPath, targetDir, {
|
|
185
|
+
recursive: true,
|
|
186
|
+
filter: (src) => {
|
|
187
|
+
const filename = src.split(/[/\\]/).pop();
|
|
188
|
+
return !excludeFiles.has(filename);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
182
191
|
} catch (err) {
|
|
183
192
|
return {
|
|
184
193
|
success: false,
|