govuk-prototype-kit
govuk-prototype-kit copied to clipboard
dotfiles like gitignore can get lost
dotfiles (like .gitignore) can easily get lost, as most operating systems hide them by default.
This is a problem as the dotfiles are needed, for example .gitignore ignores node_modules, ensuring each time the prototype is cloned to a new machine, that machine has the correct node modules installed via npm install.
We've seen this happen quite a few times, for example:
https://github.com/DEFRA/grants-prototype
Was going to open a new issue but found this one.
The documentation definitely needs to include a way to protect the .gitignore, as following it to the latter means people push the node_modules folder and create over 5k diff changes. I've seen it happen a few times now after prototype updates and it can cause VSCode to crash if you have the git features turned on. It becomes a real headache to undo.
@joelanman and I discussed this on Slack, but just for transparency and it all being in one place I'll repeat it here. =)
I believe one of the ways the .gitignore can get lost is by using the 'select all' function to highlight files before deleting as it will scoop up hidden files also. For example:
- open the
govuk-prototype-kitfolder - press
shift + cmd + .to show hidden files and make sure they're there - press
shift + cmd + .to hide them again - press
cmd + ato highlight all files - press
shiftand select the app folder to remove it from the selection - delete everything still highlighted
- press
shift + cmd + .and you should see no hidden files as they've been deleted
The second way I believe they can get lost is if you mix and match the delete and copy functions between the code editor and File Explorer. For example, if you use Atom or VSCode to delete all of the files, it will also remove hidden files and the .git ignore as they're shown in the code editor by default. If you then use the mouse to highlight and drag the new files from File Explorer back in, the hidden files aren't carried over as they're hidden by default.
I suspect one of the common ways people loose them is when installing.
- The kit installs to a
govuk-prototype-kitfolder - They've already made a folder
example-prototype - They select and drag all the files from one folder to the next.
we have this code to check for and create a .env if it is missing, but @abbott567 pointed out this won't work reliably for .gitignore, as someone could commit and push without running the kit
https://github.com/alphagov/govuk-prototype-kit/blob/master/start.js#L43-L49
basically dotfiles are a pain
It could be worth having the check in as a measure, as (I assume) a high percentage of people would run the kit to test it before pushing code. But, yeah it wouldn't be 100% effective.
Another solution could be to use terminal commands to remove the files so there is less variables. For example:
cd YOUR_PROJECTfind . \! \( -name 'app' -o -name '.gitignore' -o -name '.git' \) -delete
The command would then find and delete all of the files in theproject with the exception of the .gitignore file and the app and .git directories.
The risk is, if you ran it in the wrong directory it would delete everything recursively apart from those files and directories.
we could make a script to do commands like these for users, maybe that would be safer. You can have it run for instance on npm run update
seen this happen again - missing .gitignore
Another example https://github.com/DEFRA/wtp-glw-prototype/
seen this happen again in support
another issue on support, this time it had been replaced with a different version. I'm guess it got lost then someone copied in this: https://github.com/github/gitignore/blob/main/Node.gitignore
@joelanman to merge with missing starter files ticket
closing in favour of
- https://github.com/alphagov/govuk-prototype-kit/issues/1619