codecane 1.0.396 → 1.0.398

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 (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/install.js +51 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codecane",
3
- "version": "1.0.396",
3
+ "version": "1.0.398",
4
4
  "description": "AI dev assistant",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -1,5 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // Force output to show even when npm suppresses stdout
4
+ const originalLog = console.log
5
+ console.log = (...args) => {
6
+ process.stderr.write(args.join(' ') + '\n')
7
+ }
8
+
3
9
  const https = require('https')
4
10
  const fs = require('fs')
5
11
  const path = require('path')
@@ -33,6 +39,7 @@ const manicodeDir = path.join(homeDir, '.config', 'manicode')
33
39
  fs.mkdirSync(manicodeDir, { recursive: true })
34
40
 
35
41
  console.log(`⬇️ Downloading ${file} from GitHub releases...`)
42
+ console.log(`📍 Installing to: ${manicodeDir}`)
36
43
 
37
44
  const request = https.get(url, (res) => {
38
45
  if (res.statusCode === 302 || res.statusCode === 301) {
@@ -54,6 +61,33 @@ function handleResponse(res) {
54
61
  process.exit(1)
55
62
  }
56
63
 
64
+ const totalSize = parseInt(res.headers['content-length'] || '0', 10)
65
+ let downloadedSize = 0
66
+ let lastProgressTime = Date.now()
67
+
68
+ // Show progress for downloads
69
+ const showProgress = (downloaded, total) => {
70
+ const now = Date.now()
71
+ // Update progress every 100ms to avoid too frequent updates
72
+ if (now - lastProgressTime < 100 && downloaded < total) return
73
+ lastProgressTime = now
74
+
75
+ if (total > 0) {
76
+ const percentage = Math.round((downloaded / total) * 100)
77
+ const downloadedMB = (downloaded / 1024 / 1024).toFixed(1)
78
+ const totalMB = (total / 1024 / 1024).toFixed(1)
79
+ process.stderr.write(`\r📥 Downloaded ${downloadedMB}MB / ${totalMB}MB (${percentage}%)`)
80
+ } else {
81
+ const downloadedMB = (downloaded / 1024 / 1024).toFixed(1)
82
+ process.stderr.write(`\r📥 Downloaded ${downloadedMB}MB`)
83
+ }
84
+ }
85
+
86
+ res.on('data', (chunk) => {
87
+ downloadedSize += chunk.length
88
+ showProgress(downloadedSize, totalSize)
89
+ })
90
+
57
91
  if (file.endsWith('.zip')) {
58
92
  // Handle zip files (Windows)
59
93
  const zipPath = path.join(manicodeDir, file)
@@ -62,12 +96,14 @@ function handleResponse(res) {
62
96
  res.pipe(writeStream)
63
97
 
64
98
  writeStream.on('finish', () => {
99
+ process.stderr.write('\n') // New line after progress
100
+ console.log('📦 Extracting...')
65
101
  // Extract zip file
66
102
  const { execSync } = require('child_process')
67
103
  try {
68
104
  execSync(`cd "${manicodeDir}" && unzip -o "${file}"`, { stdio: 'inherit' })
69
105
  fs.unlinkSync(zipPath) // Clean up zip file
70
- console.log('✅ codebuff installed')
106
+ console.log('✅ codebuff installed successfully!')
71
107
  } catch (error) {
72
108
  console.error('❌ Failed to extract zip:', error.message)
73
109
  process.exit(1)
@@ -81,20 +117,22 @@ function handleResponse(res) {
81
117
  res.pipe(zlib.createGunzip())
82
118
  .pipe(tar.extract({ cwd: manicodeDir }))
83
119
  .on('finish', () => {
84
- // Make executable and rename to standard name
85
- const binaryName = platform === 'win32' ? 'codebuff.exe' : 'codebuff'
86
- const extractedBinaryName = platform === 'win32' ? 'codebuff.exe' : 'codebuff'
87
- const binaryPath = path.join(manicodeDir, extractedBinaryName)
88
- const finalBinaryPath = path.join(manicodeDir, binaryName)
120
+ process.stderr.write('\n') // New line after progress
121
+ // The extracted binary will have the platform/arch in the name
122
+ const extractedBinaryName = file.replace('.tar.gz', '').replace('.zip', '')
123
+ const finalBinaryName = platform === 'win32' ? 'codebuff.exe' : 'codebuff'
124
+ const extractedBinaryPath = path.join(manicodeDir, extractedBinaryName)
125
+ const finalBinaryPath = path.join(manicodeDir, finalBinaryName)
89
126
 
90
- if (fs.existsSync(binaryPath)) {
91
- fs.chmodSync(binaryPath, 0o755)
92
- // Rename if necessary (though it should already be the correct name)
93
- if (binaryPath !== finalBinaryPath) {
94
- fs.renameSync(binaryPath, finalBinaryPath)
95
- }
127
+ if (fs.existsSync(extractedBinaryPath)) {
128
+ fs.chmodSync(extractedBinaryPath, 0o755)
129
+ // Rename to the standard name
130
+ fs.renameSync(extractedBinaryPath, finalBinaryPath)
131
+ console.log('✅ codebuff installed successfully!')
132
+ } else {
133
+ console.error(`❌ Binary not found at ${extractedBinaryPath}`)
134
+ process.exit(1)
96
135
  }
97
- console.log('✅ codebuff installed')
98
136
  })
99
137
  .on('error', (err) => {
100
138
  console.error(`❌ Extraction failed: ${err.message}`)