Skip to content

Commit 98d35f7

Browse files
authored
Use a redirect instead of a fetch for cli auth (#10799)
1 parent f6c77c1 commit 98d35f7

File tree

3 files changed

+61
-37
lines changed

3 files changed

+61
-37
lines changed

.roo/commands/cli-release.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,58 @@ mode: code
4848
- Include links to relevant source files where helpful
4949
- Describe changes from the user's perspective
5050

51-
5. Commit the version bump and changelog update:
51+
5. Create a release branch and commit the changes:
5252

5353
```bash
54+
# Ensure you're on main and up to date
55+
git checkout main
56+
git pull origin main
57+
58+
# Create a new branch for the release
59+
git checkout -b cli-release-v<version>
60+
61+
# Commit the version bump and changelog update
5462
git add apps/cli/package.json apps/cli/CHANGELOG.md
5563
git commit -m "chore(cli): prepare release v<version>"
64+
65+
# Push the branch to origin
66+
git push -u origin cli-release-v<version>
5667
```
5768

58-
6. Run the release script from the monorepo root:
69+
6. Create a pull request for the release:
5970

6071
```bash
72+
gh pr create --title "chore(cli): prepare release v<version>" \
73+
--body "## CLI Release v<version>
74+
75+
This PR prepares the CLI release v<version>.
76+
77+
### Changes
78+
- Version bump in package.json
79+
- Changelog update
80+
81+
### Checklist
82+
- [ ] Version number is correct
83+
- [ ] Changelog entry is complete and accurate
84+
- [ ] All CI checks pass" \
85+
--base main
86+
```
87+
88+
7. Wait for PR approval and merge:
89+
90+
- Request review if required by your workflow
91+
- Ensure CI checks pass
92+
- Merge the PR using: `gh pr merge --squash --delete-branch`
93+
- Or merge via the GitHub UI
94+
95+
8. Run the release script from the monorepo root:
96+
97+
```bash
98+
# Ensure you're on the updated main branch after the PR merge
99+
git checkout main
100+
git pull origin main
101+
102+
# Run the release script
61103
./apps/cli/scripts/release.sh
62104
```
63105

@@ -69,7 +111,7 @@ mode: code
69111
- Extract changelog content and include it in the GitHub release notes
70112
- Create the GitHub release with the tarball attached
71113

72-
7. After a successful release, verify:
114+
9. After a successful release, verify:
73115
- Check the release page: https://github.com/RooCodeInc/Roo-Code/releases
74116
- Verify the "What's New" section contains the changelog content
75117
- Test installation: `curl -fsSL https://raw.githubusercontent.com/RooCodeInc/Roo-Code/main/apps/cli/install.sh | sh`

apps/cli/scripts/release.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,8 @@ ROO_VERSION=$VERSION curl -fsSL https://raw.githubusercontent.com/RooCodeInc/Roo
536536
## Usage
537537
538538
\`\`\`bash
539-
# Set your API key
540-
export OPENROUTER_API_KEY=sk-or-v1-...
541-
542539
# Run a task
543-
roo "What is this project?" ~/my-project
540+
roo "What is this project?"
544541
545542
# See all options
546543
roo --help

apps/cli/src/commands/auth/login.ts

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,58 +32,43 @@ export async function login({ timeout = 5 * 60 * 1000, verbose = false }: LoginO
3232
console.log(`[Auth] Starting local callback server on port ${port}`)
3333
}
3434

35-
const corsHeaders = {
36-
"Access-Control-Allow-Origin": AUTH_BASE_URL,
37-
"Access-Control-Allow-Methods": "POST, OPTIONS",
38-
"Access-Control-Allow-Headers": "Content-Type",
39-
}
40-
4135
// Create promise that will be resolved when we receive the callback.
4236
const tokenPromise = new Promise<{ token: string; state: string }>((resolve, reject) => {
4337
const server = http.createServer((req, res) => {
4438
const url = new URL(req.url!, host)
4539

46-
// Handle CORS preflight request.
47-
if (req.method === "OPTIONS") {
48-
res.writeHead(204, corsHeaders)
49-
res.end()
50-
return
51-
}
52-
53-
if (url.pathname === "/callback" && req.method === "POST") {
40+
if (url.pathname === "/callback") {
5441
const receivedState = url.searchParams.get("state")
5542
const token = url.searchParams.get("token")
5643
const error = url.searchParams.get("error")
5744

58-
const sendJsonResponse = (status: number, body: object) => {
59-
res.writeHead(status, {
60-
...corsHeaders,
61-
"Content-Type": "application/json",
62-
})
63-
res.end(JSON.stringify(body))
64-
}
65-
6645
if (error) {
67-
sendJsonResponse(400, { success: false, error })
68-
res.on("close", () => {
46+
const errorUrl = new URL(`${AUTH_BASE_URL}/cli/sign-in?error=error-in-callback`)
47+
errorUrl.searchParams.set("message", error)
48+
res.writeHead(302, { Location: errorUrl.toString() })
49+
res.end(() => {
6950
server.close()
7051
reject(new Error(error))
7152
})
7253
} else if (!token) {
73-
sendJsonResponse(400, { success: false, error: "Missing token in callback" })
74-
res.on("close", () => {
54+
const errorUrl = new URL(`${AUTH_BASE_URL}/cli/sign-in?error=missing-token`)
55+
errorUrl.searchParams.set("message", "Missing token in callback")
56+
res.writeHead(302, { Location: errorUrl.toString() })
57+
res.end(() => {
7558
server.close()
7659
reject(new Error("Missing token in callback"))
7760
})
7861
} else if (receivedState !== state) {
79-
sendJsonResponse(400, { success: false, error: "Invalid state parameter" })
80-
res.on("close", () => {
62+
const errorUrl = new URL(`${AUTH_BASE_URL}/cli/sign-in?error=invalid-state-parameter`)
63+
errorUrl.searchParams.set("message", "Invalid state parameter")
64+
res.writeHead(302, { Location: errorUrl.toString() })
65+
res.end(() => {
8166
server.close()
8267
reject(new Error("Invalid state parameter"))
8368
})
8469
} else {
85-
sendJsonResponse(200, { success: true })
86-
res.on("close", () => {
70+
res.writeHead(302, { Location: `${AUTH_BASE_URL}/cli/sign-in?success=true` })
71+
res.end(() => {
8772
server.close()
8873
resolve({ token, state: receivedState })
8974
})

0 commit comments

Comments
 (0)