diff --git a/src/commands/nyxr.ts b/src/commands/nyxr.ts index 5f1a23a..33daaab 100644 --- a/src/commands/nyxr.ts +++ b/src/commands/nyxr.ts @@ -1,7 +1,7 @@ -/* eslint-disable unused-imports/no-unused-vars */ import c from 'kleur' import { Fzf } from 'fzf' import * as tyck from '@tyck/prompts' +import { consolji } from 'consolji' import { dump, load } from '../storage' import { parseNyxr } from '../parse' import { getPackageJSON } from '../fs' @@ -18,7 +18,7 @@ runCli(async (agent, args, ctx) => { if (args[0] === '-') { if (!storage.lastRunCommand) { - console.error('No last command found') + consolji.error('No last command found') process.exit(1) } args[0] = storage.lastRunCommand @@ -56,7 +56,7 @@ runCli(async (agent, args, ctx) => { description: limitText(description, terminalColumns - 15), })) - const fzf = new Fzf(raw, { + const _fzf = new Fzf(raw, { selector: item => `${item.key} ${item.description}`, casing: 'case-insensitive', }) diff --git a/src/detect.ts b/src/detect.ts index 07ca8d6..81b00d0 100644 --- a/src/detect.ts +++ b/src/detect.ts @@ -4,6 +4,7 @@ import { execaCommand } from 'execa' import { findUp } from 'find-up' import terminalLink from 'terminal-link' import * as tyck from '@tyck/prompts' +import { consolji } from 'consolji' import type { Agent } from './agents' import { AGENTS, INSTALL_PAGE, LOCKS } from './agents' import { cmdExists } from './utils' @@ -40,7 +41,7 @@ export async function detect({ autoInstall, cwd }: DetectOptions = {}) { else if (name in AGENTS) agent = name else - console.warn('[nyxi] Unknown packageManager:', pkg.packageManager) + consolji.warn('[nyxi] Unknown packageManager:', pkg.packageManager) } } catch {} @@ -53,7 +54,7 @@ export async function detect({ autoInstall, cwd }: DetectOptions = {}) { // If no package manager is detected, prompt the user to choose one if (!agent) { const defaultAgent = await getDefaultAgent() - if (defaultAgent === 'prompt') { + if ((defaultAgent as any) === 'prompt') { agent = await tyck.select({ message: 'Please choose a package manager:', options: [ @@ -71,7 +72,7 @@ export async function detect({ autoInstall, cwd }: DetectOptions = {}) { // auto install if (agent && !cmdExists(agent.split('@')[0])) { if (!autoInstall) { - console.warn(`[nyxi] Detected ${agent} but it doesn't seem to be installed.\n`) + consolji.warn(`[nyxi] Detected ${agent} but it doesn't seem to be installed.\n`) if (process.env.CI) process.exit(1) diff --git a/src/fs.ts b/src/fs.ts index 9554cab..1e78dfd 100644 --- a/src/fs.ts +++ b/src/fs.ts @@ -1,5 +1,6 @@ import { resolve } from 'node:path' import fs from 'node:fs' +import { consolji } from 'consolji' export function getPackageJSON(cwd = process.cwd()): any { const path = resolve(cwd, 'package.json') @@ -11,7 +12,7 @@ export function getPackageJSON(cwd = process.cwd()): any { return data } catch (e) { - console.warn('Failed to parse package.json') + consolji.warn('Failed to parse package.json') process.exit(0) } } diff --git a/src/gradient.ts b/src/gradient.ts deleted file mode 100644 index a2a2f06..0000000 --- a/src/gradient.ts +++ /dev/null @@ -1,36 +0,0 @@ -import chalk from 'chalk' -import ora from 'ora' -import gradient from 'gradient-string' - -const GREEN = '#14F195' -const PURPLE = '#9945FF' -const RED = '#ed4245' -const YELLOW = '#fee75c' - -export const nyxGradient = gradient(GREEN, PURPLE) -export const nyxGreen = chalk.hex(GREEN) -export const nyxPurple = chalk.hex(PURPLE) -export const nyxRed = chalk.hex(RED) -export const yellow = chalk.hex(YELLOW) - -export function nyxLoader(text: string) { - return ora({ - text, - spinner: { - frames: [' ', nyxGreen('> '), nyxGreen('>> '), nyxGreen('>>>')], - }, - }) -} - -export function info(...args: any[]) { - // eslint-disable-next-line no-console - console.log(nyxGreen.bold('>>>'), ...args) -} - -export function error(...args: any[]) { - console.error(nyxRed.bold('>>>'), ...args) -} - -export function warn(...args: any[]) { - console.error(yellow.bold('>>>'), ...args) -} diff --git a/src/runner.ts b/src/runner.ts index 5997dd5..e082b63 100644 --- a/src/runner.ts +++ b/src/runner.ts @@ -1,8 +1,8 @@ -/* eslint-disable no-console */ import { resolve } from 'node:path' import * as tyck from '@tyck/prompts' import { execaCommand } from 'execa' import c from 'kleur' +import { consolji } from 'consolji' import { version } from '../package.json' import type { Agent } from './agents' import { agents } from './agents' @@ -28,7 +28,7 @@ export async function runCli(fn: Runner, options: DetectOptions = {}) { } catch (error) { if (error instanceof UnsupportedCommand) - console.log(c.red(`\u2717 ${error.message}`)) + consolji.log(c.red(`\u2717 ${error.message}`)) process.exit(1) } @@ -43,21 +43,21 @@ export async function run(fn: Runner, args: string[], options: DetectOptions = { let command if (args.length === 1 && (args[0] === '--version' || args[0] === '-v')) { - console.log(`@nyxb/nyxi v${version}`) + consolji.log(`@nyxb/nyxi v${version}`) return } if (args.length === 1 && ['-h', '--help'].includes(args[0])) { const dash = c.dim('-') - console.log(c.green(c.bold('@nyxb/nyxi')) + c.dim(` use the right package manager v${version}\n`)) - console.log(`nyxi ${dash} install`) - console.log(`nyxr ${dash} run`) - console.log(`nyxlx ${dash} execute`) - console.log(`nyxu ${dash} upgrade`) - console.log(`nyxun ${dash} uninstall`) - console.log(`nyxci ${dash} clean install`) - console.log(`nyxa ${dash} agent alias`) - console.log(c.yellow('\ncheck https://github.com/nyxb/nyxi for more documentation.')) + consolji.log(c.green(c.bold('@nyxb/nyxi')) + c.dim(` use the right package manager v${version}\n`)) + consolji.log(`nyxi ${dash} install`) + consolji.log(`nyxr ${dash} run`) + consolji.log(`nyxlx ${dash} execute`) + consolji.log(`nyxu ${dash} upgrade`) + consolji.log(`nyxun ${dash} uninstall`) + consolji.log(`nyxci ${dash} clean install`) + consolji.log(`nyxa ${dash} agent alias`) + consolji.log(c.yellow('\ncheck https://github.com/nyxb/nyxi for more documentation.')) return } @@ -102,7 +102,7 @@ export async function run(fn: Runner, args: string[], options: DetectOptions = { command = voltaPrefix.concat(' ').concat(command) if (debug) { - console.log(command) + consolji.log(command) return }