Skip to content

Commit

Permalink
Merge pull request #6 from intersystems/fix-initial-install
Browse files Browse the repository at this point in the history
Allow file promotion *after* Activate
  • Loading branch information
isc-tleavitt authored Feb 17, 2023
2 parents 952b17a + ac3e76d commit f899235
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.2] - 2023-02-17
### Fixed
- Web application file copy handles package manager operation ordering more robustly (#4)

## [1.1.1] - 2022-09-30
### Fixed
- Web application files are copied to proper target, not the current working directory
Expand Down
66 changes: 40 additions & 26 deletions cls/pkg/isc/ipm/js/base/processor.cls
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,7 @@ Method OnBeforePhase(pPhase As %String, ByRef pParams) As %Status
// Compile the UI. Supposes npm is installed and on the PATH, but that's it.
Do ..RunBuild(.pParams)
} ElseIf (pPhase = "Activate") {
// Move files to the right place.
Set sourceDir = ##class(%Library.File).NormalizeDirectory(..GetSourceDirectory())
Set targetDir = ..GetTargetDirectory()
If (targetDir = "") {
// Should never happen, but good to be safe (and avoid using working directory)
$$$ThrowStatus($$$ERROR($$$GeneralError,"Target directory not specified."))
}
Set testFile = sourceDir_"index.html"
If '##class(%Library.File).Exists(testFile) {
$$$ThrowStatus($$$ERROR($$$GeneralError,$$$FormatText("File '%1' does not exist; will not activate %2 UI changes.",testFile,..#FLAVOR)))
}
If verbose {
Write !,"Activating "_..#FLAVOR_" application changes..."
Write !,"Copying ",sourceDir," to ",targetDir
}
$$$ThrowOnError(##class(%ZPM.PackageManager.Developer.File).CopyDir(sourceDir,targetDir,..clearTarget))
// Clear CSPGateway caches...
If verbose {
Write !,"Clearing CSPGateway caches..."
}
#dim registry As %CSP.Mgr.GatewayRegistry
Set registry = $System.CSP.GetGatewayRegistry()
$$$ThrowOnError(registry.RemoveFilesFromCaches(..GetTargetDirectory()_"*"))
If verbose {
Write !,..#FLAVOR," UI changes activated."
}
Do ..PromoteFiles(verbose,.pParams)
}
} Catch e {
Set tSC = e.AsStatus()
Expand All @@ -68,6 +43,9 @@ Method OnAfterPhase(pPhase As %String, ByRef pParams) As %Status
Do ..CleanSettings()
Set verbose = $Get(pParams("Verbose"),0)
If (pPhase = "Activate") {
If '..PromotedFiles(.pParams) {
Do ..PromoteFiles(verbose,.pParams)
}
Do ..PerformActivateFileReplacements()
}
} Catch e {
Expand All @@ -76,6 +54,42 @@ Method OnAfterPhase(pPhase As %String, ByRef pParams) As %Status
Quit tSC
}

Method PromotedFiles(ByRef pParams) As %Boolean
{
Quit $Get(pParams($classname(),..ResourceReference.Name,"PromotedFiles"),0)
}

Method PromoteFiles(verbose As %Boolean, ByRef pParams)
{
// Move files to the right place.
Set sourceDir = ##class(%Library.File).NormalizeDirectory(..GetSourceDirectory())
Set targetDir = ..GetTargetDirectory()
If (targetDir = "") {
// May happen due to a chicken-and-egg problem in module activation.
Quit
}
Set testFile = sourceDir_"index.html"
If '##class(%Library.File).Exists(testFile) {
$$$ThrowStatus($$$ERROR($$$GeneralError,$$$FormatText("File '%1' does not exist; will not activate %2 UI changes.",testFile,..#FLAVOR)))
}
If verbose {
Write !,"Activating "_..#FLAVOR_" application changes..."
Write !,"Copying ",sourceDir," to ",targetDir
}
$$$ThrowOnError(##class(%ZPM.PackageManager.Developer.File).CopyDir(sourceDir,targetDir,..clearTarget))
// Clear CSPGateway caches...
If verbose {
Write !,"Clearing CSPGateway caches..."
}
#dim registry As %CSP.Mgr.GatewayRegistry
Set registry = $System.CSP.GetGatewayRegistry()
$$$ThrowOnError(registry.RemoveFilesFromCaches(..GetTargetDirectory()_"*"))
If verbose {
Write !,..#FLAVOR," UI changes activated."
}
Set pParams($classname(),..ResourceReference.Name,"PromotedFiles") = 1
}

Method CleanSettings() [ Abstract ]
{
}
Expand Down
4 changes: 2 additions & 2 deletions module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<Export generator="Cache" version="25">
<Document name="isc.ipm.js.ZPM"><Module>
<Name>isc.ipm.js</Name>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
<Dependencies>
<ModuleReference>
<Name>isc.json</Name>
<Version>^2.0.0</Version>
</ModuleReference>
</Dependencies>
<Packaging>module</Packaging>
<Resource Name="pkg.isc.ipm.js.PKG" />
<Resource Name="pkg.isc.ipm.js.PKG" Directory="cls" />
<LifecycleClass>Module</LifecycleClass>
</Module>
</Document></Export>

0 comments on commit f899235

Please sign in to comment.