@jxtools/visualgit 1.4.0 → 1.5.0

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +28 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -28,7 +28,7 @@ This opens a browser window with a visual diff between your current branch and i
28
28
  ## Update
29
29
 
30
30
  ```bash
31
- npm update -g @jxtools/visualgit
31
+ visualgit update
32
32
  ```
33
33
 
34
34
  ## Requirements
package/bin/cli.js CHANGED
@@ -3,16 +3,42 @@
3
3
  import { existsSync, readFileSync } from 'fs'
4
4
  import { resolve, dirname } from 'path'
5
5
  import { fileURLToPath } from 'url'
6
- import { spawn } from 'child_process'
6
+ import { spawn, execSync } from 'child_process'
7
7
 
8
8
  const __dirname = dirname(fileURLToPath(import.meta.url))
9
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf-8'))
9
10
 
10
11
  if (process.argv.includes('--version') || process.argv.includes('-v')) {
11
- const pkg = JSON.parse(readFileSync(resolve(__dirname, '..', 'package.json'), 'utf-8'))
12
12
  console.log(`visualgit v${pkg.version}`)
13
13
  process.exit(0)
14
14
  }
15
15
 
16
+ if (process.argv[2] === 'update') {
17
+ const current = pkg.version
18
+ console.log(`\x1b[36m⟳\x1b[0m Current version: v${current}`)
19
+ console.log(` Checking for updates...`)
20
+
21
+ try {
22
+ const latest = execSync('npm view @jxtools/visualgit version', { encoding: 'utf-8' }).trim()
23
+
24
+ if (latest === current) {
25
+ console.log(`\x1b[32m✓\x1b[0m Already on the latest version (v${current})`)
26
+ process.exit(0)
27
+ }
28
+
29
+ console.log(`\x1b[33m↑\x1b[0m New version available: v${latest}`)
30
+ console.log(` Updating...`)
31
+
32
+ execSync('npm install -g @jxtools/visualgit@latest', { stdio: 'inherit' })
33
+ console.log(`\n\x1b[32m✓\x1b[0m Updated to v${latest}`)
34
+ } catch (err) {
35
+ console.error(`\x1b[31m✗\x1b[0m Update failed: ${err.message}`)
36
+ process.exit(1)
37
+ }
38
+
39
+ process.exit(0)
40
+ }
41
+
16
42
  const repoPath = process.cwd()
17
43
  const isGitRepo = existsSync(resolve(repoPath, '.git'))
18
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jxtools/visualgit",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Terminal-style git diff viewer with AI-powered explanations",
5
5
  "type": "module",
6
6
  "bin": {