A powerful cross-runtime script runner with TUI, environment management, and colored console output. Works seamlessly with Node.js, Bun, and Deno.
π¨ NEW in v0.5.1: Enhanced documentation and improved GitHub Pages deployment!
π― NEW in v0.6.0: Interactive Environment Prompts for secure variable collection!
ποΈ NEW in v0.7.0: Unified architecture with CLI refactoring and enhanced TUI experience!
# Install globally
bun add -g @glyphtek/scriptit
# Initialize a new project
scriptit init
# Run the interactive TUI
scriptit run
# Or execute a single script (colored console enabled by default)
scriptit exec ./scripts/my-script.js
π Visit the full documentation site β
- π Getting Started Guide
- π¨ Colored Console Output
- π₯οΈ CLI Commands
- π¦ Library API
- π‘ Examples
- Colored Console Output: Automatic color coding for console methods with beautiful output
- π€ White for
console.log()
β’ π΄ Red forconsole.error()
- π‘ Yellow for
console.warn()
β’ π΅ Blue forconsole.info()
β’ β« Gray forconsole.debug()
- π€ White for
- Interactive Terminal UI: Multi-panel interface for script selection and real-time output
- Enhanced Script Context: Rich context object with colored console support
- Cross-Runtime Compatibility: Node.js (18+), Deno, and Bun support
- Dynamic Script Loading: Fresh loading on each execution for external updates
- Lambda Function Support: Perfect for existing functions - just point and run!
- Flexible Script Patterns: Traditional lifecycle or modern default export functions
- Configuration Files:
runner.config.js
for project-specific behavior - Environment Management: Smart
.env
file loading with variable interpolation - Script Discovery: Automatic nested discovery with customizable exclude patterns
- Working Directory Support: Run from anywhere with
--pwd
option
- CLI & Library: Use standalone or integrate into your applications
- Event System: Listen to script execution events
- Git Integration: Smart
.gitignore
management for temporary files
- Prerequisites
- Installation
- CLI Usage
- Script Types & Examples
- Library Usage
- Configuration
- Migration Guide
- Troubleshooting
- Development
- Community & Support
Choose one of the following JavaScript runtimes:
Bun (Recommended)
bun add -g @glyphtek/scriptit
Node.js
npm install -g @glyphtek/scriptit
# or
yarn global add @glyphtek/scriptit
Deno
deno install --allow-read --allow-write --allow-run --allow-env -n scriptit npm:@glyphtek/scriptit
Bun: bun add @glyphtek/scriptit
Node.js: npm install @glyphtek/scriptit
Deno: import { createScriptRunner } from "npm:@glyphtek/scriptit"
scriptit init
Creates a complete project structure with example scripts, configuration, and proper .gitignore
setup.
Options:
-s, --scripts-dir <dir>
- Directory for scripts (default:scripts
)-t, --tmp-dir <dir>
- Directory for temporary files (default:tmp
)-f, --force
- Overwrite existing files and directories
scriptit run
# or simply
scriptit
Options:
-c, --config <path>
- Path to runner configuration file-s, --scripts-dir <dir>
- Override scripts directory from config-t, --tmp-dir <dir>
- Override temporary directory from config--no-tui
- Run without Terminal UI, just list available scripts--force-tui
- Force TUI mode even when debug is enabled
Navigation:
- ββ or j/k: Navigate scripts β’ Tab: Switch panels β’ Enter: Execute
- C: Toggle config β’ F: Toggle files β’ R: Refresh β’ Q: Quit
# Basic execution (colored console enabled by default)
scriptit exec ./scripts/my-script.ts
# With environment variables
scriptit exec ./scripts/deploy.ts -e NODE_ENV=production API_KEY=secret
# With interactive environment prompts
scriptit exec ./scripts/deploy.ts --env-prompts API_KEY,SECRET_TOKEN
# With custom configuration
scriptit exec ./scripts/my-script.ts -c custom.config.js
# Multiple environment variables
scriptit exec ./scripts/script.ts -e NODE_ENV=prod -e DEBUG=false -e PORT=8080
# Combine static and prompted environment variables
scriptit exec ./scripts/deploy.ts -e NODE_ENV=production --env-prompts API_KEY,SECRET_TOKEN
Options:
-c, --config <path>
- Path to runner configuration file-e, --env <vars...>
- Set environment variables (e.g., NAME=value X=Y)--env-prompts <vars...>
- Prompt for environment variables before execution (e.g., API_KEY,SECRET)
Available for all commands:
# Enable debug mode with verbose logging
scriptit --debug exec ./scripts/my-script.ts
# Set working directory (all relative paths resolve from here)
scriptit --pwd /path/to/project exec ./scripts/deploy.ts
# Show version
scriptit --version
# Show help
scriptit --help
The --pwd
option is perfect for:
- CI/CD pipelines - Run from build directories
- Multi-project setups - Manage scripts across repositories
- Lambda integration - Point to existing function directories
# Change working directory before execution
scriptit --pwd /path/to/project run
# All relative paths resolve from the specified directory
scriptit --pwd /app exec ./scripts/deploy.ts
// scripts/deployment.ts
export const description = "Deploy application with full lifecycle";
export async function tearUp(context) {
context.log('Setting up deployment...');
return { startTime: Date.now() };
}
export async function execute(context, tearUpResult) {
const console = context.console || global.console;
console.info('Starting deployment...');
console.warn('This will overwrite production!');
// Main deployment logic
const result = await deployApplication(context.env.API_KEY);
console.log('Deployment completed successfully');
return result;
}
export async function tearDown(context, executeResult, tearUpResult) {
const duration = Date.now() - tearUpResult.startTime;
context.log(`Deployment completed in ${duration}ms`);
}
// scripts/data-processor.ts
export const description = "Process data with colored output";
export default async function(context) {
const console = context.console || global.console;
console.log('Processing data...');
console.info(`Environment: ${context.env.NODE_ENV}`);
try {
const result = await processLargeDataset(context.env.INPUT_FILE);
console.log('β
Processing completed successfully');
return result;
} catch (error) {
console.error('β Processing failed:', error.message);
throw error;
}
}
interface ScriptContext {
// Enhanced console with colors (when enabled)
console: {
log: (...args: unknown[]) => void; // White
info: (...args: unknown[]) => void; // Blue
warn: (...args: unknown[]) => void; // Yellow
error: (...args: unknown[]) => void; // Red
debug: (...args: unknown[]) => void; // Gray
};
// Environment & configuration
env: Record<string, string | undefined>;
tmpDir: string;
configPath?: string;
log: (message: string) => void;
params: Record<string, unknown>;
// Default parameters from config
[key: string]: unknown;
}
ScriptIt supports interactive prompting for environment variables across both CLI and TUI interfaces, allowing you to securely collect sensitive data at runtime without hardcoding values.
Environment variable prompting works seamlessly across all interfaces:
- CLI: Terminal-based prompting with readline
- TUI: Beautiful modal dialogs with visual feedback
- Library: Programmatic integration with custom prompters
Both interfaces support the same features:
- Password masking with
*
characters - Smart detection (only prompts for missing variables)
- Type-aware prompting (input vs password fields)
- Consistent variable precedence across all interfaces
Scripts can declare their required environment variables using the variables
export:
// Full definition with custom prompts and types
export const variables = [
{ name: 'API_KEY', message: 'Enter your API key:', type: 'password' },
{ name: 'USER_NAME', message: 'Enter your username:', type: 'input' },
];
// Shorthand definition for quick setup
export const variables = ['API_KEY', 'DATABASE_URL', 'SECRET_TOKEN'];
export async function execute(context) {
const console = context.console || global.console;
// Variables are automatically prompted and available in context.env
console.log(`API Key: ${context.env.API_KEY ? '***hidden***' : 'Not set'}`);
console.log(`Username: ${context.env.USER_NAME || 'Not provided'}`);
return { success: true };
}
Use the --env-prompts
flag to prompt for any variables on demand:
# Prompt for specific variables
scriptit exec my-script.js --env-prompts API_KEY,SECRET_TOKEN
# Space-separated format also works
scriptit exec my-script.js --env-prompts API_KEY SECRET_TOKEN
# Works with the run command too
scriptit run --env-prompts DATABASE_URL,API_KEY
input
(default): Regular text inputpassword
: Hidden input with masked characters (*
)
ScriptIt follows this order when collecting environment variables:
- Existing Environment: Variables already set in shell,
.env
files, or via--env
flag - Skip Prompting: Variables that are already set are not prompted again
- Combine Sources: CLI
--env-prompts
+ scriptvariables
export (CLI takes precedence for duplicates) - Interactive Collection: Prompt for any missing variables
- Script Execution: All variables available in
context.env
Final Environment Precedence (highest to lowest):
- Prompted Variables - Collected interactively
- CLI Arguments (
--env NAME=value
) - CLI-provided environment variables - Config Default Params - From runner.config.js
- Environment Files - .env, .env.local, etc.
- Password masking: Sensitive inputs are hidden with
*
characters - No logging: Prompted values are not logged or displayed in output
- Process isolation: Values are set in
process.env
for script duration only
import { createScriptRunner } from '@glyphtek/scriptit';
const runner = await createScriptRunner({
scriptsDir: './scripts',
tmpDir: './tmp',
consoleInterception: { enabled: true }, // Enable colored console
excludePatterns: ['*.helper.*', '_*'],
});
// Execute scripts
const result = await runner.executeScript('deploy.ts', {
params: { environment: 'production' },
env: { API_KEY: 'secret' }
});
// Event handling
runner.on('script:beforeExecute', (scriptPath) => {
console.log(`π Executing: ${scriptPath}`);
});
// Multi-project setup
const projectRunner = await createScriptRunner({
workingDirectory: '/projects/my-app',
scriptsDir: './deployment-scripts',
envFiles: ['.env', '.env.production'],
defaultParams: {
projectName: 'My App',
version: process.env.npm_package_version
}
});
// Lambda function integration
const lambdaRunner = await createScriptRunner({
workingDirectory: '/lambda-functions',
scriptsDir: './',
excludePatterns: ['node_modules/**', '*.test.*'],
consoleInterception: { enabled: true }
});
Create a runner.config.js
file in your project root:
// runner.config.js
export default {
scriptsDir: './scripts',
tmpDir: './tmp',
envFiles: ['.env', '.env.local', '.env.production'],
excludePatterns: [
'**/node_modules/**',
'**/*.test.*',
'**/*.helper.*',
'_*',
'**/helpers/**'
],
defaultParams: {
appName: 'My Application',
version: '1.0.0',
apiUrl: '${API_BASE_URL}/api/v1' // Environment variable interpolation
}
};
Option | Type | Default | Description |
---|---|---|---|
scriptsDir |
string |
"scripts" |
Scripts directory path |
tmpDir |
string |
"tmp" |
Temporary files directory |
envFiles |
string[] |
[".env"] |
Environment files to load |
excludePatterns |
string[] |
[] |
Script exclusion patterns |
defaultParams |
object |
{} |
Default script parameters |
CLI Usage:
# Colored console is enabled by default in CLI
scriptit exec my-script.js
Library Usage:
const runner = createScriptRunner({
consoleInterception: { enabled: true } // Enable colored console
});
Script Updates:
// Use enhanced console for best results
export default async function(context) {
const console = context.console || global.console;
console.log('This will be colored when interception is enabled');
}
- New TUI interface:
scriptit run
now opens interactive UI - Default export support: Lambda functions work directly
- No breaking changes: Existing scripts continue to work
π Script not found
- Check your
scriptsDir
configuration - Ensure files have
.js
or.ts
extensions - Verify exclude patterns aren't filtering your scripts
π Environment variables not loading
- Ensure
.env
files are in project root or configured inenvFiles
- Check file permissions and syntax
- Use
context.log()
to debug loaded variables
π₯οΈ TUI not working properly
- Some terminals have limited support - try
--no-tui
- Ensure terminal size is adequate (minimum 80x24)
- Try different terminal emulators
- Use
--debug
for verbose logging
π¨ Colored console not working
- Colored console is enabled by default in CLI mode
- For library usage, set
consoleInterception: { enabled: true }
- Some terminals may not support all colors
- Ensure scripts use
context.console
fallback pattern
π§ Permission errors
- Check file permissions for script and temp directories
- Ensure ScriptIt has necessary runtime permissions
- Verify working directory access with
--pwd
βοΈ Debug mode issues
- Use
--debug
flag for verbose logging - TUI is disabled by default in debug mode (use
--force-tui
to override) - Check
SCRIPTIT_DEBUG
environment variable
If you encounter issues not covered here, please check our troubleshooting guide or open an issue.
git clone https://github.com/glyphtek/scriptit.git
cd scriptit
bun install
bun run build
bun test
Command | Description |
---|---|
bun run dev |
Development mode |
bun run build |
Production build |
bun test |
Run all tests |
bun run lint |
Code linting |
bun run format |
Code formatting |
- Fork & Clone: Create your feature branch
- Test: Write tests for new functionality
- Quality: Follow TypeScript best practices
- Compatibility: Ensure cross-runtime support
- Documentation: Update docs for new features
- π Report Issues
- π¬ Join Discussions
- π Documentation
- π API Reference
- β Star on GitHub
- π¦ Follow on Twitter
- π Sponsor Development
We welcome contributions! Ways to help:
- Bug Reports: Detailed reproduction steps
- Feature Requests: Describe your use case
- Code Contributions: PRs with tests
- Documentation: Improve guides and examples
- Community: Help others in discussions
We welcome contributions from the community! ScriptIt is an open source project that thrives on collaboration.
- Fork the repository on GitHub
- Clone your fork locally:
git clone https://github.com/YOUR_USERNAME/scriptit.git
- Create a feature branch from
develop
:git checkout -b feature/your-feature-name
- Make your changes with tests and documentation
- Submit a pull request to the
develop
branch
# Install dependencies
bun install
# Run tests
bun test
# Build project
bun run build
# Lint and format
bun run check
- π Bug fixes - Help us squash issues
- β¨ New features - Enhance ScriptIt's capabilities
- π Documentation - Improve guides and examples
- π§ͺ Tests - Increase coverage and reliability
- π¨ UI/UX - Make the TUI even better
- β‘ Performance - Optimize for speed and memory
src/cli.ts
- Command-line interfacesrc/lib.ts
- Library APIsrc/core/
- Core execution enginesrc/ui/
- Terminal UI componentssrc/common/
- Shared utilities and typesdocs/
- Documentation and guidesexamples/
- Usage examples
For detailed contribution guidelines, see CONTRIBUTING.md.
main
- Protected production branchdevelop
- Integration branch for new features- All changes require pull requests with:
- β Passing tests
- β Code review approval
- β CI/CD checks
- Automated Testing - 31+ tests across multiple runtimes
- Continuous Integration - GitHub Actions for testing, linting, and building
- Cross-Runtime Support - Tested on Bun, Node.js, and Deno
- Security Scanning - Automated vulnerability detection
- Documentation - Comprehensive guides and API documentation
- Feature Development - Work in feature branches
- Pull Request - Submit to
develop
branch - Code Review - Maintainer review and approval
- Integration Testing - Automated CI/CD pipeline
- Release - Tagged releases with automated NPM publishing
Security is a top priority for ScriptIt. We follow responsible disclosure practices:
- Report vulnerabilities to security@glyphtek.com
- Security updates are released promptly
- Supported versions receive security patches
See SECURITY.md for our complete security policy.
MIT License - see the LICENSE file for details.
ScriptIt - Making script management simple and powerful across all JavaScript runtimes.