-
Notifications
You must be signed in to change notification settings - Fork 323
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
Support Prototype Kit v13 #2851
Conversation
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.
Thanks for doing this! Looks good, my only comment / suggestion is re adding some tests
@@ -10,5 +10,120 @@ | |||
], | |||
"sass": [ | |||
"/govuk/all.scss" | |||
], | |||
"nunjucksComponents": [ |
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.
If we can't generate this programatically, it might be worth adding something to /tasks/gulp/__tests__/after-build-package.test.js
to check that all components are in this list, and that the referenced file
looks correct and exists.
That'll then hopefully prevent us from forgetting to e.g. add new components to the list.
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's fair. If that can be picked up by automated tests then it can be generated automatically too :)
14e5ba0
to
addcb23
Compare
addcb23
to
dfeca3a
Compare
Could someone from the Design System Team take a look at the test failure here please? I tried to fix it locally before pushing but I'm not clear on the target output and the mechanism of the test itself. It's failing because of the addition of a Javascript file, I'm not sure whether I've put the file in the right location or not. I've tested this latest update with different versions of the prototype kit, it works against versions 11-13 (and I have no reason to believe it would fail in any version which uses extensions). There's a few things that have changed in v13 which are supported with this change:
I've included a If these things aren't provided by
The user can work around points 1-3 and we (the prototype kit team) should give them a way of working around point 4 but it would be great if we can release v13 of the kit containing a version of |
If I run The I don't think it makes sense to include Looking at the govuk-frontend/tasks/gulp/copy-to-destination.js Lines 112 to 119 in 64418c8
However, I think we probably only want to copy
So I think we can just remove the Would be good to get a second set of eyes on this from someone on the team to check I'm not missing something… |
dfba240
to
d8e353d
Compare
@nataliecarey @36degrees Just a comment to say this was picked up in #2876 to avoid Gulp change conflicts |
I think there are three things we need to decide on to unblock this:
Where the new CSS and JS files liveFor the purposes of separation, my preference would be to keep the new prototype-kit specific JS and CSS files outside of the
Where we author the new CSS and JS filesAt the minute, the So when the package is built, the (It's worked like that since it was added in #1102 and I don't know how intentional this choice was) Option 1: Config in package, CSS + JS in srcThis is what we currently have. The config file only exists in the package folder, the CSS and JS are copied from src. Feels slightly messy / inconsistent? Option 2: Only add the new CSS and JS files to the package folderThis is consistent with what we're currently doing for the config file, but I'm not sure that's a precedent we want to follow. We generally tell people not to edit files in the Option 3: Config, CSS and JS live in srcThey'd be copied at build time, with any additional processing done as part of the build process (see the next section about dynamically generating parts of the config). I think this is my preference at the minute. Option 4: Separate packageWe release a separate npm package for the kit which either includes or depends on govuk-frontend and includes the files needed for integration. (I've included this for completeness, but don't think we want to do this as it introduces an extra level of dependency versioning that we just don't need at this time.) Whether to automatically generate the
|
I'd go with Option 3 and (controversially) delete Feels like we should be able to pull any commit, install, and build the generated files: ./node_modules
./public
./sassdoc
./package
./dist |
Separating prototype kit specific code into its own folder sounds good to me, and I'd say that both config and JS and SCSS files should live there as well (option 3), even if we don't manipulate the config file and just copy a manually authored one across. That said, I'd be in favour of building the config file rather than authoring manually and adding a test. |
I'm not impacted by the outcome, I'm just saying this to help if I can.
Would someone like to pair on this over the next few working days? |
This is a big change and I see no reason to tie it to this work, so I'd like to consider this out of scope. If this is something we want to explore, we should consider it as part of the other future architectural changes for GOV.UK Frontend.
I think this would require a change to the Prototype Kit as I think it only looks in the top-level of each node module? If this is something you're open to I think having it all within a single folder would be good 👍🏻
👍🏻
Pairing between the two teams sounds good, but I don't think I'm personally going to have capacity for this in the next few days – but think this is good for anyone to pick up? I have raised an issue to track this work, added it to our sprint backlog and the milestone for the next release – @nataliecarey if you have a chance to review it and make sure it covers everything we need to do, that'd be great. |
Makes sense.
Sorry, I wasn't clear - I meant that you could put those files all together and the build job could move the config file into place.
Anyone is welcome to reach out to me about pairing :) |
src/govuk/_govuk-prototype-kit.scss
Outdated
$govuk-global-styles: true; | ||
$govuk-new-link-styles: true; |
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.
These should be !default
so that users can opt out in the Prototype Kit settings file.
96387e2
to
d450d31
Compare
@nataliecarey I've rebased your branch just to make it a bit easier to make the fixes on our side |
d450d31
to
a5db0d9
Compare
c86888a
to
b802791
Compare
3361d59
to
5bd5cd3
Compare
b802791
to
2e1de86
Compare
…otoype kit. Tested against v11, v12 and v13.
5bd5cd3
to
fd61c2f
Compare
fd61c2f
to
4c2a150
Compare
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.
Approach looks sound to me, but I think we can rely on the existing tests for the 'after build tests' given we're only checking the files exist anyway.
(I think it'd be neater if the .js
and .scss
files were handled by the existing copy-files
task, but that looks like it's caught up in the fact that config.src is actually src/govuk
so happy to revisit that later)
describe('GOV.UK Prototype Kit', () => { | ||
let listingPackagePrototype | ||
|
||
beforeAll(async () => { | ||
listingPackagePrototype = await getListing(join(configPaths.package, 'govuk-prototype-kit')) | ||
}) | ||
|
||
it('should have JSON config', () => { | ||
expect(listingPackage) | ||
.toEqual(expect.arrayContaining(['govuk-prototype-kit.config.json'])) | ||
}) | ||
|
||
it('should have init.js', () => { | ||
expect(listingPackagePrototype) | ||
.toEqual(expect.arrayContaining(['init.js'])) | ||
}) | ||
|
||
it('should have init.scss', () => { | ||
expect(listingPackagePrototype) | ||
.toEqual(expect.arrayContaining(['init.scss'])) | ||
}) | ||
}) | ||
|
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.
These are already covered by the 'contains the expected files' test which:
- looks for a matching file for everything in the
src/
directory (apart from the excluded files), and so already expects corresponding files in the package forgovuk-prototype-kit/init.js
andgovuk-prototype-kit/init.scss
- includes
govuk-prototype-kit.config.json
in the list of 'extra' files
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.
Fab, just me being overly cautious. I'll remove 👍
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.
@36degrees These are gone now
I've also swapped the "already present" govuk-prototype-kit.config.json
with mapped replacement:
// Replaces GOV.UK Prototype kit config with JSON
.flatMap(mapPathTo(['**/govuk-prototype-kit.config.mjs'], ({ dir: requirePath, name }) => [
join(requirePath, '../', `${name}.json`)
]))
Similar to the YAML file transform, it shows the config is replaced with JSON a directory up (same name)
Not all `*.mjs` files qualify to be copied to `./govuk-esm/**/*.mjs`
Includes missing components and new locations for init styles/scripts
4c2a150
to
866286a
Compare
🙌 Amazing! Thanks so much all 😁 |
Includes: