Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Scrypto CLI for Improved Development Experience #1840

Open
mshakeg opened this issue Jun 27, 2024 · 0 comments
Open

Enhance Scrypto CLI for Improved Development Experience #1840

mshakeg opened this issue Jun 27, 2024 · 0 comments

Comments

@mshakeg
Copy link

mshakeg commented Jun 27, 2024

Description

I would like to propose several enhancements to the Scrypto CLI to improve the development experience, especially for tasks such as compiling, testing, and managing dependencies. Drawing inspiration from the fast and efficient workflow provided by tools like Forge/Foundry in Solidity development, the following features are suggested to streamline and speed up the development process in Scrypto:

Proposed Features

  1. Conditional Compilation and Testing

    • Feature: Implement a mechanism where scrypto test only recompiles if changes have been made since the last compilation.
    • Benefit: Saves time by avoiding unnecessary recompilation and allows developers to quickly run tests.
  2. Incremental Compilation

    • Feature: Ensure incremental compilation is enabled by default for development builds.
    • Benefit: Significantly reduces compilation times for incremental changes, enhancing the iterative development process.
  3. Parallel Testing

    • Feature: Enable parallel test execution by default.
    • Benefit: Speeds up the execution of the test suite, making the feedback loop faster for developers.
  4. Custom CLI Options

    • Feature: Add CLI options for fast compilation and clean recompilation. For example:
      • --fast: Perform a fast compilation optimized for development speed.
      • --clean: Clean the build directory and recompile everything.
    • Benefit: Provides flexibility to developers to choose between fast iterative builds and complete clean builds.
  5. Automatic Change Detection with cargo watch Integration

    • Feature: Integrate cargo watch to automatically run checks, builds, or tests when files change.
    • Benefit: Provides instant feedback to developers, similar to hot-reload in other development environments.
  6. Optimized Development Profile

    • Feature: Define and use a custom profile for faster builds during development.
    • Benefit: Allows for quicker builds without sacrificing essential debugging capabilities.
  7. Improved Build Scripts

    • Feature: Provide a set of build scripts (e.g., Bash scripts or Makefiles) to handle common tasks such as conditional compilation, testing, and cleaning.
    • Benefit: Streamlines common development tasks and reduces the overhead of manually managing build commands.

Example Custom CLI Script

#!/bin/bash

# Function to compile in development mode
fast_compile() {
    echo "Performing fast compilation..."
    cargo build --profile dev
}

# Function to run tests
run_tests() {
    echo "Running tests..."
    cargo test
}

# Function to check for changes
check_for_changes() {
    echo "Checking for changes..."
    if cargo check; then
        echo "No changes detected."
        return 0
    else
        echo "Changes detected."
        return 1
    fi
}

# Function to clean and recompile
clean_and_compile() {
    echo "Cleaning and recompiling..."
    cargo clean
    cargo build
}

# Parse CLI arguments
while [[ "$#" -gt 0 ]]; do
    case $1 in
        --fast) fast=1 ;;
        --clean) clean=1 ;;
        *) echo "Unknown parameter passed: $1"; exit 1 ;;
    esac
    shift
done

# Check for changes and act accordingly
if check_for_changes; then
    run_tests
else
    if [[ $clean -eq 1 ]]; then
        clean_and_compile
    elif [[ $fast -eq 1 ]]; then
        fast_compile
    else
        cargo build
    fi
    run_tests
fi

NOTE: I don't have much Rust experience so GPT4 helped me draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant