forked from damsfx/valet-windows
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 5
Release/3.3.0 #29
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
      
      
    
                
     Merged
            
            Release/3.3.0 #29
Conversation
  
    
      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
    
  
  
    
    …directory - Move all drivers into a new `Drivers` directory within the `Valet` directory so they can be autoloaded by PSR-4. - Separate the specific drivers into a new `Specific` subdirectory of `Drivers`, and leave the basic and laravel drivers in the `Drivers` directory. - Namespace all driver classes as `Valet\Drivers` or `Valet\Drivers\Specific`. - Add `use` declarations for classes that need to be used within another class.
… namespaced drivers. These legacy drivers are deprecated by default as of v3.2.0.
- Move `require.php` into `includes` directory and rename it to `require-drivers.php` and change the require reference in `server.php`. - Add the directory loop to require all legacy drivers.
…ring concatenation to interpolation
- Remove extra spaces in the all driver's docblock params, and separate the params from the return and description.
- Convert string concatenation to string interpolation. eg. $sitePath . '/web/app/' -> "$sitePath/web/app/" or "{$sitePath}/web/app/"
    …r into it's own class, and simplify both - Extract functionality for basic driver with a public directory into it's own class `BasicWithPublicValetDriver`, and simplify both classes. - Removed now redundant methods.
