Skip to content

Commit 690c0c8

Browse files
authored
Merge pull request #30 from intersystems-community/package-description
Package description
2 parents 54283b5 + 570c93c commit 690c0c8

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

module.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<Document name="zpm-registry.ZPM">
44
<Module>
55
<Name>zpm-registry</Name>
6-
<Version>1.0.5</Version>
6+
<Description>Registry server for ZPM</Description>
7+
<Version>1.0.8</Version>
78
<Packaging>module</Packaging>
89
<SourcesRoot>src</SourcesRoot>
910
<Resource Name="ZPM.PKG"/>

src/cls/ZPM/Package.cls

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Property owner As %String;
1515

1616
Index Owner On owner;
1717

18-
Property description As %String(MAXLEN = 200, TRUNCATE = 1);
18+
Property description As %String(MAXLEN = 1000, TRUNCATE = 1);
1919

2020
Property keywords As list Of %String;
2121

@@ -173,6 +173,28 @@ ClassMethod Populate(Path As %String, kill = 0)
173173
}
174174
}
175175

176+
Method UpdateDescriptionFromManifest() As %Status
177+
{
178+
Try {
179+
//save xml to file
180+
Set tFileName = $$$FileTempDir_"/manifest.xml"
181+
Set stream=##class(%Stream.FileCharacter).%New()
182+
$$$ThrowOnError(stream.LinkToFile(tFileName))
183+
$$$ThrowOnError(stream.CopyFrom(..manifest))
184+
$$$ThrowOnError(stream.%Save())
185+
Kill stream
186+
$$$ThrowOnError(##class(%XML.XPATH.Document).CreateFromFile(tFileName, .tDocument))
187+
$$$ThrowOnError(tDocument.EvaluateExpression("/Module/Description", "text()", .tRes))
188+
If (tRes.Count()>0) {
189+
Set ..description = tRes.GetAt(1).Value
190+
}
191+
} Catch ex {
192+
Do ex.Log()
193+
return ex.AsStatus()
194+
}
195+
return $$$OK
196+
}
197+
176198
ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %Boolean = 0) As %Status
177199
{
178200
SET tStream = ##class(%Stream.FileCharacter).%New()
@@ -205,6 +227,10 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
205227
WRITE !,"Version: ", version
206228
}
207229

230+
SET tSC=tDocument.EvaluateExpression("/Export/Document/Module/Description", "text()", .tRes)
231+
IF $$$ISERR(tSC) Return tSC
232+
SET description = tRes.GetAt(1).Value
233+
208234
SET archive = ##class(%Stream.FileBinary).%New()
209235
SET archiveFileName = ##class(%File).TempFilename("tgz")
210236
SET archive.Filename = archiveFileName
@@ -220,6 +246,7 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
220246
do ..%DeleteId(name _ "||" _version)
221247
SET package = ..%New()
222248
SET package.name = name
249+
Set package.description = description
223250
Set package.repository = repository
224251
SET package.version = version
225252
SET package.package = archive
@@ -387,9 +414,9 @@ ClassMethod GetSSLConfiguration(host) As %String
387414
QUIT host
388415
}
389416

390-
Query ListLatest(searchTerm As %String = "") As %SQLQuery(ROWSPEC = "name:%String,repository:%String,version:%String")
417+
Query ListLatest(searchTerm As %String = "") As %SQLQuery(ROWSPEC = "name:%String,description:%String,repository:%String,version:%String")
391418
{
392-
SELECT name, repository, (
419+
SELECT name, description, repository, (
393420
SELECT TOP 1 version FROM ZPM.Package p2 WHERE p1.name=p2.name
394421
ORDER BY versionMajor DESC, versionMinor DESC, versionPatch DESC, versionPrerelease DESC, versionBuildmetadata DESC ) version
395422
FROM ZPM.Package p1

src/cls/ZPM/Registry.cls

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ ClassMethod PublishPackage() As %Status
158158

159159
set package = ##class(ZPM.Package).%New()
160160
$$$ThrowOnError(package.%JSONImport(%request.Content))
161-
161+
$$$ThrowOnError(package.UpdateDescriptionFromManifest())
162162
do ##class(ZPM.Package).NameVersionDelete(package.name, package.version)
163163
$$$ThrowOnError(package.%Save())
164164

@@ -206,6 +206,7 @@ ClassMethod AllPackages() As %Status
206206
While tRS.%Next() {
207207
Set tPkgInfo = {
208208
"name": (tRS.name),
209+
"description": (tRS.Description),
209210
"repository": (tRS.repository),
210211
"versions": [(tRS.version)]
211212
}

0 commit comments

Comments
 (0)