Skip to content

Commit

Permalink
fix: allow publishing with no version in config file (#868)
Browse files Browse the repository at this point in the history
https://github.com/dsherret/jsr-publish-on-tag/actions/runs/12332179143/job/34419677355

```
$ deno publish --set-version 0.2.0
Download https://registry.npmjs.org/@types/node/-/node-18.16.19.tgz
Check file:///home/runner/work/jsr-publish-on-tag/jsr-publish-on-tag/src/main.ts
Checking for slow types in the public API...
Check file:///home/runner/work/jsr-publish-on-tag/jsr-publish-on-tag/src/main.ts
Publishing @david/[email protected] ...
error: Failed to publish @david/[email protected]
Caused by:
    Failed to publish @david/publish-on-tag at 0.2.0: invalid config file '/deno.json': missing field `version`
Error: Process completed with exit code 1.
```
  • Loading branch information
dsherret authored Dec 14, 2024
1 parent f597b42 commit 34603e9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/src/npm/tarball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ mod tests {
) -> Result<(), anyhow::Error> {
let scope = spec.jsr_json.name.scope.clone();
let package = spec.jsr_json.name.package.clone();
let version = spec.jsr_json.version.clone();
let version = spec.jsr_json.version.clone().unwrap();

let exports = match exports_map_from_json(spec.jsr_json.exports.clone()) {
Ok(exports) => exports,
Expand Down
2 changes: 1 addition & 1 deletion api/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ pub mod tests {
.unwrap();
let deno_json: ConfigFile = serde_json::from_slice(&json).unwrap();
assert_eq!(deno_json.name.to_string(), "@scope/foo");
assert_eq!(deno_json.version.to_string(), "1.2.3");
assert_eq!(deno_json.version.unwrap().to_string(), "1.2.3");
{
let metadata_json = t
.buckets
Expand Down
16 changes: 9 additions & 7 deletions api/src/tarball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,14 @@ pub async fn process_tarball(
publish_task_name: publishing_task_scoped_package_name,
});
}
if config_file.version != publishing_task.package_version {
return Err(PublishError::ConfigFileVersionMismatch {
path: Box::new(publishing_task.config_file.clone()),
deno_json_version: Box::new(config_file.version),
publish_task_version: Box::new(publishing_task.package_version.clone()),
});
if let Some(config_file_version) = config_file.version {
if config_file_version != publishing_task.package_version {
return Err(PublishError::ConfigFileVersionMismatch {
path: Box::new(publishing_task.config_file.clone()),
deno_json_version: Box::new(config_file_version),
publish_task_version: Box::new(publishing_task.package_version.clone()),
});
}
}

let exports =
Expand Down Expand Up @@ -690,7 +692,7 @@ pub struct FileInfo {
#[derive(Debug, Serialize, Deserialize)]
pub struct ConfigFile {
pub name: ScopedPackageName,
pub version: Version,
pub version: Option<Version>,
pub exports: Option<serde_json::Value>,
}

Expand Down
1 change: 0 additions & 1 deletion frontend/static/schema/config-file.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "A JSON representation of a JSR configuration file.",
"required": [
"name",
"version",
"exports"
],
"title": "JSR configuration file Schema",
Expand Down

0 comments on commit 34603e9

Please sign in to comment.