Skip to content

Commit 405afad

Browse files
James LechtnerJames Lechtner
authored andcommitted
Getting rid of "ci" command in place for "-from-lockfile" flag
1 parent bdecd8b commit 405afad

7 files changed

Lines changed: 23 additions & 122 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- #992: Implement automatic history purge logic
1212
- #973: Enables CORS and JWT configuration for WebApplications in module.xml
1313
- #1110: Add `iriscli` and `ipm` container utility scripts that are auto-installed to `~/.local/bin/` and `~/bin/` so they work both inside and outside of containers (Unix/Linux only)
14-
- #962: Adding zpm "ci" command to install from a lock file
14+
- #962: Adding zpm -from-lockfile flag to install/load from a lock file
1515

1616
### Fixed
1717
- #1001: The `unmap` and `enable` commands will now only activate CPF merge once after all namespaces have been configured instead after every namespace

src/cls/IPM/General/AbstractHistory.cls

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ ClassMethod InstallInit(Package As %IPM.DataType.ModuleName) As %IPM.General.Abs
6666
quit ..Init("install", Package)
6767
}
6868

69-
ClassMethod CleanInstallInit(Package As %IPM.DataType.ModuleName) As %IPM.General.AbstractHistory
70-
{
71-
quit ..Init("ci", Package)
72-
}
73-
7469
ClassMethod LoadInit(Package As %IPM.DataType.ModuleName = "") As %IPM.General.AbstractHistory
7570
{
7671
// Package name may not known at this point, so use a placeholder

src/cls/IPM/General/LockFile.cls

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,11 @@ ClassMethod InstallFromLockFile(
123123
set verbose = $get(params("Verbose"), 0)
124124

125125
set lockFilePath = ##class(%File).NormalizeFilename("module-lock.json", directory)
126-
set lockFileJSON = ##class(%DynamicObject).%FromJSONFile(lockFilePath)
126+
try {
127+
set lockFileJSON = ##class(%DynamicObject).%FromJSONFile(lockFilePath)
128+
} catch {
129+
$$$ThrowStatus($$$ERROR($$$GeneralError,$$$FormatText("Unable to parse lock file JSON at path: %1", lockFilePath)))
130+
}
127131

128132
set repositories = lockFileJSON.%Get("repositories", {})
129133
set dependencies = lockFileJSON.%Get("dependencies", {})
@@ -156,17 +160,15 @@ ClassMethod InstallFromLockFile(
156160
set version = depVals.version
157161
set repository = depVals.repository
158162

159-
// Call CleanInstall() on dependency modules but set flag "LockFileInstallStarted" so we don't try installing from the dependency module's lock file
160-
set commandInfo = "ci"
163+
// Call Install() on dependency modules but set flag "LockFileInstallStarted" so we don't try installing from the dependency module's lock file
164+
set commandInfo = "install"
161165
set commandInfo("data", "Verbose") = verbose
162166
set commandInfo("parameters","module") = repository_"/"_depName
163167
set commandInfo("parameters", "version") = version
164168
set commandInfo("data", "LockFileInstallStarted") = 1
169+
set commandInfo("data","FromLockFile") = 1
165170

166-
set commandInfo("data","cmd") = "ci"
167-
set commandInfo("data","CleanInstall") = 1
168-
169-
do ##class(%IPM.Main).CleanInstall(.commandInfo)
171+
do ##class(%IPM.Main).Install(.commandInfo)
170172
}
171173
}
172174

src/cls/IPM/Main.cls

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ load C:\module\root\path -env C:\path\to\env1.json;C:\path\to\env2.json
292292
<modifier name="extra-pip-flags" dataAlias="ExtraPipFlags" value="true" description="Extra flags to pass to pip when installing python dependencies. Surround the flags (and values) with quotes if spaces are present. Default flags are &quot;--target &lt;target&gt; --python-version &lt;pyversion&gt; --only-binary=:all:&quot;." />
293293
<modifier name="synchronous" value="false" deprecated="true" description="DEPRECATED. Dependencies are now always loaded synchronously with independent lifecycle phases doing their own multi-threading as needed." />
294294
<modifier name="force" aliases="f" value="false" description="Allows the user to load a newer version of an existing module without running update steps." />
295-
<modifier name="create-lockfile" aliases="lock" dataAlias="CreateLockFile" dataValue="1" description="Upon load, creates/updates the module's lock file." />
296-
<modifier name="from-lockfile" aliases="ci" dataAlias="LoadFromLockFile" dataValue="1" description="Load the module from the lock file present at the path." />
295+
<modifier name="create-lockfile" dataAlias="CreateLockFile" dataValue="1" description="Upon load, creates/updates the module's lock file." />
296+
<modifier name="from-lockfile" dataAlias="FromLockFile" dataValue="1" description="Load the module from the lock file present at the path." />
297297

298298
<!-- Parameters -->
299299
<parameter name="path" required="true" description="Directory on the local filesystem, containing a file named module.xml" />
@@ -420,7 +420,8 @@ install -env /path/to/env1.json;/path/to/env2.json example-package
420420
<modifier name="extra-pip-flags" dataAlias="ExtraPipFlags" value="true" description="Extra flags to pass to pip when installing python dependencies. Surround the flags (and values) with quotes if spaces are present. Default flags are &quot;--target &lt;target&gt; --python-version &lt;pyversion&gt; --only-binary=:all:&quot;."/>
421421
<modifier name="synchronous" value="false" deprecated="true" description="DEPRECATED. Dependencies are now always loaded synchronously with independent lifecycle phases doing their own multi-threading as needed." />
422422
<modifier name="force" aliases="f" value="false" description="Allows the user to install a newer version of an existing module without running update steps." />
423-
<modifier name="create-lockfile" aliases="lock" dataAlias="CreateLockFile" dataValue="1" description="Upon install, creates/updates the module's lock file." />
423+
<modifier name="create-lockfile" dataAlias="CreateLockFile" dataValue="1" description="Upon install, creates/updates the module's lock file." />
424+
<modifier name="from-lockfile" dataAlias="FromLockFile" dataValue="1" description="Load the module from the lock file present at the path." />
424425

425426
</command>
426427

@@ -795,26 +796,6 @@ generate /my/path -export 00000,PacketName2,IgnorePacket2^00000,PacketName3,Igno
795796
<example description="Display the current history retention setting.">config get HistoryRetain</example>
796797
</command>
797798

798-
<command name="ci">
799-
<summary>Installs a module from a lock file</summary>
800-
<description>
801-
Installs a module from its lock file. Will first install all listed repositories followed by dependency modules and then the base module.
802-
</description>
803-
804-
<!-- Examples -->
805-
<example description="Reads from the module-lock.json defined for mymodule and installs the repositories, module, and dependencies">
806-
ci mymodule 3.0.0
807-
</example>
808-
809-
<!-- Parameters -->
810-
<parameter name="module" required="true" description="Name of module on which to perform update actions" />
811-
<parameter name="version" description="Version (or version expression) of module to install; defaults to the latest available if unspecified." />
812-
813-
<!-- Modifiers -->
814-
<modifier name="verbose" aliases="v" dataAlias="Verbose" dataValue="1" description="Produces verbose output from the command." />
815-
<modifier name="path" aliases="p" value="true" description="Location of local tarball containing the updated version of the module. Overrides 'version' parameter if present." />
816-
</command>
817-
818799
</commands>
819800
}
820801

