@itd2902/auggw 1.0.6 → 1.0.7
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/index.js +7 -2
- package/src/utils/update.js +24 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,13 +2,15 @@ const { Command } = require('commander');
|
|
|
2
2
|
const loginCommand = require('./commands/login');
|
|
3
3
|
const switchCommand = require('./commands/switch');
|
|
4
4
|
const statusCommand = require('./commands/status');
|
|
5
|
+
const { checkUpdate } = require('./utils/update');
|
|
6
|
+
const pkg = require('../package.json');
|
|
5
7
|
|
|
6
8
|
const program = new Command();
|
|
7
9
|
|
|
8
10
|
program
|
|
9
|
-
.name('auggw')
|
|
11
|
+
.name(Object.keys(pkg.bin)[0] || 'auggw')
|
|
10
12
|
.description('CLI tool for rotating Augment session accounts')
|
|
11
|
-
.version(
|
|
13
|
+
.version(pkg.version);
|
|
12
14
|
|
|
13
15
|
program
|
|
14
16
|
.command('login')
|
|
@@ -27,3 +29,6 @@ program
|
|
|
27
29
|
|
|
28
30
|
program.parse();
|
|
29
31
|
|
|
32
|
+
// Non-blocking update check — runs after command finishes
|
|
33
|
+
checkUpdate();
|
|
34
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const pkg = require("../../package.json");
|
|
2
|
+
|
|
3
|
+
async function checkUpdate() {
|
|
4
|
+
try {
|
|
5
|
+
const resp = await fetch(`https://registry.npmjs.org/${pkg.name}/latest`, {
|
|
6
|
+
signal: AbortSignal.timeout(3000),
|
|
7
|
+
});
|
|
8
|
+
if (!resp.ok) return;
|
|
9
|
+
const data = await resp.json();
|
|
10
|
+
if (data.version && data.version !== pkg.version) {
|
|
11
|
+
const cmd = pkg.name.startsWith("@")
|
|
12
|
+
? `npm i -g ${pkg.name}`
|
|
13
|
+
: `npm i -g ${pkg.name}`;
|
|
14
|
+
console.log(
|
|
15
|
+
`\n\x1b[33m⬆ Update available: ${pkg.version} → ${data.version}\x1b[0m`,
|
|
16
|
+
);
|
|
17
|
+
console.log(` Run: \x1b[36m${cmd}\x1b[0m\n`);
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
// Silently ignore — no network, timeout, etc.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = { checkUpdate };
|