bee icon indicating copy to clipboard operation
bee copied to clipboard

Add 'update' command

Open ghost opened this issue 4 years ago • 48 comments

I just realised that we don't have an update command for updating a module/theme/layout to a new version. We should add one.

Work is in progress on the issue-111-update-command branch. Huge thanks to @TheMetMan for getting this feature started.

  • [ ] #296
  • [ ] #297
  • [ ] #298
  • [ ] #299
  • [x] #300
  • [x] #301
  • [x] #303

The current branch should work ok for a single site, or a multisite that only uses site specific module/theme/layout folders. It will download all updates.

⚠️ WARNING: It is not recommended to use this branch directly on production until #297 is merged. ⚠️

ghost avatar Nov 25 '20 09:11 ghost

I just installed bee, and the first thing I noticed is this functionality missing. We definitely need this!

cptX avatar Jun 05 '21 06:06 cptX

+1

It would be nice to allow to specify one or more items to update, or just to use a global update command to update all that have new releases. I think on Drupal you could do (for example) drush up and it would check and update all; or drush up paragraphs or drush up drupal to pinpoint the update you want to do. Also potentially useful: a flag to say only do security updates.

laryn avatar Nov 11 '21 17:11 laryn

+1

As a starter for ten here is draft help based on @laryn 's comment above. This could form requirements:

update Description: Updates backdrop, modules, themes and layouts with new releases Aliases: up , pm-update Arguments:

  • project - (optional) one or more space separated projects (including 'backdrop') to update. Leave blank to update all projects including backdrop itself Options:
  • --security-updates-only - only updates projects/backdrop with security releases Examples:
  • bee update - update everything with a new release
  • bee update webform tatsu - updates the Webform module and Tatsu theme only
  • bee update backdrop --security-updates-only - updates only core backdrop and only security releases

If I wanted to have a go at doing this (no promises as not sure that I can), is there a good place to start?

yorkshire-pudding avatar Jan 26 '22 11:01 yorkshire-pudding

@yorkshire-pudding The new command would go into https://github.com/backdrop-contrib/bee/blob/1.x-1.x/commands/update.bee.inc

See https://github.com/backdrop-contrib/bee/blob/1.x-1.x/API.md for an explanation of the various options when creating commands.

ghost avatar Jan 26 '22 12:01 ghost

Thanks @BWPanda - that is really useful. Is this the right bit of core api ? https://docs.backdropcms.org/api/backdrop/core%21modules%21system%21system.updater.inc/1

yorkshire-pudding avatar Jan 26 '22 12:01 yorkshire-pudding

~~if anyone is interested or would like to help, I've started work here: branch removed So far, all I've done is add the details to update_bee_command and create a skeleton update_bee_callback function with a long list of todos. Even if its just to let me know if I'm on the right lines:~~

/*  
* @todo consider if any drush extension code can be re-used https://github.com/backdrop-contrib/backdrop-drush-extension/blob/1.x-1.x/commands/pm/backdrop_pm.drush.inc
  * @todo consider if brush can be re-used https://github.com/backdrop-contrib/brush/blob/1.x-1.x/commands/pm/updatecode.pm.inc
  * @todo check if file permissions allow backdrop to update itself? 
  * @todo determine required files:
  *   - core/modules/update/update.fetch.inc
  *   - core/modules/system/system.updater.inc ?? (https://docs.backdropcms.org/api/backdrop/core%21modules%21system%21system.updater.inc/1)
  *   - core/includes/update.inc
  *   - core/modules/installer/installer.manager.inc (https://docs.backdropcms.org/api/backdrop/core%21modules%21installer%21installer.manager.inc/1)
  *   - core/modules/installer/installer.manager.inc (https://docs.backdropcms.org/api/backdrop/core%21modules%21installer%21installer.manager.inc/function/installer_manager_update_ready_form/1)
  * @todo process arguments (list of projects)
  * @todo process option (security-updates-only)
  * @todo check for config item - update_disabled_extensions (Configuration>Update settings>) - if this is true (1) then need to check disabled projects also
  * @todo get list of installed projects (core, modules, themes, layouts) if no argument list of projects
  * @todo list of projects is either all installed + core, all enabled + core or argument list of projects
  * @todo get current backdrop version
  * @todo for each project in list get current version, type, name
  * @todo for each project in list get available version
  * @todo compare versions and prepare list of possible updates
  * @todo ??option to review and proceed or cancel??
  * @todo download updates to temp directory
  * @todo install updates
  * @todo can we / should we check if database updates needed and let user know
*/

