devuri / wpenv-console

Subtree split of the wp-env-app (see devuri/wp-env-config)
https://devuri.github.io/wpenv-console/
MIT License
1 stars 0 forks source link

Proposal: Implement Conversion and Reversion Commands in Nino CLI Tool #39

Open devuri opened 7 months ago

devuri commented 7 months ago

Summary

Introduce two new commands, convert and revert, to the Nino CLI tool to automate the process of transitioning WordPress installations between standard and wpenv-framework structures, ensuring seamless backups and minimal downtime.

Description

The Nino CLI tool currently lacks the capability to efficiently manage WordPress installations in various configurations. This proposal suggests adding convert and revert commands to facilitate easy transitions between a standard WordPress setup and a more structured wpenv-framework setup, tailored for developers and agencies managing multiple WordPress sites. These commands will leverage convert.json and revert.json configurations to guide the conversion and reversion processes, ensuring a smooth, automated workflow that includes necessary backups and validation checks.

Goals

Technical Considerations

Impact

This feature will significantly enhance the Nino CLI's utility for WordPress developers and site managers, offering a streamlined process for managing site configurations, reducing manual errors, and improving deployment efficiency.

Next Steps

devuri commented 7 months ago

Feature Requirements:

  1. Convert Command:

    • Utilize convert.json to transform a standard WordPress setup into a specified framework structure (e.g., wpenv-framework).
    • Automatically create backups of the current WordPress installation before any changes.
    • Migrate WordPress core files, plugins, and themes to new directory structures as defined in convert.json.
    • Update configuration files and environmental variables as necessary.
  2. Revert Command:

    • Use revert.json to restore the WordPress installation to its original state before conversion.
    • Ensure all framework-specific modifications are cleanly removed, and standard WordPress structures are reinstated.
    • Maintain a backup of the framework-structured WordPress before reverting.
  3. General:

    • Implement robust error handling and logging to manage potential issues during conversion and reversion processes.
    • Ensure the feature is compatible with various WordPress versions and hosting environments.

Potential Challenges:

devuri commented 7 months ago

Draft: Define Specifications for convert.json and revert.json Files

Objective:

This is to establish the initial specifications for the convert.json and revert.json configuration files that will be used to guide the conversion and reversion processes in the Nino CLI tool. Please note that these specifications are considered draft and subject to change as we refine the feature.

Background:

The convert.json and revert.json files play a crucial role in defining how the Nino CLI tool converts between different WordPress configurations and reverts changes. Establishing clear and comprehensive specifications for these files is essential to ensure consistency and user-friendliness.

Specifications for convert.json:

{
  "name": "Standard to WPEnv-Framework Conversion",
  "description": "Converts a standard WordPress installation to the WPEnv-Framework structure.",
  "create": [
    { "directory": ".snapshot", "description": "Directory for snapshots" },
    { "directory": "public", "description": "Web server root directory" },
    { "directory": "public/app/uploads", "description": "WordPress uploads directory" },
    { "directory": "public/app/templates", "description": "Custom themes directory" },
    { "directory": "public/mu-plugins", "description": "Must-use plugins directory" },
    { "directory": "public/plugins", "description": "WordPress plugins directory" },
    { "directory": "public/wp", "description": "WordPress core files" },
    { "directory": "storage/cache", "description": "Cache directory" },
    { "directory": "storage/logs/wp-errors", "description": "WordPress error logs" },
    { "directory": "vendor", "description": "Composer dependencies" }
  ],
  "migrate": [
    { "from": "wp-content/uploads", "to": "public/app/uploads" },
    { "from": "wp-content/themes", "to": "public/app/templates" },
    { "from": "wp-content/mu-plugins", "to": "public/mu-plugins" },
    { "from": "wp-content/plugins", "to": "public/plugins" },
    { "from": "wp-admin", "to": "public/wp/wp-admin" },
    { "from": "wp-includes", "to": "public/wp/wp-includes" }
  ],
  "files": [
    { "name": ".env", "source": "wp-config.php", "transformation": "convert_credentials_to_env" },
    { "name": "public/.htaccess", "source": ".htaccess" },
    { "name": "public/index.php", "source": "index.php", "permissions": "444" },
    { "name": "public/wp-config.php", "source": "wp-config.php", "permissions": "444" }
  ],
  "cleanup": [
    "wp-content",
    "wp-admin",
    "wp-includes",
    ".htaccess",
    "index.php",
    "wp-config.php"
  ]
}
  1. Name and Description:

    • name: A brief but descriptive name for the configuration.
    • description: An informative description of the configuration's purpose and impact.
  2. Create Directories:

    • An array of objects specifying directories to be created during conversion.
      • Each object includes:
      • directory: The path to the directory to be created.
      • description: A brief description of the directory's purpose.
  3. Migrate Files and Directories:

    • An array of objects specifying files and directories to be moved during conversion.
      • Each object includes:
      • from: The source path.
      • to: The destination path.
      • description: A brief description of the migration.
  4. File Transformations:

    • An array of objects specifying file transformations.
      • Each object includes:
      • name: The name of the target file.
      • source: The source file or data to transform from.
      • transformation: A reference to a transformation method or logic.
      • description: A brief description of the transformation.
  5. Cleanup:

    • An array of paths and files to be removed after conversion.

