Skip to content

Commit

Permalink
re-organize upload command
Browse files Browse the repository at this point in the history
  • Loading branch information
dfrankland committed Jan 2, 2025
1 parent e31f3d3 commit 0fa10f6
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 192 deletions.
8 changes: 8 additions & 0 deletions bundle/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
io::{Seek, Write},
path::PathBuf,
};
use tempfile::TempDir;
#[cfg(feature = "wasm")]
use tsify_next::Tsify;
#[cfg(feature = "wasm")]
Expand Down Expand Up @@ -107,6 +108,13 @@ impl BundlerUtil {

Ok(())
}

pub fn make_tarball_in_temp_dir(&self) -> anyhow::Result<(PathBuf, TempDir)> {
let bundle_temp_dir = tempfile::tempdir()?;
let bundle_temp_file = bundle_temp_dir.path().join("bundle.tar.zstd");
self.make_tarball(&bundle_temp_file)?;
Ok((bundle_temp_file, bundle_temp_dir))
}
}

/// Reads and decompresses a .tar.zstd file from an input stream into just a `meta.json` file
Expand Down
6 changes: 3 additions & 3 deletions cli/src/api_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ impl ApiClient {
const TRUNK_API_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
const TRUNK_API_TOKEN_HEADER: &'static str = "x-api-token";

pub fn new(api_token: String) -> anyhow::Result<Self> {
let trimmed_token = api_token.trim();
if trimmed_token.is_empty() {
pub fn new<T: AsRef<str>>(api_token: T) -> anyhow::Result<Self> {
let api_token = api_token.as_ref();
if api_token.trim().is_empty() {
return Err(anyhow::anyhow!("Trunk API token is required."));
}
let api_token_header_value = HeaderValue::from_str(&api_token)
Expand Down
Loading

0 comments on commit 0fa10f6

Please sign in to comment.