is there a commandbox command to remove unused pac...
# box-products
r
is there a commandbox command to remove unused packages? (unused meaning not found in box.json)
g
That is a good question. I didn't see one but if you need to, just delete the modules folder and do an install. Everything will get installed again.
👍 1
r
Thats what I did. Just interested though
g
One thing you can do is create a script and put in
box.json
. Something like:
Copy code
"scripts":{
        "cleanInstall":"delete modules --force --recurse;install"
    }
You can then run it from CommandBox as:
run-script cleanInstall
This will delete the modules folder and then install everything
I don't normally do much in the modules directory unless I am debugging something. That could be a handy way of doing a hard reset from the command line 🙂
r
Gotcha. Im playing around with automated deployments which is why im asking
g
depending on your setup, the deploy script can take care of deleting the directory, then just do an install. There are probably nicer ways to handle that depending on what you are trying to do. If you are always pulling a fresh container, then it shouldn't matter. If just updating a directory on the server, you can run that command
delete modules --force --recurse;install
and just have it take care of it for you.
💯 1
b
@Ryan Albrecht Generally speaking, the answer is no.
Mostly because CommandBox doesn't know what it doesn't know. It's an easier problem if all the packages CommandBox installed were in a folder like
modules
. It's harder when you account for all the packages (like coldbox, or testbox) which can be installed anywhere on disk with a custom install path.
So literally any folder on your hard drive COULD have been installed by CommandBox. 🙂
It would be fairly trivial to write a custom command which removed extra folders in common places like
modules
by just comparing all the top level folders against the
installPaths
key in
box.json
.
I've also been asked about a way to re-associate modules in the
box.json
which you want to keep installed, but have gotten untracked.
r
@bdw429s thanks for the info. Normally I just delete the modules folder
As i said im learning CI/CD which I have never really done before