Lines 562-602javascript
562 const basePath = isCompiled ? path_1.default.join(__dirname, '..') : __dirname;
563 const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(basePath, 'package.json'), 'utf-8'));
564 const currentVersion = pkg.version;
565 const res = await fetch(`https://registry.npmjs.org/${NPM_PACKAGE_NAME}/latest`, { signal: AbortSignal.timeout(2000) });
566 const data = await res.json();
567 const latestVersion = data.version;
568 if (latestVersion && latestVersion !== currentVersion) {
569 (0, ui_1.clearScreen)();
570 console.log(chalk_1.default.yellow('╭─────────────────────────────────────────────────────────────╮'));
571 console.log(chalk_1.default.yellow('│ │'));
572 console.log(chalk_1.default.yellow(`│ NEKOSTREAM ĐÃ CÓ CẬP NHẬT MỚI ! ${chalk_1.default.red(currentVersion)} → ${chalk_1.default.green(latestVersion)} │`));
573 console.log(chalk_1.default.yellow('│ Vui lòng cập nhật ứng dụng CLI để tiếp tục sử dụng ứng dụng. │'));
574 console.log(chalk_1.default.yellow('│ │'));
575 console.log(chalk_1.default.yellow('╰─────────────────────────────────────────────────────────────╯\n'));
576 const { update } = await (0, prompts_wrapper_1.default)({
579 message: 'Bạn có muốn tự động cập nhật ngay bây giờ?',
583 const installCommand = `npm i -g ${NPM_PACKAGE_NAME}@latest`;
584 const spinner = (0, ora_1.default)(`Đang cập nhật (${installCommand})...`).start();
586 (0, child_process_1.execSync)(installCommand, { stdio: 'ignore' });
587 spinner.succeed(chalk_1.default.green('Đã cập nhật thành công! Vui lòng chạy lại lệnh để sử dụng bản mới.'));
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
dist/index.jsView on unpkg · L582 590 spinner.fail(chalk_1.default.red(`Cập nhật thất bại. Vui lòng chạy thủ công: ${installCommand}`));
595 console.log(chalk_1.default.red(`\nVui lòng chạy \`npm i -g ${NPM_PACKAGE_NAME}@latest\` để cập nhật thủ công.`));
601 // Ignore network/fetch errors to not block startup