Skip to content

Commit 8a686d2

Browse files
committed
Fix: Resolve semver range to concrete version before CLI install/update
The CLI's installFramework and updateFramework expect a specific version tag, not a semver range. Passing targetVersionRange directly caused a 404 when the CLI tried to download a GitHub archive using the range as a branch name. Now resolves the range via getLatestVersion() first. Also fixes typo: getLatestFrameworkVersion param should be versionLimit not version (refs adaptlearning/adapt-cli#241).
1 parent 32433eb commit 8a686d2

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

lib/AdaptFrameworkModule.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ class AdaptFrameworkModule extends AbstractModule {
161161
if (version) {
162162
this.checkVersionCompatibility(version)
163163
}
164-
await this.runCliCommand('installFramework', { version: version ?? this.targetVersionRange })
164+
if (!version && this.targetVersionRange) {
165+
version = await this.getLatestVersion()
166+
}
167+
await this.runCliCommand('installFramework', { version })
165168
} catch (e) {
166169
this.log('error', `failed to install framework, ${e.message}`)
167170
throw e.statusCode ? e : this.app.errors.FW_INSTALL_FAILED.setData({ reason: e.message })
@@ -176,7 +179,7 @@ class AdaptFrameworkModule extends AbstractModule {
176179
*/
177180
async getLatestVersion () {
178181
try {
179-
return semver.clean(await this.runCliCommand('getLatestFrameworkVersion', { version: this.targetVersionRange }))
182+
return semver.clean(await this.runCliCommand('getLatestFrameworkVersion', { versionLimit: this.targetVersionRange }))
180183
} catch (e) {
181184
this.log('error', `failed to retrieve framework update data, ${e.message}`)
182185
throw this.app.errors.FW_LATEST_VERSION_FAILED.setData({ reason: e.message })
@@ -210,7 +213,10 @@ class AdaptFrameworkModule extends AbstractModule {
210213
if (version) {
211214
this.checkVersionCompatibility(version)
212215
}
213-
await this.runCliCommand('updateFramework', { version: version ?? this.targetVersionRange })
216+
if (!version && this.targetVersionRange) {
217+
version = await this.getLatestVersion()
218+
}
219+
await this.runCliCommand('updateFramework', { version })
214220
this._version = await this.runCliCommand('getCurrentFrameworkVersion')
215221
} catch (e) {
216222
this.log('error', `failed to update framework, ${e.message}`)

0 commit comments

Comments
 (0)