-
Notifications
You must be signed in to change notification settings - Fork 237
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
Specify plugin dependencies #2220
Specify plugin dependencies #2220
Conversation
d979b06
to
f712d80
Compare
1a1d3ed
to
8236d62
Compare
d1ee672
to
5971a44
Compare
proof-of-concept.js
Outdated
@@ -0,0 +1,19 @@ | |||
const { startPerformanceTimer, endPerformanceTimer } = require('./lib/utils/performance') |
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.
We can remove the Proof of Concept now.
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.
Removed as requested
known-plugins.json
Outdated
@@ -9,6 +9,10 @@ | |||
"hmrc-frontend", | |||
"jquery", | |||
"notifications-node-client" | |||
], | |||
"mandatory": [ |
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'm nervous about "mandatory" including govuk-frontend
, it might be a naming thing. I presume this is to separate out the ones that the user can't uninstall in the UI at the moment?
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.
Yes, that's correct
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.
@joelanman I think the reason we removed the uninstall button was because this feature was needed before we could have it in. Should we put the uninstall button back in alongside govuk-frontend
now that dependent plugins dealt with?
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.
That was one reason, but I think it was more general than that - that the user experience in general relies on Frontend - if it's missing things look and feel broken. It'd be good to review the user experience when Frontend is removed to see what it's like. Seems like that work would block this, so maybe lets leave 'mandatory' for now and remove when we're ready
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.
just thinking 'required' might be better than 'mandatory' - one to run by @oli-rose28
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 agree that "required" is a better name than "mandatory" so I have made the change as suggested.
lib/plugins/plugin-validator.js
Outdated
if (typeof configEntry.packageName !== 'string') { | ||
errors.push(`In section ${key}, the packageName '${configEntry.packageName}' should be a valid package name`) | ||
} | ||
if (typeof configEntry.minVersion !== '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.
This code suggests that minVersion has to be set, I was expecting both min and max to be optional and to accept strings as well as objects. e.g. I would see each of these as valid configs
"pluginDependencies": ["hmrc-frontend"]
"pluginDependencies": [{
"packageName": "@x-govuk/edit-prototype-in-browser",
"maxVersion": "1.0.0"
}]
"pluginDependencies": [{
"packageName": "@x-govuk/edit-prototype-in-browser",
"minVersion": "1.0.0"
}]
"pluginDependencies": [{
"packageName": "@x-govuk/edit-prototype-in-browser",
"minVersion": "0.1.1",
"maxVersion": "1.0.0"
}]
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.
Fixed as requested including some extra unit tests.
lib/plugins/packages.js
Outdated
]) | ||
|
||
if ([packageJson, pluginConfig, registryInfo].every(val => val === undefined)) { | ||
if (!version) { |
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.
Any reason why version
isn't in the array with the others?
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 point, I've added it
1f27f8a
to
81f4e71
Compare
0976800
to
b5007ba
Compare
lib/plugins/packages.js
Outdated
const packagesCache = {} | ||
|
||
// This allows npm modules to act as if they are plugins by providing the plugin config for them | ||
const proxyPluginConfig = { |
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 has been duplicated, we should keep one version (if it's needed in both places we should look up that one version in both places)
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'll remove the duplicate
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.
Removed the duplication and prevented a circular dependency
I think it's worth squashing the commits. Then it looks ready. |
e1b09b8
to
5f904cd
Compare
Added cache for config lookup.
5f904cd
to
015d0ea
Compare
See: Allow plugin developers to specify that their plugin is dependent on other plugins