…th` method for some drivers - Add `beforeLoading` method. - Move most `$_SERVER` variables for many drivers into the new method. - Remove the now unused `$sitename` param from the `serverScript` method in `Typo3ValetDriver`.
- Add new public `composerRequires` method to the base `ValetDriver` class. - Remove the private `composerRequiresSculpin` method from `SculpinValetDriver`, and update it's reference to use the new global `composerRequires` method.
…rs using the new namespaces. - Remove listing the specific drivers individually, which would be a maintenance nightmare for new drivers. - Add new `specificDrivers` method to bulk map the specific drivers into the array using the namespace.
This leverages the existing `.valet-env.php` file capability, but just adds the Valet Home directory as a first-lookup location. So, now Valet will check for `.valet-env.php` in: - `~/.config/valet/` - then the current project folder
…ivers\Custom` - Add namespace to the sample custom driver, and a `use` declaration to make sure the `ValetDriver` is available in this custom class. - Add new `customDrivers` method to bulk map the custom drivers from the `~.config/valet/Drivers` directory into the drivers array using the new namespace of `Valet\Drivers\Custom`.
convert string concatenation to interpolation
When PHP files other than `index.php` exist in `/public/` this allows them to be served by the Laravel driver.
Changed: - Moved the getting of the `rateLimit` from the `ValetException::githubApiRateLimitExceededError` method and into the "rate limit exceeded" handling of the `GithubPackage::download` method. This is because it's only returning it in the previous method, so might as well to it directly in `download` method. - Moved `ValetException::calculateTimeToGithubApiLimitReset` method back into the `GithubPackage` class and renamed it to `calculateTimeToApiRateLimitReset`. It was moved to `ValetException` in commit adae554, but its not really to do with the Exception construction. Added: - Added a call to the new `GithubPackage::calculateTimeToApiRateLimitReset` method into the "rate limit exceeded" handling of the `GithubPackage::download` method. Removed: - Removed outputting the IP address in the error in `GithubPackage::download` method. It's not really necessary. The users don't need to know their IP address, but just to be aware the API rate limit is for their IP address. - Removed the redundant `ValetException::githubApiRateLimitExceededError` method. It wasn't really doing anything with the error handling, it was just getting various variables to return to the error output construction. The IP address is no longer needed, and we've already moved the `rateLimit` and `timeLeftToReset` into the main handling of the error in `GithubPackage::download` method.
- Remove `CommandLine::runAsUser` method because it is a duplicate method of `run`. It doesn't do anything different or special. So we can just use `run` instead. - Change the `runAsUser` reference in `Valet::getComposerGlobalPath` method to use the normal `run` method.
… `Valet::homePath` method. Many of the references of the `VALET_HOME_PATH` constant can be safely changed to use the `Valet::homePath` method.
- Moved the `services` command up the file and out of the conditional check if the valet is installed. So that the command can be ran without installation. This can be helpful if valet fails to install, so we can check what was actually installed or not.
…ectory. - Added a `Diagnose` command to loop through all the directories in the Valet home directory (~/.config/valet) and output the subdirectory names and files into a temp file. - Added the ability to construct the a diretory tree diagram in the `editOutput` method. It gets the directory names and filenames from the temp file and loops through to generate a simple directory tree structure in the form of: .config/valet | |-- Directory | |-- Directory | |-- File Adding this tree diagram to the diagnostics will help diagnose any issues in the future by making sure the Valet home directory has all the required files and named correctly.
This method scans a directory path recursively, going deep into it's subdirectories, and returning an associative array of all the files and directories.
Added: - Added new `runNonCliCommand` method to run a non-CLI command/task and generate the output via PHP, instead of in the CLI. Some tasks may not be possible via the CLI, so we need to write the PHP to carry out the tasks/commands instead. - Added new `isNonCliCommand` to detect if a command is a non-CLI command, which is just a placeholder command for the task to run. Changed: - Changed `run` method to allow the usage running non-CLI commands. - Changed `beforeCommand` to remove the `placeholder` word in the non-CLI command before printing the command in the output.
Added: - Added a command placeholder to enable the Valet bin structure to be generated via PHP and not CLI. - Added the functionality to `runNonCliCommand` method to run the task for both Valet Home and Bin directories to be recursively scanned and create the array of the directories and files. This is then used to generate the directory tree output. - Added new `generateDirectoryTree` method to recursively loop through the associative array of directories and files to generate the directory tree. It uses Unicode box drawing characters and indentations to visually create the tree. Changed: - Changed the Valet home structure CLI command to a placeholder instead so it can be generated via PHP. Removed: - Removed the old code for `Valet Home Structure` in `editOutput` method as it will now use the new methods.
The Windows clip.exe program doesn't support copying of all unicode characters. If there's a character it doesn't know, it will display `????` instead of the character. This is especially true for the box characters (eg. `┣━`) used for directory trees. To fix this we need to change a few thing: - Write the output to file as UTF-8 with BOM encoding to enable usage of Unicode characters and allow them to be copied in the CLI. - Changed `clip` cmd command to use the Powershell equivalent `Set-Clipboard` to copy to the clipboard.
…der` run. On every run of `valet`, if the home directory (`~/.config/valet`) doesn't exist, the `Upgrader` spits out errors because it can't find certain files in the non existent directory. To fix, we just need to add a condition to only run the `Upgrader` methods if the home path exists.
… config key is missing and there are links in the directory. When `Upgrader::upgradeSymbolicLinks` method runs for the first time, there is no `symlinks_upgraded` key in the config, so it will run. But it will also run when the directory is empty, and outputting console messages which is redundant for new installs. Fixed by: - Added new `Upgrader:shouldUpgradeSymbolicLinks` method to determine whether both the `symlinks_upgraded` key doesn't exist and the sites directory is not empty. - Added new `Filesystem::isDirEmpty` method to check if the given directory is empty. - Changed the conditional check in the `Upgrader:upgradeSymbolicLinks` method to use the new `shouldUpgradeSymbolicLinks` method.
…g/valet/Nginx` directory The `.keep` file is not necessary, and this is the only empty directory that adds the file. Valet doesn't use the file in any way. `.keep` file is only for git to keep tracking a directory when it's empty. Valet home directory shouldn't be used with git.
… error The usage of `ValetDriver::assign` requires the full namespace to be used. Fixed by adding the namespace in a `use` clause.
…es to use the new `Specific` namespace. - Added the `Specific` namespace to all legacy drivers that extend the `Specific` driver class. eg. `Valet\Drivers\Specific\BedrockValetDriver`
…found` error. When using the deprecated legacy drivers, a PHP fatal error occurs for all legacy drivers, saying that the `Specific` respective driver class that the legacy driver extends can not be found. Extending the namespaced class is supposed to prevent this using the PSR-4 autoloading, but autoloading doesn't seem to work here. To fix, we need to `require` all of the `Specific` namespaced drivers before the legacy drivers are `require`d. This then ensures all namespaced classes are available in the legacy drivers, and fixes the PHP class not found error.
…om SourceForge. Removed: - Removed all `Acrylic` bin files. Added: - Added new `Acrylic` class with the namespace `Valet\Packages`, and extending the base `Package` class. This class will never clash with the normal `Acrylic` class because of the different namespaces. Because SourceForge doesn't have a proper API for releases, we have to use the `best_release.json` endpoint to obtain the latest `.exe` version. But because the json file only lists the download URL of the standalone `.exe` file, we have to replace the filename to get the download URL for the portable zip version (`Acrylic-Portable.zip`). - Added new `Acrylic_IPv4_Binding_Address.ini` stub file to add the custom IPv4 binding localhost loopback address as fixed in PR #15. - Added a `changeLocalIpv4BindingAddress` method to replace the default value of `LocalIPv4BindingAddress` with our custom value from the new stub file.
Forgot to add the `install` method call, so Acrylic doesn't actually download itself. Fixed by adding the call to the `Packages\Acrylic::install` method within the normal `Acrylic` install method.
The `createEmergencyUninstallFiles` method was called in `Configuration::install` method. But Valet installs the configuration before Ansicon in the `install` command. Giving out a bunch of PHP errors `The system cannot find the file` because it Ansicon doesn't exist yet. Fixed by: - Moving the `createEmergencyUninstallFiles` method from the `Configuration` class into the `Valet` class as a `public` method. This is because the emergency files are not technically related to configuration. It makes more sense to define the method in the `Valet` class instead. Also removed the call to this method from the `Configuration::install` method. - Removing the creation of the `Emergency Uninstall` directory from the newly moved `Valet::createEmergencyUninstallFiles` method in favour of adding this to a new `Configuration` method. - Adding a new `Configuration::createEmergencyUninstallDirectory` method to create the `Emergency Uninstall` directory in the Valet home directory, ready for the files to be added later on. Added the call to this method in the `Configuration::install` method. - Adding a call to the new `Valet::createEmergencyUninstallFiles` method in the Valet's `install` command. This will be the very last item to be installed by Valet to ensure Ansicon has been installed. Also changed the `maxItems` to account for this new progressbar item.
… new method. Part 1. Dev note: This commit is part 1 of 2. This refactor is split because the diff would've shown the wrong things changed, creating confusion. So splitting it would ensure proper diff. ------------ Part 1: - Added a new empty method, `Configuration::createDirectories`, ready to move the creation of directories from `install`. This will be the new method to call all the create directory methods, for better organisation. - Added a call to the new method in `install`.
… new method. Part 2. Dev note: This commit is part 2 of 2. This refactor is split because the diff would've shown the wrong things changed, creating confusion. So splitting it would ensure proper diff. ------------ Part 2: - Moved all the create directory calls from `Configuration::install` to the new `Configuration::createDirectories`. This is for better organisation.
…n` class. - Moved the `Nginx::rewriteSecureNginxFiles` method from the `installNginxDirectory` method into the `install` method. - Removed the `Nginx::installNginxDirectory` method and it's method call in `install`. - Added a new `Configuration::`createNginxDirectory` method and refactored the directory creation code that was in `Nginx::installNginxDirectory` to be more concise and inline with the other create directory methods. Moving the creation of the Nginx directory into the `Configuration` class helps to keep all directory creation for the Valet home directory all in one place, and keep things organised. - Added a call to this new method in the `Configuration::createDirectories` method.
…calls. Sort all Valet home sub directory creation methods and their calls in ascending order. This is to just a style adjustment, for better readability. No functionality change. Also added/changed some comments.
…ame. The `Ngrok::getNgrokConfig` method's name was changed to the generic `getConfig` name in commit db085bd; but the usage of it in the `set-ngrok-token` command was never changed. Therefore errors would occur. Fixed by changing the method call to the new name `getConfig`.
- Added `Configuration::createCaDirectory` method to create the directory for the Valet self-signed Certificate Authority (CA) certificates; and added a method call in the `createDirectories` method. Even though that the directory can be created via the `Site::secure` method, that should be more of a backup solution if the directory was ever deleted after installation. The `Configuration` class should be the first port of call to create the directories.
…e grouped with it's sibling `mkdir` method.
If a PHP error occurs internally while trying to access a site, nginx fails silently, and the browser just displays it's generic 500 error page. It is rather difficult to determine what caused the error from this. To help users debug the error, we can tell nginx to redirect the user to a custom 500 error page, which tells them where to look for the error. Added: - Added new `500.html` template as the error page which describes the log file to look for the nginx error, and also use the valet command. Changed: - Enabled nginx to intercept php fastcgi errors in all site conf stubs, and redirect to the new 500.html page. - Changed the replacement code for the site conf stubs to now replace any `VALET_ERROR_TEMPLATE_PATH` constants with the real absolute path of the error template location.
On installing nginx via `valet install`, the secured site confs have always been rewritten, updating the confs with new configurations thats been added. However, isolated sites wouldn't have been updated, meaning they're still stuck on the old configurations. To fix: - Changed the name of `rewriteSecureNginxFiles` method to `rewriteNginxFiles` in the `Nginx` class; and added the `Site::reisolateForNewTld` method call. This will rewrite all secured and isolated site confs and upgrade to the new configurations.
`Site::unisolate` and `Site::isolate` methods should not be outputting info directly to the terminal. This is because when using the `Site::reisolateForNewTld` method, it calls the `unisolate` and `isolate` methods, and when they output info it messes up any progress bars in the terminal. Such as when installing valet. To fix: - Remove the `info` method calls from `isolate` and `unisolate` and move them to the commands that called them respectively.
The path to the 500.html error page uses backslashes as the directory separator, this causes problems because a `\t` is a tab. So nginx interprets `\cli\templates/500.html` as `\cli   emplates/500.html`, which then fails to locate the 500 error page.
To fix:
- Added new `Filesystem::normalisePath` method to replace the backslashes with forwardslashes.
- Added a new `normalise` boolean param to the `Filesystem::realpath` method, with it defaulting to `true`, so that this method can also normalise the directory separators when resolving paths.
    This automatically fixes the `cli\templates` path issue because the code to inject the path into the confs in both `Nginx` and `Site` classes already use the `realpath` method.
    - Added known issue about symfony not being able to write large error output to terminal above the viewable area, and essentially overwriting itself, cutting off the start of the error. - Added a known issue about the "The system cannot find the path specified" error usually caused by Ansicon not removing itself from the registry when uninstalling.
