mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-05 20:28:23 +00:00
Allow publishing packages without a module
Modify the Wasmer package build logic to allow packages without a module. These packages are perfectly valid and useful (pure fs package, module comes from dependencies, ...)
This commit is contained in:
@@ -43,8 +43,6 @@ pub struct Publish {
|
|||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
enum PackageBuildError {
|
enum PackageBuildError {
|
||||||
#[error("Cannot publish without a module.")]
|
|
||||||
NoModule,
|
|
||||||
#[error("Unable to publish the \"{module}\" module because \"{}\" is not a file", path.display())]
|
#[error("Unable to publish the \"{module}\" module because \"{}\" is not a file", path.display())]
|
||||||
SourceMustBeFile { module: String, path: PathBuf },
|
SourceMustBeFile { module: String, path: PathBuf },
|
||||||
#[error("Unable to load the bindings for \"{module}\" because \"{}\" doesn't exist", path.display())]
|
#[error("Unable to load the bindings for \"{module}\" because \"{}\" doesn't exist", path.display())]
|
||||||
@@ -108,9 +106,7 @@ impl Publish {
|
|||||||
builder
|
builder
|
||||||
.finish()
|
.finish()
|
||||||
.map_err(|e| anyhow::anyhow!("failed to finish .tar.gz builder: {e}"))?;
|
.map_err(|e| anyhow::anyhow!("failed to finish .tar.gz builder: {e}"))?;
|
||||||
let tar_archive_data = builder
|
let tar_archive_data = builder.into_inner().expect("tar archive was not finalized");
|
||||||
.into_inner()
|
|
||||||
.map_err(|_| PackageBuildError::NoModule)?;
|
|
||||||
let archive_name = "package.tar.gz".to_string();
|
let archive_name = "package.tar.gz".to_string();
|
||||||
let archive_dir = tempfile::TempDir::new()?;
|
let archive_dir = tempfile::TempDir::new()?;
|
||||||
let archive_dir_path: &std::path::Path = archive_dir.as_ref();
|
let archive_dir_path: &std::path::Path = archive_dir.as_ref();
|
||||||
@@ -166,10 +162,7 @@ fn construct_tar_gz(
|
|||||||
cwd: &Path,
|
cwd: &Path,
|
||||||
) -> Result<(Option<String>, Option<String>), anyhow::Error> {
|
) -> Result<(Option<String>, Option<String>), anyhow::Error> {
|
||||||
let package = &manifest.package;
|
let package = &manifest.package;
|
||||||
let modules = manifest
|
let modules = manifest.module.as_deref().unwrap_or_default();
|
||||||
.module
|
|
||||||
.as_ref()
|
|
||||||
.ok_or(PackageBuildError::NoModule)?;
|
|
||||||
|
|
||||||
let readme = match package.readme.as_ref() {
|
let readme = match package.readme.as_ref() {
|
||||||
None => None,
|
None => None,
|
||||||
|
|||||||
Reference in New Issue
Block a user