yorkshire-pudding avatar Jan 27 '22 10:01 yorkshire-pudding

This is a really useful addition in my humble opinion. Drush does not work in PHP 8, so I need to move on. I would like to help if I can. I use PhpStorm for my own code development. I do not seem able to get the debugging to work and step through Brush or Bee. For Bee I have the arguments as follows --root=/home/francis/FG-Docs/public_html/moduledevbd.scorpio/web status But when I run it it does not pick up the Arguments as shown by this error:

Invalid argument supplied for foreach()
 /home/francis/FG-Docs/PhpstormProjects/Bee/includes/command.inc:13

The $argv variable is null Would anyone be willing help me get it working? Or am I asking in the wrong place being new to helping on GitHub

TheMetMan avatar May 26 '22 11:05 TheMetMan

@TheMetMan - if you navigate to moduledevbd.scorpio and then do bee --root=/web status does that work?

I'm afraid I kind of develop in disjointed way where I edit (in visual studio code) then test in lando so not sure how to setup for debugging. My initial guess is its struggling to parse a long path (or something in the path) but don't quite have time to investigate at the moment. Might do later this evening.

yorkshire-pudding avatar May 26 '22 12:05 yorkshire-pudding

Thanks for the quick response. I am a Linux man by the way. I always find it useful to step through the code. Perhaps consider porting the update from Brush to Bee

TheMetMan avatar May 26 '22 12:05 TheMetMan

I should have said I am trying to run the debug in the PhpStorm IDE, not from the command line, I will see if Jetbrains can help

TheMetMan avatar May 26 '22 13:05 TheMetMan

@TheMetMan I remember your presentation at Backdrop Live so I have a good idea of your setup. My thoughts in my initial statement was maybe about checking to see if bee could cope with the paths. Perhaps try that long path in the command line so you can see whether the issue is in bee or in the IDE.

yorkshire-pudding avatar May 26 '22 13:05 yorkshire-pudding

I remember you too. Judging from your accent and the 'handle' you are from Sunny Yorkshire. I was born in Sheffield, but live on the very edge of South West Ireland with a nice view into the Atlantic. I am beginning to think I have to setup the SERVER variable in the Environment. I am using a Virtual Host, so I can add a print statement to see what I get when I run it from the command line first.

TheMetMan avatar May 26 '22 14:05 TheMetMan

You might get more help on integrating with PHP Storm in Zulip as you'll reach a wider band of people who probably use it.

yorkshire-pudding avatar May 26 '22 14:05 yorkshire-pudding

Very good idea, thanks for your time. Regards

TheMetMan avatar May 26 '22 15:05 TheMetMan

@yorkshire-pudding, much to my surprise, I have got a very basic update working to update the modules and themes, not backdrop itself (already taken care of in the commands). I have created it on my account here https://github.com/TheMetMan/bee if you fancy a look. running this comand: bee update will update any modules and themes which need updating, no questions asked.

TheMetMan avatar Mar 06 '23 11:03 TheMetMan

I have tried to add a prompt Y/n before doing the actual updates so you can abort, but I cannot get it to work. It is there, but the script does not display the prompt. The script appears to hang.

TheMetMan avatar Mar 06 '23 13:03 TheMetMan

Thanks for this @TheMetMan . I have had a brief look, and will have a more detailed look and do some testing later.

I have tried to add a prompt Y/n before doing the actual updates so you can abort, but I cannot get it to work. It is there, but the script does not display the prompt. The script appears to hang.

Is your fork of bee up to date with the main repo? What version of backdrop are you on? There was an issue a little while back affecting prompts so would be good to rule out that this isn't the cause here.

yorkshire-pudding avatar Mar 06 '23 13:03 yorkshire-pudding

I am using #267 version of bee and I am using 1.22.0 on Backdrop

