Lines 571-611javascript
571 const basePath = isCompiled ? path_1.default.join(__dirname, '..') : __dirname;
572 const pkg = JSON.parse(fs_1.default.readFileSync(path_1.default.join(basePath, 'package.json'), 'utf-8'));
573 const currentVersion = pkg.version;
574 const res = await fetch(`https://registry.npmjs.org/${NPM_PACKAGE_NAME}/latest`, { signal: AbortSignal.timeout(2000) });
575 const data = await res.json();
576 const latestVersion = data.version;
577 if (latestVersion && latestVersion !== currentVersion) {
578 (0, ui_1.clearScreen)();
579 console.log(chalk_1.default.yellow('╭─────────────────────────────────────────────────────────────╮'));
580 console.log(chalk_1.default.yellow('│ │'));
581 console.log(chalk_1.default.yellow(`│ NEKOSTREAM ĐÃ CÓ CẬP NHẬT MỚI ! ${chalk_1.default.red(currentVersion)} → ${chalk_1.default.green(latestVersion)} │`));
582 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. │'));
583 console.log(chalk_1.default.yellow('│ │'));
584 console.log(chalk_1.default.yellow('╰─────────────────────────────────────────────────────────────╯\n'));
585 const { update } = await (0, prompts_wrapper_1.default)({
588 message: 'Bạn có muốn tự động cập nhật ngay bây giờ?',
592 const installCommand = `npm i -g ${NPM_PACKAGE_NAME}@latest`;
593 const spinner = (0, ora_1.default)(`Đang cập nhật (${installCommand})...`).start();
595 (0, child_process_1.execSync)(installCommand, { stdio: 'ignore' });
596 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 · L591 599 spinner.fail(chalk_1.default.red(`Cập nhật thất bại. Vui lòng chạy thủ công: ${installCommand}`));
604 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.`));
610 // Ignore network/fetch errors to not block startup