-
Notifications
You must be signed in to change notification settings - Fork 168
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
Rewrite for 6.0 #624
base: master
Are you sure you want to change the base?
Rewrite for 6.0 #624
Conversation
Spread some single quote love Remove metaprogrammed method definitions from deployer Base Here start the long way of a refactor. I've simply explicitly defined the methods, removing the metaprogramming pain. Bloatet and verbose, but easy to follow and to read. WordpressDirectory::Path module no more in a separate file Rename type variable to folder, and change `attr_accessor`s to `attr_reader`s Add tests for WordpressDirectory Extract directory methods into modules Freeze `options` inside Deployer::Base instead of cloning theme; cloning was useless and it consumes unnecessary memory. Rename `name` variable into `config_file_name` in Movefile` Refactor Movefile class Major changes: * `initialize` now requires whole `cli_options`, not just the config part. This changes the internal API, but free the implementor from passing `cli_options` to all subsequent public methods such as `load_dotenv`, `environment` and `secrets`. Once the object is created, it has all the information it needs to do its work. * now all the classes below CLI want deep symbolized options. So options `Hash` from the movefile and cli options have to be symbolized in order to guarantee to be correctly managed. The mix of `Hash`es with string keys and with symbol keys was confusing, hard to understand and to use both in the logic and in tests * now `Movefile.fetch` is coupled within `new`, so once instantiated the object, you'll have access to `object.options` to retrieve all the options from the movefile file. `load_dotenv` is now a private method. WARNING: removing support for `.env.envName` files Start to write the first organizer Actions::Ssh::Concerns Require all actions Rename concerns in Helpers and do not use context as argument Fix typo Partial implementation for live testing + first debug Rename and move common ssh actions and helpers add photocopier actions Refactor Hooks to fit service object pattern and create hooks pull actions Thoughts in comments WordpressDirectoryHelperMethods are now class methods to fit into actions Pull Organizer now also manages hooks Making tests pass, mostly with skips during the refactor :) Before_actions can't stop actions; move to reduce_if Moved and refactored other helpers Written all the pull directories actions Ssh::Pull organizer now pretends one less param Wordmove::CLI.wordpress_options is now a class method GetDirectory moved under Ssh namespace and generalized Now it's more complex, but able to handle pulling any directory for an organizer Introducting FilterAndSetupTasksToRun and refactor Thanks to this action we're able to remove a lot of complexity from the organizer, since the Guardian is called one time ahead of all the actions sequence, no more one time for each action Clean up actions array in Pull organizer Update Guardian initialize signature with more clear param Commenting code to keep track of the refactored methods Add Actions::DeleteCommandFile Add Actions::RunLocalCommand Add Actions::Ssh::RunRemoteCommand Implement WpcliAdapter::PullDb Action/Organizer update movefile spec Call the Pull interactor from cli. FTP still to be done Ruby version 2.7.1 Refactor pull organizer removing action+organizer class Moving Rubocop to Ruby 2.7.1 Rubocop: no more prefere double quotes First turn of double to single quote conversion :) Add some comments to helpers Keyword argument for `uncompress_command` helper Add dry-configurable and create a configurable object for db paths Generalize `SetupContextForDB` and introduce db_paths into context Use the new `db_paths` in organized pull actions Generalize `CleanupAfterPull` to `CleanupAfterAdapt` `ImportRemoteDump` renamed to `PutAndImportDumpRemotely` and refactored s
Fix bug in AdaptRemoteDb Undefined method `waring` was called on logger Fix wrong signature on method call in AdaptRemoteDb Warn when db adapt is skipper SetupContextForDb won't run unless necessary Update some log messages for better clarity Fix mu-plugins key in mu_plugins. Fixes #619 Please the rubocop Remove FTP support and cleanup as consequently Re-implement #597 in this branch Improve wpcli_search_replace_command with argument check Add yard documentation Fix bug in FilterAndSetupTasksToRun action Was getting key by string on a symbolized hash Migreate from Thor do dry-cli Improve UX a bit w/ better log messages Remove unused WordpressDirectory::HelperMethods module Re-enable --debug flag Update version: will stick to a pre-release Update scaffold and namespace for organizers WIP: re-implement FTP support WIP: re-implement FTP support Fix typo and reword a variable WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support WIP: re-implement FTP support Update get_file_spec Update hook_spec Update rspec config Add adapt_local_db_spec Various cleanups, typos, rubocop disables Fix Wordmove::Movefile by removing - never triggered - wrong logic Update deps and please the (new) rubocop
ed376f0
to
12fe790
Compare
12fe790
to
99f977b
Compare
We had scenarios where failures were not interrupting the procedure even if expected.
I think it's better to warn on such failures than stop the whole procedure since they are not real blockers. I know it could be risky to leave undeleted files on the remote, but probably would be worst to leave an incomplete procedure during certain stages
e1fdecb
to
fb71062
Compare
bd3d297
to
eb1a41b
Compare
The only needed one is `local.wordpress_path` now. Other config are taken through - the now mandatory - wp-cli.
Wpcli_all_the_way
Sorry for the maybe stupid questions from a pixel pusher: Since from version 6 mysql and mysqldump options are no longer available, then the connection to the (local) database via socket also no longer works, right? Currently I use the following entries in the movefile.yml in connection with local (flywheel):
|
Hello @electricarts :) Thnaks for the inquiry. That's not correct or at least that's not intended :P Flags to the underlying mysql and mysqldump commands are still possible to be proxied by configuring wp-cli. I wrote something about it in a paragraph of this PR, but for sure a more structured documentation will follow the future release. Moreover I think that using wp-cli to do BD operations, as far as your wordpress is able to connect to the DB, then you should be able to go configuration-lessly: wp-cli reads configurations directly from your wordpress installation. That said I'd be more than happy to help you troubleshooting the specific flywheel scenario if you'd be able to perform some alpha or - soon - beta testing: I'm very interested in retaining support for such a widespread stack. Let me know and feel free to open a discussion if you need to chat about the matter :) P.S.: I've not yet tested the alpha against nothing but a plain standard WP install into a directory |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Alpha version for testing
If you have other versions installed, wipe it with
gem uninstall wordmove
, thengem install wordmove --version '6.0.0.alpha.8'
The alpha version is shipped for internal testing; everyone feels free to be courious, but I'd advice to test it against staging/testing environments and anyway be wise about your backups.
Why such a big refactor?
What was wrong
thus
Which goals?
Since Wordmove is almost doing what it was created to do for almost 10 years, I can't see huge room nor huge urgency to expand its functionalities. But it still has it's place in the "market", thus I'd like to keep it alive.
In order to keep it alive I had some goals:
How does this PR accomplish those goals?
New command line implementation
the command line implementation has been re-implemented using https://dry-rb.org/gems/dry-cli/. dry-rb is minimal, class based and heavily object oriented
Service objects all the way
All the core logic is now organised into service objects; we have two organisers for SSH
Wordmove::Organizers::Ssh::Push
andWordmove::Organizers::Ssh::Pull
and two for FTPWordmove::Organizers::Ftp::Push
andWordmove::Organizers::Ftp::Pull
in charge of orchestrating all the single actions needed to accomplish the procedure. Reading the organisers should immediately give you the idea of what the code is accomplishing to do.Let's look for example into
lib/wordmove/organizers/ssh/push.rb
where it's evident what's the procedure being executed; the list of
actions
will be executed in order, and every action will have access to same context, where all the needed state (almost configurations) resides.This way, and thanks to the new design, development and bug fixes should be naturally more focused.
Testing
Testing single actions is now more straight. The coverage has been preserved and slightly improved.
The CI, moved on GitHub actions, is also a bit more polished and for sure faster.
Documentation
Now the code has an extremely wider in-code documentation coverage. When 6.0.0 will be out of pre-release, you'll find updated developer's documentation at https://www.rubydoc.info/gems/wordmove.
Not a complete rewrite still
Some part of the legacy code have been loosely adapted to work into the new design patter; I'm not happy with this surviving code, but I'll keep it as it is. Time investment has already grown too much.
Features
This release is not about features, but
--debug
flag's now more useful when you actually are dealing with bugs (try it out and you'll see a lot of info about the currently executed actions)WORDMOVE_REVEAL_SECRETS=1
, e.g:WORDMOVE_REVEAL_SECRETS=1 wordmove pull -d -e stging
. Just please don't use this feature to report your STDOUT in GitHub's issues.Maybe for the beta release also the ruby version will be bumped. I've still to check if the update to Ruby 3 would be easily affordable.
Bugfixes
Dropped features
.env
file is supported. Variations like.env.development
are not supported as it stands in the alpha version.default
global.sql_adapter
has been dropped. This is a braking change and means thatwp-cli
will be a required peer dependency for >=6.0.0. Wiki docs will be updated accordingly at release time. The key in themovefile.yml
is still required, so you need to haveBreaking changes
movefile.yml
:local.database
key andlocal.vhost
key are no more required and considered a syntax error.doctor
command is aware of the change. More on this in a later paragraph (see Wpcli_all_the_way #625 )global.sql_adapter
, stil being mandatory, now supports onlywpcli
.Thus remember to update you movefile.yml accordingly. The wiki documentation will be updated lately so you'll be on your own until then.
Configuring the local section: news and drops
From now on this will be your
local
section inmovefile.yml
:This sounds - and actually is - really cool, but you have to be aware of a few things.
local.database.mysql_options
andlocal.database.mysqldump_options
are dropped. Now we rely on wp-cli in order to dump and import the database. You can still configure wp-cli in order to achieve some of the previous configuration. In order to configure wp-cli you can follow the official docs https://make.wordpress.org/cli/handbook/references/config/#config-files, but here come some examples of awp-cli.yml
fileKeep in mind that we already always use some flags when wrapping wp-cli commands:
search-replace
:--precise
,--regex
,--regex-delimiter="|"
,--skip-columns=guid
,--all-tables
--allow-root
Keep in mind you are able to overwrite them creating hard to track misbehaviours.
Also
local.database.port
andlocal.database.charset
are dropped since they are managed differently in wp-config.php and anyway automatically managed by wp-cli.