@tng-sh/js
v0.2.8
Published
TNG JavaScript CLI
Readme
@tng-sh/js: TNG JavaScript CLI
High-performance test generation and context analysis for JavaScript/TypeScript, powered by Rust (NAPI-RS and OXC).
Installation
Install the package as a development dependency in your project:
npm install @tng-sh/js --save-devUsage
1. Initialize
First, run the init command to create a tng.config.js configuration file. This file stores your API keys and project settings.
npx tng init2. Interactive Mode (TUI)
The most powerful way to use TNG is via the high-performance terminal interface. It provides a guided experience for all analysis tasks.
npx tng iCapabilities in TUI:
- Generate Tests: Guided test creation for methods, components, and utilities.
- Audit Method: Deep security, performance, and best-practice auditing.
- Trace Method: Symbolic execution and logic flow visualization.
- X-Ray Method: Deep dependency and side-effect analysis.
- Check Duplicates: High-performance clone detection across the codebase.
- Dead Code: Identify unreachable logic and unused variables/parameters.
- User Stats: Review your usage metrics and generation history.
3. Command Line Interface (CLI) ⚙️
For direct execution or integration into scripts.
# See file outline and method list
npx tng -f path/to/file.js --outline
# Generate tests for a specific method
npx tng -f path/to/file.js -m functionName -t react_component
# Check for code clones
npx tng -f path/to/file.js --clonesSupported Types (-t):
react_component, express_handler, graphql_resolver, nest_js, orm_model, background_job, mailer, utility.
4. Machine-Readable Output (--json) 🤖
Add the --json flag to any command to receive output as structured JSON events. This is ideal for CI/CD pipelines or custom integrations.
npx tng -f path/to/file.js --clones --json4. Dead Code Analysis
Identify unreachable code, unused variables, and unused imports in your project:
npx -p @tng-sh/js tng --deadcode -f path/to/file.jsFeatures
- Blazing Fast Static Analysis: Powered by Rust and the
oxcparser for near-instant AST processing. - Interactive Terminal UI: Dual-pane keyboard-driven interface for deep code exploration.
- Smart Visualization: Generate logic flow diagrams using Mermaid.js integration.
- Dead Code Cleanup: Find and remove unused imports, variables, and unreachable logic.
- First-Class TS & React: Native support for TypeScript, JSX, and TSX.
Configuration
Your tng.config.js allows for full customization:
module.exports = {
API_KEY: "your-api-key-here",
API_URL: "https://app.tng.sh/",
FRAMEWORK: "express", // Options: express, nextjs, nestjs, generic
TESTS_PATH: "tests", // Where to save generated tests
TEST_FRAMEWORK: "jest" // Options: jest, mocha, vitest
};