
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@decaf-ts/cli
Advanced tools
A modular command-line interface framework for Decaf-ts that dynamically discovers and loads CLI modules from different packages. The CLI provides a unified entry point (decaf) for executing commands from various Decaf modules, making it easy to extend with new functionality without modifying the core CLI code.
Documentation available here
Minimal size: 1.6 KB kb gzipped
The Decaf-ts CLI is a powerful and extensible command-line interface framework designed to provide a unified entry point for all Decaf-ts modules. It enables developers to create modular CLI commands that can be discovered and executed through a single command-line tool.
CliWrapper: The central class that manages the discovery, loading, and execution of CLI modules. It:
CLIUtils: A utility class that provides helper methods for:
CLI Module System: A standardized way for Decaf-ts packages to expose CLI functionality:
decaf commandThe CLI uses a recursive filesystem crawler to find modules up to a configurable depth. It handles both ESM and CommonJS module formats, making it compatible with various JavaScript environments. The command structure follows the pattern:
decaf <module> <command> [options]
Where <module> is the name of a Decaf-ts module and <command> is a specific command provided by that module.
The Decaf-ts CLI provides a unified command-line interface for all Decaf-ts modules. Here are some examples of how to use it:
# Get general help
npx decaf help
# List all available modules
npx decaf list
# Get help for a specific module
npx decaf help <module-name>
# Run a command from a specific module
npx decaf <module-name> <command> [options]
To create a CLI module for your Decaf-ts package, follow these steps:
cli-module.ts in your package:import { Command } from "commander";
export default function myModule(): Command {
return new Command()
.command("hello <name>")
.description("Say hello to someone")
.action((name: string) => {
console.log(`Hello, ${name}!`);
});
}
// tsconfig.cli.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/cli"
},
"include": ["src/cli-module.ts"]
}
"scripts": {
"build:cli": "tsc --project tsconfig.cli.json"
}
You can also use the CliWrapper class programmatically in your own code:
import { CliWrapper } from "@decaf-ts/cli";
// Create a new CLI wrapper with custom options
const cli = new CliWrapper("./src", 2);
// Run the CLI with custom arguments
cli.run(process.argv)
.then(() => {
console.log("CLI commands executed successfully");
})
.catch((error) => {
console.error("Error executing CLI commands:", error);
});
The CLIUtils class provides utility methods for working with CLI modules:
import { CLIUtils } from "@decaf-ts/cli";
import { Command } from "commander";
// Initialize a Command object with package information
const command = new Command();
CLIUtils.initialize(command, "./path/to/package");
// Get package information
const version = CLIUtils.packageVersion("./path/to/package");
const name = CLIUtils.packageName("./path/to/package");
// Load a CLI module from a file
const modulePath = "./path/to/cli-module.js";
CLIUtils.loadFromFile(modulePath)
.then((module) => {
const command = module();
console.log("Loaded command:", command.name());
})
.catch((error) => {
console.error("Error loading module:", error);
});
The CLI package includes a demo module that shows how to create a simple command:
// Run the demo command
npx decaf demo command "hello world"
// Output:
// executed demo command with type variable: hello world
If you have bug reports, questions or suggestions please create a new issue.
I am grateful for any contributions made to this project. Please read this to get started.
The first and easiest way you can support it is by Contributing. Even just finding a typo in the documentation is important.
Financial support is always welcome and helps keep both me and the project alive and healthy.
So if you can, if this project in any way. either by learning something or simply by helping you save precious time, please consider donating.
This project is released under the MIT License.
By developers, for developers...
FAQs
cli for decaf-ts projects
We found that @decaf-ts/cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.