mirror of
https://github.com/pesde-pkg/pesde.git
synced 2025-05-04 10:33:47 +01:00
refactor: remove hack in x command
This commit is contained in:
parent
e4f496ffab
commit
0f63044fa6
2 changed files with 24 additions and 28 deletions
|
@ -18,9 +18,7 @@ use pesde::{
|
|||
source::{
|
||||
ids::PackageId,
|
||||
pesde::{specifier::PesdeDependencySpecifier, PesdePackageSource},
|
||||
traits::{
|
||||
DownloadOptions, GetTargetOptions, PackageSource as _, RefreshOptions, ResolveOptions,
|
||||
},
|
||||
traits::{DownloadOptions, PackageSource as _, RefreshOptions, ResolveOptions},
|
||||
PackageSources,
|
||||
},
|
||||
Project, RefreshedSources, DEFAULT_INDEX_NAME,
|
||||
|
@ -79,6 +77,7 @@ impl ExecuteCommand {
|
|||
None => read_config().await.ok().map(|c| c.default_index),
|
||||
}
|
||||
.context("no index specified")?;
|
||||
|
||||
let source = PesdePackageSource::new(index);
|
||||
refreshed_sources
|
||||
.refresh(
|
||||
|
@ -132,10 +131,24 @@ impl ExecuteCommand {
|
|||
project.auth_config().clone(),
|
||||
);
|
||||
|
||||
let id = Arc::new(PackageId::new(
|
||||
PackageNames::Pesde(self.package.0.clone()),
|
||||
v_id,
|
||||
));
|
||||
let name = self.package.0.clone();
|
||||
let mut file = source
|
||||
.read_index_file(&name, &project)
|
||||
.await
|
||||
.context("failed to read package index file")?
|
||||
.context("package doesn't exist on the index")?;
|
||||
|
||||
let entry = file
|
||||
.entries
|
||||
.remove(&v_id)
|
||||
.context("version id not present in index file")?;
|
||||
|
||||
let bin_path = entry
|
||||
.target
|
||||
.bin_path()
|
||||
.context("package has no binary export")?;
|
||||
|
||||
let id = Arc::new(PackageId::new(PackageNames::Pesde(name), v_id));
|
||||
|
||||
let fs = source
|
||||
.download(
|
||||
|
@ -154,22 +167,6 @@ impl ExecuteCommand {
|
|||
.await
|
||||
.context("failed to write package contents")?;
|
||||
|
||||
let target = source
|
||||
.get_target(
|
||||
&pkg_ref,
|
||||
&GetTargetOptions {
|
||||
project: project.clone(),
|
||||
path: tempdir.path().into(),
|
||||
id: id.clone(),
|
||||
// HACK: the pesde package source doesn't use the engines, so we can just use an empty map
|
||||
engines: Default::default(),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.context("failed to get target")?;
|
||||
|
||||
let bin_path = target.bin_path().context("package has no binary export")?;
|
||||
|
||||
let graph = project
|
||||
.dependency_graph(None, refreshed_sources.clone(), true)
|
||||
.await
|
||||
|
@ -203,7 +200,7 @@ impl ExecuteCommand {
|
|||
|
||||
anyhow::Ok((
|
||||
tempdir,
|
||||
compatible_runtime(target.kind(), &engines)?,
|
||||
compatible_runtime(entry.target.kind(), &engines)?,
|
||||
bin_path.to_relative_path_buf(),
|
||||
))
|
||||
},
|
||||
|
|
|
@ -8,19 +8,18 @@ use inquire::validator::Validation;
|
|||
use pesde::{
|
||||
errors::ManifestReadError,
|
||||
manifest::{target::TargetKind, DependencyType},
|
||||
names::{PackageName, PackageNames},
|
||||
names::PackageName,
|
||||
source::{
|
||||
git_index::GitBasedSource as _,
|
||||
ids::PackageId,
|
||||
pesde::{specifier::PesdeDependencySpecifier, PesdePackageSource},
|
||||
specifiers::DependencySpecifiers,
|
||||
traits::{GetTargetOptions, PackageSource as _, RefreshOptions, ResolveOptions},
|
||||
traits::{PackageSource as _, RefreshOptions, ResolveOptions},
|
||||
PackageSources,
|
||||
},
|
||||
Project, RefreshedSources, DEFAULT_INDEX_NAME, SCRIPTS_LINK_FOLDER,
|
||||
};
|
||||
use semver::VersionReq;
|
||||
use std::{fmt::Display, path::Path, str::FromStr as _, sync::Arc};
|
||||
use std::{fmt::Display, str::FromStr as _};
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
pub struct InitCommand;
|
||||
|
|
Loading…
Add table
Reference in a new issue