Conversation
WalkthroughAdds a new CLI delete command for edge functions, introduces FunctionResponse and FunctionDeploymentResult types, and updates the deploy command to parse and display deployment results (status, URL, build logs) from the API response. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/commands/functions/delete.ts (1)
35-42: Drop the impossibleresult.successfallback.
FunctionResponse.successistrueinsrc/types.ts, andossFetch()already throws on non-OK responses, so Lines 38-42 are dead code. If that type is widened later, the fallback still emits a success marker for a failure message.Proposed simplification
if (json) { outputJson(result); } else { - if (result.success) { - outputSuccess(`Function "${slug}" deleted successfully.`); - } else { - outputSuccess(`Failed to delete function "${slug}".`); - } + outputSuccess(`Function "${slug}" deleted successfully.`); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/functions/delete.ts` around lines 35 - 42, The code contains a dead fallback branch checking result.success (FunctionResponse.success is always true and ossFetch throws on errors), so remove the impossible else branch and simplify: after outputJson(result) when json is true, otherwise unconditionally call outputSuccess(`Function "${slug}" deleted successfully.`) and drop the `else { outputSuccess("Failed...") }` branch; reference symbols: delete.ts, result, slug, outputJson, outputSuccess, FunctionResponse.success, and ossFetch.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/commands/functions/delete.ts`:
- Around line 15-17: The command currently calls requireAuth() without passing
the CLI API URL override extracted via getRootOpts(cmd), so authentication may
target the default platform; update the call in delete.ts to extract the apiUrl
from getRootOpts (alongside json and yes) and pass it into requireAuth (e.g.,
requireAuth({ apiUrl })) or otherwise forward that apiUrl option into your auth
call so the command honors --api-url during authentication.
- Line 8: The import of FunctionResponse should be type-only and the variable
res is never reassigned—update the import to a type import (e.g., import type {
FunctionResponse } from '../../types.js') and change the declaration of res from
let to const where it is assigned (the res used as the FunctionResponse-typed
response in delete.ts).
In `@src/commands/functions/deploy.ts`:
- Around line 61-80: The code currently treats the API envelope result as
success and always calls reportCliUsage('cli.functions.deploy', true) and exits
0 even when result.deployment.status === 'failed'; change the branch after
printing deployment output to detect a failing deployment (check
result.deployment && result.deployment.status === 'failed') and in that case
call reportCliUsage('cli.functions.deploy', false) and exit with a non-zero code
(e.g., process.exit(1)) — also ensure the same behavior applies in JSON mode by
emitting the failing status via outputJson(result) then exiting non‑zero so
CI/scripts see the failure; adjust any uses of result.success to prefer
result.deployment.status when deciding final exit/usage state.
---
Nitpick comments:
In `@src/commands/functions/delete.ts`:
- Around line 35-42: The code contains a dead fallback branch checking
result.success (FunctionResponse.success is always true and ossFetch throws on
errors), so remove the impossible else branch and simplify: after
outputJson(result) when json is true, otherwise unconditionally call
outputSuccess(`Function "${slug}" deleted successfully.`) and drop the `else {
outputSuccess("Failed...") }` branch; reference symbols: delete.ts, result,
slug, outputJson, outputSuccess, FunctionResponse.success, and ossFetch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f7562b5d-a7fc-4c9b-8715-bb09e45bc7c2
📒 Files selected for processing (4)
src/commands/functions/delete.tssrc/commands/functions/deploy.tssrc/index.tssrc/types.ts
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/commands/functions/deploy.ts (1)
65-67:⚠️ Potential issue | 🟡 MinorMisleading success message when deployment fails.
Two issues here:
Grammar: "updation" is non-standard English; use "update" or "creation" → "update" / "create".
Misleading output:
result.successis typed as literaltrueinFunctionResponse, soresultStatuswill always be'success'. WhendeployFailedis true, the user sees:✓ Function "foo" creation success. Deployment: failedThis is confusing—showing a checkmark and "success" while the deployment actually failed.
The exit code fix (lines 82-83) addresses the CI/scripting concern from the previous review, but the human-readable output remains misleading.
Proposed fix for clearer messaging
- const action = exists ? 'updation' : 'creation'; - const resultStatus = result.success ? 'success' : 'failed'; - outputSuccess(`Function "${result.function.slug}" ${action} ${resultStatus}.`); + const action = exists ? 'updated' : 'created'; + if (deployFailed) { + console.error(`✗ Function "${result.function.slug}" ${action}, but deployment failed.`); + } else { + outputSuccess(`Function "${result.function.slug}" ${action} successfully.`); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/functions/deploy.ts` around lines 65 - 67, Replace the non-standard "updation" with "update" (use "update" when exists is true, otherwise "create") and stop using result.success (which is always true) to determine the user-facing status; instead use the actual deploy result flag (deployFailed) to choose the message and output function. Locate the block that builds action and resultStatus (references: exists, result.success, outputSuccess) and change it to compute action = exists ? 'update' : 'create', compute status = deployFailed ? 'failed' : 'success', and call the appropriate output helper (e.g., outputSuccess when success, outputError or outputInfo when failed) so the terminal message and checkmark reflect the real deployment outcome. Ensure the printed message still includes result.function.slug.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/commands/functions/deploy.ts`:
- Around line 65-67: Replace the non-standard "updation" with "update" (use
"update" when exists is true, otherwise "create") and stop using result.success
(which is always true) to determine the user-facing status; instead use the
actual deploy result flag (deployFailed) to choose the message and output
function. Locate the block that builds action and resultStatus (references:
exists, result.success, outputSuccess) and change it to compute action = exists
? 'update' : 'create', compute status = deployFailed ? 'failed' : 'success', and
call the appropriate output helper (e.g., outputSuccess when success,
outputError or outputInfo when failed) so the terminal message and checkmark
reflect the real deployment outcome. Ensure the printed message still includes
result.function.slug.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9f439ca4-dc95-4f9e-9e1a-ce3d608623ad
📒 Files selected for processing (2)
src/commands/functions/delete.tssrc/commands/functions/deploy.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/commands/functions/delete.ts
modify function deploy result, and add delete command
Summary by CodeRabbit
New Features
Improvements