Specifications for revert.json:

The revert.json should facilitate the reversion of the wpenv-framework structure back to a standard WordPress setup. This involves moving core files and directories back to their original locations and removing wpenv-framework specific directories.

{
  "name": "WPEnv-Framework to Standard WordPress Reversion",
  "description": "Reverts the WPEnv-Framework structured WordPress back to the standard setup.",
  "recreate": [
    { "directory": "wp-content/uploads", "from": "public/app/uploads" },
    { "directory": "wp-content/themes", "from": "public/app/templates" },
    { "directory": "wp-content/mu-plugins", "from": "public/mu-plugins" },
    { "directory": "wp-content/plugins", "from": "public/plugins" }
  ],
  "restore": [
    { "from": "public/wp/wp-admin", "to": "wp-admin" },
    { "from": "public/wp/wp-includes", "to": "wp-includes" }
  ],
  "files": [
    { "name": ".htaccess", "source": "public/.htaccess" },
    { "name": "index.php", "source": "public/index.php", "permissions": "444" },
    { "name": "wp-config.php", "source": "public/wp-config.php", "permissions": "444", "transformation": "revert_env_to_wpconfig" }
  ],
  "cleanup": [
    ".snapshot",
    "public",
    "storage",
    "vendor",
    ".env",
    "app.php",
    "bootstrap.php",
    "composer.json",
    "config.php"
  ]
}
  1. Name and Description:

    • name: A brief but descriptive name for the configuration.
    • description: An informative description of the configuration's purpose and impact.
  2. Recreate Directories:

    • An array of objects specifying directories to be recreated during reversion.
      • Each object includes:
      • directory: The path to the directory to be recreated.
      • from: The source path in the converted structure.
      • description: A brief description of the directory's purpose.
  3. Restore Files and Directories:

    • An array of objects specifying files and directories to be restored during reversion.
      • Each object includes:
      • from: The source path in the converted structure.
      • to: The destination path in the standard WordPress structure.
      • description: A brief description of the restoration.
  4. File Transformations:

    • An array of objects specifying file transformations needed during reversion.
      • Each object includes:
      • name: The name of the target file.
      • source: The source file or data to transform from.
      • transformation: A reference to a transformation method or logic.
      • description: A brief description of the transformation.
  5. Cleanup:

    • An array of paths and files to be removed after reversion.

Implementation Note:

These specifications are in the draft stage and may evolve as the feature is developed and tested.

devuri commented 7 months ago

Draft for Feature Request

Nino CLI: Convert and Revert Feature

This document outlines the convert and revert commands for the Nino CLI tool, designed to streamline WordPress conversion management.

Getting Started
  1. Backup: Both commands automatically create a backup of the current setup in a timestamped directory.
  2. JSON Configuration: Ensure convert.json and revert.json are properly configured to reflect the desired WordPress setup and blueprint.

Convert Command

Revert Command

Requirements
Best Practices