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

V0.0.4 #25

Merged
merged 70 commits into from
Dec 11, 2023
Merged

V0.0.4 #25

merged 70 commits into from
Dec 11, 2023

Conversation

erikyo
Copy link
Collaborator

@erikyo erikyo commented Dec 8, 2023

close #2,
close #23,
close #26

The class 'install' and corresponding file have been renamed to 'Installer'. Adjustments have been made to reflect that the class is a constructor, improving both readability and comprehensibility of the code. Additionally, module exports have been updated accordingly.
A new file 'Database.js' has been added featuring a Database class. This class includes two methods, 'uploadDatabase' and 'dumpDatabase', meant to handle respective operations on a MySQL database. The 'getConnectionSettings' utility function is used for obtaining database connection configurations. The file utilizes 'mysql2/promise' and 'mysqldump' packages for database operations.
Separated existing installation package classes (WordPressPackage, PluginPackage, ThemePackage) from `package.js` into their own files(`WpPackage.js`, `PluginPackage.js`, `ThemePackage.js`). This refactoring improves code organization, clarity, and separation of concerns. The classes are now directly exported from their files, making it easier to import them separately where necessary.
Added a new file `Updater.js` including methods to update plugins, themes, and WordPress core using the configurations. This class improves the structured and guided update process by providing dedicated methods to perform the updates separately, handling configuration validation and logging errors effectively during the update process.
Moved all functions in utils.js to a newly created index.js file within the utils directory. This refactoring effort improves code organization by defining utility functions in their respective context, under the utils directory. Meanwhile, ‘fs.js’ was renamed and moved to ‘utils/fs.js’ to maintain consistency. These changes do not alter any functionality.
Refactored the code by moving functions to newly created utils/index.js, improving the organization of utility functions. Added `getInfo` function to the utils import. Renamed WordPressInstaller to Installer, WordPressConfigDump to Dump, and added Database class for handling new database operations. Furthermore, the handling of the 'dump' and 'init' actions have been updated along with the addition of actions for 'upload-database' and 'dump-database'.
Increased the version number of package.json and package-lock.json. Also, added 'mysql2' and 'mysqldump' to the package dependencies list for improved database operations support.
Introduced detailed JSDoc typedefs for the WPMMconfig object and its subprocesses. This includes definitions for WordPress configuration, package data, and website details to improve code clarity and maintainability.
Added param typing and updated JSDoc comments in the getConfig function to improve readability and maintainability. It now provides a clear understanding of the data types used and the structure of the WPMMconfig object.
The commit introduced explicit types for parameters to improve code readibility and maintainability. Furthermore, JSDoc comments were added providing clear descriptions of the function, their parameters, and expected return types. Renamed file initialize.js to Initialize.js for consistency in the code base.
The update significantly improves code clarity and readability by adding comprehensive JSDoc comments to classes, functions, and variables across multiple files. In addition, it includes refactoring of parameters and variables for consistent naming conventions and precise type clarity with the introduction of explicit typing. The file initialize.js was also renamed to Initialize.js to maintain codebase consistency and adhere to naming standards.
This commit introduces comprehensive JSDoc comments to classes, functions, and variables for better understanding of the code and its functionality. It ensures parameters and variables follow a consistent naming convention and enhances type clarity with specific typing. It also includes a minor renaming of a file from initialize.js to Initialize.js for consistency.
Added a function to fetch user locale, removed unused functions, improved some variable labels and made small enhancements in scripts for better readability. Also replaced manual string concatenations with template literals.

Took 3 hours 18 minutes
Added new utility functions in the wpConfig.js file. These functions are used to fetch and modify the WordPress configuration details such as getting the latest version of WordPress, getting the WordPress installation paths, fetching the current WordPress version and locale information, replacing database constants in wp-config.php, generating salt codes, and replacing empty salts in the configuration.

Took 14 seconds
Upgraded the Dump class constructor to utilize new configuration utility functions. Ensured the class utilizes these functions to fetch the current WordPress version and locale information, and also to set the root, theme, and plugins folders. This results in cleaner, more efficient, and maintainable code.

Took 9 seconds
Corrected a typo in the comment on Initialize.js where WordPress was spelt as 'Wordpress'. Providing correct information in comments is essential for maintaining readability and understanding of the code.

Took 23 seconds
The Installer.js class has been streamlined by introducing utility functions and generalizing Package class for WordPress, plugin, and theme installation. This refactoring provides a more modular approach which can now handle installing WordPress and its plugins and themes more efficiently. It also improves readability and maintainability of the code.

Took 13 seconds
Removed PluginPackage.js and ThemePackage.js, and refactored Package.js to generalize the handling of plugin and theme installation. This update results in a more cohesive approach, increasing code maintainability and enhancing the efficiency of installing WordPress, plugins, and themes.

Took 12 seconds
Updated WpPackage class logic in lib/WpPackage.js to improve setup and configuration. This refactor includes better management of WordPress configuration and download links through improved handling of this.pkgInfo object. The changes focus on unifying paths, streamlining the process, and simplifying the code.

