-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add update and rollback commands, and cli new version update core plugin #132
Conversation
Codecov Report
@@ Coverage Diff @@
## master #132 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 3 5 +2
Lines 69 180 +111
Branches 10 25 +15
==========================================
+ Hits 69 180 +111
Continue to review full report at Codecov.
|
The update command will update all installed plugins by checking for any updated versions in the npm registry (with --interactive mode available). The clear command will uninstall all user-installed plugins (with --interactive mode available). This command is also aliased to `plugins:clear` 100% coverage on tests
…adobe namespaced core plugins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, I have noted a few possible issues.
I am not crazy about us adding more commands without a topic, the aio clear
command to me is a bit unclear what it does without digging deeper. ( no pun intended )
*/ | ||
async run () { | ||
const { flags } = this.parse(UpdateCommand) | ||
const spinner = ora() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use cli-ux.action.start/stop
and not add a dependency on ora
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually cli-ux
is not even a dependency of the base cli (check package.json). It just so happens to be a dependency of a dependency (I'm thinking runtime plugin). Also, I needed a spinner that "goes away" after use, cli-ux's spinner does not do that, nor can I specify an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the discover
command uses cli-ux
as well, which is not a dependency as I mentioned. In any case, we need to add cli-ux
as a dependency here because of cli.table
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did it ever work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i mentioned above "dependency of a dependency had cli-ux". so it was in node_modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a eslint plugin that would have detected this https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to mention (See the Slack thread), aio clear
is now aio rollback
. I reflected it in the issue description and title when I finalized the PR yesterday.
* @param {Array<InstalledPlugin>} installedPlugins | ||
* @returns {Array<ToUpdatePlugin} | ||
*/ | ||
async __processPlugins () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: At some point some of us started putting double __methodPrefix to signify that something is private or not exported. Personally, I don't really like this practice.
https://github.com/airbnb/javascript#naming--leading-underscore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I wanted the functions into a the helper module. But since these functions heavily use base command functionality (this.config, etc), I kept it here. Until we have private functions in EcmaScript classes, this visual convention would have to do. The only public contract we have with devs is the run() function, nothing else.
src/commands/update.js
Outdated
const { type, name, version: currentVersion } = plugin | ||
const latestVersion = await getNpmLatestVersion(name) | ||
let coreVersion = (type === 'core') ? currentVersion : null | ||
const needsUpdate = (latestVersion > currentVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we probably need to go full semver here and not just text compare, there are numerous edge cases which I don't see covered by tests. ie. v1.0.0
or 2.8.3-lts
https://www.npmjs.com/package/semver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, i'll fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@purplecabbage PR updated
…qual to core plugin versions
Description
The
update
command will update all installed plugins by checking for any updated versions in the npm registry (with --interactive mode available). Note that this will not check for any updates for any non @adobe namespaced core plugins, for compatibility reasons.The
rollback
command will uninstall all user-installed plugins (with --interactive mode available).Through a hook via the
@oclif/plugin-warn-if-update-available
plugin, npm is checked whether there is a newer version of the CLI available, and it will warn the user. This is shown at every command (can't turn it off) but it has a timeout of 7 days (so after 7 days of warnings, it won't prompt the user anymore).Motivation and Context
How Has This Been Tested?
npm test
manual tests
Types of changes
Checklist: