-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[5.0] Introduce a CLI UI for creating a public folder #41446
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
Merged
HLeithner
merged 46 commits into
joomla:5.0-dev
from
dgrammatiko:5.0-dev-expose-public-folder-cli
Sep 5, 2023
Merged
Changes from 41 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
3e43fb6
Public folder
dgrammatiko e5aafd8
CS
dgrammatiko 83ed856
Use a helper to reduce duplicate code -cli install
dgrammatiko 8d72e34
$folder -> destinationPath
dgrammatiko d17762b
CLI Installation
dgrammatiko 33728e2
one helper
dgrammatiko 74de659
consistent error text
dgrammatiko 47bbc65
wrong expected default value
dgrammatiko 0a87bf5
text
dgrammatiko 73c01d4
Draw the rest of the horse (kinda)
dgrammatiko be5b4f3
update
dgrammatiko bdc29a6
CS
dgrammatiko 10f6d6b
cs
dgrammatiko 58c47d9
Update InstallCommand.php
dgrammatiko 9817ab6
cleanup
dgrammatiko e602e8a
Simplify
dgrammatiko 86a5b53
entropy
dgrammatiko c0ccdd5
useless
dgrammatiko 5192199
typehint
dgrammatiko ab8c0f1
simplify more
dgrammatiko a6feb17
move the unset
dgrammatiko 0821e04
oops
dgrammatiko a3e6b73
code docs
dgrammatiko 4d61960
well that path doesn't resolve
dgrammatiko 5f8fbc8
Update SetupModel.php
dgrammatiko 3555276
Fix the paths
dgrammatiko 55f8786
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
HLeithner c14ef32
Fix the installation cli skipping images
dgrammatiko 7622fed
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
dgrammatiko 6fe810b
cs
dgrammatiko 2c485d4
Fix the defines path
dgrammatiko 0bd8bdf
Use full paths
dgrammatiko 0b3dce7
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
HLeithner 1cf2d13
Make the public folder input optional
dgrammatiko 1d75c1a
No reason to limit this to cli.
HLeithner e385db0
Allow public folder creation to use relative path
HLeithner 520c47e
cs
HLeithner 5cf3cb1
cs
HLeithner 2e382d6
allow empty value for public folder input
dgrammatiko f771697
Some typos
dgrammatiko 3af3baa
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
dgrammatiko 5c98da1
Update installation/src/Model/SetupModel.php
HLeithner 7cbdb09
Update libraries/src/Helper/PublicFolderGeneratorHelper.php
dgrammatiko a613616
Update libraries/src/Helper/PublicFolderGeneratorHelper.php
dgrammatiko 69b3794
Update installation/language/en-GB/joomla.ini
dgrammatiko f73031e
Update installation/language/en-GB/joomla.cli.ini
dgrammatiko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
libraries/src/Console/SiteCreatePublicFolderCommand.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Joomla! Content Management System | ||
| * | ||
| * @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org> | ||
| * @license GNU General Public License version 2 or later; see LICENSE.txt | ||
| */ | ||
|
|
||
| namespace Joomla\CMS\Console; | ||
|
|
||
| use Joomla\CMS\Helper\PublicFolderGeneratorHelper; | ||
| use Joomla\Console\Command\AbstractCommand; | ||
| use Joomla\Filter\InputFilter; | ||
| use Symfony\Component\Console\Command\Command; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
| use Symfony\Component\Console\Style\SymfonyStyle; | ||
|
|
||
| // phpcs:disable PSR1.Files.SideEffects | ||
| \defined('_JEXEC') or die; | ||
| // phpcs:enable PSR1.Files.SideEffects | ||
|
|
||
| /** | ||
| * Console command for creating a public folder | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| class SiteCreatePublicFolderCommand extends AbstractCommand | ||
| { | ||
| /** | ||
| * The default command name | ||
| * | ||
| * @var string | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected static $defaultName = 'site:create-public-folder'; | ||
|
|
||
| /** | ||
| * SymfonyStyle Object | ||
| * @var object | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| private $ioStyle; | ||
|
|
||
| /** | ||
| * Stores the Input Object | ||
| * @var object | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| private $cliInput; | ||
|
|
||
| /** | ||
| * The public folder path (absolute) | ||
| * | ||
| * @var string | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| private $publicFolder; | ||
|
|
||
| /** | ||
| * Internal function to execute the command. | ||
| * | ||
| * @param InputInterface $input The input to inject into the command. | ||
| * @param OutputInterface $output The output to inject into the command. | ||
| * | ||
| * @return integer The command exit code | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected function doExecute(InputInterface $input, OutputInterface $output): int | ||
| { | ||
| $this->configureIO($input, $output); | ||
| $this->ioStyle->title('Create a public folder'); | ||
|
|
||
| $this->publicFolder = $this->getStringFromOption('public-folder', 'Please enter the absolute path to the public folder', true); | ||
|
|
||
| // Remove the last (Windows || NIX) slash | ||
| $this->publicFolder = rtrim((new InputFilter())->clean($this->publicFolder, 'PATH'), '/'); | ||
| $this->publicFolder = rtrim($this->publicFolder, '\\'); | ||
|
|
||
| if (!((new PublicFolderGeneratorHelper())->createPublicFolder($this->publicFolder))) { | ||
| return Command::FAILURE; | ||
| } | ||
|
|
||
| $this->ioStyle->success("Public folder created! \nAdjust your server configuration to serve from the public folder."); | ||
|
|
||
| return Command::SUCCESS; | ||
| } | ||
|
|
||
| /** | ||
| * Method to get a value from option | ||
| * | ||
| * @param string $option set the option name | ||
| * @param string $question set the question if user enters no value to option | ||
| * @param bool $required is it required | ||
| * | ||
| * @return string | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| public function getStringFromOption($option, $question, $required = true): string | ||
| { | ||
| $answer = (string) $this->cliInput->getOption($option); | ||
|
|
||
| while (!$answer && $required) { | ||
| $answer = (string) $this->ioStyle->ask($question); | ||
| } | ||
|
|
||
| if (!$required) { | ||
| $answer = (string) $this->ioStyle->ask($question); | ||
| } | ||
|
|
||
| return $answer; | ||
| } | ||
|
|
||
| /** | ||
| * Configure the IO. | ||
| * | ||
| * @param InputInterface $input The input to inject into the command. | ||
| * @param OutputInterface $output The output to inject into the command. | ||
| * | ||
| * @return void | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| private function configureIO(InputInterface $input, OutputInterface $output) | ||
| { | ||
| $this->cliInput = $input; | ||
| $this->ioStyle = new SymfonyStyle($input, $output); | ||
| } | ||
|
|
||
| /** | ||
| * Configure the command. | ||
| * | ||
| * @return void | ||
| * | ||
| * @since __DEPLOY_VERSION__ | ||
| */ | ||
| protected function configure(): void | ||
| { | ||
| $help = "<info>%command.name%</info> will create a public folder | ||
| \nUsage: <info>php %command.full_name%</info>"; | ||
|
|
||
| $this->addOption('public-folder', null, InputOption::VALUE_REQUIRED, 'public folder absolute path'); | ||
| $this->setDescription('Create a public folder'); | ||
| $this->setHelp($help); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.