@snapcommit/cli 3.9.16 ā 3.9.18
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/dist/commands/cursor-style.js +229 -11
- package/package.json +1 -1
|
@@ -771,9 +771,71 @@ async function executeGitHubCommand(intent) {
|
|
|
771
771
|
case 'new_pr':
|
|
772
772
|
const isDraft = intent.options?.draft || false;
|
|
773
773
|
console.log(chalk_1.default.blue(`\nš Creating ${isDraft ? 'draft ' : ''}PR...`));
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
774
|
+
try {
|
|
775
|
+
const pr = await github.createPullRequest(intent.options || {});
|
|
776
|
+
console.log(chalk_1.default.green(`ā ${isDraft ? 'Draft ' : ''}PR #${pr.number} created`));
|
|
777
|
+
console.log(chalk_1.default.cyan(` ${pr.html_url}\n`));
|
|
778
|
+
}
|
|
779
|
+
catch (error) {
|
|
780
|
+
console.log(chalk_1.default.red('\nā Cannot create PR\n'));
|
|
781
|
+
// Check if it's because we're on main branch
|
|
782
|
+
try {
|
|
783
|
+
const currentBranch = (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD', { encoding: 'utf-8' }).trim();
|
|
784
|
+
const defaultBranch = (0, child_process_1.execSync)('git symbolic-ref refs/remotes/origin/HEAD', { encoding: 'utf-8' }).trim().replace('refs/remotes/origin/', '');
|
|
785
|
+
if (currentBranch === defaultBranch || currentBranch === 'main' || currentBranch === 'master') {
|
|
786
|
+
console.log(chalk_1.default.yellow('ā ļø You\'re on the main branch!\n'));
|
|
787
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
788
|
+
console.log(chalk_1.default.gray(' ⢠PRs merge FROM a feature branch TO main'));
|
|
789
|
+
console.log(chalk_1.default.gray(' ⢠You can\'t create a PR from main to main\n'));
|
|
790
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
791
|
+
console.log(chalk_1.default.white('1. Create a new branch:'));
|
|
792
|
+
console.log(chalk_1.default.cyan(' create a new branch called feature/your-feature\n'));
|
|
793
|
+
console.log(chalk_1.default.white('2. Make your changes'));
|
|
794
|
+
console.log(chalk_1.default.white('3. Commit and push:'));
|
|
795
|
+
console.log(chalk_1.default.cyan(' commit and push changes\n'));
|
|
796
|
+
console.log(chalk_1.default.white('4. Then create PR:'));
|
|
797
|
+
console.log(chalk_1.default.cyan(' create a PR to main\n'));
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
catch (branchError) {
|
|
802
|
+
// If we can't determine branch, show generic error
|
|
803
|
+
}
|
|
804
|
+
// Check if there are no commits to push
|
|
805
|
+
try {
|
|
806
|
+
const commitsAhead = (0, child_process_1.execSync)('git rev-list --count @{u}..HEAD 2>/dev/null || echo 0', { encoding: 'utf-8' }).trim();
|
|
807
|
+
if (commitsAhead === '0') {
|
|
808
|
+
console.log(chalk_1.default.yellow('ā ļø No new commits on this branch!\n'));
|
|
809
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
810
|
+
console.log(chalk_1.default.gray(' ⢠PRs need at least 1 commit that\'s not in main'));
|
|
811
|
+
console.log(chalk_1.default.gray(' ⢠Your branch is identical to main\n'));
|
|
812
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
813
|
+
console.log(chalk_1.default.white('1. Make some changes to your code'));
|
|
814
|
+
console.log(chalk_1.default.white('2. Commit and push:'));
|
|
815
|
+
console.log(chalk_1.default.cyan(' commit and push changes\n'));
|
|
816
|
+
console.log(chalk_1.default.white('3. Then create PR:'));
|
|
817
|
+
console.log(chalk_1.default.cyan(' create a PR to main\n'));
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
catch (commitError) {
|
|
822
|
+
// If we can't check commits, continue to generic error
|
|
823
|
+
}
|
|
824
|
+
// Generic error with helpful message
|
|
825
|
+
console.log(chalk_1.default.white('Common reasons:'));
|
|
826
|
+
console.log(chalk_1.default.gray(' ⢠Branch is up to date with main (no changes)'));
|
|
827
|
+
console.log(chalk_1.default.gray(' ⢠PR already exists for this branch'));
|
|
828
|
+
console.log(chalk_1.default.gray(' ⢠No commits on this branch\n'));
|
|
829
|
+
console.log(chalk_1.default.cyan('š” Try:\n'));
|
|
830
|
+
console.log(chalk_1.default.white('⢠Check existing PRs:'));
|
|
831
|
+
console.log(chalk_1.default.cyan(' show all PRs\n'));
|
|
832
|
+
console.log(chalk_1.default.white('⢠Check your branch:'));
|
|
833
|
+
console.log(chalk_1.default.cyan(' what branch am i on'));
|
|
834
|
+
console.log(chalk_1.default.cyan(' show last 5 commits\n'));
|
|
835
|
+
if (error.message) {
|
|
836
|
+
console.log(chalk_1.default.gray(`\nError: ${error.message}\n`));
|
|
837
|
+
}
|
|
838
|
+
}
|
|
777
839
|
break;
|
|
778
840
|
case 'pr_list':
|
|
779
841
|
case 'list_prs':
|
|
@@ -799,12 +861,73 @@ async function executeGitHubCommand(intent) {
|
|
|
799
861
|
prNumber = await github.findPRNumber('current');
|
|
800
862
|
if (!prNumber) {
|
|
801
863
|
console.log(chalk_1.default.red('\nā No PR found for current branch\n'));
|
|
864
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
865
|
+
console.log(chalk_1.default.gray(' ⢠This branch doesn\'t have an open PR\n'));
|
|
866
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
867
|
+
console.log(chalk_1.default.white('1. Check if a PR exists:'));
|
|
868
|
+
console.log(chalk_1.default.cyan(' show all PRs\n'));
|
|
869
|
+
console.log(chalk_1.default.white('2. Or create a PR first:'));
|
|
870
|
+
console.log(chalk_1.default.cyan(' create a PR to main\n'));
|
|
871
|
+
console.log(chalk_1.default.white('3. Then merge it:'));
|
|
872
|
+
console.log(chalk_1.default.cyan(' merge my PR\n'));
|
|
802
873
|
return;
|
|
803
874
|
}
|
|
804
875
|
}
|
|
805
876
|
console.log(chalk_1.default.blue(`\nš Merging PR #${prNumber}...`));
|
|
806
|
-
|
|
807
|
-
|
|
877
|
+
try {
|
|
878
|
+
await github.mergePullRequest(prNumber);
|
|
879
|
+
console.log(chalk_1.default.green(`ā PR #${prNumber} merged\n`));
|
|
880
|
+
}
|
|
881
|
+
catch (error) {
|
|
882
|
+
console.log(chalk_1.default.red('\nā Cannot merge PR\n'));
|
|
883
|
+
const errorMsg = error.message?.toLowerCase() || '';
|
|
884
|
+
if (errorMsg.includes('not mergeable') || errorMsg.includes('merge conflict')) {
|
|
885
|
+
console.log(chalk_1.default.yellow('ā ļø PR has merge conflicts!\n'));
|
|
886
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
887
|
+
console.log(chalk_1.default.gray(' ⢠Changes in this PR conflict with main branch'));
|
|
888
|
+
console.log(chalk_1.default.gray(' ⢠You need to resolve conflicts first\n'));
|
|
889
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
890
|
+
console.log(chalk_1.default.white('1. Pull latest changes from main:'));
|
|
891
|
+
console.log(chalk_1.default.cyan(' merge main into this branch\n'));
|
|
892
|
+
console.log(chalk_1.default.white('2. SnapCommit will auto-resolve conflicts'));
|
|
893
|
+
console.log(chalk_1.default.white('3. Then try merging PR again:'));
|
|
894
|
+
console.log(chalk_1.default.cyan(' merge my PR\n'));
|
|
895
|
+
}
|
|
896
|
+
else if (errorMsg.includes('required status check') || errorMsg.includes('checks')) {
|
|
897
|
+
console.log(chalk_1.default.yellow('ā ļø CI checks haven\'t passed!\n'));
|
|
898
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
899
|
+
console.log(chalk_1.default.gray(' ⢠GitHub requires all checks to pass before merging'));
|
|
900
|
+
console.log(chalk_1.default.gray(' ⢠Your tests/build might be failing\n'));
|
|
901
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
902
|
+
console.log(chalk_1.default.white('1. Check CI status:'));
|
|
903
|
+
console.log(chalk_1.default.cyan(' check if my build passed\n'));
|
|
904
|
+
console.log(chalk_1.default.white('2. Fix any failing tests'));
|
|
905
|
+
console.log(chalk_1.default.white('3. Push fixes:'));
|
|
906
|
+
console.log(chalk_1.default.cyan(' commit and push changes\n'));
|
|
907
|
+
console.log(chalk_1.default.white('4. Then try merging again'));
|
|
908
|
+
}
|
|
909
|
+
else if (errorMsg.includes('review') || errorMsg.includes('approval')) {
|
|
910
|
+
console.log(chalk_1.default.yellow('ā ļø PR needs approval!\n'));
|
|
911
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
912
|
+
console.log(chalk_1.default.gray(' ⢠Repository requires code review approval'));
|
|
913
|
+
console.log(chalk_1.default.gray(' ⢠You need a teammate to review and approve\n'));
|
|
914
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
915
|
+
console.log(chalk_1.default.white('1. Ask a teammate to review your PR'));
|
|
916
|
+
console.log(chalk_1.default.white('2. Wait for approval'));
|
|
917
|
+
console.log(chalk_1.default.white('3. Then try merging again\n'));
|
|
918
|
+
}
|
|
919
|
+
else {
|
|
920
|
+
console.log(chalk_1.default.white('Common reasons:'));
|
|
921
|
+
console.log(chalk_1.default.gray(' ⢠CI checks still running'));
|
|
922
|
+
console.log(chalk_1.default.gray(' ⢠Required reviews not approved'));
|
|
923
|
+
console.log(chalk_1.default.gray(' ⢠Merge conflicts exist\n'));
|
|
924
|
+
console.log(chalk_1.default.cyan('š” Try:\n'));
|
|
925
|
+
console.log(chalk_1.default.cyan(' check if my build passed\n'));
|
|
926
|
+
if (error.message) {
|
|
927
|
+
console.log(chalk_1.default.gray(`Error: ${error.message}\n`));
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
808
931
|
break;
|
|
809
932
|
case 'ci_check':
|
|
810
933
|
case 'ci_status':
|
|
@@ -817,26 +940,52 @@ async function executeGitHubCommand(intent) {
|
|
|
817
940
|
const totalChecks = ciStatus.checks.length;
|
|
818
941
|
const failedChecks = ciStatus.checks.filter((c) => c.conclusion === 'failure').length;
|
|
819
942
|
if (state === 'success' || (totalChecks > 0 && failedChecks === 0)) {
|
|
820
|
-
console.log(chalk_1.default.green(
|
|
943
|
+
console.log(chalk_1.default.green(`ā
All checks passed (${totalChecks} checks)\n`));
|
|
821
944
|
}
|
|
822
945
|
else if (state === 'pending') {
|
|
823
946
|
console.log(chalk_1.default.yellow(`ā³ Checks running (${totalChecks} checks)\n`));
|
|
947
|
+
console.log(chalk_1.default.gray('š” Wait a few minutes and check again\n'));
|
|
824
948
|
}
|
|
825
949
|
else {
|
|
826
950
|
console.log(chalk_1.default.red(`ā ${failedChecks}/${totalChecks} checks failed\n`));
|
|
951
|
+
console.log(chalk_1.default.white('Why this matters:'));
|
|
952
|
+
console.log(chalk_1.default.gray(' ⢠Failed checks block PR merging'));
|
|
953
|
+
console.log(chalk_1.default.gray(' ⢠Something is broken in your code\n'));
|
|
954
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
955
|
+
console.log(chalk_1.default.white('1. View full details on GitHub:'));
|
|
956
|
+
console.log(chalk_1.default.cyan(' show my PR\n'));
|
|
957
|
+
console.log(chalk_1.default.white('2. Fix the failing tests/build'));
|
|
958
|
+
console.log(chalk_1.default.white('3. Push the fixes:'));
|
|
959
|
+
console.log(chalk_1.default.cyan(' commit and push changes\n'));
|
|
960
|
+
console.log(chalk_1.default.white('4. Check status again:'));
|
|
961
|
+
console.log(chalk_1.default.cyan(' check if my build passed\n'));
|
|
827
962
|
}
|
|
828
963
|
}
|
|
829
964
|
catch (error) {
|
|
830
|
-
console.log(chalk_1.default.gray('
|
|
965
|
+
console.log(chalk_1.default.gray('\nā No CI checks configured\n'));
|
|
966
|
+
console.log(chalk_1.default.white('This is fine! Not all repos need CI.\n'));
|
|
831
967
|
}
|
|
832
968
|
break;
|
|
833
969
|
case 'issue_create':
|
|
834
970
|
case 'create_issue':
|
|
835
971
|
case 'new_issue':
|
|
836
972
|
console.log(chalk_1.default.blue('\nš Creating issue...'));
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
973
|
+
try {
|
|
974
|
+
const issue = await github.createIssue(intent.options || {});
|
|
975
|
+
console.log(chalk_1.default.green(`ā Issue #${issue.number} created`));
|
|
976
|
+
console.log(chalk_1.default.cyan(` ${issue.html_url}\n`));
|
|
977
|
+
}
|
|
978
|
+
catch (error) {
|
|
979
|
+
console.log(chalk_1.default.red('\nā Cannot create issue\n'));
|
|
980
|
+
console.log(chalk_1.default.white('Common reasons:'));
|
|
981
|
+
console.log(chalk_1.default.gray(' ⢠Missing title or description'));
|
|
982
|
+
console.log(chalk_1.default.gray(' ⢠No permission to create issues\n'));
|
|
983
|
+
console.log(chalk_1.default.cyan('š” Try:\n'));
|
|
984
|
+
console.log(chalk_1.default.cyan(' create an issue with title "Bug in login" and description "Users cant login"\n'));
|
|
985
|
+
if (error.message) {
|
|
986
|
+
console.log(chalk_1.default.gray(`Error: ${error.message}\n`));
|
|
987
|
+
}
|
|
988
|
+
}
|
|
840
989
|
break;
|
|
841
990
|
case 'issue_list':
|
|
842
991
|
case 'list_issues':
|
|
@@ -1246,7 +1395,76 @@ async function executeGitHubCommand(intent) {
|
|
|
1246
1395
|
}
|
|
1247
1396
|
}
|
|
1248
1397
|
catch (error) {
|
|
1249
|
-
|
|
1398
|
+
// Intelligent error handling - NEVER show raw API errors
|
|
1399
|
+
const errorMsg = error.message?.toLowerCase() || '';
|
|
1400
|
+
// GitHub authentication errors
|
|
1401
|
+
if (errorMsg.includes('bad credentials') || errorMsg.includes('unauthorized') || errorMsg.includes('401')) {
|
|
1402
|
+
console.log(chalk_1.default.red('\nā GitHub authentication failed\n'));
|
|
1403
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
1404
|
+
console.log(chalk_1.default.gray(' ⢠Your GitHub connection expired'));
|
|
1405
|
+
console.log(chalk_1.default.gray(' ⢠Invalid or revoked access token\n'));
|
|
1406
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
1407
|
+
console.log(chalk_1.default.white('1. Reconnect GitHub:'));
|
|
1408
|
+
console.log(chalk_1.default.cyan(' github connect\n'));
|
|
1409
|
+
console.log(chalk_1.default.white('2. Then try your command again\n'));
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
// Permission errors
|
|
1413
|
+
if (errorMsg.includes('not found') || errorMsg.includes('404')) {
|
|
1414
|
+
console.log(chalk_1.default.red('\nā Repository or resource not found\n'));
|
|
1415
|
+
console.log(chalk_1.default.white('Common reasons:'));
|
|
1416
|
+
console.log(chalk_1.default.gray(' ⢠Repository is private and you don\'t have access'));
|
|
1417
|
+
console.log(chalk_1.default.gray(' ⢠PR/issue number doesn\'t exist'));
|
|
1418
|
+
console.log(chalk_1.default.gray(' ⢠Repository name changed\n'));
|
|
1419
|
+
console.log(chalk_1.default.cyan('š” Try:\n'));
|
|
1420
|
+
console.log(chalk_1.default.white('⢠Check repository access'));
|
|
1421
|
+
console.log(chalk_1.default.white('⢠Verify PR/issue numbers:'));
|
|
1422
|
+
console.log(chalk_1.default.cyan(' show all PRs\n'));
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
// Rate limit errors
|
|
1426
|
+
if (errorMsg.includes('rate limit') || errorMsg.includes('403')) {
|
|
1427
|
+
console.log(chalk_1.default.red('\nā GitHub rate limit exceeded\n'));
|
|
1428
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
1429
|
+
console.log(chalk_1.default.gray(' ⢠Too many API requests in a short time'));
|
|
1430
|
+
console.log(chalk_1.default.gray(' ⢠GitHub limits API calls per hour\n'));
|
|
1431
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
1432
|
+
console.log(chalk_1.default.white('Wait 10-15 minutes and try again'));
|
|
1433
|
+
console.log(chalk_1.default.gray('(Rate limits reset hourly)\n'));
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
// Validation errors
|
|
1437
|
+
if (errorMsg.includes('validation') || errorMsg.includes('invalid')) {
|
|
1438
|
+
console.log(chalk_1.default.red('\nā Invalid input\n'));
|
|
1439
|
+
console.log(chalk_1.default.white('Common reasons:'));
|
|
1440
|
+
console.log(chalk_1.default.gray(' ⢠Missing required information (title, body, etc.)'));
|
|
1441
|
+
console.log(chalk_1.default.gray(' ⢠Invalid format or parameters\n'));
|
|
1442
|
+
console.log(chalk_1.default.cyan('š” Try:\n'));
|
|
1443
|
+
console.log(chalk_1.default.white('Be more specific with your command'));
|
|
1444
|
+
console.log(chalk_1.default.gray('Example: "create a PR with title \'Fix bug\' and description \'Fixes #123\'"\n'));
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
// Network errors
|
|
1448
|
+
if (errorMsg.includes('network') || errorMsg.includes('fetch failed') || errorMsg.includes('econnrefused')) {
|
|
1449
|
+
console.log(chalk_1.default.red('\nā Network error\n'));
|
|
1450
|
+
console.log(chalk_1.default.white('Why this fails:'));
|
|
1451
|
+
console.log(chalk_1.default.gray(' ⢠No internet connection'));
|
|
1452
|
+
console.log(chalk_1.default.gray(' ⢠GitHub API is down (rare)\n'));
|
|
1453
|
+
console.log(chalk_1.default.cyan('š” Here\'s what to do:\n'));
|
|
1454
|
+
console.log(chalk_1.default.white('1. Check your internet connection'));
|
|
1455
|
+
console.log(chalk_1.default.white('2. Try again in a few seconds\n'));
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
// Generic fallback with helpful context
|
|
1459
|
+
console.log(chalk_1.default.red('\nā Command failed\n'));
|
|
1460
|
+
console.log(chalk_1.default.white('What happened:'));
|
|
1461
|
+
console.log(chalk_1.default.gray(` ${error.message}\n`));
|
|
1462
|
+
console.log(chalk_1.default.cyan('š” Try:\n'));
|
|
1463
|
+
console.log(chalk_1.default.white('⢠Check your command:'));
|
|
1464
|
+
console.log(chalk_1.default.cyan(' what branch am i on'));
|
|
1465
|
+
console.log(chalk_1.default.cyan(' show last 5 commits\n'));
|
|
1466
|
+
console.log(chalk_1.default.white('⢠Reconnect GitHub if needed:'));
|
|
1467
|
+
console.log(chalk_1.default.cyan(' github connect\n'));
|
|
1250
1468
|
}
|
|
1251
1469
|
}
|
|
1252
1470
|
/**
|