@magentrix-corp/magentrix-cli 1.3.6 → 1.3.8
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 +16 -1
- package/actions/iris/buildStage.js +37 -23
- package/package.json +1 -1
- package/utils/iris/builder.js +11 -6
package/README.md
CHANGED
|
@@ -505,7 +505,9 @@ magentrix vue-build-stage
|
|
|
505
505
|
1. Select from linked projects or enter path manually
|
|
506
506
|
2. Run `npm run build` in the Vue project
|
|
507
507
|
3. Validate the build output
|
|
508
|
-
4. Copy to workspace `src/iris-apps/<app-slug>/`
|
|
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
|
|
509
511
|
|
|
510
512
|
#### Vue Development Server
|
|
511
513
|
```bash
|
|
@@ -678,6 +680,19 @@ When running from a Vue project, the command looks for registered workspaces in
|
|
|
678
680
|
|
|
679
681
|
**Note**: Existing workspaces are auto-registered when you run any command from them.
|
|
680
682
|
|
|
683
|
+
#### "Publishing Iris apps from an out-of-sync workspace is not allowed"
|
|
684
|
+
When running `vue-build-stage` 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.
|
|
685
|
+
|
|
686
|
+
**Why this is required:**
|
|
687
|
+
- Prevents deployment conflicts
|
|
688
|
+
- Ensures your app is deployed alongside the latest server state
|
|
689
|
+
- Avoids overwriting changes made by other team members
|
|
690
|
+
|
|
691
|
+
**To resolve:**
|
|
692
|
+
1. Navigate to the workspace: `cd /path/to/workspace`
|
|
693
|
+
2. Pull latest changes: `magentrix pull`
|
|
694
|
+
3. Re-run `vue-build-stage` from your Vue project
|
|
695
|
+
|
|
681
696
|
#### "Missing required field in config.ts: slug (appPath)"
|
|
682
697
|
Your Vue project's `config.ts` is missing the app identifier. Add an `appPath` or `slug` field.
|
|
683
698
|
|
|
@@ -398,28 +398,9 @@ async function buildFromVueProject(options) {
|
|
|
398
398
|
console.log(chalk.green('\u2713 Build output validated'));
|
|
399
399
|
}
|
|
400
400
|
|
|
401
|
-
//
|
|
401
|
+
// Check if workspace might be out of sync and offer to pull first (BEFORE staging)
|
|
402
|
+
// This ensures pull doesn't overwrite our staged files
|
|
402
403
|
console.log();
|
|
403
|
-
console.log(chalk.blue(`Staging to workspace: ${workspacePath}`));
|
|
404
|
-
|
|
405
|
-
const stageResult = stageToWorkspace(distPath, slug, workspacePath);
|
|
406
|
-
|
|
407
|
-
if (!stageResult.success) {
|
|
408
|
-
console.log(chalk.red(`Failed to stage: ${stageResult.error}`));
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
console.log(chalk.green(`\u2713 Staged ${stageResult.fileCount} files to ${stageResult.stagedPath}`));
|
|
413
|
-
|
|
414
|
-
// Summary
|
|
415
|
-
console.log();
|
|
416
|
-
console.log(chalk.green('─'.repeat(48)));
|
|
417
|
-
console.log(chalk.green.bold('\u2713 Build & Stage Complete!'));
|
|
418
|
-
console.log();
|
|
419
|
-
console.log(chalk.gray(`Staged to: ${stageResult.stagedPath}`));
|
|
420
|
-
console.log();
|
|
421
|
-
|
|
422
|
-
// Check if workspace might be out of sync and offer to pull first
|
|
423
404
|
console.log(chalk.gray('Checking workspace sync status...'));
|
|
424
405
|
const syncStatus = await checkWorkspaceSyncStatus(workspacePath);
|
|
425
406
|
|
|
@@ -444,7 +425,7 @@ async function buildFromVueProject(options) {
|
|
|
444
425
|
console.log(chalk.yellow('Pull encountered issues. You may want to resolve them manually.'));
|
|
445
426
|
|
|
446
427
|
const continueAnyway = await confirm({
|
|
447
|
-
message: 'Do you still want to continue with publishing?',
|
|
428
|
+
message: 'Do you still want to continue with staging and publishing?',
|
|
448
429
|
default: false
|
|
449
430
|
});
|
|
450
431
|
|
|
@@ -453,16 +434,49 @@ async function buildFromVueProject(options) {
|
|
|
453
434
|
console.log(chalk.cyan('To continue manually:'));
|
|
454
435
|
console.log(chalk.white(` 1. Navigate to workspace: ${chalk.yellow(`cd "${workspacePath}"`)}`));
|
|
455
436
|
console.log(chalk.white(` 2. Run ${chalk.yellow('magentrix pull')} to resolve conflicts`));
|
|
456
|
-
console.log(chalk.white(` 3. Run ${chalk.yellow('magentrix
|
|
437
|
+
console.log(chalk.white(` 3. Run ${chalk.yellow('magentrix vue-build-stage --skip-build')} to stage`));
|
|
438
|
+
console.log(chalk.white(` 4. Run ${chalk.yellow('magentrix publish')} to deploy`));
|
|
457
439
|
return;
|
|
458
440
|
}
|
|
459
441
|
}
|
|
460
442
|
console.log();
|
|
443
|
+
} else {
|
|
444
|
+
// User declined to pull - block publishing from out-of-sync workspace
|
|
445
|
+
console.log();
|
|
446
|
+
console.log(chalk.red('Publishing Iris apps from an out-of-sync workspace is not allowed.'));
|
|
447
|
+
console.log(chalk.gray('This prevents conflicts and ensures your deployment is based on the latest server state.'));
|
|
448
|
+
console.log();
|
|
449
|
+
console.log(chalk.cyan('To continue:'));
|
|
450
|
+
console.log(chalk.white(` 1. Navigate to workspace: ${chalk.yellow(`cd "${workspacePath}"`)}`));
|
|
451
|
+
console.log(chalk.white(` 2. Run ${chalk.yellow('magentrix pull')} to sync with server`));
|
|
452
|
+
console.log(chalk.white(` 3. Run ${chalk.yellow('magentrix publish')} to deploy`));
|
|
453
|
+
return;
|
|
461
454
|
}
|
|
462
455
|
} else if (syncStatus.checked) {
|
|
463
456
|
console.log(chalk.green('✓ Workspace is in sync'));
|
|
464
457
|
}
|
|
465
458
|
|
|
459
|
+
// Stage to selected workspace (AFTER pull to avoid overwriting)
|
|
460
|
+
console.log();
|
|
461
|
+
console.log(chalk.blue(`Staging to workspace: ${workspacePath}`));
|
|
462
|
+
|
|
463
|
+
const stageResult = stageToWorkspace(distPath, slug, workspacePath);
|
|
464
|
+
|
|
465
|
+
if (!stageResult.success) {
|
|
466
|
+
console.log(chalk.red(`Failed to stage: ${stageResult.error}`));
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
console.log(chalk.green(`\u2713 Staged ${stageResult.fileCount} files to ${stageResult.stagedPath}`));
|
|
471
|
+
|
|
472
|
+
// Summary
|
|
473
|
+
console.log();
|
|
474
|
+
console.log(chalk.green('─'.repeat(48)));
|
|
475
|
+
console.log(chalk.green.bold('\u2713 Build & Stage Complete!'));
|
|
476
|
+
console.log();
|
|
477
|
+
console.log(chalk.gray(`Staged to: ${stageResult.stagedPath}`));
|
|
478
|
+
console.log();
|
|
479
|
+
|
|
466
480
|
// Ask if they want to publish now
|
|
467
481
|
const shouldPublish = await confirm({
|
|
468
482
|
message: 'Do you want to publish to Magentrix now?',
|
package/package.json
CHANGED
package/utils/iris/builder.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { existsSync, mkdirSync, cpSync, rmSync, readdirSync } from 'node:fs';
|
|
3
|
-
import { join, resolve } from 'node:path';
|
|
3
|
+
import { join, resolve, basename } from 'node:path';
|
|
4
4
|
import { validateIrisBuild } from './validator.js';
|
|
5
5
|
import { updateLastBuild } from './linker.js';
|
|
6
6
|
import { EXPORT_ROOT, IRIS_APPS_DIR } from '../../vars/global.js';
|
|
7
7
|
|
|
8
|
+
// Files to exclude when staging Iris apps (not needed on server)
|
|
9
|
+
const EXCLUDED_FILES = new Set(['index.html', 'favicon.ico']);
|
|
10
|
+
|
|
8
11
|
/**
|
|
9
12
|
* Build a Vue project using npm run build.
|
|
10
13
|
*
|
|
@@ -176,16 +179,18 @@ export function stageToWorkspace(distPath, slug, workspacePath = process.cwd())
|
|
|
176
179
|
rmSync(targetDir, { recursive: true, force: true });
|
|
177
180
|
}
|
|
178
181
|
|
|
179
|
-
// Files to exclude from staging (not needed for Iris apps)
|
|
180
|
-
const excludeFiles = new Set(['index.html', 'favicon.ico']);
|
|
181
|
-
|
|
182
182
|
// Copy dist contents to target, excluding unnecessary files
|
|
183
183
|
try {
|
|
184
184
|
cpSync(resolvedDistPath, targetDir, {
|
|
185
185
|
recursive: true,
|
|
186
186
|
filter: (src) => {
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
// Use basename for reliable cross-platform filename extraction
|
|
188
|
+
const filename = basename(src);
|
|
189
|
+
// Only exclude specific files, not directories
|
|
190
|
+
if (EXCLUDED_FILES.has(filename)) {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
return true;
|
|
189
194
|
}
|
|
190
195
|
});
|
|
191
196
|
} catch (err) {
|