@@ -1103,8 +1084,6 @@ ClassMethod ShellInternal(
11031084
do ..Information(.tCommandInfo)
11041085
} elseif (tCommandInfo = "history") {
11051086
do ..History(.tCommandInfo)
1106-
} elseif (tCommandInfo = "ci") {
1107-
do ..CleanInstall(.tCommandInfo)
11081087
}
11091088
} catch pException {
11101089
if (pException.Code = $$$ERCTRLC) {
@@ -2401,7 +2380,7 @@ ClassMethod LoadInternal(
24012380
}
24022381

24032382
set tTargetDirectory = $get(tTargetDirectory, tDirectoryName)
2404-
if ($get(pCommandInfo("data", "LoadFromLockFile"))) {
2383+
if ($get(pCommandInfo("data", "FromLockFile"))) {
24052384
do ##class(%IPM.General.LockFile).InstallFromLockFile(tTargetDirectory, .tParams)
24062385
} else {
24072386
// When loading a module from a local folder, there might be a <mod root>/.modules/ folder containining dependencies.
@@ -2542,35 +2521,6 @@ ClassMethod Install(
25422521
$$$ThrowOnError(log.Finalize($$$OK, devMode))
25432522
}
25442523

2545-
ClassMethod CleanInstall(ByRef commandInfo) [ Internal ]
2546-
{
2547-
set moduleName = $get(commandInfo("parameters","module"))
2548-
set version = $get(commandInfo("parameters","version"))
2549-
set verbose = $get(commandInfo("data","Verbose"))
2550-
set log = ##class(%IPM.General.HistoryTemp).CleanInstallInit(moduleName)
2551-
2552-
// TODO: Add "path"? (see Update() for more info of calling install v load)
2553-
2554-
if verbose {
2555-
write !, "Going to run a clean install on "_moduleName
2556-
}
2557-
2558-
// Indicating to commandInfo that this is a clean install command, not an install or load command. commandInfo will be passed to either Install() or Load() to continue performing the update.
2559-
set commandInfo("data","cmd") = "ci"
2560-
set commandInfo("data","CleanInstall") = 1
2561-
//set log = ##class(%IPM.General.HistoryTemp).UpdateInit(moduleName)
2562-
2563-
// A path to a tarball is specified. Call ..Load() in order to load the newer version of the module.
2564-
set path = $$$GetModifier(pCommandInfo,"path")
2565-
if (path) {
2566-
set pCommandInfo("parameters","path") = path
2567-
do ..Load(.pCommandInfo, log)
2568-
} else {
2569-
// Forward execution to install
2570-
do ..Install(.commandInfo, log)
2571-
}
2572-
}
2573-
25742524
ClassMethod Reinstall(ByRef pCommandInfo) [ Internal ]
25752525
{
25762526
// Overriding defaults in the "data" array:

src/cls/IPM/Utils/Module.cls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ ClassMethod LoadModuleFromDirectory(
271271
{
272272
set tSC = $$$OK
273273
try {
274-
if $get(pParams("CleanInstall"), 0) && '$get(pParams("LockFileInstallStarted"), 0) {
274+
if $get(pParams("FromLockFile"), 0) && '$get(pParams("LockFileInstallStarted"), 0) {
275275
do ##class(%IPM.General.LockFile).InstallFromLockFile(pDirectory, .pParams)
276276
}
277277
set tVerbose = $get(pParams("Verbose"))
@@ -1252,8 +1252,8 @@ ClassMethod LoadNewModule(
12521252
}
12531253

12541254
// If installing from a lock file, don't need to load dependencies since dependencies will be installed in order anyways
1255-
if ('$get(params("CleanInstall"), 0)) {
1256-
do ..LoadDependencies(tModule, .params)
1255+
if ('$get(params("FromLockFile"), 0)) {
1256+
do ..LoadDependencies(tModule,,.params)
12571257
}
12581258

12591259

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

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -535,41 +535,6 @@ Method TestUpdate()
535535
}
536536
}
537537

538-
Method TestCleanInstall()
539-
{
540-
// Setup repo for "ci" test
541-
set repoName = "lock-file-base"
542-
do ##class(%IPM.Main).Shell("repo -n " _ repoName _ " -fs -path /home/irisowner/zpm/tests/integration_tests/Test/PM/Integration/_data/lock-test/mods-base-cases/")
543-
544-
// Call zpm "ci" on a simple module
545-
set moduleName = "lock-mod-a-no-deps"
546-
set command = "ci " _ moduleName
547-
set sc = ##class(%IPM.Main).Shell(command)
548-
do $$$AssertStatusOK(sc, "Successfully installed " _ moduleName _ " from lock file")
549-
550-
// get history
551-
set rs = ##class(%IPM.General.History).GetHistory(,,1)
552-
while rs.%Next() {
553-
do $$$AssertTrue(rs.%Get("ID") '= "")
554-
do $$$AssertEquals(rs.%Get("Action"), "ci")
555-
do $$$AssertEquals(rs.%Get("Package"), moduleName)
556-
do $$$AssertEquals(rs.%Get("Version_Major"), "1")
557-
do $$$AssertEquals(rs.%Get("Version_Minor"), "0")
558-
do $$$AssertEquals(rs.%Get("Version_Patch"), "0")
559-
do $$$AssertEquals(rs.%Get("UserName"), "irisowner")
560-
do $$$AssertTrue(rs.%Get("TimeStart") '= "")
561-
do $$$AssertTrue(rs.%Get("TimeEnd") '= "")
562-
do $$$AssertEquals(rs.%Get("Success"),1)
563-
do $$$AssertEquals(rs.%Get("Committed"),1)
564-
do $$$AssertEquals(rs.%Get("CommandString"), command)
565-
do $$$AssertEquals(rs.%Get("SourceMoniker"), "filesystem")
566-
do $$$AssertEquals(rs.%Get("SourceName"), repoName)
567-
}
568-
569-
// Remove this test's repo now that the test is over
570-
do ##class(%IPM.Main).Shell("repo -n " _ repoName _ " -fs -path /home/irisowner/zpm/tests/integration_tests/Test/PM/Integration/_data/lock-test/mods-base-cases/")
571-
}
572-
573538
/// Tests that history entries correctly record all phases of module operations.
574539
/// Verifies that:
575540
/// - Load and install operations record 5 phases: Initialize, Reload, Validate, Compile, Activate

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ Method Test06ModuleMultipleVersions()
205205
do $$$AssertStatusOK(sc, "Uninstalled "_moduleName)
206206

207207
// Install module from lock file
208-
set sc = ##class(%IPM.Main).Shell("ci "_moduleName)
208+
set sc = ##class(%IPM.Main).Shell("install -from-lockfile "_moduleName)
209209
do $$$AssertStatusOK(sc, "Able to install "_moduleName_" v"_latestVersion_" from the lock file")
210210

211211
// Confirm classes and dependencies get installed as well
@@ -236,7 +236,7 @@ Method Test06ModuleMultipleVersions()
236236
do $$$AssertStatusOK(sc, "Uninstalled "_moduleName)
237237

238238
// Install module from lock file
239-
set sc = ##class(%IPM.Main).Shell("ci "_moduleName_" "_olderVersion)
239+
set sc = ##class(%IPM.Main).Shell("install -from-lockfile "_moduleName_" "_olderVersion)
240240
do $$$AssertStatusOK(sc, "Able to install "_moduleName_" v"_olderVersion_" from the lock file")
241241

242242
// Confirm classes and dependencies get installed as well
@@ -272,8 +272,8 @@ Method Test07ModuleNoLockFile()
272272
do $$$AssertStatusOK(sc, "Uninstalled "_moduleName)
273273

274274
// This should fail due to no lock file
275-
set sc = ##class(%IPM.Main).Shell("ci "_moduleName)
276-
do $$$AssertStatusNotOK(sc, "zpm ""ci"" fails on module "_moduleName_"due to not having a lock file")
275+
set sc = ##class(%IPM.Main).Shell("install -from-lockfile "_moduleName)
276+
do $$$AssertStatusNotOK(sc, "Installing from a lock file fails on module "_moduleName_"due to not having a lock file")
277277
} catch e {
278278
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred in Test07ModuleNoLockFile.")
279279
}
@@ -318,25 +318,14 @@ Method Test10InstallViaLoad()
318318
set sc = ##class(%IPM.Main).Shell("uninstall -r " _ moduleName)
319319
do $$$AssertStatusOK(sc, "Successfully packaged " _ moduleName _ " and dependencies prior to load")
320320

321-
do $$$LogMessage("GOING TO repo -list")
322-
zpm "repo -list"
323-
324321
set sc = ##class(%IPM.Main).Shell("repo -delete -name lock-file-base")
325322
do $$$AssertStatusOK(sc, "Successfully removed repo lock-file-base prior to load")
326323
set sc = ##class(%IPM.Main).Shell("repo -delete -name lock-file-edge")
327324
do $$$AssertStatusOK(sc, "Successfully removed repo lock-file-edge prior to load")
328325

329-
do $$$LogMessage("GOING TO repo -list")
330-
zpm "repo -list"
331-
332326
set sc = ##class(%IPM.Main).Shell("load -from-lockfile " _ packagePath _ ".tgz")
333327
do $$$AssertStatusOK(sc, "Successfully loaded packaged module from its lock file")
334-
335-
do $$$LogMessage("GOING TO repo -list")
336-
zpm "repo -list"
337328
} catch e {
338-
do $$$LogMessage("GOING TO repo -list")
339-
zpm "repo -list"
340329
do $$$AssertStatusOK(e.AsStatus(),"An exception occurred in Test10InstallViaLoad.")
341330
}
342331
}
@@ -402,7 +391,7 @@ Method AssertInstallFromLockFileAsExpected(
402391
moduleName As %String,
403392
className As %String = "")
404393
{
405-
set sc = ##class(%IPM.Main).Shell("ci "_moduleName)
394+
set sc = ##class(%IPM.Main).Shell("install -from-lockfile "_moduleName)
406395
do $$$AssertStatusOK(sc, "Installed "_moduleName_" via the lock file successfully")
407396

408397
set sc = $$$OK

0 commit comments

Comments
 (0)