Skip to content

Commit 329ccfd

Browse files
isc-jlechtneJames LechtnerCarolina Borbon Miranda
authored
Packaging should recognize resources in dependency modules set to deploy (#1123)
* Packaging should recognize resources in dependency modules set to deploy * No need to check export path specifically just that the recurse flag is present * Removing phaselist check + unused variables * integeration test --------- Co-authored-by: James Lechtner <James.Lechtner@intersystems.com> Co-authored-by: Carolina Borbon Miranda <carolina.borbonmiranda@intersystems.com>
1 parent ffba34e commit 329ccfd

5 files changed

Lines changed: 51 additions & 21 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- #1102: %IPM.Storage.QualifiedModuleInfo:%New() will now copy over version properties when passed in a resolvedReference
1818
- #1112: Packaging a module with a globals resource now respects SourcesRoot, placing the exported file at the correct path in the tarball
1919
- #1057: Fix IPM not cleaning up after itself on self-uninstall
20+
- #1122: Packaging should recognize resources in dependency modules set to deploy
2021

2122
## [0.10.6] - 2026-02-24
2223

src/cls/IPM/Lifecycle/Base.cls

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,16 +1190,6 @@ Method %Export(
11901190
}
11911191
}
11921192

1193-
// Deployed items should be exported as a studio project to a designated directory
1194-
set tDeployedProjectName = ##class(%IPM.Utils.Module).GetDeployedProjectName(..Module.Name)
1195-
set tDeployedProject = ##class(%Studio.Project).%OpenId(tDeployedProjectName)
1196-
if '$isobject(tDeployedProject) {
1197-
set tDeployedProject = ##class(%Studio.Project).%New()
1198-
set tDeployedProject.Name = tDeployedProjectName
1199-
}
1200-
do tDeployedProject.Items.Clear()
1201-
set tParams($$$DeployedProjectIndex) = tDeployedProject
1202-
12031193
set tModuleName = ""
12041194
set exportPythonDependencies = $get(pParams("ExportPythonDependencies"), 0)
12051195
for {
@@ -1215,14 +1205,26 @@ Method %Export(
12151205
}
12161206
kill tSingleModuleArray
12171207
merge tSingleModuleArray = tResourceArray(tModuleName)
1208+
1209+
// Deployed items for each module + dependency should be exported as a studio project to a designated directory
1210+
set tDeployedProjectName = ##class(%IPM.Utils.Module).GetDeployedProjectName(tModuleName)
1211+
set tDeployedProject = ##class(%Studio.Project).%OpenId(tDeployedProjectName)
1212+
if '$isobject(tDeployedProject) {
1213+
set tDeployedProject = ##class(%Studio.Project).%New()
1214+
set tDeployedProject.Name = tDeployedProjectName
1215+
}
1216+
do tDeployedProject.Items.Clear()
1217+
set tParams($$$DeployedProjectIndex) = tDeployedProject
1218+
12181219
do ..ExportSingleModule(.tSingleModuleArray, pTargetDirectory, .pDependencyGraph, .tParams, tVerbose)
1219-
}
12201220

1221-
// Export the deployed project to the target directory, if it's non-empty
1222-
if tDeployedProject.Items.Count() > 0 {
1223-
// Intentionally not calling .%Save() on the project; we don't want to persist it.
1224-
set tDeployedProjectPath = ##class(%IPM.Utils.Module).GetDeployedProjectPath(pTargetDirectory)
1225-
$$$ThrowOnError(tDeployedProject.DeployToFile(tDeployedProjectPath, $select(tVerbose:"d",1:"-d")_"/createdirs"))
1221+
// Export the deployed project for this module to the target directory, if it's non-empty
1222+
if tDeployedProject.Items.Count() > 0 {
1223+
// Intentionally not calling .%Save() on the project; we don't want to persist it.
1224+
set tDeployTargetDirectory = pTargetDirectory _ $get(pDependencyGraph(tModuleName, "Location"))
1225+
set tDeployedProjectPath = ##class(%IPM.Utils.Module).GetDeployedProjectPath(tDeployTargetDirectory)
1226+
$$$ThrowOnError(tDeployedProject.DeployToFile(tDeployedProjectPath, $select(tVerbose:"d",1:"-d")_"/createdirs"))
1227+
}
12261228
}
12271229

