deployphp / deployer

The PHP deployment tool with support for popular frameworks out of the box
https://deployer.org
MIT License
10.62k stars 1.48k forks source link

Deploy command missing from common recipe #3266

Closed thinkcube-solutions closed 2 years ago

thinkcube-solutions commented 2 years ago

When running dep init from a fresh install of Deployer 7 and selecting php as the configuration type and the third recipe option common the deploy command is not available. When you run dep and look at all of the available commands it does not show in the list and is reported as undefined if you attempt to run dep deploy. If you however select Laravel as the recipe, the deploy command is available. Shouldn't the deploy command be available in a common recipe?

Thank you!

sgrossberndt commented 2 years ago

I had a hard time figuring out a similar issue yesterday and I wonder if the same problem you had: if there is no deploy.php, I get exactly the same behaviour you described - the deploy command is missing:

user@host:~/# docker run -it composer:2.3.10 /bin/bash
bash-5.1# composer global require deployer/deployer:^7 --dev
Changed current directory to /tmp
./composer.json has been created
Running composer update deployer/deployer
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking deployer/deployer (v7.0.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Downloading deployer/deployer (v7.0.2)
  - Installing deployer/deployer (v7.0.2): Extracting archive
Generating autoload files
1 package you are using is looking for funding.
Use the `composer fund` command to find out more!
bash-5.1# ls
bash-5.1# /tmp/vendor/bin/dep deploy

  Command "deploy" is not defined.

bash-5.1# /tmp/vendor/bin/dep
Deployer 7.0.2

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -f, --file=FILE       Recipe file path
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  blackjack    Play blackjack
  completion   Dump the shell completion script
  config       Get all configuration options for hosts
  help         Display help for a command
  init         Initialize deployer in your project
  list         List commands
  run          Run any arbitrary command on hosts
  self-update  Updates deployer.phar to the latest version
  ssh          Connect to host through ssh
  tree         Display the task-tree for a given task

For me it works though even if I add the common recipe:

bash-5.1# printf "<?php \nnamespace Deployer; \nrequire 'recipe/common.php';\n" > deploy.php
bash-5.1# cat deploy.php
<?php
namespace Deployer;
recipe/common.php';
bash-5.1# /tmp/vendor/bin/dep
Deployer 7.0.2

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -f, --file=FILE       Recipe file path
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  blackjack             Play blackjack
  completion            Dump the shell completion script
  config                Get all configuration options for hosts
  help                  Display help for a command
  init                  Initialize deployer in your project
  list                  List commands
  provision             Provision the server
  push                  Pushes local changes to remote host
  releases              Shows releases list
  rollback              Rollbacks to the previous release
  run                   Run any arbitrary command on hosts
  self-update           Updates deployer.phar to the latest version
  ssh                   Connect to host through ssh
  tree                  Display the task-tree for a given task
 deploy
  deploy:check_remote   Checks remote head
  deploy:cleanup        Cleanup old releases
  deploy:clear_paths    Cleanup files and/or directories
  deploy:copy_dirs      Copies directories
  deploy:info           Displays info about deployment
  deploy:is_locked      Checks if deploy is locked
  deploy:lock           Locks deploy
  deploy:prepare        Prepares a new release
  deploy:publish        Publishes the release
  deploy:release        Prepares release
  deploy:setup          Prepares host for deploy
  deploy:shared         Creates symlinks for shared files and dirs
  deploy:symlink        Creates symlink to release
  deploy:unlock         Unlocks deploy
  deploy:update_code    Updates code
  deploy:vendors        Installs vendors
  deploy:writable       Makes writable dirs
 logs
  logs:app              Shows application logs
  logs:caddy            Shows caddy logs
  logs:caddy:syslog     Shows caddy syslog
  logs:php-fpm          Shows php-fpm logs
 provision
  provision:check       Checks pre-required state
  provision:composer    Installs Composer
  provision:configure   Collects required params
  provision:databases   Provision databases
  provision:deployer    Setups a deployer user
  provision:firewall    Setups a firewall
  provision:install     Installs packages
  provision:mariadb     Provision MariaDB
  provision:mysql       Provision MySQL
  provision:npm         Installs npm packages
  provision:php         Installs PHP packages
  provision:postgresql  Provision PostgreSQL
  provision:server      Configures a server
  provision:ssh         Configures the ssh
  provision:update      Adds repositories and update
  provision:upgrade     Upgrades all packages
  provision:verify      Verifies what provision was successful
  provision:website     Provision website

So maybe you did not have a deploy.php instead when running dep?

antonmedv commented 2 years ago

if there is no deploy.php, I get exactly the same behaviour you described - the deploy command is missing:

This is exactly how Deployer should work. Task deploy is defined inside a recipe. No recipe - no deploy.

As @sgrossberndt showed it's not a bug - closing.

sgrossberndt commented 2 years ago

Well, this issue as reported by @thinkcube-solutions was although his deploy.php did contain the require 'recipe/common.php'; part he still did not get the deploy commands, only when using require 'recipe/laravel.php';. I am unsure if there could be a difference on a Mac, still it would be good if @thinkcube-solutions could verify whether this is solved for him/her as well.