free-coding-models 0.1.36 → 0.1.37

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.
@@ -102,6 +102,7 @@ function runUpdate(latestVersion) {
102
102
  console.log()
103
103
  console.log(chalk.bold.cyan(' ⬆ Updating free-coding-models to v' + latestVersion + '...'))
104
104
  console.log()
105
+
105
106
  try {
106
107
  // 📖 Force install from npm registry (ignore local cache)
107
108
  // 📖 Use --prefer-online to ensure we get the latest published version
@@ -118,8 +119,37 @@ function runUpdate(latestVersion) {
118
119
  process.exit(0)
119
120
  } catch (err) {
120
121
  console.log()
121
- console.log(chalk.red(' ✖ Update failed. Try manually: npm i -g free-coding-models@' + latestVersion))
122
- console.log()
122
+ // 📖 Check if error is permission-related (EACCES or EPERM)
123
+ const isPermissionError = err.code === 'EACCES' || err.code === 'EPERM' ||
124
+ (err.stderr && (err.stderr.includes('EACCES') || err.stderr.includes('permission') ||
125
+ err.stderr.includes('EACCES'))) ||
126
+ (err.message && (err.message.includes('EACCES') || err.message.includes('permission')))
127
+
128
+ if (isPermissionError) {
129
+ console.log(chalk.yellow(' ⚠️ Permission denied. Retrying with sudo...'))
130
+ console.log()
131
+ try {
132
+ execSync(`sudo npm i -g free-coding-models@${latestVersion} --prefer-online`, { stdio: 'inherit' })
133
+ console.log()
134
+ console.log(chalk.green(' ✅ Update complete with sudo! Version ' + latestVersion + ' installed.'))
135
+ console.log()
136
+ console.log(chalk.dim(' 🔄 Restarting with new version...'))
137
+ console.log()
138
+
139
+ // 📖 Relaunch automatically with the same arguments
140
+ const args = process.argv.slice(2)
141
+ execSync(`node bin/free-coding-models.js ${args.join(' ')}`, { stdio: 'inherit' })
142
+ process.exit(0)
143
+ } catch (sudoErr) {
144
+ console.log()
145
+ console.log(chalk.red(' ✖ Update failed even with sudo. Try manually:'))
146
+ console.log(chalk.dim(' sudo npm i -g free-coding-models@' + latestVersion))
147
+ console.log()
148
+ }
149
+ } else {
150
+ console.log(chalk.red(' ✖ Update failed. Try manually: npm i -g free-coding-models@' + latestVersion))
151
+ console.log()
152
+ }
123
153
  }
124
154
  process.exit(1)
125
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-coding-models",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "description": "Find the fastest coding LLM models in seconds — ping free models from multiple providers, pick the best one for OpenCode, Cursor, or any AI coding assistant.",
5
5
  "keywords": [
6
6
  "nvidia",