noxid-cli 0.2.0

The Noxid compiler command line: check, build, test, adapt, and the agent surface
//! Give a scaffolded temp project the vetted database driver it now owns.
//!
//! `2cd38b2` ("Resolve database drivers from projects") removed the migration
//! runner's fallback to the compiler installation's own `node_modules`, and
//! `d27d3e7` ("Resolve hoisted migration drivers") settled the replacement on
//! plain Node resolution rooted at the project manifest, so a workspace-hoisted
//! install still resolves. A fixture created under the system temp directory
//! has no `node_modules` in any ancestor, so `noxid db migrate` now refuses
//! with `DATABASE_DRIVER_MISSING` before it can reach the behaviour under test.
//!
//! Linking the repository's installed dependencies into the fixture root is the
//! pattern the same commit introduced for `wo37_mysql.rs`
//! (`install_repository_dependencies`); this is that helper, shared by every
//! fixture that drives a live database.

use std::path::Path;

/// Link the repository's installed `node_modules` into `root`, so the project
/// owns the vetted driver the way a real project would. Idempotent.
pub fn link_repository_dependencies(root: &Path) {
    let link = root.join("node_modules");
    if link.exists() {
        return;
    }
    let dependencies = Path::new(env!("CARGO_MANIFEST_DIR"))
        .join("../..")
        .join("node_modules");
    assert!(
        dependencies.is_dir(),
        "repository dependencies are installed at {}",
        dependencies.display()
    );
    #[cfg(unix)]
    std::os::unix::fs::symlink(&dependencies, &link).expect("link project dependencies");
    #[cfg(windows)]
    {
        let status = std::process::Command::new("cmd")
            .args(["/C", "mklink", "/J"])
            .arg(&link)
            .arg(&dependencies)
            .status()
            .expect("create project dependency junction");
        assert!(status.success(), "create project dependency junction");
    }
}