mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 20:25:12 -05:00
cleanup, fix name space padding
This commit is contained in:
parent
898a00fc39
commit
cbec379189
3 changed files with 15 additions and 23 deletions
|
@ -194,6 +194,12 @@ pub struct Dep {
|
|||
pub alias: Option<String>,
|
||||
}
|
||||
|
||||
impl Dep {
|
||||
pub fn alias_or_name(&self) -> &str {
|
||||
self.alias.as_deref().unwrap_or_else(|| &self.req.name)
|
||||
}
|
||||
}
|
||||
|
||||
fn import_map_entries(
|
||||
import_map: &ImportMap,
|
||||
) -> impl Iterator<Item = (KeyPath, SpecifierMapEntry<'_>)> {
|
||||
|
|
|
@ -348,16 +348,11 @@ async fn update(
|
|||
)| {
|
||||
let dep = deps.get_dep(*dep_id);
|
||||
interactive::PackageInfo {
|
||||
location: dep.location.clone(),
|
||||
current_version: current_version
|
||||
.as_ref()
|
||||
.map(|nv| nv.version.to_string())
|
||||
.unwrap_or_default(),
|
||||
name: dep
|
||||
.alias
|
||||
.as_ref()
|
||||
.cloned()
|
||||
.unwrap_or_else(|| dep.req.name.to_string()),
|
||||
name: dep.alias_or_name().into(),
|
||||
kind: dep.kind,
|
||||
new_version: new_req
|
||||
.version_text()
|
||||
|
|
|
@ -17,16 +17,13 @@ use crossterm::QueueableCommand;
|
|||
use deno_core::anyhow;
|
||||
use deno_core::anyhow::Context;
|
||||
|
||||
use super::super::deps::DepLocation;
|
||||
use crate::tools::registry::pm::deps::DepKind;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PackageInfo {
|
||||
pub location: DepLocation,
|
||||
pub current_version: String,
|
||||
pub new_version: String,
|
||||
pub name: String,
|
||||
|
||||
pub kind: DepKind,
|
||||
}
|
||||
|
||||
|
@ -54,10 +51,6 @@ impl State {
|
|||
.max()
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut packages = packages;
|
||||
packages
|
||||
.sort_by(|a, b| a.location.file_path().cmp(&b.location.file_path()));
|
||||
|
||||
Ok(Self {
|
||||
packages,
|
||||
currently_selected: 0,
|
||||
|
@ -110,24 +103,22 @@ impl State {
|
|||
let want = &package.new_version;
|
||||
let new_version_highlight =
|
||||
highlight_new_version(&package.current_version, want)?;
|
||||
// let style = style::PrintStyledContent()
|
||||
let formatted_name = format!(
|
||||
"{}{}",
|
||||
deno_terminal::colors::gray(format!("{}:", package.kind.scheme())),
|
||||
package.name
|
||||
);
|
||||
let name_pad = " ".repeat(self.name_width + 2 - (package.name.len() + 4));
|
||||
|
||||
crossterm::queue!(
|
||||
out,
|
||||
Print(format!(
|
||||
"{:<name_width$} {:<current_width$} -> {}",
|
||||
format!(
|
||||
"{}{}{}",
|
||||
deno_terminal::colors::gray(package.kind.scheme()),
|
||||
deno_terminal::colors::gray(":"),
|
||||
package.name
|
||||
),
|
||||
"{formatted_name}{name_pad} {:<current_width$} -> {}",
|
||||
package.current_version,
|
||||
new_version_highlight,
|
||||
name_width = self.name_width + 2,
|
||||
current_width = self.current_width
|
||||
)),
|
||||
)?;
|
||||
// out.queue(Print(&package.package.name))?;
|
||||
if self.currently_selected == i {
|
||||
out.queue(style::ResetColor)?;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue