openclawsetup 2.5.0 → 2.5.1
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/bin/cli.mjs +22 -0
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -1501,6 +1501,28 @@ function askQuestion(prompt) {
|
|
|
1501
1501
|
async function main() {
|
|
1502
1502
|
const options = parseArgs();
|
|
1503
1503
|
|
|
1504
|
+
// 检查是否为最新版本,提示用户更新
|
|
1505
|
+
try {
|
|
1506
|
+
const pkgJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
1507
|
+
const currentVersion = pkgJson.version;
|
|
1508
|
+
const latestResult = safeExec('npm view openclawsetup version 2>/dev/null');
|
|
1509
|
+
if (latestResult.ok && latestResult.output) {
|
|
1510
|
+
const latestVersion = latestResult.output.trim();
|
|
1511
|
+
if (latestVersion && latestVersion !== currentVersion) {
|
|
1512
|
+
console.log(colors.yellow(`\n⚠ 当前版本 ${currentVersion},最新版本 ${latestVersion}`));
|
|
1513
|
+
console.log(colors.yellow(' 正在更新到最新版本...\n'));
|
|
1514
|
+
const updateCmd = platform() === 'win32'
|
|
1515
|
+
? `npx --yes openclawsetup@${latestVersion}`
|
|
1516
|
+
: `npx --yes openclawsetup@${latestVersion}`;
|
|
1517
|
+
spawnSync(updateCmd.split(' ')[0], updateCmd.split(' ').slice(1), {
|
|
1518
|
+
stdio: 'inherit',
|
|
1519
|
+
shell: true,
|
|
1520
|
+
});
|
|
1521
|
+
process.exit(0);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
} catch { /* ignore version check errors */ }
|
|
1525
|
+
|
|
1504
1526
|
if (options.help) {
|
|
1505
1527
|
showHelp();
|
|
1506
1528
|
process.exit(0);
|