Skip to content

bestdan/tsu

Repository files navigation

tsutils

TypeScript command line utilities package.

Installation

Clone and biuld

git clone https://github.com/bestdan/tsu.git
cd tsu
chmod +x script/setup.sh
sh script/setup.sh

Usage

tsu <namespace> <command> [options]

Git hook

To use tsu to check your dart changes before pushing, create a pre-push hook in your .git/hooks directory:

cd ~/src/mobile
cat > .git/hooks/pre-push << 'EOF'
#!/bin/bash

# Enable pipefail so pipe failures are captured properly
set -o pipefail

echo "📋 Running pre-push tsu checks"
tsu hook collate
# tsu hook collate --verbose # If you want verbose output
EOF

chmod +x .git/hooks/pre-push

Available Namespaces

Top-level Commands

# Run all checks concurrently, collate results
tsu hook format --verbose

# Check and upgrade tsutils
tsutils check version --verbose
tsutils upgrade --verbose

# Check external dependencies
tsutils check externals --verbose

# Check if in a git repository
tsutils git check && echo "In a git repo"

# Get git root path
cd "$(tsutils git root)"

# Show changed files
tsutils git changed

# Format check for Dart files (git hook)
tsutils hook format check

# Filter files by extension
tsutils git changed | tsutils files filter --suffix .ts

Command Design Philosophy

All commands follow a pipe-friendly design:

  • Clean, parseable output to stdout
  • Error messages to stderr
  • Appropriate exit codes
  • --verbose flag for debugging (outputs to stderr)

Requirements

  • Node.js: >=20.0.0

Developer

  • Vitest: >=4.0.6 // for proper ignores in test coverage

Optional Dependencies

Some commands require additional tools:

  • Claude CLI: For git commit-msg and git pr-description - Install
  • Dart SDK: For dart commands - Install
  • DCM: For hook dcm check - Install
  • Melos: For hook graphql check - Install

See the git docs and dart docs for details on which commands need what.

Project Structure

src/
├── cli.ts                       # CLI entry point
├── index.ts                     # Library exports
├── commands/                    # CLI commands
│   ├── git/                     # Git namespace commands
│   ├── dart/                    # Dart namespace commands
│   └── files/                   # Files namespace commands
└── utils/                       # Utility functions
    ├── logger.ts
    ├── git.ts                   # Git utilities
    ├── dart.ts                  # Dart utilities
    └── files.ts                 # File utilities

Development

Security

  • Security Policy: See SECURITY.md for our security policy and how to report vulnerabilities
  • Automated Scanning: CodeQL security scanning runs on every PR and weekly
  • Dependency Monitoring: Dependabot monitors dependencies for known vulnerabilities
  • Minimal Dependencies: Only one runtime dependency (commander)
  • Regular Updates: Dependencies are regularly updated to patch security issues
  • Code Reviews: All changes undergo security-focused code review

Reporting Security Issues

Please do not report security vulnerabilities through public GitHub issues.

Report security issues privately via GitHub Security Advisories or see our Security Policy for details.

License

MIT

About

Utility package written in TS

Resources

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 6