|
| 1 | +# Lagoon CLI Wrapper |
| 2 | + |
| 3 | +A Node.js CLI wrapper for the Lagoon CLI that provides an interactive interface for common operations. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Node.js (v14 or higher) |
| 8 | +- Lagoon CLI installed and configured |
| 9 | +- A valid `.lagoon.yml` file in your home directory |
| 10 | + |
| 11 | +## Installation |
| 12 | + |
| 13 | +1. Clone this repository |
| 14 | +2. Install dependencies: |
| 15 | + |
| 16 | +```bash |
| 17 | +npm install |
| 18 | +``` |
| 19 | + |
| 20 | +3. Link the CLI globally: |
| 21 | + |
| 22 | +```bash |
| 23 | +npm link |
| 24 | +``` |
| 25 | + |
| 26 | +## Usage |
| 27 | + |
| 28 | +Simply run the command: |
| 29 | + |
| 30 | +```bash |
| 31 | +lagoon-wrapper |
| 32 | +``` |
| 33 | + |
| 34 | +This will start the interactive mode, which will guide you through: |
| 35 | + |
| 36 | +1. Selecting a Lagoon instance |
| 37 | +2. Selecting a project |
| 38 | +3. Performing operations on the selected project: |
| 39 | + - Listing environments |
| 40 | + - Listing users |
| 41 | + - Deleting environments (except protected ones) |
| 42 | + - Generating login links for environments |
| 43 | + - Clearing Drupal caches |
| 44 | + - Viewing GitHub PR links for PR environments |
| 45 | + |
| 46 | +## Features |
| 47 | + |
| 48 | +- Interactive CLI interface |
| 49 | +- Easy navigation between instances and projects |
| 50 | +- Safe environment deletion (prevents deletion of protected environments) |
| 51 | +- GitHub PR integration for PR environments |
| 52 | +- One-click login link generation for Drupal environments |
| 53 | +- Quick Drupal cache clearing for any environment |
| 54 | +- Comprehensive logging of all operations |
| 55 | +- Extensible architecture for adding new commands |
| 56 | + |
| 57 | +## Protected Environments |
| 58 | + |
| 59 | +The following environments cannot be deleted: |
| 60 | +- production |
| 61 | +- master |
| 62 | +- develop |
| 63 | +- Any environment starting with `project/` |
| 64 | + |
| 65 | +## GitHub Integration |
| 66 | + |
| 67 | +For projects hosted on GitHub, the CLI will: |
| 68 | +- Automatically detect PR environments (environments named `pr-XX`) |
| 69 | +- Display links to the corresponding GitHub pull requests |
| 70 | +- Show PR information when listing, deleting, or generating login links for environments |
| 71 | + |
| 72 | +## Login Link Generation |
| 73 | + |
| 74 | +The CLI can generate login links for Drupal environments by: |
| 75 | +- Unblocking the admin user (uid=1) |
| 76 | +- Generating a one-time login link |
| 77 | +- Displaying the link in the terminal |
| 78 | + |
| 79 | +Note: Login links cannot be generated for production or master environments. |
| 80 | + |
| 81 | +## Cache Clearing |
| 82 | + |
| 83 | +The CLI can clear Drupal caches on any environment: |
| 84 | +- Works on all environments including production and master |
| 85 | +- Executes the `drush cr` command on the selected environment |
| 86 | +- Shows the command output in the terminal |
| 87 | + |
| 88 | +## Logging |
| 89 | + |
| 90 | +All operations performed by the CLI are logged to daily log files in the `.logs` directory: |
| 91 | +- Log files are named in the format `log--YYYYMMDD.txt` |
| 92 | +- Each log entry includes a timestamp, the action performed, and the Lagoon command executed |
| 93 | +- Errors are also logged with detailed error messages |
| 94 | +- The logs directory is excluded from Git |
| 95 | + |
| 96 | +## Adding New Commands |
| 97 | + |
| 98 | +To add new commands, modify the `src/interactive.js` file to add new menu options and implement the corresponding functionality in the appropriate modules. |
0 commit comments