Took 11 seconds
Enhancements have been made to the WordPress paths utility in lib/index.js for better path management. More concise action function descriptions and improved handling of default 'install' action command were also incorporated. This refactoring aims to streamline processes, simplify codes and provide a more intuitive user experience.

Took 8 seconds
Several package dependencies also have been updated, new ones have been added including 'axios' and 'node-fetch', and 'eslint-plugin-import' has been removed. Additionally, numerous dependencies shifted to a peer dependency. These changes enhance the compatibility and operability of the package.

Took 32 seconds
The main wp-package.json configuration file has been simplified to remove unnecessary values and clean up host settings. This included nullifying the WordPress version and language, while updating the database user and password details. Also, a new file tests/assets/wp-package.json has been created to separate the testing configuration. Moreover, the tests/utils.test.js file has been updated to reflect these changes.

Took 1 minute
The utility test file imports in tests/utils.test.js were restructured for improved legibility and clarity. Specific utilities were moved to a separate import from ../lib/utils/wpConfig, enhancing separation of concerns. This coincides with the simplification of the main wp-package.json configuration file and the creation of a new test configuration file in tests/assets/wp-package.json.

Took 2 minutes
A new utility function has been added in lib/utils/index.js for executing commands asynchronously after installation. This addition allows post-install commands to be defined and run, useful for tasks that should occur only once the installation process is completed. Additionally, code organization is improved by moving the runPostInstallCommands implementation to the utils library.

Took 9 minutes
Took 4 minutes
The logic for handling the --template option has been improved. Now, in addition to using a local file, we can also get a configuration file from a remote source with axios, offering more flexibility. Error handling is provided in case a remote source fails to load properly.

Took 53 minutes
The baseFolder for WordPress installation has been updated to use a constant instead of a hardcoded value. This change makes it more flexible and easier to maintain because you can change the default WordPress install folder by simply updating the constant in one place.

Took 12 seconds
Created a new lib/constants.js file containing the default settings for WordPress installation. This refactoring improves the code maintainability by centralizing the configuration values for the WordPress install folder, language, and default config settings in one place.

Took 10 seconds
Updated the constructor and the 'generateConfig' method in Initialize.js to rely on default configuration values sourced from lib/constants.js. This makes the code cleaner and centralizes default settings for WordPress installation.

Took 33 seconds
Changed the definition of base folder in 'Package.js' and 'WpPackage.js'. File 'wpConfig.js' was renamed to 'wordpress.js', and all references to this file were updated. Removed redundant import statements and refactored the way functions are imported from utility files. This is done to simplify the code and improve its maintainability. Removed the function 'geVarFromPHPFile' from 'data.js' and moved it to 'wordpress.js'.
Renamed the function 'getVarFromPHPFile' to 'getDataFromFile'. This change better reflects the function's purpose and improves code clarity. Added new tests for this function in 'tests/utils.test.js' to ensure it correctly extracts data from PHP files. Additionally, adjusted import statements to reflect these changes in 'lib/utils/wordpress.js'.
Introduced a function to parse WordPress configuration file (wp-config.php) in `lib/utils/wordpress.js`. This function extracts defined constants and variables, providing crucial information for further operations. Additionally, created new test files to ensure the accuracy of this parsing function. Furthermore, some command names and function calls were updated for consistency.
The code diff reveals added functionality to the 'lib/utils/data.js' file. A new function `initConfig` initializes the configuration for a provided base folder. If the base folder doesn't exist, it gets created, and a default config is generated and written into this template file.
The getConfig function in 'data.js' file has been refactored to handle scenarios when a template is not provided and add an "initConfig" function for initialising the configuration with the base folder. The parameters in the getConnectionSettings function have also been modified to align with the new configuration settings format.
A new function, axiosFetch, has been added to wordpress.js for fetching data from a specified URL using Axios. This function includes headers for 'User-Agent', 'Content-Type', 'Accept', 'Accept-Encoding', 'Connection', and 'Pragma'. If the fetch is successful, it resolves with the fetched data; in the case of an error, it logs the error to the console.
The getLastWp function in wordpress.js has been updated to use the axiosFetch function instead of axios.get. In addition to the replacement, error handling has been improved: now in case of an error or if no offers are received from the WordPress API, an appropriate message is logged to the console instead of throwing an exception.
A new utility function called getWpConfigContent has been added to the wordpress.js file. This function reads the 'wp-config.php' content from any given WordPress folder. It includes proper error handling for cases where the file is not found or is empty, logging appropriate warning messages.
Updated the naming of constants to be in Pascal case as per code style conventions. Changes also include improvements to how files and variables are parsed in functions, and code readability has also been enhanced by removing unnecessary comments and reformatting the code structures.
The existing `dumpDatabase` method has been overhauled to improve user experience. The change includes generating filenames based on database name and date, creating the backup directory if it doesn't exist, and better error handling. The readability of the code has also been improved with some restructuring.
The `parseWpConfig` method in the Dump class has been updated to use the `getWpConfigContent` method. The configuration details are now included in the result, combining both constant and variable values.
All names of the declared constants were updated to use upper camel casing. This ensures consistency with other declarations in the code and adheres to the chosen coding style conventions.
The library entry point lib/index.js has been refactored to handle asynchronous loading of configuration data properly. The configuration object is now fetched using a promise, and operations dependent on that configuration are processed within the 'then' clause. All other changes are related: variable declarations were moved inside the 'then' clause and usage of the 'actions' object was wrapped in a condition to prevent premature invocation.
The code in lib/Initialize.js was refactored to use async functions, providing clearer asynchronous control flow. This implies transforming some synchronous operations into asynchronous ones. At the same time, the names of the constants coming from "constants.js" have been capitalized to follow naming conventions more closely. Furthermore, minor changes have been made to improve code readability and structure, including the addition of default parameters and clarification of folder paths.
Modified parseWpConfig tests to read actual file content instead of mocking it in the wpConfig.test.js file. Furthermore, test assets have been moved from the "assets" directory to a new "fixtures" directory. This change enhances test configuration and better reflects real-world scenarios by using actual files instead of mocked instances.
Added a check within the `scanDirectory` method in `lib/Dump.js` to validate whether a directory exists before attempting to read its content. This will prevent errors from occurring when a directory is not found, instead returning an empty result set.
…cations

