Skip to content

Commit fc816bf

Browse files
github-actions[bot]Fredrik Rombach Ekelund
andcommitted
docs: Update CLI documentation for auth login command
Add comprehensive documentation for the new `studio auth login` command including usage instructions, flow description, and important notes about token lifetime and authentication sharing between CLI and desktop app. Co-authored-by: Fredrik Rombach Ekelund <undefined@users.noreply.github.com>
1 parent 2908170 commit fc816bf

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

‎docs/ai-instructions.md‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,56 @@ npm test -- path/to/test.test.ts
3939
npm test -- --testNamePattern="test name pattern"
4040
```
4141

42+
## CLI Commands
43+
44+
The Studio CLI provides commands for managing authentication, preview sites, and local sites (beta). All CLI commands follow this pattern:
45+
46+
```bash
47+
npm run cli:build && node dist/cli/main.js <command>
48+
```
49+
50+
### Authentication Commands
51+
52+
#### `studio auth login`
53+
Log in to WordPress.com using OAuth2 authentication.
54+
55+
**Usage:**
56+
```bash
57+
node dist/cli/main.js auth login
58+
```
59+
60+
**Description:**
61+
This command initiates the WordPress.com OAuth2 authentication flow:
62+
1. Opens your default browser to the WordPress.com authorization page
63+
2. After authorization, you'll be redirected to a page with your access token
64+
3. Copy the token and paste it back into the terminal
65+
4. The token is stored in your app data and shared with the Studio desktop app
66+
67+
**Options:**
68+
- None required
69+
70+
**Example:**
71+
```bash
72+
npm run cli:build
73+
node dist/cli/main.js auth login
74+
# Browser opens for authentication
75+
# Copy token from browser and paste when prompted
76+
```
77+
78+
**Notes:**
79+
- The access token is valid for 2 weeks
80+
- If already authenticated, the command will notify you
81+
- Authentication is shared between the CLI and the Studio desktop app
82+
- If the browser fails to open, the URL will be displayed for manual opening
83+
84+
### Preview Site Commands
85+
86+
See the existing preview site commands (create, list, delete, update) in `cli/commands/preview/`.
87+
88+
### Local Site Commands (Beta)
89+
90+
Local site management commands are available when the `studioSitesCli` beta feature is enabled in app data.
91+
4292
## WordPress Studio - Architecture Overview
4393

4494
WordPress Studio is a desktop application for creating, managing, and testing WordPress sites locally. It's built as an Electron desktop application with a React renderer, powered by WordPress Playground and PHP WASM.
@@ -109,11 +159,13 @@ WordPress Studio is a desktop application for creating, managing, and testing Wo
109159
### `/cli` - Command-Line Interface
110160
- **`index.ts`** - CLI entry point using yargs
111161
- **`commands/`** - Command implementations
162+
- `auth/` - Authentication commands (login to WordPress.com)
112163
- `preview/` - Preview site management commands
113164
- `site/` - Local site management commands (beta)
114165
- **`lib/`** - CLI-specific utilities and helpers
115166
- `appdata.ts` - Reading app configuration
116167
- `i18n.ts` - Locale loading for CLI
168+
- `browser.ts` - Cross-platform browser opening utility
117169

118170
### `/common` - Shared Code (Both Main and Renderer)
119171
- **`lib/`** - Shared utility libraries

0 commit comments

Comments
 (0)