@snapcommit/cli 3.9.16 → 3.9.17

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.
@@ -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
- const pr = await github.createPullRequest(intent.options || {});
775
- console.log(chalk_1.default.green(`āœ“ ${isDraft ? 'Draft ' : ''}PR #${pr.number} created`));
776
- console.log(chalk_1.default.cyan(` ${pr.html_url}\n`));
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':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapcommit/cli",
3
- "version": "3.9.16",
3
+ "version": "3.9.17",
4
4
  "description": "Instant AI commits. Beautiful progress tracking. Never write commit messages again.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {