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

Feature/init command #14

Merged
merged 7 commits into from
Dec 2, 2023
Merged

Feature/init command #14

merged 7 commits into from
Dec 2, 2023

Conversation

erikyo
Copy link
Collaborator

@erikyo erikyo commented Dec 2, 2023

Hey team,

I hope this message finds you well. I wanted to bring your attention to the latest set of commits that have significantly improved our WordPress project setup and configuration processes.

I was initially thinking of just doing a command that initialized the configuration but then @gardenboi got me thinking that, like npm init, it would be nice to have a command to do the same with the wp-package.json file

  • --dump for creating and saving a JSON dump of a WordPress configuration. This includes information about the WordPress version, installed themes and plugins. The dumped configuration is saved in a wp-package.json file in the root directory. This feature enables the user to easily retrieve and check the details of their WordPress configuration.
  • --init for a simplified setup process of WordPress projects. Renamed init class to Initialize and replaced installer parameter with options to allow custom configuration during construction. Modified init method to generateConfig to better reflect its functionality. Also added default WordPress configuration options and added error handling for pre-existing configuration files. This change provides more flexibility in project setup, easier adaptation for different environments, and a standardized way to setup WordPress configuration.

Here's a brief overview of the recent changes:

Init command

  • Refactored code to pass command line arguments to getConfig in 'lib/index.js'.
  • Enhanced modularity by removing the dependence on the 'yargs' package in 'lib/utils.js'.
  • Updated tests to reflect the changes.
  • Started exporting WordPressInstaller using module.exports for consistency.

WordPress Configuration Dump Tool

  • Introduced a new file, dump.js, to create and save a JSON dump of a WordPress configuration.
  • The dump includes information about the WordPress version, installed themes, and plugins.
  • The configuration is saved in a wp-package.json file in the root directory.
  • This feature enables users to easily retrieve and check the details of their WordPress configuration.

Refactoring init.js for WordPress Setup Configuration

  • Renamed init class to Initialize for clarity.
  • Replaced the installer parameter with options for custom configuration during construction.
  • Modified init method to generateConfig for better functionality representation.
  • Added default WordPress configuration options and error handling for pre-existing configuration files.
  • Provides more flexibility in project setup, easier adaptation for different environments, and a standardized way to set up WordPress configuration.

New Utility Functions for File System Operations

  • Introduced a new module, fs.js, with utility functions for various file system operations.
  • Functions include creating directories, renaming folders, downloading files, and extracting zip files.
  • Essential for tasks like setting up environments, downloading dependencies, or cleaning up temporary files.

Code Readability and Function Arrangement Improvements

  • Moved all file system-related functions from 'utils.js' to 'fs.js' for better organization.
  • Renamed 'WordPressConfigInitializer' to 'Initialize' for consistency.
  • Added a new function, 'printTimePassed,' for reusable time logging.
  • Replaced the 'init' function with 'dump' and 'initialize' functions for clearer code structure.

close #6

Refactor code to pass command line arguments to getConfig
This change better organizes command line argument handling, by moving it from 'lib/utils.js' to 'lib/index.js'. This allows us to remove the dependence of the 'lib/utils.js' module on the 'yargs' package. This transition to explicitly pass command line arguments to the getConfig function enhances modularity and the cleanliness of our codebase. Moreover, similar changes were made to tests to reflect this change. Furthermore, we started to export WordPressInstaller using module.exports for consistency.
Added new file `dump.js` for creating and saving a JSON dump of a WordPress configuration. This includes information about the WordPress version, installed themes and plugins. The dumped configuration is saved in a `wp-package.json` file in the root directory. This feature enables the user to easily retrieve and check the details of their WordPress configuration.
Refactored the `init.js` file for a simplified setup process of WordPress projects. Renamed `init` class to `Initialize` and replaced `installer` parameter with `options` to allow custom configuration during construction. Modified `init` method to `generateConfig` to better reflect its functionality. Also added default WordPress configuration options and added error handling for pre-existing configuration files. This change provides more flexibility in project setup, easier adaptation for different environments, and a standardized way to setup WordPress configuration.
Introduced new module fs.js with multiple utility functions to handle file system operations such as creating directories, renaming folders, downloading files, and extracting zip files. These operations are essential for various process like setting up environments, downloading dependencies or cleaning up temporary files.
Modified file structures as the 'utils.js' and 'fs.js' files both contained functions related to file system operations, causing confusion. Moved all the file system related functions into 'fs.js', making the roles of 'utils.js' (holding the utility functions) and 'fs.js' (handling the filesystem operations) distinct. Additionally, renamed 'WordPressConfigInitializer' to 'Initialize' and added new function 'printTimePassed' for reusable time logging. Also replaced the 'init' function with 'dump' and 'initialize' functions to make the code more understandable and manage specific tasks separately.
The diff represents several updates across the codebase. Reorganized 'scripts' in 'package.json' for better readability and further separation of concerns by adding the 'docs' command. Introduced a 'postInstall' property in 'wp-package.json'.

Refactored 'lib/index.js' by wrapping actions within an object, which allows selection of the appropriate action based on the provided argv key. It improves code readability and maintainability whilst keeping the intent of the original code.

In 'lib/package.js', reorganization of the 'require' statements was made. Reordered them to better reflect their execution sequence.

'Rename' command used to better align with the language used in rest of the code. The renaming of 'lib/init.js' to 'lib/initialize.js' helps in achieving consistency across the codebase.
@erikyo erikyo requested a review from gardenboi December 2, 2023 18:01
@erikyo erikyo merged commit 8a0680b into master Dec 2, 2023
2 checks passed
@erikyo erikyo deleted the feature/init-command branch December 2, 2023 18:13
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.

Request for Reverse Command to Generate JSON from Site Configuration
2 participants