Skip to content
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

Add a --force option to the publish command #669

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/sail
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ function display_help {
echo " ${GREEN}sail bin ...${NC} Run Composer binary scripts from the vendor/bin directory"
echo
echo "${YELLOW}Customization:${NC}"
echo " ${GREEN}sail artisan sail:publish${NC} Publish the Sail configuration files"
echo " ${GREEN}sail build --no-cache${NC} Rebuild all of the Sail containers"
echo " ${GREEN}sail artisan sail:publish${NC} Publish the Sail configuration files"
echo " ${GREEN}sail artisan sail:publish --force${NC} Force publishing the Sail configuration (override existing files)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo " ${GREEN}sail artisan sail:publish --force${NC} Force publishing the Sail configuration (override existing files)"
echo " ${GREEN}sail artisan sail:publish --force${NC} Force publish the Sail configuration (overrides existing files)"

echo " ${GREEN}sail build --no-cache${NC} Rebuild all of the Sail containers"

exit 1
}
Expand Down
14 changes: 10 additions & 4 deletions src/Console/PublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ class PublishCommand extends Command
*
* @var string
*/
protected $signature = 'sail:publish';
protected $signature = 'sail:publish
{--force : The services that should be included in the installation}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Publish the Laravel Sail Docker files';
protected $description = 'Publish the Laravel Sail Docker files. If you want overwrite the existing files, you can add the `--force` option';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the extra explanation here.

Suggested change
protected $description = 'Publish the Laravel Sail Docker files. If you want overwrite the existing files, you can add the `--force` option';
protected $description = 'Publish the Laravel Sail Docker files.';

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @driesvints,

thanks for your suggestions.
Just for learning: is this really extra explanation? For me it was useful, because it's shown when php artisan is called.


/**
* Execute the console command.
Expand All @@ -27,8 +28,13 @@ class PublishCommand extends Command
*/
public function handle()
{
$this->call('vendor:publish', ['--tag' => 'sail-docker']);
$this->call('vendor:publish', ['--tag' => 'sail-database']);
if ($this->option('force')) {
$this->call('vendor:publish', ['--tag' => 'sail-docker', '--force' => '1']);
$this->call('vendor:publish', ['--tag' => 'sail-database', '--force' => '1']);
} else {
$this->call('vendor:publish', ['--tag' => 'sail-docker']);
$this->call('vendor:publish', ['--tag' => 'sail-database']);
}

file_put_contents(
$this->laravel->basePath('docker-compose.yml'),
Expand Down
Loading