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>,
|
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(
|
fn import_map_entries(
|
||||||
import_map: &ImportMap,
|
import_map: &ImportMap,
|
||||||
) -> impl Iterator<Item = (KeyPath, SpecifierMapEntry<'_>)> {
|
) -> impl Iterator<Item = (KeyPath, SpecifierMapEntry<'_>)> {
|
||||||
|
|
|
@ -348,16 +348,11 @@ async fn update(
|
||||||
)| {
|
)| {
|
||||||
let dep = deps.get_dep(*dep_id);
|
let dep = deps.get_dep(*dep_id);
|
||||||
interactive::PackageInfo {
|
interactive::PackageInfo {
|
||||||
location: dep.location.clone(),
|
|
||||||
current_version: current_version
|
current_version: current_version
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|nv| nv.version.to_string())
|
.map(|nv| nv.version.to_string())
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
name: dep
|
name: dep.alias_or_name().into(),
|
||||||
.alias
|
|
||||||
.as_ref()
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or_else(|| dep.req.name.to_string()),
|
|
||||||
kind: dep.kind,
|
kind: dep.kind,
|
||||||
new_version: new_req
|
new_version: new_req
|
||||||
.version_text()
|
.version_text()
|
||||||
|
|
|
@ -17,16 +17,13 @@ use crossterm::QueueableCommand;
|
||||||
use deno_core::anyhow;
|
use deno_core::anyhow;
|
||||||
use deno_core::anyhow::Context;
|
use deno_core::anyhow::Context;
|
||||||
|
|
||||||
use super::super::deps::DepLocation;
|
|
||||||
use crate::tools::registry::pm::deps::DepKind;
|
use crate::tools::registry::pm::deps::DepKind;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PackageInfo {
|
pub struct PackageInfo {
|
||||||
pub location: DepLocation,
|
|
||||||
pub current_version: String,
|
pub current_version: String,
|
||||||
pub new_version: String,
|
pub new_version: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
||||||
pub kind: DepKind,
|
pub kind: DepKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,10 +51,6 @@ impl State {
|
||||||
.max()
|
.max()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
let mut packages = packages;
|
|
||||||
packages
|
|
||||||
.sort_by(|a, b| a.location.file_path().cmp(&b.location.file_path()));
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
packages,
|
packages,
|
||||||
currently_selected: 0,
|
currently_selected: 0,
|
||||||
|
@ -110,24 +103,22 @@ impl State {
|
||||||
let want = &package.new_version;
|
let want = &package.new_version;
|
||||||
let new_version_highlight =
|
let new_version_highlight =
|
||||||
highlight_new_version(&package.current_version, want)?;
|
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!(
|
crossterm::queue!(
|
||||||
out,
|
out,
|
||||||
Print(format!(
|
Print(format!(
|
||||||
"{:<name_width$} {:<current_width$} -> {}",
|
"{formatted_name}{name_pad} {:<current_width$} -> {}",
|
||||||
format!(
|
|
||||||
"{}{}{}",
|
|
||||||
deno_terminal::colors::gray(package.kind.scheme()),
|
|
||||||
deno_terminal::colors::gray(":"),
|
|
||||||
package.name
|
|
||||||
),
|
|
||||||
package.current_version,
|
package.current_version,
|
||||||
new_version_highlight,
|
new_version_highlight,
|
||||||
name_width = self.name_width + 2,
|
|
||||||
current_width = self.current_width
|
current_width = self.current_width
|
||||||
)),
|
)),
|
||||||
)?;
|
)?;
|
||||||
// out.queue(Print(&package.package.name))?;
|
|
||||||
if self.currently_selected == i {
|
if self.currently_selected == i {
|
||||||
out.queue(style::ResetColor)?;
|
out.queue(style::ResetColor)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue