Transform command outputs to custom logs for an outstanding developer experience
https://github.com/leog/ldx.git
A lightweight tool to enhance your development workflow by processing command output with customizable transformations.
To install LDX globally, run:
pnpm install -g ldx
Alternatively, you can install it locally in your project:
pnpm install --save-dev ldx
Create a ldx.config.js file in your project's root directory. This file defines the patterns and transformations for your command output.
Example:
module.exports = {
// Simple string replacement
"Test match 1": "โ
Test match 1 processed",
// Function-based processing
"Function match": (line) => `Processed: ${line}`,
};
Use LDX to run your commands and transform their output:
ldx <your-command>
For example:
ldx pnpm run dev
module.exports = {
"String contained in output line": "Replacement text for the entire line"
}
module.exports = {
"String contained in output line": (line) => {
// Custom processing logic
return `Formatted: ${line}`;
}
}
LDX provides clear error messages for common issues:
If ldx.config.js is not found in your project root:
Oops, no ldx.config.js file found!
Solution: Create a ldx.config.js file in your project root. You can copy ldx.config.example.js as a starting point.
If your configuration has invalid values:
LDX: Configuration error - Invalid value type for key "myKey". Expected string or function, got number.
Solution: Ensure all configuration values are either strings or functions.
If your configuration object is empty:
LDX: Configuration error - Configuration cannot be empty.
Solution: Add at least one pattern-transformation pair to your configuration.
If the command you're trying to run doesn't exist:
Error executing command: Failed to start command: spawn xyz ENOENT
Solution: Verify the command exists and is in your PATH.
If a transformer function throws an error, LDX will:
LDX: provided function errored: <error message>Run tests with:
pnpm test
ldx echo "Testing LDX tool"
ldx pnpm run dev
ldx docker-compose up
pnpm i
pnpm test
This project uses standard-version for automated versioning and changelog generation based on Conventional Commits.
<type>(<scope>): <description>
[optional body]
[optional footer(s)]
Types: feat, fix, docs, style, refactor, perf, test, chore, ci, build
Examples:
git commit -m "feat: add support for regex patterns"
git commit -m "fix: handle empty lines in output"
git commit -m "docs: update configuration examples"
# Automatic version bump based on commits (recommended)
pnpm release
# Specific version bumps
pnpm release:patch # 1.0.2 -> 1.0.3
pnpm release:minor # 1.0.2 -> 1.1.0
pnpm release:major # 1.0.2 -> 2.0.0
After running the release command:
git push --follow-tags origin main && npm publish
Contributions are welcome! Please open issues or pull requests in this repo.