Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 0 additions & 20 deletions crates/pm/src/cmd/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,26 +372,6 @@ mod tests {
assert!(topology.is_empty());
}

#[tokio::test]
async fn test_run_script_in_all_workspaces_no_workspaces() {
let _dir = tempdir().unwrap();
let package_json = r#"
{
"name": "test-project",
"version": "1.0.0",
"scripts": {
"test": "echo test"
}
}"#;

fs::write(_dir.path().join("package.json"), package_json).unwrap();
std::env::set_current_dir(_dir.path()).unwrap();

let result = run_script_in_all_workspaces("test", None).await;
// Should succeed but do nothing when no workspaces exist
assert!(result.is_ok());
}

#[tokio::test]
#[allow(unused_variables)]
async fn test_need_run_with_script() {
Expand Down
20 changes: 11 additions & 9 deletions crates/pm/src/service/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,18 @@ type CacheMap = HashMap<String, (SpecMap, VersionMap)>; // name -> (specs, versi
// Lightweight versions info stored in versions.json
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VersionsInfo {
pub versions: Value, // versions object from npm registry
pub versions: Versions,
pub etag: Option<String>,
pub last_updated: u64, // Unix timestamp
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Versions {
pub version_list: Vec<String>,
#[serde(rename = "dist-tags")]
pub dist_tags: HashMap<String, String>,
}

// Individual version manifest stored in manifests/version.json
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VersionManifest {
Expand All @@ -38,7 +45,7 @@ struct CachedFullManifest {
manifest: Arc<FullManifest>,
}

#[derive(Debug, Clone)]
#[derive(Debug)]
struct CachedVersionsInfo {
info: Arc<VersionsInfo>,
}
Expand Down Expand Up @@ -110,13 +117,8 @@ impl PackageCache {
}

/// Set versions info in memory cache (sync)
pub fn set_versions(&self, name: &str, versions: &VersionsInfo, etag: Option<String>) {
let mut versions_with_etag = versions.clone();
versions_with_etag.etag = etag;

let cached = CachedVersionsInfo {
info: Arc::new(versions_with_etag),
};
pub fn set_versions(&self, name: &str, versions: Arc<VersionsInfo>) {
let cached = CachedVersionsInfo { info: versions };
self.versions_info.insert(name.to_string(), cached);
log_verbose(&format!("Cached versions info in memory: {name}"));
}
Expand Down
Loading
Loading