TheMetMan avatar Mar 06 '23 14:03 TheMetMan

If you're using PHP 8, then you will need 1.24+ or 1.23.2 for the confirmation prompts to work on bee - there was a temporary workaround while we got core fixed, but that workaround has now been removed.

This may not be the case here but worth ruling in or out.

yorkshire-pudding avatar Mar 06 '23 14:03 yorkshire-pudding

OK @yorkshire-pudding , I will check it out.

TheMetMan avatar Mar 06 '23 14:03 TheMetMan

OK, @yorkshire-pudding, the prompt works in 1.24.0, but the messages prior to the prompt have not yet displayed. I cannot see how to force the messages to display prior to the prompt. This is because I am a bit of a beginner at this.

TheMetMan avatar Mar 06 '23 14:03 TheMetMan

@TheMetMan - I'll have a look later

yorkshire-pudding avatar Mar 06 '23 14:03 yorkshire-pudding

@TheMetMan - sorry this is taking a while; I've tested a couple of scenarios, some more to check before feeding back, but day job is getting in the way.

yorkshire-pudding avatar Mar 13 '23 11:03 yorkshire-pudding

Ok, Martin, I am away on hols, so no rush at all. Cheers

On March 13, 2023 at 11:28 AM Martin Price @.***> wrote:

@TheMetMan https://github.com/TheMetMan - sorry this is taking a while; I've tested a couple of scenarios, some more to check before feeding back, but day job is getting in the way.

— Reply to this email directly, view it on GitHub https://github.com/backdrop-contrib/bee/issues/111#issuecomment-1465972224, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOLWRJZ22SDY3YZLO6UBN3W34AFVANCNFSM4UCEY3NQ. You are receiving this because you were mentioned.Message ID: @.***>

TheMetMan avatar Mar 13 '23 11:03 TheMetMan

I have got a very basic update working to update the modules and themes, not backdrop itself (already taken care of in the commands).

@TheMetMan Can you please point me to the command that you use to update backdrop itself?

I tried using download-core but it refuses to download backdrop in the dir of the website. So currently to update I'm using download-core to an external dir and then manually moving the core dir to the site I want and then finally using update-db which is working really great.

Thank you for creating bee!

marioawad avatar Jun 21 '23 08:06 marioawad

@marioawad - this is not ready yet as a bee command. I need to worth with @TheMetMan and hopefully we will have this ready for release at some point.

bee has been created by a number of people over the years. See https://github.com/backdrop-contrib/bee/graphs/contributors for a list of all contributors who have had code merged.

yorkshire-pudding avatar Jun 21 '23 09:06 yorkshire-pudding

Thanks for the prompt reply. Do you know of any alternative to update backdrop core from the command line please? Also, where do you recommend I look around to try and help you out if I can?

marioawad avatar Jun 21 '23 09:06 marioawad

Do you know of any alternative to update backdrop core from the command line please?

You may be able to do this with brush - this tool is no longer supported but I believe it has this command and it may work. But be aware that you will not get any support if it doesn't. Alternatively, you could script how you're currently doing it.

However, be encouraged that your interest in this ticket has spurred me on, so hopefully we won't have too long to wait for this.

Also, where do you recommend I look around to try and help you out if I can?

It's great that you're interested in helping. Have a look at the issue queue and see if you fancy doing a PR for any of the tickets there. If you need any pointers just ask.

yorkshire-pudding avatar Jun 21 '23 09:06 yorkshire-pudding

@marioawad I am away from home until tomorrow, I will contact you again then with my scrips to update core and modules using bee with my mods.

TheMetMan avatar Jun 21 '23 10:06 TheMetMan

Hi @TheMetMan - I have created a new branch as I think this may require a bit of work before merging to 1.x-1.x . https://github.com/backdrop-contrib/bee/tree/issue-111-update-command

Please rebase (Sync) your repo to the latest bee and then do a PR to this branch rather than to the 1.x-1.x branch. Don't worry if you create the PR to the wrong branch as I can edit this to the right branch. I will then create some suggestions against your PR.

yorkshire-pudding avatar Jun 21 '23 10:06 yorkshire-pudding