Scripts and Tools

Comprehensive documentation for all scripts and tools in the monorepo

Scripts and Tools

This section contains comprehensive documentation for all scripts and tools available in our monorepo. These tools help with development, building, maintenance, and automation tasks.

Available Documentation

Quick Start

For the most common tasks, see the Scripts Index page with quick commands and workflows.

sal-component-manager.js libs/scroll-trigger/src/lib/components/ # Fix barrel export issues node tools/scripts/smart-barrel-manager.js libs/ux-test-lib/src/lib/components/ --create-nested

Building

# Build everything
node tools/scripts/build-scripts/build-all.js

# Build specific library
node tools/scripts/build-scripts/build-libs.js core-types

# Build specific application
node tools/scripts/build-scripts/build-apps.js docs-angular

Cache Management

# Check cache health
node tools/scripts/cache-monitor.js

# Fix cache issues
node tools/scripts/cache-monitor.js --fix

Cleanup

# Analyze unused files
node tools/scripts/cleanup-unused-files.js --dry-run

# Clean old branches
./tools/scripts/cleanup-branches.sh

๐Ÿ“ Script Categories

๐ŸŽฏ Angular Component Management

Purpose: Automate component separation and barrel export management

Key Scripts:

Quick Commands:

# Complete refactoring
node tools/scripts/universal-component-manager.js path/to/components/

# Fix barrel exports
node tools/scripts/smart-barrel-manager.js path/to/components/ --create-nested

๐Ÿ—๏ธ Build Scripts

Purpose: Comprehensive build automation for the NX monorepo

Key Scripts:

Quick Commands:

# Build everything
node tools/scripts/build-scripts/build-all.js

# Build libraries only
node tools/scripts/build-scripts/build-libs.js

# Build applications only
node tools/scripts/build-scripts/build-apps.js

๐Ÿ” Cache Monitoring

Purpose: Monitor and maintain NX cache health

Key Scripts:

Quick Commands:

# Check cache health
node tools/scripts/cache-monitor.js

# Fix cache issues
node tools/scripts/cache-monitor.js --fix

๐Ÿงน Cleanup and Maintenance

Purpose: Maintain clean and optimized monorepo

Key Scripts:

Quick Commands:

# Analyze unused files
node tools/scripts/cleanup-unused-files.js --dry-run

# Clean old branches
./tools/scripts/cleanup-branches.sh

๐Ÿ› ๏ธ Development Utilities

Purpose: Development tools, debugging, and code generation

Key Scripts:

Quick Commands:

# Generate theme utilities
node tools/scripts/generate-theme-utilities.js

# Update import paths
node tools/scripts/update-imports.js

# Debug theme issues
node tools/scripts/debug-tools.js

๐Ÿš Shell Scripts

Purpose: System-level automation and environment setup

Key Scripts:

Quick Commands:

# Build docs-angular
./tools/scripts/build-docs-angular.sh

# Setup development environment
./tools/scripts/pre-dev-setup.sh

๐ŸŽฏ Common Workflows

Daily Development

# 1. Check cache health
node tools/scripts/cache-monitor.js

# 2. Build libraries
node tools/scripts/build-scripts/build-libs.js

# 3. Build applications
node tools/scripts/build-scripts/build-apps.js

Component Refactoring

# 1. Preview changes
node tools/scripts/universal-component-manager.js path/to/components/ --dry-run

# 2. Apply changes
node tools/scripts/universal-component-manager.js path/to/components/

# 3. Fix barrel exports
node tools/scripts/smart-barrel-manager.js path/to/components/ --create-nested

Maintenance Tasks

# 1. Analyze unused files
node tools/scripts/cleanup-unused-files.js --dry-run

# 2. Clean unused files
node tools/scripts/cleanup-unused-files.js

# 3. Clean old branches
./tools/scripts/cleanup-branches.sh

Troubleshooting

# 1. Check cache health
node tools/scripts/cache-monitor.js --report

# 2. Fix cache issues
node tools/scripts/cache-monitor.js --fix

# 3. Clean and rebuild
node tools/scripts/build-scripts/clean-dist.js
node tools/scripts/build-scripts/build-all.js --skip-nx-cache

๐Ÿ”ง Configuration

Environment Variables

# Cache configuration
export NX_CACHE_DIRECTORY=/tmp/nx-cache

# Build configuration
export NODE_ENV=development

Script Permissions

# Make shell scripts executable
chmod +x tools/scripts/*.sh

# Make Node.js scripts executable
chmod +x tools/scripts/*.js

๐Ÿ“Š Script Features Comparison

Feature Component Mgmt Build Scripts Cache Monitor Cleanup Dev Utils Shell Scripts
Automation โœ… โœ… โœ… โœ… โœ… โœ…
Error Recovery โœ… โœ… โœ… โœ… โŒ โŒ
Dry Run Mode โœ… โŒ โœ… โœ… โœ… โŒ
Progress Tracking โœ… โœ… โœ… โœ… โŒ โŒ
Backup Creation โŒ โŒ โŒ โœ… โŒ โŒ
Configuration โœ… โœ… โœ… โœ… โœ… โœ…

๐Ÿ› Common Issues and Solutions

Permission Issues

# Fix script permissions
chmod +x tools/scripts/*.sh
chmod +x tools/scripts/*.js

Cache Issues

# Check and fix cache
node tools/scripts/cache-monitor.js --fix

Build Issues

# Clean and rebuild
node tools/scripts/build-scripts/clean-dist.js
node tools/scripts/build-scripts/build-all.js --skip-nx-cache

Import Issues

# Update import paths
node tools/scripts/update-imports.js

๐Ÿ“ Best Practices

  1. Always Use Dry Run First: Test scripts with --dry-run when available
  2. Check Cache Health: Monitor cache health regularly
  3. Clean Before Building: Clean dist directory before major builds
  4. Use Appropriate Scripts: Choose the right tool for the task
  5. Monitor Progress: Use scripts with progress tracking for long operations
  6. Create Backups: Use scripts that create backups for destructive operations

๐Ÿค Contributing

To improve scripts and tools:

  1. Add Error Handling: Improve error detection and recovery
  2. Enhance Reporting: Add better progress tracking and reporting
  3. Add Configuration: Make scripts more configurable
  4. Improve Safety: Add more safety checks and validations
  5. Add Tests: Create tests for critical scripts
  6. Update Documentation: Keep documentation current with script changes

๐Ÿ“„ License

All scripts and tools are part of the project and follow the same license terms.


For detailed information about each category of scripts, see the individual documentation pages linked above.