- Update Services shipped:
    - Remove `Acrylic` from the services shipped with valet table.
    - Add `Acrylic` to the auto-downloaded services table.
    - Update all auto-downloaded services versions to the latest versions and change the date using the ISO 8601 date format.
- Update emergency uninstall:
    - Change all paths to use the new "Emergency Uninstall" directory.
    - Add an important note in the section for the Ansicon `The system cannot find the path specified` error.
    - Add descriptions of the new "Emergency Uninstall" directory.
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  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.
  
    
  
    
This v3.3.0 release is a big PR that focuses on code-parity with macOS Valet, enhanced emergency uninstallation, significant code quality improvements and lots of refactoring for improved maintainability. Valet will also no longer ship with the executable for Acrylic, instead the latest version is dynamically downloaded and installed from SourceForge.
Here are some notable changes:
New Features
Added new http 500 error page to help users debug nginx errors that fail silently.
Added new
Packages\PackageandPackages\Acrylicclasses for better maintainability and usability.Added
Ansiconto the emergency uninstall services script to help cases where Ansicon fails to uninstall properly viavalet uninstall, which leaves it's path in the registry, and upon reinstalling valet, the"The system cannot find the path specified"error then fails the installation process. This is a workaround and not a direct fix for issue Bug: path cannot be found #28. Also improved the UX of the script.Many code-parity changes, additions, and fixes with the Mac version (v4.8.7). Including moving the drivers into the PSR-4 autoloaded
Valetdirectory and namespacing them asValet\DriversorValet\Drivers\Specific. Also introduced new legacy drivers to extend the namespaced drivers so user custom drivers will still work.Removals
Removed all the bin files for Acrylic, in favour of downloading the latest versions from SourceForge.
Removed the redundant
CommandLine::runAsUser,Valet::composerGlobalDiagnose,Valet::composerGlobalUpdate, andValetException::githubApiRateLimitExceededErrormethods.Deprecations
Fixes
Fixed the coping of Unicode characters in the
Diagnoseoutput.Fixed errors when the Valet home directory (
~/.config/valet) doesn't exist during theUpgraderrun.Upgradernow only runs if the home path exists.Fixed
Upgrader::upgradeSymbolicLinksmethod running when the directory is empty causing redundant console messages. It now only runs when the config key is missing and there are symlinks in the directory.Fixed system compatibility check to PHP 7.4 as a minimum.
Fixed
set-ngrok-tokencommand errors that was caused by a method name change. It now uses theNgrok::getConfiginstead of the oldNgrok::getNgrokConfig.Fixed updating old isolated site conf files on
valet install. Secured site conf files have always been updated on installing valet, but isolated sites were stuck using old configs. All files are now rewritten to use the updated conf structure.Fixed
Site::unisolateandSite::isolatemethods to not output info directly to the terminal, as this causes progress bars to mess up. The output is now moved to the commands that called the methods.