Skip to content

Commit

Permalink
Expand registry specification to registry URL when packaging (#805)
Browse files Browse the repository at this point in the history
**Stack**:
- #819
- #818
- #809
- #808
- #807
- #806
- #805⚠️ *Part of a stack created by [spr](https://github.com/ejoffe/spr). Do
not merge manually using the UI - doing so may have unexpected results.*
  • Loading branch information
mkaput authored Oct 27, 2023
1 parent 51f35eb commit 1cede5d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
10 changes: 9 additions & 1 deletion scarb/src/core/publishing/manifest_normalization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,21 @@ fn generate_dependency(dep: &ManifestDependency) -> Result<TomlDependency> {

Ok(TomlDependency::Detailed(Box::new(DetailedTomlDependency {
version,

// Erase path information, effectively making the dependency default registry-based.
path: None,

// Same for Git specification.
git: None,
branch: None,
tag: None,
rev: None,

// Unless it is default registry, expand registry specification to registry URL.
//
// NOTE: Default registry will reject packages with dependencies from other registries.
registry: if dep.source_id.is_registry() && !dep.source_id.is_default_registry() {
todo!("Packaging packages with dependencies from non-default registries is not implemented yet.")
Some(dep.source_id.url.clone())
} else {
None
},
Expand Down
16 changes: 14 additions & 2 deletions scarb/tests/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use scarb_test_support::command::Scarb;
use scarb_test_support::fsx::unix_paths_to_os_lossy;
use scarb_test_support::gitx;
use scarb_test_support::project_builder::{Dep, DepBuilder, ProjectBuilder};
use scarb_test_support::registry::local::LocalRegistry;
use scarb_test_support::workspace_builder::WorkspaceBuilder;

struct PackageChecker {
Expand Down Expand Up @@ -308,11 +309,18 @@ fn generated_manifest() {
.build(&t);
});

let mut registry = LocalRegistry::create();
registry.publish(|t| {
ProjectBuilder::start()
.name("registry_dep")
.version("1.0.0")
.build(t);
});

ProjectBuilder::start()
.name("hello")
.version("1.0.0")
// TODO(mkaput): Uncomment this when registry source will be implemented.
// .dep("registry_dep", Dep.version("1.0.0"))
.dep("registry_dep", Dep.version("1.0.0").registry(&registry))
.dep("path_dep", path_dep.version("0.1.0"))
.dep("git_dep", git_dep.version("0.2.0"))
.dep_starknet()
Expand Down Expand Up @@ -355,6 +363,10 @@ fn generated_manifest() {
[dependencies.path_dep]
version = "^0.1.0"
[dependencies.registry_dep]
version = "^1.0.0"
registry = "file://[..]"
[dependencies.starknet]
version = "[..]"
Expand Down

0 comments on commit 1cede5d

Please sign in to comment.