From fc6a542959d0b37a2ce9bb49d949a0f73927801d Mon Sep 17 00:00:00 2001 From: Shuheng Liu Date: Wed, 8 Jan 2025 17:38:49 -0500 Subject: [PATCH 1/2] refactor: return status instead of boolean on `Publish` --- src/cls/IPM/Lifecycle/Base.cls | 2 +- src/cls/IPM/Repo/IPublishService.cls | 2 +- src/cls/IPM/Repo/Remote/PublishService.cls | 12 ++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cls/IPM/Lifecycle/Base.cls b/src/cls/IPM/Lifecycle/Base.cls index 0f2e9c79..38df90f8 100644 --- a/src/cls/IPM/Lifecycle/Base.cls +++ b/src/cls/IPM/Lifecycle/Base.cls @@ -1403,7 +1403,7 @@ Method %Publish(ByRef pParams) As %Status } - Do tPublishClient.PublishModule(tModule) + $$$ThrowOnError(tPublishClient.PublishModule(tModule)) // May need to update the version of the currently-installed module. diff --git a/src/cls/IPM/Repo/IPublishService.cls b/src/cls/IPM/Repo/IPublishService.cls index e2e0a384..acd14e69 100644 --- a/src/cls/IPM/Repo/IPublishService.cls +++ b/src/cls/IPM/Repo/IPublishService.cls @@ -1,7 +1,7 @@ Class %IPM.Repo.IPublishService [ Abstract ] { -Method PublishModule(pModule As %IPM.Repo.Remote.ModuleInfo) As %Boolean [ Abstract ] +Method PublishModule(pModule As %IPM.Repo.Remote.ModuleInfo) As %Status [ Abstract ] { } diff --git a/src/cls/IPM/Repo/Remote/PublishService.cls b/src/cls/IPM/Repo/Remote/PublishService.cls index 7522ed2e..70375246 100644 --- a/src/cls/IPM/Repo/Remote/PublishService.cls +++ b/src/cls/IPM/Repo/Remote/PublishService.cls @@ -1,12 +1,17 @@ Class %IPM.Repo.Remote.PublishService Extends (%IPM.Repo.Remote.PackageService, %IPM.Repo.IPublishService) { -Method PublishModule(pModule As %IPM.Repo.Remote.ModuleInfo) As %Boolean +Method PublishModule(pModule As %IPM.Repo.Remote.ModuleInfo) As %Status { - Quit ..Publish(pModule) + Try { + Do ..Publish(pModule) + } Catch Ex { + Return Ex.AsStatus() + } + Return $$$OK } -Method Publish(pModule As %IPM.Repo.Remote.ModuleInfo) As %Boolean +Method Publish(pModule As %IPM.Repo.Remote.ModuleInfo) { If ((..Username="") || (..Password="")) && (..Token="") { $$$ThrowStatus($$$ERROR($$$GeneralError, "Publishing module, authorization required.")) @@ -28,7 +33,6 @@ Method Publish(pModule As %IPM.Repo.Remote.ModuleInfo) As %Boolean $$$ThrowStatus($$$ERROR($$$GeneralError, tMessage)) } } - Return 1 } Method CheckUnpublishEnabled(packageName As %String, packageVersion As %String) As %Boolean From 75e9b5ca9a680235865a7e917d530729f80b631c Mon Sep 17 00:00:00 2001 From: Shuheng Liu Date: Wed, 8 Jan 2025 17:45:04 -0500 Subject: [PATCH 2/2] chore: update change log This change doesn't affect any functionality in v0.9, but will matter in v0.10 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b36f587..f0021f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - #678 Only update comment-flagged part of the language extension, allowing users to keep their custom code when upgrading - #680, #683 Always export static files (README.md, LICENSE, requirements.txt, CHANGELOG.md) if existent +### Security +- #697 When publishing modules, will get an status with error message (instead of just a boolean) in case of failures. + ## [0.9.1] - 2024-12-18 ### Added