feat: migrate from inquirer to @inquirer/prompts for interactive prompts
- Replaced inquirer with @inquirer/prompts in various command files for improved prompt handling. - Updated confirmation and input prompts in commands such as app, config, deploy, login, and others. - Added a new command 'cc' for switching between Claude code models with appropriate configurations. - Enhanced user experience by ensuring prompts are more streamlined and consistent across the application.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { program, Command } from '@/program.ts';
|
||||
import { getConfig, getEnvToken } from '@/module/get-config.ts';
|
||||
import inquirer from 'inquirer';
|
||||
import { input, password } from '@inquirer/prompts';
|
||||
import { loginInCommand } from '@/module/login/login-by-web.ts';
|
||||
import { queryLogin, storage } from '@/module/query.ts';
|
||||
import chalk from 'chalk';
|
||||
@@ -28,24 +28,15 @@ const loginCommand = new Command('login')
|
||||
return;
|
||||
}
|
||||
// 如果没有传递参数,则通过交互式输入
|
||||
if (!username || !password) {
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'username',
|
||||
message: 'Enter your username:',
|
||||
when: () => !username, // 当 username 为空时,提示用户输入
|
||||
},
|
||||
{
|
||||
type: 'password',
|
||||
name: 'password',
|
||||
message: 'Enter your password:',
|
||||
mask: '*', // 隐藏输入的字符
|
||||
when: () => !password, // 当 password 为空时,提示用户输入
|
||||
},
|
||||
]);
|
||||
username = answers.username || username;
|
||||
password = answers.password || password;
|
||||
if (!username) {
|
||||
username = await input({
|
||||
message: 'Enter your username:',
|
||||
});
|
||||
}
|
||||
if (!password) {
|
||||
password = await password({
|
||||
message: 'Enter your password:',
|
||||
});
|
||||
}
|
||||
const token = storage.getItem('token');
|
||||
if (token) {
|
||||
|
||||
Reference in New Issue
Block a user