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::{
|
source::{
|
||||||
ids::PackageId,
|
ids::PackageId,
|
||||||
pesde::{specifier::PesdeDependencySpecifier, PesdePackageSource},
|
pesde::{specifier::PesdeDependencySpecifier, PesdePackageSource},
|
||||||
traits::{
|
traits::{DownloadOptions, PackageSource as _, RefreshOptions, ResolveOptions},
|
||||||
DownloadOptions, GetTargetOptions, PackageSource as _, RefreshOptions, ResolveOptions,
|
|
||||||
},
|
|
||||||
PackageSources,
|
PackageSources,
|
||||||
},
|
},
|
||||||
Project, RefreshedSources, DEFAULT_INDEX_NAME,
|
Project, RefreshedSources, DEFAULT_INDEX_NAME,
|
||||||
|
@ -79,6 +77,7 @@ impl ExecuteCommand {
|
||||||
None => read_config().await.ok().map(|c| c.default_index),
|
None => read_config().await.ok().map(|c| c.default_index),
|
||||||
}
|
}
|
||||||
.context("no index specified")?;
|
.context("no index specified")?;
|
||||||
|
|
||||||
let source = PesdePackageSource::new(index);
|
let source = PesdePackageSource::new(index);
|
||||||
refreshed_sources
|
refreshed_sources
|
||||||
.refresh(
|
.refresh(
|
||||||
|
@ -132,10 +131,24 @@ impl ExecuteCommand {
|
||||||
project.auth_config().clone(),
|
project.auth_config().clone(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let id = Arc::new(PackageId::new(
|
let name = self.package.0.clone();
|
||||||
PackageNames::Pesde(self.package.0.clone()),
|
let mut file = source
|
||||||
v_id,
|
.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
|
let fs = source
|
||||||
.download(
|
.download(
|
||||||
|
@ -154,22 +167,6 @@ impl ExecuteCommand {
|
||||||
.await
|
.await
|
||||||
.context("failed to write package contents")?;
|
.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
|
let graph = project
|
||||||
.dependency_graph(None, refreshed_sources.clone(), true)
|
.dependency_graph(None, refreshed_sources.clone(), true)
|
||||||
.await
|
.await
|
||||||
|
@ -203,7 +200,7 @@ impl ExecuteCommand {
|
||||||
|
|
||||||
anyhow::Ok((
|
anyhow::Ok((
|
||||||
tempdir,
|
tempdir,
|
||||||
compatible_runtime(target.kind(), &engines)?,
|
compatible_runtime(entry.target.kind(), &engines)?,
|
||||||
bin_path.to_relative_path_buf(),
|
bin_path.to_relative_path_buf(),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,19 +8,18 @@ use inquire::validator::Validation;
|
||||||
use pesde::{
|
use pesde::{
|
||||||
errors::ManifestReadError,
|
errors::ManifestReadError,
|
||||||
manifest::{target::TargetKind, DependencyType},
|
manifest::{target::TargetKind, DependencyType},
|
||||||
names::{PackageName, PackageNames},
|
names::PackageName,
|
||||||
source::{
|
source::{
|
||||||
git_index::GitBasedSource as _,
|
git_index::GitBasedSource as _,
|
||||||
ids::PackageId,
|
|
||||||
pesde::{specifier::PesdeDependencySpecifier, PesdePackageSource},
|
pesde::{specifier::PesdeDependencySpecifier, PesdePackageSource},
|
||||||
specifiers::DependencySpecifiers,
|
specifiers::DependencySpecifiers,
|
||||||
traits::{GetTargetOptions, PackageSource as _, RefreshOptions, ResolveOptions},
|
traits::{PackageSource as _, RefreshOptions, ResolveOptions},
|
||||||
PackageSources,
|
PackageSources,
|
||||||
},
|
},
|
||||||
Project, RefreshedSources, DEFAULT_INDEX_NAME, SCRIPTS_LINK_FOLDER,
|
Project, RefreshedSources, DEFAULT_INDEX_NAME, SCRIPTS_LINK_FOLDER,
|
||||||
};
|
};
|
||||||
use semver::VersionReq;
|
use semver::VersionReq;
|
||||||
use std::{fmt::Display, path::Path, str::FromStr as _, sync::Arc};
|
use std::{fmt::Display, str::FromStr as _};
|
||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct InitCommand;
|
pub struct InitCommand;
|
||||||
|
|
Loading…
Add table
Reference in a new issue