ethagent 1.0.5 → 1.0.6
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/package.json +1 -1
- package/src/cli/main.tsx +20 -2
package/package.json
CHANGED
package/src/cli/main.tsx
CHANGED
|
@@ -12,13 +12,29 @@ import { AppInputProvider, useAppInput } from '../app/input/AppInputProvider.js'
|
|
|
12
12
|
import { loadConfig, type EthagentConfig } from '../storage/config.js'
|
|
13
13
|
import { runResetCommand } from './reset.js'
|
|
14
14
|
import { runPreviewCommand } from './preview.js'
|
|
15
|
-
import updateNotifier from 'update-notifier'
|
|
16
15
|
|
|
17
16
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
18
17
|
const pkgPath = path.resolve(__dirname, '..', '..', 'package.json')
|
|
19
18
|
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
async function checkForUpdates() {
|
|
21
|
+
try {
|
|
22
|
+
const res = await fetch('https://registry.npmjs.org/ethagent/latest', { signal: AbortSignal.timeout(1200) })
|
|
23
|
+
const { version: latest } = await res.json() as { version: string }
|
|
24
|
+
if (latest && latest !== pkg.version) {
|
|
25
|
+
const line1 = ` Update available: ${theme.accentPrimary}${pkg.version}${theme.text} -> ${theme.accentMint}${latest}${theme.text} `
|
|
26
|
+
const line2 = ` Run ${theme.accentPeach}npm install -g ethagent${theme.text} to update `
|
|
27
|
+
const border = theme.dim + '─'.repeat(Math.max(line1.length - 20, line2.length - 20) + 10) + theme.text
|
|
28
|
+
|
|
29
|
+
process.stdout.write(`\n${theme.dim}┌${border}┐${theme.text}\n`)
|
|
30
|
+
process.stdout.write(`${theme.dim}│${theme.text} ${line1} ${theme.dim}│${theme.text}\n`)
|
|
31
|
+
process.stdout.write(`${theme.dim}│${theme.text} ${line2} ${theme.dim}│${theme.text}\n`)
|
|
32
|
+
process.stdout.write(`${theme.dim}└${border}┘${theme.text}\n\n`)
|
|
33
|
+
}
|
|
34
|
+
} catch {
|
|
35
|
+
// Silent fail for offline/timeout
|
|
36
|
+
}
|
|
37
|
+
}
|
|
22
38
|
|
|
23
39
|
function readVersion(): string {
|
|
24
40
|
try {
|
|
@@ -153,6 +169,8 @@ async function main(): Promise<number> {
|
|
|
153
169
|
const argv = process.argv.slice(2)
|
|
154
170
|
const [cmd, ...rest] = argv
|
|
155
171
|
|
|
172
|
+
await checkForUpdates()
|
|
173
|
+
|
|
156
174
|
if (!cmd) return runDefault()
|
|
157
175
|
if (cmd === '--version' || cmd === '-v') {
|
|
158
176
|
process.stdout.write(`ethagent ${readVersion()}\n`)
|