shadcn-svelte
shadcn-svelte copied to clipboard
Remove outdated files on CLI update
Describe the feature
With #776, some Form component files have been deleted in favor of others. Using the CLI update adds the new files and updates the modified ones, but does not remove the no-longer-existing ones.
As I’m implementing this feature in my JetBrains plugin, can I also push the change to the CLI update command?
Hmm, I'm not sure we should go deleting all files in a folder that we don't own (and we aren't going to keep a running record of all past files). I'll defer to @AdrianGonz97 to get his thoughts on this!
Yeah, I don't think deleting would be the best idea, especially when we're not keeping track of the history of files that we've created/own.
Perhaps printing a list of files that are potentially no longer needed would suffice instead?
we aren't going to keep a running record of all past files
No need for that! Just removing all files that are not currently listed remotely
Perhaps printing a list of files that are potentially no longer needed would suffice instead?
IMO that's not that an issue, but I get your fear. What about deleting them only if a git repository is initiated, else list the files? We could even check if the file starts with the name of the component (or == index.ts) as a triple check safety net.
But I'm pretty sure we should do something about it instead of leaving useless files in users' projects
We could even check if the file starts with the name of the component (or ==
index.ts) as a triple check safety net.
Still don't like this idea, if I create a custom form-input.svelte, I don't expect it to be obliterated by updating the form. At the moment, listing the files that exist that are "no longer necessary" is the only approach I feel comfortable with.
You also have to remember the whole idea behind this project. You own the code. You are responsible for keeping the components up to date and cleaning up any leftovers during an update.
Get it. You're right. Will do that!
this has been brought up in the past: https://github.com/huntabyte/shadcn-svelte/issues/530 and I also ran into this again today.
@huntabyte I understand:
Still don't like this idea, if I create a custom form-input.svelte, I don't expect it to be obliterated by updating the form.
but at the same time, say that I customize form-legend.svelte, then those changes are in fact obliterated by updating the form.
I personally believe that the warning that you should commit your changes before updating is enough, regardless if they are custom changes to existing files added by shadcn-svelte or custom changes to new files added by the user.
another example: the file names used by shadcn-svelte are not reserved in any way. if I have previously created a custom form-field.svelte component and then I update shadcn-svelte - it would now have been obliterated after https://github.com/huntabyte/shadcn-svelte/commit/3e858d268c17619c0e3a0e294a08841072dc5eb8#diff-5049016897f5c47ecf4cec09f654ac3cc993a3362db36a9b883bb7d18119d1e2 right?
therefore, I don't feel like this argument is super solid 🤔
at the very least, could this be a CLI option? so user who wants to remove unused files can do so with for example pnpx shadcn-svelte@latest update --all --clean or whatever that option could be called. that option would nuke the contents of each component directory before installing them again (which is what I have done now manually after detecting loads of false positives in linting errors stemming from old files)