Move files by keyword #75
Replies: 1 comment 1 reply
-
Hey @matiaseche thanks for the kind words and providing feedback. We actually started with the same CLI tools too ( The gem currently doesn't have much tooling to find files to move based on any heuristics. The only thing it can do at the moment is accept files and folders. One small addition that maybe could help is having it accept globs, but I chose not to add that since you can always pass in an expanded glob into the public API: UsePacks.move_to_pack!(
pack_name: 'packs/my_pack',
paths_relative_to_root: paths_relative_to_root,
) So in this case, you could use the public API and pass in an identical glob, i.e. paths_relative_to_root = Dir.glob('**/namespace/**') If you wanted to pass in files that contain a certain string, you could do: paths_relative_to_root = Pathname.glob('**/**').select{|p| p.read.include?('my_keyword')} I know it's not quite as convenient as being able to do it on the command line, but I imagine that big messy moves involving heuristic based matching probably happen a bit more rarely than surgical moves of single files or folders. Let me know what ya think! |
Beta Was this translation helpful? Give feedback.
-
Hello 👋
I've been working a lot with modularization lately in a big monolith, using all the tools available at
rubyatscale
. Thanks for developing and maintaining such useful tools!This particular gem,
use_packs
I have not yet used, because it feels repetitive.For the codebase I am working on, I wrote a bash script to create packs which follows these pattern:
What this does is:
pack_name
, if it already exists then it goes to the next step.-k
flag (except for a list of directories like "db/", "public/", "bin", "packs", "fixtures" and others)-f
is given, only files underfolder
and containing the keyword in their path will be moved.So for example:
Will move all files that have
namespace/
in their path to the created pack, which eases the process of moving files and is less repetitive.With these approach all files under
app/**/namespace/*
,config/locales/**/namespace/*
andtest/**/namespace/*
will be moved.This does not guarantee that all the files moved are the ones that should be on the pack, but it sure moves most. Then after reviewing the changes the developer can note if a file is not supposed to be there and revert that change.
Using
use_packs
it would have been the same command, but repeat for models, controlles, views, helpers, jobs, mailers, and whatever other folders are in the app, and then the same for tests.Does this make sense? Would it be useful to add a functionality to support this to the gem? What approaches have you used to ease this process?
Beta Was this translation helpful? Give feedback.
All reactions