@eldrforge/kodrdriv 1.2.6 → 1.2.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/.kodrdriv-example-branch-targeting.yaml +71 -0
- package/dist/application.js +7 -3
- package/dist/application.js.map +1 -1
- package/dist/arguments.js +49 -7
- package/dist/arguments.js.map +1 -1
- package/dist/commands/development.js +246 -227
- package/dist/commands/development.js.map +1 -1
- package/dist/commands/link.js +64 -4
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/publish.js +232 -47
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/tree.js +262 -31
- package/dist/commands/tree.js.map +1 -1
- package/dist/commands/updates.js +56 -0
- package/dist/commands/updates.js.map +1 -0
- package/dist/constants.js +27 -4
- package/dist/constants.js.map +1 -1
- package/dist/util/general.js +199 -2
- package/dist/util/general.js.map +1 -1
- package/dist/util/github.js +1 -107
- package/dist/util/github.js.map +1 -1
- package/package.json +1 -1
package/dist/commands/tree.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import path__default from 'path';
|
|
3
3
|
import fs__default from 'fs/promises';
|
|
4
4
|
import { exec } from 'child_process';
|
|
5
|
+
import { runSecure } from '../util/child.js';
|
|
5
6
|
import util from 'util';
|
|
6
7
|
import { getLogger } from '../logging.js';
|
|
7
8
|
import { create } from '../util/storage.js';
|
|
@@ -654,16 +655,44 @@ const executePackage = async (packageName, packageInfo, commandToRun, runConfig,
|
|
|
654
655
|
if (hasUpdates) {
|
|
655
656
|
// Commit the dependency updates using kodrdriv commit
|
|
656
657
|
packageLogger.info('Committing inter-project dependency updates...');
|
|
658
|
+
packageLogger.info('⏱️ This step may take a few minutes as it generates a commit message using AI...');
|
|
659
|
+
// Add timeout wrapper around commit execution
|
|
660
|
+
const commitTimeoutMs = 300000; // 5 minutes
|
|
661
|
+
const commitPromise = execute$3({
|
|
662
|
+
...runConfig,
|
|
663
|
+
dryRun: false
|
|
664
|
+
});
|
|
665
|
+
const timeoutPromise = new Promise((_, reject)=>{
|
|
666
|
+
setTimeout(()=>reject(new Error(`Commit operation timed out after ${commitTimeoutMs / 1000} seconds`)), commitTimeoutMs);
|
|
667
|
+
});
|
|
668
|
+
// Add progress indicator
|
|
669
|
+
let progressInterval = null;
|
|
657
670
|
try {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
});
|
|
662
|
-
|
|
671
|
+
// Start progress indicator
|
|
672
|
+
progressInterval = setInterval(()=>{
|
|
673
|
+
packageLogger.info('⏳ Still generating commit message... (this can take 1-3 minutes)');
|
|
674
|
+
}, 30000); // Every 30 seconds
|
|
675
|
+
await Promise.race([
|
|
676
|
+
commitPromise,
|
|
677
|
+
timeoutPromise
|
|
678
|
+
]);
|
|
679
|
+
packageLogger.info('✅ Inter-project dependency updates committed successfully');
|
|
663
680
|
} catch (commitError) {
|
|
664
|
-
|
|
681
|
+
if (commitError.message.includes('timed out')) {
|
|
682
|
+
packageLogger.error(`❌ Commit operation timed out after ${commitTimeoutMs / 1000} seconds`);
|
|
683
|
+
packageLogger.error('This usually indicates an issue with the AI service or very large changes');
|
|
684
|
+
packageLogger.error('You may need to manually commit the dependency updates');
|
|
685
|
+
} else {
|
|
686
|
+
packageLogger.warn(`Failed to commit inter-project dependency updates: ${commitError.message}`);
|
|
687
|
+
}
|
|
665
688
|
// Continue with publish anyway - the updates are still in place
|
|
689
|
+
} finally{
|
|
690
|
+
if (progressInterval) {
|
|
691
|
+
clearInterval(progressInterval);
|
|
692
|
+
}
|
|
666
693
|
}
|
|
694
|
+
} else {
|
|
695
|
+
packageLogger.info('No inter-project dependency updates needed');
|
|
667
696
|
}
|
|
668
697
|
}
|
|
669
698
|
if (runConfig.debug || runConfig.verbose) {
|
|
@@ -682,14 +711,39 @@ const executePackage = async (packageName, packageInfo, commandToRun, runConfig,
|
|
|
682
711
|
if (runConfig.debug) {
|
|
683
712
|
packageLogger.debug(`Shelling out to separate kodrdriv process for ${builtInCommandName} command`);
|
|
684
713
|
}
|
|
714
|
+
// Add progress indication for publish commands
|
|
715
|
+
if (builtInCommandName === 'publish') {
|
|
716
|
+
packageLogger.info('🚀 Starting publish process...');
|
|
717
|
+
packageLogger.info('⏱️ This may take several minutes (AI processing, PR creation, etc.)');
|
|
718
|
+
}
|
|
685
719
|
// Ensure dry-run propagates to subprocess even during overall dry-run mode
|
|
686
720
|
const effectiveCommand = runConfig.dryRun && !commandToRun.includes('--dry-run') ? `${commandToRun} --dry-run` : commandToRun;
|
|
687
|
-
//
|
|
688
|
-
const
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
721
|
+
// Add timeout wrapper for publish commands
|
|
722
|
+
const commandTimeoutMs = 1800000; // 30 minutes for publish commands
|
|
723
|
+
if (builtInCommandName === 'publish') {
|
|
724
|
+
packageLogger.info(`⏰ Setting timeout of ${commandTimeoutMs / 60000} minutes for publish command`);
|
|
725
|
+
}
|
|
726
|
+
const commandPromise = runWithLogging(effectiveCommand, packageLogger, {}, showOutput);
|
|
727
|
+
const commandTimeoutPromise = new Promise((_, reject)=>{
|
|
728
|
+
setTimeout(()=>reject(new Error(`Command timed out after ${commandTimeoutMs / 60000} minutes`)), commandTimeoutMs);
|
|
729
|
+
});
|
|
730
|
+
try {
|
|
731
|
+
const { stdout } = await Promise.race([
|
|
732
|
+
commandPromise,
|
|
733
|
+
commandTimeoutPromise
|
|
734
|
+
]);
|
|
735
|
+
// Detect explicit skip marker from publish to avoid propagating versions
|
|
736
|
+
if (builtInCommandName === 'publish' && stdout && stdout.includes('KODRDRIV_PUBLISH_SKIPPED')) {
|
|
737
|
+
packageLogger.info('Publish skipped for this package; will not record or propagate a version.');
|
|
738
|
+
publishWasSkipped = true;
|
|
739
|
+
}
|
|
740
|
+
} catch (error) {
|
|
741
|
+
if (error.message.includes('timed out')) {
|
|
742
|
+
packageLogger.error(`❌ ${builtInCommandName} command timed out after ${commandTimeoutMs / 60000} minutes`);
|
|
743
|
+
packageLogger.error('This usually indicates the command is stuck waiting for user input or an external service');
|
|
744
|
+
throw error;
|
|
745
|
+
}
|
|
746
|
+
throw error;
|
|
693
747
|
}
|
|
694
748
|
} else {
|
|
695
749
|
// For custom commands, use the existing logic
|
|
@@ -765,12 +819,47 @@ const executePackage = async (packageName, packageInfo, commandToRun, runConfig,
|
|
|
765
819
|
};
|
|
766
820
|
}
|
|
767
821
|
};
|
|
822
|
+
// Add a simple status check function
|
|
823
|
+
const checkTreePublishStatus = async ()=>{
|
|
824
|
+
const logger = getLogger();
|
|
825
|
+
try {
|
|
826
|
+
// Check for running kodrdriv processes
|
|
827
|
+
const { stdout } = await runSecure('ps', [
|
|
828
|
+
'aux'
|
|
829
|
+
], {});
|
|
830
|
+
const kodrdrivProcesses = stdout.split('\n').filter((line)=>line.includes('kodrdriv') && !line.includes('grep') && !line.includes('ps aux') && !line.includes('tree --status') // Exclude the current status command
|
|
831
|
+
);
|
|
832
|
+
if (kodrdrivProcesses.length > 0) {
|
|
833
|
+
logger.info('🔍 Found running kodrdriv processes:');
|
|
834
|
+
kodrdrivProcesses.forEach((process1)=>{
|
|
835
|
+
const parts = process1.trim().split(/\s+/);
|
|
836
|
+
const pid = parts[1];
|
|
837
|
+
const command = parts.slice(10).join(' ');
|
|
838
|
+
logger.info(` PID ${pid}: ${command}`);
|
|
839
|
+
});
|
|
840
|
+
} else {
|
|
841
|
+
logger.info('No kodrdriv processes currently running');
|
|
842
|
+
}
|
|
843
|
+
} catch (error) {
|
|
844
|
+
logger.warn('Could not check process status:', error);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
768
847
|
const execute = async (runConfig)=>{
|
|
769
|
-
var _runConfig_tree, _runConfig_tree1, _runConfig_tree2, _runConfig_tree3, _runConfig_tree4, _runConfig_tree5;
|
|
848
|
+
var _runConfig_tree, _runConfig_tree1, _runConfig_tree2, _runConfig_tree3, _runConfig_tree4, _runConfig_tree5, _runConfig_tree6, _runConfig_tree7;
|
|
770
849
|
const logger = getLogger();
|
|
771
850
|
const isDryRun = runConfig.dryRun || false;
|
|
772
851
|
const isContinue = ((_runConfig_tree = runConfig.tree) === null || _runConfig_tree === void 0 ? void 0 : _runConfig_tree.continue) || false;
|
|
773
852
|
const promotePackage = (_runConfig_tree1 = runConfig.tree) === null || _runConfig_tree1 === void 0 ? void 0 : _runConfig_tree1.promote;
|
|
853
|
+
// Debug logging
|
|
854
|
+
logger.debug('Tree config:', JSON.stringify(runConfig.tree, null, 2));
|
|
855
|
+
logger.debug('Status flag:', (_runConfig_tree2 = runConfig.tree) === null || _runConfig_tree2 === void 0 ? void 0 : _runConfig_tree2.status);
|
|
856
|
+
logger.debug('Full runConfig:', JSON.stringify(runConfig, null, 2));
|
|
857
|
+
// Handle status check
|
|
858
|
+
if ((_runConfig_tree3 = runConfig.tree) === null || _runConfig_tree3 === void 0 ? void 0 : _runConfig_tree3.status) {
|
|
859
|
+
logger.info('🔍 Checking for running kodrdriv processes...');
|
|
860
|
+
await checkTreePublishStatus();
|
|
861
|
+
return 'Status check completed';
|
|
862
|
+
}
|
|
774
863
|
// Handle promote mode
|
|
775
864
|
if (promotePackage) {
|
|
776
865
|
logger.info(`Promoting package '${promotePackage}' to completed status...`);
|
|
@@ -817,7 +906,7 @@ const execute = async (runConfig)=>{
|
|
|
817
906
|
executionContext = null;
|
|
818
907
|
}
|
|
819
908
|
// Check if we're in built-in command mode (tree command with second argument)
|
|
820
|
-
const builtInCommand = (
|
|
909
|
+
const builtInCommand = (_runConfig_tree4 = runConfig.tree) === null || _runConfig_tree4 === void 0 ? void 0 : _runConfig_tree4.builtInCommand;
|
|
821
910
|
const supportedBuiltInCommands = [
|
|
822
911
|
'commit',
|
|
823
912
|
'publish',
|
|
@@ -825,15 +914,17 @@ const execute = async (runConfig)=>{
|
|
|
825
914
|
'unlink',
|
|
826
915
|
'development',
|
|
827
916
|
'branches',
|
|
828
|
-
'run'
|
|
917
|
+
'run',
|
|
918
|
+
'checkout',
|
|
919
|
+
'updates'
|
|
829
920
|
];
|
|
830
921
|
if (builtInCommand && !supportedBuiltInCommands.includes(builtInCommand)) {
|
|
831
922
|
throw new Error(`Unsupported built-in command: ${builtInCommand}. Supported commands: ${supportedBuiltInCommands.join(', ')}`);
|
|
832
923
|
}
|
|
833
924
|
// Handle run subcommand - convert space-separated scripts to npm run commands
|
|
834
925
|
if (builtInCommand === 'run') {
|
|
835
|
-
var
|
|
836
|
-
const packageArgument = (
|
|
926
|
+
var _runConfig_tree8;
|
|
927
|
+
const packageArgument = (_runConfig_tree8 = runConfig.tree) === null || _runConfig_tree8 === void 0 ? void 0 : _runConfig_tree8.packageArgument;
|
|
837
928
|
if (!packageArgument) {
|
|
838
929
|
throw new Error('run subcommand requires script names. Usage: kodrdriv tree run "clean build test"');
|
|
839
930
|
}
|
|
@@ -856,11 +947,11 @@ const execute = async (runConfig)=>{
|
|
|
856
947
|
runConfig.__scriptsToValidate = scripts;
|
|
857
948
|
}
|
|
858
949
|
// Determine the target directories - either specified or current working directory
|
|
859
|
-
const directories = ((
|
|
950
|
+
const directories = ((_runConfig_tree5 = runConfig.tree) === null || _runConfig_tree5 === void 0 ? void 0 : _runConfig_tree5.directories) || [
|
|
860
951
|
process.cwd()
|
|
861
952
|
];
|
|
862
953
|
// Handle link status subcommand
|
|
863
|
-
if (builtInCommand === 'link' && ((
|
|
954
|
+
if (builtInCommand === 'link' && ((_runConfig_tree6 = runConfig.tree) === null || _runConfig_tree6 === void 0 ? void 0 : _runConfig_tree6.packageArgument) === 'status') {
|
|
864
955
|
// For tree link status, we want to show status across all packages
|
|
865
956
|
logger.info(`${isDryRun ? 'DRY RUN: ' : ''}Running link status across workspace...`);
|
|
866
957
|
// Create a config that will be passed to the link command
|
|
@@ -880,7 +971,7 @@ const execute = async (runConfig)=>{
|
|
|
880
971
|
}
|
|
881
972
|
}
|
|
882
973
|
// Handle unlink status subcommand
|
|
883
|
-
if (builtInCommand === 'unlink' && ((
|
|
974
|
+
if (builtInCommand === 'unlink' && ((_runConfig_tree7 = runConfig.tree) === null || _runConfig_tree7 === void 0 ? void 0 : _runConfig_tree7.packageArgument) === 'status') {
|
|
884
975
|
// For tree unlink status, we want to show status across all packages
|
|
885
976
|
logger.info(`${isDryRun ? 'DRY RUN: ' : ''}Running unlink status across workspace...`);
|
|
886
977
|
// Create a config that will be passed to the unlink command
|
|
@@ -905,9 +996,9 @@ const execute = async (runConfig)=>{
|
|
|
905
996
|
logger.info(`${isDryRun ? 'DRY RUN: ' : ''}Analyzing workspaces at: ${directories.join(', ')}`);
|
|
906
997
|
}
|
|
907
998
|
try {
|
|
908
|
-
var
|
|
999
|
+
var _runConfig_tree9, _runConfig_tree10, _runConfig_tree11, _runConfig_tree12;
|
|
909
1000
|
// Get exclusion patterns from config, fallback to empty array
|
|
910
|
-
const excludedPatterns = ((
|
|
1001
|
+
const excludedPatterns = ((_runConfig_tree9 = runConfig.tree) === null || _runConfig_tree9 === void 0 ? void 0 : _runConfig_tree9.exclude) || [];
|
|
911
1002
|
if (excludedPatterns.length > 0) {
|
|
912
1003
|
logger.verbose(`${isDryRun ? 'DRY RUN: ' : ''}Using exclusion patterns: ${excludedPatterns.join(', ')}`);
|
|
913
1004
|
}
|
|
@@ -934,7 +1025,7 @@ const execute = async (runConfig)=>{
|
|
|
934
1025
|
logger.verbose(`${isDryRun ? 'DRY RUN: ' : ''}Determining build order...`);
|
|
935
1026
|
let buildOrder = topologicalSort(dependencyGraph);
|
|
936
1027
|
// Handle start-from functionality if specified
|
|
937
|
-
const startFrom = (
|
|
1028
|
+
const startFrom = (_runConfig_tree10 = runConfig.tree) === null || _runConfig_tree10 === void 0 ? void 0 : _runConfig_tree10.startFrom;
|
|
938
1029
|
if (startFrom) {
|
|
939
1030
|
logger.verbose(`${isDryRun ? 'DRY RUN: ' : ''}Looking for start package: ${startFrom}`);
|
|
940
1031
|
// Resolve the actual package name (can be package name or directory name)
|
|
@@ -991,7 +1082,7 @@ const execute = async (runConfig)=>{
|
|
|
991
1082
|
logger.info(`${isDryRun ? 'DRY RUN: ' : ''}Starting execution from package '${startFrom}' (${buildOrder.length} of ${originalLength} packages remaining).`);
|
|
992
1083
|
}
|
|
993
1084
|
// Handle stop-at functionality if specified
|
|
994
|
-
const stopAt = (
|
|
1085
|
+
const stopAt = (_runConfig_tree11 = runConfig.tree) === null || _runConfig_tree11 === void 0 ? void 0 : _runConfig_tree11.stopAt;
|
|
995
1086
|
if (stopAt) {
|
|
996
1087
|
logger.verbose(`${isDryRun ? 'DRY RUN: ' : ''}Looking for stop package: ${stopAt}`);
|
|
997
1088
|
// Find the package that matches the stopAt directory name
|
|
@@ -1308,6 +1399,146 @@ const execute = async (runConfig)=>{
|
|
|
1308
1399
|
logger.info('');
|
|
1309
1400
|
return `Branch status summary for ${branchInfos.length} packages completed.`;
|
|
1310
1401
|
}
|
|
1402
|
+
// Handle special "checkout" command that switches all packages to specified branch
|
|
1403
|
+
if (builtInCommand === 'checkout') {
|
|
1404
|
+
var _runConfig_tree13;
|
|
1405
|
+
const targetBranch = (_runConfig_tree13 = runConfig.tree) === null || _runConfig_tree13 === void 0 ? void 0 : _runConfig_tree13.packageArgument;
|
|
1406
|
+
if (!targetBranch) {
|
|
1407
|
+
throw new Error('checkout subcommand requires a branch name. Usage: kodrdriv tree checkout <branch-name>');
|
|
1408
|
+
}
|
|
1409
|
+
logger.info(`${isDryRun ? 'DRY RUN: ' : ''}Workspace Checkout to Branch: ${targetBranch}`);
|
|
1410
|
+
logger.info('');
|
|
1411
|
+
// Phase 1: Safety check - scan all packages for uncommitted changes
|
|
1412
|
+
logger.info('🔍 Phase 1: Checking for uncommitted changes across workspace...');
|
|
1413
|
+
const packagesWithChanges = [];
|
|
1414
|
+
for (const packageName of buildOrder){
|
|
1415
|
+
const packageInfo = dependencyGraph.packages.get(packageName);
|
|
1416
|
+
try {
|
|
1417
|
+
const gitStatus = await getGitStatusSummary(packageInfo.path);
|
|
1418
|
+
const hasProblems = gitStatus.hasUncommittedChanges || gitStatus.hasUnstagedFiles;
|
|
1419
|
+
packagesWithChanges.push({
|
|
1420
|
+
name: packageName,
|
|
1421
|
+
path: packageInfo.path,
|
|
1422
|
+
status: gitStatus.status,
|
|
1423
|
+
hasUncommittedChanges: gitStatus.hasUncommittedChanges,
|
|
1424
|
+
hasUnstagedFiles: gitStatus.hasUnstagedFiles
|
|
1425
|
+
});
|
|
1426
|
+
if (hasProblems) {
|
|
1427
|
+
logger.warn(`⚠️ ${packageName}: ${gitStatus.status}`);
|
|
1428
|
+
} else {
|
|
1429
|
+
logger.verbose(`✅ ${packageName}: clean`);
|
|
1430
|
+
}
|
|
1431
|
+
} catch (error) {
|
|
1432
|
+
logger.warn(`❌ ${packageName}: error checking status - ${error.message}`);
|
|
1433
|
+
packagesWithChanges.push({
|
|
1434
|
+
name: packageName,
|
|
1435
|
+
path: packageInfo.path,
|
|
1436
|
+
status: 'error',
|
|
1437
|
+
hasUncommittedChanges: false,
|
|
1438
|
+
hasUnstagedFiles: false
|
|
1439
|
+
});
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
// Check if any packages have uncommitted changes
|
|
1443
|
+
const problemPackages = packagesWithChanges.filter((pkg)=>pkg.hasUncommittedChanges || pkg.hasUnstagedFiles || pkg.status === 'error');
|
|
1444
|
+
if (problemPackages.length > 0) {
|
|
1445
|
+
logger.error(`❌ Cannot proceed with checkout: ${problemPackages.length} packages have uncommitted changes or errors:`);
|
|
1446
|
+
logger.error('');
|
|
1447
|
+
for (const pkg of problemPackages){
|
|
1448
|
+
logger.error(` 📦 ${pkg.name} (${pkg.path}):`);
|
|
1449
|
+
logger.error(` Status: ${pkg.status}`);
|
|
1450
|
+
}
|
|
1451
|
+
logger.error('');
|
|
1452
|
+
logger.error('🔧 To resolve this issue:');
|
|
1453
|
+
logger.error(' 1. Commit or stash changes in the packages listed above');
|
|
1454
|
+
logger.error(' 2. Or use "kodrdriv tree commit" to commit changes across all packages');
|
|
1455
|
+
logger.error(' 3. Then re-run the checkout command');
|
|
1456
|
+
logger.error('');
|
|
1457
|
+
throw new Error(`Workspace checkout blocked: ${problemPackages.length} packages have uncommitted changes`);
|
|
1458
|
+
}
|
|
1459
|
+
logger.info(`✅ Phase 1 complete: All ${packagesWithChanges.length} packages are clean`);
|
|
1460
|
+
logger.info('');
|
|
1461
|
+
// Phase 2: Perform the checkout
|
|
1462
|
+
logger.info(`🔄 Phase 2: Checking out all packages to branch '${targetBranch}'...`);
|
|
1463
|
+
let successCount = 0;
|
|
1464
|
+
const failedPackages = [];
|
|
1465
|
+
for(let i = 0; i < buildOrder.length; i++){
|
|
1466
|
+
const packageName = buildOrder[i];
|
|
1467
|
+
const packageInfo = dependencyGraph.packages.get(packageName);
|
|
1468
|
+
if (isDryRun) {
|
|
1469
|
+
logger.info(`[${i + 1}/${buildOrder.length}] ${packageName}: Would checkout ${targetBranch}`);
|
|
1470
|
+
successCount++;
|
|
1471
|
+
} else {
|
|
1472
|
+
try {
|
|
1473
|
+
const originalCwd = process.cwd();
|
|
1474
|
+
process.chdir(packageInfo.path);
|
|
1475
|
+
try {
|
|
1476
|
+
// Check if target branch exists locally
|
|
1477
|
+
let branchExists = false;
|
|
1478
|
+
try {
|
|
1479
|
+
await runSecure('git', [
|
|
1480
|
+
'rev-parse',
|
|
1481
|
+
'--verify',
|
|
1482
|
+
targetBranch
|
|
1483
|
+
]);
|
|
1484
|
+
branchExists = true;
|
|
1485
|
+
} catch {
|
|
1486
|
+
// Branch doesn't exist locally
|
|
1487
|
+
branchExists = false;
|
|
1488
|
+
}
|
|
1489
|
+
if (branchExists) {
|
|
1490
|
+
await runSecure('git', [
|
|
1491
|
+
'checkout',
|
|
1492
|
+
targetBranch
|
|
1493
|
+
]);
|
|
1494
|
+
logger.info(`[${i + 1}/${buildOrder.length}] ${packageName}: ✅ Checked out ${targetBranch}`);
|
|
1495
|
+
} else {
|
|
1496
|
+
// Try to check out branch from remote
|
|
1497
|
+
try {
|
|
1498
|
+
await runSecure('git', [
|
|
1499
|
+
'checkout',
|
|
1500
|
+
'-b',
|
|
1501
|
+
targetBranch,
|
|
1502
|
+
`origin/${targetBranch}`
|
|
1503
|
+
]);
|
|
1504
|
+
logger.info(`[${i + 1}/${buildOrder.length}] ${packageName}: ✅ Checked out ${targetBranch} from origin`);
|
|
1505
|
+
} catch {
|
|
1506
|
+
// If that fails, create a new branch
|
|
1507
|
+
await runSecure('git', [
|
|
1508
|
+
'checkout',
|
|
1509
|
+
'-b',
|
|
1510
|
+
targetBranch
|
|
1511
|
+
]);
|
|
1512
|
+
logger.info(`[${i + 1}/${buildOrder.length}] ${packageName}: ✅ Created new branch ${targetBranch}`);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
successCount++;
|
|
1516
|
+
} finally{
|
|
1517
|
+
process.chdir(originalCwd);
|
|
1518
|
+
}
|
|
1519
|
+
} catch (error) {
|
|
1520
|
+
logger.error(`[${i + 1}/${buildOrder.length}] ${packageName}: ❌ Failed - ${error.message}`);
|
|
1521
|
+
failedPackages.push({
|
|
1522
|
+
name: packageName,
|
|
1523
|
+
error: error.message
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
// Report results
|
|
1529
|
+
if (failedPackages.length > 0) {
|
|
1530
|
+
logger.error(`❌ Checkout completed with errors: ${successCount}/${buildOrder.length} packages successful`);
|
|
1531
|
+
logger.error('');
|
|
1532
|
+
logger.error('Failed packages:');
|
|
1533
|
+
for (const failed of failedPackages){
|
|
1534
|
+
logger.error(` - ${failed.name}: ${failed.error}`);
|
|
1535
|
+
}
|
|
1536
|
+
throw new Error(`Checkout failed for ${failedPackages.length} packages`);
|
|
1537
|
+
} else {
|
|
1538
|
+
logger.info(`✅ Checkout complete: All ${buildOrder.length} packages successfully checked out to '${targetBranch}'`);
|
|
1539
|
+
return `Workspace checkout complete: ${successCount} packages checked out to '${targetBranch}'`;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1311
1542
|
// Display results
|
|
1312
1543
|
logger.info(`${isDryRun ? 'DRY RUN: ' : ''}Build order determined:`);
|
|
1313
1544
|
let returnOutput = '';
|
|
@@ -1350,12 +1581,12 @@ const execute = async (runConfig)=>{
|
|
|
1350
1581
|
returnOutput = `\nBuild order: ${buildOrder.join(' → ')}\n`;
|
|
1351
1582
|
}
|
|
1352
1583
|
// Execute command if provided (custom command or built-in command)
|
|
1353
|
-
const cmd = (
|
|
1584
|
+
const cmd = (_runConfig_tree12 = runConfig.tree) === null || _runConfig_tree12 === void 0 ? void 0 : _runConfig_tree12.cmd;
|
|
1354
1585
|
// Determine command to execute
|
|
1355
1586
|
let commandToRun;
|
|
1356
1587
|
let isBuiltInCommand = false;
|
|
1357
1588
|
if (builtInCommand) {
|
|
1358
|
-
var
|
|
1589
|
+
var _runConfig_tree14, _runConfig_tree15, _runConfig_tree16;
|
|
1359
1590
|
// Built-in command mode: shell out to kodrdriv subprocess
|
|
1360
1591
|
// Build command with propagated global options
|
|
1361
1592
|
const globalOptions = [];
|
|
@@ -1371,15 +1602,15 @@ const execute = async (runConfig)=>{
|
|
|
1371
1602
|
if (runConfig.preferencesDirectory) globalOptions.push(`--preferences-dir "${runConfig.preferencesDirectory}"`);
|
|
1372
1603
|
// Build the command with global options
|
|
1373
1604
|
const optionsString = globalOptions.length > 0 ? ` ${globalOptions.join(' ')}` : '';
|
|
1374
|
-
// Add package argument for link/unlink commands
|
|
1375
|
-
const packageArg = (
|
|
1376
|
-
const packageArgString = packageArg && (builtInCommand === 'link' || builtInCommand === 'unlink') ? ` "${packageArg}"` : '';
|
|
1605
|
+
// Add package argument for link/unlink/updates commands
|
|
1606
|
+
const packageArg = (_runConfig_tree14 = runConfig.tree) === null || _runConfig_tree14 === void 0 ? void 0 : _runConfig_tree14.packageArgument;
|
|
1607
|
+
const packageArgString = packageArg && (builtInCommand === 'link' || builtInCommand === 'unlink' || builtInCommand === 'updates') ? ` "${packageArg}"` : '';
|
|
1377
1608
|
// Add command-specific options
|
|
1378
1609
|
let commandSpecificOptions = '';
|
|
1379
|
-
if (builtInCommand === 'unlink' && ((
|
|
1610
|
+
if (builtInCommand === 'unlink' && ((_runConfig_tree15 = runConfig.tree) === null || _runConfig_tree15 === void 0 ? void 0 : _runConfig_tree15.cleanNodeModules)) {
|
|
1380
1611
|
commandSpecificOptions += ' --clean-node-modules';
|
|
1381
1612
|
}
|
|
1382
|
-
if ((builtInCommand === 'link' || builtInCommand === 'unlink') && ((
|
|
1613
|
+
if ((builtInCommand === 'link' || builtInCommand === 'unlink') && ((_runConfig_tree16 = runConfig.tree) === null || _runConfig_tree16 === void 0 ? void 0 : _runConfig_tree16.externals) && runConfig.tree.externals.length > 0) {
|
|
1383
1614
|
commandSpecificOptions += ` --externals ${runConfig.tree.externals.join(' ')}`;
|
|
1384
1615
|
}
|
|
1385
1616
|
commandToRun = `kodrdriv ${builtInCommand}${optionsString}${packageArgString}${commandSpecificOptions}`;
|