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

Feature: Allow skipping downloads of engines by setting env vars #405

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions crates/cli/src/binaries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@ pub fn global_cache_dir() -> PathBuf {
.join(PRISMA_CLI_VERSION)
}

pub fn fetch_native(to_dir: &PathBuf) -> Result<(), String> {
if !to_dir.is_absolute() {
Err("to_dir must be absolute".to_string())?;
}

download_cli(to_dir)?;

for e in &ENGINES {
download_engine(&e.name, &to_dir)?;
}

Ok(())
}

pub fn download_cli(to_dir: &PathBuf) -> Result<(), String> {
let cli = prisma_cli_name();

Expand Down Expand Up @@ -92,7 +78,7 @@ pub fn download_cli(to_dir: &PathBuf) -> Result<(), String> {
Ok(())
}

fn download_engine(engine_name: &str, to_dir: &PathBuf) -> Result<(), String> {
pub fn download_engine(engine_name: &str, to_dir: &PathBuf) -> Result<(), String> {
let os_name = platform::binary_platform_name();

let to = platform::check_for_extension(
Expand Down
8 changes: 4 additions & 4 deletions crates/cli/src/prisma_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ use std::process::Command;
pub fn main(args: &Vec<String>) {
let dir = binaries::global_cache_dir();

binaries::fetch_native(&dir).unwrap();

binaries::download_cli(&dir).unwrap();
let prisma = binaries::prisma_cli_name();

let mut cmd = Command::new(dir.join(prisma));
let binary_name =
platform::check_for_extension(&platform::name(), &platform::binary_platform_name());

let mut cmd = Command::new(dir.join(prisma));

cmd.args(args);

cmd.envs(env::vars());
Expand All @@ -25,6 +24,7 @@ pub fn main(args: &Vec<String>) {
cmd.env(e.env, path);
}
Err(_) => {
binaries::download_engine(&e.name, &dir).unwrap();
let path = dir
.join(binaries::ENGINE_VERSION)
.join(format!("prisma-{}-{}", e.name, binary_name));
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod utils;

#[tokio::test]
async fn aaaa_run_migrations() -> TestResult {
let client = db::new_client().await.unwrap();
let client = db::PrismaClient::_builder().build().await.unwrap();

client._db_push().accept_data_loss().await.unwrap();

Expand Down
Loading