Skip to content

Commit 57b128e

Browse files
committed
[WIP]
1 parent 3180cac commit 57b128e

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
],
3737
"dependencies": {
3838
"cosmiconfig": "^9.0.0",
39-
"typescript": "^5.8.3"
39+
"typescript": "^5.8.3",
40+
"@jsr/luca__cases": "1",
41+
"@std/path": "npm:@jsr/std__path@^1.0.3",
42+
"@std/fs": "npm:@jsr/std__fs@^1.0.2"
4043
},
4144
"devDependencies": {
4245
"@biomejs/biome": "^1.9.4",

src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ impl Context {
124124
let client = Arc::clone(&client);
125125
let progress_bars = Arc::clone(&progress_bars);
126126

127+
println!("{update_url:?}");
128+
127129
handles.push((
128130
update_url.internal_name.clone(),
129131
spawn(async move {

src/dependency.rs

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,52 @@ impl Dependency {
6767
}
6868
}
6969

70-
pub fn is_updateable(&self) -> bool {
71-
self.matches_cli_filter && self.internal_name_is_supported() && !self.has_local_instance() && !self.contains_alias_specifier()
72-
}
73-
7470
pub fn get_update_url(&self) -> Option<UpdateUrl> {
75-
if self.is_updateable() {
76-
Some(UpdateUrl {
77-
internal_name: self.internal_name.clone(),
78-
url: format!("https://registry.npmjs.org/{}", self.internal_name),
79-
})
71+
if self.matches_cli_filter && self.internal_name_is_supported() && !self.has_local_instance() {
72+
if self.contains_alias_specifier() {
73+
self
74+
.instances
75+
.iter()
76+
.find(|instance| instance.descriptor.specifier.is_alias())
77+
.and_then(|instance| {
78+
if instance.descriptor.specifier.get_raw().starts_with("npm:@jsr/") {
79+
let raw = instance.descriptor.specifier.get_raw();
80+
let without_npm = raw.strip_prefix("npm:").unwrap_or(&raw);
81+
let parts: Vec<&str> = without_npm.split('@').collect();
82+
let name = if parts.len() > 2 {
83+
format!("{}@{}", parts[0], parts[1])
84+
} else {
85+
without_npm.to_string()
86+
};
87+
88+
Some(UpdateUrl {
89+
internal_name: self.internal_name.clone(),
90+
url: format!("https://npm.jsr.io/{}", name),
91+
})
92+
} else {
93+
None
94+
}
95+
})
96+
}
97+
// @FIXME: Cannot alias JSR dependencies with this in place
98+
else if self.internal_name.starts_with("@jsr/") {
99+
Some(UpdateUrl {
100+
internal_name: self.internal_name.clone(),
101+
url: format!(
102+
"https://npm.jsr.io/{}",
103+
&self
104+
.internal_name
105+
.replace("/", "__")
106+
// @TODO: do this properly
107+
.replace("@jsr__", "@jsr/")
108+
),
109+
})
110+
} else {
111+
Some(UpdateUrl {
112+
internal_name: self.internal_name.clone(),
113+
url: format!("https://registry.npmjs.org/{}", self.internal_name),
114+
})
115+
}
80116
} else {
81117
None
82118
}

0 commit comments

Comments
 (0)