Leprechaun CLI Logger
Leprechaun is a specialized logging utility designed for command-line interface (CLI) applications, providing simple, lightweight, and visually distinct output. It offers `info`, `success`, `warning`, and `error` functions, each prepending messages with appropriate colored icons, enhancing readability and user experience in console environments. The package is currently at version 1.0.0, having recently migrated to TypeScript, which indicates a focus on type safety and maintainability. Its release cadence is not yet established, with 1.0.0 being the first major stable release. A key differentiator is its emphasis on aesthetics and a minimal API, making it easy to integrate for developers who prioritize clear, color-coded CLI feedback without extensive configuration.
Common errors
-
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/leprechaun/index.js from ... not supported.
cause Attempting to import `leprechaun` using CommonJS `require()` syntax in a project that expects ESM.fixChange `const { info } = require('leprechaun');` to `import { info } from 'leprechaun';` and ensure your project is configured for ESM (e.g., `"type": "module"` in package.json). -
The package 'leprechaun' requires Node.js version >=20.0.0. The current active Node.js version is X.Y.Z.
cause Running `leprechaun` on a Node.js version older than 20.0.0, which is unsupported by the package.fixUpgrade your Node.js runtime to version 20.0.0 or newer using a version manager like `nvm` or `volta`. -
ReferenceError: info is not defined (or similar for other functions)
cause This usually indicates an incorrect import statement, either trying to import a non-existent default export or an incorrect named export from a CommonJS context.fixEnsure you are using `import { info, success, warning, error } from 'leprechaun';` and your environment supports ESM.
Warnings
- breaking Version 1.0.0 introduced a minimum Node.js requirement of `>=20.0.0`. Projects running on older Node.js versions must upgrade to use Leprechaun v1.0.0 and above.
- breaking The package migrated to TypeScript in version 1.0.0. While the primary API remains consistent, this may introduce changes to type definitions or internal module structure that could subtly affect existing JavaScript consumers or custom type declarations.
- gotcha As indicated by the `TODO` section in the README, Leprechaun currently lacks comprehensive documentation and tests. This could lead to unexpected behavior in edge cases, difficulty understanding advanced usage patterns, or instability in future updates.
Install
-
npm install leprechaun -
yarn add leprechaun -
pnpm add leprechaun
Imports
- info
const { info } = require('leprechaun');import { info } from 'leprechaun'; - success, warning, error
import leprechaun from 'leprechaun'; leprechaun.success(...);
import { success, warning, error } from 'leprechaun'; - All logging functions
const { info, success, warning, error } = require('leprechaun');import { info, success, warning, error } from 'leprechaun';
Quickstart
import { info, success, warning, error } from 'leprechaun';
const project = 'MyCLIApp';
const version = '1.0.0';
const featureEnabled = true;
info('Starting', project, 'v' + version);
success('Configuration loaded:', featureEnabled ? 'enabled' : 'disabled');
warning('Check for updates recommended for', project);
error('Failed to connect to service. Retrying...');