govuk-prototype-kit icon indicating copy to clipboard operation
govuk-prototype-kit copied to clipboard

Allow plugin authors to explicitly provide a name, organisation and documentation link

Open paulrobertlloyd opened this issue 1 year ago • 5 comments

Context

The plugins list attempts to infer the origin of a plugin from its npm scope:

Screenshot 2023-05-21 at 15 43 19

In this example we can see that:

  • @ministryofjustice => ‘Ministryofjustice’ (should be ‘Ministry of Justice’)
  • @xgovuk => ‘X-GOV.UK’ (should be ‘X-GOVUK’)

It should also be noted that while government departments will often change their names, npm organisation scopes may not be updated to match. Or they may use a shortened handle (DLHUC’s GitHub organisation name is communities, for example).

Further still, package names might not be enough to identity a plugin, for example ‘Frontend’,

There is also no link to any documentation related to these plugins. In the above screenshot these would be:

  1. https://prototype-kit.service.gov.uk/docs/
  2. https://design-patterns.service.justice.gov.uk
  3. https://x-govuk.github.io/govuk-prototype-components/

Alternatives

Given that plugins need to include a govuk-prototype-kit.config.json file, allow plugin authors to explicitly declare values for plugin name, organisation and documentation.

For example:

{
  "name": "Ministry of Justice Frontend",
  "organisation": "Ministry of Justice",
  "documentation": "https://design-patterns.service.justice.gov.uk",
  "nunjucksFilters": [
    "/moj/filters/prototype-kit-13-filters.js"
  ],
  "scripts": [
    "/moj/all.jquery.min.js",
    "/moj/init.js"
  ],
  ...
}

paulrobertlloyd avatar May 21 '23 15:05 paulrobertlloyd

Thanks! Good timing, we are looking into these issues at the moment, great to get your input. I agree naming via config gives more flexibility and control, however some points naming via npm give us:

  1. Uniqueness - we won't have 2 plugins with the same name and org name, and
  2. Some level of verification - we can trust that a certain org on npm are who they claim to be

Any thoughts on those?

joelanman avatar May 23 '23 17:05 joelanman

How about something like this:

Screenshot 2023-05-23 at 18 57 26

Where

  • plugin name is config.name else package.name with existing text transformation applied
  • hint text is always package.name, and something that can’t be altered by a plugin config

So, without any changes, MOJ Frontend would appear as

Frontend
@ministryofjustice/frontend

But if config.name is provided:

Ministry of Justice Frontend
@ministryofjustice/frontend

With this approach, you wouldn’t need an organisation name in the config, either.

paulrobertlloyd avatar May 23 '23 17:05 paulrobertlloyd

nice thanks! We'll continue the conversation in the team and update here. Feel free to add more ideas if you have them!

joelanman avatar May 24 '23 08:05 joelanman

raised a ticket to discuss as a team: https://github.com/alphagov/govuk-prototype-kit/issues/2222

joelanman avatar Jun 09 '23 10:06 joelanman

+1 to the suggestions above.

Some libraries might want to provide multiple links for documentation or other resources. For example, it might make sense to link from the GOV.UK Frontend plugin to both the Design System and Frontend Docs.

36degrees avatar Jun 09 '23 12:06 36degrees