welaika / wordmove

Multi-stage command line deploy/mirroring and task runner for Wordpress
https://wptools.it/wordmove
MIT License
1.87k stars 165 forks source link

Activity log #494

Closed Bandi017 closed 5 years ago

Bandi017 commented 5 years ago

Hi there, i have a small question or probably new feature request, if possible.

Is there a way of logging wordmove activity ? i came across this situation : several people are working on a site...everyone has its virtual machine working and from time to time pushing small code changes to the live site.. i would like to have on the live site(or somewhere else ---even within an email ) a small log of the recent activity. Someone pulls or pushes i would like to know who has done so by using an id or name, a copy of the command, plus time stamp..; in order to have a better control over what is being done... of course we can organise and leave pushing to a single person but sometimes for smaller stuff it seems to be a waste of time waiting for that specific person :D

alessandro-fazzi commented 5 years ago

Hello there,

wordmove has no logging facilities; we manage all this sort of things - the domain of update data when deploying - through hooks, but the problem in your scenario is that you do not have curent wordmove's command at your disposal ... 🤔 but you have the push/pull action, the timestamp and the user. You just need to use some bash foo within hooks 😄

alessandro-fazzi commented 5 years ago

@Bandi017 i managed to get my own last command from my fish shell like this:

  hooks:
    pull:
      before:
        local:
          - 'fish -c "history" | head -n 1'
alessandro-fazzi commented 5 years ago

With

  hooks:
    pull:
      before:
        local:
          - 'fish -c "echo [(date)] User (whoami) just run command: (history | head -n 1)"'

I obtain this result:

  2.4.1  ~/d/sshwordmove   master  1  
 wordmove pull -u                                                                                                                                                                                            3582ms

▬▬ Using Movefile: ./movefile.yml ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

▬▬ Running local hooks ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
    local | Exec command: fish -c "echo [(date)] User (whoami) just run command: (history | head -n 1)"
    local | Output: [Ven 12 Ott 2018 09:31:12 CEST] User fuzzy just run command: wordmove pull -u
    ✅  success |

Obviously I got it on STDOUT, but you can redirect >> the output wherever you need

alessandro-fazzi commented 5 years ago

Oh last advise: if the command gets complicated, write a script, put it into a folder in the project (bin/? scripts/?) and call the script from the hook. You will thank yourself someday ;)

Bandi017 commented 5 years ago

thanks :) i will give this a try pretty soon !