12281230
/// Always keep these files

src/cls/IPM/Lifecycle/Module.cls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ Method %Package(ByRef pParams) As %Status
135135
{
136136
set tSC = $$$OK
137137
try {
138+
if ($get(pParams("ExportDependencies"), 0)) {
139+
set pParams("Recurse") = 1
140+
}
138141
set tVerbose = $get(pParams("Verbose"))
139142
if ..Module.HaveToDeploy() {
140143
$$$ThrowOnError(..MakeDeployed(.pParams))

src/cls/IPM/ResourceProcessor/Default/Document.cls

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,11 @@ Method OnExportDeployedItem(
280280
try {
281281
set tVerbose = $get(pParams("Verbose"),0)
282282
set tDeveloperMode = $get(pParams("DeveloperMode"),0)
283-
if (tDeveloperMode || ('..ResourceReference.Deploy) || ('$listlength(..ResourceReference.Module.Lifecycle.PhaseList))) {
284-
// Only export deployed items if we say to, are in a non-developer-mode context, and are currently executing module lifecycle phases.
285-
// OnExportItem may also be called from a source control extension context, and in this case PhaseList will be empty.
283+
if (tDeveloperMode || ('..ResourceReference.Deploy)) {
284+
// Only export deployed items if they are marked for deploy, we are in a non-developer-mode context
286285
quit
287286
}
288-
set tModuleName = ..ResourceReference.Module.Name
289287
set fileExt = $$$ucase($piece(pItemName, ".", *))
290-
set tName = $piece(pItemName, ".", 1, * - 1)
291288
quit:'($listfind($listbuild("CLS","MAC","INT"), fileExt))
292289
if $data(pParams($$$DeployedProjectIndex), deployedProject) {
293290
if tVerbose {

tests/integration_tests/Test/PM/Integration/DeployedItems.cls

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,31 @@ Method TestPublishWithoutDevMode()
103103
do ..DeployedItemsHelper(1)
104104
}
105105

106+
Method TestDeployedDependencies()
107+
{
108+
do ..SetupModule()
109+
110+
set tmpDir = $$$FileTempDir _ "package"
111+
set sc = ##class(%IPM.Main).Shell("package " _..#ModuleName _ " -v -export-deps 1 -path " _ tmpDir)
112+
do $$$AssertStatusOK(sc, "Successfully packaged module to "_tmpDir)
113+
114+
// Uninstall modules and delete repos, then load from tarball
115+
set sc = ##class(%IPM.Main).Shell("uninstall -all")
116+
do $$$AssertStatusOK(sc, "Successfully uninstalled modules")
117+
set sc = ##class(%IPM.Main).Shell("repo -delete-all")
118+
do $$$AssertStatusOK(sc, "Successfully deleted repos")
119+
set sc = ##class(%IPM.Main).Shell("load -v "_tmpDir_".tgz")
120+
do $$$AssertStatusOK(sc, "Successfully loaded module with deployed items at "_tmpDir)
121+
122+
// Check the class properties to confirm loaded as deployed
123+
set baseClass = ##class(%Dictionary.ClassDefinition).%OpenId("DeployableTest.Main")
124+
do $$$AssertTrue(baseClass.Deployed, "Base class deployed.")
125+
set depClass = ##class(%Dictionary.ClassDefinition).%OpenId("DeployableDepTest.Main")
126+
do $$$AssertTrue(depClass.Deployed, "Dep class deployed.")
127+
128+
// Uninstall module and reset registry
129+
do ..UninstallModule()
130+
do ..RestoreDefaultRegistry()
131+
}
132+
106133
}

0 commit comments

Comments
 (0)