-
Notifications
You must be signed in to change notification settings - Fork 1
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
Reshape the script using OOP #4
Merged
Conversation
This file contains 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
The commit includes the change of the earlier function-based approach to an Object-Oriented way for handling WordPress package in the index. This refactor was made to increase readability and modularity of the code. The utility functions have been merged into a single `utils.js` file, which was moved to 'lib' directory and reexported as an object for simpler imports. Also, to increase readability, 'getOptionValue' was replaced with 'yargs' and 'hideBin' for more efficient and streamlined command-line parameters parsing. The revision also includes addition of 'getConfig' function to handle reading and parsing of configuration file (wp-package.json). index.js was also renamed and relocated to 'lib' folder for better project structure and increased code maintainability. A new dependency to yargs library was added to parse command line parameters. The handcrafted function to parse command line arguments was dropped in favour of popular 'yargs' library for increased reliability and easier maintenance. The binary and main entry point in the package.json was updated to reflect the new file location. The version was also bumped. The package-lock.json was automatically updated to adjust the new 'yargs' dependency and version bump.
Three utility functions are introduced in utils.js to enhance security and ease of use for WordPress installations. replaceDbConstant(configContent, constantName, userDefinedValue) replaces a constant in wp-config.php with a user-defined value. generateSalt() creates a random salt code, and replaceEmptySalts(configContent) replaces empty salt place holders in the wp-config.php with generated salt codes. These functions allow users to easily replace database constants and salts in WordPress configurations without having to manually edit wp-config.php. The exported functions of utils.js were also updated to incorporate these new methods. In the Package class, the way of updating WordPress configurations was changed to use these new utility functions, making the code cleaner and more readable. wp-package.json was modified to change the name, DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST to more meaningful, user-defined values. New scripts field was also added to package.json to standardize the entry point for the application. The readme.md file has been updated to reflect these changes, with the version number incremented accordingly. Overall, this commit improves the security and usability of the tool, by allowing automatic generation and configuration of constants and salts in the wp-config.php file.
…tyles for various editors and IDEs, following WordPress coding standards. And, the '.gitignore' file was updated to remove a now redundant 'wp-folder'.
gardenboi
approved these changes
Dec 1, 2023
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.
not a great fan of OOP, but I must admit that in this case it suits very well.
close #1, close #3