xgem-cli 2.0.0-alpha.14 → 2.0.0-alpha.15

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/lib/git.sh CHANGED
@@ -33,6 +33,35 @@ _git_base_branch() {
33
33
  return 1
34
34
  }
35
35
 
36
+ _git_resolve_conflicts_help() {
37
+ local files
38
+ files=$(git diff --name-only --diff-filter=U 2>/dev/null)
39
+ if [ -n "$files" ]; then
40
+ log_warn "Files with conflicts:"
41
+ echo "$files" | sed 's/^/ - /'
42
+ fi
43
+ log_warn "Resolve them, then run: git add <files> && git rebase --continue (or give up with: git rebase --abort)"
44
+
45
+ local open_editor
46
+ read -r -p "Do you want to open VS Code to resolve this now? (y/n): " open_editor
47
+ [[ "$open_editor" == "y" || "$open_editor" == "Y" ]] || return 0
48
+
49
+ if has_cmd code; then
50
+ code .
51
+ return 0
52
+ fi
53
+ if [ "$(detect_os)" = "darwin" ]; then
54
+ local app
55
+ for app in "Visual Studio Code" "Visual Studio Code - Insiders"; do
56
+ if [ -d "/Applications/$app.app" ]; then
57
+ open -a "$app" .
58
+ return 0
59
+ fi
60
+ done
61
+ fi
62
+ log_warn "VS Code's 'code' command isn't on your PATH (a shell alias doesn't count — scripts can't see it). In VS Code run Cmd+Shift+P -> 'Shell Command: Install code command in PATH', or open the files above manually."
63
+ }
64
+
36
65
  cmd_git_cmt() {
37
66
  local commit_msg=$1
38
67
  [ -n "$commit_msg" ] || die "Missing commit message!"
@@ -115,9 +144,7 @@ cmd_git_cmt() {
115
144
  log_warn "Your commit is safe locally. Re-run 'xgem git cmt' once connectivity is restored, or push manually: git push $remote_name $current_branch"
116
145
  exit 1
117
146
  fi
118
- local open_editor
119
- read -r -p "Do you want to open VS Code to resolve this now? (y/n): " open_editor
120
- [[ "$open_editor" == "y" || "$open_editor" == "Y" ]] && code .
147
+ _git_resolve_conflicts_help
121
148
  exit 1
122
149
  fi
123
150
 
@@ -386,10 +413,7 @@ cmd_git_sync() {
386
413
  git_dir=$(git rev-parse --git-dir 2>/dev/null)
387
414
  if [ -d "$git_dir/rebase-merge" ] || [ -d "$git_dir/rebase-apply" ]; then
388
415
  log_error "MERGE CONFLICT DETECTED!"
389
- log_warn "Execution paused. Resolve conflicts, then 'git rebase --continue'."
390
- local open_editor
391
- read -r -p "Do you want to open VS Code to resolve this now? (y/n): " open_editor
392
- [[ "$open_editor" == "y" || "$open_editor" == "Y" ]] && code .
416
+ _git_resolve_conflicts_help
393
417
  else
394
418
  log_error "Rebase failed — this looks like a connection problem, not a merge conflict (see the git error above)."
395
419
  fi
package/lib/version.sh CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
  # xgem version info.
3
3
 
4
- XGEM_VERSION="2.0.0-alpha.14"
4
+ XGEM_VERSION="2.0.0-alpha.15"
5
5
 
6
6
  print_version() {
7
7
  echo "xgem $XGEM_VERSION"
package/lib-win/git.js CHANGED
@@ -57,6 +57,24 @@ function baseBranch(remote) {
57
57
  return '';
58
58
  }
59
59
 
60
+ async function resolveConflictsHelp() {
61
+ const files = gitCapture(['diff', '--name-only', '--diff-filter=U']).split(/\r?\n/).filter(Boolean);
62
+ if (files.length) {
63
+ logWarn('Files with conflicts:');
64
+ files.forEach((f) => console.log(` - ${f}`));
65
+ }
66
+ logWarn('Resolve them, then run: git add <files> && git rebase --continue (or give up with: git rebase --abort)');
67
+
68
+ const openEditor = (await prompt('Do you want to open VS Code to resolve this now? (y/n)')).toLowerCase();
69
+ if (openEditor !== 'y') return;
70
+
71
+ if (hasCmd('code')) {
72
+ spawnSync('code', ['.'], { stdio: 'inherit', shell: true });
73
+ } else {
74
+ logWarn("VS Code's 'code' command isn't on your PATH. Reinstall VS Code with 'Add to PATH' enabled, or open the files above manually.");
75
+ }
76
+ }
77
+
60
78
  async function cmdCmt(commitMsg) {
61
79
  if (!commitMsg) die('Missing commit message!');
62
80
 
@@ -131,7 +149,7 @@ async function cmdCmt(commitMsg) {
131
149
  const inConflict = fs.existsSync(path.join(gitDir, 'rebase-merge')) || fs.existsSync(path.join(gitDir, 'rebase-apply'));
132
150
  if (inConflict) {
133
151
  logError('MERGE CONFLICT DETECTED!');
134
- logWarn('Execution paused. Resolve conflicts to proceed.');
152
+ await resolveConflictsHelp();
135
153
  } else {
136
154
  logError(`Could not sync with '${remoteName}' — this looks like a connection problem, not a merge conflict (see the git error above).`);
137
155
  logWarn(`Your commit is safe locally. Re-run 'xgem git cmt' once connectivity is restored, or push manually: git push ${remoteName} ${currentBranch}`);
@@ -369,9 +387,7 @@ async function cmdSync() {
369
387
  const inConflict = fs.existsSync(path.join(gitDir, 'rebase-merge')) || fs.existsSync(path.join(gitDir, 'rebase-apply'));
370
388
  if (inConflict) {
371
389
  logError('MERGE CONFLICT DETECTED!');
372
- logWarn("Execution paused. Resolve conflicts, then 'git rebase --continue'.");
373
- const openEditor = (await prompt('Do you want to open VS Code to resolve this now? (y/n)')).toLowerCase();
374
- if (openEditor === 'y') spawnSync('code', ['.'], { stdio: 'inherit' });
390
+ await resolveConflictsHelp();
375
391
  } else {
376
392
  logError('Rebase failed — this looks like a connection problem, not a merge conflict (see the git error above).');
377
393
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xgem-cli",
3
- "version": "2.0.0-alpha.14",
3
+ "version": "2.0.0-alpha.15",
4
4
  "description": "Framework-aware automation CLI: scaffolds and runs clean/build/dev scripts per project type, an environment doctor, a SwiftPM-aware iOS build engine, and a git workflow helper. Runs natively on macOS, Linux, and Windows.",
5
5
  "bin": {
6
6
  "xgem": "bin/xgem.js"