Skip to content

Commit 2cd20ea

Browse files
committed
Added a wrapper around lagoon-cli to allow faster deletion of PR environments.
0 parents  commit 2cd20ea

File tree

8 files changed

+1686
-0
lines changed

8 files changed

+1686
-0
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
.logs/
10+
11+
# Dependency directories
12+
node_modules/
13+
jspm_packages/
14+
15+
# Optional npm cache directory
16+
.npm
17+
18+
# Optional eslint cache
19+
.eslintcache
20+
21+
# Output of 'npm pack'
22+
*.tgz
23+
24+
# dotenv environment variable files
25+
.env
26+
.env.development.local
27+
.env.test.local
28+
.env.production.local
29+
.env.local

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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.

index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env node
2+
3+
import { program } from 'commander';
4+
import { startInteractiveMode } from './src/interactive.js';
5+
6+
program
7+
.name('lagoon-wrapper')
8+
.description('A CLI wrapper for Lagoon CLI')
9+
.version('1.0.0');
10+
11+
program
12+
.command('interactive')
13+
.description('Start interactive mode')
14+
.action(startInteractiveMode);
15+
16+
// Default to interactive mode if no command is specified
17+
if (process.argv.length === 2) {
18+
startInteractiveMode();
19+
} else {
20+
program.parse(process.argv);
21+
}

0 commit comments

Comments
 (0)