morph-cli 0.1.0

AST-based codebase migration and codemod tool for JavaScript and TypeScript projects.
Documentation
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};

fn main() {
    // 1. Get Git Hash
    let commit = std::env::var("MORPH_CLI_GIT_HASH").unwrap_or_else(|_| {
        Command::new("git")
            .args(&["rev-parse", "--short", "HEAD"])
            .output()
            .ok()
            .and_then(|output| String::from_utf8(output.stdout).ok())
            .map(|s| s.trim().to_string())
            .unwrap_or_else(|| "unknown".to_string())
    });

    // 2. Get Build Timestamp
    let timestamp = std::env::var("MORPH_CLI_BUILD_TIME").unwrap_or_else(|_| {
        SystemTime::now()
            .duration_since(UNIX_EPOCH)
            .unwrap()
            .as_secs()
            .to_string()
    });

    println!("cargo:rustc-env=MORPH_CLI_GIT_HASH={}", commit);
    println!("cargo:rustc-env=MORPH_CLI_BUILD_TIME={}", timestamp);
    
    // Rerun if git state changes
    println!("cargo:rerun-if-changed=.git/HEAD");
    println!("cargo:rerun-if-env-changed=MORPH_CLI_GIT_HASH");
    println!("cargo:rerun-if-env-changed=MORPH_CLI_BUILD_TIME");
}