Skip to content

Commit

Permalink
Replace several TODO comments with todo! calls in packaging logic (#…
Browse files Browse the repository at this point in the history
…758)

**Stack**:
- #767
- #768
- #758⚠️ *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 9, 2023
1 parent d09f6e2 commit 8fd1c46
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
25 changes: 17 additions & 8 deletions scarb/src/core/publishing/manifest_normalization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use indoc::formatdoc;

use crate::core::{
DepKind, DependencyVersionReq, DetailedTomlDependency, ManifestDependency, MaybeWorkspace,
Package, PackageName, TomlDependency, TomlManifest, TomlPackage, TomlWorkspaceDependency,
TomlWorkspaceField,
Package, PackageName, TargetKind, TomlDependency, TomlManifest, TomlPackage,
TomlWorkspaceDependency, TomlWorkspaceField,
};

pub fn prepare_manifest_for_publish(pkg: &Package) -> Result<TomlManifest> {
Expand All @@ -26,13 +26,17 @@ pub fn prepare_manifest_for_publish(pkg: &Package) -> Result<TomlManifest> {
.collect()
});

let cairo_plugin = match pkg.target(&TargetKind::CAIRO_PLUGIN) {
None => None,
Some(_) => todo!("Packaging Cairo plugins is not implemented yet."),
};

Ok(TomlManifest {
package,
workspace: None,
dependencies,
lib: None,
// TODO(mkaput): Allow packaging Cairo plugins.
cairo_plugin: None,
cairo_plugin,
test: None,
target: None,
cairo: None,
Expand All @@ -55,8 +59,10 @@ fn generate_package(pkg: &Package) -> Box<TomlPackage> {
homepage: metadata.homepage.clone().map(MaybeWorkspace::Defined),
keywords: metadata.keywords.clone().map(MaybeWorkspace::Defined),
license: metadata.license.clone().map(MaybeWorkspace::Defined),
// TODO(mkaput): Normalize this the same way as readme is.
license_file: metadata.license_file.clone().map(MaybeWorkspace::Defined),
license_file: metadata
.license_file
.as_ref()
.map(|_| todo!("Packaging packages with a license file is not implemented yet.")),
readme: metadata
.readme
.as_ref()
Expand Down Expand Up @@ -117,8 +123,11 @@ fn generate_dependency(dep: &ManifestDependency) -> Result<TomlDependency> {
branch: None,
tag: None,
rev: None,
// TODO(mkaput): What to do if package is mixing dependencies from different registries?
registry: None,
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.")
} else {
None
},
})))
}

Expand Down
4 changes: 4 additions & 0 deletions scarb/src/core/source/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ impl SourceId {
*CACHE
}

pub fn is_registry(self) -> bool {
self.kind == SourceKind::Registry
}

pub fn is_default_registry(self) -> bool {
self == Self::default_registry()
}
Expand Down

0 comments on commit 8fd1c46

Please sign in to comment.