Reorganized WordPress and package configuration definitions, moving them from `lib/index.js` to `lib/constants.js`. Streamlined how actions such as installation and update are invoked in `lib/index.js`, improving code readability and maintainability. As a result, the `actions` object in `lib/index.js` is now cleaner and operations are displayed in a more logical order.
Introduced `actions.js` that centralizes all WordPress management actions. This new file encapsulates functions for retrieving information, initializing WordPress installation, installing and updating WordPress, dumping data and database, among others. This centralization is intended to facilitate maintenance and improve extendibility.
Adjusted argument intake in `actions.js` and `index.js` files for better encapsulation. In `actions.js` we replaced `actions` with `wpmmActions` to reflect consolidated function. Similarly, in `index.js`, the actionLauncher now takes an object containing both config and paths. These changes focused on improving code maintainability and readability.
Replaced the direct use of axios's get method in `data.js` with `axiosFetch` from `wordpress.js` to improve consistency and readability of code. This also aids in error handling and response data extraction, making the code easier to understand and maintain.
Refactored action functions by renaming certain modules and improving error handling. Updated comments and parameter types across multiple modules for better code readability and understanding. Integrated new method descriptions and enhanced the clarity of existing ones.
Added TypeScript along with necessary TypeScript definitions to the project. Removed 'node-fetch' and other unused dependencies. The operation includes the generation of a new tsconfig.json file.
The commit encompasses several important changes targeted towards WordPress package installation and configuration. It first optimizes the WpPackage.js file for more streamlined and efficient handling of WordPress installations. It also includes smarter parsing and generation of WordPress and other package config files. Furthermore, it enhances the database.js file to use better defined configurations. Major changes involve movement of parser-related functions to a new utils/parsers.js file, and inclusion of user prompts related to WordPress installation in a new utils/prompts.js file.
…ation

New functions have been added to a utility file parsers.js to handle parsing and modification of WordPress config files. These functions include parsing the wp-config.php file, replacing database constants and empty salts, and generating salt codes. Also, certain configurations related to WordPress installation have been moved to this utility for better structuring and ease of use.
Introducing new utility file prompts.js which contains two asynchronous functions; one that prompts the user for their new WordPress installation details for configuration initialization and another that checks if the user wants to dump installation. These prompts help to improve the user experience by allowing interactive customization for WordPress installations and dump handling, and serve to better structure the codebase.
The commit organizes the imports from utils directory by moving data processing functions to parsers.js. Also, it updates the test configurations by replacing the deprecated method getConfig with initConfig and changes parameters to make it more representative of deploy conditions. This results in a neater, more intuitive import schema and test set-up, enhancing code readability and understanding.
This commit modifies the typescript target to "es5" for maximum compatibility and updates the "lint" script in package.json to automatically fix problems. It also introduces new dependencies including "inquirer" and corresponding types, as well as the "prettier" code formatter, and updated typescript and "lint" configurations to reflect these changes. These updates enhance the linting process, introduce user inquiry functionality, and ensure consistent code style.
This commit updates handling of configuration in data.js by adjusting the method of creating a new WordPress installation if template file does not exist. It moves the configuration initialization process to data.js from prompts.js, for consistent handling of configuration. The look and feel of prompts.js are simplified by removing the process of calling initConfig() function and unnecessary results handling. These changes lead to better code organization and simplified logic in the prompt functionality.
@erikyo erikyo merged commit 9e32c7e into master Dec 11, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get the configuration from a remote file Database export Add the possibility to import database
1 participant