From 22d32265c91ae70195f82ec80bba08f8c73bf115 Mon Sep 17 00:00:00 2001 From: Mike Donnalley Date: Tue, 28 May 2024 09:00:55 -0600 Subject: [PATCH] feat: use ansis instead of chalk --- package.json | 2 +- src/commands/autocomplete/index.ts | 38 +++++++++++++++--------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index bbec3e81..bc752e1e 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/oclif/plugin-autocomplete/issues", "dependencies": { "@oclif/core": "^4.0.0-beta.13", - "chalk": "^5.3.0", + "ansis": "^3.2.0", "debug": "^4.3.4", "ejs": "^3.1.10" }, diff --git a/src/commands/autocomplete/index.ts b/src/commands/autocomplete/index.ts index 681efd87..0ff3860d 100644 --- a/src/commands/autocomplete/index.ts +++ b/src/commands/autocomplete/index.ts @@ -1,5 +1,5 @@ import {Args, Flags, ux} from '@oclif/core' -import chalk from 'chalk' +import {bold, cyan} from 'ansis' import {EOL} from 'node:os' import {AutocompleteBase} from '../../base.js' @@ -38,7 +38,7 @@ export default class Index extends AutocompleteBase { ) } - ux.action.start(`${chalk.bold('Building the autocomplete cache')}`) + ux.action.start(`${bold('Building the autocomplete cache')}`) await Create.run([], this.config) ux.action.stop() @@ -62,22 +62,22 @@ Setup Instructions for ${this.config.bin.toUpperCase()} CLI Autocomplete --- instructions += ` 1) Run this command in your terminal window: - ${chalk.cyan(`printf "eval $(${scriptCommand})" >> ~/.bashrc; source ~/.bashrc`)} + ${cyan(`printf "eval $(${scriptCommand})" >> ~/.bashrc; source ~/.bashrc`)} - The previous command adds the ${chalk.cyan(setupEnvVar)} environment variable to your Bash config file and then sources the file. + The previous command adds the ${cyan(setupEnvVar)} environment variable to your Bash config file and then sources the file. - ${chalk.bold('NOTE')}: If you’ve configured your terminal to start as a login shell, you may need to modify the command so it updates either the ~/.bash_profile or ~/.profile file. For example: + ${bold('NOTE')}: If you’ve configured your terminal to start as a login shell, you may need to modify the command so it updates either the ~/.bash_profile or ~/.profile file. For example: + + ${cyan(`printf "eval $(${scriptCommand}) >> ~/.bash_profile; source ~/.bash_profile`)} - ${chalk.cyan(`printf "eval $(${scriptCommand}) >> ~/.bash_profile; source ~/.bash_profile`)} - Or: - ${chalk.cyan(`printf "eval $(${scriptCommand})" >> ~/.profile; source ~/.profile`)} + ${cyan(`printf "eval $(${scriptCommand})" >> ~/.profile; source ~/.profile`)} 2) Start using autocomplete: - ${chalk.cyan(`${this.config.bin} ${tabStr}`)} # Command completion - ${chalk.cyan(`${this.config.bin} command --${tabStr}`)} # Flag completion + ${cyan(`${this.config.bin} ${tabStr}`)} # Command completion + ${cyan(`${this.config.bin} command --${tabStr}`)} # Flag completion ` break } @@ -86,18 +86,18 @@ Setup Instructions for ${this.config.bin.toUpperCase()} CLI Autocomplete --- instructions += ` 1) Run this command in your terminal window: - ${chalk.cyan(`printf "eval $(${scriptCommand})" >> ~/.zshrc; source ~/.zshrc`)} + ${cyan(`printf "eval $(${scriptCommand})" >> ~/.zshrc; source ~/.zshrc`)} - The previous command adds the ${chalk.cyan(setupEnvVar)} environment variable to your zsh config file and then sources the file. + The previous command adds the ${cyan(setupEnvVar)} environment variable to your zsh config file and then sources the file. 2) (Optional) Run this command to ensure that you have no permissions conflicts: - ${chalk.cyan('compaudit -D')} + ${cyan('compaudit -D')} 3) Start using autocomplete: - ${chalk.cyan(`${this.config.bin} ${tabStr}`)} # Command completion - ${chalk.cyan(`${this.config.bin} command --${tabStr}`)} # Flag completion + ${cyan(`${this.config.bin} ${tabStr}`)} # Command completion + ${cyan(`${this.config.bin} command --${tabStr}`)} # Flag completion ` break } @@ -106,17 +106,17 @@ Setup Instructions for ${this.config.bin.toUpperCase()} CLI Autocomplete --- instructions += ` 1) Run these two cmdlets in your PowerShell window in the order shown: - ${chalk.cyan(`New-Item -Type Directory -Path (Split-Path -Parent $PROFILE) -ErrorAction SilentlyContinue + ${cyan(`New-Item -Type Directory -Path (Split-Path -Parent $PROFILE) -ErrorAction SilentlyContinue Add-Content -Path $PROFILE -Value (Invoke-Expression -Command "${scriptCommand}"); .$PROFILE`)} 2) (Optional) If you want matching completions printed below the command line, run this cmdlet: - ${chalk.cyan('Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete')} + ${cyan('Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete')} 3) Start using autocomplete: - ${chalk.cyan(`${this.config.bin} ${tabStr}`)} # Command completion - ${chalk.cyan(`${this.config.bin} command --${tabStr}`)} # Flag completion + ${cyan(`${this.config.bin} ${tabStr}`)} # Command completion + ${cyan(`${this.config.bin} command --${tabStr}`)} # Flag completion ` break }