adaptlearning / adapt-cli

Command line and library interface for the Adapt Framework
https://community.adaptlearning.org/
24 stars 21 forks source link

update fails if a plugin is not bower registered #180

Closed chris-steele closed 4 weeks ago

chris-steele commented 1 year ago

Subject of the issue/enhancement/features

Running adapt update may produce a runtime error if there are plugins not registered with bower registry being used.

The cause seems to be trying to read _sourceInfo in getMatchingVersion (Plugin.js). The property is null if trying to retrieve bower info from a registry that does not have the requested plugin registered.

Your environment

Steps to reproduce

See description

Expected behaviour

The update command should skip unregistered plugins

Actual behaviour

 Cannot read properties of null (reading 'framework')
    at getMatchingVersion (file:///C:/Users/Chris/AppData/Roaming/nvm/v16.18.1/node_modules/adapt-cli/lib/integration/Plugin.js:296:79)
    at Target.findCompatibleVersion (file:///C:/Users/Chris/AppData/Roaming/nvm/v16.18.1/node_modules/adapt-cli/lib/integration/Plugin.js:321:33)
    at file:///C:/Users/Chris/AppData/Roaming/nvm/v16.18.1/node_modules/adapt-cli/lib/integration/PluginManagement/update.js:115:22
    at file:///C:/Users/Chris/AppData/Roaming/nvm/v16.18.1/node_modules/adapt-cli/lib/util/promises.js:16:12
    at C:\Users\Chris\AppData\Roaming\nvm\v16.18.1\node_modules\adapt-cli\node_modules\async\dist\async.js:151:38
    at replenish (C:\Users\Chris\AppData\Roaming\nvm\v16.18.1\node_modules\adapt-cli\node_modules\async\dist\async.js:446:21)
    at C:\Users\Chris\AppData\Roaming\nvm\v16.18.1\node_modules\adapt-cli\node_modules\async\dist\async.js:451:13
    at eachOfLimit$1 (C:\Users\Chris\AppData\Roaming\nvm\v16.18.1\node_modules\adapt-cli\node_modules\async\dist\async.js:477:34)
    at C:\Users\Chris\AppData\Roaming\nvm\v16.18.1\node_modules\adapt-cli\node_modules\async\dist\async.js:219:25
swashbuck commented 5 months ago

It looks like there is a similar error when running adapt ls.

swashbuck commented 2 months ago

https://github.com/adaptlearning/adapt-cli/blob/5950af660ee756731cac71670d887896b83c286b/lib/integration/Plugin.js#L292

@oliverfoster What about changing this line to:

if (!this.isPresent || !this._sourceInfo?.version || !this._sourceInfo?.framework) return null;

This seems to resolve the issue.

oliverfoster commented 1 month ago

I can't replicate on version 3.1.4 in either case, for adapt update and adapt ls. I've tested with a local plugin and with a non existent plugin in the adapt.json file.

Please reopen if you have replication instructions.

swashbuck commented 1 month ago

@oliverfoster I am also using 3.1.4. Will you try this?

  1. In your extensions directory, git clone git@github.com:cgkineo/adapt-toc.git
  2. Optionally, add it to your adapt.json with "adapt-toc": "*". I get the error either way.
  3. Run adapt update --check

Result:

TypeError: Cannot read properties of null (reading 'framework')
    at getMatchingVersion (file:///Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/lib/integration/Plugin.js:298:79)
    at Target.findCompatibleVersion (file:///Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/lib/integration/Plugin.js:323:33)
    at file:///Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/lib/integration/PluginManagement/update.js:115:22
    at file:///Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/lib/util/promises.js:16:12
    at /Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/node_modules/async/dist/async.js:151:38
    at replenish (/Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/node_modules/async/dist/async.js:448:21)
    at iterateeCallback (/Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/node_modules/async/dist/async.js:432:21)
    at /Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/node_modules/async/dist/async.js:329:20
    at invokeCallback (/Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/node_modules/async/dist/async.js:182:13)
    at /Users/bradsimpson/.nvm/versions/node/v20.11.1/lib/node_modules/adapt-cli/node_modules/async/dist/async.js:174:13
oliverfoster commented 1 month ago

That helped. Thanks.

github-actions[bot] commented 4 weeks ago

:tada: This issue has been resolved in version 3.1.5 :tada:

The release is available on:

Your semantic-release bot :package::rocket: